diff --git a/.gitignore b/.gitignore index 116b86805b0..179ad1679cf 100644 --- a/.gitignore +++ b/.gitignore @@ -1,14 +1,10 @@ *~ +.bundle db/*.sqlite3 +log/*.log +tmp/ db/schema.rb -log/* -nbproject/* -tmp/* config/settings.yaml config/email.yaml -tftp -public/images/active_scaffold -public/javascripts/active_scaffold -public/stylesheets/active_scaffold *.sw? -.idea/* +.idea diff --git a/Gemfile b/Gemfile new file mode 100644 index 00000000000..ae0b70a9e34 --- /dev/null +++ b/Gemfile @@ -0,0 +1,32 @@ +source 'http://rubygems.org' + +gem 'rails', '3.0.10' +gem "jquery-rails" +gem 'json' +gem 'rest-client', :require => 'rest_client' +gem "acts_as_audited", "2.0.0" +gem "has_many_polymorphs", :git => "https://github.com/jystewart/has_many_polymorphs.git" +gem "will_paginate", "~> 3.0.2" +gem "ancestry", "~> 1.2.4" + +gem 'sqlite3', :require => 'sqlite3' + +gem 'scoped_search', '>= 2.3.4' +#group :provisioning do + gem "safemode", "1.0", :git => "https://github.com/svenfuchs/safemode.git" + gem "ruby2ruby" + gem "ruby_parser" + gem "virt", ">= 0.2.0" +#end + +group :authentication do + gem 'net-ldap' +end + +group :test, :development do + # To use debugger + gem 'ruby-debug' + gem 'mocha' + gem 'shoulda' + gem 'rr' +end diff --git a/Gemfile.lock b/Gemfile.lock new file mode 100644 index 00000000000..2957a0d6415 --- /dev/null +++ b/Gemfile.lock @@ -0,0 +1,140 @@ +GIT + remote: https://github.com/jystewart/has_many_polymorphs.git + revision: 36f15d24ca4200f657a5203d9fc0253b58477705 + specs: + has_many_polymorphs (3.0.0.beta1) + activerecord + +GIT + remote: https://github.com/svenfuchs/safemode.git + revision: 77d53c3c52718ec4634bc6e71ccd230188ba6c90 + specs: + safemode (1.0) + +GEM + remote: http://rubygems.org/ + specs: + abstract (1.0.0) + actionmailer (3.0.10) + actionpack (= 3.0.10) + mail (~> 2.2.19) + actionpack (3.0.10) + activemodel (= 3.0.10) + activesupport (= 3.0.10) + builder (~> 2.1.2) + erubis (~> 2.6.6) + i18n (~> 0.5.0) + rack (~> 1.2.1) + rack-mount (~> 0.6.14) + rack-test (~> 0.5.7) + tzinfo (~> 0.3.23) + activemodel (3.0.10) + activesupport (= 3.0.10) + builder (~> 2.1.2) + i18n (~> 0.5.0) + activerecord (3.0.10) + activemodel (= 3.0.10) + activesupport (= 3.0.10) + arel (~> 2.0.10) + tzinfo (~> 0.3.23) + activeresource (3.0.10) + activemodel (= 3.0.10) + activesupport (= 3.0.10) + activesupport (3.0.10) + acts_as_audited (2.0.0) + rails (>= 3.0.3) + ancestry (1.2.4) + activerecord (>= 2.2.2) + arel (2.0.10) + builder (2.1.2) + columnize (0.3.4) + erubis (2.6.6) + abstract (>= 1.0.0) + i18n (0.5.0) + jquery-rails (1.0.16) + railties (~> 3.0) + thor (~> 0.14) + json (1.6.1) + linecache (0.46) + rbx-require-relative (> 0.0.4) + mail (2.2.19) + activesupport (>= 2.3.6) + i18n (>= 0.4.0) + mime-types (~> 1.16) + treetop (~> 1.4.8) + mime-types (1.17.2) + mocha (0.9.12) + net-ldap (0.2.2) + polyglot (0.3.3) + rack (1.2.4) + rack-mount (0.6.14) + rack (>= 1.0.0) + rack-test (0.5.7) + rack (>= 1.0) + rails (3.0.10) + actionmailer (= 3.0.10) + actionpack (= 3.0.10) + activerecord (= 3.0.10) + activeresource (= 3.0.10) + activesupport (= 3.0.10) + bundler (~> 1.0) + railties (= 3.0.10) + railties (3.0.10) + actionpack (= 3.0.10) + activesupport (= 3.0.10) + rake (>= 0.8.7) + rdoc (~> 3.4) + thor (~> 0.14.4) + rake (0.9.2.2) + rbx-require-relative (0.0.5) + rdoc (3.11) + json (~> 1.4) + rest-client (1.6.7) + mime-types (>= 1.16) + rr (1.0.2) + ruby-debug (0.10.4) + columnize (>= 0.1) + ruby-debug-base (~> 0.10.4.0) + ruby-debug-base (0.10.4) + linecache (>= 0.3) + ruby2ruby (1.3.1) + ruby_parser (~> 2.0) + sexp_processor (~> 3.0) + ruby_parser (2.3.1) + sexp_processor (~> 3.0) + scoped_search (2.3.5) + activerecord (>= 2.1.0) + sexp_processor (3.0.7) + shoulda (2.11.3) + sqlite3 (1.3.4) + thor (0.14.6) + treetop (1.4.10) + polyglot + polyglot (>= 0.3.1) + tzinfo (0.3.31) + virt (0.2.0) + will_paginate (3.0.2) + +PLATFORMS + ruby + +DEPENDENCIES + acts_as_audited (= 2.0.0) + ancestry (~> 1.2.4) + has_many_polymorphs! + jquery-rails + json + mocha + net-ldap + rails (= 3.0.10) + rest-client + rr + ruby-debug + ruby2ruby + ruby_parser + safemode (= 1.0)! + scoped_search (>= 2.3.4) + shoulda + sqlite3 + virt (>= 0.2.0) + will_paginate (~> 3.0.2) diff --git a/Rakefile b/Rakefile index 3bb0e8592a4..0ca48f1bf07 100644 --- a/Rakefile +++ b/Rakefile @@ -1,10 +1,5 @@ -# 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 File.expand_path('../config/application', __FILE__) require 'rake' -require 'rake/testtask' -require 'rake/rdoctask' +include Rake::DSL -require 'tasks/rails' +Foreman::Application.load_tasks diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 0783d9195e8..29d1570bf43 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -1,10 +1,9 @@ -# Filters added to this controller apply to all controllers in the application. -# Likewise, all the methods added will be available for all controllers. +require 'foreman/controller/auto_complete_search' class ApplicationController < ActionController::Base protect_from_forgery # See ActionController::RequestForgeryProtection for details rescue_from ScopedSearch::QueryNotSupported, :with => :invalid_search_query - rescue_from Exception, :with => :generic_exception + #rescue_from Exception, :with => :generic_exception rescue_from ActiveRecord::RecordNotFound, :with => :not_found # standard layout to all controllers @@ -60,10 +59,10 @@ def require_login # JSON requests (REST API calls) use basic http authenitcation and should not use/store cookies user = authenticate_or_request_with_http_basic { |u, p| User.try_to_login(u, p) } User.current = user.is_a?(User) ? user : nil - logger.warn("Failed authentcation from #{request.remote_ip} #{user}") if User.current.nil? + logger.warn("Failed authentication from #{request.remote_ip} #{user}") if User.current.nil? return !User.current.nil? end - session[:original_uri] = request.request_uri # keep the old request uri that we can redirect later on + session[:original_uri] = request.fullpath # keep the old request uri that we can redirect later on redirect_to login_users_path and return else # We assume we always have a user logged in, if authentication is disabled, the user is the build-in admin account. @@ -76,7 +75,7 @@ def require_login end end - # this method is returns the active user which gets used to puplate the audits table + # this method is returns the active user which gets used to populate the audits table def current_user User.current end @@ -129,6 +128,10 @@ def error error flash[:error] = error end + def warning warning + flash[:warning] = warning + end + # this method is used with nested resources, where obj_id is passed into the parameters hash. # it automatically updates the search text box with the relevant relationship # e.g. /hosts/fqdn/reports # would add host = fqdn to the search bar @@ -174,7 +177,7 @@ def no_puppetclass_documentation_handler(exception) if exception.message =~ /No route matches "\/puppet\/rdoc\/([^\/]+)\/classes\/(.+?)\.html/ render :template => "puppetclasses/no_route", :locals => {:environment => $1, :name => $2.gsub("/","::")}, :layout => false else - local_request? ? rescue_action_locally(exception) : rescue_action_in_public(exception) + request.local? ? request.rescue_action_locally(exception) : rescue_action_in_public(exception) end end @@ -203,7 +206,7 @@ def process_error hash = {} else hash[:redirect] ||= eval("#{controller_name}_url") end - hash[:error_msg] ||= hash[:object].errors.on_base.to_a + hash[:error_msg] ||= hash[:object].errors[:base] hash[:json_code] ||= :unprocessable_entity logger.info "Failed to save: #{hash[:object].errors.full_messages.join(", ")}" diff --git a/app/controllers/auth_source_ldaps_controller.rb b/app/controllers/auth_source_ldaps_controller.rb index 8eb29a00470..6d42d27bb0b 100644 --- a/app/controllers/auth_source_ldaps_controller.rb +++ b/app/controllers/auth_source_ldaps_controller.rb @@ -1,6 +1,4 @@ class AuthSourceLdapsController < ApplicationController - filter_parameter_logging :account_password - def index @auth_source_ldaps = AuthSourceLdap.all respond_to do |format| diff --git a/app/controllers/bookmarks_controller.rb b/app/controllers/bookmarks_controller.rb index dcd3428bb24..cc9d024ff57 100644 --- a/app/controllers/bookmarks_controller.rb +++ b/app/controllers/bookmarks_controller.rb @@ -2,7 +2,7 @@ class BookmarksController < ApplicationController before_filter :find_by_name, :only => %w{show edit update destroy} def index - @bookmarks = Bookmark.all.paginate(:page => params[:page]) + @bookmarks = Bookmark.paginate(:page => params[:page]) respond_to do |format| format.html diff --git a/app/controllers/config_templates_controller.rb b/app/controllers/config_templates_controller.rb index 6fe1e8bc858..5a4b0486a91 100644 --- a/app/controllers/config_templates_controller.rb +++ b/app/controllers/config_templates_controller.rb @@ -114,7 +114,7 @@ def build_pxe_default # generated for def pxe_default_combos combos = [] - ConfigTemplate.template_kind_name_eq("provision").each do |template| + ConfigTemplate.joins(:template_kind).where("template_kinds.name" => "provision").each do |template| template.template_combinations.each do |combination| hostgroup = combination.hostgroup if hostgroup and hostgroup.operatingsystem and hostgroup.architecture and hostgroup.medium diff --git a/app/controllers/environments_controller.rb b/app/controllers/environments_controller.rb index 5f4d08be339..569f4de7ef4 100644 --- a/app/controllers/environments_controller.rb +++ b/app/controllers/environments_controller.rb @@ -1,3 +1,5 @@ +require 'foreman/controller/environments' + class EnvironmentsController < ApplicationController include Foreman::Controller::Environments include Foreman::Controller::AutoCompleteSearch diff --git a/app/controllers/fact_values_controller.rb b/app/controllers/fact_values_controller.rb index e692817df67..1e4eeabbf4c 100644 --- a/app/controllers/fact_values_controller.rb +++ b/app/controllers/fact_values_controller.rb @@ -8,9 +8,6 @@ class FactValuesController < ApplicationController before_filter :set_admin_user, :only => :create before_filter :setup_search_options, :only => :index - # avoids storing the facts data in the log files - filter_parameter_logging :facts - def index begin values = FactValue.no_timestamp_facts.search_for(params[:search],:order => params[:order]) diff --git a/app/controllers/hostgroups_controller.rb b/app/controllers/hostgroups_controller.rb index 59a4a8740e3..a08eafd6a5b 100644 --- a/app/controllers/hostgroups_controller.rb +++ b/app/controllers/hostgroups_controller.rb @@ -1,8 +1,9 @@ +require 'foreman/controller/host_details' + class HostgroupsController < ApplicationController include Foreman::Controller::HostDetails include Foreman::Controller::AutoCompleteSearch - filter_parameter_logging :root_pass before_filter :find_hostgroup, :only => [:show, :edit, :update, :destroy, :clone] def index diff --git a/app/controllers/hosts_controller.rb b/app/controllers/hosts_controller.rb index dbac4466601..3232e239f1d 100644 --- a/app/controllers/hosts_controller.rb +++ b/app/controllers/hosts_controller.rb @@ -1,3 +1,5 @@ +require 'foreman/controller/host_details' + class HostsController < ApplicationController include Foreman::Controller::HostDetails include Foreman::Controller::AutoCompleteSearch @@ -10,7 +12,6 @@ class HostsController < ApplicationController before_filter :set_admin_user, :only => ANONYMOUS_ACTIONS before_filter :find_hosts, :only => :query - before_filter :ajax_methods, :only => [:hostgroup_or_environment_selected] before_filter :find_multiple, :only => [:update_multiple_parameters, :multiple_build, :select_multiple_hostgroup, :select_multiple_environment, :multiple_parameters, :multiple_destroy, :multiple_enable, :multiple_disable, :submit_multiple_disable, :submit_multiple_enable, :update_multiple_hostgroup, @@ -18,7 +19,6 @@ class HostsController < ApplicationController before_filter :find_by_name, :only => %w[show edit update destroy puppetrun setBuild cancelBuild report reports facts storeconfig_klasses clone pxe_config toggle_manage] - filter_parameter_logging :root_pass helper :hosts, :reports def index (title = nil) @@ -35,8 +35,6 @@ def index (title = nil) @hosts = search.paginate :page => params[:page], :include => included_associations # SQL optimizations queries @last_reports = Report.maximum(:id, :group => :host_id, :conditions => {:host_id => @hosts}) - @fact_kernels = FactValue.all(:select => "host_id, fact_values.value", :joins => [:host, :fact_name], - :conditions => {"fact_values.host_id" => @hosts, "fact_names.name" => 'kernel'}) # rendering index page for non index page requests (out of sync hosts etc) render :index if title and @title = title end @@ -79,8 +77,7 @@ def clone new.puppetclasses = @host.puppetclasses # Clone any parameters as well @host.host_parameters.each{|param| new.host_parameters << param.clone} - flash[:error_customisation] = {:header_message => nil, :class => "flash notice", :id => nil, - :message => "The following fields will need reviewing:" } + flash[:warning] = "The following fields will need reviewing" new.valid? @host = new render :action => :new @@ -121,11 +118,13 @@ def destroy end # form AJAX methods - def hostgroup_or_environment_selected - @environment = Environment.find(params[:environment_id]) if params[:environment_id].to_i > 0 - @hostgroup = Hostgroup.find(params[:hostgroup_id]) if params[:hostgroup_id].to_i > 0 - if @environment or @hostgroup + return head(:method_not_allowed) unless request.xhr? + + @environment = Environment.find(params[:environment_id]) unless params[:environment_id].empty? + @hostgroup = Hostgroup.find(params[:hostgroup_id]) unless params[:hostgroup_id].empty? + @host = Host.find(params[:host_id]) if params[:host_id].to_i > 0 + if @environment or @hostgroup @host ||= Host.new @host.hostgroup = @hostgroup if @hostgroup @host.environment = @environment if @environment @@ -262,7 +261,7 @@ def update_multiple_hostgroup #update the hosts @hosts.each do |host| host.hostgroup=hg - host.save(false) + host.save(:validate => false) end notice 'Updated hosts: Changed Hostgroup' @@ -284,7 +283,7 @@ def update_multiple_environment #update the hosts @hosts.each do |host| host.environment=ev - host.save(false) + host.save(:validate => false) end notice 'Updated hosts: Changed Environment' @@ -374,16 +373,15 @@ def process_hostgroup @host.set_hostgroup_defaults render :update do |page| - page['host_environment_id'].value = @hostgroup.environment_id if @hostgroup.environment_id + page['*[id*=environment_id]'].val(@hostgroup.environment_id) if @hostgroup.environment_id # process_hostgroup is only ever called for new host records therefore the assigned value can never be @hostgroup.puppetmaster_name # This means that we should use the puppetproxy display type as new hosts should use this feature - page['host_puppetproxy_id'].value = @hostgroup.puppetca? ? @hostgroup.puppetmaster.id : "" - if @environment - page.replace_html :puppet_klasses, :partial => 'puppetclasses/class_selection', :locals => {:obj => @host} - end + page['*[id*=puppetproxy_id]'].val(@hostgroup.puppetca? ? @hostgroup.puppetmaster.id : "") + + page['#puppet_klasses'].html(render(:partial => 'puppetclasses/class_selection', :locals => {:obj => @host})) if @environment if SETTINGS[:unattended] - page['host_root_pass'].value = @hostgroup.root_pass + page['*[id*=root_pass]'].val(@hostgroup.root_pass) if (@hypervisor = @hostgroup.hypervisor) @hypervisor.connect # we are in a view context @@ -392,19 +390,18 @@ def process_hostgroup end if @architecture - page.replace_html :architecture_select, :partial => 'common/os_selection/architecture', :locals => {:item => @host} - page['host_architecture_id'].value = @architecture.id - end - if @operatingsystem - page.replace_html :operatingsystem_select, :partial => 'common/os_selection/operatingsystem', :locals => {:item => @host} + page['#os_select'].html(render(:partial => 'common/os_selection/architecture', :locals => {:item => @host})) + page['#*[id*=architecture_id]'].val(@architecture.id) end + + page['#media_select'].html(render(:partial => 'common/os_selection/operatingsystem', :locals => {:item => @host})) if @operatingsystem + if @domain - page['host_domain_id'].value = @domain.id + page['*[id*=domain_id]'].val(@domain.id) if @subnet - page.replace_html(:host_subnet, :partial => 'common/domain', :locals => {:item => @host}) - page['host_subnet_id'].val("0").change - page['host_subnet_id'].val("#{@subnet.id}").change - page.replace_html(:sp_subnet, :partial => 'hosts/sp_subnet', :locals => {:item => @host}) + page['#subnet_select'].html(render(:partial => 'common/domain', :locals => {:item => @host})) + page['#host_subnet_id'].val(@subnet.id).change + page['#sp_subnet'].html(render(:partial => 'hosts/sp_subnet', :locals => {:item => @host})) end end end @@ -459,7 +456,7 @@ def find_hosts end unless klass.nil? group.each do |k| - list = Host.hostgroup_name_eq(k).send(state).map(&:name) + list = Host.joins(:hostgroup).where("hostgroups.name" => k).send(state).map(&:name) @hosts = counter == 0 ? list : @hosts & list counter +=1 end unless group.nil? @@ -467,11 +464,6 @@ def find_hosts not_found if @hosts.empty? end - def ajax_methods - return head(:method_not_allowed) unless request.xhr? - @host = Host.find(params[:id]) unless params[:id].empty? - end - def load_vars_for_ajax return unless @host @environment = @host.environment diff --git a/app/controllers/hypervisors/guests_controller.rb b/app/controllers/hypervisors/guests_controller.rb index 63a291cbe4e..fbc70d94c0d 100644 --- a/app/controllers/hypervisors/guests_controller.rb +++ b/app/controllers/hypervisors/guests_controller.rb @@ -1,4 +1,4 @@ -require_dependency 'hypervisor/guest' +require 'hypervisor/guest' class Hypervisors::GuestsController < ApplicationController before_filter :find_hypervisor diff --git a/app/controllers/lookup_values_controller.rb b/app/controllers/lookup_values_controller.rb index baa1c194623..176c814855b 100644 --- a/app/controllers/lookup_values_controller.rb +++ b/app/controllers/lookup_values_controller.rb @@ -3,7 +3,6 @@ class LookupValuesController < ApplicationController before_filter :reject_non_json_requests before_filter :find_by_id, :except => [:index, :create] before_filter :setup_search_options, :only => :index - filter_parameter_logging :value # might contain sensative information def index begin diff --git a/app/controllers/media_controller.rb b/app/controllers/media_controller.rb index b8d7dc629ce..38fefc77e69 100644 --- a/app/controllers/media_controller.rb +++ b/app/controllers/media_controller.rb @@ -6,7 +6,7 @@ def index values = Medium.search_for(params[:search], :order => params[:order]) respond_to do |format| format.html { @media = values.paginate(:page => params[:page], :include => [:operatingsystems]) } - format.json { render :json => values.as_json } + format.json { render :json => values } end end diff --git a/app/controllers/operatingsystems_controller.rb b/app/controllers/operatingsystems_controller.rb index 4fde5891839..6b0464731c4 100644 --- a/app/controllers/operatingsystems_controller.rb +++ b/app/controllers/operatingsystems_controller.rb @@ -35,7 +35,9 @@ def create def edit # Generates default OS template entries @operatingsystem.config_templates.map(&:template_kind_id).uniq.each do |kind| - @operatingsystem.os_default_templates.build(:template_kind_id => kind) if @operatingsystem.os_default_templates.template_kind_id_eq(kind).blank? + if @operatingsystem.os_default_templates.where(:template_kind_id => kind).blank? + @operatingsystem.os_default_templates.build(:template_kind_id => kind) + end end if SETTINGS[:unattended] end diff --git a/app/controllers/puppetclasses_controller.rb b/app/controllers/puppetclasses_controller.rb index 7cfac0ed322..617fd18d1bb 100644 --- a/app/controllers/puppetclasses_controller.rb +++ b/app/controllers/puppetclasses_controller.rb @@ -1,3 +1,5 @@ +require 'foreman/controller/environments' + class PuppetclassesController < ApplicationController include Foreman::Controller::Environments include Foreman::Controller::AutoCompleteSearch @@ -56,23 +58,4 @@ def destroy redirect_to puppetclasses_url end - # AJAX methods - - # adds a puppetclass to an existing host or hostgroup - # - # We assign the new puppetclasses (e.g. in the context of a Host or a Host Group) - # via ajax and not java script as rendering javascript for each and every class - # seems to be much longer than the average roundtrip time to the server - # TODO: convert this to pure javascript then AJAX will not be required. - def assign - return unless request.xhr? - - type = params[:type] - render :update do |page| - page.insert_html :bottom, :selected_classes, :partial => 'selectedClasses', :locals => {:klass => @puppetclass, :type => type} - page["selected_puppetclass_#{@puppetclass.id}"].highlight(5000) - page["puppetclass_#{@puppetclass.id}"].hide - end - end - end diff --git a/app/controllers/reports_controller.rb b/app/controllers/reports_controller.rb index d697b8f6623..bf8bb2aa328 100644 --- a/app/controllers/reports_controller.rb +++ b/app/controllers/reports_controller.rb @@ -8,9 +8,6 @@ class ReportsController < ApplicationController before_filter :set_admin_user, :only => :create before_filter :setup_search_options, :only => :index - # avoids storing the report data in the log files - filter_parameter_logging :report - def index values = Report.search_for(params[:search], :order => params[:order]) pagination_opts = { :page => params[:page], :per_page => params[:per_page] } diff --git a/app/controllers/subnets_controller.rb b/app/controllers/subnets_controller.rb index 299bd6adf1d..2e959c1fd5f 100644 --- a/app/controllers/subnets_controller.rb +++ b/app/controllers/subnets_controller.rb @@ -53,9 +53,8 @@ def freeip respond_to do |format| format.html do render :update do |page| - page['host_ip'].value = ip - page['indicator'].hide - page['host_ip'].visual_effect :highlight + page['#host_ip'].val(ip) + page['#host_ip'].show('highlight', 5000) end end format.json { render :json => {:ip => ip} } diff --git a/app/controllers/unattended_controller.rb b/app/controllers/unattended_controller.rb index b42c3c2bba8..ebb62715eb5 100644 --- a/app/controllers/unattended_controller.rb +++ b/app/controllers/unattended_controller.rb @@ -2,14 +2,14 @@ class UnattendedController < ApplicationController layout nil # Methods which return configuration files for syslinux(pxe), pxegrub or g/ipxe - PXE_CONFIG_URLS = [:pxe_kickstart_config, :pxe_debian_config, :pxemenu] + TemplateKind.name_like("pxelinux").map(&:name) - PXEGRUB_CONFIG_URLS = [:pxe_jumpstart_config] + TemplateKind.name_like("pxegrub").map(&:name) - GPXE_CONFIG_URLS = [:gpxe_kickstart_config] + TemplateKind.name_like("gpxe").map(&:name) + PXE_CONFIG_URLS = [:pxe_kickstart_config, :pxe_debian_config, :pxemenu] + TemplateKind.where("name LIKE ?","pxelinux").map(&:name) + PXEGRUB_CONFIG_URLS = [:pxe_jumpstart_config] + TemplateKind.where("name LIKE ?", "pxegrub").map(&:name) + GPXE_CONFIG_URLS = [:gpxe_kickstart_config] + TemplateKind.where("name LIKE ?", "gpxe").map(&:name) CONFIG_URLS = PXE_CONFIG_URLS + GPXE_CONFIG_URLS + PXEGRUB_CONFIG_URLS # Methods which return valid provision instructions, used by the OS - PROVISION_URLS = [:kickstart, :preseed, :jumpstart ] + TemplateKind.name_like("provision").map(&:name) + PROVISION_URLS = [:kickstart, :preseed, :jumpstart ] + TemplateKind.where("name LIKE ?", "provision").map(&:name) # Methods which returns post install instructions for OS's which require it - FINISH_URLS = [:preseed_finish, :jumpstart_finish] + TemplateKind.name_like("finish").map(&:name) + FINISH_URLS = [:preseed_finish, :jumpstart_finish] + TemplateKind.where("name LIKE ?", "finish").map(&:name) # We dont require any of these methods for provisioning skip_before_filter :require_ssl, :require_login, :authorize @@ -151,7 +151,7 @@ def unattended_local safe_render config and return end type = "unattended_local/#{request.path.gsub("/#{controller_name}/","")}.local" - render :template => type if File.exists?("#{RAILS_ROOT}/app/views/#{type}.rhtml") + render :template => type if File.exists?("#{Rails.root}/app/views/#{type}.rhtml") end def set_content_type diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 142cb271abb..3544be3fb27 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -1,7 +1,6 @@ class UsersController < ApplicationController include Foreman::Controller::AutoCompleteSearch - filter_parameter_logging :password, :password_confirmation skip_before_filter :require_login, :only => [:login, :logout] skip_before_filter :authorize, :only => [:login, :logout] @@ -117,9 +116,9 @@ def logout def auth_source_selected render :update do |page| if params[:auth_source_id] and AuthSource.find(params[:auth_source_id]).can_set_password? - page.show 'password' + page['#password'].show else - page.hide 'password' + page['#password'].hide end end end diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 4cadd8dcfb7..f6654854409 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -29,7 +29,7 @@ def link_to_add_fields(name, f, association, partial = nil, options = {}) fields = f.fields_for(association, new_object, :child_index => "new_#{association}") do |builder| render((partial.nil? ? association.to_s.singularize + "_fields" : partial), :f => builder) end - link_to_function(name, h("add_fields(this, \"#{association}\", \"#{escape_javascript(fields)}\")"), options.merge({:class => "btn small info"}) ) + link_to_function(name, ("add_fields(this, \"#{association}\", \"#{escape_javascript(fields)}\")").html_safe, options.merge({:class => "btn small info"}) ) end def toggle_div divs @@ -48,20 +48,11 @@ def toggle_div divs end def link_to_remove_puppetclass klass - link_to_function "",:class=>"ui-icon ui-icon-minus" do |page| - page["selected_puppetclass_#{klass.id}"].remove - #TODO if the class is already selected, removing it will not add it to the avail class list - page << "if ($('puppetclass_#{klass.id}')) {" - page["puppetclass_#{klass.id}"].show - page << "}" - end + link_to_function "","remove_puppet_class(this)", :'data-class-id'=>klass.id, :class=>"ui-icon ui-icon-minus" end def link_to_add_puppetclass klass, type - # link to remote is faster than inline js when having many classes - link_to_remote "", - {:url => assign_puppetclass_path(klass, :type => type), - :position => {:after => {:success => "selected_classes" }}},{:class=>"ui-icon ui-icon-plus"} + link_to_function "", "add_puppet_class(this)", :'data-class-id'=>klass.id, :class=>"ui-icon ui-icon-plus" end def check_all_links(form_name) @@ -146,7 +137,7 @@ def auto_complete_search(method, val,tag_options = {}, completion_options = {}) end def help_path - link_to "Help", :action => "help" + link_to "Help", :action => "welcome" end def edit_textfield(object, property, options={}) diff --git a/app/helpers/audits_helper.rb b/app/helpers/audits_helper.rb index fafb91a6f88..598cfe34cf2 100644 --- a/app/helpers/audits_helper.rb +++ b/app/helpers/audits_helper.rb @@ -13,11 +13,11 @@ def audit_title audit end def audit_parent audit - audit.try(:auditable_parent).try(:name) + audit.try(:associated).try(:name) end - def auditable_type audit - audit.auditable_type.split("::").last + def association_type audit + audit.association_type.split("::").last if audit.association_type end def change_order action, value diff --git a/app/helpers/dashboard_helper.rb b/app/helpers/dashboard_helper.rb index dbf3128e5f9..af0f865ecee 100644 --- a/app/helpers/dashboard_helper.rb +++ b/app/helpers/dashboard_helper.rb @@ -32,4 +32,10 @@ def render_run_distribution data, options = {} data[:counter], options end + + def searchable_links name, search + search += " and #{params[:search]}" unless params[:search].blank? + link_to name, hosts_path(:search => search) + end + end diff --git a/app/helpers/hosts_helper.rb b/app/helpers/hosts_helper.rb index 6864236c961..25e36ecd2d6 100644 --- a/app/helpers/hosts_helper.rb +++ b/app/helpers/hosts_helper.rb @@ -101,14 +101,6 @@ def selected? host session[:selected].include?(host.id.to_s) end - def update_details_from_hostgroup - return nil unless @host.new_record? - remote_function(:url => { :action => "process_hostgroup" }, - :method => :post, :loading => "$('#indicator1').show()", - :complete => "$('#indicator1').hide()", - :with => "'hostgroup_id=' + value") - end - def report_status_chart name, title, subtitle, data, options = {} content_tag(:div, nil, { :id => name, @@ -139,11 +131,10 @@ def runtime_chart name, title, subtitle, data, options = {} def reports_show return unless @host.reports.size > 0 form_tag @host, :id => 'days_filter', :method => :get do - content_tag(:p, {}) { "Reports from the last " + - select(nil, 'range', 1..days_ago(@host.reports.first.reported_at), - {:selected => @range}, {:class=>"mini", :onchange =>"$('#days_filter').submit();$(this).disabled();"}) + - " days - #{@host.reports.recent(@range.days.ago).count} reports found" - } + content_tag(:span, "Reports from the last ") + + select(nil, 'range', 1..days_ago(@host.reports.first.reported_at), + {:selected => @range}, {:class=>"mini", :onchange =>"$('#days_filter').submit();$(this).disabled();"}).html_safe + + " days - #{@host.reports.recent(@range.days.ago).count} reports found" end end diff --git a/app/helpers/layout_helper.rb b/app/helpers/layout_helper.rb index eee3642ee19..8057c880184 100644 --- a/app/helpers/layout_helper.rb +++ b/app/helpers/layout_helper.rb @@ -1,15 +1,15 @@ module LayoutHelper def title(page_title, page_header = nil) - @content_for_title = page_title.to_s + content_for(:title, page_title.to_s) @page_header = page_header || @content_for_title end def title_actions *elements - content_for(:title_actions) { elements.join(" ") } + content_for(:title_actions) { elements.join(" ").html_safe } end def search_bar *elements - content_for(:search_bar) { elements.join(" ") } + content_for(:search_bar) { elements.join(" ").html_safe } end def stylesheet(*args) @@ -20,25 +20,6 @@ def javascript(*args) content_for(:head) { javascript_include_tag(*args) } end - def will_paginate(collection = nil, options = {}) - options.merge!(:class=>"span10 pagination fr") - options[:renderer] ||= "WillPaginate::ViewHelpers::BootstrapLinkRenderer" - options[:inner_window] ||= 3 - options[:outer_window] ||= 0 - super collection, options - end - - def page_entries_info(collection, options = {}) - html = super(collection, options) - html += options[:more] if options[:more] - content_tag( - :div,content_tag( - :ul, content_tag( - :li, link_to(html, "#") - ), :style=>"float: left;" - ), :class => "span6 pagination") - end - def text_f(f, attr, options = {}) field(f, attr, options) do f.text_field attr, options @@ -83,29 +64,28 @@ def selectable_f(f, attr, array, select_options = {}, html_options = {}) def field(f, attr, options = {}) obj = f.object - error = obj.errors.on(attr) + error = obj.errors[attr] + help_inline = content_tag(:span, (error.empty? ? options.delete(:help_inline) : error.to_sentence.html_safe), :class => "help-inline") + help_block = content_tag(:span, options.delete(:help_block), :class => "help-block") content_tag :div, :class => "clearfix #{error.empty? ? "" : 'error'}" do - f.label(attr, options.delete(:label)) + + f.label(attr, options.delete(:label)).html_safe + content_tag(:div, :class => "input") do - raw = "" - raw += content_tag(:span, (error.empty? ? options[:help_inline] : error.to_a.to_sentence), :class => "help-inline") - raw += content_tag(:span, options[:help_block], :class => "help-block") - yield + raw - end + yield.html_safe + help_inline.html_safe + help_block.html_safe + end.html_safe end end def submit_or_cancel f - "
" + content_tag(:p, :class => "ra") do + "
".html_safe + content_tag(:p, :class => "ra") do link_to("Cancel", eval("#{controller_name}_path"), :class => "btn") + " " + f.submit("Submit", :class => "btn primary") end end def base_errors_for obj - if errors = obj.errors.on(:base) + unless obj.errors[:base].blank? content_tag(:div, :class => "alert-message block-message error base in fade", "data-alert" => true) do - '×' + "

Unable to save

" + errors.map {|e| "
  • #{e}
  • "}.join + "×

    Unable to save

    ".html_safe + obj.errors[:base].map {|e| "
  • #{e}
  • "}.to_s.html_safe end end end @@ -114,4 +94,23 @@ def popover title, msg, options = {} link_to_function title, {:rel => "popover", "data-content" => msg, "data-original-title" => title}.merge(options) end + def will_paginate(collection = nil, options = {}) + options.merge!(:class=>"span10 pagination fr") + options[:renderer] ||= "WillPaginate::ActionView::BootstrapLinkRenderer" + options[:inner_window] ||= 2 + options[:outer_window] ||= 0 + super collection, options + end + + def page_entries_info(collection, options = {}) + html = super(collection, options) + html += options[:more].html_safe if options[:more] + content_tag( + :div,content_tag( + :ul, content_tag( + :li, link_to(html, "#") + ), :style=>"float: left;" + ), :class => "span6 pagination") + end + end diff --git a/app/helpers/lookup_keys_helper.rb b/app/helpers/lookup_keys_helper.rb index faaed1f9e70..23d8a49bc9a 100644 --- a/app/helpers/lookup_keys_helper.rb +++ b/app/helpers/lookup_keys_helper.rb @@ -8,7 +8,7 @@ def remove_child_link(name, f, opts = {}) def add_child_link(name, association, opts = {}) opts[:class] = [opts[:class], "add_nested_fields btn small success"].compact.join(" ") opts[:"data-association"] = association - link_to(name, "javascript:void(0)", opts) + link_to(name.to_s, "javascript:void(0)", opts) end def new_child_fields_template(form_builder, association, options = { }) diff --git a/app/helpers/operatingsystems_helper.rb b/app/helpers/operatingsystems_helper.rb index 3015b98b08d..14552e0409c 100644 --- a/app/helpers/operatingsystems_helper.rb +++ b/app/helpers/operatingsystems_helper.rb @@ -1,18 +1,6 @@ module OperatingsystemsHelper include CommonParametersHelper - # displays release name on debian based distributions on operating system edit page. - def show_release - update_page do |page| - page << "if (value == 'Debian' || value == 'Solaris') {" - page[:release_name].show - page[:release_name].highlight - page << "} else {" - page[:release_name].hide - page << "}" - end - end - def icon record, opts = {} return "" if record.blank? or record.name.blank? family = case record.name @@ -39,7 +27,7 @@ def icon record, opts = {} end def os_name record, opts = {} - "#{icon(record, opts)} #{h(record)}" + "#{icon(record, opts)} #{record}".html_safe end end diff --git a/app/helpers/puppetclasses_helper.rb b/app/helpers/puppetclasses_helper.rb index 934edd10bbc..f3a82edcf14 100644 --- a/app/helpers/puppetclasses_helper.rb +++ b/app/helpers/puppetclasses_helper.rb @@ -3,7 +3,7 @@ module PuppetclassesHelper include LookupKeysHelper def rdoc_classes_path environment, name klass = name.gsub('::', '/') - frame = '
    ' + frame = '
    '.html_safe update_page do |page| page.replace_html(:content, frame) page.insert_html(:after, "puppetdoc",link_to(:back)) diff --git a/app/helpers/reports_helper.rb b/app/helpers/reports_helper.rb index e34afb81ead..ce9b7d1290c 100644 --- a/app/helpers/reports_helper.rb +++ b/app/helpers/reports_helper.rb @@ -22,7 +22,7 @@ def reports_since builder end def metric m - h(m.round_with_precision(4)) rescue "N/A" + m.round(4) rescue "N/A" end def report_tag level @@ -42,10 +42,9 @@ def report_tag level def logs_show return unless @report.logs.size > 0 form_tag @report, :id => 'level_filter', :method => :get do - content_tag(:p, {}) { "Show log messages: " + - select(nil, 'level', [['All messages', 'notice'],['Warnings and errors', 'warning'],['Errors only', 'error']], - {}, {:class=>"span4", :onchange =>"filter_by_level($(this).val());"}) - } + content_tag(:span, "Show log messages: ") + + select(nil, 'level', [['All messages', 'notice'],['Warnings and errors', 'warning'],['Errors only', 'error']], + {}, {:class=>"span4", :onchange =>"filter_by_level($(this).val());"}) end end end diff --git a/vendor/gems/rack-1.1.0/RDOX b/app/mailers/.gitkeep similarity index 100% rename from vendor/gems/rack-1.1.0/RDOX rename to app/mailers/.gitkeep diff --git a/app/models/.gitkeep b/app/models/.gitkeep new file mode 100644 index 00000000000..e69de29bb2d diff --git a/app/models/architecture.rb b/app/models/architecture.rb index fe6294f75bf..91d5f76b18d 100644 --- a/app/models/architecture.rb +++ b/app/models/architecture.rb @@ -3,7 +3,7 @@ class Architecture < ActiveRecord::Base has_many :hosts has_and_belongs_to_many :operatingsystems validates_uniqueness_of :name - before_destroy Ensure_not_used_by.new(:hosts) + before_destroy EnsureNotUsedBy.new(:hosts) validates_format_of :name, :with => /\A(\S+)\Z/, :message => "can't be blank or contain white spaces." acts_as_audited @@ -14,6 +14,7 @@ def to_param end def as_json(options={}) + options ||= {} super({:only => [:name, :id]}.merge(options)) end diff --git a/app/models/auth_source_ldap.rb b/app/models/auth_source_ldap.rb index 5054473a31a..b5d2d57ccaa 100644 --- a/app/models/auth_source_ldap.rb +++ b/app/models/auth_source_ldap.rb @@ -27,10 +27,7 @@ class AuthSourceLdap < AuthSource validates_numericality_of :port, :only_integer => true before_validation :strip_ldap_attributes - - def after_initialize - self.port = 389 if self.port == 0 - end + after_initialize :set_defaults # Loads the LDAP info for a user and authenticates the user with their password # Returns : Array of Strings. @@ -104,5 +101,9 @@ def self.get_attr(entry, attr_name) entry[attr_name].is_a?(Array) ? entry[attr_name].first : entry[attr_name] end end -end + def set_defaults + self.port ||= 389 + end + +end diff --git a/app/models/authorization.rb b/app/models/authorization.rb index cb37dbd88f1..05616cf3d14 100644 --- a/app/models/authorization.rb +++ b/app/models/authorization.rb @@ -30,7 +30,7 @@ def enforce_permissions operation klasses = klass.pluralize return true if User.current and User.current.allowed_to?("#{operation}_#{klasses}".to_sym) - errors.add_to_base "You do not have permission to #{operation} this #{klass}" + errors.add :base, "You do not have permission to #{operation} this #{klass}" false end diff --git a/app/models/bookmark.rb b/app/models/bookmark.rb index 2dbc4ead0f1..5e02c3967af 100644 --- a/app/models/bookmark.rb +++ b/app/models/bookmark.rb @@ -9,10 +9,11 @@ class Bookmark < ActiveRecord::Base default_scope :order => :name before_validation :set_default_user - named_scope :my_bookmarks, lambda { + scope :my_bookmarks, lambda { user = User.current return {} unless SETTINGS[:login] and !user.nil? + user = User.current conditions = sanitize_sql_for_conditions(["((bookmarks.public = ?) OR (bookmarks.owner_id in (?) AND bookmarks.owner_type = 'Usergroup') OR (bookmarks.owner_id = ? AND bookmarks.owner_type = 'User'))", true, user.my_usergroups.map(&:id), user.id]) {:conditions => conditions} } diff --git a/app/models/config_template.rb b/app/models/config_template.rb index ea2503545d6..0ab44b63097 100644 --- a/app/models/config_template.rb +++ b/app/models/config_template.rb @@ -36,27 +36,28 @@ def self.find_template opts = {} raise "Must provide an operating systems" unless opts[:operatingsystem_id] # first filter valid templates to our OS and requested template kind. - templates = ConfigTemplate.operatingsystems_id_eq(opts[:operatingsystem_id]).template_kind_name_eq(opts[:kind]) + templates = ConfigTemplate.joins(:operatingsystems, :template_kind).where('operatingsystems.id' => opts[:operatingsystem_id], 'template_kinds.name' => opts[:kind]) + # once a template has been matched, we no longer look for others. if opts[:hostgroup_id] and opts[:environment_id] # try to find a full match to our host group and environment - template = templates.hostgroups_id_eq(opts[:hostgroup_id]).environments_id_eq(opts[:environment_id]).first + template = templates.joins(:hostgroups, :environments).where("hostgroups.id" => opts[:hostgroup_id], "environments.id" => opts[:environment_id]).first end if opts[:hostgroup_id] # try to find a match with our hostgroup only - template ||= templates.hostgroups_id_eq(opts[:hostgroup_id]).first + template ||= templates.joins(:hostgroups).where("hostgroups.id" => opts[:hostgroup_id]).first end if opts[:environment_id] # search for a template based only on our environment - template ||= templates.environments_id_eq(opts[:environment_id]).first + template ||= templates.joins(:environments).where("environments.id" => opts[:environment_id]).first end # fall back to the os default template - template ||= templates.os_default_templates_operatingsystem_id_eq(opts[:operatingsystem_id]).first + template ||= templates.joins(:os_default_templates).where("os_default_templates.operatingsystem_id" => opts[:operatingsystem_id]).first template.is_a?(ConfigTemplate) ? template : nil end @@ -66,10 +67,15 @@ def enforce_permissions operation return true if User.current and User.current.allowed_to?("#{operation}_templates".to_sym) - errors.add_to_base "You do not have permission to #{operation} this template" + errors.add :base, "You do not have permission to #{operation} this template" false end + def as_json(options={}) + options ||= {} + super({:only => [:name, :template, :id, :snippet],:include => [:template_kind]}.merge(options)) + end + private # check if our template is a snippet, and remove its associations just in case they were selected. @@ -85,9 +91,4 @@ def check_for_snippet_assoications def remove_trailing_chars self.template.gsub!("\r","") unless template.empty? end - - def as_json(options={}) - super({:only => [:name, :template, :id, :snippet],:include => [:template_kind]}.merge(options)) - end - end diff --git a/app/models/domain.rb b/app/models/domain.rb index d55fd7193ef..b4bd0c9b1dd 100644 --- a/app/models/domain.rb +++ b/app/models/domain.rb @@ -15,7 +15,7 @@ class Domain < ActiveRecord::Base scoped_search :on => [:name, :fullname], :complete_value => true - before_destroy Ensure_not_used_by.new(:hosts, :subnets) + before_destroy EnsureNotUsedBy.new(:hosts, :subnets) default_scope :order => 'LOWER(domains.name)' class Jail < Safemode::Jail @@ -45,7 +45,7 @@ def enforce_permissions operation end end - errors.add_to_base "You do not have permission to #{operation} this domain" + errors.add :base, "You do not have permission to #{operation} this domain" false end diff --git a/app/models/domain_parameter.rb b/app/models/domain_parameter.rb index dcc7aa25509..064f02ebf0d 100644 --- a/app/models/domain_parameter.rb +++ b/app/models/domain_parameter.rb @@ -16,7 +16,7 @@ def enforce_permissions operation end end - errors.add_to_base "You do not have permission to #{operation} this domain parameter" + errors.add :base, "You do not have permission to #{operation} this domain parameter" false end end diff --git a/app/models/environment.rb b/app/models/environment.rb index 9823adf7e1b..fc7f9221b63 100644 --- a/app/models/environment.rb +++ b/app/models/environment.rb @@ -7,7 +7,7 @@ class Environment < ActiveRecord::Base has_many :config_templates, :through => :template_combinations, :dependent => :destroy has_many :template_combinations - before_destroy Ensure_not_used_by.new(:hosts) + before_destroy EnsureNotUsedBy.new(:hosts) default_scope :order => 'LOWER(environments.name)' scoped_search :on => :name, :complete_value => :true @@ -174,6 +174,7 @@ def self.obsolete_and_new changed end def as_json(options={}) + options ||= {} super({:only => [:name, :id]}.merge(options)) end diff --git a/app/models/fact_value.rb b/app/models/fact_value.rb index 98d0871039d..94aaa1a8022 100644 --- a/app/models/fact_value.rb +++ b/app/models/fact_value.rb @@ -7,14 +7,14 @@ class FactValue < Puppet::Rails::FactValue scoped_search :in => :fact_name, :on => :name, :complete_value => true, :alias => "fact" scoped_search :in => :host, :on => :name, :rename => :host, :complete_value => true - named_scope :no_timestamp_facts, :include => [:fact_name], + scope :no_timestamp_facts, :include => [:fact_name], :conditions => ["fact_names.name <> ?",:_timestamp] - named_scope :timestamp_facts, :joins => [:fact_name], + scope :timestamp_facts, :joins => [:fact_name], :conditions => ["fact_names.name = ?",:_timestamp] - named_scope :distinct, { :select => 'DISTINCT "fact_values.value"' } - named_scope :required_fields, { :include => :host } + scope :distinct, { :select => 'DISTINCT "fact_values.value"' } + scope :required_fields, { :include => :host } default_scope :order => 'LOWER(fact_values.value)' # Todo: find a way to filter which values are logged, @@ -28,12 +28,12 @@ class FactValue < Puppet::Rails::FactValue def self.mem_average(fact) total, count = to_gb(fact) return 0 if count == 0 - (total / count).round_with_precision(1) + (total / count).round(1) end # returns the rounded total of memory fact values (e.g. MB, GB etc) def self.mem_sum(fact) - to_gb(fact).first.round_with_precision(1) + to_gb(fact).first.to_f.round(1) rescue 0 end diff --git a/app/models/group_parameter.rb b/app/models/group_parameter.rb index 75ea348e713..1dab518f260 100644 --- a/app/models/group_parameter.rb +++ b/app/models/group_parameter.rb @@ -16,7 +16,7 @@ def enforce_permissions operation end end - errors.add_to_base "You do not have permission to #{operation} this group parameter" + errors.add :base, "You do not have permission to #{operation} this group parameter" false end end diff --git a/app/models/host.rb b/app/models/host.rb index cf0c0fdaacc..db9c30d3644 100644 --- a/app/models/host.rb +++ b/app/models/host.rb @@ -14,17 +14,17 @@ class Host < Puppet::Rails::Host include Hostext::Search include HostCommon - class Jail < Safemode::Jail + class Jail < ::Safemode::Jail allow :name, :diskLayout, :puppetmaster, :operatingsystem, :os, :environment, :ptable, :hostgroup, :url_for_boot, :params, :hostgroup, :domain, :ip, :mac, :shortname, :architecture end attr_reader :cached_host_params, :cached_lookup_keys_params - named_scope :recent, lambda { |*args| {:conditions => ["last_report > ?", (args.first || (Setting[:puppet_interval] + 5).minutes.ago)]} } - named_scope :out_of_sync, lambda { |*args| {:conditions => ["last_report < ? and enabled != ?", (args.first || (Setting[:puppet_interval] + 5).minutes.ago), false]} } + scope :recent, lambda { |*args| {:conditions => ["last_report > ?", (args.first || (Setting[:puppet_interval] + 5).minutes.ago)]} } + scope :out_of_sync, lambda { |*args| {:conditions => ["last_report < ? and enabled != ?", (args.first || (Setting[:puppet_interval] + 5).minutes.ago), false]} } - named_scope :with_fact, lambda { |fact,value| + scope :with_fact, lambda { |fact,value| unless fact.nil? or value.nil? { :joins => "INNER JOIN fact_values fv_#{fact} ON fv_#{fact}.host_id = hosts.id INNER JOIN fact_names fn_#{fact} ON fn_#{fact}.id = fv_#{fact}.fact_name_id", @@ -35,7 +35,7 @@ class Jail < Safemode::Jail end } - named_scope :with_class, lambda { |klass| + scope :with_class, lambda { |klass| unless klass.nil? { :joins => :puppetclasses, :select => "hosts.name", :conditions => {:puppetclasses => {:name => klass }} } else @@ -43,31 +43,31 @@ class Jail < Safemode::Jail end } - named_scope :with_error, { :conditions => "(puppet_status > 0) and + scope :with_error, { :conditions => "(puppet_status > 0) and ( ((puppet_status >> #{BIT_NUM*METRIC.index("failed")} & #{MAX}) != 0) or ((puppet_status >> #{BIT_NUM*METRIC.index("failed_restarts")} & #{MAX}) != 0) )" } - named_scope :without_error, { :conditions => + scope :without_error, { :conditions => "((puppet_status >> #{BIT_NUM*METRIC.index("failed")} & #{MAX}) = 0) and ((puppet_status >> #{BIT_NUM*METRIC.index("failed_restarts")} & #{MAX}) = 0)" } - named_scope :with_changes, { :conditions => "(puppet_status > 0) and + scope :with_changes, { :conditions => "(puppet_status > 0) and ( ((puppet_status >> #{BIT_NUM*METRIC.index("applied")} & #{MAX}) != 0) or ((puppet_status >> #{BIT_NUM*METRIC.index("restarted")} & #{MAX}) != 0) )" } - named_scope :without_changes, { :conditions => + scope :without_changes, { :conditions => "((puppet_status >> #{BIT_NUM*METRIC.index("applied")} & #{MAX}) = 0) and ((puppet_status >> #{BIT_NUM*METRIC.index("restarted")} & #{MAX}) = 0)" } - named_scope :successful, lambda { without_changes.without_error.scope(:find)} + scope :successful, lambda { without_changes.without_error } - named_scope :alerts_disabled, {:conditions => ["enabled = ?", false] } + scope :alerts_disabled, {:conditions => ["enabled = ?", false] } - named_scope :my_hosts, lambda { + scope :my_hosts, lambda { user = User.current owner_conditions = sanitize_sql_for_conditions(["((hosts.owner_id in (?) AND hosts.owner_type = 'Usergroup') OR (hosts.owner_id = ? AND hosts.owner_type = 'User'))", user.my_usergroups.map(&:id), user.id]) domain_conditions = sanitize_sql_for_conditions([" (hosts.domain_id in (?))",dms = (user.domains).map(&:id)]) @@ -95,9 +95,9 @@ class Jail < Safemode::Jail {:conditions => conditions} } - named_scope :completer_scope, lambda { my_hosts.scope(:find) } + scope :completer_scope, lambda { my_hosts } - named_scope :run_distribution, lambda { |fromtime,totime| + scope :run_distribution, lambda { |fromtime,totime| unless fromtime.nil? or totime.nil? { :joins => "INNER JOIN reports ON reports.host_id = hosts.id", :conditions => ["reports.reported_at BETWEEN ? AND ?", fromtime, totime] } @@ -108,6 +108,7 @@ class Jail < Safemode::Jail # audit the changes to this model acts_as_audited :except => [:last_report, :puppet_status, :last_compile] + has_associated_audits # some shortcuts alias_attribute :os, :operatingsystem @@ -331,7 +332,7 @@ def self.importHostAndFacts yaml return false unless facts.is_a?(Puppet::Node::Facts) h=find_or_create_by_name(facts.name) - h.save(false) if h.new_record? + h.save(:validate => false) if h.new_record? h.importFacts(facts) end @@ -351,7 +352,7 @@ def importFacts facts self.last_compile = time # save all other facts - pre 0.25 it was called setfacts respond_to?("merge_facts") ? self.merge_facts(facts.values) : self.setfacts(facts.values) - save(false) + save(:validate => false) # we want to import other information only if this host was never installed via Foreman populateFieldsFromFacts if installed_at.nil? @@ -361,7 +362,7 @@ def importFacts facts # If we don't (e.g. we never install the server via Foreman, we populate the fields from facts # TODO: if it was installed by Foreman and there is a mismatch, # we should probably send out an alert. - return self.save(false) + return self.save(:validate => false) rescue Exception => e logger.warn "Failed to save #{facts.name}: #{e}" @@ -405,7 +406,7 @@ def populateFieldsFromFacts end # again we are saving without validations as input is required (e.g. partition tables) - self.save(false) + self.save(:validate => false) end # Called by build link in the list @@ -555,7 +556,7 @@ def enforce_permissions operation (!current.hostgroups.empty? and current.hostgroups.include?(hostgroup)) end end - errors.add_to_base "You do not have permission to #{operation} this host" + errors.add :base, "You do not have permission to #{operation} this host" false end diff --git a/app/models/host_class.rb b/app/models/host_class.rb index ff9bf4f6faf..4ed7a746787 100644 --- a/app/models/host_class.rb +++ b/app/models/host_class.rb @@ -1,5 +1,5 @@ class HostClass < ActiveRecord::Base - acts_as_audited :parent => :host + acts_as_audited :associated_with => :host belongs_to :host belongs_to :puppetclass diff --git a/app/models/host_common.rb b/app/models/host_common.rb index bfee385511d..e2441a65b54 100644 --- a/app/models/host_common.rb +++ b/app/models/host_common.rb @@ -55,6 +55,7 @@ def root_pass # Else if the host/hostgroup's operatingsystem has only one media then use the image_path from that as this is automatically displayed when there is only one item # Else we cannot provide a default and it is cut and paste time def default_image_file + return "" unless operatingsystem and operatingsystem.supports_image if medium nfs_path = medium.try :image_path if operatingsystem.try(:media) and operatingsystem.media.size == 1 diff --git a/app/models/host_parameter.rb b/app/models/host_parameter.rb index 6ec0b4c8af1..04faf7e9ad3 100644 --- a/app/models/host_parameter.rb +++ b/app/models/host_parameter.rb @@ -1,6 +1,6 @@ class HostParameter < Parameter belongs_to :host, :foreign_key => :reference_id - acts_as_audited :except => [:priority], :parent => :host + acts_as_audited :except => [:priority], :associated_with => :host validates_uniqueness_of :name, :scope => :reference_id def to_s diff --git a/app/models/host_template_helpers.rb b/app/models/host_template_helpers.rb index 55a3b25fd18..d70fdbabcea 100644 --- a/app/models/host_template_helpers.rb +++ b/app/models/host_template_helpers.rb @@ -6,7 +6,7 @@ def install_path operatingsystem.interpolate_medium_vars(operatingsystem.media_path(medium, domain), architecture.name, operatingsystem) end - # Calculates the jumpstart's path in relation to the domain and convert host to an IP + # Calculates the jumpstart path in relation to the domain and convert host to an IP def jumpstart_path operatingsystem.jumpstart_path medium, domain end diff --git a/app/models/hostgroup.rb b/app/models/hostgroup.rb index 65fa197cf7d..250cc3fa81a 100644 --- a/app/models/hostgroup.rb +++ b/app/models/hostgroup.rb @@ -10,10 +10,11 @@ class Hostgroup < ActiveRecord::Base has_many :group_parameters, :dependent => :destroy, :foreign_key => :reference_id accepts_nested_attributes_for :group_parameters, :reject_if => lambda { |a| a[:value].blank? }, :allow_destroy => true has_many :hosts - before_destroy Ensure_not_used_by.new(:hosts) + before_destroy EnsureNotUsedBy.new(:hosts) has_many :config_templates, :through => :template_combinations has_many :template_combinations before_save :serialize_vm_attributes + after_find :deserialize_vm_attributes default_scope :order => 'LOWER(hostgroups.name)' @@ -55,7 +56,7 @@ def to_param end def as_json(options={}) - super({:only => [:name, :subnet_id, :operatingsystem_id, :domain_id, :id], :methods => [:label, :classes, :parameters].concat(Vm::PROPERTIES), :include => [:environment]}.merge(options)) + super({:only => [:name, :subnet_id, :operatingsystem_id, :domain_id, :id], :methods => [:label, :classes, :parameters].concat(Vm::PROPERTIES), :include => [:environment]}) end def hostgroup @@ -110,10 +111,6 @@ def vm_defaults=(v={}) write_attribute :vm_defaults, v.to_yaml end - def after_find - deserialize_vm_attributes - end - private def serialize_vm_attributes diff --git a/app/models/hypervisor.rb b/app/models/hypervisor.rb index a57fa8225d6..ca3bf2538a8 100644 --- a/app/models/hypervisor.rb +++ b/app/models/hypervisor.rb @@ -71,7 +71,7 @@ def disconnect def try_to_connect connect rescue => e - errors.add_to_base "Unable to connect to Hypervisor: #{e}" + errors.add :base, "Unable to connect to Hypervisor: #{e}" false ensure disconnect diff --git a/app/models/lookup_key.rb b/app/models/lookup_key.rb index 83b9f1c37cb..0819a070f2b 100644 --- a/app/models/lookup_key.rb +++ b/app/models/lookup_key.rb @@ -74,7 +74,7 @@ def attr_to_value host, element return host.host_params[element] if host.host_params.include?(element) # fact attribute if fn = host.fact_names.first(:conditions => {:name => element}) - return FactValue.first(:conditions => {:host_id => host.id, :fact_name_id => fn.id}).value + return FactValue.where(:host_id => host.id, :fact_name_id => fn.id).first.value end end diff --git a/app/models/lookup_value.rb b/app/models/lookup_value.rb index a4f50da861e..ff3fb77996d 100644 --- a/app/models/lookup_value.rb +++ b/app/models/lookup_value.rb @@ -7,7 +7,7 @@ class LookupValue < ActiveRecord::Base validate :validate_range, :validate_list, :validate_regexp, :validate_match before_validation :sanitize_match - named_scope :default, :conditions => { :match => "default" }, :limit => 1 + scope :default, :conditions => { :match => "default" }, :limit => 1 default_scope :order => 'LOWER(lookup_values.value)' diff --git a/app/models/medium.rb b/app/models/medium.rb index 9a94c7a4bda..6f2ca8ad93a 100644 --- a/app/models/medium.rb +++ b/app/models/medium.rb @@ -17,11 +17,12 @@ class Medium < ActiveRecord::Base :if => Proc.new { |m| m.respond_to? :media_path } alias_attribute :os, :operatingsystem - before_destroy Ensure_not_used_by.new(:hosts) + before_destroy EnsureNotUsedBy.new(:hosts) default_scope :order => 'LOWER(media.name)' scoped_search :on => [:name, :path], :complete_value => :true def as_json(options={}) + options ||= {} super({:only => [:name, :id]}.merge(options)) end diff --git a/app/models/model.rb b/app/models/model.rb index b1253c7a78f..7f8af64c61c 100644 --- a/app/models/model.rb +++ b/app/models/model.rb @@ -1,7 +1,7 @@ class Model < ActiveRecord::Base include Authorization has_many :hosts - before_destroy Ensure_not_used_by.new(:hosts) + before_destroy EnsureNotUsedBy.new(:hosts) validates_uniqueness_of :name validates_presence_of :name default_scope :order => 'LOWER(models.name)' diff --git a/app/models/operatingsystem.rb b/app/models/operatingsystem.rb index 2e9fdeee600..def4c9d2a08 100644 --- a/app/models/operatingsystem.rb +++ b/app/models/operatingsystem.rb @@ -23,9 +23,9 @@ class Operatingsystem < ActiveRecord::Base before_validation :downcase_release_name #TODO: add validation for name and major uniqueness - before_destroy Ensure_not_used_by.new(:hosts) + before_destroy EnsureNotUsedBy.new(:hosts) before_save :deduce_family - acts_as_audited + #acts_as_audited default_scope :order => 'LOWER(operatingsystems.name)' scoped_search :on => :name, :complete_value => :true diff --git a/app/models/orchestration.rb b/app/models/orchestration.rb index 192b4db61d9..682567c7ce2 100644 --- a/app/models/orchestration.rb +++ b/app/models/orchestration.rb @@ -42,7 +42,7 @@ def rollback # log and add to errors def failure msg, backtrace=nil logger.warn(backtrace ? msg + backtrace.join("\n") : msg) - errors.add_to_base msg + errors.add :base, msg false end @@ -51,7 +51,7 @@ def failure msg, backtrace=nil # we override this method in order to include checking the # after validation callbacks status, as rails by default does # not care about their return status. - def valid? + def valid?(context = nil) super errors.empty? end diff --git a/app/models/orchestration/tftp.rb b/app/models/orchestration/tftp.rb index 5203bcd7a16..9c65ac80979 100644 --- a/app/models/orchestration/tftp.rb +++ b/app/models/orchestration/tftp.rb @@ -7,7 +7,7 @@ def self.included(base) before_destroy :queue_tftp_destroy # required for pxe template url helpers - include ActionController::UrlWriter + include Rails.application.routes.url_helpers end end diff --git a/app/models/os_parameter.rb b/app/models/os_parameter.rb index 92b3e421b86..441c17d5c7e 100644 --- a/app/models/os_parameter.rb +++ b/app/models/os_parameter.rb @@ -1,6 +1,6 @@ class OsParameter < Parameter belongs_to :operatingsystem, :foreign_key => :reference_id - acts_as_audited :except => [:priority], :parent => :operatingsystem + acts_as_audited :except => [:priority], :associated_with => :operatingsystem validates_uniqueness_of :name, :scope => :reference_id private @@ -9,7 +9,7 @@ def enforce_permissions operation return true if operation == "edit" and new_record? return true if User.current.allowed_to?("#{operation}_operatingsystems".to_sym) - errors.add_to_base "You do not have permission to #{operation} this Operating System parameter" + errors.add :base, "You do not have permission to #{operation} this Operating System parameter" false end diff --git a/app/models/parameter.rb b/app/models/parameter.rb index 7d0c7e61a30..d375c79a5d0 100644 --- a/app/models/parameter.rb +++ b/app/models/parameter.rb @@ -5,22 +5,24 @@ class Parameter < ActiveRecord::Base validates_presence_of :name, :value validates_format_of :name, :value, :with => /^.*\S$/, :message => "can't be blank or contain trailing white space" - validates_presence_of :reference_id, :message => "parameters require an associated domain, host or hostgroup", :unless => 'nested or self.is_a? CommonParameter' + validates_presence_of :reference_id, :message => "parameters require an associated domain, host or hostgroup", :unless => Proc.new {|p| p.nested or p.is_a? CommonParameter} attr_accessor :nested + after_initialize :set_priority PRIORITY = {:common_parameter => 0, :domain_parameter => 1, :os_parameter => 2, :group_parameter => 3 , :host_parameter => 4} - def after_initialize - t = read_attribute(:type) - self.priority = PRIORITY[t.to_s.underscore.to_sym] unless t.blank? - end - def self.reassign_priorities # priorities will be reassigned because of after_initialize find_in_batches do |params| params.each { |param| param.update_attribute(:priority, param.priority) } end end + private + + def set_priority + t = read_attribute(:type) + self.priority = PRIORITY[t.to_s.underscore.to_sym] unless t.blank? + end end diff --git a/app/models/ptable.rb b/app/models/ptable.rb index 29ce13675e0..98a616e6696 100644 --- a/app/models/ptable.rb +++ b/app/models/ptable.rb @@ -6,7 +6,7 @@ class Ptable < ActiveRecord::Base include Authorization has_many :hosts has_and_belongs_to_many :operatingsystems - before_destroy Ensure_not_used_by.new(:hosts) + before_destroy EnsureNotUsedBy.new(:hosts) validates_uniqueness_of :name validates_uniqueness_of :layout validates_presence_of :layout @@ -17,6 +17,7 @@ class Ptable < ActiveRecord::Base scoped_search :on => :layout, :complete_value => false def as_json(options={}) + options ||= {} super({:only => [:name, :id]}.merge(options)) end diff --git a/app/models/puppetclass.rb b/app/models/puppetclass.rb index aa65112bf21..4f01bd28f7c 100644 --- a/app/models/puppetclass.rb +++ b/app/models/puppetclass.rb @@ -15,8 +15,8 @@ class Puppetclass < ActiveRecord::Base validates_format_of :name, :with => /\A(\S+\s?)+\Z/, :message => "can't be blank or contain white spaces." acts_as_audited - before_destroy Ensure_not_used_by.new(:hosts) - before_destroy Ensure_not_used_by.new(:hostgroups) + before_destroy EnsureNotUsedBy.new(:hosts) + before_destroy EnsureNotUsedBy.new(:hostgroups) default_scope :order => 'LOWER(puppetclasses.name)' scoped_search :on => :name, :complete_value => :true @@ -148,13 +148,13 @@ def self.rdoc root # If your 'live' manifests and modules can be parsed by puppetdoc # then you do not need to do this step. (Unfortunately some sites have circular # symlinks which have to be removed.) - # If the executable RAILS_ROOT/script/rdoc_prepare_script exists then it is run + # If the executable Rails,root/script/rdoc_prepare_script exists then it is run # and passed a list of all directory paths in all environments. # It should return the directory into which it has copied the cleaned modules" def self.prepare_rdoc root debug, verbose = false, false - prepare_script = Pathname.new(RAILS_ROOT) + "script/rdoc_prepare_script.rb" + prepare_script = Pathname.new(Rails.root) + "script/rdoc_prepare_script.rb" if prepare_script.executable? dirs = Environment.puppetEnvs.values.join(":").split(":").uniq.sort.join(" ") puts "Running #{prepare_script} #{dirs}" if debug @@ -170,7 +170,7 @@ def self.prepare_rdoc root end def as_json(options={}) - super({:only => [:name, :id], :methods => [:lookup_keys]}.merge(options)) + super({:only => [:name, :id], :methods => [:lookup_keys]}) end def self.search_by_host(key, operator, value) diff --git a/app/models/redhat.rb b/app/models/redhat.rb index 640068cc0d1..b6fd00c8a29 100644 --- a/app/models/redhat.rb +++ b/app/models/redhat.rb @@ -5,14 +5,14 @@ class Redhat < Operatingsystem # outputs kickstart installation medium based on the medium type (NFS or URL) # it also convert the $arch string to the current host architecture def mediumpath host - uri = medium_uri(host) - server = uri.select(:host, :port).compact.join(':') - dir = uri.select(:path, :query).compact.join('?') unless uri.scheme == 'ftp' + uri = medium_uri(host) case uri.scheme when 'http', 'https', 'ftp' - "url --url #{uri.to_s}" + "url --url #{uri}" else + server = uri.select(:host, :port).compact.join(':') + dir = uri.select(:path, :query).compact.join('?') "nfs --server #{server} --dir #{dir}" end end diff --git a/app/models/report.rb b/app/models/report.rb index 6c8d9a6099b..f5cdb418081 100644 --- a/app/models/report.rb +++ b/app/models/report.rb @@ -22,10 +22,10 @@ class Report < ActiveRecord::Base scoped_search :on => :status, :offset => METRIC.index("skipped"), :word_size => BIT_NUM, :rename => :skipped # returns recent reports - named_scope :recent, lambda { |*args| {:conditions => ["reported_at > ?", (args.first || 1.day.ago)]} } + scope :recent, lambda { |*args| {:conditions => ["reported_at > ?", (args.first || 1.day.ago)]} } # with_changes - named_scope :interesting, {:conditions => "status != 0"} + scope :interesting, {:conditions => "status != 0"} # a method that save the report values (e.g. values from METRIC) # it is not supported to edit status values after it has been written once. @@ -87,7 +87,7 @@ def self.import(yaml) # 1. It might be auto imported, therefore might not be valid (e.g. missing partition table etc) # 2. We want this to be fast and light on the db. # at this point, the report is important, not as much of the host - host.save_with_validation(false) + host.save(:validate => false) # and save our report r = self.create!(:host => host, :reported_at => report.time.utc, :status => st, :metrics => self.m2h(report.metrics)) @@ -196,7 +196,7 @@ def inspect_report logger.warn "#{report.host} is disabled - skipping." and return if host.disabled? logger.debug "error detected, checking if we need to send an email alert" - HostMailer.deliver_error_state(self) if Setting[:failed_report_email_notification] + HostMailer.error_state(self).deliver if Setting[:failed_report_email_notification] # add here more actions - e.g. snmp alert etc end rescue => e @@ -208,6 +208,14 @@ def no_report false end + def as_json(options={}) + {:report => + { :reported_at => reported_at, :status => status, + :host => host.name, :metrics => metrics, :logs => logs.all(:include => [:source, :message]), + :id => id, :summary => summaryStatus + }, + } + end private # Converts metrics form Puppet report into a hash @@ -300,7 +308,7 @@ def enforce_permissions operation return true if operation == "create" return true if operation == "destroy" and User.current.allowed_to?(:destroy_reports) - errors.add_to_base "You do not have permission to #{operation} this report" + errors.add :base, "You do not have permission to #{operation} this report" false end @@ -310,15 +318,6 @@ def summaryStatus return "Success" end - def as_json(options={}) - {:report => - { :reported_at => reported_at, :status => status, - :host => host.name, :metrics => metrics, :logs => logs.all(:include => [:source, :message]), - :id => id, :summary => summaryStatus - }, - } - end - # puppet report status table column name def self.report_status "status" diff --git a/app/models/report_common.rb b/app/models/report_common.rb index ae4de1cf388..b5fa4319562 100644 --- a/app/models/report_common.rb +++ b/app/models/report_common.rb @@ -8,7 +8,7 @@ def self.included(base) # search for a metric - e.g.: # Report.with("failed") --> all reports which have a failed counter > 0 # Report.with("failed",20) --> all reports which have a failed counter > 20 - named_scope :with, lambda { |*arg| { + scope :with, lambda { |*arg| { :conditions => "(#{report_status} >> #{BIT_NUM*METRIC.index(arg[0])} & #{MAX}) > #{arg[1] || 0}"} } end diff --git a/app/models/role.rb b/app/models/role.rb index e9b1903797b..1cc7aff585e 100644 --- a/app/models/role.rb +++ b/app/models/role.rb @@ -20,8 +20,8 @@ class Role < ActiveRecord::Base BUILTIN_DEFAULT_USER = 1 BUILTIN_ANONYMOUS = 2 - named_scope :givable, { :conditions => "builtin = 0", :order => 'name' } - named_scope :builtin, lambda { |*args| + scope :givable, { :conditions => "builtin = 0", :order => 'name' } + scope :builtin, lambda { |*args| compare = 'not' if args.first == true { :conditions => "#{compare} builtin = 0" } } @@ -110,13 +110,13 @@ def setable_permissions # Find all the roles that can be given to a user def self.find_all_givable - find(:all, :conditions => {:builtin => 0}, :order => 'name') + all(:conditions => {:builtin => 0}, :order => 'name') end # Return the builtin 'default user' role. If the role doesn't exist, # it will be created on the fly. def self.default_user - default_user_role = find(:first, :conditions => {:builtin => BUILTIN_DEFAULT_USER}) + default_user_role = first(:conditions => {:builtin => BUILTIN_DEFAULT_USER}) if default_user_role.nil? default_user_role = create(:name => 'Default user') do |role| role.builtin = BUILTIN_DEFAULT_USER @@ -129,7 +129,7 @@ def self.default_user # Return the builtin 'anonymous' role. If the role doesn't exist, # it will be created on the fly. def self.anonymous - anonymous_role = find(:first, :conditions => {:builtin => BUILTIN_ANONYMOUS}) + anonymous_role = first(:conditions => {:builtin => BUILTIN_ANONYMOUS}) if anonymous_role.nil? anonymous_role = create(:name => 'Anonymous') do |role| role.builtin = BUILTIN_ANONYMOUS @@ -149,8 +149,8 @@ def allowed_actions end def check_deletable - errors.add_to_base "Role is in use" if users.any? - errors.add_to_base "Can't delete builtin role" if builtin? + errors.add :base, "Role is in use" if users.any? + errors.add :base, "Can't delete builtin role" if builtin? errors.empty? end end diff --git a/app/models/setting.rb b/app/models/setting.rb index d6b1a32a86a..99e1e8bc931 100644 --- a/app/models/setting.rb +++ b/app/models/setting.rb @@ -21,7 +21,7 @@ class Setting < ActiveRecord::Base scoped_search :on => :category, :complete_value => :true scoped_search :on => :description, :complete_value => :true - def self.per_page; 20; end # can't use our own settings + def self.per_page; 20 end # can't use our own settings def self.[](name) if record = first(:conditions => {:name => name.to_s}) diff --git a/app/models/smart_proxies/puppet_ca.rb b/app/models/smart_proxies/puppet_ca.rb index bca9db41838..3f880e7172c 100644 --- a/app/models/smart_proxies/puppet_ca.rb +++ b/app/models/smart_proxies/puppet_ca.rb @@ -55,9 +55,9 @@ def destroy ProxyAPI::Puppetca.new({:url => proxy.url}).del_certificate name end - def to_param; name; end + def to_param; name end - def to_s; name; end + def to_s; name end def <=> other self.name <=> other.name diff --git a/app/models/smart_proxy.rb b/app/models/smart_proxy.rb index 8b060da8cf1..44b2a932bb0 100644 --- a/app/models/smart_proxy.rb +++ b/app/models/smart_proxy.rb @@ -16,7 +16,7 @@ class SmartProxy < ActiveRecord::Base # There should be no problem with associating features before the proxy is saved as the whole operation is in a transaction before_save :sanitize_url, :associate_features - before_destroy Ensure_not_used_by.new(:subnets, :domains, :hosts, :hostgroups) + before_destroy EnsureNotUsedBy.new(:subnets, :domains, :hosts, :hostgroups) default_scope :order => 'LOWER(smart_proxies.name)' @@ -56,13 +56,13 @@ def associate_features reason = false begin reply = ProxyAPI::Features.new(:url => url).features - self.features = reply.map{|f| name_map[f]} unless reply.empty? + self.features = reply.map{|f| name_map[f]} if reply.is_a?(Array) and reply.any? rescue => e reason = e.message end unless reply - errors.add_to_base "Unable to communicate with the proxy: #{reason}" - errors.add_to_base "Please check the proxy is configured and running on the host before saving." + errors.add :base, "Unable to communicate with the proxy: #{reason}" + errors.add :base, "Please check the proxy is configured and running on the host before saving." end !reply.empty? end diff --git a/app/models/subnet.rb b/app/models/subnet.rb index e474a821d3b..8e899c70bc0 100644 --- a/app/models/subnet.rb +++ b/app/models/subnet.rb @@ -14,7 +14,7 @@ class Subnet < ActiveRecord::Base validates_uniqueness_of :name, :scope => :domain_id default_scope :order => 'priority' - before_destroy Ensure_not_used_by.new(:hosts, :sps) + before_destroy EnsureNotUsedBy.new(:hosts, :sps) scoped_search :on => [:name, :network, :mask], :complete_value => true scoped_search :in => :domain, :on => :name, :rename => :domain, :complete_value => true diff --git a/app/models/user.rb b/app/models/user.rb index af2cad1f5a4..b759cb98511 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -33,7 +33,7 @@ class User < ActiveRecord::Base validates_format_of :mail, :with => /^([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})$/i, :allow_nil => true validates_length_of :mail, :maximum => 60, :allow_nil => true - before_destroy Ensure_not_used_by.new(:hosts), :ensure_admin_is_not_deleted + before_destroy EnsureNotUsedBy.new(:hosts), :ensure_admin_is_not_deleted validate :name_used_in_a_usergroup before_validation :prepare_password after_destroy Proc.new {|user| user.domains.clear; user.hostgroups.clear} @@ -79,7 +79,6 @@ def self.try_to_login(login, password) # Make sure no one can sign in with an empty password return nil if password.to_s.empty? - user = nil # user is already in local database if user = find_by_login(login) # user has an authentication method and the authentication was successful @@ -187,15 +186,15 @@ def self.try_to_auto_create_user(login, password) user = nil end end + user end - user end protected def name_used_in_a_usergroup if Usergroup.all.map(&:name).include?(self.login) - errors.add_to_base "A usergroup already exists with this name" + errors.add :base, "A usergroup already exists with this name" end end @@ -204,7 +203,7 @@ def name_used_in_a_usergroup # admin account automatically def ensure_admin_is_not_deleted if login == "admin" - errors.add_to_base "Can't delete internal admin account" + errors.add :base, "Can't delete internal admin account" logger.warn "Unable to delete internal admin account" return false end diff --git a/app/models/user_fact.rb b/app/models/user_fact.rb index 3dbfb878b1a..62d048a735b 100644 --- a/app/models/user_fact.rb +++ b/app/models/user_fact.rb @@ -1,22 +1,26 @@ +require 'puppet/rails' + class UserFact < ActiveRecord::Base belongs_to :user - belongs_to :fact_name + belongs_to :fact_name, :class_name => "Puppet::Rails::FactName" validates_inclusion_of :andor, :in => %w{and or} validates_inclusion_of :operator, :in => %w{= != > >= < <= } validates_presence_of :fact_name validates_presence_of :criteria validates_presence_of :user - - def initialize *args - super *args - operator = "=" if operator.empty? - andor = "or" if andor.empty? - end + before_validation :set_defaults def to_s n = user.try(:name) || "Unknown user" fn = fact_name.try(:name) || "Unknown fact" "#{n}:#{fn}:#{criteria.empty? ? "Empty" : criteria}:#{operator}:#{andor}" end + + private + def set_defaults + self.operator ||= "=" + self.andor ||= "or" + end + end diff --git a/app/models/usergroup.rb b/app/models/usergroup.rb index f35efdfe79c..a5b28597b2b 100644 --- a/app/models/usergroup.rb +++ b/app/models/usergroup.rb @@ -1,3 +1,4 @@ +require 'user' class Usergroup < ActiveRecord::Base include Authorization has_many_polymorphs :members, :from => [:usergroups, :users ], :as => :member, @@ -5,11 +6,12 @@ class Usergroup < ActiveRecord::Base has_many :hosts, :as => :owner validates_uniqueness_of :name - before_destroy Ensure_not_used_by.new(:hosts, :usergroups) + before_destroy EnsureNotUsedBy.new(:hosts, :usergroups) # The text item to see in a select dropdown menu alias_attribute :select_title, :to_s default_scope :order => 'LOWER(usergroups.name)' + validate :ensure_uniq_name # This methods retrieves all user addresses in a usergroup # Returns: Array of strings representing the user's email addresses @@ -46,14 +48,12 @@ def retrieve_users_and_groups(group_list, user_list) user_list.concat users end - def validate - if User.all.map(&:login).include?(self.name) - errors.add :name, "is already used by a user account" - end + def ensure_uniq_name + errors.add :name, "is already used by a user account" if User.where(:login => name).first end def as_json(options={}) - super({:only => [:name, :id]}.merge(options)) + super({:only => [:name, :id]}) end end diff --git a/app/views/architectures/_form.html.erb b/app/views/architectures/_form.html.erb index 96752ee975b..ccd744de643 100644 --- a/app/views/architectures/_form.html.erb +++ b/app/views/architectures/_form.html.erb @@ -1,4 +1,4 @@ -<% form_for @architecture do |f| %> +<%= form_for @architecture do |f| %> <%= base_errors_for @architecture %> <%= text_f f, :name %> <%= multiple_checkboxes(f, :operatingsystems, @architecture, Operatingsystem, :label => "Operating Systems") %> diff --git a/app/views/audits/_search_line.html.erb b/app/views/audits/_search_line.html.erb deleted file mode 100644 index 93fbb15c1e2..00000000000 --- a/app/views/audits/_search_line.html.erb +++ /dev/null @@ -1,13 +0,0 @@ -<% form_for @search do |f|-%> -
    - <%= f.label :auditable_type_eq, "Type" %> - <%= f.select :auditable_type, options_for_select(Audit.all(:select => "DISTINCT auditable_type").map{|a| auditable_type a}.sort), :include_blank => true %> -
    -
    - <%= f.label :action_eq, "Action" %> - <%= f.select :action_eq, options_for_select(Audit.all(:select => "DISTINCT action").map(&:action)), :include_blank => true %> - <%= f.label :user_id_eq, "User" %> - <%= f.collection_select :user_id_eq, Audit.all(:select => "DISTINCT user_id,user_type, username"), :user_id, :user %> - <%= f.submit "Go" %> Save as tab: <%= text_field_tag :tab_name, "", :size => 10 %> -
    -<% end %> diff --git a/app/views/audits/index.html.erb b/app/views/audits/index.html.erb index 1518b674ab6..66096610f2e 100644 --- a/app/views/audits/index.html.erb +++ b/app/views/audits/index.html.erb @@ -13,13 +13,13 @@ <% for audit in @audits %> "> - <%=h auditable_type(audit) %> - <%=h audit_title(audit) %> - <%=h audit_parent(audit) %> - <%=h audit.action %> - <%=h audit.created_at.to_s(:long) %> - <%=h changes_column audit.changes %> - <%=h audit.user_as_string %> + <%= association_type(audit) %> + <%= audit_title(audit) %> + <%= audit_parent(audit) %> + <%= audit.action %> + <%= audit.created_at.to_s(:long) %> + <%= changes_column audit.changes %> + <%= audit.user_as_string %> <%= link_to "Details", audit %> <% end %> diff --git a/app/views/audits/show.html.erb b/app/views/audits/show.html.erb index cba48594ecb..9dd73479722 100644 --- a/app/views/audits/show.html.erb +++ b/app/views/audits/show.html.erb @@ -1,4 +1,4 @@ -<% title "#{@audit.action.camelize} #{auditable_type @audit} #{audit_title @audit}" %> +<% title "#{@audit.action.camelize} #{association_type @audit} #{audit_title @audit}" %> @@ -7,11 +7,11 @@ - <% @audit.changes.each do |name,change| -%> + <% @audit.audited_changes.each do |name,change| -%> <% next if change.nil? or change.to_s.empty? -%> "> - - + + <%# TODO: Refactor this whole code away from here -%> <% record = true if name =~ /.*_id$/ -%> <% if change.is_a?(Array) %> @@ -21,7 +21,7 @@ <% end -%> <% else -%> <% change = id_to_label(name,change) if record -%> - <%= change_order(@audit.action, change).map {|v| ""} -%> + <%= change_order(@audit.action, change).map{|v| ""}.join.html_safe -%> <% end -%> <% end -%> diff --git a/app/views/auth_source_ldaps/_form.html.erb b/app/views/auth_source_ldaps/_form.html.erb index 072af2c1e59..34d66843fff 100644 --- a/app/views/auth_source_ldaps/_form.html.erb +++ b/app/views/auth_source_ldaps/_form.html.erb @@ -1,6 +1,6 @@ <% title_actions link_to("Documentation", "http://theforeman.org/projects/foreman/wiki/LDAP_Authentication", :rel => "external") %> -<% form_for @auth_source_ldap do |f| %> +<%= form_for @auth_source_ldap do |f| %> <%= base_errors_for @auth_source_ldap %> <%= text_f f, :name %> @@ -13,7 +13,7 @@ <%= checkbox_f f, :onthefly_register, :label => "On-the-fly user creation", :onchange => "$('#on_the_fly_attrs').toggle($('#auth_source_ldap_onthefly_register').attr('checked'))", :help_inline => "LDAP user will have his Foreman account automatically created the first time he logs into Foreman" %>
    > - <% field_set_tag("Attributes for on the fly user creation") do %> + <%= field_set_tag("Attributes for on the fly user creation") do %> <%= text_f f, :attr_login, :help_inline => "e.g. uid" %> <%= text_f f, :attr_firstname, :help_inline => "e.g. givenName" %> <%= text_f f, :attr_lastname, :help_inline => "e.g. sn" %> diff --git a/app/views/bookmarks/_form.html.erb b/app/views/bookmarks/_form.html.erb index eaedd438a7b..0ca4dc2de0d 100644 --- a/app/views/bookmarks/_form.html.erb +++ b/app/views/bookmarks/_form.html.erb @@ -1,4 +1,4 @@ -<% form_for @bookmark do |f| %> +<%= form_for @bookmark do |f| %> <%= base_errors_for @bookmark %> <%= text_f f, :name, :value => params[:query].to_s.strip.split(/\s|=|!|~|>| <%= textarea_f f, :query, :value => params[:query], :class => "xlarge" , :rows=> '3' %> diff --git a/app/views/common/_domain.html.erb b/app/views/common/_domain.html.erb index 8cff6c61d2c..00efc23b1c4 100644 --- a/app/views/common/_domain.html.erb +++ b/app/views/common/_domain.html.erb @@ -1,13 +1,8 @@ -<% fields_for item do |f| %> +<%= fields_for item do |f| %> <%= select_f f, :subnet_id, domain_subnets, :id, :title, { :include_blank => domain_subnets.any? ? true : "No subnets"}, - { :disabled => domain_subnets.empty? ? true : false, - :help_inline => image_tag("spinner.gif", :id => "indicator", :style => "display:none") } + { :disabled => domain_subnets.empty?, + :help_inline => image_tag("spinner.gif", :id => "subnet_indicator", :class => "hide"), + :onchange => 'subnet_selected(this);'} %> - <%= observe_field(:host_subnet_id, - :url => { :controller => "subnets", :action => "freeip" }, - :method => :get, :loading => "$('#indicator').show()", - :complete => "$('#indicator').hide()", - :with => :subnet_id) if type.to_s == "host" - %> <% end -%> diff --git a/app/views/common/_domain_subnet.html.erb b/app/views/common/_domain_subnet.html.erb index 3f9148b25ce..34904b08378 100644 --- a/app/views/common/_domain_subnet.html.erb +++ b/app/views/common/_domain_subnet.html.erb @@ -1,13 +1,7 @@ -<% fields_for item do |f| %> - <%= select_f f, :domain_id, accessible_domains, :id, :to_label, :include_blank => true %> +<%= fields_for item do |f| %> + <%= select_f f, :domain_id, accessible_domains, :id, :to_label, {:include_blank => true}, {:onchange => 'domain_selected(this);'} %> - + <%= render 'common/domain', :item => item %> - - <%= observe_field("#{type}_domain_id", - :url => { :action => :domain_selected }, - :update => "#{type}_subnet", - :with => :domain_id) - %> <% end -%> diff --git a/app/views/common/_edit_habtm.erb b/app/views/common/_edit_habtm.erb index 8b32b6d4799..288df9e9769 100644 --- a/app/views/common/_edit_habtm.erb +++ b/app/views/common/_edit_habtm.erb @@ -4,7 +4,7 @@ <% else -%> <% associations.sort{|a,b| a.to_s <=> b.to_s}.each do |association| -%>
  • - <% content_tag_for :label, association do %> + <%= content_tag_for :label, association do %> <%= check_box_tag( "#{klass.class.table_name.singularize}[#{association.class.to_s.downcase}_ids][]", association.id, klass.send(association.class.table_name).map(&:id).include?(association.id)) diff --git a/app/views/common/_hypervisor.html.erb b/app/views/common/_hypervisor.html.erb index 16500405d0c..eddea1f7db3 100644 --- a/app/views/common/_hypervisor.html.erb +++ b/app/views/common/_hypervisor.html.erb @@ -1,8 +1,8 @@ -<% fields_for item do |f| %> +<%= fields_for item do |f| %>
    <%= selectable_f f, :hypervisor_id, select_hypervisor(item), { :include_blank => "Bare Metal" }, - { :label => "Provision on", :help_inline => image_tag("spinner.gif", :id => "vm_indicator", :style => "display:none") } + { :label => "Provision on", :help_inline => image_tag("spinner.gif", :id => "vm_indicator", :class => "hide"),:onchange => 'hypervisor_selected(this);' } %> <% if @hypervisor ||= item.try(:hypervisor) -%> @@ -16,15 +16,8 @@ <% else -%> <%= selectable_f f, :interface, interfaces %> <% end -%> - <% if type.to_s == "host" -%> - <%= checkbox_f f, :powerup, :help_inline => "Power up this instance", :checked => true, :label => "Start?" %> - <% end -%> + <%= checkbox_f f, :powerup, :help_inline => "Power up this instance", :checked => true, :label => "Start?" %> <% end -%>
    <% end -%> -<%= observe_field("#{type}_hypervisor_id", - :url => { :action => :hypervisor_selected }, - :loading => "$('#vm_indicator').show()", - :complete => "$('#vm_indicator').hide()", - :with => "#{type}_hypervisor_id") -%> + diff --git a/app/views/common/_notice.erb b/app/views/common/_notice.erb index 4ae67e197b8..d1b14b67c22 100644 --- a/app/views/common/_notice.erb +++ b/app/views/common/_notice.erb @@ -1,5 +1,5 @@
    - <% field_set_tag "Notifications" do %> + <%= field_set_tag "Notifications" do %>
  • Old New
    <%= h name.humanize %><%= h audit_parent @audit %><%= name.humanize %><%= audit_parent @audit %>#{h v}#{v}
    <% for notice in @notices-%> diff --git a/app/views/common/_puppetclasses_or_envs_changed.html.erb b/app/views/common/_puppetclasses_or_envs_changed.html.erb index 2d49a42130f..e4e52b5a297 100644 --- a/app/views/common/_puppetclasses_or_envs_changed.html.erb +++ b/app/views/common/_puppetclasses_or_envs_changed.html.erb @@ -1,21 +1,21 @@ <% title "Changed environments and puppet classes" -%> -<% form_tag '/environments/obsolete_and_new' do -%> +<%= form_tag "/#{controller_path}/obsolete_and_new" do -%>
    Accept these environment changes found in puppet?
    <% for kind in ["new", "obsolete"] -%> - <% unless (envs = @changed.send(:[], kind)).empty? -%> + <% unless (envs = @changed[kind]).empty? -%> <% for env in envs.keys.sort -%> " > - <% pcs = @changed.send(:[], kind)[env] -%> + <% pcs = @changed[kind][env] -%> @@ -26,6 +26,7 @@
    EnvironmentOperationClasses
    - <%= check_box_tag "changed[#{kind}][#{env}]", @changed.send(:[], kind)[env].to_json, true %> + <%= check_box_tag "changed[#{kind}][#{env}]", @changed[kind][env].to_json, true %> <%= env -%> <%= kind == "new" ? "Add:" : "Remove:" -%> <%= class_update_text pcs, env %>
    - <%= submit_tag "Update" -%> or <%= link_to "Cancel", environments_path -%> + <%= link_to "Cancel","/" + controller_path, :class => "btn" %> + <%= submit_tag "Update", :class => "btn primary" %>
    <% end -%> diff --git a/app/views/common/_searchbar.erb b/app/views/common/_searchbar.erb index b0c1de67d17..b5718f3955f 100644 --- a/app/views/common/_searchbar.erb +++ b/app/views/common/_searchbar.erb @@ -1,5 +1,5 @@ -<% form_tag eval("#{controller_name}_path"), :method => "get" do %> - <%= auto_complete_search(:search, params[:search], {:placeholder => "Filter ..."},{ :delay => 100, :min_length => -1 }) %> +<%= form_tag eval("#{controller_name}_path"), :method => "get" do %> + <%= auto_complete_search(:search, params[:search].try(:squeeze," "), {:placeholder => "Filter ..."},{ :delay => 100, :min_length => -1 }).html_safe %> <%= display_link_if_authorized image_tag('bookmark.png', :class => "bookmark", :alt => "Bookmark this search"), {:controller => :bookmarks, :action => :new, :kontroller => controller_name}, {:'data-controls-modal'=>"bookmarks-modal", :"data-backdrop"=>"static", :id => "bookmark", :class => "btn small", :title => "Bookmark this search"} %> <%= link_to_function 'Search', "$(this).parent().submit()" , {:id => 'submit_search', :class => 'btn small' } %> <% end -%> diff --git a/app/views/common/os_selection/_architecture.html.erb b/app/views/common/os_selection/_architecture.html.erb index d123c3fdff4..c5dc206cc88 100644 --- a/app/views/common/os_selection/_architecture.html.erb +++ b/app/views/common/os_selection/_architecture.html.erb @@ -1,14 +1,9 @@ -<% fields_for item do |f| %> +<%= fields_for item do |f| %> <%= select_f f, :operatingsystem_id, arch_oss, :id, :to_label, {:selected => item.operatingsystem_id, :include_blank => true}, {:id => type + "_operatingsystem_id", :name => type + "[operatingsystem_id]", :label => "Operating Systems", - :disabled => arch_oss.empty? ? true : false } - %> - - <%= observe_field type + "_operatingsystem_id", - :url => { :action => :os_selected }, - :update => :operatingsystem_select, - :with => :operatingsystem_id + :disabled => arch_oss.empty? ? true : false, + :onchange => 'os_selected(this);'} %> <% end -%> diff --git a/app/views/common/os_selection/_image_details.html.erb b/app/views/common/os_selection/_image_details.html.erb index 6adec93a43a..c62783b5183 100644 --- a/app/views/common/os_selection/_image_details.html.erb +++ b/app/views/common/os_selection/_image_details.html.erb @@ -1,4 +1,4 @@ -<% fields_for item do |f| %> +<%= fields_for item do |f| %> <%= checkbox_f f, :use_image, :id => type + "_cb_use_image", :label => "Build from img?" -%> <%= hidden_field_tag type + "[use_image]", 0 %> diff --git a/app/views/common/os_selection/_initial.html.erb b/app/views/common/os_selection/_initial.html.erb index 09e8565d02e..21eeea0facc 100644 --- a/app/views/common/os_selection/_initial.html.erb +++ b/app/views/common/os_selection/_initial.html.erb @@ -1,19 +1,14 @@ -<% fields_for item do |f| %> - <%= select_f f, :architecture_id, Architecture.all, :id, :to_label, :include_blank => true %> +<%= fields_for item do |f| %> + <%= select_f f, :architecture_id, Architecture.all, :id, :to_label, {:include_blank => true}, {:onchange => 'architecture_selected(this);'} %> - + <%= render 'common/os_selection/architecture', :item => item %> - + <%= render 'common/os_selection/operatingsystem', :item => item %> -<% end -%> - -<%= observe_field(type + "_architecture_id", - :url => { :action => :architecture_selected}, - :update => :architecture_select, :id => item.id, - :with => :architecture_id) %> +<% end -%> \ No newline at end of file diff --git a/app/views/common/os_selection/_operatingsystem.html.erb b/app/views/common/os_selection/_operatingsystem.html.erb index 1366f035007..752ecd908e7 100644 --- a/app/views/common/os_selection/_operatingsystem.html.erb +++ b/app/views/common/os_selection/_operatingsystem.html.erb @@ -1,4 +1,4 @@ -<% fields_for item do |f| %> +<%= fields_for item do |f| %> <%= select_f f, :medium_id, os_media, :id, :to_label, {:include_blank => os_media.size > 1, :selected => item.medium_id}, {:id => type + "_medium_id", :name => type + "[medium_id]", :label => "Media", :disabled => os_media.empty? } diff --git a/app/views/common_parameters/_form.html.erb b/app/views/common_parameters/_form.html.erb index cc893611015..a5a9dff70c2 100644 --- a/app/views/common_parameters/_form.html.erb +++ b/app/views/common_parameters/_form.html.erb @@ -1,4 +1,4 @@ -<% form_for @common_parameter do |f| %> +<%= form_for @common_parameter do |f| %> <%= base_errors_for @common_parameter %> <%= text_f f, :name %> <%= text_f f, :value, :class => "xxlarge" %> diff --git a/app/views/common_parameters/_parameters.erb b/app/views/common_parameters/_parameters.erb index 21fad5ef48a..2ef71ef5a10 100644 --- a/app/views/common_parameters/_parameters.erb +++ b/app/views/common_parameters/_parameters.erb @@ -1,5 +1,5 @@ -<% field_set_tag "Parameters", :id => "parameters", :title => parameters_title do -%> - <% f.fields_for type do |builder| -%> +<%= field_set_tag "Parameters", :id => "parameters", :title => parameters_title do -%> + <%= f.fields_for type do |builder| -%> <%= render "common_parameters/parameter", :f => builder %> <% end -%>

    <%= authorized_via_my_scope(params[:controller], params[:action]) ? link_to_add_fields("+", f, type, "common_parameters/parameter") : "Add a parameter" %>

    diff --git a/app/views/config_templates/_combinations.html.erb b/app/views/config_templates/_combinations.html.erb index 3480a651d05..80ff8c54761 100644 --- a/app/views/config_templates/_combinations.html.erb +++ b/app/views/config_templates/_combinations.html.erb @@ -1,5 +1,5 @@ -<% field_set_tag "Valid Host group and Environment Combinations", :id => "template_combination" do -%> - <% f.fields_for :template_combinations do |builder| -%> +<%= field_set_tag "Valid Host group and Environment Combinations", :id => "template_combination" do -%> + <%= f.fields_for :template_combinations do |builder| -%> <%= render 'combination', :f => builder %> <% end -%>

    <%= link_to_add_fields("+", f, :template_combinations, "combination") %>

    diff --git a/app/views/config_templates/_form.html.erb b/app/views/config_templates/_form.html.erb index 250965e1f2c..e500cf5a132 100644 --- a/app/views/config_templates/_form.html.erb +++ b/app/views/config_templates/_form.html.erb @@ -1,4 +1,4 @@ -<% form_for @config_template do |f| %> +<%= form_for @config_template do |f| %> <%= base_errors_for @config_template %> <%= text_f f, :name %> <%= checkbox_f f, :snippet, :onchange => "$('#kind_selector, #template_associations').toggle(!$('#config_template_snippet').attr('checked'))" %> diff --git a/app/views/dashboard/index.html.erb b/app/views/dashboard/index.html.erb index b76711c3c18..851acf23a2f 100644 --- a/app/views/dashboard/index.html.erb +++ b/app/views/dashboard/index.html.erb @@ -7,27 +7,27 @@ Data - <%= link_to 'Hosts that had performed modifications', active_hosts_path %> + <%= searchable_links 'Hosts that had performed modifications', "last_report > \"#{Setting[:puppet_interval] + 5} minutes ago\" and (status.applied > 0 or status.restarted > 0)" %> <%= @report[:active_hosts] %> - <%= link_to 'Hosts in Error State', errors_hosts_path %> + <%= searchable_links 'Hosts in Error State', "last_report > \"#{Setting[:puppet_interval] + 5} minutes ago\" and (status.failed > 0 or status.failed_restarts > 0)" %> <%= @report[:bad_hosts] %> - <%=link_to "Good Host Reports in the last #{Setting[:puppet_interval]} minutes", "hosts?search=last_report+>+'#{Setting[:puppet_interval]} minutes ago'+and+status.enabled+%3D+true+and+status.interesting++%3D+false"%> + <%=searchable_links "Good Host Reports in the last #{Setting[:puppet_interval]} minutes", "last_report > \"#{Setting[:puppet_interval]} minutes ago\" and status.enabled = true and status.interesting=false" %> <%= "#{@report[:good_hosts]} / #{@report[:total_hosts]}" %> hosts (<%= @report[:percentage] %>%) - <%= link_to 'Out Of Sync Hosts', out_of_sync_hosts_path %> + <%= searchable_links 'Out Of Sync Hosts', "last_report < \"#{Setting[:puppet_interval] + 5} minutes ago\" and status.enabled = true" %> <%= @report[:out_of_sync_hosts] %> - <%= link_to 'Hosts With No Reports', 'hosts?search=not+has+last_report' %> + <%= searchable_links 'Hosts With No Reports', "not has last_report" %> <%= @report[:reports_missing] %> - <%= link_to 'Hosts With Alerts Disabled', disabled_hosts_path %> + <%= searchable_links 'Hosts With Alerts Disabled', "status.enabled = false" %> <%= @report[:disabled_hosts] %> diff --git a/app/views/domains/_form.html.erb b/app/views/domains/_form.html.erb index fd23665c4fc..f0a993762ce 100644 --- a/app/views/domains/_form.html.erb +++ b/app/views/domains/_form.html.erb @@ -1,4 +1,4 @@ -<% form_for @domain do |f| %> +<%= form_for @domain do |f| %> <%= base_errors_for @domain %>
    • Primary
    • diff --git a/app/views/environments/_form.html.erb b/app/views/environments/_form.html.erb index e16dd796ade..22b8b2d2540 100644 --- a/app/views/environments/_form.html.erb +++ b/app/views/environments/_form.html.erb @@ -1,4 +1,4 @@ -<% form_for @environment do |f| %> +<%= form_for @environment do |f| %> <%= base_errors_for @environment %> <%= text_f f, :name %> <%= submit_or_cancel f %> diff --git a/app/views/environments/index.html.erb b/app/views/environments/index.html.erb index f8840693358..2b87d077e98 100644 --- a/app/views/environments/index.html.erb +++ b/app/views/environments/index.html.erb @@ -18,7 +18,7 @@ <%= link_to_if environment.hosts.any?, environment.hosts.size, hosts_path(:search => "environment = #{environment}") %> - <%= link_to "classes", puppetclasses_path(:search => "environment = #{environment}")%> + <%= link_to "Classes", puppetclasses_path(:search => "environment = #{environment}")%> <%= display_link_if_authorized "Destroy", hash_for_environment_path(:id => environment.name, :auth_action => :destroy), :confirm => "Delete #{environment.name}?", :method => :delete %> diff --git a/app/views/host_mailer/_active_hosts.text.html.erb b/app/views/host_mailer/_active_hosts.html.erb similarity index 100% rename from app/views/host_mailer/_active_hosts.text.html.erb rename to app/views/host_mailer/_active_hosts.html.erb diff --git a/app/views/host_mailer/_link_to_host.text.html.erb b/app/views/host_mailer/_link_to_host.html.erb similarity index 100% rename from app/views/host_mailer/_link_to_host.text.html.erb rename to app/views/host_mailer/_link_to_host.html.erb diff --git a/app/views/host_mailer/_list.text.html.erb b/app/views/host_mailer/_list.html.erb similarity index 100% rename from app/views/host_mailer/_list.text.html.erb rename to app/views/host_mailer/_list.html.erb diff --git a/app/views/host_mailer/_nonactive_hosts.text.html.erb b/app/views/host_mailer/_nonactive_hosts.html.erb similarity index 100% rename from app/views/host_mailer/_nonactive_hosts.text.html.erb rename to app/views/host_mailer/_nonactive_hosts.html.erb diff --git a/app/views/host_mailer/error_state.text.html.erb b/app/views/host_mailer/error_state.html.erb similarity index 100% rename from app/views/host_mailer/error_state.text.html.erb rename to app/views/host_mailer/error_state.html.erb diff --git a/app/views/host_mailer/summary.text.html.erb b/app/views/host_mailer/summary.html.erb similarity index 100% rename from app/views/host_mailer/summary.text.html.erb rename to app/views/host_mailer/summary.html.erb diff --git a/app/views/hostgroups/_form.html.erb b/app/views/hostgroups/_form.html.erb index 64d1deb52c6..f0f4bd42c00 100644 --- a/app/views/hostgroups/_form.html.erb +++ b/app/views/hostgroups/_form.html.erb @@ -1,4 +1,5 @@ -<% form_for @hostgroup do |f| %> +<%= javascript 'host_edit' %> +<%= form_for @hostgroup do |f| %> <%= base_errors_for @hostgroup %>
        @@ -17,19 +18,15 @@
        - <%= select_f f, :parent_id, accessible_hostgroups, :id, :to_label, :include_blank => true %> + <%= select_f f, :parent_id, accessible_hostgroups, :id, :to_label, {:include_blank => true}, {:onchange => 'hostgroup_changed(this);', + :help_inline => image_tag('spinner.gif', :id => 'hostgroup_indicator', :class => 'hide').html_safe } %> <%= text_f f, :name %> - <%= select_f f, :environment_id, Environment.all, :id, :to_label, :include_blank => true %> - + <%= select_f f, :environment_id, Environment.all, :id, :to_label, {:include_blank => true}, {:onchange => 'update_puppetclasses(this);'} %> <%= select_f f, :puppetproxy_id,Feature.find_by_name("Puppet CA").smart_proxies, :id, :name, { :include_blank => true}, { :label => "Puppet Master Proxy"} %> <%= text_f f, :puppetmaster_name, :label => "Puppet Master FQDN", :size => 8, :value => f.object.puppetmaster %> - <%= observe_field(:hostgroup_environment_id, - :url => { :action => :environment_selected, :id => @hostgroup.id }, - :update => :puppet_klasses, - :with => "'environment_id=' + value") %>
        diff --git a/app/views/hosts/_form.html.erb b/app/views/hosts/_form.html.erb index 8a814aaa2dc..8041c74c5a7 100644 --- a/app/views/hosts/_form.html.erb +++ b/app/views/hosts/_form.html.erb @@ -1,4 +1,5 @@ -<% form_for @host do |f| %> +<%= javascript 'host_edit' %> +<%= form_for @host do |f| %> <%= base_errors_for @host %>
          @@ -20,11 +21,11 @@
          <%= text_f f, :name, :class => "xlarge", :value => name_field(@host) %> <%= select_f f, :hostgroup_id, accessible_hostgroups, :id, :to_label, - { :include_blank => true }, - { :onchange => update_details_from_hostgroup, - :help_inline => image_tag("spinner.gif", :id => "indicator1", :style => "display:none;") - } %> - <%= select_f f, :environment_id, Environment.all, :id, :to_label, { :include_blank => true } %> + { :include_blank => true}, + { :onchange => 'hostgroup_changed(this);', :'data-host-id' => @host.id, + :help_inline => image_tag('spinner.gif', :id => 'hostgroup_indicator', :class => 'hide').html_safe } %> + + <%= select_f f, :environment_id, Environment.all, :id, :to_label, { :include_blank => true },{:onchange => 'update_puppetclasses(this);'} %> <%= select_f f, :puppetproxy_id,Feature.find_by_name("Puppet CA").smart_proxies, :id, :name, { :include_blank => true}, { :label => "Puppet Master Proxy"} @@ -33,15 +34,6 @@ :value => f.object.puppetmaster, :class => "xlarge", :help_inline => "only required for legacy puppet run" %> - <%= (observe_field(:host_hostgroup_id, - :url => { :action => :hostgroup_or_environment_selected, :id => @host.id }, - :update => :puppet_klasses, - :with => "'hostgroup_id=' + value+'&environment_id='+$('#host_environment_id').attr('value')") - ) unless @host.new_record? %> - <%= observe_field(:host_environment_id, - :url => { :action => :hostgroup_or_environment_selected, :id => @host.id }, - :update => :puppet_klasses, - :with => "'environment_id=' + value+'&hostgroup_id='+$('#host_hostgroup_id').attr('value')") %>
          diff --git a/app/views/hosts/_sp_subnet.html.erb b/app/views/hosts/_sp_subnet.html.erb index b16fa1f1a7c..8b26305c33b 100644 --- a/app/views/hosts/_sp_subnet.html.erb +++ b/app/views/hosts/_sp_subnet.html.erb @@ -1,4 +1,4 @@ -<% fields_for item do |f| -%> +<%= fields_for item do |f| -%> <%= select_f f, :sp_subnet_id, domain_subnets, :id, :title, { :include_blank => domain_subnets.any? ? true : "No subnets"}, { :disabled => domain_subnets.empty? ? true : false, :label => "BMC Subnet" } diff --git a/app/views/hosts/multiple_build.html.erb b/app/views/hosts/multiple_build.html.erb index ef60b1167fa..7d54e899dbc 100644 --- a/app/views/hosts/multiple_build.html.erb +++ b/app/views/hosts/multiple_build.html.erb @@ -1,5 +1,5 @@ <%= render 'selected_hosts', :hosts => @hosts %> -<% form_tag submit_multiple_build_hosts_path({:host_ids => params[:host_ids]}) do -%> +<%= form_tag submit_multiple_build_hosts_path({:host_ids => params[:host_ids]}) do -%> Provision these hosts for a build operation on next boot <% end %> diff --git a/app/views/hosts/multiple_destroy.html.erb b/app/views/hosts/multiple_destroy.html.erb index 4d29c05bd05..cc9a86b0f73 100644 --- a/app/views/hosts/multiple_destroy.html.erb +++ b/app/views/hosts/multiple_destroy.html.erb @@ -1,5 +1,5 @@ <%= render 'selected_hosts', :hosts => @hosts %> -<% form_tag submit_multiple_destroy_hosts_path(:host_ids => params[:host_ids]) do -%> +<%= form_tag submit_multiple_destroy_hosts_path(:host_ids => params[:host_ids]) do -%> Warning This might take a while, as all hosts, facts and reports will be destroyed as well <% end %> diff --git a/app/views/hosts/multiple_disable.html.erb b/app/views/hosts/multiple_disable.html.erb index 96ebd8ac99f..0072044365d 100644 --- a/app/views/hosts/multiple_disable.html.erb +++ b/app/views/hosts/multiple_disable.html.erb @@ -1,6 +1,6 @@ <%= render 'selected_hosts', :hosts => @hosts %> -<% form_tag submit_multiple_disable_hosts_path({:host_ids => params[:host_ids]}) do -%> +<%= form_tag submit_multiple_disable_hosts_path({:host_ids => params[:host_ids]}) do -%> <%# submit_tag "Disable alerts for selected hosts" %> Disable alerts for selected hosts <% end %> diff --git a/app/views/hosts/multiple_enable.html.erb b/app/views/hosts/multiple_enable.html.erb index 3acd612ce74..74bd6dc5f54 100644 --- a/app/views/hosts/multiple_enable.html.erb +++ b/app/views/hosts/multiple_enable.html.erb @@ -1,6 +1,6 @@ <%= render 'selected_hosts', :hosts => @hosts %> -<% form_tag submit_multiple_enable_hosts_path({:host_ids => params[:host_ids]}) do -%> +<%= form_tag submit_multiple_enable_hosts_path({:host_ids => params[:host_ids]}) do -%> <%# submit_tag "Enable alerts for selected hosts" %> Enable alerts for selected hosts <% end %> diff --git a/app/views/hosts/multiple_parameters.html.erb b/app/views/hosts/multiple_parameters.html.erb index 966cb4555de..4d8930be296 100644 --- a/app/views/hosts/multiple_parameters.html.erb +++ b/app/views/hosts/multiple_parameters.html.erb @@ -4,7 +4,7 @@ Sorry, these hosts do not have parameters assigned to them, you must add them first.

          <%= link_to "Back to host list", hosts_path %>

          <% else -%> - <% form_tag update_multiple_parameters_hosts_path({:host_ids => params[:host_ids]}) do %> + <%= form_tag update_multiple_parameters_hosts_path({:host_ids => params[:host_ids]}) do %> <% for param in @parameters %>
          <%= label_tag :name, param.name %> diff --git a/app/views/hosts/select_multiple_environment.html.erb b/app/views/hosts/select_multiple_environment.html.erb index 5337d0a6404..9560d926360 100644 --- a/app/views/hosts/select_multiple_environment.html.erb +++ b/app/views/hosts/select_multiple_environment.html.erb @@ -1,6 +1,6 @@ <%= render 'selected_hosts', :hosts => @hosts %> -<% form_for :environment, :url => update_multiple_environment_hosts_path(:host_ids => params[:host_ids]) do |f| %> +<%= form_for :environment, :url => update_multiple_environment_hosts_path(:host_ids => params[:host_ids]) do |f| %> <%= f.select :id, [["Select Environment", "disabled"],["*Clear environment*", "" ]] + Environment.all.map{|e| [e.name, e.id]},{}, :onchange => "toggle_multiple_ok_button(this)" %> <% end %> diff --git a/app/views/hypervisors/_form.html.erb b/app/views/hypervisors/_form.html.erb index 17b3177d155..a139188fd47 100644 --- a/app/views/hypervisors/_form.html.erb +++ b/app/views/hypervisors/_form.html.erb @@ -1,4 +1,4 @@ -<% form_for @hypervisor do |f| %> +<%= form_for @hypervisor do |f| %> <%= base_errors_for @hypervisor %> <%= text_f f, :name %> <%= text_f f, :uri, :label => "URI", :class =>"xxlarge" %> diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 74fdf2ecba1..f390047654b 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -1,13 +1,10 @@ - - - + + - - <%= h(yield(:title) || "Foreman") %> <%= stylesheet_link_tag 'jquery-ui', 'jquery.jnotify', 'bootstrap.min', 'style' %> - <%= javascript_include_tag :defaults, 'highcharts', 'charts', 'jquery.jnotify', 'jquery.jeditable', 'bootstrap-dropdown', 'bootstrap-alerts', 'bootstrap-tabs', 'bootstrap-modal', 'bootstrap-twipsy', 'bootstrap-popover' %> + <%= javascript_include_tag :defaults, 'jquery_ujs', 'jquery-ui', 'highcharts', 'charts', 'jquery.jnotify', 'jquery.jeditable', 'bootstrap-dropdown', 'bootstrap-alerts', 'bootstrap-tabs', 'bootstrap-modal', 'bootstrap-twipsy', 'bootstrap-popover' %> + <%= csrf_meta_tag %> <%= javascript_tag "var AUTH_TOKEN = #{form_authenticity_token.inspect};" if protect_against_forgery? %> <%= yield(:head) %> @@ -50,7 +47,7 @@ -
          \ No newline at end of file +
          diff --git a/app/views/roles/_form.rhtml b/app/views/roles/_form.rhtml index 47f65742f96..9a8dc4bf398 100644 --- a/app/views/roles/_form.rhtml +++ b/app/views/roles/_form.rhtml @@ -1,6 +1,6 @@ <% title_actions check_all_links('permissions') %> -<% form_for @role do |f| %> +<%= form_for @role do |f| %> <%= base_errors_for @role %> <%= text_f f, :name, :class => @role.builtin? ? "disabled" : "" %> @@ -13,7 +13,7 @@
            <% perms_by_block[block].each do |permission| %>
          • - <% content_tag_for 'role[permissions][]', permission do %> + <%= content_tag :div, 'role[permissions][]' do %> <%= check_box_tag 'role[permissions][]', permission.name, (@role.permissions.include? permission.name) %> <%= permission.name %> <%= hidden_field_tag 'role[permissions][]' %> diff --git a/app/views/roles/report.rhtml b/app/views/roles/report.rhtml index 5229dcb4d94..0df2370e8b2 100644 --- a/app/views/roles/report.rhtml +++ b/app/views/roles/report.rhtml @@ -1,6 +1,6 @@ <% title "Permissions report" %> -<% form_tag(report_roles_path, :id => 'permissions_form') do %> +<%= form_tag(report_roles_path, :id => 'permissions_form') do %> <%= hidden_field_tag 'permissions[0]', '', :id => nil %> diff --git a/app/views/smart_proxies/_form.html.erb b/app/views/smart_proxies/_form.html.erb index c2c1b1aa792..929b961957b 100644 --- a/app/views/smart_proxies/_form.html.erb +++ b/app/views/smart_proxies/_form.html.erb @@ -1,4 +1,4 @@ -<% form_for @proxy do |f| %> +<%= form_for @proxy do |f| %> <%= base_errors_for @proxy %> <%= text_f(f, :name) %> <%= text_f(f, :url, :label => "URL", :class => "xlarge" ) %> diff --git a/app/views/smart_proxies/autosign/_form.html.erb b/app/views/smart_proxies/autosign/_form.html.erb index 87875d60209..ff67a946b54 100644 --- a/app/views/smart_proxies/autosign/_form.html.erb +++ b/app/views/smart_proxies/autosign/_form.html.erb @@ -1,4 +1,4 @@ -<% form_tag smart_proxy_autosign_index_path(@proxy) do |f| %> +<%= form_tag smart_proxy_autosign_index_path(@proxy) do |f| %>
            <%= label_tag("Name") %>
            diff --git a/app/views/smart_proxies/autosign/index.html.erb b/app/views/smart_proxies/autosign/index.html.erb index 990cc0984ae..25f486ed24d 100644 --- a/app/views/smart_proxies/autosign/index.html.erb +++ b/app/views/smart_proxies/autosign/index.html.erb @@ -17,5 +17,5 @@ <% end -%>
            -<%= page_entries_info @autosign, :entry_name => "Autosign entries" %> +<%= page_entries_info @autosign, :model => "Autosign entries" %> <%= will_paginate @autosign %> diff --git a/app/views/smart_proxies/puppetca/index.html.erb b/app/views/smart_proxies/puppetca/index.html.erb index 90d625dda7f..9a363f6d889 100644 --- a/app/views/smart_proxies/puppetca/index.html.erb +++ b/app/views/smart_proxies/puppetca/index.html.erb @@ -26,5 +26,5 @@ <% end -%> -<%= page_entries_info @certificates, :entry_name => "Puppet Certificates" %> +<%= page_entries_info @certificates, :model => "Puppet Certificates" %> <%= will_paginate @certificates %> diff --git a/app/views/statistics/index.html.erb b/app/views/statistics/index.html.erb index 91807ce3fd9..d6295509636 100644 --- a/app/views/statistics/index.html.erb +++ b/app/views/statistics/index.html.erb @@ -1,7 +1,7 @@
              <% charts.each do |ch| -%>
            • - <%= link_to_function content_tag (:div, ch, :class=>"thumbnail"), "expand_chart(this);" %> + <%= link_to_function content_tag(:div, ch, :class=>"thumbnail"), "expand_chart(this);" %>
            • <% end -%> -
            \ No newline at end of file +
          diff --git a/app/views/subnets/_form.html.erb b/app/views/subnets/_form.html.erb index 36af204ec39..b1d724f3e9a 100644 --- a/app/views/subnets/_form.html.erb +++ b/app/views/subnets/_form.html.erb @@ -1,4 +1,4 @@ -<% form_for @subnet do |f| %> +<%= form_for @subnet do |f| %> <%= base_errors_for @subnet %> <%= render 'fields', :f => f %> <%= submit_or_cancel f %> diff --git a/app/views/subnets/import.html.erb b/app/views/subnets/import.html.erb index c3d4981bf1c..68811e607e3 100644 --- a/app/views/subnets/import.html.erb +++ b/app/views/subnets/import.html.erb @@ -1,12 +1,12 @@ <% title "Import subnets" %>

          We've found the following subnets

          -<% form_tag create_multiple_subnets_path do |f| -%> +<%= form_tag create_multiple_subnets_path do |f| -%> <% @subnets.each do |subnet| -%>
        • <%= subnet %> <%= options(@subnets) %>
        • > - <% fields_for "subnets[]", subnet do |f| -%> + <%= fields_for "subnets[]", subnet do |f| -%> <%= render 'fields', :f => f %> <% end -%> diff --git a/app/views/usergroups/_form.html.erb b/app/views/usergroups/_form.html.erb index 8818873b83b..067bbdc6f37 100644 --- a/app/views/usergroups/_form.html.erb +++ b/app/views/usergroups/_form.html.erb @@ -1,4 +1,4 @@ -<% form_for @usergroup do |f| %> +<%= form_for @usergroup do |f| %> <%= base_errors_for @usergroup %> <%= text_f f, :name %> <%= multiple_checkboxes f, :usergroups, @usergroup, Usergroup, :label => "User Groups" %> diff --git a/app/views/users/_filters.html.erb b/app/views/users/_filters.html.erb index 573a18ea839..5293721978f 100644 --- a/app/views/users/_filters.html.erb +++ b/app/views/users/_filters.html.erb @@ -1,6 +1,6 @@
          - <% field_set_tag "Owned hosts" do %> + <%= field_set_tag "Owned hosts" do %>
          Select <%= f.check_box :filter_on_owner %>
          @@ -11,7 +11,7 @@ <% end -%>
          - <% field_set_tag "Domain hosts" do %> + <%= field_set_tag "Domain hosts" do %>
          <%= f.select :domains_andor, [["in domain", "and"], ["plus all", "or"]], {}, :class => "small" %>
          @@ -21,7 +21,7 @@ <% end %>
          - <% field_set_tag "Hostgroup hosts" do %> + <%= field_set_tag "Hostgroup hosts" do %>
          <%= f.select :hostgroups_andor, [["must be", "and"], ["plus all", "or"]], {}, :class => "small" %>
          @@ -31,12 +31,12 @@ <% end %>
          - <% field_set_tag "Fact filters" do %> + <%= field_set_tag "Fact filters" do %>
          <%= f.select :facts_andor, [["must match", "and"], ["plus all", "or"]], {} ,:class => "small" %>
          - <% f.fields_for :user_facts do |builder| -%> + <%= f.fields_for :user_facts do |builder| -%> <%= render "user_fact", :f => builder %> <% end -%> <% if authorized_for(params[:controller], params[:action]) -%> diff --git a/app/views/users/_form.html.erb b/app/views/users/_form.html.erb index b369f5356cf..db9b5a193ee 100644 --- a/app/views/users/_form.html.erb +++ b/app/views/users/_form.html.erb @@ -1,4 +1,4 @@ -<% form_for @user do |f| %> +<%= form_for @user do |f| %> <%= base_errors_for @user %>
            @@ -17,8 +17,8 @@ <%= text_f f, :mail %> <% unless @editing_self -%> - <%= select_f f, :auth_source_id, AuthSource.all.delete_if { |a| a.to_label.nil? }, :id, :to_label, :include_blank => true, - :label => "Authorized by" + <%= select_f f, :auth_source_id, AuthSource.all.delete_if { |a| a.to_label.nil? }, :id, :to_label, {:include_blank => true, + :label => "Authorized by"}, {:onchange => 'auth_source_selected()'} %> <% end -%> @@ -40,6 +40,4 @@
          <%= submit_or_cancel f %> <% end -%> -<%= observe_field(:user_auth_source_id, - :url => {:action => :auth_source_selected}, - :with => 'auth_source_id') %> + diff --git a/app/views/users/login.html.erb b/app/views/users/login.html.erb index 7bd42e61785..c6f0ae140d9 100644 --- a/app/views/users/login.html.erb +++ b/app/views/users/login.html.erb @@ -1,6 +1,6 @@
          - <% form_tag({:action=> "login"}) do %> + <%= form_tag({:action=> "login"}) do %> diff --git a/config.ru b/config.ru new file mode 100644 index 00000000000..be8d864a718 --- /dev/null +++ b/config.ru @@ -0,0 +1,4 @@ +# This file is used by Rack-based servers to start the application. + +require ::File.expand_path('../config/environment', __FILE__) +run Foreman::Application diff --git a/config/application.rb b/config/application.rb new file mode 100644 index 00000000000..26c684c979f --- /dev/null +++ b/config/application.rb @@ -0,0 +1,57 @@ +require File.expand_path('../boot', __FILE__) + +require 'rails/all' + +# If you have a Gemfile, require the gems listed there, including any gems +# you've limited to :test, :development, or :production. +Bundler.require(:default, Rails.env) if defined?(Bundler) + +require File.expand_path('../../lib/timed_cached_store.rb', __FILE__) +require File.expand_path('../../lib/core_extensions', __FILE__) + +module Foreman + class Application < Rails::Application + # 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. + + # Custom directories with classes and modules you want to be autoloadable. + # config.autoload_paths += %W(#{config.root}/extras) + config.autoload_paths += %W(#{config.root}/lib) + + # 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 ] + + # Activate observers that should always be running. + # config.active_record.observers = :cacher, :garbage_collector, :forum_observer + config.active_record.observers = :host_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. Default is UTC. + # config.time_zone = 'Central Time (US & Canada)' + 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}').to_s] + # config.i18n.default_locale = :de + + # JavaScript files you want as :defaults (application.js is always included). + config.action_view.javascript_expansions[:defaults] = %w(jquery) + #config.action_view.javascript_expansions[:defaults] = %w(jquery rails) + + # Disable fieldWithErrors divs + config.action_view.field_error_proc = Proc.new {|html_tag, instance| "#{html_tag}" } + + # Configure the default encoding used in templates for Ruby 1.9. + config.encoding = "utf-8" + + # Configure sensitive parameters which will be filtered from the log file. + config.filter_parameters += [:password, :account_password, :facts, :root_pass, :value, :report, :password_confirmation] + + config.session_store :active_record_store + + # enables in memory cache store with ttl + config.cache_store = TimedCachedStore.new + end +end diff --git a/config/boot.rb b/config/boot.rb index 0ad0f787f86..4489e58688c 100644 --- a/config/boot.rb +++ b/config/boot.rb @@ -1,110 +1,6 @@ -# Don't change this file! -# Configure your app in config/environment.rb and config/environments/*.rb +require 'rubygems' -RAILS_ROOT = "#{File.dirname(__FILE__)}/.." unless defined?(RAILS_ROOT) +# Set up gems listed in the Gemfile. +ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__) -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 - $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 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 - require 'rubygems' - min_version = '1.3.1' - 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! +require 'bundler/setup' if File.exists?(ENV['BUNDLE_GEMFILE']) diff --git a/config/database.yml b/config/database.yml index 025d62a8d81..90d87cc295f 100644 --- a/config/database.yml +++ b/config/database.yml @@ -1,5 +1,5 @@ # SQLite version 3.x -# gem install sqlite3-ruby (not necessary on OS X Leopard) +# gem install sqlite3 development: adapter: sqlite3 database: db/development.sqlite3 diff --git a/config/environment.rb b/config/environment.rb index 97d12af3018..b2569e3dbe1 100644 --- a/config/environment.rb +++ b/config/environment.rb @@ -1,51 +1,5 @@ -# Be sure to restart your server when you modify this file +# Load the rails application +require File.expand_path('../application', __FILE__) -# Specifies gem version of Rails to use when vendor/rails is not present -RAILS_GEM_VERSION = '2.3.2' 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.load_paths += %W( #{RAILS_ROOT}/extras ) - - # Specify gems that this application depends on and have them installed with rake gems:install - config.gem "safemode" - config.gem "rack", :version => '1.1.0' - config.gem "rest-client", :version => '>=1.4.0', :lib => "restclient" - config.gem "json" - # 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 - config.active_record.observers = :host_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 - - # enables in memory cache store with ttl - config.cache_store = :timed_cached_store - # Disable fieldWithErrors divs - config.action_view.field_error_proc = Proc.new {|html_tag, instance| "#{html_tag}" } -end +# Initialize the rails application +Foreman::Application.initialize! diff --git a/config/environments/development.rb b/config/environments/development.rb index 5ba272b08de..daf06c7ccb4 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -1,18 +1,26 @@ -# Settings specified here will take precedence over those in config/environment.rb +Foreman::Application.configure do + # Settings specified here will take precedence over those in config/application.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. -# Audit trail reads from cache, therefor for debugging this is required -config.cache_classes = false + # 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 + # 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 + # Show full error reports and disable caching + config.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 + + # Print deprecation notices to the Rails logger + config.active_support.deprecation = :log + + # Only use best-standards-support built into browsers + config.action_dispatch.best_standards_support = :builtin +end -# Don't care if the mailer can't send -config.action_mailer.raise_delivery_errors = false diff --git a/config/environments/production.rb b/config/environments/production.rb index 27119d2d18b..73e2507ec46 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -1,28 +1,49 @@ -# Settings specified here will take precedence over those in config/environment.rb +Foreman::Application.configure do + # Settings specified here will take precedence over those in config/application.rb -# The production environment is meant for finished, "live" apps. -# Code is not reloaded between requests -config.cache_classes = true + # 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 + # Full error reports are disabled and caching is turned on + config.consider_all_requests_local = false + config.action_controller.perform_caching = true -# See everything in the log (default is :info) -# config.log_level = :debug + # Specifies the header that your server uses for sending files + config.action_dispatch.x_sendfile_header = "X-Sendfile" -# Use a different logger for distributed setups -# config.logger = SyslogLogger.new + # For nginx: + # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' -# Use a different cache store in production -# config.cache_store = :mem_cache_store + # If you have no front-end server that supports something like X-Sendfile, + # just comment this out and Rails will serve the files -# Enable serving of images, stylesheets, and javascripts from an asset server -# config.action_controller.asset_host = "http://assets.example.com" + # See everything in the log (default is :info) + # config.log_level = :debug -# Disable delivery errors, bad email addresses will be ignored -# config.action_mailer.raise_delivery_errors = false + # Use a different logger for distributed setups + # config.logger = SyslogLogger.new -# Enable threaded mode -# config.threadsafe! \ No newline at end of file + # Use a different cache store in production + # config.cache_store = :mem_cache_store + + # Disable Rails's static asset server + # In production, Apache or nginx will already do this + config.serve_static_assets = 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 + + # Enable threaded mode + # config.threadsafe! + + # Enable locale fallbacks for I18n (makes lookups for any locale fall back to + # the I18n.default_locale when a translation can not be found) + config.i18n.fallbacks = true + + # Send deprecation notices to registered listeners + config.active_support.deprecation = :notify +end diff --git a/config/environments/test.rb b/config/environments/test.rb index d9148ee88da..6c0688abe3f 100644 --- a/config/environments/test.rb +++ b/config/environments/test.rb @@ -1,27 +1,35 @@ -# 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 +Foreman::Application.configure do + # Settings specified here will take precedence over those in config/application.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.consider_all_requests_local = true + config.action_controller.perform_caching = false + + # Raise exceptions instead of rendering exception templates + config.action_dispatch.show_exceptions = false + + # 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 + + # Print deprecation notices to the stderr + config.active_support.deprecation = :stderr +end diff --git a/config/initializers/fix_already_loading_missing_dependencies.rb b/config/initializers/fix_already_loading_missing_dependencies.rb deleted file mode 100644 index f96dac016f4..00000000000 --- a/config/initializers/fix_already_loading_missing_dependencies.rb +++ /dev/null @@ -1,21 +0,0 @@ -module ActiveSupport - module Dependencies - extend self - - #def load_missing_constant(from_mod, const_name) - - def forgiving_load_missing_constant( from_mod, const_name ) - begin - old_load_missing_constant(from_mod, const_name) - rescue ArgumentError => arg_err - if arg_err.message == "#{from_mod} is not missing constant #{const_name}!" - return from_mod.const_get(const_name) - else - raise - end - end - end - alias :old_load_missing_constant :load_missing_constant - alias :load_missing_constant :forgiving_load_missing_constant - end -end \ No newline at end of file diff --git a/config/initializers/foreman.rb b/config/initializers/foreman.rb index 95c40f544c4..1a55ee4afcf 100644 --- a/config/initializers/foreman.rb +++ b/config/initializers/foreman.rb @@ -1,12 +1,10 @@ -require 'core_extensions' -require 'access_permissions' +require 'foreman' require 'puppet' require 'puppet/rails' - # import settings file -SETTINGS= YAML.load_file("#{RAILS_ROOT}/config/settings.yaml") +SETTINGS= YAML.load_file("#{Rails.root}/config/settings.yaml") -SETTINGS[:version] = "0.4" +SETTINGS[:version] = "0.5" SETTINGS[:unattended] = SETTINGS[:unattended].nil? || SETTINGS[:unattended] Puppet[:config] = SETTINGS[:puppetconfdir] || "/etc/puppet/puppet.conf" @@ -22,7 +20,7 @@ SETTINGS[:libvirt] = false end rescue LoadError - RAILS_DEFAULT_LOGGER.debug "Libvirt binding are missing - hypervisor management is disabled" + Rails.logger.debug "Libvirt binding are missing - hypervisor management is disabled" SETTINGS[:libvirt] = false end @@ -31,3 +29,5 @@ # We load the default settings for the roles if they are not already present Foreman::DefaultData::Loader.load(false) + +WillPaginate.per_page = Setting.entries_per_page rescue 20 diff --git a/config/initializers/inflections.rb b/config/initializers/inflections.rb index d531b8bb825..9e8b0131f8f 100644 --- a/config/initializers/inflections.rb +++ b/config/initializers/inflections.rb @@ -1,6 +1,6 @@ # Be sure to restart your server when you modify this file. -# Add new inflection rules using the following format +# 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' diff --git a/config/initializers/new_rails_defaults.rb b/config/initializers/new_rails_defaults.rb deleted file mode 100644 index 8ec3186c84d..00000000000 --- a/config/initializers/new_rails_defaults.rb +++ /dev/null @@ -1,19 +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 - -# 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/config/initializers/puppet.rb b/config/initializers/puppet.rb index 689ced460a0..acba5626c35 100644 --- a/config/initializers/puppet.rb +++ b/config/initializers/puppet.rb @@ -12,8 +12,8 @@ class Puppet::Rails::FactName has_many :user_facts has_many :users, :through => :user_facts - named_scope :no_timestamp_fact, :conditions => ["fact_names.name <> ?",:_timestamp] - named_scope :timestamp_facts, :conditions => ["fact_names.name = ?", :_timestamp] + scope :no_timestamp_fact, :conditions => ["fact_names.name <> ?",:_timestamp] + scope :timestamp_facts, :conditions => ["fact_names.name = ?", :_timestamp] default_scope :order => 'LOWER(fact_names.name)' diff --git a/config/initializers/secret_token.rb b/config/initializers/secret_token.rb new file mode 100644 index 00000000000..327b4073158 --- /dev/null +++ b/config/initializers/secret_token.rb @@ -0,0 +1,7 @@ +# 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. +Foreman::Application.config.secret_token = '1d53dcb00e724f72a15823d6939a2ee6f3b3ab3af7c47d074cefb1c9d3fe197cce3d0e2050a68d593f9275242d01658f3e9badd6221cf0e76e18896e4862358c' diff --git a/config/initializers/session_store.rb b/config/initializers/session_store.rb index 91c4a5a72ea..afea5dcdeaa 100644 --- a/config/initializers/session_store.rb +++ b/config/initializers/session_store.rb @@ -1,15 +1,8 @@ # 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 => '_Foreman_session', - :secret => '4fe1a103699cf36976181cb4d343e6cb27d7904113c9a2113862c53b51f12357f413c996e820e6e544464242915d643d32b698a9679bbfe63f6eedfd9bf67961' -} +# Foreman::Application.config.session_store :cookie_store, :key => '_foreman_session' # 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 +# (create the session table with "rails generate session_migration") +Foreman::Application.config.session_store :active_record_store diff --git a/config/initializers/will_paginate.rb b/config/initializers/will_paginate.rb index 3482de9d9b9..9b397dcb90a 100644 --- a/config/initializers/will_paginate.rb +++ b/config/initializers/will_paginate.rb @@ -1,36 +1,27 @@ # config/initializers/will_paginate.rb +require 'will_paginate/array' module WillPaginate - module ViewHelpers + module ActionView class BootstrapLinkRenderer < LinkRenderer + protected - def to_html - links = @options[:page_links] ? visible_page_numbers.map {|n| page_link_or_span(n, '')} : [] - html = add_prev_next(links).join(@options[:separator]) - @options[:container] ? @template.content_tag(:div, @template.content_tag(:ul, html), html_attributes) : html + def html_container(html) + tag :div, tag(:ul, html), container_attributes end - protected - - # previous/next buttons - def add_prev_next(links) - prev_class = "prev" - next_class = "next" - prev_class += " disabled" if visible_page_numbers.first == current_page - next_class += " disabled" if visible_page_numbers.last == current_page - links.unshift page_link_or_span(visible_page_numbers.first == current_page ? current_page : @collection.previous_page, prev_class, @options[:previous_label]) - links.push page_link_or_span(visible_page_numbers.last == current_page ? current_page : @collection.next_page, next_class, @options[:next_label]) + def page_number(page) + tag :li, link(page, page, :rel => rel_value(page)), :class => ('active' if page == current_page) end - def page_link_or_span(page, span_class, text = nil) - span_class ||="" - span_class += " active" if page and page == current_page - page_link page, text ||= page.to_s, :rel => rel_value(page), :class => span_class + def previous_or_next_page(page, text, classname) + tag :li, link(text, page || '#'), :class => [classname[0..3], classname, ('disabled' unless page)].join(' ') end - def page_link(page, text, attributes = {}) - @template.content_tag(:li, @template.link_to(text, url_for(page), attributes) ,attributes) + def gap + tag :li, link(super, '#'), :class => 'disabled' end + end end -end \ No newline at end of file +end diff --git a/config/locales/en.yml b/config/locales/en.yml index f265c068d89..a747bfa6987 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -2,4 +2,4 @@ # See http://github.com/svenfuchs/rails-i18n/tree/master/rails%2Flocale for starting points. en: - hello: "Hello world" \ No newline at end of file + hello: "Hello world" diff --git a/config/routes.rb b/config/routes.rb index 953b1d6d3b3..702ff785f00 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,80 +1,235 @@ -ActionController::Routing::Routes.draw do |map| - map.root :controller => "dashboard" - - map.connect ':controller/help', :action => 'welcome' - - map.resources :reports, :collection => { :auto_complete_search => :get } - map.connect "node/:name", :controller => 'hosts', :action => 'externalNodes', - :requirements => { :name => /[^\.][\w\.-]+/ } - map.resources :hosts, - :requirements => {:id => /[^\/]+/}, - :member => { :report => :get, :clone => :get, :toggle_manage => :put, - :environment_selected => :post, :architecture_selected => :post, :os_selected => :post, - :storeconfig_klasses => :get, :externalNodes => :get, :setBuild => :get, :cancelBuild => :get, - :puppetrun => :get, :facts => :get, :pxe_config => :get }, - :collection => { :show_search => :get, :multiple_actions => :get, :multiple_parameters => :get, - :update_multiple_parameters => :post, :select_multiple_hostgroup => :get, - :update_multiple_hostgroup => :post, :select_multiple_environment => :get, :update_multiple_environment => :post, - :multiple_destroy => :get, :submit_multiple_destroy => :post, :multiple_build => :get, :submit_multiple_build => :post, - :reset_multiple => :get, :multiple_disable => :get, :submit_multiple_disable => :post, - :multiple_enable => :get, :submit_multiple_enable => :post, :auto_complete_search => :get, :template_used => :get, - :query => :get, :active => :get, :out_of_sync => :get, :errors => :get, :disabled => :get } do |hosts| - hosts.resources :reports, :requirements => {:host_id => /[^\/]+/}, :only => [:index, :show] - hosts.resources :facts, :requirements => {:host_id => /[^\/]+/}, :only => :index, :controller => :fact_values - hosts.resources :puppetclasses, :requirements => {:host_id => /[^\/]+/}, :only => :index - hosts.resources :lookup_keys, :requirements => {:host_id => /[^\/]+/}, :only => :show +Foreman::Application.routes.draw do + #ENC requests goes here + match "node/:name" => 'hosts#externalNodes', :constraints => { :name => /[^\.][\w\.-]+/ } + post "reports/create" + post "fact_values/create" + + resources :reports, :only => [:index, :show, :destroy] do + collection do + get 'auto_complete_search' + end end - map.dashboard '/dashboard', :controller => 'dashboard' - map.dashboard_auto_completer '/dashboard/auto_complete_search', :controller => 'hosts', :action => :auto_complete_search - map.statistics '/statistics', :controller => 'statistics' - map.resources :notices, :only => :destroy - map.resources :audits, :collection => {:auto_complete_search => :get} - if SETTINGS[:login] - map.resources :usergroups - map.resources :users, :collection => {:login => [:get, :post], :logout => :get, :auth_source_selected => :get, :auto_complete_search => :get} - map.resources :roles, :collection => {:report => [:get, :post], :auto_complete_search => :get} + + match '(:controller)/help', :action => 'welcome', :as => "help" + constraints(:id => /[^\/]+/) do + resources :hosts do + member do + get 'clone' + get 'storeconfig_klasses' + get 'externalNodes' + get 'setBuild' + get 'cancelBuild' + get 'puppetrun' + get 'pxe_config' + put 'toggle_manage' + post 'environment_selected' + end + collection do + get 'show_search' + get 'multiple_actions' + get 'multiple_parameters' + post 'update_multiple_parameters' + get 'select_multiple_hostgroup' + post 'update_multiple_hostgroup' + get 'select_multiple_environment' + post 'update_multiple_environment' + get 'multiple_destroy' + post 'submit_multiple_destroy' + get 'multiple_build' + post 'submit_multiple_build' + get 'reset_multiple' + get 'multiple_disable' + post 'submit_multiple_disable' + get 'multiple_enable' + post 'submit_multiple_enable' + get 'auto_complete_search' + get 'template_used' + get 'query' # Legacy query interface + get 'active' + get 'out_of_sync' + get 'errors' + get 'disabled' + post 'process_hostgroup' + post 'hostgroup_or_environment_selected' + post 'hypervisor_selected' + post 'architecture_selected' + post 'os_selected' + post 'domain_selected' + end + + constraints(:host_id => /[^\/]+/) do + resources :reports ,:only => [:index, :show] + resources :facts ,:only => :index, :controller => :fact_values + resources :puppetclasses ,:only => :index + resources :lookup_keys ,:only => :show + end + end + + resources :bookmarks, :except => [:show] + resources :lookup_keys, :except => [:new, :create] do + resources :lookup_values, :only => [:index, :create, :update, :destroy] + end + + resources :facts, :only => [:index, :show] do + constraints(:id => /[^\/]+/) do + resources :values, :only => :index, :controller => :fact_values, :as => "host_fact_values" + end + end + + resources :hypervisors do + constraints(:id => /[^\/]+/) do + resources :guests, :controller => "Hypervisors::Guests", :except => [:edit] do + member do + put 'power' + end + end + end + end if SETTINGS[:libvirt] end - if SETTINGS[:unattended] - map.resources :domains, :requirements => {:id => /[^\/]+/}, :collection => {:auto_complete_search => :get} - map.resources :operatingsystems, :member => {:bootfiles => :get}, :collection => {:auto_complete_search => :get} - map.resources :media, :collection => {:auto_complete_search => :get} - map.resources :models, :collection => {:auto_complete_search => :get} - map.resources :architectures, :collection => {:auto_complete_search => :get} - map.resources :ptables, :collection => {:auto_complete_search => :get} - map.resources :config_templates, :except => [:show], :collection => { :auto_complete_search => :get }, :requirements => { :id => /[^\/]+/ } - map.resources :subnets, :except => [:show], :collection => {:auto_complete_search => :get, :import => :get, :create_multiple => :post} - map.connect 'unattended/template/:id/:hostgroup', :controller => "unattended", :action => "template" + resources :settings, :only => [:index, :update] + resources :common_parameters do + collection do + get 'auto_complete_search' + end + end + resources :environments do + collection do + get 'import_environments' + post 'obsolete_and_new' + get 'auto_complete_search' + end + end + + resources :hostgroups do + member do + get 'nest' + get 'clone' + end + collection do + get 'auto_complete_search' + end + end + + resources :puppetclasses do + collection do + get 'import_environments' + get 'auto_complete_search' + end + constraints(:id => /[^\/]+/) do + resources :hosts + resources :lookup_keys, :except => [:show, :new, :create] + end + end + + resources :smart_proxies, :except => [:show] do + constraints(:id => /[^\/]+/) do + resources :puppetca, :controller => "SmartProxies::Puppetca", :only => [:index, :update, :destroy] + resources :autosign, :controller => "SmartProxies::Autosign", :only => [:index, :new, :create, :destroy] + end end - map.resources :lookup_keys, :except => [:new, :create], :requirements => {:id => /[^\/]+/} do |keys| - keys.resources :lookup_values, :only => [:index, :create, :update, :destroy] + resources :fact_values, :only => [:index] do + collection do + get 'auto_complete_search' + end end - map.resources :puppetclasses, :member => { :assign => :post }, :collection => {:import_environments => :get, :auto_complete_search => :get} do |pc| - pc.resources :hosts, :requirements => {:id => /[^\/]+/} - pc.resources :lookup_keys, :except => [:show, :new, :create], :requirements => {:id => /[^\/]+/} + + resources :notices, :only => :destroy + resources :audits do + collection do + get 'auto_complete_search' + end end - map.resources :hostgroups, :member => { :nest => :get, :clone => :get }, :collection => { :auto_complete_search => :get } - map.resources :common_parameters, :collection => {:auto_complete_search => :get} - map.resources :environments, :collection => {:import_environments => :get, :obsolete_and_new => :post, :auto_complete_search => :get} - map.resources :fact_values, :only => [:create, :index], :collection => { :auto_complete_search => :get } - map.resources :facts, :only => [:index, :show], :requirements => {:id => /[^\/]+/} do |facts| - facts.resources :values, :requirements => {:id => /[^\/]+/}, :only => :index, :controller => :fact_values + + if SETTINGS[:login] + resources :usergroups + resources :users do + collection do + get 'login' + post 'login' + get 'logout' + get 'auth_source_selected' + get 'auto_complete_search' + end + end + resources :roles do + collection do + get 'report' + post 'report' + get 'auto_complete_search' + end + end + + resources :auth_source_ldaps end - map.resources :auth_source_ldaps - map.resources :smart_proxies, :except => [:show] do |proxy| - proxy.resources :puppetca, :controller => "SmartProxies::Puppetca", :only => [:index, :update, :destroy], :requirements => { :id => /[^\.][\w\.-]+/ } - proxy.resources :autosign, :controller => "SmartProxies::Autosign", :only => [:index, :new, :create, :destroy], :requirements => { :id => /[^\.][\w\.-]+/ } + + if SETTINGS[:unattended] + constraints(:id => /[^\/]+/) do + resources :domains do + collection do + get 'auto_complete_search' + end + end + resources :config_templates, :except => [:show] do + collection do + get 'auto_complete_search' + get 'build_pxe_default' + end + end + end + + resources :operatingsystems do + member do + get 'bootfiles' + end + collection do + get 'auto_complete_search' + end + end + resources :media do + collection do + get 'auto_complete_search' + end + end + + resources :models do + collection do + get 'auto_complete_search' + end + end + + resources :architectures do + collection do + get 'auto_complete_search' + end + end + + resources :ptables do + collection do + get 'auto_complete_search' + end + end + + resources :subnets, :except => [:show] do + collection do + get 'auto_complete_search' + get 'import' + post 'create_multiple' + post 'freeip' + end + end + + match 'unattended/template/:id/:hostgroup', :to => "unattended#template" end - map.resources :hypervisors, :requirements => { :id => /[^\/]+/ } do |hypervisor| - hypervisor.resources :guests, :controller => "Hypervisors::Guests", :except => [:edit], - :member => {:power => :put}, :requirements => { :id => /[^\.][\w\.-]+/ } - end if SETTINGS[:libvirt] - map.resources :bookmarks, :except => [:show], :requirements => { :id => /[^\/]+/ } - map.resources :settings, :only => [:index, :update] - map.connect '/status', :controller => "home", :action => "status" - - #default - map.connect ':controller/:action/:id' - map.connect ':controller/:action/:id.:format' + + root :to => 'dashboard#index' + match 'dashboard', :to => 'dashboard#index', :as => "dashboard" + match 'dashboard/auto_complete_search', :to => 'hosts#auto_complete_search', :as => "auto_complete_search_dashboards" + match 'statistics', :to => 'statistics#index', :as => "statistics" + match 'home/status', :to => 'home#status' + + # match for all unattended scripts + match 'unattended/(:action/(:id(.format)))', :controller => 'unattended' + end diff --git a/config/routes.rb.rails2 b/config/routes.rb.rails2 new file mode 100644 index 00000000000..72f502fd6ba --- /dev/null +++ b/config/routes.rb.rails2 @@ -0,0 +1,8 @@ +ActionController::Routing::Routes.draw do |map| + + map.connect '/status', :controller => "home", :action => "status" + + #default + map.connect ':controller/:action/:id' + map.connect ':controller/:action/:id.:format' +end diff --git a/config/settings.yaml b/config/settings.yaml deleted file mode 100644 index a9fcf8341ea..00000000000 --- a/config/settings.yaml +++ /dev/null @@ -1,12 +0,0 @@ ---- -#:modulepath: /etc/puppet/modules/ -:tftppath: tftp/ -#:rrd_report_url: report/ -#:ldap: true -#your default puppet server - can be overridden in the host level -#if none specified, plain "puppet" will be used. -#:puppet_server: puppet -#:unattended: false -#use the following setting to override the default 30 minutes puppet run interval - value must be in minutes -#:puppet_interval: 60 -#:document_root: /var/www diff --git a/db/migrate/20090715143858_create_architectures.rb b/db/migrate/20090715143858_create_architectures.rb index 77eedfda4b7..0f29b204753 100644 --- a/db/migrate/20090715143858_create_architectures.rb +++ b/db/migrate/20090715143858_create_architectures.rb @@ -10,8 +10,6 @@ def self.up t.references :operatingsystem, :null => false end - Architecture.create :name => "x86_64" - Architecture.create :name => "i386" end def self.down diff --git a/db/migrate/20100629093200_create_roles.rb b/db/migrate/20100629093200_create_roles.rb index 24d9be0f583..8f6cd6313e3 100644 --- a/db/migrate/20100629093200_create_roles.rb +++ b/db/migrate/20100629093200_create_roles.rb @@ -2,15 +2,15 @@ class CreateRoles < ActiveRecord::Migration def self.up add_column :users, :role_id, :integer create_table "roles", :force => true do |t| - t.column "name", :string, :limit => 30 - t.column "builtin", :integer - t.column "permissions", :text + t.string "name", :limit => 30 + t.integer "builtin" + t.text "permissions" end create_table :user_roles do |t| - t.column :user_id, :integer - t.column :role_id, :integer - t.columm :inherited_from, :integer + t.integer :user_id + t.integer :role_id + t.integer :inherited_from end end diff --git a/db/migrate/20111124095053_rename_changes_to_audited_changes.rb b/db/migrate/20111124095053_rename_changes_to_audited_changes.rb new file mode 100644 index 00000000000..f0bde3df0c4 --- /dev/null +++ b/db/migrate/20111124095053_rename_changes_to_audited_changes.rb @@ -0,0 +1,9 @@ +class RenameChangesToAuditedChanges < ActiveRecord::Migration + def self.up + rename_column :audits, :changes, :audited_changes + end + + def self.down + rename_column :audits, :audited_changes, :changes + end +end diff --git a/db/migrate/20111124095054_add_remote_address_to_audits.rb b/db/migrate/20111124095054_add_remote_address_to_audits.rb new file mode 100644 index 00000000000..0dcf94d6d6e --- /dev/null +++ b/db/migrate/20111124095054_add_remote_address_to_audits.rb @@ -0,0 +1,10 @@ +class AddRemoteAddressToAudits < ActiveRecord::Migration + def self.up + add_column :audits, :remote_address, :string + end + + def self.down + remove_column :audits, :remote_address + end +end + diff --git a/db/migrate/20111124095055_rename_parent_to_association.rb b/db/migrate/20111124095055_rename_parent_to_association.rb new file mode 100644 index 00000000000..b298d65cd4e --- /dev/null +++ b/db/migrate/20111124095055_rename_parent_to_association.rb @@ -0,0 +1,11 @@ +class RenameParentToAssociation < ActiveRecord::Migration + def self.up + rename_column :audits, :auditable_parent_id, :association_id + rename_column :audits, :auditable_parent_type, :association_type + end + + def self.down + rename_column :audits, :association_type, :auditable_parent_type + rename_column :audits, :association_id, :auditable_parent_id + end +end diff --git a/db/seeds.rb b/db/seeds.rb new file mode 100644 index 00000000000..a5500da3155 --- /dev/null +++ b/db/seeds.rb @@ -0,0 +1,9 @@ +# 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' }]) +# Mayor.create(:name => 'Daley', :city => cities.first) +Architecture.create :name => "x86_64" +Architecture.create :name => "i386" diff --git a/doc/README_FOR_APP b/doc/README_FOR_APP new file mode 100644 index 00000000000..fe41f5cc24d --- /dev/null +++ b/doc/README_FOR_APP @@ -0,0 +1,2 @@ +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/lib/core_extensions.rb b/lib/core_extensions.rb index 5c3f3c9f78c..12e6fd6667a 100644 --- a/lib/core_extensions.rb +++ b/lib/core_extensions.rb @@ -27,16 +27,18 @@ def update_single_attribute(attribute, value) "#{self.class.name} Attribute Update" ) end - class Ensure_not_used_by - def initialize(*attribute) + + # ActiveRecord Callback class + class EnsureNotUsedBy + def initialize *attribute @klasses = attribute - @logger = RAILS_DEFAULT_LOGGER + @logger = Rails.logger end def before_destroy(record) for klass in @klasses - for what in eval "record.#{klass.to_s}" - record.errors.add_to_base(record.to_label + " is used by " + what.to_s) + for what in record.send(klass.to_sym) + record.errors.add :base, "#{record} is used by #{what}" end end unless record.errors.empty? @@ -54,16 +56,14 @@ def id_and_type alias_attribute :to_label, :name alias_attribute :to_s, :to_label - def self.per_page - Setting["entries_per_page"] - end - def self.unconfigured? first.nil? end end + + module ExemptedFromLogging def process(request, *args) logger.silence { super } @@ -86,16 +86,3 @@ def to_gb end end end -module ActionView::Helpers::ActiveRecordHelper - def error_messages_for_with_customisation(*params) - if flash[:error_customisation] - if params[-1].is_a? Hash - params[-1].update flash[:error_customisation] - else - params << flash[:error_customisation] - end - end - error_messages_for_without_customisation(*params) - end - alias_method_chain :error_messages_for, :customisation -end diff --git a/lib/foreman.rb b/lib/foreman.rb new file mode 100644 index 00000000000..2920ff93bbe --- /dev/null +++ b/lib/foreman.rb @@ -0,0 +1,9 @@ +require 'foreman/access_permissions' +require 'foreman/default_data/loader' +require 'foreman/default_settings/loader' +require 'foreman/renderer' +require 'foreman/controller' +require 'net' + +module Foreman +end diff --git a/lib/access_permissions.rb b/lib/foreman/access_permissions.rb similarity index 100% rename from lib/access_permissions.rb rename to lib/foreman/access_permissions.rb diff --git a/lib/foreman/controller.rb b/lib/foreman/controller.rb new file mode 100644 index 00000000000..7356a843d1b --- /dev/null +++ b/lib/foreman/controller.rb @@ -0,0 +1,2 @@ +module Foreman::Controller +end diff --git a/lib/foreman/controller/environments.rb b/lib/foreman/controller/environments.rb index 07c96398844..e5c44c95b54 100644 --- a/lib/foreman/controller/environments.rb +++ b/lib/foreman/controller/environments.rb @@ -5,7 +5,7 @@ module Foreman::Controller::Environments def import_environments @changed = Environment.importClasses if @changed["new"].size > 0 or @changed["obsolete"].size > 0 - render :partial => "common/puppetclasses_or_envs_changed", :layout => true + render "common/_puppetclasses_or_envs_changed" else notice "No changes to your environments detected" redirect_to "/" + controller_path diff --git a/lib/foreman/controller/host_details.rb b/lib/foreman/controller/host_details.rb index a6343fdcbfc..d6de790c482 100644 --- a/lib/foreman/controller/host_details.rb +++ b/lib/foreman/controller/host_details.rb @@ -40,7 +40,7 @@ def use_image_selected end def hypervisor_selected - hypervisor_id = params["#{item_name}_hypervisor_id".to_sym].to_i + hypervisor_id = params["hypervisor_id".to_sym].to_i # bare metal selected hypervisor_defaults and return if hypervisor_id == 0 @@ -88,7 +88,7 @@ def item_object end def update_hypervisor_details item, page - page.replace_html :virtual_machine, :partial => "common/hypervisor", :locals => { :item => item } + page['#virtual_machine'].html(render(:partial => "common/hypervisor", :locals => { :item => item })) page << "if ($('#host_mac')) $('#host_mac').parentsUntil('.clearfix').parent().remove()" end diff --git a/lib/foreman/default_data/loader.rb b/lib/foreman/default_data/loader.rb index aca32cedc01..f9dd537410f 100644 --- a/lib/foreman/default_data/loader.rb +++ b/lib/foreman/default_data/loader.rb @@ -35,27 +35,27 @@ def load(reset=false) Role.count rescue return Role.transaction do # Roles - manager = Role.name_is("Manager").empty? ? Role.create(:name => "Manager") : Role.name_is("Manager")[0] + manager = Role.where(:name => "Manager").empty? ? Role.create(:name => "Manager") : Role.where(:name => "Manager")[0] if reset or manager.permissions.empty? manager.update_attribute :permissions, manager.setable_permissions.collect {|p| p.name} end - ptable_editor = Role.name_is("Edit partition tables").empty? ? Role.create(:name => "Edit partition tables") : Role.name_is("Edit partition tables")[0] + ptable_editor = Role.where(:name => "Edit partition tables").empty? ? Role.create(:name => "Edit partition tables") : Role.where(:name => "Edit partition tables")[0] if reset or ptable_editor.permissions.empty? ptable_editor.update_attribute :permissions, [:view_ptables, :create_ptables, :edit_ptables, :destroy_ptables] end - hosts_reader = Role.name_is("View hosts").empty? ? Role.create(:name => "View hosts") : Role.name_is("View hosts")[0] + hosts_reader = Role.where(:name => "View hosts").empty? ? Role.create(:name => "View hosts") : Role.where(:name => "View hosts")[0] if reset or hosts_reader.permissions.empty? hosts_reader.update_attribute :permissions, [:view_hosts] end - hosts_editor = Role.name_is("Edit hosts").empty? ? Role.create(:name => "Edit hosts") : Role.name_is("Edit hosts")[0] + hosts_editor = Role.where(:name => "Edit hosts").empty? ? Role.create(:name => "Edit hosts") : Role.where(:name => "Edit hosts")[0] if reset or hosts_editor.permissions.empty? hosts_editor.update_attribute :permissions, [:view_hosts, :edit_hosts, :create_hosts, :destroy_hosts, :build_hosts] end - viewer = Role.name_is("Viewer").empty? ? Role.create(:name => "Viewer") : Role.name_is("Viewer")[0] + viewer = Role.where(:name => "Viewer").empty? ? Role.create(:name => "Viewer") : Role.where(:name => "Viewer")[0] if reset or viewer.permissions.empty? viewer.update_attribute :permissions, [:view_hosts, :view_puppetclasses, @@ -83,7 +83,7 @@ def load(reset=false) :view_audit_logs] end - siteman = Role.name_is("Site manager").empty? ? Role.create(:name => "Site manager") : Role.name_is("Site manager")[0] + siteman = Role.where(:name => "Site manager").empty? ? Role.create(:name => "Site manager") : Role.where(:name => "Site manager")[0] if reset or siteman.permissions.empty? siteman.update_attribute :permissions, [ :view_architectures, :view_audit_logs, diff --git a/lib/foreman/default_settings/loader.rb b/lib/foreman/default_settings/loader.rb index 5fcfd874233..4c220dd4bbe 100644 --- a/lib/foreman/default_settings/loader.rb +++ b/lib/foreman/default_settings/loader.rb @@ -44,7 +44,7 @@ def load(reset=false) set('puppet_interval', "Puppet interval in minutes", 30 ), set('default_puppet_environment',"The Puppet environment foreman would default to in case it can't auto detect it", "production"), set('modulepath',"The Puppet default module path in case that Foreman can't auto detect it", "/etc/puppet/modules"), - set('document_root', "Document root where puppetdoc files should be created", "#{RAILS_ROOT}/public/puppet/rdoc"), + set('document_root', "Document root where puppetdoc files should be created", "#{Rails.root}/public/puppet/rdoc"), set('puppetrun', "Enables Puppetrun Support", false), set('puppet_server', "Default Puppet Server hostname", "puppet"), set('failed_report_email_notification', "Enable Email Alerts per each failed puppet report", false), diff --git a/lib/foreman/renderer.rb b/lib/foreman/renderer.rb index 28fd585d13d..7241abb4e5c 100644 --- a/lib/foreman/renderer.rb +++ b/lib/foreman/renderer.rb @@ -9,6 +9,7 @@ def render_safe template, allowed_methods = [], allowed_vars = {} ERB.new(template, nil, '-').result(binding) end end + #returns the URL for Foreman Built status (when a host has finished the OS installation) def foreman_url(action = "built") url_for :only_path => false, :controller => "unattended", :action => action @@ -16,7 +17,7 @@ def foreman_url(action = "built") # provide embedded snippets support as simple erb templates def snippets(file) - unless ConfigTemplate.name_eq(file).snippet_eq(true).empty? + unless ConfigTemplate.where(:name => file, :snippet => true).empty? return snippet(file.gsub(/^_/,"")) else render :partial => "unattended/snippets/#{file}" @@ -24,7 +25,7 @@ def snippets(file) end def snippet name - if template = ConfigTemplate.name_eq(name).snippet_eq(true).first + if template = ConfigTemplate.where(:name => name, :snippet => true).first logger.debug "rendering snippet #{template.name}" begin return unattended_render(template.template) diff --git a/lib/net.rb b/lib/net.rb index 5f3910046fe..698010f3cd1 100644 --- a/lib/net.rb +++ b/lib/net.rb @@ -1,3 +1,5 @@ +require "net/validations" + module Net class Record include Net::Validations diff --git a/lib/proxy_api.rb b/lib/proxy_api.rb index 5a7bad7288a..68c0231e0e7 100644 --- a/lib/proxy_api.rb +++ b/lib/proxy_api.rb @@ -31,7 +31,7 @@ def initialize(args) @resource = RestClient::Resource.new(url, connect_params) end - def logger; RAILS_DEFAULT_LOGGER; end + def logger; Rails.logger; end private diff --git a/lib/tasks/.gitkeep b/lib/tasks/.gitkeep new file mode 100644 index 00000000000..e69de29bb2d diff --git a/lib/tasks/convert.rake b/lib/tasks/convert.rake index 269dc383f84..9f2e39e4db8 100644 --- a/lib/tasks/convert.rake +++ b/lib/tasks/convert.rake @@ -98,7 +98,7 @@ namespace :db do models.each do |model| new_model = DevelopmentModelClass.new(model.attributes) new_model.id = model.id - new_model.save(false) + new_model.save(:validate => false) end end break if args.records and args.records.to_i > offset diff --git a/lib/tasks/model.rake b/lib/tasks/model.rake index 4e1415f7ae1..10dffcf337f 100644 --- a/lib/tasks/model.rake +++ b/lib/tasks/model.rake @@ -66,7 +66,7 @@ def consolidate mappings, dryrun end unless dryrun model.hosts << valid_hosts - model.save(false) + model.save(:validate => false) if model.errors.empty? original.delete if original.hosts.count == 0 else diff --git a/lib/timed_cached_store.rb b/lib/timed_cached_store.rb index b7eceed9fa9..348602764b9 100644 --- a/lib/timed_cached_store.rb +++ b/lib/timed_cached_store.rb @@ -3,7 +3,7 @@ # it has a similar behaviour to memcached, but does not require memcache # however this will not clean up automatically, only upon request -class TimedCachedStore < ActiveSupport::Cache::SynchronizedMemoryStore +class TimedCachedStore < ActiveSupport::Cache::MemoryStore def exist?(name, options = nil) delete_if_expired name super @@ -52,4 +52,4 @@ def ts_field name "#{name}_timestamp" end -end \ No newline at end of file +end diff --git a/log/.gitkeep b/log/.gitkeep new file mode 100644 index 00000000000..e69de29bb2d diff --git a/public/404.html b/public/404.html index eff660b90c3..9a48320a5f1 100644 --- a/public/404.html +++ b/public/404.html @@ -1,23 +1,19 @@ - - - - + + - The page you were looking for doesn't exist (404) - + @@ -27,4 +23,4 @@

          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/public/422.html b/public/422.html index b54e4a3cadb..83660ab1878 100644 --- a/public/422.html +++ b/public/422.html @@ -1,23 +1,19 @@ - - - - + + - The change you wanted was rejected (422) - + @@ -27,4 +23,4 @@

          The change you wanted was rejected.

          Maybe you tried to change something you didn't have access to.

          - \ No newline at end of file + diff --git a/public/500.html b/public/500.html index ec3bbf02c43..b80307fc166 100644 --- a/public/500.html +++ b/public/500.html @@ -1,23 +1,19 @@ - - - - + + - We're sorry, but something went wrong (500) - + diff --git a/public/javascripts/application.js b/public/javascripts/application.js index 4d9cec6ef1e..c3ee88389a6 100644 --- a/public/javascripts/application.js +++ b/public/javascripts/application.js @@ -233,3 +233,21 @@ function filter_by_level(level){ $('#ntsh').hide(); } } + +function auth_source_selected(){ + var auth_source_id = $('#user_auth_source_id').attr('value'); + if (auth_source_id == '') return false; + $.ajax({ + type:'get', + url:'/users/auth_source_selected', + data:'auth_source_id=' + auth_source_id + }) +} +function show_release(element){ + var os_family = $(element).val(); + if (os_family == 'Debian' || os_family == 'Solaris') { + $("#release_name").show('highlight', 1000); + } else { + $("#release_name").hide(); + } +} diff --git a/public/javascripts/host_edit.js b/public/javascripts/host_edit.js new file mode 100644 index 00000000000..9fab41567f1 --- /dev/null +++ b/public/javascripts/host_edit.js @@ -0,0 +1,122 @@ +function add_puppet_class(item){ + var id = $(item).attr('data-class-id'); + var content = $(item).parent().clone(); + content.attr('title', 'Click to remove this class'); + content.attr('id', 'selected_puppetclass_'+ id); + content.append(""); + + var link = content.children().first(); + link.attr('onclick', 'remove_puppet_class(this)'); + link.removeClass('ui-icon-plus').addClass('ui-icon-minus'); + + $('#selected_classes').append(content) + + $("#selected_puppetclass_"+ id).show('highlight', 5000); + $("#puppetclass_"+ id).hide(); +} + +function remove_puppet_class(item){ + var id = $(item).attr('data-class-id'); + $('#puppetclass_' + id ).show(); + $('#selected_puppetclass_' + id).remove(); + + return false; +} + +function hostgroup_changed(element) { + var host_id = $(element).attr('data-host-id'); + var hostgroup_id = $('*[id*=hostgroup_id]').attr('value'); + if (hostgroup_id == undefined) hostgroup_id = $('#hostgroup_parent_id').attr('value'); + $('#hostgroup_indicator').show(); + if (!host_id){ // a new host + $.ajax({ + type:'post', + url:'/hosts/process_hostgroup', + data:'hostgroup_id=' + hostgroup_id, + complete: function(request){ + $('#hostgroup_indicator').hide(); + } + }) + } else { // edit host + update_puppetclasses(element); + } +} + +function update_puppetclasses(element) { + var host_id = $(element).attr('data-host-id'); + var env_id = $('*[id*=environment_id]').attr('value'); + var hostgroup_id = $('*[id*=hostgroup_id]').attr('value'); + if (env_id == "") return false; + $.ajax({ + type:'post', + url:'/hosts/hostgroup_or_environment_selected', + data:'host_id=' + host_id + '&hostgroup_id=' + hostgroup_id + '&environment_id=' + env_id, + success: function(request) { + $('#puppet_klasses').html(request); + }, + complete: function(request) { + $('#hostgroup_indicator').hide(); + } + }) +} +function hypervisor_selected(element){ + var hypervisor_id = $(element).val(); + $('#vm_indicator').show(); + $.ajax({ + data:'hypervisor_id=' + hypervisor_id, + type:'post', + url:'/hosts/hypervisor_selected', + complete: function(request){ + $('#vm_indicator').hide(); + if ($('#host_name').size() == 0 ) $('#host_powerup').parent().parent().remove(); + } + }) +} + +function subnet_selected(element){ + var subnet_id = $(element).val(); + if (subnet_id == '' || $('#host_ip').size() == 0) return false; + $('#subnet_indicator').show(); + $.ajax({ + data:'subnet_id=' + subnet_id, + type:'post', + url:'/subnets/freeip', + complete: function(request){$('#subnet_indicator').hide()} + }) +} + +function domain_selected(element){ + var domain_id = $(element).val(); + $.ajax({ + data:'domain_id=' + domain_id, + type:'post', + url:'/hosts/domain_selected', + success: function(request) { + $('#subnet_select').html(request); + } + }) +} + +function architecture_selected(element){ + var architecture_id = $(element).val(); + $.ajax({ + data:'architecture_id=' + architecture_id, + type:'post', + url:'/hosts/architecture_selected', + success: function(request) { + $('#os_select').html(request); + } + }) +} + +function os_selected(element){ + var operatingsystem_id = $(element).val(); + $.ajax({ + data:'operatingsystem_id=' + operatingsystem_id, + type:'post', + url:'/hosts/os_selected', + success: function(request) { + $('#media_select').html(request); + } + }) +} diff --git a/public/javascripts/jquery.js b/public/javascripts/jquery.js index 6437874c699..11e6d067962 100644 --- a/public/javascripts/jquery.js +++ b/public/javascripts/jquery.js @@ -1,5 +1,5 @@ /*! - * jQuery JavaScript Library v1.5.1 + * jQuery JavaScript Library v1.6.4 * http://jquery.com/ * * Copyright 2011, John Resig @@ -11,6 +11,9036 @@ * Copyright 2011, The Dojo Foundation * Released under the MIT, BSD, and GPL Licenses. * - * Date: Wed Feb 23 13:55:29 2011 -0500 + * Date: Mon Sep 12 18:54:48 2011 -0400 */ -(function(a,b){function cg(a){return d.isWindow(a)?a:a.nodeType===9?a.defaultView||a.parentWindow:!1}function cd(a){if(!bZ[a]){var b=d("<"+a+">").appendTo("body"),c=b.css("display");b.remove();if(c==="none"||c==="")c="block";bZ[a]=c}return bZ[a]}function cc(a,b){var c={};d.each(cb.concat.apply([],cb.slice(0,b)),function(){c[this]=a});return c}function bY(){try{return new a.ActiveXObject("Microsoft.XMLHTTP")}catch(b){}}function bX(){try{return new a.XMLHttpRequest}catch(b){}}function bW(){d(a).unload(function(){for(var a in bU)bU[a](0,1)})}function bQ(a,c){a.dataFilter&&(c=a.dataFilter(c,a.dataType));var e=a.dataTypes,f={},g,h,i=e.length,j,k=e[0],l,m,n,o,p;for(g=1;g=0===c})}function N(a){return!a||!a.parentNode||a.parentNode.nodeType===11}function F(a,b){return(a&&a!=="*"?a+".":"")+b.replace(r,"`").replace(s,"&")}function E(a){var b,c,e,f,g,h,i,j,k,l,m,n,o,q=[],r=[],s=d._data(this,"events");if(a.liveFired!==this&&s&&s.live&&!a.target.disabled&&(!a.button||a.type!=="click")){a.namespace&&(n=new RegExp("(^|\\.)"+a.namespace.split(".").join("\\.(?:.*\\.)?")+"(\\.|$)")),a.liveFired=this;var t=s.live.slice(0);for(i=0;ic)break;a.currentTarget=f.elem,a.data=f.handleObj.data,a.handleObj=f.handleObj,o=f.handleObj.origHandler.apply(f.elem,arguments);if(o===!1||a.isPropagationStopped()){c=f.level,o===!1&&(b=!1);if(a.isImmediatePropagationStopped())break}}return b}}function C(a,c,e){var f=d.extend({},e[0]);f.type=a,f.originalEvent={},f.liveFired=b,d.event.handle.call(c,f),f.isDefaultPrevented()&&e[0].preventDefault()}function w(){return!0}function v(){return!1}function g(a){for(var b in a)if(b!=="toJSON")return!1;return!0}function f(a,c,f){if(f===b&&a.nodeType===1){f=a.getAttribute("data-"+c);if(typeof f==="string"){try{f=f==="true"?!0:f==="false"?!1:f==="null"?null:d.isNaN(f)?e.test(f)?d.parseJSON(f):f:parseFloat(f)}catch(g){}d.data(a,c,f)}else f=b}return f}var c=a.document,d=function(){function I(){if(!d.isReady){try{c.documentElement.doScroll("left")}catch(a){setTimeout(I,1);return}d.ready()}}var d=function(a,b){return new d.fn.init(a,b,g)},e=a.jQuery,f=a.$,g,h=/^(?:[^<]*(<[\w\W]+>)[^>]*$|#([\w\-]+)$)/,i=/\S/,j=/^\s+/,k=/\s+$/,l=/\d/,m=/^<(\w+)\s*\/?>(?:<\/\1>)?$/,n=/^[\],:{}\s]*$/,o=/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,p=/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,q=/(?:^|:|,)(?:\s*\[)+/g,r=/(webkit)[ \/]([\w.]+)/,s=/(opera)(?:.*version)?[ \/]([\w.]+)/,t=/(msie) ([\w.]+)/,u=/(mozilla)(?:.*? rv:([\w.]+))?/,v=navigator.userAgent,w,x=!1,y,z="then done fail isResolved isRejected promise".split(" "),A,B=Object.prototype.toString,C=Object.prototype.hasOwnProperty,D=Array.prototype.push,E=Array.prototype.slice,F=String.prototype.trim,G=Array.prototype.indexOf,H={};d.fn=d.prototype={constructor:d,init:function(a,e,f){var g,i,j,k;if(!a)return this;if(a.nodeType){this.context=this[0]=a,this.length=1;return this}if(a==="body"&&!e&&c.body){this.context=c,this[0]=c.body,this.selector="body",this.length=1;return this}if(typeof a==="string"){g=h.exec(a);if(!g||!g[1]&&e)return!e||e.jquery?(e||f).find(a):this.constructor(e).find(a);if(g[1]){e=e instanceof d?e[0]:e,k=e?e.ownerDocument||e:c,j=m.exec(a),j?d.isPlainObject(e)?(a=[c.createElement(j[1])],d.fn.attr.call(a,e,!0)):a=[k.createElement(j[1])]:(j=d.buildFragment([g[1]],[k]),a=(j.cacheable?d.clone(j.fragment):j.fragment).childNodes);return d.merge(this,a)}i=c.getElementById(g[2]);if(i&&i.parentNode){if(i.id!==g[2])return f.find(a);this.length=1,this[0]=i}this.context=c,this.selector=a;return this}if(d.isFunction(a))return f.ready(a);a.selector!==b&&(this.selector=a.selector,this.context=a.context);return d.makeArray(a,this)},selector:"",jquery:"1.5.1",length:0,size:function(){return this.length},toArray:function(){return E.call(this,0)},get:function(a){return a==null?this.toArray():a<0?this[this.length+a]:this[a]},pushStack:function(a,b,c){var e=this.constructor();d.isArray(a)?D.apply(e,a):d.merge(e,a),e.prevObject=this,e.context=this.context,b==="find"?e.selector=this.selector+(this.selector?" ":"")+c:b&&(e.selector=this.selector+"."+b+"("+c+")");return e},each:function(a,b){return d.each(this,a,b)},ready:function(a){d.bindReady(),y.done(a);return this},eq:function(a){return a===-1?this.slice(a):this.slice(a,+a+1)},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},slice:function(){return this.pushStack(E.apply(this,arguments),"slice",E.call(arguments).join(","))},map:function(a){return this.pushStack(d.map(this,function(b,c){return a.call(b,c,b)}))},end:function(){return this.prevObject||this.constructor(null)},push:D,sort:[].sort,splice:[].splice},d.fn.init.prototype=d.fn,d.extend=d.fn.extend=function(){var a,c,e,f,g,h,i=arguments[0]||{},j=1,k=arguments.length,l=!1;typeof i==="boolean"&&(l=i,i=arguments[1]||{},j=2),typeof i!=="object"&&!d.isFunction(i)&&(i={}),k===j&&(i=this,--j);for(;j0)return;y.resolveWith(c,[d]),d.fn.trigger&&d(c).trigger("ready").unbind("ready")}},bindReady:function(){if(!x){x=!0;if(c.readyState==="complete")return setTimeout(d.ready,1);if(c.addEventListener)c.addEventListener("DOMContentLoaded",A,!1),a.addEventListener("load",d.ready,!1);else if(c.attachEvent){c.attachEvent("onreadystatechange",A),a.attachEvent("onload",d.ready);var b=!1;try{b=a.frameElement==null}catch(e){}c.documentElement.doScroll&&b&&I()}}},isFunction:function(a){return d.type(a)==="function"},isArray:Array.isArray||function(a){return d.type(a)==="array"},isWindow:function(a){return a&&typeof a==="object"&&"setInterval"in a},isNaN:function(a){return a==null||!l.test(a)||isNaN(a)},type:function(a){return a==null?String(a):H[B.call(a)]||"object"},isPlainObject:function(a){if(!a||d.type(a)!=="object"||a.nodeType||d.isWindow(a))return!1;if(a.constructor&&!C.call(a,"constructor")&&!C.call(a.constructor.prototype,"isPrototypeOf"))return!1;var c;for(c in a){}return c===b||C.call(a,c)},isEmptyObject:function(a){for(var b in a)return!1;return!0},error:function(a){throw a},parseJSON:function(b){if(typeof b!=="string"||!b)return null;b=d.trim(b);if(n.test(b.replace(o,"@").replace(p,"]").replace(q,"")))return a.JSON&&a.JSON.parse?a.JSON.parse(b):(new Function("return "+b))();d.error("Invalid JSON: "+b)},parseXML:function(b,c,e){a.DOMParser?(e=new DOMParser,c=e.parseFromString(b,"text/xml")):(c=new ActiveXObject("Microsoft.XMLDOM"),c.async="false",c.loadXML(b)),e=c.documentElement,(!e||!e.nodeName||e.nodeName==="parsererror")&&d.error("Invalid XML: "+b);return c},noop:function(){},globalEval:function(a){if(a&&i.test(a)){var b=c.head||c.getElementsByTagName("head")[0]||c.documentElement,e=c.createElement("script");d.support.scriptEval()?e.appendChild(c.createTextNode(a)):e.text=a,b.insertBefore(e,b.firstChild),b.removeChild(e)}},nodeName:function(a,b){return a.nodeName&&a.nodeName.toUpperCase()===b.toUpperCase()},each:function(a,c,e){var f,g=0,h=a.length,i=h===b||d.isFunction(a);if(e){if(i){for(f in a)if(c.apply(a[f],e)===!1)break}else for(;g1){var f=E.call(arguments,0),g=b,h=function(a){return function(b){f[a]=arguments.length>1?E.call(arguments,0):b,--g||c.resolveWith(e,f)}};while(b--)a=f[b],a&&d.isFunction(a.promise)?a.promise().then(h(b),c.reject):--g;g||c.resolveWith(e,f)}else c!==a&&c.resolve(a);return e},uaMatch:function(a){a=a.toLowerCase();var b=r.exec(a)||s.exec(a)||t.exec(a)||a.indexOf("compatible")<0&&u.exec(a)||[];return{browser:b[1]||"",version:b[2]||"0"}},sub:function(){function a(b,c){return new a.fn.init(b,c)}d.extend(!0,a,this),a.superclass=this,a.fn=a.prototype=this(),a.fn.constructor=a,a.subclass=this.subclass,a.fn.init=function b(b,c){c&&c instanceof d&&!(c instanceof a)&&(c=a(c));return d.fn.init.call(this,b,c,e)},a.fn.init.prototype=a.fn;var e=a(c);return a},browser:{}}),y=d._Deferred(),d.each("Boolean Number String Function Array Date RegExp Object".split(" "),function(a,b){H["[object "+b+"]"]=b.toLowerCase()}),w=d.uaMatch(v),w.browser&&(d.browser[w.browser]=!0,d.browser.version=w.version),d.browser.webkit&&(d.browser.safari=!0),G&&(d.inArray=function(a,b){return G.call(b,a)}),i.test(" ")&&(j=/^[\s\xA0]+/,k=/[\s\xA0]+$/),g=d(c),c.addEventListener?A=function(){c.removeEventListener("DOMContentLoaded",A,!1),d.ready()}:c.attachEvent&&(A=function(){c.readyState==="complete"&&(c.detachEvent("onreadystatechange",A),d.ready())});return d}();(function(){d.support={};var b=c.createElement("div");b.style.display="none",b.innerHTML="
          a";var e=b.getElementsByTagName("*"),f=b.getElementsByTagName("a")[0],g=c.createElement("select"),h=g.appendChild(c.createElement("option")),i=b.getElementsByTagName("input")[0];if(e&&e.length&&f){d.support={leadingWhitespace:b.firstChild.nodeType===3,tbody:!b.getElementsByTagName("tbody").length,htmlSerialize:!!b.getElementsByTagName("link").length,style:/red/.test(f.getAttribute("style")),hrefNormalized:f.getAttribute("href")==="/a",opacity:/^0.55$/.test(f.style.opacity),cssFloat:!!f.style.cssFloat,checkOn:i.value==="on",optSelected:h.selected,deleteExpando:!0,optDisabled:!1,checkClone:!1,noCloneEvent:!0,noCloneChecked:!0,boxModel:null,inlineBlockNeedsLayout:!1,shrinkWrapBlocks:!1,reliableHiddenOffsets:!0},i.checked=!0,d.support.noCloneChecked=i.cloneNode(!0).checked,g.disabled=!0,d.support.optDisabled=!h.disabled;var j=null;d.support.scriptEval=function(){if(j===null){var b=c.documentElement,e=c.createElement("script"),f="script"+d.now();try{e.appendChild(c.createTextNode("window."+f+"=1;"))}catch(g){}b.insertBefore(e,b.firstChild),a[f]?(j=!0,delete a[f]):j=!1,b.removeChild(e),b=e=f=null}return j};try{delete b.test}catch(k){d.support.deleteExpando=!1}!b.addEventListener&&b.attachEvent&&b.fireEvent&&(b.attachEvent("onclick",function l(){d.support.noCloneEvent=!1,b.detachEvent("onclick",l)}),b.cloneNode(!0).fireEvent("onclick")),b=c.createElement("div"),b.innerHTML="";var m=c.createDocumentFragment();m.appendChild(b.firstChild),d.support.checkClone=m.cloneNode(!0).cloneNode(!0).lastChild.checked,d(function(){var a=c.createElement("div"),b=c.getElementsByTagName("body")[0];if(b){a.style.width=a.style.paddingLeft="1px",b.appendChild(a),d.boxModel=d.support.boxModel=a.offsetWidth===2,"zoom"in a.style&&(a.style.display="inline",a.style.zoom=1,d.support.inlineBlockNeedsLayout=a.offsetWidth===2,a.style.display="",a.innerHTML="
          ",d.support.shrinkWrapBlocks=a.offsetWidth!==2),a.innerHTML="
          t
          ";var e=a.getElementsByTagName("td");d.support.reliableHiddenOffsets=e[0].offsetHeight===0,e[0].style.display="",e[1].style.display="none",d.support.reliableHiddenOffsets=d.support.reliableHiddenOffsets&&e[0].offsetHeight===0,a.innerHTML="",b.removeChild(a).style.display="none",a=e=null}});var n=function(a){var b=c.createElement("div");a="on"+a;if(!b.attachEvent)return!0;var d=a in b;d||(b.setAttribute(a,"return;"),d=typeof b[a]==="function"),b=null;return d};d.support.submitBubbles=n("submit"),d.support.changeBubbles=n("change"),b=e=f=null}})();var e=/^(?:\{.*\}|\[.*\])$/;d.extend({cache:{},uuid:0,expando:"jQuery"+(d.fn.jquery+Math.random()).replace(/\D/g,""),noData:{embed:!0,object:"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000",applet:!0},hasData:function(a){a=a.nodeType?d.cache[a[d.expando]]:a[d.expando];return!!a&&!g(a)},data:function(a,c,e,f){if(d.acceptData(a)){var g=d.expando,h=typeof c==="string",i,j=a.nodeType,k=j?d.cache:a,l=j?a[d.expando]:a[d.expando]&&d.expando;if((!l||f&&l&&!k[l][g])&&h&&e===b)return;l||(j?a[d.expando]=l=++d.uuid:l=d.expando),k[l]||(k[l]={},j||(k[l].toJSON=d.noop));if(typeof c==="object"||typeof c==="function")f?k[l][g]=d.extend(k[l][g],c):k[l]=d.extend(k[l],c);i=k[l],f&&(i[g]||(i[g]={}),i=i[g]),e!==b&&(i[c]=e);if(c==="events"&&!i[c])return i[g]&&i[g].events;return h?i[c]:i}},removeData:function(b,c,e){if(d.acceptData(b)){var f=d.expando,h=b.nodeType,i=h?d.cache:b,j=h?b[d.expando]:d.expando;if(!i[j])return;if(c){var k=e?i[j][f]:i[j];if(k){delete k[c];if(!g(k))return}}if(e){delete i[j][f];if(!g(i[j]))return}var l=i[j][f];d.support.deleteExpando||i!=a?delete i[j]:i[j]=null,l?(i[j]={},h||(i[j].toJSON=d.noop),i[j][f]=l):h&&(d.support.deleteExpando?delete b[d.expando]:b.removeAttribute?b.removeAttribute(d.expando):b[d.expando]=null)}},_data:function(a,b,c){return d.data(a,b,c,!0)},acceptData:function(a){if(a.nodeName){var b=d.noData[a.nodeName.toLowerCase()];if(b)return b!==!0&&a.getAttribute("classid")===b}return!0}}),d.fn.extend({data:function(a,c){var e=null;if(typeof a==="undefined"){if(this.length){e=d.data(this[0]);if(this[0].nodeType===1){var g=this[0].attributes,h;for(var i=0,j=g.length;i-1)return!0;return!1},val:function(a){if(!arguments.length){var c=this[0];if(c){if(d.nodeName(c,"option")){var e=c.attributes.value;return!e||e.specified?c.value:c.text}if(d.nodeName(c,"select")){var f=c.selectedIndex,g=[],h=c.options,i=c.type==="select-one";if(f<0)return null;for(var k=i?f:0,l=i?f+1:h.length;k=0;else if(d.nodeName(this,"select")){var f=d.makeArray(e);d("option",this).each(function(){this.selected=d.inArray(d(this).val(),f)>=0}),f.length||(this.selectedIndex=-1)}else this.value=e}})}}),d.extend({attrFn:{val:!0,css:!0,html:!0,text:!0,data:!0,width:!0,height:!0,offset:!0},attr:function(a,c,e,f){if(!a||a.nodeType===3||a.nodeType===8||a.nodeType===2)return b;if(f&&c in d.attrFn)return d(a)[c](e);var g=a.nodeType!==1||!d.isXMLDoc(a),h=e!==b;c=g&&d.props[c]||c;if(a.nodeType===1){var i=k.test(c);if(c==="selected"&&!d.support.optSelected){var j=a.parentNode;j&&(j.selectedIndex,j.parentNode&&j.parentNode.selectedIndex)}if((c in a||a[c]!==b)&&g&&!i){h&&(c==="type"&&l.test(a.nodeName)&&a.parentNode&&d.error("type property can't be changed"),e===null?a.nodeType===1&&a.removeAttribute(c):a[c]=e);if(d.nodeName(a,"form")&&a.getAttributeNode(c))return a.getAttributeNode(c).nodeValue;if(c==="tabIndex"){var o=a.getAttributeNode("tabIndex");return o&&o.specified?o.value:m.test(a.nodeName)||n.test(a.nodeName)&&a.href?0:b}return a[c]}if(!d.support.style&&g&&c==="style"){h&&(a.style.cssText=""+e);return a.style.cssText}h&&a.setAttribute(c,""+e);if(!a.attributes[c]&&(a.hasAttribute&&!a.hasAttribute(c)))return b;var p=!d.support.hrefNormalized&&g&&i?a.getAttribute(c,2):a.getAttribute(c);return p===null?b:p}h&&(a[c]=e);return a[c]}});var p=/\.(.*)$/,q=/^(?:textarea|input|select)$/i,r=/\./g,s=/ /g,t=/[^\w\s.|`]/g,u=function(a){return a.replace(t,"\\$&")};d.event={add:function(c,e,f,g){if(c.nodeType!==3&&c.nodeType!==8){try{d.isWindow(c)&&(c!==a&&!c.frameElement)&&(c=a)}catch(h){}if(f===!1)f=v;else if(!f)return;var i,j;f.handler&&(i=f,f=i.handler),f.guid||(f.guid=d.guid++);var k=d._data(c);if(!k)return;var l=k.events,m=k.handle;l||(k.events=l={}),m||(k.handle=m=function(){return typeof d!=="undefined"&&!d.event.triggered?d.event.handle.apply(m.elem,arguments):b}),m.elem=c,e=e.split(" ");var n,o=0,p;while(n=e[o++]){j=i?d.extend({},i):{handler:f,data:g},n.indexOf(".")>-1?(p=n.split("."),n=p.shift(),j.namespace=p.slice(0).sort().join(".")):(p=[],j.namespace=""),j.type=n,j.guid||(j.guid=f.guid);var q=l[n],r=d.event.special[n]||{};if(!q){q=l[n]=[];if(!r.setup||r.setup.call(c,g,p,m)===!1)c.addEventListener?c.addEventListener(n,m,!1):c.attachEvent&&c.attachEvent("on"+n,m)}r.add&&(r.add.call(c,j),j.handler.guid||(j.handler.guid=f.guid)),q.push(j),d.event.global[n]=!0}c=null}},global:{},remove:function(a,c,e,f){if(a.nodeType!==3&&a.nodeType!==8){e===!1&&(e=v);var g,h,i,j,k=0,l,m,n,o,p,q,r,s=d.hasData(a)&&d._data(a),t=s&&s.events;if(!s||!t)return;c&&c.type&&(e=c.handler,c=c.type);if(!c||typeof c==="string"&&c.charAt(0)==="."){c=c||"";for(h in t)d.event.remove(a,h+c);return}c=c.split(" ");while(h=c[k++]){r=h,q=null,l=h.indexOf(".")<0,m=[],l||(m=h.split("."),h=m.shift(),n=new RegExp("(^|\\.)"+d.map(m.slice(0).sort(),u).join("\\.(?:.*\\.)?")+"(\\.|$)")),p=t[h];if(!p)continue;if(!e){for(j=0;j=0&&(a.type=f=f.slice(0,-1),a.exclusive=!0),e||(a.stopPropagation(),d.event.global[f]&&d.each(d.cache,function(){var b=d.expando,e=this[b];e&&e.events&&e.events[f]&&d.event.trigger(a,c,e.handle.elem)}));if(!e||e.nodeType===3||e.nodeType===8)return b;a.result=b,a.target=e,c=d.makeArray(c),c.unshift(a)}a.currentTarget=e;var h=d._data(e,"handle");h&&h.apply(e,c);var i=e.parentNode||e.ownerDocument;try{e&&e.nodeName&&d.noData[e.nodeName.toLowerCase()]||e["on"+f]&&e["on"+f].apply(e,c)===!1&&(a.result=!1,a.preventDefault())}catch(j){}if(!a.isPropagationStopped()&&i)d.event.trigger(a,c,i,!0);else if(!a.isDefaultPrevented()){var k,l=a.target,m=f.replace(p,""),n=d.nodeName(l,"a")&&m==="click",o=d.event.special[m]||{};if((!o._default||o._default.call(e,a)===!1)&&!n&&!(l&&l.nodeName&&d.noData[l.nodeName.toLowerCase()])){try{l[m]&&(k=l["on"+m],k&&(l["on"+m]=null),d.event.triggered=!0,l[m]())}catch(q){}k&&(l["on"+m]=k),d.event.triggered=!1}}},handle:function(c){var e,f,g,h,i,j=[],k=d.makeArray(arguments);c=k[0]=d.event.fix(c||a.event),c.currentTarget=this,e=c.type.indexOf(".")<0&&!c.exclusive,e||(g=c.type.split("."),c.type=g.shift(),j=g.slice(0).sort(),h=new RegExp("(^|\\.)"+j.join("\\.(?:.*\\.)?")+"(\\.|$)")),c.namespace=c.namespace||j.join("."),i=d._data(this,"events"),f=(i||{})[c.type];if(i&&f){f=f.slice(0);for(var l=0,m=f.length;l-1?d.map(a.options,function(a){return a.selected}).join("-"):"":a.nodeName.toLowerCase()==="select"&&(c=a.selectedIndex);return c},B=function B(a){var c=a.target,e,f;if(q.test(c.nodeName)&&!c.readOnly){e=d._data(c,"_change_data"),f=A(c),(a.type!=="focusout"||c.type!=="radio")&&d._data(c,"_change_data",f);if(e===b||f===e)return;if(e!=null||f)a.type="change",a.liveFired=b,d.event.trigger(a,arguments[1],c)}};d.event.special.change={filters:{focusout:B,beforedeactivate:B,click:function(a){var b=a.target,c=b.type;(c==="radio"||c==="checkbox"||b.nodeName.toLowerCase()==="select")&&B.call(this,a)},keydown:function(a){var b=a.target,c=b.type;(a.keyCode===13&&b.nodeName.toLowerCase()!=="textarea"||a.keyCode===32&&(c==="checkbox"||c==="radio")||c==="select-multiple")&&B.call(this,a)},beforeactivate:function(a){var b=a.target;d._data(b,"_change_data",A(b))}},setup:function(a,b){if(this.type==="file")return!1;for(var c in z)d.event.add(this,c+".specialChange",z[c]);return q.test(this.nodeName)},teardown:function(a){d.event.remove(this,".specialChange");return q.test(this.nodeName)}},z=d.event.special.change.filters,z.focus=z.beforeactivate}c.addEventListener&&d.each({focus:"focusin",blur:"focusout"},function(a,b){function c(a){a=d.event.fix(a),a.type=b;return d.event.handle.call(this,a)}d.event.special[b]={setup:function(){this.addEventListener(a,c,!0)},teardown:function(){this.removeEventListener(a,c,!0)}}}),d.each(["bind","one"],function(a,c){d.fn[c]=function(a,e,f){if(typeof a==="object"){for(var g in a)this[c](g,e,a[g],f);return this}if(d.isFunction(e)||e===!1)f=e,e=b;var h=c==="one"?d.proxy(f,function(a){d(this).unbind(a,h);return f.apply(this,arguments)}):f;if(a==="unload"&&c!=="one")this.one(a,e,f);else for(var i=0,j=this.length;i0?this.bind(b,a,c):this.trigger(b)},d.attrFn&&(d.attrFn[b]=!0)}),function(){function u(a,b,c,d,e,f){for(var g=0,h=d.length;g0){j=i;break}}i=i[a]}d[g]=j}}}function t(a,b,c,d,e,f){for(var g=0,h=d.length;g+~,(\[\\]+)+|[>+~])(\s*,\s*)?((?:.|\r|\n)*)/g,e=0,f=Object.prototype.toString,g=!1,h=!0,i=/\\/g,j=/\W/;[0,0].sort(function(){h=!1;return 0});var k=function(b,d,e,g){e=e||[],d=d||c;var h=d;if(d.nodeType!==1&&d.nodeType!==9)return[];if(!b||typeof b!=="string")return e;var i,j,n,o,q,r,s,t,u=!0,w=k.isXML(d),x=[],y=b;do{a.exec(""),i=a.exec(y);if(i){y=i[3],x.push(i[1]);if(i[2]){o=i[3];break}}}while(i);if(x.length>1&&m.exec(b))if(x.length===2&&l.relative[x[0]])j=v(x[0]+x[1],d);else{j=l.relative[x[0]]?[d]:k(x.shift(),d);while(x.length)b=x.shift(),l.relative[b]&&(b+=x.shift()),j=v(b,j)}else{!g&&x.length>1&&d.nodeType===9&&!w&&l.match.ID.test(x[0])&&!l.match.ID.test(x[x.length-1])&&(q=k.find(x.shift(),d,w),d=q.expr?k.filter(q.expr,q.set)[0]:q.set[0]);if(d){q=g?{expr:x.pop(),set:p(g)}:k.find(x.pop(),x.length===1&&(x[0]==="~"||x[0]==="+")&&d.parentNode?d.parentNode:d,w),j=q.expr?k.filter(q.expr,q.set):q.set,x.length>0?n=p(j):u=!1;while(x.length)r=x.pop(),s=r,l.relative[r]?s=x.pop():r="",s==null&&(s=d),l.relative[r](n,s,w)}else n=x=[]}n||(n=j),n||k.error(r||b);if(f.call(n)==="[object Array]")if(u)if(d&&d.nodeType===1)for(t=0;n[t]!=null;t++)n[t]&&(n[t]===!0||n[t].nodeType===1&&k.contains(d,n[t]))&&e.push(j[t]);else for(t=0;n[t]!=null;t++)n[t]&&n[t].nodeType===1&&e.push(j[t]);else e.push.apply(e,n);else p(n,e);o&&(k(o,h,e,g),k.uniqueSort(e));return e};k.uniqueSort=function(a){if(r){g=h,a.sort(r);if(g)for(var b=1;b0},k.find=function(a,b,c){var d;if(!a)return[];for(var e=0,f=l.order.length;e":function(a,b){var c,d=typeof b==="string",e=0,f=a.length;if(d&&!j.test(b)){b=b.toLowerCase();for(;e=0)?c||d.push(h):c&&(b[g]=!1));return!1},ID:function(a){return a[1].replace(i,"")},TAG:function(a,b){return a[1].replace(i,"").toLowerCase()},CHILD:function(a){if(a[1]==="nth"){a[2]||k.error(a[0]),a[2]=a[2].replace(/^\+|\s*/g,"");var b=/(-?)(\d*)(?:n([+\-]?\d*))?/.exec(a[2]==="even"&&"2n"||a[2]==="odd"&&"2n+1"||!/\D/.test(a[2])&&"0n+"+a[2]||a[2]);a[2]=b[1]+(b[2]||1)-0,a[3]=b[3]-0}else a[2]&&k.error(a[0]);a[0]=e++;return a},ATTR:function(a,b,c,d,e,f){var g=a[1]=a[1].replace(i,"");!f&&l.attrMap[g]&&(a[1]=l.attrMap[g]),a[4]=(a[4]||a[5]||"").replace(i,""),a[2]==="~="&&(a[4]=" "+a[4]+" ");return a},PSEUDO:function(b,c,d,e,f){if(b[1]==="not")if((a.exec(b[3])||"").length>1||/^\w/.test(b[3]))b[3]=k(b[3],null,null,c);else{var g=k.filter(b[3],c,d,!0^f);d||e.push.apply(e,g);return!1}else if(l.match.POS.test(b[0])||l.match.CHILD.test(b[0]))return!0;return b},POS:function(a){a.unshift(!0);return a}},filters:{enabled:function(a){return a.disabled===!1&&a.type!=="hidden"},disabled:function(a){return a.disabled===!0},checked:function(a){return a.checked===!0},selected:function(a){a.parentNode&&a.parentNode.selectedIndex;return a.selected===!0},parent:function(a){return!!a.firstChild},empty:function(a){return!a.firstChild},has:function(a,b,c){return!!k(c[3],a).length},header:function(a){return/h\d/i.test(a.nodeName)},text:function(a){return"text"===a.getAttribute("type")},radio:function(a){return"radio"===a.type},checkbox:function(a){return"checkbox"===a.type},file:function(a){return"file"===a.type},password:function(a){return"password"===a.type},submit:function(a){return"submit"===a.type},image:function(a){return"image"===a.type},reset:function(a){return"reset"===a.type},button:function(a){return"button"===a.type||a.nodeName.toLowerCase()==="button"},input:function(a){return/input|select|textarea|button/i.test(a.nodeName)}},setFilters:{first:function(a,b){return b===0},last:function(a,b,c,d){return b===d.length-1},even:function(a,b){return b%2===0},odd:function(a,b){return b%2===1},lt:function(a,b,c){return bc[3]-0},nth:function(a,b,c){return c[3]-0===b},eq:function(a,b,c){return c[3]-0===b}},filter:{PSEUDO:function(a,b,c,d){var e=b[1],f=l.filters[e];if(f)return f(a,c,b,d);if(e==="contains")return(a.textContent||a.innerText||k.getText([a])||"").indexOf(b[3])>=0;if(e==="not"){var g=b[3];for(var h=0,i=g.length;h=0}},ID:function(a,b){return a.nodeType===1&&a.getAttribute("id")===b},TAG:function(a,b){return b==="*"&&a.nodeType===1||a.nodeName.toLowerCase()===b},CLASS:function(a,b){return(" "+(a.className||a.getAttribute("class"))+" ").indexOf(b)>-1},ATTR:function(a,b){var c=b[1],d=l.attrHandle[c]?l.attrHandle[c](a):a[c]!=null?a[c]:a.getAttribute(c),e=d+"",f=b[2],g=b[4];return d==null?f==="!=":f==="="?e===g:f==="*="?e.indexOf(g)>=0:f==="~="?(" "+e+" ").indexOf(g)>=0:g?f==="!="?e!==g:f==="^="?e.indexOf(g)===0:f==="$="?e.substr(e.length-g.length)===g:f==="|="?e===g||e.substr(0,g.length+1)===g+"-":!1:e&&d!==!1},POS:function(a,b,c,d){var e=b[2],f=l.setFilters[e];if(f)return f(a,c,b,d)}}},m=l.match.POS,n=function(a,b){return"\\"+(b-0+1)};for(var o in l.match)l.match[o]=new RegExp(l.match[o].source+/(?![^\[]*\])(?![^\(]*\))/.source),l.leftMatch[o]=new RegExp(/(^(?:.|\r|\n)*?)/.source+l.match[o].source.replace(/\\(\d+)/g,n));var p=function(a,b){a=Array.prototype.slice.call(a,0);if(b){b.push.apply(b,a);return b}return a};try{Array.prototype.slice.call(c.documentElement.childNodes,0)[0].nodeType}catch(q){p=function(a,b){var c=0,d=b||[];if(f.call(a)==="[object Array]")Array.prototype.push.apply(d,a);else if(typeof a.length==="number")for(var e=a.length;c",e.insertBefore(a,e.firstChild),c.getElementById(d)&&(l.find.ID=function(a,c,d){if(typeof c.getElementById!=="undefined"&&!d){var e=c.getElementById(a[1]);return e?e.id===a[1]||typeof e.getAttributeNode!=="undefined"&&e.getAttributeNode("id").nodeValue===a[1]?[e]:b:[]}},l.filter.ID=function(a,b){var c=typeof a.getAttributeNode!=="undefined"&&a.getAttributeNode("id");return a.nodeType===1&&c&&c.nodeValue===b}),e.removeChild(a),e=a=null}(),function(){var a=c.createElement("div");a.appendChild(c.createComment("")),a.getElementsByTagName("*").length>0&&(l.find.TAG=function(a,b){var c=b.getElementsByTagName(a[1]);if(a[1]==="*"){var d=[];for(var e=0;c[e];e++)c[e].nodeType===1&&d.push(c[e]);c=d}return c}),a.innerHTML="",a.firstChild&&typeof a.firstChild.getAttribute!=="undefined"&&a.firstChild.getAttribute("href")!=="#"&&(l.attrHandle.href=function(a){return a.getAttribute("href",2)}),a=null}(),c.querySelectorAll&&function(){var a=k,b=c.createElement("div"),d="__sizzle__";b.innerHTML="

          ";if(!b.querySelectorAll||b.querySelectorAll(".TEST").length!==0){k=function(b,e,f,g){e=e||c;if(!g&&!k.isXML(e)){var h=/^(\w+$)|^\.([\w\-]+$)|^#([\w\-]+$)/.exec(b);if(h&&(e.nodeType===1||e.nodeType===9)){if(h[1])return p(e.getElementsByTagName(b),f);if(h[2]&&l.find.CLASS&&e.getElementsByClassName)return p(e.getElementsByClassName(h[2]),f)}if(e.nodeType===9){if(b==="body"&&e.body)return p([e.body],f);if(h&&h[3]){var i=e.getElementById(h[3]);if(!i||!i.parentNode)return p([],f);if(i.id===h[3])return p([i],f)}try{return p(e.querySelectorAll(b),f)}catch(j){}}else if(e.nodeType===1&&e.nodeName.toLowerCase()!=="object"){var m=e,n=e.getAttribute("id"),o=n||d,q=e.parentNode,r=/^\s*[+~]/.test(b);n?o=o.replace(/'/g,"\\$&"):e.setAttribute("id",o),r&&q&&(e=e.parentNode);try{if(!r||q)return p(e.querySelectorAll("[id='"+o+"'] "+b),f)}catch(s){}finally{n||m.removeAttribute("id")}}}return a(b,e,f,g)};for(var e in a)k[e]=a[e];b=null}}(),function(){var a=c.documentElement,b=a.matchesSelector||a.mozMatchesSelector||a.webkitMatchesSelector||a.msMatchesSelector,d=!1;try{b.call(c.documentElement,"[test!='']:sizzle")}catch(e){d=!0}b&&(k.matchesSelector=function(a,c){c=c.replace(/\=\s*([^'"\]]*)\s*\]/g,"='$1']");if(!k.isXML(a))try{if(d||!l.match.PSEUDO.test(c)&&!/!=/.test(c))return b.call(a,c)}catch(e){}return k(c,null,null,[a]).length>0})}(),function(){var a=c.createElement("div");a.innerHTML="
          ";if(a.getElementsByClassName&&a.getElementsByClassName("e").length!==0){a.lastChild.className="e";if(a.getElementsByClassName("e").length===1)return;l.order.splice(1,0,"CLASS"),l.find.CLASS=function(a,b,c){if(typeof b.getElementsByClassName!=="undefined"&&!c)return b.getElementsByClassName(a[1])},a=null}}(),c.documentElement.contains?k.contains=function(a,b){return a!==b&&(a.contains?a.contains(b):!0)}:c.documentElement.compareDocumentPosition?k.contains=function(a,b){return!!(a.compareDocumentPosition(b)&16)}:k.contains=function(){return!1},k.isXML=function(a){var b=(a?a.ownerDocument||a:0).documentElement;return b?b.nodeName!=="HTML":!1};var v=function(a,b){var c,d=[],e="",f=b.nodeType?[b]:b;while(c=l.match.PSEUDO.exec(a))e+=c[0],a=a.replace(l.match.PSEUDO,"");a=l.relative[a]?a+"*":a;for(var g=0,h=f.length;g0)for(var g=c;g0},closest:function(a,b){var c=[],e,f,g=this[0];if(d.isArray(a)){var h,i,j={},k=1;if(g&&a.length){for(e=0,f=a.length;e-1:d(g).is(h))&&c.push({selector:i,elem:g,level:k});g=g.parentNode,k++}}return c}var l=L.test(a)?d(a,b||this.context):null;for(e=0,f=this.length;e-1:d.find.matchesSelector(g,a)){c.push(g);break}g=g.parentNode;if(!g||!g.ownerDocument||g===b)break}}c=c.length>1?d.unique(c):c;return this.pushStack(c,"closest",a)},index:function(a){if(!a||typeof a==="string")return d.inArray(this[0],a?d(a):this.parent().children());return d.inArray(a.jquery?a[0]:a,this)},add:function(a,b){var c=typeof a==="string"?d(a,b):d.makeArray(a),e=d.merge(this.get(),c);return this.pushStack(N(c[0])||N(e[0])?e:d.unique(e))},andSelf:function(){return this.add(this.prevObject)}}),d.each({parent:function(a){var b=a.parentNode;return b&&b.nodeType!==11?b:null},parents:function(a){return d.dir(a,"parentNode")},parentsUntil:function(a,b,c){return d.dir(a,"parentNode",c)},next:function(a){return d.nth(a,2,"nextSibling")},prev:function(a){return d.nth(a,2,"previousSibling")},nextAll:function(a){return d.dir(a,"nextSibling")},prevAll:function(a){return d.dir(a,"previousSibling")},nextUntil:function(a,b,c){return d.dir(a,"nextSibling",c)},prevUntil:function(a,b,c){return d.dir(a,"previousSibling",c)},siblings:function(a){return d.sibling(a.parentNode.firstChild,a)},children:function(a){return d.sibling(a.firstChild)},contents:function(a){return d.nodeName(a,"iframe")?a.contentDocument||a.contentWindow.document:d.makeArray(a.childNodes)}},function(a,b){d.fn[a]=function(c,e){var f=d.map(this,b,c),g=K.call(arguments);G.test(a)||(e=c),e&&typeof e==="string"&&(f=d.filter(e,f)),f=this.length>1&&!M[a]?d.unique(f):f,(this.length>1||I.test(e))&&H.test(a)&&(f=f.reverse());return this.pushStack(f,a,g.join(","))}}),d.extend({filter:function(a,b,c){c&&(a=":not("+a+")");return b.length===1?d.find.matchesSelector(b[0],a)?[b[0]]:[]:d.find.matches(a,b)},dir:function(a,c,e){var f=[],g=a[c];while(g&&g.nodeType!==9&&(e===b||g.nodeType!==1||!d(g).is(e)))g.nodeType===1&&f.push(g),g=g[c];return f},nth:function(a,b,c,d){b=b||1;var e=0;for(;a;a=a[c])if(a.nodeType===1&&++e===b)break;return a},sibling:function(a,b){var c=[];for(;a;a=a.nextSibling)a.nodeType===1&&a!==b&&c.push(a);return c}});var P=/ jQuery\d+="(?:\d+|null)"/g,Q=/^\s+/,R=/<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/ig,S=/<([\w:]+)/,T=/",""],legend:[1,"
          ","
          "],thead:[1,"","
          "],tr:[2,"","
          "],td:[3,"","
          "],col:[2,"","
          "],area:[1,"",""],_default:[0,"",""]};X.optgroup=X.option,X.tbody=X.tfoot=X.colgroup=X.caption=X.thead,X.th=X.td,d.support.htmlSerialize||(X._default=[1,"div
          ","
          "]),d.fn.extend({text:function(a){if(d.isFunction(a))return this.each(function(b){var c=d(this);c.text(a.call(this,b,c.text()))});if(typeof a!=="object"&&a!==b)return this.empty().append((this[0]&&this[0].ownerDocument||c).createTextNode(a));return d.text(this)},wrapAll:function(a){if(d.isFunction(a))return this.each(function(b){d(this).wrapAll(a.call(this,b))});if(this[0]){var b=d(a,this[0].ownerDocument).eq(0).clone(!0);this[0].parentNode&&b.insertBefore(this[0]),b.map(function(){var a=this;while(a.firstChild&&a.firstChild.nodeType===1)a=a.firstChild;return a}).append(this)}return this},wrapInner:function(a){if(d.isFunction(a))return this.each(function(b){d(this).wrapInner(a.call(this,b))});return this.each(function(){var b=d(this),c=b.contents();c.length?c.wrapAll(a):b.append(a)})},wrap:function(a){return this.each(function(){d(this).wrapAll(a)})},unwrap:function(){return this.parent().each(function(){d.nodeName(this,"body")||d(this).replaceWith(this.childNodes)}).end()},append:function(){return this.domManip(arguments,!0,function(a){this.nodeType===1&&this.appendChild(a)})},prepend:function(){return this.domManip(arguments,!0,function(a){this.nodeType===1&&this.insertBefore(a,this.firstChild)})},before:function(){if(this[0]&&this[0].parentNode)return this.domManip(arguments,!1,function(a){this.parentNode.insertBefore(a,this)});if(arguments.length){var a=d(arguments[0]);a.push.apply(a,this.toArray());return this.pushStack(a,"before",arguments)}},after:function(){if(this[0]&&this[0].parentNode)return this.domManip(arguments,!1,function(a){this.parentNode.insertBefore(a,this.nextSibling)});if(arguments.length){var a=this.pushStack(this,"after",arguments);a.push.apply(a,d(arguments[0]).toArray());return a}},remove:function(a,b){for(var c=0,e;(e=this[c])!=null;c++)if(!a||d.filter(a,[e]).length)!b&&e.nodeType===1&&(d.cleanData(e.getElementsByTagName("*")),d.cleanData([e])),e.parentNode&&e.parentNode.removeChild(e);return this},empty:function(){for(var a=0,b;(b=this[a])!=null;a++){b.nodeType===1&&d.cleanData(b.getElementsByTagName("*"));while(b.firstChild)b.removeChild(b.firstChild)}return this},clone:function(a,b){a=a==null?!1:a,b=b==null?a:b;return this.map(function(){return d.clone(this,a,b)})},html:function(a){if(a===b)return this[0]&&this[0].nodeType===1?this[0].innerHTML.replace(P,""):null;if(typeof a!=="string"||V.test(a)||!d.support.leadingWhitespace&&Q.test(a)||X[(S.exec(a)||["",""])[1].toLowerCase()])d.isFunction(a)?this.each(function(b){var c=d(this);c.html(a.call(this,b,c.html()))}):this.empty().append(a);else{a=a.replace(R,"<$1>");try{for(var c=0,e=this.length;c1&&l0?this.clone(!0):this).get();d(f[h])[b](j),e=e.concat(j)}return this.pushStack(e,a,f.selector)}}),d.extend({clone:function(a,b,c){var e=a.cloneNode(!0),f,g,h;if((!d.support.noCloneEvent||!d.support.noCloneChecked)&&(a.nodeType===1||a.nodeType===11)&&!d.isXMLDoc(a)){$(a,e),f=_(a),g=_(e);for(h=0;f[h];++h)$(f[h],g[h])}if(b){Z(a,e);if(c){f=_(a),g=_(e);for(h=0;f[h];++h)Z(f[h],g[h])}}return e},clean:function(a,b,e,f){b=b||c,typeof b.createElement==="undefined"&&(b=b.ownerDocument||b[0]&&b[0].ownerDocument||c);var g=[];for(var h=0,i;(i=a[h])!=null;h++){typeof i==="number"&&(i+="");if(!i)continue;if(typeof i!=="string"||U.test(i)){if(typeof i==="string"){i=i.replace(R,"<$1>");var j=(S.exec(i)||["",""])[1].toLowerCase(),k=X[j]||X._default,l=k[0],m=b.createElement("div");m.innerHTML=k[1]+i+k[2];while(l--)m=m.lastChild;if(!d.support.tbody){var n=T.test(i),o=j==="table"&&!n?m.firstChild&&m.firstChild.childNodes:k[1]===""&&!n?m.childNodes:[];for(var p=o.length-1;p>=0;--p)d.nodeName(o[p],"tbody")&&!o[p].childNodes.length&&o[p].parentNode.removeChild(o[p])}!d.support.leadingWhitespace&&Q.test(i)&&m.insertBefore(b.createTextNode(Q.exec(i)[0]),m.firstChild),i=m.childNodes}}else i=b.createTextNode(i);i.nodeType?g.push(i):g=d.merge(g,i)}if(e)for(h=0;g[h];h++)!f||!d.nodeName(g[h],"script")||g[h].type&&g[h].type.toLowerCase()!=="text/javascript"?(g[h].nodeType===1&&g.splice.apply(g,[h+1,0].concat(d.makeArray(g[h].getElementsByTagName("script")))),e.appendChild(g[h])):f.push(g[h].parentNode?g[h].parentNode.removeChild(g[h]):g[h]);return g},cleanData:function(a){var b,c,e=d.cache,f=d.expando,g=d.event.special,h=d.support.deleteExpando;for(var i=0,j;(j=a[i])!=null;i++){if(j.nodeName&&d.noData[j.nodeName.toLowerCase()])continue;c=j[d.expando];if(c){b=e[c]&&e[c][f];if(b&&b.events){for(var k in b.events)g[k]?d.event.remove(j,k):d.removeEvent(j,k,b.handle);b.handle&&(b.handle.elem=null)}h?delete j[d.expando]:j.removeAttribute&&j.removeAttribute(d.expando),delete e[c]}}}});var bb=/alpha\([^)]*\)/i,bc=/opacity=([^)]*)/,bd=/-([a-z])/ig,be=/([A-Z])/g,bf=/^-?\d+(?:px)?$/i,bg=/^-?\d/,bh={position:"absolute",visibility:"hidden",display:"block"},bi=["Left","Right"],bj=["Top","Bottom"],bk,bl,bm,bn=function(a,b){return b.toUpperCase()};d.fn.css=function(a,c){if(arguments.length===2&&c===b)return this;return d.access(this,a,c,!0,function(a,c,e){return e!==b?d.style(a,c,e):d.css(a,c)})},d.extend({cssHooks:{opacity:{get:function(a,b){if(b){var c=bk(a,"opacity","opacity");return c===""?"1":c}return a.style.opacity}}},cssNumber:{zIndex:!0,fontWeight:!0,opacity:!0,zoom:!0,lineHeight:!0},cssProps:{"float":d.support.cssFloat?"cssFloat":"styleFloat"},style:function(a,c,e,f){if(a&&a.nodeType!==3&&a.nodeType!==8&&a.style){var g,h=d.camelCase(c),i=a.style,j=d.cssHooks[h];c=d.cssProps[h]||h;if(e===b){if(j&&"get"in j&&(g=j.get(a,!1,f))!==b)return g;return i[c]}if(typeof e==="number"&&isNaN(e)||e==null)return;typeof e==="number"&&!d.cssNumber[h]&&(e+="px");if(!j||!("set"in j)||(e=j.set(a,e))!==b)try{i[c]=e}catch(k){}}},css:function(a,c,e){var f,g=d.camelCase(c),h=d.cssHooks[g];c=d.cssProps[g]||g;if(h&&"get"in h&&(f=h.get(a,!0,e))!==b)return f;if(bk)return bk(a,c,g)},swap:function(a,b,c){var d={};for(var e in b)d[e]=a.style[e],a.style[e]=b[e];c.call(a);for(e in b)a.style[e]=d[e]},camelCase:function(a){return a.replace(bd,bn)}}),d.curCSS=d.css,d.each(["height","width"],function(a,b){d.cssHooks[b]={get:function(a,c,e){var f;if(c){a.offsetWidth!==0?f=bo(a,b,e):d.swap(a,bh,function(){f=bo(a,b,e)});if(f<=0){f=bk(a,b,b),f==="0px"&&bm&&(f=bm(a,b,b));if(f!=null)return f===""||f==="auto"?"0px":f}if(f<0||f==null){f=a.style[b];return f===""||f==="auto"?"0px":f}return typeof f==="string"?f:f+"px"}},set:function(a,b){if(!bf.test(b))return b;b=parseFloat(b);if(b>=0)return b+"px"}}}),d.support.opacity||(d.cssHooks.opacity={get:function(a,b){return bc.test((b&&a.currentStyle?a.currentStyle.filter:a.style.filter)||"")?parseFloat(RegExp.$1)/100+"":b?"1":""},set:function(a,b){var c=a.style;c.zoom=1;var e=d.isNaN(b)?"":"alpha(opacity="+b*100+")",f=c.filter||"";c.filter=bb.test(f)?f.replace(bb,e):c.filter+" "+e}}),c.defaultView&&c.defaultView.getComputedStyle&&(bl=function(a,c,e){var f,g,h;e=e.replace(be,"-$1").toLowerCase();if(!(g=a.ownerDocument.defaultView))return b;if(h=g.getComputedStyle(a,null))f=h.getPropertyValue(e),f===""&&!d.contains(a.ownerDocument.documentElement,a)&&(f=d.style(a,e));return f}),c.documentElement.currentStyle&&(bm=function(a,b){var c,d=a.currentStyle&&a.currentStyle[b],e=a.runtimeStyle&&a.runtimeStyle[b],f=a.style;!bf.test(d)&&bg.test(d)&&(c=f.left,e&&(a.runtimeStyle.left=a.currentStyle.left),f.left=b==="fontSize"?"1em":d||0,d=f.pixelLeft+"px",f.left=c,e&&(a.runtimeStyle.left=e));return d===""?"auto":d}),bk=bl||bm,d.expr&&d.expr.filters&&(d.expr.filters.hidden=function(a){var b=a.offsetWidth,c=a.offsetHeight;return b===0&&c===0||!d.support.reliableHiddenOffsets&&(a.style.display||d.css(a,"display"))==="none"},d.expr.filters.visible=function(a){return!d.expr.filters.hidden(a)});var bp=/%20/g,bq=/\[\]$/,br=/\r?\n/g,bs=/#.*$/,bt=/^(.*?):[ \t]*([^\r\n]*)\r?$/mg,bu=/^(?:color|date|datetime|email|hidden|month|number|password|range|search|tel|text|time|url|week)$/i,bv=/(?:^file|^widget|\-extension):$/,bw=/^(?:GET|HEAD)$/,bx=/^\/\//,by=/\?/,bz=/)<[^<]*)*<\/script>/gi,bA=/^(?:select|textarea)/i,bB=/\s+/,bC=/([?&])_=[^&]*/,bD=/(^|\-)([a-z])/g,bE=function(a,b,c){return b+c.toUpperCase()},bF=/^([\w\+\.\-]+:)\/\/([^\/?#:]*)(?::(\d+))?/,bG=d.fn.load,bH={},bI={},bJ,bK;try{bJ=c.location.href}catch(bL){bJ=c.createElement("a"),bJ.href="",bJ=bJ.href}bK=bF.exec(bJ.toLowerCase()),d.fn.extend({load:function(a,c,e){if(typeof a!=="string"&&bG)return bG.apply(this,arguments);if(!this.length)return this;var f=a.indexOf(" ");if(f>=0){var g=a.slice(f,a.length);a=a.slice(0,f)}var h="GET";c&&(d.isFunction(c)?(e=c,c=b):typeof c==="object"&&(c=d.param(c,d.ajaxSettings.traditional),h="POST"));var i=this;d.ajax({url:a,type:h,dataType:"html",data:c,complete:function(a,b,c){c=a.responseText,a.isResolved()&&(a.done(function(a){c=a}),i.html(g?d("
          ").append(c.replace(bz,"")).find(g):c)),e&&i.each(e,[c,b,a])}});return this},serialize:function(){return d.param(this.serializeArray())},serializeArray:function(){return this.map(function(){return this.elements?d.makeArray(this.elements):this}).filter(function(){return this.name&&!this.disabled&&(this.checked||bA.test(this.nodeName)||bu.test(this.type))}).map(function(a,b){var c=d(this).val();return c==null?null:d.isArray(c)?d.map(c,function(a,c){return{name:b.name,value:a.replace(br,"\r\n")}}):{name:b.name,value:c.replace(br,"\r\n")}}).get()}}),d.each("ajaxStart ajaxStop ajaxComplete ajaxError ajaxSuccess ajaxSend".split(" "),function(a,b){d.fn[b]=function(a){return this.bind(b,a)}}),d.each(["get","post"],function(a,c){d[c]=function(a,e,f,g){d.isFunction(e)&&(g=g||f,f=e,e=b);return d.ajax({type:c,url:a,data:e,success:f,dataType:g})}}),d.extend({getScript:function(a,c){return d.get(a,b,c,"script")},getJSON:function(a,b,c){return d.get(a,b,c,"json")},ajaxSetup:function(a,b){b?d.extend(!0,a,d.ajaxSettings,b):(b=a,a=d.extend(!0,d.ajaxSettings,b));for(var c in {context:1,url:1})c in b?a[c]=b[c]:c in d.ajaxSettings&&(a[c]=d.ajaxSettings[c]);return a},ajaxSettings:{url:bJ,isLocal:bv.test(bK[1]),global:!0,type:"GET",contentType:"application/x-www-form-urlencoded",processData:!0,async:!0,accepts:{xml:"application/xml, text/xml",html:"text/html",text:"text/plain",json:"application/json, text/javascript","*":"*/*"},contents:{xml:/xml/,html:/html/,json:/json/},responseFields:{xml:"responseXML",text:"responseText"},converters:{"* text":a.String,"text html":!0,"text json":d.parseJSON,"text xml":d.parseXML}},ajaxPrefilter:bM(bH),ajaxTransport:bM(bI),ajax:function(a,c){function v(a,c,l,n){if(r!==2){r=2,p&&clearTimeout(p),o=b,m=n||"",u.readyState=a?4:0;var q,t,v,w=l?bP(e,u,l):b,x,y;if(a>=200&&a<300||a===304){if(e.ifModified){if(x=u.getResponseHeader("Last-Modified"))d.lastModified[k]=x;if(y=u.getResponseHeader("Etag"))d.etag[k]=y}if(a===304)c="notmodified",q=!0;else try{t=bQ(e,w),c="success",q=!0}catch(z){c="parsererror",v=z}}else{v=c;if(!c||a)c="error",a<0&&(a=0)}u.status=a,u.statusText=c,q?h.resolveWith(f,[t,c,u]):h.rejectWith(f,[u,c,v]),u.statusCode(j),j=b,s&&g.trigger("ajax"+(q?"Success":"Error"),[u,e,q?t:v]),i.resolveWith(f,[u,c]),s&&(g.trigger("ajaxComplete",[u,e]),--d.active||d.event.trigger("ajaxStop"))}}typeof a==="object"&&(c=a,a=b),c=c||{};var e=d.ajaxSetup({},c),f=e.context||e,g=f!==e&&(f.nodeType||f instanceof d)?d(f):d.event,h=d.Deferred(),i=d._Deferred(),j=e.statusCode||{},k,l={},m,n,o,p,q,r=0,s,t,u={readyState:0,setRequestHeader:function(a,b){r||(l[a.toLowerCase().replace(bD,bE)]=b);return this},getAllResponseHeaders:function(){return r===2?m:null},getResponseHeader:function(a){var c;if(r===2){if(!n){n={};while(c=bt.exec(m))n[c[1].toLowerCase()]=c[2]}c=n[a.toLowerCase()]}return c===b?null:c},overrideMimeType:function(a){r||(e.mimeType=a);return this},abort:function(a){a=a||"abort",o&&o.abort(a),v(0,a);return this}};h.promise(u),u.success=u.done,u.error=u.fail,u.complete=i.done,u.statusCode=function(a){if(a){var b;if(r<2)for(b in a)j[b]=[j[b],a[b]];else b=a[u.status],u.then(b,b)}return this},e.url=((a||e.url)+"").replace(bs,"").replace(bx,bK[1]+"//"),e.dataTypes=d.trim(e.dataType||"*").toLowerCase().split(bB),e.crossDomain||(q=bF.exec(e.url.toLowerCase()),e.crossDomain=q&&(q[1]!=bK[1]||q[2]!=bK[2]||(q[3]||(q[1]==="http:"?80:443))!=(bK[3]||(bK[1]==="http:"?80:443)))),e.data&&e.processData&&typeof e.data!=="string"&&(e.data=d.param(e.data,e.traditional)),bN(bH,e,c,u);if(r===2)return!1;s=e.global,e.type=e.type.toUpperCase(),e.hasContent=!bw.test(e.type),s&&d.active++===0&&d.event.trigger("ajaxStart");if(!e.hasContent){e.data&&(e.url+=(by.test(e.url)?"&":"?")+e.data),k=e.url;if(e.cache===!1){var w=d.now(),x=e.url.replace(bC,"$1_="+w);e.url=x+(x===e.url?(by.test(e.url)?"&":"?")+"_="+w:"")}}if(e.data&&e.hasContent&&e.contentType!==!1||c.contentType)l["Content-Type"]=e.contentType;e.ifModified&&(k=k||e.url,d.lastModified[k]&&(l["If-Modified-Since"]=d.lastModified[k]),d.etag[k]&&(l["If-None-Match"]=d.etag[k])),l.Accept=e.dataTypes[0]&&e.accepts[e.dataTypes[0]]?e.accepts[e.dataTypes[0]]+(e.dataTypes[0]!=="*"?", */*; q=0.01":""):e.accepts["*"];for(t in e.headers)u.setRequestHeader(t,e.headers[t]);if(e.beforeSend&&(e.beforeSend.call(f,u,e)===!1||r===2)){u.abort();return!1}for(t in {success:1,error:1,complete:1})u[t](e[t]);o=bN(bI,e,c,u);if(o){u.readyState=1,s&&g.trigger("ajaxSend",[u,e]),e.async&&e.timeout>0&&(p=setTimeout(function(){u.abort("timeout")},e.timeout));try{r=1,o.send(l,v)}catch(y){status<2?v(-1,y):d.error(y)}}else v(-1,"No Transport");return u},param:function(a,c){var e=[],f=function(a,b){b=d.isFunction(b)?b():b,e[e.length]=encodeURIComponent(a)+"="+encodeURIComponent(b)};c===b&&(c=d.ajaxSettings.traditional);if(d.isArray(a)||a.jquery&&!d.isPlainObject(a))d.each(a,function(){f(this.name,this.value)});else for(var g in a)bO(g,a[g],c,f);return e.join("&").replace(bp,"+")}}),d.extend({active:0,lastModified:{},etag:{}});var bR=d.now(),bS=/(\=)\?(&|$)|()\?\?()/i;d.ajaxSetup({jsonp:"callback",jsonpCallback:function(){return d.expando+"_"+bR++}}),d.ajaxPrefilter("json jsonp",function(b,c,e){var f=typeof b.data==="string";if(b.dataTypes[0]==="jsonp"||c.jsonpCallback||c.jsonp!=null||b.jsonp!==!1&&(bS.test(b.url)||f&&bS.test(b.data))){var g,h=b.jsonpCallback=d.isFunction(b.jsonpCallback)?b.jsonpCallback():b.jsonpCallback,i=a[h],j=b.url,k=b.data,l="$1"+h+"$2",m=function(){a[h]=i,g&&d.isFunction(i)&&a[h](g[0])};b.jsonp!==!1&&(j=j.replace(bS,l),b.url===j&&(f&&(k=k.replace(bS,l)),b.data===k&&(j+=(/\?/.test(j)?"&":"?")+b.jsonp+"="+h))),b.url=j,b.data=k,a[h]=function(a){g=[a]},e.then(m,m),b.converters["script json"]=function(){g||d.error(h+" was not called");return g[0]},b.dataTypes[0]="json";return"script"}}),d.ajaxSetup({accepts:{script:"text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"},contents:{script:/javascript|ecmascript/},converters:{"text script":function(a){d.globalEval(a);return a}}}),d.ajaxPrefilter("script",function(a){a.cache===b&&(a.cache=!1),a.crossDomain&&(a.type="GET",a.global=!1)}),d.ajaxTransport("script",function(a){if(a.crossDomain){var d,e=c.head||c.getElementsByTagName("head")[0]||c.documentElement;return{send:function(f,g){d=c.createElement("script"),d.async="async",a.scriptCharset&&(d.charset=a.scriptCharset),d.src=a.url,d.onload=d.onreadystatechange=function(a,c){if(!d.readyState||/loaded|complete/.test(d.readyState))d.onload=d.onreadystatechange=null,e&&d.parentNode&&e.removeChild(d),d=b,c||g(200,"success")},e.insertBefore(d,e.firstChild)},abort:function(){d&&d.onload(0,1)}}}});var bT=d.now(),bU,bV;d.ajaxSettings.xhr=a.ActiveXObject?function(){return!this.isLocal&&bX()||bY()}:bX,bV=d.ajaxSettings.xhr(),d.support.ajax=!!bV,d.support.cors=bV&&"withCredentials"in bV,bV=b,d.support.ajax&&d.ajaxTransport(function(a){if(!a.crossDomain||d.support.cors){var c;return{send:function(e,f){var g=a.xhr(),h,i;a.username?g.open(a.type,a.url,a.async,a.username,a.password):g.open(a.type,a.url,a.async);if(a.xhrFields)for(i in a.xhrFields)g[i]=a.xhrFields[i];a.mimeType&&g.overrideMimeType&&g.overrideMimeType(a.mimeType),(!a.crossDomain||a.hasContent)&&!e["X-Requested-With"]&&(e["X-Requested-With"]="XMLHttpRequest");try{for(i in e)g.setRequestHeader(i,e[i])}catch(j){}g.send(a.hasContent&&a.data||null),c=function(e,i){var j,k,l,m,n;try{if(c&&(i||g.readyState===4)){c=b,h&&(g.onreadystatechange=d.noop,delete bU[h]);if(i)g.readyState!==4&&g.abort();else{j=g.status,l=g.getAllResponseHeaders(),m={},n=g.responseXML,n&&n.documentElement&&(m.xml=n),m.text=g.responseText;try{k=g.statusText}catch(o){k=""}j||!a.isLocal||a.crossDomain?j===1223&&(j=204):j=m.text?200:404}}}catch(p){i||f(-1,p)}m&&f(j,k,m,l)},a.async&&g.readyState!==4?(bU||(bU={},bW()),h=bT++,g.onreadystatechange=bU[h]=c):c()},abort:function(){c&&c(0,1)}}}});var bZ={},b$=/^(?:toggle|show|hide)$/,b_=/^([+\-]=)?([\d+.\-]+)([a-z%]*)$/i,ca,cb=[["height","marginTop","marginBottom","paddingTop","paddingBottom"],["width","marginLeft","marginRight","paddingLeft","paddingRight"],["opacity"]];d.fn.extend({show:function(a,b,c){var e,f;if(a||a===0)return this.animate(cc("show",3),a,b,c);for(var g=0,h=this.length;g=0;a--)c[a].elem===this&&(b&&c[a](!0),c.splice(a,1))}),b||this.dequeue();return this}}),d.each({slideDown:cc("show",1),slideUp:cc("hide",1),slideToggle:cc("toggle",1),fadeIn:{opacity:"show"},fadeOut:{opacity:"hide"},fadeToggle:{opacity:"toggle"}},function(a,b){d.fn[a]=function(a,c,d){return this.animate(b,a,c,d)}}),d.extend({speed:function(a,b,c){var e=a&&typeof a==="object"?d.extend({},a):{complete:c||!c&&b||d.isFunction(a)&&a,duration:a,easing:c&&b||b&&!d.isFunction(b)&&b};e.duration=d.fx.off?0:typeof e.duration==="number"?e.duration:e.duration in d.fx.speeds?d.fx.speeds[e.duration]:d.fx.speeds._default,e.old=e.complete,e.complete=function(){e.queue!==!1&&d(this).dequeue(),d.isFunction(e.old)&&e.old.call(this)};return e},easing:{linear:function(a,b,c,d){return c+d*a},swing:function(a,b,c,d){return(-Math.cos(a*Math.PI)/2+.5)*d+c}},timers:[],fx:function(a,b,c){this.options=b,this.elem=a,this.prop=c,b.orig||(b.orig={})}}),d.fx.prototype={update:function(){this.options.step&&this.options.step.call(this.elem,this.now,this),(d.fx.step[this.prop]||d.fx.step._default)(this)},cur:function(){if(this.elem[this.prop]!=null&&(!this.elem.style||this.elem.style[this.prop]==null))return this.elem[this.prop];var a,b=d.css(this.elem,this.prop);return isNaN(a=parseFloat(b))?!b||b==="auto"?0:b:a},custom:function(a,b,c){function g(a){return e.step(a)}var e=this,f=d.fx;this.startTime=d.now(),this.start=a,this.end=b,this.unit=c||this.unit||(d.cssNumber[this.prop]?"":"px"),this.now=this.start,this.pos=this.state=0,g.elem=this.elem,g()&&d.timers.push(g)&&!ca&&(ca=setInterval(f.tick,f.interval))},show:function(){this.options.orig[this.prop]=d.style(this.elem,this.prop),this.options.show=!0,this.custom(this.prop==="width"||this.prop==="height"?1:0,this.cur()),d(this.elem).show()},hide:function(){this.options.orig[this.prop]=d.style(this.elem,this.prop),this.options.hide=!0,this.custom(this.cur(),0)},step:function(a){var b=d.now(),c=!0;if(a||b>=this.options.duration+this.startTime){this.now=this.end,this.pos=this.state=1,this.update(),this.options.curAnim[this.prop]=!0;for(var e in this.options.curAnim)this.options.curAnim[e]!==!0&&(c=!1);if(c){if(this.options.overflow!=null&&!d.support.shrinkWrapBlocks){var f=this.elem,g=this.options;d.each(["","X","Y"],function(a,b){f.style["overflow"+b]=g.overflow[a]})}this.options.hide&&d(this.elem).hide();if(this.options.hide||this.options.show)for(var h in this.options.curAnim)d.style(this.elem,h,this.options.orig[h]);this.options.complete.call(this.elem)}return!1}var i=b-this.startTime;this.state=i/this.options.duration;var j=this.options.specialEasing&&this.options.specialEasing[this.prop],k=this.options.easing||(d.easing.swing?"swing":"linear");this.pos=d.easing[j||k](this.state,i,0,1,this.options.duration),this.now=this.start+(this.end-this.start)*this.pos,this.update();return!0}},d.extend(d.fx,{tick:function(){var a=d.timers;for(var b=0;b
          ";d.extend(b.style,{position:"absolute",top:0,left:0,margin:0,border:0,width:"1px",height:"1px",visibility:"hidden"}),b.innerHTML=j,a.insertBefore(b,a.firstChild),e=b.firstChild,f=e.firstChild,h=e.nextSibling.firstChild.firstChild,this.doesNotAddBorder=f.offsetTop!==5,this.doesAddBorderForTableAndCells=h.offsetTop===5,f.style.position="fixed",f.style.top="20px",this.supportsFixedPosition=f.offsetTop===20||f.offsetTop===15,f.style.position=f.style.top="",e.style.overflow="hidden",e.style.position="relative",this.subtractsBorderForOverflowNotVisible=f.offsetTop===-5,this.doesNotIncludeMarginInBodyOffset=a.offsetTop!==i,a.removeChild(b),a=b=e=f=g=h=null,d.offset.initialize=d.noop},bodyOffset:function(a){var b=a.offsetTop,c=a.offsetLeft;d.offset.initialize(),d.offset.doesNotIncludeMarginInBodyOffset&&(b+=parseFloat(d.css(a,"marginTop"))||0,c+=parseFloat(d.css(a,"marginLeft"))||0);return{top:b,left:c}},setOffset:function(a,b,c){var e=d.css(a,"position");e==="static"&&(a.style.position="relative");var f=d(a),g=f.offset(),h=d.css(a,"top"),i=d.css(a,"left"),j=e==="absolute"&&d.inArray("auto",[h,i])>-1,k={},l={},m,n;j&&(l=f.position()),m=j?l.top:parseInt(h,10)||0,n=j?l.left:parseInt(i,10)||0,d.isFunction(b)&&(b=b.call(a,c,g)),b.top!=null&&(k.top=b.top-g.top+m),b.left!=null&&(k.left=b.left-g.left+n),"using"in b?b.using.call(a,k):f.css(k)}},d.fn.extend({position:function(){if(!this[0])return null;var a=this[0],b=this.offsetParent(),c=this.offset(),e=cf.test(b[0].nodeName)?{top:0,left:0}:b.offset();c.top-=parseFloat(d.css(a,"marginTop"))||0,c.left-=parseFloat(d.css(a,"marginLeft"))||0,e.top+=parseFloat(d.css(b[0],"borderTopWidth"))||0,e.left+=parseFloat(d.css(b[0],"borderLeftWidth"))||0;return{top:c.top-e.top,left:c.left-e.left}},offsetParent:function(){return this.map(function(){var a=this.offsetParent||c.body;while(a&&(!cf.test(a.nodeName)&&d.css(a,"position")==="static"))a=a.offsetParent;return a})}}),d.each(["Left","Top"],function(a,c){var e="scroll"+c;d.fn[e]=function(c){var f=this[0],g;if(!f)return null;if(c!==b)return this.each(function(){g=cg(this),g?g.scrollTo(a?d(g).scrollLeft():c,a?c:d(g).scrollTop()):this[e]=c});g=cg(f);return g?"pageXOffset"in g?g[a?"pageYOffset":"pageXOffset"]:d.support.boxModel&&g.document.documentElement[e]||g.document.body[e]:f[e]}}),d.each(["Height","Width"],function(a,c){var e=c.toLowerCase();d.fn["inner"+c]=function(){return this[0]?parseFloat(d.css(this[0],e,"padding")):null},d.fn["outer"+c]=function(a){return this[0]?parseFloat(d.css(this[0],e,a?"margin":"border")):null},d.fn[e]=function(a){var f=this[0];if(!f)return a==null?null:this;if(d.isFunction(a))return this.each(function(b){var c=d(this);c[e](a.call(this,b,c[e]()))});if(d.isWindow(f)){var g=f.document.documentElement["client"+c];return f.document.compatMode==="CSS1Compat"&&g||f.document.body["client"+c]||g}if(f.nodeType===9)return Math.max(f.documentElement["client"+c],f.body["scroll"+c],f.documentElement["scroll"+c],f.body["offset"+c],f.documentElement["offset"+c]);if(a===b){var h=d.css(f,e),i=parseFloat(h);return d.isNaN(i)?h:i}return this.css(e,typeof a==="string"?a:a+"px")}}),a.jQuery=a.$=d})(window); \ No newline at end of file +(function( window, undefined ) { + +// Use the correct document accordingly with window argument (sandbox) +var document = window.document, + navigator = window.navigator, + location = window.location; +var jQuery = (function() { + +// Define a local copy of jQuery +var jQuery = function( selector, context ) { + // The jQuery object is actually just the init constructor 'enhanced' + return new jQuery.fn.init( selector, context, rootjQuery ); + }, + + // Map over jQuery in case of overwrite + _jQuery = window.jQuery, + + // Map over the $ in case of overwrite + _$ = window.$, + + // A central reference to the root jQuery(document) + rootjQuery, + + // A simple way to check for HTML strings or ID strings + // Prioritize #id over to avoid XSS via location.hash (#9521) + quickExpr = /^(?:[^#<]*(<[\w\W]+>)[^>]*$|#([\w\-]*)$)/, + + // Check if a string has a non-whitespace character in it + rnotwhite = /\S/, + + // Used for trimming whitespace + trimLeft = /^\s+/, + trimRight = /\s+$/, + + // Check for digits + rdigit = /\d/, + + // Match a standalone tag + rsingleTag = /^<(\w+)\s*\/?>(?:<\/\1>)?$/, + + // JSON RegExp + rvalidchars = /^[\],:{}\s]*$/, + rvalidescape = /\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g, + rvalidtokens = /"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g, + rvalidbraces = /(?:^|:|,)(?:\s*\[)+/g, + + // Useragent RegExp + rwebkit = /(webkit)[ \/]([\w.]+)/, + ropera = /(opera)(?:.*version)?[ \/]([\w.]+)/, + rmsie = /(msie) ([\w.]+)/, + rmozilla = /(mozilla)(?:.*? rv:([\w.]+))?/, + + // Matches dashed string for camelizing + rdashAlpha = /-([a-z]|[0-9])/ig, + rmsPrefix = /^-ms-/, + + // Used by jQuery.camelCase as callback to replace() + fcamelCase = function( all, letter ) { + return ( letter + "" ).toUpperCase(); + }, + + // Keep a UserAgent string for use with jQuery.browser + userAgent = navigator.userAgent, + + // For matching the engine and version of the browser + browserMatch, + + // The deferred used on DOM ready + readyList, + + // The ready event handler + DOMContentLoaded, + + // Save a reference to some core methods + toString = Object.prototype.toString, + hasOwn = Object.prototype.hasOwnProperty, + push = Array.prototype.push, + slice = Array.prototype.slice, + trim = String.prototype.trim, + indexOf = Array.prototype.indexOf, + + // [[Class]] -> type pairs + class2type = {}; + +jQuery.fn = jQuery.prototype = { + constructor: jQuery, + init: function( selector, context, rootjQuery ) { + var match, elem, ret, doc; + + // Handle $(""), $(null), or $(undefined) + if ( !selector ) { + return this; + } + + // Handle $(DOMElement) + if ( selector.nodeType ) { + this.context = this[0] = selector; + this.length = 1; + return this; + } + + // The body element only exists once, optimize finding it + if ( selector === "body" && !context && document.body ) { + this.context = document; + this[0] = document.body; + this.selector = selector; + this.length = 1; + return this; + } + + // Handle HTML strings + if ( typeof selector === "string" ) { + // Are we dealing with HTML string or an ID? + if ( selector.charAt(0) === "<" && selector.charAt( selector.length - 1 ) === ">" && selector.length >= 3 ) { + // Assume that strings that start and end with <> are HTML and skip the regex check + match = [ null, selector, null ]; + + } else { + match = quickExpr.exec( selector ); + } + + // Verify a match, and that no context was specified for #id + if ( match && (match[1] || !context) ) { + + // HANDLE: $(html) -> $(array) + if ( match[1] ) { + context = context instanceof jQuery ? context[0] : context; + doc = (context ? context.ownerDocument || context : document); + + // If a single string is passed in and it's a single tag + // just do a createElement and skip the rest + ret = rsingleTag.exec( selector ); + + if ( ret ) { + if ( jQuery.isPlainObject( context ) ) { + selector = [ document.createElement( ret[1] ) ]; + jQuery.fn.attr.call( selector, context, true ); + + } else { + selector = [ doc.createElement( ret[1] ) ]; + } + + } else { + ret = jQuery.buildFragment( [ match[1] ], [ doc ] ); + selector = (ret.cacheable ? jQuery.clone(ret.fragment) : ret.fragment).childNodes; + } + + return jQuery.merge( this, selector ); + + // HANDLE: $("#id") + } else { + elem = document.getElementById( match[2] ); + + // Check parentNode to catch when Blackberry 4.6 returns + // nodes that are no longer in the document #6963 + if ( elem && elem.parentNode ) { + // Handle the case where IE and Opera return items + // by name instead of ID + if ( elem.id !== match[2] ) { + return rootjQuery.find( selector ); + } + + // Otherwise, we inject the element directly into the jQuery object + this.length = 1; + this[0] = elem; + } + + this.context = document; + this.selector = selector; + return this; + } + + // HANDLE: $(expr, $(...)) + } else if ( !context || context.jquery ) { + return (context || rootjQuery).find( selector ); + + // HANDLE: $(expr, context) + // (which is just equivalent to: $(context).find(expr) + } else { + return this.constructor( context ).find( selector ); + } + + // HANDLE: $(function) + // Shortcut for document ready + } else if ( jQuery.isFunction( selector ) ) { + return rootjQuery.ready( selector ); + } + + if (selector.selector !== undefined) { + this.selector = selector.selector; + this.context = selector.context; + } + + return jQuery.makeArray( selector, this ); + }, + + // Start with an empty selector + selector: "", + + // The current version of jQuery being used + jquery: "1.6.4", + + // The default length of a jQuery object is 0 + length: 0, + + // The number of elements contained in the matched element set + size: function() { + return this.length; + }, + + toArray: function() { + return slice.call( this, 0 ); + }, + + // Get the Nth element in the matched element set OR + // Get the whole matched element set as a clean array + get: function( num ) { + return num == null ? + + // Return a 'clean' array + this.toArray() : + + // Return just the object + ( num < 0 ? this[ this.length + num ] : this[ num ] ); + }, + + // Take an array of elements and push it onto the stack + // (returning the new matched element set) + pushStack: function( elems, name, selector ) { + // Build a new jQuery matched element set + var ret = this.constructor(); + + if ( jQuery.isArray( elems ) ) { + push.apply( ret, elems ); + + } else { + jQuery.merge( ret, elems ); + } + + // Add the old object onto the stack (as a reference) + ret.prevObject = this; + + ret.context = this.context; + + if ( name === "find" ) { + ret.selector = this.selector + (this.selector ? " " : "") + selector; + } else if ( name ) { + ret.selector = this.selector + "." + name + "(" + selector + ")"; + } + + // Return the newly-formed element set + return ret; + }, + + // Execute a callback for every element in the matched set. + // (You can seed the arguments with an array of args, but this is + // only used internally.) + each: function( callback, args ) { + return jQuery.each( this, callback, args ); + }, + + ready: function( fn ) { + // Attach the listeners + jQuery.bindReady(); + + // Add the callback + readyList.done( fn ); + + return this; + }, + + eq: function( i ) { + return i === -1 ? + this.slice( i ) : + this.slice( i, +i + 1 ); + }, + + first: function() { + return this.eq( 0 ); + }, + + last: function() { + return this.eq( -1 ); + }, + + slice: function() { + return this.pushStack( slice.apply( this, arguments ), + "slice", slice.call(arguments).join(",") ); + }, + + map: function( callback ) { + return this.pushStack( jQuery.map(this, function( elem, i ) { + return callback.call( elem, i, elem ); + })); + }, + + end: function() { + return this.prevObject || this.constructor(null); + }, + + // For internal use only. + // Behaves like an Array's method, not like a jQuery method. + push: push, + sort: [].sort, + splice: [].splice +}; + +// Give the init function the jQuery prototype for later instantiation +jQuery.fn.init.prototype = jQuery.fn; + +jQuery.extend = jQuery.fn.extend = function() { + var options, name, src, copy, copyIsArray, clone, + target = arguments[0] || {}, + i = 1, + length = arguments.length, + deep = false; + + // Handle a deep copy situation + if ( typeof target === "boolean" ) { + deep = target; + target = arguments[1] || {}; + // skip the boolean and the target + i = 2; + } + + // Handle case when target is a string or something (possible in deep copy) + if ( typeof target !== "object" && !jQuery.isFunction(target) ) { + target = {}; + } + + // extend jQuery itself if only one argument is passed + if ( length === i ) { + target = this; + --i; + } + + for ( ; i < length; i++ ) { + // Only deal with non-null/undefined values + if ( (options = arguments[ i ]) != null ) { + // Extend the base object + for ( name in options ) { + src = target[ name ]; + copy = options[ name ]; + + // Prevent never-ending loop + if ( target === copy ) { + continue; + } + + // Recurse if we're merging plain objects or arrays + if ( deep && copy && ( jQuery.isPlainObject(copy) || (copyIsArray = jQuery.isArray(copy)) ) ) { + if ( copyIsArray ) { + copyIsArray = false; + clone = src && jQuery.isArray(src) ? src : []; + + } else { + clone = src && jQuery.isPlainObject(src) ? src : {}; + } + + // Never move original objects, clone them + target[ name ] = jQuery.extend( deep, clone, copy ); + + // Don't bring in undefined values + } else if ( copy !== undefined ) { + target[ name ] = copy; + } + } + } + } + + // Return the modified object + return target; +}; + +jQuery.extend({ + noConflict: function( deep ) { + if ( window.$ === jQuery ) { + window.$ = _$; + } + + if ( deep && window.jQuery === jQuery ) { + window.jQuery = _jQuery; + } + + return jQuery; + }, + + // Is the DOM ready to be used? Set to true once it occurs. + isReady: false, + + // A counter to track how many items to wait for before + // the ready event fires. See #6781 + readyWait: 1, + + // Hold (or release) the ready event + holdReady: function( hold ) { + if ( hold ) { + jQuery.readyWait++; + } else { + jQuery.ready( true ); + } + }, + + // Handle when the DOM is ready + ready: function( wait ) { + // Either a released hold or an DOMready/load event and not yet ready + if ( (wait === true && !--jQuery.readyWait) || (wait !== true && !jQuery.isReady) ) { + // Make sure body exists, at least, in case IE gets a little overzealous (ticket #5443). + if ( !document.body ) { + return setTimeout( jQuery.ready, 1 ); + } + + // Remember that the DOM is ready + jQuery.isReady = true; + + // If a normal DOM Ready event fired, decrement, and wait if need be + if ( wait !== true && --jQuery.readyWait > 0 ) { + return; + } + + // If there are functions bound, to execute + readyList.resolveWith( document, [ jQuery ] ); + + // Trigger any bound ready events + if ( jQuery.fn.trigger ) { + jQuery( document ).trigger( "ready" ).unbind( "ready" ); + } + } + }, + + bindReady: function() { + if ( readyList ) { + return; + } + + readyList = jQuery._Deferred(); + + // Catch cases where $(document).ready() is called after the + // browser event has already occurred. + if ( document.readyState === "complete" ) { + // Handle it asynchronously to allow scripts the opportunity to delay ready + return setTimeout( jQuery.ready, 1 ); + } + + // Mozilla, Opera and webkit nightlies currently support this event + if ( document.addEventListener ) { + // Use the handy event callback + document.addEventListener( "DOMContentLoaded", DOMContentLoaded, false ); + + // A fallback to window.onload, that will always work + window.addEventListener( "load", jQuery.ready, false ); + + // If IE event model is used + } else if ( document.attachEvent ) { + // ensure firing before onload, + // maybe late but safe also for iframes + document.attachEvent( "onreadystatechange", DOMContentLoaded ); + + // A fallback to window.onload, that will always work + window.attachEvent( "onload", jQuery.ready ); + + // If IE and not a frame + // continually check to see if the document is ready + var toplevel = false; + + try { + toplevel = window.frameElement == null; + } catch(e) {} + + if ( document.documentElement.doScroll && toplevel ) { + doScrollCheck(); + } + } + }, + + // See test/unit/core.js for details concerning isFunction. + // Since version 1.3, DOM methods and functions like alert + // aren't supported. They return false on IE (#2968). + isFunction: function( obj ) { + return jQuery.type(obj) === "function"; + }, + + isArray: Array.isArray || function( obj ) { + return jQuery.type(obj) === "array"; + }, + + // A crude way of determining if an object is a window + isWindow: function( obj ) { + return obj && typeof obj === "object" && "setInterval" in obj; + }, + + isNaN: function( obj ) { + return obj == null || !rdigit.test( obj ) || isNaN( obj ); + }, + + type: function( obj ) { + return obj == null ? + String( obj ) : + class2type[ toString.call(obj) ] || "object"; + }, + + isPlainObject: function( obj ) { + // Must be an Object. + // Because of IE, we also have to check the presence of the constructor property. + // Make sure that DOM nodes and window objects don't pass through, as well + if ( !obj || jQuery.type(obj) !== "object" || obj.nodeType || jQuery.isWindow( obj ) ) { + return false; + } + + try { + // Not own constructor property must be Object + if ( obj.constructor && + !hasOwn.call(obj, "constructor") && + !hasOwn.call(obj.constructor.prototype, "isPrototypeOf") ) { + return false; + } + } catch ( e ) { + // IE8,9 Will throw exceptions on certain host objects #9897 + return false; + } + + // Own properties are enumerated firstly, so to speed up, + // if last one is own, then all properties are own. + + var key; + for ( key in obj ) {} + + return key === undefined || hasOwn.call( obj, key ); + }, + + isEmptyObject: function( obj ) { + for ( var name in obj ) { + return false; + } + return true; + }, + + error: function( msg ) { + throw msg; + }, + + parseJSON: function( data ) { + if ( typeof data !== "string" || !data ) { + return null; + } + + // Make sure leading/trailing whitespace is removed (IE can't handle it) + data = jQuery.trim( data ); + + // Attempt to parse using the native JSON parser first + if ( window.JSON && window.JSON.parse ) { + return window.JSON.parse( data ); + } + + // Make sure the incoming data is actual JSON + // Logic borrowed from http://json.org/json2.js + if ( rvalidchars.test( data.replace( rvalidescape, "@" ) + .replace( rvalidtokens, "]" ) + .replace( rvalidbraces, "")) ) { + + return (new Function( "return " + data ))(); + + } + jQuery.error( "Invalid JSON: " + data ); + }, + + // Cross-browser xml parsing + parseXML: function( data ) { + var xml, tmp; + try { + if ( window.DOMParser ) { // Standard + tmp = new DOMParser(); + xml = tmp.parseFromString( data , "text/xml" ); + } else { // IE + xml = new ActiveXObject( "Microsoft.XMLDOM" ); + xml.async = "false"; + xml.loadXML( data ); + } + } catch( e ) { + xml = undefined; + } + if ( !xml || !xml.documentElement || xml.getElementsByTagName( "parsererror" ).length ) { + jQuery.error( "Invalid XML: " + data ); + } + return xml; + }, + + noop: function() {}, + + // Evaluates a script in a global context + // Workarounds based on findings by Jim Driscoll + // http://weblogs.java.net/blog/driscoll/archive/2009/09/08/eval-javascript-global-context + globalEval: function( data ) { + if ( data && rnotwhite.test( data ) ) { + // We use execScript on Internet Explorer + // We use an anonymous function so that context is window + // rather than jQuery in Firefox + ( window.execScript || function( data ) { + window[ "eval" ].call( window, data ); + } )( data ); + } + }, + + // Convert dashed to camelCase; used by the css and data modules + // Microsoft forgot to hump their vendor prefix (#9572) + camelCase: function( string ) { + return string.replace( rmsPrefix, "ms-" ).replace( rdashAlpha, fcamelCase ); + }, + + nodeName: function( elem, name ) { + return elem.nodeName && elem.nodeName.toUpperCase() === name.toUpperCase(); + }, + + // args is for internal usage only + each: function( object, callback, args ) { + var name, i = 0, + length = object.length, + isObj = length === undefined || jQuery.isFunction( object ); + + if ( args ) { + if ( isObj ) { + for ( name in object ) { + if ( callback.apply( object[ name ], args ) === false ) { + break; + } + } + } else { + for ( ; i < length; ) { + if ( callback.apply( object[ i++ ], args ) === false ) { + break; + } + } + } + + // A special, fast, case for the most common use of each + } else { + if ( isObj ) { + for ( name in object ) { + if ( callback.call( object[ name ], name, object[ name ] ) === false ) { + break; + } + } + } else { + for ( ; i < length; ) { + if ( callback.call( object[ i ], i, object[ i++ ] ) === false ) { + break; + } + } + } + } + + return object; + }, + + // Use native String.trim function wherever possible + trim: trim ? + function( text ) { + return text == null ? + "" : + trim.call( text ); + } : + + // Otherwise use our own trimming functionality + function( text ) { + return text == null ? + "" : + text.toString().replace( trimLeft, "" ).replace( trimRight, "" ); + }, + + // results is for internal usage only + makeArray: function( array, results ) { + var ret = results || []; + + if ( array != null ) { + // The window, strings (and functions) also have 'length' + // The extra typeof function check is to prevent crashes + // in Safari 2 (See: #3039) + // Tweaked logic slightly to handle Blackberry 4.7 RegExp issues #6930 + var type = jQuery.type( array ); + + if ( array.length == null || type === "string" || type === "function" || type === "regexp" || jQuery.isWindow( array ) ) { + push.call( ret, array ); + } else { + jQuery.merge( ret, array ); + } + } + + return ret; + }, + + inArray: function( elem, array ) { + if ( !array ) { + return -1; + } + + if ( indexOf ) { + return indexOf.call( array, elem ); + } + + for ( var i = 0, length = array.length; i < length; i++ ) { + if ( array[ i ] === elem ) { + return i; + } + } + + return -1; + }, + + merge: function( first, second ) { + var i = first.length, + j = 0; + + if ( typeof second.length === "number" ) { + for ( var l = second.length; j < l; j++ ) { + first[ i++ ] = second[ j ]; + } + + } else { + while ( second[j] !== undefined ) { + first[ i++ ] = second[ j++ ]; + } + } + + first.length = i; + + return first; + }, + + grep: function( elems, callback, inv ) { + var ret = [], retVal; + inv = !!inv; + + // Go through the array, only saving the items + // that pass the validator function + for ( var i = 0, length = elems.length; i < length; i++ ) { + retVal = !!callback( elems[ i ], i ); + if ( inv !== retVal ) { + ret.push( elems[ i ] ); + } + } + + return ret; + }, + + // arg is for internal usage only + map: function( elems, callback, arg ) { + var value, key, ret = [], + i = 0, + length = elems.length, + // jquery objects are treated as arrays + isArray = elems instanceof jQuery || length !== undefined && typeof length === "number" && ( ( length > 0 && elems[ 0 ] && elems[ length -1 ] ) || length === 0 || jQuery.isArray( elems ) ) ; + + // Go through the array, translating each of the items to their + if ( isArray ) { + for ( ; i < length; i++ ) { + value = callback( elems[ i ], i, arg ); + + if ( value != null ) { + ret[ ret.length ] = value; + } + } + + // Go through every key on the object, + } else { + for ( key in elems ) { + value = callback( elems[ key ], key, arg ); + + if ( value != null ) { + ret[ ret.length ] = value; + } + } + } + + // Flatten any nested arrays + return ret.concat.apply( [], ret ); + }, + + // A global GUID counter for objects + guid: 1, + + // Bind a function to a context, optionally partially applying any + // arguments. + proxy: function( fn, context ) { + if ( typeof context === "string" ) { + var tmp = fn[ context ]; + context = fn; + fn = tmp; + } + + // Quick check to determine if target is callable, in the spec + // this throws a TypeError, but we will just return undefined. + if ( !jQuery.isFunction( fn ) ) { + return undefined; + } + + // Simulated bind + var args = slice.call( arguments, 2 ), + proxy = function() { + return fn.apply( context, args.concat( slice.call( arguments ) ) ); + }; + + // Set the guid of unique handler to the same of original handler, so it can be removed + proxy.guid = fn.guid = fn.guid || proxy.guid || jQuery.guid++; + + return proxy; + }, + + // Mutifunctional method to get and set values to a collection + // The value/s can optionally be executed if it's a function + access: function( elems, key, value, exec, fn, pass ) { + var length = elems.length; + + // Setting many attributes + if ( typeof key === "object" ) { + for ( var k in key ) { + jQuery.access( elems, k, key[k], exec, fn, value ); + } + return elems; + } + + // Setting one attribute + if ( value !== undefined ) { + // Optionally, function values get executed if exec is true + exec = !pass && exec && jQuery.isFunction(value); + + for ( var i = 0; i < length; i++ ) { + fn( elems[i], key, exec ? value.call( elems[i], i, fn( elems[i], key ) ) : value, pass ); + } + + return elems; + } + + // Getting an attribute + return length ? fn( elems[0], key ) : undefined; + }, + + now: function() { + return (new Date()).getTime(); + }, + + // Use of jQuery.browser is frowned upon. + // More details: http://docs.jquery.com/Utilities/jQuery.browser + uaMatch: function( ua ) { + ua = ua.toLowerCase(); + + var match = rwebkit.exec( ua ) || + ropera.exec( ua ) || + rmsie.exec( ua ) || + ua.indexOf("compatible") < 0 && rmozilla.exec( ua ) || + []; + + return { browser: match[1] || "", version: match[2] || "0" }; + }, + + sub: function() { + function jQuerySub( selector, context ) { + return new jQuerySub.fn.init( selector, context ); + } + jQuery.extend( true, jQuerySub, this ); + jQuerySub.superclass = this; + jQuerySub.fn = jQuerySub.prototype = this(); + jQuerySub.fn.constructor = jQuerySub; + jQuerySub.sub = this.sub; + jQuerySub.fn.init = function init( selector, context ) { + if ( context && context instanceof jQuery && !(context instanceof jQuerySub) ) { + context = jQuerySub( context ); + } + + return jQuery.fn.init.call( this, selector, context, rootjQuerySub ); + }; + jQuerySub.fn.init.prototype = jQuerySub.fn; + var rootjQuerySub = jQuerySub(document); + return jQuerySub; + }, + + browser: {} +}); + +// Populate the class2type map +jQuery.each("Boolean Number String Function Array Date RegExp Object".split(" "), function(i, name) { + class2type[ "[object " + name + "]" ] = name.toLowerCase(); +}); + +browserMatch = jQuery.uaMatch( userAgent ); +if ( browserMatch.browser ) { + jQuery.browser[ browserMatch.browser ] = true; + jQuery.browser.version = browserMatch.version; +} + +// Deprecated, use jQuery.browser.webkit instead +if ( jQuery.browser.webkit ) { + jQuery.browser.safari = true; +} + +// IE doesn't match non-breaking spaces with \s +if ( rnotwhite.test( "\xA0" ) ) { + trimLeft = /^[\s\xA0]+/; + trimRight = /[\s\xA0]+$/; +} + +// All jQuery objects should point back to these +rootjQuery = jQuery(document); + +// Cleanup functions for the document ready method +if ( document.addEventListener ) { + DOMContentLoaded = function() { + document.removeEventListener( "DOMContentLoaded", DOMContentLoaded, false ); + jQuery.ready(); + }; + +} else if ( document.attachEvent ) { + DOMContentLoaded = function() { + // Make sure body exists, at least, in case IE gets a little overzealous (ticket #5443). + if ( document.readyState === "complete" ) { + document.detachEvent( "onreadystatechange", DOMContentLoaded ); + jQuery.ready(); + } + }; +} + +// The DOM ready check for Internet Explorer +function doScrollCheck() { + if ( jQuery.isReady ) { + return; + } + + try { + // If IE is used, use the trick by Diego Perini + // http://javascript.nwbox.com/IEContentLoaded/ + document.documentElement.doScroll("left"); + } catch(e) { + setTimeout( doScrollCheck, 1 ); + return; + } + + // and execute any waiting functions + jQuery.ready(); +} + +return jQuery; + +})(); + + +var // Promise methods + promiseMethods = "done fail isResolved isRejected promise then always pipe".split( " " ), + // Static reference to slice + sliceDeferred = [].slice; + +jQuery.extend({ + // Create a simple deferred (one callbacks list) + _Deferred: function() { + var // callbacks list + callbacks = [], + // stored [ context , args ] + fired, + // to avoid firing when already doing so + firing, + // flag to know if the deferred has been cancelled + cancelled, + // the deferred itself + deferred = { + + // done( f1, f2, ...) + done: function() { + if ( !cancelled ) { + var args = arguments, + i, + length, + elem, + type, + _fired; + if ( fired ) { + _fired = fired; + fired = 0; + } + for ( i = 0, length = args.length; i < length; i++ ) { + elem = args[ i ]; + type = jQuery.type( elem ); + if ( type === "array" ) { + deferred.done.apply( deferred, elem ); + } else if ( type === "function" ) { + callbacks.push( elem ); + } + } + if ( _fired ) { + deferred.resolveWith( _fired[ 0 ], _fired[ 1 ] ); + } + } + return this; + }, + + // resolve with given context and args + resolveWith: function( context, args ) { + if ( !cancelled && !fired && !firing ) { + // make sure args are available (#8421) + args = args || []; + firing = 1; + try { + while( callbacks[ 0 ] ) { + callbacks.shift().apply( context, args ); + } + } + finally { + fired = [ context, args ]; + firing = 0; + } + } + return this; + }, + + // resolve with this as context and given arguments + resolve: function() { + deferred.resolveWith( this, arguments ); + return this; + }, + + // Has this deferred been resolved? + isResolved: function() { + return !!( firing || fired ); + }, + + // Cancel + cancel: function() { + cancelled = 1; + callbacks = []; + return this; + } + }; + + return deferred; + }, + + // Full fledged deferred (two callbacks list) + Deferred: function( func ) { + var deferred = jQuery._Deferred(), + failDeferred = jQuery._Deferred(), + promise; + // Add errorDeferred methods, then and promise + jQuery.extend( deferred, { + then: function( doneCallbacks, failCallbacks ) { + deferred.done( doneCallbacks ).fail( failCallbacks ); + return this; + }, + always: function() { + return deferred.done.apply( deferred, arguments ).fail.apply( this, arguments ); + }, + fail: failDeferred.done, + rejectWith: failDeferred.resolveWith, + reject: failDeferred.resolve, + isRejected: failDeferred.isResolved, + pipe: function( fnDone, fnFail ) { + return jQuery.Deferred(function( newDefer ) { + jQuery.each( { + done: [ fnDone, "resolve" ], + fail: [ fnFail, "reject" ] + }, function( handler, data ) { + var fn = data[ 0 ], + action = data[ 1 ], + returned; + if ( jQuery.isFunction( fn ) ) { + deferred[ handler ](function() { + returned = fn.apply( this, arguments ); + if ( returned && jQuery.isFunction( returned.promise ) ) { + returned.promise().then( newDefer.resolve, newDefer.reject ); + } else { + newDefer[ action + "With" ]( this === deferred ? newDefer : this, [ returned ] ); + } + }); + } else { + deferred[ handler ]( newDefer[ action ] ); + } + }); + }).promise(); + }, + // Get a promise for this deferred + // If obj is provided, the promise aspect is added to the object + promise: function( obj ) { + if ( obj == null ) { + if ( promise ) { + return promise; + } + promise = obj = {}; + } + var i = promiseMethods.length; + while( i-- ) { + obj[ promiseMethods[i] ] = deferred[ promiseMethods[i] ]; + } + return obj; + } + }); + // Make sure only one callback list will be used + deferred.done( failDeferred.cancel ).fail( deferred.cancel ); + // Unexpose cancel + delete deferred.cancel; + // Call given func if any + if ( func ) { + func.call( deferred, deferred ); + } + return deferred; + }, + + // Deferred helper + when: function( firstParam ) { + var args = arguments, + i = 0, + length = args.length, + count = length, + deferred = length <= 1 && firstParam && jQuery.isFunction( firstParam.promise ) ? + firstParam : + jQuery.Deferred(); + function resolveFunc( i ) { + return function( value ) { + args[ i ] = arguments.length > 1 ? sliceDeferred.call( arguments, 0 ) : value; + if ( !( --count ) ) { + // Strange bug in FF4: + // Values changed onto the arguments object sometimes end up as undefined values + // outside the $.when method. Cloning the object into a fresh array solves the issue + deferred.resolveWith( deferred, sliceDeferred.call( args, 0 ) ); + } + }; + } + if ( length > 1 ) { + for( ; i < length; i++ ) { + if ( args[ i ] && jQuery.isFunction( args[ i ].promise ) ) { + args[ i ].promise().then( resolveFunc(i), deferred.reject ); + } else { + --count; + } + } + if ( !count ) { + deferred.resolveWith( deferred, args ); + } + } else if ( deferred !== firstParam ) { + deferred.resolveWith( deferred, length ? [ firstParam ] : [] ); + } + return deferred.promise(); + } +}); + + + +jQuery.support = (function() { + + var div = document.createElement( "div" ), + documentElement = document.documentElement, + all, + a, + select, + opt, + input, + marginDiv, + support, + fragment, + body, + testElementParent, + testElement, + testElementStyle, + tds, + events, + eventName, + i, + isSupported; + + // Preliminary tests + div.setAttribute("className", "t"); + div.innerHTML = "
          a"; + + + all = div.getElementsByTagName( "*" ); + a = div.getElementsByTagName( "a" )[ 0 ]; + + // Can't get basic test support + if ( !all || !all.length || !a ) { + return {}; + } + + // First batch of supports tests + select = document.createElement( "select" ); + opt = select.appendChild( document.createElement("option") ); + input = div.getElementsByTagName( "input" )[ 0 ]; + + support = { + // IE strips leading whitespace when .innerHTML is used + leadingWhitespace: ( div.firstChild.nodeType === 3 ), + + // Make sure that tbody elements aren't automatically inserted + // IE will insert them into empty tables + tbody: !div.getElementsByTagName( "tbody" ).length, + + // Make sure that link elements get serialized correctly by innerHTML + // This requires a wrapper element in IE + htmlSerialize: !!div.getElementsByTagName( "link" ).length, + + // Get the style information from getAttribute + // (IE uses .cssText instead) + style: /top/.test( a.getAttribute("style") ), + + // Make sure that URLs aren't manipulated + // (IE normalizes it by default) + hrefNormalized: ( a.getAttribute( "href" ) === "/a" ), + + // Make sure that element opacity exists + // (IE uses filter instead) + // Use a regex to work around a WebKit issue. See #5145 + opacity: /^0.55$/.test( a.style.opacity ), + + // Verify style float existence + // (IE uses styleFloat instead of cssFloat) + cssFloat: !!a.style.cssFloat, + + // Make sure that if no value is specified for a checkbox + // that it defaults to "on". + // (WebKit defaults to "" instead) + checkOn: ( input.value === "on" ), + + // Make sure that a selected-by-default option has a working selected property. + // (WebKit defaults to false instead of true, IE too, if it's in an optgroup) + optSelected: opt.selected, + + // Test setAttribute on camelCase class. If it works, we need attrFixes when doing get/setAttribute (ie6/7) + getSetAttribute: div.className !== "t", + + // Will be defined later + submitBubbles: true, + changeBubbles: true, + focusinBubbles: false, + deleteExpando: true, + noCloneEvent: true, + inlineBlockNeedsLayout: false, + shrinkWrapBlocks: false, + reliableMarginRight: true + }; + + // Make sure checked status is properly cloned + input.checked = true; + support.noCloneChecked = input.cloneNode( true ).checked; + + // Make sure that the options inside disabled selects aren't marked as disabled + // (WebKit marks them as disabled) + select.disabled = true; + support.optDisabled = !opt.disabled; + + // Test to see if it's possible to delete an expando from an element + // Fails in Internet Explorer + try { + delete div.test; + } catch( e ) { + support.deleteExpando = false; + } + + if ( !div.addEventListener && div.attachEvent && div.fireEvent ) { + div.attachEvent( "onclick", function() { + // Cloning a node shouldn't copy over any + // bound event handlers (IE does this) + support.noCloneEvent = false; + }); + div.cloneNode( true ).fireEvent( "onclick" ); + } + + // Check if a radio maintains it's value + // after being appended to the DOM + input = document.createElement("input"); + input.value = "t"; + input.setAttribute("type", "radio"); + support.radioValue = input.value === "t"; + + input.setAttribute("checked", "checked"); + div.appendChild( input ); + fragment = document.createDocumentFragment(); + fragment.appendChild( div.firstChild ); + + // WebKit doesn't clone checked state correctly in fragments + support.checkClone = fragment.cloneNode( true ).cloneNode( true ).lastChild.checked; + + div.innerHTML = ""; + + // Figure out if the W3C box model works as expected + div.style.width = div.style.paddingLeft = "1px"; + + body = document.getElementsByTagName( "body" )[ 0 ]; + // We use our own, invisible, body unless the body is already present + // in which case we use a div (#9239) + testElement = document.createElement( body ? "div" : "body" ); + testElementStyle = { + visibility: "hidden", + width: 0, + height: 0, + border: 0, + margin: 0, + background: "none" + }; + if ( body ) { + jQuery.extend( testElementStyle, { + position: "absolute", + left: "-1000px", + top: "-1000px" + }); + } + for ( i in testElementStyle ) { + testElement.style[ i ] = testElementStyle[ i ]; + } + testElement.appendChild( div ); + testElementParent = body || documentElement; + testElementParent.insertBefore( testElement, testElementParent.firstChild ); + + // Check if a disconnected checkbox will retain its checked + // value of true after appended to the DOM (IE6/7) + support.appendChecked = input.checked; + + support.boxModel = div.offsetWidth === 2; + + if ( "zoom" in div.style ) { + // Check if natively block-level elements act like inline-block + // elements when setting their display to 'inline' and giving + // them layout + // (IE < 8 does this) + div.style.display = "inline"; + div.style.zoom = 1; + support.inlineBlockNeedsLayout = ( div.offsetWidth === 2 ); + + // Check if elements with layout shrink-wrap their children + // (IE 6 does this) + div.style.display = ""; + div.innerHTML = "
          "; + support.shrinkWrapBlocks = ( div.offsetWidth !== 2 ); + } + + div.innerHTML = "
          t
          "; + tds = div.getElementsByTagName( "td" ); + + // Check if table cells still have offsetWidth/Height when they are set + // to display:none and there are still other visible table cells in a + // table row; if so, offsetWidth/Height are not reliable for use when + // determining if an element has been hidden directly using + // display:none (it is still safe to use offsets if a parent element is + // hidden; don safety goggles and see bug #4512 for more information). + // (only IE 8 fails this test) + isSupported = ( tds[ 0 ].offsetHeight === 0 ); + + tds[ 0 ].style.display = ""; + tds[ 1 ].style.display = "none"; + + // Check if empty table cells still have offsetWidth/Height + // (IE < 8 fail this test) + support.reliableHiddenOffsets = isSupported && ( tds[ 0 ].offsetHeight === 0 ); + div.innerHTML = ""; + + // Check if div with explicit width and no margin-right incorrectly + // gets computed margin-right based on width of container. For more + // info see bug #3333 + // Fails in WebKit before Feb 2011 nightlies + // WebKit Bug 13343 - getComputedStyle returns wrong value for margin-right + if ( document.defaultView && document.defaultView.getComputedStyle ) { + marginDiv = document.createElement( "div" ); + marginDiv.style.width = "0"; + marginDiv.style.marginRight = "0"; + div.appendChild( marginDiv ); + support.reliableMarginRight = + ( parseInt( ( document.defaultView.getComputedStyle( marginDiv, null ) || { marginRight: 0 } ).marginRight, 10 ) || 0 ) === 0; + } + + // Remove the body element we added + testElement.innerHTML = ""; + testElementParent.removeChild( testElement ); + + // Technique from Juriy Zaytsev + // http://thinkweb2.com/projects/prototype/detecting-event-support-without-browser-sniffing/ + // We only care about the case where non-standard event systems + // are used, namely in IE. Short-circuiting here helps us to + // avoid an eval call (in setAttribute) which can cause CSP + // to go haywire. See: https://developer.mozilla.org/en/Security/CSP + if ( div.attachEvent ) { + for( i in { + submit: 1, + change: 1, + focusin: 1 + } ) { + eventName = "on" + i; + isSupported = ( eventName in div ); + if ( !isSupported ) { + div.setAttribute( eventName, "return;" ); + isSupported = ( typeof div[ eventName ] === "function" ); + } + support[ i + "Bubbles" ] = isSupported; + } + } + + // Null connected elements to avoid leaks in IE + testElement = fragment = select = opt = body = marginDiv = div = input = null; + + return support; +})(); + +// Keep track of boxModel +jQuery.boxModel = jQuery.support.boxModel; + + + + +var rbrace = /^(?:\{.*\}|\[.*\])$/, + rmultiDash = /([A-Z])/g; + +jQuery.extend({ + cache: {}, + + // Please use with caution + uuid: 0, + + // Unique for each copy of jQuery on the page + // Non-digits removed to match rinlinejQuery + expando: "jQuery" + ( jQuery.fn.jquery + Math.random() ).replace( /\D/g, "" ), + + // The following elements throw uncatchable exceptions if you + // attempt to add expando properties to them. + noData: { + "embed": true, + // Ban all objects except for Flash (which handle expandos) + "object": "clsid:D27CDB6E-AE6D-11cf-96B8-444553540000", + "applet": true + }, + + hasData: function( elem ) { + elem = elem.nodeType ? jQuery.cache[ elem[jQuery.expando] ] : elem[ jQuery.expando ]; + + return !!elem && !isEmptyDataObject( elem ); + }, + + data: function( elem, name, data, pvt /* Internal Use Only */ ) { + if ( !jQuery.acceptData( elem ) ) { + return; + } + + var thisCache, ret, + internalKey = jQuery.expando, + getByName = typeof name === "string", + + // We have to handle DOM nodes and JS objects differently because IE6-7 + // can't GC object references properly across the DOM-JS boundary + isNode = elem.nodeType, + + // Only DOM nodes need the global jQuery cache; JS object data is + // attached directly to the object so GC can occur automatically + cache = isNode ? jQuery.cache : elem, + + // Only defining an ID for JS objects if its cache already exists allows + // the code to shortcut on the same path as a DOM node with no cache + id = isNode ? elem[ jQuery.expando ] : elem[ jQuery.expando ] && jQuery.expando; + + // Avoid doing any more work than we need to when trying to get data on an + // object that has no data at all + if ( (!id || (pvt && id && (cache[ id ] && !cache[ id ][ internalKey ]))) && getByName && data === undefined ) { + return; + } + + if ( !id ) { + // Only DOM nodes need a new unique ID for each element since their data + // ends up in the global cache + if ( isNode ) { + elem[ jQuery.expando ] = id = ++jQuery.uuid; + } else { + id = jQuery.expando; + } + } + + if ( !cache[ id ] ) { + cache[ id ] = {}; + + // TODO: This is a hack for 1.5 ONLY. Avoids exposing jQuery + // metadata on plain JS objects when the object is serialized using + // JSON.stringify + if ( !isNode ) { + cache[ id ].toJSON = jQuery.noop; + } + } + + // An object can be passed to jQuery.data instead of a key/value pair; this gets + // shallow copied over onto the existing cache + if ( typeof name === "object" || typeof name === "function" ) { + if ( pvt ) { + cache[ id ][ internalKey ] = jQuery.extend(cache[ id ][ internalKey ], name); + } else { + cache[ id ] = jQuery.extend(cache[ id ], name); + } + } + + thisCache = cache[ id ]; + + // Internal jQuery data is stored in a separate object inside the object's data + // cache in order to avoid key collisions between internal data and user-defined + // data + if ( pvt ) { + if ( !thisCache[ internalKey ] ) { + thisCache[ internalKey ] = {}; + } + + thisCache = thisCache[ internalKey ]; + } + + if ( data !== undefined ) { + thisCache[ jQuery.camelCase( name ) ] = data; + } + + // TODO: This is a hack for 1.5 ONLY. It will be removed in 1.6. Users should + // not attempt to inspect the internal events object using jQuery.data, as this + // internal data object is undocumented and subject to change. + if ( name === "events" && !thisCache[name] ) { + return thisCache[ internalKey ] && thisCache[ internalKey ].events; + } + + // Check for both converted-to-camel and non-converted data property names + // If a data property was specified + if ( getByName ) { + + // First Try to find as-is property data + ret = thisCache[ name ]; + + // Test for null|undefined property data + if ( ret == null ) { + + // Try to find the camelCased property + ret = thisCache[ jQuery.camelCase( name ) ]; + } + } else { + ret = thisCache; + } + + return ret; + }, + + removeData: function( elem, name, pvt /* Internal Use Only */ ) { + if ( !jQuery.acceptData( elem ) ) { + return; + } + + var thisCache, + + // Reference to internal data cache key + internalKey = jQuery.expando, + + isNode = elem.nodeType, + + // See jQuery.data for more information + cache = isNode ? jQuery.cache : elem, + + // See jQuery.data for more information + id = isNode ? elem[ jQuery.expando ] : jQuery.expando; + + // If there is already no cache entry for this object, there is no + // purpose in continuing + if ( !cache[ id ] ) { + return; + } + + if ( name ) { + + thisCache = pvt ? cache[ id ][ internalKey ] : cache[ id ]; + + if ( thisCache ) { + + // Support interoperable removal of hyphenated or camelcased keys + if ( !thisCache[ name ] ) { + name = jQuery.camelCase( name ); + } + + delete thisCache[ name ]; + + // If there is no data left in the cache, we want to continue + // and let the cache object itself get destroyed + if ( !isEmptyDataObject(thisCache) ) { + return; + } + } + } + + // See jQuery.data for more information + if ( pvt ) { + delete cache[ id ][ internalKey ]; + + // Don't destroy the parent cache unless the internal data object + // had been the only thing left in it + if ( !isEmptyDataObject(cache[ id ]) ) { + return; + } + } + + var internalCache = cache[ id ][ internalKey ]; + + // Browsers that fail expando deletion also refuse to delete expandos on + // the window, but it will allow it on all other JS objects; other browsers + // don't care + // Ensure that `cache` is not a window object #10080 + if ( jQuery.support.deleteExpando || !cache.setInterval ) { + delete cache[ id ]; + } else { + cache[ id ] = null; + } + + // We destroyed the entire user cache at once because it's faster than + // iterating through each key, but we need to continue to persist internal + // data if it existed + if ( internalCache ) { + cache[ id ] = {}; + // TODO: This is a hack for 1.5 ONLY. Avoids exposing jQuery + // metadata on plain JS objects when the object is serialized using + // JSON.stringify + if ( !isNode ) { + cache[ id ].toJSON = jQuery.noop; + } + + cache[ id ][ internalKey ] = internalCache; + + // Otherwise, we need to eliminate the expando on the node to avoid + // false lookups in the cache for entries that no longer exist + } else if ( isNode ) { + // IE does not allow us to delete expando properties from nodes, + // nor does it have a removeAttribute function on Document nodes; + // we must handle all of these cases + if ( jQuery.support.deleteExpando ) { + delete elem[ jQuery.expando ]; + } else if ( elem.removeAttribute ) { + elem.removeAttribute( jQuery.expando ); + } else { + elem[ jQuery.expando ] = null; + } + } + }, + + // For internal use only. + _data: function( elem, name, data ) { + return jQuery.data( elem, name, data, true ); + }, + + // A method for determining if a DOM node can handle the data expando + acceptData: function( elem ) { + if ( elem.nodeName ) { + var match = jQuery.noData[ elem.nodeName.toLowerCase() ]; + + if ( match ) { + return !(match === true || elem.getAttribute("classid") !== match); + } + } + + return true; + } +}); + +jQuery.fn.extend({ + data: function( key, value ) { + var data = null; + + if ( typeof key === "undefined" ) { + if ( this.length ) { + data = jQuery.data( this[0] ); + + if ( this[0].nodeType === 1 ) { + var attr = this[0].attributes, name; + for ( var i = 0, l = attr.length; i < l; i++ ) { + name = attr[i].name; + + if ( name.indexOf( "data-" ) === 0 ) { + name = jQuery.camelCase( name.substring(5) ); + + dataAttr( this[0], name, data[ name ] ); + } + } + } + } + + return data; + + } else if ( typeof key === "object" ) { + return this.each(function() { + jQuery.data( this, key ); + }); + } + + var parts = key.split("."); + parts[1] = parts[1] ? "." + parts[1] : ""; + + if ( value === undefined ) { + data = this.triggerHandler("getData" + parts[1] + "!", [parts[0]]); + + // Try to fetch any internally stored data first + if ( data === undefined && this.length ) { + data = jQuery.data( this[0], key ); + data = dataAttr( this[0], key, data ); + } + + return data === undefined && parts[1] ? + this.data( parts[0] ) : + data; + + } else { + return this.each(function() { + var $this = jQuery( this ), + args = [ parts[0], value ]; + + $this.triggerHandler( "setData" + parts[1] + "!", args ); + jQuery.data( this, key, value ); + $this.triggerHandler( "changeData" + parts[1] + "!", args ); + }); + } + }, + + removeData: function( key ) { + return this.each(function() { + jQuery.removeData( this, key ); + }); + } +}); + +function dataAttr( elem, key, data ) { + // If nothing was found internally, try to fetch any + // data from the HTML5 data-* attribute + if ( data === undefined && elem.nodeType === 1 ) { + + var name = "data-" + key.replace( rmultiDash, "-$1" ).toLowerCase(); + + data = elem.getAttribute( name ); + + if ( typeof data === "string" ) { + try { + data = data === "true" ? true : + data === "false" ? false : + data === "null" ? null : + !jQuery.isNaN( data ) ? parseFloat( data ) : + rbrace.test( data ) ? jQuery.parseJSON( data ) : + data; + } catch( e ) {} + + // Make sure we set the data so it isn't changed later + jQuery.data( elem, key, data ); + + } else { + data = undefined; + } + } + + return data; +} + +// TODO: This is a hack for 1.5 ONLY to allow objects with a single toJSON +// property to be considered empty objects; this property always exists in +// order to make sure JSON.stringify does not expose internal metadata +function isEmptyDataObject( obj ) { + for ( var name in obj ) { + if ( name !== "toJSON" ) { + return false; + } + } + + return true; +} + + + + +function handleQueueMarkDefer( elem, type, src ) { + var deferDataKey = type + "defer", + queueDataKey = type + "queue", + markDataKey = type + "mark", + defer = jQuery.data( elem, deferDataKey, undefined, true ); + if ( defer && + ( src === "queue" || !jQuery.data( elem, queueDataKey, undefined, true ) ) && + ( src === "mark" || !jQuery.data( elem, markDataKey, undefined, true ) ) ) { + // Give room for hard-coded callbacks to fire first + // and eventually mark/queue something else on the element + setTimeout( function() { + if ( !jQuery.data( elem, queueDataKey, undefined, true ) && + !jQuery.data( elem, markDataKey, undefined, true ) ) { + jQuery.removeData( elem, deferDataKey, true ); + defer.resolve(); + } + }, 0 ); + } +} + +jQuery.extend({ + + _mark: function( elem, type ) { + if ( elem ) { + type = (type || "fx") + "mark"; + jQuery.data( elem, type, (jQuery.data(elem,type,undefined,true) || 0) + 1, true ); + } + }, + + _unmark: function( force, elem, type ) { + if ( force !== true ) { + type = elem; + elem = force; + force = false; + } + if ( elem ) { + type = type || "fx"; + var key = type + "mark", + count = force ? 0 : ( (jQuery.data( elem, key, undefined, true) || 1 ) - 1 ); + if ( count ) { + jQuery.data( elem, key, count, true ); + } else { + jQuery.removeData( elem, key, true ); + handleQueueMarkDefer( elem, type, "mark" ); + } + } + }, + + queue: function( elem, type, data ) { + if ( elem ) { + type = (type || "fx") + "queue"; + var q = jQuery.data( elem, type, undefined, true ); + // Speed up dequeue by getting out quickly if this is just a lookup + if ( data ) { + if ( !q || jQuery.isArray(data) ) { + q = jQuery.data( elem, type, jQuery.makeArray(data), true ); + } else { + q.push( data ); + } + } + return q || []; + } + }, + + dequeue: function( elem, type ) { + type = type || "fx"; + + var queue = jQuery.queue( elem, type ), + fn = queue.shift(), + defer; + + // If the fx queue is dequeued, always remove the progress sentinel + if ( fn === "inprogress" ) { + fn = queue.shift(); + } + + if ( fn ) { + // Add a progress sentinel to prevent the fx queue from being + // automatically dequeued + if ( type === "fx" ) { + queue.unshift("inprogress"); + } + + fn.call(elem, function() { + jQuery.dequeue(elem, type); + }); + } + + if ( !queue.length ) { + jQuery.removeData( elem, type + "queue", true ); + handleQueueMarkDefer( elem, type, "queue" ); + } + } +}); + +jQuery.fn.extend({ + queue: function( type, data ) { + if ( typeof type !== "string" ) { + data = type; + type = "fx"; + } + + if ( data === undefined ) { + return jQuery.queue( this[0], type ); + } + return this.each(function() { + var queue = jQuery.queue( this, type, data ); + + if ( type === "fx" && queue[0] !== "inprogress" ) { + jQuery.dequeue( this, type ); + } + }); + }, + dequeue: function( type ) { + return this.each(function() { + jQuery.dequeue( this, type ); + }); + }, + // Based off of the plugin by Clint Helfers, with permission. + // http://blindsignals.com/index.php/2009/07/jquery-delay/ + delay: function( time, type ) { + time = jQuery.fx ? jQuery.fx.speeds[time] || time : time; + type = type || "fx"; + + return this.queue( type, function() { + var elem = this; + setTimeout(function() { + jQuery.dequeue( elem, type ); + }, time ); + }); + }, + clearQueue: function( type ) { + return this.queue( type || "fx", [] ); + }, + // Get a promise resolved when queues of a certain type + // are emptied (fx is the type by default) + promise: function( type, object ) { + if ( typeof type !== "string" ) { + object = type; + type = undefined; + } + type = type || "fx"; + var defer = jQuery.Deferred(), + elements = this, + i = elements.length, + count = 1, + deferDataKey = type + "defer", + queueDataKey = type + "queue", + markDataKey = type + "mark", + tmp; + function resolve() { + if ( !( --count ) ) { + defer.resolveWith( elements, [ elements ] ); + } + } + while( i-- ) { + if (( tmp = jQuery.data( elements[ i ], deferDataKey, undefined, true ) || + ( jQuery.data( elements[ i ], queueDataKey, undefined, true ) || + jQuery.data( elements[ i ], markDataKey, undefined, true ) ) && + jQuery.data( elements[ i ], deferDataKey, jQuery._Deferred(), true ) )) { + count++; + tmp.done( resolve ); + } + } + resolve(); + return defer.promise(); + } +}); + + + + +var rclass = /[\n\t\r]/g, + rspace = /\s+/, + rreturn = /\r/g, + rtype = /^(?:button|input)$/i, + rfocusable = /^(?:button|input|object|select|textarea)$/i, + rclickable = /^a(?:rea)?$/i, + rboolean = /^(?:autofocus|autoplay|async|checked|controls|defer|disabled|hidden|loop|multiple|open|readonly|required|scoped|selected)$/i, + nodeHook, boolHook; + +jQuery.fn.extend({ + attr: function( name, value ) { + return jQuery.access( this, name, value, true, jQuery.attr ); + }, + + removeAttr: function( name ) { + return this.each(function() { + jQuery.removeAttr( this, name ); + }); + }, + + prop: function( name, value ) { + return jQuery.access( this, name, value, true, jQuery.prop ); + }, + + removeProp: function( name ) { + name = jQuery.propFix[ name ] || name; + return this.each(function() { + // try/catch handles cases where IE balks (such as removing a property on window) + try { + this[ name ] = undefined; + delete this[ name ]; + } catch( e ) {} + }); + }, + + addClass: function( value ) { + var classNames, i, l, elem, + setClass, c, cl; + + if ( jQuery.isFunction( value ) ) { + return this.each(function( j ) { + jQuery( this ).addClass( value.call(this, j, this.className) ); + }); + } + + if ( value && typeof value === "string" ) { + classNames = value.split( rspace ); + + for ( i = 0, l = this.length; i < l; i++ ) { + elem = this[ i ]; + + if ( elem.nodeType === 1 ) { + if ( !elem.className && classNames.length === 1 ) { + elem.className = value; + + } else { + setClass = " " + elem.className + " "; + + for ( c = 0, cl = classNames.length; c < cl; c++ ) { + if ( !~setClass.indexOf( " " + classNames[ c ] + " " ) ) { + setClass += classNames[ c ] + " "; + } + } + elem.className = jQuery.trim( setClass ); + } + } + } + } + + return this; + }, + + removeClass: function( value ) { + var classNames, i, l, elem, className, c, cl; + + if ( jQuery.isFunction( value ) ) { + return this.each(function( j ) { + jQuery( this ).removeClass( value.call(this, j, this.className) ); + }); + } + + if ( (value && typeof value === "string") || value === undefined ) { + classNames = (value || "").split( rspace ); + + for ( i = 0, l = this.length; i < l; i++ ) { + elem = this[ i ]; + + if ( elem.nodeType === 1 && elem.className ) { + if ( value ) { + className = (" " + elem.className + " ").replace( rclass, " " ); + for ( c = 0, cl = classNames.length; c < cl; c++ ) { + className = className.replace(" " + classNames[ c ] + " ", " "); + } + elem.className = jQuery.trim( className ); + + } else { + elem.className = ""; + } + } + } + } + + return this; + }, + + toggleClass: function( value, stateVal ) { + var type = typeof value, + isBool = typeof stateVal === "boolean"; + + if ( jQuery.isFunction( value ) ) { + return this.each(function( i ) { + jQuery( this ).toggleClass( value.call(this, i, this.className, stateVal), stateVal ); + }); + } + + return this.each(function() { + if ( type === "string" ) { + // toggle individual class names + var className, + i = 0, + self = jQuery( this ), + state = stateVal, + classNames = value.split( rspace ); + + while ( (className = classNames[ i++ ]) ) { + // check each className given, space seperated list + state = isBool ? state : !self.hasClass( className ); + self[ state ? "addClass" : "removeClass" ]( className ); + } + + } else if ( type === "undefined" || type === "boolean" ) { + if ( this.className ) { + // store className if set + jQuery._data( this, "__className__", this.className ); + } + + // toggle whole className + this.className = this.className || value === false ? "" : jQuery._data( this, "__className__" ) || ""; + } + }); + }, + + hasClass: function( selector ) { + var className = " " + selector + " "; + for ( var i = 0, l = this.length; i < l; i++ ) { + if ( this[i].nodeType === 1 && (" " + this[i].className + " ").replace(rclass, " ").indexOf( className ) > -1 ) { + return true; + } + } + + return false; + }, + + val: function( value ) { + var hooks, ret, + elem = this[0]; + + if ( !arguments.length ) { + if ( elem ) { + hooks = jQuery.valHooks[ elem.nodeName.toLowerCase() ] || jQuery.valHooks[ elem.type ]; + + if ( hooks && "get" in hooks && (ret = hooks.get( elem, "value" )) !== undefined ) { + return ret; + } + + ret = elem.value; + + return typeof ret === "string" ? + // handle most common string cases + ret.replace(rreturn, "") : + // handle cases where value is null/undef or number + ret == null ? "" : ret; + } + + return undefined; + } + + var isFunction = jQuery.isFunction( value ); + + return this.each(function( i ) { + var self = jQuery(this), val; + + if ( this.nodeType !== 1 ) { + return; + } + + if ( isFunction ) { + val = value.call( this, i, self.val() ); + } else { + val = value; + } + + // Treat null/undefined as ""; convert numbers to string + if ( val == null ) { + val = ""; + } else if ( typeof val === "number" ) { + val += ""; + } else if ( jQuery.isArray( val ) ) { + val = jQuery.map(val, function ( value ) { + return value == null ? "" : value + ""; + }); + } + + hooks = jQuery.valHooks[ this.nodeName.toLowerCase() ] || jQuery.valHooks[ this.type ]; + + // If set returns undefined, fall back to normal setting + if ( !hooks || !("set" in hooks) || hooks.set( this, val, "value" ) === undefined ) { + this.value = val; + } + }); + } +}); + +jQuery.extend({ + valHooks: { + option: { + get: function( elem ) { + // attributes.value is undefined in Blackberry 4.7 but + // uses .value. See #6932 + var val = elem.attributes.value; + return !val || val.specified ? elem.value : elem.text; + } + }, + select: { + get: function( elem ) { + var value, + index = elem.selectedIndex, + values = [], + options = elem.options, + one = elem.type === "select-one"; + + // Nothing was selected + if ( index < 0 ) { + return null; + } + + // Loop through all the selected options + for ( var i = one ? index : 0, max = one ? index + 1 : options.length; i < max; i++ ) { + var option = options[ i ]; + + // Don't return options that are disabled or in a disabled optgroup + if ( option.selected && (jQuery.support.optDisabled ? !option.disabled : option.getAttribute("disabled") === null) && + (!option.parentNode.disabled || !jQuery.nodeName( option.parentNode, "optgroup" )) ) { + + // Get the specific value for the option + value = jQuery( option ).val(); + + // We don't need an array for one selects + if ( one ) { + return value; + } + + // Multi-Selects return an array + values.push( value ); + } + } + + // Fixes Bug #2551 -- select.val() broken in IE after form.reset() + if ( one && !values.length && options.length ) { + return jQuery( options[ index ] ).val(); + } + + return values; + }, + + set: function( elem, value ) { + var values = jQuery.makeArray( value ); + + jQuery(elem).find("option").each(function() { + this.selected = jQuery.inArray( jQuery(this).val(), values ) >= 0; + }); + + if ( !values.length ) { + elem.selectedIndex = -1; + } + return values; + } + } + }, + + attrFn: { + val: true, + css: true, + html: true, + text: true, + data: true, + width: true, + height: true, + offset: true + }, + + attrFix: { + // Always normalize to ensure hook usage + tabindex: "tabIndex" + }, + + attr: function( elem, name, value, pass ) { + var nType = elem.nodeType; + + // don't get/set attributes on text, comment and attribute nodes + if ( !elem || nType === 3 || nType === 8 || nType === 2 ) { + return undefined; + } + + if ( pass && name in jQuery.attrFn ) { + return jQuery( elem )[ name ]( value ); + } + + // Fallback to prop when attributes are not supported + if ( !("getAttribute" in elem) ) { + return jQuery.prop( elem, name, value ); + } + + var ret, hooks, + notxml = nType !== 1 || !jQuery.isXMLDoc( elem ); + + // Normalize the name if needed + if ( notxml ) { + name = jQuery.attrFix[ name ] || name; + + hooks = jQuery.attrHooks[ name ]; + + if ( !hooks ) { + // Use boolHook for boolean attributes + if ( rboolean.test( name ) ) { + hooks = boolHook; + + // Use nodeHook if available( IE6/7 ) + } else if ( nodeHook ) { + hooks = nodeHook; + } + } + } + + if ( value !== undefined ) { + + if ( value === null ) { + jQuery.removeAttr( elem, name ); + return undefined; + + } else if ( hooks && "set" in hooks && notxml && (ret = hooks.set( elem, value, name )) !== undefined ) { + return ret; + + } else { + elem.setAttribute( name, "" + value ); + return value; + } + + } else if ( hooks && "get" in hooks && notxml && (ret = hooks.get( elem, name )) !== null ) { + return ret; + + } else { + + ret = elem.getAttribute( name ); + + // Non-existent attributes return null, we normalize to undefined + return ret === null ? + undefined : + ret; + } + }, + + removeAttr: function( elem, name ) { + var propName; + if ( elem.nodeType === 1 ) { + name = jQuery.attrFix[ name ] || name; + + jQuery.attr( elem, name, "" ); + elem.removeAttribute( name ); + + // Set corresponding property to false for boolean attributes + if ( rboolean.test( name ) && (propName = jQuery.propFix[ name ] || name) in elem ) { + elem[ propName ] = false; + } + } + }, + + attrHooks: { + type: { + set: function( elem, value ) { + // We can't allow the type property to be changed (since it causes problems in IE) + if ( rtype.test( elem.nodeName ) && elem.parentNode ) { + jQuery.error( "type property can't be changed" ); + } else if ( !jQuery.support.radioValue && value === "radio" && jQuery.nodeName(elem, "input") ) { + // Setting the type on a radio button after the value resets the value in IE6-9 + // Reset value to it's default in case type is set after value + // This is for element creation + var val = elem.value; + elem.setAttribute( "type", value ); + if ( val ) { + elem.value = val; + } + return value; + } + } + }, + // Use the value property for back compat + // Use the nodeHook for button elements in IE6/7 (#1954) + value: { + get: function( elem, name ) { + if ( nodeHook && jQuery.nodeName( elem, "button" ) ) { + return nodeHook.get( elem, name ); + } + return name in elem ? + elem.value : + null; + }, + set: function( elem, value, name ) { + if ( nodeHook && jQuery.nodeName( elem, "button" ) ) { + return nodeHook.set( elem, value, name ); + } + // Does not return so that setAttribute is also used + elem.value = value; + } + } + }, + + propFix: { + tabindex: "tabIndex", + readonly: "readOnly", + "for": "htmlFor", + "class": "className", + maxlength: "maxLength", + cellspacing: "cellSpacing", + cellpadding: "cellPadding", + rowspan: "rowSpan", + colspan: "colSpan", + usemap: "useMap", + frameborder: "frameBorder", + contenteditable: "contentEditable" + }, + + prop: function( elem, name, value ) { + var nType = elem.nodeType; + + // don't get/set properties on text, comment and attribute nodes + if ( !elem || nType === 3 || nType === 8 || nType === 2 ) { + return undefined; + } + + var ret, hooks, + notxml = nType !== 1 || !jQuery.isXMLDoc( elem ); + + if ( notxml ) { + // Fix name and attach hooks + name = jQuery.propFix[ name ] || name; + hooks = jQuery.propHooks[ name ]; + } + + if ( value !== undefined ) { + if ( hooks && "set" in hooks && (ret = hooks.set( elem, value, name )) !== undefined ) { + return ret; + + } else { + return (elem[ name ] = value); + } + + } else { + if ( hooks && "get" in hooks && (ret = hooks.get( elem, name )) !== null ) { + return ret; + + } else { + return elem[ name ]; + } + } + }, + + propHooks: { + tabIndex: { + get: function( elem ) { + // elem.tabIndex doesn't always return the correct value when it hasn't been explicitly set + // http://fluidproject.org/blog/2008/01/09/getting-setting-and-removing-tabindex-values-with-javascript/ + var attributeNode = elem.getAttributeNode("tabindex"); + + return attributeNode && attributeNode.specified ? + parseInt( attributeNode.value, 10 ) : + rfocusable.test( elem.nodeName ) || rclickable.test( elem.nodeName ) && elem.href ? + 0 : + undefined; + } + } + } +}); + +// Add the tabindex propHook to attrHooks for back-compat +jQuery.attrHooks.tabIndex = jQuery.propHooks.tabIndex; + +// Hook for boolean attributes +boolHook = { + get: function( elem, name ) { + // Align boolean attributes with corresponding properties + // Fall back to attribute presence where some booleans are not supported + var attrNode; + return jQuery.prop( elem, name ) === true || ( attrNode = elem.getAttributeNode( name ) ) && attrNode.nodeValue !== false ? + name.toLowerCase() : + undefined; + }, + set: function( elem, value, name ) { + var propName; + if ( value === false ) { + // Remove boolean attributes when set to false + jQuery.removeAttr( elem, name ); + } else { + // value is true since we know at this point it's type boolean and not false + // Set boolean attributes to the same name and set the DOM property + propName = jQuery.propFix[ name ] || name; + if ( propName in elem ) { + // Only set the IDL specifically if it already exists on the element + elem[ propName ] = true; + } + + elem.setAttribute( name, name.toLowerCase() ); + } + return name; + } +}; + +// IE6/7 do not support getting/setting some attributes with get/setAttribute +if ( !jQuery.support.getSetAttribute ) { + + // Use this for any attribute in IE6/7 + // This fixes almost every IE6/7 issue + nodeHook = jQuery.valHooks.button = { + get: function( elem, name ) { + var ret; + ret = elem.getAttributeNode( name ); + // Return undefined if nodeValue is empty string + return ret && ret.nodeValue !== "" ? + ret.nodeValue : + undefined; + }, + set: function( elem, value, name ) { + // Set the existing or create a new attribute node + var ret = elem.getAttributeNode( name ); + if ( !ret ) { + ret = document.createAttribute( name ); + elem.setAttributeNode( ret ); + } + return (ret.nodeValue = value + ""); + } + }; + + // Set width and height to auto instead of 0 on empty string( Bug #8150 ) + // This is for removals + jQuery.each([ "width", "height" ], function( i, name ) { + jQuery.attrHooks[ name ] = jQuery.extend( jQuery.attrHooks[ name ], { + set: function( elem, value ) { + if ( value === "" ) { + elem.setAttribute( name, "auto" ); + return value; + } + } + }); + }); +} + + +// Some attributes require a special call on IE +if ( !jQuery.support.hrefNormalized ) { + jQuery.each([ "href", "src", "width", "height" ], function( i, name ) { + jQuery.attrHooks[ name ] = jQuery.extend( jQuery.attrHooks[ name ], { + get: function( elem ) { + var ret = elem.getAttribute( name, 2 ); + return ret === null ? undefined : ret; + } + }); + }); +} + +if ( !jQuery.support.style ) { + jQuery.attrHooks.style = { + get: function( elem ) { + // Return undefined in the case of empty string + // Normalize to lowercase since IE uppercases css property names + return elem.style.cssText.toLowerCase() || undefined; + }, + set: function( elem, value ) { + return (elem.style.cssText = "" + value); + } + }; +} + +// Safari mis-reports the default selected property of an option +// Accessing the parent's selectedIndex property fixes it +if ( !jQuery.support.optSelected ) { + jQuery.propHooks.selected = jQuery.extend( jQuery.propHooks.selected, { + get: function( elem ) { + var parent = elem.parentNode; + + if ( parent ) { + parent.selectedIndex; + + // Make sure that it also works with optgroups, see #5701 + if ( parent.parentNode ) { + parent.parentNode.selectedIndex; + } + } + return null; + } + }); +} + +// Radios and checkboxes getter/setter +if ( !jQuery.support.checkOn ) { + jQuery.each([ "radio", "checkbox" ], function() { + jQuery.valHooks[ this ] = { + get: function( elem ) { + // Handle the case where in Webkit "" is returned instead of "on" if a value isn't specified + return elem.getAttribute("value") === null ? "on" : elem.value; + } + }; + }); +} +jQuery.each([ "radio", "checkbox" ], function() { + jQuery.valHooks[ this ] = jQuery.extend( jQuery.valHooks[ this ], { + set: function( elem, value ) { + if ( jQuery.isArray( value ) ) { + return (elem.checked = jQuery.inArray( jQuery(elem).val(), value ) >= 0); + } + } + }); +}); + + + + +var rnamespaces = /\.(.*)$/, + rformElems = /^(?:textarea|input|select)$/i, + rperiod = /\./g, + rspaces = / /g, + rescape = /[^\w\s.|`]/g, + fcleanup = function( nm ) { + return nm.replace(rescape, "\\$&"); + }; + +/* + * A number of helper functions used for managing events. + * Many of the ideas behind this code originated from + * Dean Edwards' addEvent library. + */ +jQuery.event = { + + // Bind an event to an element + // Original by Dean Edwards + add: function( elem, types, handler, data ) { + if ( elem.nodeType === 3 || elem.nodeType === 8 ) { + return; + } + + if ( handler === false ) { + handler = returnFalse; + } else if ( !handler ) { + // Fixes bug #7229. Fix recommended by jdalton + return; + } + + var handleObjIn, handleObj; + + if ( handler.handler ) { + handleObjIn = handler; + handler = handleObjIn.handler; + } + + // Make sure that the function being executed has a unique ID + if ( !handler.guid ) { + handler.guid = jQuery.guid++; + } + + // Init the element's event structure + var elemData = jQuery._data( elem ); + + // If no elemData is found then we must be trying to bind to one of the + // banned noData elements + if ( !elemData ) { + return; + } + + var events = elemData.events, + eventHandle = elemData.handle; + + if ( !events ) { + elemData.events = events = {}; + } + + if ( !eventHandle ) { + elemData.handle = eventHandle = function( e ) { + // Discard the second event of a jQuery.event.trigger() and + // when an event is called after a page has unloaded + return typeof jQuery !== "undefined" && (!e || jQuery.event.triggered !== e.type) ? + jQuery.event.handle.apply( eventHandle.elem, arguments ) : + undefined; + }; + } + + // Add elem as a property of the handle function + // This is to prevent a memory leak with non-native events in IE. + eventHandle.elem = elem; + + // Handle multiple events separated by a space + // jQuery(...).bind("mouseover mouseout", fn); + types = types.split(" "); + + var type, i = 0, namespaces; + + while ( (type = types[ i++ ]) ) { + handleObj = handleObjIn ? + jQuery.extend({}, handleObjIn) : + { handler: handler, data: data }; + + // Namespaced event handlers + if ( type.indexOf(".") > -1 ) { + namespaces = type.split("."); + type = namespaces.shift(); + handleObj.namespace = namespaces.slice(0).sort().join("."); + + } else { + namespaces = []; + handleObj.namespace = ""; + } + + handleObj.type = type; + if ( !handleObj.guid ) { + handleObj.guid = handler.guid; + } + + // Get the current list of functions bound to this event + var handlers = events[ type ], + special = jQuery.event.special[ type ] || {}; + + // Init the event handler queue + if ( !handlers ) { + handlers = events[ type ] = []; + + // Check for a special event handler + // Only use addEventListener/attachEvent if the special + // events handler returns false + if ( !special.setup || special.setup.call( elem, data, namespaces, eventHandle ) === false ) { + // Bind the global event handler to the element + if ( elem.addEventListener ) { + elem.addEventListener( type, eventHandle, false ); + + } else if ( elem.attachEvent ) { + elem.attachEvent( "on" + type, eventHandle ); + } + } + } + + if ( special.add ) { + special.add.call( elem, handleObj ); + + if ( !handleObj.handler.guid ) { + handleObj.handler.guid = handler.guid; + } + } + + // Add the function to the element's handler list + handlers.push( handleObj ); + + // Keep track of which events have been used, for event optimization + jQuery.event.global[ type ] = true; + } + + // Nullify elem to prevent memory leaks in IE + elem = null; + }, + + global: {}, + + // Detach an event or set of events from an element + remove: function( elem, types, handler, pos ) { + // don't do events on text and comment nodes + if ( elem.nodeType === 3 || elem.nodeType === 8 ) { + return; + } + + if ( handler === false ) { + handler = returnFalse; + } + + var ret, type, fn, j, i = 0, all, namespaces, namespace, special, eventType, handleObj, origType, + elemData = jQuery.hasData( elem ) && jQuery._data( elem ), + events = elemData && elemData.events; + + if ( !elemData || !events ) { + return; + } + + // types is actually an event object here + if ( types && types.type ) { + handler = types.handler; + types = types.type; + } + + // Unbind all events for the element + if ( !types || typeof types === "string" && types.charAt(0) === "." ) { + types = types || ""; + + for ( type in events ) { + jQuery.event.remove( elem, type + types ); + } + + return; + } + + // Handle multiple events separated by a space + // jQuery(...).unbind("mouseover mouseout", fn); + types = types.split(" "); + + while ( (type = types[ i++ ]) ) { + origType = type; + handleObj = null; + all = type.indexOf(".") < 0; + namespaces = []; + + if ( !all ) { + // Namespaced event handlers + namespaces = type.split("."); + type = namespaces.shift(); + + namespace = new RegExp("(^|\\.)" + + jQuery.map( namespaces.slice(0).sort(), fcleanup ).join("\\.(?:.*\\.)?") + "(\\.|$)"); + } + + eventType = events[ type ]; + + if ( !eventType ) { + continue; + } + + if ( !handler ) { + for ( j = 0; j < eventType.length; j++ ) { + handleObj = eventType[ j ]; + + if ( all || namespace.test( handleObj.namespace ) ) { + jQuery.event.remove( elem, origType, handleObj.handler, j ); + eventType.splice( j--, 1 ); + } + } + + continue; + } + + special = jQuery.event.special[ type ] || {}; + + for ( j = pos || 0; j < eventType.length; j++ ) { + handleObj = eventType[ j ]; + + if ( handler.guid === handleObj.guid ) { + // remove the given handler for the given type + if ( all || namespace.test( handleObj.namespace ) ) { + if ( pos == null ) { + eventType.splice( j--, 1 ); + } + + if ( special.remove ) { + special.remove.call( elem, handleObj ); + } + } + + if ( pos != null ) { + break; + } + } + } + + // remove generic event handler if no more handlers exist + if ( eventType.length === 0 || pos != null && eventType.length === 1 ) { + if ( !special.teardown || special.teardown.call( elem, namespaces ) === false ) { + jQuery.removeEvent( elem, type, elemData.handle ); + } + + ret = null; + delete events[ type ]; + } + } + + // Remove the expando if it's no longer used + if ( jQuery.isEmptyObject( events ) ) { + var handle = elemData.handle; + if ( handle ) { + handle.elem = null; + } + + delete elemData.events; + delete elemData.handle; + + if ( jQuery.isEmptyObject( elemData ) ) { + jQuery.removeData( elem, undefined, true ); + } + } + }, + + // Events that are safe to short-circuit if no handlers are attached. + // Native DOM events should not be added, they may have inline handlers. + customEvent: { + "getData": true, + "setData": true, + "changeData": true + }, + + trigger: function( event, data, elem, onlyHandlers ) { + // Event object or event type + var type = event.type || event, + namespaces = [], + exclusive; + + if ( type.indexOf("!") >= 0 ) { + // Exclusive events trigger only for the exact event (no namespaces) + type = type.slice(0, -1); + exclusive = true; + } + + if ( type.indexOf(".") >= 0 ) { + // Namespaced trigger; create a regexp to match event type in handle() + namespaces = type.split("."); + type = namespaces.shift(); + namespaces.sort(); + } + + if ( (!elem || jQuery.event.customEvent[ type ]) && !jQuery.event.global[ type ] ) { + // No jQuery handlers for this event type, and it can't have inline handlers + return; + } + + // Caller can pass in an Event, Object, or just an event type string + event = typeof event === "object" ? + // jQuery.Event object + event[ jQuery.expando ] ? event : + // Object literal + new jQuery.Event( type, event ) : + // Just the event type (string) + new jQuery.Event( type ); + + event.type = type; + event.exclusive = exclusive; + event.namespace = namespaces.join("."); + event.namespace_re = new RegExp("(^|\\.)" + namespaces.join("\\.(?:.*\\.)?") + "(\\.|$)"); + + // triggerHandler() and global events don't bubble or run the default action + if ( onlyHandlers || !elem ) { + event.preventDefault(); + event.stopPropagation(); + } + + // Handle a global trigger + if ( !elem ) { + // TODO: Stop taunting the data cache; remove global events and always attach to document + jQuery.each( jQuery.cache, function() { + // internalKey variable is just used to make it easier to find + // and potentially change this stuff later; currently it just + // points to jQuery.expando + var internalKey = jQuery.expando, + internalCache = this[ internalKey ]; + if ( internalCache && internalCache.events && internalCache.events[ type ] ) { + jQuery.event.trigger( event, data, internalCache.handle.elem ); + } + }); + return; + } + + // Don't do events on text and comment nodes + if ( elem.nodeType === 3 || elem.nodeType === 8 ) { + return; + } + + // Clean up the event in case it is being reused + event.result = undefined; + event.target = elem; + + // Clone any incoming data and prepend the event, creating the handler arg list + data = data != null ? jQuery.makeArray( data ) : []; + data.unshift( event ); + + var cur = elem, + // IE doesn't like method names with a colon (#3533, #8272) + ontype = type.indexOf(":") < 0 ? "on" + type : ""; + + // Fire event on the current element, then bubble up the DOM tree + do { + var handle = jQuery._data( cur, "handle" ); + + event.currentTarget = cur; + if ( handle ) { + handle.apply( cur, data ); + } + + // Trigger an inline bound script + if ( ontype && jQuery.acceptData( cur ) && cur[ ontype ] && cur[ ontype ].apply( cur, data ) === false ) { + event.result = false; + event.preventDefault(); + } + + // Bubble up to document, then to window + cur = cur.parentNode || cur.ownerDocument || cur === event.target.ownerDocument && window; + } while ( cur && !event.isPropagationStopped() ); + + // If nobody prevented the default action, do it now + if ( !event.isDefaultPrevented() ) { + var old, + special = jQuery.event.special[ type ] || {}; + + if ( (!special._default || special._default.call( elem.ownerDocument, event ) === false) && + !(type === "click" && jQuery.nodeName( elem, "a" )) && jQuery.acceptData( elem ) ) { + + // Call a native DOM method on the target with the same name name as the event. + // Can't use an .isFunction)() check here because IE6/7 fails that test. + // IE<9 dies on focus to hidden element (#1486), may want to revisit a try/catch. + try { + if ( ontype && elem[ type ] ) { + // Don't re-trigger an onFOO event when we call its FOO() method + old = elem[ ontype ]; + + if ( old ) { + elem[ ontype ] = null; + } + + jQuery.event.triggered = type; + elem[ type ](); + } + } catch ( ieError ) {} + + if ( old ) { + elem[ ontype ] = old; + } + + jQuery.event.triggered = undefined; + } + } + + return event.result; + }, + + handle: function( event ) { + event = jQuery.event.fix( event || window.event ); + // Snapshot the handlers list since a called handler may add/remove events. + var handlers = ((jQuery._data( this, "events" ) || {})[ event.type ] || []).slice(0), + run_all = !event.exclusive && !event.namespace, + args = Array.prototype.slice.call( arguments, 0 ); + + // Use the fix-ed Event rather than the (read-only) native event + args[0] = event; + event.currentTarget = this; + + for ( var j = 0, l = handlers.length; j < l; j++ ) { + var handleObj = handlers[ j ]; + + // Triggered event must 1) be non-exclusive and have no namespace, or + // 2) have namespace(s) a subset or equal to those in the bound event. + if ( run_all || event.namespace_re.test( handleObj.namespace ) ) { + // Pass in a reference to the handler function itself + // So that we can later remove it + event.handler = handleObj.handler; + event.data = handleObj.data; + event.handleObj = handleObj; + + var ret = handleObj.handler.apply( this, args ); + + if ( ret !== undefined ) { + event.result = ret; + if ( ret === false ) { + event.preventDefault(); + event.stopPropagation(); + } + } + + if ( event.isImmediatePropagationStopped() ) { + break; + } + } + } + return event.result; + }, + + props: "altKey attrChange attrName bubbles button cancelable charCode clientX clientY ctrlKey currentTarget data detail eventPhase fromElement handler keyCode layerX layerY metaKey newValue offsetX offsetY pageX pageY prevValue relatedNode relatedTarget screenX screenY shiftKey srcElement target toElement view wheelDelta which".split(" "), + + fix: function( event ) { + if ( event[ jQuery.expando ] ) { + return event; + } + + // store a copy of the original event object + // and "clone" to set read-only properties + var originalEvent = event; + event = jQuery.Event( originalEvent ); + + for ( var i = this.props.length, prop; i; ) { + prop = this.props[ --i ]; + event[ prop ] = originalEvent[ prop ]; + } + + // Fix target property, if necessary + if ( !event.target ) { + // Fixes #1925 where srcElement might not be defined either + event.target = event.srcElement || document; + } + + // check if target is a textnode (safari) + if ( event.target.nodeType === 3 ) { + event.target = event.target.parentNode; + } + + // Add relatedTarget, if necessary + if ( !event.relatedTarget && event.fromElement ) { + event.relatedTarget = event.fromElement === event.target ? event.toElement : event.fromElement; + } + + // Calculate pageX/Y if missing and clientX/Y available + if ( event.pageX == null && event.clientX != null ) { + var eventDocument = event.target.ownerDocument || document, + doc = eventDocument.documentElement, + body = eventDocument.body; + + event.pageX = event.clientX + (doc && doc.scrollLeft || body && body.scrollLeft || 0) - (doc && doc.clientLeft || body && body.clientLeft || 0); + event.pageY = event.clientY + (doc && doc.scrollTop || body && body.scrollTop || 0) - (doc && doc.clientTop || body && body.clientTop || 0); + } + + // Add which for key events + if ( event.which == null && (event.charCode != null || event.keyCode != null) ) { + event.which = event.charCode != null ? event.charCode : event.keyCode; + } + + // Add metaKey to non-Mac browsers (use ctrl for PC's and Meta for Macs) + if ( !event.metaKey && event.ctrlKey ) { + event.metaKey = event.ctrlKey; + } + + // Add which for click: 1 === left; 2 === middle; 3 === right + // Note: button is not normalized, so don't use it + if ( !event.which && event.button !== undefined ) { + event.which = (event.button & 1 ? 1 : ( event.button & 2 ? 3 : ( event.button & 4 ? 2 : 0 ) )); + } + + return event; + }, + + // Deprecated, use jQuery.guid instead + guid: 1E8, + + // Deprecated, use jQuery.proxy instead + proxy: jQuery.proxy, + + special: { + ready: { + // Make sure the ready event is setup + setup: jQuery.bindReady, + teardown: jQuery.noop + }, + + live: { + add: function( handleObj ) { + jQuery.event.add( this, + liveConvert( handleObj.origType, handleObj.selector ), + jQuery.extend({}, handleObj, {handler: liveHandler, guid: handleObj.handler.guid}) ); + }, + + remove: function( handleObj ) { + jQuery.event.remove( this, liveConvert( handleObj.origType, handleObj.selector ), handleObj ); + } + }, + + beforeunload: { + setup: function( data, namespaces, eventHandle ) { + // We only want to do this special case on windows + if ( jQuery.isWindow( this ) ) { + this.onbeforeunload = eventHandle; + } + }, + + teardown: function( namespaces, eventHandle ) { + if ( this.onbeforeunload === eventHandle ) { + this.onbeforeunload = null; + } + } + } + } +}; + +jQuery.removeEvent = document.removeEventListener ? + function( elem, type, handle ) { + if ( elem.removeEventListener ) { + elem.removeEventListener( type, handle, false ); + } + } : + function( elem, type, handle ) { + if ( elem.detachEvent ) { + elem.detachEvent( "on" + type, handle ); + } + }; + +jQuery.Event = function( src, props ) { + // Allow instantiation without the 'new' keyword + if ( !this.preventDefault ) { + return new jQuery.Event( src, props ); + } + + // Event object + if ( src && src.type ) { + this.originalEvent = src; + this.type = src.type; + + // Events bubbling up the document may have been marked as prevented + // by a handler lower down the tree; reflect the correct value. + this.isDefaultPrevented = (src.defaultPrevented || src.returnValue === false || + src.getPreventDefault && src.getPreventDefault()) ? returnTrue : returnFalse; + + // Event type + } else { + this.type = src; + } + + // Put explicitly provided properties onto the event object + if ( props ) { + jQuery.extend( this, props ); + } + + // timeStamp is buggy for some events on Firefox(#3843) + // So we won't rely on the native value + this.timeStamp = jQuery.now(); + + // Mark it as fixed + this[ jQuery.expando ] = true; +}; + +function returnFalse() { + return false; +} +function returnTrue() { + return true; +} + +// jQuery.Event is based on DOM3 Events as specified by the ECMAScript Language Binding +// http://www.w3.org/TR/2003/WD-DOM-Level-3-Events-20030331/ecma-script-binding.html +jQuery.Event.prototype = { + preventDefault: function() { + this.isDefaultPrevented = returnTrue; + + var e = this.originalEvent; + if ( !e ) { + return; + } + + // if preventDefault exists run it on the original event + if ( e.preventDefault ) { + e.preventDefault(); + + // otherwise set the returnValue property of the original event to false (IE) + } else { + e.returnValue = false; + } + }, + stopPropagation: function() { + this.isPropagationStopped = returnTrue; + + var e = this.originalEvent; + if ( !e ) { + return; + } + // if stopPropagation exists run it on the original event + if ( e.stopPropagation ) { + e.stopPropagation(); + } + // otherwise set the cancelBubble property of the original event to true (IE) + e.cancelBubble = true; + }, + stopImmediatePropagation: function() { + this.isImmediatePropagationStopped = returnTrue; + this.stopPropagation(); + }, + isDefaultPrevented: returnFalse, + isPropagationStopped: returnFalse, + isImmediatePropagationStopped: returnFalse +}; + +// Checks if an event happened on an element within another element +// Used in jQuery.event.special.mouseenter and mouseleave handlers +var withinElement = function( event ) { + + // Check if mouse(over|out) are still within the same parent element + var related = event.relatedTarget, + inside = false, + eventType = event.type; + + event.type = event.data; + + if ( related !== this ) { + + if ( related ) { + inside = jQuery.contains( this, related ); + } + + if ( !inside ) { + + jQuery.event.handle.apply( this, arguments ); + + event.type = eventType; + } + } +}, + +// In case of event delegation, we only need to rename the event.type, +// liveHandler will take care of the rest. +delegate = function( event ) { + event.type = event.data; + jQuery.event.handle.apply( this, arguments ); +}; + +// Create mouseenter and mouseleave events +jQuery.each({ + mouseenter: "mouseover", + mouseleave: "mouseout" +}, function( orig, fix ) { + jQuery.event.special[ orig ] = { + setup: function( data ) { + jQuery.event.add( this, fix, data && data.selector ? delegate : withinElement, orig ); + }, + teardown: function( data ) { + jQuery.event.remove( this, fix, data && data.selector ? delegate : withinElement ); + } + }; +}); + +// submit delegation +if ( !jQuery.support.submitBubbles ) { + + jQuery.event.special.submit = { + setup: function( data, namespaces ) { + if ( !jQuery.nodeName( this, "form" ) ) { + jQuery.event.add(this, "click.specialSubmit", function( e ) { + // Avoid triggering error on non-existent type attribute in IE VML (#7071) + var elem = e.target, + type = jQuery.nodeName( elem, "input" ) || jQuery.nodeName( elem, "button" ) ? elem.type : ""; + + if ( (type === "submit" || type === "image") && jQuery( elem ).closest("form").length ) { + trigger( "submit", this, arguments ); + } + }); + + jQuery.event.add(this, "keypress.specialSubmit", function( e ) { + var elem = e.target, + type = jQuery.nodeName( elem, "input" ) || jQuery.nodeName( elem, "button" ) ? elem.type : ""; + + if ( (type === "text" || type === "password") && jQuery( elem ).closest("form").length && e.keyCode === 13 ) { + trigger( "submit", this, arguments ); + } + }); + + } else { + return false; + } + }, + + teardown: function( namespaces ) { + jQuery.event.remove( this, ".specialSubmit" ); + } + }; + +} + +// change delegation, happens here so we have bind. +if ( !jQuery.support.changeBubbles ) { + + var changeFilters, + + getVal = function( elem ) { + var type = jQuery.nodeName( elem, "input" ) ? elem.type : "", + val = elem.value; + + if ( type === "radio" || type === "checkbox" ) { + val = elem.checked; + + } else if ( type === "select-multiple" ) { + val = elem.selectedIndex > -1 ? + jQuery.map( elem.options, function( elem ) { + return elem.selected; + }).join("-") : + ""; + + } else if ( jQuery.nodeName( elem, "select" ) ) { + val = elem.selectedIndex; + } + + return val; + }, + + testChange = function testChange( e ) { + var elem = e.target, data, val; + + if ( !rformElems.test( elem.nodeName ) || elem.readOnly ) { + return; + } + + data = jQuery._data( elem, "_change_data" ); + val = getVal(elem); + + // the current data will be also retrieved by beforeactivate + if ( e.type !== "focusout" || elem.type !== "radio" ) { + jQuery._data( elem, "_change_data", val ); + } + + if ( data === undefined || val === data ) { + return; + } + + if ( data != null || val ) { + e.type = "change"; + e.liveFired = undefined; + jQuery.event.trigger( e, arguments[1], elem ); + } + }; + + jQuery.event.special.change = { + filters: { + focusout: testChange, + + beforedeactivate: testChange, + + click: function( e ) { + var elem = e.target, type = jQuery.nodeName( elem, "input" ) ? elem.type : ""; + + if ( type === "radio" || type === "checkbox" || jQuery.nodeName( elem, "select" ) ) { + testChange.call( this, e ); + } + }, + + // Change has to be called before submit + // Keydown will be called before keypress, which is used in submit-event delegation + keydown: function( e ) { + var elem = e.target, type = jQuery.nodeName( elem, "input" ) ? elem.type : ""; + + if ( (e.keyCode === 13 && !jQuery.nodeName( elem, "textarea" ) ) || + (e.keyCode === 32 && (type === "checkbox" || type === "radio")) || + type === "select-multiple" ) { + testChange.call( this, e ); + } + }, + + // Beforeactivate happens also before the previous element is blurred + // with this event you can't trigger a change event, but you can store + // information + beforeactivate: function( e ) { + var elem = e.target; + jQuery._data( elem, "_change_data", getVal(elem) ); + } + }, + + setup: function( data, namespaces ) { + if ( this.type === "file" ) { + return false; + } + + for ( var type in changeFilters ) { + jQuery.event.add( this, type + ".specialChange", changeFilters[type] ); + } + + return rformElems.test( this.nodeName ); + }, + + teardown: function( namespaces ) { + jQuery.event.remove( this, ".specialChange" ); + + return rformElems.test( this.nodeName ); + } + }; + + changeFilters = jQuery.event.special.change.filters; + + // Handle when the input is .focus()'d + changeFilters.focus = changeFilters.beforeactivate; +} + +function trigger( type, elem, args ) { + // Piggyback on a donor event to simulate a different one. + // Fake originalEvent to avoid donor's stopPropagation, but if the + // simulated event prevents default then we do the same on the donor. + // Don't pass args or remember liveFired; they apply to the donor event. + var event = jQuery.extend( {}, args[ 0 ] ); + event.type = type; + event.originalEvent = {}; + event.liveFired = undefined; + jQuery.event.handle.call( elem, event ); + if ( event.isDefaultPrevented() ) { + args[ 0 ].preventDefault(); + } +} + +// Create "bubbling" focus and blur events +if ( !jQuery.support.focusinBubbles ) { + jQuery.each({ focus: "focusin", blur: "focusout" }, function( orig, fix ) { + + // Attach a single capturing handler while someone wants focusin/focusout + var attaches = 0; + + jQuery.event.special[ fix ] = { + setup: function() { + if ( attaches++ === 0 ) { + document.addEventListener( orig, handler, true ); + } + }, + teardown: function() { + if ( --attaches === 0 ) { + document.removeEventListener( orig, handler, true ); + } + } + }; + + function handler( donor ) { + // Donor event is always a native one; fix it and switch its type. + // Let focusin/out handler cancel the donor focus/blur event. + var e = jQuery.event.fix( donor ); + e.type = fix; + e.originalEvent = {}; + jQuery.event.trigger( e, null, e.target ); + if ( e.isDefaultPrevented() ) { + donor.preventDefault(); + } + } + }); +} + +jQuery.each(["bind", "one"], function( i, name ) { + jQuery.fn[ name ] = function( type, data, fn ) { + var handler; + + // Handle object literals + if ( typeof type === "object" ) { + for ( var key in type ) { + this[ name ](key, data, type[key], fn); + } + return this; + } + + if ( arguments.length === 2 || data === false ) { + fn = data; + data = undefined; + } + + if ( name === "one" ) { + handler = function( event ) { + jQuery( this ).unbind( event, handler ); + return fn.apply( this, arguments ); + }; + handler.guid = fn.guid || jQuery.guid++; + } else { + handler = fn; + } + + if ( type === "unload" && name !== "one" ) { + this.one( type, data, fn ); + + } else { + for ( var i = 0, l = this.length; i < l; i++ ) { + jQuery.event.add( this[i], type, handler, data ); + } + } + + return this; + }; +}); + +jQuery.fn.extend({ + unbind: function( type, fn ) { + // Handle object literals + if ( typeof type === "object" && !type.preventDefault ) { + for ( var key in type ) { + this.unbind(key, type[key]); + } + + } else { + for ( var i = 0, l = this.length; i < l; i++ ) { + jQuery.event.remove( this[i], type, fn ); + } + } + + return this; + }, + + delegate: function( selector, types, data, fn ) { + return this.live( types, data, fn, selector ); + }, + + undelegate: function( selector, types, fn ) { + if ( arguments.length === 0 ) { + return this.unbind( "live" ); + + } else { + return this.die( types, null, fn, selector ); + } + }, + + trigger: function( type, data ) { + return this.each(function() { + jQuery.event.trigger( type, data, this ); + }); + }, + + triggerHandler: function( type, data ) { + if ( this[0] ) { + return jQuery.event.trigger( type, data, this[0], true ); + } + }, + + toggle: function( fn ) { + // Save reference to arguments for access in closure + var args = arguments, + guid = fn.guid || jQuery.guid++, + i = 0, + toggler = function( event ) { + // Figure out which function to execute + var lastToggle = ( jQuery.data( this, "lastToggle" + fn.guid ) || 0 ) % i; + jQuery.data( this, "lastToggle" + fn.guid, lastToggle + 1 ); + + // Make sure that clicks stop + event.preventDefault(); + + // and execute the function + return args[ lastToggle ].apply( this, arguments ) || false; + }; + + // link all the functions, so any of them can unbind this click handler + toggler.guid = guid; + while ( i < args.length ) { + args[ i++ ].guid = guid; + } + + return this.click( toggler ); + }, + + hover: function( fnOver, fnOut ) { + return this.mouseenter( fnOver ).mouseleave( fnOut || fnOver ); + } +}); + +var liveMap = { + focus: "focusin", + blur: "focusout", + mouseenter: "mouseover", + mouseleave: "mouseout" +}; + +jQuery.each(["live", "die"], function( i, name ) { + jQuery.fn[ name ] = function( types, data, fn, origSelector /* Internal Use Only */ ) { + var type, i = 0, match, namespaces, preType, + selector = origSelector || this.selector, + context = origSelector ? this : jQuery( this.context ); + + if ( typeof types === "object" && !types.preventDefault ) { + for ( var key in types ) { + context[ name ]( key, data, types[key], selector ); + } + + return this; + } + + if ( name === "die" && !types && + origSelector && origSelector.charAt(0) === "." ) { + + context.unbind( origSelector ); + + return this; + } + + if ( data === false || jQuery.isFunction( data ) ) { + fn = data || returnFalse; + data = undefined; + } + + types = (types || "").split(" "); + + while ( (type = types[ i++ ]) != null ) { + match = rnamespaces.exec( type ); + namespaces = ""; + + if ( match ) { + namespaces = match[0]; + type = type.replace( rnamespaces, "" ); + } + + if ( type === "hover" ) { + types.push( "mouseenter" + namespaces, "mouseleave" + namespaces ); + continue; + } + + preType = type; + + if ( liveMap[ type ] ) { + types.push( liveMap[ type ] + namespaces ); + type = type + namespaces; + + } else { + type = (liveMap[ type ] || type) + namespaces; + } + + if ( name === "live" ) { + // bind live handler + for ( var j = 0, l = context.length; j < l; j++ ) { + jQuery.event.add( context[j], "live." + liveConvert( type, selector ), + { data: data, selector: selector, handler: fn, origType: type, origHandler: fn, preType: preType } ); + } + + } else { + // unbind live handler + context.unbind( "live." + liveConvert( type, selector ), fn ); + } + } + + return this; + }; +}); + +function liveHandler( event ) { + var stop, maxLevel, related, match, handleObj, elem, j, i, l, data, close, namespace, ret, + elems = [], + selectors = [], + events = jQuery._data( this, "events" ); + + // Make sure we avoid non-left-click bubbling in Firefox (#3861) and disabled elements in IE (#6911) + if ( event.liveFired === this || !events || !events.live || event.target.disabled || event.button && event.type === "click" ) { + return; + } + + if ( event.namespace ) { + namespace = new RegExp("(^|\\.)" + event.namespace.split(".").join("\\.(?:.*\\.)?") + "(\\.|$)"); + } + + event.liveFired = this; + + var live = events.live.slice(0); + + for ( j = 0; j < live.length; j++ ) { + handleObj = live[j]; + + if ( handleObj.origType.replace( rnamespaces, "" ) === event.type ) { + selectors.push( handleObj.selector ); + + } else { + live.splice( j--, 1 ); + } + } + + match = jQuery( event.target ).closest( selectors, event.currentTarget ); + + for ( i = 0, l = match.length; i < l; i++ ) { + close = match[i]; + + for ( j = 0; j < live.length; j++ ) { + handleObj = live[j]; + + if ( close.selector === handleObj.selector && (!namespace || namespace.test( handleObj.namespace )) && !close.elem.disabled ) { + elem = close.elem; + related = null; + + // Those two events require additional checking + if ( handleObj.preType === "mouseenter" || handleObj.preType === "mouseleave" ) { + event.type = handleObj.preType; + related = jQuery( event.relatedTarget ).closest( handleObj.selector )[0]; + + // Make sure not to accidentally match a child element with the same selector + if ( related && jQuery.contains( elem, related ) ) { + related = elem; + } + } + + if ( !related || related !== elem ) { + elems.push({ elem: elem, handleObj: handleObj, level: close.level }); + } + } + } + } + + for ( i = 0, l = elems.length; i < l; i++ ) { + match = elems[i]; + + if ( maxLevel && match.level > maxLevel ) { + break; + } + + event.currentTarget = match.elem; + event.data = match.handleObj.data; + event.handleObj = match.handleObj; + + ret = match.handleObj.origHandler.apply( match.elem, arguments ); + + if ( ret === false || event.isPropagationStopped() ) { + maxLevel = match.level; + + if ( ret === false ) { + stop = false; + } + if ( event.isImmediatePropagationStopped() ) { + break; + } + } + } + + return stop; +} + +function liveConvert( type, selector ) { + return (type && type !== "*" ? type + "." : "") + selector.replace(rperiod, "`").replace(rspaces, "&"); +} + +jQuery.each( ("blur focus focusin focusout load resize scroll unload click dblclick " + + "mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave " + + "change select submit keydown keypress keyup error").split(" "), function( i, name ) { + + // Handle event binding + jQuery.fn[ name ] = function( data, fn ) { + if ( fn == null ) { + fn = data; + data = null; + } + + return arguments.length > 0 ? + this.bind( name, data, fn ) : + this.trigger( name ); + }; + + if ( jQuery.attrFn ) { + jQuery.attrFn[ name ] = true; + } +}); + + + +/*! + * Sizzle CSS Selector Engine + * Copyright 2011, The Dojo Foundation + * Released under the MIT, BSD, and GPL Licenses. + * More information: http://sizzlejs.com/ + */ +(function(){ + +var chunker = /((?:\((?:\([^()]+\)|[^()]+)+\)|\[(?:\[[^\[\]]*\]|['"][^'"]*['"]|[^\[\]'"]+)+\]|\\.|[^ >+~,(\[\\]+)+|[>+~])(\s*,\s*)?((?:.|\r|\n)*)/g, + done = 0, + toString = Object.prototype.toString, + hasDuplicate = false, + baseHasDuplicate = true, + rBackslash = /\\/g, + rNonWord = /\W/; + +// Here we check if the JavaScript engine is using some sort of +// optimization where it does not always call our comparision +// function. If that is the case, discard the hasDuplicate value. +// Thus far that includes Google Chrome. +[0, 0].sort(function() { + baseHasDuplicate = false; + return 0; +}); + +var Sizzle = function( selector, context, results, seed ) { + results = results || []; + context = context || document; + + var origContext = context; + + if ( context.nodeType !== 1 && context.nodeType !== 9 ) { + return []; + } + + if ( !selector || typeof selector !== "string" ) { + return results; + } + + var m, set, checkSet, extra, ret, cur, pop, i, + prune = true, + contextXML = Sizzle.isXML( context ), + parts = [], + soFar = selector; + + // Reset the position of the chunker regexp (start from head) + do { + chunker.exec( "" ); + m = chunker.exec( soFar ); + + if ( m ) { + soFar = m[3]; + + parts.push( m[1] ); + + if ( m[2] ) { + extra = m[3]; + break; + } + } + } while ( m ); + + if ( parts.length > 1 && origPOS.exec( selector ) ) { + + if ( parts.length === 2 && Expr.relative[ parts[0] ] ) { + set = posProcess( parts[0] + parts[1], context ); + + } else { + set = Expr.relative[ parts[0] ] ? + [ context ] : + Sizzle( parts.shift(), context ); + + while ( parts.length ) { + selector = parts.shift(); + + if ( Expr.relative[ selector ] ) { + selector += parts.shift(); + } + + set = posProcess( selector, set ); + } + } + + } else { + // Take a shortcut and set the context if the root selector is an ID + // (but not if it'll be faster if the inner selector is an ID) + if ( !seed && parts.length > 1 && context.nodeType === 9 && !contextXML && + Expr.match.ID.test(parts[0]) && !Expr.match.ID.test(parts[parts.length - 1]) ) { + + ret = Sizzle.find( parts.shift(), context, contextXML ); + context = ret.expr ? + Sizzle.filter( ret.expr, ret.set )[0] : + ret.set[0]; + } + + if ( context ) { + ret = seed ? + { expr: parts.pop(), set: makeArray(seed) } : + Sizzle.find( parts.pop(), parts.length === 1 && (parts[0] === "~" || parts[0] === "+") && context.parentNode ? context.parentNode : context, contextXML ); + + set = ret.expr ? + Sizzle.filter( ret.expr, ret.set ) : + ret.set; + + if ( parts.length > 0 ) { + checkSet = makeArray( set ); + + } else { + prune = false; + } + + while ( parts.length ) { + cur = parts.pop(); + pop = cur; + + if ( !Expr.relative[ cur ] ) { + cur = ""; + } else { + pop = parts.pop(); + } + + if ( pop == null ) { + pop = context; + } + + Expr.relative[ cur ]( checkSet, pop, contextXML ); + } + + } else { + checkSet = parts = []; + } + } + + if ( !checkSet ) { + checkSet = set; + } + + if ( !checkSet ) { + Sizzle.error( cur || selector ); + } + + if ( toString.call(checkSet) === "[object Array]" ) { + if ( !prune ) { + results.push.apply( results, checkSet ); + + } else if ( context && context.nodeType === 1 ) { + for ( i = 0; checkSet[i] != null; i++ ) { + if ( checkSet[i] && (checkSet[i] === true || checkSet[i].nodeType === 1 && Sizzle.contains(context, checkSet[i])) ) { + results.push( set[i] ); + } + } + + } else { + for ( i = 0; checkSet[i] != null; i++ ) { + if ( checkSet[i] && checkSet[i].nodeType === 1 ) { + results.push( set[i] ); + } + } + } + + } else { + makeArray( checkSet, results ); + } + + if ( extra ) { + Sizzle( extra, origContext, results, seed ); + Sizzle.uniqueSort( results ); + } + + return results; +}; + +Sizzle.uniqueSort = function( results ) { + if ( sortOrder ) { + hasDuplicate = baseHasDuplicate; + results.sort( sortOrder ); + + if ( hasDuplicate ) { + for ( var i = 1; i < results.length; i++ ) { + if ( results[i] === results[ i - 1 ] ) { + results.splice( i--, 1 ); + } + } + } + } + + return results; +}; + +Sizzle.matches = function( expr, set ) { + return Sizzle( expr, null, null, set ); +}; + +Sizzle.matchesSelector = function( node, expr ) { + return Sizzle( expr, null, null, [node] ).length > 0; +}; + +Sizzle.find = function( expr, context, isXML ) { + var set; + + if ( !expr ) { + return []; + } + + for ( var i = 0, l = Expr.order.length; i < l; i++ ) { + var match, + type = Expr.order[i]; + + if ( (match = Expr.leftMatch[ type ].exec( expr )) ) { + var left = match[1]; + match.splice( 1, 1 ); + + if ( left.substr( left.length - 1 ) !== "\\" ) { + match[1] = (match[1] || "").replace( rBackslash, "" ); + set = Expr.find[ type ]( match, context, isXML ); + + if ( set != null ) { + expr = expr.replace( Expr.match[ type ], "" ); + break; + } + } + } + } + + if ( !set ) { + set = typeof context.getElementsByTagName !== "undefined" ? + context.getElementsByTagName( "*" ) : + []; + } + + return { set: set, expr: expr }; +}; + +Sizzle.filter = function( expr, set, inplace, not ) { + var match, anyFound, + old = expr, + result = [], + curLoop = set, + isXMLFilter = set && set[0] && Sizzle.isXML( set[0] ); + + while ( expr && set.length ) { + for ( var type in Expr.filter ) { + if ( (match = Expr.leftMatch[ type ].exec( expr )) != null && match[2] ) { + var found, item, + filter = Expr.filter[ type ], + left = match[1]; + + anyFound = false; + + match.splice(1,1); + + if ( left.substr( left.length - 1 ) === "\\" ) { + continue; + } + + if ( curLoop === result ) { + result = []; + } + + if ( Expr.preFilter[ type ] ) { + match = Expr.preFilter[ type ]( match, curLoop, inplace, result, not, isXMLFilter ); + + if ( !match ) { + anyFound = found = true; + + } else if ( match === true ) { + continue; + } + } + + if ( match ) { + for ( var i = 0; (item = curLoop[i]) != null; i++ ) { + if ( item ) { + found = filter( item, match, i, curLoop ); + var pass = not ^ !!found; + + if ( inplace && found != null ) { + if ( pass ) { + anyFound = true; + + } else { + curLoop[i] = false; + } + + } else if ( pass ) { + result.push( item ); + anyFound = true; + } + } + } + } + + if ( found !== undefined ) { + if ( !inplace ) { + curLoop = result; + } + + expr = expr.replace( Expr.match[ type ], "" ); + + if ( !anyFound ) { + return []; + } + + break; + } + } + } + + // Improper expression + if ( expr === old ) { + if ( anyFound == null ) { + Sizzle.error( expr ); + + } else { + break; + } + } + + old = expr; + } + + return curLoop; +}; + +Sizzle.error = function( msg ) { + throw "Syntax error, unrecognized expression: " + msg; +}; + +var Expr = Sizzle.selectors = { + order: [ "ID", "NAME", "TAG" ], + + match: { + ID: /#((?:[\w\u00c0-\uFFFF\-]|\\.)+)/, + CLASS: /\.((?:[\w\u00c0-\uFFFF\-]|\\.)+)/, + NAME: /\[name=['"]*((?:[\w\u00c0-\uFFFF\-]|\\.)+)['"]*\]/, + ATTR: /\[\s*((?:[\w\u00c0-\uFFFF\-]|\\.)+)\s*(?:(\S?=)\s*(?:(['"])(.*?)\3|(#?(?:[\w\u00c0-\uFFFF\-]|\\.)*)|)|)\s*\]/, + TAG: /^((?:[\w\u00c0-\uFFFF\*\-]|\\.)+)/, + CHILD: /:(only|nth|last|first)-child(?:\(\s*(even|odd|(?:[+\-]?\d+|(?:[+\-]?\d*)?n\s*(?:[+\-]\s*\d+)?))\s*\))?/, + POS: /:(nth|eq|gt|lt|first|last|even|odd)(?:\((\d*)\))?(?=[^\-]|$)/, + PSEUDO: /:((?:[\w\u00c0-\uFFFF\-]|\\.)+)(?:\((['"]?)((?:\([^\)]+\)|[^\(\)]*)+)\2\))?/ + }, + + leftMatch: {}, + + attrMap: { + "class": "className", + "for": "htmlFor" + }, + + attrHandle: { + href: function( elem ) { + return elem.getAttribute( "href" ); + }, + type: function( elem ) { + return elem.getAttribute( "type" ); + } + }, + + relative: { + "+": function(checkSet, part){ + var isPartStr = typeof part === "string", + isTag = isPartStr && !rNonWord.test( part ), + isPartStrNotTag = isPartStr && !isTag; + + if ( isTag ) { + part = part.toLowerCase(); + } + + for ( var i = 0, l = checkSet.length, elem; i < l; i++ ) { + if ( (elem = checkSet[i]) ) { + while ( (elem = elem.previousSibling) && elem.nodeType !== 1 ) {} + + checkSet[i] = isPartStrNotTag || elem && elem.nodeName.toLowerCase() === part ? + elem || false : + elem === part; + } + } + + if ( isPartStrNotTag ) { + Sizzle.filter( part, checkSet, true ); + } + }, + + ">": function( checkSet, part ) { + var elem, + isPartStr = typeof part === "string", + i = 0, + l = checkSet.length; + + if ( isPartStr && !rNonWord.test( part ) ) { + part = part.toLowerCase(); + + for ( ; i < l; i++ ) { + elem = checkSet[i]; + + if ( elem ) { + var parent = elem.parentNode; + checkSet[i] = parent.nodeName.toLowerCase() === part ? parent : false; + } + } + + } else { + for ( ; i < l; i++ ) { + elem = checkSet[i]; + + if ( elem ) { + checkSet[i] = isPartStr ? + elem.parentNode : + elem.parentNode === part; + } + } + + if ( isPartStr ) { + Sizzle.filter( part, checkSet, true ); + } + } + }, + + "": function(checkSet, part, isXML){ + var nodeCheck, + doneName = done++, + checkFn = dirCheck; + + if ( typeof part === "string" && !rNonWord.test( part ) ) { + part = part.toLowerCase(); + nodeCheck = part; + checkFn = dirNodeCheck; + } + + checkFn( "parentNode", part, doneName, checkSet, nodeCheck, isXML ); + }, + + "~": function( checkSet, part, isXML ) { + var nodeCheck, + doneName = done++, + checkFn = dirCheck; + + if ( typeof part === "string" && !rNonWord.test( part ) ) { + part = part.toLowerCase(); + nodeCheck = part; + checkFn = dirNodeCheck; + } + + checkFn( "previousSibling", part, doneName, checkSet, nodeCheck, isXML ); + } + }, + + find: { + ID: function( match, context, isXML ) { + if ( typeof context.getElementById !== "undefined" && !isXML ) { + var m = context.getElementById(match[1]); + // Check parentNode to catch when Blackberry 4.6 returns + // nodes that are no longer in the document #6963 + return m && m.parentNode ? [m] : []; + } + }, + + NAME: function( match, context ) { + if ( typeof context.getElementsByName !== "undefined" ) { + var ret = [], + results = context.getElementsByName( match[1] ); + + for ( var i = 0, l = results.length; i < l; i++ ) { + if ( results[i].getAttribute("name") === match[1] ) { + ret.push( results[i] ); + } + } + + return ret.length === 0 ? null : ret; + } + }, + + TAG: function( match, context ) { + if ( typeof context.getElementsByTagName !== "undefined" ) { + return context.getElementsByTagName( match[1] ); + } + } + }, + preFilter: { + CLASS: function( match, curLoop, inplace, result, not, isXML ) { + match = " " + match[1].replace( rBackslash, "" ) + " "; + + if ( isXML ) { + return match; + } + + for ( var i = 0, elem; (elem = curLoop[i]) != null; i++ ) { + if ( elem ) { + if ( not ^ (elem.className && (" " + elem.className + " ").replace(/[\t\n\r]/g, " ").indexOf(match) >= 0) ) { + if ( !inplace ) { + result.push( elem ); + } + + } else if ( inplace ) { + curLoop[i] = false; + } + } + } + + return false; + }, + + ID: function( match ) { + return match[1].replace( rBackslash, "" ); + }, + + TAG: function( match, curLoop ) { + return match[1].replace( rBackslash, "" ).toLowerCase(); + }, + + CHILD: function( match ) { + if ( match[1] === "nth" ) { + if ( !match[2] ) { + Sizzle.error( match[0] ); + } + + match[2] = match[2].replace(/^\+|\s*/g, ''); + + // parse equations like 'even', 'odd', '5', '2n', '3n+2', '4n-1', '-n+6' + var test = /(-?)(\d*)(?:n([+\-]?\d*))?/.exec( + match[2] === "even" && "2n" || match[2] === "odd" && "2n+1" || + !/\D/.test( match[2] ) && "0n+" + match[2] || match[2]); + + // calculate the numbers (first)n+(last) including if they are negative + match[2] = (test[1] + (test[2] || 1)) - 0; + match[3] = test[3] - 0; + } + else if ( match[2] ) { + Sizzle.error( match[0] ); + } + + // TODO: Move to normal caching system + match[0] = done++; + + return match; + }, + + ATTR: function( match, curLoop, inplace, result, not, isXML ) { + var name = match[1] = match[1].replace( rBackslash, "" ); + + if ( !isXML && Expr.attrMap[name] ) { + match[1] = Expr.attrMap[name]; + } + + // Handle if an un-quoted value was used + match[4] = ( match[4] || match[5] || "" ).replace( rBackslash, "" ); + + if ( match[2] === "~=" ) { + match[4] = " " + match[4] + " "; + } + + return match; + }, + + PSEUDO: function( match, curLoop, inplace, result, not ) { + if ( match[1] === "not" ) { + // If we're dealing with a complex expression, or a simple one + if ( ( chunker.exec(match[3]) || "" ).length > 1 || /^\w/.test(match[3]) ) { + match[3] = Sizzle(match[3], null, null, curLoop); + + } else { + var ret = Sizzle.filter(match[3], curLoop, inplace, true ^ not); + + if ( !inplace ) { + result.push.apply( result, ret ); + } + + return false; + } + + } else if ( Expr.match.POS.test( match[0] ) || Expr.match.CHILD.test( match[0] ) ) { + return true; + } + + return match; + }, + + POS: function( match ) { + match.unshift( true ); + + return match; + } + }, + + filters: { + enabled: function( elem ) { + return elem.disabled === false && elem.type !== "hidden"; + }, + + disabled: function( elem ) { + return elem.disabled === true; + }, + + checked: function( elem ) { + return elem.checked === true; + }, + + selected: function( elem ) { + // Accessing this property makes selected-by-default + // options in Safari work properly + if ( elem.parentNode ) { + elem.parentNode.selectedIndex; + } + + return elem.selected === true; + }, + + parent: function( elem ) { + return !!elem.firstChild; + }, + + empty: function( elem ) { + return !elem.firstChild; + }, + + has: function( elem, i, match ) { + return !!Sizzle( match[3], elem ).length; + }, + + header: function( elem ) { + return (/h\d/i).test( elem.nodeName ); + }, + + text: function( elem ) { + var attr = elem.getAttribute( "type" ), type = elem.type; + // IE6 and 7 will map elem.type to 'text' for new HTML5 types (search, etc) + // use getAttribute instead to test this case + return elem.nodeName.toLowerCase() === "input" && "text" === type && ( attr === type || attr === null ); + }, + + radio: function( elem ) { + return elem.nodeName.toLowerCase() === "input" && "radio" === elem.type; + }, + + checkbox: function( elem ) { + return elem.nodeName.toLowerCase() === "input" && "checkbox" === elem.type; + }, + + file: function( elem ) { + return elem.nodeName.toLowerCase() === "input" && "file" === elem.type; + }, + + password: function( elem ) { + return elem.nodeName.toLowerCase() === "input" && "password" === elem.type; + }, + + submit: function( elem ) { + var name = elem.nodeName.toLowerCase(); + return (name === "input" || name === "button") && "submit" === elem.type; + }, + + image: function( elem ) { + return elem.nodeName.toLowerCase() === "input" && "image" === elem.type; + }, + + reset: function( elem ) { + var name = elem.nodeName.toLowerCase(); + return (name === "input" || name === "button") && "reset" === elem.type; + }, + + button: function( elem ) { + var name = elem.nodeName.toLowerCase(); + return name === "input" && "button" === elem.type || name === "button"; + }, + + input: function( elem ) { + return (/input|select|textarea|button/i).test( elem.nodeName ); + }, + + focus: function( elem ) { + return elem === elem.ownerDocument.activeElement; + } + }, + setFilters: { + first: function( elem, i ) { + return i === 0; + }, + + last: function( elem, i, match, array ) { + return i === array.length - 1; + }, + + even: function( elem, i ) { + return i % 2 === 0; + }, + + odd: function( elem, i ) { + return i % 2 === 1; + }, + + lt: function( elem, i, match ) { + return i < match[3] - 0; + }, + + gt: function( elem, i, match ) { + return i > match[3] - 0; + }, + + nth: function( elem, i, match ) { + return match[3] - 0 === i; + }, + + eq: function( elem, i, match ) { + return match[3] - 0 === i; + } + }, + filter: { + PSEUDO: function( elem, match, i, array ) { + var name = match[1], + filter = Expr.filters[ name ]; + + if ( filter ) { + return filter( elem, i, match, array ); + + } else if ( name === "contains" ) { + return (elem.textContent || elem.innerText || Sizzle.getText([ elem ]) || "").indexOf(match[3]) >= 0; + + } else if ( name === "not" ) { + var not = match[3]; + + for ( var j = 0, l = not.length; j < l; j++ ) { + if ( not[j] === elem ) { + return false; + } + } + + return true; + + } else { + Sizzle.error( name ); + } + }, + + CHILD: function( elem, match ) { + var type = match[1], + node = elem; + + switch ( type ) { + case "only": + case "first": + while ( (node = node.previousSibling) ) { + if ( node.nodeType === 1 ) { + return false; + } + } + + if ( type === "first" ) { + return true; + } + + node = elem; + + case "last": + while ( (node = node.nextSibling) ) { + if ( node.nodeType === 1 ) { + return false; + } + } + + return true; + + case "nth": + var first = match[2], + last = match[3]; + + if ( first === 1 && last === 0 ) { + return true; + } + + var doneName = match[0], + parent = elem.parentNode; + + if ( parent && (parent.sizcache !== doneName || !elem.nodeIndex) ) { + var count = 0; + + for ( node = parent.firstChild; node; node = node.nextSibling ) { + if ( node.nodeType === 1 ) { + node.nodeIndex = ++count; + } + } + + parent.sizcache = doneName; + } + + var diff = elem.nodeIndex - last; + + if ( first === 0 ) { + return diff === 0; + + } else { + return ( diff % first === 0 && diff / first >= 0 ); + } + } + }, + + ID: function( elem, match ) { + return elem.nodeType === 1 && elem.getAttribute("id") === match; + }, + + TAG: function( elem, match ) { + return (match === "*" && elem.nodeType === 1) || elem.nodeName.toLowerCase() === match; + }, + + CLASS: function( elem, match ) { + return (" " + (elem.className || elem.getAttribute("class")) + " ") + .indexOf( match ) > -1; + }, + + ATTR: function( elem, match ) { + var name = match[1], + result = Expr.attrHandle[ name ] ? + Expr.attrHandle[ name ]( elem ) : + elem[ name ] != null ? + elem[ name ] : + elem.getAttribute( name ), + value = result + "", + type = match[2], + check = match[4]; + + return result == null ? + type === "!=" : + type === "=" ? + value === check : + type === "*=" ? + value.indexOf(check) >= 0 : + type === "~=" ? + (" " + value + " ").indexOf(check) >= 0 : + !check ? + value && result !== false : + type === "!=" ? + value !== check : + type === "^=" ? + value.indexOf(check) === 0 : + type === "$=" ? + value.substr(value.length - check.length) === check : + type === "|=" ? + value === check || value.substr(0, check.length + 1) === check + "-" : + false; + }, + + POS: function( elem, match, i, array ) { + var name = match[2], + filter = Expr.setFilters[ name ]; + + if ( filter ) { + return filter( elem, i, match, array ); + } + } + } +}; + +var origPOS = Expr.match.POS, + fescape = function(all, num){ + return "\\" + (num - 0 + 1); + }; + +for ( var type in Expr.match ) { + Expr.match[ type ] = new RegExp( Expr.match[ type ].source + (/(?![^\[]*\])(?![^\(]*\))/.source) ); + Expr.leftMatch[ type ] = new RegExp( /(^(?:.|\r|\n)*?)/.source + Expr.match[ type ].source.replace(/\\(\d+)/g, fescape) ); +} + +var makeArray = function( array, results ) { + array = Array.prototype.slice.call( array, 0 ); + + if ( results ) { + results.push.apply( results, array ); + return results; + } + + return array; +}; + +// Perform a simple check to determine if the browser is capable of +// converting a NodeList to an array using builtin methods. +// Also verifies that the returned array holds DOM nodes +// (which is not the case in the Blackberry browser) +try { + Array.prototype.slice.call( document.documentElement.childNodes, 0 )[0].nodeType; + +// Provide a fallback method if it does not work +} catch( e ) { + makeArray = function( array, results ) { + var i = 0, + ret = results || []; + + if ( toString.call(array) === "[object Array]" ) { + Array.prototype.push.apply( ret, array ); + + } else { + if ( typeof array.length === "number" ) { + for ( var l = array.length; i < l; i++ ) { + ret.push( array[i] ); + } + + } else { + for ( ; array[i]; i++ ) { + ret.push( array[i] ); + } + } + } + + return ret; + }; +} + +var sortOrder, siblingCheck; + +if ( document.documentElement.compareDocumentPosition ) { + sortOrder = function( a, b ) { + if ( a === b ) { + hasDuplicate = true; + return 0; + } + + if ( !a.compareDocumentPosition || !b.compareDocumentPosition ) { + return a.compareDocumentPosition ? -1 : 1; + } + + return a.compareDocumentPosition(b) & 4 ? -1 : 1; + }; + +} else { + sortOrder = function( a, b ) { + // The nodes are identical, we can exit early + if ( a === b ) { + hasDuplicate = true; + return 0; + + // Fallback to using sourceIndex (in IE) if it's available on both nodes + } else if ( a.sourceIndex && b.sourceIndex ) { + return a.sourceIndex - b.sourceIndex; + } + + var al, bl, + ap = [], + bp = [], + aup = a.parentNode, + bup = b.parentNode, + cur = aup; + + // If the nodes are siblings (or identical) we can do a quick check + if ( aup === bup ) { + return siblingCheck( a, b ); + + // If no parents were found then the nodes are disconnected + } else if ( !aup ) { + return -1; + + } else if ( !bup ) { + return 1; + } + + // Otherwise they're somewhere else in the tree so we need + // to build up a full list of the parentNodes for comparison + while ( cur ) { + ap.unshift( cur ); + cur = cur.parentNode; + } + + cur = bup; + + while ( cur ) { + bp.unshift( cur ); + cur = cur.parentNode; + } + + al = ap.length; + bl = bp.length; + + // Start walking down the tree looking for a discrepancy + for ( var i = 0; i < al && i < bl; i++ ) { + if ( ap[i] !== bp[i] ) { + return siblingCheck( ap[i], bp[i] ); + } + } + + // We ended someplace up the tree so do a sibling check + return i === al ? + siblingCheck( a, bp[i], -1 ) : + siblingCheck( ap[i], b, 1 ); + }; + + siblingCheck = function( a, b, ret ) { + if ( a === b ) { + return ret; + } + + var cur = a.nextSibling; + + while ( cur ) { + if ( cur === b ) { + return -1; + } + + cur = cur.nextSibling; + } + + return 1; + }; +} + +// Utility function for retreiving the text value of an array of DOM nodes +Sizzle.getText = function( elems ) { + var ret = "", elem; + + for ( var i = 0; elems[i]; i++ ) { + elem = elems[i]; + + // Get the text from text nodes and CDATA nodes + if ( elem.nodeType === 3 || elem.nodeType === 4 ) { + ret += elem.nodeValue; + + // Traverse everything else, except comment nodes + } else if ( elem.nodeType !== 8 ) { + ret += Sizzle.getText( elem.childNodes ); + } + } + + return ret; +}; + +// Check to see if the browser returns elements by name when +// querying by getElementById (and provide a workaround) +(function(){ + // We're going to inject a fake input element with a specified name + var form = document.createElement("div"), + id = "script" + (new Date()).getTime(), + root = document.documentElement; + + form.innerHTML = ""; + + // Inject it into the root element, check its status, and remove it quickly + root.insertBefore( form, root.firstChild ); + + // The workaround has to do additional checks after a getElementById + // Which slows things down for other browsers (hence the branching) + if ( document.getElementById( id ) ) { + Expr.find.ID = function( match, context, isXML ) { + if ( typeof context.getElementById !== "undefined" && !isXML ) { + var m = context.getElementById(match[1]); + + return m ? + m.id === match[1] || typeof m.getAttributeNode !== "undefined" && m.getAttributeNode("id").nodeValue === match[1] ? + [m] : + undefined : + []; + } + }; + + Expr.filter.ID = function( elem, match ) { + var node = typeof elem.getAttributeNode !== "undefined" && elem.getAttributeNode("id"); + + return elem.nodeType === 1 && node && node.nodeValue === match; + }; + } + + root.removeChild( form ); + + // release memory in IE + root = form = null; +})(); + +(function(){ + // Check to see if the browser returns only elements + // when doing getElementsByTagName("*") + + // Create a fake element + var div = document.createElement("div"); + div.appendChild( document.createComment("") ); + + // Make sure no comments are found + if ( div.getElementsByTagName("*").length > 0 ) { + Expr.find.TAG = function( match, context ) { + var results = context.getElementsByTagName( match[1] ); + + // Filter out possible comments + if ( match[1] === "*" ) { + var tmp = []; + + for ( var i = 0; results[i]; i++ ) { + if ( results[i].nodeType === 1 ) { + tmp.push( results[i] ); + } + } + + results = tmp; + } + + return results; + }; + } + + // Check to see if an attribute returns normalized href attributes + div.innerHTML = ""; + + if ( div.firstChild && typeof div.firstChild.getAttribute !== "undefined" && + div.firstChild.getAttribute("href") !== "#" ) { + + Expr.attrHandle.href = function( elem ) { + return elem.getAttribute( "href", 2 ); + }; + } + + // release memory in IE + div = null; +})(); + +if ( document.querySelectorAll ) { + (function(){ + var oldSizzle = Sizzle, + div = document.createElement("div"), + id = "__sizzle__"; + + div.innerHTML = "

          "; + + // Safari can't handle uppercase or unicode characters when + // in quirks mode. + if ( div.querySelectorAll && div.querySelectorAll(".TEST").length === 0 ) { + return; + } + + Sizzle = function( query, context, extra, seed ) { + context = context || document; + + // Only use querySelectorAll on non-XML documents + // (ID selectors don't work in non-HTML documents) + if ( !seed && !Sizzle.isXML(context) ) { + // See if we find a selector to speed up + var match = /^(\w+$)|^\.([\w\-]+$)|^#([\w\-]+$)/.exec( query ); + + if ( match && (context.nodeType === 1 || context.nodeType === 9) ) { + // Speed-up: Sizzle("TAG") + if ( match[1] ) { + return makeArray( context.getElementsByTagName( query ), extra ); + + // Speed-up: Sizzle(".CLASS") + } else if ( match[2] && Expr.find.CLASS && context.getElementsByClassName ) { + return makeArray( context.getElementsByClassName( match[2] ), extra ); + } + } + + if ( context.nodeType === 9 ) { + // Speed-up: Sizzle("body") + // The body element only exists once, optimize finding it + if ( query === "body" && context.body ) { + return makeArray( [ context.body ], extra ); + + // Speed-up: Sizzle("#ID") + } else if ( match && match[3] ) { + var elem = context.getElementById( match[3] ); + + // Check parentNode to catch when Blackberry 4.6 returns + // nodes that are no longer in the document #6963 + if ( elem && elem.parentNode ) { + // Handle the case where IE and Opera return items + // by name instead of ID + if ( elem.id === match[3] ) { + return makeArray( [ elem ], extra ); + } + + } else { + return makeArray( [], extra ); + } + } + + try { + return makeArray( context.querySelectorAll(query), extra ); + } catch(qsaError) {} + + // qSA works strangely on Element-rooted queries + // We can work around this by specifying an extra ID on the root + // and working up from there (Thanks to Andrew Dupont for the technique) + // IE 8 doesn't work on object elements + } else if ( context.nodeType === 1 && context.nodeName.toLowerCase() !== "object" ) { + var oldContext = context, + old = context.getAttribute( "id" ), + nid = old || id, + hasParent = context.parentNode, + relativeHierarchySelector = /^\s*[+~]/.test( query ); + + if ( !old ) { + context.setAttribute( "id", nid ); + } else { + nid = nid.replace( /'/g, "\\$&" ); + } + if ( relativeHierarchySelector && hasParent ) { + context = context.parentNode; + } + + try { + if ( !relativeHierarchySelector || hasParent ) { + return makeArray( context.querySelectorAll( "[id='" + nid + "'] " + query ), extra ); + } + + } catch(pseudoError) { + } finally { + if ( !old ) { + oldContext.removeAttribute( "id" ); + } + } + } + } + + return oldSizzle(query, context, extra, seed); + }; + + for ( var prop in oldSizzle ) { + Sizzle[ prop ] = oldSizzle[ prop ]; + } + + // release memory in IE + div = null; + })(); +} + +(function(){ + var html = document.documentElement, + matches = html.matchesSelector || html.mozMatchesSelector || html.webkitMatchesSelector || html.msMatchesSelector; + + if ( matches ) { + // Check to see if it's possible to do matchesSelector + // on a disconnected node (IE 9 fails this) + var disconnectedMatch = !matches.call( document.createElement( "div" ), "div" ), + pseudoWorks = false; + + try { + // This should fail with an exception + // Gecko does not error, returns false instead + matches.call( document.documentElement, "[test!='']:sizzle" ); + + } catch( pseudoError ) { + pseudoWorks = true; + } + + Sizzle.matchesSelector = function( node, expr ) { + // Make sure that attribute selectors are quoted + expr = expr.replace(/\=\s*([^'"\]]*)\s*\]/g, "='$1']"); + + if ( !Sizzle.isXML( node ) ) { + try { + if ( pseudoWorks || !Expr.match.PSEUDO.test( expr ) && !/!=/.test( expr ) ) { + var ret = matches.call( node, expr ); + + // IE 9's matchesSelector returns false on disconnected nodes + if ( ret || !disconnectedMatch || + // As well, disconnected nodes are said to be in a document + // fragment in IE 9, so check for that + node.document && node.document.nodeType !== 11 ) { + return ret; + } + } + } catch(e) {} + } + + return Sizzle(expr, null, null, [node]).length > 0; + }; + } +})(); + +(function(){ + var div = document.createElement("div"); + + div.innerHTML = "
          "; + + // Opera can't find a second classname (in 9.6) + // Also, make sure that getElementsByClassName actually exists + if ( !div.getElementsByClassName || div.getElementsByClassName("e").length === 0 ) { + return; + } + + // Safari caches class attributes, doesn't catch changes (in 3.2) + div.lastChild.className = "e"; + + if ( div.getElementsByClassName("e").length === 1 ) { + return; + } + + Expr.order.splice(1, 0, "CLASS"); + Expr.find.CLASS = function( match, context, isXML ) { + if ( typeof context.getElementsByClassName !== "undefined" && !isXML ) { + return context.getElementsByClassName(match[1]); + } + }; + + // release memory in IE + div = null; +})(); + +function dirNodeCheck( dir, cur, doneName, checkSet, nodeCheck, isXML ) { + for ( var i = 0, l = checkSet.length; i < l; i++ ) { + var elem = checkSet[i]; + + if ( elem ) { + var match = false; + + elem = elem[dir]; + + while ( elem ) { + if ( elem.sizcache === doneName ) { + match = checkSet[elem.sizset]; + break; + } + + if ( elem.nodeType === 1 && !isXML ){ + elem.sizcache = doneName; + elem.sizset = i; + } + + if ( elem.nodeName.toLowerCase() === cur ) { + match = elem; + break; + } + + elem = elem[dir]; + } + + checkSet[i] = match; + } + } +} + +function dirCheck( dir, cur, doneName, checkSet, nodeCheck, isXML ) { + for ( var i = 0, l = checkSet.length; i < l; i++ ) { + var elem = checkSet[i]; + + if ( elem ) { + var match = false; + + elem = elem[dir]; + + while ( elem ) { + if ( elem.sizcache === doneName ) { + match = checkSet[elem.sizset]; + break; + } + + if ( elem.nodeType === 1 ) { + if ( !isXML ) { + elem.sizcache = doneName; + elem.sizset = i; + } + + if ( typeof cur !== "string" ) { + if ( elem === cur ) { + match = true; + break; + } + + } else if ( Sizzle.filter( cur, [elem] ).length > 0 ) { + match = elem; + break; + } + } + + elem = elem[dir]; + } + + checkSet[i] = match; + } + } +} + +if ( document.documentElement.contains ) { + Sizzle.contains = function( a, b ) { + return a !== b && (a.contains ? a.contains(b) : true); + }; + +} else if ( document.documentElement.compareDocumentPosition ) { + Sizzle.contains = function( a, b ) { + return !!(a.compareDocumentPosition(b) & 16); + }; + +} else { + Sizzle.contains = function() { + return false; + }; +} + +Sizzle.isXML = function( elem ) { + // documentElement is verified for cases where it doesn't yet exist + // (such as loading iframes in IE - #4833) + var documentElement = (elem ? elem.ownerDocument || elem : 0).documentElement; + + return documentElement ? documentElement.nodeName !== "HTML" : false; +}; + +var posProcess = function( selector, context ) { + var match, + tmpSet = [], + later = "", + root = context.nodeType ? [context] : context; + + // Position selectors must be done after the filter + // And so must :not(positional) so we move all PSEUDOs to the end + while ( (match = Expr.match.PSEUDO.exec( selector )) ) { + later += match[0]; + selector = selector.replace( Expr.match.PSEUDO, "" ); + } + + selector = Expr.relative[selector] ? selector + "*" : selector; + + for ( var i = 0, l = root.length; i < l; i++ ) { + Sizzle( selector, root[i], tmpSet ); + } + + return Sizzle.filter( later, tmpSet ); +}; + +// EXPOSE +jQuery.find = Sizzle; +jQuery.expr = Sizzle.selectors; +jQuery.expr[":"] = jQuery.expr.filters; +jQuery.unique = Sizzle.uniqueSort; +jQuery.text = Sizzle.getText; +jQuery.isXMLDoc = Sizzle.isXML; +jQuery.contains = Sizzle.contains; + + +})(); + + +var runtil = /Until$/, + rparentsprev = /^(?:parents|prevUntil|prevAll)/, + // Note: This RegExp should be improved, or likely pulled from Sizzle + rmultiselector = /,/, + isSimple = /^.[^:#\[\.,]*$/, + slice = Array.prototype.slice, + POS = jQuery.expr.match.POS, + // methods guaranteed to produce a unique set when starting from a unique set + guaranteedUnique = { + children: true, + contents: true, + next: true, + prev: true + }; + +jQuery.fn.extend({ + find: function( selector ) { + var self = this, + i, l; + + if ( typeof selector !== "string" ) { + return jQuery( selector ).filter(function() { + for ( i = 0, l = self.length; i < l; i++ ) { + if ( jQuery.contains( self[ i ], this ) ) { + return true; + } + } + }); + } + + var ret = this.pushStack( "", "find", selector ), + length, n, r; + + for ( i = 0, l = this.length; i < l; i++ ) { + length = ret.length; + jQuery.find( selector, this[i], ret ); + + if ( i > 0 ) { + // Make sure that the results are unique + for ( n = length; n < ret.length; n++ ) { + for ( r = 0; r < length; r++ ) { + if ( ret[r] === ret[n] ) { + ret.splice(n--, 1); + break; + } + } + } + } + } + + return ret; + }, + + has: function( target ) { + var targets = jQuery( target ); + return this.filter(function() { + for ( var i = 0, l = targets.length; i < l; i++ ) { + if ( jQuery.contains( this, targets[i] ) ) { + return true; + } + } + }); + }, + + not: function( selector ) { + return this.pushStack( winnow(this, selector, false), "not", selector); + }, + + filter: function( selector ) { + return this.pushStack( winnow(this, selector, true), "filter", selector ); + }, + + is: function( selector ) { + return !!selector && ( typeof selector === "string" ? + jQuery.filter( selector, this ).length > 0 : + this.filter( selector ).length > 0 ); + }, + + closest: function( selectors, context ) { + var ret = [], i, l, cur = this[0]; + + // Array + if ( jQuery.isArray( selectors ) ) { + var match, selector, + matches = {}, + level = 1; + + if ( cur && selectors.length ) { + for ( i = 0, l = selectors.length; i < l; i++ ) { + selector = selectors[i]; + + if ( !matches[ selector ] ) { + matches[ selector ] = POS.test( selector ) ? + jQuery( selector, context || this.context ) : + selector; + } + } + + while ( cur && cur.ownerDocument && cur !== context ) { + for ( selector in matches ) { + match = matches[ selector ]; + + if ( match.jquery ? match.index( cur ) > -1 : jQuery( cur ).is( match ) ) { + ret.push({ selector: selector, elem: cur, level: level }); + } + } + + cur = cur.parentNode; + level++; + } + } + + return ret; + } + + // String + var pos = POS.test( selectors ) || typeof selectors !== "string" ? + jQuery( selectors, context || this.context ) : + 0; + + for ( i = 0, l = this.length; i < l; i++ ) { + cur = this[i]; + + while ( cur ) { + if ( pos ? pos.index(cur) > -1 : jQuery.find.matchesSelector(cur, selectors) ) { + ret.push( cur ); + break; + + } else { + cur = cur.parentNode; + if ( !cur || !cur.ownerDocument || cur === context || cur.nodeType === 11 ) { + break; + } + } + } + } + + ret = ret.length > 1 ? jQuery.unique( ret ) : ret; + + return this.pushStack( ret, "closest", selectors ); + }, + + // Determine the position of an element within + // the matched set of elements + index: function( elem ) { + + // No argument, return index in parent + if ( !elem ) { + return ( this[0] && this[0].parentNode ) ? this.prevAll().length : -1; + } + + // index in selector + if ( typeof elem === "string" ) { + return jQuery.inArray( this[0], jQuery( elem ) ); + } + + // Locate the position of the desired element + return jQuery.inArray( + // If it receives a jQuery object, the first element is used + elem.jquery ? elem[0] : elem, this ); + }, + + add: function( selector, context ) { + var set = typeof selector === "string" ? + jQuery( selector, context ) : + jQuery.makeArray( selector && selector.nodeType ? [ selector ] : selector ), + all = jQuery.merge( this.get(), set ); + + return this.pushStack( isDisconnected( set[0] ) || isDisconnected( all[0] ) ? + all : + jQuery.unique( all ) ); + }, + + andSelf: function() { + return this.add( this.prevObject ); + } +}); + +// A painfully simple check to see if an element is disconnected +// from a document (should be improved, where feasible). +function isDisconnected( node ) { + return !node || !node.parentNode || node.parentNode.nodeType === 11; +} + +jQuery.each({ + parent: function( elem ) { + var parent = elem.parentNode; + return parent && parent.nodeType !== 11 ? parent : null; + }, + parents: function( elem ) { + return jQuery.dir( elem, "parentNode" ); + }, + parentsUntil: function( elem, i, until ) { + return jQuery.dir( elem, "parentNode", until ); + }, + next: function( elem ) { + return jQuery.nth( elem, 2, "nextSibling" ); + }, + prev: function( elem ) { + return jQuery.nth( elem, 2, "previousSibling" ); + }, + nextAll: function( elem ) { + return jQuery.dir( elem, "nextSibling" ); + }, + prevAll: function( elem ) { + return jQuery.dir( elem, "previousSibling" ); + }, + nextUntil: function( elem, i, until ) { + return jQuery.dir( elem, "nextSibling", until ); + }, + prevUntil: function( elem, i, until ) { + return jQuery.dir( elem, "previousSibling", until ); + }, + siblings: function( elem ) { + return jQuery.sibling( elem.parentNode.firstChild, elem ); + }, + children: function( elem ) { + return jQuery.sibling( elem.firstChild ); + }, + contents: function( elem ) { + return jQuery.nodeName( elem, "iframe" ) ? + elem.contentDocument || elem.contentWindow.document : + jQuery.makeArray( elem.childNodes ); + } +}, function( name, fn ) { + jQuery.fn[ name ] = function( until, selector ) { + var ret = jQuery.map( this, fn, until ), + // The variable 'args' was introduced in + // https://github.com/jquery/jquery/commit/52a0238 + // to work around a bug in Chrome 10 (Dev) and should be removed when the bug is fixed. + // http://code.google.com/p/v8/issues/detail?id=1050 + args = slice.call(arguments); + + if ( !runtil.test( name ) ) { + selector = until; + } + + if ( selector && typeof selector === "string" ) { + ret = jQuery.filter( selector, ret ); + } + + ret = this.length > 1 && !guaranteedUnique[ name ] ? jQuery.unique( ret ) : ret; + + if ( (this.length > 1 || rmultiselector.test( selector )) && rparentsprev.test( name ) ) { + ret = ret.reverse(); + } + + return this.pushStack( ret, name, args.join(",") ); + }; +}); + +jQuery.extend({ + filter: function( expr, elems, not ) { + if ( not ) { + expr = ":not(" + expr + ")"; + } + + return elems.length === 1 ? + jQuery.find.matchesSelector(elems[0], expr) ? [ elems[0] ] : [] : + jQuery.find.matches(expr, elems); + }, + + dir: function( elem, dir, until ) { + var matched = [], + cur = elem[ dir ]; + + while ( cur && cur.nodeType !== 9 && (until === undefined || cur.nodeType !== 1 || !jQuery( cur ).is( until )) ) { + if ( cur.nodeType === 1 ) { + matched.push( cur ); + } + cur = cur[dir]; + } + return matched; + }, + + nth: function( cur, result, dir, elem ) { + result = result || 1; + var num = 0; + + for ( ; cur; cur = cur[dir] ) { + if ( cur.nodeType === 1 && ++num === result ) { + break; + } + } + + return cur; + }, + + sibling: function( n, elem ) { + var r = []; + + for ( ; n; n = n.nextSibling ) { + if ( n.nodeType === 1 && n !== elem ) { + r.push( n ); + } + } + + return r; + } +}); + +// Implement the identical functionality for filter and not +function winnow( elements, qualifier, keep ) { + + // Can't pass null or undefined to indexOf in Firefox 4 + // Set to 0 to skip string check + qualifier = qualifier || 0; + + if ( jQuery.isFunction( qualifier ) ) { + return jQuery.grep(elements, function( elem, i ) { + var retVal = !!qualifier.call( elem, i, elem ); + return retVal === keep; + }); + + } else if ( qualifier.nodeType ) { + return jQuery.grep(elements, function( elem, i ) { + return (elem === qualifier) === keep; + }); + + } else if ( typeof qualifier === "string" ) { + var filtered = jQuery.grep(elements, function( elem ) { + return elem.nodeType === 1; + }); + + if ( isSimple.test( qualifier ) ) { + return jQuery.filter(qualifier, filtered, !keep); + } else { + qualifier = jQuery.filter( qualifier, filtered ); + } + } + + return jQuery.grep(elements, function( elem, i ) { + return (jQuery.inArray( elem, qualifier ) >= 0) === keep; + }); +} + + + + +var rinlinejQuery = / jQuery\d+="(?:\d+|null)"/g, + rleadingWhitespace = /^\s+/, + rxhtmlTag = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/ig, + rtagName = /<([\w:]+)/, + rtbody = /", "" ], + legend: [ 1, "
          ", "
          " ], + thead: [ 1, "", "
          " ], + tr: [ 2, "", "
          " ], + td: [ 3, "", "
          " ], + col: [ 2, "", "
          " ], + area: [ 1, "", "" ], + _default: [ 0, "", "" ] + }; + +wrapMap.optgroup = wrapMap.option; +wrapMap.tbody = wrapMap.tfoot = wrapMap.colgroup = wrapMap.caption = wrapMap.thead; +wrapMap.th = wrapMap.td; + +// IE can't serialize and - - - -
          -

          <%=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 28258c7c892..00000000000 --- 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 168e8f83b2c..00000000000 --- 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 b699d35b943..00000000000 --- 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 68fd6aceefa..00000000000 --- 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 e28b9bb203a..00000000000 --- 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 0176efc8b30..00000000000 --- 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 a980acc80b5..00000000000 --- 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 3fad9810e3c..00000000000 --- 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 bed1171087c..00000000000 --- 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 cf3c29b4821..00000000000 --- 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 59500cd7b75..00000000000 --- 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 39eea4824cd..00000000000 --- 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 46a72e86be8..00000000000 --- 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 ca34cc922c0..00000000000 --- 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 a508ea4beb5..00000000000 --- 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 7db9345f860..00000000000 --- 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 9975b94d62b..00000000000 --- 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 c9bb318942f..00000000000 --- 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 d255c91da5c..00000000000 --- 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 73cd31ac02e..00000000000 --- 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 1ae55ace69b..00000000000 --- 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 0a2f8ee81c8..00000000000 --- 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 fcf19b78012..00000000000 --- 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 48d3f81ff2a..00000000000 --- 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 bbf75c17a40..00000000000 --- 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 7be267a28c0..00000000000 --- 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 18af2b2347e..00000000000 --- 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 d55b9c777e0..00000000000 --- 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 57452394c31..00000000000 --- 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 a03bedc21c5..00000000000 --- 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 4b38689132b..00000000000 --- 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 b3c2bc9c658..00000000000 --- 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 afc1a0d9a9c..00000000000 --- 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 fcdeb48441c..00000000000 --- 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 7989013daba..00000000000 --- 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 78bebfc90ae..00000000000 --- 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 62d8095646d..00000000000 --- 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 8cfe2017b52..00000000000 --- 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 fba3f83bfa1..00000000000 --- 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 faac796ebd9..00000000000 --- 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 6be382ec758..00000000000 --- 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 bdbc1201341..00000000000 --- 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 7870013412f..00000000000 --- 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 19d2ecb7eaf..00000000000 --- 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 324f64986fa..00000000000 --- 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 3d8fe60538f..00000000000 --- 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 269a52bdf08..00000000000 --- 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 599425c4f3d..00000000000 --- 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 d9926fda0f0..00000000000 --- 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/rparsec-1.0/.specification b/vendor/gems/rparsec-1.0/.specification deleted file mode 100644 index 8f44dee573c..00000000000 --- a/vendor/gems/rparsec-1.0/.specification +++ /dev/null @@ -1,112 +0,0 @@ ---- !ruby/object:Gem::Specification -name: rparsec -version: !ruby/object:Gem::Version - hash: 15 - prerelease: false - segments: - - 1 - - 0 - version: "1.0" -platform: ruby -authors: -- Ben Yu -autorequire: rparsec -bindir: bin -cert_chain: -date: 2008-06-17 00:00:00 +03:00 -default_executable: -dependencies: [] - -description: rparsec is a recursive descent parser combinator framework. Declarative API allows creating parser intuitively and dynamically. -email: ajoo.email@gmail.com -executables: [] - -extensions: [] - -extra_rdoc_files: [] - -files: -- rparsec/context.rb -- rparsec/error.rb -- rparsec/expressions.rb -- rparsec/functors.rb -- rparsec/id_monad.rb -- rparsec/keywords.rb -- rparsec/locator.rb -- rparsec/misc.rb -- rparsec/monad.rb -- rparsec/operators.rb -- rparsec/parser.rb -- rparsec/parser_monad.rb -- rparsec/parsers.rb -- rparsec/token.rb -- rparsec.rb -- test/src/expression_test.rb -- test/src/full_parser_test.rb -- test/src/functor_test.rb -- test/src/import.rb -- test/src/keyword_test.rb -- test/src/operator_test.rb -- test/src/parser_test.rb -- test/src/perf_benchmark.rb -- test/src/s_expression_test.rb -- test/src/scratch.rb -- test/src/simple_monad_test.rb -- test/src/simple_parser_test.rb -- test/src/sql.rb -- test/src/sql_parser.rb -- test/src/sql_test.rb -- test/src/tests.rb -has_rdoc: true -homepage: -licenses: [] - -post_install_message: -rdoc_options: [] - -require_paths: -- . -required_ruby_version: !ruby/object:Gem::Requirement - none: false - requirements: - - - ">" - - !ruby/object:Gem::Version - hash: 31 - segments: - - 0 - - 0 - - 0 - version: 0.0.0 -required_rubygems_version: !ruby/object:Gem::Requirement - none: false - requirements: - - - ">=" - - !ruby/object:Gem::Version - hash: 3 - segments: - - 0 - version: "0" -requirements: [] - -rubyforge_project: -rubygems_version: 1.3.7 -signing_key: -specification_version: 1 -summary: A Ruby Parser Combinator Framework -test_files: -- test/src/expression_test.rb -- test/src/full_parser_test.rb -- test/src/functor_test.rb -- test/src/import.rb -- test/src/keyword_test.rb -- test/src/operator_test.rb -- test/src/parser_test.rb -- test/src/perf_benchmark.rb -- test/src/s_expression_test.rb -- test/src/scratch.rb -- test/src/simple_monad_test.rb -- test/src/simple_parser_test.rb -- test/src/sql.rb -- test/src/sql_parser.rb -- test/src/sql_test.rb -- test/src/tests.rb diff --git a/vendor/gems/rparsec-1.0/rparsec.rb b/vendor/gems/rparsec-1.0/rparsec.rb deleted file mode 100644 index 2163cfcb45f..00000000000 --- a/vendor/gems/rparsec-1.0/rparsec.rb +++ /dev/null @@ -1,3 +0,0 @@ -%w{ -parsers operators keywords expressions -}.each {|lib| require "rparsec/#{lib}"} \ No newline at end of file diff --git a/vendor/gems/rparsec-1.0/rparsec/context.rb b/vendor/gems/rparsec-1.0/rparsec/context.rb deleted file mode 100644 index de4dd246d6b..00000000000 --- a/vendor/gems/rparsec-1.0/rparsec/context.rb +++ /dev/null @@ -1,83 +0,0 @@ -module RParsec - -class ParseContext - attr_reader :error, :src, :index, :result - attr_writer :error, :index, :result - - def initialize(src, index=0, error=nil) - @src, @index, @error = src, index, error - end - - def scanner - @scanner = StringScanner.new(src) if @scanner.nil? - @scanner.pos= @index - @scanner - end - - def prepare_error - @error.flatten! if @error.kind_of?(Array) - end - - def to_msg - return '' if @error.nil? - return @error.msg unless @error.kind_of?(Array) - @error.map{|e|e.msg}.join(' or ') - end - - def error_input - return nil if @error.nil? - err = @error - err = err.last if err.kind_of? Array - err.input - end - - def reset_error - @error = nil - end - - def current - @src[@index] - end - - def eof - @index >= @src.length - end - - def available - @src.length - @index - end - - def peek i - @src[@index+i] - end - - def next - @index += 1 - end - - def advance n - @index += n - end - - def retn(val) - @result = val - true - end - - def failure(msg=nil) - @error = Failure.new(@index, get_current_input, msg) - return false - end - - def expecting(expected=nil) - @error = Expected.new(@index, get_current_input, expected) - return false - end - - def get_current_input - return nil if eof - current - end -end - -end # module diff --git a/vendor/gems/rparsec-1.0/rparsec/error.rb b/vendor/gems/rparsec-1.0/rparsec/error.rb deleted file mode 100644 index caef96f1b4c..00000000000 --- a/vendor/gems/rparsec-1.0/rparsec/error.rb +++ /dev/null @@ -1,28 +0,0 @@ -require 'rparsec/misc' - -module RParsec - -class ParserException < StandardError - extend DefHelper - def_readable :index -end -class Failure - def initialize(ind, input, message=nil) - @index, @input, @msg = ind, input, message - end - - attr_reader :index, :input - attr_writer :index - - def msg - return @msg.to_s - end - - Precedence = 100 -end - -class Expected < Failure - Precedence = 100 -end - -end # module \ No newline at end of file diff --git a/vendor/gems/rparsec-1.0/rparsec/expressions.rb b/vendor/gems/rparsec-1.0/rparsec/expressions.rb deleted file mode 100644 index 55c65af3960..00000000000 --- a/vendor/gems/rparsec-1.0/rparsec/expressions.rb +++ /dev/null @@ -1,184 +0,0 @@ -require 'rparsec/parser' - -module RParsec - -Associativities = [:prefix, :postfix, :infixn, :infixr, :infixl] -# -# This class holds information about operator precedences -# and associativities. -# prefix, postfix, infixl, infixr, infixn can be called -# to register operators. -# -class OperatorTable - # - # operators attribute is used internally. Do not access it. - # - attr_reader :operators - - # - # Re-initialize the operator table. Internal use only. - # - def reinit - @operators = [] - end - - # - # To create an OperatorTable instance. - # If a block is given, it is invoked to do post-instantiation. - # For example: - # - # OperatorTable.new do |tbl| - # tbl.infixl(char(?+) >> Plus, 10) - # tbl.infixl(char(?-) >> Minus, 10) - # tbl.infixl(char(?*) >> Mul, 20) - # tbl.infixl(char(?/) >> Div, 20) - # tbl.prefix(char(?-) >> Neg, 50) - # end - # - def self.new - this = allocate - this.reinit - if block_given? - yield this - end - this - end - - # - # Defines a prefix operator that returns a unary Proc object with a precedence associated. - # Returns self. - # - def prefix(op, precedence) - add(:prefix, op, precedence) - end - - # - # Defines a postfix operator that returns a unary Proc object with a precedence associated. - # Returns self. - # - def postfix(op, precedence) - add(:postfix, op, precedence) - end - - # - # Defines a left associative infix operator that returns a binary Proc object with a precedence - # associated. Returns self. - # - def infixl(op, precedence) - add(:infixl, op, precedence) - end - - # - # Defines a right associative infix operator that returns a binary Proc object with a precedence - # associated. Returns self. - # - def infixr(op, precedence) - add(:infixr, op, precedence) - end - - # - # Defines a non-associative infix operator that returns a binary Proc object with a precedence - # associated. Returns self. - # - def infixn(op, precedence) - add(:infixn, op, precedence) - end - - private - - def add(*entry) - @operators << entry - self - end -end - -# -# This module helps build an expression parser -# using an OperatorTable instance and a parser -# that parses the term expression. -# -module Expressions - private - - def self.array_to_dict arr - result = {} - arr.each_with_index do |key,i| - result [key] = i unless result.include? key - end - result - end - - KindPrecedence = array_to_dict Associativities - - public - - # - # build an expression parser using the given term parser - # and operator table. - # When _delim_ is specified, patterns recognized by _delim_ - # is automatically ignored. - # - def self.build(term, table, delim=nil) - # sort so that higher precedence first. - apply_operators(term, prepare_suites(table).sort, delim) - end - - private - - def self.apply_operators(term, entries, delim) - # apply operators stored in [[precedence,associativity],[op...]] starting from beginning. - entries.inject(term) do |result, entry| - key, ops = *entry - null, kind_index = *key - op = ops[0] - op = Parsers.sum(*ops) if ops.length>1 - apply_operator(result, op, Associativities[kind_index], delim) - end - end - - def self.apply_operator(term, op, kind, delim) - term, op = ignore_rest(term, delim), ignore_rest(op, delim) - # we could use send here, - # but explicit case stmt is more straight forward and less coupled with names. - # performance might be another benefit, - # though it is not clear whether meta-code is indeed slower than regular ones at all. - case kind - when :prefix - term.prefix(op) - when :postfix - term.postfix(op) - when :infixl - term.infixl(op) - when :infixr - term.infixr(op) - when :infixn - term.infixn(op) - else - raise ArgumentError, "unknown associativity: #{kind}" - end - end - - def self.ignore_rest(parser, delim) - return parser if delim.nil? - parser << delim - end - - def self.prepare_suites(table) - # create a hash with [precedence, associativity] as key, and op as value. - suites = {} - table.operators.each do |entry| - kind, op, precedence = *entry - key = [-precedence, KindPrecedence[kind]] - suite = suites[key] - if suite.nil? - suite = [op] - suites[key] = suite - else - suite << op - end - end - suites - end -end - -end # module \ No newline at end of file diff --git a/vendor/gems/rparsec-1.0/rparsec/functors.rb b/vendor/gems/rparsec-1.0/rparsec/functors.rb deleted file mode 100644 index 8a836082fc0..00000000000 --- a/vendor/gems/rparsec-1.0/rparsec/functors.rb +++ /dev/null @@ -1,274 +0,0 @@ -module RParsec - -# -# This module provides frequently used functors. -# -module Functors - Id = proc {|x|x} - Idn = proc {|*x|x} - Neg = proc {|x|-x} - Inc = proc {|x|x+1} - Dec = proc {|x|x-1} - Plus = proc {|x,y|x+y} - Minus = proc {|x,y|x-y} - Mul = proc {|x,y|x*y} - Div = proc {|x,y|x/y} - Mod = proc {|x,y|x%y} - Power = proc {|x,y|x**y} - Not = proc {|x,y|!x} - And = proc {|x,y|x&&y} - Or = proc {|x,y|x||y} - Xor = proc {|x,y|x^y} - BitAnd = proc {|x,y|x&y} - Union = proc {|x,y|x|y} - Match = proc {|x,y|x=~y} - Eq = proc {|x,y|x==y} - Ne = proc {|x,y|x!=y} - Lt = proc {|x,y|xy} - Le = proc {|x,y|x<=y} - Ge = proc {|x,y|x>=y} - Compare = proc {|x,y|x<=>y} - Call = proc {|x,y|x.call(y)} - Feed = proc {|x,y|y.call(x)} - Fst = proc {|x,_|x} - Snd = proc {|_, x|x} - At = proc {|x,y|x[y]} - To_a = proc {|x|x.to_a} - To_s = proc {|x|x.to_s} - To_i = proc {|x|x.to_i} - To_sym = proc {|x|x.to_sym} - To_f = proc {|x|x.to_f} - - # - # Get a Proc, when called, always return the given value. - # - def const(v) - proc {|_|v} - end - - # - # Get a Proc, when called, return the nth parameter. - # - def nth(n) - proc {|*args|args[n]} - end - - # - # Create a Proc, which expects the two parameters - # in the reverse order of _block_. - # - def flip(&block) - proc {|x,y|block.call(y,x)} - end - - # - # Create a Proc, when called, the parameter is - # first passed into _f2_, _f1_ is called in turn - # with the return value from _other_. - # - def compose(f1, f2) - proc {|*x|f1.call(f2.call(*x))} - end - - # - # Create a Proc that's curriable. - # When curried, parameters are passed in from left to right. - # i.e. curry(closure).call(a).call(b) is quivalent to closure.call(a,b) . - # _block_ is encapsulated under the hood to perform the actual - # job when currying is done. - # arity explicitly specifies the number of parameters to curry. - # - def curry(arity, &block) - fail "cannot curry for unknown arity" if arity < 0 - Functors.make_curry(arity, &block) - end - - # - # Create a Proc that's curriable. - # When curried, parameters are passed in from right to left. - # i.e. reverse_curry(closure).call(a).call(b) is quivalent to closure.call(b,a) . - # _block_ is encapsulated under the hood to perform the actual - # job when currying is done. - # arity explicitly specifies the number of parameters to curry. - # - def reverse_curry(arity, &block) - fail "cannot curry for unknown arity" if arity < 0 - Functors.make_reverse_curry(arity, &block) - end - - # - # Uncurry a curried closure. - # - def uncurry(&block) - return block unless block.arity == 1 - proc do |*args| - result = block - args.each do |a| - result = result.call(a) - end - result - end - end - - # - # Uncurry a reverse curried closure. - # - def reverse_uncurry(&block) - return block unless block.arity == 1 - proc do |*args| - result = block - args.reverse_each do |a| - result = result.call(a) - end - result - end - end - - # - # Create a Proc, when called, - # repeatedly call _block_ for _n_ times. - # The same arguments are passed to each invocation. - # - def repeat(n, &block) - proc do |*args| - result = nil - n.times {result = block.call(*args)} - result - end - end - - # - # Create a Proc, when called, - # repeatedly call _block_ for _n_ times. - # At each iteration, return value from the previous iteration - # is used as parameter. - # - def power(n, &block) - return const(nil) if n<=0 - return block if n==1 - proc do |*args| - result = block.call(*args) - (n-1).times {result = block.call(result)} - result - end - end - - extend self - - private_class_method - - def self.make_curry(arity, &block) - return block if arity<=1 - proc do |x| - make_curry(arity-1) do |*rest| - block.call(*rest.insert(0, x)) - end - end - end - - def self.make_reverse_curry(arity, &block) - return block if arity <= 1 - proc do |x| - make_reverse_curry(arity-1) do |*rest| - block.call(*rest << x) - end - end - end - -end - -# -# This module provides instance methods that -# manipulate closures in a functional style. -# It is typically included in Proc and Method. -# -module FunctorMixin - # - # Create a Proc, which expects the two parameters - # in the reverse order of _self_. - # - def flip - Functors.flip(&self) - end - - # - # Create a Proc, when called, the parameter is - # first passed into _other_, _self_ is called in turn - # with the return value from _other_. - # - def compose(other) - Functors.compose(self, other) - end - - alias << compose - - # - # a >> b is equivalent to b << a - # - def >> (other) - other << self - end - - # - # Create a Proc that's curriable. - # When curried, parameters are passed in from left to right. - # i.e. closure.curry.call(a).call(b) is quivalent to closure.call(a,b) . - # _self_ is encapsulated under the hood to perform the actual - # job when currying is done. - # _ary_ explicitly specifies the number of parameters to curry. - # - def curry(ary=arity) - Functors.curry(ary, &self) - end - - # - # Create a Proc that's curriable. - # When curried, parameters are passed in from right to left. - # i.e. closure.reverse_curry.call(a).call(b) is quivalent to closure.call(b,a) . - # _self_ is encapsulated under the hood to perform the actual - # job when currying is done. - # _ary_ explicitly specifies the number of parameters to curry. - # - def reverse_curry(ary=arity) - Functors.reverse_curry(ary, &self) - end - - # - # Uncurry a curried closure. - # - def uncurry - Functors.uncurry(&self) - end - - # - # Uncurry a reverse curried closure. - # - def reverse_uncurry - Functors.reverse_uncurry(&self) - end - - # - # Create a Proc, when called, - # repeatedly call _self_ for _n_ times. - # The same arguments are passed to each invocation. - # - def repeat(n) - Functors.repeat(n, &self) - end - # - - # Create a Proc, when called, - # repeatedly call _self_ for _n_ times. - # At each iteration, return value from the previous iteration - # is used as parameter. - # - def power(n) - Functors.power(n, &self) - end - - alias ** power - alias * repeat -end - -end # module \ No newline at end of file diff --git a/vendor/gems/rparsec-1.0/rparsec/id_monad.rb b/vendor/gems/rparsec-1.0/rparsec/id_monad.rb deleted file mode 100644 index d8d2ed48d73..00000000000 --- a/vendor/gems/rparsec-1.0/rparsec/id_monad.rb +++ /dev/null @@ -1,17 +0,0 @@ -module RParsec - -class IdMonad - def value v - v - end - - def bind prev - yield prev - end - - def mplus a, b - a - end -end - -end # module \ No newline at end of file diff --git a/vendor/gems/rparsec-1.0/rparsec/keywords.rb b/vendor/gems/rparsec-1.0/rparsec/keywords.rb deleted file mode 100644 index a276d6220a1..00000000000 --- a/vendor/gems/rparsec-1.0/rparsec/keywords.rb +++ /dev/null @@ -1,114 +0,0 @@ -require 'rparsec/parser' - -module RParsec - -# -# This class helps building lexers and parsers for keywords. -# -class Keywords - extend Parsers - - private_class_method :new - - # - # The symbol used to identify a keyword token - # - attr_reader :keyword_symbol - - # - # The lexer that parses all the keywords represented - # - attr_reader :lexer - - # - # Do we lex case sensitively? - # - def case_sensitive? - @case_sensitive - end - - # - # To create an instance that lexes the given keywords - # case sensitively. - # _default_lexer_ is used to lex a token first, the token text is then compared with - # the given keywords. If it matches any of the keyword, a keyword token is generated instead - # using _keyword_symbol_. - # The _block_ parameter, if present, is used to convert the token text to another object - # when the token is recognized during grammar parsing phase. - # - def self.case_sensitive(words, default_lexer=word.token(:word), keyword_symbol=:keyword, &block) - new(words, true, default_lexer, keyword_symbol, &block) - end - - # - # To create an instance that lexes the given keywords - # case insensitively. - # _default_lexer_ is used to lex a token first, the token text is then compared with - # the given keywords. If it matches any of the keyword, a keyword token is generated instead - # using _keyword_symbol_. - # The _block_ parameter, if present, is used to convert the token text to another object - # when the token is recognized during parsing phase. - # - def self.case_insensitive(words, default_lexer=word.token(:word), keyword_symbol=:keyword, &block) - new(words, false, default_lexer, keyword_symbol, &block) - end - - # scanner has to return a string - def initialize(words, case_sensitive, default_lexer, keyword_symbol, &block) - @default_lexer, @case_sensitive, @keyword_symbol = default_lexer, case_sensitive, keyword_symbol - # this guarantees that we have copy of the words array and all the word strings. - words = copy_words(words, case_sensitive) - @name_map = {} - @symbol_map = {} - word_map = {} - words.each do |w| - symbol = "#{keyword_symbol}:#{w}".to_sym - word_map[w] = symbol - parser = Parsers.token(symbol, &block) - @symbol_map["#{w}".to_sym] = parser - @name_map[w] = parser - end - @lexer = make_lexer(default_lexer, word_map) - end - - # - # Get the parser that recognizes the token of the given keyword during the parsing phase. - # - def parser(key) - result = nil - if key.kind_of? String - name = canonical_name(key) - result = @name_map[name] - else - result = @symbol_map[key] - end - raise ArgumentError, "parser not found for #{key}" if result.nil? - result - end - - alias [] parser - - private - - def make_lexer(default_lexer, word_map) - default_lexer.map do |tok| - text,ind = tok.text, tok.index - key = canonical_name(text) - my_symbol = word_map[key] - case when my_symbol.nil? then tok - else Token.new(my_symbol, text, ind) end - end - end - - def canonical_name(name) - case when @case_sensitive then name else name.downcase end - end - - def copy_words(words, case_sensitive) - words.map do |w| - case when case_sensitive then w.dup else w.downcase end - end - end -end - -end # module \ No newline at end of file diff --git a/vendor/gems/rparsec-1.0/rparsec/locator.rb b/vendor/gems/rparsec-1.0/rparsec/locator.rb deleted file mode 100644 index f305d17dcb0..00000000000 --- a/vendor/gems/rparsec-1.0/rparsec/locator.rb +++ /dev/null @@ -1,40 +0,0 @@ -require 'rparsec/misc' - -module RParsec - -class CodeLocator - extend DefHelper - - def_readable :code - - LF = ?\n - - def locate(ind) - return _locateEof if ind >= code.length - line, col = 1,1 - return line,col if ind<=0 - for i in (0...ind) - c = code[i] - if c == LF - line, col = line+1, 1 - else - col = col+1 - end - end - return line, col - end - - def _locateEof - line, col = 1, 1 - code.each_byte do |c| - if c == LF - line, col = line+1, 1 - else - col = col+1 - end - end - return line, col - end -end - -end # module \ No newline at end of file diff --git a/vendor/gems/rparsec-1.0/rparsec/misc.rb b/vendor/gems/rparsec-1.0/rparsec/misc.rb deleted file mode 100644 index 362e913934f..00000000000 --- a/vendor/gems/rparsec-1.0/rparsec/misc.rb +++ /dev/null @@ -1,130 +0,0 @@ -module RParsec - -# -# Internal utility functions for string manipulations. -# -module StringUtils - # - # Does _str_ starts with the _sub_ string? - # - def self.starts_with? str, sub - return true if sub.nil? - len = sub.length - return false if len > str.length - for i in (0...len) - return false if str[i] != sub[i] - end - true - end -end - -# -# Helpers for defining ctor. -# -module DefHelper - def def_ctor(*vars) - define_method(:initialize) do |*params| - vars.each_with_index do |var, i| - instance_variable_set("@"+var.to_s, params[i]) - end - end - end - - def def_readable(*vars) - attr_reader(*vars) - def_ctor(*vars) - end - - def def_mutable(*vars) - attr_accessor(*vars) - def_ctor(*vars) - end -end - -# -# To type check method parameters. -# -module TypeChecker - private - - def nth n - th = case n when 0 then 'st' when 1 then 'nd' else 'th' end - "#{n+1}#{th}" - end - - public - - def check_arg_type expected, obj, mtd, n=0 - unless obj.kind_of? expected - raise ArgumentError, - "#{obj.class} assigned to #{expected} for the #{nth n} argument of #{mtd}." - end - end - - def check_arg_array_type elem_type, arg, mtd, n=0 - check_arg_type Array, arg, mtd, n - arg.each_with_index do |x, i| - unless x.kind_of? elem_type - raise ArgumentError, - "#{x.class} assigned to #{elem_type} for the #{nth i} element of the #{nth n} argument of #{mtd}." - end - end - end - - def check_vararg_type expected, args, mtd, n = 0 - (n...args.length).each do |i| - check_arg_type expected, args[i], mtd, i - end - end - - extend self -end - -# -# To add declarative signature support. -# -module Signature - # Signatures = {} - def def_sig sym, *types - types.each_with_index do |t,i| - unless t.kind_of? Class - TypeChecker.check_arg_type Class, t, :def_sig, i unless t.kind_of? Array - TypeChecker.check_arg_type Class, t, :def_sig, i unless t.length <= 1 - TypeChecker.check_arg_array_type Class, t, :def_sig, i - end - end - # Signatures[sym] = types - __intercept_method_to_check_param_types__(sym, types) - end - - private - - def __intercept_method_to_check_param_types__(sym, types) - mtd = instance_method(sym) - helper = "_#{sym}_param_types_checked_helper".to_sym - define_method(helper) do |*params| - star_type, star_ind = nil, nil - types.each_with_index do |t, i| - t = star_type unless star_type.nil? - arg = params[i] - if t.kind_of? Class - TypeChecker.check_arg_type t, arg, sym, i - elsif t.empty? - TypeChecker.check_arg_type Array, arg, sym, i - else - star_type, star_ind = t[0], i - break - end - end - TypeChecker.check_vararg_type star_type, params, sym, star_ind unless star_ind.nil? - mtd.bind(self) - end - module_eval """ - def #{sym}(*params, &block) - #{helper}(*params).call(*params, &block) - end - """ - end -end - -end # module \ No newline at end of file diff --git a/vendor/gems/rparsec-1.0/rparsec/monad.rb b/vendor/gems/rparsec-1.0/rparsec/monad.rb deleted file mode 100644 index 6a10674dbb3..00000000000 --- a/vendor/gems/rparsec-1.0/rparsec/monad.rb +++ /dev/null @@ -1,62 +0,0 @@ -module RParsec - -# -# module for Monad -# -module Monad - attr_reader :this - - # - # To initialize with a monad implementation and an object that obeys the monad law. - # - def initMonad(m, v) - raise ArgumentError, 'monad cannot be nil' if m.nil? - @monad = m; - @this = v; - end - - # - # To create a value based on the monad impl. - # - def value v - @monad.value v - end - - # - # Run the _bind_ operation on the encapsulated object following the monad law. - # - def bind(&binder) - @monad.bind(@this, &binder) - end - - # - # Run the _seq_ operation on the encapsulated object following the monad law. - # If _seq_ is not defined by the monad impl, use _bind_ to implement. - # - def seq(other) - if @monad.respond_to? :seq - @monad.seq(other) - else bind {|x|other} - end - end - - # - # Run the _map_ operation on the encapsulated object following the monad law. - # _bind_ is used to implement. - # - def map(&mapper) - bind do |v| - result = mapper.call v; - value(result); - end - end - - # - # Run the _plus_ operation on the encapsulated object following the MonadPlus law. - # - def plus other - @monad.mplus(@this, other.this) - end -end - -end # module \ No newline at end of file diff --git a/vendor/gems/rparsec-1.0/rparsec/operators.rb b/vendor/gems/rparsec-1.0/rparsec/operators.rb deleted file mode 100644 index 480cd668c3f..00000000000 --- a/vendor/gems/rparsec-1.0/rparsec/operators.rb +++ /dev/null @@ -1,103 +0,0 @@ -require 'rparsec/parser' - -module RParsec - -# -# This class helps building lexer and parser for operators. -# The case that one operator (++ for example) contains another operator (+) -# is automatically handled so client code don't have to worry about ambiguity. -# -class Operators - # - # To create an instance of Operators for the given operators. - # The _block_ parameter, if present, is used to convert the token text to another object - # when the token is recognized during grammar parsing phase. - # - def initialize(ops, &block) - @lexers = {} - @parsers = {} - sorted = Operators.sort(ops) - lexers = sorted.map do |op| - symbol = op.to_sym - result = nil - if op.length == 1 - result = Parsers.char(op) - else - result = Parsers.str(op) - end - result = result.token(symbol) - @lexers[symbol] = result - @parsers[symbol] = Parsers.token(symbol, &block) - result - end - @lexer = Parsers.sum(*lexers) - end - - # - # Get the parser for the given operator. - # - def parser(op) - result = @parsers[op.to_sym] - raise ArgumentError, "parser not found for #{op}" if result.nil? - result - end - - alias [] parser - - # - # Get the lexer that lexes operators. - # If an operator is specified, the lexer for that operator is returned. - # - def lexer(op=nil) - return @lexer if op.nil? - @lexers[op.to_sym] - end - - # - # Sort an array of operators so that contained operator appears after containers. - # When no containment exist between two operators, the shorter one takes precedence. - # - def self.sort(ops) - #sort the array by longer-string-first. - ordered = ops.sort {|x, y|y.length <=> x.length} - suites = [] - # loop from the longer to shorter string - ordered.each do |s| - populate_suites(suites, s) - end - # suites are populated with bigger suite first - to_array suites - end - - private - - def self.populate_suites(suites, s) - # populate the suites so that bigger suite first - # this way we can use << operator for non-contained strings. - - # we need to start from bigger suite. So loop in reverse order - for suite in suites - return if populate_suite(suite, s) - end - suites << [s] - end - - def self.populate_suite(suite, s) - # loop from the tail of the suite - for i in (1..suite.length) - ind = suite.length - i - cur = suite[ind] - if StringUtils.starts_with? cur, s - suite.insert(ind+1, s) unless cur == s - return true - end - end - false - end - - def self.to_array suites - suites.reverse!.flatten! - end -end - -end # module \ No newline at end of file diff --git a/vendor/gems/rparsec-1.0/rparsec/parser.rb b/vendor/gems/rparsec-1.0/rparsec/parser.rb deleted file mode 100644 index 8d715d887e9..00000000000 --- a/vendor/gems/rparsec-1.0/rparsec/parser.rb +++ /dev/null @@ -1,894 +0,0 @@ -%w{ -monad misc error context locator token functors parser_monad -}.each {|lib| require "rparsec/#{lib}"} -require 'strscan' - -module RParsec - -# -# Represents a parser that parses a certain grammar rule. -# -class Parser - include Functors - include Monad - extend Signature - extend DefHelper - MyMonad = ParserMonad.new - attr_accessor :name - - private - - def initialize - initMonad(MyMonad, self) - end - - def self.init(*vars) - parser_checker = {} - vars.each_with_index do |var, i| - name = var.to_s - parser_checker[i] = var if name.include?('parser') && !name.include?('parsers') - end - define_method(:initialize) do |*params| - super() - vars.each_with_index do |var, i| - param = params[i] - if parser_checker.include? i - TypeChecker.check_arg_type Parser, param, self, i - end - instance_variable_set("@"+var.to_s, param) - end - end - end - - def _display_current_input(input, code, index) - return 'EOF' if input.nil? - c = input - case c when Fixnum then "'"< max - if(min==max) - return Parsers.one if max <= 0 - return self if max == 1 - Repeat_Parser.new(self, max) - else - Some_Parser.new(self, min, max) - end - end - - # - # To create a parser that repeats self for a minimum _min_ times, - # and maximally _max_ times. - # All return values are collected in an array. - # - def repeat(min, max=min) - return Parsers.failure("min=#{min}, max=#{max}") if min > max - if(min==max) - RepeatParser.new(self, max) - else - SomeParser.new(self, min, max) - end - end - - # - # To create a parser that repeats self for at least _least_ times. - # parser.many_ is equivalent to bnf notation "parser*". - # Only the return value of the last execution is preserved. - # - def many_(least=0) - Many_Parser.new(self, least) - end - - # - # To create a parser that repeats self for at least _least_ times. - # All return values are collected in an array. - # - def many(least=0) - ManyParser.new(self, least) - end - - # - # To create a parser that repeats self for at most _max_ times. - # Only the return value of the last execution is preserved. - # - def some_(max) - repeat_(0, max) - end - - # - # To create a parser that repeats self for at most _max_ times. - # All return values are collected in an array. - # - def some(max) - repeat(0, max) - end - - # - # To create a parser that repeats self for unlimited times, - # with the pattern recognized by _delim_ as separator that separates each occurrence. - # self has to match for at least once. - # Return values of self are collected in an array. - # - def separated1 delim - rest = delim >> self - self.bind do |v0| - result = [v0] - (rest.map {|v| result << v}).many_ >> value(result) - end - end - - # - # To create a parser that repeats self for unlimited times, - # with the pattern recognized by _delim_ as separator that separates each occurrence. - # Return values of self are collected in an array. - # - def separated delim - separated1(delim).plus value([]) - end - - # - # To create a parser that repeats self for unlimited times, - # with the pattern recognized by _delim_ as separator that separates each occurrence - # and also possibly ends the pattern. - # self has to match for at least once. - # Return values of self are collected in an array. - # - def delimited1 delim - rest = delim >> (self.plus Parsers.throwp(:__end_delimiter__)) - self.bind do |v0| - result = [v0] - (rest.map {|v| result << v}).many_.catchp(:__end_delimiter__) >> value(result) - end - end - - # - # To create a parser that repeats self for unlimited times, - # with the pattern recognized by _delim_ as separator that separates each occurrence - # and also possibly ends the pattern. - # Return values of self are collected in an array. - # - def delimited delim - delimited1(delim).plus value([]) - end - - # - # String representation - # - def to_s - return name unless name.nil? - self.class.to_s - end - - # - # a | b will run b when a fails. - # b is auto-boxed to Parser when it is not of type Parser. - # - def | other - AltParser.new([self, autobox_parser(other)]) - end - - # - # a.optional(default) is equivalent to a.plus(value(default)) - # - def optional(default=nil) - self.plus(value(default)) - end - - # - # a.catchp(:somesymbol) will catch the :somesymbol thrown by a. - # - def catchp(symbol) - CatchParser.new(symbol, self) - end - - # - # a.fragment will return the string matched by a. - # - def fragment - FragmentParser.new(self) - end - - # - # a.nested b will feed the token array returned by parser a to parser b - # for a nested parsing. - # - def nested(parser) - NestedParser.new(self, parser) - end - - # - # a.lexeme(delim) will parse _a_ for 0 or more times and ignore all - # patterns recognized by _delim_. - # Values returned by _a_ are collected in an array. - # - def lexeme(delim = Parsers.whitespaces) - delim = delim.many_ - delim >> self.delimited(delim) - end - - # - # For prefix unary operator. - # a.prefix op will run parser _op_ for 0 or more times and eventually run parser _a_ - # for one time. - # _op_ should return a Proc that accepts one parameter. - # Proc objects returned by _op_ is then fed with the value returned by _a_ - # from right to left. - # The final result is returned as return value. - # - def prefix(op) - Parsers.sequence(op.many, self) do |funcs, v| - funcs.reverse_each {|f|v=f.call(v)} - v - end - end - - # - # For postfix unary operator. - # a.postfix op will run parser _a_ for once and then _op_ for 0 or more times. - # _op_ should return a Proc that accepts one parameter. - # Proc objects returned by _op_ is then fed with the value returned by _a_ - # from left to right. - # The final result is returned as return value. - # - def postfix(op) - Parsers.sequence(self, op.many) do |v, funcs| - funcs.each{|f|v=f.call(v)} - v - end - end - - # - # For non-associative infix binary operator. - # _op_ has to return a Proc that takes two parameters, who - # are returned by the _self_ parser as operands. - # - def infixn(op) - bind do |v1| - bin = Parsers.sequence(op, self) do |f, v2| - f.call(v1,v2) - end - bin | value(v1) - end - end - - # - # For left-associative infix binary operator. - # _op_ has to return a Proc that takes two parameters, who - # are returned by the _self_ parser as operands. - # - def infixl(op) - Parsers.sequence(self, _infix_rest(op, self).many) do |v, rests| - rests.each do |r| - f, v1 = *r - v = f.call(v,v1) - end - v - end - end - - # - # For right-associative infix binary operator. - # _op_ has to return a Proc that takes two parameters, who - # are returned by the _self_ parser as operands. - # - def infixr(op) - Parsers.sequence(self, _infix_rest(op, self).many) do |v, rests| - if rests.empty? - v - else - f, seed = *rests.last - for i in (0...rests.length-1) - cur = rests.length-2-i - f1, v1 = *rests[cur] - seed = f.call(v1, seed) - f = f1 - end - f.call(v, seed) - end - end - end - - # - # a.token(:word_token) will return a Token object when _a_ succeeds. - # The matched string (or the string returned by _a_, if any) is - # encapsulated in the token, together with the :word_token symbol and - # the starting index of the match. - # - def token(kind) - TokenParser.new(kind, self) - end - - # - # a.seq b will sequentially run a then b. - # The result of b is preserved as return value. - # If a block is associated, values returned by _a_ and _b_ - # are passed into the block and the return value of - # the block is used as the final result of the parser. - # - def seq(other, &block) - # TypeChecker.check_arg_type Parser, other, :seq - Parsers.sequence(self, other, &block) - end - def_sig :seq, Parser - - # - # Similar to _seq_. _other_ is auto-boxed if it is not of type Parser. - # - def >> (other) - seq(autobox_parser(other)) - end - - private - - def autobox_parser(val) - return Parsers.value(val) unless val.kind_of? Parser - val - end - - def _infix_rest(operator, operand) - Parsers.sequence(operator, operand, &Idn) - end - - public - - alias ~ not - alias << followed - alias * repeat_ - - def_sig :plus, Parser - - private - - def _parse(ctxt) - false - end -end -# -# This module provides all out-of-box parser implementations. -# -module Parsers - extend Signature - - # - # A parser that always fails with the given error message. - # - def failure msg - FailureParser.new(msg) - end - - # - # A parser that always succeeds with the given return value. - # - def value v - ValueParser.new(v) - end - - # - # A parser that calls alternative parsers until one succeed, - # or any failure with input consumption beyond the current look-ahead. - # - def sum(*alts) - # TypeChecker.check_vararg_type Parser, alts, :sum - PlusParser.new(alts) - end - def_sig :sum, [Parser] - - # - # A parser that calls alternative parsers until one succeeds. - # - def alt(*alts) - AltParser.new(alts) - end - def_sig :alt, [Parser] - - # - # A parser that succeeds when the given predicate returns true - # (with the current input as the parameter). - # _expected_ is the error message when _pred_ returns false. - # - def satisfies(expected, &pred) - SatisfiesParser.new(pred, expected) - end - - # - # A parser that succeeds when the the current input is equal to the given value. - # _expected_ is the error message when _pred_ returns false. - # - def is(v, expected="#{v} expected") - satisfies(expected) {|c|c==v} - end - - # - # A parser that succeeds when the the current input is not equal to the given value. - # _expected_ is the error message when _pred_ returns false. - # - def isnt(v, expected="#{v} unexpected") - satisfies(expected) {|c|c!=v} - end - - # - # A parser that succeeds when the the current input is among the given values. - # - def among(*vals) - expected="one of [#{vals.join(', ')}] expected" - vals = as_list vals - satisfies(expected) {|c|vals.include? c} - end - - # - # A parser that succeeds when the the current input is not among the given values. - # - def not_among(*vals) - expected = "one of [#{vals.join(', ')}] unexpected" - vals = as_list vals - satisfies(expected) {|c|!vals.include? c} - end - - # - # A parser that succeeds when the the current input is the given character. - # - def char(c) - if c.kind_of? Fixnum - nm = c.chr - is(c, "'#{nm}' expected").setName(nm) - else - is(c[0], "'#{c}' expected").setName(c) - end - end - - # - # A parser that succeeds when the the current input is not the given character. - # - def not_char(c) - if c.kind_of? Fixnum - nm = c.chr - isnt(c, "'#{nm}' unexpected").setName("~#{nm}") - else - isnt(c[0], "'#{c}' unexpected").setName("~#{c}") - end - end - - # - # A parser that succeeds when there's no input available. - # - def eof(expected="EOF expected") - EofParser.new(expected).setName('EOF') - end - - # - # A parser that tries to match the current inputs one by one - # with the given values. - # It succeeds only when all given values are matched, in which case all the - # matched inputs are consumed. - # - def are(vals, expected="#{vals} expected") - AreParser.new(vals, expected) - end - - # - # A parser that makes sure that the given values don't match - # the current inputs. One input is consumed if it succeeds. - # - def arent(vals, expected="#{vals} unexpected") - are(vals, '').not(expected) >> any - end - - # - # A parser that matches the given string. - # - def string(str, msg = "\"#{str}\" expected") - are(str, msg).setName(str) - end - - # - # A parser that makes sure that the current input doesn't match a string. - # One character is consumed if it succeeds. - # - def not_string(str, msg="\"#{str}\" unexpected") - string(str).not(msg) >> any - end - - alias str string - - # - # A parser that sequentially run the given parsers. - # The result of the last parser is used as return value. - # If a block is given, the results of the parsers are passed - # into the block as parameters, and the block return value - # is used as result instead. - # - def sequence(*parsers, &proc) - # TypeChecker.check_vararg_type Parser, parsers, :sequence - SequenceParser.new(parsers, proc) - end - def_sig :sequence, [Parser] - - # - # A parser that returns the current input index (starting from 0). - # - def get_index - GetIndexParser.new.setName('get_index') - end - - # - # A parser that moves the current input pointer to a certain index. - # - def set_index ind - SetIndexParser.new(ind).setName('set_index') - end - - # - # A parser that tries all given alternative parsers - # and picks the one with the longest match. - # - def longest(*parsers) - # TypeChecker.check_vararg_type Parser, parsers, :longest - BestParser.new(parsers, true) - end - def_sig :longest, [Parser] - - # - # A parser that tries all given alternative parsers - # and picks the one with the shortest match. - # - def shortest(*parsers) - # TypeChecker.check_vararg_type Parser, parsers, :shortest - BestParser.new(parsers, false) - end - def_sig :shortest, [Parser] - - alias shorter shortest - alias longer longest - - # - # A parser that consumes one input. - # - def any - AnyParser.new - end - - # - # A parser that always fails. - # - def zero - ZeroParser.new - end - - # - # A parser that always succeeds. - # - def one - OneParser.new - end - - # - # A parser that succeeds if the current input is within a certain range. - # - def range(from, to, msg="#{as_char from}..#{as_char to} expected") - from, to = as_num(from), as_num(to) - satisfies(msg) {|c| c <= to && c >= from} - end - - # - # A parser that throws a symbol. - # - def throwp(symbol) - ThrowParser.new(symbol) - end - - # - # A parser that succeeds if the current inputs match - # the given regular expression. - # The matched string is consumed and returned as result. - # - def regexp(ptn, expected="/#{ptn.to_s}/ expected") - RegexpParser.new(as_regexp(ptn), expected).setName(expected) - end - - # - # A parser that parses a word - # (starting with alpha or underscore, followed by 0 or more alpha, number or underscore). - # and return the matched word as string. - # - def word(expected='word expected') - regexp(/[a-zA-Z_]\w*/, expected) - end - - # - # A parser that parses an integer - # and return the matched integer as string. - # - def integer(expected='integer expected') - regexp(/\d+(?!\w)/, expected) - end - - # - # A parser that parses a number (integer, or decimal number) - # and return the matched number as string. - # - def number(expected='number expected') - regexp(/\d+(\.\d+)?/, expected) - end - - # - # A parser that matches the given string, case insensitively. - # - def string_nocase(str, expected="'#{str}' expected") - StringCaseInsensitiveParser.new(str, expected).setName(str) - end - - # - # A parser that succeeds when the current input - # is a token with one of the the given token kinds. - # If a block is given, the token text is passed to the block - # as parameter, and the block return value is used as result. - # Otherwise, the token object is used as result. - # - def token(*kinds, &proc) - expected="#{kinds.join(' or ')} expected" - recognizer = nil - if kinds.length==1 - kind = kinds[0] - recognizer = satisfies(expected) do |tok| - tok.respond_to? :kind, :text and kind == tok.kind - end - else - recognizer = satisfies(expected) do |tok| - tok.respond_to? :kind, :text and kinds.include? tok.kind - end - end - recognizer = recognizer.map{|tok|proc.call(tok.text)} if proc - recognizer - end - - # - # A parser that parses a white space character. - # - def whitespace(expected="whitespace expected") - satisfies(expected) {|c| Whitespaces.include? c} - end - - # - # A parser that parses 1 or more white space characters. - # - def whitespaces(expected="whitespace(s) expected") - whitespace(expected).many_(1) - end - - # - # A parser that parses a line started with _start_. - # nil is the result. - # - def comment_line start - string(start) >> not_char(?\n).many_ >> char(?\n).optional >> value(nil) - end - - # - # A parser that parses a chunk of text started with _open_ - # and ended by _close_. - # nil is the result. - # - def comment_block open, close - string(open) >> not_string(close).many_ >> string(close) >> value(nil) - end - - # - # A lazy parser, when executed, calls the given block - # to get a parser object and delegate the call to this lazily - # instantiated parser. - # - def lazy(&block) - LazyParser.new(block) - end - - # - # A parser that watches the current parser result without changing it. - # The following assert will succeed: - ## - # char(?a) >> watch{|x|assert_equal(?a, x)} - ## - # watch can also be used as a handy tool to print trace information, - # for example: - ## - # some_parser >> watch {puts "some_parser succeeded."} - # - def watch(&block) - return one unless block - WatchParser.new(block) - end - - # - # A parser that watches the current parser result without changing it. - # The following assert will succeed: - ## - # char(?a).repeat(2) >> watchn{|x,y|assert_equal([?a,?a], [x,y])} - ## - # Slightly different from _watch_, _watchn_ expands the current parser result - # before passing it into the associated block. - # - def watchn(&block) - return one unless block - WatchnParser.new(block) - end - - # - # A parser that maps current parser result to a new result using - # the given block. - ## - # Different from Parser#map, this method does not need to be combined - # with any Parser object. It is rather an independent Parser object - # that maps the _current_ parser result. - ## - # parser1.map{|x|...} is equivalent to parser1 >> map{|x|...} - # - def map(&block) - return one unless block - MapCurrentParser.new(block) - end - - # - # A parser that maps current parser result to a new result using - # the given block. If the current parser result is an array, the array - # elements are expanded and then passed as parameters to the block. - ## - # Different from Parser#mapn, this method does not need to be combined - # with any Parser object. It is rather an independent Parser object - # that maps the _current_ parser result. - ## - # parser1.mapn{|x,y|...} is equivalent to parser1 >> mapn{|x,y|...} - # - def mapn(&block) - return one unless block - MapnCurrentParser.new(block) - end - - private - - # - # characters considered white space. - # - Whitespaces = " \t\r\n" - - def as_regexp ptn - case ptn when String then Regexp.new(ptn) else ptn end - end - - def as_char c - case c when String then c else c.chr end - end - - def as_num c - case c when String: c[0] else c end - end - - def as_list vals - return vals unless vals.length==1 - val = vals[0] - return vals unless val.kind_of? String - val - end - - extend self -end - -end # module diff --git a/vendor/gems/rparsec-1.0/rparsec/parser_monad.rb b/vendor/gems/rparsec-1.0/rparsec/parser_monad.rb deleted file mode 100644 index d1a3b01651a..00000000000 --- a/vendor/gems/rparsec-1.0/rparsec/parser_monad.rb +++ /dev/null @@ -1,23 +0,0 @@ -module RParsec - -class ParserMonad - def fail msg - FailureParser.new(msg) - end - - def value v - return Nil if v.nil? - ValueParser.new(v); - end - - def bind(v, &proc) - return v unless proc - BoundParser.new(v, proc); - end - - def mplus(p1, p2) - PlusParser.new([p1,p2]); - end -end - -end # module \ No newline at end of file diff --git a/vendor/gems/rparsec-1.0/rparsec/parsers.rb b/vendor/gems/rparsec-1.0/rparsec/parsers.rb deleted file mode 100644 index b5b9616d4b6..00000000000 --- a/vendor/gems/rparsec-1.0/rparsec/parsers.rb +++ /dev/null @@ -1,623 +0,0 @@ -require 'rparsec/parser' - -module RParsec - -class FailureParser < Parser - init :msg - def _parse ctxt - return ctxt.failure(@msg) - end -end - -class ValueParser < Parser - init :value - def _parse ctxt - ctxt.retn @value - end -end - -class LazyParser < Parser - init :block - def _parse ctxt - @block.call._parse ctxt - end -end - -class Failures - def self.add_error(err, e) - return e if err.nil? - return err if e.nil? - cmp = compare_error(err, e) - return err if cmp > 0 - return e if cmp < 0 - err - # merge_error(err, e) - end - - private - - def self.get_first_element(err) - while err.kind_of?(Array) - err = err[0] - end - err - end - - def self.compare_error(e1, e2) - e1, e2 = get_first_element(e1), get_first_element(e2) - return -1 if e1.index < e2.index - return 1 if e1.index > e2.index - 0 - end -end - -############################################### -#def merge_error(e1, e2) -# return e1 << e2 if e1.kind_of?(Array) -# [e1,e2] -#end -############################################### -class ThrowParser < Parser - init :symbol - def _parse ctxt - throw @symbol - end -end - -class CatchParser < Parser - init :symbol, :parser - def _parse ctxt - interrupted = true - ok = false - catch @symbol do - ok = @parser._parse(ctxt) - interrupted = false - end - return ctxt.retn(@symbol) if interrupted - ok - end -end - -class PeekParser < Parser - init :parser - def _parse ctxt - ind = ctxt.index - return false unless @parser._parse ctxt - ctxt.index = ind - return true - end - def peek - self - end -end - -class AtomParser < Parser - init :parser - def _parse ctxt - ind = ctxt.index - return true if @parser._parse ctxt - ctxt.index = ind - return false - end - def atomize - self - end -end - -class LookAheadSensitiveParser < Parser - def initialize(la=1) - super() - @lookahead = la - end - def visible(ctxt, n) - ctxt.index - n < @lookahead - end - def lookahead(n) - raise ArgumentError, "lookahead number #{n} should be positive" unless n>0 - return self if n == @lookahead - withLookahead(n) - end - def not(msg="#{self} unexpected") - NotParser.new(self, msg, @lookahead) - end -end - -class NotParser < LookAheadSensitiveParser - def initialize(parser, msg, la=1) - super(la) - @parser, @msg, @name = parser, msg, "~#{parser.name}" - end - def _parse ctxt - ind = ctxt.index - if @parser._parse ctxt - ctxt.index = ind - return ctxt.expecting(@msg) - end - return ctxt.retn(nil) if visible(ctxt, ind) - return false - end - def withLookahead(n) - NotParser.new(@parser, @msg, n) - end - def not() - @parser - end -end - -class ExpectParser < Parser - def initialize(parser, msg) - super() - @parser, @msg, @name = parser, msg, msg - end - def _parse ctxt - ind = ctxt.index - return true if @parser._parse ctxt - return false unless ind == ctxt.index - ctxt.expecting(@msg) - end -end - -class PlusParser < LookAheadSensitiveParser - def initialize(alts, la=1) - super(la) - @alts = alts - end - def _parse ctxt - ind, result, err = ctxt.index, ctxt.result, ctxt.error - for p in @alts - ctxt.reset_error - ctxt.index, ctxt.result = ind, result - return true if p._parse(ctxt) - return false unless visible(ctxt, ind) - err = Failures.add_error(err, ctxt.error) - end - ctxt.error = err - return false - end - def withLookahead(n) - PlusParser.new(@alts, n) - end - def plus other - PlusParser.new(@alts.dup << other, @lookahead).setName(name) - end - def_sig :plus, Parser -end - - -class AltParser < LookAheadSensitiveParser - def initialize(alts, la = 1) - super(la) - @alts, @lookahead = alts, la - end - def _parse ctxt - ind, result, err = ctxt.index, ctxt.result, ctxt.error - err_ind, err_pos = -1, -1 - for p in @alts - ctxt.reset_error - ctxt.index, ctxt.result = ind, result - return true if p._parse(ctxt) - if ctxt.error.index > err_pos - err, err_ind, err_pos = ctxt.error, ctxt.index, ctxt.error.index - end - end - ctxt.index, ctxt.error = err_ind, err - return false - end - def withLookahead(n) - AltParser.new(@alts, n) - end - def | other - AltParser.new(@alts.dup << autobox_parser(other)).setName(name) - end -end - - -class BestParser < Parser - init :alts, :longer - def _parse ctxt - best_result, best_ind = nil, -1 - err_ind, err_pos = -1, -1 - ind, result, err = ctxt.index, ctxt.result, ctxt.error - for p in @alts - ctxt.reset_error - ctxt.index, ctxt.result = ind, result - if p._parse(ctxt) - err, now_ind = nil, ctxt.index - if best_ind==-1 || now_ind != best_ind && @longer == (now_ind>best_ind) - best_result, best_ind = ctxt.result, now_ind - end - elsif best_ind < 0 # no good match found yet. - if ctxt.error.index > err_pos - err_ind, err_pos = ctxt.index, ctxt.error.index - end - err = Failures.add_error(err, ctxt.error) - end - end - if best_ind >= 0 - ctxt.index = best_ind - return ctxt.retn(best_result) - else - ctxt.error, ctxt.index = err, err_ind - return false - end - end -end - -class BoundParser < Parser - init :parser, :proc - def _parse ctxt - return false unless @parser._parse(ctxt) - @proc.call(ctxt.result)._parse ctxt - end -end - -class BoundnParser < Parser - init :parser, :proc - def _parse ctxt - return false unless @parser._parse(ctxt) - @proc.call(*ctxt.result)._parse ctxt - end -end - -class MapParser < Parser - init :parser, :proc - def _parse ctxt - return false unless @parser._parse(ctxt) - ctxt.result = @proc.call(ctxt.result) - true - end -end - -class MapnParser < Parser - init :parser, :proc - def _parse ctxt - return false unless @parser._parse(ctxt) - ctxt.result = @proc.call(*ctxt.result) - true - end -end - -class SequenceParser < Parser - init :parsers, :proc - def _parse ctxt - if @proc.nil? - for p in @parsers - return false unless p._parse(ctxt) - end - else - results = [] - for p in @parsers - return false unless p._parse(ctxt) - results << ctxt.result - end - ctxt.retn(@proc.call(*results)) - end - return true - end - def seq(other, &block) - # TypeChecker.check_arg_type Parser, other, :seq - SequenceParser.new(@parsers.dup << other, &block) - end - def_sig :seq, Parser -end - -class FollowedParser < Parser - init :p1, :p2 - def _parse ctxt - return false unless @p1._parse ctxt - result = ctxt.result - return false unless @p2._parse ctxt - ctxt.retn(result) - end -end - -class SatisfiesParser < Parser - init :pred, :expected - def _parse ctxt - elem = nil - if ctxt.eof || !@pred.call(elem=ctxt.current) - return ctxt.expecting(@expected) - end - ctxt.next - ctxt.retn elem - end -end - -class AnyParser < Parser - def _parse ctxt - return ctxt.expecting if ctxt.eof - result = ctxt.current - ctxt.next - ctxt.retn result - end -end - -class EofParser < Parser - init :msg - def _parse ctxt - return true if ctxt.eof - return ctxt.expecting(@msg) - end -end - -class RegexpParser < Parser - init :ptn, :msg - def _parse ctxt - scanner = ctxt.scanner - result = scanner.check @ptn - if result.nil? - ctxt.expecting(@msg) - else - ctxt.advance(scanner.matched_size) - ctxt.retn(result) - end - end -end - -class AreParser < Parser - init :vals, :msg - def _parse ctxt - if @vals.length > ctxt.available - return ctxt.expecting(@msg) - end - cur = 0 - for cur in (0...@vals.length) - if @vals[cur] != ctxt.peek(cur) - return ctxt.expecting(@msg) - end - end - ctxt.advance(@vals.length) - ctxt.retn @vals - end -end - -def downcase c - case when c >= ?A && c <=?Z then c + (?a - ?A) else c end -end - -class StringCaseInsensitiveParser < Parser - init :str, :msg - def _parse ctxt - if @str.length > ctxt.available - return ctxt.expecting(@msg) - end - cur = 0 - for cur in (0...@str.length) - if downcase(@str[cur]) != downcase(ctxt.peek(cur)) - return ctxt.expecting(@msg) - end - end - result = ctxt.src[ctxt.index, @str.length] - ctxt.advance(@str.length) - ctxt.retn result - end -end - -class FragmentParser < Parser - init :parser - def _parse ctxt - ind = ctxt.index - return false unless @parser._parse ctxt - ctxt.retn(ctxt.src[ind, ctxt.index-ind]) - end -end - -class TokenParser < Parser - init :symbol, :parser - def _parse ctxt - ind = ctxt.index - return false unless @parser._parse ctxt - raw = ctxt.result - raw = ctxt.src[ind, ctxt.index-ind] unless raw.kind_of? String - ctxt.retn(Token.new(@symbol, raw, ind)) - end -end - -class NestedParser < Parser - init :parser1, :parser2 - def _parse ctxt - ind = ctxt.index - return false unless @parser1._parse ctxt - _run_nested(ind, ctxt, ctxt.result, @parser2) - end - private - def _run_nested(start, ctxt, src, parser) - ctxt.error = nil - new_ctxt = nil - if src.kind_of? String - new_ctxt = ParseContext.new(src) - return true if _run_parser parser, ctxt, new_ctxt - ctxt.index = start + new_ctxt.index - elsif src.kind_of? Array - new_ctxt = ParseContext.new(src) - return true if _run_parser parser, ctxt, new_ctxt - ctxt.index = start + _get_index(new_ctxt) unless new_ctxt.eof - else - new_ctxt = ParseContext.new([src]) - return true if _run_parser parser, ctxt, new_ctxt - ctxt.index = ind unless new_ctxt.eof - end - ctxt.error.index = ctxt.index - false - end - def _get_index ctxt - cur = ctxt.current - return cur.index if cur.respond_to? :index - ctxt.index - end - def _run_parser parser, old_ctxt, new_ctxt - if parser._parse new_ctxt - old_ctxt.result = new_ctxt.result - true - else - old_ctxt.error = new_ctxt.error - false - end - end -end - -class WatchParser < Parser - init :proc - def _parse ctxt - @proc.call(ctxt.result) - true - end -end - -class WatchnParser < Parser - init :proc - def _parse ctxt - @proc.call(*ctxt.result) - true - end -end - -class MapCurrentParser < Parser - init :proc - def _parse ctxt - ctxt.result = @proc.call(ctxt.result) - true - end -end - -class MapnCurrentParser < Parser - init :proc - def _parse ctxt - ctxt.result = @proc.call(*ctxt.result) - true - end -end - -class Repeat_Parser < Parser - init :parser, :times - def _parse ctxt - for i in (0...@times) - return false unless @parser._parse ctxt - end - return true - end -end - -class RepeatParser < Parser - init :parser, :times - def _parse ctxt - result = [] - for i in (0...@times) - return false unless @parser._parse ctxt - result << ctxt.result - end - return ctxt.retn(result) - end -end - -class Many_Parser < Parser - init :parser, :least - def _parse ctxt - for i in (0...@least) - return false unless @parser._parse ctxt - end - while(true) - ind = ctxt.index - if @parser._parse ctxt - return true if ind==ctxt.index # infinite loop - next - end - return ind==ctxt.index - end - end -end - -class ManyParser < Parser - init :parser, :least - def _parse ctxt - result = [] - for i in (0...@least) - return false unless @parser._parse ctxt - result << ctxt.result - end - while(true) - ind = ctxt.index - if @parser._parse ctxt - result << ctxt.result - return ctxt.retn(result) if ind==ctxt.index # infinite loop - next - end - if ind==ctxt.index - return ctxt.retn(result) - else - return false - end - end - end -end - -class Some_Parser < Parser - init :parser, :least, :max - def _parse ctxt - for i in (0...@least) - return false unless @parser._parse ctxt - end - for i in (@least...@max) - ind = ctxt.index - if @parser._parse ctxt - return true if ind==ctxt.index # infinite loop - next - end - return ind==ctxt.index - end - return true - end -end - -class SomeParser < Parser - init :parser, :least, :max - def _parse ctxt - result = [] - for i in (0...@least) - return false unless @parser._parse ctxt - result << ctxt.result - end - for i in (@least...@max) - ind = ctxt.index - if @parser._parse ctxt - result << ctxt.result - return ctxt.retn(result) if ind==ctxt.index # infinite loop - next - end - if ind==ctxt.index - return ctxt.retn(result) - else - return false - end - end - return ctxt.retn(result) - end -end - -class OneParser < Parser - def _parse ctxt - true - end -end - -class ZeroParser < Parser - def _parse ctxt - return ctxt.failure - end -end - -class GetIndexParser < Parser - def _parse ctxt - ctxt.retn(ctxt.index) - end -end -class SetIndexParser < Parser - init :index - def _parse ctxt - ctxt.index = @index - end -end - -Nil = ValueParser.new(nil) - -end # module \ No newline at end of file diff --git a/vendor/gems/rparsec-1.0/rparsec/token.rb b/vendor/gems/rparsec-1.0/rparsec/token.rb deleted file mode 100644 index 30090af30c7..00000000000 --- a/vendor/gems/rparsec-1.0/rparsec/token.rb +++ /dev/null @@ -1,43 +0,0 @@ -require 'rparsec/misc' - -module RParsec - -# -# Represents a token during lexical analysis. -# -class Token - extend DefHelper - - def_ctor :kind, :text, :index - - # - # The type of the token - # - attr_reader :kind - - # - # The text of the matched range - # - attr_reader :text - - # - # The starting index of the matched range - # - attr_reader :index - - # - # The length of the token. - # - def length - @text.length - end - - # - # String representation of the token. - # - def to_s - "#{@kind}: #{@text}" - end -end - -end # module \ No newline at end of file diff --git a/vendor/gems/rparsec-1.0/test/src/expression_test.rb b/vendor/gems/rparsec-1.0/test/src/expression_test.rb deleted file mode 100644 index 1eebda9778f..00000000000 --- a/vendor/gems/rparsec-1.0/test/src/expression_test.rb +++ /dev/null @@ -1,124 +0,0 @@ -require 'import' -import :parsers, :functors, :expressions -require 'parser_test' - -class ExpressionParserTest < ParserTestCase - include Functors - def setup - @use_around = true - end - def around(p) - return p unless @use_around - delim = whitespace.many_ - p << delim; - end - def negate - around(char('-')) >> value(Neg) - end - def positive - around(char('+')) >> value(Id) - end - def increment - around(string('++') >> value(Inc)) - end - def decrement - around(string('--')) >> value(Dec) - end - def plus - around(char('+')) >> value(Plus) - end - def minus - around(char('-')) >> value(Minus) - end - def mul - around(char('*')) >> value(Mul) - end - def space_mul - not_among('+-*/%').peek >> value(Mul) - end - def div - around(char('/')) >> value(Div) - end - def rdiv - around(str('//')) >> value(Div) - end - def mod - around(char('%')) >> value(Mod) - end - def lparen - around(char('(')) - end - def rparen - around(char(')')) - end - def int - around(integer).map(&To_i) - end - def testPrefix - parser = whitespace.many_ >> int.prefix(negate) << eof - assertParser(' - -3 ', 3, parser) - assertParser(' 3', 3, parser) - assertParser('3 ', 3, parser) - assertParser('-3', -3, parser) - assertError(' - -', 'integer expected', parser, 4) - assertError(' - -5 3', 'EOF expected', parser, 6) - end - def testPostfix - parser = whitespace.many_ >> int.postfix(increment) << eof - assertParser(' 3++ ++', 5, parser) - assertParser('3++++ ', 5, parser) - assertParser(' 3', 3, parser) - assertError(' ++', 'integer expected', parser, 1) - assertError('5++ 3', 'EOF expected', parser, 4) - end - def testInfixn - parser = whitespace.many_ >> int.infixn(plus) << eof - assertParser(' 1 + 2 ', 3, parser) - assertParser('1 + 2 ', 3, parser) - assertError('1+2 +3', 'EOF expected', parser, 4) - end - def testInfixl - parser = whitespace.many_ >> int.infixl(minus) << eof - assertParser(' 1-2 -3 ', -4, parser) - assertParser('1 - 2 ', -1, parser) - assertParser('1 ', 1, parser) - assertError('1-2-3-', 'integer expected', parser, 6) - end - def testInfixr - parser = whitespace.many_ >> int.infixr(minus) << eof - assertParser(' 1-2 -3 ', 2, parser) - assertParser(' 1-2 -3-4 ', -2, parser) - assertParser('1 - 2 ', -1, parser) - assertParser('1 ', 1, parser) - assertError('1-2-3-', 'integer expected', parser, 6) - end - def testExpression - @use_around = false - ops = OperatorTable.new do |tbl| - tbl.infixl(plus, 20) - tbl.infixl(minus, 20) - tbl.infixl(mul, 40) - tbl.infixl(space_mul, 40) - tbl.infixl(div, 40) - tbl.prefix(negate, 60) - tbl.prefix(positive, 60) - tbl.postfix(increment, 50) - tbl.postfix(decrement, 50) - tbl.infixr(rdiv, 40) - end - expr = nil - term = int | char(?() >> lazy{expr} << char(?)) - delim = whitespace.many_ - expr = delim >> Expressions.build(term, ops, delim) - - assertParser('1', 1, expr) - assertParser('1+2', 3, expr) - assertParser('(1-2)', -1, expr) - assertParser('2-3* 2', -4, expr) - assertParser("\n ((2-3 )*-+2--) ", 3, expr) - assertParser('((2-3 )*-+2--/2//2) ', 3, expr) - assertParser('((2-3 )*-+2--/2//2--) ', 1, expr) - assertParser('((2-3 )*-+2--//4//2) ', 2, expr) - assertParser('((2-3 )*-+2--/2/2) ', 0, expr) - end -end \ No newline at end of file diff --git a/vendor/gems/rparsec-1.0/test/src/full_parser_test.rb b/vendor/gems/rparsec-1.0/test/src/full_parser_test.rb deleted file mode 100644 index 703da8e4422..00000000000 --- a/vendor/gems/rparsec-1.0/test/src/full_parser_test.rb +++ /dev/null @@ -1,95 +0,0 @@ -require 'import' -import :parsers, :keywords, :operators, :functors, :expressions -require 'parser_test' - -class FullParserTest < ParserTestCase - def calculate_simple_cases(val, cases, default) - cases.each do |cond, consequence| - # cond, consequence = *cs - return consequence if cond == val - end - default - end - def calculate_full_cases(cases, default) - cases.each do |cond, consequence| - return consequence if cond - end - default - end - def parser - keywords = Keywords.case_sensitive(%w{case when else end and or not true false}) - ops = Operators.new(%w{+ - * / % ++ -- == > < >= <= != : ( )}) - lexer = integer.token(:int)|keywords.lexer|ops.lexer - delim = whitespaces |comment_line('#') - lexeme = lexer.lexeme(delim) << eof - expr = nil - lazy_expr = lazy{expr} - compare = ops['>'] >> Gt | ops['<'] >> Lt | ops['>='] >> Ge | ops['<='] >> Le | - ops['=='] >> Eq | ops['!='] >> Ne - comparison = sequence(lazy_expr, compare, lazy_expr) {|e1,f,e2|f.call(e1,e2)} - bool = nil - lazy_bool = lazy{bool} - bool_term = keywords[:true] >> true | keywords[:false] >> false | - comparison | ops['('] >> lazy_bool << ops[')'] - bool_table = OperatorTable.new. - infixl(keywords[:or] >> Or, 20). - infixl(keywords[:and] >> And, 30). - infixl(keywords[:not] >> Not, 30) - - bool = Expressions.build(bool_term, bool_table) - simple_case = sequence(keywords[:when], lazy_expr, ops[':'], lazy_expr) do |w,cond,t,val| - [cond, val] - end - full_case = sequence(keywords[:when], bool, ops[':'], lazy_expr) do |w,cond,t,val| - [cond, val] - end - default_case = (keywords[:else] >> lazy_expr).optional - simple_when_then = sequence(lazy_expr, simple_case.many, default_case, - keywords[:end]) do |val, cases, default| - calculate_simple_cases(val, cases, default) - end - full_when_then = sequence(full_case.many, default_case, keywords[:end]) do |cases, default| - calculate_full_cases(cases, default) - end - case_expr = keywords[:case] >> (simple_when_then | full_when_then) - - term = token(:int, &To_i) | (ops['('] >> lazy_expr << ops[')']) | case_expr - table = OperatorTable.new. - infixl(ops['+'] >> Plus, 20). - infixl(ops['-'] >> Minus, 20). - infixl(ops['*'] >> Mul, 30). - infixl(ops['/'] >> Div, 30). - postfix(ops['++'] >> Inc, 40). - postfix(ops['--'] >> Dec, 40). - prefix(ops['-'] >> Neg, 50) - expr = Expressions.build(term, table) - lexeme.nested(expr << eof) - end - def verify(code, expected=eval(code)) - assertParser(code, expected, self.parser) - end - def testNumber - verify(' 1') - end - def testSimpleCalc - verify('1 - 2') - end - def testComplexCalculationWithComment - verify('2*15/-(5- -2) #this is test') - end - def testSimpleCaseWhen - verify('case 1 when 1: 0 else 1 end') - end - def testSimpleCaseWhenWithRegularCalc - verify('case 1 when 1*1: (1-2) when 3:4 end+1') - end - def testFullCaseWhen - assertParser('3*case when 1==0 and 1==1: 1 when 1==1 : 2 end', 6, parser) - begin - parser.parse('3*case when (1==0 and 1==1): 1 when 1==1 then 2 end') - fail('should have failed') - rescue ParserException => e - assert(e.message.include?(': expected, then at line 1, col 42')) - end - end -end \ No newline at end of file diff --git a/vendor/gems/rparsec-1.0/test/src/functor_test.rb b/vendor/gems/rparsec-1.0/test/src/functor_test.rb deleted file mode 100644 index cf5c2616ec1..00000000000 --- a/vendor/gems/rparsec-1.0/test/src/functor_test.rb +++ /dev/null @@ -1,66 +0,0 @@ -require 'import' -require 'runit/testcase' -import :parsers, :functors - -include RParsec -class Proc - include FunctorMixin -end -class Method - include FunctorMixin -end - -class FunctorTestCase < RUNIT::TestCase - include Functors - def verify(expected, f, *args) - assert_equal(expected, f.call(*args)) - end - def testConst - verify(1, const(1), 'a') - end - def testMethod - verify(true, 1.method(:kind_of?), Fixnum) - end - def testFlip - verify(1, Minus.flip, 1, 2) - end - def testCompose - verify(-3, Neg.compose(Plus), 1, 2) - verify(-3, Neg << Plus, 1, 2) - verify(-3, Plus >> Neg, 1, 2) - verify(3, Neg << Neg << Plus, 1, 2) - end - def testCurry - assert_equal(3, Plus.curry.call(1).call(2)) - assert_equal(-1, Minus.curry.call(1).call(2)) - end - def testReverse_curry - assert_equal(1, Minus.reverse_curry.call(1).call(2)) - end - def testUncurry - verify(-1, Minus.curry.uncurry, 1, 2) - end - def testReverse_uncurry - verify(-1, Minus.reverse_curry.reverse_uncurry, 1, 2) - verify(1, Minus.reverse_curry.uncurry, 1, 2) - verify(1, Minus.curry.reverse_uncurry, 1, 2) - end - def testRepeat - cnt=0 - inc = proc {cnt+=1} - n = 10 - verify(n, (inc*n)) - assert_equal(10, cnt) - end - def testPower - double = Mul.curry.call(2) - verify(8, double ** 3, 1) - verify(nil, double ** 0, 1) - end - def testNth - verify(2, nth(1), 1, 2, 3) - end - def testMethodIsMixedIn - verify(false, 1.method(:kind_of?).compose(Id), String) - end -end \ No newline at end of file diff --git a/vendor/gems/rparsec-1.0/test/src/import.rb b/vendor/gems/rparsec-1.0/test/src/import.rb deleted file mode 100644 index daa55217002..00000000000 --- a/vendor/gems/rparsec-1.0/test/src/import.rb +++ /dev/null @@ -1,5 +0,0 @@ -# $: << "#{File.dirname(__FILE__)}/../.." - -def import *names - names.each {|lib|require "rparsec/#{lib}"} -end \ No newline at end of file diff --git a/vendor/gems/rparsec-1.0/test/src/keyword_test.rb b/vendor/gems/rparsec-1.0/test/src/keyword_test.rb deleted file mode 100644 index abb709c805e..00000000000 --- a/vendor/gems/rparsec-1.0/test/src/keyword_test.rb +++ /dev/null @@ -1,28 +0,0 @@ -require 'import' -import :parsers, :keywords -require 'parser_test' - -class KeywordTestCase < ParserTestCase - Insensitive = Keywords.case_insensitive(%w{select from where group by order having}){|x|x.downcase} - Sensitive = Keywords.case_sensitive(%w{new delete if else then void int}){|x|x} - def verifySensitiveKeyword(code, keyword) - assertParser(code, keyword, Sensitive.lexer.lexeme.nested(Sensitive.parser(keyword))) - assertParser(code, keyword, Sensitive.lexer.lexeme.nested(Sensitive.parser(keyword.to_sym))) - end - def verifyInsensitiveKeyword(code, keyword) - assertParser(code, keyword.downcase, - Insensitive.lexer.lexeme.nested(Insensitive.parser(keyword))) - assertParser(code, keyword.downcase,Insensitive.lexer.lexeme.nested(Insensitive.parser(keyword.downcase.to_sym))) - end - def testCaseSensitiveKeywords - verifySensitiveKeyword('new int void', 'new') - end - def testCaseInsensitiveKeywords - verifyInsensitiveKeyword('select from where', 'SeleCt') - end - def testBasics - assert(!Insensitive.case_sensitive?) - assert(Sensitive.case_sensitive?) - assert(:keyword, Sensitive.keyword_symbol) - end -end \ No newline at end of file diff --git a/vendor/gems/rparsec-1.0/test/src/operator_test.rb b/vendor/gems/rparsec-1.0/test/src/operator_test.rb deleted file mode 100644 index 0c862231110..00000000000 --- a/vendor/gems/rparsec-1.0/test/src/operator_test.rb +++ /dev/null @@ -1,21 +0,0 @@ -require 'import' -import :parsers, :operators, :functors -require 'parser_test' - -class OperatorTestCase < ParserTestCase - Ops = Operators.new(%w{++ + - -- * / ~}, &Id) - def verifyToken(src, op) - verifyParser(src, op, Ops[op]) - end - def verifyParser(src, expected, parser) - assertParser(src, expected, Ops.lexer.lexeme.nested(parser)) - end - def testAll - verifyToken('++ -', '++') - verifyParser('++ + -- ++ - +', '-', - (Ops['++']|Ops['--']|Ops['+']).many_ >> Ops['-']) - end - def testSort - assert_equal(%w{+++ ++- ++ + --- -- -}, Operators.sort(%w{++ - + -- +++ ++- ---})) - end -end \ No newline at end of file diff --git a/vendor/gems/rparsec-1.0/test/src/parser_test.rb b/vendor/gems/rparsec-1.0/test/src/parser_test.rb deleted file mode 100644 index 6d9c6ee89eb..00000000000 --- a/vendor/gems/rparsec-1.0/test/src/parser_test.rb +++ /dev/null @@ -1,53 +0,0 @@ -require 'import' -require 'rubyunit' -import :parsers, :functors - -include RParsec - -class ParserTestCase < RUNIT::TestCase - include Functors - include Parsers - def assertParser(code, expected, parser) - assert_equal(expected, parser.parse(code)) - end - def assertError(code, expected, parser, index=0, line=1, col=1+index) - begin - parser.parse(code) - assert_fail("error should have happened") - rescue ParserException => e - assert_equal(index, e.index) - msg = expected - msg = add_encountered(msg, current(code,index)) << " at line #{line}, col #{col}." unless expected.include? 'at line' - assert_equal(msg, e.message) - end - end - def assertGrammar(code, expected, lexer, grammar) - assertParser(code, expected, lexer.nested(grammar)) - end - def assertGrammarError(code, expected, token_name, lexer, grammar, index=0, line=1, col=1+index) - parser = lexer.nested(grammar) - begin - parser.parse(code) - assert_fail("error should have happened") - rescue ParserException => e - assert_equal(index, e.index) - msg = expected - msg = "#{msg}, #{token_name}" << " at line #{line}, col #{col}." unless expected.include? 'at line' - assert_equal(msg, e.message) - end - end - def current(code, index) - return "EOF" if code.length <= index - c = code[index] - if c.kind_of? Fixnum - "'"<> Plus, 20) - tbl.infixl(char(?-) >> Minus, 20) - tbl.infixl(char(?*) >> Mul, 40) - tbl.infixl(char(?/) >> Div, 40) - tbl.prefix(char(?-) >> Neg, 60) - end - expr = nil - term = integer.map(&To_i) | char(?() >> lazy{expr} << char(?)) - delim = whitespace.many_ - expr = delim >> Expressions.build(term, ops, delim) - Benchmark.bm do |x| - x.report("parsing") {puts(expr.parse(code))} - end - end -end \ No newline at end of file diff --git a/vendor/gems/rparsec-1.0/test/src/s_expression_test.rb b/vendor/gems/rparsec-1.0/test/src/s_expression_test.rb deleted file mode 100644 index 190b9c4a7aa..00000000000 --- a/vendor/gems/rparsec-1.0/test/src/s_expression_test.rb +++ /dev/null @@ -1,33 +0,0 @@ -require 'import' -import :parsers, :functors, :expressions -require 'parser_test' - -class SExpressionTestCase < ParserTestCase - def delim - whitespace.many_ - end - def ignore parser - parser << delim - end - def lparen - ignore(char('(')) - end - def rparen - ignore(char(')')) - end - def parser - expr = nil - lazy_expr = lazy{expr} - term = number.map(&To_f) | lparen >> lazy_expr << rparen - binop = char('+') >> Plus | char('-') >> Minus | char('*') >> Mul | char('/') >> Div - binop = ignore binop - term = ignore term - binary = sequence(binop, lazy_expr, lazy_expr) do |op, e1, e2| - op.call(e1, e2) - end - expr = delim >> (term | binary) - end - def test1 - assertParser('- (+ 1 * 2 2.0) (1)', 4, parser) - end -end \ No newline at end of file diff --git a/vendor/gems/rparsec-1.0/test/src/scratch.rb b/vendor/gems/rparsec-1.0/test/src/scratch.rb deleted file mode 100644 index d641e2845d4..00000000000 --- a/vendor/gems/rparsec-1.0/test/src/scratch.rb +++ /dev/null @@ -1,41 +0,0 @@ -require 'benchmark' -require 'strscan' - -puts __FILE__ -str = '' -N = 10 -N.times{str << 'abc'} - -def scanner - StringScanner.new(str) -end - -ptn1 = /bc/ -ptn2 = /^bc/ - -Benchmark.bm do |x| - x.report("check with anchor") {N.times{StringScanner.new(str).scan(ptn2)}} - x.report("check without anchor") {N.times{StringScanner.new(str).scan(ptn1)}} - x.report("check_until with anchor") {N.times{StringScanner.new(str).check_until(ptn2)}} - x.report("check_until without anchor") {N.times{StringScanner.new(str).check_until(ptn1)}} - x.report("=~ with anchor") {N.times{ptn2 =~ str}} - x.report("=~ without anchor") {N.times{ptn1 =~ str[N/2,N]}} -end - -module X - def f1 - 'x1' - end - def method_missing n - puts "missing #{n}" - end - F2 = 'F2' - extend self -end -puts X::F2 -#puts X::f1 -#puts X.f1 -puts X::F2 -include X -puts F2 -puts X.F2 \ No newline at end of file diff --git a/vendor/gems/rparsec-1.0/test/src/simple_monad_test.rb b/vendor/gems/rparsec-1.0/test/src/simple_monad_test.rb deleted file mode 100644 index 8b2fa6d8033..00000000000 --- a/vendor/gems/rparsec-1.0/test/src/simple_monad_test.rb +++ /dev/null @@ -1,22 +0,0 @@ -require 'import' -require 'runit/testcase' -import :id_monad, :monad - -include RParsec -class Idm - include Monad - MyMonad = IdMonad.new - def initialize(v) - initMonad(MyMonad, v); - end - def to_s - @obj.to_s - end -end - -class SimpleMonadTest < RUNIT::TestCase - def test1 - assert 20, Idm.new(10).map{|i|i*2} - assert 10, Idm.new(10).plus(Idm.new(20)) - end -end diff --git a/vendor/gems/rparsec-1.0/test/src/simple_parser_test.rb b/vendor/gems/rparsec-1.0/test/src/simple_parser_test.rb deleted file mode 100644 index d6db578587d..00000000000 --- a/vendor/gems/rparsec-1.0/test/src/simple_parser_test.rb +++ /dev/null @@ -1,423 +0,0 @@ -require 'import' -import :parsers -require 'parser_test' - -class SimpleParserTest < ParserTestCase - def testValue - assertParser('', 1, value(1)) - end - def testFail - assertError('', 'wrong', failure('wrong')) - end - def testGoodPlusGoodReturnFirst - assertParser('', 1, value(1)|value(2)) - end - def testFailPlusGoodReturnGood - assertParser('', 2, failure('wrong')|value(2)) - end - def testFailPlusFailFailsWithFirstError - assertError('', 'wrong', failure('wrong') | failure('wrong too')) - end - def testFailBreaksSeq - assertError('', 'wrong', failure('wrong') >> value(2)) - end - def testGoodSeqGoodReturnsSecond - assertParser('', 2, value(1).seq(value(2))) - end - def testGoodSeqFailFails - assertError('', 'wrong', value(1) >> failure('wrong')) - end - def testFailSeqFailFails - assertError('', 'wrong', failure('wrong') >> failure('wrong too')) - end - def testMap - assertParser('', 2, value(1).map{|x|x*2}) - relative = Proc.new{|x|x-?a} - assertParser('b', 1, char('b').map(&relative)) - end - def testMapOnFailFails - assertError('', 'wrong', failure('wrong').map{|x|x*2}) - end - def testBinds - assertParser('', 3, value(1).bind do |a| - value(2).bind{|b|value(a+b)} - end) - assertParser('', 2, value(1).repeat(2).bindn do |a,b| - value(a+b) - end) - end - def testSum - assertParser('', 1, sum(value(1), value(2), value(3))) - end - def testNestedErrorRecoveredShouldNotAppearInFinalError - assertError('', 'wrong too', (failure('wrong') | value(1)) >> failure('wrong too')) - end - def testSatisfies - assertParser('abc', ?a, Parsers.satisfies('a expected'){|c|c==(?a)}) - assertError('abc', 'b expected', Parsers.satisfies('b expected'){|c|c==(?b)}) - end - def testIs - assertParser('abc', ?a, is(?a)) - assertError('abc', '98 expected', is(?b)) - end - def testIsnt - assertParser('abc', ?a, isnt(?b)) - assertError('abc', '97 unexpected', isnt(?a)) - assertError('abc', "'b' unexpected", not_char(?b) >> not_char('b'), 1) - end - def testCharAndEof - assertParser('abc', ?c, char('a') >> char('b') >> char('c') >> eof()) - end - def testAre - assertParser('abc', 'ab', string('ab')) - assertError('abc', '"ab" expected', char('a') >> str('ab'), 1) - end - def testSequence - assertParser('abc', ?c, sequence(char(?a),char('b'),char('c'))) - a = ?a - relative = proc {|c|c-a} - parser = sequence( - char('c').map(&relative), - char('b').map(&relative), - char('a').map(&relative) - ){|x,y,z| x+y+z} - assertParser('cba', 3, parser) - end - def testPlusAutomaticallyRecoverInputConsumption - assertError('abc', '"bcd" expected', char('a') >> str('bcd').plus(str('abc')), 1) - assertParser('abc', 'abc', char('a') >> str('bcd') | str('abc')) - assertError('abc', "'d' expected", char('a') >> char(?b) >> char(?d) | char(?a) >> char(?c) | str('abd'), 2) - end - def testLookaheadRecoversInputConsumption - assertParser('abc', 'abc', (char('x') | char('a') >> str('bcd') | str('abc') | char('x')).lookahead(2)) - end - def testLocator - line, col = CodeLocator.new("abc").locate(2) - assert_equal([1,3],[line,col]) - end - def testInputConsumptionBiggerThanLookaheadShouldFail - assertError('abc', "'d' expected", sum(str('ab')>>char('d'), str('abc')).lookahead(2), 2) - end - - def testInputConsumptionDoesNotFailForAlt - assertParser('abc', 'abc', alt(str('ab')>>char('d'), str('abc'))) - end - def testAtomParserIsAlwaysRecoverable - assertParser('abc', 'abc', (str('ab')>>char('d')).atomize | str('abc')) - end - def testSimpleNot - assertParser('abc', nil, str('abd').not) - assertError('abc', 'abc unexpected', str('abc').not) - end - def testNotDoesntConsume - assertParser('abc', 'abc', ~str('abc') | str('abc')) - end - def testNotDoesntRecoverAlreadyConsumedInputWhenFailingUnlessUsingLookahead - parser = (char('a') >> str('abc')).not - assertError('abc', '"abc" expected', parser, 1) - parser = parser.lookahead(2) - assertParser('abc', nil, parser) - end - def testLookeaheadUsedInPlusCanBeUsedByNot - parser = (char('a') >> str('abc') | char('a') >> str('bcd')).lookahead(2) - # assertError('abc', '"abc" expected or "bcd" expected', parser, 1) - assertError('abc', '"abc" expected', parser, 1) - assertParser('abc', nil, parser.not) - end - def testNotString - assertParser('abc', ?a, not_string('abcd')) - assertError('abc', '"abc" unexpected', not_string('abc')) - assertError('aabcd', '"abc" unexpected', not_string('abc')*2, 1) - end - def testArent - assertError('abc', 'abc unexpected', arent('abc')) - assertParser('abc', ?a, arent('abcd')) - end - def testAmong - assertParser('abc', ?a, among(?b, ?a)) - assertParser('abc', ?a, among('ba')) - assertError('abc', "one of [98, 99] expected", among(?b,?c)) - end - def testNotAmong - assertError('abc', "one of [98, 97] unexpected", not_among(?b, ?a)) - assertParser('abc', ?a, not_among(?b,?c)) - end - def testGetIndex - assertParser('abc', 1, char('a') >> get_index) - end - def testMultilineErrorMessage - assertError("ab\nc", "'d' expected", str("ab\nc") >> char(?d), 4, 2, 2) - end - def testExpect - assertError("abc", 'word expected', str("abcd").expect("word expected")) - end - def testExpectDoesntRecover - assertError('abc', '"bcd" expected', (char(?a) >> str('bcd')).expect('word expected'), 1) - end - def testLonger - assertParser('abc', 'abc', longer(char('a')>>char('b'), str('abc'))) - end - def testShorter - assertParser('abc', ?b, shorter(char('a')>>char('b')>>char('c'), char(?a) >> char(?c), char('a')>>char('b'))) - end - def testLongerReportsDeepestError - assertError('abc', "'d' expected", - longer(char('a')>>char('b')>>char('d'), char('a')>>char('c')), 2) - end - def testShorterReportsDeepestError - assertError('abc', "'d' expected", - shorter(char('a')>>char('b')>>char('d'), char('a')>>char('c')), 2) - end - def testFollowed - assertParser('abc', ?a, char(?a)<> char(?d), 3) - end - def testMany_ - assertParser('abc', ?c, any.many_) - assertParser('abc', ?c, any.many_(3)) - assertError('abc', "a..b expected", range(?a, ?b).many_(3), 2) - assertParser('abc', ?b, range(?a, ?b).many_()) - assertParser('abc', 1, value(1).many_()) - assertError('abc', "'b' expected", value(1).many_ >> char(?b)) - end - def testNonDeterministicRepeat_ - assertParser('abc', ?c, any.repeat_(3,4)) - assertParser('abc', ?b, any.some_(2)) - assertError('abc', "min=4, max=3", range(?a, ?b).repeat_(4,3)) - assertParser('abc', ?b, range(?a, ?b).some_(10)) - # should we break for infinite loop? they are not really infinite for some. - assertError('abc', "'b' expected", value(1).some_(2) >> char(?b)) - assertParser('abc', nil, any.some_(0)) - end - def testRange - assertParser('abc', ?a, range(?a, ?c)) - assertError('abc', 'd..e expected', range(?d, 'e')) - assertError('abc', 'c expected', range(?c, ?b, 'c expected')) - end - def testBetween - assertParser('abc', ?b, char(?a) >> char('b') << char(?c)) - end - def testRepeat - assertParser('abc', [?a, ?b, ?c], any.repeat(3)) - assertParser('abc', [?a, ?b], any.repeat(2)) - assertParser('abc', [], any.repeat(0)) - assertError('abc', '', any.repeat(4), 3) - assertError('abc', "a..b expected", range(?a, ?b).repeat(3), 2) - end - def testMany - assertParser('abc', [?a, ?b, ?c], any.many) - assertParser('abc', [?a, ?b], range(?a, ?b).many) - assertError('abc', '', any.many(4), 3) - end - def testSome - assertParser('abc', [?a, ?b, ?c], any.some(3)) - assertParser('abc', [?a, ?b], any.some(2)) - assertError('abc', "a..b expected", range(?a,?b).repeat(3,4), 2) - assertParser('abc', ?c, any.some(2) >> any) - end - def testSeparated1 - assertParser('a,b,c', [?a,?b,?c], any.separated1(char(','))) - assertParser('abc', [?a], any.separated1(char(','))) - assertError('a,', "'a' expected", char('a').separated1(char(',')), 2) - assertError('', '', any.separated1(char(','))) - end - def testSeparated - assertParser('a,b,c', [?a,?b,?c], any.separated(char(','))) - assertParser('abc', [?a], any.separated(char(','))) - assertError('a,', "'a' expected", char('a').separated(char(',')), 2) - assertParser('', [], any.separated(char(','))) - end - def testValueCalledImplicitlyForOverloadedOrOperator - assertParser('abc', 1, char(',')|1) - end - def testOptional - assertParser('abc', nil, char(?,).optional) - assertParser('abc', 'xyz', char(?,).optional('xyz')) - assertError('abc', "'.' expected", (any.some_(2) >> char(?.)).optional, 2) - # assertParser('abc', nil, (any.some_(2) >> char(?.)).optional) - end - def testThrowCatch - assertParser('abc', :hello, (char('a')>>throwp(:hello)).catchp(:hello)) - assertParser('abc', ?a, char(?a).catchp(:hello)) - end - def testDelimited1 - assertParser('a,b,c', [?a,?b,?c], any.delimited1(char(','))) - assertParser('abc', [?a], any.delimited1(char(','))) - assertParser('a,', [?a], char('a').delimited1(char(','))) - assertError('', '', any.delimited1(char(','))) - assertParser('a,b', ?b, char(?a).delimited1(char(',')) >> char(?b)) - end - def testDelimited - assertParser('a,b,c', [?a,?b,?c], any.delimited(char(','))) - assertParser('abc', [?a], any.delimited(char(','))) - assertParser('a,b,', [?a,?b], range('a', 'b').delimited(char(','))) - assertParser('', [], any.delimited(char(','))) - assertParser('a,b', ?b, char(?a).delimited(char(',')) >> char(?b)) - end - def testRegexp - assertParser('abc', 'ab', regexp('(a|b)+', 'a or b expected')) - assertError('abc', 'x or y expected', char('a') >> regexp('(x|y)+', 'x or y expected'), 1) - end - def testWord - assertParser('abc123', 'abc123', word) - assertError('1abc123', 'word expected', word) - assertParser('abc a123', 'a123', word >> char(' ') >> word) - end - def testInteger - assertParser('123', '123', integer) - assertError('a123', 'integer expected', integer) - assertError('123a', 'integer expected', integer) - end - def testNumber - assertParser('123.456', '123.456', number) - assertParser('0123', '0123', number) - assertParser('123.2.5', '5', number >> char('.') >> number) - assertError('a123', 'number expected', number) - end - def testStringCaseInsensitive - assertParser('abc', 'abc', string_nocase('ABc')) - assertError('abc', "'ABc' expected", string_nocase('A') >> string_nocase('ABc'), 1) - end - def testFragment - assertParser('abc', 'bc', any >> (any*2).fragment) - assertError('abc', "'b' expected", any >> (char('b')*2).fragment, 2) - end - def testToken - assertGrammar('abc', 'abcabc', word.token(:word).many, token(:word){|x|x+x}) - assertGrammar('abc defg', 1, word.token(:word).delimited(char(' ')), token(:word) >> token(:word) >> value(1)) - assertGrammarError('abc defg', 'integer expected', 'defg', word.token(:word).delimited(char(' ')), - token(:word) >> token(:integer), 4) - end - def testGetIndexFromGrammar - assertGrammar('abc cdef', 1, word.token(:word).many, token(:word) >> get_index) - end - def testWhitespace - assertParser(' ', ?\s, whitespace) - assertParser("\t", ?\t, whitespace) - assertParser("\n", ?\n, whitespace) - assertError('abc', 'whitespace expected', whitespace) - end - def testWhitespaces - assertParser(' ', ?\s, whitespaces) - assertParser("\n\t", ?\t, whitespaces) - assertError("\n \tabc ", "whitespace(s) expected, 'a' at line 2, col 3.", whitespaces >> whitespaces, 3) - end - def testCommentLineWithLexeme - assertParser('#abc', nil, comment_line('#')) - code = <<-HERE - //HELLO - 123 - HERE - delim = (comment_line('//')|whitespaces) - assertParser(code, ["123"], integer.lexeme(delim) >> eof) - assertParser('//', nil, comment_line('//')) - code = '123' - assertParser(code, ["123"], integer.lexeme(delim) >> eof) - - end - def testBlockComment - cmt =comment_block('/*', '*/') - assertParser('/*abc*/', nil, cmt) - assertError('/*abcd ', '"*/" expected', cmt, 7) - end - def testLazy - expr = nil - lazy_expr = lazy{expr} - expr = integer.map(&To_i) | char('(') >> lazy_expr << char(')') - assertParser('123', 123, expr) - assertParser('((123))', 123, expr) - end - def testPeek - assertParser('abc', ?a, char('a').peek) - assertParser('abc', ?a, char('a').peek.repeat_(2)) - assertError('abc', "'b' expected", char('a').peek >> char('b')) - end - def testParserTypeCheck - verifyTypeMismatch(:plus, '1st', Parser, String) do - char('a').plus('a') - end - verifyTypeMismatch(:seq, '1st', Parser, String) do - char('a').seq('a') - end - verifyTypeMismatch(:followed, '1st', Parser, String) do - char('a') << 'a' - end - verifyTypeMismatch(:sequence, '2nd', Parser, Fixnum) do - sequence(char('a'), 1, 2) - end - verifyTypeMismatch(:sum, '2nd', Parser, Fixnum) do - sum(char('a'), 1, 2) - end - verifyTypeMismatch(:longest, '2nd', Parser, Fixnum) do - longest(char('a'), 1, 2) - end - verifyTypeMismatch(:shortest, '2nd', Parser, Fixnum) do - shortest(char('a'), 1, 2) - end - end - def testSetIndex - parser = get_index.bind do |ind| - char('a') << set_index(ind) - end - assertParser('abc', [?a,?a,?a], parser.repeat(3)) - end - def testMapn - assertParser('abc', ?b, any.repeat(3).mapn{|a,b,c|c-b+a}) - end - def testWatch - i = nil - assertParser('abc', ?b, any.repeat_(2) >> watch{i=1}); - assert_equal(1, i) - assertParser('abc', ?b, any.repeat_(2) >> - watch{|x|assert_equal(?b, x)} - ) - assertParser('abc', [?a,?b], any.repeat(2) >> - watchn do |x,y| - assert_equal(?a, x) - assert_equal(?b, y) - end - ) - assertParser('abc', ?b, any.repeat_(2) >> watch); - end - def testMapCurrent - assertParser('abc', ?b, any >> map{|x|x+1}) - assertParser('abc', ?a, any >> map) - assertParser('abc', ?a, any.map) - assertParser('abc', ?a, any.mapn) - end - def testMapnCurrent - assertParser('abc', ?a, any.repeat(2) >> mapn{|a,_|a}) - assertParser('abc', ?c, any.repeat_(2) >> mapn(&Inc)) - assertParser('abc', [?a,?b], any.repeat(2) >> mapn) - end - def verifyTypeMismatch(mtd, n, expected, actual) - begin - yield - assert_fail('should have failed with type mismatch') - rescue ArgumentError => e - assert_equal("#{actual} assigned to #{expected} for the #{n} argument of #{mtd}.", - e.message) - end - end - def verifyArrayTypeMismatch(mtd, n_arg, n_elem, expected, actual) - begin - yield - assert_fail('should have failed with type mismatch') - rescue ArgumentError => e - assert_equal("#{actual} assigned to #{expected} for the #{n_elem} element of the #{n_arg} argument of #{mtd}.", - e.message) - end - end -end diff --git a/vendor/gems/rparsec-1.0/test/src/sql.rb b/vendor/gems/rparsec-1.0/test/src/sql.rb deleted file mode 100644 index 577674654eb..00000000000 --- a/vendor/gems/rparsec-1.0/test/src/sql.rb +++ /dev/null @@ -1,268 +0,0 @@ -require 'import' -import :misc - -include RParsec -class Module - include DefHelper -end -class Expr - def self.binary(*ops) - ops.each do |op| - define_method(op) do |other| - BinaryExpr.new(self, op, other) - end - end - end - binary :+,:-,:*,:/,:% - def -@ - PrefixExpr.new(:-, self) - end - def self.compare(*ops) - ops.each do |op| - define_method(op) do |other| - ComparePredicate.new(self, op, other) - end - end - end - compare :'==', :'>', :'<', :'>=', :'<=' -end -class LiteralExpr < Expr - def_readable :lit - def to_s - @lit.to_s - end -end -class VarExpr < Expr - def_readable :name - def to_s - "$#{name}" - end -end -class WordExpr < Expr - def_readable :name - def to_s - name - end -end -class QualifiedColumnExpr < Expr - def_readable :owner, :col - def to_s - "#{owner}.#{col}" - end -end -class WildcardExpr < Expr - Instance = WildcardExpr.new - def to_s - '*' - end -end -class BinaryExpr < Expr - def_readable :left, :op, :right - def to_s - "(#{left} #{op} #{right})" - end -end -class PostfixExpr < Expr - def_readable :expr, :op - def to_s - "(#{expr} #{op})" - end -end -class PrefixExpr < Expr - def_readable :op, :expr - def to_s - "(#{op} #{expr})" - end -end -def cases_string cases, default, result - cases.each do |cond, val| - result << " when #{cond}: #{val}" - end - unless default.nil? - result << " else #{default}" - end - result << " end" - result -end -class SimpleCaseExpr < Expr - def_readable :expr, :cases, :default - def to_s - cases_string cases, default, "case #{expr}" - end -end -class CaseExpr < Expr - def_readable :cases, :default - def to_s - cases_string cases, default, 'case' - end -end - - -############Predicate######################## -class Predicate -end - -class ComparePredicate < Predicate - def_readable :left, :op, :right - def to_s - "#{left} #{op_name} #{right}" - end - def op_name - case op when :"!=": "<>" else op.to_s end - end -end -class CompoundPredicate < Predicate - def_readable :left, :op, :right - def to_s - "(#{left} #{op} #{right})" - end -end -class NotPredicate < Predicate - def_readable :predicate - def to_s - "(not #{predicate})" - end -end -class ExistsPredicate < Predicate - def_readable :relation - def to_s - "exists(#{relation})" - end -end -class NotExistsPredicate < Predicate - def_readable :relation - def to_s - "not exists(#{relation})" - end -end -class InRelationPredicate < Predicate - def_readable :expr, :relation - def to_s - "#{expr} in (#{relation})" - end -end -class NotInRelationPredicate < Predicate - def_readable :expr, :relation - def to_s - "#{expr} not in (#{relation})" - end -end -class InPredicate < Predicate - def_readable :expr, :vals - def to_s - "#{expr} in (#{vals.join(', ')})" - end -end -class NotInPredicate < Predicate - def_readable :expr, :vals - def to_s - "#{expr} not in (#{vals.join(', ')})" - end -end -class BetweenPredicate < Predicate - def_readable :expr, :from, :to - def to_s - "#{expr} between #{from} and #{to}" - end -end -class NotBetweenPredicate < Predicate - def_readable :expr, :from, :to - def to_s - "#{expr} not between #{from} and #{to}" - end -end -class GroupComparisonPredicate < Predicate - def_readable :group1, :op, :group2 - def to_s - "#{list_exprs group1} #{op} #{list_exprs group2}" - end - def list_exprs exprs - "(#{exprs.join(', ')})" - end -end -#############Relations###################### - -class OrderElement - def_readable :expr, :asc - def to_s - result = "#{expr}" - unless asc - result << ' desc' - end - result - end -end -class GroupByClause - def_readable :exprs, :having - def to_s - result = exprs.join(', ') - unless having.nil? - result << " having #{having}" - end - result - end -end -class Relation - def as_inner - to_s - end -end -class TableRelation < Relation - def_readable :table - def to_s - table - end -end -class SelectRelation < Relation - def_readable :select, :distinct, :from, :where, :groupby, :orderby - def to_s - result = "select " - if distinct - result << 'distinct ' - end - result << "#{select.join(', ')} from #{from.as_inner}" - unless where.nil? - result << " where #{where}" - end - unless groupby.nil? - result << " group by #{groupby}" - end - unless orderby.nil? - result << " order by #{orderby.join(', ')}" - end - result - end - def as_inner - "(#{self})" - end -end -class LimitRelation < Relation - def_readable :rel, :limit - def to_s - "#{rel} limit #{limit}" - end -end -class JoinRelation < Relation - def_readable :kind, :left, :right, :on - def to_s - "#{left} #{kind} join #{right} on #{on}" - end -end -class CrossJoinRelation < Relation - def_readable :left, :right - def to_s - "#{left} cross join #{right}" - end -end -class AliasRelation < Relation - def_readable :relation, :name - def to_s - "#{relation.as_inner} AS #{name}" - end -end -class UnionRelation < Relation - def_readable :left, :all, :right - def to_s - "#{left} union #{case when all: 'all ' else '' end}#{right}" - end -end \ No newline at end of file diff --git a/vendor/gems/rparsec-1.0/test/src/sql_parser.rb b/vendor/gems/rparsec-1.0/test/src/sql_parser.rb deleted file mode 100644 index a8c50b7f30b..00000000000 --- a/vendor/gems/rparsec-1.0/test/src/sql_parser.rb +++ /dev/null @@ -1,258 +0,0 @@ -require 'import' -import :parsers, :keywords, :operators, :functors, :expressions - -include RParsec - -class Method - include FunctorMixin -end -class Proc - include FunctorMixin -end -module SqlParser - include Functors - include Parsers - extend Parsers - MyKeywords = Keywords.case_insensitive(%w{ - select from where group by having order desc asc - inner left right full outer inner join on cross - union all distinct as exists in between limit - case when else end and or not true false - }) - MyOperators = Operators.new(%w{+ - * / % = > < >= <= <> != : ( ) . ,}) - def self.operators(*ops) - result = [] - ops.each do |op| - result << (MyOperators[op] >> op.to_sym) - end - sum(*result) - end - Comparators = operators(*%w{= > < >= <= <> !=}) - StringLiteral = (char(?') >> (not_char(?')|str("''")).many_.fragment << char(?')). - map do |raw| - raw.gsub!(/''/,"'") - end - QuotedName = char(?[) >> not_char(?]).many_.fragment << char(?]) - Variable = char(?$) >> word - MyLexer = number.token(:number) | StringLiteral.token(:string) | Variable.token(:var) | QuotedName.token(:word) | - MyKeywords.lexer | MyOperators.lexer - MyLexeme = MyLexer.lexeme(whitespaces | comment_line('#')) << eof - - - ######################################### utilities ######################################### - def keyword - MyKeywords - end - def operator - MyOperators - end - def comma - operator[','] - end - def list expr - paren(expr.delimited(comma)) - end - def word(&block) - if block.nil? - token(:word, &Id) - else - token(:word, &block) - end - end - def paren parser - operator['('] >> parser << operator[')'] - end - def ctor cls - cls.method :new - end - def rctor cls, arity=2 - ctor(cls).reverse_curry arity - end - ################################### predicate parser ############################# - def logical_operator op - proc{|a,b|CompoundPredicate.new(a,op,b)} - end - def make_predicate expr, rel - expr_list = list expr - comparison = make_comparison_predicate expr, rel - group_comparison = sequence(expr_list, Comparators, expr_list, &ctor(GroupComparisonPredicate)) - bool = nil - lazy_bool = lazy{bool} - bool_term = keyword[:true] >> true | keyword[:false] >> false | - comparison | group_comparison | paren(lazy_bool) | - make_exists(rel) | make_not_exists(rel) - bool_table = OperatorTable.new. - infixl(keyword[:or] >> logical_operator(:or), 20). - infixl(keyword[:and] >> logical_operator(:and), 30). - prefix(keyword[:not] >> ctor(NotPredicate), 40) - bool = Expressions.build(bool_term, bool_table) - end - def make_exists rel - keyword[:exists] >> rel.map(&ctor(ExistsPredicate)) - end - def make_not_exists rel - keyword[:not] >> keyword[:exists] >> rel.map(&ctor(NotExistsPredicate)) - end - def make_in expr - keyword[:in] >> list(expr) >> map(&rctor(InPredicate)) - end - def make_not_in expr - keyword[:not] >> keyword[:in] >> list(expr) >> map(&rctor(NotInPredicate)) - end - def make_in_relation rel - keyword[:in] >> rel.map(&rctor(InRelationPredicate)) - end - def make_not_in_relation rel - keyword[:not] >> keyword[:in] >> rel.map(&rctor(NotInRelationPredicate)) - end - def make_between expr - make_between_clause(expr, &ctor(BetweenPredicate)) - end - def make_not_between expr - keyword[:not] >> make_between_clause(expr, &ctor(NotBetweenPredicate)) - end - def make_comparison_predicate expr, rel - comparison = sequence(Comparators, expr) do |op,e2| - proc{|e1|ComparePredicate.new(e1, op, e2)} - end - in_clause = make_in expr - not_in_clause = make_not_in expr - in_relation = make_in_relation rel - not_in_relation = make_not_in_relation rel - between = make_between expr - not_between = make_not_between expr - compare_with = comparison | in_clause | not_in_clause | - in_relation | not_in_relation | between | not_between - sequence(expr, compare_with, &Feed) - end - def make_between_clause expr, &maker - factory = proc do |a,_,b| - proc {|v|maker.call(v,a,b)} - end - variant1 = keyword[:between] >> paren(sequence(expr, comma, expr, &factory)) - variant2 = keyword[:between] >> sequence(expr, keyword[:and], expr, &factory) - variant1 | variant2 - end - - ################################ expression parser ############################### - def calculate_simple_cases(val, cases, default) - SimpleCaseExpr.new(val, cases, default) - end - def calculate_full_cases(cases, default) - CaseExpr.new(cases, default) - end - def make_expression predicate, rel - expr = nil - lazy_expr = lazy{expr} - simple_case = sequence(keyword[:when], lazy_expr, operator[':'], lazy_expr) do |_,cond,_,val| - [cond, val] - end - full_case = sequence(keyword[:when], predicate, operator[':'], lazy_expr) do |_,cond,_,val| - [cond, val] - end - default_case = (keyword[:else] >> lazy_expr).optional - simple_when_then = sequence(lazy_expr, simple_case.many, default_case, - keyword[:end]) do |val, cases, default, _| - calculate_simple_cases(val, cases, default) - end - full_when_then = sequence(full_case.many, default_case, keyword[:end]) do |cases, default, _| - calculate_full_cases(cases, default) - end - case_expr = keyword[:case] >> (simple_when_then | full_when_then) - wildcard = operator[:*] >> WildcardExpr::Instance - lit = token(:number, :string, &ctor(LiteralExpr)) | token(:var, &ctor(VarExpr)) - atom = lit | wildcard | - sequence(word, operator['.'], word|wildcard) {|owner, _, col| QualifiedColumnExpr.new owner, col} | - word(&ctor(WordExpr)) - term = atom | (operator['('] >> lazy_expr << operator[')']) | case_expr - table = OperatorTable.new. - infixl(operator['+'] >> Plus, 20). - infixl(operator['-'] >> Minus, 20). - infixl(operator['*'] >> Mul, 30). - infixl(operator['/'] >> Div, 30). - infixl(operator['%'] >> Mod, 30). - prefix(operator['-'] >> Neg, 50) - expr = Expressions.build(term, table) - end - - ################################ relation parser ############################### - def make_relation expr, pred - exprs = expr.delimited1(comma) - relation = nil - lazy_relation = lazy{relation} - term_relation = word {|w|TableRelation.new w} | operator['('] >> lazy_relation << operator[')'] - sub_relation = sequence(term_relation, (keyword[:as].optional >> word).optional) do |rel, name| - case when name.nil?: rel else AliasRelation.new(rel, name) end - end - joined_relation = sub_relation.postfix(join_maker(lazy{joined_relation}, pred)) - where_clause = keyword[:where] >> pred - order_element = sequence(expr, (keyword[:asc] >> true | keyword[:desc] >> false).optional(true), - &ctor(OrderElement)) - order_elements = order_element.separated1(comma) - exprs = expr.separated1(comma) - order_by_clause = keyword[:order] >> keyword[:by] >> order_elements - group_by = keyword[:group] >> keyword[:by] >> exprs - group_by_clause = sequence(group_by, (keyword[:having] >> pred).optional, &ctor(GroupByClause)) - relation = sub_relation | sequence(keyword[:select], - keyword[:distinct].optional(false), exprs, - keyword[:from], joined_relation, - where_clause.optional, group_by_clause.optional, order_by_clause.optional - ) do |_, distinct, projected, _, from, where, groupby, orderby| - SelectRelation.new(projected, distinct, from, where, groupby, orderby) - end - relation = sequence(relation, (keyword[:limit] >> token(:number, &To_i)).optional) do |rel, limit| - case when limit.nil?: rel else LimitRelation.new(rel, limit) end - end - relation = relation.infixl(union_maker) - end - def union_maker - keyword[:union] >> (keyword[:all]>>true|false).map do |all| - proc {|r1, r2|UnionRelation.new(r1, all, r2)} - end - end - def join_maker rel, pred - crossjoin = keyword[:cross] >> keyword[:join] >> rel.map(&rctor(CrossJoinRelation)) - leftjoin = outer_join :left - rightjoin = outer_join :right - fulljoin = outer_join :full - innerjoin = keyword[:inner].optional >> keyword[:join] >> :inner - join_with_condition = sequence(sum(leftjoin, rightjoin, innerjoin), rel, - keyword[:on], pred) do |kind, r, _, on| - proc{|r0|JoinRelation.new(kind, r0, r, on)} - end - sum(crossjoin, join_with_condition) - end - def outer_join kind - keyword[kind] >> keyword[:outer].optional >> keyword[:join] >> kind - end - - - - ########################## put together ############################### - def expression - assemble[0] - end - - def relation - assemble[2] - end - def predicate - assemble[1] - end - - def assemble - pred = nil - rel = nil - lazy_predicate = lazy{pred} - lazy_rel = lazy{rel} - expr = make_expression lazy_predicate, lazy_rel - pred = make_predicate expr, lazy_rel - rel = make_relation expr, pred - return expr, pred, rel - end - - - def make parser - MyLexeme.nested(parser << eof) - end -end \ No newline at end of file diff --git a/vendor/gems/rparsec-1.0/test/src/sql_test.rb b/vendor/gems/rparsec-1.0/test/src/sql_test.rb deleted file mode 100644 index f1453632141..00000000000 --- a/vendor/gems/rparsec-1.0/test/src/sql_test.rb +++ /dev/null @@ -1,128 +0,0 @@ -require 'parser_test' -require 'sql' -require 'sql_parser' -class SqlTestCase < ParserTestCase - include SqlParser - def verify_sql(code, expected, parser) - assert_equal(expected, make(parser).parse(code).to_s) - end - def verify_relation(code, expected) - verify_sql(code, expected, relation) - end - def verify_predicate(code, expected) - verify_sql(code, expected, predicate) - end - def testSimpleExpression - verify_sql('1+2+3', '((1 + 2) + 3)', expression) - end - def testExpressionWithBool - verify_sql('1+Case 2 when 1: x else dbo.y end', - '(1 + case 2 when 1: x else dbo.y end)', expression) - end - def testExpressionWithWildcard - verify_sql('a.*', 'a.*', expression) - end - def testSimpleRelation - verify_relation('select * from table1', 'select * from table1') - end - def testSimpleRelationWithStringLiteral - verify_relation("select 'a',* from table1", "select 'a', * from table1") - end - def testSimpleRelationWithVar - verify_relation("select $a,* from table1", "select $a, * from table1") - end - def testSimpleRelationWithQuotedName - # the print out isn't really valid. but we care about parser, not the printer. - verify_relation("select $a,* from [table 1]", "select $a, * from table 1") - end - def testSubRelation - verify_relation('select * from (select a, b, c.* from c)', - 'select * from (select a, b, c.* from c)') - end - def testSimpleRelationWithAlias - verify_relation('select x.* from table1 x', 'select x.* from table1 AS x') - end - def testSubRelationWithAlias - verify_relation('select * from ((select a, b, c.* from c)) x', - 'select * from (select a, b, c.* from c) AS x') - end - def testRelationWithWhere - verify_relation('select * from table where x=1', - 'select * from table where x = 1') - end - def testRelationWithWhereAndDistinct - verify_relation('select distinct * from table where x=1', - 'select distinct * from table where x = 1') - end - def testRelationWithCompoundPredicateInWhereClause - verify_relation('select * from table where x=1 and y=3', - 'select * from table where (x = 1 and y = 3)') - end - def testRelationWithOrderBy - verify_relation('select distinct * from table where x=1 order by x asc, y desc', - 'select distinct * from table where x = 1 order by x, y desc') - end - def testRelationWithOrderByAndLimit - verify_relation('select distinct * from table where x=1 order by x asc, y desc limit 5', - 'select distinct * from table where x = 1 order by x, y desc limit 5') - end - def testRelationWithGroupByWithoutHaving - verify_relation('select distinct * from table where x=1 group by x, y order by x asc, y desc', - 'select distinct * from table where x = 1 group by x, y order by x, y desc') - end - def testRelationWithGroupByWithHaving - verify_relation('select distinct * from table where x=1 group by x, y having x!=y order by x asc, y desc', - 'select distinct * from table where x = 1 group by x, y having x <> y order by x, y desc') - end - def testRelationWithSimpleJoin - verify_relation('select * from table1 t1 inner join table2 t2 on t1.a=t2.b where x=1', - 'select * from table1 AS t1 inner join table2 AS t2 on t1.a = t2.b where x = 1') - end - def testRelationWithMultiJoins - verify_relation('select * from table1 t1 inner join table2 t2 right outer join table3 on t2.x>t3.y on t1.a=t2.b cross join table3 where x=1', - 'select * from table1 AS t1 inner join table2 AS t2 right join table3 on t2.x > t3.y on t1.a = t2.b cross join table3 where x = 1') - end - def testRelationWithExists - verify_relation('select 1 from table1 where exists(select id from table2 where x=name)', - 'select 1 from table1 where exists(select id from table2 where x = name)') - end - def testRelationWithIn - verify_relation('select 1 from table1 where x in(1,2,3)', - 'select 1 from table1 where x in (1, 2, 3)') - end - def testRelationWithNotIn - verify_relation('select 1 from table1 where x not in(1,2,3)', - 'select 1 from table1 where x not in (1, 2, 3)') - end - def testRelationWithInRelation - verify_relation('select 1 from table1 where x in(select * from table)', - 'select 1 from table1 where x in (select * from table)') - end - def testRelationWithNotInRelation - verify_relation('select 1 from table1 where x not in table', - 'select 1 from table1 where x not in (table)') - end - def testRelationWithNotInRelationAndAmbiguousSubRelation - verify_relation('select 1 from table1 where x not in (table)', - 'select 1 from table1 where x not in (table)') - end - def testRelationWithBetween - verify_relation('select 1 from table1 where x between a and b', - 'select 1 from table1 where x between a and b') - end - def testRelationWithNotBetween - verify_relation('select 1 from table1 where x not between (a,b)', - 'select 1 from table1 where x not between a and b') - end - def testRelationWithGroupCompare - verify_relation('select 1 from table1 where not (a,b,c)>(1,2,3)', - 'select 1 from table1 where (not (a, b, c) > (1, 2, 3))') - end - def testUnion - verify_relation('select * from table1 where a=2 union select * from table2 where a=1', - 'select * from table1 where a = 2 union select * from table2 where a = 1') - end - def testAndOrNot - verify_predicate '1>1 or 1<=1 and not true', '(1 > 1 or (1 <= 1 and (not true)))' - end -end \ No newline at end of file diff --git a/vendor/gems/rparsec-1.0/test/src/tests.rb b/vendor/gems/rparsec-1.0/test/src/tests.rb deleted file mode 100644 index 06d3d5c2d2f..00000000000 --- a/vendor/gems/rparsec-1.0/test/src/tests.rb +++ /dev/null @@ -1,13 +0,0 @@ -%w{ - simple_monad - functor - simple_parser - operator - keyword - expression - s_expression - full_parser - sql -}.each do |name| - require "#{name}_test" -end \ No newline at end of file diff --git a/vendor/gems/ruby2ruby-1.2.5/.autotest b/vendor/gems/ruby2ruby-1.2.5/.autotest deleted file mode 100644 index 55bc6c347e9..00000000000 --- a/vendor/gems/ruby2ruby-1.2.5/.autotest +++ /dev/null @@ -1,26 +0,0 @@ -# -*- ruby -*- - -require 'autotest/restart' - -Autotest.add_hook :initialize do |at| - at.order = :random - at.testlib = "minitest/autorun" - - at.extra_files << "../../ParseTree/dev/test/pt_testcase.rb" - at.extra_files << "../../ParseTree/dev/lib/unified_ruby.rb" - at.libs << ":../../sexp_processor/dev/lib:../../ParseTree/dev/lib:../../ParseTree/dev/test" - - (1..4).each do |n| - at.extra_class_map["TestRuby2Ruby#{n}"] = "test/test_ruby2ruby.rb" - end - - at.add_mapping(/unified|pt_testcase/) do |f, _| - at.files_matching(/test.*rb$/) - end -end - -if ENV['RCOV'] then - require 'autotest/rcov' - Autotest::RCov.command = 'rcov_info' - Autotest::RCov.pattern = 'test/test_ruby2ruby.rb' -end diff --git a/vendor/gems/ruby2ruby-1.2.5/.specification b/vendor/gems/ruby2ruby-1.2.5/.specification deleted file mode 100644 index 3c81b2b9d8b..00000000000 --- a/vendor/gems/ruby2ruby-1.2.5/.specification +++ /dev/null @@ -1,194 +0,0 @@ ---- !ruby/object:Gem::Specification -name: ruby2ruby -version: !ruby/object:Gem::Version - hash: 21 - prerelease: false - segments: - - 1 - - 2 - - 5 - version: 1.2.5 -platform: ruby -authors: -- Ryan Davis -autorequire: -bindir: bin -cert_chain: -- | - -----BEGIN CERTIFICATE----- - MIIDPjCCAiagAwIBAgIBADANBgkqhkiG9w0BAQUFADBFMRMwEQYDVQQDDApyeWFu - ZC1ydWJ5MRkwFwYKCZImiZPyLGQBGRYJemVuc3BpZGVyMRMwEQYKCZImiZPyLGQB - GRYDY29tMB4XDTA5MDMwNjE4NTMxNVoXDTEwMDMwNjE4NTMxNVowRTETMBEGA1UE - AwwKcnlhbmQtcnVieTEZMBcGCgmSJomT8ixkARkWCXplbnNwaWRlcjETMBEGCgmS - JomT8ixkARkWA2NvbTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBALda - b9DCgK+627gPJkB6XfjZ1itoOQvpqH1EXScSaba9/S2VF22VYQbXU1xQXL/WzCkx - taCPaLmfYIaFcHHCSY4hYDJijRQkLxPeB3xbOfzfLoBDbjvx5JxgJxUjmGa7xhcT - oOvjtt5P8+GSK9zLzxQP0gVLS/D0FmoE44XuDr3iQkVS2ujU5zZL84mMNqNB1znh - GiadM9GHRaDiaxuX0cIUBj19T01mVE2iymf9I6bEsiayK/n6QujtyCbTWsAS9Rqt - qhtV7HJxNKuPj/JFH0D2cswvzznE/a5FOYO68g+YCuFi5L8wZuuM8zzdwjrWHqSV - gBEfoTEGr7Zii72cx+sCAwEAAaM5MDcwCQYDVR0TBAIwADALBgNVHQ8EBAMCBLAw - HQYDVR0OBBYEFEfFe9md/r/tj/Wmwpy+MI8d9k/hMA0GCSqGSIb3DQEBBQUAA4IB - AQAY59gYvDxqSqgC92nAP9P8dnGgfZgLxP237xS6XxFGJSghdz/nI6pusfCWKM8m - vzjjH2wUMSSf3tNudQ3rCGLf2epkcU13/rguI88wO6MrE0wi4ZqLQX+eZQFskJb/ - w6x9W1ur8eR01s397LSMexySDBrJOh34cm2AlfKr/jokKCTwcM0OvVZnAutaovC0 - l1SVZ0ecg88bsWHA0Yhh7NFxK1utWoIhtB6AFC/+trM0FQEB/jZkIS8SaNzn96Rl - n0sZEf77FLf5peR8TP/PtmIg7Cyqz23sLM4mCOoTGIy5OcZ8TdyiyINUHtb5ej/T - FBHgymkyj/AOSqKRIpXPhjC6 - -----END CERTIFICATE----- - -date: 2010-09-01 00:00:00 +03:00 -default_executable: r2r_show -dependencies: -- !ruby/object:Gem::Dependency - name: sexp_processor - prerelease: false - requirement: &id001 !ruby/object:Gem::Requirement - none: false - requirements: - - - ~> - - !ruby/object:Gem::Version - hash: 7 - segments: - - 3 - - 0 - version: "3.0" - type: :runtime - version_requirements: *id001 -- !ruby/object:Gem::Dependency - name: ruby_parser - prerelease: false - requirement: &id002 !ruby/object:Gem::Requirement - none: false - requirements: - - - ~> - - !ruby/object:Gem::Version - hash: 3 - segments: - - 2 - - 0 - version: "2.0" - type: :runtime - version_requirements: *id002 -- !ruby/object:Gem::Dependency - name: rubyforge - prerelease: false - requirement: &id003 !ruby/object:Gem::Requirement - none: false - requirements: - - - ">=" - - !ruby/object:Gem::Version - hash: 7 - segments: - - 2 - - 0 - - 4 - version: 2.0.4 - type: :development - version_requirements: *id003 -- !ruby/object:Gem::Dependency - name: minitest - prerelease: false - requirement: &id004 !ruby/object:Gem::Requirement - none: false - requirements: - - - ">=" - - !ruby/object:Gem::Version - hash: 9 - segments: - - 1 - - 7 - - 1 - version: 1.7.1 - type: :development - version_requirements: *id004 -- !ruby/object:Gem::Dependency - name: ParseTree - prerelease: false - requirement: &id005 !ruby/object:Gem::Requirement - none: false - requirements: - - - ~> - - !ruby/object:Gem::Version - hash: 7 - segments: - - 3 - - 0 - version: "3.0" - type: :development - version_requirements: *id005 -- !ruby/object:Gem::Dependency - name: hoe - prerelease: false - requirement: &id006 !ruby/object:Gem::Requirement - none: false - requirements: - - - ">=" - - !ruby/object:Gem::Version - hash: 19 - segments: - - 2 - - 6 - - 2 - version: 2.6.2 - type: :development - version_requirements: *id006 -description: |- - ruby2ruby provides a means of generating pure ruby code easily from - RubyParser compatible Sexps. This makes making dynamic language - processors in ruby easier than ever! -email: -- ryand-ruby@zenspider.com -executables: -- r2r_show -extensions: [] - -extra_rdoc_files: -- History.txt -- Manifest.txt -- README.txt -files: -- .autotest -- History.txt -- Manifest.txt -- README.txt -- Rakefile -- bin/r2r_show -- lib/ruby2ruby.rb -- test/test_ruby2ruby.rb -has_rdoc: true -homepage: http://seattlerb.rubyforge.org/ -licenses: [] - -post_install_message: -rdoc_options: -- --main -- README.txt -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: seattlerb -rubygems_version: 1.3.7 -signing_key: -specification_version: 3 -summary: ruby2ruby provides a means of generating pure ruby code easily from RubyParser compatible Sexps -test_files: -- test/test_ruby2ruby.rb diff --git a/vendor/gems/ruby2ruby-1.2.5/History.txt b/vendor/gems/ruby2ruby-1.2.5/History.txt deleted file mode 100644 index 44d175c5241..00000000000 --- a/vendor/gems/ruby2ruby-1.2.5/History.txt +++ /dev/null @@ -1,200 +0,0 @@ -=== 1.2.5 / 2010-09-01 - -* 4 minor enhancements: - - * Added braces to hash args surrounded if in a binary method call. - * Added rewrite_resbody to double check structure and freak if necessary. - * Added stress task - * rewrite_rescue now detects rescue with multiple arguments. - -* 2 bug fixes: - - * Fixed dstr/dregex/d* roundtripping problem - * Fixed up call arg processing to be more correct and to work with the new sexp form - -=== 1.2.4 / 2009-08-14 - -* 2 bug fixes: - - * Fixed all doco to use ruby_praser - * Fixed bin/r2r_show to use ruby_parser. oops - -=== 1.2.3 / 2009-06-23 - -* 4 minor enhancements: - - * Overhauled 4-generation tests to use RubyParser. Much cleaner - * Removed last of ParseTree. Fully switched to RubyParser. - * Switched to minitest - * Updated Rakefile to new hoe capabilities - -=== 1.2.2 / 2009-01-20 - -* 3 minor enhancements: - - * Added -s to display sexp before printing r2r - * Added a bunch of backslash and masgn tests. - * Refactored tests. - -* 4 bug fixes: - - * Fixed iters to deal with empty bodies. - * Fixed process_call for a number of cases incl [], []=, and args processing. - * Fixed process_hash to always generate braces if in arglist. - * Switched process_alias to producing alias again, needed for globals. - -=== 1.2.1 / 2008-11-04 - -* 1 bug fix: - - * Don't freak out and die if passed a c function defn. stupid rails. - -=== 1.2.0 / 2008-10-22 - -* 2 minor enhancements: - - * Removed all PT dependent code to PT project (see parse_tree_extensions.rb). - * Revamped. Got working with new unified ruby output. Much much cleaner. - -=== 1.1.9 / 2008-06-09 - -* 5 minor enhancements: - - * Added more defensive programming in the tests to make it work with 1.9 and rubinius better. - * Converted r2r_show to more plain parse style, no more discover_new_classes. - * Made Proc#to_sexp and #to_ruby more resiliant. - * Started to work on fallback to ruby_parser code. Should prolly do flog first. - * Updated rakefile and readme format for hoe. Much cleaner! - -* 6 bug fixes: - - * Added 1.9 fixes. - * Added code to tests to isolate rubyinline builds. - * Fixed miniunit-deprecated assertions - * Fixes for const2/3, esp in class names - * Renamed ProcStoreTmp#name to #new_name. dur. - * Skip proc tests in 1.9 since they require ParseTree. - -=== 1.1.8 / 2007-08-21 - -* 6 minor enhancements: - - * Added super awesome .autotest file. YAY! - * Removed nil.method_missing... too many ppl bitching about it. - * Renamed RubyToRuby (the class name) to Ruby2Ruby. - * Restructured self-translation tests so they were friendlier when dying. - * Strings are now always one line long only. - * Fully in sync with ParseTree and ruby_parser. - -* 2 bug fixes: - - * Fixed a number of issues/bugs discovered via ruby_parser. - * Cleaned out some dead code and hacks we don't need anymore. - -=== 1.1.7 / 2007-08-21 - -* 2 major enhancements: - - * Switched to ParseTree's UnifiedRuby... much much cleaner now! - * Made test_ruby2ruby MUCH more rigorous with circular testing. - -* 5 minor enhancements: - - * Add r2r_show command like parse_tree_show. - * Add parens for :block nodes as appropriate. May be overzealous. - * Make SexpAny work with #==. - * Removed calls to processor_stack / caller in favor of self.context. - * Some style differences, eschew rescue. - -* 6 bug fixes: - - * Fix R2R bug with masgn/argscat. - * Fixed a bug with new resbody unification. - * Fixes for changes to pt_testcase. - * Fixes the rest of the tests under strict sexp checking. - * Fixed some circular bugs, mostly by hacking them out, wrt operator precidence. - * Fixed trinary operator. - -=== 1.1.6 / 2007-06-05 - -* 2 minor enhancements: - - * Extended tests for dstr/dsym/drgx to test against embedded slashes and quotes. - * Updated for dasgn_curr changes to PT. - -* 2 bug fixes: - - * Fixed a bug with begin/rescue/ensure. - * Fixed argscat and blockpass bug. blah(42, *args, &block) handled. - -=== 1.1.5 / 2007-02-13 - -* 3 minor enhancements: - - * Can now heckle ActiveRecord::Base in full. - * Cleaned up 1-liner generating code. - * Made clean/simple rescues 1-liners. - -* 7 bug fixes: - - * Finally got the rest of block_pass working. - * Fixed block_pass on procs in iters. UGH! - * Fixed attrasgn in masgn. - * Fixed splat in masgn. - * Fixed unary/prefix methods. - * Fixed attrasgn for []= where there were multiple args inside []. - * Fixed a couple resbody bugs. - -=== 1.1.4 / 2007-01-15 - -* 4 minor enhancements: - - * Added some extra rewriting code and tests for various bmethods. Ugh. - * Added support for splatted block args. - * Refactored class/module and dsym/dstr. - * Short if/unless statements are now post-conditional expressions. - -* 4 bug fixes: - - * Finally fixed eric's nebulous proc code-in-goalposts bug. - * Fixed dasgn_curr so block's dasgn vars decl goes away (bug 7420). - * Fixed dmethod. I think the tests were bogus before. - * Fixed improper end in method rescues (bug 7396). - -=== 1.1.3 / 2006-12-20 - -* 1 minor enhancement - - * Unit tests do self-translation and retesting for 3 generations! Solid. BAM! - -* 1 bug fixes - - * iasgn inside masgn was totally borked in ruby2ruby. - -=== 1.1.2 / 2006-12-19 - -* 2 minor enhancements - - * Improved []= and [] to be more idiomatic. - * Support for nested whens (from when case has no expression). - -* 3 bug fixes - - * Fixed case output when there is no case expression. - * NEARLY have RubyToRuby self-cloning and passing tests again. - * Minor cleanup - -=== 1.1.1 / 2006-11-13 - -* 3 bug fixes - - * Fixed procs - * Cleaned return when no return values. - * Rewrote process_if. No more elsif but no more bugs. :) - -=== 1.1.0 / 2006-10-11 - -* 2 major enhancements - - * Released separately from ZenHacks. - * Major overhaul/audit from the new ParseTree test infrastructure. Very complete now. diff --git a/vendor/gems/ruby2ruby-1.2.5/Manifest.txt b/vendor/gems/ruby2ruby-1.2.5/Manifest.txt deleted file mode 100644 index a2ab5f041d9..00000000000 --- a/vendor/gems/ruby2ruby-1.2.5/Manifest.txt +++ /dev/null @@ -1,8 +0,0 @@ -.autotest -History.txt -Manifest.txt -README.txt -Rakefile -bin/r2r_show -lib/ruby2ruby.rb -test/test_ruby2ruby.rb diff --git a/vendor/gems/ruby2ruby-1.2.5/README.txt b/vendor/gems/ruby2ruby-1.2.5/README.txt deleted file mode 100644 index 81d0e9999fd..00000000000 --- a/vendor/gems/ruby2ruby-1.2.5/README.txt +++ /dev/null @@ -1,74 +0,0 @@ -= ruby2ruby - -* http://seattlerb.rubyforge.org/ -* http://rubyforge.org/projects/seattlerb - -== DESCRIPTION: - -ruby2ruby provides a means of generating pure ruby code easily from -RubyParser compatible Sexps. This makes making dynamic language -processors in ruby easier than ever! - -== FEATURES/PROBLEMS: - -* Clean, simple SexpProcessor generates ruby code from RubyParser compatible sexps. - -== SYNOPSYS: - - require 'rubygems' - require 'ruby2ruby' - require 'ruby_parser' - require 'pp' - - ruby = "def a\n puts 'A'\nend\n\ndef b\n a\nend" - parser = RubyParser.new - ruby2ruby = Ruby2Ruby.new - sexp = parser.process(ruby) - - pp sexp - - p ruby2ruby.process(sexp) - - ## outputs: - - s(:block, - s(:defn, - :a, - s(:args), - s(:scope, s(:block, s(:call, nil, :puts, s(:arglist, s(:str, "A")))))), - s(:defn, :b, s(:args), s(:scope, s(:block, s(:call, nil, :a, s(:arglist)))))) - "def a\n puts(\"A\")\nend\ndef b\n a\nend\n" - -== REQUIREMENTS: - -+ sexp_processor -+ ruby_parser - -== INSTALL: - -+ sudo gem install ruby2ruby - -== LICENSE: - -(The MIT License) - -Copyright (c) Ryan Davis, Seattle.rb - -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/ruby2ruby-1.2.5/Rakefile b/vendor/gems/ruby2ruby-1.2.5/Rakefile deleted file mode 100644 index a79e48077d1..00000000000 --- a/vendor/gems/ruby2ruby-1.2.5/Rakefile +++ /dev/null @@ -1,58 +0,0 @@ -# -*- ruby -*- - -require 'rubygems' -require 'hoe' - -Hoe.add_include_dirs("lib", - "../../ParseTree/dev/test", - "../../ruby_parser/dev/lib", - "../../sexp_processor/dev/lib") - -Hoe.plugin :seattlerb - -Hoe.spec 'ruby2ruby' do - developer 'Ryan Davis', 'ryand-ruby@zenspider.com' - - self.rubyforge_name = 'seattlerb' - - extra_deps << ["sexp_processor", "~> 3.0"] - extra_deps << ["ruby_parser", "~> 2.0"] - extra_dev_deps << ["ParseTree", "~> 3.0"] -end - -task :stress do - $: << "lib" - $: << "../../ruby_parser/dev/lib" - require "ruby_parser" - require "ruby2ruby" - require "pp" - - files = Dir["../../*/dev/**/*.rb"] - - warn "Stress testing against #{files.size} files" - parser = RubyParser.new - ruby2ruby = Ruby2Ruby.new - - bad = {} - - files.each do |file| - warn file - ruby = File.read(file) - - begin - sexp = parser.process(ruby, file) - - # $stderr.puts sexp.pretty_inspect - - ruby2ruby.process(sexp) - rescue Interrupt => e - raise e - rescue Exception => e - bad[file] = e - end - end - - pp bad -end - -# vim: syntax=ruby diff --git a/vendor/gems/ruby2ruby-1.2.5/bin/r2r_show b/vendor/gems/ruby2ruby-1.2.5/bin/r2r_show deleted file mode 100755 index 9ea00f48cbc..00000000000 --- a/vendor/gems/ruby2ruby-1.2.5/bin/r2r_show +++ /dev/null @@ -1,33 +0,0 @@ -#!/usr/bin/ruby -ws - -require 'rubygems' -require 'ruby2ruby' -require 'ruby_parser' - -$h ||= false -$s ||= false - -if $h then - puts "usage: #{File.basename $0} [options] [file...]" - puts "options:" - puts "-h : display usage" - puts "-s : print the sexp before displaying the translated ruby" - - exit 1 -end - -ARGV.push "-" if ARGV.empty? - -parser = RubyParser.new -ruby2ruby = Ruby2Ruby.new - -ARGV.each do |file| - ruby = file == "-" ? $stdin.read : File.read(file) - - sexp = parser.process(ruby, file) - - p sexp if $s - - puts ruby2ruby.process(sexp) -end - diff --git a/vendor/gems/ruby2ruby-1.2.5/lib/ruby2ruby.rb b/vendor/gems/ruby2ruby-1.2.5/lib/ruby2ruby.rb deleted file mode 100755 index baa3da93d67..00000000000 --- a/vendor/gems/ruby2ruby-1.2.5/lib/ruby2ruby.rb +++ /dev/null @@ -1,970 +0,0 @@ -#!/usr/bin/env ruby -w - -require 'rubygems' -require 'sexp_processor' - -class Ruby2Ruby < SexpProcessor - VERSION = '1.2.5' - LINE_LENGTH = 78 - - BINARY = [:<=>, :==, :<, :>, :<=, :>=, :-, :+, :*, :/, :%, :<<, :>>, :**] - - ## - # Nodes that represent assignment and probably need () around them. - - ASSIGN_NODES = [ - :dasgn, - :flip2, - :flip3, - :lasgn, - :masgn, - :attrasgn, - :op_asgn1, - :op_asgn2, - :op_asgn_and, - :op_asgn_or, - :return, - ] - - def initialize - super - @indent = " " - self.auto_shift_type = true - self.strict = true - self.expected = String - - @calls = [] - - # self.debug[:defn] = /zsuper/ - end - - ############################################################ - # Processors - - def process_alias(exp) - "alias #{process(exp.shift)} #{process(exp.shift)}" - end - - def process_and(exp) - "(#{process exp.shift} and #{process exp.shift})" - end - - def process_arglist(exp) # custom made node - code = [] - until exp.empty? do - code << process(exp.shift) - end - code.join ', ' - end - - def process_args(exp) - args = [] - - until exp.empty? do - arg = exp.shift - case arg - when Symbol then - args << arg - when Array then - case arg.first - when :block then - asgns = {} - arg[1..-1].each do |lasgn| - asgns[lasgn[1]] = process(lasgn) - end - - args.each_with_index do |name, index| - args[index] = asgns[name] if asgns.has_key? name - end - else - raise "unknown arg type #{arg.first.inspect}" - end - else - raise "unknown arg type #{arg.inspect}" - end - end - - return "(#{args.join ', '})" - end - - def process_array(exp) - "[#{process_arglist(exp)}]" - end - - def process_attrasgn(exp) - receiver = process exp.shift - name = exp.shift - args = exp.empty? ? nil : exp.shift - - case name - when :[]= then - rhs = process args.pop - "#{receiver}[#{process(args)}] = #{rhs}" - else - name = name.to_s.sub(/=$/, '') - if args && args != s(:arglist) then - "#{receiver}.#{name} = #{process(args)}" - end - end - end - - def process_back_ref(exp) - "$#{exp.shift}" - end - - # TODO: figure out how to do rescue and ensure ENTIRELY w/o begin - def process_begin(exp) - code = [] - code << "begin" - until exp.empty? - src = process(exp.shift) - src = indent(src) unless src =~ /(^|\n)rescue/ # ensure no level 0 rescues - code << src - end - code << "end" - return code.join("\n") - end - - def process_block(exp) - result = [] - - exp << nil if exp.empty? - until exp.empty? do - code = exp.shift - if code.nil? or code.first == :nil then - result << "# do nothing" - else - result << process(code) - end - end - - result = result.join "\n" - - result = case self.context[1] - when nil, :scope, :if, :iter, :resbody, :when, :while then - result + "\n" - else - "(#{result})" - end - - return result - end - - def process_block_pass exp - raise "huh?: #{exp.inspect}" if exp.size > 1 - - "&#{process exp.shift}" - end - - def process_break(exp) - val = exp.empty? ? nil : process(exp.shift) - # HACK "break" + (val ? " #{val}" : "") - if val then - "break #{val}" - else - "break" - end - end - - def process_call(exp) - receiver_node_type = exp.first.nil? ? nil : exp.first.first - receiver = process exp.shift - - receiver = "(#{receiver})" if - Ruby2Ruby::ASSIGN_NODES.include? receiver_node_type - - name = exp.shift - args = [] - - # this allows us to do both old and new sexp forms: - exp.push(*exp.pop[1..-1]) if exp.size == 1 && exp.first.first == :arglist - - @calls.push name - - in_context :arglist do - until exp.empty? do - arg = process exp.shift - args << arg unless arg.empty? - end - end - - case name - when *BINARY then - "(#{receiver} #{name} #{args.join(', ')})" - when :[] then - receiver ||= "self" - "#{receiver}[#{args.join(', ')}]" - when :[]= then - receiver ||= "self" - rhs = args.pop - "#{receiver}[#{args.join(', ')}] = #{rhs}" - when :"-@" then - "-#{receiver}" - when :"+@" then - "+#{receiver}" - else - args = nil if args.empty? - args = "(#{args.join(', ')})" if args - receiver = "#{receiver}." if receiver - - "#{receiver}#{name}#{args}" - end - ensure - @calls.pop - end - - def process_case(exp) - result = [] - expr = process exp.shift - if expr then - result << "case #{expr}" - else - result << "case" - end - until exp.empty? - pt = exp.shift - if pt and pt.first == :when - result << "#{process(pt)}" - else - code = indent(process(pt)) - code = indent("# do nothing") if code =~ /^\s*$/ - result << "else\n#{code}" - end - end - result << "end" - result.join("\n") - end - - def process_cdecl(exp) - lhs = exp.shift - lhs = process lhs if Sexp === lhs - unless exp.empty? then - rhs = process(exp.shift) - "#{lhs} = #{rhs}" - else - lhs.to_s - end - end - - def process_class(exp) - "class #{util_module_or_class(exp, true)}" - end - - def process_colon2(exp) - "#{process(exp.shift)}::#{exp.shift}" - end - - def process_colon3(exp) - "::#{exp.shift}" - end - - def process_const(exp) - exp.shift.to_s - end - - def process_cvar(exp) - "#{exp.shift}" - end - - def process_cvasgn(exp) - "#{exp.shift} = #{process(exp.shift)}" - end - - def process_cvdecl(exp) - "#{exp.shift} = #{process(exp.shift)}" - end - - def process_defined(exp) - "defined? #{process(exp.shift)}" - end - - def process_defn(exp) - type1 = exp[1].first - type2 = exp[2].first rescue nil - - if type1 == :args and [:ivar, :attrset].include? type2 then - name = exp.shift - case type2 - when :ivar then - exp.clear - return "attr_reader #{name.inspect}" - when :attrset then - exp.clear - return "attr_writer :#{name.to_s[0..-2]}" - else - raise "Unknown defn type: #{exp.inspect}" - end - end - - case type1 - when :scope, :args then - name = exp.shift - args = process(exp.shift) - args = "" if args == "()" - body = [] - until exp.empty? do - body << indent(process(exp.shift)) - end - body = body.join("\n") - return "def #{name}#{args}\n#{body}\nend".gsub(/\n\s*\n+/, "\n") - else - raise "Unknown defn type: #{type1} for #{exp.inspect}" - end - end - - def process_defs(exp) - lhs = exp.shift - var = [:self, :cvar, :dvar, :ivar, :gvar, :lvar].include? lhs.first - name = exp.shift - - lhs = process(lhs) - lhs = "(#{lhs})" unless var - - exp.unshift "#{lhs}.#{name}" - process_defn(exp) - end - - def process_dot2(exp) - "(#{process exp.shift}..#{process exp.shift})" - end - - def process_dot3(exp) - "(#{process exp.shift}...#{process exp.shift})" - end - - def process_dregx(exp) - "/" << util_dthing(:dregx, exp) << "/" - end - - def process_dregx_once(exp) - process_dregx(exp) + "o" - end - - def process_dstr(exp) - "\"#{util_dthing(:dstr, exp)}\"" - end - - def process_dsym(exp) - ":\"#{util_dthing(:dsym, exp)}\"" - end - - def process_dxstr(exp) - "`#{util_dthing(:dxstr, exp)}`" - end - - def process_ensure(exp) - body = process exp.shift - ens = exp.shift - ens = nil if ens == s(:nil) - ens = process(ens) || "# do nothing" - - body.sub!(/\n\s*end\z/, '') - - return "#{body}\nensure\n#{indent ens}" - end - - def process_evstr(exp) - exp.empty? ? '' : process(exp.shift) - end - - def process_false(exp) - "false" - end - - def process_flip2(exp) - "#{process(exp.shift)}..#{process(exp.shift)}" - end - - def process_flip3(exp) - "#{process(exp.shift)}...#{process(exp.shift)}" - end - - def process_for(exp) - recv = process exp.shift - iter = process exp.shift - body = exp.empty? ? nil : process(exp.shift) - - result = ["for #{iter} in #{recv} do"] - result << indent(body ? body : "# do nothing") - result << "end" - - result.join("\n") - end - - def process_gasgn(exp) - process_iasgn(exp) - end - - def process_gvar(exp) - return exp.shift.to_s - end - - def process_hash(exp) - result = [] - until exp.empty? - lhs = process(exp.shift) - rhs = exp.shift - t = rhs.first - rhs = process rhs - rhs = "(#{rhs})" unless [:lit, :str].include? t # TODO: verify better! - - result << "#{lhs} => #{rhs}" - end - - case self.context[1] - when :arglist, :argscat then - unless result.empty? then - # HACK - this will break w/ 2 hashes as args - if BINARY.include? @calls.last then - return "{ #{result.join(', ')} }" - else - return "#{result.join(', ')}" - end - else - return "{}" - end - else - return "{ #{result.join(', ')} }" - end - end - - def process_iasgn(exp) - lhs = exp.shift - if exp.empty? then # part of an masgn - lhs.to_s - else - "#{lhs} = #{process exp.shift}" - end - end - - def process_if(exp) - expand = Ruby2Ruby::ASSIGN_NODES.include? exp.first.first - c = process exp.shift - t = process exp.shift - f = process exp.shift - - c = "(#{c.chomp})" if c =~ /\n/ - - if t then - unless expand then - if f then - r = "#{c} ? (#{t}) : (#{f})" - r = nil if r =~ /return/ # HACK - need contextual awareness or something - else - r = "#{t} if #{c}" - end - return r if r and (@indent+r).size < LINE_LENGTH and r !~ /\n/ - end - - r = "if #{c} then\n#{indent(t)}\n" - r << "else\n#{indent(f)}\n" if f - r << "end" - - r - else - unless expand then - r = "#{f} unless #{c}" - return r if (@indent+r).size < LINE_LENGTH and r !~ /\n/ - end - "unless #{c} then\n#{indent(f)}\nend" - end - end - - def process_iter(exp) - iter = process exp.shift - args = exp.shift - args = (args == 0) ? '' : process(args) - body = exp.empty? ? nil : process(exp.shift) - - b, e = if iter == "END" then - [ "{", "}" ] - else - [ "do", "end" ] - end - - iter.sub!(/\(\)$/, '') - - # REFACTOR: ugh - result = [] - result << "#{iter} {" - result << " |#{args}|" if args - if body then - result << " #{body.strip} " - else - result << ' ' - end - result << "}" - result = result.join - return result if result !~ /\n/ and result.size < LINE_LENGTH - - result = [] - result << "#{iter} #{b}" - result << " |#{args}|" if args - result << "\n" - if body then - result << indent(body.strip) - result << "\n" - end - result << e - result.join - end - - def process_ivar(exp) - exp.shift.to_s - end - - def process_lasgn(exp) - s = "#{exp.shift}" - s += " = #{process exp.shift}" unless exp.empty? - s - end - - def process_lit(exp) - obj = exp.shift - case obj - when Range then - "(#{obj.inspect})" - else - obj.inspect - end - end - - def process_lvar(exp) - exp.shift.to_s - end - - def splat(sym) - :"*#{sym}" - end - - def process_masgn(exp) - lhs = exp.shift - rhs = exp.empty? ? nil : exp.shift - - case lhs.first - when :array then - lhs.shift - lhs = lhs.map do |l| - case l.first - when :masgn then - "(#{process(l)})" - else - process(l) - end - end - when :lasgn then - lhs = [ splat(lhs.last) ] - when :splat then - lhs = [ :"*" ] - else - raise "no clue: #{lhs.inspect}" - end - - if context[1] == :iter and rhs then - lhs << splat(rhs[1]) - rhs = nil - end - - unless rhs.nil? then - t = rhs.first - rhs = process rhs - rhs = rhs[1..-2] if t == :array # FIX: bad? I dunno - return "#{lhs.join(", ")} = #{rhs}" - else - return lhs.join(", ") - end - end - - def process_match(exp) - "#{process(exp.shift)}" - end - - def process_match2(exp) - lhs = process(exp.shift) - rhs = process(exp.shift) - "#{lhs} =~ #{rhs}" - end - - def process_match3(exp) - rhs = process(exp.shift) - lhs = process(exp.shift) - "#{lhs} =~ #{rhs}" - end - - def process_module(exp) - "module #{util_module_or_class(exp)}" - end - - def process_next(exp) - val = exp.empty? ? nil : process(exp.shift) - if val then - "next #{val}" - else - "next" - end - end - - def process_nil(exp) - "nil" - end - - def process_not(exp) - "(not #{process exp.shift})" - end - - def process_nth_ref(exp) - "$#{exp.shift}" - end - - def process_op_asgn1(exp) - # [[:lvar, :b], [:arglist, [:lit, 1]], :"||", [:lit, 10]] - lhs = process(exp.shift) - index = process(exp.shift) - msg = exp.shift - rhs = process(exp.shift) - - "#{lhs}[#{index}] #{msg}= #{rhs}" - end - - def process_op_asgn2(exp) - # [[:lvar, :c], :var=, :"||", [:lit, 20]] - lhs = process(exp.shift) - index = exp.shift.to_s[0..-2] - msg = exp.shift - - rhs = process(exp.shift) - - "#{lhs}.#{index} #{msg}= #{rhs}" - end - - def process_op_asgn_and(exp) - # a &&= 1 - # [[:lvar, :a], [:lasgn, :a, [:lit, 1]]] - exp.shift - process(exp.shift).sub(/\=/, '&&=') - end - - def process_op_asgn_or(exp) - # a ||= 1 - # [[:lvar, :a], [:lasgn, :a, [:lit, 1]]] - exp.shift - process(exp.shift).sub(/\=/, '||=') - end - - def process_or(exp) - "(#{process exp.shift} or #{process exp.shift})" - end - - def process_postexe(exp) - "END" - end - - def process_redo(exp) - "redo" - end - - def process_resbody exp - args = exp.shift - body = process(exp.shift) || "# do nothing" - - name = args.lasgn true - name ||= args.iasgn true - args = process(args)[1..-2] - args = " #{args}" unless args.empty? - args += " => #{name[1]}" if name - - "rescue#{args}\n#{indent body}" - end - - def process_rescue exp - body = process(exp.shift) unless exp.first.first == :resbody - els = process(exp.pop) unless exp.last.first == :resbody - - body ||= "# do nothing" - simple = exp.size == 1 - - resbodies = [] - until exp.empty? do - resbody = exp.shift - simple &&= resbody[1] == s(:array) && resbody[2] != nil - resbodies << process(resbody) - end - - if els then - "#{indent body}\n#{resbodies.join("\n")}\nelse\n#{indent els}" - elsif simple then - resbody = resbodies.first.sub(/\n\s*/, ' ') - "#{body} #{resbody}" - else - "#{indent body}\n#{resbodies.join("\n")}" - end - end - - def process_retry(exp) - "retry" - end - - def process_return(exp) - # HACK return "return" + (exp.empty? ? "" : " #{process exp.shift}") - - if exp.empty? then - return "return" - else - return "return #{process exp.shift}" - end - end - - def process_sclass(exp) - "class << #{process(exp.shift)}\n#{indent(process(exp.shift))}\nend" - end - - def process_scope(exp) - exp.empty? ? "" : process(exp.shift) - end - - def process_self(exp) - "self" - end - - def process_splat(exp) - if exp.empty? then - "*" - else - "*#{process(exp.shift)}" - end - end - - def process_str(exp) - return exp.shift.dump - end - - def process_super(exp) - args = [] - until exp.empty? do - args << process(exp.shift) - end - - "super(#{args.join(', ')})" - end - - def process_svalue(exp) - code = [] - until exp.empty? do - code << process(exp.shift) - end - code.join(", ") - end - - def process_to_ary(exp) - process(exp.shift) - end - - def process_true(exp) - "true" - end - - def process_undef(exp) - "undef #{process(exp.shift)}" - end - - def process_until(exp) - cond_loop(exp, 'until') - end - - def process_valias(exp) - "alias #{exp.shift} #{exp.shift}" - end - - def process_when(exp) - src = [] - - if self.context[1] == :array then # ugh. matz! why not an argscat?!? - val = process(exp.shift) - exp.shift # empty body - return "*#{val}" - end - - until exp.empty? - cond = process(exp.shift).to_s[1..-2] - code = indent(process(exp.shift)) - code = indent "# do nothing" if code =~ /\A\s*\Z/ - src << "when #{cond} then\n#{code.chomp}" - end - - src.join("\n") - end - - def process_while(exp) - cond_loop(exp, 'while') - end - - def process_xstr(exp) - "`#{process_str(exp)[1..-2]}`" - end - - def process_yield(exp) - args = [] - until exp.empty? do - args << process(exp.shift) - end - - unless args.empty? then - "yield(#{args.join(', ')})" - else - "yield" - end - end - - def process_zsuper(exp) - "super" - end - - def cond_loop(exp, name) - cond = process(exp.shift) - body = process(exp.shift) - head_controlled = exp.shift - - body = indent(body).chomp if body - - code = [] - if head_controlled then - code << "#{name} #{cond} do" - code << body if body - code << "end" - else - code << "begin" - code << body if body - code << "end #{name} #{cond}" - end - code.join("\n") - end - - ############################################################ - # Rewriters: - - def rewrite_attrasgn exp - if context.first(2) == [:array, :masgn] then - exp[0] = :call - exp[2] = exp[2].to_s.sub(/=$/, '').to_sym - end - - exp - end - - def rewrite_ensure exp - exp = s(:begin, exp) unless context.first == :begin - exp - end - - def rewrite_resbody exp - raise "no exception list in #{exp.inspect}" unless exp.size > 2 && exp[1] - raise exp[1].inspect if exp[1][0] != :array - # for now, do nothing, just check and freak if we see an errant structure - exp - end - - def rewrite_rescue exp - complex = false - complex ||= exp.size > 3 - complex ||= exp.block - complex ||= exp.find_nodes(:resbody).any? { |n| n[1] != s(:array) } - complex ||= exp.find_nodes(:resbody).any? { |n| n.last.nil? } - - handled = context.first == :ensure - - exp = s(:begin, exp) if complex unless handled - - exp - end - - def rewrite_svalue(exp) - case exp.last.first - when :array - s(:svalue, *exp[1][1..-1]) - when :splat - exp - else - raise "huh: #{exp.inspect}" - end - end - - ############################################################ - # Utility Methods: - - def dthing_escape type, lit - lit = lit.gsub(/\n/, '\n') - case type - when :dregx then - lit.gsub(/(\A|[^\\])\//, '\1\/') - when :dstr, :dsym then - lit.gsub(/"/, '\"') - when :dxstr then - lit.gsub(/`/, '\`') - else - raise "unsupported type #{type.inspect}" - end - end - - def util_dthing(type, exp) - s = [] - - # first item in sexp is a string literal - s << dthing_escape(type, exp.shift) - - until exp.empty? - pt = exp.shift - case pt - when Sexp then - case pt.first - when :str then - s << dthing_escape(type, pt.last) - when :evstr then - s << '#{' << process(pt) << '}' # do not use interpolation here - else - raise "unknown type: #{pt.inspect}" - end - else - # HACK: raise "huh?: #{pt.inspect}" -- hitting # constants in regexps - # do nothing for now - end - end - - s.join - end - - def util_module_or_class(exp, is_class=false) - result = [] - - name = exp.shift - name = process name if Sexp === name - - result << name - - if is_class then - superk = process(exp.shift) - result << " < #{superk}" if superk - end - - result << "\n" - - body = [] - begin - code = process(exp.shift) - body << code.chomp unless code.nil? or code.chomp.empty? - end until exp.empty? - - unless body.empty? then - body = indent(body.join("\n\n")) + "\n" - else - body = "" - end - result << body - result << "end" - - result.join - end - - def indent(s) - s.to_s.split(/\n/).map{|line| @indent + line}.join("\n") - end -end diff --git a/vendor/gems/ruby2ruby-1.2.5/test/test_ruby2ruby.rb b/vendor/gems/ruby2ruby-1.2.5/test/test_ruby2ruby.rb deleted file mode 100644 index 8d7156beb80..00000000000 --- a/vendor/gems/ruby2ruby-1.2.5/test/test_ruby2ruby.rb +++ /dev/null @@ -1,262 +0,0 @@ -#!/usr/local/bin/ruby -w - -$TESTING = true - -$: << 'lib' - -require 'minitest/autorun' -require 'ruby2ruby' -require 'pt_testcase' -require 'fileutils' -require 'tmpdir' - -class R2RTestCase < ParseTreeTestCase - def self.previous key - "ParseTree" - end - - def self.generate_test klass, node, data, input_name, output_name - output_name = data.has_key?('Ruby2Ruby') ? 'Ruby2Ruby' : 'Ruby' - - klass.class_eval <<-EOM - def test_#{node} - pt = #{data[input_name].inspect} - rb = #{data[output_name].inspect} - - refute_nil pt, \"ParseTree for #{node} undefined\" - refute_nil rb, \"Ruby for #{node} undefined\" - - assert_equal rb, @processor.process(pt) - end - EOM - end -end - -start = __LINE__ - -class TestRuby2Ruby < R2RTestCase - def setup - super - @processor = Ruby2Ruby.new - end - - def test_util_dthing_dregx - inn = util_thingy(:dregx) - inn.shift - out = '/a"b#{(1 + 1)}c"d\/e/' - exp = /a"b2c"d\/e/ - - assert_equal exp, eval(out) - - assert_equal out[1..-2], @processor.util_dthing(:dregx, inn) - end - - def test_util_dthing_dstr - inn = util_thingy(:dstr) - inn.shift - out = '"a\"b#{(1 + 1)}c\"d/e"' - exp = 'a"b2c"d/e' - - assert_equal exp, eval(out) - - assert_equal out[1..-2], @processor.util_dthing(:dstr, inn) - end - - def test_util_dthing_dregx_bug? - inn = s(:dregx, '[\/\"]', s(:evstr, s(:lit, 42))) - inn.shift - out = '/[\/\"]#{42}/' - exp = /[\/\"]42/ - - assert_equal out[1..-2], @processor.util_dthing(:dregx, inn) - assert_equal exp, eval(out) - end - - def test_dregx_slash - inn = util_thingy(:dregx) - out = '/a"b#{(1 + 1)}c"d\/e/' - util_compare inn, out, /a"b2c"d\/e/ - end - - def test_dstr_quote - inn = util_thingy(:dstr) - out = '"a\"b#{(1 + 1)}c\"d/e"' - util_compare inn, out, 'a"b2c"d/e' - end - - def test_dsym_quote - inn = util_thingy(:dsym) - out = ':"a\"b#{(1 + 1)}c\"d/e"' - util_compare inn, out, :'a"b2c"d/e' - end - - def test_lit_regexp_slash - util_compare s(:lit, /blah\/blah/), '/blah\/blah/', /blah\/blah/ - end - - def test_call_self_index - util_compare s(:call, nil, :[], s(:arglist, s(:lit, 42))), "self[42]" - end - - def test_call_self_index_equals - util_compare(s(:call, nil, :[]=, s(:arglist, s(:lit, 42), s(:lit, 24))), - "self[42] = 24") - end - - def test_masgn_wtf - inn = s(:block, - s(:masgn, - s(:array, s(:lasgn, :k), s(:lasgn, :v)), - s(:array, - s(:splat, - s(:call, - s(:call, nil, :line, s(:arglist)), - :split, - s(:arglist, s(:lit, /\=/), s(:lit, 2)))))), - s(:attrasgn, - s(:self), - :[]=, - s(:arglist, s(:lvar, :k), - s(:call, s(:lvar, :v), :strip, s(:arglist))))) - - out = "k, v = *line.split(/\\=/, 2)\nself[k] = v.strip\n" - - util_compare inn, out - end - - - def test_masgn_splat_wtf - inn = s(:masgn, - s(:array, s(:lasgn, :k), s(:lasgn, :v)), - s(:array, - s(:splat, - s(:call, - s(:call, nil, :line, s(:arglist)), - :split, - s(:arglist, s(:lit, /\=/), s(:lit, 2)))))) - out = 'k, v = *line.split(/\\=/, 2)' - util_compare inn, out - end - - def test_splat_call - inn = s(:call, nil, :x, - s(:arglist, - s(:splat, - s(:call, - s(:call, nil, :line, s(:arglist)), - :split, - s(:arglist, s(:lit, /\=/), s(:lit, 2)))))) - - out = 'x(*line.split(/\=/, 2))' - util_compare inn, out - end - - def test_resbody_short_with_begin_end - # "begin; blah; rescue; []; end" - inn = s(:rescue, - s(:call, nil, :blah, s(:arglist)), - s(:resbody, s(:array), s(:array))) - out = "blah rescue []" - util_compare inn, out - end - - def test_resbody_short_with_rescue_args - inn = s(:rescue, - s(:call, nil, :blah, s(:arglist)), - s(:resbody, s(:array, s(:const, :A), s(:const, :B)), s(:array))) - out = "begin\n blah\nrescue A, B\n []\nend" - util_compare inn, out - end - - def test_call_binary_call_with_hash_arg - # if 42 - # args << {:key => 24} - # end - - inn = s(:if, s(:lit, 42), - s(:call, s(:call, nil, :args, s(:arglist)), - :<<, - s(:arglist, s(:hash, s(:lit, :key), s(:lit, 24)))), - nil) - - out = "(args << { :key => 24 }) if 42" - - util_compare inn, out - end - - def test_interpolation_and_escapes - # log_entry = " \e[#{message_color}m#{message}\e[0m " - inn = s(:lasgn, :log_entry, - s(:dstr, " \e[", - s(:evstr, s(:call, nil, :message_color, s(:arglist))), - s(:str, "m"), - s(:evstr, s(:call, nil, :message, s(:arglist))), - s(:str, "\e[0m "))) - out = "log_entry = \" \e[#\{message_color}m#\{message}\e[0m \"" - - util_compare inn, out - end - - def util_compare sexp, expected_ruby, expected_eval = nil - assert_equal expected_ruby, @processor.process(sexp) - assert_equal expected_eval, eval(expected_ruby) if expected_eval - end - - def util_thingy(type) - s(type, - 'a"b', - s(:evstr, s(:call, s(:lit, 1), :+, s(:arglist, s(:lit, 1)))), - s(:str, 'c"d/e')) - end -end - -#################### -# impl -# old new -# -# t old 0 1 -# e -# s -# t new 2 3 - -tr2r = File.read(__FILE__).split(/\n/)[start+1..__LINE__-2].join("\n") -ir2r = File.read("lib/ruby2ruby.rb") - -require 'ruby_parser' - -def silent_eval ruby - old, $-w = $-w, nil - eval ruby - $-w = old -end - -def morph_and_eval src, from, to, processor - new_src = processor.new.process(RubyParser.new.process(src.sub(from, to))) - silent_eval new_src - new_src -end - -____ = morph_and_eval tr2r, /TestRuby2Ruby/, 'TestRuby2Ruby2', Ruby2Ruby -ruby = morph_and_eval ir2r, /Ruby2Ruby/, 'Ruby2Ruby2', Ruby2Ruby -____ = morph_and_eval ruby, /Ruby2Ruby2/, 'Ruby2Ruby3', Ruby2Ruby2 - -class TestRuby2Ruby1 < TestRuby2Ruby - def setup - super - @processor = Ruby2Ruby2.new - end -end - -class TestRuby2Ruby3 < TestRuby2Ruby2 - def setup - super - @processor = Ruby2Ruby2.new - end -end - -class TestRuby2Ruby4 < TestRuby2Ruby2 - def setup - super - @processor = Ruby2Ruby3.new - end -end diff --git a/vendor/gems/ruby_parser-2.0.5/.autotest b/vendor/gems/ruby_parser-2.0.5/.autotest deleted file mode 100644 index a377b016072..00000000000 --- a/vendor/gems/ruby_parser-2.0.5/.autotest +++ /dev/null @@ -1,43 +0,0 @@ -# -*- ruby -*- - -require 'autotest/restart' -require 'autotest/rcov' if ENV['RCOV'] - -Autotest.add_hook :initialize do |at| - at.extra_files << "../../ParseTree/dev/test/pt_testcase.rb" - at.libs << ":../../ParseTree/dev/test:../../sexp_processor/dev/lib" - at.add_exception 'unit' - at.add_exception 'coverage' - at.add_exception 'coverage.info' - at.add_exception '.diff' - - at.libs << ':../../minitest/dev/lib' - at.testlib = "minitest/autorun" - at.unit_diff = "unit_diff -u -b" - - at.add_mapping(/^lib\/.*\.y$/) do |f, _| - at.files_matching %r%^test/.*#{File.basename(f, '.y').gsub '_', '_?'}.rb$% - end - - at.add_mapping(/pt_testcase.rb/) do |f, _| - at.files_matching(/test_.*rb$/) - end - - %w(TestEnvironment TestStackState).each do |klass| - at.extra_class_map[klass] = "test/test_ruby_parser_extras.rb" - end - - %w(TestRubyParser TestParseTree).each do |klass| # HACK - at.extra_class_map[klass] = "test/test_ruby_parser.rb" - end -end - -Autotest.add_hook :run_command do |at| - system "rake parser" -end - -class Autotest - def ruby - File.expand_path "~/.multiruby/install/1.9.0-0/bin/ruby" - end -end if ENV['ONENINE'] diff --git a/vendor/gems/ruby_parser-2.0.5/.specification b/vendor/gems/ruby_parser-2.0.5/.specification deleted file mode 100644 index 6ecc6671474..00000000000 --- a/vendor/gems/ruby_parser-2.0.5/.specification +++ /dev/null @@ -1,72 +0,0 @@ ---- !ruby/object:Gem::Specification -name: ruby_parser -version: !ruby/object:Gem::Version - hash: 5 - prerelease: false - segments: - - 2 - - 0 - - 5 - version: 2.0.5 -platform: ruby -authors: [] - -autorequire: -bindir: bin -cert_chain: [] - -date: 2010-12-07 07:00:00 +02:00 -default_executable: -dependencies: [] - -description: -email: -executables: [] - -extensions: [] - -extra_rdoc_files: [] - -files: -- lib -- lib/ruby_parser.y -- lib/gauntlet_rubyparser.rb -- lib/ruby_parser_extras.rb -- lib/ruby_lexer.rb -- lib/ruby_parser.rb -has_rdoc: true -homepage: -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: -rubygems_version: 1.3.7 -signing_key: -specification_version: 3 -summary: -test_files: [] - diff --git a/vendor/gems/ruby_parser-2.0.5/History.txt b/vendor/gems/ruby_parser-2.0.5/History.txt deleted file mode 100644 index 0d1f0b67686..00000000000 --- a/vendor/gems/ruby_parser-2.0.5/History.txt +++ /dev/null @@ -1,169 +0,0 @@ -=== 2.0.5 / 2010-09-01 - -* 1 minor enhancement: - - * Started merging like lexical cases to try to squeeze some optimization out - -=== 2.0.4 / 2009-08-18 - -* 1 minor enhancement: - - * Changed requires around to be more accurate. - -* 4 bug fixes: - - * Fixed .autotest for minitest - * Fixed emacs escape lexing bug: "\C-\\" (maglev/gemstone) - * Fixed octal lexing edgecases. (maglev/gemstone) - * Fixed regexp lexing edgecases. (maglev/gemstone) - -=== 2.0.3 / 2009-06-23 - -* 4 minor enhancements: - - * Removed dead code handling d/regex match node cruft. - * Switched to minitest - * Updated .autotest and rakefile wrt rcov for new hoe capabilities - * Updated hoe for new capabilities - -* 4 bug fixes: - - * Environment#all now deals with strange edge cases in RAD. - * Fixed packaging/compilation issue. - * Minor 1.9 fixes - * hoe -> flay -> rubyparser rakefile circularity fixed - -=== 2.0.2 / 2009-01-20 - -* 2 minor enhancements: - - * Added gauntlet_rubyparser plugin. YAY for easy massive bug-hunting. - * Promoted Sexp's file/line/comments to sexp_processor. - -* 4 bug fixes: - - * Fixed and improved the readme - * Fixed lexing heredoc newlines. - * Fixed line numbers on defns. - * Fixed rdoc generation bug pointed out by hugh sasse (who rocks) - -=== 2.0.1 / 2008-11-04 - -* 2 minor enhancements: - - * Updated for changes to splat node in many contexts. - * Made PT a developer dep - -=== 2.0.0 / 2008-10-22 - -* 1 major enhancement - - * Brought on the AWESOME! 4x faster! no known lexing/parsing bugs! - -* 71 minor enhancements - - * 1.9: Added Fixnum#ord. - * 1.9: Added missing Regexp constants and did it so it'd work on 1.9. - * Added #store_comment and #comments - * Added StringScanner #begin_of_line? - * Added a bunch of tests for regexp escape chars, #parse_string, #read_escape, ? numbers, ? whitespace. - * Added a hack for rubinius' r2l eval bug. - * Added a new token type tSTRING that bypasses tSTRING_BEG/END entirely. Only does non-interpolated strings and then falls back to the old way. MUCH cleaner tho. - * Added bin/ruby_parse - * Added compare rule to Rakefile. - * Added coverage files/dirs to clean rule. - * Added file and line numbers to all sexp nodes. Column/ranges to come. - * Added lex_state change for lvars at the end of yylex. - * Added lexed comments to defn/defs/class/module nodes. - * Added stats gathering for yylex. Reordered yylex for avg data - * Added tSYMBOL token type and parser rule to speed up symbol lexing. - * Added tally output for getch, unread, and unread_many. - * Added tests for ambigous uminus/uplus, backtick in cmdarg, square and curly brackets, numeric gvars, eos edge cases, string quoting %<> and %%%. - * All cases throughout yylex now return directly if they match, no passthroughs. - * All lexer cases now slurp entire token in one swoop. - * All zarrays are now just empty arrays. - * Changed s(:block_arg, :blah) to :"&blah" in args sexp. - * Cleaned up lexer error handling. Now just raises all over. - * Cleaned up read_escape and regx_options - * Cleaned up tokadd_string (for some definition of cleaned). - * Converted single quoted strings to new tSTRING token type. - * Coverage is currently 94.4% on lexer. - * Done what I can to clean up heredoc lexing... still sucks. - * Flattened resbodies in rescue node. Fixed .autotest file. - * Folded lex_keywords back in now that it screams. - * Found very last instanceof ILiteralNode in the code. haha! - * Got the tests subclassing PTTC and cleaned up a lot. YAY - * Handle yield(*ary) properly - * MASSIVELY cleaned out =begin/=end comment processor. - * Massive overhaul on Keyword class. All hail the mighty Hash! - * Massively cleaned up ident= edge cases and fixed a stupid bug from jruby. - * Merged @/@@ scanner together, going to try to do the same everywhere. - * Refactored fix_arg_lex_state, common across the lexer. - * Refactored new_fcall into new_call. - * Refactored some code to get better profile numbers. - * Refactored some more #fix_arg_lex_state. - * Refactored tail of yylex into its own method. - * Removed Module#kill - * Removed Token, replaced with Sexp. - * Removed all parse_number and parse_quote tests. - * Removed argspush, argscat. YAY! - * Removed as many token_buffer.split(//)'s as possible. 1 to go. - * Removed begins from compstmts - * Removed buffer arg for tokadd_string. - * Removed crufty (?) solo '@' token... wtf was that anyhow? - * Removed most jruby/stringio cruft from StringScanner. - * Removed one unread_many... 2 to go. They're harder. - * Removed store_comment, now done directly. - * Removed token_buffer. Now I just use token ivar. - * Removed use of s() from lexer. Changed the way line numbers are gathered. - * Renamed *qwords to *awords. - * Renamed StringScanner to RPStringScanner (a subclass) to fix namespace trashing. - * Renamed parse to process and aliased to parse. - * Renamed token_buffer to string_buffer since that arcane shit still needs it. - * Resolved the rest of the lexing issues I brought up w/ ruby-core. - * Revamped tokadd_escape. - * Rewrote Keyword and KWtable. - * Rewrote RubyLexer using StringScanner. - * Rewrote tokadd_escape. 79 lines down to 21. - * Split out lib/ruby_parser_extras.rb so lexer is standalone. - * Started to clean up the parser and make it as skinny as possible - * Stripped out as much code as possible. - * Stripped yylex of some dead code. - * Switched from StringIO to StringScanner. - * Updated rakefile for new hoe. - * Uses pure ruby racc if ENV['PURE_RUBY'], otherwise use c. - * Wrote a ton of lexer tests. Coverage is as close to 100% as possible. - * Wrote args to clean up the big nasty args processing grammar section. - * lex_strterm is now a plain array, removed RubyLexer#s(...). - * yield and super now flatten args. - -* 21+ bug fixes: - - * I'm sure this list is missing a lot: - * Fixed 2 bugs both involving attrasgn (and ilk) esp when lhs is an array. - * Fixed a bug in the lexer for strings with single digit hex escapes. - * Fixed a bug parsing: a (args) { expr }... the space caused a different route to be followed and all hell broke loose. - * Fixed a bug with x\n=beginvar not putting begin back. - * Fixed attrasgn to have arglists, not arrays. - * Fixed bug in defn/defs with block fixing. - * Fixed class/module's name slot if colon2/3. - * Fixed dstr with empty interpolation body. - * Fixed for 1.9 string/char changes. - * Fixed lexer BS wrt determining token type of words. - * Fixed lexer BS wrt pass through values and lexing words. SO STUPID. - * Fixed lexing of floats. - * Fixed lexing of identifiers followed by equals. I hope. - * Fixed masgn with splat on lhs - * Fixed new_super to deal with block_pass correctly. - * Fixed parser's treatment of :colon2 and :colon3. - * Fixed regexp scanning of escaped numbers, ANY number is valid, not just octs. - * Fixed string scanning of escaped octs, allowing 1-3 chars. - * Fixed unescape for \n - * Fixed: omg this is stupid. '()' was returning bare nil - * Fixed: remove_begin now goes to the end, not sure why it didn't before. - -=== 1.0.0 / 2007-12-20 - -* 1 major enhancement - * Birthday! - diff --git a/vendor/gems/ruby_parser-2.0.5/Manifest.txt b/vendor/gems/ruby_parser-2.0.5/Manifest.txt deleted file mode 100644 index 630368153c8..00000000000 --- a/vendor/gems/ruby_parser-2.0.5/Manifest.txt +++ /dev/null @@ -1,13 +0,0 @@ -.autotest -History.txt -Manifest.txt -README.txt -Rakefile -bin/ruby_parse -lib/gauntlet_rubyparser.rb -lib/ruby_lexer.rb -lib/ruby_parser.y -lib/ruby_parser_extras.rb -test/test_ruby_lexer.rb -test/test_ruby_parser.rb -test/test_ruby_parser_extras.rb diff --git a/vendor/gems/ruby_parser-2.0.5/README.txt b/vendor/gems/ruby_parser-2.0.5/README.txt deleted file mode 100644 index 9af5b68a88c..00000000000 --- a/vendor/gems/ruby_parser-2.0.5/README.txt +++ /dev/null @@ -1,86 +0,0 @@ -= ruby_parser - -* http://parsetree.rubyforge.org/ - -== DESCRIPTION: - -ruby_parser (RP) is a ruby parser written in pure ruby (utilizing -racc--which does by default use a C extension). RP's output is -the same as ParseTree's output: s-expressions using ruby's arrays and -base types. - -As an example: - - def conditional1(arg1) - if arg1 == 0 then - return 1 - end - return 0 - end - -becomes: - - s(:defn, :conditional1, - s(:args, :arg1), - s(:scope, - s(:block, - s(:if, - s(:call, s(:lvar, :arg1), :==, s(:arglist, s(:lit, 0))), - s(:return, s(:lit, 1)), - nil), - s(:return, s(:lit, 0))))) - -== FEATURES/PROBLEMS: - -* Pure ruby, no compiles. -* Includes preceding comment data for defn/defs/class/module nodes! -* Incredibly simple interface. -* Output is 100% equivalent to ParseTree. - * Can utilize PT's SexpProcessor and UnifiedRuby for language processing. -* Known Issue: Speed is now pretty good, but can always improve: - * RP parses a corpus of 3702 files in 125s (avg 108 Kb/s) - * MRI+PT parsed the same in 67.38s (avg 200.89 Kb/s) -* Known Issue: Code is much better, but still has a long way to go. -* Known Issue: Totally awesome. -* Known Issue: line number values can be slightly off. Parsing LR sucks. - -== SYNOPSIS: - - RubyParser.new.parse "1+1" - # => s(:call, s(:lit, 1), :+, s(:array, s(:lit, 1))) - -== REQUIREMENTS: - -* ruby. woot. -* sexp_processor for Sexp and SexpProcessor classes. -* ParseTree for testing. -* racc full package for parser development (compiling .y to .rb). - -== INSTALL: - -* sudo gem install ruby_parser - -== LICENSE: - -(The MIT License) - -Copyright (c) 2007-2008 Ryan Davis - -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/ruby_parser-2.0.5/Rakefile b/vendor/gems/ruby_parser-2.0.5/Rakefile deleted file mode 100644 index b870365dbc1..00000000000 --- a/vendor/gems/ruby_parser-2.0.5/Rakefile +++ /dev/null @@ -1,127 +0,0 @@ -# -*- ruby -*- - -require 'rubygems' -require 'hoe' - -Hoe.plugin :seattlerb - -Hoe.add_include_dirs("../../ParseTree/dev/test", - "../../RubyInline/dev/lib", - "../../sexp_processor/dev/lib") - -hoe = Hoe.spec 'ruby_parser' do - developer 'Ryan Davis', 'ryand-ruby@zenspider.com' - - self.rubyforge_name = 'parsetree' - - extra_dev_deps << ['ParseTree', '~> 3.0'] - extra_deps << ['sexp_processor', '~> 3.0'] -end - -hoe.spec.files += ['lib/ruby_parser.rb'] # jim.... cmon man - -[:default, :multi, :test].each do |t| - task t => :parser -end - -path = "pkg/ruby_parser-#{hoe.version}" -task path => :parser do - Dir.chdir path do - sh "rake parser" - end -end - -desc "build the parser" -task :parser => ["lib/ruby_parser.rb"] - -rule '.rb' => '.y' do |t| - # -v = verbose - # -t = debugging parser ~4% reduction in speed -- keep for now - # -l = no-line-convert - sh "racc -v -t -l -o #{t.name} #{t.source}" -end - -task :clean do - rm_rf(Dir["**/*~"] + - Dir["**/*.diff"] + - Dir["coverage.info"] + - Dir["coverage"] + - Dir["lib/ruby_parser.rb"] + - Dir["lib/*.output"]) -end - -def next_num(glob) - num = Dir[glob].max[/\d+/].to_i + 1 -end - -desc "Compares PT to RP and deletes all files that match" -task :compare do - files = Dir["unit/**/*.rb"] - puts "Parsing #{files.size} files" - files.each do |file| - puts file - system "./cmp.rb -q #{file} && rm #{file}" - end - system 'find -d unit -type d -empty -exec rmdir {} \;' -end - -desc "Compares PT to RP and stops on first failure" -task :find_bug do - files = Dir["unit/**/*.rb"] - puts "Parsing #{files.size} files" - files.each do |file| - puts file - sh "./cmp.rb -q #{file}" - end -end - -task :sort do - sh 'grepsort "^ +def" lib/ruby_lexer.rb' - sh 'grepsort "^ +def (test|util)" test/test_ruby_lexer.rb' -end - -task :loc do - loc1 = `wc -l ../1.0.0/lib/ruby_lexer.rb`[/\d+/] - flog1 = `flog -s ../1.0.0/lib/ruby_lexer.rb`[/\d+\.\d+/] - loc2 = `cat lib/ruby_lexer.rb lib/ruby_parser_extras.rb | wc -l`[/\d+/] - flog2 = `flog -s lib/ruby_lexer.rb lib/ruby_parser_extras.rb`[/\d+\.\d+/] - - loc1, loc2, flog1, flog2 = loc1.to_i, loc2.to_i, flog1.to_f, flog2.to_f - - puts "1.0.0: loc = #{loc1} flog = #{flog1}" - puts "dev : loc = #{loc2} flog = #{flog2}" - puts "delta: loc = #{loc2-loc1} flog = #{flog2-flog1}" -end - -desc "Validate against all normal files in unit dir" -task :validate do - sh "./cmp.rb unit/*.rb" -end - -def run_and_log cmd, prefix - files = ENV['FILES'] || 'unit/*.rb' - p, x = prefix, "txt" - n = Dir["#{p}.*.#{x}"].map { |s| s[/\d+/].to_i }.max + 1 rescue 1 - f = "#{p}.#{n}.#{x}" - - sh "#{cmd} #{Hoe::RUBY_FLAGS} bin/ruby_parse -q -g #{files} &> #{f}" - - puts File.read(f) -end - -desc "Benchmark against all normal files in unit dir" -task :benchmark do - run_and_log "ruby", "benchmark" -end - -desc "Profile against all normal files in unit dir" -task :profile do - run_and_log "zenprofile", "profile" -end - -desc "what was that command again?" -task :huh? do - puts "ruby #{Hoe::RUBY_FLAGS} bin/ruby_parse -q -g ..." -end - -# vim: syntax=Ruby diff --git a/vendor/gems/ruby_parser-2.0.5/bin/ruby_parse b/vendor/gems/ruby_parser-2.0.5/bin/ruby_parse deleted file mode 100755 index dd51aade192..00000000000 --- a/vendor/gems/ruby_parser-2.0.5/bin/ruby_parse +++ /dev/null @@ -1,88 +0,0 @@ -#!/usr/bin/ruby -s - -$q ||= false -$g ||= false - -require 'rubygems' -require 'ruby_parser' -require 'pp' - -good = bad = 0 - -multi = ARGV.size != 1 -total_time = 0 -total_loc = 0 -total_kbytes = 0 -times = {} -locs = {} -kbytes = {} - -begin - ARGV.each do |file| - rp = RubyParser.new - loc = `wc -l #{file}`.strip.to_i - size = `wc -c #{file}`.strip.to_i / 1024.0 - locs[file] = loc - kbytes[file] = size - total_loc += loc - total_kbytes += size - if $q then - $stderr.print "." - else - warn "# file = #{file} loc = #{loc}" - end - GC.start if $g - - t = Time.now - begin - begin - rp.reset - r = rp.parse(File.read(file), file) - pp r unless $q - good += 1 - rescue SyntaxError => e - warn "SyntaxError for #{file}: #{e.message}" - bad += 1 - end - rescue => e - warn "#{e.backtrace.first} #{e.inspect.gsub(/\n/, ' ')} for #{file}" - warn " #{e.backtrace.join("\n ")}" - bad += 1 - end - - t = Time.now - t - times[file] = t - total_time += t - end -rescue Interrupt - # do nothing -end - -warn "done" - -total = 0 -times.values.each do |t| - total += t -end - -puts -puts "good = #{good} bad = #{bad}" if multi -puts - -format = "%5.2fs:%9.2f l/s:%8.2f Kb/s:%5d Kb:%5d loc:%s" - -times.sort_by { |f, t| -t }.each do |f, t| - next if t < 0.005 - loc = locs[f] - size = kbytes[f] - puts format % [t, loc / t, size / t, size, loc, f] -end - -puts - -puts format % [total_time, - total_loc / total_time, - total_kbytes / total_time, - total_kbytes, - total_loc, - "TOTAL"] unless total_time == 0 diff --git a/vendor/gems/ruby_parser-2.0.5/lib/gauntlet_rubyparser.rb b/vendor/gems/ruby_parser-2.0.5/lib/gauntlet_rubyparser.rb deleted file mode 100755 index 4463c38e654..00000000000 --- a/vendor/gems/ruby_parser-2.0.5/lib/gauntlet_rubyparser.rb +++ /dev/null @@ -1,120 +0,0 @@ -#!/usr/bin/ruby -ws - -$f ||= false - -$:.unshift "../../ruby_parser/dev/lib" -$:.unshift "../../ruby2ruby/dev/lib" - -require 'rubygems' -require 'ruby2ruby' -require 'ruby_parser' - -require 'gauntlet' - -class RubyParserGauntlet < Gauntlet - def initialize - super - - self.data = Hash.new { |h,k| h[k] = {} } - old_data = load_yaml data_file - self.data.merge! old_data - end - - def should_skip? name - if $f then - if Hash === data[name] then - ! data[name].empty? - else - data[name] - end - else - data[name] == true # yes, == true on purpose - end - end - - def diff_pp o1, o2 - require 'pp' - - File.open("/tmp/a.#{$$}", "w") do |f| - PP.pp o1, f - end - - File.open("/tmp/b.#{$$}", "w") do |f| - PP.pp o2, f - end - - `diff -u /tmp/a.#{$$} /tmp/b.#{$$}` - ensure - File.unlink "/tmp/a.#{$$}" rescue nil - File.unlink "/tmp/b.#{$$}" rescue nil - end - - def broke name, file, msg - warn "bad" - self.data[name][file] = msg - self.dirty = true - end - - def process path, name - begin - $stderr.print " #{path}: " - rp = RubyParser.new - r2r = Ruby2Ruby.new - - old_ruby = File.read(path) - - begin - old_sexp = rp.process old_ruby - rescue Racc::ParseError => e - self.data[name][path] = :unparsable - self.dirty = true - return - end - - new_ruby = r2r.process old_sexp.deep_clone - - begin - new_sexp = rp.process new_ruby - rescue Racc::ParseError => e - broke name, path, "couldn't parse new_ruby: #{e.message.strip}" - return - end - - if old_sexp != new_sexp then - broke name, path, diff_pp(old_sexp, new_sexp) - return - end - - self.data[name][path] = true - self.dirty = true - - warn "good" - rescue Interrupt - puts "User cancelled" - exit 1 - rescue Exception => e - broke name, path, " UNKNOWN ERROR: #{e}: #{e.message.strip}" - end - end - - def run name - warn name - Dir["**/*.rb"].sort.each do |path| - next if path =~ /gemspec.rb/ # HACK - next if data[name][path] == true - process path, name - end - - if self.data[name].values.all? { |v| v == true } then - warn " ALL GOOD!" - self.data[name] = true - self.dirty = true - end - end -end - -filter = ARGV.shift -filter = Regexp.new filter if filter - -gauntlet = RubyParserGauntlet.new -gauntlet.run_the_gauntlet filter diff --git a/vendor/gems/ruby_parser-2.0.5/lib/ruby_lexer.rb b/vendor/gems/ruby_parser-2.0.5/lib/ruby_lexer.rb deleted file mode 100644 index 8ed4e09943b..00000000000 --- a/vendor/gems/ruby_parser-2.0.5/lib/ruby_lexer.rb +++ /dev/null @@ -1,1307 +0,0 @@ -class RubyLexer - attr_accessor :command_start - attr_accessor :cmdarg - attr_accessor :cond - attr_accessor :nest - - ESC_RE = /\\([0-7]{1,3}|x[0-9a-fA-F]{1,2}|M-[^\\]|(C-|c)[^\\]|[^0-7xMCc])/ - - # Additional context surrounding tokens that both the lexer and - # grammar use. - attr_reader :lex_state - - attr_accessor :lex_strterm - - attr_accessor :parser # HACK for very end of lexer... *sigh* - - # Stream of data that yylex examines. - attr_reader :src - - # Last token read via yylex. - attr_accessor :token - - attr_accessor :string_buffer - - # Value of last token which had a value associated with it. - attr_accessor :yacc_value - - # What handles warnings - attr_accessor :warnings - - EOF = :eof_haha! - - # ruby constants for strings (should this be moved somewhere else?) - STR_FUNC_BORING = 0x00 - STR_FUNC_ESCAPE = 0x01 # TODO: remove and replace with REGEXP - STR_FUNC_EXPAND = 0x02 - STR_FUNC_REGEXP = 0x04 - STR_FUNC_AWORDS = 0x08 - STR_FUNC_SYMBOL = 0x10 - STR_FUNC_INDENT = 0x20 # <<-HEREDOC - - STR_SQUOTE = STR_FUNC_BORING - STR_DQUOTE = STR_FUNC_BORING | STR_FUNC_EXPAND - STR_XQUOTE = STR_FUNC_BORING | STR_FUNC_EXPAND - STR_REGEXP = STR_FUNC_REGEXP | STR_FUNC_ESCAPE | STR_FUNC_EXPAND - STR_SSYM = STR_FUNC_SYMBOL - STR_DSYM = STR_FUNC_SYMBOL | STR_FUNC_EXPAND - - TOKENS = { - "!" => :tBANG, - "!=" => :tNEQ, - "!~" => :tNMATCH, - "," => :tCOMMA, - ".." => :tDOT2, - "..." => :tDOT3, - "=" => :tEQL, - "==" => :tEQ, - "===" => :tEQQ, - "=>" => :tASSOC, - "=~" => :tMATCH, - } - - # How the parser advances to the next token. - # - # @return true if not at end of file (EOF). - - def advance - r = yylex - self.token = r - - raise "yylex returned nil" unless r - - return RubyLexer::EOF != r - end - - def arg_ambiguous - self.warning("Ambiguous first argument. make sure.") - end - - def comments - c = @comments.join - @comments.clear - c - end - - def expr_beg_push val - cond.push false - cmdarg.push false - self.lex_state = :expr_beg - self.yacc_value = val - end - - def fix_arg_lex_state - self.lex_state = if lex_state == :expr_fname || lex_state == :expr_dot - :expr_arg - else - :expr_beg - end - end - - def heredoc here # 63 lines - _, eos, func, last_line = here - - indent = (func & STR_FUNC_INDENT) != 0 - expand = (func & STR_FUNC_EXPAND) != 0 - eos_re = indent ? /[ \t]*#{eos}(\r?\n|\z)/ : /#{eos}(\r?\n|\z)/ - err_msg = "can't match #{eos_re.inspect} anywhere in " - - rb_compile_error err_msg if - src.eos? - - if src.beginning_of_line? && src.scan(eos_re) then - src.unread_many last_line # TODO: figure out how to remove this - self.yacc_value = eos - return :tSTRING_END - end - - self.string_buffer = [] - - if expand then - case - when src.scan(/#[$@]/) then - src.pos -= 1 # FIX omg stupid - self.yacc_value = src.matched - return :tSTRING_DVAR - when src.scan(/#[{]/) then - self.yacc_value = src.matched - return :tSTRING_DBEG - when src.scan(/#/) then - string_buffer << '#' - end - - until src.scan(eos_re) do - c = tokadd_string func, "\n", nil - - rb_compile_error err_msg if - c == RubyLexer::EOF - - if c != "\n" then - self.yacc_value = string_buffer.join.delete("\r") - return :tSTRING_CONTENT - else - string_buffer << src.scan(/\n/) - end - - rb_compile_error err_msg if - src.eos? - end - - # tack on a NL after the heredoc token - FIX NL should not be needed - src.unread_many(eos + "\n") # TODO: remove this... stupid stupid stupid - else - until src.check(eos_re) do - string_buffer << src.scan(/.*(\n|\z)/) - rb_compile_error err_msg if - src.eos? - end - end - - self.lex_strterm = [:heredoc, eos, func, last_line] - self.yacc_value = string_buffer.join.delete("\r") - - return :tSTRING_CONTENT - end - - def heredoc_identifier # 51 lines - term, func = nil, STR_FUNC_BORING - self.string_buffer = [] - - case - when src.scan(/(-?)(['"`])(.*?)\2/) then - term = src[2] - unless src[1].empty? then - func |= STR_FUNC_INDENT - end - func |= case term - when "\'" then - STR_SQUOTE - when '"' then - STR_DQUOTE - else - STR_XQUOTE - end - string_buffer << src[3] - when src.scan(/-?(['"`])(?!\1*\Z)/) then - rb_compile_error "unterminated here document identifier" - when src.scan(/(-?)(\w+)/) then - term = '"' - func |= STR_DQUOTE - unless src[1].empty? then - func |= STR_FUNC_INDENT - end - string_buffer << src[2] - else - return nil - end - - if src.check(/.*\n/) then - # TODO: think about storing off the char range instead - line = src.string[src.pos, src.matched_size] - src.string[src.pos, src.matched_size] = "\n" - src.pos += 1 - else - line = nil - end - - self.lex_strterm = [:heredoc, string_buffer.join, func, line] - - if term == '`' then - self.yacc_value = "`" - return :tXSTRING_BEG - else - self.yacc_value = "\"" - return :tSTRING_BEG - end - end - - def initialize - self.cond = StackState.new(:cond) - self.cmdarg = StackState.new(:cmdarg) - self.nest = 0 - @comments = [] - - reset - end - - def int_with_base base - rb_compile_error "Invalid numeric format" if src.matched =~ /__/ - self.yacc_value = src.matched.to_i(base) - return :tINTEGER - end - - def lex_state= o - raise "wtf?" unless Symbol === o - @lex_state = o - end - - attr_writer :lineno - def lineno - @lineno ||= src.lineno - end - - ## - # Parse a number from the input stream. - # - # @param c The first character of the number. - # @return A int constant wich represents a token. - - def parse_number - self.lex_state = :expr_end - - case - when src.scan(/[+-]?0[xbd]\b/) then - rb_compile_error "Invalid numeric format" - when src.scan(/[+-]?0x[a-f0-9_]+/i) then - int_with_base(16) - when src.scan(/[+-]?0b[01_]+/) then - int_with_base(2) - when src.scan(/[+-]?0d[0-9_]+/) then - int_with_base(10) - when src.scan(/[+-]?0[Oo]?[0-7_]*[89]/) then - rb_compile_error "Illegal octal digit." - when src.scan(/[+-]?0[Oo]?[0-7_]+|0[Oo]/) then - int_with_base(8) - when src.scan(/[+-]?[\d_]+_(e|\.)/) then - rb_compile_error "Trailing '_' in number." - when src.scan(/[+-]?[\d_]+\.[\d_]+(e[+-]?[\d_]+)?\b|[+-]?[\d_]+e[+-]?[\d_]+\b/i) then - number = src.matched - if number =~ /__/ then - rb_compile_error "Invalid numeric format" - end - self.yacc_value = number.to_f - :tFLOAT - when src.scan(/[+-]?0\b/) then - int_with_base(10) - when src.scan(/[+-]?[\d_]+\b/) then - int_with_base(10) - else - rb_compile_error "Bad number format" - end - end - - def parse_quote # 58 lines - beg, nnd, short_hand, c = nil, nil, false, nil - - if src.scan(/[a-z0-9]{1,2}/i) then # Long-hand (e.g. %Q{}). - rb_compile_error "unknown type of %string" if src.matched_size == 2 - c, beg, short_hand = src.matched, src.getch, false - else # Short-hand (e.g. %{, %., %!, etc) - c, beg, short_hand = 'Q', src.getch, true - end - - if src.eos? or c == RubyLexer::EOF or beg == RubyLexer::EOF then - rb_compile_error "unterminated quoted string meets end of file" - end - - # Figure nnd-char. "\0" is special to indicate beg=nnd and that no nesting? - nnd = { "(" => ")", "[" => "]", "{" => "}", "<" => ">" }[beg] - nnd, beg = beg, "\0" if nnd.nil? - - token_type, self.yacc_value = nil, "%#{c}#{beg}" - token_type, string_type = case c - when 'Q' then - ch = short_hand ? nnd : c + beg - self.yacc_value = "%#{ch}" - [:tSTRING_BEG, STR_DQUOTE] - when 'q' then - [:tSTRING_BEG, STR_SQUOTE] - when 'W' then - src.scan(/\s*/) - [:tWORDS_BEG, STR_DQUOTE | STR_FUNC_AWORDS] - when 'w' then - src.scan(/\s*/) - [:tAWORDS_BEG, STR_SQUOTE | STR_FUNC_AWORDS] - when 'x' then - [:tXSTRING_BEG, STR_XQUOTE] - when 'r' then - [:tREGEXP_BEG, STR_REGEXP] - when 's' then - self.lex_state = :expr_fname - [:tSYMBEG, STR_SSYM] - end - - rb_compile_error "Bad %string type. Expected [Qqwxr\W], found '#{c}'." if - token_type.nil? - - self.lex_strterm = [:strterm, string_type, nnd, beg] - - return token_type - end - - def parse_string(quote) # 65 lines - _, string_type, term, open = quote - - space = false # FIX: remove these - func = string_type - paren = open - term_re = Regexp.escape term - - awords = (func & STR_FUNC_AWORDS) != 0 - regexp = (func & STR_FUNC_REGEXP) != 0 - expand = (func & STR_FUNC_EXPAND) != 0 - - unless func then # FIX: impossible, prolly needs == 0 - self.lineno = nil - return :tSTRING_END - end - - space = true if awords and src.scan(/\s+/) - - if self.nest == 0 && src.scan(/#{term_re}/) then - if awords then - quote[1] = nil - return :tSPACE - elsif regexp then - self.yacc_value = self.regx_options - self.lineno = nil - return :tREGEXP_END - else - self.yacc_value = term - self.lineno = nil - return :tSTRING_END - end - end - - if space then - return :tSPACE - end - - self.string_buffer = [] - - if expand - case - when src.scan(/#(?=[$@])/) then - return :tSTRING_DVAR - when src.scan(/#[{]/) then - return :tSTRING_DBEG - when src.scan(/#/) then - string_buffer << '#' - end - end - - if tokadd_string(func, term, paren) == RubyLexer::EOF then - rb_compile_error "unterminated string meets end of file" - end - - self.yacc_value = string_buffer.join - - - return :tSTRING_CONTENT - end - - def rb_compile_error msg - msg += ". near line #{self.lineno}: #{src.rest[/^.*/].inspect}" - raise SyntaxError, msg - end - - def read_escape # 51 lines - case - when src.scan(/\\/) then # Backslash - '\\' - when src.scan(/n/) then # newline - "\n" - when src.scan(/t/) then # horizontal tab - "\t" - when src.scan(/r/) then # carriage-return - "\r" - when src.scan(/f/) then # form-feed - "\f" - when src.scan(/v/) then # vertical tab - "\13" - when src.scan(/a/) then # alarm(bell) - "\007" - when src.scan(/e/) then # escape - "\033" - when src.scan(/b/) then # backspace - "\010" - when src.scan(/s/) then # space - " " - when src.scan(/[0-7]{1,3}/) then # octal constant - src.matched.to_i(8).chr - when src.scan(/x([0-9a-fA-F]{1,2})/) then # hex constant - src[1].to_i(16).chr - when src.check(/M-\\[\\MCc]/) then - src.scan(/M-\\/) # eat it - c = self.read_escape - c[0] = (c[0].ord | 0x80).chr - c - when src.scan(/M-(.)/) then - c = src[1] - c[0] = (c[0].ord | 0x80).chr - c - when src.check(/(C-|c)\\[\\MCc]/) then - src.scan(/(C-|c)\\/) # eat it - c = self.read_escape - c[0] = (c[0].ord & 0x9f).chr - c - when src.scan(/C-\?|c\?/) then - 127.chr - when src.scan(/(C-|c)(.)/) then - c = src[2] - c[0] = (c[0].ord & 0x9f).chr - c - when src.scan(/[McCx0-9]/) || src.eos? then - rb_compile_error("Invalid escape character syntax") - else - src.getch - end - end - - def regx_options # 15 lines - good, bad = [], [] - - if src.scan(/[a-z]+/) then - good, bad = src.matched.split(//).partition { |s| s =~ /^[ixmonesu]$/ } - end - - unless bad.empty? then - rb_compile_error("unknown regexp option%s - %s" % - [(bad.size > 1 ? "s" : ""), bad.join.inspect]) - end - - return good.join - end - - def reset - self.command_start = true - self.lex_strterm = nil - self.token = nil - self.yacc_value = nil - - @src = nil - @lex_state = nil - end - - def src= src - raise "bad src: #{src.inspect}" unless String === src - @src = RPStringScanner.new(src) - end - - def tokadd_escape term # 20 lines - case - when src.scan(/\\\n/) then - # just ignore - when src.scan(/\\([0-7]{1,3}|x[0-9a-fA-F]{1,2})/) then - self.string_buffer << src.matched - when src.scan(/\\([MC]-|c)(?=\\)/) then - self.string_buffer << src.matched - self.tokadd_escape term - when src.scan(/\\([MC]-|c)(.)/) then - self.string_buffer << src.matched - when src.scan(/\\[McCx]/) then - rb_compile_error "Invalid escape character syntax" - when src.scan(/\\(.)/m) then - self.string_buffer << src.matched - else - rb_compile_error "Invalid escape character syntax" - end - end - - def tokadd_string(func, term, paren) # 105 lines - awords = (func & STR_FUNC_AWORDS) != 0 - escape = (func & STR_FUNC_ESCAPE) != 0 - expand = (func & STR_FUNC_EXPAND) != 0 - regexp = (func & STR_FUNC_REGEXP) != 0 - symbol = (func & STR_FUNC_SYMBOL) != 0 - - paren_re = paren.nil? ? nil : Regexp.new(Regexp.escape(paren)) - term_re = Regexp.new(Regexp.escape(term)) - - until src.eos? do - c = nil - handled = true - case - when self.nest == 0 && src.scan(term_re) then - src.pos -= 1 - break - when paren_re && src.scan(paren_re) then - self.nest += 1 - when src.scan(term_re) then - self.nest -= 1 - when awords && src.scan(/\s/) then - src.pos -= 1 - break - when expand && src.scan(/#(?=[\$\@\{])/) then - src.pos -= 1 - break - when expand && src.scan(/#(?!\n)/) then - # do nothing - when src.check(/\\/) then - case - when awords && src.scan(/\\\n/) then - string_buffer << "\n" - next - when awords && src.scan(/\\\s/) then - c = ' ' - when expand && src.scan(/\\\n/) then - next - when regexp && src.check(/\\/) then - self.tokadd_escape term - next - when expand && src.scan(/\\/) then - c = self.read_escape - when src.scan(/\\\n/) then - # do nothing - when src.scan(/\\\\/) then - string_buffer << '\\' if escape - c = '\\' - when src.scan(/\\/) then - unless src.scan(term_re) || paren.nil? || src.scan(paren_re) then - string_buffer << "\\" - end - else - handled = false - end - else - handled = false - end # case - - unless handled then - - t = Regexp.escape term - x = Regexp.escape(paren) if paren && paren != "\000" - re = if awords then - /[^#{t}#{x}\#\0\\\n\ ]+|./ # |. to pick up whatever - else - /[^#{t}#{x}\#\0\\]+|./ - end - - src.scan re - c = src.matched - - rb_compile_error "symbol cannot contain '\\0'" if symbol && c =~ /\0/ - end # unless handled - - c ||= src.matched - string_buffer << c - end # until - - c ||= src.matched - c = RubyLexer::EOF if src.eos? - - - return c - end - - def unescape s - - r = { - "a" => "\007", - "b" => "\010", - "e" => "\033", - "f" => "\f", - "n" => "\n", - "r" => "\r", - "s" => " ", - "t" => "\t", - "v" => "\13", - "\\" => '\\', - "\n" => "", - "C-\?" => 127.chr, - "c\?" => 127.chr, - }[s] - - return r if r - - case s - when /^[0-7]{1,3}/ then - $&.to_i(8).chr - when /^x([0-9a-fA-F]{1,2})/ then - $1.to_i(16).chr - when /^M-(.)/ then - ($1[0].ord | 0x80).chr - when /^(C-|c)(.)/ then - ($2[0].ord & 0x9f).chr - when /^[McCx0-9]/ then - rb_compile_error("Invalid escape character syntax") - else - s - end - end - - def warning s - # do nothing for now - end - - ## - # Returns the next token. Also sets yy_val is needed. - # - # @return Description of the Returned Value - - def yylex # 826 lines - - c = '' - space_seen = false - command_state = false - src = self.src - - self.token = nil - self.yacc_value = nil - - return yylex_string if lex_strterm - - command_state = self.command_start - self.command_start = false - - last_state = lex_state - - loop do # START OF CASE - if src.scan(/[\ \t\r\f\v]/) then # \s - \n + \v - space_seen = true - next - elsif src.check(/[^a-zA-Z]/) then - if src.scan(/\n|#/) then - self.lineno = nil - c = src.matched - if c == '#' then - src.unread c # ok - - while src.scan(/\s*#.*(\n+|\z)/) do - @comments << src.matched.gsub(/^ +#/, '#').gsub(/^ +$/, '') - end - - if src.eos? then - return RubyLexer::EOF - end - end - - # Replace a string of newlines with a single one - src.scan(/\n+/) - - if [:expr_beg, :expr_fname, - :expr_dot, :expr_class].include? lex_state then - next - end - - self.command_start = true - self.lex_state = :expr_beg - return :tNL - elsif src.scan(/[\]\)\}]/) then - cond.lexpop - cmdarg.lexpop - self.lex_state = :expr_end - self.yacc_value = src.matched - result = { - ")" => :tRPAREN, - "]" => :tRBRACK, - "}" => :tRCURLY - }[src.matched] - return result - elsif src.scan(/\.\.\.?|,|![=~]?/) then - self.lex_state = :expr_beg - tok = self.yacc_value = src.matched - return TOKENS[tok] - elsif src.check(/\./) then - if src.scan(/\.\d/) then - rb_compile_error "no . floating literal anymore put 0 before dot" - elsif src.scan(/\./) then - self.lex_state = :expr_dot - self.yacc_value = "." - return :tDOT - end - elsif src.scan(/\(/) then - result = :tLPAREN2 - self.command_start = true - - if lex_state == :expr_beg || lex_state == :expr_mid then - result = :tLPAREN - elsif space_seen then - if lex_state == :expr_cmdarg then - result = :tLPAREN_ARG - elsif lex_state == :expr_arg then - warning("don't put space before argument parentheses") - result = :tLPAREN2 - end - end - - self.expr_beg_push "(" - - return result - elsif src.check(/\=/) then - if src.scan(/\=\=\=|\=\=|\=~|\=>|\=(?!begin\b)/) then - self.fix_arg_lex_state - tok = self.yacc_value = src.matched - return TOKENS[tok] - elsif src.was_begin_of_line and src.scan(/\=begin(?=\s)/) then - # @comments << '=' << src.matched - @comments << src.matched - - unless src.scan(/.*?\n=end\s*(\n|\z)/m) then - @comments.clear - rb_compile_error("embedded document meets end of file") - end - - @comments << src.matched - - next - else - raise "you shouldn't be able to get here" - end - elsif src.scan(/\"(#{ESC_RE}|#(#{ESC_RE}|[^\{\#\@\$\"\\])|[^\"\\\#])*\"/o) then - self.yacc_value = src.matched[1..-2].gsub(ESC_RE) { unescape $1 } - self.lex_state = :expr_end - return :tSTRING - elsif src.scan(/\"/) then # FALLBACK - self.lex_strterm = [:strterm, STR_DQUOTE, '"', "\0"] # TODO: question this - self.yacc_value = "\"" - return :tSTRING_BEG - elsif src.scan(/\@\@?\w*/) then - self.token = src.matched - - rb_compile_error "`#{token}` is not allowed as a variable name" if - token =~ /\@\d/ - - return process_token(command_state) - elsif src.scan(/\:\:/) then - if (lex_state == :expr_beg || - lex_state == :expr_mid || - lex_state == :expr_class || - (lex_state.is_argument && space_seen)) then - self.lex_state = :expr_beg - self.yacc_value = "::" - return :tCOLON3 - end - - self.lex_state = :expr_dot - self.yacc_value = "::" - return :tCOLON2 - elsif lex_state != :expr_end && lex_state != :expr_endarg && src.scan(/:([a-zA-Z_]\w*(?:[?!]|=(?!>))?)/) then - self.yacc_value = src[1] - self.lex_state = :expr_end - return :tSYMBOL - elsif src.scan(/\:/) then - # ?: / then / when - if (lex_state == :expr_end || lex_state == :expr_endarg|| - src.check(/\s/)) then - self.lex_state = :expr_beg - self.yacc_value = ":" - return :tCOLON - end - - case - when src.scan(/\'/) then - self.lex_strterm = [:strterm, STR_SSYM, src.matched, "\0"] - when src.scan(/\"/) then - self.lex_strterm = [:strterm, STR_DSYM, src.matched, "\0"] - end - - self.lex_state = :expr_fname - self.yacc_value = ":" - return :tSYMBEG - elsif src.check(/[0-9]/) then - return parse_number - elsif src.scan(/\[/) then - result = src.matched - - if lex_state == :expr_fname || lex_state == :expr_dot then - self.lex_state = :expr_arg - case - when src.scan(/\]\=/) then - self.yacc_value = "[]=" - return :tASET - when src.scan(/\]/) then - self.yacc_value = "[]" - return :tAREF - else - rb_compile_error "unexpected '['" - end - elsif lex_state == :expr_beg || lex_state == :expr_mid then - result = :tLBRACK - elsif lex_state.is_argument && space_seen then - result = :tLBRACK - end - - self.expr_beg_push "[" - - return result - elsif src.scan(/\'(\\.|[^\'])*\'/) then - self.yacc_value = src.matched[1..-2].gsub(/\\\\/, "\\").gsub(/\\'/, "'") - self.lex_state = :expr_end - return :tSTRING - elsif src.check(/\|/) then - if src.scan(/\|\|\=/) then - self.lex_state = :expr_beg - self.yacc_value = "||" - return :tOP_ASGN - elsif src.scan(/\|\|/) then - self.lex_state = :expr_beg - self.yacc_value = "||" - return :tOROP - elsif src.scan(/\|\=/) then - self.lex_state = :expr_beg - self.yacc_value = "|" - return :tOP_ASGN - elsif src.scan(/\|/) then - self.fix_arg_lex_state - self.yacc_value = "|" - return :tPIPE - end - elsif src.scan(/\{/) then - result = if lex_state.is_argument || lex_state == :expr_end then - :tLCURLY # block (primary) - elsif lex_state == :expr_endarg then - :tLBRACE_ARG # block (expr) - else - :tLBRACE # hash - end - - self.expr_beg_push "{" - - return result - elsif src.scan(/[+-]/) then - sign = src.matched - utype, type = if sign == "+" then - [:tUPLUS, :tPLUS] - else - [:tUMINUS, :tMINUS] - end - - if lex_state == :expr_fname || lex_state == :expr_dot then - self.lex_state = :expr_arg - if src.scan(/@/) then - self.yacc_value = "#{sign}@" - return utype - else - self.yacc_value = sign - return type - end - end - - if src.scan(/\=/) then - self.lex_state = :expr_beg - self.yacc_value = sign - return :tOP_ASGN - end - - if (lex_state == :expr_beg || lex_state == :expr_mid || - (lex_state.is_argument && space_seen && !src.check(/\s/))) then - if lex_state.is_argument then - arg_ambiguous - end - - self.lex_state = :expr_beg - self.yacc_value = sign - - if src.check(/\d/) then - if utype == :tUPLUS then - return self.parse_number - else - return :tUMINUS_NUM - end - end - - return utype - end - - self.lex_state = :expr_beg - self.yacc_value = sign - return type - elsif src.check(/\*/) then - if src.scan(/\*\*=/) then - self.lex_state = :expr_beg - self.yacc_value = "**" - return :tOP_ASGN - elsif src.scan(/\*\*/) then - self.yacc_value = "**" - self.fix_arg_lex_state - return :tPOW - elsif src.scan(/\*\=/) then - self.lex_state = :expr_beg - self.yacc_value = "*" - return :tOP_ASGN - elsif src.scan(/\*/) then - result = if lex_state.is_argument && space_seen && src.check(/\S/) then - warning("`*' interpreted as argument prefix") - :tSTAR - elsif lex_state == :expr_beg || lex_state == :expr_mid then - :tSTAR - else - :tSTAR2 - end - self.yacc_value = "*" - self.fix_arg_lex_state - - return result - end - elsif src.check(/\/) then - self.fix_arg_lex_state - self.yacc_value = "<=>" - return :tCMP - elsif src.scan(/\<\=/) then - self.fix_arg_lex_state - self.yacc_value = "<=" - return :tLEQ - elsif src.scan(/\<\<\=/) then - self.fix_arg_lex_state - self.lex_state = :expr_beg - self.yacc_value = "\<\<" - return :tOP_ASGN - elsif src.scan(/\<\/) then - if src.scan(/\>\=/) then - self.fix_arg_lex_state - self.yacc_value = ">=" - return :tGEQ - elsif src.scan(/\>\>=/) then - self.fix_arg_lex_state - self.lex_state = :expr_beg - self.yacc_value = ">>" - return :tOP_ASGN - elsif src.scan(/\>\>/) then - self.fix_arg_lex_state - self.yacc_value = ">>" - return :tRSHFT - elsif src.scan(/\>/) then - self.fix_arg_lex_state - self.yacc_value = ">" - return :tGT - end - elsif src.scan(/\`/) then - self.yacc_value = "`" - case lex_state - when :expr_fname then - self.lex_state = :expr_end - return :tBACK_REF2 - when :expr_dot then - self.lex_state = if command_state then - :expr_cmdarg - else - :expr_arg - end - return :tBACK_REF2 - end - self.lex_strterm = [:strterm, STR_XQUOTE, '`', "\0"] - return :tXSTRING_BEG - elsif src.scan(/\?/) then - if lex_state == :expr_end || lex_state == :expr_endarg then - self.lex_state = :expr_beg - self.yacc_value = "?" - return :tEH - end - - if src.eos? then - rb_compile_error "incomplete character syntax" - end - - if src.check(/\s|\v/) then - unless lex_state.is_argument then - c2 = { " " => 's', - "\n" => 'n', - "\t" => 't', - "\v" => 'v', - "\r" => 'r', - "\f" => 'f' }[src.matched] - - if c2 then - warning("invalid character syntax; use ?\\" + c2) - end - end - - # ternary - self.lex_state = :expr_beg - self.yacc_value = "?" - return :tEH - elsif src.check(/\w(?=\w)/) then # ternary, also - self.lex_state = :expr_beg - self.yacc_value = "?" - return :tEH - end - - c = if src.scan(/\\/) then - self.read_escape - else - src.getch - end - self.lex_state = :expr_end - self.yacc_value = c[0].ord & 0xff - return :tINTEGER - elsif src.check(/\&/) then - if src.scan(/\&\&\=/) then - self.yacc_value = "&&" - self.lex_state = :expr_beg - return :tOP_ASGN - elsif src.scan(/\&\&/) then - self.lex_state = :expr_beg - self.yacc_value = "&&" - return :tANDOP - elsif src.scan(/\&\=/) then - self.yacc_value = "&" - self.lex_state = :expr_beg - return :tOP_ASGN - elsif src.scan(/&/) then - result = if lex_state.is_argument && space_seen && - !src.check(/\s/) then - warning("`&' interpreted as argument prefix") - :tAMPER - elsif lex_state == :expr_beg || lex_state == :expr_mid then - :tAMPER - else - :tAMPER2 - end - - self.fix_arg_lex_state - self.yacc_value = "&" - return result - end - elsif src.scan(/\//) then - if lex_state == :expr_beg || lex_state == :expr_mid then - self.lex_strterm = [:strterm, STR_REGEXP, '/', "\0"] - self.yacc_value = "/" - return :tREGEXP_BEG - end - - if src.scan(/\=/) then - self.yacc_value = "/" - self.lex_state = :expr_beg - return :tOP_ASGN - end - - if lex_state.is_argument && space_seen then - unless src.scan(/\s/) then - arg_ambiguous - self.lex_strterm = [:strterm, STR_REGEXP, '/', "\0"] - self.yacc_value = "/" - return :tREGEXP_BEG - end - end - - self.fix_arg_lex_state - self.yacc_value = "/" - - return :tDIVIDE - elsif src.scan(/\^=/) then - self.lex_state = :expr_beg - self.yacc_value = "^" - return :tOP_ASGN - elsif src.scan(/\^/) then - self.fix_arg_lex_state - self.yacc_value = "^" - return :tCARET - elsif src.scan(/\;/) then - self.command_start = true - self.lex_state = :expr_beg - self.yacc_value = ";" - return :tSEMI - elsif src.scan(/\~/) then - if lex_state == :expr_fname || lex_state == :expr_dot then - src.scan(/@/) - end - - self.fix_arg_lex_state - self.yacc_value = "~" - - return :tTILDE - elsif src.scan(/\\/) then - if src.scan(/\n/) then - self.lineno = nil - space_seen = true - next - end - rb_compile_error "bare backslash only allowed before newline" - elsif src.scan(/\%/) then - if lex_state == :expr_beg || lex_state == :expr_mid then - return parse_quote - end - - if src.scan(/\=/) then - self.lex_state = :expr_beg - self.yacc_value = "%" - return :tOP_ASGN - end - - if lex_state.is_argument && space_seen && ! src.check(/\s/) then - return parse_quote - end - - self.fix_arg_lex_state - self.yacc_value = "%" - - return :tPERCENT - elsif src.check(/\$/) then - if src.scan(/(\$_)(\w+)/) then - self.lex_state = :expr_end - self.token = src.matched - return process_token(command_state) - elsif src.scan(/\$_/) then - self.lex_state = :expr_end - self.token = src.matched - self.yacc_value = src.matched - return :tGVAR - elsif src.scan(/\$[~*$?!@\/\\;,.=:<>\"]|\$-\w?/) then - self.lex_state = :expr_end - self.yacc_value = src.matched - return :tGVAR - elsif src.scan(/\$([\&\`\'\+])/) then - self.lex_state = :expr_end - # Explicit reference to these vars as symbols... - if last_state == :expr_fname then - self.yacc_value = src.matched - return :tGVAR - else - self.yacc_value = src[1].to_sym - return :tBACK_REF - end - elsif src.scan(/\$([1-9]\d*)/) then - self.lex_state = :expr_end - if last_state == :expr_fname then - self.yacc_value = src.matched - return :tGVAR - else - self.yacc_value = src[1].to_i - return :tNTH_REF - end - elsif src.scan(/\$0/) then - self.lex_state = :expr_end - self.token = src.matched - return process_token(command_state) - elsif src.scan(/\$\W|\$\z/) then # TODO: remove? - self.lex_state = :expr_end - self.yacc_value = "$" - return "$" - elsif src.scan(/\$\w+/) - self.lex_state = :expr_end - self.token = src.matched - return process_token(command_state) - end - elsif src.check(/\_/) then - if src.beginning_of_line? && src.scan(/\__END__(\n|\Z)/) then - self.lineno = nil - return RubyLexer::EOF - elsif src.scan(/\_\w*/) then - self.token = src.matched - return process_token(command_state) - end - end - end # END OF CASE - - if src.scan(/\004|\032|\000/) || src.eos? then # ^D, ^Z, EOF - return RubyLexer::EOF - else # alpha check - if src.scan(/\W/) then - rb_compile_error "Invalid char #{src.matched.inspect} in expression" - end - end - - self.token = src.matched if self.src.scan(/\w+/) - - return process_token(command_state) - end - end - - def process_token(command_state) - - token << src.matched if token =~ /^\w/ && src.scan(/[\!\?](?!=)/) - - result = nil - last_state = lex_state - - - case token - when /^\$/ then - self.lex_state, result = :expr_end, :tGVAR - when /^@@/ then - self.lex_state, result = :expr_end, :tCVAR - when /^@/ then - self.lex_state, result = :expr_end, :tIVAR - else - if token =~ /[!?]$/ then - result = :tFID - else - if lex_state == :expr_fname then - # ident=, not =~ => == or followed by => - # TODO test lexing of a=>b vs a==>b - if src.scan(/=(?:(?![~>=])|(?==>))/) then - result = :tIDENTIFIER - token << src.matched - end - end - - result ||= if token =~ /^[A-Z]/ then - :tCONSTANT - else - :tIDENTIFIER - end - end - - unless lex_state == :expr_dot then - # See if it is a reserved word. - keyword = Keyword.keyword token - - if keyword then - state = lex_state - self.lex_state = keyword.state - self.yacc_value = token - - if keyword.id0 == :kDO then - self.command_start = true - return :kDO_COND if cond.is_in_state - return :kDO_BLOCK if cmdarg.is_in_state && state != :expr_cmdarg - return :kDO_BLOCK if state == :expr_endarg - return :kDO - end - - return keyword.id0 if state == :expr_beg - - self.lex_state = :expr_beg if keyword.id0 != keyword.id1 - - return keyword.id1 - end - end - - if (lex_state == :expr_beg || lex_state == :expr_mid || - lex_state == :expr_dot || lex_state == :expr_arg || - lex_state == :expr_cmdarg) then - if command_state then - self.lex_state = :expr_cmdarg - else - self.lex_state = :expr_arg - end - else - self.lex_state = :expr_end - end - end - - self.yacc_value = token - - - self.lex_state = :expr_end if - last_state != :expr_dot && self.parser.env[token.to_sym] == :lvar - - return result - end - - def yylex_string # 23 lines - token = if lex_strterm[0] == :heredoc then - self.heredoc lex_strterm - else - self.parse_string lex_strterm - end - - if token == :tSTRING_END || token == :tREGEXP_END then - self.lineno = nil - self.lex_strterm = nil - self.lex_state = :expr_end - end - - return token - end -end diff --git a/vendor/gems/ruby_parser-2.0.5/lib/ruby_parser.rb b/vendor/gems/ruby_parser-2.0.5/lib/ruby_parser.rb deleted file mode 100644 index 250a03bfae3..00000000000 --- a/vendor/gems/ruby_parser-2.0.5/lib/ruby_parser.rb +++ /dev/null @@ -1,5545 +0,0 @@ -# -# DO NOT MODIFY!!!! -# This file is automatically generated by Racc 1.4.7 -# from Racc grammer file "". -# - -require 'racc/parser.rb' -class RubyParser < Racc::Parser - - -require "ruby_lexer" -require "ruby_parser_extras" - -# Local Variables: ** -# racc-token-length-max:14 ** -# End: ** -##### State transition tables begin ### - -clist = [ -'-487,357,482,261,262,801,-87,-487,-487,-487,-90,600,398,-487,-487,122', -'-487,410,399,-64,89,563,563,509,3,-487,514,-432,34,-86,-273,-86,122', -'-435,-432,-487,-487,-273,-487,-487,-487,-487,-487,509,482,482,511,-87', -'786,673,618,620,621,625,564,564,-72,-90,700,-85,482,359,361,531,-487', -'-487,-487,-487,-487,-487,-487,-487,-487,-487,-487,-487,-487,-487,-83', -'411,-487,-487,-487,673,544,738,-273,673,-487,652,266,-90,-483,-84,299', -'-487,651,-487,123,-487,-487,-487,-487,-487,-487,-487,-483,-487,-487', -'-487,-86,-82,269,601,484,123,-87,271,-87,261,262,-87,-487,-487,482,-78', -'-274,-487,-87,-86,-78,-487,269,-274,-274,-274,266,271,-274,-274,-274', -'-86,-274,-86,357,269,-86,671,-79,563,271,-84,-274,-274,269,269,484,484', -'122,271,271,-274,-274,-89,-274,-274,-274,-274,-274,-85,269,-85,484,452', -'-85,271,299,-88,-85,269,-428,671,564,269,271,671,752,-428,271,-83,-274', -'-274,-274,-274,-274,-274,-274,-274,-274,-274,-274,-274,-274,-274,359', -'361,-274,-274,-274,-434,563,-274,732,574,-274,-281,-434,-274,-89,-274', -'-350,-274,-281,-274,730,-274,-274,-274,-274,-274,-274,-274,-84,-274', -'269,-274,484,357,755,271,-484,123,357,564,-89,357,729,-280,-274,-274', -'-274,-274,-76,-274,-280,-280,-280,-274,-88,-85,-280,-280,652,-280,-81', -'-434,-429,738,-423,651,-83,-281,-79,-429,-434,-423,-487,759,-80,-77', -'707,-434,-280,-280,-273,-280,-280,-280,-280,-280,-75,-273,261,262,706', -'269,727,359,361,525,271,-326,359,361,392,359,361,536,-326,266,725,-280', -'-280,-280,-280,-280,-280,-280,-280,-280,-280,-280,-280,-280,-280,-87', -'-487,-280,-280,-280,-434,545,269,-487,-282,-280,-79,271,-483,-85,-273', -'-282,-280,724,-280,745,-280,-280,-280,-280,-280,-280,-280,-79,-280,357', -'-280,-326,358,-487,-430,595,598,521,425,523,599,-430,594,-280,-280,424', -'-80,-79,-280,764,-88,-79,-280,-484,-484,-484,-487,-484,-433,721,423', -'-484,-484,768,-282,-433,-484,422,-484,-484,-484,-484,-484,-484,-484', -'738,-435,523,-77,-484,-484,-484,-484,-484,-484,-484,433,155,299,359', -'361,596,440,432,426,-484,438,439,-484,-484,-484,-484,-484,-484,-484', -'-484,-484,-484,-426,-484,-484,691,-484,-484,-484,-426,396,-75,771,295', -'102,-83,375,277,280,283,286,101,-82,374,509,269,-90,514,-484,545,271', -'-484,-484,-280,-484,-484,-77,-484,399,-484,-280,-484,-431,-484,131,-484', -'-76,872,-281,-431,-84,-484,710,-77,871,-281,-484,-484,-484,-484,-484', -'-484,263,264,399,-484,-484,-483,-483,-483,103,-483,376,-77,-88,-483', -'-483,-77,509,708,-483,527,-483,-483,-483,-483,-483,-483,-483,-280,801', -'261,262,-483,-483,-483,-483,-483,-483,-483,-282,326,703,873,-281,269', -'269,-282,325,-483,271,271,-483,-483,-483,-483,-483,-483,-483,-483,-483', -'-483,701,-483,-483,452,-483,-483,-483,678,679,692,681,88,92,618,620', -'621,625,395,-481,777,-487,-480,321,269,394,779,-483,705,271,-483,-483', -'-280,-483,-483,-282,-483,321,-483,-280,-483,-281,-483,587,-484,-81,378', -'379,-281,-89,-483,749,738,384,-503,-483,-483,-483,-483,-483,-483,-503', -'-503,-503,-483,-483,-503,-503,-503,-426,-503,-487,-423,-86,396,-280', -'-426,384,-487,-423,-503,-481,-280,-483,-480,551,-261,-484,-280,-503', -'-503,523,-503,-503,-503,-503,-503,-281,621,625,749,738,-481,668,-487', -'-480,616,587,-503,622,627,629,261,262,665,-503,-503,-503,261,262,-503', -'-503,-503,587,-503,-426,-79,-487,-423,-503,-87,-280,550,266,-503,654', -'-503,266,791,303,649,321,-503,-503,-503,648,-503,-503,-503,-503,-503', -'618,620,621,625,616,299,794,622,627,629,616,647,-503,622,627,629,616', -'-72,646,622,627,629,-77,643,804,-503,-85,-503,266,806,-503,299,-503', -'809,299,811,295,-261,299,-503,277,280,630,746,321,-503,299,816,630,618', -'620,621,625,321,321,618,620,621,625,303,299,618,620,621,625,295,-503', -'818,638,277,280,283,286,637,18,22,26,299,37,-503,-262,-503,53,63,-503', -'609,592,82,822,91,95,6,11,17,23,27,587,449,552,321,51,56,60,64,69,73', -'77,528,295,97,828,829,277,280,664,830,39,451,833,48,52,59,67,70,74,78', -'83,88,92,266,9,15,507,25,30,36,299,300,276,279,282,285,288,290,292,294', -'296,487,301,278,486,839,284,287,-63,136,841,732,139,729,732,72,76,845', -'87,453,445,295,444,298,20,277,280,283,286,289,291,293,61,297,853,441', -'855,84,89,93,4,10,16,299,428,858,34,40,269,281,859,-217,427,271,18,22', -'26,31,37,861,409,587,53,63,407,587,405,82,403,91,95,6,11,17,23,27,401', -'400,399,393,51,56,60,64,69,73,77,384,874,97,321,321,313,381,664,29,39', -'44,47,48,52,59,67,70,74,78,83,88,92,881,9,15,266,25,30,36,299,300,276', -'279,282,285,288,290,292,294,296,883,301,278,377,886,284,287,887,43,732', -'353,54,350,334,72,76,303,87,637,96,295,302,298,20,277,280,283,286,289', -'291,293,61,297,587,274,587,84,89,93,4,10,16,266,166,153,34,40,149,281', -'899,128,98,451,14,18,22,26,31,37,587,,,53,63,,,,82,,91,95,6,11,17,23', -'27,,,,,51,56,60,64,69,73,77,,,97,314,315,316,317,318,29,39,44,47,48', -'52,59,67,70,74,78,83,88,92,,9,15,,25,30,36,299,-505,-505,-505,-505,285', -'288,,,-505,-505,314,315,316,317,318,284,287,,43,,,54,,,72,76,,87,,96', -'295,,298,20,277,280,283,286,289,291,293,61,297,,,,84,89,93,4,10,16,', -',,34,40,14,18,22,26,31,37,,,,53,63,,,,82,,91,95,6,11,17,23,27,,,,,51', -'56,60,64,69,73,77,,,97,314,315,316,317,318,29,39,44,47,48,52,59,67,70', -'74,78,83,88,92,,9,15,,25,30,36,299,-505,-505,-505,-505,285,288,,,-505', -'-505,,,,,,284,287,,43,,,54,,,72,76,,87,,96,295,,298,20,277,280,283,286', -'289,291,293,61,297,,,,84,89,93,4,10,16,,,,34,40,14,18,22,26,31,37,,', -',53,63,,,,82,,91,95,6,11,17,23,27,,,,,51,56,60,64,69,73,77,,,97,,,,', -',29,39,44,47,48,52,59,67,70,74,78,83,88,92,,9,15,,25,30,36,299,-505', -'-505,-505,-505,285,288,,,-505,-505,,,,,,284,287,,43,,,54,,,72,76,,87', -',96,295,,298,20,277,280,283,286,289,291,293,61,297,,,,84,89,93,4,10', -'16,,,,34,40,14,18,22,26,31,37,,,,53,63,,,,82,,91,95,6,11,17,23,27,,', -',,51,56,60,64,69,73,77,,,97,,,,,,29,39,44,47,48,52,59,67,70,74,78,83', -'88,92,,9,15,,25,30,36,299,,,,,,,,,,,,,,,,284,287,,43,,,54,,,72,76,,87', -',96,295,,298,20,277,280,283,286,,,293,61,297,,,,84,89,93,4,10,16,,,', -'34,40,14,18,22,26,31,37,,,,53,63,,,,82,,91,95,6,11,17,23,27,,,,,51,56', -'60,64,69,73,77,,,97,,,,,,29,39,44,47,48,52,59,67,70,74,78,83,88,92,', -'9,15,,25,30,36,299,,,,,,,,,,,,,,,,284,287,,43,,,54,,,72,76,,87,,96,295', -',298,20,277,280,283,286,,,293,61,297,,,,84,89,93,4,10,16,,,,34,40,14', -'18,22,26,31,37,,,,53,63,,,,82,,91,95,6,11,17,23,27,,,,,51,56,60,64,69', -'73,77,,,97,,,,,,29,39,44,47,48,52,59,67,70,74,78,83,88,92,,9,15,,25', -'30,36,299,300,276,279,282,285,288,290,292,294,296,,-505,-505,,,284,287', -',43,,,54,,,72,76,,87,,96,295,,298,20,277,280,283,286,289,291,293,61', -'297,,,,84,89,93,4,10,16,,,,34,40,14,18,22,26,31,37,,,,53,63,,,,82,,91', -'95,6,11,17,23,27,,,,,51,56,60,64,69,73,77,,,97,,,,,,29,39,44,47,48,52', -'59,67,70,74,78,83,88,92,,9,15,,25,30,36,299,-505,-505,-505,-505,285', -'288,,,-505,-505,,,,,,284,287,,43,,,54,,,72,76,,87,,96,295,,298,20,277', -'280,283,286,289,291,293,61,297,,,,84,89,93,4,10,16,,,,34,40,14,18,22', -'26,31,37,,,,53,63,,,,82,,91,95,6,11,17,23,27,,,,,51,56,60,64,69,73,77', -',,97,,,,,,29,39,44,47,48,52,59,67,70,74,78,83,88,92,,9,15,,25,30,36', -'299,300,276,279,282,285,288,,,294,296,,,,,,284,287,,43,,,311,,,72,76', -',87,,96,295,,298,20,277,280,283,286,289,291,293,61,297,,,,84,89,93,4', -'10,16,,,,34,40,14,18,22,26,31,37,,,,53,63,,,,82,,91,95,6,11,17,23,27', -',,,,51,56,60,64,69,73,77,,,97,,,,,,29,39,44,47,48,52,59,67,70,74,78', -'83,88,92,,9,15,,25,30,36,299,-505,-505,-505,-505,285,288,,,-505,-505', -',,,,,284,287,,43,,,54,,,72,76,,87,,96,295,,298,20,277,280,283,286,289', -'291,293,61,297,,,,84,89,93,4,10,16,,,,34,40,14,18,22,26,31,37,,,,53', -'63,,,,82,,91,95,6,11,17,23,27,,,,,51,56,60,64,69,73,77,,,97,,,,,,29', -'39,44,47,48,52,59,67,70,74,78,83,88,92,,9,15,,25,30,36,299,,,,,,,,,', -',,,,,,284,287,,43,,,54,,,72,76,,87,,96,295,,298,20,277,280,283,286,', -',293,61,297,,,,84,89,93,4,10,16,,,,34,40,14,18,22,26,31,37,,,,53,63', -',,,82,,91,95,6,11,17,23,27,,,,,51,56,60,64,69,73,77,,,97,,,,,,29,39', -'44,47,48,52,59,67,70,74,78,83,88,92,,9,15,,25,30,36,299,-505,-505,-505', -'-505,285,288,,,-505,-505,,,,,,284,287,,43,,,54,,,72,76,,87,,96,295,', -'298,20,277,280,283,286,289,291,293,61,297,,,,84,89,93,4,10,16,,,,34', -'40,14,18,22,26,31,37,,,,53,63,,,,82,,91,95,6,11,17,23,27,,,,,51,56,60', -'64,69,73,77,,,97,,,,,,29,39,44,47,48,52,59,67,70,74,78,83,88,92,,9,15', -',25,30,36,299,,,,,,,,,,,,,,,,284,287,,43,,,54,,,72,76,,87,,96,295,,298', -'20,277,280,283,286,,,293,61,297,,,,84,89,93,4,10,16,,,,34,40,14,18,22', -'26,31,37,,,,53,63,,,,82,,91,95,6,11,17,23,27,,,,,51,56,60,64,69,73,77', -',,97,,,,,,29,39,44,47,48,52,59,67,70,74,78,83,88,92,,9,15,,25,30,36', -'299,300,276,279,282,285,288,290,,294,296,,,,,,284,287,,43,,,54,,,72', -'76,,87,,96,295,,298,20,277,280,283,286,289,291,293,61,297,,,,84,89,93', -'4,10,16,,,,34,40,14,18,22,26,31,37,,,,53,63,,,,82,,91,95,6,11,17,23', -'27,,,,,51,56,60,64,69,73,77,,,97,,,,,,29,39,44,47,48,52,59,67,70,74', -'78,83,88,92,,9,15,,25,30,36,299,300,276,279,282,285,288,290,292,294', -'296,,-505,-505,,,284,287,,43,,,54,,,72,76,,87,,96,295,,298,20,277,280', -'283,286,289,291,293,61,297,,,,84,89,93,4,10,16,,,,34,40,14,18,22,26', -'31,37,,,,53,63,,,,82,,91,95,6,11,17,23,27,,,,,51,56,60,64,69,73,77,', -',97,,,,,,29,39,44,47,48,52,59,67,70,74,78,83,88,92,,9,15,,25,30,36,299', -',,,,,,,,,,,,,,,284,287,,43,,,54,,,72,76,,87,,96,295,,298,20,277,280', -'283,286,,,,61,,,,,84,89,93,4,10,16,,,,34,40,14,18,22,26,31,37,,,,53', -'63,,,,82,,91,95,6,11,17,23,27,,,,,51,56,60,64,69,73,77,,,97,,,,,,29', -'39,44,47,48,52,59,67,70,74,78,83,88,92,,9,15,,25,30,36,299,,,,,,,,,', -',,,,,,284,287,,43,,,54,,,72,76,,87,,96,295,,,20,277,280,283,286,,,,61', -',,,,84,89,93,4,10,16,,,,34,40,14,18,22,26,31,37,,,,53,63,,,,82,,91,95', -'6,11,17,23,27,,,,,51,56,60,64,69,73,77,,,97,,,,,,29,39,44,47,48,52,59', -'67,70,74,78,83,88,92,,9,15,,25,30,36,299,,,,,,,,,,,,,,,,284,287,,43', -',,54,,,72,76,,87,,96,295,,298,20,277,280,283,286,,,,61,,,,,84,89,93', -'4,10,16,,,,34,40,14,18,22,26,31,37,,,,53,63,,,,82,,91,95,6,11,17,23', -'27,,,,,51,56,60,64,69,73,77,,,97,,,,,,29,39,44,47,48,52,59,67,70,74', -'78,83,88,92,,9,15,,25,30,36,,,,,,,,,,,,,,,,,,,,43,,,311,,,72,76,,87', -',96,,,,20,,,,,,,,61,,,,,84,89,93,4,10,16,,,,34,40,14,18,22,26,31,37', -',,,53,63,,,,82,,91,95,6,11,17,23,27,,,,,51,56,60,64,69,73,77,,,97,,', -',,,29,39,44,47,48,52,59,67,70,74,78,83,88,92,,9,15,,25,30,36,,,,,,,', -',,,,,,,,,,,,43,,,54,,,72,76,,87,,96,,,,20,,,,,,,,61,,,,,84,89,93,4,10', -'16,,,,34,40,14,18,22,26,31,37,,,,53,63,,,,82,,91,95,6,11,17,23,27,,', -',,51,56,60,64,69,73,77,,,97,,,,,,29,39,44,47,48,52,59,67,70,74,78,83', -'88,92,,9,15,,25,30,36,,,,,,,,,,,,,,,,,,,,43,,,54,,,72,76,,87,,96,,,', -'20,,,,,,,,61,,,,,84,89,93,4,10,16,,,,34,40,14,18,22,26,31,37,,,,53,63', -',,,82,,91,95,6,11,17,23,27,,,,,51,56,60,64,69,73,77,,,97,,,,,,29,39', -'44,47,48,52,59,67,70,74,78,83,88,92,,9,15,,25,30,36,,,,,,,,,,,,,,,,', -',,,43,,,54,,,72,76,,87,,96,,,,20,,,,,,,,61,,,,,84,89,93,4,10,16,,,,34', -'40,14,18,22,26,31,37,,,,53,63,,,,82,,91,95,6,11,17,23,27,,,,,51,56,60', -'64,69,73,77,,,97,,,,,,29,39,44,47,48,52,59,67,70,74,78,83,88,92,,9,15', -',25,30,36,,,,,,,,,,,,,,,,,,,,43,,,54,,,72,76,,87,,96,,,,20,,,,,,,,61', -',,,,84,89,93,4,10,16,,,,34,40,14,18,22,26,31,37,,,,53,63,,,,82,,91,95', -'6,11,17,23,27,,,,,51,56,60,64,69,73,77,,,97,,,,,,29,39,44,47,48,52,59', -'67,70,74,78,83,88,92,,9,15,,25,30,36,,,,,,,,,,,,,,,,,,,,43,,,54,,,72', -'76,,87,,96,,,,20,,,,,,,,61,,,,,84,89,93,4,10,16,,,,34,40,14,18,22,26', -'31,37,,,,53,63,,,,82,,91,95,6,11,17,23,27,,,,,51,56,60,64,69,73,77,', -',97,,,,,,29,39,44,47,48,52,59,67,70,74,78,83,88,92,,9,15,,25,30,36,', -',,,,,,,,,,,,,,,,,,43,,,54,,,72,76,,87,,96,,,,20,,,,,,,,61,,,,,84,89', -'93,4,10,16,,,,34,40,14,18,22,26,31,37,,,,53,63,,,,82,,91,95,6,11,17', -'23,27,,,,,51,56,60,64,69,73,77,,,97,,,,,,29,39,44,47,48,52,59,67,70', -'74,78,83,88,92,,9,15,,25,30,36,,,,,,,,,,,,,,,,,,,,43,,,311,,,72,76,', -'87,,96,,,,20,,,,,,,,61,,,,,84,89,93,4,10,16,,,,34,40,14,18,22,26,31', -'37,,,,53,63,,,,82,,91,95,6,11,17,23,27,,,,,51,56,60,64,69,73,77,,,97', -',,,,,29,39,44,47,48,52,59,67,70,74,78,83,88,92,,9,15,,25,30,36,,,,,', -',,,,,,,,,,,,,,43,,,54,,,72,76,,87,,96,,,,20,,,,,,,,61,,,,,84,89,93,4', -'10,16,,,,34,40,14,18,22,26,31,37,,,,53,63,,,,82,,91,95,6,11,17,23,27', -',,,,51,56,60,64,69,73,77,,,97,,,,,,29,39,44,47,48,52,59,67,70,74,78', -'83,88,92,,9,15,,25,30,36,,,,,,,,,,,,,,,,,,,,43,,,54,,,72,76,,87,,96', -',,,20,,,,,,,,61,,,,,84,89,93,4,10,16,,,,34,40,14,18,22,26,31,37,,,,53', -'63,,,,82,,91,95,6,11,17,23,27,,,,,51,56,60,64,69,73,77,,,97,,,,,,29', -'39,44,47,48,52,59,67,70,74,78,83,88,92,,9,15,,25,30,36,,,,,,,,,,,,,', -',,,,,,43,,,54,,,72,76,,87,,96,,,,20,,,,,,,,61,,,,,84,89,93,4,10,16,', -',,34,40,14,18,22,26,31,37,,,,53,63,,,,82,,91,95,6,11,17,23,27,,,,,51', -'56,60,64,69,73,77,,,97,,,,,,29,39,44,47,48,52,59,67,70,74,78,83,88,92', -',9,15,,25,30,36,,,,,,,,,,,,,,,,,,,,43,,,54,,,72,76,,87,,96,,,,20,,,', -',,,,61,,,,,84,89,93,4,10,16,,,,34,40,18,22,26,,37,,,,53,63,,,,82,,91', -'95,6,106,107,23,27,,,,,114,56,60,64,69,73,77,,,,,,,,,,39,,,48,52,59', -'67,70,74,78,83,88,92,,9,15,,25,30,36,,,,,,,,,,,,,,,,,,,,136,,,139,,', -'72,76,,87,,146,,131,,20,,,,,,,,141,,,,,84,89,93,4,10,16,,,,34,40,18', -'22,26,,37,,,,53,63,,,,82,,91,95,6,11,17,23,27,,,,,51,56,60,64,69,73', -'77,,,97,,,,,,,39,,,48,52,59,67,70,74,78,83,88,92,,9,15,,25,30,36,,,', -',,,,,,,,,,,,,,,,136,,,139,,,72,76,,87,,,,,,20,,,,,,,,61,,,,,84,89,93', -'4,10,16,,,,34,40,-251,-251,-251,,-251,,,,-251,-251,,,,-251,,-251,-251', -'-251,-251,-251,-251,-251,,,,,-251,-251,-251,-251,-251,-251,-251,,,,', -',,,,,-251,,,-251,-251,-251,-251,-251,-251,-251,-251,-251,-251,,-251', -'-251,,-251,-251,-251,,,,,,,,,,,,,,,,,,,,-251,,,-251,321,,-251,-251,', -'-251,,-251,,-251,,-251,,,,,,,,-251,,,,,-251,-251,-251,-251,-251,-251', -',,,-251,-251,-480,-480,-480,,-480,,,,-480,-480,,,,-480,,-480,-480,-480', -'-480,-480,-480,-480,,-480,,,-480,-480,-480,-480,-480,-480,-480,,,,,', -',,,,-480,,,-480,-480,-480,-480,-480,-480,-480,-480,-480,-480,,-480,-480', -',-480,-480,-480,,,,,,,,,,,,,,,,,,,,-480,,,-480,-480,,-480,-480,,-480', -',-480,,-480,,-480,,,,,,,,-480,,-480,,,-480,-480,-480,-480,-480,-480', -',,,-480,-480,18,22,26,,37,,,,53,63,,,,82,,91,95,6,11,17,23,27,,,,,51', -'56,60,64,69,73,77,,,97,,,,,,,39,,,48,52,59,67,70,74,78,83,88,92,,9,15', -',25,30,36,,,,,,,,,,,,,,,,,,,,136,,,139,,,72,76,,87,,,,,,20,,,,,,,,61', -',,,,84,89,93,4,10,16,,,,34,40,18,22,26,,37,,,,53,63,,,,82,,91,95,6,106', -'107,23,27,,,,,114,56,60,64,69,73,77,,,,,,,,,,39,,,48,52,59,67,70,74', -'78,83,88,92,,9,15,,25,30,36,,,,,,,,,,,,,,,,,,,,136,,,139,,,72,76,,87', -',332,,,,20,,,,,,,,141,,,,,84,89,93,4,10,16,,,,34,40,-481,-481,-481,', -'-481,,,,-481,-481,,,,-481,,-481,-481,-481,-481,-481,-481,-481,,-481', -',,-481,-481,-481,-481,-481,-481,-481,,,,,,,,,,-481,,,-481,-481,-481', -'-481,-481,-481,-481,-481,-481,-481,,-481,-481,,-481,-481,-481,,,,,,', -',,,,,,,,,,,,,-481,,,-481,-481,,-481,-481,,-481,,-481,,-481,,-481,,,', -',,,,-481,,-481,,,-481,-481,-481,-481,-481,-481,,,,-481,-481,18,22,26', -',37,,,,53,63,,,,82,,91,95,6,106,107,23,27,,,,,114,115,116,64,69,73,77', -',,,,,,,,,39,,,48,52,59,67,70,74,78,83,88,92,,9,15,,25,30,36,,,,,,,,', -',,,,,,,,,,,136,,,139,,,72,76,,87,,767,,,,20,,,,,,,,141,,,,,84,89,93', -'4,10,16,,,,34,40,18,22,26,,37,,,,53,63,,,,82,,91,95,6,106,107,23,27', -',,,,114,56,60,64,69,73,77,,,,,,,,,,39,,,48,52,59,67,70,74,78,83,88,92', -',9,15,,25,30,36,,,,,,,,,,,,,,,,,,,,136,,,139,,,72,76,,87,,332,,,,20', -',,,,,,,141,,,,,84,89,93,4,10,16,,,,34,40,18,22,26,,37,,,,53,63,,,,82', -',91,95,6,106,107,23,27,,,,,114,115,116,64,69,73,77,,,,,,,,,,39,,,48', -'52,59,67,70,74,78,83,88,92,,9,15,,25,30,36,,,,,,,,,,,,,,,,,,,,136,,', -'139,,,72,76,,87,,520,,,,20,,,,,,,,141,,,,,84,89,93,4,10,16,,,,34,40', -'18,22,26,,37,,,,53,63,,,,82,,91,95,6,106,107,23,27,,,,,114,115,116,64', -'69,73,77,,,,,,,,,,39,,,48,52,59,67,70,74,78,83,88,92,,9,15,,25,30,36', -',,,,,,,,,,,,,,,,,,,136,,,139,,,72,76,,87,,,,,,20,,,,,,,,141,,,,,84,89', -'93,4,10,16,,,,34,40,18,22,26,,37,,,,53,63,,,,82,,91,95,6,106,107,23', -'27,,,,,114,115,116,64,69,73,77,,,,,,,,,,39,,,48,52,59,67,70,74,78,83', -'88,92,,9,15,,25,30,36,,,,,,,,,,,,,,,,,,,,136,,,139,,,72,76,,87,,,,,', -'20,,,,,,,,141,,,,,84,89,93,4,10,16,,,,34,40,18,22,26,,37,,,,53,63,,', -',82,,91,95,6,106,107,23,27,,,,,114,115,116,64,69,73,77,,,,,,,,,,39,', -',48,52,59,67,70,74,78,83,88,92,,9,15,,25,30,36,,,,,,,,,,,,,,,,,,,,136', -',,139,,,72,76,,87,,,,,,20,,,,,,,,141,,,,,84,89,93,4,10,16,,,,34,40,18', -'22,26,,37,,,,53,63,,,,82,,91,95,6,106,107,23,27,,,,,114,115,116,64,69', -'73,77,,,,,,,,,,112,,,48,52,59,67,70,74,78,83,88,92,,9,15,,,,110,,,,', -',,,,,,,,,,,,,,,113,,,54,,,72,76,,87,,96,,,,,,,,,,,,,,,,,84,89,93,4,10', -'16,,,,34,40,18,22,26,,37,,,,53,63,,,,82,,91,95,6,106,107,23,27,,,,,114', -'115,116,64,69,73,77,,,,,,,,,,112,,,48,52,59,67,70,74,78,83,88,92,,9', -'15,,,,110,,,,,,,,,,,,,,,,,,,,162,,,139,,,72,76,,87,,,,,,,,,,,,,,,,,', -',84,89,93,4,10,16,,,,34,40,18,22,26,,37,,,,53,63,,,,82,,91,95,6,11,17', -'23,27,,,,,51,56,60,64,69,73,77,,,97,,,,,,,39,,,48,52,59,67,70,74,78', -'83,88,92,,9,15,,25,30,36,,,,,,,,,,,,,,,,,,,,136,,,139,,,72,76,,87,,', -',,,20,,,,,,,,61,,,,,84,89,93,4,10,16,,,,34,40,18,22,26,,37,,,,53,63', -',,,82,,91,95,6,11,17,23,27,,,,,51,56,60,64,69,73,77,,,97,,,,,,,39,,', -'48,52,59,67,70,74,78,83,88,92,,9,15,,25,30,36,,,,,,,,,,,,,,,,,,,,136', -',,139,,,72,76,,87,,,,,,20,,,,,,,,61,,,,,84,89,93,4,10,16,,,,34,40,18', -'22,26,,37,,,,53,63,,,,82,,91,95,6,11,17,23,27,,,,,51,56,60,64,69,73', -'77,,,97,,,,,,,39,,,48,52,59,67,70,74,78,83,88,92,,9,15,,25,30,36,,,', -',,,,,,,,,,,,,,,,136,,,139,,,72,76,,87,,,,,,20,,,,,,,,61,,,,,84,89,93', -'4,10,16,,,,34,40,18,22,26,,37,,,,53,63,,,,82,,91,95,6,106,107,23,27', -',,,,114,115,116,64,69,73,77,,,,,,,,,,39,,,48,52,59,67,70,74,78,83,88', -'92,,9,15,,25,30,36,,,,,,,,,,,,,,,,,,,,136,,,139,,,72,76,,87,,,,,,20', -',,,,,,,141,,,,,84,89,93,4,10,16,,,,34,40,18,22,26,,37,,,,53,63,,,,82', -',91,95,6,106,107,23,27,,,,,114,56,60,64,69,73,77,,,,,,,,,,39,,,48,52', -'59,67,70,74,78,83,88,92,,9,15,,25,30,36,,,,,,,,,,,,,,,,,,,,136,,,139', -',,72,76,,87,,332,,,,20,,,,,,,,141,,,,,84,89,93,4,10,16,,,,34,40,18,22', -'26,,37,,,,53,63,,,,82,,91,95,6,106,107,23,27,,,,,114,115,116,64,69,73', -'77,,,,,,,,,,39,,,48,52,59,67,70,74,78,83,88,92,,9,15,,25,30,36,,,,,', -',,,,,,,,,,,,,,136,,,139,,,72,76,,87,,662,,,,20,,,,,,,,141,,,,,84,89', -'93,4,10,16,,,,34,40,18,22,26,,37,,,,53,63,,,,82,,91,95,6,106,107,23', -'27,,,,,114,115,116,64,69,73,77,,,,,,,,,,39,,,48,52,59,67,70,74,78,83', -'88,92,,9,15,,25,30,36,,,,,,,,,,,,,,,,,,,,136,,,139,,,72,76,,87,,,,,', -'20,,,,,,,,141,,,,,84,89,93,4,10,16,,,,34,40,18,22,26,,37,,,,53,63,,', -',82,,91,95,6,106,107,23,27,,,,,114,56,60,64,69,73,77,,,,,,,,,,39,,,48', -'52,59,67,70,74,78,83,88,92,,9,15,,25,30,36,,,,,,,,,,,,,,,,,,,,136,,', -'139,,,72,76,,87,,146,,131,,20,,,,,,,,141,,,,,84,89,93,4,10,16,,,,34', -'40,18,22,26,,37,,,,53,63,,,,82,,91,95,6,106,107,23,27,,,,,114,115,116', -'64,69,73,77,,,,,,,,,,39,,,48,52,59,67,70,74,78,83,88,92,,9,15,,25,30', -'36,,,,,,,,,,,,,,,,,,,,136,,,139,,,72,76,,87,,,,,,20,,,,,,,,141,,,,,84', -'89,93,4,10,16,,,,34,40,18,22,26,,37,,,,53,63,,,,82,,91,95,6,106,107', -'23,27,,,,,114,115,116,64,69,73,77,,,,,,,,,,39,,,48,52,59,67,70,74,78', -'83,88,92,,9,15,,25,30,36,,,,,,,,,,,,,,,,,,,,136,,,139,,,72,76,,87,,', -',,,20,,,,,,,,141,,,,,84,89,93,4,10,16,,,,34,40,18,22,26,,37,,,,53,63', -',,,82,,91,95,6,11,17,23,27,,,,,51,56,60,64,69,73,77,,,97,,,,,,,39,,', -'48,52,59,67,70,74,78,83,88,92,,9,15,,25,30,36,,,,,,,,,,,,,,,,,,,,136', -',,139,,,72,76,,87,,,,,,20,,,,,,,,61,,,,,84,89,93,4,10,16,,,,34,40,18', -'22,26,,37,,,,53,63,,,,82,,91,95,6,106,107,23,27,,,,,114,115,116,64,69', -'73,77,,,,,,,,,,39,,,48,52,59,67,70,74,78,83,88,92,,9,15,,25,30,36,,', -',,,,,,,,,,,,,,,,,136,,,139,,,72,76,,87,,,,,,20,,,,,,,,141,,,,,84,89', -'93,4,10,16,,,,34,40,18,22,26,,37,,,,53,63,,,,82,,91,95,6,106,107,23', -'27,,,,,114,115,116,64,69,73,77,,,,,,,,,,39,,,48,52,59,67,70,74,78,83', -'88,92,,9,15,,25,30,36,,,,,,,,,,,,,,,,,,,,136,,,139,,,72,76,,87,,,,,', -'20,,,,,,,,141,,,,,84,89,93,4,10,16,,,,34,40,18,22,26,,37,,,,53,63,,', -',82,,91,95,6,106,107,23,27,,,,,114,115,116,64,69,73,77,,,,,,,,,,39,', -',48,52,59,67,70,74,78,83,88,92,,9,15,,25,30,36,,,,,,,,,,,,,,,,,,,,136', -',,139,,,72,76,,87,,,,,,20,,,,,,,,141,,,,,84,89,93,4,10,16,,,,34,40,-251', -'-251,-251,,-251,,,,-251,-251,,,,-251,,-251,-251,-251,-251,-251,-251', -'-251,,,,,-251,-251,-251,-251,-251,-251,-251,,,,,,,,,,-251,,,-251,-251', -'-251,-251,-251,-251,-251,-251,-251,-251,,-251,-251,,-251,-251,-251,', -',,,,,,,,,,,,,,,,,,-251,,,-251,313,,-251,-251,,-251,,-251,,-251,,-251', -',,,,,,,-251,,,,,-251,-251,-251,-251,-251,-251,,,,-251,-251,18,22,26', -',37,,,,53,63,,,,82,,91,95,6,11,17,23,27,,,,,51,56,60,64,69,73,77,,,97', -',,,,,,39,,,48,52,59,67,70,74,78,83,88,92,,9,15,,25,30,36,,,,,,,,,,,', -',,,,,,,,136,,,139,,,72,76,,87,,,,,,20,,,,,,,,61,,,,,84,89,93,4,10,16', -',,,34,40,18,22,26,,37,,,,53,63,,,,82,,91,95,6,106,107,23,27,,,,,114', -'56,60,64,69,73,77,,,,,,,,,,39,,,48,52,59,67,70,74,78,83,88,92,,9,15', -',25,30,36,,,,,,,,,,,,,,,,,,,,136,,,139,,,72,76,,87,,332,,,,20,,,,,,', -',141,,,,,84,89,93,4,10,16,,,,34,40,18,22,26,,37,,,,53,63,,,,82,,91,95', -'6,106,107,23,27,,,,,114,56,60,64,69,73,77,,,,,,,,,,39,,,48,52,59,67', -'70,74,78,83,88,92,,9,15,,25,30,36,,,,,,,,,,,,,,,,,,,,136,,,139,,,389', -'76,,87,,146,,131,,20,,,,,,,,141,,,,,84,89,93,4,10,16,,,,34,40,18,22', -'26,,37,,,,53,63,,,,82,,91,95,6,106,107,23,27,,,,,114,115,116,64,69,73', -'77,,,,,,,,,,39,,,48,52,59,67,70,74,78,83,88,92,,9,15,,25,30,36,,,,,', -',,,,,,,,,,,,,,136,,,139,,,72,76,,87,,,,,,20,,,,,,,,141,,,,,84,89,93', -'4,10,16,,,,34,40,176,180,185,191,196,201,205,210,,,228,231,232,235,240', -',,169,172,174,182,187,193,197,,,211,215,221,249,252,254,256,241,242', -'244,168,171,173,178,183,189,199,203,207,246,247,248,226,,,255,,,,,,', -',184,190,,200,204,214,219,,227,230,,,239,,,,,177,181,186,192,,,,,,,', -',,,,,243,170,,175,179,188,194,198,202,206,212,216,,225,,,237,257,,,18', -'22,26,,37,,,40,53,63,,,,82,,91,95,6,11,17,23,27,,,,,51,56,60,64,69,73', -'77,,,97,,,,,,,39,,,48,52,59,67,70,74,78,83,88,92,,9,15,,25,30,36,,,', -',,,,,,,,,,,,,,,,136,,,139,,,72,76,,87,,,,,,20,,,,,,,,61,,,,,84,89,93', -'4,10,16,,,,34,40,18,22,26,,37,,,,53,63,,,,82,,91,95,6,106,107,23,27', -',,,,114,115,116,64,69,73,77,,,,,,,,,,39,,,48,52,59,67,70,74,78,83,88', -'92,,9,15,,25,30,36,,,,,,,,,,,,,,,,,,,,136,,,139,,,72,76,,87,,,,,,20', -',,,,,,,141,,,,,84,89,93,4,10,16,,,,34,40,18,22,26,,37,,,,53,63,,,,82', -',91,95,6,106,107,23,27,,,,,114,115,116,64,69,73,77,,,,,,,,,,39,,,48', -'52,59,67,70,74,78,83,88,92,,9,15,,25,30,36,,,,,,,,,,,,,,,,,,,,136,,', -'139,,,72,76,,87,,,,,,20,,,,,,,,141,,,,,84,89,93,4,10,16,,,,34,40,18', -'22,26,,37,,,,53,63,,,,82,,91,95,6,106,107,23,27,,,,,114,115,116,64,69', -'73,77,,,,,,,,,,39,,,48,52,59,67,70,74,78,83,88,92,,9,15,,25,30,36,,', -',,,,,,,,,,,,,,,,,136,,,139,,,72,76,,87,,788,,131,,20,,,,,,,,141,,,,', -'84,89,93,4,10,16,,,,34,40,18,22,26,,37,,,,53,63,,,,82,,91,95,6,106,107', -'23,27,,,,,114,115,116,64,69,73,77,,,,,,,,,,112,,,48,52,59,67,70,74,78', -'83,88,92,,9,15,,,,110,,,,,,,,,,,,,,,,,,,,162,,,163,,,72,76,,87,,164', -',,,,,,,,,,,,,,,,84,89,93,4,10,16,,,,34,40,18,22,26,,37,,,,53,63,,,,82', -',91,95,6,106,107,23,27,,,,,114,115,116,64,69,73,77,,,,,,,,,,39,,,48', -'52,59,67,70,74,78,83,88,92,,9,15,,25,30,36,,,,,,,,,,,,,,,,,,,,136,,', -'139,,,72,76,,87,,,,,,20,,,,,,,,141,,,,,84,89,93,4,10,16,,,,34,40,18', -'22,26,,37,,,,53,63,,,,82,,91,95,6,106,107,23,27,,,,,114,56,60,64,69', -'73,77,,,,,,,,,,39,,,48,52,59,67,70,74,78,83,88,92,,9,15,,25,30,36,,', -',,,,,,,,,,,,,,,,,136,,,139,,,72,76,,87,,332,,,,20,,,,,,,,141,,,,,84', -'89,93,4,10,16,,,,34,40,18,22,26,,37,,,,53,63,,,,82,,91,95,6,11,17,23', -'27,,,,,51,56,60,64,69,73,77,,,,,,,,,,39,,,48,52,59,67,70,74,78,83,88', -'92,,9,15,,25,30,36,,,,,,,,,,,,,,,,,,,,136,,,139,,,72,76,,87,,,,,,20', -',,,,,,,141,,,,,84,89,93,4,10,16,,,,34,40,18,22,26,,37,,,,53,63,,,,82', -',91,95,6,106,107,23,27,,,,,114,115,116,64,69,73,77,,,,,,,,,,39,,,48', -'52,59,67,70,74,78,83,88,92,,9,15,,25,30,36,,,,,,,,,,,,,,,,,,,,136,,', -'139,,,72,76,,87,,,,,,20,,,,,,,,141,,,,,84,89,93,4,10,16,,,,34,40,18', -'22,26,,37,,,,53,63,,,,82,,91,95,6,106,107,23,27,,,,,114,115,116,64,69', -'73,77,,,,,,,,,,39,,,48,52,59,67,70,74,78,83,88,92,,9,15,,25,30,36,,', -',,,,,,,,,,,,,,,,,136,,,139,,,72,76,,87,,763,,,,20,,,,,,,,141,,,,,84', -'89,93,4,10,16,,,,34,40,18,22,26,,37,,,,53,63,,,,82,,91,95,6,106,107', -'23,27,,,,,114,115,116,64,69,73,77,,,,,,,,,,39,,,48,52,59,67,70,74,78', -'83,88,92,,9,15,,25,30,36,,,,,,,,,,,,,,,,,,,,136,,,139,,,72,76,,87,,', -',,,20,,,,,,,,141,,,,,84,89,93,4,10,16,,,,34,40,18,22,26,31,37,,,,53', -'63,,,,82,,91,95,6,11,17,23,27,,,,,51,56,60,64,69,73,77,,,97,,,,,,29', -'39,44,47,48,52,59,67,70,74,78,83,88,92,,9,15,,25,30,36,,,,,,,,,,,,,', -',,,,,,43,,,54,,,72,76,,87,,96,,,,20,,,,,,,,61,,,,,84,89,93,4,10,16,', -',,34,40,18,22,26,,37,,,,53,63,,,,82,,91,95,6,106,107,23,27,,,,,114,115', -'116,64,69,73,77,,,,,,,,,,39,,,48,52,59,67,70,74,78,83,88,92,,9,15,,25', -'30,36,,,,,,,,,,,,,,,,,,,,136,,,139,,,72,76,,87,,,,,,20,,,,,,,,141,,', -',,84,89,93,4,10,16,,,,34,40,18,22,26,,37,,,,53,63,,,,82,,91,95,6,106', -'107,23,27,,,,,114,115,116,64,69,73,77,,,,,,,,,,39,,,48,52,59,67,70,74', -'78,83,88,92,,9,15,,25,30,36,,,,,,,,,,,,,,,,,,,,136,,,139,,,72,76,,87', -',865,,131,,20,,,,,,,,141,,,,,84,89,93,4,10,16,,,,34,40,18,22,26,,37', -',,,53,63,,,,82,,91,95,6,106,107,23,27,,,,,114,115,116,64,69,73,77,,', -',,,,,,,39,,,48,52,59,67,70,74,78,83,88,92,,9,15,,25,30,36,,,,,,,,,,', -',,,,,,,,,136,,,139,,,72,76,,87,,,,,,20,,,,,,,,141,,,,,84,89,93,4,10', -'16,,,,34,40,18,22,26,,37,,,,53,63,,,,82,,91,95,6,106,107,23,27,,,,,114', -'115,116,64,69,73,77,,,,,,,,,,39,,,48,52,59,67,70,74,78,83,88,92,,9,15', -',25,30,36,,,,,,,,,,,,,,,,,,,,136,,,139,,,72,76,,87,,862,,131,,20,,,', -',,,,141,,,,,84,89,93,4,10,16,,,,34,40,18,22,26,,37,,,,53,63,,,,82,,91', -'95,6,106,107,23,27,,,,,114,115,116,64,69,73,77,,,,,,,,,,39,,,48,52,59', -'67,70,74,78,83,88,92,,9,15,,25,30,36,,,,,,,,,,,,,,,,,,,,136,,,139,,', -'72,76,,87,,,,,,20,,,,,,,,141,,,,,84,89,93,4,10,16,,,,34,40,18,22,26', -',37,,,,53,63,,,,82,,91,95,6,106,107,23,27,,,,,114,115,116,64,69,73,77', -',,,,,,,,,112,,,48,52,418,67,70,74,419,83,88,92,,9,15,,,,110,,,,,,,,', -',,,,,,,,,,,415,,,139,,,72,76,,87,,,,,,,,,,,,,,,,,,,84,89,93,4,10,16', -',,,34,40,18,22,26,,37,,,,53,63,,,,82,,91,95,6,11,17,23,27,,,,,51,56', -'60,64,69,73,77,,,,,,,,,,39,,,48,52,59,67,70,74,78,83,88,92,,9,15,,25', -'30,36,,,,,,,,,,,,,,,,,,,,136,,,139,,,72,76,,87,,,,,,20,,,,,,,,141,,', -',,84,89,93,4,10,16,,,,34,40,18,22,26,,37,,,,53,63,,,,82,,91,95,6,11', -'17,23,27,,,,,51,56,60,64,69,73,77,,,97,,,,,,,39,,,48,52,59,67,70,74', -'78,83,88,92,,9,15,,25,30,36,,,,,,,,,,,,,,,,,,,,136,,,139,,,72,76,,87', -',,,,,20,,,,,,,,61,,,,,84,89,93,4,10,16,,,,34,40,18,22,26,,37,,,,53,63', -',,,82,,91,95,6,106,107,23,27,,,,,114,115,116,64,69,73,77,,,,,,,,,,39', -',,48,52,59,67,70,74,78,83,88,92,,9,15,,25,30,36,,,,,,,,,,,,,,,,,,,,136', -',,139,,,72,76,,87,,591,,131,,20,,,,,,,,141,,,,,84,89,93,4,10,16,,,,34', -'40,18,22,26,,37,,,,53,63,,,,82,,91,95,6,11,17,23,27,,,,,51,56,60,64', -'69,73,77,,,,,,,,,,39,,,48,52,59,67,70,74,78,83,88,92,,9,15,,25,30,36', -',,,,,,,,,,,,,,,,,,,136,,,139,,,72,76,,87,,,,,,20,,,,,,,,141,,,,,84,89', -'93,4,10,16,,,,34,40,18,22,26,,37,,,,53,63,,,,82,,91,95,6,106,107,23', -'27,,,,,114,115,116,64,69,73,77,,,,,,,,,,39,,,48,52,59,67,70,74,78,83', -'88,92,,9,15,,25,30,36,,,,,,,,,,,,,,,,,,,,136,,,139,,,72,76,,87,,,,,', -'20,,,,,,,,141,,,,,84,89,93,4,10,16,,,,34,40,18,22,26,,37,,,,53,63,,', -',82,,91,95,6,106,107,23,27,,,,,114,115,116,64,69,73,77,,,,,,,,,,39,', -',48,52,59,67,70,74,78,83,88,92,,9,15,,25,30,36,,,,,,,,,,,,,,,,,,,,136', -',,139,,,72,76,,87,,897,,131,,20,,,,,,,,141,,,,,84,89,93,4,10,16,,,,34', -'40,18,22,26,,37,,,,53,63,,,,82,,91,95,6,106,107,23,27,,,,,114,115,116', -'64,69,73,77,,,,,,,,,,39,,,48,52,59,67,70,74,78,83,88,92,,9,15,,25,30', -'36,,,,,,,,,,,,,,,,,,,,136,,,139,,,72,76,,87,,857,,,,20,,,,,,,,141,,', -',,84,89,93,4,10,16,,,,34,40,18,22,26,,37,,,,53,63,,,,82,,91,95,6,106', -'107,23,27,,,,,114,115,116,64,69,73,77,,,,,,,,,,39,,,48,52,59,67,70,74', -'78,83,88,92,,9,15,,25,30,36,,,,,,,,,,,,,,,,,,,,136,,,139,,,72,76,,87', -',,,,,20,,,,,,,,141,,,,,84,89,93,4,10,16,,,,34,40,18,22,26,,37,,,,53', -'63,,,,82,,91,95,6,106,107,23,27,,,,,114,115,116,64,69,73,77,,,,,,,,', -',112,,,48,52,59,67,70,74,78,83,88,92,,9,15,,,,110,,,,,,,,,,,,,,,,,,', -',162,,,139,,,72,76,,87,,,,,,,,,,,,,,,,,,,84,89,93,4,10,16,,,,34,40,18', -'22,26,,37,,,,53,63,,,,82,,91,95,6,106,107,23,27,,,,,114,115,116,64,69', -'73,77,,,,,,,,,,112,,,48,52,418,67,70,74,419,83,88,92,,9,15,,,,110,,', -',,,,,,,,,,,,,,,,,415,,,139,,,72,76,,87,,,,,,,,,,,,,,,,,,,84,89,93,4', -'10,16,,,,34,40,18,22,26,,37,,,,53,63,,,,82,,91,95,6,106,107,23,27,,', -',,114,56,60,64,69,73,77,,,,,,,,,,39,,,48,52,59,67,70,74,78,83,88,92', -',9,15,,25,30,36,,,,,,,,,,,,,,,,,,,,136,,,139,,,72,76,,87,,585,,131,', -'20,,,,,,,,141,,,,,84,89,93,4,10,16,,,,34,40,18,22,26,,37,,,,53,63,,', -',82,,91,95,6,106,107,23,27,,,,,114,115,116,64,69,73,77,,,,,,,,,,39,', -',48,52,59,67,70,74,78,83,88,92,,9,15,,25,30,36,,,,,,,,,,,,,,,,,,,,136', -',,139,,,72,76,,87,,,,,,20,,,,,,,,141,,,,,84,89,93,4,10,16,,,,34,40,18', -'22,26,,37,,,,53,63,,,,82,,91,95,6,106,107,23,27,,,,,114,115,116,64,69', -'73,77,,,,,,,,,,39,,,48,52,59,67,70,74,78,83,88,92,,9,15,,25,30,36,,', -',,,,,,,,,,,,,,,,,136,,,139,,,72,76,,87,,,,,,20,,,,,,,,141,,,,,84,89', -'93,4,10,16,,,,34,40,18,22,26,,37,,,,53,63,,,,82,,91,95,6,106,107,23', -'27,,,,,114,115,116,64,69,73,77,,,,,,,,,,39,,,48,52,59,67,70,74,78,83', -'88,92,,9,15,,25,30,36,,,,,,,,,,,,,,,,,,,,136,,,139,,,72,76,,87,,585', -',131,,20,,,,,,,,141,,,,,84,89,93,4,10,16,,,,34,40,18,22,26,,37,,,,53', -'63,,,,82,,91,95,6,106,107,23,27,,,,,114,115,116,64,69,73,77,,,,,,,,', -',39,,,48,52,59,67,70,74,78,83,88,92,,9,15,,25,30,36,,,,,,,,,,,,,,,,', -',,,136,,,139,,,72,76,,87,,,,,,20,,,,,,,,141,,,,,84,89,93,4,10,16,,,', -'34,40,18,22,26,,37,,,,53,63,,,,82,,91,95,6,106,107,23,27,,,,,114,115', -'116,64,69,73,77,,,,,,,,,,112,,,48,52,59,67,70,74,78,83,88,92,,9,15,', -',,110,,,,,,,,,,,,,,,,,,,,113,,,54,,,72,76,,87,,96,,,,,,,,,,,697,,,,', -',84,89,93,4,10,16,,,,34,40,18,22,26,,37,,,,53,63,,,,82,,91,95,6,11,17', -'23,27,,,,,51,56,60,64,69,73,77,,,97,,,,,,,39,,,48,52,59,67,70,74,78', -'83,88,92,,9,15,,25,30,36,,,,,,,,,,,,,,,,,,,,136,,,139,,,72,76,,87,,', -',,,20,,,,,,,,61,,,,,84,89,93,4,10,16,,,,34,40,18,22,26,,37,,,,53,63', -',,,82,,91,95,6,106,107,23,27,,,,,114,115,116,64,69,73,77,,,,,,,,,,39', -',,48,52,59,67,70,74,78,83,88,92,,9,15,,25,30,36,,,,,,,,,,,,,,,,,,,,136', -',,139,,,72,76,,87,,,,,,20,,,,,,,,141,,,,,84,89,93,4,10,16,,,,34,40,18', -'22,26,,37,,,,53,63,,,,82,,91,95,6,106,107,23,27,,,,,114,115,116,64,69', -'73,77,,,,,,,,,,39,,,48,52,59,67,70,74,78,83,88,92,,9,15,,25,30,36,,', -',,,,,,,,,,,,,,,,,136,,,139,,,72,76,,87,,,,,,20,,,,,,,,141,,,,,84,89', -'93,4,10,16,,,,34,40,18,22,26,,37,,,,53,63,,,,82,,91,95,6,106,107,23', -'27,,,,,114,115,116,64,69,73,77,,,,,,,,,,39,,,48,52,59,67,70,74,78,83', -'88,92,,9,15,,25,30,36,,,,,,,,,,,,,,,,,,,,136,,,139,,,72,76,,87,,,,,', -'20,,,,,,,,141,,,,,84,89,93,4,10,16,,,,34,40,18,22,26,,37,,,,53,63,,', -',82,,91,95,6,106,107,23,27,,,,,114,56,60,64,69,73,77,,,,,,,,,,39,,,48', -'52,59,67,70,74,78,83,88,92,,9,15,,25,30,36,,,,,,,,,,,,,,,,,,,,136,,', -'139,,,72,76,,87,,332,,,,20,,,,,,,,141,,,,,84,89,93,4,10,16,,,,34,40', -'18,22,26,,37,,,,53,63,,,,82,,91,95,6,11,17,23,27,,,,,51,56,60,64,69', -'73,77,,,97,,,,,,,39,,,48,52,59,67,70,74,78,83,88,92,,9,15,,25,30,36', -',,,,,,,,,,,,,,,,,,,136,,,139,,,72,76,,87,,572,,131,,20,,,,,,,,61,,,', -',84,89,93,4,10,16,,,,34,40,18,22,26,,37,,,,53,63,,,,82,,91,95,6,106', -'107,23,27,,,,,114,115,116,64,69,73,77,,,,,,,,,,39,,,48,52,59,67,70,74', -'78,83,88,92,,9,15,,25,30,36,,,,,,,,,,,,,,,,,,,,136,,,139,,,72,76,,87', -',,,,,20,,,,,,,,141,,,,,84,89,93,4,10,16,,,,34,40,18,22,26,,37,,,,53', -'63,,,,82,,91,95,6,11,17,23,27,,,,,51,56,60,64,69,73,77,,,97,,,,,,,39', -',,48,52,59,67,70,74,78,83,88,92,,9,15,,25,30,36,,,,,,,,,,,,,,,,,,,,136', -',,139,,,72,76,,87,,,,,,20,,,,,,,,61,,,,,84,89,93,4,10,16,,,,34,40,18', -'22,26,,37,,,,53,63,,,,82,,91,95,6,11,17,23,27,,,,,51,56,60,64,69,73', -'77,,,97,,,,,,,39,,,48,52,59,67,70,74,78,83,88,92,,9,15,,25,30,36,,,', -',,,,,,,,,,,,,,,,136,,,139,,,72,76,,87,,,,,,20,,,,,,,,61,,,,,84,89,93', -'4,10,16,,,,34,40,18,22,26,,37,,,,53,63,,,,82,,91,95,6,106,107,23,27', -',,,,114,56,60,64,69,73,77,,,,,,,,,,39,,,48,52,59,67,70,74,78,83,88,92', -',9,15,,25,30,36,,,,,,,,,,,,,,,,,,,,136,,,139,,,72,76,,87,,146,,131,', -'20,,,,,,,,141,,,,,84,89,93,4,10,16,,,,34,40,18,22,26,,37,,,,53,63,,', -',82,,91,95,6,106,107,23,27,,,,,114,115,116,64,69,73,77,,,,,,,,,,112', -',,48,52,59,67,70,74,78,83,88,92,,9,15,,,,110,,,,,,,,,,,,,,,,,,,,850', -',,139,,,72,76,,87,,,,,,,,,,,,,,,,,,,84,89,93,4,10,16,,,,34,40,18,22', -'26,,37,,,,53,63,,,,82,,91,95,6,106,107,23,27,,,,,114,56,60,64,69,73', -'77,,,,,,,,,,39,,,48,52,59,67,70,74,78,83,88,92,,9,15,,25,30,36,,,,,', -',,,,,,,,,,,,,,136,,,139,,,72,76,,87,,332,,,,20,,,,,,,,141,,,,,84,89', -'93,4,10,16,,,,34,40,18,22,26,,37,,,,53,63,,,,82,,91,95,6,106,107,23', -'27,,,,,114,115,116,64,69,73,77,,,,,,,,,,39,,,48,52,59,67,70,74,78,83', -'88,92,,9,15,,25,30,36,,,,,,,,,,,,,,,,,,,,136,,,139,449,,72,76,,87,,', -',,,20,,,,,,,,141,,,,,84,89,93,4,10,16,,,,34,40,176,180,185,191,196,201', -'205,210,,,228,231,232,235,240,,,169,172,174,182,187,193,197,,,211,215', -'221,249,252,254,256,241,242,244,168,171,173,178,183,189,199,203,207', -'246,247,248,226,,,255,,,,,,,,184,190,,200,204,214,219,,227,230,,,239', -',,,,177,181,186,192,,,,,,,,,,,,,243,170,,175,179,188,194,198,202,206', -'212,216,,225,,,237,257,,,18,22,26,,37,,,40,53,63,,,,82,,91,95,6,106', -'107,23,27,,,,,114,115,116,64,69,73,77,,,,,,,,,,39,,,48,52,59,67,70,74', -'78,83,88,92,,9,15,,25,30,36,,,,,,,,,,,,,,,,,,,,136,,,139,,,72,76,,87', -',,,,,20,,,,,,,,141,,,,,84,89,93,4,10,16,,,,34,40,176,180,185,191,196', -'201,205,210,,,228,231,232,235,240,,,169,172,174,182,187,193,197,,,211', -'215,221,249,252,254,256,241,242,244,168,171,173,178,183,189,199,203', -'207,246,247,248,226,253,,255,,,,,,,,184,190,,200,204,214,219,,227,230', -',,239,,,,,177,181,186,192,,,,,,,,,,,,,243,170,,175,179,188,194,198,202', -'206,212,216,,225,,,237,257,,,18,22,26,,37,,,40,53,63,,,,82,,91,95,6', -'106,107,23,27,,,,,114,115,116,64,69,73,77,,,,,,,,,,39,,,48,52,59,67', -'70,74,78,83,88,92,,9,15,,25,30,36,,,,,,,,,,,,,,,,,,,,136,,,139,,,72', -'76,,87,,,,,,20,,,,,,,,141,,,,,84,89,93,4,10,16,,,,34,40,18,22,26,,37', -',,,53,63,,,,82,,91,95,6,106,107,23,27,,,,,114,115,116,64,69,73,77,,', -',,,,,,,39,,,48,52,59,67,70,74,78,83,88,92,,9,15,,25,30,36,,,,,,,,,,', -',,,,,,,,,136,,,139,,,72,76,,87,,,,,,20,,,,,,,,141,,,,,84,89,93,4,10', -'16,,,,34,40,18,22,26,,37,,,,53,63,,,,82,,91,95,6,106,107,23,27,,,,,114', -'115,116,64,69,73,77,,,,,,,,,,39,,,48,52,59,67,70,74,78,83,88,92,,9,15', -',25,30,36,,,,,,,,,,,,,,,,,,,,136,,,139,,,72,76,,87,,,,,,20,,,,,,,,141', -',,,,84,89,93,4,10,16,,,,34,40,18,22,26,,37,,,,53,63,,,,82,,91,95,6,106', -'107,23,27,,,,,114,115,116,64,69,73,77,,,,,,,,,,39,,,48,52,59,67,70,74', -'78,83,88,92,,9,15,,25,30,36,,,,,,,,,,,,,,,,,,,,136,,,139,,,72,76,,87', -',,,,,20,,,,,,,,141,,,,,84,89,93,4,10,16,,,,34,40,18,22,26,,37,,,,53', -'63,,,,82,,91,95,6,106,107,23,27,,,,,114,115,116,64,69,73,77,,,,,,,,', -',39,,,48,52,59,67,70,74,78,83,88,92,,9,15,,25,30,36,,,,,,,,,,,,,,,,', -',,,136,,,139,,,72,76,,87,,,,,,20,,,,,,,,141,,,,,84,89,93,4,10,16,,,', -'34,40,18,22,26,,37,,,,53,63,,,,82,,91,95,6,106,107,23,27,,,,,114,115', -'116,64,69,73,77,,,,,,,,,,39,,,48,52,59,67,70,74,78,83,88,92,,9,15,,25', -'30,36,,,,,,,,,,,,,,,,,,,,136,,,139,,,72,76,,87,,,,,,20,,,,,,,,141,,', -',,84,89,93,4,10,16,,,,34,40,18,22,26,,37,,,,53,63,,,,82,,91,95,6,106', -'107,23,27,,,,,114,115,116,64,69,73,77,,,,,,,,,,39,,,48,52,59,67,70,74', -'78,83,88,92,,9,15,,25,30,36,,,,,,,,,,,,,,,,,,,,136,,,139,,,72,76,,87', -',,,,,20,,,,,,,,141,,,,,84,89,93,4,10,16,,,,34,40,18,22,26,,37,,,,53', -'63,,,,82,,91,95,6,106,107,23,27,,,,,114,115,116,64,69,73,77,,,,,,,,', -',39,,,48,52,59,67,70,74,78,83,88,92,,9,15,,25,30,36,,,,,,,,,,,,,,,,', -',,,136,,,139,,,72,76,,87,,,,,,20,,,,,,,,141,,,,,84,89,93,4,10,16,,,', -'34,40,18,22,26,,37,,,,53,63,,,,82,,91,95,6,106,107,23,27,,,,,114,115', -'116,64,69,73,77,,,,,,,,,,39,,,48,52,59,67,70,74,78,83,88,92,,9,15,,25', -'30,36,,,,,,,,,,,,,,,,,,,,136,,,139,,,72,76,,87,,,,,,20,,,,,,,,141,,', -',,84,89,93,4,10,16,,,,34,40,18,22,26,,37,,,,53,63,,,,82,,91,95,6,106', -'107,23,27,,,,,114,115,116,64,69,73,77,,,,,,,,,,39,,,48,52,59,67,70,74', -'78,83,88,92,,9,15,,25,30,36,,,,,,,,,,,,,,,,,,,,136,,,139,,,72,76,,87', -',,,,,20,,,,,,,,141,,,,,84,89,93,4,10,16,,,,34,40,18,22,26,,37,,,,53', -'63,,,,82,,91,95,6,106,107,23,27,,,,,114,115,116,64,69,73,77,,,,,,,,', -',39,,,48,52,59,67,70,74,78,83,88,92,,9,15,,25,30,36,,,,,,,,,,,,,,,,', -',,,136,,,139,,,72,76,,87,,,,,,20,,,,,,,,141,,,,,84,89,93,4,10,16,,,', -'34,40,18,22,26,,37,,,,53,63,,,,82,,91,95,6,106,107,23,27,,,,,114,115', -'116,64,69,73,77,,,,,,,,,,39,,,48,52,59,67,70,74,78,83,88,92,,9,15,,25', -'30,36,,,,,,,,,,,,,,,,,,,,136,,,139,,,72,76,,87,,,,,,20,,,,,,,,141,,', -',,84,89,93,4,10,16,,,,34,40,18,22,26,,37,,,,53,63,,,,82,,91,95,6,106', -'107,23,27,,,,,114,115,116,64,69,73,77,,,,,,,,,,39,,,48,52,59,67,70,74', -'78,83,88,92,,9,15,,25,30,36,,,,,,,,,,,,,,,,,,,,136,,,139,,,72,76,,87', -',,,,,20,,,,,,,,141,,,,,84,89,93,4,10,16,,,,34,40,18,22,26,,37,,,,53', -'63,,,,82,,91,95,6,106,107,23,27,,,,,114,115,116,64,69,73,77,,,,,,,,', -',39,,,48,52,59,67,70,74,78,83,88,92,,9,15,,25,30,36,,,,,,,,,,,,,,,,', -',,,136,,,139,,,72,76,,87,,,,,,20,,,,,,,,141,,,,,84,89,93,4,10,16,,,', -'34,40,18,22,26,,37,,,,53,63,,,,82,,91,95,6,106,107,23,27,,,,,114,115', -'116,64,69,73,77,,,,,,,,,,39,,,48,52,59,67,70,74,78,83,88,92,,9,15,,25', -'30,36,,,,,,,,,,,,,,,,,,,,136,,,139,,,72,76,,87,,,,,,20,,,,,,,,141,,', -',,84,89,93,4,10,16,,,,34,40,18,22,26,,37,,,,53,63,,,,82,,91,95,6,106', -'107,23,27,,,,,114,115,116,64,69,73,77,,,,,,,,,,39,,,48,52,59,67,70,74', -'78,83,88,92,,9,15,,25,30,36,,,,,,,,,,,,,,,,,,,,136,,,139,,,72,76,,87', -',,,,,20,,,,,,,,141,,,,,84,89,93,4,10,16,,,,34,40,18,22,26,,37,,,,53', -'63,,,,82,,91,95,6,106,107,23,27,,,,,114,115,116,64,69,73,77,,,,,,,,', -',39,,,48,52,59,67,70,74,78,83,88,92,,9,15,,25,30,36,,,,,,,,,,,,,,,,', -',,,136,,,139,,,72,76,,87,,,,,,20,,,,,,,,141,,,,,84,89,93,4,10,16,,,', -'34,40,18,22,26,,37,,,,53,63,,,,82,,91,95,6,106,107,23,27,,,,,114,115', -'116,64,69,73,77,,,,,,,,,,39,,,48,52,59,67,70,74,78,83,88,92,,9,15,,25', -'30,36,,,,,,,,,,,,,,,,,,,,136,,,139,,,72,76,,87,,,,,,20,,,,,,,,141,,', -',,84,89,93,4,10,16,,,,34,40,18,22,26,,37,,,,53,63,,,,82,,91,95,6,106', -'107,23,27,,,,,114,115,116,64,69,73,77,,,,,,,,,,39,,,48,52,59,67,70,74', -'78,83,88,92,,9,15,,25,30,36,,,,,,,,,,,,,,,,,,,,136,,,139,,,72,76,,87', -',,,,,20,,,,,,,,141,,,,,84,89,93,4,10,16,,,,34,40,18,22,26,,37,,,,53', -'63,,,,82,,91,95,6,106,107,23,27,,,,,114,115,116,64,69,73,77,,,,,,,,', -',39,,,48,52,59,67,70,74,78,83,88,92,,9,15,,25,30,36,,,,,,,,,,,,,,,,', -',,,136,,,139,,,72,76,,87,,,,,,20,,,,,,,,141,,,,,84,89,93,4,10,16,,,', -'34,40,18,22,26,,37,,,,53,63,,,,82,,91,95,6,106,107,23,27,,,,,114,115', -'116,64,69,73,77,,,,,,,,,,39,,,48,52,59,67,70,74,78,83,88,92,,9,15,,25', -'30,36,,,,,,,,,,,,,,,,,,,,136,,,139,,,72,76,,87,,,,,,20,,,,,,,,141,,', -',,84,89,93,4,10,16,,,,34,40,18,22,26,,37,,,,53,63,,,,82,,91,95,6,106', -'107,23,27,,,,,114,115,116,64,69,73,77,,,,,,,,,,39,,,48,52,59,67,70,74', -'78,83,88,92,,9,15,,25,30,36,,,,,,,,,,,,,,,,,,,,136,,,139,,,72,76,,87', -',,,,,20,,,,,,,,141,,,,,84,89,93,4,10,16,,,,34,40,18,22,26,,37,,,,53', -'63,,,,82,,91,95,6,106,107,23,27,,,,,114,115,116,64,69,73,77,,,,,,,,', -',39,,,48,52,59,67,70,74,78,83,88,92,,9,15,,25,30,36,,,,,,,,,,,,,,,,', -',,,136,,,139,,,72,76,,87,,,,,,20,,,,,,,,141,,,,,84,89,93,4,10,16,,,', -'34,40,18,22,26,,37,,,,53,63,,,,82,,91,95,6,106,107,23,27,,,,,114,115', -'116,64,69,73,77,,,,,,,,,,39,,,48,52,59,67,70,74,78,83,88,92,,9,15,,25', -'30,36,,,,,,,,,,,,,,,,,,,,136,,,139,,,72,76,,87,,,,,,20,,,,,,,,141,,', -',,84,89,93,4,10,16,,,,34,40,18,22,26,,37,,,,53,63,,,,82,,91,95,6,106', -'107,23,27,,,,,114,115,116,64,69,73,77,,,,,,,,,,39,,,48,52,59,67,70,74', -'78,83,88,92,,9,15,,25,30,36,,,,,,,,,,,,,,,,,,,,136,,,139,,,72,76,,87', -',,,,,20,,,,,,,,141,,,,,84,89,93,4,10,16,,,,34,40,18,22,26,,37,,,,53', -'63,,,,82,,91,95,6,106,107,23,27,,,,,114,115,116,64,69,73,77,,,,,,,,', -',39,,,48,52,59,67,70,74,78,83,88,92,,9,15,,25,30,36,,,,,,,,,,,,,,,,', -',,,136,,,139,,,72,76,,87,,,,,,20,,,,,,,,141,,,,,84,89,93,4,10,16,,,', -'34,40,-251,-251,-251,,-251,,,,-251,-251,,,,-251,,-251,-251,-251,-251', -'-251,-251,-251,,,,,-251,-251,-251,-251,-251,-251,-251,,,,,,,,,,-251', -',,-251,-251,-251,-251,-251,-251,-251,-251,-251,-251,,-251,-251,,-251', -'-251,-251,,,,,,,,,,,,,,,,,,,,-251,,,-251,321,,-251,-251,,-251,,-251', -',-251,,-251,,,,,,,,-251,,,,,-251,-251,-251,-251,-251,-251,,,,-251,-251', -'176,180,185,191,196,201,205,210,,,228,231,232,235,240,,,169,172,174', -'182,187,193,197,,,211,215,221,249,252,254,256,241,242,244,168,171,173', -'178,183,189,199,203,207,246,247,248,226,,,255,,,,,,,,184,190,,200,204', -'214,219,,227,230,,,239,,,,,177,181,186,192,,,,,,,,,,,,,243,170,,175', -'179,188,194,198,202,206,212,216,,225,,,237,257,,,-485,-485,-485,,-485', -',,40,-485,-485,,,,-485,,-485,-485,-485,-485,-485,-485,-485,,,,,-485', -'-485,-485,-485,-485,-485,-485,,,,,,,,,,-485,,,-485,-485,-485,-485,-485', -'-485,-485,-485,-485,-485,,-485,-485,,-485,-485,-485,,,,,,,,,,,,,,,,', -',,,-485,,,-485,-485,,-485,-485,,-485,,-485,,-485,,-485,,,,,,,,-485,', -',,,-485,-485,-485,-485,-485,-485,,,,-485,-485,18,22,26,,37,,,,53,63', -',,,82,,91,95,6,106,107,23,27,,,,,114,115,116,64,69,73,77,,,,,,,,,,39', -',,48,52,59,67,70,74,78,83,88,92,,9,15,,25,30,36,,,,,,,,,,,,,,,,,,,,136', -',,139,,,72,76,,87,,,,,,20,,,,,,,,141,,,,,84,89,93,4,10,16,,,,34,40,18', -'22,26,,37,,,,53,63,,,,82,,91,95,6,106,107,23,27,,,,,114,115,116,64,69', -'73,77,,,,,,,,,,39,,,48,52,59,67,70,74,78,83,88,92,,9,15,,25,30,36,,', -',,,,,,,,,,,,,,,,,136,,,139,,,72,76,,87,,782,,131,,20,,,,,,,,141,,,,', -'84,89,93,4,10,16,,,,34,40,18,22,26,,37,,,,53,63,,,,82,,91,95,6,106,107', -'23,27,,,,,114,115,116,64,69,73,77,,,,,,,,,,39,,,48,52,59,67,70,74,78', -'83,88,92,,9,15,,25,30,36,,,,,,,,,,,,,,,,,,,,136,,,139,,,72,76,,87,,', -',,,20,,,,,,,,141,,,,,84,89,93,4,10,16,,,,34,40,18,22,26,,37,,,,53,63', -',,,82,,91,95,6,106,107,23,27,,,,,114,115,116,64,69,73,77,,,,,,,,,,39', -',,48,52,59,67,70,74,78,83,88,92,,9,15,,25,30,36,,,,,,,,,,,,,,,,,,,,136', -',,139,,,72,76,,87,,,,,,20,,,,,,,,141,,,,,84,89,93,4,10,16,,,,34,40,18', -'22,26,,37,,,,53,63,,,,82,,91,95,6,106,107,23,27,,,,,114,56,60,64,69', -'73,77,,,,,,,,,,39,,,48,52,59,67,70,74,78,83,88,92,,9,15,,25,30,36,,', -',,,,,,,,,,,,,,,,,136,,,139,,490,72,76,,87,,146,,131,,20,,,,,,,,141,', -',,,84,89,93,4,10,16,,,,34,40,18,22,26,,37,,,,53,63,,,,82,,91,95,6,11', -'17,23,27,,,,,51,56,60,64,69,73,77,,,97,,,,,,,39,,,48,52,59,67,70,74', -'78,83,88,92,,9,15,,25,30,36,,,,,,,,,,,,,,,,,,,,136,,,139,,,72,76,,87', -',,,,,20,,,,,,,,61,,,,,84,89,93,4,10,16,,,,34,40,18,22,26,,37,,,,53,63', -',,,82,,91,95,6,11,17,23,27,,,,,51,56,60,64,69,73,77,,,97,,,,,,,39,,', -'48,52,59,67,70,74,78,83,88,92,,9,15,,25,30,36,,,,,,,,,,,,,,,,,,,,136', -',,139,,,72,76,,87,,,,,,20,,,,,,,,61,,,,,84,89,93,4,10,16,,,,34,40,18', -'22,26,,37,,,,53,63,,,,82,,91,95,6,11,17,23,27,,,,,51,56,60,64,69,73', -'77,,,97,,,,,,,39,,,48,52,59,67,70,74,78,83,88,92,,9,15,,25,30,36,,,', -',,,,,,,,,,,,,,,,136,,,139,,,72,76,,87,,,,,,20,,,,,,,,61,,,,,84,89,93', -'4,10,16,,,,34,40,18,22,26,,37,,,,53,63,,,,82,,91,95,6,11,17,23,27,,', -',,51,56,60,64,69,73,77,,,97,,,,,,,39,,,48,52,59,67,70,74,78,83,88,92', -',9,15,,25,30,36,,,,,,,,,,,,,,,,,,,,136,,,139,,,72,76,,87,,,,,,20,,,', -',,,,61,,,,,84,89,93,4,10,16,,,,34,40,18,22,26,31,37,,,,53,63,,,,82,', -'91,95,6,11,17,23,27,,,,,51,56,60,64,69,73,77,,,97,,,,,,29,39,44,47,48', -'52,59,67,70,74,78,83,88,92,,9,15,,25,30,36,,,,,,,,,,,,,,,,,,,,43,,,54', -',,72,76,,87,,96,,,,20,,,,,,,,61,,,,,84,89,93,4,10,16,,,,34,40,18,22', -'26,,37,,,,53,63,,,,82,,91,95,6,106,107,23,27,,,,,114,56,60,64,69,73', -'77,,,,,,,,,,39,,,48,52,59,67,70,74,78,83,88,92,,9,15,,25,30,36,,,,,', -',,,,,,,,,,,,,,136,,,139,,,72,76,,87,,146,,131,,20,,,,,,,,141,,,,,84', -'89,93,4,10,16,,,,34,40,-486,-486,-486,,-486,,,,-486,-486,,,,-486,,-486', -'-486,-486,-486,-486,-486,-486,,,,,-486,-486,-486,-486,-486,-486,-486', -',,,,,,,,,-486,,,-486,-486,-486,-486,-486,-486,-486,-486,-486,-486,,-486', -'-486,,-486,-486,-486,,,,,,,,,,,,,,,,,,,,-486,,,-486,-486,,-486,-486', -',-486,,-486,,-486,,-486,,,,,,,,-486,,,,,-486,-486,-486,-486,-486,-486', -',,,-486,-486,18,22,26,,37,,,,53,63,,,,82,,91,95,6,11,17,23,27,,,,,51', -'56,60,64,69,73,77,,,97,,,,,,,39,,,48,52,59,67,70,74,78,83,88,92,,9,15', -',25,30,36,,,,,,,,,,,,,,,,,,,,136,,,139,,,72,76,,87,,,,,,20,,,,,,,,61', -',,,,84,89,93,4,10,16,,,,34,40,18,22,26,,37,,,,53,63,,,,82,,91,95,6,11', -'17,23,27,,,,,51,56,60,64,69,73,77,,,,,,,,,,39,,,48,52,59,67,70,74,78', -'83,88,92,,9,15,,25,30,36,,,,,,,,,,,,,,,,,,,,136,,,139,,,72,76,,87,,', -',,,20,,,,,,,,141,,,,,84,89,93,4,10,16,,,,34,40,18,22,26,,37,,,,53,63', -',,,82,,91,95,6,11,17,23,27,,,,,51,56,60,64,69,73,77,,,,,,,,,,39,,,48', -'52,59,67,70,74,78,83,88,92,,9,15,,25,30,36,,,,,,,,,,,,,,,,,,,,136,,', -'139,,,72,76,,87,,,,,,20,,,,,,,,141,,,,,84,89,93,4,10,16,,,,34,40,18', -'22,26,,37,,,,53,63,,,,82,,91,95,6,106,107,23,27,,,,,114,115,116,64,69', -'73,77,,,,,,,,,,39,,,48,52,59,67,70,74,78,83,88,92,,9,15,,25,30,36,,', -',,,,,,,,,,,,,,,,,136,,,139,,,72,76,,87,,,,,,20,,,,,,,,141,,,,,84,89', -'93,4,10,16,,,,34,40,18,22,26,,37,,,,53,63,,,,82,,91,95,6,106,107,23', -'27,,,,,114,115,116,64,69,73,77,,,,,,,,,,39,,,48,52,59,67,70,74,78,83', -'88,92,,9,15,,25,30,36,,,,,,,,,,,,,,,,,,,,136,,,139,,,72,76,,87,,,,,', -'20,,,,,,,,141,,,,,84,89,93,4,10,16,,,,34,40,18,22,26,,37,,,,53,63,,', -',82,,91,95,6,11,17,23,27,,,,,51,56,60,64,69,73,77,,,,,,,,,,39,,,48,52', -'59,67,70,74,78,83,88,92,,9,15,,25,30,36,,,,,,,,,,,,,,,,,,,,136,,,139', -',,72,76,,87,,,,,,20,,,,,,,,141,,,,,84,89,93,4,10,16,,,,34,40,18,22,26', -',37,,,,53,63,,,,82,,91,95,6,106,107,23,27,,,,,114,115,116,64,69,73,77', -',,,,,,,,,39,,,48,52,59,67,70,74,78,83,88,92,,9,15,,25,30,36,,,,,,,,', -',,,,,,,,,,,136,,,139,,,72,76,,87,,,,,,20,,,,,,,,141,,,,,84,89,93,4,10', -'16,,,,34,40,18,22,26,,37,,,,53,63,,,,82,,91,95,6,106,107,23,27,,,,,114', -'115,116,64,69,73,77,,,,,,,,,,39,,,48,52,59,67,70,74,78,83,88,92,,9,15', -',25,30,36,,,,,,,,,,,,,,,,,,,,136,,,139,,,72,76,,87,,785,,131,,20,,,', -',,,,141,,,,,84,89,93,4,10,16,,,,34,40,18,22,26,,37,,,,53,63,,,,82,,91', -'95,6,11,17,23,27,,,,,51,56,60,64,69,73,77,,,,,,,,,,39,,,48,52,59,67', -'70,74,78,83,88,92,,9,15,,25,30,36,,,,,,,,,,,,,,,,,,,,136,,,139,,,72', -'76,,87,,520,,,,20,,,,,,,,141,,,,,84,89,93,4,10,16,,,,34,40,18,22,26', -',37,,,,53,63,,,,82,,91,95,6,106,107,23,27,,,,,114,115,116,64,69,73,77', -',,,,,,,,,39,,,48,52,59,67,70,74,78,83,88,92,,9,15,,25,30,36,,,,,,,,', -',,,,,,,,,,,136,,,139,,,72,76,,87,,,,,,20,,,,,,,,141,,,,,84,89,93,4,10', -'16,,,,34,40,18,22,26,,37,,,,53,63,,,,82,,91,95,6,106,107,23,27,,,,,114', -'115,116,64,69,73,77,,,,,,,,,,39,,,48,52,59,67,70,74,78,83,88,92,,9,15', -',25,30,36,,,,,,,,,,,,,,,,,,,,136,,,139,,,72,76,,87,,,,,,20,,,,,,,,141', -',,,,84,89,93,4,10,16,,,,34,40,18,22,26,,37,,,,53,63,,,,82,,91,95,6,11', -'17,23,27,,,,,51,56,60,64,69,73,77,,,,,,,,,,39,,,48,52,59,67,70,74,78', -'83,88,92,,9,15,,25,30,36,,,,,,,,,,,,,,,,,,,,136,,,139,,,72,76,,87,,', -',,,20,,,,,,,,141,,,,,84,89,93,4,10,16,,,,34,40,18,22,26,,37,,,,53,63', -',,,82,,91,95,6,11,17,23,27,,,,,51,56,60,64,69,73,77,,,97,,,,,,,39,,', -'48,52,59,67,70,74,78,83,88,92,,9,15,,25,30,36,,,,,,,,,,,,,,,,,,,,136', -',,139,,,72,76,,87,,,,,,20,,,,,,,,61,,,,,84,89,93,4,10,16,,,,34,40,18', -'22,26,,37,,,,53,63,,,,82,,91,95,6,106,107,23,27,,,,,114,115,116,64,69', -'73,77,,,,,,,,,,39,,,48,52,59,67,70,74,78,83,88,92,,9,15,,25,30,36,,', -',,,,,,,,,,,,,,,,,136,,,139,,,72,76,,87,,,,,,20,,,,,,,,141,,,,,84,89', -'93,4,10,16,,,,34,40,18,22,26,,37,,,,53,63,,,,82,,91,95,6,11,17,23,27', -',,,,51,56,60,64,69,73,77,,,,,,,,,,39,,,48,52,59,67,70,74,78,83,88,92', -',9,15,,25,30,36,,,,,,,,,,,,,,,,,,,,136,,,139,,,72,76,,87,,520,,,,20', -',,,,,,,141,,,,,84,89,93,4,10,16,,,,34,40,18,22,26,,37,,,,53,63,,,,82', -',91,95,6,106,107,23,27,,,,,114,115,116,64,69,73,77,,,,,,,,,,39,,,48', -'52,59,67,70,74,78,83,88,92,,9,15,,25,30,36,,,,,,,,,,,,,,,,,,,,136,,', -'139,,,72,76,,87,,,,,,20,,,,,,,,141,,,,,84,89,93,4,10,16,,,,34,40,176', -'180,185,191,196,201,205,210,,,228,231,232,235,240,,,169,172,174,182', -'187,193,197,,,211,215,221,249,252,254,256,241,242,244,168,171,173,178', -'183,189,199,203,207,246,247,248,226,340,341,255,342,,,,,,,184,190,,200', -'204,214,219,,227,230,,,239,,,,,177,181,186,192,,,,,,,,,,,,,243,170,', -'175,179,188,194,198,202,206,212,216,,225,,,237,176,180,185,191,196,201', -'205,210,,,228,231,232,235,240,,,169,172,174,182,187,193,197,,,211,215', -'221,249,252,254,256,241,242,244,168,171,173,178,183,189,199,203,207', -'246,247,248,226,,,255,,,,,,,,184,190,,200,204,214,219,,227,230,,,239', -',,,,177,181,186,192,,,,,,,,,,,,,243,170,,175,179,188,194,198,202,206', -'212,216,,225,,,237,176,180,185,191,196,201,205,210,,,228,231,232,235', -'240,,,169,172,174,182,187,193,197,,,211,215,221,249,252,254,256,241', -'242,244,168,171,173,178,183,189,199,203,207,246,247,248,226,340,341', -'255,342,,,,,,,184,190,,200,204,214,219,,227,230,,,239,,,,,177,181,186', -'192,,,,,,,,,,,,,243,170,,175,179,188,194,198,202,206,212,216,,225,,', -'237,176,180,185,191,196,201,205,210,,,228,231,232,235,240,,,169,172', -'174,182,187,193,197,,,211,215,221,224,229,233,236,241,242,244,168,171', -'173,178,183,189,199,203,207,213,218,223,226,70,74,234,83,,,,,,,184,190', -',200,204,214,219,,227,230,,,239,,,,,177,181,186,192,,,,,,220,,,,,,,243', -'170,,175,179,188,194,198,202,206,212,216,,225,503,371,237,,504,,,,,', -',,184,190,,200,204,214,219,,227,230,,,239,,,,,177,181,186,192,,,,,,', -',,,,,,243,170,,175,179,188,194,198,202,206,212,216,,225,,,237,299,300', -'276,279,282,285,288,290,292,294,296,,301,278,,,284,287,,,,-217,,,,,', -',,,,295,,298,,277,280,283,286,289,291,293,,297,,,,,,,576,365,,,577,', -',,,281,,-217,184,190,,200,204,214,219,,227,230,,,239,,,,,177,181,186', -'192,,,,,,,,,,,,,243,170,,175,179,188,194,198,202,206,212,216,,225,578', -'371,237,,579,,,,,,,,184,190,,200,204,214,219,,227,230,,,239,,,,,177', -'181,186,192,,,,,,,,,,,,,243,170,,175,179,188,194,198,202,206,212,216', -',225,604,365,237,,605,,,,,,,,184,190,,200,204,214,219,,227,230,,,239', -',,,,177,181,186,192,,,,,,,,,,,,,243,170,,175,179,188,194,198,202,206', -'212,216,,225,606,371,237,,607,,,,,,,,184,190,,200,204,214,219,,227,230', -',,239,,,,,177,181,186,192,,,,,,,,,,,,,243,170,,175,179,188,194,198,202', -'206,212,216,,225,891,371,237,,892,,,,,,,,184,190,,200,204,214,219,,227', -'230,,,239,,,,,177,181,186,192,,,,,,,,,,,,,243,170,,175,179,188,194,198', -'202,206,212,216,,225,889,365,237,,890,,,,,,,,184,190,,200,204,214,219', -',227,230,,,239,,,,,177,181,186,192,,,,,,,,,,,,,243,170,,175,179,188', -'194,198,202,206,212,216,,225,578,371,237,,579,,,,,,,,184,190,,200,204', -'214,219,,227,230,,,239,,,,,177,181,186,192,,,,,,,,,,,,,243,170,,175', -'179,188,194,198,202,206,212,216,,225,715,365,237,,716,,,,,,,,184,190', -',200,204,214,219,,227,230,,,239,,,,,177,181,186,192,,,,,,,,,,,,,243', -'170,,175,179,188,194,198,202,206,212,216,,225,557,371,237,,558,,,,,', -',,184,190,,200,204,214,219,,227,230,,,239,,,,,177,181,186,192,,,,,,', -',,,,,,243,170,,175,179,188,194,198,202,206,212,216,,225,,,237,299,300', -'276,279,282,285,288,290,292,294,296,,301,278,,,284,287,,,,,,,,,,,,,', -'295,,298,,277,280,283,286,289,291,293,,297,,,,,,,576,365,,,577,,,,,281', -',587,184,190,,200,204,214,219,,227,230,,,239,,,,,177,181,186,192,,,', -',,,,,,,,,243,170,,175,179,188,194,198,202,206,212,216,,225,503,371,237', -',504,,,,,,,,184,190,,200,204,214,219,,227,230,,,239,,,,,177,181,186', -'192,,,,,,,,,,,,,243,170,,175,179,188,194,198,202,206,212,216,,225,554', -'365,237,,555,,,,,,,,184,190,,200,204,214,219,,227,230,,,239,,,,,177', -'181,186,192,,,,,,,,,,,,,243,170,,175,179,188,194,198,202,206,212,216', -',225,364,365,237,,366,,,,,,,,184,190,,200,204,214,219,,227,230,,,239', -',,,,177,181,186,192,,,,,,,,,,,,,243,170,,175,179,188,194,198,202,206', -'212,216,,225,503,371,237,,504,,,,,,,,184,190,,200,204,214,219,,227,230', -',,239,,,,,177,181,186,192,,,,,,,,,,,,,243,170,,175,179,188,194,198,202', -'206,212,216,,225,370,371,237,,372,,,,,,,,184,190,,200,204,214,219,,227', -'230,,,239,,,,,177,181,186,192,,,,,,,,,,,,,243,170,,175,179,188,194,198', -'202,206,212,216,,225,503,371,237,,504,,,,,,,,184,190,,200,204,214,219', -',227,230,,,239,,,,,177,181,186,192,,,,,,,,,,,,,243,170,,175,179,188', -'194,198,202,206,212,216,,225,503,371,237,,504,,,,,,,,184,190,,200,204', -'214,219,,227,230,,,239,,,,,177,181,186,192,,,,,,,,,,,,,243,170,,175', -'179,188,194,198,202,206,212,216,,225,,,237,299,300,276,279,282,285,288', -'290,292,294,296,,301,278,,,284,287,,,,,,,,,,,,,,295,,298,,277,280,283', -'286,289,291,293,,297,,299,300,276,279,282,285,288,290,292,294,296,,301', -'278,281,642,284,287,,,,,,,,,,,,,,295,,298,,277,280,283,286,289,291,293', -',297,299,300,276,279,282,285,288,290,292,294,296,,301,278,,281,284,287', -',,,,,,,,,,,,,295,,298,,277,280,283,286,289,291,293,,297,299,300,276', -'279,282,285,288,290,292,294,296,,301,278,,281,284,287,,,,,,,,,,,,,,295', -',298,,277,280,283,286,289,291,293,,297,299,300,276,279,282,285,288,290', -'292,294,296,,301,278,,281,284,287,,,,,,,,,,,,,,295,,298,,277,280,283', -'286,289,291,293,,297,299,300,276,279,282,285,288,290,292,294,296,,301', -'278,266,281,284,287,,,,,,,,,,,,,,295,,298,,277,280,283,286,289,291,293', -',297,299,300,276,279,282,285,288,290,292,294,296,,301,278,266,281,284', -'287,,,,,,,,,,,,,,295,,298,,277,280,283,286,289,291,293,,297,299,300', -'276,279,282,285,288,290,292,294,296,,301,278,,281,284,287,,,,,,,,,,', -',,,295,,298,,277,280,283,286,289,291,293,,297,299,300,276,279,282,285', -'288,290,292,294,296,,301,278,,281,284,287,,,,,,,,,,,,,,295,,298,,277', -'280,283,286,289,291,293,,297,299,300,276,279,282,285,288,290,292,294', -'296,,301,278,,281,284,287,,,,,,,,,,,,,,295,,298,,277,280,283,286,289', -'291,293,,297,299,300,276,279,282,285,288,290,292,294,296,,301,278,,281', -'284,287,,,,,,,,,,,,,,295,,298,,277,280,283,286,289,291,293,,297,299', -'300,276,279,282,285,288,290,292,294,296,,301,278,,281,284,287,,,,,,', -',,,,,,,295,,298,,277,280,283,286,289,291,293,,297,299,300,276,279,282', -'285,288,290,292,294,296,,301,278,,281,284,287,,,,,,,,,,,,,,295,,298', -',277,280,283,286,289,291,293,,297,299,300,276,279,282,285,288,290,292', -'294,296,,301,278,,281,284,287,,,,,,,,,,,,,,295,,298,,277,280,283,286', -'289,291,293,,297,299,300,276,279,282,285,288,290,292,294,296,,301,278', -',281,284,287,,,,,,,,,,,,,,295,,298,,277,280,283,286,289,291,293,,297', -'299,300,276,279,282,285,288,290,292,294,296,,301,278,,281,284,287,,', -',,,,,,,,,,,295,,298,,277,280,283,286,289,291,293,,297,,,,,,,,,,,,,,', -',281' ] - racc_action_table = arr = ::Array.new(23872, nil) - idx = 0 - clist.each do |str| - str.split(',', -1).each do |i| - arr[idx] = i.to_i unless i.empty? - idx += 1 - end - end - -clist = [ -'364,348,765,631,631,730,892,364,364,364,108,417,132,364,364,105,364', -'150,569,647,41,481,561,347,1,364,347,218,41,554,848,889,8,135,218,364', -'364,848,364,364,364,364,364,331,815,324,331,558,708,693,730,730,730', -'730,481,561,647,132,569,891,307,348,348,348,364,364,364,364,364,364', -'364,364,364,364,364,364,364,364,135,150,364,364,364,535,364,636,848', -'539,364,757,631,108,554,708,635,364,757,364,105,364,364,364,364,364', -'364,364,889,364,364,364,554,108,765,417,765,8,892,765,892,32,32,892', -'364,364,812,364,67,364,558,364,554,364,417,67,67,67,757,417,67,67,67', -'889,67,889,390,693,889,693,558,385,693,692,67,67,815,324,815,324,7,815', -'324,67,67,381,67,67,67,67,67,891,307,891,307,400,891,307,634,555,557', -'535,229,535,385,539,535,539,650,229,539,111,67,67,67,67,67,67,67,67', -'67,67,67,67,67,67,390,390,67,67,67,849,386,67,619,390,67,599,849,67', -'400,67,7,67,599,67,617,67,67,67,67,67,67,67,692,67,812,67,812,339,653', -'812,555,7,127,386,381,352,616,366,67,67,67,67,692,67,366,366,366,67', -'555,557,366,366,499,366,381,849,224,655,223,499,111,599,607,224,161', -'223,604,660,555,557,579,161,366,366,159,366,366,366,366,366,111,159', -'639,639,578,792,615,339,339,339,792,79,127,127,127,352,352,352,79,499', -'613,366,366,366,366,366,366,366,366,366,366,366,366,366,366,579,604', -'366,366,366,161,366,600,604,899,366,607,600,604,578,159,899,366,612', -'366,639,366,366,366,366,366,366,366,607,366,99,366,79,99,604,233,413', -'415,335,158,335,415,233,413,366,366,158,366,607,366,667,366,607,366', -'577,577,577,604,577,213,608,156,577,577,670,899,213,577,156,577,577', -'577,577,577,577,577,856,38,856,606,577,577,577,577,577,577,577,208,19', -'462,99,99,413,253,208,158,577,253,253,577,577,577,577,577,577,577,577', -'577,577,234,577,577,552,577,577,577,234,156,38,676,462,5,38,104,462', -'462,462,462,5,19,104,333,337,19,333,577,577,337,577,577,605,577,577', -'606,577,589,577,605,577,236,577,587,605,552,847,874,236,552,577,586', -'606,847,874,577,577,577,577,577,577,36,36,584,577,577,576,576,576,5', -'576,104,606,577,576,576,606,345,580,576,345,576,576,576,576,576,576', -'576,605,841,593,593,576,576,576,576,576,576,576,721,66,573,847,874,713', -'614,721,66,576,713,614,576,576,576,576,576,576,576,576,576,576,570,576', -'576,274,576,576,576,541,541,559,541,541,541,841,841,841,841,130,419', -'696,715,418,556,42,130,699,576,576,42,576,576,716,576,576,721,576,553', -'576,716,576,428,576,702,716,274,110,110,428,274,576,645,645,546,505', -'576,576,576,576,576,576,505,505,505,576,576,505,505,505,419,505,715', -'418,576,130,890,419,542,715,418,505,419,890,715,418,372,533,890,716', -'505,505,524,505,505,505,505,505,428,732,732,876,876,419,522,715,418', -'727,709,502,727,727,727,327,327,519,502,502,502,306,306,502,502,502', -'712,502,419,372,715,418,505,372,890,370,506,502,500,505,498,717,497', -'496,505,505,502,502,489,502,502,502,502,502,727,727,727,727,435,461', -'722,435,435,435,795,488,505,795,795,795,630,487,485,630,630,630,370', -'480,734,505,370,505,735,736,505,477,502,739,465,741,461,743,473,502', -'461,461,435,641,502,502,458,750,795,435,435,435,435,753,754,795,795', -'795,795,756,455,630,630,630,630,465,502,758,447,465,465,465,465,446', -'82,82,82,464,82,502,762,502,82,82,502,429,410,82,766,82,82,82,82,82', -'82,82,406,380,373,362,82,82,82,82,82,82,82,346,464,82,776,778,464,464', -'517,781,82,336,783,82,82,82,82,82,82,82,82,82,82,330,82,82,328,82,82', -'82,517,517,517,517,517,517,517,517,517,517,517,310,517,517,309,793,517', -'517,308,82,796,797,82,801,802,82,82,805,82,275,264,517,263,517,82,517', -'517,517,517,517,517,517,82,517,814,260,817,82,82,82,82,82,82,258,162', -'824,82,82,82,517,825,517,160,82,270,270,270,270,270,827,149,832,270', -'270,147,835,145,270,144,270,270,270,270,270,270,270,143,136,134,128', -'270,270,270,270,270,270,270,121,850,270,120,116,115,113,582,270,270', -'270,270,270,270,270,270,270,270,270,270,270,270,860,270,270,112,270', -'270,270,582,582,582,582,582,582,582,582,582,582,582,863,582,582,109', -'868,582,582,869,270,870,94,270,90,81,270,270,50,270,875,270,582,47,582', -'270,582,582,582,582,582,582,582,270,582,882,43,885,270,270,270,270,270', -'270,39,24,18,270,270,16,582,893,10,3,270,809,809,809,809,809,809,900', -',,809,809,,,,809,,809,809,809,809,809,809,809,,,,,809,809,809,809,809', -'809,809,,,809,58,58,58,58,58,809,809,809,809,809,809,809,809,809,809', -'809,809,809,809,,809,809,,809,809,809,454,454,454,454,454,454,454,,', -'454,454,450,450,450,450,450,454,454,,809,,,809,,,809,809,,809,,809,454', -',454,809,454,454,454,454,454,454,454,809,454,,,,809,809,809,809,809', -'809,,,,809,809,769,769,769,769,769,769,,,,769,769,,,,769,,769,769,769', -'769,769,769,769,,,,,769,769,769,769,769,769,769,,,769,148,148,148,148', -'148,769,769,769,769,769,769,769,769,769,769,769,769,769,769,,769,769', -',769,769,769,457,457,457,457,457,457,457,,,457,457,,,,,,457,457,,769', -',,769,,,769,769,,769,,769,457,,457,769,457,457,457,457,457,457,457,769', -'457,,,,769,769,769,769,769,769,,,,769,769,770,770,770,770,770,770,,', -',770,770,,,,770,,770,770,770,770,770,770,770,,,,,770,770,770,770,770', -'770,770,,,770,,,,,,770,770,770,770,770,770,770,770,770,770,770,770,770', -'770,,770,770,,770,770,770,460,460,460,460,460,460,460,,,460,460,,,,', -',460,460,,770,,,770,,,770,770,,770,,770,460,,460,770,460,460,460,460', -'460,460,460,770,460,,,,770,770,770,770,770,770,,,,770,770,453,453,453', -'453,453,453,,,,453,453,,,,453,,453,453,453,453,453,453,453,,,,,453,453', -'453,453,453,453,453,,,453,,,,,,453,453,453,453,453,453,453,453,453,453', -'453,453,453,453,,453,453,,453,453,453,463,,,,,,,,,,,,,,,,463,463,,453', -',,453,,,453,453,,453,,453,463,,463,453,463,463,463,463,,,463,453,463', -',,,453,453,453,453,453,453,,,,453,453,738,738,738,738,738,738,,,,738', -'738,,,,738,,738,738,738,738,738,738,738,,,,,738,738,738,738,738,738', -'738,,,738,,,,,,738,738,738,738,738,738,738,738,738,738,738,738,738,738', -',738,738,,738,738,738,467,,,,,,,,,,,,,,,,467,467,,738,,,738,,,738,738', -',738,,738,467,,467,738,467,467,467,467,,,467,738,467,,,,738,738,738', -'738,738,738,,,,738,738,540,540,540,540,540,540,,,,540,540,,,,540,,540', -'540,540,540,540,540,540,,,,,540,540,540,540,540,540,540,,,540,,,,,,540', -'540,540,540,540,540,540,540,540,540,540,540,540,540,,540,540,,540,540', -'540,479,479,479,479,479,479,479,479,479,479,479,,479,479,,,479,479,', -'540,,,540,,,540,540,,540,,540,479,,479,540,479,479,479,479,479,479,479', -'540,479,,,,540,540,540,540,540,540,,,,540,540,775,775,775,775,775,775', -',,,775,775,,,,775,,775,775,775,775,775,775,775,,,,,775,775,775,775,775', -'775,775,,,775,,,,,,775,775,775,775,775,775,775,775,775,775,775,775,775', -'775,,775,775,,775,775,775,478,478,478,478,478,478,478,,,478,478,,,,', -',478,478,,775,,,775,,,775,775,,775,,775,478,,478,775,478,478,478,478', -'478,478,478,775,478,,,,775,775,775,775,775,775,,,,775,775,311,311,311', -'311,311,311,,,,311,311,,,,311,,311,311,311,311,311,311,311,,,,,311,311', -'311,311,311,311,311,,,311,,,,,,311,311,311,311,311,311,311,311,311,311', -'311,311,311,311,,311,311,,311,311,311,468,468,468,468,468,468,468,,', -'468,468,,,,,,468,468,,311,,,311,,,311,311,,311,,311,468,,468,311,468', -'468,468,468,468,468,468,311,468,,,,311,311,311,311,311,311,,,,311,311', -'302,302,302,302,302,302,,,,302,302,,,,302,,302,302,302,302,302,302,302', -',,,,302,302,302,302,302,302,302,,,302,,,,,,302,302,302,302,302,302,302', -'302,302,302,302,302,302,302,,302,302,,302,302,302,474,474,474,474,474', -'474,474,,,474,474,,,,,,474,474,,302,,,302,,,302,302,,302,,302,474,,474', -'302,474,474,474,474,474,474,474,302,474,,,,302,302,302,302,302,302,', -',,302,302,521,521,521,521,521,521,,,,521,521,,,,521,,521,521,521,521', -'521,521,521,,,,,521,521,521,521,521,521,521,,,521,,,,,,521,521,521,521', -'521,521,521,521,521,521,521,521,521,521,,521,521,,521,521,521,469,,', -',,,,,,,,,,,,,469,469,,521,,,521,,,521,521,,521,,521,469,,469,521,469', -'469,469,469,,,469,521,469,,,,521,521,521,521,521,521,,,,521,521,698', -'698,698,698,698,698,,,,698,698,,,,698,,698,698,698,698,698,698,698,', -',,,698,698,698,698,698,698,698,,,698,,,,,,698,698,698,698,698,698,698', -'698,698,698,698,698,698,698,,698,698,,698,698,698,472,472,472,472,472', -'472,472,,,472,472,,,,,,472,472,,698,,,698,,,698,698,,698,,698,472,,472', -'698,472,472,472,472,472,472,472,698,472,,,,698,698,698,698,698,698,', -',,698,698,501,501,501,501,501,501,,,,501,501,,,,501,,501,501,501,501', -'501,501,501,,,,,501,501,501,501,501,501,501,,,501,,,,,,501,501,501,501', -'501,501,501,501,501,501,501,501,501,501,,501,501,,501,501,501,466,,', -',,,,,,,,,,,,,466,466,,501,,,501,,,501,501,,501,,501,466,,466,501,466', -'466,466,466,,,466,501,466,,,,501,501,501,501,501,501,,,,501,501,624', -'624,624,624,624,624,,,,624,624,,,,624,,624,624,624,624,624,624,624,', -',,,624,624,624,624,624,624,624,,,624,,,,,,624,624,624,624,624,624,624', -'624,624,624,624,624,624,624,,624,624,,624,624,624,470,470,470,470,470', -'470,470,470,,470,470,,,,,,470,470,,624,,,624,,,624,624,,624,,624,470', -',470,624,470,470,470,470,470,470,470,624,470,,,,624,624,624,624,624', -'624,,,,624,624,265,265,265,265,265,265,,,,265,265,,,,265,,265,265,265', -'265,265,265,265,,,,,265,265,265,265,265,265,265,,,265,,,,,,265,265,265', -'265,265,265,265,265,265,265,265,265,265,265,,265,265,,265,265,265,456', -'456,456,456,456,456,456,456,456,456,456,,456,456,,,456,456,,265,,,265', -',,265,265,,265,,265,456,,456,265,456,456,456,456,456,456,456,265,456', -',,,265,265,265,265,265,265,,,,265,265,821,821,821,821,821,821,,,,821', -'821,,,,821,,821,821,821,821,821,821,821,,,,,821,821,821,821,821,821', -'821,,,821,,,,,,821,821,821,821,821,821,821,821,821,821,821,821,821,821', -',821,821,,821,821,821,471,,,,,,,,,,,,,,,,471,471,,821,,,821,,,821,821', -',821,,821,471,,471,821,471,471,471,471,,,,821,,,,,821,821,821,821,821', -'821,,,,821,821,695,695,695,695,695,695,,,,695,695,,,,695,,695,695,695', -'695,695,695,695,,,,,695,695,695,695,695,695,695,,,695,,,,,,695,695,695', -'695,695,695,695,695,695,695,695,695,695,695,,695,695,,695,695,695,476', -',,,,,,,,,,,,,,,476,476,,695,,,695,,,695,695,,695,,695,476,,,695,476', -'476,476,476,,,,695,,,,,695,695,695,695,695,695,,,,695,695,720,720,720', -'720,720,720,,,,720,720,,,,720,,720,720,720,720,720,720,720,,,,,720,720', -'720,720,720,720,720,,,720,,,,,,720,720,720,720,720,720,720,720,720,720', -'720,720,720,720,,720,720,,720,720,720,475,,,,,,,,,,,,,,,,475,475,,720', -',,720,,,720,720,,720,,720,475,,475,720,475,475,475,475,,,,720,,,,,720', -'720,720,720,720,720,,,,720,720,163,163,163,163,163,163,,,,163,163,,', -',163,,163,163,163,163,163,163,163,,,,,163,163,163,163,163,163,163,,', -'163,,,,,,163,163,163,163,163,163,163,163,163,163,163,163,163,163,,163', -'163,,163,163,163,,,,,,,,,,,,,,,,,,,,163,,,163,,,163,163,,163,,163,,', -',163,,,,,,,,163,,,,,163,163,163,163,163,163,,,,163,163,748,748,748,748', -'748,748,,,,748,748,,,,748,,748,748,748,748,748,748,748,,,,,748,748,748', -'748,748,748,748,,,748,,,,,,748,748,748,748,748,748,748,748,748,748,748', -'748,748,748,,748,748,,748,748,748,,,,,,,,,,,,,,,,,,,,748,,,748,,,748', -'748,,748,,748,,,,748,,,,,,,,748,,,,,748,748,748,748,748,748,,,,748,748', -'826,826,826,826,826,826,,,,826,826,,,,826,,826,826,826,826,826,826,826', -',,,,826,826,826,826,826,826,826,,,826,,,,,,826,826,826,826,826,826,826', -'826,826,826,826,826,826,826,,826,826,,826,826,826,,,,,,,,,,,,,,,,,,', -',826,,,826,,,826,826,,826,,826,,,,826,,,,,,,,826,,,,,826,826,826,826', -'826,826,,,,826,826,837,837,837,837,837,837,,,,837,837,,,,837,,837,837', -'837,837,837,837,837,,,,,837,837,837,837,837,837,837,,,837,,,,,,837,837', -'837,837,837,837,837,837,837,837,837,837,837,837,,837,837,,837,837,837', -',,,,,,,,,,,,,,,,,,,837,,,837,,,837,837,,837,,837,,,,837,,,,,,,,837,', -',,,837,837,837,837,837,837,,,,837,837,840,840,840,840,840,840,,,,840', -'840,,,,840,,840,840,840,840,840,840,840,,,,,840,840,840,840,840,840', -'840,,,840,,,,,,840,840,840,840,840,840,840,840,840,840,840,840,840,840', -',840,840,,840,840,840,,,,,,,,,,,,,,,,,,,,840,,,840,,,840,840,,840,,840', -',,,840,,,,,,,,840,,,,,840,840,840,840,840,840,,,,840,840,139,139,139', -'139,139,139,,,,139,139,,,,139,,139,139,139,139,139,139,139,,,,,139,139', -'139,139,139,139,139,,,139,,,,,,139,139,139,139,139,139,139,139,139,139', -'139,139,139,139,,139,139,,139,139,139,,,,,,,,,,,,,,,,,,,,139,,,139,', -',139,139,,139,,139,,,,139,,,,,,,,139,,,,,139,139,139,139,139,139,,,', -'139,139,852,852,852,852,852,852,,,,852,852,,,,852,,852,852,852,852,852', -'852,852,,,,,852,852,852,852,852,852,852,,,852,,,,,,852,852,852,852,852', -'852,852,852,852,852,852,852,852,852,,852,852,,852,852,852,,,,,,,,,,', -',,,,,,,,,852,,,852,,,852,852,,852,,852,,,,852,,,,,,,,852,,,,,852,852', -'852,852,852,852,,,,852,852,54,54,54,54,54,54,,,,54,54,,,,54,,54,54,54', -'54,54,54,54,,,,,54,54,54,54,54,54,54,,,54,,,,,,54,54,54,54,54,54,54', -'54,54,54,54,54,54,54,,54,54,,54,54,54,,,,,,,,,,,,,,,,,,,,54,,,54,,,54', -'54,,54,,54,,,,54,,,,,,,,54,,,,,54,54,54,54,54,54,,,,54,54,854,854,854', -'854,854,854,,,,854,854,,,,854,,854,854,854,854,854,854,854,,,,,854,854', -'854,854,854,854,854,,,854,,,,,,854,854,854,854,854,854,854,854,854,854', -'854,854,854,854,,854,854,,854,854,854,,,,,,,,,,,,,,,,,,,,854,,,854,', -',854,854,,854,,854,,,,854,,,,,,,,854,,,,,854,854,854,854,854,854,,,', -'854,854,483,483,483,483,483,483,,,,483,483,,,,483,,483,483,483,483,483', -'483,483,,,,,483,483,483,483,483,483,483,,,483,,,,,,483,483,483,483,483', -'483,483,483,483,483,483,483,483,483,,483,483,,483,483,483,,,,,,,,,,', -',,,,,,,,,483,,,483,,,483,483,,483,,483,,,,483,,,,,,,,483,,,,,483,483', -'483,483,483,483,,,,483,483,2,2,2,2,2,2,,,,2,2,,,,2,,2,2,2,2,2,2,2,,', -',,2,2,2,2,2,2,2,,,2,,,,,,2,2,2,2,2,2,2,2,2,2,2,2,2,2,,2,2,,2,2,2,,,', -',,,,,,,,,,,,,,,,2,,,2,,,2,2,,2,,2,,,,2,,,,,,,,2,,,,,2,2,2,2,2,2,,,,2', -'2,610,610,610,610,610,610,,,,610,610,,,,610,,610,610,610,610,610,610', -'610,,,,,610,610,610,610,610,610,610,,,610,,,,,,610,610,610,610,610,610', -'610,610,610,610,610,610,610,610,,610,610,,610,610,610,,,,,,,,,,,,,,', -',,,,,610,,,610,,,610,610,,610,,610,,,,610,,,,,,,,610,,,,,610,610,610', -'610,610,610,,,,610,610,51,51,51,,51,,,,51,51,,,,51,,51,51,51,51,51,51', -'51,,,,,51,51,51,51,51,51,51,,,,,,,,,,51,,,51,51,51,51,51,51,51,51,51', -'51,,51,51,,51,51,51,,,,,,,,,,,,,,,,,,,,51,,,51,,,51,51,,51,,51,,51,', -'51,,,,,,,,51,,,,,51,51,51,51,51,51,,,,51,51,63,63,63,,63,,,,63,63,,', -',63,,63,63,63,63,63,63,63,,,,,63,63,63,63,63,63,63,,,63,,,,,,,63,,,63', -'63,63,63,63,63,63,63,63,63,,63,63,,63,63,63,,,,,,,,,,,,,,,,,,,,63,,', -'63,,,63,63,,63,,,,,,63,,,,,,,,63,,,,,63,63,63,63,63,63,,,,63,63,60,60', -'60,,60,,,,60,60,,,,60,,60,60,60,60,60,60,60,,,,,60,60,60,60,60,60,60', -',,,,,,,,,60,,,60,60,60,60,60,60,60,60,60,60,,60,60,,60,60,60,,,,,,,', -',,,,,,,,,,,,60,,,60,60,,60,60,,60,,60,,60,,60,,,,,,,,60,,,,,60,60,60', -'60,60,60,,,,60,60,59,59,59,,59,,,,59,59,,,,59,,59,59,59,59,59,59,59', -',59,,,59,59,59,59,59,59,59,,,,,,,,,,59,,,59,59,59,59,59,59,59,59,59', -'59,,59,59,,59,59,59,,,,,,,,,,,,,,,,,,,,59,,,59,59,,59,59,,59,,59,,59', -',59,,,,,,,,59,,59,,,59,59,59,59,59,59,,,,59,59,72,72,72,,72,,,,72,72', -',,,72,,72,72,72,72,72,72,72,,,,,72,72,72,72,72,72,72,,,72,,,,,,,72,', -',72,72,72,72,72,72,72,72,72,72,,72,72,,72,72,72,,,,,,,,,,,,,,,,,,,,72', -',,72,,,72,72,,72,,,,,,72,,,,,,,,72,,,,,72,72,72,72,72,72,,,,72,72,76', -'76,76,,76,,,,76,76,,,,76,,76,76,76,76,76,76,76,,,,,76,76,76,76,76,76', -'76,,,,,,,,,,76,,,76,76,76,76,76,76,76,76,76,76,,76,76,,76,76,76,,,,', -',,,,,,,,,,,,,,,76,,,76,,,76,76,,76,,76,,,,76,,,,,,,,76,,,,,76,76,76', -'76,76,76,,,,76,76,78,78,78,,78,,,,78,78,,,,78,,78,78,78,78,78,78,78', -',78,,,78,78,78,78,78,78,78,,,,,,,,,,78,,,78,78,78,78,78,78,78,78,78', -'78,,78,78,,78,78,78,,,,,,,,,,,,,,,,,,,,78,,,78,78,,78,78,,78,,78,,78', -',78,,,,,,,,78,,78,,,78,78,78,78,78,78,,,,78,78,669,669,669,,669,,,,669', -'669,,,,669,,669,669,669,669,669,669,669,,,,,669,669,669,669,669,669', -'669,,,,,,,,,,669,,,669,669,669,669,669,669,669,669,669,669,,669,669', -',669,669,669,,,,,,,,,,,,,,,,,,,,669,,,669,,,669,669,,669,,669,,,,669', -',,,,,,,669,,,,,669,669,669,669,669,669,,,,669,669,873,873,873,,873,', -',,873,873,,,,873,,873,873,873,873,873,873,873,,,,,873,873,873,873,873', -'873,873,,,,,,,,,,873,,,873,873,873,873,873,873,873,873,873,873,,873', -'873,,873,873,873,,,,,,,,,,,,,,,,,,,,873,,,873,,,873,873,,873,,873,,', -',873,,,,,,,,873,,,,,873,873,873,873,873,873,,,,873,873,637,637,637,', -'637,,,,637,637,,,,637,,637,637,637,637,637,637,637,,,,,637,637,637,637', -'637,637,637,,,,,,,,,,637,,,637,637,637,637,637,637,637,637,637,637,', -'637,637,,637,637,637,,,,,,,,,,,,,,,,,,,,637,,,637,,,637,637,,637,,637', -',,,637,,,,,,,,637,,,,,637,637,637,637,637,637,,,,637,637,642,642,642', -',642,,,,642,642,,,,642,,642,642,642,642,642,642,642,,,,,642,642,642', -'642,642,642,642,,,,,,,,,,642,,,642,642,642,642,642,642,642,642,642,642', -',642,642,,642,642,642,,,,,,,,,,,,,,,,,,,,642,,,642,,,642,642,,642,,', -',,,642,,,,,,,,642,,,,,642,642,642,642,642,642,,,,642,642,87,87,87,,87', -',,,87,87,,,,87,,87,87,87,87,87,87,87,,,,,87,87,87,87,87,87,87,,,,,,', -',,,87,,,87,87,87,87,87,87,87,87,87,87,,87,87,,87,87,87,,,,,,,,,,,,,', -',,,,,,87,,,87,,,87,87,,87,,,,,,87,,,,,,,,87,,,,,87,87,87,87,87,87,,', -',87,87,729,729,729,,729,,,,729,729,,,,729,,729,729,729,729,729,729,729', -',,,,729,729,729,729,729,729,729,,,,,,,,,,729,,,729,729,729,729,729,729', -'729,729,729,729,,729,729,,729,729,729,,,,,,,,,,,,,,,,,,,,729,,,729,', -',729,729,,729,,,,,,729,,,,,,,,729,,,,,729,729,729,729,729,729,,,,729', -'729,6,6,6,,6,,,,6,6,,,,6,,6,6,6,6,6,6,6,,,,,6,6,6,6,6,6,6,,,,,,,,,,6', -',,6,6,6,6,6,6,6,6,6,6,,6,6,,,,6,,,,,,,,,,,,,,,,,,,,6,,,6,,,6,6,,6,,6', -',,,,,,,,,,,,,,,,6,6,6,6,6,6,,,,6,6,96,96,96,,96,,,,96,96,,,,96,,96,96', -'96,96,96,96,96,,,,,96,96,96,96,96,96,96,,,,,,,,,,96,,,96,96,96,96,96', -'96,96,96,96,96,,96,96,,,,96,,,,,,,,,,,,,,,,,,,,96,,,96,,,96,96,,96,', -',,,,,,,,,,,,,,,,,96,96,96,96,96,96,,,,96,96,97,97,97,,97,,,,97,97,,', -',97,,97,97,97,97,97,97,97,,,,,97,97,97,97,97,97,97,,,97,,,,,,,97,,,97', -'97,97,97,97,97,97,97,97,97,,97,97,,97,97,97,,,,,,,,,,,,,,,,,,,,97,,', -'97,,,97,97,,97,,,,,,97,,,,,,,,97,,,,,97,97,97,97,97,97,,,,97,97,719', -'719,719,,719,,,,719,719,,,,719,,719,719,719,719,719,719,719,,,,,719', -'719,719,719,719,719,719,,,719,,,,,,,719,,,719,719,719,719,719,719,719', -'719,719,719,,719,719,,719,719,719,,,,,,,,,,,,,,,,,,,,719,,,719,,,719', -'719,,719,,,,,,719,,,,,,,,719,,,,,719,719,719,719,719,719,,,,719,719', -'749,749,749,,749,,,,749,749,,,,749,,749,749,749,749,749,749,749,,,,', -'749,749,749,749,749,749,749,,,749,,,,,,,749,,,749,749,749,749,749,749', -'749,749,749,749,,749,749,,749,749,749,,,,,,,,,,,,,,,,,,,,749,,,749,', -',749,749,,749,,,,,,749,,,,,,,,749,,,,,749,749,749,749,749,749,,,,749', -'749,897,897,897,,897,,,,897,897,,,,897,,897,897,897,897,897,897,897', -',,,,897,897,897,897,897,897,897,,,,,,,,,,897,,,897,897,897,897,897,897', -'897,897,897,897,,897,897,,897,897,897,,,,,,,,,,,,,,,,,,,,897,,,897,', -',897,897,,897,,,,,,897,,,,,,,,897,,,,,897,897,897,897,897,897,,,,897', -'897,103,103,103,,103,,,,103,103,,,,103,,103,103,103,103,103,103,103', -',,,,103,103,103,103,103,103,103,,,,,,,,,,103,,,103,103,103,103,103,103', -'103,103,103,103,,103,103,,103,103,103,,,,,,,,,,,,,,,,,,,,103,,,103,', -',103,103,,103,,103,,,,103,,,,,,,,103,,,,,103,103,103,103,103,103,,,', -'103,103,511,511,511,,511,,,,511,511,,,,511,,511,511,511,511,511,511', -'511,,,,,511,511,511,511,511,511,511,,,,,,,,,,511,,,511,511,511,511,511', -'511,511,511,511,511,,511,511,,511,511,511,,,,,,,,,,,,,,,,,,,,511,,,511', -',,511,511,,511,,511,,,,511,,,,,,,,511,,,,,511,511,511,511,511,511,,', -',511,511,514,514,514,,514,,,,514,514,,,,514,,514,514,514,514,514,514', -'514,,,,,514,514,514,514,514,514,514,,,,,,,,,,514,,,514,514,514,514,514', -'514,514,514,514,514,,514,514,,514,514,514,,,,,,,,,,,,,,,,,,,,514,,,514', -',,514,514,,514,,,,,,514,,,,,,,,514,,,,,514,514,514,514,514,514,,,,514', -'514,11,11,11,,11,,,,11,11,,,,11,,11,11,11,11,11,11,11,,,,,11,11,11,11', -'11,11,11,,,,,,,,,,11,,,11,11,11,11,11,11,11,11,11,11,,11,11,,11,11,11', -',,,,,,,,,,,,,,,,,,,11,,,11,,,11,11,,11,,11,,11,,11,,,,,,,,11,,,,,11', -'11,11,11,11,11,,,,11,11,865,865,865,,865,,,,865,865,,,,865,,865,865', -'865,865,865,865,865,,,,,865,865,865,865,865,865,865,,,,,,,,,,865,,,865', -'865,865,865,865,865,865,865,865,865,,865,865,,865,865,865,,,,,,,,,,', -',,,,,,,,,865,,,865,,,865,865,,865,,,,,,865,,,,,,,,865,,,,,865,865,865', -'865,865,865,,,,865,865,452,452,452,,452,,,,452,452,,,,452,,452,452,452', -'452,452,452,452,,,,,452,452,452,452,452,452,452,,,,,,,,,,452,,,452,452', -'452,452,452,452,452,452,452,452,,452,452,,452,452,452,,,,,,,,,,,,,,', -',,,,,452,,,452,,,452,452,,452,,,,,,452,,,,,,,,452,,,,,452,452,452,452', -'452,452,,,,452,452,449,449,449,,449,,,,449,449,,,,449,,449,449,449,449', -'449,449,449,,,,,449,449,449,449,449,449,449,,,449,,,,,,,449,,,449,449', -'449,449,449,449,449,449,449,449,,449,449,,449,449,449,,,,,,,,,,,,,,', -',,,,,449,,,449,,,449,449,,449,,,,,,449,,,,,,,,449,,,,,449,449,449,449', -'449,449,,,,449,449,862,862,862,,862,,,,862,862,,,,862,,862,862,862,862', -'862,862,862,,,,,862,862,862,862,862,862,862,,,,,,,,,,862,,,862,862,862', -'862,862,862,862,862,862,862,,862,862,,862,862,862,,,,,,,,,,,,,,,,,,', -',862,,,862,,,862,862,,862,,,,,,862,,,,,,,,862,,,,,862,862,862,862,862', -'862,,,,862,862,857,857,857,,857,,,,857,857,,,,857,,857,857,857,857,857', -'857,857,,,,,857,857,857,857,857,857,857,,,,,,,,,,857,,,857,857,857,857', -'857,857,857,857,857,857,,857,857,,857,857,857,,,,,,,,,,,,,,,,,,,,857', -',,857,,,857,857,,857,,,,,,857,,,,,,,,857,,,,,857,857,857,857,857,857', -',,,857,857,445,445,445,,445,,,,445,445,,,,445,,445,445,445,445,445,445', -'445,,,,,445,445,445,445,445,445,445,,,,,,,,,,445,,,445,445,445,445,445', -'445,445,445,445,445,,445,445,,445,445,445,,,,,,,,,,,,,,,,,,,,445,,,445', -',,445,445,,445,,,,,,445,,,,,,,,445,,,,,445,445,445,445,445,445,,,,445', -'445,56,56,56,,56,,,,56,56,,,,56,,56,56,56,56,56,56,56,,,,,56,56,56,56', -'56,56,56,,,,,,,,,,56,,,56,56,56,56,56,56,56,56,56,56,,56,56,,56,56,56', -',,,,,,,,,,,,,,,,,,,56,,,56,56,,56,56,,56,,56,,56,,56,,,,,,,,56,,,,,56', -'56,56,56,56,56,,,,56,56,53,53,53,,53,,,,53,53,,,,53,,53,53,53,53,53', -'53,53,,,,,53,53,53,53,53,53,53,,,53,,,,,,,53,,,53,53,53,53,53,53,53', -'53,53,53,,53,53,,53,53,53,,,,,,,,,,,,,,,,,,,,53,,,53,,,53,53,,53,,,', -',,53,,,,,,,,53,,,,,53,53,53,53,53,53,,,,53,53,596,596,596,,596,,,,596', -'596,,,,596,,596,596,596,596,596,596,596,,,,,596,596,596,596,596,596', -'596,,,,,,,,,,596,,,596,596,596,596,596,596,596,596,596,596,,596,596', -',596,596,596,,,,,,,,,,,,,,,,,,,,596,,,596,,,596,596,,596,,596,,,,596', -',,,,,,,596,,,,,596,596,596,596,596,596,,,,596,596,124,124,124,,124,', -',,124,124,,,,124,,124,124,124,124,124,124,124,,,,,124,124,124,124,124', -'124,124,,,,,,,,,,124,,,124,124,124,124,124,124,124,124,124,124,,124', -'124,,124,124,124,,,,,,,,,,,,,,,,,,,,124,,,124,,,124,124,,124,,124,,124', -',124,,,,,,,,124,,,,,124,124,124,124,124,124,,,,124,124,444,444,444,', -'444,,,,444,444,,,,444,,444,444,444,444,444,444,444,,,,,444,444,444,444', -'444,444,444,,,,,,,,,,444,,,444,444,444,444,444,444,444,444,444,444,', -'444,444,,444,444,444,,,,,,,,,,,,,,,,,,,,444,,,444,,,444,444,,444,,,', -',,444,,,,,,,,444,,,,,444,444,444,444,444,444,,,,444,444,437,437,437', -'437,437,437,437,437,,,437,437,437,437,437,,,437,437,437,437,437,437', -'437,,,437,437,437,437,437,437,437,437,437,437,437,437,437,437,437,437', -'437,437,437,437,437,437,437,,,437,,,,,,,,437,437,,437,437,437,437,,437', -'437,,,437,,,,,437,437,437,437,,,,,,,,,,,,,437,437,,437,437,437,437,437', -'437,437,437,437,,437,,,437,437,,,436,436,436,,436,,,437,436,436,,,,436', -',436,436,436,436,436,436,436,,,,,436,436,436,436,436,436,436,,,436,', -',,,,,436,,,436,436,436,436,436,436,436,436,436,436,,436,436,,436,436', -'436,,,,,,,,,,,,,,,,,,,,436,,,436,,,436,436,,436,,,,,,436,,,,,,,,436', -',,,,436,436,436,436,436,436,,,,436,436,131,131,131,,131,,,,131,131,', -',,131,,131,131,131,131,131,131,131,,,,,131,131,131,131,131,131,131,', -',,,,,,,,131,,,131,131,131,131,131,131,131,131,131,131,,131,131,,131', -'131,131,,,,,,,,,,,,,,,,,,,,131,,,131,,,131,131,,131,,,,,,131,,,,,,,', -'131,,,,,131,131,131,131,131,131,,,,131,131,591,591,591,,591,,,,591,591', -',,,591,,591,591,591,591,591,591,591,,,,,591,591,591,591,591,591,591', -',,,,,,,,,591,,,591,591,591,591,591,591,591,591,591,591,,591,591,,591', -'591,591,,,,,,,,,,,,,,,,,,,,591,,,591,,,591,591,,591,,,,,,591,,,,,,,', -'591,,,,,591,591,591,591,591,591,,,,591,591,710,710,710,,710,,,,710,710', -',,,710,,710,710,710,710,710,710,710,,,,,710,710,710,710,710,710,710', -',,,,,,,,,710,,,710,710,710,710,710,710,710,710,710,710,,710,710,,710', -'710,710,,,,,,,,,,,,,,,,,,,,710,,,710,,,710,710,,710,,710,,710,,710,', -',,,,,,710,,,,,710,710,710,710,710,710,,,,710,710,21,21,21,,21,,,,21', -'21,,,,21,,21,21,21,21,21,21,21,,,,,21,21,21,21,21,21,21,,,,,,,,,,21', -',,21,21,21,21,21,21,21,21,21,21,,21,21,,,,21,,,,,,,,,,,,,,,,,,,,21,', -',21,,,21,21,,21,,21,,,,,,,,,,,,,,,,,21,21,21,21,21,21,,,,21,21,520,520', -'520,,520,,,,520,520,,,,520,,520,520,520,520,520,520,520,,,,,520,520', -'520,520,520,520,520,,,,,,,,,,520,,,520,520,520,520,520,520,520,520,520', -'520,,520,520,,520,520,520,,,,,,,,,,,,,,,,,,,,520,,,520,,,520,520,,520', -',,,,,520,,,,,,,,520,,,,,520,520,520,520,520,520,,,,520,520,426,426,426', -',426,,,,426,426,,,,426,,426,426,426,426,426,426,426,,,,,426,426,426', -'426,426,426,426,,,,,,,,,,426,,,426,426,426,426,426,426,426,426,426,426', -',426,426,,426,426,426,,,,,,,,,,,,,,,,,,,,426,,,426,,,426,426,,426,,426', -',,,426,,,,,,,,426,,,,,426,426,426,426,426,426,,,,426,426,61,61,61,,61', -',,,61,61,,,,61,,61,61,61,61,61,61,61,,,,,61,61,61,61,61,61,61,,,,,,', -',,,61,,,61,61,61,61,61,61,61,61,61,61,,61,61,,61,61,61,,,,,,,,,,,,,', -',,,,,,61,,,61,,,61,61,,61,,,,,,61,,,,,,,,61,,,,,61,61,61,61,61,61,,', -',61,61,141,141,141,,141,,,,141,141,,,,141,,141,141,141,141,141,141,141', -',,,,141,141,141,141,141,141,141,,,,,,,,,,141,,,141,141,141,141,141,141', -'141,141,141,141,,141,141,,141,141,141,,,,,,,,,,,,,,,,,,,,141,,,141,', -',141,141,,141,,,,,,141,,,,,,,,141,,,,,141,141,141,141,141,141,,,,141', -'141,665,665,665,,665,,,,665,665,,,,665,,665,665,665,665,665,665,665', -',,,,665,665,665,665,665,665,665,,,,,,,,,,665,,,665,665,665,665,665,665', -'665,665,665,665,,665,665,,665,665,665,,,,,,,,,,,,,,,,,,,,665,,,665,', -',665,665,,665,,665,,,,665,,,,,,,,665,,,,,665,665,665,665,665,665,,,', -'665,665,664,664,664,,664,,,,664,664,,,,664,,664,664,664,664,664,664', -'664,,,,,664,664,664,664,664,664,664,,,,,,,,,,664,,,664,664,664,664,664', -'664,664,664,664,664,,664,664,,664,664,664,,,,,,,,,,,,,,,,,,,,664,,,664', -',,664,664,,664,,,,,,664,,,,,,,,664,,,,,664,664,664,664,664,664,,,,664', -'664,14,14,14,14,14,,,,14,14,,,,14,,14,14,14,14,14,14,14,,,,,14,14,14', -'14,14,14,14,,,14,,,,,,14,14,14,14,14,14,14,14,14,14,14,14,14,14,,14', -'14,,14,14,14,,,,,,,,,,,,,,,,,,,,14,,,14,,,14,14,,14,,14,,,,14,,,,,,', -',14,,,,,14,14,14,14,14,14,,,,14,14,146,146,146,,146,,,,146,146,,,,146', -',146,146,146,146,146,146,146,,,,,146,146,146,146,146,146,146,,,,,,,', -',,146,,,146,146,146,146,146,146,146,146,146,146,,146,146,,146,146,146', -',,,,,,,,,,,,,,,,,,,146,,,146,,,146,146,,146,,,,,,146,,,,,,,,146,,,,', -'146,146,146,146,146,146,,,,146,146,833,833,833,,833,,,,833,833,,,,833', -',833,833,833,833,833,833,833,,,,,833,833,833,833,833,833,833,,,,,,,', -',,833,,,833,833,833,833,833,833,833,833,833,833,,833,833,,833,833,833', -',,,,,,,,,,,,,,,,,,,833,,,833,,,833,833,,833,,833,,833,,833,,,,,,,,833', -',,,,833,833,833,833,833,833,,,,833,833,585,585,585,,585,,,,585,585,', -',,585,,585,585,585,585,585,585,585,,,,,585,585,585,585,585,585,585,', -',,,,,,,,585,,,585,585,585,585,585,585,585,585,585,585,,585,585,,585', -'585,585,,,,,,,,,,,,,,,,,,,,585,,,585,,,585,585,,585,,,,,,585,,,,,,,', -'585,,,,,585,585,585,585,585,585,,,,585,585,830,830,830,,830,,,,830,830', -',,,830,,830,830,830,830,830,830,830,,,,,830,830,830,830,830,830,830', -',,,,,,,,,830,,,830,830,830,830,830,830,830,830,830,830,,830,830,,830', -'830,830,,,,,,,,,,,,,,,,,,,,830,,,830,,,830,830,,830,,830,,830,,830,', -',,,,,,830,,,,,830,830,830,830,830,830,,,,830,830,707,707,707,,707,,', -',707,707,,,,707,,707,707,707,707,707,707,707,,,,,707,707,707,707,707', -'707,707,,,,,,,,,,707,,,707,707,707,707,707,707,707,707,707,707,,707', -'707,,707,707,707,,,,,,,,,,,,,,,,,,,,707,,,707,,,707,707,,707,,,,,,707', -',,,,,,,707,,,,,707,707,707,707,707,707,,,,707,707,154,154,154,,154,', -',,154,154,,,,154,,154,154,154,154,154,154,154,,,,,154,154,154,154,154', -'154,154,,,,,,,,,,154,,,154,154,154,154,154,154,154,154,154,154,,154', -'154,,,,154,,,,,,,,,,,,,,,,,,,,154,,,154,,,154,154,,154,,,,,,,,,,,,,', -',,,,,154,154,154,154,154,154,,,,154,154,155,155,155,,155,,,,155,155', -',,,155,,155,155,155,155,155,155,155,,,,,155,155,155,155,155,155,155', -',,,,,,,,,155,,,155,155,155,155,155,155,155,155,155,155,,155,155,,155', -'155,155,,,,,,,,,,,,,,,,,,,,155,,,155,,,155,155,,155,,,,,,155,,,,,,,', -'155,,,,,155,155,155,155,155,155,,,,155,155,412,412,412,,412,,,,412,412', -',,,412,,412,412,412,412,412,412,412,,,,,412,412,412,412,412,412,412', -',,412,,,,,,,412,,,412,412,412,412,412,412,412,412,412,412,,412,412,', -'412,412,412,,,,,,,,,,,,,,,,,,,,412,,,412,,,412,412,,412,,,,,,412,,,', -',,,,412,,,,,412,412,412,412,412,412,,,,412,412,407,407,407,,407,,,,407', -'407,,,,407,,407,407,407,407,407,407,407,,,,,407,407,407,407,407,407', -'407,,,,,,,,,,407,,,407,407,407,407,407,407,407,407,407,407,,407,407', -',407,407,407,,,,,,,,,,,,,,,,,,,,407,,,407,,,407,407,,407,,407,,407,', -'407,,,,,,,,407,,,,,407,407,407,407,407,407,,,,407,407,691,691,691,,691', -',,,691,691,,,,691,,691,691,691,691,691,691,691,,,,,691,691,691,691,691', -'691,691,,,,,,,,,,691,,,691,691,691,691,691,691,691,691,691,691,,691', -'691,,691,691,691,,,,,,,,,,,,,,,,,,,,691,,,691,,,691,691,,691,,,,,,691', -',,,,,,,691,,,,,691,691,691,691,691,691,,,,691,691,767,767,767,,767,', -',,767,767,,,,767,,767,767,767,767,767,767,767,,,,,767,767,767,767,767', -'767,767,,,,,,,,,,767,,,767,767,767,767,767,767,767,767,767,767,,767', -'767,,767,767,767,,,,,,,,,,,,,,,,,,,,767,,,767,,,767,767,,767,,,,,,767', -',,,,,,,767,,,,,767,767,767,767,767,767,,,,767,767,883,883,883,,883,', -',,883,883,,,,883,,883,883,883,883,883,883,883,,,,,883,883,883,883,883', -'883,883,,,,,,,,,,883,,,883,883,883,883,883,883,883,883,883,883,,883', -'883,,883,883,883,,,,,,,,,,,,,,,,,,,,883,,,883,,,883,883,,883,,883,,883', -',883,,,,,,,,883,,,,,883,883,883,883,883,883,,,,883,883,822,822,822,', -'822,,,,822,822,,,,822,,822,822,822,822,822,822,822,,,,,822,822,822,822', -'822,822,822,,,,,,,,,,822,,,822,822,822,822,822,822,822,822,822,822,', -'822,822,,822,822,822,,,,,,,,,,,,,,,,,,,,822,,,822,,,822,822,,822,,822', -',,,822,,,,,,,,822,,,,,822,822,822,822,822,822,,,,822,822,662,662,662', -',662,,,,662,662,,,,662,,662,662,662,662,662,662,662,,,,,662,662,662', -'662,662,662,662,,,,,,,,,,662,,,662,662,662,662,662,662,662,662,662,662', -',662,662,,662,662,662,,,,,,,,,,,,,,,,,,,,662,,,662,,,662,662,,662,,', -',,,662,,,,,,,,662,,,,,662,662,662,662,662,662,,,,662,662,164,164,164', -',164,,,,164,164,,,,164,,164,164,164,164,164,164,164,,,,,164,164,164', -'164,164,164,164,,,,,,,,,,164,,,164,164,164,164,164,164,164,164,164,164', -',164,164,,,,164,,,,,,,,,,,,,,,,,,,,164,,,164,,,164,164,,164,,,,,,,,', -',,,,,,,,,,164,164,164,164,164,164,,,,164,164,165,165,165,,165,,,,165', -'165,,,,165,,165,165,165,165,165,165,165,,,,,165,165,165,165,165,165', -'165,,,,,,,,,,165,,,165,165,165,165,165,165,165,165,165,165,,165,165', -',,,165,,,,,,,,,,,,,,,,,,,,165,,,165,,,165,165,,165,,,,,,,,,,,,,,,,,', -',165,165,165,165,165,165,,,,165,165,654,654,654,,654,,,,654,654,,,,654', -',654,654,654,654,654,654,654,,,,,654,654,654,654,654,654,654,,,,,,,', -',,654,,,654,654,654,654,654,654,654,654,654,654,,654,654,,654,654,654', -',,,,,,,,,,,,,,,,,,,654,,,654,,,654,654,,654,,654,,654,,654,,,,,,,,654', -',,,,654,654,654,654,654,654,,,,654,654,405,405,405,,405,,,,405,405,', -',,405,,405,405,405,405,405,405,405,,,,,405,405,405,405,405,405,405,', -',,,,,,,,405,,,405,405,405,405,405,405,405,405,405,405,,405,405,,405', -'405,405,,,,,,,,,,,,,,,,,,,,405,,,405,,,405,405,,405,,,,,,405,,,,,,,', -'405,,,,,405,405,405,405,405,405,,,,405,405,572,572,572,,572,,,,572,572', -',,,572,,572,572,572,572,572,572,572,,,,,572,572,572,572,572,572,572', -',,,,,,,,,572,,,572,572,572,572,572,572,572,572,572,572,,572,572,,572', -'572,572,,,,,,,,,,,,,,,,,,,,572,,,572,,,572,572,,572,,,,,,572,,,,,,,', -'572,,,,,572,572,572,572,572,572,,,,572,572,403,403,403,,403,,,,403,403', -',,,403,,403,403,403,403,403,403,403,,,,,403,403,403,403,403,403,403', -',,,,,,,,,403,,,403,403,403,403,403,403,403,403,403,403,,403,403,,403', -'403,403,,,,,,,,,,,,,,,,,,,,403,,,403,,,403,403,,403,,403,,403,,403,', -',,,,,,403,,,,,403,403,403,403,403,403,,,,403,403,401,401,401,,401,,', -',401,401,,,,401,,401,401,401,401,401,401,401,,,,,401,401,401,401,401', -'401,401,,,,,,,,,,401,,,401,401,401,401,401,401,401,401,401,401,,401', -'401,,401,401,401,,,,,,,,,,,,,,,,,,,,401,,,401,,,401,401,,401,,,,,,401', -',,,,,,,401,,,,,401,401,401,401,401,401,,,,401,401,564,564,564,,564,', -',,564,564,,,,564,,564,564,564,564,564,564,564,,,,,564,564,564,564,564', -'564,564,,,,,,,,,,564,,,564,564,564,564,564,564,564,564,564,564,,564', -'564,,,,564,,,,,,,,,,,,,,,,,,,,564,,,564,,,564,564,,564,,564,,,,,,,,', -',,564,,,,,,564,564,564,564,564,564,,,,564,564,560,560,560,,560,,,,560', -'560,,,,560,,560,560,560,560,560,560,560,,,,,560,560,560,560,560,560', -'560,,,560,,,,,,,560,,,560,560,560,560,560,560,560,560,560,560,,560,560', -',560,560,560,,,,,,,,,,,,,,,,,,,,560,,,560,,,560,560,,560,,,,,,560,,', -',,,,,560,,,,,560,560,560,560,560,560,,,,560,560,527,527,527,,527,,,', -'527,527,,,,527,,527,527,527,527,527,527,527,,,,,527,527,527,527,527', -'527,527,,,,,,,,,,527,,,527,527,527,527,527,527,527,527,527,527,,527', -'527,,527,527,527,,,,,,,,,,,,,,,,,,,,527,,,527,,,527,527,,527,,,,,,527', -',,,,,,,527,,,,,527,527,527,527,527,527,,,,527,527,399,399,399,,399,', -',,399,399,,,,399,,399,399,399,399,399,399,399,,,,,399,399,399,399,399', -'399,399,,,,,,,,,,399,,,399,399,399,399,399,399,399,399,399,399,,399', -'399,,399,399,399,,,,,,,,,,,,,,,,,,,,399,,,399,,,399,399,,399,,,,,,399', -',,,,,,,399,,,,,399,399,399,399,399,399,,,,399,399,398,398,398,,398,', -',,398,398,,,,398,,398,398,398,398,398,398,398,,,,,398,398,398,398,398', -'398,398,,,,,,,,,,398,,,398,398,398,398,398,398,398,398,398,398,,398', -'398,,398,398,398,,,,,,,,,,,,,,,,,,,,398,,,398,,,398,398,,398,,,,,,398', -',,,,,,,398,,,,,398,398,398,398,398,398,,,,398,398,396,396,396,,396,', -',,396,396,,,,396,,396,396,396,396,396,396,396,,,,,396,396,396,396,396', -'396,396,,,,,,,,,,396,,,396,396,396,396,396,396,396,396,396,396,,396', -'396,,396,396,396,,,,,,,,,,,,,,,,,,,,396,,,396,,,396,396,,396,,396,,', -',396,,,,,,,,396,,,,,396,396,396,396,396,396,,,,396,396,389,389,389,', -'389,,,,389,389,,,,389,,389,389,389,389,389,389,389,,,,,389,389,389,389', -'389,389,389,,,389,,,,,,,389,,,389,389,389,389,389,389,389,389,389,389', -',389,389,,389,389,389,,,,,,,,,,,,,,,,,,,,389,,,389,,,389,389,,389,,389', -',389,,389,,,,,,,,389,,,,,389,389,389,389,389,389,,,,389,389,706,706', -'706,,706,,,,706,706,,,,706,,706,706,706,706,706,706,706,,,,,706,706', -'706,706,706,706,706,,,,,,,,,,706,,,706,706,706,706,706,706,706,706,706', -'706,,706,706,,706,706,706,,,,,,,,,,,,,,,,,,,,706,,,706,,,706,706,,706', -',,,,,706,,,,,,,,706,,,,,706,706,706,706,706,706,,,,706,706,261,261,261', -',261,,,,261,261,,,,261,,261,261,261,261,261,261,261,,,,,261,261,261', -'261,261,261,261,,,261,,,,,,,261,,,261,261,261,261,261,261,261,261,261', -'261,,261,261,,261,261,261,,,,,,,,,,,,,,,,,,,,261,,,261,,,261,261,,261', -',,,,,261,,,,,,,,261,,,,,261,261,261,261,261,261,,,,261,261,262,262,262', -',262,,,,262,262,,,,262,,262,262,262,262,262,262,262,,,,,262,262,262', -'262,262,262,262,,,262,,,,,,,262,,,262,262,262,262,262,262,262,262,262', -'262,,262,262,,262,262,262,,,,,,,,,,,,,,,,,,,,262,,,262,,,262,262,,262', -',,,,,262,,,,,,,,262,,,,,262,262,262,262,262,262,,,,262,262,17,17,17', -',17,,,,17,17,,,,17,,17,17,17,17,17,17,17,,,,,17,17,17,17,17,17,17,,', -',,,,,,,17,,,17,17,17,17,17,17,17,17,17,17,,17,17,,17,17,17,,,,,,,,,', -',,,,,,,,,,17,,,17,,,17,17,,17,,17,,17,,17,,,,,,,,17,,,,,17,17,17,17', -'17,17,,,,17,17,811,811,811,,811,,,,811,811,,,,811,,811,811,811,811,811', -'811,811,,,,,811,811,811,811,811,811,811,,,,,,,,,,811,,,811,811,811,811', -'811,811,811,811,811,811,,811,811,,,,811,,,,,,,,,,,,,,,,,,,,811,,,811', -',,811,811,,811,,,,,,,,,,,,,,,,,,,811,811,811,811,811,811,,,,811,811', -'376,376,376,,376,,,,376,376,,,,376,,376,376,376,376,376,376,376,,,,', -'376,376,376,376,376,376,376,,,,,,,,,,376,,,376,376,376,376,376,376,376', -'376,376,376,,376,376,,376,376,376,,,,,,,,,,,,,,,,,,,,376,,,376,,,376', -'376,,376,,376,,,,376,,,,,,,,376,,,,,376,376,376,376,376,376,,,,376,376', -'267,267,267,,267,,,,267,267,,,,267,,267,267,267,267,267,267,267,,,,', -'267,267,267,267,267,267,267,,,,,,,,,,267,,,267,267,267,267,267,267,267', -'267,267,267,,267,267,,267,267,267,,,,,,,,,,,,,,,,,,,,267,,,267,267,', -'267,267,,267,,,,,,267,,,,,,,,267,,,,,267,267,267,267,267,267,,,,267', -'267,31,31,31,31,31,31,31,31,,,31,31,31,31,31,,,31,31,31,31,31,31,31', -',,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31', -'31,,,31,,,,,,,,31,31,,31,31,31,31,,31,31,,,31,,,,,31,31,31,31,,,,,,', -',,,,,,31,31,,31,31,31,31,31,31,31,31,31,,31,,,31,31,,,30,30,30,,30,', -',31,30,30,,,,30,,30,30,30,30,30,30,30,,,,,30,30,30,30,30,30,30,,,,,', -',,,,30,,,30,30,30,30,30,30,30,30,30,30,,30,30,,30,30,30,,,,,,,,,,,,', -',,,,,,,30,,,30,,,30,30,,30,,,,,,30,,,,,,,,30,,,,,30,30,30,30,30,30,', -',,30,30,29,29,29,29,29,29,29,29,,,29,29,29,29,29,,,29,29,29,29,29,29', -'29,,,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29', -'29,29,29,,29,,,,,,,,29,29,,29,29,29,29,,29,29,,,29,,,,,29,29,29,29,', -',,,,,,,,,,,29,29,,29,29,29,29,29,29,29,29,29,,29,,,29,29,,,276,276,276', -',276,,,29,276,276,,,,276,,276,276,276,276,276,276,276,,,,,276,276,276', -'276,276,276,276,,,,,,,,,,276,,,276,276,276,276,276,276,276,276,276,276', -',276,276,,276,276,276,,,,,,,,,,,,,,,,,,,,276,,,276,,,276,276,,276,,', -',,,276,,,,,,,,276,,,,,276,276,276,276,276,276,,,,276,276,277,277,277', -',277,,,,277,277,,,,277,,277,277,277,277,277,277,277,,,,,277,277,277', -'277,277,277,277,,,,,,,,,,277,,,277,277,277,277,277,277,277,277,277,277', -',277,277,,277,277,277,,,,,,,,,,,,,,,,,,,,277,,,277,,,277,277,,277,,', -',,,277,,,,,,,,277,,,,,277,277,277,277,277,277,,,,277,277,278,278,278', -',278,,,,278,278,,,,278,,278,278,278,278,278,278,278,,,,,278,278,278', -'278,278,278,278,,,,,,,,,,278,,,278,278,278,278,278,278,278,278,278,278', -',278,278,,278,278,278,,,,,,,,,,,,,,,,,,,,278,,,278,,,278,278,,278,,', -',,,278,,,,,,,,278,,,,,278,278,278,278,278,278,,,,278,278,279,279,279', -',279,,,,279,279,,,,279,,279,279,279,279,279,279,279,,,,,279,279,279', -'279,279,279,279,,,,,,,,,,279,,,279,279,279,279,279,279,279,279,279,279', -',279,279,,279,279,279,,,,,,,,,,,,,,,,,,,,279,,,279,,,279,279,,279,,', -',,,279,,,,,,,,279,,,,,279,279,279,279,279,279,,,,279,279,280,280,280', -',280,,,,280,280,,,,280,,280,280,280,280,280,280,280,,,,,280,280,280', -'280,280,280,280,,,,,,,,,,280,,,280,280,280,280,280,280,280,280,280,280', -',280,280,,280,280,280,,,,,,,,,,,,,,,,,,,,280,,,280,,,280,280,,280,,', -',,,280,,,,,,,,280,,,,,280,280,280,280,280,280,,,,280,280,281,281,281', -',281,,,,281,281,,,,281,,281,281,281,281,281,281,281,,,,,281,281,281', -'281,281,281,281,,,,,,,,,,281,,,281,281,281,281,281,281,281,281,281,281', -',281,281,,281,281,281,,,,,,,,,,,,,,,,,,,,281,,,281,,,281,281,,281,,', -',,,281,,,,,,,,281,,,,,281,281,281,281,281,281,,,,281,281,282,282,282', -',282,,,,282,282,,,,282,,282,282,282,282,282,282,282,,,,,282,282,282', -'282,282,282,282,,,,,,,,,,282,,,282,282,282,282,282,282,282,282,282,282', -',282,282,,282,282,282,,,,,,,,,,,,,,,,,,,,282,,,282,,,282,282,,282,,', -',,,282,,,,,,,,282,,,,,282,282,282,282,282,282,,,,282,282,283,283,283', -',283,,,,283,283,,,,283,,283,283,283,283,283,283,283,,,,,283,283,283', -'283,283,283,283,,,,,,,,,,283,,,283,283,283,283,283,283,283,283,283,283', -',283,283,,283,283,283,,,,,,,,,,,,,,,,,,,,283,,,283,,,283,283,,283,,', -',,,283,,,,,,,,283,,,,,283,283,283,283,283,283,,,,283,283,284,284,284', -',284,,,,284,284,,,,284,,284,284,284,284,284,284,284,,,,,284,284,284', -'284,284,284,284,,,,,,,,,,284,,,284,284,284,284,284,284,284,284,284,284', -',284,284,,284,284,284,,,,,,,,,,,,,,,,,,,,284,,,284,,,284,284,,284,,', -',,,284,,,,,,,,284,,,,,284,284,284,284,284,284,,,,284,284,285,285,285', -',285,,,,285,285,,,,285,,285,285,285,285,285,285,285,,,,,285,285,285', -'285,285,285,285,,,,,,,,,,285,,,285,285,285,285,285,285,285,285,285,285', -',285,285,,285,285,285,,,,,,,,,,,,,,,,,,,,285,,,285,,,285,285,,285,,', -',,,285,,,,,,,,285,,,,,285,285,285,285,285,285,,,,285,285,286,286,286', -',286,,,,286,286,,,,286,,286,286,286,286,286,286,286,,,,,286,286,286', -'286,286,286,286,,,,,,,,,,286,,,286,286,286,286,286,286,286,286,286,286', -',286,286,,286,286,286,,,,,,,,,,,,,,,,,,,,286,,,286,,,286,286,,286,,', -',,,286,,,,,,,,286,,,,,286,286,286,286,286,286,,,,286,286,287,287,287', -',287,,,,287,287,,,,287,,287,287,287,287,287,287,287,,,,,287,287,287', -'287,287,287,287,,,,,,,,,,287,,,287,287,287,287,287,287,287,287,287,287', -',287,287,,287,287,287,,,,,,,,,,,,,,,,,,,,287,,,287,,,287,287,,287,,', -',,,287,,,,,,,,287,,,,,287,287,287,287,287,287,,,,287,287,288,288,288', -',288,,,,288,288,,,,288,,288,288,288,288,288,288,288,,,,,288,288,288', -'288,288,288,288,,,,,,,,,,288,,,288,288,288,288,288,288,288,288,288,288', -',288,288,,288,288,288,,,,,,,,,,,,,,,,,,,,288,,,288,,,288,288,,288,,', -',,,288,,,,,,,,288,,,,,288,288,288,288,288,288,,,,288,288,289,289,289', -',289,,,,289,289,,,,289,,289,289,289,289,289,289,289,,,,,289,289,289', -'289,289,289,289,,,,,,,,,,289,,,289,289,289,289,289,289,289,289,289,289', -',289,289,,289,289,289,,,,,,,,,,,,,,,,,,,,289,,,289,,,289,289,,289,,', -',,,289,,,,,,,,289,,,,,289,289,289,289,289,289,,,,289,289,290,290,290', -',290,,,,290,290,,,,290,,290,290,290,290,290,290,290,,,,,290,290,290', -'290,290,290,290,,,,,,,,,,290,,,290,290,290,290,290,290,290,290,290,290', -',290,290,,290,290,290,,,,,,,,,,,,,,,,,,,,290,,,290,,,290,290,,290,,', -',,,290,,,,,,,,290,,,,,290,290,290,290,290,290,,,,290,290,291,291,291', -',291,,,,291,291,,,,291,,291,291,291,291,291,291,291,,,,,291,291,291', -'291,291,291,291,,,,,,,,,,291,,,291,291,291,291,291,291,291,291,291,291', -',291,291,,291,291,291,,,,,,,,,,,,,,,,,,,,291,,,291,,,291,291,,291,,', -',,,291,,,,,,,,291,,,,,291,291,291,291,291,291,,,,291,291,292,292,292', -',292,,,,292,292,,,,292,,292,292,292,292,292,292,292,,,,,292,292,292', -'292,292,292,292,,,,,,,,,,292,,,292,292,292,292,292,292,292,292,292,292', -',292,292,,292,292,292,,,,,,,,,,,,,,,,,,,,292,,,292,,,292,292,,292,,', -',,,292,,,,,,,,292,,,,,292,292,292,292,292,292,,,,292,292,293,293,293', -',293,,,,293,293,,,,293,,293,293,293,293,293,293,293,,,,,293,293,293', -'293,293,293,293,,,,,,,,,,293,,,293,293,293,293,293,293,293,293,293,293', -',293,293,,293,293,293,,,,,,,,,,,,,,,,,,,,293,,,293,,,293,293,,293,,', -',,,293,,,,,,,,293,,,,,293,293,293,293,293,293,,,,293,293,294,294,294', -',294,,,,294,294,,,,294,,294,294,294,294,294,294,294,,,,,294,294,294', -'294,294,294,294,,,,,,,,,,294,,,294,294,294,294,294,294,294,294,294,294', -',294,294,,294,294,294,,,,,,,,,,,,,,,,,,,,294,,,294,,,294,294,,294,,', -',,,294,,,,,,,,294,,,,,294,294,294,294,294,294,,,,294,294,295,295,295', -',295,,,,295,295,,,,295,,295,295,295,295,295,295,295,,,,,295,295,295', -'295,295,295,295,,,,,,,,,,295,,,295,295,295,295,295,295,295,295,295,295', -',295,295,,295,295,295,,,,,,,,,,,,,,,,,,,,295,,,295,,,295,295,,295,,', -',,,295,,,,,,,,295,,,,,295,295,295,295,295,295,,,,295,295,296,296,296', -',296,,,,296,296,,,,296,,296,296,296,296,296,296,296,,,,,296,296,296', -'296,296,296,296,,,,,,,,,,296,,,296,296,296,296,296,296,296,296,296,296', -',296,296,,296,296,296,,,,,,,,,,,,,,,,,,,,296,,,296,,,296,296,,296,,', -',,,296,,,,,,,,296,,,,,296,296,296,296,296,296,,,,296,296,297,297,297', -',297,,,,297,297,,,,297,,297,297,297,297,297,297,297,,,,,297,297,297', -'297,297,297,297,,,,,,,,,,297,,,297,297,297,297,297,297,297,297,297,297', -',297,297,,297,297,297,,,,,,,,,,,,,,,,,,,,297,,,297,,,297,297,,297,,', -',,,297,,,,,,,,297,,,,,297,297,297,297,297,297,,,,297,297,298,298,298', -',298,,,,298,298,,,,298,,298,298,298,298,298,298,298,,,,,298,298,298', -'298,298,298,298,,,,,,,,,,298,,,298,298,298,298,298,298,298,298,298,298', -',298,298,,298,298,298,,,,,,,,,,,,,,,,,,,,298,,,298,,,298,298,,298,,', -',,,298,,,,,,,,298,,,,,298,298,298,298,298,298,,,,298,298,299,299,299', -',299,,,,299,299,,,,299,,299,299,299,299,299,299,299,,,,,299,299,299', -'299,299,299,299,,,,,,,,,,299,,,299,299,299,299,299,299,299,299,299,299', -',299,299,,299,299,299,,,,,,,,,,,,,,,,,,,,299,,,299,,,299,299,,299,,', -',,,299,,,,,,,,299,,,,,299,299,299,299,299,299,,,,299,299,300,300,300', -',300,,,,300,300,,,,300,,300,300,300,300,300,300,300,,,,,300,300,300', -'300,300,300,300,,,,,,,,,,300,,,300,300,300,300,300,300,300,300,300,300', -',300,300,,300,300,300,,,,,,,,,,,,,,,,,,,,300,,,300,,,300,300,,300,,', -',,,300,,,,,,,,300,,,,,300,300,300,300,300,300,,,,300,300,301,301,301', -',301,,,,301,301,,,,301,,301,301,301,301,301,301,301,,,,,301,301,301', -'301,301,301,301,,,,,,,,,,301,,,301,301,301,301,301,301,301,301,301,301', -',301,301,,301,301,301,,,,,,,,,,,,,,,,,,,,301,,,301,,,301,301,,301,,', -',,,301,,,,,,,,301,,,,,301,301,301,301,301,301,,,,301,301,368,368,368', -',368,,,,368,368,,,,368,,368,368,368,368,368,368,368,,,,,368,368,368', -'368,368,368,368,,,,,,,,,,368,,,368,368,368,368,368,368,368,368,368,368', -',368,368,,368,368,368,,,,,,,,,,,,,,,,,,,,368,,,368,368,,368,368,,368', -',368,,368,,368,,,,,,,,368,,,,,368,368,368,368,368,368,,,,368,368,633', -'633,633,633,633,633,633,633,,,633,633,633,633,633,,,633,633,633,633', -'633,633,633,,,633,633,633,633,633,633,633,633,633,633,633,633,633,633', -'633,633,633,633,633,633,633,633,633,,,633,,,,,,,,633,633,,633,633,633', -'633,,633,633,,,633,,,,,633,633,633,633,,,,,,,,,,,,,633,633,,633,633', -'633,633,633,633,633,633,633,,633,,,633,633,,,365,365,365,,365,,,633', -'365,365,,,,365,,365,365,365,365,365,365,365,,,,,365,365,365,365,365', -'365,365,,,,,,,,,,365,,,365,365,365,365,365,365,365,365,365,365,,365', -'365,,365,365,365,,,,,,,,,,,,,,,,,,,,365,,,365,365,,365,365,,365,,365', -',365,,365,,,,,,,,365,,,,,365,365,365,365,365,365,,,,365,365,20,20,20', -',20,,,,20,20,,,,20,,20,20,20,20,20,20,20,,,,,20,20,20,20,20,20,20,,', -',,,,,,,20,,,20,20,20,20,20,20,20,20,20,20,,20,20,,20,20,20,,,,,,,,,', -',,,,,,,,,,20,,,20,,,20,20,,20,,,,,,20,,,,,,,,20,,,,,20,20,20,20,20,20', -',,,20,20,700,700,700,,700,,,,700,700,,,,700,,700,700,700,700,700,700', -'700,,,,,700,700,700,700,700,700,700,,,,,,,,,,700,,,700,700,700,700,700', -'700,700,700,700,700,,700,700,,700,700,700,,,,,,,,,,,,,,,,,,,,700,,,700', -',,700,700,,700,,700,,700,,700,,,,,,,,700,,,,,700,700,700,700,700,700', -',,,700,700,788,788,788,,788,,,,788,788,,,,788,,788,788,788,788,788,788', -'788,,,,,788,788,788,788,788,788,788,,,,,,,,,,788,,,788,788,788,788,788', -'788,788,788,788,788,,788,788,,788,788,788,,,,,,,,,,,,,,,,,,,,788,,,788', -',,788,788,,788,,,,,,788,,,,,,,,788,,,,,788,788,788,788,788,788,,,,788', -'788,25,25,25,,25,,,,25,25,,,,25,,25,25,25,25,25,25,25,,,,,25,25,25,25', -'25,25,25,,,,,,,,,,25,,,25,25,25,25,25,25,25,25,25,25,,25,25,,25,25,25', -',,,,,,,,,,,,,,,,,,,25,,,25,,,25,25,,25,,,,,,25,,,,,,,,25,,,,,25,25,25', -'25,25,25,,,,25,25,313,313,313,,313,,,,313,313,,,,313,,313,313,313,313', -'313,313,313,,,,,313,313,313,313,313,313,313,,,,,,,,,,313,,,313,313,313', -'313,313,313,313,313,313,313,,313,313,,313,313,313,,,,,,,,,,,,,,,,,,', -',313,,,313,,313,313,313,,313,,313,,313,,313,,,,,,,,313,,,,,313,313,313', -'313,313,313,,,,313,313,314,314,314,,314,,,,314,314,,,,314,,314,314,314', -'314,314,314,314,,,,,314,314,314,314,314,314,314,,,314,,,,,,,314,,,314', -'314,314,314,314,314,314,314,314,314,,314,314,,314,314,314,,,,,,,,,,', -',,,,,,,,,314,,,314,,,314,314,,314,,,,,,314,,,,,,,,314,,,,,314,314,314', -'314,314,314,,,,314,314,315,315,315,,315,,,,315,315,,,,315,,315,315,315', -'315,315,315,315,,,,,315,315,315,315,315,315,315,,,315,,,,,,,315,,,315', -'315,315,315,315,315,315,315,315,315,,315,315,,315,315,315,,,,,,,,,,', -',,,,,,,,,315,,,315,,,315,315,,315,,,,,,315,,,,,,,,315,,,,,315,315,315', -'315,315,315,,,,315,315,316,316,316,,316,,,,316,316,,,,316,,316,316,316', -'316,316,316,316,,,,,316,316,316,316,316,316,316,,,316,,,,,,,316,,,316', -'316,316,316,316,316,316,316,316,316,,316,316,,316,316,316,,,,,,,,,,', -',,,,,,,,,316,,,316,,,316,316,,316,,,,,,316,,,,,,,,316,,,,,316,316,316', -'316,316,316,,,,316,316,317,317,317,,317,,,,317,317,,,,317,,317,317,317', -'317,317,317,317,,,,,317,317,317,317,317,317,317,,,317,,,,,,,317,,,317', -'317,317,317,317,317,317,317,317,317,,317,317,,317,317,317,,,,,,,,,,', -',,,,,,,,,317,,,317,,,317,317,,317,,,,,,317,,,,,,,,317,,,,,317,317,317', -'317,317,317,,,,317,317,318,318,318,318,318,,,,318,318,,,,318,,318,318', -'318,318,318,318,318,,,,,318,318,318,318,318,318,318,,,318,,,,,,318,318', -'318,318,318,318,318,318,318,318,318,318,318,318,,318,318,,318,318,318', -',,,,,,,,,,,,,,,,,,,318,,,318,,,318,318,,318,,318,,,,318,,,,,,,,318,', -',,,318,318,318,318,318,318,,,,318,318,321,321,321,,321,,,,321,321,,', -',321,,321,321,321,321,321,321,321,,,,,321,321,321,321,321,321,321,,', -',,,,,,,321,,,321,321,321,321,321,321,321,321,321,321,,321,321,,321,321', -'321,,,,,,,,,,,,,,,,,,,,321,,,321,,,321,321,,321,,321,,321,,321,,,,,', -',,321,,,,,321,321,321,321,321,321,,,,321,321,363,363,363,,363,,,,363', -'363,,,,363,,363,363,363,363,363,363,363,,,,,363,363,363,363,363,363', -'363,,,,,,,,,,363,,,363,363,363,363,363,363,363,363,363,363,,363,363', -',363,363,363,,,,,,,,,,,,,,,,,,,,363,,,363,363,,363,363,,363,,363,,363', -',363,,,,,,,,363,,,,,363,363,363,363,363,363,,,,363,363,354,354,354,', -'354,,,,354,354,,,,354,,354,354,354,354,354,354,354,,,,,354,354,354,354', -'354,354,354,,,354,,,,,,,354,,,354,354,354,354,354,354,354,354,354,354', -',354,354,,354,354,354,,,,,,,,,,,,,,,,,,,,354,,,354,,,354,354,,354,,', -',,,354,,,,,,,,354,,,,,354,354,354,354,354,354,,,,354,354,353,353,353', -',353,,,,353,353,,,,353,,353,353,353,353,353,353,353,,,,,353,353,353', -'353,353,353,353,,,,,,,,,,353,,,353,353,353,353,353,353,353,353,353,353', -',353,353,,353,353,353,,,,,,,,,,,,,,,,,,,,353,,,353,,,353,353,,353,,', -',,,353,,,,,,,,353,,,,,353,353,353,353,353,353,,,,353,353,551,551,551', -',551,,,,551,551,,,,551,,551,551,551,551,551,551,551,,,,,551,551,551', -'551,551,551,551,,,,,,,,,,551,,,551,551,551,551,551,551,551,551,551,551', -',551,551,,551,551,551,,,,,,,,,,,,,,,,,,,,551,,,551,,,551,551,,551,,', -',,,551,,,,,,,,551,,,,,551,551,551,551,551,551,,,,551,551,786,786,786', -',786,,,,786,786,,,,786,,786,786,786,786,786,786,786,,,,,786,786,786', -'786,786,786,786,,,,,,,,,,786,,,786,786,786,786,786,786,786,786,786,786', -',786,786,,786,786,786,,,,,,,,,,,,,,,,,,,,786,,,786,,,786,786,,786,,', -',,,786,,,,,,,,786,,,,,786,786,786,786,786,786,,,,786,786,785,785,785', -',785,,,,785,785,,,,785,,785,785,785,785,785,785,785,,,,,785,785,785', -'785,785,785,785,,,,,,,,,,785,,,785,785,785,785,785,785,785,785,785,785', -',785,785,,785,785,785,,,,,,,,,,,,,,,,,,,,785,,,785,,,785,785,,785,,', -',,,785,,,,,,,,785,,,,,785,785,785,785,785,785,,,,785,785,550,550,550', -',550,,,,550,550,,,,550,,550,550,550,550,550,550,550,,,,,550,550,550', -'550,550,550,550,,,,,,,,,,550,,,550,550,550,550,550,550,550,550,550,550', -',550,550,,550,550,550,,,,,,,,,,,,,,,,,,,,550,,,550,,,550,550,,550,,', -',,,550,,,,,,,,550,,,,,550,550,550,550,550,550,,,,550,550,332,332,332', -',332,,,,332,332,,,,332,,332,332,332,332,332,332,332,,,,,332,332,332', -'332,332,332,332,,,,,,,,,,332,,,332,332,332,332,332,332,332,332,332,332', -',332,332,,332,332,332,,,,,,,,,,,,,,,,,,,,332,,,332,,,332,332,,332,,', -',,,332,,,,,,,,332,,,,,332,332,332,332,332,332,,,,332,332,703,703,703', -',703,,,,703,703,,,,703,,703,703,703,703,703,703,703,,,,,703,703,703', -'703,703,703,703,,,,,,,,,,703,,,703,703,703,703,703,703,703,703,703,703', -',703,703,,703,703,703,,,,,,,,,,,,,,,,,,,,703,,,703,,,703,703,,703,,703', -',703,,703,,,,,,,,703,,,,,703,703,703,703,703,703,,,,703,703,334,334', -'334,,334,,,,334,334,,,,334,,334,334,334,334,334,334,334,,,,,334,334', -'334,334,334,334,334,,,,,,,,,,334,,,334,334,334,334,334,334,334,334,334', -'334,,334,334,,334,334,334,,,,,,,,,,,,,,,,,,,,334,,,334,,,334,334,,334', -',334,,,,334,,,,,,,,334,,,,,334,334,334,334,334,334,,,,334,334,545,545', -'545,,545,,,,545,545,,,,545,,545,545,545,545,545,545,545,,,,,545,545', -'545,545,545,545,545,,,,,,,,,,545,,,545,545,545,545,545,545,545,545,545', -'545,,545,545,,545,545,545,,,,,,,,,,,,,,,,,,,,545,,,545,,,545,545,,545', -',,,,,545,,,,,,,,545,,,,,545,545,545,545,545,545,,,,545,545,782,782,782', -',782,,,,782,782,,,,782,,782,782,782,782,782,782,782,,,,,782,782,782', -'782,782,782,782,,,,,,,,,,782,,,782,782,782,782,782,782,782,782,782,782', -',782,782,,782,782,782,,,,,,,,,,,,,,,,,,,,782,,,782,,,782,782,,782,,', -',,,782,,,,,,,,782,,,,,782,782,782,782,782,782,,,,782,782,544,544,544', -',544,,,,544,544,,,,544,,544,544,544,544,544,544,544,,,,,544,544,544', -'544,544,544,544,,,,,,,,,,544,,,544,544,544,544,544,544,544,544,544,544', -',544,544,,544,544,544,,,,,,,,,,,,,,,,,,,,544,,,544,,,544,544,,544,,', -',,,544,,,,,,,,544,,,,,544,544,544,544,544,544,,,,544,544,351,351,351', -',351,,,,351,351,,,,351,,351,351,351,351,351,351,351,,,,,351,351,351', -'351,351,351,351,,,351,,,,,,,351,,,351,351,351,351,351,351,351,351,351', -'351,,351,351,,351,351,351,,,,,,,,,,,,,,,,,,,,351,,,351,,,351,351,,351', -',,,,,351,,,,,,,,351,,,,,351,351,351,351,351,351,,,,351,351,705,705,705', -',705,,,,705,705,,,,705,,705,705,705,705,705,705,705,,,,,705,705,705', -'705,705,705,705,,,,,,,,,,705,,,705,705,705,705,705,705,705,705,705,705', -',705,705,,705,705,705,,,,,,,,,,,,,,,,,,,,705,,,705,,,705,705,,705,,', -',,,705,,,,,,,,705,,,,,705,705,705,705,705,705,,,,705,705,350,350,350', -',350,,,,350,350,,,,350,,350,350,350,350,350,350,350,,,,,350,350,350', -'350,350,350,350,,,,,,,,,,350,,,350,350,350,350,350,350,350,350,350,350', -',350,350,,350,350,350,,,,,,,,,,,,,,,,,,,,350,,,350,,,350,350,,350,,350', -',,,350,,,,,,,,350,,,,,350,350,350,350,350,350,,,,350,350,763,763,763', -',763,,,,763,763,,,,763,,763,763,763,763,763,763,763,,,,,763,763,763', -'763,763,763,763,,,,,,,,,,763,,,763,763,763,763,763,763,763,763,763,763', -',763,763,,763,763,763,,,,,,,,,,,,,,,,,,,,763,,,763,,,763,763,,763,,', -',,,763,,,,,,,,763,,,,,763,763,763,763,763,763,,,,763,763,257,257,257', -'257,257,257,257,257,,,257,257,257,257,257,,,257,257,257,257,257,257', -'257,,,257,257,257,257,257,257,257,257,257,257,257,257,257,257,257,257', -'257,257,257,257,257,257,257,257,257,257,257,,,,,,,257,257,,257,257,257', -'257,,257,257,,,257,,,,,257,257,257,257,,,,,,,,,,,,,257,257,,257,257', -'257,257,257,257,257,257,257,,257,,,257,611,611,611,611,611,611,611,611', -',,611,611,611,611,611,,,611,611,611,611,611,611,611,,,611,611,611,611', -'611,611,611,611,611,611,611,611,611,611,611,611,611,611,611,611,611', -'611,611,,,611,,,,,,,,611,611,,611,611,611,611,,611,611,,,611,,,,,611', -'611,611,611,,,,,,,,,,,,,611,611,,611,611,611,611,611,611,611,611,611', -',611,,,611,84,84,84,84,84,84,84,84,,,84,84,84,84,84,,,84,84,84,84,84', -'84,84,,,84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,84,84', -'84,84,84,84,84,84,84,,,,,,,84,84,,84,84,84,84,,84,84,,,84,,,,,84,84', -'84,84,,,,,,,,,,,,,84,84,,84,84,84,84,84,84,84,84,84,,84,,,84,26,26,26', -'26,26,26,26,26,,,26,26,26,26,26,,,26,26,26,26,26,26,26,,,26,26,26,26', -'26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26', -',,,,,,26,26,,26,26,26,26,,26,26,,,26,,,,,26,26,26,26,,,,,,26,,,,,,,26', -'26,,26,26,26,26,26,26,26,26,26,,26,326,326,26,,326,,,,,,,,326,326,,326', -'326,326,326,,326,326,,,326,,,,,326,326,326,326,,,,,,,,,,,,,326,326,', -'326,326,326,326,326,326,326,326,326,,326,,,326,571,571,571,571,571,571', -'571,571,571,571,571,,571,571,,,571,571,,,,571,,,,,,,,,,571,,571,,571', -'571,571,571,571,571,571,,571,,,,,,,422,422,,,422,,,,,571,,571,422,422', -',422,422,422,422,,422,422,,,422,,,,,422,422,422,422,,,,,,,,,,,,,422', -'422,,422,422,422,422,422,422,422,422,422,,422,423,423,422,,423,,,,,', -',,423,423,,423,423,423,423,,423,423,,,423,,,,,423,423,423,423,,,,,,', -',,,,,,423,423,,423,423,423,423,423,423,423,423,423,,423,424,424,423', -',424,,,,,,,,424,424,,424,424,424,424,,424,424,,,424,,,,,424,424,424', -'424,,,,,,,,,,,,,424,424,,424,424,424,424,424,424,424,424,424,,424,425', -'425,424,,425,,,,,,,,425,425,,425,425,425,425,,425,425,,,425,,,,,425', -'425,425,425,,,,,,,,,,,,,425,425,,425,425,425,425,425,425,425,425,425', -',425,872,872,425,,872,,,,,,,,872,872,,872,872,872,872,,872,872,,,872', -',,,,872,872,872,872,,,,,,,,,,,,,872,872,,872,872,872,872,872,872,872', -'872,872,,872,871,871,872,,871,,,,,,,,871,871,,871,871,871,871,,871,871', -',,871,,,,,871,871,871,871,,,,,,,,,,,,,871,871,,871,871,871,871,871,871', -'871,871,871,,871,395,395,871,,395,,,,,,,,395,395,,395,395,395,395,,395', -'395,,,395,,,,,395,395,395,395,,,,,,,,,,,,,395,395,,395,395,395,395,395', -'395,395,395,395,,395,594,594,395,,594,,,,,,,,594,594,,594,594,594,594', -',594,594,,,594,,,,,594,594,594,594,,,,,,,,,,,,,594,594,,594,594,594', -'594,594,594,594,594,594,,594,375,375,594,,375,,,,,,,,375,375,,375,375', -'375,375,,375,375,,,375,,,,,375,375,375,375,,,,,,,,,,,,,375,375,,375', -'375,375,375,375,375,375,375,375,,375,,,375,836,836,836,836,836,836,836', -'836,836,836,836,,836,836,,,836,836,,,,,,,,,,,,,,836,,836,,836,836,836', -'836,836,836,836,,836,,,,,,,394,394,,,394,,,,,836,,836,394,394,,394,394', -'394,394,,394,394,,,394,,,,,394,394,394,394,,,,,,,,,,,,,394,394,,394', -'394,394,394,394,394,394,394,394,,394,325,325,394,,325,,,,,,,,325,325', -',325,325,325,325,,325,325,,,325,,,,,325,325,325,325,,,,,,,,,,,,,325', -'325,,325,325,325,325,325,325,325,325,325,,325,374,374,325,,374,,,,,', -',,374,374,,374,374,374,374,,374,374,,,374,,,,,374,374,374,374,,,,,,', -',,,,,,374,374,,374,374,374,374,374,374,374,374,374,,374,101,101,374', -',101,,,,,,,,101,101,,101,101,101,101,,101,101,,,101,,,,,101,101,101', -'101,,,,,,,,,,,,,101,101,,101,101,101,101,101,101,101,101,101,,101,652', -'652,101,,652,,,,,,,,652,652,,652,652,652,652,,652,652,,,652,,,,,652', -'652,652,652,,,,,,,,,,,,,652,652,,652,652,652,652,652,652,652,652,652', -',652,102,102,652,,102,,,,,,,,102,102,,102,102,102,102,,102,102,,,102', -',,,,102,102,102,102,,,,,,,,,,,,,102,102,,102,102,102,102,102,102,102', -'102,102,,102,651,651,102,,651,,,,,,,,651,651,,651,651,651,651,,651,651', -',,651,,,,,651,651,651,651,,,,,,,,,,,,,651,651,,651,651,651,651,651,651', -'651,651,651,,651,595,595,651,,595,,,,,,,,595,595,,595,595,595,595,,595', -'595,,,595,,,,,595,595,595,595,,,,,,,,,,,,,595,595,,595,595,595,595,595', -'595,595,595,595,,595,,,595,459,459,459,459,459,459,459,459,459,459,459', -',459,459,,,459,459,,,,,,,,,,,,,,459,,459,,459,459,459,459,459,459,459', -',459,,448,448,448,448,448,448,448,448,448,448,448,,448,448,459,459,448', -'448,,,,,,,,,,,,,,448,,448,,448,448,448,448,448,448,448,,448,537,537', -'537,537,537,537,537,537,537,537,537,,537,537,,448,537,537,,,,,,,,,,', -',,,537,,537,,537,537,537,537,537,537,537,,537,689,689,689,689,689,689', -'689,689,689,689,689,,689,689,,537,689,689,,,,,,,,,,,,,,689,,689,,689', -'689,689,689,689,689,689,,689,512,512,512,512,512,512,512,512,512,512', -'512,,512,512,,689,512,512,,,,,,,,,,,,,,512,,512,,512,512,512,512,512', -'512,512,,512,760,760,760,760,760,760,760,760,760,760,760,,760,760,512', -'512,760,760,,,,,,,,,,,,,,760,,760,,760,760,760,760,760,760,760,,760', -'772,772,772,772,772,772,772,772,772,772,772,,772,772,760,760,772,772', -',,,,,,,,,,,,,772,,772,,772,772,772,772,772,772,772,,772,761,761,761', -'761,761,761,761,761,761,761,761,,761,761,,772,761,761,,,,,,,,,,,,,,761', -',761,,761,761,761,761,761,761,761,,761,683,683,683,683,683,683,683,683', -'683,683,683,,683,683,,761,683,683,,,,,,,,,,,,,,683,,683,,683,683,683', -'683,683,683,683,,683,685,685,685,685,685,685,685,685,685,685,685,,685', -'685,,683,685,685,,,,,,,,,,,,,,685,,685,,685,685,685,685,685,685,685', -',685,687,687,687,687,687,687,687,687,687,687,687,,687,687,,685,687,687', -',,,,,,,,,,,,,687,,687,,687,687,687,687,687,687,687,,687,137,137,137', -'137,137,137,137,137,137,137,137,,137,137,,687,137,137,,,,,,,,,,,,,,137', -',137,,137,137,137,137,137,137,137,,137,420,420,420,420,420,420,420,420', -'420,420,420,,420,420,,137,420,420,,,,,,,,,,,,,,420,,420,,420,420,420', -'420,420,420,420,,420,46,46,46,46,46,46,46,46,46,46,46,,46,46,,420,46', -'46,,,,,,,,,,,,,,46,,46,,46,46,46,46,46,46,46,,46,747,747,747,747,747', -'747,747,747,747,747,747,,747,747,,46,747,747,,,,,,,,,,,,,,747,,747,', -'747,747,747,747,747,747,747,,747,640,640,640,640,640,640,640,640,640', -'640,640,,640,640,,747,640,640,,,,,,,,,,,,,,640,,640,,640,640,640,640', -'640,640,640,,640,,,,,,,,,,,,,,,,640' ] - racc_action_check = arr = ::Array.new(23872, nil) - idx = 0 - clist.each do |str| - str.split(',', -1).each do |i| - arr[idx] = i.to_i unless i.empty? - idx += 1 - end - end - -racc_action_pointer = [ - nil, 24, 4296, 1028, nil, 371, 6097, 133, 7, nil, - 901, 7177, nil, nil, 10049, nil, 898, 13889, 941, 329, - 18185, 9209, nil, nil, 895, 18545, 21872, nil, nil, 14601, - 14481, 14369, 84, nil, nil, nil, 436, nil, 318, 897, - nil, -92, 455, 958, nil, nil, 23660, 890, nil, nil, - 966, 4537, nil, 8137, 3933, nil, 8017, nil, 1029, 4897, - 4777, 9569, nil, 4657, nil, nil, 458, 126, nil, nil, - nil, nil, 5017, nil, nil, nil, 5137, nil, 5257, 226, - nil, 861, 776, nil, 21763, nil, nil, 5857, nil, nil, - 860, nil, nil, nil, 903, nil, 6217, 6337, nil, 298, - nil, 22804, 22922, 6817, 373, -10, nil, nil, -14, 956, - 541, 165, 840, 890, nil, 855, 854, nil, nil, nil, - 853, 844, nil, nil, 8377, nil, nil, 185, 810, nil, - 496, 8849, -72, nil, 843, -51, 874, 23572, nil, 3691, - nil, 9689, nil, 797, 793, 832, 10169, 789, 1150, 791, - -40, nil, nil, nil, 10769, 10889, 311, nil, 289, 209, - 777, 199, 841, 3086, 11849, 11969, nil, nil, nil, nil, - nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, - nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, - nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, - nil, nil, nil, nil, nil, nil, nil, nil, 337, nil, - nil, nil, nil, 309, nil, nil, nil, nil, -48, nil, - nil, nil, nil, 193, 191, nil, nil, nil, nil, 105, - nil, nil, nil, 285, 359, nil, 399, nil, nil, nil, - nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, - nil, nil, nil, 367, nil, nil, nil, 21545, 829, nil, - 760, 13649, 13769, 808, 806, 2602, nil, 14249, nil, nil, - 902, nil, nil, nil, 473, 761, 14713, 14833, 14953, 15073, - 15193, 15313, 15433, 15553, 15673, 15793, 15913, 16033, 16153, 16273, - 16393, 16513, 16633, 16753, 16873, 16993, 17113, 17233, 17353, 17473, - 17593, 17713, 1997, nil, nil, nil, 636, 48, 770, 766, - 763, 1876, nil, 18665, 18785, 18905, 19025, 19145, 19265, nil, - nil, 19385, nil, nil, 33, 22686, 21931, 630, 745, nil, - 711, -79, 20345, 334, 20585, 349, 694, 335, nil, 180, - nil, nil, nil, nil, nil, 388, 702, -99, -56, nil, - 21305, 21065, 188, 19745, 19625, nil, nil, nil, nil, nil, - nil, nil, 716, 19505, 0, 18065, 247, nil, 17833, nil, - 601, nil, 554, 711, 22745, 22515, 14129, nil, nil, nil, - 714, 139, nil, nil, nil, 77, 138, nil, nil, 13409, - 87, nil, nil, nil, 22627, 22397, 13289, nil, 13169, 13049, - 89, 12569, nil, 12449, nil, 12209, 675, 11129, nil, nil, - 664, nil, 11009, 286, nil, 313, nil, 10, 550, 547, - 23616, nil, 22043, 22102, 22161, 22220, 9449, nil, 519, 701, - nil, nil, nil, nil, nil, 659, 8729, 8617, nil, nil, - nil, nil, nil, nil, 8497, 7897, 770, 763, 23132, 7537, - 1066, nil, 7417, 1392, 1029, 700, 2602, 1150, 686, 23087, - 1271, 645, 350, 1392, 717, 674, 2360, 1513, 1876, 2118, - 2481, 2723, 2239, 678, 1997, 2965, 2844, 671, 1755, 1634, - 618, -51, nil, 4175, nil, 710, nil, 596, 627, 610, - nil, nil, nil, nil, nil, nil, 605, 665, 568, 187, - 563, 2360, 661, nil, nil, 607, 564, nil, nil, nil, - nil, 6937, 23264, nil, 7057, nil, nil, 776, nil, 542, - 9329, 2118, 647, nil, 628, nil, nil, 12929, nil, nil, - nil, nil, nil, 514, nil, 57, nil, 23176, nil, 61, - 1634, 510, 537, nil, 20945, 20705, 513, nil, nil, nil, - 20225, 19865, 353, 503, 5, 153, 489, 154, 23, 472, - 12809, -50, nil, nil, 12689, nil, nil, nil, nil, -67, - 466, 21978, 12329, 409, nil, nil, 497, 377, 210, 196, - 420, nil, 902, nil, 411, 10409, 359, 380, nil, 385, - nil, 8969, nil, 488, 22456, 23040, 8257, nil, nil, 140, - 210, nil, nil, nil, 251, 390, 380, 248, 294, nil, - 4417, 21654, 294, 261, 416, 171, 117, 99, nil, 87, - nil, nil, nil, nil, 2481, nil, nil, nil, nil, nil, - 671, -32, nil, 17953, 112, 30, 71, 5617, nil, 257, - 23748, 638, 5737, nil, nil, 591, nil, -69, nil, nil, - 98, 22981, 22863, 150, 12089, 253, nil, nil, nil, nil, - 189, nil, 11729, nil, 9929, 9809, nil, 366, nil, 5377, - 380, nil, nil, nil, nil, nil, 335, nil, nil, nil, - nil, nil, nil, 23440, nil, 23484, nil, 23528, nil, 23220, - nil, 11249, 127, 23, nil, 2844, 468, nil, 2239, 491, - 18305, nil, 471, 20465, nil, 21185, 13529, 10649, -36, 535, - 9089, nil, 551, 415, nil, 549, 510, 600, nil, 6457, - 2965, 457, 701, nil, nil, nil, nil, 610, nil, 5977, - -44, nil, 555, nil, 719, 610, 645, nil, 1513, 729, - nil, 654, nil, 616, nil, nil, nil, 23704, 3207, 6577, - 742, nil, nil, 670, 671, nil, 736, 14, 762, nil, - 23308, 23396, 659, 21425, nil, -10, 667, 11369, nil, 1150, - 1271, nil, 23352, nil, nil, 1755, 805, nil, 706, nil, - nil, 694, 20825, 697, nil, 20105, 19985, nil, 18425, nil, - nil, nil, 173, 846, nil, 665, 735, 736, nil, nil, - nil, 734, 739, nil, nil, 779, nil, nil, nil, 1029, - nil, 14009, 112, nil, 875, 32, nil, 798, nil, nil, - nil, 2723, 11609, nil, 886, 891, 3328, 800, nil, nil, - 10529, nil, 786, 10289, nil, 790, 22562, 3449, nil, nil, - 3570, 473, nil, nil, nil, nil, nil, 404, -45, 134, - 885, nil, 3812, nil, 4054, nil, 387, 7777, nil, nil, - 950, nil, 7657, 852, nil, 7297, nil, nil, 972, 975, - 861, 22338, 22279, 5497, 405, 988, 640, nil, nil, nil, - nil, nil, 885, 11489, nil, 887, nil, nil, nil, 19, - 553, 47, -6, 935, nil, nil, nil, 6697, nil, 259, - 911, nil ] - -racc_action_default = [ - -1, -505, -503, -505, -503, -505, -505, -251, -291, -419, - -503, -322, -61, -2, -505, -420, -503, -323, -307, -273, - -505, -65, -314, -324, -505, -505, -505, -325, -379, -505, - -505, -505, -34, -71, -386, -381, -505, -275, -434, -494, - -413, -382, -492, -505, -20, -383, -40, -505, -433, -5, - -42, -285, -432, -505, -503, -43, -288, -266, -6, -423, - -356, -505, -267, -505, -429, -380, -47, -482, -268, -428, - -425, -269, -505, -430, -424, -270, -503, -431, -426, -216, - -271, -505, -492, -427, -503, -272, -35, -503, -436, -503, - -505, -295, -437, -503, -505, -298, -70, -505, 902, -505, - -401, -505, -505, -503, -505, -350, -322, -323, -273, -505, - -505, -434, -494, -505, -285, -288, -356, -326, -338, -339, - -505, -53, -360, -357, -505, -290, -292, -505, -505, -391, - -505, -505, -273, -238, -261, -434, -505, -217, -230, -503, - -45, -505, -477, -505, -504, -505, -505, -504, -8, -505, - -505, -397, -46, -310, -505, -505, -505, -209, -505, -82, - -66, -75, -505, -503, -68, -505, -73, -193, -168, -150, - -121, -169, -139, -170, -153, -108, -141, -129, -171, -126, - -152, -130, -157, -172, -127, -142, -117, -159, -124, -136, - -128, -165, -118, -151, -123, -434, -138, -144, -119, -143, - -125, -158, -120, -134, -109, -148, -115, -135, -505, -317, - -147, -160, -113, -132, -110, -167, -106, -99, -133, -111, - -472, -162, -100, -96, -161, -107, -98, -114, -163, -154, - -116, -146, -145, -164, -97, -140, -149, -131, -471, -112, - -166, -137, -156, -122, -155, -101, -132, -133, -96, -161, - -102, -9, -154, -505, -164, -97, -149, -505, -194, -103, - -14, -505, -505, -421, -422, -503, -495, -505, -384, -500, - -493, -499, -501, -4, -281, -505, -505, -505, -505, -505, - -505, -505, -505, -505, -505, -505, -505, -505, -505, -505, - -505, -505, -505, -505, -505, -505, -505, -505, -505, -505, - -505, -505, -503, -344, -347, -44, -41, -505, -61, -505, - -505, -503, -60, -505, -505, -505, -505, -505, -505, -59, - -355, -503, -208, -39, -505, -505, -505, -277, -505, -218, - -494, -496, -505, -496, -505, -505, -493, -492, -414, -505, - -416, -415, -417, -412, -474, -496, -505, -496, -505, -399, - -505, -505, -505, -505, -505, -69, -38, -403, -388, -406, - -402, -404, -251, -489, -483, -488, -484, -354, -503, -486, - -483, -485, -484, -505, -505, -505, -503, -304, -421, -422, - -505, -281, -351, -54, -50, -503, -503, -252, -253, -254, - -505, -393, -390, -389, -505, -505, -503, -258, -505, -505, - -281, -505, -260, -505, -231, -505, -504, -505, -233, -395, - -505, -396, -505, -505, -273, -505, -94, -505, -91, -92, - -182, -30, -505, -505, -505, -505, -503, -74, -81, -505, - -67, -315, -491, -490, -319, -452, -505, -505, -13, -12, - -11, -104, -36, -37, -505, -505, -371, -505, -214, -505, - -7, -502, -505, -503, -203, -189, -184, -204, -188, -505, - -205, -185, -210, -200, -186, -211, -202, -201, -212, -199, - -213, -195, -206, -187, -207, -196, -197, -190, -198, -183, - -505, -503, -329, -503, -328, -327, -279, -62, -505, -505, - -287, -15, -16, -17, -18, -19, -505, -230, -494, -494, - -504, -503, -251, -483, -484, -251, -494, -283, -219, -497, - -220, -498, -494, -222, -498, -31, -261, -173, -23, -505, - -505, -503, -505, -363, -505, -418, -476, -498, -284, -475, - -400, -385, -33, -32, -24, -505, -387, -175, -25, -505, - -503, -505, -57, -353, -505, -505, -55, -229, -352, -228, - -505, -505, -282, -505, -487, -280, -503, -483, -484, -505, - -505, -503, -361, -342, -505, -340, -358, -250, -256, -505, - -505, -40, -505, -504, -392, -394, -487, -280, -483, -484, - -505, -479, -173, -259, -262, -505, -504, -505, -237, -505, - -478, -505, -398, -311, -505, -505, -503, -93, -91, -92, - -505, -439, -308, -438, -78, -80, -483, -484, -505, -72, - -503, -505, -465, -505, -505, -470, -456, -470, -463, -470, - -462, -467, -454, -451, -503, -466, -457, -453, -460, -455, - -452, -494, -10, -505, -191, -192, -503, -503, -276, -505, - -181, -505, -505, -22, -345, -503, -330, -62, -286, -224, - -505, -505, -505, -505, -505, -503, -49, -349, -48, -348, - -505, -262, -505, -223, -505, -505, -265, -505, -302, -505, - -505, -332, -296, -333, -331, -299, -505, -411, -408, -409, - -405, -410, -58, -179, -29, -180, -56, -177, -27, -178, - -28, -505, -282, -505, -51, -503, -505, -341, -503, -505, - -505, -255, -504, -505, -243, -505, -505, -505, -282, -504, - -505, -235, -504, -505, -95, -91, -92, -505, -441, -505, - -503, -76, -505, -320, -464, -468, -443, -505, -447, -505, - -505, -449, -505, -450, -505, -494, -505, -105, -503, -503, - -336, -503, -373, -372, -374, -289, -21, -215, -503, -505, - -505, -334, -225, -503, -503, -226, -505, -494, -505, -278, - -494, -174, -263, -505, -303, -505, -365, -505, -301, -503, - -503, -407, -176, -26, -305, -503, -505, -343, -505, -257, - -240, -504, -505, -504, -249, -505, -505, -232, -505, -234, - -312, -282, -505, -505, -316, -452, -470, -470, -469, -458, - -459, -505, -470, -461, -318, -505, -473, -337, -3, -503, - -378, -505, -505, -376, -505, -505, -293, -505, -294, -221, - -264, -503, -505, -367, -505, -505, -503, -505, -362, -359, - -505, -239, -504, -505, -245, -504, -504, -503, -440, -309, - -503, -505, -445, -446, -448, -442, -377, -505, -90, -83, - -505, -375, -503, -346, -503, -227, -503, -505, -297, -300, - -505, -52, -505, -504, -241, -505, -244, -236, -505, -505, - -470, -505, -505, -503, -89, -371, -503, -369, -368, -364, - -366, -306, -504, -505, -246, -504, -313, -321, -444, -487, - -88, -483, -484, -505, -370, -335, -242, -505, -247, -84, - -504, -248 ] - -clist = [ -'137,209,320,522,138,328,137,267,109,157,138,117,483,250,167,250,251', -'119,259,258,636,383,447,623,624,515,117,273,391,501,147,499,373,144', -'739,597,147,362,368,144,137,532,590,148,138,562,566,355,133,657,322', -'121,659,758,133,308,310,797,320,338,802,217,382,750,217,137,217,335', -'672,330,147,99,675,144,417,803,137,795,238,346,380,126,570,100,387,431', -'568,323,133,129,633,160,137,140,602,151,330,775,561,152,312,117,208', -'434,319,265,347,506,510,345,513,351,408,137,769,430,354,138,272,217', -'137,770,526,560,529,826,154,720,412,713,322,837,165,305,610,137,363', -'435,611,699,481,644,748,147,420,386,144,698,385,590,695,339,765,879', -'669,329,741,812,272,117,352,133,268,100,308,429,344,348,349,117,117', -'870,100,275,127,307,390,437,150,680,541,421,329,540,719,324,803,735', -'796,260,270,808,670,799,2,436,1,,,,,,,,337,,388,,,,,,13,,714,,,,623', -',,694,,728,,731,774,733,,,,,338,,,,,,,,,,,,,,,,,530,,,,,878,,448,,,', -',502,505,,309,454,455,456,457,458,459,460,461,462,463,464,465,466,467', -'468,469,470,471,472,473,474,475,476,477,478,479,575,217,,895,,,,508', -'450,657,659,137,,543,559,138,,,,137,556,308,488,497,,,,,,,512,524,517', -',580,,,742,,362,368,147,,,144,,,590,137,147,,537,500,,590,,495,,309', -'133,,,,,608,519,,133,556,518,556,81,,757,137,118,722,,330,,588,519,309', -'81,,534,,571,538,,734,,623,840,137,,420,137,330,582,,137,,537,489,137', -',,,496,,,498,842,843,542,,573,363,844,,546,272,81,137,,,,330,,250,586', -',632,,567,,,363,,,,634,635,,491,492,493,494,,640,682,,,,686,549,,894', -',,,,,329,,363,,363,,,,,565,565,650,653,590,,821,,217,535,660,329,539', -'793,888,,663,,,,,,,,,,,,,603,,543,,,,81,137,,,137,,329,,,,137,,,480', -',,,137,852,590,,854,309,,81,877,717,,,,,,556,,683,685,,,,704,687,689', -',,,7,,656,,,658,,711,,7,,,7,,,7,565,137,,,,,696,,,117,684,,,,137,119', -'688,690,,,137,549,,,549,137,723,753,754,330,,,,7,868,7,7,869,,736,,', -',7,,7,,,,,,674,,,7,674,,250,7,,737,,,,7,81,137,,,363,81,747,,,,549,', -',,7,565,,,137,,7,217,756,,,,760,,761,137,,,,137,519,,,81,641,,,7,784', -'217,,,81,,586,787,329,718,789,81,,772,7,693,,,,,,,137,726,766,137,645', -'683,687,689,7,,137,,,,805,,7,,,,,,655,,,,740,744,773,137,783,,,781,', -'740,817,,,819,,,667,,,740,,,780,,,,,,,,,831,,834,,676,,137,,,,137,,', -',,,,,,,,,,674,,137,,,137,772,,836,,,,,,,,,,,,790,,,,,,,,864,,,866,867', -'893,7,7,,,7,556,,,137,7,81,,,117,,810,137,813,,137,,,,,,884,,,,549,549', -',,,,,,,792,,81,7,,137,896,,863,898,137,,7,137,7,7,7,7,7,7,81,137,7,', -'901,330,,838,,,815,137,,,,7,,,,,81,,,,,137,,,,,,7,7,,7,7,,,,81,,,,,776', -'363,,778,,,,,,,,,,7,,,,,,118,,,,,,,7,,,,740,,,7,,,,,,,,,,807,,,,329', -',7,740,,,814,,,,,,,,,,7,,81,,,,,,,,7,824,825,,,,81,827,,,,,,7,,,,7,', -',,,,,,,,,,,306,,,,,,,,,,306,846,,,,,,7,5,327,,,104,856,,,,130,860,306', -'5,,,130,,7,,158,,,,,,,356,,,81,,,81,,,,875,7,876,,,,,,,,,,,130,,130', -'5,,81,,7,,,130,7,130,,,,,7,7,,,130,,81,,130,,7,,,,130,,81,,,,,,,,,,', -',158,130,,,,,,130,,81,81,,,,,81,,,7,,,,,,,,,,130,,,,7,,,,,,,,,,,5,,', -'7,,,81,,851,,,,,,,413,130,,81,,,,,81,5,158,413,,,,,19,,7,81,108,,81', -',,,,,19,,,,,,81,159,81,,442,443,,,,,,,,,,,,,,,,7,,,,7,,,7,,,,,,19,,', -',,,,,,,,,,,,7,7,,,,,,,306,306,306,306,,,,,,,,7,,,,,130,130,,159,5,7', -'7,,,5,,,,,,,,94,,,,306,,,306,,7,7,,94,,,7,,,,,,,,,5,,,,,19,,,,5,,130', -'130,130,130,130,5,,327,130,414,,,,,7,,,94,19,159,414,130,,,,,7,,,,593', -'7,,,,,,130,130,,130,130,7,,,7,,,,,,,,,631,,,7,,7,,,,130,,,,639,,,,,', -',,,130,,7,,,,,130,,,,,,,,,,,,,,,,130,,,94,,,,,,,,,,,130,,,,,,,19,,,130', -',19,94,,,,,,,,,,130,,,,5,,,,,,,,,,,,,,,,,19,,,,,,,,,19,,,,5,,,19,,,', -',306,,,,,,,,,,5,,,38,,,,111,,,,,,,,38,,,,,5,,161,,,,,195,,,,,,,,,,,', -'5,94,,,130,,94,,,,130,130,,,,,38,,,,130,,,,104,,,,,,,,,,,,,,94,,,,,', -',,,94,,,,,,,94,,130,,161,,,,,,,,,,,,5,,,,,,,,,,,19,,,5,,,,,,,,,,,,,', -',,,38,,,,,,,,,306,19,,,130,,195,,,,,,,,397,38,161,195,,19,,,,,,,,,,406', -'306,,,,,,,,,19,,130,,,,5,,,5,,,,,,,,,,19,677,,,,,,,,,,130,5,,,,,,,,', -'94,,,108,,,,,,5,,,,,,,,,,5,130,,,,,,,,,,94,,,,,,,,38,,5,5,,38,,,5,,94', -'19,,,,,,,,,,,,,,19,,,,,94,,,,,,,38,,,,,5,,847,,38,,,94,,,,38,5,,,,,5', -',,,,,,,,,,5,,,5,,,,,,,,,,,,5,,5,,,,,,,,,19,,,19,516,,,,,,130,,,,,,,', -',,533,,,94,,19,,,,,,,,,,,,94,,,,,,19,,,,,,,,,,19,,,,,,569,,,,,,,,,,581', -',,,584,19,19,,589,,,19,,,,,,,,,,,,38,,,,,,,,,,,,,,,,94,,,94,,,19,,848', -',,,,,38,,,,19,,,,,19,,94,,,,,,,38,,19,,,19,,,,,,94,,,,,,19,,19,38,94', -',,,,,,,,,,,,,,,,,38,,661,94,94,589,,,,94,,666,,,,,,,661,,,,,,111,,,', -',,,,,,,,,,,,,,,94,,,,,,,,,,,,94,,,,,94,,,702,,,,,,,38,94,,,94,,709,', -',,,,712,,38,,94,,94,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,743,,,,,', -',,,,,,,,,,,584,,,,,,,,,,38,762,,38,,516,,,,,,,,,,,,,,,,,,,,38,,,,,,', -',,,,,,,589,,,,38,,,589,,,,,,,38,,,,,,,,,,,,800,,,,,,,,,38,38,,,,,38', -',,,,,,,,,,,,,,,,,,820,,,,823,,,,,,,,,,,38,,849,,832,,,835,,,,,38,,,', -',38,,,,,,,,,,,38,,,38,,,,,,,,,,,,38,661,38,,,,,,,584,,,589,,,,,,,,,', -',,,,,,,,,,,,,,880,,,,,882,,,885,,,,,,,,,,,,,,,,,,589,,,,,,,,,,,,,,900' ] - racc_goto_table = arr = ::Array.new(2455, nil) - idx = 0 - clist.each do |str| - str.split(',', -1).each do |i| - arr[idx] = i.to_i unless i.empty? - idx += 1 - end - end - -clist = [ -'28,48,58,81,29,21,28,53,82,28,29,54,78,51,28,51,13,18,13,28,5,35,3,140', -'85,23,54,9,128,78,57,32,21,55,6,46,57,33,33,55,28,23,146,11,29,36,36', -'44,61,59,28,34,59,6,61,40,41,138,58,48,138,49,58,79,49,28,49,9,80,29', -'57,125,80,55,47,142,28,105,74,75,53,76,65,10,63,47,62,17,61,10,52,43', -'28,31,83,10,29,38,37,31,34,54,86,87,34,88,57,89,56,55,56,90,60,28,91', -'44,92,29,84,49,28,93,56,94,56,95,96,97,98,99,28,100,101,31,102,28,49', -'103,104,66,107,36,108,57,28,111,55,112,113,146,114,125,115,116,117,10', -'118,119,84,54,125,61,123,10,40,41,10,124,10,54,54,138,10,27,126,15,127', -'26,129,130,131,17,10,132,134,15,142,135,137,14,12,7,81,141,4,145,1,', -',,,,,,15,,31,,,,,,2,,46,,,,140,,,36,,139,,139,80,139,,,,,48,,,,,,,,', -',,,,,,,,128,,,,,6,,28,,,,,33,33,,2,28,28,28,28,28,28,28,28,28,28,28', -'28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,128,49,,79,,,,53,11,59', -'59,28,,58,21,29,,,,28,33,40,41,29,,,,,,,28,9,28,,21,,,23,,33,33,57,', -',55,,,146,28,57,,28,55,,146,,11,,2,61,,,,,21,55,,61,33,17,33,16,,32', -'28,16,3,,29,,60,55,2,16,,17,,28,17,,3,,140,85,28,,28,28,29,28,,28,,28', -'31,28,,,,10,,,31,139,139,34,,57,49,139,,34,84,16,28,,,,29,,51,57,,13', -',61,,,49,,,,28,28,,15,15,15,15,,28,35,,,,35,10,,5,,,,,,10,,49,,49,,', -',,10,10,53,53,146,,78,,49,15,53,10,15,3,139,,53,,,,,,,,,,,,,84,,58,', -',,16,28,,,28,,10,,,,28,,,2,,,,28,78,146,,78,2,,16,81,21,,,,,,33,,28', -'28,,,,60,28,28,,,,39,,34,,,34,,60,,39,,,39,,,39,10,28,,,,,82,,,54,17', -',,,28,18,17,17,,,28,10,,,10,28,48,33,33,29,,,,39,3,39,39,3,,53,,,,39', -',39,,,,,,84,,,39,84,,51,39,,13,,,,39,16,28,,,49,16,28,,,,10,,,,39,10', -',,28,,39,49,29,,,,28,,28,28,,,,28,55,,,16,2,,,39,60,49,,,16,,57,60,10', -'84,60,16,,28,39,15,,,,,,,28,84,55,28,2,28,28,28,39,,28,,,,53,,39,,,', -',,2,,,,10,10,17,28,57,,,55,,10,53,,,53,,,2,,,10,,,61,,,,,,,,,60,,60', -',2,,28,,,,28,,,,,,,,,,,,,84,,28,,,28,28,,28,,,,,,,,,,,,84,,,,,,,,60', -',,60,60,21,39,39,,,39,33,,,28,39,16,,,54,,10,28,10,,28,,,,,,60,,,,10', -'10,,,,,,,,15,,16,39,,28,60,,57,60,28,,39,28,39,39,39,39,39,39,16,28', -'39,,60,29,,84,,,15,28,,,,39,,,,,16,,,,,28,,,,,,39,39,,39,39,,,,16,,', -',,2,49,,2,,,,,,,,,,39,,,,,,16,,,,,,,39,,,,10,,,39,,,,,,,,,,2,,,,10,', -'39,10,,,2,,,,,,,,,,39,,16,,,,,,,,39,2,2,,,,16,2,,,,,,39,,,,39,,,,,,', -',,,,,,25,,,,,,,,,,25,2,,,,,,39,20,25,,,20,2,,,,20,2,25,20,,,20,,39,', -'20,,,,,,,25,,,16,,,16,,,,2,39,2,,,,,,,,,,,20,,20,20,,16,,39,,,20,39', -'20,,,,,39,39,,,20,,16,,20,,39,,,,20,,16,,,,,,,,,,,,20,20,,,,,,20,,16', -'16,,,,,16,,,39,,,,,,,,,,20,,,,39,,,,,,,,,,,20,,,39,,,16,,16,,,,,,,20', -'20,,16,,,,,16,20,20,20,,,,,22,,39,16,22,,16,,,,,,22,,,,,,16,22,16,,25', -'25,,,,,,,,,,,,,,,,39,,,,39,,,39,,,,,,22,,,,,,,,,,,,,,,39,39,,,,,,,25', -'25,25,25,,,,,,,,39,,,,,20,20,,22,20,39,39,,,20,,,,,,,,19,,,,25,,,25', -',39,39,,19,,,39,,,,,,,,,20,,,,,22,,,,20,,20,20,20,20,20,20,,25,20,22', -',,,,39,,,19,22,22,22,20,,,,,39,,,,25,39,,,,,,20,20,,20,20,39,,,39,,', -',,,,,,25,,,39,,39,,,,20,,,,25,,,,,,,,,20,,39,,,,,20,,,,,,,,,,,,,,,,20', -',,19,,,,,,,,,,,20,,,,,,,22,,,20,,22,19,,,,,,,,,,20,,,,20,,,,,,,,,,,', -',,,,,22,,,,,,,,,22,,,,20,,,22,,,,,25,,,,,,,,,,20,,,45,,,,45,,,,,,,,45', -',,,,20,,45,,,,,45,,,,,,,,,,,,20,19,,,20,,19,,,,20,20,,,,,45,,,,20,,', -',20,,,,,,,,,,,,,,19,,,,,,,,,19,,,,,,,19,,20,,45,,,,,,,,,,,,20,,,,,,', -',,,,22,,,20,,,,,,,,,,,,,,,,,45,,,,,,,,,25,22,,,20,,45,,,,,,,,24,45,45', -'45,,22,,,,,,,,,,24,25,,,,,,,,,22,,20,,,,20,,,20,,,,,,,,,,22,22,,,,,', -',,,,20,20,,,,,,,,,19,,,22,,,,,,20,,,,,,,,,,20,20,,,,,,,,,,19,,,,,,,', -'45,,20,20,,45,,,20,,19,22,,,,,,,,,,,,,,22,,,,,19,,,,,,,45,,,,,20,,20', -',45,,,19,,,,45,20,,,,,20,,,,,,,,,,,20,,,20,,,,,,,,,,,,20,,20,,,,,,,', -',22,,,22,24,,,,,,20,,,,,,,,,,24,,,19,,22,,,,,,,,,,,,19,,,,,,22,,,,,', -',,,,22,,,,,,24,,,,,,,,,,24,,,,24,22,22,,24,,,22,,,,,,,,,,,,45,,,,,,', -',,,,,,,,,19,,,19,,,22,,22,,,,,,45,,,,22,,,,,22,,19,,,,,,,45,,22,,,22', -',,,,,19,,,,,,22,,22,45,19,,,,,,,,,,,,,,,,,,45,,24,19,19,24,,,,19,,24', -',,,,,,24,,,,,,45,,,,,,,,,,,,,,,,,,,19,,,,,,,,,,,,19,,,,,19,,,24,,,,', -',,45,19,,,19,,24,,,,,,24,,45,,19,,19,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,', -',,,,,,,,24,,,,,,,,,,,,,,,,,24,,,,,,,,,,45,24,,45,,24,,,,,,,,,,,,,,,', -',,,,45,,,,,,,,,,,,,,24,,,,45,,,24,,,,,,,45,,,,,,,,,,,,24,,,,,,,,,45', -'45,,,,,45,,,,,,,,,,,,,,,,,,,24,,,,24,,,,,,,,,,,45,,45,,24,,,24,,,,,45', -',,,,45,,,,,,,,,,,45,,,45,,,,,,,,,,,,45,24,45,,,,,,,24,,,24,,,,,,,,,', -',,,,,,,,,,,,,,24,,,,,24,,,24,,,,,,,,,,,,,,,,,,24,,,,,,,,,,,,,,24' ] - racc_goto_check = arr = ::Array.new(2455, nil) - idx = 0 - clist.each do |str| - str.split(',', -1).each do |i| - arr[idx] = i.to_i unless i.empty? - idx += 1 - end - end - -racc_goto_pointer = [ - nil, 196, 210, -243, 194, -426, -602, -548, nil, -15, - 79, 29, 148, -13, 158, 122, 360, 26, 11, 1300, - 1024, -71, 1192, -309, 1557, 955, -74, 129, -11, -7, - nil, 82, -290, -64, 44, -100, -340, -286, -597, 542, - 1, 2, nil, 70, -49, 1526, -380, -80, -25, 35, - nil, -16, -351, -32, 5, 22, -223, 19, -58, -453, - -35, 37, -303, -40, nil, -307, -429, nil, nil, nil, - nil, nil, nil, nil, 52, -8, 73, nil, -295, -582, - -467, -332, 2, -323, 76, -411, 76, -105, 68, -220, - 20, -558, 21, -554, -254, -649, 108, -475, -25, -464, - -659, 110, -297, -72, -296, -646, nil, -163, -502, nil, - nil, 22, -419, 26, -412, -517, -703, -369, -481, -584, - nil, nil, nil, 121, 78, 67, 164, 49, -99, 162, - -362, -181, -176, nil, -417, -443, nil, -539, -670, -392, - -412, -534, -655, nil, nil, -25, -365 ] - -racc_goto_default = [ - nil, nil, 446, nil, nil, nil, 751, nil, 42, nil, - 49, 58, 336, nil, nil, nil, 143, 86, 90, 145, - 156, nil, 132, nil, 134, 32, nil, nil, 46, 50, - 55, nil, 66, 553, nil, nil, nil, nil, nil, 105, - 12, nil, 21, 24, 33, 135, 416, nil, 245, 369, - 222, 65, nil, nil, 79, 331, nil, 333, 547, 548, - 404, 583, nil, nil, 124, nil, nil, 402, 57, 62, - 68, 71, 75, 80, 85, nil, 125, 8, nil, nil, - nil, nil, nil, nil, 485, nil, nil, nil, nil, nil, - nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, - nil, nil, nil, nil, nil, nil, 304, nil, nil, 367, - 120, nil, nil, nil, nil, nil, nil, nil, nil, nil, - 28, 35, 41, 45, nil, nil, nil, nil, 360, nil, - nil, nil, nil, 343, nil, 614, 615, 617, 619, nil, - 798, 626, 628, 612, 613, nil, 142 ] - -racc_reduce_table = [ - 0, 0, :racc_error, - 0, 136, :_reduce_1, - 2, 133, :_reduce_2, - 4, 135, :_reduce_3, - 2, 134, :_reduce_4, - 1, 140, :_reduce_none, - 1, 140, :_reduce_none, - 3, 140, :_reduce_7, - 2, 140, :_reduce_8, - 0, 158, :_reduce_9, - 4, 143, :_reduce_10, - 3, 143, :_reduce_11, - 3, 143, :_reduce_12, - 3, 143, :_reduce_13, - 2, 143, :_reduce_14, - 3, 143, :_reduce_15, - 3, 143, :_reduce_16, - 3, 143, :_reduce_17, - 3, 143, :_reduce_18, - 3, 143, :_reduce_19, - 0, 159, :_reduce_20, - 5, 143, :_reduce_21, - 4, 143, :_reduce_22, - 3, 143, :_reduce_23, - 3, 143, :_reduce_24, - 3, 143, :_reduce_25, - 6, 143, :_reduce_26, - 5, 143, :_reduce_27, - 5, 143, :_reduce_28, - 5, 143, :_reduce_29, - 3, 143, :_reduce_30, - 3, 143, :_reduce_31, - 3, 143, :_reduce_32, - 3, 143, :_reduce_33, - 1, 143, :_reduce_none, - 1, 157, :_reduce_none, - 3, 157, :_reduce_36, - 3, 157, :_reduce_37, - 2, 157, :_reduce_38, - 2, 157, :_reduce_39, - 1, 157, :_reduce_none, - 1, 147, :_reduce_41, - 1, 149, :_reduce_none, - 1, 149, :_reduce_none, - 2, 149, :_reduce_44, - 2, 149, :_reduce_45, - 2, 149, :_reduce_46, - 1, 162, :_reduce_none, - 4, 162, :_reduce_48, - 4, 162, :_reduce_49, - 0, 169, :_reduce_50, - 0, 170, :_reduce_51, - 6, 167, :_reduce_52, - 2, 161, :_reduce_53, - 3, 161, :_reduce_54, - 4, 161, :_reduce_55, - 5, 161, :_reduce_56, - 4, 161, :_reduce_57, - 5, 161, :_reduce_58, - 2, 161, :_reduce_59, - 2, 161, :_reduce_60, - 1, 150, :_reduce_none, - 3, 150, :_reduce_62, - 1, 173, :_reduce_none, - 3, 173, :_reduce_64, - 1, 172, :_reduce_65, - 2, 172, :_reduce_66, - 3, 172, :_reduce_67, - 2, 172, :_reduce_68, - 2, 172, :_reduce_69, - 1, 172, :_reduce_70, - 1, 175, :_reduce_none, - 3, 175, :_reduce_72, - 2, 174, :_reduce_73, - 3, 174, :_reduce_74, - 1, 176, :_reduce_75, - 4, 176, :_reduce_76, - 3, 176, :_reduce_77, - 3, 176, :_reduce_78, - 3, 176, :_reduce_79, - 3, 176, :_reduce_80, - 2, 176, :_reduce_81, - 1, 176, :_reduce_82, - 1, 148, :_reduce_83, - 4, 148, :_reduce_84, - 3, 148, :_reduce_85, - 3, 148, :_reduce_86, - 3, 148, :_reduce_87, - 3, 148, :_reduce_88, - 2, 148, :_reduce_89, - 1, 148, :_reduce_90, - 1, 178, :_reduce_91, - 1, 178, :_reduce_none, - 2, 179, :_reduce_93, - 1, 179, :_reduce_94, - 3, 179, :_reduce_95, - 1, 180, :_reduce_none, - 1, 180, :_reduce_none, - 1, 180, :_reduce_none, - 1, 180, :_reduce_99, - 1, 180, :_reduce_100, - 1, 145, :_reduce_101, - 1, 145, :_reduce_102, - 1, 146, :_reduce_103, - 0, 184, :_reduce_104, - 4, 146, :_reduce_105, - 1, 181, :_reduce_none, - 1, 181, :_reduce_none, - 1, 181, :_reduce_none, - 1, 181, :_reduce_none, - 1, 181, :_reduce_none, - 1, 181, :_reduce_none, - 1, 181, :_reduce_none, - 1, 181, :_reduce_none, - 1, 181, :_reduce_none, - 1, 181, :_reduce_none, - 1, 181, :_reduce_none, - 1, 181, :_reduce_none, - 1, 181, :_reduce_none, - 1, 181, :_reduce_none, - 1, 181, :_reduce_none, - 1, 181, :_reduce_none, - 1, 181, :_reduce_none, - 1, 181, :_reduce_none, - 1, 181, :_reduce_none, - 1, 181, :_reduce_none, - 1, 181, :_reduce_none, - 1, 181, :_reduce_none, - 1, 181, :_reduce_none, - 1, 181, :_reduce_none, - 1, 181, :_reduce_none, - 1, 181, :_reduce_none, - 1, 182, :_reduce_none, - 1, 182, :_reduce_none, - 1, 182, :_reduce_none, - 1, 182, :_reduce_none, - 1, 182, :_reduce_none, - 1, 182, :_reduce_none, - 1, 182, :_reduce_none, - 1, 182, :_reduce_none, - 1, 182, :_reduce_none, - 1, 182, :_reduce_none, - 1, 182, :_reduce_none, - 1, 182, :_reduce_none, - 1, 182, :_reduce_none, - 1, 182, :_reduce_none, - 1, 182, :_reduce_none, - 1, 182, :_reduce_none, - 1, 182, :_reduce_none, - 1, 182, :_reduce_none, - 1, 182, :_reduce_none, - 1, 182, :_reduce_none, - 1, 182, :_reduce_none, - 1, 182, :_reduce_none, - 1, 182, :_reduce_none, - 1, 182, :_reduce_none, - 1, 182, :_reduce_none, - 1, 182, :_reduce_none, - 1, 182, :_reduce_none, - 1, 182, :_reduce_none, - 1, 182, :_reduce_none, - 1, 182, :_reduce_none, - 1, 182, :_reduce_none, - 1, 182, :_reduce_none, - 1, 182, :_reduce_none, - 1, 182, :_reduce_none, - 1, 182, :_reduce_none, - 1, 182, :_reduce_none, - 1, 182, :_reduce_none, - 1, 182, :_reduce_none, - 1, 182, :_reduce_none, - 1, 182, :_reduce_none, - 1, 182, :_reduce_none, - 3, 160, :_reduce_173, - 5, 160, :_reduce_174, - 3, 160, :_reduce_175, - 6, 160, :_reduce_176, - 5, 160, :_reduce_177, - 5, 160, :_reduce_178, - 5, 160, :_reduce_179, - 5, 160, :_reduce_180, - 4, 160, :_reduce_181, - 3, 160, :_reduce_182, - 3, 160, :_reduce_183, - 3, 160, :_reduce_184, - 3, 160, :_reduce_185, - 3, 160, :_reduce_186, - 3, 160, :_reduce_187, - 3, 160, :_reduce_188, - 3, 160, :_reduce_189, - 3, 160, :_reduce_190, - 4, 160, :_reduce_191, - 4, 160, :_reduce_192, - 2, 160, :_reduce_193, - 2, 160, :_reduce_194, - 3, 160, :_reduce_195, - 3, 160, :_reduce_196, - 3, 160, :_reduce_197, - 3, 160, :_reduce_198, - 3, 160, :_reduce_199, - 3, 160, :_reduce_200, - 3, 160, :_reduce_201, - 3, 160, :_reduce_202, - 3, 160, :_reduce_203, - 3, 160, :_reduce_204, - 3, 160, :_reduce_205, - 3, 160, :_reduce_206, - 3, 160, :_reduce_207, - 2, 160, :_reduce_208, - 2, 160, :_reduce_209, - 3, 160, :_reduce_210, - 3, 160, :_reduce_211, - 3, 160, :_reduce_212, - 3, 160, :_reduce_213, - 3, 160, :_reduce_214, - 5, 160, :_reduce_215, - 1, 160, :_reduce_none, - 1, 156, :_reduce_217, - 1, 153, :_reduce_none, - 2, 153, :_reduce_219, - 2, 153, :_reduce_220, - 5, 153, :_reduce_221, - 2, 153, :_reduce_222, - 3, 153, :_reduce_223, - 3, 190, :_reduce_224, - 4, 190, :_reduce_225, - 4, 190, :_reduce_226, - 6, 190, :_reduce_227, - 1, 191, :_reduce_none, - 1, 191, :_reduce_none, - 1, 163, :_reduce_230, - 2, 163, :_reduce_231, - 5, 163, :_reduce_232, - 2, 163, :_reduce_233, - 5, 163, :_reduce_234, - 4, 163, :_reduce_235, - 7, 163, :_reduce_236, - 3, 163, :_reduce_237, - 1, 163, :_reduce_none, - 4, 194, :_reduce_239, - 3, 194, :_reduce_240, - 5, 194, :_reduce_241, - 7, 194, :_reduce_242, - 2, 194, :_reduce_243, - 5, 194, :_reduce_244, - 4, 194, :_reduce_245, - 6, 194, :_reduce_246, - 7, 194, :_reduce_247, - 9, 194, :_reduce_248, - 3, 194, :_reduce_249, - 1, 194, :_reduce_none, - 0, 196, :_reduce_251, - 2, 166, :_reduce_252, - 1, 195, :_reduce_none, - 0, 197, :_reduce_254, - 3, 195, :_reduce_255, - 0, 198, :_reduce_256, - 4, 195, :_reduce_257, - 2, 193, :_reduce_258, - 2, 192, :_reduce_259, - 1, 192, :_reduce_none, - 1, 187, :_reduce_261, - 3, 187, :_reduce_262, - 3, 155, :_reduce_263, - 4, 155, :_reduce_264, - 2, 155, :_reduce_265, - 1, 186, :_reduce_none, - 1, 186, :_reduce_none, - 1, 186, :_reduce_none, - 1, 186, :_reduce_none, - 1, 186, :_reduce_none, - 1, 186, :_reduce_none, - 1, 186, :_reduce_none, - 1, 186, :_reduce_none, - 1, 186, :_reduce_274, - 0, 220, :_reduce_275, - 4, 186, :_reduce_276, - 0, 221, :_reduce_277, - 5, 186, :_reduce_278, - 3, 186, :_reduce_279, - 3, 186, :_reduce_280, - 2, 186, :_reduce_281, - 4, 186, :_reduce_282, - 3, 186, :_reduce_283, - 3, 186, :_reduce_284, - 1, 186, :_reduce_285, - 4, 186, :_reduce_286, - 3, 186, :_reduce_287, - 1, 186, :_reduce_288, - 5, 186, :_reduce_289, - 2, 186, :_reduce_290, - 1, 186, :_reduce_none, - 2, 186, :_reduce_292, - 6, 186, :_reduce_293, - 6, 186, :_reduce_294, - 0, 222, :_reduce_295, - 0, 223, :_reduce_296, - 7, 186, :_reduce_297, - 0, 224, :_reduce_298, - 0, 225, :_reduce_299, - 7, 186, :_reduce_300, - 5, 186, :_reduce_301, - 4, 186, :_reduce_302, - 5, 186, :_reduce_303, - 0, 226, :_reduce_304, - 0, 227, :_reduce_305, - 9, 186, :_reduce_306, - 0, 228, :_reduce_307, - 0, 229, :_reduce_308, - 7, 186, :_reduce_309, - 0, 230, :_reduce_310, - 0, 231, :_reduce_311, - 0, 232, :_reduce_312, - 9, 186, :_reduce_313, - 0, 233, :_reduce_314, - 0, 234, :_reduce_315, - 6, 186, :_reduce_316, - 0, 235, :_reduce_317, - 6, 186, :_reduce_318, - 0, 236, :_reduce_319, - 0, 237, :_reduce_320, - 9, 186, :_reduce_321, - 1, 186, :_reduce_322, - 1, 186, :_reduce_323, - 1, 186, :_reduce_324, - 1, 186, :_reduce_325, - 1, 152, :_reduce_326, - 1, 210, :_reduce_none, - 1, 210, :_reduce_none, - 1, 210, :_reduce_none, - 2, 210, :_reduce_none, - 1, 212, :_reduce_none, - 1, 212, :_reduce_none, - 1, 212, :_reduce_none, - 1, 211, :_reduce_none, - 5, 211, :_reduce_335, - 1, 138, :_reduce_none, - 2, 138, :_reduce_337, - 1, 214, :_reduce_none, - 1, 214, :_reduce_339, - 1, 168, :_reduce_none, - 2, 168, :_reduce_341, - 1, 168, :_reduce_342, - 3, 168, :_reduce_343, - 0, 239, :_reduce_344, - 0, 240, :_reduce_345, - 6, 238, :_reduce_346, - 2, 164, :_reduce_347, - 4, 164, :_reduce_348, - 4, 164, :_reduce_349, - 0, 242, :_reduce_350, - 3, 209, :_reduce_351, - 4, 209, :_reduce_352, - 4, 209, :_reduce_353, - 3, 209, :_reduce_354, - 2, 209, :_reduce_355, - 1, 209, :_reduce_356, - 0, 243, :_reduce_357, - 0, 244, :_reduce_358, - 6, 208, :_reduce_359, - 0, 245, :_reduce_360, - 0, 246, :_reduce_361, - 6, 208, :_reduce_362, - 0, 249, :_reduce_363, - 6, 213, :_reduce_364, - 1, 247, :_reduce_none, - 4, 247, :_reduce_366, - 2, 247, :_reduce_367, - 1, 248, :_reduce_none, - 1, 248, :_reduce_none, - 6, 137, :_reduce_370, - 0, 137, :_reduce_371, - 1, 250, :_reduce_372, - 1, 250, :_reduce_none, - 1, 250, :_reduce_none, - 2, 251, :_reduce_375, - 1, 251, :_reduce_none, - 2, 139, :_reduce_377, - 1, 139, :_reduce_none, - 1, 200, :_reduce_379, - 1, 200, :_reduce_380, - 1, 200, :_reduce_none, - 1, 201, :_reduce_382, - 1, 254, :_reduce_none, - 2, 254, :_reduce_384, - 3, 255, :_reduce_385, - 1, 255, :_reduce_386, - 3, 202, :_reduce_387, - 3, 203, :_reduce_388, - 3, 204, :_reduce_389, - 3, 204, :_reduce_390, - 1, 258, :_reduce_391, - 3, 258, :_reduce_392, - 1, 259, :_reduce_none, - 2, 259, :_reduce_394, - 3, 205, :_reduce_395, - 3, 205, :_reduce_396, - 1, 261, :_reduce_397, - 3, 261, :_reduce_398, - 1, 256, :_reduce_399, - 2, 256, :_reduce_400, - 1, 257, :_reduce_401, - 2, 257, :_reduce_402, - 1, 260, :_reduce_403, - 0, 263, :_reduce_404, - 3, 260, :_reduce_405, - 0, 264, :_reduce_406, - 4, 260, :_reduce_407, - 1, 262, :_reduce_408, - 1, 262, :_reduce_409, - 1, 262, :_reduce_410, - 1, 262, :_reduce_none, - 2, 183, :_reduce_412, - 1, 183, :_reduce_413, - 1, 265, :_reduce_none, - 1, 265, :_reduce_none, - 1, 265, :_reduce_none, - 1, 265, :_reduce_none, - 3, 253, :_reduce_418, - 1, 252, :_reduce_none, - 1, 252, :_reduce_none, - 2, 252, :_reduce_421, - 2, 252, :_reduce_422, - 1, 177, :_reduce_none, - 1, 177, :_reduce_none, - 1, 177, :_reduce_none, - 1, 177, :_reduce_none, - 1, 177, :_reduce_none, - 1, 177, :_reduce_428, - 1, 177, :_reduce_429, - 1, 177, :_reduce_430, - 1, 177, :_reduce_431, - 1, 177, :_reduce_432, - 1, 177, :_reduce_433, - 1, 206, :_reduce_434, - 1, 151, :_reduce_435, - 1, 154, :_reduce_436, - 1, 154, :_reduce_437, - 1, 215, :_reduce_438, - 0, 266, :_reduce_439, - 4, 215, :_reduce_440, - 2, 215, :_reduce_441, - 4, 217, :_reduce_442, - 2, 217, :_reduce_443, - 6, 267, :_reduce_444, - 4, 267, :_reduce_445, - 4, 267, :_reduce_446, - 2, 267, :_reduce_447, - 4, 267, :_reduce_448, - 2, 267, :_reduce_449, - 2, 267, :_reduce_450, - 1, 267, :_reduce_451, - 0, 267, :_reduce_452, - 1, 273, :_reduce_453, - 1, 273, :_reduce_454, - 1, 273, :_reduce_455, - 1, 273, :_reduce_456, - 1, 268, :_reduce_457, - 3, 268, :_reduce_458, - 3, 274, :_reduce_459, - 1, 269, :_reduce_460, - 3, 269, :_reduce_461, - 1, 275, :_reduce_none, - 1, 275, :_reduce_none, - 2, 270, :_reduce_464, - 1, 270, :_reduce_465, - 1, 276, :_reduce_none, - 1, 276, :_reduce_none, - 2, 272, :_reduce_468, - 2, 271, :_reduce_469, - 0, 271, :_reduce_470, - 1, 218, :_reduce_none, - 0, 277, :_reduce_472, - 5, 218, :_reduce_473, - 1, 207, :_reduce_474, - 2, 207, :_reduce_475, - 2, 207, :_reduce_476, - 1, 189, :_reduce_none, - 3, 189, :_reduce_478, - 3, 278, :_reduce_479, - 1, 171, :_reduce_none, - 1, 171, :_reduce_none, - 1, 171, :_reduce_none, - 1, 165, :_reduce_none, - 1, 165, :_reduce_none, - 1, 165, :_reduce_none, - 1, 165, :_reduce_none, - 1, 241, :_reduce_none, - 1, 241, :_reduce_none, - 1, 241, :_reduce_none, - 1, 219, :_reduce_none, - 1, 219, :_reduce_none, - 0, 141, :_reduce_none, - 1, 141, :_reduce_none, - 0, 185, :_reduce_none, - 1, 185, :_reduce_none, - 0, 188, :_reduce_none, - 1, 188, :_reduce_none, - 1, 188, :_reduce_none, - 1, 216, :_reduce_499, - 1, 216, :_reduce_none, - 1, 144, :_reduce_none, - 2, 144, :_reduce_502, - 0, 142, :_reduce_503, - 0, 199, :_reduce_504 ] - -racc_reduce_n = 505 - -racc_shift_n = 902 - -racc_token_table = { - false => 0, - :error => 1, - :kCLASS => 2, - :kMODULE => 3, - :kDEF => 4, - :kUNDEF => 5, - :kBEGIN => 6, - :kRESCUE => 7, - :kENSURE => 8, - :kEND => 9, - :kIF => 10, - :kUNLESS => 11, - :kTHEN => 12, - :kELSIF => 13, - :kELSE => 14, - :kCASE => 15, - :kWHEN => 16, - :kWHILE => 17, - :kUNTIL => 18, - :kFOR => 19, - :kBREAK => 20, - :kNEXT => 21, - :kREDO => 22, - :kRETRY => 23, - :kIN => 24, - :kDO => 25, - :kDO_COND => 26, - :kDO_BLOCK => 27, - :kRETURN => 28, - :kYIELD => 29, - :kSUPER => 30, - :kSELF => 31, - :kNIL => 32, - :kTRUE => 33, - :kFALSE => 34, - :kAND => 35, - :kOR => 36, - :kNOT => 37, - :kIF_MOD => 38, - :kUNLESS_MOD => 39, - :kWHILE_MOD => 40, - :kUNTIL_MOD => 41, - :kRESCUE_MOD => 42, - :kALIAS => 43, - :kDEFINED => 44, - :klBEGIN => 45, - :klEND => 46, - :k__LINE__ => 47, - :k__FILE__ => 48, - :tIDENTIFIER => 49, - :tFID => 50, - :tGVAR => 51, - :tIVAR => 52, - :tCONSTANT => 53, - :tCVAR => 54, - :tNTH_REF => 55, - :tBACK_REF => 56, - :tSTRING_CONTENT => 57, - :tINTEGER => 58, - :tFLOAT => 59, - :tREGEXP_END => 60, - :tUPLUS => 61, - :tUMINUS => 62, - :tUMINUS_NUM => 63, - :tPOW => 64, - :tCMP => 65, - :tEQ => 66, - :tEQQ => 67, - :tNEQ => 68, - :tGEQ => 69, - :tLEQ => 70, - :tANDOP => 71, - :tOROP => 72, - :tMATCH => 73, - :tNMATCH => 74, - :tDOT => 75, - :tDOT2 => 76, - :tDOT3 => 77, - :tAREF => 78, - :tASET => 79, - :tLSHFT => 80, - :tRSHFT => 81, - :tCOLON2 => 82, - :tCOLON3 => 83, - :tOP_ASGN => 84, - :tASSOC => 85, - :tLPAREN => 86, - :tLPAREN2 => 87, - :tRPAREN => 88, - :tLPAREN_ARG => 89, - :tLBRACK => 90, - :tRBRACK => 91, - :tLBRACE => 92, - :tLBRACE_ARG => 93, - :tSTAR => 94, - :tSTAR2 => 95, - :tAMPER => 96, - :tAMPER2 => 97, - :tTILDE => 98, - :tPERCENT => 99, - :tDIVIDE => 100, - :tPLUS => 101, - :tMINUS => 102, - :tLT => 103, - :tGT => 104, - :tPIPE => 105, - :tBANG => 106, - :tCARET => 107, - :tLCURLY => 108, - :tRCURLY => 109, - :tBACK_REF2 => 110, - :tSYMBEG => 111, - :tSTRING_BEG => 112, - :tXSTRING_BEG => 113, - :tREGEXP_BEG => 114, - :tWORDS_BEG => 115, - :tAWORDS_BEG => 116, - :tSTRING_DBEG => 117, - :tSTRING_DVAR => 118, - :tSTRING_END => 119, - :tSTRING => 120, - :tSYMBOL => 121, - :tNL => 122, - :tEH => 123, - :tCOLON => 124, - :tCOMMA => 125, - :tSPACE => 126, - :tSEMI => 127, - :tLAST_TOKEN => 128, - :tEQL => 129, - :tLOWEST => 130, - "[" => 131 } - -racc_nt_base = 132 - -racc_use_result_var = true - -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", - "kCLASS", - "kMODULE", - "kDEF", - "kUNDEF", - "kBEGIN", - "kRESCUE", - "kENSURE", - "kEND", - "kIF", - "kUNLESS", - "kTHEN", - "kELSIF", - "kELSE", - "kCASE", - "kWHEN", - "kWHILE", - "kUNTIL", - "kFOR", - "kBREAK", - "kNEXT", - "kREDO", - "kRETRY", - "kIN", - "kDO", - "kDO_COND", - "kDO_BLOCK", - "kRETURN", - "kYIELD", - "kSUPER", - "kSELF", - "kNIL", - "kTRUE", - "kFALSE", - "kAND", - "kOR", - "kNOT", - "kIF_MOD", - "kUNLESS_MOD", - "kWHILE_MOD", - "kUNTIL_MOD", - "kRESCUE_MOD", - "kALIAS", - "kDEFINED", - "klBEGIN", - "klEND", - "k__LINE__", - "k__FILE__", - "tIDENTIFIER", - "tFID", - "tGVAR", - "tIVAR", - "tCONSTANT", - "tCVAR", - "tNTH_REF", - "tBACK_REF", - "tSTRING_CONTENT", - "tINTEGER", - "tFLOAT", - "tREGEXP_END", - "tUPLUS", - "tUMINUS", - "tUMINUS_NUM", - "tPOW", - "tCMP", - "tEQ", - "tEQQ", - "tNEQ", - "tGEQ", - "tLEQ", - "tANDOP", - "tOROP", - "tMATCH", - "tNMATCH", - "tDOT", - "tDOT2", - "tDOT3", - "tAREF", - "tASET", - "tLSHFT", - "tRSHFT", - "tCOLON2", - "tCOLON3", - "tOP_ASGN", - "tASSOC", - "tLPAREN", - "tLPAREN2", - "tRPAREN", - "tLPAREN_ARG", - "tLBRACK", - "tRBRACK", - "tLBRACE", - "tLBRACE_ARG", - "tSTAR", - "tSTAR2", - "tAMPER", - "tAMPER2", - "tTILDE", - "tPERCENT", - "tDIVIDE", - "tPLUS", - "tMINUS", - "tLT", - "tGT", - "tPIPE", - "tBANG", - "tCARET", - "tLCURLY", - "tRCURLY", - "tBACK_REF2", - "tSYMBEG", - "tSTRING_BEG", - "tXSTRING_BEG", - "tREGEXP_BEG", - "tWORDS_BEG", - "tAWORDS_BEG", - "tSTRING_DBEG", - "tSTRING_DVAR", - "tSTRING_END", - "tSTRING", - "tSYMBOL", - "tNL", - "tEH", - "tCOLON", - "tCOMMA", - "tSPACE", - "tSEMI", - "tLAST_TOKEN", - "tEQL", - "tLOWEST", - "\"[\"", - "$start", - "program", - "compstmt", - "bodystmt", - "@1", - "opt_rescue", - "opt_else", - "opt_ensure", - "stmts", - "opt_terms", - "none", - "stmt", - "terms", - "fitem", - "undef_list", - "expr_value", - "lhs", - "command_call", - "mlhs", - "var_lhs", - "primary_value", - "aref_args", - "backref", - "mrhs", - "arg_value", - "expr", - "@2", - "@3", - "arg", - "command", - "block_command", - "call_args", - "block_call", - "operation2", - "command_args", - "cmd_brace_block", - "opt_block_var", - "@4", - "@5", - "operation", - "mlhs_basic", - "mlhs_entry", - "mlhs_head", - "mlhs_item", - "mlhs_node", - "variable", - "cname", - "cpath", - "fname", - "op", - "reswords", - "symbol", - "@6", - "opt_nl", - "primary", - "args", - "trailer", - "assocs", - "paren_args", - "opt_paren_args", - "opt_block_arg", - "block_arg", - "call_args2", - "open_args", - "@7", - "@8", - "@9", - "none_block_pass", - "literal", - "strings", - "xstring", - "regexp", - "words", - "awords", - "var_ref", - "assoc_list", - "brace_block", - "method_call", - "then", - "if_tail", - "do", - "case_body", - "block_var", - "superclass", - "term", - "f_arglist", - "singleton", - "dot_or_colon", - "@10", - "@11", - "@12", - "@13", - "@14", - "@15", - "@16", - "@17", - "@18", - "@19", - "@20", - "@21", - "@22", - "@23", - "@24", - "@25", - "@26", - "@27", - "do_block", - "@28", - "@29", - "operation3", - "@30", - "@31", - "@32", - "@33", - "@34", - "when_args", - "cases", - "@35", - "exc_list", - "exc_var", - "numeric", - "dsym", - "string", - "string1", - "string_contents", - "xstring_contents", - "word_list", - "word", - "string_content", - "qword_list", - "string_dvar", - "@36", - "@37", - "sym", - "@38", - "f_args", - "f_arg", - "f_optarg", - "f_rest_arg", - "opt_f_block_arg", - "f_block_arg", - "f_norm_arg", - "f_opt", - "restarg_mark", - "blkarg_mark", - "@39", - "assoc" ] - -Racc_debug_parser = true - -##### State transition tables end ##### - -# reduce 0 omitted - -def _reduce_1(val, _values, result) - self.lexer.lex_state = :expr_beg - - result -end - -def _reduce_2(val, _values, result) - result = val[1] - - result -end - -def _reduce_3(val, _values, result) - result = new_body val - - result -end - -def _reduce_4(val, _values, result) - result = new_compstmt val - - result -end - -# reduce 5 omitted - -# reduce 6 omitted - -def _reduce_7(val, _values, result) - result = self.block_append val[0], val[2] - - result -end - -def _reduce_8(val, _values, result) - result = val[1] - - result -end - -def _reduce_9(val, _values, result) - lexer.lex_state = :expr_fname - result = self.lexer.lineno - - result -end - -def _reduce_10(val, _values, result) - result = s(:alias, val[1], val[3]).line(val[2]) - - result -end - -def _reduce_11(val, _values, result) - result = s(:valias, val[1].to_sym, val[2].to_sym) - - result -end - -def _reduce_12(val, _values, result) - result = s(:valias, val[1].to_sym, :"$#{val[2]}") - - result -end - -def _reduce_13(val, _values, result) - yyerror "can't make alias for the number variables" - - result -end - -def _reduce_14(val, _values, result) - result = val[1] - - result -end - -def _reduce_15(val, _values, result) - result = new_if val[2], val[0], nil - - result -end - -def _reduce_16(val, _values, result) - result = new_if val[2], nil, val[0] - - result -end - -def _reduce_17(val, _values, result) - result = new_while val[0], val[2], true - - result -end - -def _reduce_18(val, _values, result) - result = new_until val[0], val[2], true - - result -end - -def _reduce_19(val, _values, result) - result = s(:rescue, val[0], s(:resbody, s(:array), val[2])) - - result -end - -def _reduce_20(val, _values, result) - if (self.in_def || self.in_single > 0) then - yyerror "BEGIN in method" - end - self.env.extend - - result -end - -def _reduce_21(val, _values, result) - result = new_iter s(:preexe), nil, val[3] # TODO: add test? - result = nil # TODO: since it isn't supposed to go in the AST - - result -end - -def _reduce_22(val, _values, result) - if (self.in_def || self.in_single > 0) then - yyerror "END in method; use at_exit" - end - result = new_iter s(:postexe), nil, val[2] - - result -end - -def _reduce_23(val, _values, result) - result = self.node_assign val[0], val[2] - - result -end - -def _reduce_24(val, _values, result) - result = new_masgn val[0], val[2], :wrap - - result -end - -def _reduce_25(val, _values, result) - result = new_op_asgn val - - result -end - -def _reduce_26(val, _values, result) - result = s(:op_asgn1, val[0], val[2], val[4].to_sym, val[5]) - - result -end - -def _reduce_27(val, _values, result) - result = s(:op_asgn, val[0], val[4], val[2], val[3]) - - result -end - -def _reduce_28(val, _values, result) - result = s(:op_asgn, val[0], val[4], val[2], val[3]) - - result -end - -def _reduce_29(val, _values, result) - result = s(:op_asgn, val[0], val[4], val[2], val[3]) - - result -end - -def _reduce_30(val, _values, result) - self.backref_assign_error val[0] - - result -end - -def _reduce_31(val, _values, result) - result = self.node_assign val[0], s(:svalue, val[2]) - - result -end - -def _reduce_32(val, _values, result) - result = new_masgn val[0], val[2], :wrap - - result -end - -def _reduce_33(val, _values, result) - result = new_masgn val[0], val[2] - - result -end - -# reduce 34 omitted - -# reduce 35 omitted - -def _reduce_36(val, _values, result) - result = logop(:and, val[0], val[2]) - - result -end - -def _reduce_37(val, _values, result) - result = logop(:or, val[0], val[2]) - - result -end - -def _reduce_38(val, _values, result) - result = s(:not, val[1]) - - result -end - -def _reduce_39(val, _values, result) - result = s(:not, val[1]) - - result -end - -# reduce 40 omitted - -def _reduce_41(val, _values, result) - result = value_expr(val[0]) - - result -end - -# reduce 42 omitted - -# reduce 43 omitted - -def _reduce_44(val, _values, result) - result = s(:return, ret_args(val[1])) - - result -end - -def _reduce_45(val, _values, result) - result = s(:break, ret_args(val[1])) - - result -end - -def _reduce_46(val, _values, result) - result = s(:next, ret_args(val[1])) - - result -end - -# reduce 47 omitted - -def _reduce_48(val, _values, result) - result = new_call val[0], val[2], val[3] - - result -end - -def _reduce_49(val, _values, result) - result = new_call val[0], val[2], val[3] - - result -end - -def _reduce_50(val, _values, result) - self.env.extend(:dynamic) - result = self.lexer.lineno - - result -end - -def _reduce_51(val, _values, result) - result = self.env.dynamic.keys - - result -end - -def _reduce_52(val, _values, result) - result = new_iter nil, val[2], val[4] - self.env.unextend - - result -end - -def _reduce_53(val, _values, result) - result = new_call nil, val[0].to_sym, val[1] - - result -end - -def _reduce_54(val, _values, result) - result = new_call nil, val[0].to_sym, val[1] - if val[2] then - if result[0] == :block_pass then - raise "both block arg and actual block given" - end - result, operation = val[2], result - result.insert 1, operation - end - - result -end - -def _reduce_55(val, _values, result) - result = new_call val[0], val[2].to_sym, val[3] - - result -end - -def _reduce_56(val, _values, result) - result = new_call val[0], val[2].to_sym, val[3] - - result -end - -def _reduce_57(val, _values, result) - result = new_call val[0], val[2].to_sym, val[3] - - result -end - -def _reduce_58(val, _values, result) - result = new_call val[0], val[2].to_sym, val[3] - if val[4] then - if result[0] == :block_pass then # REFACTOR - raise "both block arg and actual block given" - end - val[2] << result - result = val[2] - end - - result -end - -def _reduce_59(val, _values, result) - result = new_super val[1] - - result -end - -def _reduce_60(val, _values, result) - result = new_yield val[1] - - result -end - -# reduce 61 omitted - -def _reduce_62(val, _values, result) - result = val[1] - - result -end - -# reduce 63 omitted - -def _reduce_64(val, _values, result) - result = s(:masgn, s(:array, val[1])) - - result -end - -def _reduce_65(val, _values, result) - result = s(:masgn, val[0]) - - result -end - -def _reduce_66(val, _values, result) - result = s(:masgn, val[0] << val[1].compact) - - result -end - -def _reduce_67(val, _values, result) - result = s(:masgn, val[0] << s(:splat, val[2])) - - result -end - -def _reduce_68(val, _values, result) - result = s(:masgn, val[0] << s(:splat)) - - result -end - -def _reduce_69(val, _values, result) - result = s(:masgn, s(:array, s(:splat, val[1]))) - - result -end - -def _reduce_70(val, _values, result) - result = s(:masgn, s(:array, s(:splat))) - - result -end - -# reduce 71 omitted - -def _reduce_72(val, _values, result) - result = val[1] - - result -end - -def _reduce_73(val, _values, result) - result = s(:array, val[0]) - - result -end - -def _reduce_74(val, _values, result) - result = val[0] << val[1].compact - - result -end - -def _reduce_75(val, _values, result) - result = self.assignable val[0] - - result -end - -def _reduce_76(val, _values, result) - result = self.aryset val[0], val[2] - - result -end - -def _reduce_77(val, _values, result) - result = s(:attrasgn, val[0], :"#{val[2]}=", s(:arglist)) - - result -end - -def _reduce_78(val, _values, result) - result = s(:attrasgn, val[0], :"#{val[2]}=", s(:arglist)) - - result -end - -def _reduce_79(val, _values, result) - result = s(:attrasgn, val[0], :"#{val[2]}=", s(:arglist)) - - result -end - -def _reduce_80(val, _values, result) - if (self.in_def || self.in_single > 0) then - yyerror "dynamic constant assignment" - end - - result = s(:const, s(:colon2, val[0], val[2].to_sym), nil) - - result -end - -def _reduce_81(val, _values, result) - if (self.in_def || self.in_single > 0) then - yyerror "dynamic constant assignment" - end - - result = s(:const, nil, s(:colon3, val[1].to_sym)) - - result -end - -def _reduce_82(val, _values, result) - self.backref_assign_error val[0] - - result -end - -def _reduce_83(val, _values, result) - result = self.assignable val[0] - - result -end - -def _reduce_84(val, _values, result) - result = self.aryset val[0], val[2] - - result -end - -def _reduce_85(val, _values, result) - result = s(:attrasgn, val[0], :"#{val[2]}=") - - result -end - -def _reduce_86(val, _values, result) - result = s(:attrasgn, val[0], :"#{val[2]}=") - - result -end - -def _reduce_87(val, _values, result) - result = s(:attrasgn, val[0], :"#{val[2]}=") - - result -end - -def _reduce_88(val, _values, result) - if (self.in_def || self.in_single > 0) then - yyerror "dynamic constant assignment" - end - - result = s(:const, s(:colon2, val[0], val[2].to_sym)) - - result -end - -def _reduce_89(val, _values, result) - if (self.in_def || self.in_single > 0) then - yyerror "dynamic constant assignment" - end - - result = s(:const, s(:colon3, val[1].to_sym)) - - result -end - -def _reduce_90(val, _values, result) - self.backref_assign_error val[0] - - result -end - -def _reduce_91(val, _values, result) - yyerror "class/module name must be CONSTANT" - - result -end - -# reduce 92 omitted - -def _reduce_93(val, _values, result) - result = s(:colon3, val[1].to_sym) - - result -end - -def _reduce_94(val, _values, result) - result = val[0].to_sym - - result -end - -def _reduce_95(val, _values, result) - result = s(:colon2, val[0], val[2].to_sym) - - result -end - -# reduce 96 omitted - -# reduce 97 omitted - -# reduce 98 omitted - -def _reduce_99(val, _values, result) - lexer.lex_state = :expr_end - result = val[0] - - result -end - -def _reduce_100(val, _values, result) - lexer.lex_state = :expr_end - result = val[0] - - result -end - -def _reduce_101(val, _values, result) - result = s(:lit, val[0].to_sym) - result -end - -def _reduce_102(val, _values, result) - result = s(:lit, val[0]) - result -end - -def _reduce_103(val, _values, result) - result = new_undef val[0] - - result -end - -def _reduce_104(val, _values, result) - lexer.lex_state = :expr_fname - - result -end - -def _reduce_105(val, _values, result) - result = new_undef val[0], val[3] - - result -end - -# reduce 106 omitted - -# reduce 107 omitted - -# reduce 108 omitted - -# reduce 109 omitted - -# reduce 110 omitted - -# reduce 111 omitted - -# reduce 112 omitted - -# reduce 113 omitted - -# reduce 114 omitted - -# reduce 115 omitted - -# reduce 116 omitted - -# reduce 117 omitted - -# reduce 118 omitted - -# reduce 119 omitted - -# reduce 120 omitted - -# reduce 121 omitted - -# reduce 122 omitted - -# reduce 123 omitted - -# reduce 124 omitted - -# reduce 125 omitted - -# reduce 126 omitted - -# reduce 127 omitted - -# reduce 128 omitted - -# reduce 129 omitted - -# reduce 130 omitted - -# reduce 131 omitted - -# reduce 132 omitted - -# reduce 133 omitted - -# reduce 134 omitted - -# reduce 135 omitted - -# reduce 136 omitted - -# reduce 137 omitted - -# reduce 138 omitted - -# reduce 139 omitted - -# reduce 140 omitted - -# reduce 141 omitted - -# reduce 142 omitted - -# reduce 143 omitted - -# reduce 144 omitted - -# reduce 145 omitted - -# reduce 146 omitted - -# reduce 147 omitted - -# reduce 148 omitted - -# reduce 149 omitted - -# reduce 150 omitted - -# reduce 151 omitted - -# reduce 152 omitted - -# reduce 153 omitted - -# reduce 154 omitted - -# reduce 155 omitted - -# reduce 156 omitted - -# reduce 157 omitted - -# reduce 158 omitted - -# reduce 159 omitted - -# reduce 160 omitted - -# reduce 161 omitted - -# reduce 162 omitted - -# reduce 163 omitted - -# reduce 164 omitted - -# reduce 165 omitted - -# reduce 166 omitted - -# reduce 167 omitted - -# reduce 168 omitted - -# reduce 169 omitted - -# reduce 170 omitted - -# reduce 171 omitted - -# reduce 172 omitted - -def _reduce_173(val, _values, result) - result = self.node_assign val[0], val[2] - - result -end - -def _reduce_174(val, _values, result) - result = self.node_assign val[0], s(:rescue, val[2], s(:resbody, s(:array), val[4])) - # result.line = val[0].line - - result -end - -def _reduce_175(val, _values, result) - result = new_op_asgn val - - result -end - -def _reduce_176(val, _values, result) - result = s(:op_asgn1, val[0], val[2], val[4].to_sym, val[5]) - val[2][0] = :arglist - - result -end - -def _reduce_177(val, _values, result) - result = s(:op_asgn2, val[0], :"#{val[2]}=", val[3].to_sym, val[4]) - - result -end - -def _reduce_178(val, _values, result) - result = s(:op_asgn2, val[0], :"#{val[2]}=", val[3].to_sym, val[4]) - - result -end - -def _reduce_179(val, _values, result) - result = s(:op_asgn, val[0], val[4], val[2], val[3]) - - result -end - -def _reduce_180(val, _values, result) - yyerror "constant re-assignment" - - result -end - -def _reduce_181(val, _values, result) - yyerror "constant re-assignment" - - result -end - -def _reduce_182(val, _values, result) - self.backref_assign_error val[0] - - result -end - -def _reduce_183(val, _values, result) - v1, v2 = val[0], val[2] - if v1.node_type == :lit and v2.node_type == :lit and Fixnum === v1.last and Fixnum === v2.last then - result = s(:lit, (v1.last)..(v2.last)) - else - result = s(:dot2, v1, v2) - end - - result -end - -def _reduce_184(val, _values, result) - v1, v2 = val[0], val[2] - if v1.node_type == :lit and v2.node_type == :lit and Fixnum === v1.last and Fixnum === v2.last then - result = s(:lit, (v1.last)...(v2.last)) - else - result = s(:dot3, v1, v2) - end - - result -end - -def _reduce_185(val, _values, result) - result = new_call val[0], :+, s(:arglist, val[2]) - - result -end - -def _reduce_186(val, _values, result) - result = new_call val[0], :-, s(:arglist, val[2]) - - result -end - -def _reduce_187(val, _values, result) - result = new_call val[0], :*, s(:arglist, val[2]) - - result -end - -def _reduce_188(val, _values, result) - result = new_call val[0], :"/", s(:arglist, val[2]) - - result -end - -def _reduce_189(val, _values, result) - result = new_call val[0], :%, s(:arglist, val[2]) - - result -end - -def _reduce_190(val, _values, result) - result = new_call val[0], :**, s(:arglist, val[2]) - - result -end - -def _reduce_191(val, _values, result) - result = new_call(new_call(s(:lit, val[1]), :"**", s(:arglist, val[3])), :"-@", s(:arglist)) - - result -end - -def _reduce_192(val, _values, result) - result = new_call(new_call(s(:lit, val[1]), :"**", s(:arglist, val[3])), :"-@", s(:arglist)) - - result -end - -def _reduce_193(val, _values, result) - if val[1][0] == :lit then - result = val[1] - else - result = new_call val[1], :"+@", s(:arglist) - end - - result -end - -def _reduce_194(val, _values, result) - result = new_call val[1], :"-@", s(:arglist) - - result -end - -def _reduce_195(val, _values, result) - result = new_call val[0], :"|", s(:arglist, val[2]) - - result -end - -def _reduce_196(val, _values, result) - result = new_call val[0], :"^", s(:arglist, val[2]) - - result -end - -def _reduce_197(val, _values, result) - result = new_call val[0], :"&", s(:arglist, val[2]) - - result -end - -def _reduce_198(val, _values, result) - result = new_call val[0], :"<=>", s(:arglist, val[2]) - - result -end - -def _reduce_199(val, _values, result) - result = new_call val[0], :">", s(:arglist, val[2]) - - result -end - -def _reduce_200(val, _values, result) - result = new_call val[0], :">=", s(:arglist, val[2]) - - result -end - -def _reduce_201(val, _values, result) - result = new_call val[0], :"<", s(:arglist, val[2]) - - result -end - -def _reduce_202(val, _values, result) - result = new_call val[0], :"<=", s(:arglist, val[2]) - - result -end - -def _reduce_203(val, _values, result) - result = new_call val[0], :"==", s(:arglist, val[2]) - - result -end - -def _reduce_204(val, _values, result) - result = new_call val[0], :"===", s(:arglist, val[2]) - - result -end - -def _reduce_205(val, _values, result) - val[0] = value_expr val[0] # TODO: port call_op and clean these - val[2] = value_expr val[2] - result = s(:not, new_call(val[0], :"==", s(:arglist, val[2]))) - - result -end - -def _reduce_206(val, _values, result) - result = self.get_match_node val[0], val[2] - - result -end - -def _reduce_207(val, _values, result) - result = s(:not, self.get_match_node(val[0], val[2])) - - result -end - -def _reduce_208(val, _values, result) - result = s(:not, val[1]) - - result -end - -def _reduce_209(val, _values, result) - val[2] = value_expr val[2] - result = new_call val[1], :"~", s(:arglist) - - result -end - -def _reduce_210(val, _values, result) - val[0] = value_expr val[0] - val[2] = value_expr val[2] - result = new_call val[0], :"\<\<", s(:arglist, val[2]) - - result -end - -def _reduce_211(val, _values, result) - val[0] = value_expr val[0] - val[2] = value_expr val[2] - result = new_call val[0], :">>", s(:arglist, val[2]) - - result -end - -def _reduce_212(val, _values, result) - result = logop(:and, val[0], val[2]) - - result -end - -def _reduce_213(val, _values, result) - result = logop(:or, val[0], val[2]) - - result -end - -def _reduce_214(val, _values, result) - result = s(:defined, val[2]) - - result -end - -def _reduce_215(val, _values, result) - result = s(:if, val[0], val[2], val[4]) - - result -end - -# reduce 216 omitted - -def _reduce_217(val, _values, result) - result = value_expr(val[0]) - - result -end - -# reduce 218 omitted - -def _reduce_219(val, _values, result) - warning 'parenthesize argument(s) for future version' - result = s(:array, val[0]) - - result -end - -def _reduce_220(val, _values, result) - result = val[0] - - result -end - -def _reduce_221(val, _values, result) - result = self.arg_concat val[0], val[3] - - result -end - -def _reduce_222(val, _values, result) - result = s(:array, s(:hash, *val[0].values)) - - result -end - -def _reduce_223(val, _values, result) - result = s(:array, s(:splat, val[1])) - - result -end - -def _reduce_224(val, _values, result) - result = val[1] - - result -end - -def _reduce_225(val, _values, result) - result = val[1] - - result -end - -def _reduce_226(val, _values, result) - warning "parenthesize argument(s) for future version" - result = s(:array, val[1]) - - result -end - -def _reduce_227(val, _values, result) - warning "parenthesize argument(s) for future version" - result = val[1].add val[3] - - result -end - -# reduce 228 omitted - -# reduce 229 omitted - -def _reduce_230(val, _values, result) - warning "parenthesize argument(s) for future version" - result = s(:array, val[0]) - - result -end - -def _reduce_231(val, _values, result) - result = self.arg_blk_pass val[0], val[1] - - result -end - -def _reduce_232(val, _values, result) - result = self.arg_concat val[0], val[3] - result = self.arg_blk_pass result, val[4] - - result -end - -def _reduce_233(val, _values, result) - result = s(:array, s(:hash, *val[0].values)) - result = self.arg_blk_pass result, val[1] - - result -end - -def _reduce_234(val, _values, result) - result = self.arg_concat s(:array, s(:hash, *val[0].values)), val[3] - result = self.arg_blk_pass result, val[4] - - result -end - -def _reduce_235(val, _values, result) - result = val[0] << s(:hash, *val[2].values) - result = self.arg_blk_pass result, val[3] - - result -end - -def _reduce_236(val, _values, result) - val[0] << s(:hash, *val[2].values) - result = self.arg_concat val[0], val[5] - result = self.arg_blk_pass result, val[6] - - result -end - -def _reduce_237(val, _values, result) - result = self.arg_blk_pass s(:splat, val[1]), val[2] - - result -end - -# reduce 238 omitted - -def _reduce_239(val, _values, result) - args = self.list_prepend val[0], val[2] - result = self.arg_blk_pass args, val[3] - - result -end - -def _reduce_240(val, _values, result) - result = self.arg_blk_pass val[0], val[2] - - result -end - -def _reduce_241(val, _values, result) - result = self.arg_concat s(:array, val[0]), val[3] - result = self.arg_blk_pass result, val[4] - - result -end - -def _reduce_242(val, _values, result) - result = self.arg_concat s(:array, val[0], s(:hash, *val[2].values)), val[5] - result = self.arg_blk_pass result, val[6] - - result -end - -def _reduce_243(val, _values, result) - result = s(:array, s(:hash, *val[0].values)) - result = self.arg_blk_pass result, val[1] - - result -end - -def _reduce_244(val, _values, result) - result = s(:array, s(:hash, *val[0].values), val[3]) - result = self.arg_blk_pass result, val[4] - - result -end - -def _reduce_245(val, _values, result) - result = s(:array, val[0], s(:hash, *val[2].values)) - result = self.arg_blk_pass result, val[3] - - result -end - -def _reduce_246(val, _values, result) - result = s(:array, val[0]).add_all(val[2]).add(s(:hash, *val[4].values)) - result = self.arg_blk_pass result, val[5] - - result -end - -def _reduce_247(val, _values, result) - result = self.arg_concat s(:array, val[0]).add(s(:hash, *val[2].values)), val[5] - result = self.arg_blk_pass result, val[6] - - result -end - -def _reduce_248(val, _values, result) - result = self.arg_concat s(:array, val[0]).add_all(val[2]).add(s(:hash, *val[4].values)), val[7] - result = self.arg_blk_pass result, val[8] - - result -end - -def _reduce_249(val, _values, result) - result = self.arg_blk_pass s(:splat, val[1]), val[2] - - result -end - -# reduce 250 omitted - -def _reduce_251(val, _values, result) - result = lexer.cmdarg.stack.dup - lexer.cmdarg.push true - - result -end - -def _reduce_252(val, _values, result) - lexer.cmdarg.stack.replace val[0] - result = val[1] - - result -end - -# reduce 253 omitted - -def _reduce_254(val, _values, result) - lexer.lex_state = :expr_endarg - - result -end - -def _reduce_255(val, _values, result) - warning "don't put space before argument parentheses" - result = nil - - result -end - -def _reduce_256(val, _values, result) - lexer.lex_state = :expr_endarg - - result -end - -def _reduce_257(val, _values, result) - warning "don't put space before argument parentheses" - result = val[1] - - result -end - -def _reduce_258(val, _values, result) - result = s(:block_pass, val[1]) - - result -end - -def _reduce_259(val, _values, result) - result = val[1] - - result -end - -# reduce 260 omitted - -def _reduce_261(val, _values, result) - result = s(:array, val[0]) - - result -end - -def _reduce_262(val, _values, result) - result = self.list_append val[0], val[2] - - result -end - -def _reduce_263(val, _values, result) - result = val[0] << val[2] - - result -end - -def _reduce_264(val, _values, result) - result = self.arg_concat val[0], val[3] - - result -end - -def _reduce_265(val, _values, result) - result = s(:splat, val[1]) - - result -end - -# reduce 266 omitted - -# reduce 267 omitted - -# reduce 268 omitted - -# reduce 269 omitted - -# reduce 270 omitted - -# reduce 271 omitted - -# reduce 272 omitted - -# reduce 273 omitted - -def _reduce_274(val, _values, result) - result = new_call nil, val[0].to_sym - - result -end - -def _reduce_275(val, _values, result) - result = self.lexer.lineno - - result -end - -def _reduce_276(val, _values, result) - unless val[2] then - result = s(:nil) - else - result = s(:begin, val[2]) - end - - result.line = val[1] - - result -end - -def _reduce_277(val, _values, result) - lexer.lex_state = :expr_endarg - - result -end - -def _reduce_278(val, _values, result) - warning "(...) interpreted as grouped expression" - result = val[1] - - result -end - -def _reduce_279(val, _values, result) - result = val[1] || s(:nil) - result.paren = true - - result -end - -def _reduce_280(val, _values, result) - result = s(:colon2, val[0], val[2].to_sym) - - result -end - -def _reduce_281(val, _values, result) - result = s(:colon3, val[1].to_sym) - - result -end - -def _reduce_282(val, _values, result) - result = new_aref val - - result -end - -def _reduce_283(val, _values, result) - result = val[1] || s(:array) - - result -end - -def _reduce_284(val, _values, result) - result = s(:hash, *val[1].values) - - result -end - -def _reduce_285(val, _values, result) - result = s(:return) - - result -end - -def _reduce_286(val, _values, result) - result = new_yield val[2] - - result -end - -def _reduce_287(val, _values, result) - result = new_yield - - result -end - -def _reduce_288(val, _values, result) - result = new_yield - - result -end - -def _reduce_289(val, _values, result) - result = s(:defined, val[3]) - - result -end - -def _reduce_290(val, _values, result) - oper, iter = val[0], val[1] - call = new_call(nil, oper.to_sym) - iter.insert 1, call - result = iter - call.line ||= iter.line - - result -end - -# reduce 291 omitted - -def _reduce_292(val, _values, result) - call, iter = val[0], val[1] - iter.insert 1, call - result = iter - - result -end - -def _reduce_293(val, _values, result) - result = new_if val[1], val[3], val[4] - - result -end - -def _reduce_294(val, _values, result) - result = new_if val[1], val[4], val[3] - - result -end - -def _reduce_295(val, _values, result) - lexer.cond.push true - - result -end - -def _reduce_296(val, _values, result) - lexer.cond.pop - - result -end - -def _reduce_297(val, _values, result) - result = new_while val[5], val[2], true - - result -end - -def _reduce_298(val, _values, result) - lexer.cond.push true - - result -end - -def _reduce_299(val, _values, result) - lexer.cond.pop - - result -end - -def _reduce_300(val, _values, result) - result = new_until val[5], val[2], true - - result -end - -def _reduce_301(val, _values, result) - result = new_case val[1], val[3] - - result -end - -def _reduce_302(val, _values, result) - result = new_case nil, val[2] - - result -end - -def _reduce_303(val, _values, result) - result = new_case nil, val[3] - - result -end - -def _reduce_304(val, _values, result) - lexer.cond.push true - - result -end - -def _reduce_305(val, _values, result) - lexer.cond.pop - - result -end - -def _reduce_306(val, _values, result) - result = new_for val[4], val[1], val[7] - - result -end - -def _reduce_307(val, _values, result) - result = self.lexer.lineno - - result -end - -def _reduce_308(val, _values, result) - self.comments.push self.lexer.comments - if (self.in_def || self.in_single > 0) then - yyerror "class definition in method body" - end - self.env.extend - - result -end - -def _reduce_309(val, _values, result) - result = new_class val - self.env.unextend - - result -end - -def _reduce_310(val, _values, result) - result = self.lexer.lineno - - result -end - -def _reduce_311(val, _values, result) - result = self.in_def - self.in_def = false - - result -end - -def _reduce_312(val, _values, result) - result = self.in_single - self.in_single = 0 - self.env.extend - - result -end - -def _reduce_313(val, _values, result) - result = new_sclass val - self.env.unextend - - result -end - -def _reduce_314(val, _values, result) - result = self.lexer.lineno - - result -end - -def _reduce_315(val, _values, result) - self.comments.push self.lexer.comments - yyerror "module definition in method body" if - self.in_def or self.in_single > 0 - - self.env.extend - - result -end - -def _reduce_316(val, _values, result) - result = new_module val - self.env.unextend - - result -end - -def _reduce_317(val, _values, result) - self.comments.push self.lexer.comments - self.in_def = true - self.env.extend - result = lexer.lineno, lexer.src.beginning_of_line? - - result -end - -def _reduce_318(val, _values, result) - result = new_defn val - self.env.unextend - self.in_def = false - - result -end - -def _reduce_319(val, _values, result) - self.comments.push self.lexer.comments - lexer.lex_state = :expr_fname - - result -end - -def _reduce_320(val, _values, result) - self.in_single += 1 - self.env.extend - lexer.lex_state = :expr_end # force for args - - result -end - -def _reduce_321(val, _values, result) - result = new_defs val - - self.env.unextend - self.in_single -= 1 - - result -end - -def _reduce_322(val, _values, result) - result = s(:break) - - result -end - -def _reduce_323(val, _values, result) - result = s(:next) - - result -end - -def _reduce_324(val, _values, result) - result = s(:redo) - - result -end - -def _reduce_325(val, _values, result) - result = s(:retry) - - result -end - -def _reduce_326(val, _values, result) - result = value_expr(val[0]) - - result -end - -# reduce 327 omitted - -# reduce 328 omitted - -# reduce 329 omitted - -# reduce 330 omitted - -# reduce 331 omitted - -# reduce 332 omitted - -# reduce 333 omitted - -# reduce 334 omitted - -def _reduce_335(val, _values, result) - result = s(:if, val[1], val[3], val[4]) - - result -end - -# reduce 336 omitted - -def _reduce_337(val, _values, result) - result = val[1] - - result -end - -# reduce 338 omitted - -def _reduce_339(val, _values, result) - val[0].delete_at 1 if val[0][1].nil? # HACK - - result -end - -# reduce 340 omitted - -def _reduce_341(val, _values, result) - result = 0 - - result -end - -def _reduce_342(val, _values, result) - result = 0 - - result -end - -def _reduce_343(val, _values, result) - result = val[1] - - result -end - -def _reduce_344(val, _values, result) - self.env.extend :dynamic - - result -end - -def _reduce_345(val, _values, result) - result = self.env.dynamic.keys - - result -end - -def _reduce_346(val, _values, result) - vars = val[2] - body = val[4] - result = new_iter nil, vars, body - - self.env.unextend - - result -end - -def _reduce_347(val, _values, result) - raise SyntaxError, "Both block arg and actual block given." if - val[0] && val[0][0] == :blockpass - - result = val[1] - result.insert 1, val[0] - - result -end - -def _reduce_348(val, _values, result) - result = new_call val[0], val[2], val[3] - - result -end - -def _reduce_349(val, _values, result) - result = new_call val[0], val[2], val[3] - - result -end - -def _reduce_350(val, _values, result) - result = self.lexer.lineno - - result -end - -def _reduce_351(val, _values, result) - result = new_call nil, val[0].to_sym, val[2] - - result -end - -def _reduce_352(val, _values, result) - result = new_call val[0], val[2].to_sym, val[3] - - result -end - -def _reduce_353(val, _values, result) - result = new_call val[0], val[2].to_sym, val[3] - - result -end - -def _reduce_354(val, _values, result) - result = new_call val[0], val[2].to_sym - - result -end - -def _reduce_355(val, _values, result) - result = new_super val[1] - - result -end - -def _reduce_356(val, _values, result) - result = s(:zsuper) - - result -end - -def _reduce_357(val, _values, result) - self.env.extend :dynamic - result = self.lexer.lineno - - result -end - -def _reduce_358(val, _values, result) - result = self.env.dynamic.keys - - result -end - -def _reduce_359(val, _values, result) - # REFACTOR - args = val[2] - body = val[4] - result = new_iter nil, args, body - self.env.unextend - result.line = val[1] - - result -end - -def _reduce_360(val, _values, result) - self.env.extend :dynamic - result = self.lexer.lineno - - result -end - -def _reduce_361(val, _values, result) - result = self.env.dynamic.keys - - result -end - -def _reduce_362(val, _values, result) - args = val[2] - body = val[4] - result = new_iter nil, args, body - self.env.unextend - result.line = val[1] - - result -end - -def _reduce_363(val, _values, result) - result = self.lexer.lineno - - result -end - -def _reduce_364(val, _values, result) - result = s(:when, val[2], val[4]) - result.line = val[1] - result << val[5] if val[5] - - result -end - -# reduce 365 omitted - -def _reduce_366(val, _values, result) - result = self.list_append val[0], s(:when, val[3], nil) - - result -end - -def _reduce_367(val, _values, result) - result = s(:array, s(:when, val[1], nil)) - - result -end - -# reduce 368 omitted - -# reduce 369 omitted - -def _reduce_370(val, _values, result) - klasses, var, body, rest = val[1], val[2], val[4], val[5] - - klasses ||= s(:array) - klasses << node_assign(var, s(:gvar, :"$!")) if var - - result = s(:resbody, klasses, body) - result << rest if rest # UGH, rewritten above - - result -end - -def _reduce_371(val, _values, result) - result = nil - - result -end - -def _reduce_372(val, _values, result) - result = s(:array, val[0]) - - result -end - -# reduce 373 omitted - -# reduce 374 omitted - -def _reduce_375(val, _values, result) - result = val[1] - - result -end - -# reduce 376 omitted - -def _reduce_377(val, _values, result) - if (val[1] != nil) then - result = val[1] - else - result = s(:nil) - end - - result -end - -# reduce 378 omitted - -def _reduce_379(val, _values, result) - result = s(:lit, val[0]) - result -end - -def _reduce_380(val, _values, result) - result = s(:lit, val[0]) - result -end - -# reduce 381 omitted - -def _reduce_382(val, _values, result) - val[0] = s(:dstr, val[0].value) if val[0][0] == :evstr - result = val[0] - - result -end - -# reduce 383 omitted - -def _reduce_384(val, _values, result) - result = self.literal_concat val[0], val[1] - - result -end - -def _reduce_385(val, _values, result) - result = val[1] - - result -end - -def _reduce_386(val, _values, result) - result = s(:str, val[0]) - - result -end - -def _reduce_387(val, _values, result) - result = new_xstring val[1] - - result -end - -def _reduce_388(val, _values, result) - result = new_regexp val - - result -end - -def _reduce_389(val, _values, result) - result = s(:array) - - result -end - -def _reduce_390(val, _values, result) - result = val[1] - - result -end - -def _reduce_391(val, _values, result) - result = s(:array) - - result -end - -def _reduce_392(val, _values, result) - word = val[1][0] == :evstr ? s(:dstr, "", val[1]) : val[1] - result = val[0] << word - - result -end - -# reduce 393 omitted - -def _reduce_394(val, _values, result) - result = self.literal_concat val[0], val[1] - - result -end - -def _reduce_395(val, _values, result) - result = s(:array) - - result -end - -def _reduce_396(val, _values, result) - result = val[1] - - result -end - -def _reduce_397(val, _values, result) - result = s(:array) - - result -end - -def _reduce_398(val, _values, result) - result = val[0] << s(:str, val[1]) - - result -end - -def _reduce_399(val, _values, result) - result = s(:str, "") - - result -end - -def _reduce_400(val, _values, result) - result = literal_concat(val[0], val[1]) - - result -end - -def _reduce_401(val, _values, result) - result = nil - - result -end - -def _reduce_402(val, _values, result) - result = literal_concat(val[0], val[1]) - - result -end - -def _reduce_403(val, _values, result) - result = s(:str, val[0]) - - result -end - -def _reduce_404(val, _values, result) - result = lexer.lex_strterm - lexer.lex_strterm = nil - lexer.lex_state = :expr_beg - - result -end - -def _reduce_405(val, _values, result) - lexer.lex_strterm = val[1] - result = s(:evstr, val[2]) - - result -end - -def _reduce_406(val, _values, result) - result = lexer.lex_strterm - lexer.lex_strterm = nil - lexer.lex_state = :expr_beg - lexer.cond.push false - lexer.cmdarg.push false - - result -end - -def _reduce_407(val, _values, result) - lexer.lex_strterm = val[1] - lexer.cond.lexpop - lexer.cmdarg.lexpop - - case val[2] - when Sexp then - case val[2][0] - when :str, :dstr, :evstr then - result = val[2] - else - result = s(:evstr, val[2]) - end - when nil then - result = s(:evstr) - else - raise "unknown rescue body: #{val[2].inspect}" - end - - result -end - -def _reduce_408(val, _values, result) - result = s(:gvar, val[0].to_sym) - result -end - -def _reduce_409(val, _values, result) - result = s(:ivar, val[0].to_sym) - result -end - -def _reduce_410(val, _values, result) - result = s(:cvar, val[0].to_sym) - result -end - -# reduce 411 omitted - -def _reduce_412(val, _values, result) - lexer.lex_state = :expr_end - result = val[1].to_sym - - result -end - -def _reduce_413(val, _values, result) - result = val[0].to_sym - - result -end - -# reduce 414 omitted - -# reduce 415 omitted - -# reduce 416 omitted - -# reduce 417 omitted - -def _reduce_418(val, _values, result) - lexer.lex_state = :expr_end - result = val[1] - - yyerror "empty symbol literal" if - result.nil? or result.empty? - - case result[0] - when :dstr then - result[0] = :dsym - when :str then - result = s(:lit, result.last.intern) - else - result = s(:dsym, "", result) - end - - result -end - -# reduce 419 omitted - -# reduce 420 omitted - -def _reduce_421(val, _values, result) - result = -val[1] # TODO: pt_testcase - - result -end - -def _reduce_422(val, _values, result) - result = -val[1] # TODO: pt_testcase - - result -end - -# reduce 423 omitted - -# reduce 424 omitted - -# reduce 425 omitted - -# reduce 426 omitted - -# reduce 427 omitted - -def _reduce_428(val, _values, result) - result = :nil - result -end - -def _reduce_429(val, _values, result) - result = :self - result -end - -def _reduce_430(val, _values, result) - result = :true - result -end - -def _reduce_431(val, _values, result) - result = :false - result -end - -def _reduce_432(val, _values, result) - result = :__FILE__ - result -end - -def _reduce_433(val, _values, result) - result = :__LINE__ - result -end - -def _reduce_434(val, _values, result) - result = self.gettable val[0] - - result -end - -def _reduce_435(val, _values, result) - result = self.assignable val[0] - - result -end - -def _reduce_436(val, _values, result) - result = s(:nth_ref, val[0]) - result -end - -def _reduce_437(val, _values, result) - result = s(:back_ref, val[0]) - result -end - -def _reduce_438(val, _values, result) - result = nil - - result -end - -def _reduce_439(val, _values, result) - lexer.lex_state = :expr_beg - - result -end - -def _reduce_440(val, _values, result) - result = val[2] - - result -end - -def _reduce_441(val, _values, result) - yyerrok - result = nil - - result -end - -def _reduce_442(val, _values, result) - result = val[1] - lexer.lex_state = :expr_beg - - result -end - -def _reduce_443(val, _values, result) - result = val[0] - - result -end - -def _reduce_444(val, _values, result) - result = args val[0], val[2], val[4], val[5] - - result -end - -def _reduce_445(val, _values, result) - result = args val[0], val[2], nil, val[3] - - result -end - -def _reduce_446(val, _values, result) - result = args val[0], nil, val[2], val[3] - - result -end - -def _reduce_447(val, _values, result) - result = args val[0], nil, nil, val[1] - - result -end - -def _reduce_448(val, _values, result) - result = args nil, val[0], val[2], val[3] - - result -end - -def _reduce_449(val, _values, result) - result = args nil, val[0], nil, val[1] - - result -end - -def _reduce_450(val, _values, result) - result = args nil, nil, val[0], val[1] - - result -end - -def _reduce_451(val, _values, result) - result = args nil, nil, nil, val[0] - - result -end - -def _reduce_452(val, _values, result) - result = args nil, nil, nil, nil - - result -end - -def _reduce_453(val, _values, result) - yyerror "formal argument cannot be a constant: #{val[0]}" - - result -end - -def _reduce_454(val, _values, result) - yyerror "formal argument cannot be an instance variable" - - result -end - -def _reduce_455(val, _values, result) - yyerror "formal argument cannot be a class variable" - - result -end - -def _reduce_456(val, _values, result) - identifier = val[0].to_sym - self.env[identifier] = :lvar - - result = val[0] - - result -end - -def _reduce_457(val, _values, result) - result = s(:args) - result << val[0].to_sym - - result -end - -def _reduce_458(val, _values, result) - val[0] << val[2].to_sym - result = val[0] - - result -end - -def _reduce_459(val, _values, result) - result = self.assignable val[0], val[2] - # TODO: detect duplicate names - - result -end - -def _reduce_460(val, _values, result) - result = s(:block, val[0]) - - result -end - -def _reduce_461(val, _values, result) - result = self.append_to_block val[0], val[2] - - result -end - -# reduce 462 omitted - -# reduce 463 omitted - -def _reduce_464(val, _values, result) - # TODO: differs from parse.y - needs tests - name = val[1].to_sym - self.assignable name - result = :"*#{name}" - - result -end - -def _reduce_465(val, _values, result) - name = :"*" - self.env[name] = :lvar - result = name - - result -end - -# reduce 466 omitted - -# reduce 467 omitted - -def _reduce_468(val, _values, result) - identifier = val[1].to_sym - - self.env[identifier] = :lvar - result = s(:block_arg, identifier.to_sym) - - result -end - -def _reduce_469(val, _values, result) - result = val[1] - - result -end - -def _reduce_470(val, _values, result) - result = nil - - result -end - -# reduce 471 omitted - -def _reduce_472(val, _values, result) - lexer.lex_state = :expr_beg - - result -end - -def _reduce_473(val, _values, result) - result = val[2] - yyerror "Can't define single method for literals." if - result[0] == :lit - - result -end - -def _reduce_474(val, _values, result) - result = s(:array) - - result -end - -def _reduce_475(val, _values, result) - result = val[0] - - result -end - -def _reduce_476(val, _values, result) - size = val[0].size - if (size % 2 != 1) then # != 1 because of leading :array - yyerror "Odd number (#{size}) list for Hash. #{val[0].inspect}" - end - result = val[0] - - result -end - -# reduce 477 omitted - -def _reduce_478(val, _values, result) - list = val[0].dup - more = val[2][1..-1] - list.push(*more) unless more.empty? - result = list - - result -end - -def _reduce_479(val, _values, result) - result = s(:array, val[0], val[2]) - - result -end - -# reduce 480 omitted - -# reduce 481 omitted - -# reduce 482 omitted - -# reduce 483 omitted - -# reduce 484 omitted - -# reduce 485 omitted - -# reduce 486 omitted - -# reduce 487 omitted - -# reduce 488 omitted - -# reduce 489 omitted - -# reduce 490 omitted - -# reduce 491 omitted - -# reduce 492 omitted - -# reduce 493 omitted - -# reduce 494 omitted - -# reduce 495 omitted - -# reduce 496 omitted - -# reduce 497 omitted - -# reduce 498 omitted - -def _reduce_499(val, _values, result) - yyerrok - result -end - -# reduce 500 omitted - -# reduce 501 omitted - -def _reduce_502(val, _values, result) - yyerrok - result -end - -def _reduce_503(val, _values, result) - result = nil - result -end - -def _reduce_504(val, _values, result) - result = nil - result -end - -def _reduce_none(val, _values, result) - val[0] -end - -end # class RubyParser diff --git a/vendor/gems/ruby_parser-2.0.5/lib/ruby_parser.y b/vendor/gems/ruby_parser-2.0.5/lib/ruby_parser.y deleted file mode 100644 index b7741811bb6..00000000000 --- a/vendor/gems/ruby_parser-2.0.5/lib/ruby_parser.y +++ /dev/null @@ -1,1790 +0,0 @@ -# -*- racc -*- - -class RubyParser - -token kCLASS kMODULE kDEF kUNDEF kBEGIN kRESCUE kENSURE kEND kIF kUNLESS - kTHEN kELSIF kELSE kCASE kWHEN kWHILE kUNTIL kFOR kBREAK kNEXT - kREDO kRETRY kIN kDO kDO_COND kDO_BLOCK kRETURN kYIELD kSUPER - kSELF kNIL kTRUE kFALSE kAND kOR kNOT kIF_MOD kUNLESS_MOD kWHILE_MOD - kUNTIL_MOD kRESCUE_MOD kALIAS kDEFINED klBEGIN klEND k__LINE__ - k__FILE__ tIDENTIFIER tFID tGVAR tIVAR tCONSTANT tCVAR tNTH_REF - tBACK_REF tSTRING_CONTENT tINTEGER tFLOAT tREGEXP_END tUPLUS - tUMINUS tUMINUS_NUM tPOW tCMP tEQ tEQQ tNEQ tGEQ tLEQ tANDOP - tOROP tMATCH tNMATCH tDOT tDOT2 tDOT3 tAREF tASET tLSHFT tRSHFT - tCOLON2 tCOLON3 tOP_ASGN tASSOC tLPAREN tLPAREN2 tRPAREN tLPAREN_ARG - tLBRACK tRBRACK tLBRACE tLBRACE_ARG tSTAR tSTAR2 tAMPER tAMPER2 - tTILDE tPERCENT tDIVIDE tPLUS tMINUS tLT tGT tPIPE tBANG tCARET - tLCURLY tRCURLY tBACK_REF2 tSYMBEG tSTRING_BEG tXSTRING_BEG tREGEXP_BEG - tWORDS_BEG tAWORDS_BEG tSTRING_DBEG tSTRING_DVAR tSTRING_END tSTRING - tSYMBOL tNL tEH tCOLON tCOMMA tSPACE tSEMI tLAST_TOKEN - -prechigh - right tBANG tTILDE tUPLUS - right tPOW - right tUMINUS_NUM tUMINUS - left tSTAR2 tDIVIDE tPERCENT - left tPLUS tMINUS - left tLSHFT tRSHFT - left tAMPER2 - left tPIPE tCARET - left tGT tGEQ tLT tLEQ - nonassoc tCMP tEQ tEQQ tNEQ tMATCH tNMATCH - left tANDOP - left tOROP - nonassoc tDOT2 tDOT3 - right tEH tCOLON - left kRESCUE_MOD - right tEQL tOP_ASGN - nonassoc kDEFINED - right kNOT - left kOR kAND - nonassoc kIF_MOD kUNLESS_MOD kWHILE_MOD kUNTIL_MOD - nonassoc tLBRACE_ARG - nonassoc tLOWEST -preclow - -rule - - program: { - self.lexer.lex_state = :expr_beg - } - compstmt - { - result = val[1] - } - - bodystmt: compstmt opt_rescue opt_else opt_ensure - { - result = new_body val - } - - compstmt: stmts opt_terms - { - result = new_compstmt val - } - - stmts: none - | stmt - | stmts terms stmt - { - result = self.block_append val[0], val[2] - } - | error stmt - { - result = val[1] - } - - stmt: kALIAS fitem - { - lexer.lex_state = :expr_fname - result = self.lexer.lineno - } - fitem - { - result = s(:alias, val[1], val[3]).line(val[2]) - } - | kALIAS tGVAR tGVAR - { - result = s(:valias, val[1].to_sym, val[2].to_sym) - } - | kALIAS tGVAR tBACK_REF - { - result = s(:valias, val[1].to_sym, :"$#{val[2]}") - } - | kALIAS tGVAR tNTH_REF - { - yyerror "can't make alias for the number variables" - } - | kUNDEF undef_list - { - result = val[1] - } - | stmt kIF_MOD expr_value - { - result = new_if val[2], val[0], nil - } - | stmt kUNLESS_MOD expr_value - { - result = new_if val[2], nil, val[0] - } - | stmt kWHILE_MOD expr_value - { - result = new_while val[0], val[2], true - } - | stmt kUNTIL_MOD expr_value - { - result = new_until val[0], val[2], true - } - | stmt kRESCUE_MOD stmt - { - result = s(:rescue, val[0], s(:resbody, s(:array), val[2])) - } - | klBEGIN - { - if (self.in_def || self.in_single > 0) then - yyerror "BEGIN in method" - end - self.env.extend - } - tLCURLY compstmt tRCURLY - { - result = new_iter s(:preexe), nil, val[3] # TODO: add test? - result = nil # TODO: since it isn't supposed to go in the AST - } - | klEND tLCURLY compstmt tRCURLY - { - if (self.in_def || self.in_single > 0) then - yyerror "END in method; use at_exit" - end - result = new_iter s(:postexe), nil, val[2] - } - | lhs tEQL command_call - { - result = self.node_assign val[0], val[2] - } - | mlhs tEQL command_call - { - result = new_masgn val[0], val[2], :wrap - } - | var_lhs tOP_ASGN command_call - { - result = new_op_asgn val - } - | primary_value "[" aref_args tRBRACK tOP_ASGN command_call - { - result = s(:op_asgn1, val[0], val[2], val[4].to_sym, val[5]) - } - | primary_value tDOT tIDENTIFIER tOP_ASGN command_call - { - result = s(:op_asgn, val[0], val[4], val[2], val[3]) - } - | primary_value tDOT tCONSTANT tOP_ASGN command_call - { - result = s(:op_asgn, val[0], val[4], val[2], val[3]) - } - | primary_value tCOLON2 tIDENTIFIER tOP_ASGN command_call - { - result = s(:op_asgn, val[0], val[4], val[2], val[3]) - } - | backref tOP_ASGN command_call - { - self.backref_assign_error val[0] - } - | lhs tEQL mrhs - { - result = self.node_assign val[0], s(:svalue, val[2]) - } - | mlhs tEQL arg_value - { - result = new_masgn val[0], val[2], :wrap - } - | mlhs tEQL mrhs - { - result = new_masgn val[0], val[2] - } - | expr - - expr: command_call - | expr kAND expr - { - result = logop(:and, val[0], val[2]) - } - | expr kOR expr - { - result = logop(:or, val[0], val[2]) - } - | kNOT expr - { - result = s(:not, val[1]) - } - | tBANG command_call - { - result = s(:not, val[1]) - } - | arg - - expr_value: expr - { - result = value_expr(val[0]) - } - - command_call: command - | block_command - | kRETURN call_args - { - result = s(:return, ret_args(val[1])) - } - | kBREAK call_args - { - result = s(:break, ret_args(val[1])) - } - | kNEXT call_args - { - result = s(:next, ret_args(val[1])) - } - - block_command: block_call - | block_call tDOT operation2 command_args - { - result = new_call val[0], val[2], val[3] - } - | block_call tCOLON2 operation2 command_args - { - result = new_call val[0], val[2], val[3] - } - - cmd_brace_block: tLBRACE_ARG - { - self.env.extend(:dynamic) - result = self.lexer.lineno - } - opt_block_var - { - result = self.env.dynamic.keys - } - compstmt tRCURLY - { - result = new_iter nil, val[2], val[4] - self.env.unextend - } - - command: operation command_args =tLOWEST - { - result = new_call nil, val[0].to_sym, val[1] - } - | operation command_args cmd_brace_block - { - result = new_call nil, val[0].to_sym, val[1] - if val[2] then - if result[0] == :block_pass then - raise "both block arg and actual block given" - end - result, operation = val[2], result - result.insert 1, operation - end - } - | primary_value tDOT operation2 command_args =tLOWEST - { - result = new_call val[0], val[2].to_sym, val[3] - } - | primary_value tDOT operation2 command_args cmd_brace_block - { - result = new_call val[0], val[2].to_sym, val[3] - } - | primary_value tCOLON2 operation2 command_args =tLOWEST - { - result = new_call val[0], val[2].to_sym, val[3] - } - | primary_value tCOLON2 operation2 command_args cmd_brace_block - { - result = new_call val[0], val[2].to_sym, val[3] - if val[4] then - if result[0] == :block_pass then # REFACTOR - raise "both block arg and actual block given" - end - val[2] << result - result = val[2] - end - } - | kSUPER command_args - { - result = new_super val[1] - } - | kYIELD command_args - { - result = new_yield val[1] - } - - mlhs: mlhs_basic - | tLPAREN mlhs_entry tRPAREN - { - result = val[1] - } - - mlhs_entry: mlhs_basic - | tLPAREN mlhs_entry tRPAREN - { - result = s(:masgn, s(:array, val[1])) - } - - mlhs_basic: mlhs_head - { - result = s(:masgn, val[0]) - } - | mlhs_head mlhs_item - { - result = s(:masgn, val[0] << val[1].compact) - } - | mlhs_head tSTAR mlhs_node - { - result = s(:masgn, val[0] << s(:splat, val[2])) - } - | mlhs_head tSTAR - { - result = s(:masgn, val[0] << s(:splat)) - } - | tSTAR mlhs_node - { - result = s(:masgn, s(:array, s(:splat, val[1]))) - } - | tSTAR - { - result = s(:masgn, s(:array, s(:splat))) - } - - mlhs_item: mlhs_node - | tLPAREN mlhs_entry tRPAREN - { - result = val[1] - } - - mlhs_head: mlhs_item tCOMMA - { - result = s(:array, val[0]) - } - | mlhs_head mlhs_item tCOMMA - { - result = val[0] << val[1].compact - } - - mlhs_node: variable - { - result = self.assignable val[0] - } - | primary_value "[" aref_args tRBRACK - { - result = self.aryset val[0], val[2] - } - | primary_value tDOT tIDENTIFIER - { - result = s(:attrasgn, val[0], :"#{val[2]}=", s(:arglist)) - } - | primary_value tCOLON2 tIDENTIFIER - { - result = s(:attrasgn, val[0], :"#{val[2]}=", s(:arglist)) - } - | primary_value tDOT tCONSTANT - { - result = s(:attrasgn, val[0], :"#{val[2]}=", s(:arglist)) - } - | primary_value tCOLON2 tCONSTANT - { - if (self.in_def || self.in_single > 0) then - yyerror "dynamic constant assignment" - end - - result = s(:const, s(:colon2, val[0], val[2].to_sym), nil) - } - | tCOLON3 tCONSTANT - { - if (self.in_def || self.in_single > 0) then - yyerror "dynamic constant assignment" - end - - result = s(:const, nil, s(:colon3, val[1].to_sym)) - } - | backref - { - self.backref_assign_error val[0] - } - - lhs: variable - { - result = self.assignable val[0] - } - | primary_value "[" aref_args tRBRACK - { - result = self.aryset val[0], val[2] - } - | primary_value tDOT tIDENTIFIER - { - result = s(:attrasgn, val[0], :"#{val[2]}=") - } - | primary_value tCOLON2 tIDENTIFIER - { - result = s(:attrasgn, val[0], :"#{val[2]}=") - } - | primary_value tDOT tCONSTANT - { - result = s(:attrasgn, val[0], :"#{val[2]}=") - } - | primary_value tCOLON2 tCONSTANT - { - if (self.in_def || self.in_single > 0) then - yyerror "dynamic constant assignment" - end - - result = s(:const, s(:colon2, val[0], val[2].to_sym)) - } - | tCOLON3 tCONSTANT - { - if (self.in_def || self.in_single > 0) then - yyerror "dynamic constant assignment" - end - - result = s(:const, s(:colon3, val[1].to_sym)) - } - | backref - { - self.backref_assign_error val[0] - } - - cname: tIDENTIFIER - { - yyerror "class/module name must be CONSTANT" - } - | tCONSTANT - - cpath: tCOLON3 cname - { - result = s(:colon3, val[1].to_sym) - } - | cname - { - result = val[0].to_sym - } - | primary_value tCOLON2 cname - { - result = s(:colon2, val[0], val[2].to_sym) - } - - fname: tIDENTIFIER | tCONSTANT | tFID - | op - { - lexer.lex_state = :expr_end - result = val[0] - } - - | reswords - { - lexer.lex_state = :expr_end - result = val[0] - } - - # TODO: cruby has fsym and dsym - fitem: fname { result = s(:lit, val[0].to_sym) } - | symbol { result = s(:lit, val[0]) } - - undef_list: fitem - { - result = new_undef val[0] - } - | - undef_list tCOMMA - { - lexer.lex_state = :expr_fname - } - fitem - { - result = new_undef val[0], val[3] - } - - op: tPIPE | tCARET | tAMPER2 | tCMP | tEQ | tEQQ - | tMATCH | tGT | tGEQ | tLT | tLEQ | tLSHFT - | tRSHFT | tPLUS | tMINUS | tSTAR2 | tSTAR | tDIVIDE - | tPERCENT | tPOW | tTILDE | tUPLUS | tUMINUS | tAREF - | tASET | tBACK_REF2 - - reswords: k__LINE__ | k__FILE__ | klBEGIN | klEND | kALIAS | kAND - | kBEGIN | kBREAK | kCASE | kCLASS | kDEF | kDEFINED - | kDO | kELSE | kELSIF | kEND | kENSURE | kFALSE - | kFOR | kIN | kMODULE | kNEXT | kNIL | kNOT - | kOR | kREDO | kRESCUE | kRETRY | kRETURN | kSELF - | kSUPER | kTHEN | kTRUE | kUNDEF | kWHEN | kYIELD - | kIF_MOD | kUNLESS_MOD | kWHILE_MOD | kUNTIL_MOD | kRESCUE_MOD - - arg: lhs tEQL arg - { - result = self.node_assign val[0], val[2] - } - | lhs tEQL arg kRESCUE_MOD arg - { - result = self.node_assign val[0], s(:rescue, val[2], s(:resbody, s(:array), val[4])) - # result.line = val[0].line - } - | var_lhs tOP_ASGN arg - { - result = new_op_asgn val - } - | primary_value "[" aref_args tRBRACK tOP_ASGN arg - { - result = s(:op_asgn1, val[0], val[2], val[4].to_sym, val[5]) - val[2][0] = :arglist - } - | primary_value tDOT tIDENTIFIER tOP_ASGN arg - { - result = s(:op_asgn2, val[0], :"#{val[2]}=", val[3].to_sym, val[4]) - } - | primary_value tDOT tCONSTANT tOP_ASGN arg - { - result = s(:op_asgn2, val[0], :"#{val[2]}=", val[3].to_sym, val[4]) - } - | primary_value tCOLON2 tIDENTIFIER tOP_ASGN arg - { - result = s(:op_asgn, val[0], val[4], val[2], val[3]) - } - | primary_value tCOLON2 tCONSTANT tOP_ASGN arg - - { - yyerror "constant re-assignment" - } - | tCOLON3 tCONSTANT tOP_ASGN arg - { - yyerror "constant re-assignment" - } - | backref tOP_ASGN arg - { - self.backref_assign_error val[0] - } - | arg tDOT2 arg - { - v1, v2 = val[0], val[2] - if v1.node_type == :lit and v2.node_type == :lit and Fixnum === v1.last and Fixnum === v2.last then - result = s(:lit, (v1.last)..(v2.last)) - else - result = s(:dot2, v1, v2) - end - } - | arg tDOT3 arg - { - v1, v2 = val[0], val[2] - if v1.node_type == :lit and v2.node_type == :lit and Fixnum === v1.last and Fixnum === v2.last then - result = s(:lit, (v1.last)...(v2.last)) - else - result = s(:dot3, v1, v2) - end - } - | arg tPLUS arg - { - result = new_call val[0], :+, s(:arglist, val[2]) - } - | arg tMINUS arg - { - result = new_call val[0], :-, s(:arglist, val[2]) - } - | arg tSTAR2 arg - { - result = new_call val[0], :*, s(:arglist, val[2]) - } - | arg tDIVIDE arg - { - result = new_call val[0], :"/", s(:arglist, val[2]) - } - | arg tPERCENT arg - { - result = new_call val[0], :%, s(:arglist, val[2]) - } - | arg tPOW arg - { - result = new_call val[0], :**, s(:arglist, val[2]) - } - | tUMINUS_NUM tINTEGER tPOW arg - { - result = new_call(new_call(s(:lit, val[1]), :"**", s(:arglist, val[3])), :"-@", s(:arglist)) - } - | tUMINUS_NUM tFLOAT tPOW arg - { - result = new_call(new_call(s(:lit, val[1]), :"**", s(:arglist, val[3])), :"-@", s(:arglist)) - } - | tUPLUS arg - { - if val[1][0] == :lit then - result = val[1] - else - result = new_call val[1], :"+@", s(:arglist) - end - } - | tUMINUS arg - { - result = new_call val[1], :"-@", s(:arglist) - } - | arg tPIPE arg - { - result = new_call val[0], :"|", s(:arglist, val[2]) - } - | arg tCARET arg - { - result = new_call val[0], :"^", s(:arglist, val[2]) - } - | arg tAMPER2 arg - { - result = new_call val[0], :"&", s(:arglist, val[2]) - } - | arg tCMP arg - { - result = new_call val[0], :"<=>", s(:arglist, val[2]) - } - | arg tGT arg - { - result = new_call val[0], :">", s(:arglist, val[2]) - } - | arg tGEQ arg - { - result = new_call val[0], :">=", s(:arglist, val[2]) - } - | arg tLT arg - { - result = new_call val[0], :"<", s(:arglist, val[2]) - } - | arg tLEQ arg - { - result = new_call val[0], :"<=", s(:arglist, val[2]) - } - | arg tEQ arg - { - result = new_call val[0], :"==", s(:arglist, val[2]) - } - | arg tEQQ arg - { - result = new_call val[0], :"===", s(:arglist, val[2]) - } - | arg tNEQ arg - { - val[0] = value_expr val[0] # TODO: port call_op and clean these - val[2] = value_expr val[2] - result = s(:not, new_call(val[0], :"==", s(:arglist, val[2]))) - } - | arg tMATCH arg - { - result = self.get_match_node val[0], val[2] - } - | arg tNMATCH arg - { - result = s(:not, self.get_match_node(val[0], val[2])) - } - | tBANG arg - { - result = s(:not, val[1]) - } - | tTILDE arg - { - val[2] = value_expr val[2] - result = new_call val[1], :"~", s(:arglist) - } - | arg tLSHFT arg - { - val[0] = value_expr val[0] - val[2] = value_expr val[2] - result = new_call val[0], :"\<\<", s(:arglist, val[2]) - } - | arg tRSHFT arg - { - val[0] = value_expr val[0] - val[2] = value_expr val[2] - result = new_call val[0], :">>", s(:arglist, val[2]) - } - | arg tANDOP arg - { - result = logop(:and, val[0], val[2]) - } - | arg tOROP arg - { - result = logop(:or, val[0], val[2]) - } - | kDEFINED opt_nl arg - { - result = s(:defined, val[2]) - } - | arg tEH arg tCOLON arg - { - result = s(:if, val[0], val[2], val[4]) - } - | primary - - arg_value: arg - { - result = value_expr(val[0]) - } - - aref_args: none - | command opt_nl - { - warning 'parenthesize argument(s) for future version' - result = s(:array, val[0]) - } - | args trailer - { - result = val[0] - } - | args tCOMMA tSTAR arg opt_nl - { - result = self.arg_concat val[0], val[3] - } - | assocs trailer - { - result = s(:array, s(:hash, *val[0].values)) - } - | tSTAR arg opt_nl - { - result = s(:array, s(:splat, val[1])) - } - - paren_args: tLPAREN2 none tRPAREN - { - result = val[1] - } - | tLPAREN2 call_args opt_nl tRPAREN - { - result = val[1] - } - | tLPAREN2 block_call opt_nl tRPAREN - { - warning "parenthesize argument(s) for future version" - result = s(:array, val[1]) - } - | tLPAREN2 args tCOMMA block_call opt_nl tRPAREN - { - warning "parenthesize argument(s) for future version" - result = val[1].add val[3] - } - - opt_paren_args: none - | paren_args - - call_args: command - { - warning "parenthesize argument(s) for future version" - result = s(:array, val[0]) - } - | args opt_block_arg - { - result = self.arg_blk_pass val[0], val[1] - } - | args tCOMMA tSTAR arg_value opt_block_arg - { - result = self.arg_concat val[0], val[3] - result = self.arg_blk_pass result, val[4] - } - | assocs opt_block_arg - { - result = s(:array, s(:hash, *val[0].values)) - result = self.arg_blk_pass result, val[1] - } - | assocs tCOMMA tSTAR arg_value opt_block_arg - { - result = self.arg_concat s(:array, s(:hash, *val[0].values)), val[3] - result = self.arg_blk_pass result, val[4] - } - | args tCOMMA assocs opt_block_arg - { - result = val[0] << s(:hash, *val[2].values) - result = self.arg_blk_pass result, val[3] - } - | args tCOMMA assocs tCOMMA tSTAR arg opt_block_arg - { - val[0] << s(:hash, *val[2].values) - result = self.arg_concat val[0], val[5] - result = self.arg_blk_pass result, val[6] - } - | tSTAR arg_value opt_block_arg - { - result = self.arg_blk_pass s(:splat, val[1]), val[2] - } - | block_arg - - call_args2: arg_value tCOMMA args opt_block_arg - { - args = self.list_prepend val[0], val[2] - result = self.arg_blk_pass args, val[3] - } - | arg_value tCOMMA block_arg - { - result = self.arg_blk_pass val[0], val[2] - } - | arg_value tCOMMA tSTAR arg_value opt_block_arg - { - result = self.arg_concat s(:array, val[0]), val[3] - result = self.arg_blk_pass result, val[4] - } - | arg_value tCOMMA args tCOMMA tSTAR arg_value opt_block_arg - { - result = self.arg_concat s(:array, val[0], s(:hash, *val[2].values)), val[5] - result = self.arg_blk_pass result, val[6] - } - | assocs opt_block_arg - { - result = s(:array, s(:hash, *val[0].values)) - result = self.arg_blk_pass result, val[1] - } - | assocs tCOMMA tSTAR arg_value opt_block_arg - { - result = s(:array, s(:hash, *val[0].values), val[3]) - result = self.arg_blk_pass result, val[4] - } - | arg_value tCOMMA assocs opt_block_arg - { - result = s(:array, val[0], s(:hash, *val[2].values)) - result = self.arg_blk_pass result, val[3] - } - | arg_value tCOMMA args tCOMMA assocs opt_block_arg - { - result = s(:array, val[0]).add_all(val[2]).add(s(:hash, *val[4].values)) - result = self.arg_blk_pass result, val[5] - } - | arg_value tCOMMA assocs tCOMMA tSTAR arg_value opt_block_arg - { - result = self.arg_concat s(:array, val[0]).add(s(:hash, *val[2].values)), val[5] - result = self.arg_blk_pass result, val[6] - } - | arg_value tCOMMA args tCOMMA assocs tCOMMA tSTAR arg_value opt_block_arg - { - result = self.arg_concat s(:array, val[0]).add_all(val[2]).add(s(:hash, *val[4].values)), val[7] - result = self.arg_blk_pass result, val[8] - } - | tSTAR arg_value opt_block_arg - { - result = self.arg_blk_pass s(:splat, val[1]), val[2] - } - | block_arg - - command_args: { - result = lexer.cmdarg.stack.dup - lexer.cmdarg.push true - } - open_args - { - lexer.cmdarg.stack.replace val[0] - result = val[1] - } - - open_args: call_args - | tLPAREN_ARG - { - lexer.lex_state = :expr_endarg - } - tRPAREN - { - warning "don't put space before argument parentheses" - result = nil - } - | tLPAREN_ARG call_args2 - { - lexer.lex_state = :expr_endarg - } - tRPAREN - { - warning "don't put space before argument parentheses" - result = val[1] - } - - block_arg: tAMPER arg_value - { - result = s(:block_pass, val[1]) - } - - opt_block_arg: tCOMMA block_arg - { - result = val[1] - } - | none_block_pass - - args: arg_value - { - result = s(:array, val[0]) - } - | args tCOMMA arg_value - { - result = self.list_append val[0], val[2] - } - - mrhs: args tCOMMA arg_value - { - result = val[0] << val[2] - } - | args tCOMMA tSTAR arg_value - { - result = self.arg_concat val[0], val[3] - } - | tSTAR arg_value - { - result = s(:splat, val[1]) - } - - primary: literal - | strings - | xstring - | regexp - | words - | awords - | var_ref - | backref - | tFID - { - result = new_call nil, val[0].to_sym - } - | kBEGIN - { - result = self.lexer.lineno - } - bodystmt kEND - { - unless val[2] then - result = s(:nil) - else - result = s(:begin, val[2]) - end - - result.line = val[1] - } - | tLPAREN_ARG expr - { - lexer.lex_state = :expr_endarg - } - opt_nl tRPAREN - { - warning "(...) interpreted as grouped expression" - result = val[1] - } - | tLPAREN compstmt tRPAREN - { - result = val[1] || s(:nil) - result.paren = true - } - | primary_value tCOLON2 tCONSTANT - { - result = s(:colon2, val[0], val[2].to_sym) - } - | tCOLON3 tCONSTANT - { - result = s(:colon3, val[1].to_sym) - } - | primary_value "[" aref_args tRBRACK - { - result = new_aref val - } - | tLBRACK aref_args tRBRACK - { - result = val[1] || s(:array) - } - | tLBRACE assoc_list tRCURLY - { - result = s(:hash, *val[1].values) - } - | kRETURN - { - result = s(:return) - } - | kYIELD tLPAREN2 call_args tRPAREN - { - result = new_yield val[2] - } - | kYIELD tLPAREN2 tRPAREN - { - result = new_yield - } - | kYIELD - { - result = new_yield - } - | kDEFINED opt_nl tLPAREN2 expr tRPAREN - { - result = s(:defined, val[3]) - } - | operation brace_block - { - oper, iter = val[0], val[1] - call = new_call(nil, oper.to_sym) - iter.insert 1, call - result = iter - call.line ||= iter.line - } - | method_call - | method_call brace_block - { - call, iter = val[0], val[1] - iter.insert 1, call - result = iter - } - | kIF expr_value then compstmt if_tail kEND - { - result = new_if val[1], val[3], val[4] - } - | kUNLESS expr_value then compstmt opt_else kEND - { - result = new_if val[1], val[4], val[3] - } - | kWHILE - { - lexer.cond.push true - } - expr_value do - { - lexer.cond.pop - } - compstmt kEND - { - result = new_while val[5], val[2], true - } - | kUNTIL - { - lexer.cond.push true - } - expr_value do - { - lexer.cond.pop - } - compstmt kEND - { - result = new_until val[5], val[2], true - } - | kCASE expr_value opt_terms case_body kEND - { - result = new_case val[1], val[3] - } - | kCASE opt_terms case_body kEND - { - result = new_case nil, val[2] - } - | kCASE opt_terms kELSE compstmt kEND # TODO: need a test - { - result = new_case nil, val[3] - } - | kFOR block_var kIN - { - lexer.cond.push true - } - expr_value do - { - lexer.cond.pop - } - compstmt kEND - { - result = new_for val[4], val[1], val[7] - } - | kCLASS - { - result = self.lexer.lineno - } - cpath superclass - { - self.comments.push self.lexer.comments - if (self.in_def || self.in_single > 0) then - yyerror "class definition in method body" - end - self.env.extend - } - bodystmt kEND - { - result = new_class val - self.env.unextend - } - | kCLASS tLSHFT - { - result = self.lexer.lineno - } - expr - { - result = self.in_def - self.in_def = false - } - term - { - result = self.in_single - self.in_single = 0 - self.env.extend - } - bodystmt kEND - { - result = new_sclass val - self.env.unextend - } - | kMODULE - { - result = self.lexer.lineno - } - cpath - { - self.comments.push self.lexer.comments - yyerror "module definition in method body" if - self.in_def or self.in_single > 0 - - self.env.extend - } - bodystmt kEND - { - result = new_module val - self.env.unextend - } - | kDEF fname - { - self.comments.push self.lexer.comments - self.in_def = true - self.env.extend - result = lexer.lineno, lexer.src.beginning_of_line? - } - f_arglist bodystmt kEND - { - result = new_defn val - self.env.unextend - self.in_def = false - } - | kDEF singleton dot_or_colon - { - self.comments.push self.lexer.comments - lexer.lex_state = :expr_fname - } - fname - { - self.in_single += 1 - self.env.extend - lexer.lex_state = :expr_end # force for args - } - f_arglist bodystmt kEND - { - result = new_defs val - - self.env.unextend - self.in_single -= 1 - } - | kBREAK - { - result = s(:break) - } - | kNEXT - { - result = s(:next) - } - | kREDO - { - result = s(:redo) - } - | kRETRY - { - result = s(:retry) - } - - primary_value: primary - { - result = value_expr(val[0]) - } - - then: term - | tCOLON - | kTHEN - | term kTHEN - - do: term - | tCOLON - | kDO_COND - - if_tail: opt_else - | kELSIF expr_value then compstmt if_tail - { - result = s(:if, val[1], val[3], val[4]) - } - - opt_else: none - | kELSE compstmt - { - result = val[1] - } - - block_var: lhs - | mlhs - { - val[0].delete_at 1 if val[0][1].nil? # HACK - } - - opt_block_var: none - | tPIPE tPIPE - { - result = 0 - } - | tOROP - { - result = 0 - } - | tPIPE block_var tPIPE - { - result = val[1] - } - - do_block: kDO_BLOCK - { - self.env.extend :dynamic - } - opt_block_var - { - result = self.env.dynamic.keys - } - compstmt kEND - { - vars = val[2] - body = val[4] - result = new_iter nil, vars, body - - self.env.unextend - } - - block_call: command do_block - { - raise SyntaxError, "Both block arg and actual block given." if - val[0] && val[0][0] == :blockpass - - result = val[1] - result.insert 1, val[0] - } - | block_call tDOT operation2 opt_paren_args - { - result = new_call val[0], val[2], val[3] - } - | block_call tCOLON2 operation2 opt_paren_args - { - result = new_call val[0], val[2], val[3] - } - - method_call: operation - { - result = self.lexer.lineno - } - paren_args - { - result = new_call nil, val[0].to_sym, val[2] - } - | primary_value tDOT operation2 opt_paren_args - { - result = new_call val[0], val[2].to_sym, val[3] - } - | primary_value tCOLON2 operation2 paren_args - { - result = new_call val[0], val[2].to_sym, val[3] - } - | primary_value tCOLON2 operation3 - { - result = new_call val[0], val[2].to_sym - } - | kSUPER paren_args - { - result = new_super val[1] - } - | kSUPER - { - result = s(:zsuper) - } - - brace_block: tLCURLY - { - self.env.extend :dynamic - result = self.lexer.lineno - } - opt_block_var - { - result = self.env.dynamic.keys - } - compstmt tRCURLY - { - # REFACTOR - args = val[2] - body = val[4] - result = new_iter nil, args, body - self.env.unextend - result.line = val[1] - } - | kDO - { - self.env.extend :dynamic - result = self.lexer.lineno - } - opt_block_var - { - result = self.env.dynamic.keys - } - compstmt kEND - { - args = val[2] - body = val[4] - result = new_iter nil, args, body - self.env.unextend - result.line = val[1] - } - - case_body: kWHEN - { - result = self.lexer.lineno - } - when_args then compstmt cases - { - result = s(:when, val[2], val[4]) - result.line = val[1] - result << val[5] if val[5] - } - - when_args: args - | args tCOMMA tSTAR arg_value - { - result = self.list_append val[0], s(:when, val[3], nil) - } - | tSTAR arg_value - { - result = s(:array, s(:when, val[1], nil)) - } - - cases: opt_else | case_body - - opt_rescue: kRESCUE exc_list exc_var then compstmt opt_rescue - { - klasses, var, body, rest = val[1], val[2], val[4], val[5] - - klasses ||= s(:array) - klasses << node_assign(var, s(:gvar, :"$!")) if var - - result = s(:resbody, klasses, body) - result << rest if rest # UGH, rewritten above - } - | - { - result = nil - } - - exc_list: arg_value - { - result = s(:array, val[0]) - } - | mrhs - | none - - exc_var: tASSOC lhs - { - result = val[1] - } - | none - - opt_ensure: kENSURE compstmt - { - if (val[1] != nil) then - result = val[1] - else - result = s(:nil) - end - } - | none - - literal: numeric { result = s(:lit, val[0]) } - | symbol { result = s(:lit, val[0]) } - | dsym - - strings: string - { - val[0] = s(:dstr, val[0].value) if val[0][0] == :evstr - result = val[0] - } - - string: string1 - | string string1 - { - result = self.literal_concat val[0], val[1] - } - - string1: tSTRING_BEG string_contents tSTRING_END - { - result = val[1] - } - | tSTRING - { - result = s(:str, val[0]) - } - - xstring: tXSTRING_BEG xstring_contents tSTRING_END - { - result = new_xstring val[1] - } - - regexp: tREGEXP_BEG xstring_contents tREGEXP_END - { - result = new_regexp val - } - - words: tWORDS_BEG tSPACE tSTRING_END - { - result = s(:array) - } - | tWORDS_BEG word_list tSTRING_END - { - result = val[1] - } - - word_list: none - { - result = s(:array) - } - | word_list word tSPACE - { - word = val[1][0] == :evstr ? s(:dstr, "", val[1]) : val[1] - result = val[0] << word - } - - word: string_content - | word string_content - { - result = self.literal_concat val[0], val[1] - } - - awords: tAWORDS_BEG tSPACE tSTRING_END - { - result = s(:array) - } - | tAWORDS_BEG qword_list tSTRING_END - { - result = val[1] - } - - qword_list: none - { - result = s(:array) - } - | qword_list tSTRING_CONTENT tSPACE - { - result = val[0] << s(:str, val[1]) - } - - string_contents: none - { - result = s(:str, "") - } - | string_contents string_content - { - result = literal_concat(val[0], val[1]) - } - -xstring_contents: none - { - result = nil - } - | xstring_contents string_content - { - result = literal_concat(val[0], val[1]) - } - - string_content: tSTRING_CONTENT - { - result = s(:str, val[0]) - } - | tSTRING_DVAR - { - result = lexer.lex_strterm - lexer.lex_strterm = nil - lexer.lex_state = :expr_beg - } - string_dvar - { - lexer.lex_strterm = val[1] - result = s(:evstr, val[2]) - } - | tSTRING_DBEG - { - result = lexer.lex_strterm - lexer.lex_strterm = nil - lexer.lex_state = :expr_beg - lexer.cond.push false - lexer.cmdarg.push false - } - compstmt tRCURLY - { - lexer.lex_strterm = val[1] - lexer.cond.lexpop - lexer.cmdarg.lexpop - - case val[2] - when Sexp then - case val[2][0] - when :str, :dstr, :evstr then - result = val[2] - else - result = s(:evstr, val[2]) - end - when nil then - result = s(:evstr) - else - raise "unknown rescue body: #{val[2].inspect}" - end - } - - string_dvar: tGVAR { result = s(:gvar, val[0].to_sym) } - | tIVAR { result = s(:ivar, val[0].to_sym) } - | tCVAR { result = s(:cvar, val[0].to_sym) } - | backref - - - symbol: tSYMBEG sym - { - lexer.lex_state = :expr_end - result = val[1].to_sym - } - | tSYMBOL - { - result = val[0].to_sym - } - - sym: fname | tIVAR | tGVAR | tCVAR - - dsym: tSYMBEG xstring_contents tSTRING_END - { - lexer.lex_state = :expr_end - result = val[1] - - yyerror "empty symbol literal" if - result.nil? or result.empty? - - case result[0] - when :dstr then - result[0] = :dsym - when :str then - result = s(:lit, result.last.intern) - else - result = s(:dsym, "", result) - end - } - - numeric: tINTEGER - | tFLOAT - | tUMINUS_NUM tINTEGER =tLOWEST - { - result = -val[1] # TODO: pt_testcase - } - | tUMINUS_NUM tFLOAT =tLOWEST - { - result = -val[1] # TODO: pt_testcase - } - - variable: tIDENTIFIER - | tIVAR - | tGVAR - | tCONSTANT - | tCVAR - | kNIL { result = :nil } - | kSELF { result = :self } - | kTRUE { result = :true } - | kFALSE { result = :false } - | k__FILE__ { result = :__FILE__ } - | k__LINE__ { result = :__LINE__ } - - var_ref: variable - { - result = self.gettable val[0] - } - - var_lhs: variable - { - result = self.assignable val[0] - } - - backref: tNTH_REF { result = s(:nth_ref, val[0]) } - | tBACK_REF { result = s(:back_ref, val[0]) } - - superclass: term - { - result = nil - } - | tLT - { - lexer.lex_state = :expr_beg - } - expr_value term - { - result = val[2] - } - | error term - { - yyerrok - result = nil - } - - f_arglist: tLPAREN2 f_args opt_nl tRPAREN - { - result = val[1] - lexer.lex_state = :expr_beg - } - | f_args term - { - result = val[0] - } - - f_args: f_arg tCOMMA f_optarg tCOMMA f_rest_arg opt_f_block_arg - { - result = args val[0], val[2], val[4], val[5] - } - | f_arg tCOMMA f_optarg opt_f_block_arg - { - result = args val[0], val[2], nil, val[3] - } - | f_arg tCOMMA f_rest_arg opt_f_block_arg - { - result = args val[0], nil, val[2], val[3] - } - | f_arg opt_f_block_arg - { - result = args val[0], nil, nil, val[1] - } - | f_optarg tCOMMA f_rest_arg opt_f_block_arg - { - result = args nil, val[0], val[2], val[3] - } - | f_optarg opt_f_block_arg - { - result = args nil, val[0], nil, val[1] - } - | f_rest_arg opt_f_block_arg - { - result = args nil, nil, val[0], val[1] - } - | f_block_arg - { - result = args nil, nil, nil, val[0] - } - | - { - result = args nil, nil, nil, nil - } - - f_norm_arg: tCONSTANT - { - yyerror "formal argument cannot be a constant: #{val[0]}" - } - | tIVAR - { - yyerror "formal argument cannot be an instance variable" - } - | tCVAR - { - yyerror "formal argument cannot be a class variable" - } - | tIDENTIFIER - { - identifier = val[0].to_sym - self.env[identifier] = :lvar - - result = val[0] - } - - f_arg: f_norm_arg - { - result = s(:args) - result << val[0].to_sym - } - | f_arg tCOMMA f_norm_arg - { - val[0] << val[2].to_sym - result = val[0] - } - - f_opt: tIDENTIFIER tEQL arg_value - { - result = self.assignable val[0], val[2] - # TODO: detect duplicate names - } - - f_optarg: f_opt - { - result = s(:block, val[0]) - } - | f_optarg tCOMMA f_opt - { - result = self.append_to_block val[0], val[2] - } - - restarg_mark: tSTAR2 | tSTAR - - f_rest_arg: restarg_mark tIDENTIFIER - { - # TODO: differs from parse.y - needs tests - name = val[1].to_sym - self.assignable name - result = :"*#{name}" - } - | restarg_mark - { - name = :"*" - self.env[name] = :lvar - result = name - } - - blkarg_mark: tAMPER2 | tAMPER - - f_block_arg: blkarg_mark tIDENTIFIER - { - identifier = val[1].to_sym - - self.env[identifier] = :lvar - result = s(:block_arg, identifier.to_sym) - } - - opt_f_block_arg: tCOMMA f_block_arg - { - result = val[1] - } - | - { - result = nil - } - - singleton: var_ref - | tLPAREN2 - { - lexer.lex_state = :expr_beg - } - expr opt_nl tRPAREN - { - result = val[2] - yyerror "Can't define single method for literals." if - result[0] == :lit - } - - assoc_list: none # [!nil] - { - result = s(:array) - } - | assocs trailer # [!nil] - { - result = val[0] - } - | args trailer - { - size = val[0].size - if (size % 2 != 1) then # != 1 because of leading :array - yyerror "Odd number (#{size}) list for Hash. #{val[0].inspect}" - end - result = val[0] - } - - assocs: assoc - | assocs tCOMMA assoc - { - list = val[0].dup - more = val[2][1..-1] - list.push(*more) unless more.empty? - result = list - } - - assoc: arg_value tASSOC arg_value - { - result = s(:array, val[0], val[2]) - } - - operation: tIDENTIFIER | tCONSTANT | tFID - operation2: tIDENTIFIER | tCONSTANT | tFID | op - operation3: tIDENTIFIER | tFID | op - dot_or_colon: tDOT | tCOLON2 - opt_terms: | terms - opt_nl: | tNL - trailer: | tNL | tCOMMA - - term: tSEMI { yyerrok } - | tNL - - terms: term - | terms tSEMI { yyerrok } - - none: { result = nil } - - none_block_pass: { result = nil } - -end - ----- inner - -require "ruby_lexer" -require "ruby_parser_extras" - -# Local Variables: ** -# racc-token-length-max:14 ** -# End: ** diff --git a/vendor/gems/ruby_parser-2.0.5/lib/ruby_parser_extras.rb b/vendor/gems/ruby_parser-2.0.5/lib/ruby_parser_extras.rb deleted file mode 100644 index 54893f069fb..00000000000 --- a/vendor/gems/ruby_parser-2.0.5/lib/ruby_parser_extras.rb +++ /dev/null @@ -1,1030 +0,0 @@ -require 'stringio' -require 'racc/parser' -require 'sexp' -require 'strscan' - -# WHY do I have to do this?!? -class Regexp - unless defined? ONCE then - ONCE = 0 # 16 # ? - ENC_NONE = /x/n.options - ENC_EUC = /x/e.options - ENC_SJIS = /x/s.options - ENC_UTF8 = /x/u.options - end -end - -# I hate ruby 1.9 string changes -class Fixnum - def ord - self - end -end unless "a"[0] == "a" - -class RPStringScanner < StringScanner -# if ENV['TALLY'] then -# alias :old_getch :getch -# def getch -# warn({:getch => caller[0]}.inspect) -# old_getch -# end -# end - - def current_line # HAHA fuck you (HACK) - string[0..pos][/\A.*__LINE__/m].split(/\n/).size - end - - def lineno - string[0...pos].count("\n") + 1 - end - - # TODO: once we get rid of these, we can make things like - # TODO: current_line and lineno much more accurate and easy to do - def unread c # TODO: remove this entirely - we should not need it - return if c.nil? # UGH - warn({:unread => caller[0]}.inspect) if ENV['TALLY'] - string[pos, 0] = c - end - - def unread_many str # TODO: remove this entirely - we should not need it - warn({:unread_many => caller[0]}.inspect) if ENV['TALLY'] - string[pos, 0] = str - end - - def begin_of_line? - pos == 0 or string[pos-1] == ?\n - end - - def was_begin_of_line # TODO: kill me - pos <= 2 or string[pos-2] == ?\n - end - - if ENV['DEBUG'] then - alias :old_getch :getch - def getch - c = self.old_getch - p :getch => [c, caller.first] - c - end - - alias :old_scan :scan - def scan re - s = old_scan re - p :scan => [s, caller.first] if s - s - end - end - - # TODO: - # def last_line(src) - # if n = src.rindex("\n") - # src[(n+1) .. -1] - # else - # src - # end - # end - # private :last_line - - # def next_words_on_error - # if n = @src.rest.index("\n") - # @src.rest[0 .. (n-1)] - # else - # @src.rest - # end - # end - - # def prev_words_on_error(ev) - # pre = @pre - # if ev and /#{Regexp.quote(ev)}$/ =~ pre - # pre = $` - # end - # last_line(pre) - # end - - # def on_error(et, ev, values) - # lines_of_rest = @src.rest.to_a.length - # prev_words = prev_words_on_error(ev) - # at = 4 + prev_words.length - # message = <<-MSG - # RD syntax error: line #{@blockp.line_index - lines_of_rest}: - # ...#{prev_words} #{(ev||'')} #{next_words_on_error()} ... - # MSG - # message << " " * at + "^" * (ev ? ev.length : 0) + "\n" - # raise ParseError, message - # end -end - -class RubyParser < Racc::Parser - VERSION = '2.0.5' unless constants.include? "VERSION" # SIGH - - attr_accessor :lexer, :in_def, :in_single, :file - attr_reader :env, :comments - - def append_to_block head, tail # FIX: wtf is this?!? switch to block_append - return head if tail.nil? - return tail if head.nil? - - head = s(:block, head) unless head.node_type == :block - head << tail - head - end - - def arg_add(node1, node2) # TODO: nuke - return s(:arglist, node2) unless node1 - - node1[0] = :arglist if node1[0] == :array - return node1 << node2 if node1[0] == :arglist - - return s(:arglist, node1, node2) - end - - def arg_blk_pass node1, node2 # TODO: nuke - node1 = s(:arglist, node1) unless [:arglist, :array].include? node1.first - node1 << node2 if node2 - node1 - end - - def arg_concat node1, node2 # TODO: nuke - raise "huh" unless node2 - node1 << s(:splat, node2).compact - node1 - end - - def args arg, optarg, rest_arg, block_arg - arg ||= s(:args) - - result = arg - if optarg then - optarg[1..-1].each do |lasgn| # FIX clean sexp iter - raise "wtf? #{lasgn.inspect}" unless lasgn[0] == :lasgn - result << lasgn[1] - end - end - - result << rest_arg if rest_arg - result << :"&#{block_arg.last}" if block_arg - result << optarg if optarg # TODO? huh - processed above as well - - result - end - - def aryset receiver, index - index[0] = :arglist if index[0] == :array - s(:attrasgn, receiver, :"[]=", index) - end - - def assignable(lhs, value = nil) - id = lhs.to_sym - id = id.to_sym if Sexp === id - - raise SyntaxError, "Can't change the value of #{id}" if - id.to_s =~ /^(?:self|nil|true|false|__LINE__|__FILE__)$/ - - result = case id.to_s - when /^@@/ then - asgn = in_def || in_single > 0 - s((asgn ? :cvasgn : :cvdecl), id) - when /^@/ then - s(:iasgn, id) - when /^\$/ then - s(:gasgn, id) - when /^[A-Z]/ then - s(:cdecl, id) - else - case self.env[id] - when :lvar then - s(:lasgn, id) - when :dvar, nil then - if self.env.current[id] == :dvar then - s(:lasgn, id) - elsif self.env[id] == :dvar then - self.env.use(id) - s(:lasgn, id) - elsif ! self.env.dynamic? then - s(:lasgn, id) - else - s(:lasgn, id) - end - else - raise "wtf? unknown type: #{self.env[id]}" - end - end - - self.env[id] ||= :lvar - - result << value if value - - return result - end - - def block_append(head, tail, strip_tail_block=false) - return head unless tail - return tail unless head - - case head[0] - when :lit, :str then - return tail - end - - line = [head.line, tail.line].compact.min - - head = remove_begin(head) - head = s(:block, head) unless head[0] == :block - - if strip_tail_block and Sexp === tail and tail[0] == :block then - head.push(*tail.values) - else - head << tail - end - - head.line = line - head - end - - def cond node - return nil if node.nil? - node = value_expr node - - case node.first - when :lit then - if Regexp === node.last then - return s(:match, node) - else - return node - end - when :and then - return s(:and, cond(node[1]), cond(node[2])) - when :or then - return s(:or, cond(node[1]), cond(node[2])) - when :dot2 then - label = "flip#{node.hash}" - env[label] = :lvar - return s(:flip2, node[1], node[2]) - when :dot3 then - label = "flip#{node.hash}" - env[label] = :lvar - return s(:flip3, node[1], node[2]) - else - return node - end - end - - ## - # for pure ruby systems only - - def do_parse - _racc_do_parse_rb(_racc_setup, false) - end if ENV['PURE_RUBY'] - - def get_match_node lhs, rhs # TODO: rename to new_match - if lhs then - case lhs[0] - when :dregx, :dregx_once then - return s(:match2, lhs, rhs).line(lhs.line) - when :lit then - return s(:match2, lhs, rhs).line(lhs.line) if Regexp === lhs.last - end - end - - if rhs then - case rhs[0] - when :dregx, :dregx_once then - return s(:match3, rhs, lhs).line(lhs.line) - when :lit then - return s(:match3, rhs, lhs).line(lhs.line) if Regexp === rhs.last - end - end - - return s(:call, lhs, :"=~", s(:arglist, rhs)).line(lhs.line) - end - - def gettable(id) - raise "no: #{id.inspect}" if Sexp === id - id = id.to_sym if Sexp === id # HACK - id = id.to_sym if String === id # HACK - - return s(:self) if id == :self - return s(:nil) if id == :nil - return s(:true) if id == :true - return s(:false) if id == :false - return s(:str, self.file) if id == :"__FILE__" - return s(:lit, lexer.src.current_line) if id == :"__LINE__" - - result = case id.to_s - when /^@@/ then - s(:cvar, id) - when /^@/ then - s(:ivar, id) - when /^\$/ then - s(:gvar, id) - when /^[A-Z]/ then - s(:const, id) - else - type = env[id] - if type then - s(type, id) - elsif env.dynamic? and :dvar == env[id] then - s(:lvar, id) - else - s(:call, nil, id, s(:arglist)) - end - end - - return result if result - - raise "identifier #{id.inspect} is not valid" - end - - def initialize - super - self.lexer = RubyLexer.new - self.lexer.parser = self - @env = RBEnvironment.new - @comments = [] - - self.reset - end - - def list_append list, item # TODO: nuke me *sigh* - return s(:array, item) unless list - list = s(:array, list) unless Sexp === list && list.first == :array - list << item - end - - def list_prepend item, list # TODO: nuke me *sigh* - list = s(:array, list) unless Sexp === list && list[0] == :array - list.insert 1, item - list - end - - def literal_concat head, tail - return tail unless head - return head unless tail - - htype, ttype = head[0], tail[0] - - head = s(:dstr, '', head) if htype == :evstr - - case ttype - when :str then - if htype == :str - head[-1] << tail[-1] - elsif htype == :dstr and head.size == 2 then - head[-1] << tail[-1] - else - head << tail - end - when :dstr then - if htype == :str then - tail[1] = head[-1] + tail[1] - head = tail - else - tail[0] = :array - tail[1] = s(:str, tail[1]) - tail.delete_at 1 if tail[1] == s(:str, '') - - head.push(*tail[1..-1]) - end - when :evstr then - head[0] = :dstr if htype == :str - if head.size == 2 and tail.size > 1 and tail[1][0] == :str then - head[-1] << tail[1][-1] - head[0] = :str if head.size == 2 # HACK ? - else - head.push(tail) - end - else - x = [head, tail] - raise "unknown type: #{x.inspect}" - end - - return head - end - - def logop(type, left, right) # TODO: rename logical_op - left = value_expr left - - if left and left[0] == type and not left.paren then - node, second = left, nil - - while (second = node[2]) && second[0] == type and not second.paren do - node = second - end - - node[2] = s(type, second, right) - - return left - end - - return s(type, left, right) - end - - def new_aref val - val[2] ||= s(:arglist) - val[2][0] = :arglist if val[2][0] == :array # REFACTOR - if val[0].node_type == :self then - result = new_call nil, :"[]", val[2] - else - result = new_call val[0], :"[]", val[2] - end - result - end - - def new_body val - result = val[0] - - if val[1] then - result = s(:rescue) - result << val[0] if val[0] - - resbody = val[1] - - while resbody do - result << resbody - resbody = resbody.resbody(true) - end - - result << val[2] if val[2] - - result.line = (val[0] || val[1]).line - elsif not val[2].nil? then - warning("else without rescue is useless") - result = block_append(result, val[2]) - end - - result = s(:ensure, result, val[3]).compact if val[3] - return result - end - - def new_call recv, meth, args = nil - result = s(:call, recv, meth) - result.line = recv.line if recv - - args ||= s(:arglist) - args[0] = :arglist if args.first == :array - args = s(:arglist, args) unless args.first == :arglist - result << args - result - end - - def new_case expr, body - result = s(:case, expr) - line = (expr || body).line - - while body and body.node_type == :when - result << body - body = body.delete_at 3 - end - - # else - body = nil if body == s(:block) - result << body - - result.line = line - result - end - - def new_class val - line, path, superclass, body = val[1], val[2], val[3], val[5] - scope = s(:scope, body).compact - result = s(:class, path, superclass, scope) - result.line = line - result.comments = self.comments.pop - result - end - - def new_compstmt val - result = void_stmts(val[0]) - result = remove_begin(result) if result - result - end - - def new_defn val - (line, bol), name, args, body = val[2], val[1], val[3], val[4] - body ||= s(:nil) - - body ||= s(:block) - body = s(:block, body) unless body.first == :block - - result = s(:defn, name.to_sym, args, s(:scope, body)) - result.line = line - result.line -= 1 if bol - result.comments = self.comments.pop - result - end - - def new_defs val - recv, name, args, body = val[1], val[4], val[6], val[7] - - body ||= s(:block) - body = s(:block, body) unless body.first == :block - - result = s(:defs, recv, name.to_sym, args, s(:scope, body)) - result.line = recv.line - result.comments = self.comments.pop - result - end - - def new_for expr, var, body - result = s(:for, expr, var).line(var.line) - result << body if body - result - end - - def new_if c, t, f - l = [c.line, t && t.line, f && f.line].compact.min - c = cond c - c, t, f = c.last, f, t if c[0] == :not - s(:if, c, t, f).line(l) - end - - def new_iter call, args, body - result = s(:iter) - result << call if call - result << args - result << body if body - result - end - - def new_masgn lhs, rhs, wrap = false - rhs = value_expr(rhs) - rhs = lhs[1] ? s(:to_ary, rhs) : s(:array, rhs) if wrap - - lhs.delete_at 1 if lhs[1].nil? - lhs << rhs - - lhs - end - - def new_module val - line, path, body = val[1], val[2], val[4] - body = s(:scope, body).compact - result = s(:module, path, body) - result.line = line - result.comments = self.comments.pop - result - end - - def new_op_asgn val - lhs, asgn_op, arg = val[0], val[1].to_sym, val[2] - name = lhs.value - arg = remove_begin(arg) - result = case asgn_op # REFACTOR - when :"||" then - lhs << arg - s(:op_asgn_or, self.gettable(name), lhs) - when :"&&" then - lhs << arg - s(:op_asgn_and, self.gettable(name), lhs) - else - # TODO: why [2] ? - lhs[2] = new_call(self.gettable(name), asgn_op, - s(:arglist, arg)) - lhs - end - result.line = lhs.line - result - end - - def new_regexp val - node = val[1] || s(:str, '') - options = val[2] - - o, k = 0, nil - options.split(//).uniq.each do |c| # FIX: this has a better home - v = { - 'x' => Regexp::EXTENDED, - 'i' => Regexp::IGNORECASE, - 'm' => Regexp::MULTILINE, - 'o' => Regexp::ONCE, - 'n' => Regexp::ENC_NONE, - 'e' => Regexp::ENC_EUC, - 's' => Regexp::ENC_SJIS, - 'u' => Regexp::ENC_UTF8, - }[c] - raise "unknown regexp option: #{c}" unless v - o += v - k = c if c =~ /[esu]/ - end - - case node[0] - when :str then - node[0] = :lit - node[1] = if k then - Regexp.new(node[1], o, k) - else - Regexp.new(node[1], o) - end - when :dstr then - if options =~ /o/ then - node[0] = :dregx_once - else - node[0] = :dregx - end - node << o if o and o != 0 - else - node = s(:dregx, '', node); - node[0] = :dregx_once if options =~ /o/ - node << o if o and o != 0 - end - - node - end - - def new_sclass val - recv, in_def, in_single, body = val[3], val[4], val[6], val[7] - scope = s(:scope, body).compact - result = s(:sclass, recv, scope) - result.line = val[2] - self.in_def = in_def - self.in_single = in_single - result - end - - def new_super args - if args && args.node_type == :block_pass then - s(:super, args) - else - args ||= s(:arglist) - s(:super, *args[1..-1]) - end - end - - def new_undef n, m = nil - if m then - block_append(n, s(:undef, m)) - else - s(:undef, n) - end - end - - def new_until block, expr, pre - expr = (expr.first == :not ? expr.last : s(:not, expr)).line(expr.line) - new_while block, expr, pre - end - - def new_while block, expr, pre - line = [block && block.line, expr.line].compact.min - block, pre = block.last, false if block && block[0] == :begin - - expr = cond expr - result = if expr.first == :not then - s(:until, expr.last, block, pre) - else - s(:while, expr, block, pre) - end - - result.line = line - result - end - - def new_xstring str - if str then - case str[0] - when :str - str[0] = :xstr - when :dstr - str[0] = :dxstr - else - str = s(:dxstr, '', str) - end - str - else - s(:xstr, '') - end - end - - def new_yield args = nil - # TODO: raise args.inspect unless [:arglist].include? args.first # HACK - raise SyntaxError, "Block argument should not be given." if - args && args.node_type == :block_pass - - args ||= s(:arglist) - - # TODO: I can prolly clean this up - args[0] = :arglist if args.first == :array - args = s(:arglist, args) unless args.first == :arglist - - return s(:yield, *args[1..-1]) - end - - def next_token - if self.lexer.advance then - return self.lexer.token, self.lexer.yacc_value - else - return [false, '$end'] - end - end - - def node_assign(lhs, rhs) # TODO: rename new_assign - return nil unless lhs - - rhs = value_expr rhs - - case lhs[0] - when :gasgn, :iasgn, :lasgn, :dasgn, :dasgn_curr, - :masgn, :cdecl, :cvdecl, :cvasgn then - lhs << rhs - when :attrasgn, :call then - args = lhs.pop unless Symbol === lhs.last - lhs << arg_add(args, rhs) - when :const then - lhs[0] = :cdecl - lhs << rhs - else - raise "unknown lhs #{lhs.inspect}" - end - - lhs - end - - def process(str, file = "(string)") - raise "bad val: #{str.inspect}" unless String === str - - self.file = file - self.lexer.src = str - - @yydebug = ENV.has_key? 'DEBUG' - - do_parse - end - alias :parse :process - - def remove_begin node - oldnode = node - if node and :begin == node[0] and node.size == 2 then - node = node[-1] - node.line = oldnode.line - end - node - end - - def reset - lexer.reset - self.in_def = false - self.in_single = 0 - self.env.reset - self.comments.clear - end - - def ret_args node - if node then - raise SyntaxError, "block argument should not be given" if - node[0] == :block_pass - - node = node.last if node[0] == :array && node.size == 2 - # HACK matz wraps ONE of the FOUR splats in a newline to - # distinguish. I use paren for now. ugh - node = s(:svalue, node) if node[0] == :splat and not node.paren - node[0] = :svalue if node[0] == :arglist && node[1][0] == :splat - end - - node - end - - def s(*args) - result = Sexp.new(*args) - result.line ||= lexer.lineno if lexer.src # otherwise... - result.file = self.file - result - end - - def value_expr oldnode # HACK - node = remove_begin oldnode - node.line = oldnode.line if oldnode - node[2] = value_expr(node[2]) if node and node[0] == :if - node - end - - def void_stmts node - return nil unless node - return node unless node[0] == :block - - node[1..-1] = node[1..-1].map { |n| remove_begin(n) } - node - end - - def warning s - # do nothing for now - end - - alias :old_yyerror :yyerror - def yyerror msg - # for now do nothing with the msg - old_yyerror - end -end - -class Keyword - class KWtable - attr_accessor :name, :state, :id0, :id1 - def initialize(name, id=[], state=nil) - @name = name - @id0, @id1 = id - @state = state - end - end - - ## - # :stopdoc: - # - # :expr_beg = ignore newline, +/- is a sign. - # :expr_end = newline significant, +/- is a operator. - # :expr_arg = newline significant, +/- is a operator. - # :expr_cmdarg = newline significant, +/- is a operator. - # :expr_endarg = newline significant, +/- is a operator. - # :expr_mid = newline significant, +/- is a operator. - # :expr_fname = ignore newline, no reserved words. - # :expr_dot = right after . or ::, no reserved words. - # :expr_class = immediate after class, no here document. - - wordlist = [ - ["end", [:kEND, :kEND ], :expr_end ], - ["else", [:kELSE, :kELSE ], :expr_beg ], - ["case", [:kCASE, :kCASE ], :expr_beg ], - ["ensure", [:kENSURE, :kENSURE ], :expr_beg ], - ["module", [:kMODULE, :kMODULE ], :expr_beg ], - ["elsif", [:kELSIF, :kELSIF ], :expr_beg ], - ["def", [:kDEF, :kDEF ], :expr_fname ], - ["rescue", [:kRESCUE, :kRESCUE_MOD ], :expr_mid ], - ["not", [:kNOT, :kNOT ], :expr_beg ], - ["then", [:kTHEN, :kTHEN ], :expr_beg ], - ["yield", [:kYIELD, :kYIELD ], :expr_arg ], - ["for", [:kFOR, :kFOR ], :expr_beg ], - ["self", [:kSELF, :kSELF ], :expr_end ], - ["false", [:kFALSE, :kFALSE ], :expr_end ], - ["retry", [:kRETRY, :kRETRY ], :expr_end ], - ["return", [:kRETURN, :kRETURN ], :expr_mid ], - ["true", [:kTRUE, :kTRUE ], :expr_end ], - ["if", [:kIF, :kIF_MOD ], :expr_beg ], - ["defined?", [:kDEFINED, :kDEFINED ], :expr_arg ], - ["super", [:kSUPER, :kSUPER ], :expr_arg ], - ["undef", [:kUNDEF, :kUNDEF ], :expr_fname ], - ["break", [:kBREAK, :kBREAK ], :expr_mid ], - ["in", [:kIN, :kIN ], :expr_beg ], - ["do", [:kDO, :kDO ], :expr_beg ], - ["nil", [:kNIL, :kNIL ], :expr_end ], - ["until", [:kUNTIL, :kUNTIL_MOD ], :expr_beg ], - ["unless", [:kUNLESS, :kUNLESS_MOD ], :expr_beg ], - ["or", [:kOR, :kOR ], :expr_beg ], - ["next", [:kNEXT, :kNEXT ], :expr_mid ], - ["when", [:kWHEN, :kWHEN ], :expr_beg ], - ["redo", [:kREDO, :kREDO ], :expr_end ], - ["and", [:kAND, :kAND ], :expr_beg ], - ["begin", [:kBEGIN, :kBEGIN ], :expr_beg ], - ["__LINE__", [:k__LINE__, :k__LINE__ ], :expr_end ], - ["class", [:kCLASS, :kCLASS ], :expr_class ], - ["__FILE__", [:k__FILE__, :k__FILE__ ], :expr_end ], - ["END", [:klEND, :klEND ], :expr_end ], - ["BEGIN", [:klBEGIN, :klBEGIN ], :expr_end ], - ["while", [:kWHILE, :kWHILE_MOD ], :expr_beg ], - ["alias", [:kALIAS, :kALIAS ], :expr_fname ], - ].map { |args| KWtable.new(*args) } - - # :startdoc: - - WORDLIST = Hash[*wordlist.map { |o| [o.name, o] }.flatten] unless - defined? WORDLIST - - def self.keyword str - WORDLIST[str] - end -end - -class RBEnvironment - attr_reader :env, :dyn - - def [] k - self.all[k] - end - - def []= k, v - raise "no" if v == true - self.current[k] = v - end - - def all - idx = @dyn.index(false) || 0 - @env[0..idx].reverse.inject { |env, scope| env.merge scope } - end - - def current - @env.first - end - - def dynamic - idx = @dyn.index false - @env[0...idx].reverse.inject { |env, scope| env.merge scope } || {} - end - - def dynamic? - @dyn[0] != false - end - - def extend dyn = false - @dyn.unshift dyn - @env.unshift({}) - @use.unshift({}) - end - - def initialize dyn = false - @dyn = [] - @env = [] - @use = [] - self.reset - end - - def reset - @dyn.clear - @env.clear - @use.clear - self.extend - end - - def unextend - @dyn.shift - @env.shift - @use.shift - raise "You went too far unextending env" if @env.empty? - end - - def use id - @env.each_with_index do |env, i| - if env[id] then - @use[i][id] = true - end - end - end - - def used? id - idx = @dyn.index false # REFACTOR - u = @use[0...idx].reverse.inject { |env, scope| env.merge scope } || {} - u[id] - end -end - -class StackState - attr_reader :stack - - def initialize(name) - @name = name - @stack = [false] - end - - def inspect - "StackState(#{@name}, #{@stack.inspect})" - end - - def is_in_state - @stack.last - end - - def lexpop - raise if @stack.size == 0 - a = @stack.pop - b = @stack.pop - @stack.push(a || b) - end - - def pop - r = @stack.pop - @stack.push false if @stack.size == 0 - r - end - - def push val - @stack.push val - end -end - -############################################################ -# HACK HACK HACK HACK HACK HACK HACK HACK HACK HACK HACK HACK - -class Symbol - def is_argument # TODO: phase this out - return self == :expr_arg || self == :expr_cmdarg - end -end - -class Sexp - attr_writer :paren - - def paren - @paren ||= false - end - - def value - raise "multi item sexp" if size > 2 - last - end - - def to_sym - self.value.to_sym - end - - alias :node_type :sexp_type - alias :values :sexp_body # TODO: retire -end - -# END HACK -############################################################ diff --git a/vendor/gems/ruby_parser-2.0.5/test/test_ruby_lexer.rb b/vendor/gems/ruby_parser-2.0.5/test/test_ruby_lexer.rb deleted file mode 100755 index eb8b7a29c87..00000000000 --- a/vendor/gems/ruby_parser-2.0.5/test/test_ruby_lexer.rb +++ /dev/null @@ -1,1824 +0,0 @@ -#!/usr/local/bin/ruby - -require 'rubygems' -require 'minitest/autorun' -require 'ruby_lexer' -require 'ruby_parser' - -class TestRubyLexer < MiniTest::Unit::TestCase - alias :deny :refute - - def setup - p = RubyParser.new - @lex = p.lexer - @lex.src = "blah blah" - @lex.lex_state = :expr_beg - end - - def test_advance - assert @lex.advance # blah - assert @lex.advance # blah - deny @lex.advance # nada - end - - def test_read_escape - util_escape "\\", "\\" - util_escape "\n", "n" - util_escape "\t", "t" - util_escape "\r", "r" - util_escape "\f", "f" - util_escape "\13", "v" - util_escape "\0", "0" - util_escape "\07", "a" - util_escape "\007", "a" - util_escape "\033", "e" - util_escape "\377", "377" - util_escape "\377", "xff" - util_escape "\010", "b" - util_escape " ", "s" - util_escape "q", "q" # plain vanilla escape - end - - def test_read_escape_c - util_escape "\030", "C-x" - util_escape "\030", "cx" - util_escape "\230", 'C-\M-x' - util_escape "\230", 'c\M-x' - - util_escape "\177", "C-?" - util_escape "\177", "c?" - end - - def test_read_escape_errors - util_escape_bad "" - - util_escape_bad "M" - util_escape_bad "M-" - util_escape_bad "Mx" - - util_escape_bad "Cx" - util_escape_bad "C" - util_escape_bad "C-" - - util_escape_bad "c" - end - - def test_read_escape_m - util_escape "\370", "M-x" - util_escape "\230", 'M-\C-x' - util_escape "\230", 'M-\cx' - end - - def test_yylex_ambiguous_uminus - util_lex_token("m -3", - :tIDENTIFIER, "m", - :tUMINUS_NUM, "-", - :tINTEGER, 3) - # TODO: verify warning - end - - def test_yylex_ambiguous_uplus - util_lex_token("m +3", - :tIDENTIFIER, "m", - :tINTEGER, 3) - # TODO: verify warning - end - - def test_yylex_and - util_lex_token "&", :tAMPER, "&" - end - - def test_yylex_and2 - util_lex_token "&&", :tANDOP, "&&" - end - - def test_yylex_and2_equals - util_lex_token "&&=", :tOP_ASGN, "&&" - end - - def test_yylex_and_arg - @lex.lex_state = :expr_arg - - util_lex_token(" &y", - :tAMPER, "&", - :tIDENTIFIER, "y") - end - - def test_yylex_and_equals - util_lex_token "&=", :tOP_ASGN, "&" - end - - def test_yylex_and_expr - @lex.lex_state = :expr_arg - - util_lex_token("x & y", - :tIDENTIFIER, "x", - :tAMPER2, "&", - :tIDENTIFIER, "y") - end - - def test_yylex_and_meth - util_lex_fname "&", :tAMPER2 - end - - def test_yylex_assoc - util_lex_token "=>", :tASSOC, "=>" - end - - def test_yylex_back_ref - util_lex_token("[$&, $`, $', $+]", - :tLBRACK, "[", - :tBACK_REF, :"&", :tCOMMA, ",", - :tBACK_REF, :"`", :tCOMMA, ",", - :tBACK_REF, :"'", :tCOMMA, ",", - :tBACK_REF, :"+", - :tRBRACK, "]") - end - - def test_yylex_backslash - util_lex_token("1 \\\n+ 2", - :tINTEGER, 1, - :tPLUS, "+", - :tINTEGER, 2) - end - - def test_yylex_backslash_bad - util_bad_token("1 \\ + 2", - :tINTEGER, 1) - end - - def test_yylex_backtick - util_lex_token("`ls`", - :tXSTRING_BEG, "`", - :tSTRING_CONTENT, "ls", - :tSTRING_END, "`") - end - - def test_yylex_backtick_cmdarg - @lex.lex_state = :expr_dot - util_lex_token("\n`", :tBACK_REF2, "`") # \n ensures expr_cmd - - assert_equal :expr_cmdarg, @lex.lex_state - end - - def test_yylex_backtick_dot - @lex.lex_state = :expr_dot - util_lex_token("a.`(3)", - :tIDENTIFIER, "a", - :tDOT, ".", - :tBACK_REF2, "`", - :tLPAREN2, "(", - :tINTEGER, 3, - :tRPAREN, ")") - end - - def test_yylex_backtick_method - @lex.lex_state = :expr_fname - util_lex_token("`", :tBACK_REF2, "`") - assert_equal :expr_end, @lex.lex_state - end - - def test_yylex_bad_char - util_bad_token(" \010 ") - end - - def test_yylex_bang - util_lex_token "!", :tBANG, "!" - end - - def test_yylex_bang_equals - util_lex_token "!=", :tNEQ, "!=" - end - - def test_yylex_bang_tilde - util_lex_token "!~", :tNMATCH, "!~" - end - - def test_yylex_carat - util_lex_token "^", :tCARET, "^" - end - - def test_yylex_carat_equals - util_lex_token "^=", :tOP_ASGN, "^" - end - - def test_yylex_colon2 - util_lex_token("A::B", - :tCONSTANT, "A", - :tCOLON2, "::", - :tCONSTANT, "B") - end - - def test_yylex_colon3 - util_lex_token("::Array", - :tCOLON3, "::", - :tCONSTANT, "Array") - end - - def test_yylex_comma - util_lex_token ",", :tCOMMA, "," - end - - def test_yylex_comment - util_lex_token("1 # one\n# two\n2", - :tINTEGER, 1, - :tNL, nil, - :tINTEGER, 2) - assert_equal "# one\n# two\n", @lex.comments - end - - def test_yylex_comment_begin - util_lex_token("=begin\nblah\nblah\n=end\n42", - :tINTEGER, 42) - assert_equal "=begin\nblah\nblah\n=end\n", @lex.comments - end - - def test_yylex_comment_begin_bad - util_bad_token("=begin\nblah\nblah\n") - assert_equal "", @lex.comments - end - - def test_yylex_comment_begin_not_comment - util_lex_token("beginfoo = 5\np x \\\n=beginfoo", - :tIDENTIFIER, "beginfoo", - :tEQL, "=", - :tINTEGER, 5, - :tNL, nil, - :tIDENTIFIER, "p", - :tIDENTIFIER, "x", - :tEQL, "=", - :tIDENTIFIER, "beginfoo") - end - - def test_yylex_comment_begin_space - util_lex_token("=begin blah\nblah\n=end\n") - assert_equal "=begin blah\nblah\n=end\n", @lex.comments - end - - def test_yylex_comment_eos - util_lex_token("# comment") - end - - def test_yylex_constant - util_lex_token("ArgumentError", - :tCONSTANT, "ArgumentError") - end - - def test_yylex_constant_semi - util_lex_token("ArgumentError;", - :tCONSTANT, "ArgumentError", - :tSEMI, ";") - end - - def test_yylex_cvar - util_lex_token "@@blah", :tCVAR, "@@blah" - end - - def test_yylex_cvar_bad - assert_raises SyntaxError do - util_lex_token "@@1" - end - end - - def test_yylex_def_bad_name - @lex.lex_state = :expr_fname - util_bad_token("def [ ", :kDEF, "def") - end - - def test_yylex_div - util_lex_token("a / 2", - :tIDENTIFIER, "a", - :tDIVIDE, "/", - :tINTEGER, 2) - end - - def test_yylex_div_equals - util_lex_token("a /= 2", - :tIDENTIFIER, "a", - :tOP_ASGN, "/", - :tINTEGER, 2) - end - - def test_yylex_do - util_lex_token("x do 42 end", - :tIDENTIFIER, "x", - :kDO, "do", - :tINTEGER, 42, - :kEND, "end") - end - - def test_yylex_do_block - @lex.lex_state = :expr_endarg - @lex.cmdarg.push true - - util_lex_token("x.y do 42 end", - :tIDENTIFIER, "x", - :tDOT, ".", - :tIDENTIFIER, "y", - :kDO_BLOCK, "do", - :tINTEGER, 42, - :kEND, "end") - end - - def test_yylex_do_block2 - @lex.lex_state = :expr_endarg - - util_lex_token("do 42 end", - :kDO_BLOCK, "do", - :tINTEGER, 42, - :kEND, "end") - end - - def test_yylex_do_cond - @lex.cond.push true - - util_lex_token("x do 42 end", - :tIDENTIFIER, "x", - :kDO_COND, "do", - :tINTEGER, 42, - :kEND, "end") - end - - def test_yylex_dollar - util_lex_token("$", "$", "$") # FIX: wtf is this?!? - end - - def test_yylex_dot # HINT message sends - util_lex_token ".", :tDOT, "." - end - - def test_yylex_dot2 - util_lex_token "..", :tDOT2, ".." - end - - def test_yylex_dot3 - util_lex_token "...", :tDOT3, "..." - end - - def test_yylex_equals - util_lex_token "=", :tEQL, "=" # FIX: this sucks - end - - def test_yylex_equals2 - util_lex_token "==", :tEQ, "==" - end - - def test_yylex_equals3 - util_lex_token "===", :tEQQ, "===" - end - - def test_yylex_equals_tilde - util_lex_token "=~", :tMATCH, "=~" - end - - def test_yylex_float - util_lex_token "1.0", :tFLOAT, 1.0 - end - - def test_yylex_float_bad_no_underscores - util_bad_token "1__0.0" - end - - def test_yylex_float_bad_no_zero_leading - util_bad_token ".0" - end - - def test_yylex_float_bad_trailing_underscore - util_bad_token "123_.0" - end - - def test_yylex_float_call - util_lex_token("1.0.to_s", - :tFLOAT, 1.0, - :tDOT, ".", - :tIDENTIFIER, "to_s") - end - - def test_yylex_float_dot_E - util_lex_token "1.0E10", :tFLOAT, 1.0e10 - end - - def test_yylex_float_dot_E_neg - util_lex_token("-1.0E10", - :tUMINUS_NUM, "-", - :tFLOAT, 1.0e10) - end - - def test_yylex_float_dot_e - util_lex_token "1.0e10", :tFLOAT, 1.0e10 - end - - def test_yylex_float_dot_e_neg - util_lex_token("-1.0e10", - :tUMINUS_NUM, "-", - :tFLOAT, 1.0e10) - end - - def test_yylex_float_e - util_lex_token "1e10", :tFLOAT, 1e10 - end - - def test_yylex_float_e_bad_double_e - util_bad_token "1e2e3" - end - - def test_yylex_float_e_bad_trailing_underscore - util_bad_token "123_e10" - end - - def test_yylex_float_e_minus - util_lex_token "1e-10", :tFLOAT, 1e-10 - end - - def test_yylex_float_e_neg - util_lex_token("-1e10", - :tUMINUS_NUM, "-", - :tFLOAT, 1e10) - end - - def test_yylex_float_e_neg_minus - util_lex_token("-1e-10", - :tUMINUS_NUM, "-", - :tFLOAT, 1e-10) - end - - def test_yylex_float_e_neg_plus - util_lex_token("-1e+10", - :tUMINUS_NUM, "-", - :tFLOAT, 1e10) - end - - def test_yylex_float_e_plus - util_lex_token "1e+10", :tFLOAT, 1e10 - end - - def test_yylex_float_e_zero - util_lex_token "0e0", :tFLOAT, 0e0 - end - - def test_yylex_float_neg - util_lex_token("-1.0", - :tUMINUS_NUM, "-", - :tFLOAT, 1.0) - end - - def test_yylex_ge - util_lex_token("a >= 2", - :tIDENTIFIER, "a", - :tGEQ, ">=", - :tINTEGER, 2) - end - - def test_yylex_global - util_lex_token("$blah", :tGVAR, "$blah") - end - - def test_yylex_global_backref - @lex.lex_state = :expr_fname - util_lex_token("$`", :tGVAR, "$`") - end - - def test_yylex_global_dash_nothing - util_lex_token("$- ", :tGVAR, "$-") - end - - def test_yylex_global_dash_something - util_lex_token("$-x", :tGVAR, "$-x") - end - - def test_yylex_global_number - @lex.lex_state = :expr_fname - util_lex_token("$1", :tGVAR, "$1") - end - - def test_yylex_global_number_big - @lex.lex_state = :expr_fname - util_lex_token("$1234", :tGVAR, "$1234") - end - - def test_yylex_global_other - util_lex_token("[$~, $*, $$, $?, $!, $@, $/, $\\, $;, $,, $., $=, $:, $<, $>, $\"]", - :tLBRACK, "[", - :tGVAR, "$~", :tCOMMA, ",", - :tGVAR, "$*", :tCOMMA, ",", - :tGVAR, "$$", :tCOMMA, ",", - :tGVAR, "$\?", :tCOMMA, ",", - :tGVAR, "$!", :tCOMMA, ",", - :tGVAR, "$@", :tCOMMA, ",", - :tGVAR, "$/", :tCOMMA, ",", - :tGVAR, "$\\", :tCOMMA, ",", - :tGVAR, "$;", :tCOMMA, ",", - :tGVAR, "$,", :tCOMMA, ",", - :tGVAR, "$.", :tCOMMA, ",", - :tGVAR, "$=", :tCOMMA, ",", - :tGVAR, "$:", :tCOMMA, ",", - :tGVAR, "$<", :tCOMMA, ",", - :tGVAR, "$>", :tCOMMA, ",", - :tGVAR, "$\"", - :tRBRACK, "]") - end - - def test_yylex_global_underscore - util_lex_token("$_", - :tGVAR, "$_") - end - - def test_yylex_global_wierd - util_lex_token("$__blah", - :tGVAR, "$__blah") - end - - def test_yylex_global_zero - util_lex_token("$0", :tGVAR, "$0") - end - - def test_yylex_gt - util_lex_token("a > 2", - :tIDENTIFIER, "a", - :tGT, ">", - :tINTEGER, 2) - end - - def test_yylex_heredoc_backtick - util_lex_token("a = <<`EOF`\n blah blah\nEOF\n", - :tIDENTIFIER, "a", - :tEQL, "=", - :tXSTRING_BEG, "`", - :tSTRING_CONTENT, " blah blah\n", - :tSTRING_END, "EOF", - :tNL, nil) - end - - def test_yylex_heredoc_double - util_lex_token("a = <<\"EOF\"\n blah blah\nEOF\n", - :tIDENTIFIER, "a", - :tEQL, "=", - :tSTRING_BEG, "\"", - :tSTRING_CONTENT, " blah blah\n", - :tSTRING_END, "EOF", - :tNL, nil) - end - - def test_yylex_heredoc_double_dash - util_lex_token("a = <<-\"EOF\"\n blah blah\n EOF\n", - :tIDENTIFIER, "a", - :tEQL, "=", - :tSTRING_BEG, "\"", - :tSTRING_CONTENT, " blah blah\n", - :tSTRING_END, "EOF", - :tNL, nil) - end - - def test_yylex_heredoc_double_eos - util_bad_token("a = <<\"EOF\"\nblah", - :tIDENTIFIER, "a", - :tEQL, "=", - :tSTRING_BEG, "\"") - end - - def test_yylex_heredoc_double_eos_nl - util_bad_token("a = <<\"EOF\"\nblah\n", - :tIDENTIFIER, "a", - :tEQL, "=", - :tSTRING_BEG, "\"") - end - - def test_yylex_heredoc_double_interp - util_lex_token("a = <<\"EOF\"\n#x a \#@a b \#$b c \#{3} \nEOF\n", - :tIDENTIFIER, "a", - :tEQL, "=", - :tSTRING_BEG, "\"", - :tSTRING_CONTENT, "#x a ", - :tSTRING_DVAR, "\#@", - :tSTRING_CONTENT, "@a b ", # HUH? - :tSTRING_DVAR, "\#$", - :tSTRING_CONTENT, "$b c ", # HUH? - :tSTRING_DBEG, "\#{", - :tSTRING_CONTENT, "3} \n", # HUH? - :tSTRING_END, "EOF", - :tNL, nil) - end - - def test_yylex_heredoc_none - util_lex_token("a = <", :tCMP - end - - def test_yylex_identifier_def - util_lex_fname "identifier", :tIDENTIFIER, :expr_end - end - - def test_yylex_identifier_eh - util_lex_token("identifier?", :tFID, "identifier?") - end - - def test_yylex_identifier_equals_arrow - @lex.lex_state = :expr_fname - util_lex_token(":blah==>", - :tSYMBOL, "blah=", - :tASSOC, "=>") - end - - def test_yylex_identifier_equals_caret - util_lex_fname "^", :tCARET - end - - def test_yylex_identifier_equals_def - util_lex_fname "identifier=", :tIDENTIFIER, :expr_end - end - - def test_yylex_identifier_equals_def2 - util_lex_fname "==", :tEQ - end - - def test_yylex_identifier_equals_expr - @lex.lex_state = :expr_dot - util_lex_token("y = arg", - :tIDENTIFIER, "y", - :tEQL, "=", - :tIDENTIFIER, "arg") - - assert_equal :expr_arg, @lex.lex_state - end - - def test_yylex_identifier_equals_or - util_lex_fname "|", :tPIPE - end - - def test_yylex_identifier_equals_slash - util_lex_fname "/", :tDIVIDE - end - - def test_yylex_identifier_equals_tilde - @lex.lex_state = :expr_fname # can only set via parser's defs - util_lex_token("identifier=~", - :tIDENTIFIER, "identifier", - :tMATCH, "=~") - end - - def test_yylex_identifier_gt - util_lex_fname ">", :tGT - end - - def test_yylex_identifier_le - util_lex_fname "<=", :tLEQ - end - - def test_yylex_identifier_lt - util_lex_fname "<", :tLT - end - - def test_yylex_identifier_tilde - util_lex_fname "~", :tTILDE - end - - def test_yylex_index - util_lex_fname "[]", :tAREF - end - - def test_yylex_index_equals - util_lex_fname "[]=", :tASET - end - - def test_yylex_integer - util_lex_token "42", :tINTEGER, 42 - end - - def test_yylex_integer_bin - util_lex_token "0b101010", :tINTEGER, 42 - end - - def test_yylex_integer_bin_bad_none - util_bad_token "0b " - end - - def test_yylex_integer_bin_bad_underscores - util_bad_token "0b10__01" - end - - def test_yylex_integer_dec - util_lex_token "42", :tINTEGER, 42 - end - - def test_yylex_integer_dec_bad_underscores - util_bad_token "42__24" - end - - def test_yylex_integer_dec_d - util_lex_token "0d42", :tINTEGER, 42 - end - - def test_yylex_integer_dec_d_bad_none - util_bad_token "0d" - end - - def test_yylex_integer_dec_d_bad_underscores - util_bad_token "0d42__24" - end - - def test_yylex_integer_eh_a - util_lex_token '?a', :tINTEGER, 97 - end - - def test_yylex_integer_eh_escape_M_escape_C - util_lex_token '?\M-\C-a', :tINTEGER, 129 - end - - def test_yylex_integer_hex - util_lex_token "0x2a", :tINTEGER, 42 - end - - def test_yylex_integer_hex_bad_none - util_bad_token "0x " - end - - def test_yylex_integer_hex_bad_underscores - util_bad_token "0xab__cd" - end - - def test_yylex_integer_oct - util_lex_token "052", :tINTEGER, 42 - end - - def test_yylex_integer_oct_bad_range - util_bad_token "08" - end - - def test_yylex_integer_oct_bad_underscores - util_bad_token "01__23" - end - - def test_yylex_integer_oct_O - util_lex_token "0O52", :tINTEGER, 42 - end - - def test_yylex_integer_oct_O_bad_range - util_bad_token "0O8" - end - - def test_yylex_integer_oct_O_bad_underscores - util_bad_token "0O1__23" - end - - def test_yylex_integer_oct_O_not_bad_none - util_lex_token "0O ", :tINTEGER, 0 - end - - def test_yylex_integer_oct_o - util_lex_token "0o52", :tINTEGER, 42 - end - - def test_yylex_integer_oct_o_bad_range - util_bad_token "0o8" - end - - def test_yylex_integer_oct_o_bad_underscores - util_bad_token "0o1__23" - end - - def test_yylex_integer_oct_o_not_bad_none - util_lex_token "0o ", :tINTEGER, 0 - end - - def test_yylex_integer_trailing - util_lex_token("1.to_s", - :tINTEGER, 1, - :tDOT, '.', - :tIDENTIFIER, 'to_s') - end - - def test_yylex_integer_underscore - util_lex_token "4_2", :tINTEGER, 42 - end - - def test_yylex_integer_underscore_bad - util_bad_token "4__2" - end - - def test_yylex_integer_zero - util_lex_token "0", :tINTEGER, 0 - end - - def test_yylex_ivar - util_lex_token "@blah", :tIVAR, "@blah" - end - - def test_yylex_ivar_bad - util_bad_token "@1" - end - - def test_yylex_keyword_expr - @lex.lex_state = :expr_endarg - - util_lex_token("if", :kIF_MOD, "if") - - assert_equal :expr_beg, @lex.lex_state - end - - def test_yylex_lt - util_lex_token "<", :tLT, "<" - end - - def test_yylex_lt2 - util_lex_token("a <\< b", - :tIDENTIFIER, "a", - :tLSHFT, "<\<", - :tIDENTIFIER, "b") - - end - - def test_yylex_lt2_equals - util_lex_token("a <\<= b", - :tIDENTIFIER, "a", - :tOP_ASGN, "<\<", - :tIDENTIFIER, "b") - end - - def test_yylex_lt_equals - util_lex_token "<=", :tLEQ, "<=" - end - - def test_yylex_minus - util_lex_token("1 - 2", - :tINTEGER, 1, - :tMINUS, "-", - :tINTEGER, 2) - end - - def test_yylex_minus_equals - util_lex_token "-=", :tOP_ASGN, "-" - end - - def test_yylex_minus_method - @lex.lex_state = :expr_fname - util_lex_token "-", :tMINUS, "-" - end - - def test_yylex_minus_unary_method - @lex.lex_state = :expr_fname - util_lex_token "-@", :tUMINUS, "-@" - end - - def test_yylex_minus_unary_number - util_lex_token("-42", - :tUMINUS_NUM, "-", - :tINTEGER, 42) - end - - def test_yylex_nth_ref - util_lex_token('[$1, $2, $3, $4, $5, $6, $7, $8, $9]', - :tLBRACK, "[", - :tNTH_REF, 1, :tCOMMA, ",", - :tNTH_REF, 2, :tCOMMA, ",", - :tNTH_REF, 3, :tCOMMA, ",", - :tNTH_REF, 4, :tCOMMA, ",", - :tNTH_REF, 5, :tCOMMA, ",", - :tNTH_REF, 6, :tCOMMA, ",", - :tNTH_REF, 7, :tCOMMA, ",", - :tNTH_REF, 8, :tCOMMA, ",", - :tNTH_REF, 9, - :tRBRACK, "]") - end - - def test_yylex_open_bracket - util_lex_token("(", :tLPAREN, "(") - end - - def test_yylex_open_bracket_cmdarg - @lex.lex_state = :expr_cmdarg - util_lex_token(" (", :tLPAREN_ARG, "(") - end - - def test_yylex_open_bracket_exprarg - @lex.lex_state = :expr_arg - util_lex_token(" (", :tLPAREN2, "(") - end - - def test_yylex_open_curly_bracket - util_lex_token("{", - :tLBRACE, "{") - end - - def test_yylex_open_curly_bracket_arg - @lex.lex_state = :expr_arg - util_lex_token("m { 3 }", - :tIDENTIFIER, "m", - :tLCURLY, "{", - :tINTEGER, 3, - :tRCURLY, "}") - end - - def test_yylex_open_curly_bracket_block - @lex.lex_state = :expr_endarg # seen m(3) - util_lex_token("{ 4 }", - :tLBRACE_ARG, "{", - :tINTEGER, 4, - :tRCURLY, "}") - end - - def test_yylex_open_square_bracket_arg - @lex.lex_state = :expr_arg - util_lex_token("m [ 3 ]", - :tIDENTIFIER, "m", - :tLBRACK, "[", - :tINTEGER, 3, - :tRBRACK, "]") - end - - def test_yylex_open_square_bracket_ary - util_lex_token("[1, 2, 3]", - :tLBRACK, "[", - :tINTEGER, 1, - :tCOMMA, ",", - :tINTEGER, 2, - :tCOMMA, ",", - :tINTEGER, 3, - :tRBRACK, "]") - end - - def test_yylex_open_square_bracket_meth - util_lex_token("m[3]", - :tIDENTIFIER, "m", - "[", "[", - :tINTEGER, 3, - :tRBRACK, "]") - end - - def test_yylex_or - util_lex_token "|", :tPIPE, "|" - end - - def test_yylex_or2 - util_lex_token "||", :tOROP, "||" - end - - def test_yylex_or2_equals - util_lex_token "||=", :tOP_ASGN, "||" - end - - def test_yylex_or_equals - util_lex_token "|=", :tOP_ASGN, "|" - end - - def test_yylex_percent - util_lex_token("a % 2", - :tIDENTIFIER, "a", - :tPERCENT, "%", - :tINTEGER, 2) - end - - def test_yylex_percent_equals - util_lex_token("a %= 2", - :tIDENTIFIER, "a", - :tOP_ASGN, "%", - :tINTEGER, 2) - end - - def test_yylex_plus - util_lex_token("1 + 1", # TODO lex_state? - :tINTEGER, 1, - :tPLUS, "+", - :tINTEGER, 1) - end - - def test_yylex_plus_equals - util_lex_token "+=", :tOP_ASGN, "+" - end - - def test_yylex_plus_method - @lex.lex_state = :expr_fname - util_lex_token "+", :tPLUS, "+" - end - - def test_yylex_plus_unary_method - @lex.lex_state = :expr_fname - util_lex_token "+@", :tUPLUS, "+@" - end - - def test_yylex_plus_unary_number - util_lex_token("+42", - :tINTEGER, 42) - end - - def test_yylex_question - util_lex_token "?*", :tINTEGER, 42 - end - - def test_yylex_question_bad_eos - util_bad_token "?" - end - - def test_yylex_question_ws - util_lex_token "? ", :tEH, "?" - util_lex_token "?\n", :tEH, "?" - util_lex_token "?\t", :tEH, "?" - util_lex_token "?\v", :tEH, "?" - util_lex_token "?\r", :tEH, "?" - util_lex_token "?\f", :tEH, "?" - end - - def test_yylex_question_ws_backslashed - @lex.lex_state = :expr_beg - util_lex_token "?\\ ", :tINTEGER, 32 - @lex.lex_state = :expr_beg - util_lex_token "?\\n", :tINTEGER, 10 - @lex.lex_state = :expr_beg - util_lex_token "?\\t", :tINTEGER, 9 - @lex.lex_state = :expr_beg - util_lex_token "?\\v", :tINTEGER, 11 - @lex.lex_state = :expr_beg - util_lex_token "?\\r", :tINTEGER, 13 - @lex.lex_state = :expr_beg - util_lex_token "?\\f", :tINTEGER, 12 - end - - def test_yylex_rbracket - util_lex_token "]", :tRBRACK, "]" - end - - def test_yylex_rcurly - util_lex_token "}", :tRCURLY, "}" - end - - def test_yylex_regexp - util_lex_token("/regexp/", - :tREGEXP_BEG, "/", - :tSTRING_CONTENT, "regexp", - :tREGEXP_END, "") - end - - def test_yylex_regexp_ambiguous - util_lex_token("method /regexp/", - :tIDENTIFIER, "method", - :tREGEXP_BEG, "/", - :tSTRING_CONTENT, "regexp", - :tREGEXP_END, "") - end - - def test_yylex_regexp_bad - util_bad_token("/.*/xyz", - :tREGEXP_BEG, "/", - :tSTRING_CONTENT, ".*") - end - - def test_yylex_regexp_escape_C - util_lex_token('/regex\\C-x/', - :tREGEXP_BEG, "/", - :tSTRING_CONTENT, "regex\\C-x", - :tREGEXP_END, "") - end - - def test_yylex_regexp_escape_C_M - util_lex_token('/regex\\C-\\M-x/', - :tREGEXP_BEG, "/", - :tSTRING_CONTENT, "regex\\C-\\M-x", - :tREGEXP_END, "") - end - - def test_yylex_regexp_escape_C_M_craaaazy - util_lex_token("/regex\\C-\\\n\\M-x/", - :tREGEXP_BEG, "/", - :tSTRING_CONTENT, "regex\\C-\\M-x", - :tREGEXP_END, "") - end - - def test_yylex_regexp_escape_C_bad_dash - util_bad_token '/regex\\Cx/', :tREGEXP_BEG, "/" - end - - def test_yylex_regexp_escape_C_bad_dash_eos - util_bad_token '/regex\\C-/', :tREGEXP_BEG, "/" - end - - def test_yylex_regexp_escape_C_bad_dash_eos2 - util_bad_token '/regex\\C-', :tREGEXP_BEG, "/" - end - - def test_yylex_regexp_escape_C_bad_eos - util_bad_token '/regex\\C/', :tREGEXP_BEG, "/" - end - - def test_yylex_regexp_escape_C_bad_eos2 - util_bad_token '/regex\\c', :tREGEXP_BEG, "/" - end - - def test_yylex_regexp_escape_M - util_lex_token('/regex\\M-x/', - :tREGEXP_BEG, "/", - :tSTRING_CONTENT, "regex\\M-x", - :tREGEXP_END, "") - end - - def test_yylex_regexp_escape_M_C - util_lex_token('/regex\\M-\\C-x/', - :tREGEXP_BEG, "/", - :tSTRING_CONTENT, "regex\\M-\\C-x", - :tREGEXP_END, "") - end - - def test_yylex_regexp_escape_M_bad_dash - util_bad_token '/regex\\Mx/', :tREGEXP_BEG, "/" - end - - def test_yylex_regexp_escape_M_bad_dash_eos - util_bad_token '/regex\\M-/', :tREGEXP_BEG, "/" - end - - def test_yylex_regexp_escape_M_bad_dash_eos2 - util_bad_token '/regex\\M-', :tREGEXP_BEG, "/" - end - - def test_yylex_regexp_escape_M_bad_eos - util_bad_token '/regex\\M/', :tREGEXP_BEG, "/" - end - - def test_yylex_regexp_escape_backslash_slash - util_lex_token('/\\//', - :tREGEXP_BEG, "/", - :tSTRING_CONTENT, '\\/', - :tREGEXP_END, "") - end - - def test_yylex_regexp_escape_backslash_terminator - util_lex_token('%r%blah\\%blah%', - :tREGEXP_BEG, "%r\000", # FIX ?!? - :tSTRING_CONTENT, "blah\\%blah", - :tREGEXP_END, "") - end - - def test_yylex_regexp_escape_backslash_terminator_meta1 - util_lex_token('%r{blah\\}blah}', - :tREGEXP_BEG, "%r{", # FIX ?!? - :tSTRING_CONTENT, "blah\\}blah", - :tREGEXP_END, "") - end - - def test_yylex_regexp_escape_backslash_terminator_meta2 - util_lex_token('%r/blah\\/blah/', - :tREGEXP_BEG, "%r\000", # FIX ?!? - :tSTRING_CONTENT, "blah\\/blah", - :tREGEXP_END, "") - end - - def test_yylex_regexp_escape_backslash_terminator_meta3 - util_lex_token('%r/blah\\%blah/', - :tREGEXP_BEG, "%r\000", # FIX ?!? - :tSTRING_CONTENT, "blah\\%blah", - :tREGEXP_END, "") - end - - def test_yylex_regexp_escape_bad_eos - util_bad_token '/regex\\', :tREGEXP_BEG, "/" - end - - def test_yylex_regexp_escape_bs - util_lex_token('/regex\\\\regex/', - :tREGEXP_BEG, "/", - :tSTRING_CONTENT, "regex\\\\regex", - :tREGEXP_END, "") - end - - def test_yylex_regexp_escape_c - util_lex_token('/regex\\cxxx/', - :tREGEXP_BEG, "/", - :tSTRING_CONTENT, "regex\\cxxx", - :tREGEXP_END, "") - end - - def test_yylex_regexp_escape_c_backslash - util_lex_token('/regex\\c\\n/', - :tREGEXP_BEG, "/", - :tSTRING_CONTENT, "regex\\c\\n", - :tREGEXP_END, "") - end - - def test_yylex_regexp_escape_chars - util_lex_token('/re\\tge\\nxp/', - :tREGEXP_BEG, "/", - :tSTRING_CONTENT, "re\\tge\\nxp", - :tREGEXP_END, "") - end - - def test_yylex_regexp_escape_double_backslash - regexp = '/[\\/\\\\]$/' - util_lex_token(regexp, - :tREGEXP_BEG, "/", - :tSTRING_CONTENT, regexp[1..-2], - :tREGEXP_END, "") - end - - def test_yylex_regexp_escape_hex - util_lex_token('/regex\\x61xp/', - :tREGEXP_BEG, "/", - :tSTRING_CONTENT, "regex\\x61xp", - :tREGEXP_END, "") - end - - def test_yylex_regexp_escape_hex_bad - util_bad_token '/regex\\xzxp/', :tREGEXP_BEG, "/" - end - - def test_yylex_regexp_escape_hex_one - util_lex_token('/^[\\xd\\xa]{2}/on', - :tREGEXP_BEG, '/', - :tSTRING_CONTENT, '^[\\xd\\xa]{2}', - :tREGEXP_END, 'on') - end - - def test_yylex_regexp_escape_oct1 - util_lex_token('/regex\\0xp/', - :tREGEXP_BEG, "/", - :tSTRING_CONTENT, "regex\\0xp", - :tREGEXP_END, "") - end - - def test_yylex_regexp_escape_oct2 - util_lex_token('/regex\\07xp/', - :tREGEXP_BEG, "/", - :tSTRING_CONTENT, "regex\\07xp", - :tREGEXP_END, "") - end - - def test_yylex_regexp_escape_oct3 - util_lex_token('/regex\\10142/', - :tREGEXP_BEG, "/", - :tSTRING_CONTENT, "regex\\10142", - :tREGEXP_END, "") - end - - def test_yylex_regexp_escape_return - util_lex_token("/regex\\\nregex/", - :tREGEXP_BEG, "/", - :tSTRING_CONTENT, "regexregex", - :tREGEXP_END, "") - end - - def test_yylex_regexp_nm - util_lex_token("/.*/nm", - :tREGEXP_BEG, "/", - :tSTRING_CONTENT, ".*", - :tREGEXP_END, "nm") - end - - def test_yylex_rparen - util_lex_token ")", :tRPAREN, ")" - end - - def test_yylex_rshft - util_lex_token("a >> 2", - :tIDENTIFIER, "a", - :tRSHFT, ">>", - :tINTEGER, 2) - end - - def test_yylex_rshft_equals - util_lex_token("a >>= 2", - :tIDENTIFIER, "a", - :tOP_ASGN, ">>", - :tINTEGER, 2) - end - - def test_yylex_star - util_lex_token("a * ", - :tIDENTIFIER, "a", - :tSTAR2, "*") - - assert_equal :expr_beg, @lex.lex_state - end - - def test_yylex_star2 - util_lex_token("a ** ", - :tIDENTIFIER, "a", - :tPOW, "**") - - assert_equal :expr_beg, @lex.lex_state - end - - def test_yylex_star2_equals - util_lex_token("a **= ", - :tIDENTIFIER, "a", - :tOP_ASGN, "**") - - assert_equal :expr_beg, @lex.lex_state - end - - def test_yylex_star_arg - @lex.lex_state = :expr_arg - - util_lex_token(" *a", - :tSTAR, "*", - :tIDENTIFIER, "a") - - assert_equal :expr_arg, @lex.lex_state - end - - def test_yylex_star_arg_beg - @lex.lex_state = :expr_beg - - util_lex_token("*a", - :tSTAR, "*", - :tIDENTIFIER, "a") - - assert_equal :expr_arg, @lex.lex_state - end - - def test_yylex_star_arg_beg_fname - @lex.lex_state = :expr_fname - - util_lex_token("*a", - :tSTAR2, "*", - :tIDENTIFIER, "a") - - assert_equal :expr_arg, @lex.lex_state - end - - def test_yylex_star_equals - util_lex_token("a *= ", - :tIDENTIFIER, "a", - :tOP_ASGN, "*") - - assert_equal :expr_beg, @lex.lex_state - end - - def test_yylex_string_bad_eos - util_bad_token('%', - :tSTRING_BEG, '%') - end - - def test_yylex_string_bad_eos_quote - util_bad_token('%{nest', - :tSTRING_BEG, '%}') - end - - def test_yylex_string_double - util_lex_token('"string"', - :tSTRING, "string") - end - - def test_yylex_string_double_escape_C - util_lex_token('"\\C-a"', - :tSTRING, "\001") - end - - def test_yylex_string_double_escape_C_backslash - util_lex_token('"\\C-\\\\"', - :tSTRING_BEG, "\"", - :tSTRING_CONTENT, "\034", - :tSTRING_END, "\"") - end - - def test_yylex_string_double_escape_C_escape - util_lex_token('"\\C-\\M-a"', - :tSTRING_BEG, "\"", - :tSTRING_CONTENT, "\201", - :tSTRING_END, "\"") - end - - def test_yylex_string_double_escape_C_question - util_lex_token('"\\C-?"', - :tSTRING, "\177") - end - - def test_yylex_string_double_escape_M - util_lex_token('"\\M-a"', - :tSTRING, "\341") - end - - def test_yylex_string_double_escape_M_backslash - util_lex_token('"\\M-\\\\"', - :tSTRING_BEG, "\"", - :tSTRING_CONTENT, "\334", - :tSTRING_END, "\"") - end - - def test_yylex_string_double_escape_M_escape - util_lex_token('"\\M-\\C-a"', - :tSTRING_BEG, "\"", - :tSTRING_CONTENT, "\201", - :tSTRING_END, "\"") - end - - def test_yylex_string_double_escape_bs1 - util_lex_token('"a\\a\\a"', - :tSTRING, "a\a\a") - end - - def test_yylex_string_double_escape_bs2 - util_lex_token('"a\\\\a"', - :tSTRING, "a\\a") - end - - def test_yylex_string_double_escape_c - util_lex_token('"\\ca"', - :tSTRING, "\001") - end - - def test_yylex_string_double_escape_c_backslash - util_lex_token('"\\c\\"', - :tSTRING_BEG, "\"", - :tSTRING_CONTENT, "\034", - :tSTRING_END, "\"") - end - - def test_yylex_string_double_escape_c_escape - util_lex_token('"\\c\\M-a"', - :tSTRING_BEG, "\"", - :tSTRING_CONTENT, "\201", - :tSTRING_END, "\"") - end - - def test_yylex_string_double_escape_c_question - util_lex_token('"\\c?"', - :tSTRING, "\177") - end - - def test_yylex_string_double_escape_chars - util_lex_token('"s\\tri\\ng"', - :tSTRING, "s\tri\ng") - end - - def test_yylex_string_double_escape_hex - util_lex_token('"n = \\x61\\x62\\x63"', - :tSTRING, "n = abc") - end - - def test_yylex_string_double_escape_octal - util_lex_token('"n = \\101\\102\\103"', - :tSTRING, "n = ABC") - end - - def test_yylex_string_double_interp - util_lex_token("\"blah #x a \#@a b \#$b c \#{3} # \"", - :tSTRING_BEG, "\"", - :tSTRING_CONTENT, "blah #x a ", - :tSTRING_DVAR, nil, - :tSTRING_CONTENT, "@a b ", - :tSTRING_DVAR, nil, - :tSTRING_CONTENT, "$b c ", - :tSTRING_DBEG, nil, - :tSTRING_CONTENT, "3} # ", - :tSTRING_END, "\"") - end - - def test_yylex_string_double_nested_curlies - util_lex_token('%{nest{one{two}one}nest}', - :tSTRING_BEG, '%}', - :tSTRING_CONTENT, "nest{one{two}one}nest", - :tSTRING_END, '}') - end - - def test_yylex_string_double_no_interp - util_lex_token("\"# blah\"", # pound first - :tSTRING, "# blah") - - util_lex_token("\"blah # blah\"", # pound not first - :tSTRING, "blah # blah") - end - - def test_yylex_string_escape_x_single - util_lex_token('"\\x0"', - :tSTRING, "\000") - end - - def test_yylex_string_pct_Q - util_lex_token("%Q[s1 s2]", - :tSTRING_BEG, "%Q[", - :tSTRING_CONTENT, "s1 s2", - :tSTRING_END, "]") - end - - def test_yylex_string_pct_W - util_lex_token("%W[s1 s2\ns3]", # TODO: add interpolation to these - :tWORDS_BEG, "%W[", - :tSTRING_CONTENT, "s1", - :tSPACE, nil, - :tSTRING_CONTENT, "s2", - :tSPACE, nil, - :tSTRING_CONTENT, "s3", - :tSPACE, nil, - :tSTRING_END, nil) - end - - def test_yylex_string_pct_W_bs_nl - util_lex_token("%W[s1 \\\ns2]", # TODO: add interpolation to these - :tWORDS_BEG, "%W[", - :tSTRING_CONTENT, "s1", - :tSPACE, nil, - :tSTRING_CONTENT, "\ns2", - :tSPACE, nil, - :tSTRING_END, nil) - end - - def test_yylex_string_pct_angle - util_lex_token("%", - :tSTRING_BEG, "%>", - :tSTRING_CONTENT, "blah", - :tSTRING_END, ">") - end - - def test_yylex_string_pct_other - util_lex_token("%%blah%", - :tSTRING_BEG, "%%", - :tSTRING_CONTENT, "blah", - :tSTRING_END, "%") - end - - def test_yylex_string_pct_w - util_bad_token("%w[s1 s2 ", - :tAWORDS_BEG, "%w[", - :tSTRING_CONTENT, "s1", - :tSPACE, nil, - :tSTRING_CONTENT, "s2", - :tSPACE, nil) - end - - def test_yylex_string_pct_w_bs_nl - util_lex_token("%w[s1 \\\ns2]", - :tAWORDS_BEG, "%w[", - :tSTRING_CONTENT, "s1", - :tSPACE, nil, - :tSTRING_CONTENT, "\ns2", - :tSPACE, nil, - :tSTRING_END, nil) - end - - def test_yylex_string_pct_w_bs_sp - util_lex_token("%w[s\\ 1 s\\ 2]", - :tAWORDS_BEG, "%w[", - :tSTRING_CONTENT, "s 1", - :tSPACE, nil, - :tSTRING_CONTENT, "s 2", - :tSPACE, nil, - :tSTRING_END, nil) - end - - def test_yylex_string_pct_w_tab - util_lex_token("%w[abc\tdef]", - :tAWORDS_BEG, "%w[", - :tSTRING_CONTENT, "abc\tdef", - :tSPACE, nil, - :tSTRING_END, nil) - end - - def test_yylex_string_single - util_lex_token("'string'", - :tSTRING, "string") - end - - def test_yylex_string_single_escape_chars - util_lex_token("'s\\tri\\ng'", - :tSTRING, "s\\tri\\ng") - end - - def test_yylex_string_single_nl - util_lex_token("'blah\\\nblah'", - :tSTRING, "blah\\\nblah") - end - - def test_yylex_symbol - util_lex_token(":symbol", - :tSYMBOL, "symbol") - end - - def test_yylex_symbol_bad_zero - util_bad_token(":\"blah\0\"", - :tSYMBEG, ":") - end - - def test_yylex_symbol_double - util_lex_token(":\"symbol\"", - :tSYMBEG, ":", - :tSTRING_CONTENT, "symbol", - :tSTRING_END, '"') - end - - def test_yylex_symbol_single - util_lex_token(":'symbol'", - :tSYMBEG, ":", - :tSTRING_CONTENT, "symbol", - :tSTRING_END, "'") - end - - def test_yylex_ternary - util_lex_token("a ? b : c", - :tIDENTIFIER, "a", - :tEH, "?", - :tIDENTIFIER, "b", - :tCOLON, ":", - :tIDENTIFIER, "c") - - util_lex_token("a ?bb : c", # GAH! MATZ!!! - :tIDENTIFIER, "a", - :tEH, "?", - :tIDENTIFIER, "bb", - :tCOLON, ":", - :tIDENTIFIER, "c") - - util_lex_token("42 ?", # 42 forces expr_end - :tINTEGER, 42, - :tEH, "?") - end - - def test_yylex_tilde - util_lex_token "~", :tTILDE, "~" - end - - def test_yylex_tilde_unary - @lex.lex_state = :expr_fname - util_lex_token "~@", :tTILDE, "~" - end - - def test_yylex_uminus - util_lex_token("-blah", - :tUMINUS, "-", - :tIDENTIFIER, "blah") - end - - def test_yylex_underscore - util_lex_token("_var", :tIDENTIFIER, "_var") - end - - def test_yylex_underscore_end - @lex.src = "__END__\n" - deny @lex.advance - end - - def test_yylex_uplus - util_lex_token("+blah", - :tUPLUS, "+", - :tIDENTIFIER, "blah") - end - - def test_zbug_float_in_decl - util_lex_token("def initialize(u = ", - :kDEF, "def", - :tIDENTIFIER, "initialize", - :tLPAREN2, "(", - :tIDENTIFIER, "u", - :tEQL, "=") - - assert_equal :expr_beg, @lex.lex_state - - util_lex_token("0.0, s = 0.0", - :tFLOAT, 0.0, - :tCOMMA, ',', - :tIDENTIFIER, "s", - :tEQL, "=", - :tFLOAT, 0.0) - end - - def test_zbug_id_equals - util_lex_token("a =", - :tIDENTIFIER, "a", - :tEQL, "=") - - assert_equal :expr_beg, @lex.lex_state - - util_lex_token("0.0", - :tFLOAT, 0.0) - end - - def test_zbug_no_spaces_in_decl - util_lex_token("def initialize(u=", - :kDEF, "def", - :tIDENTIFIER, "initialize", - :tLPAREN2, "(", - :tIDENTIFIER, "u", - :tEQL, "=") - - assert_equal :expr_beg, @lex.lex_state - - util_lex_token("0.0,s=0.0", - :tFLOAT, 0.0, - :tCOMMA, ",", - :tIDENTIFIER, "s", - :tEQL, "=", - :tFLOAT, 0.0) - end - - ############################################################ - - def util_bad_token s, *args - assert_raises SyntaxError do - util_lex_token s, *args - end - end - - def util_escape expected, input - @lex.src = input - assert_equal expected, @lex.read_escape - end - - def util_escape_bad input - @lex.src = input - assert_raises SyntaxError do - @lex.read_escape - end - end - - def util_lex_fname name, type, end_state = :expr_arg - @lex.lex_state = :expr_fname # can only set via parser's defs - - util_lex_token("def #{name} ", :kDEF, "def", type, name) - - assert_equal end_state, @lex.lex_state - end - - def util_lex_token input, *args - @lex.src = input - - until args.empty? do - token = args.shift - value = args.shift - assert @lex.advance, "no more tokens" - assert_equal [token, value], [@lex.token, @lex.yacc_value] - end - - deny @lex.advance, "must be empty, but had #{[@lex.token, @lex.yacc_value].inspect}" - end -end - diff --git a/vendor/gems/ruby_parser-2.0.5/test/test_ruby_parser.rb b/vendor/gems/ruby_parser-2.0.5/test/test_ruby_parser.rb deleted file mode 100755 index 2bb429862eb..00000000000 --- a/vendor/gems/ruby_parser-2.0.5/test/test_ruby_parser.rb +++ /dev/null @@ -1,480 +0,0 @@ -#!/usr/local/bin/ruby - -require 'rubygems' -require 'minitest/autorun' -require 'ruby_parser' - -$: << File.expand_path('~/Work/p4/zss/src/ParseTree/dev/test') - -require 'pt_testcase' - -class RubyParser - def process input - parse input - end -end - -class RubyParserTestCase < ParseTreeTestCase - def self.previous key - "Ruby" - end - - def self.generate_test klass, node, data, input_name, output_name - return if node.to_s =~ /bmethod|dmethod/ - return if Array === data['Ruby'] - - output_name = "ParseTree" - - super - end -end - -class TestRubyParser < RubyParserTestCase - def setup - super - - # puts self.name - - @processor = RubyParser.new - end - - def test_attrasgn_array_lhs - rb = '[1, 2, 3, 4][from .. to] = ["a", "b", "c"]' - pt = s(:attrasgn, - s(:array, s(:lit, 1), s(:lit, 2), s(:lit, 3), s(:lit, 4)), - :[]=, - s(:arglist, - s(:dot2, - s(:call, nil, :from, s(:arglist)), - s(:call, nil, :to, s(:arglist))), - s(:array, s(:str, "a"), s(:str, "b"), s(:str, "c")))) - - result = @processor.parse(rb) - - assert_equal pt, result - end - - def test_block_append - head = s(:args) - tail = s(:zsuper) - expected = s(:block, s(:args), s(:zsuper)) - assert_equal expected, @processor.block_append(head, tail) - end - - def test_block_append_begin_begin - head = s(:begin, s(:args)) - tail = s(:begin, s(:args)) - expected = s(:block, s(:args), s(:begin, s(:args))) - assert_equal expected, @processor.block_append(head, tail) - end - - def test_block_append_block - head = s(:block, s(:args)) - tail = s(:zsuper) - expected = s(:block, s(:args), s(:zsuper)) - assert_equal expected, @processor.block_append(head, tail) - end - - def test_block_append_nil_head - head = nil - tail = s(:zsuper) - expected = s(:zsuper) - assert_equal expected, @processor.block_append(head, tail) - end - - def test_block_append_nil_tail - head = s(:args) - tail = nil - expected = s(:args) - assert_equal expected, @processor.block_append(head, tail) - end - - def test_block_append_tail_block - head = s(:call, nil, :f1, s(:arglist)) - tail = s(:block, s(:undef, s(:lit, :x)), s(:undef, s(:lit, :y))) - expected = s(:block, - s(:call, nil, :f1, s(:arglist)), - s(:block, s(:undef, s(:lit, :x)), s(:undef, s(:lit, :y)))) - assert_equal expected, @processor.block_append(head, tail) - end - - def test_call_env - @processor.env[:a] = :lvar - expected = s(:call, s(:lvar, :a), :happy, s(:arglist)) - - assert_equal expected, @processor.parse('a.happy') - end - - def test_dasgn_icky2 - rb = "a do\n v = nil\n begin\n yield\n rescue Exception => v\n break\n end\nend" - pt = s(:iter, - s(:call, nil, :a, s(:arglist)), - nil, - s(:block, - s(:lasgn, :v, s(:nil)), - s(:rescue, - s(:yield), - s(:resbody, - s(:array, s(:const, :Exception), s(:lasgn, :v, s(:gvar, :$!))), - s(:break))))) - - assert_equal pt, @processor.parse(rb) - end - - def test_class_comments - rb = "# blah 1\n# blah 2\n\nclass X\n # blah 3\n def blah\n # blah 4\n end\nend" - pt = s(:class, :X, nil, - s(:scope, - s(:defn, :blah, s(:args), s(:scope, s(:block, s(:nil)))))) - - actual = @processor.parse(rb) - assert_equal pt, actual - - assert_equal "# blah 1\n# blah 2\n\n", actual.comments - assert_equal "# blah 3\n", actual.scope.defn.comments - end - - def test_module_comments - rb = "# blah 1\n \n # blah 2\n\nmodule X\n # blah 3\n def blah\n # blah 4\n end\nend" - pt = s(:module, :X, - s(:scope, - s(:defn, :blah, s(:args), s(:scope, s(:block, s(:nil)))))) - - actual = @processor.parse(rb) - assert_equal pt, actual - assert_equal "# blah 1\n\n# blah 2\n\n", actual.comments - assert_equal "# blah 3\n", actual.scope.defn.comments - end - - def test_defn_comments - rb = "# blah 1\n# blah 2\n\ndef blah\nend" - pt = s(:defn, :blah, s(:args), s(:scope, s(:block, s(:nil)))) - - actual = @processor.parse(rb) - assert_equal pt, actual - assert_equal "# blah 1\n# blah 2\n\n", actual.comments - end - - def test_defs_comments - rb = "# blah 1\n# blah 2\n\ndef self.blah\nend" - pt = s(:defs, s(:self), :blah, s(:args), s(:scope, s(:block))) - - actual = @processor.parse(rb) - assert_equal pt, actual - assert_equal "# blah 1\n# blah 2\n\n", actual.comments - end - - def test_do_bug # TODO: rename - rb = "a 1\na.b do |c|\n # do nothing\nend" - pt = s(:block, - s(:call, nil, :a, s(:arglist, s(:lit, 1))), - s(:iter, - s(:call, s(:call, nil, :a, s(:arglist)), :b, s(:arglist)), - s(:lasgn, :c))) - - assert_equal pt, @processor.parse(rb) - end - - def test_dstr_evstr - rb = "\"#\{'a'}#\{b}\"" - pt = s(:dstr, "a", s(:evstr, s(:call, nil, :b, s(:arglist)))) - - assert_equal pt, @processor.parse(rb) - end - - def test_dstr_str - rb = "\"#\{'a'} b\"" - pt = s(:str, "a b") - - assert_equal pt, @processor.parse(rb) - end - - def test_empty - rb = "" - pt = nil - - assert_equal pt, @processor.parse(rb) - end - - def test_evstr_evstr - rb = "\"#\{a}#\{b}\"" - pt = s(:dstr, "", s(:evstr, s(:call, nil, :a, s(:arglist))), s(:evstr, s(:call, nil, :b, s(:arglist)))) - - assert_equal pt, @processor.parse(rb) - end - - def test_evstr_str - rb = "\"#\{a} b\"" - pt = s(:dstr, "", s(:evstr, s(:call, nil, :a, s(:arglist))), s(:str, " b")) - - assert_equal pt, @processor.parse(rb) - end - - def test_lasgn_env - rb = 'a = 42' - pt = s(:lasgn, :a, s(:lit, 42)) - expected_env = { :a => :lvar } - - assert_equal pt, @processor.parse(rb) - assert_equal expected_env, @processor.env.all - end - - def test_list_append - a = s(:lit, 1) - b = s(:lit, 2) - c = s(:lit, 3) - - result = @processor.list_append(s(:array, b.dup), c.dup) - - assert_equal s(:array, b, c), result - - result = @processor.list_append(b.dup, c.dup) - - assert_equal s(:array, b, c), result - - result = @processor.list_append(result, a.dup) - - assert_equal s(:array, b, c, a), result - - lhs, rhs = s(:array, s(:lit, :iter)), s(:when, s(:const, :BRANCHING), nil) - expected = s(:array, s(:lit, :iter), s(:when, s(:const, :BRANCHING), nil)) - - assert_equal expected, @processor.list_append(lhs, rhs) - end - - def test_list_prepend - a = s(:lit, 1) - b = s(:lit, 2) - c = s(:lit, 3) - - result = @processor.list_prepend(b.dup, s(:array, c.dup)) - - assert_equal s(:array, b, c), result - - result = @processor.list_prepend(b.dup, c.dup) - - assert_equal s(:array, b, c), result - - result = @processor.list_prepend(a.dup, result) - - assert_equal s(:array, a, b, c), result - end - - def test_literal_concat_dstr_dstr - lhs = s(:dstr, "Failed to download spec ", - s(:evstr, s(:call, nil, :spec_name, s(:arglist))), - s(:str, " from "), - s(:evstr, s(:call, nil, :source_uri, s(:arglist))), - s(:str, ":\n")) - rhs = s(:dstr, "\t", - s(:evstr, s(:call, s(:ivar, :@fetch_error), :message))) - expected = s(:dstr, "Failed to download spec ", - s(:evstr, s(:call, nil, :spec_name, s(:arglist))), - s(:str, " from "), - s(:evstr, s(:call, nil, :source_uri, s(:arglist))), - s(:str, ":\n"), - s(:str, "\t"), - s(:evstr, s(:call, s(:ivar, :@fetch_error), :message))) - - assert_equal expected, @processor.literal_concat(lhs, rhs) - end - - def test_literal_concat_dstr_evstr - lhs, rhs = s(:dstr, "a"), s(:evstr, s(:call, nil, :b, s(:arglist))) - expected = s(:dstr, "a", s(:evstr, s(:call, nil, :b, s(:arglist)))) - - assert_equal expected, @processor.literal_concat(lhs, rhs) - end - - def test_literal_concat_evstr_evstr - lhs, rhs = s(:evstr, s(:lit, 1)), s(:evstr, s(:lit, 2)) - expected = s(:dstr, "", s(:evstr, s(:lit, 1)), s(:evstr, s(:lit, 2))) - - assert_equal expected, @processor.literal_concat(lhs, rhs) - end - - def test_literal_concat_str_evstr - lhs, rhs = s(:str, ""), s(:evstr, s(:str, "blah")) - - assert_equal s(:str, "blah"), @processor.literal_concat(lhs, rhs) - end - - def test_logop_12 - lhs = s(:lit, 1) - rhs = s(:lit, 2) - exp = s(:and, s(:lit, 1), s(:lit, 2)) - - assert_equal exp, @processor.logop(:and, lhs, rhs) - end - - def test_logop_1234_5 - lhs = s(:and, s(:lit, 1), s(:and, s(:lit, 2), s(:and, s(:lit, 3), s(:lit, 4)))) - rhs = s(:lit, 5) - exp = s(:and, - s(:lit, 1), - s(:and, - s(:lit, 2), - s(:and, - s(:lit, 3), - s(:and, - s(:lit, 4), - s(:lit, 5))))) - - assert_equal exp, @processor.logop(:and, lhs, rhs) - end - - def test_logop_123_4 - lhs = s(:and, s(:lit, 1), s(:and, s(:lit, 2), s(:lit, 3))) - rhs = s(:lit, 4) - exp = s(:and, - s(:lit, 1), - s(:and, - s(:lit, 2), - s(:and, - s(:lit, 3), - s(:lit, 4)))) - - assert_equal exp, @processor.logop(:and, lhs, rhs) - end - - def test_logop_12_3 - lhs = s(:and, s(:lit, 1), s(:lit, 2)) - rhs = s(:lit, 3) - exp = s(:and, s(:lit, 1), s(:and, s(:lit, 2), s(:lit, 3))) - - assert_equal exp, @processor.logop(:and, lhs, rhs) - end - - def test_logop_nested_mix - lhs = s(:or, s(:call, nil, :a, s(:arglist)), s(:call, nil, :b, s(:arglist))) - rhs = s(:and, s(:call, nil, :c, s(:arglist)), s(:call, nil, :d, s(:arglist))) - exp = s(:or, - s(:or, s(:call, nil, :a, s(:arglist)), s(:call, nil, :b, s(:arglist))), - s(:and, s(:call, nil, :c, s(:arglist)), s(:call, nil, :d, s(:arglist)))) - - lhs.paren = true - rhs.paren = true - - assert_equal exp, @processor.logop(:or, lhs, rhs) - end - - def test_str_evstr - rb = "\"a #\{b}\"" - pt = s(:dstr, "a ", s(:evstr, s(:call, nil, :b, s(:arglist)))) - - assert_equal pt, @processor.parse(rb) - end - - def test_regexp - regexps = { - "/wtf/" => /wtf/, - "/wtf/n" => /wtf/n, - "/wtf/m" => /wtf/m, - "/wtf/nm" => /wtf/nm, - "/wtf/nmnmnmnm" => /wtf/nm, - } - - regexps.each do |rb, lit| - assert_equal s(:lit, lit), @processor.parse(rb) - end - - # TODO: add more including interpolation etc - end - - def test_str_pct_Q_nested - rb = "%Q[before [#\{nest}] after]" - pt = s(:dstr, "before [", s(:evstr, s(:call, nil, :nest, s(:arglist))), s(:str, "] after")) - - assert_equal pt, @processor.parse(rb) - end - -# def test_str_pct_nested_nested -# rb = "%{ { #\{ \"#\{1}\" } } }" -# pt = s(:dstr, " { ", s(:evstr, s(:lit, 1)), s(:str, " } ")) - -# assert_equal pt, @processor.parse(rb) -# end - - def test_str_str - rb = "\"a #\{'b'}\"" - pt = s(:str, "a b") - - assert_equal pt, @processor.parse(rb) - end - - def test_str_str_str - rb = "\"a #\{'b'} c\"" - pt = s(:str, "a b c") - - assert_equal pt, @processor.parse(rb) - end - - STARTING_LINE = { - "case_nested_inner_no_expr" => 2, - "case_no_expr" => 2, - "case_splat" => 2, - "dstr_heredoc_expand" => 2, - "dstr_heredoc_windoze_sucks" => 2, - "dstr_heredoc_yet_again" => 2, - "str_heredoc" => 2, - "str_heredoc_call" => 2, - "str_heredoc_empty" => 2, - "str_heredoc_indent" => 2, - "structure_unused_literal_wwtt" => 3, # yes, 3... odd test - "undef_block_1" => 2, - "undef_block_2" => 2, - "undef_block_3" => 2, - "undef_block_wtf" => 2, - } - - def after_process_hook klass, node, data, input_name, output_name - expected = STARTING_LINE[node] || 1 - assert_equal expected, @result.line, "should have proper line number" - end - - def test_position_info - rb = "a = 42\np a" - pt = s(:block, - s(:lasgn, :a, s(:lit, 42)), - s(:call, nil, :p, s(:arglist, s(:lvar, :a)))) - - result = @processor.parse(rb, "blah.rb") - - assert_equal pt, result - - assert_equal 1, result.line, "block should have line number" - assert_equal 1, result.lasgn.line, "lasgn should have line number" - assert_equal 2, result.call.line, "call should have line number" - - expected = "blah.rb" - - assert_equal expected, result.file - assert_equal expected, result.lasgn.file - assert_equal expected, result.call.file - - assert_same result.file, result.lasgn.file - assert_same result.file, result.call.file - end - - def test_position_info2 - rb = "def x(y)\n p(y)\n y *= 2\n return y;\nend" # TODO: remove () & ; - pt = s(:defn, :x, s(:args, :y), - s(:scope, - s(:block, - s(:call, nil, :p, s(:arglist, s(:lvar, :y))), - s(:lasgn, :y, - s(:call, s(:lvar, :y), :*, s(:arglist, s(:lit, 2)))), - s(:return, s(:lvar, :y))))) - - result = @processor.parse(rb) - - assert_equal pt, result - - body = result.scope.block - - assert_equal 1, result.line, "defn should have line number" - assert_equal 2, body.call.line, "call should have line number" - assert_equal 3, body.lasgn.line, "lasgn should have line number" - assert_equal 4, body.return.line, "return should have line number" - end -end diff --git a/vendor/gems/ruby_parser-2.0.5/test/test_ruby_parser_extras.rb b/vendor/gems/ruby_parser-2.0.5/test/test_ruby_parser_extras.rb deleted file mode 100644 index d56bd73015b..00000000000 --- a/vendor/gems/ruby_parser-2.0.5/test/test_ruby_parser_extras.rb +++ /dev/null @@ -1,178 +0,0 @@ -require 'rubygems' -require 'minitest/autorun' -require 'ruby_parser_extras' - -class TestStackState < MiniTest::Unit::TestCase - def test_stack_state - s = StackState.new :test - s.push true - s.push false - s.lexpop - assert_equal [false, true], s.stack - end - - def test_is_in_state - s = StackState.new :test - assert_equal false, s.is_in_state - s.push false - assert_equal false, s.is_in_state - s.push true - assert_equal true, s.is_in_state - s.push false - assert_equal false, s.is_in_state - end - - def test_lexpop - s = StackState.new :test - assert_equal [false], s.stack - s.push true - s.push false - assert_equal [false, true, false], s.stack - s.lexpop - assert_equal [false, true], s.stack - end - - def test_pop - s = StackState.new :test - assert_equal [false], s.stack - s.push true - assert_equal [false, true], s.stack - assert_equal true, s.pop - assert_equal [false], s.stack - end - - def test_push - s = StackState.new :test - assert_equal [false], s.stack - s.push true - s.push false - assert_equal [false, true, false], s.stack - end -end - -class TestEnvironment < MiniTest::Unit::TestCase - def deny t - assert ! t - end - - def setup - @env = Environment.new - @env[:blah] = 42 - assert_equal 42, @env[:blah] - end - - def test_use - @env.use :blah - expected = [{ :blah => true }] - assert_equal expected, @env.instance_variable_get(:"@use") - end - - def test_use_scoped - @env.use :blah - @env.extend - expected = [{}, { :blah => true }] - assert_equal expected, @env.instance_variable_get(:"@use") - end - - def test_used_eh - @env.extend :dynamic - @env[:x] = :dvar - @env.use :x - assert_equal true, @env.used?(:x) - end - - def test_used_eh_none - assert_equal nil, @env.used?(:x) - end - - def test_used_eh_scoped - self.test_used_eh - @env.extend :dynamic - assert_equal true, @env.used?(:x) - end - - def test_var_scope_dynamic - @env.extend :dynamic - assert_equal 42, @env[:blah] - @env.unextend - assert_equal 42, @env[:blah] - end - - def test_var_scope_static - @env.extend - assert_equal nil, @env[:blah] - @env.unextend - assert_equal 42, @env[:blah] - end - - def test_dynamic - expected1 = {} - expected2 = { :x => 42 } - - assert_equal expected1, @env.dynamic - begin - @env.extend :dynamic - assert_equal expected1, @env.dynamic - - @env[:x] = 42 - assert_equal expected2, @env.dynamic - - begin - @env.extend :dynamic - assert_equal expected2, @env.dynamic - @env.unextend - end - - assert_equal expected2, @env.dynamic - @env.unextend - end - assert_equal expected1, @env.dynamic - end - - def test_all_dynamic - expected = { :blah => 42 } - - @env.extend :dynamic - assert_equal expected, @env.all - @env.unextend - assert_equal expected, @env.all - end - - def test_all_static - @env.extend - expected = { } - assert_equal expected, @env.all - - @env.unextend - expected = { :blah => 42 } - assert_equal expected, @env.all - end - - def test_dynamic_eh - assert_equal false, @env.dynamic? - @env.extend :dynamic - assert_equal true, @env.dynamic? - @env.extend - assert_equal false, @env.dynamic? - end - - def test_all_static_deeper - expected0 = { :blah => 42 } - expected1 = { :blah => 42, :blah2 => 24 } - expected2 = { :blah => 27 } - - @env.extend :dynamic - @env[:blah2] = 24 - assert_equal expected1, @env.all - - @env.extend - @env[:blah] = 27 - assert_equal expected2, @env.all - - @env.unextend - assert_equal expected1, @env.all - - @env.unextend - assert_equal expected0, @env.all - end -end diff --git a/vendor/gems/safemode-1.0/.specification b/vendor/gems/safemode-1.0/.specification deleted file mode 100644 index 7bf0c968cb7..00000000000 --- a/vendor/gems/safemode-1.0/.specification +++ /dev/null @@ -1,82 +0,0 @@ ---- !ruby/object:Gem::Specification -name: safemode -version: !ruby/object:Gem::Version - hash: 15 - prerelease: false - segments: - - 1 - - 0 - version: "1.0" -platform: ruby -authors: -- foobar -autorequire: -bindir: bin -cert_chain: [] - -date: 2010-11-30 07:00:00 +02:00 -default_executable: -dependencies: [] - -description: this is a desc -email: foo@foobar.org -executables: [] - -extensions: [] - -extra_rdoc_files: [] - -files: -- LICENCSE -- README.markdown -- init.rb -- lib/safemode.rb -- lib/safemode/core_jails.rb -- lib/safemode/jail.rb -- lib/safemode/core_ext.rb -- lib/safemode/exceptions.rb -- lib/safemode/blankslate.rb -- lib/safemode/parser.rb -- lib/safemode/scope.rb -- lib/haml/safemode.rb -- lib/action_view/template_handlers/safemode_handler.rb -- lib/action_view/template_handlers/safe_haml.rb -- lib/action_view/template_handlers/safe_erb.rb -- lib/rubyparser_bug.rb -- lib/ruby_parser_string_io_patch.diff -has_rdoc: true -homepage: http://safemode.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: -rubygems_version: 1.3.7 -signing_key: -specification_version: 3 -summary: safemode does stuff that is safe -test_files: [] - diff --git a/vendor/gems/safemode-1.0/LICENCSE b/vendor/gems/safemode-1.0/LICENCSE deleted file mode 100644 index 836ebe36b88..00000000000 --- a/vendor/gems/safemode-1.0/LICENCSE +++ /dev/null @@ -1,22 +0,0 @@ -Copyright (c) 2008, Sven Fuchs, Peter Cooper - -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/gems/safemode-1.0/README.markdown b/vendor/gems/safemode-1.0/README.markdown deleted file mode 100644 index 881b683fa92..00000000000 --- a/vendor/gems/safemode-1.0/README.markdown +++ /dev/null @@ -1,71 +0,0 @@ -## Safemode - -A library for safe evaluation of Ruby code based on RubyParser and -Ruby2Ruby. Provides Rails ActionView template handlers for ERB and Haml. - -### Word of warning - -This library is still highly experimental. Only use it at your own risk for -anything beyond experiments and playing. - -That said, please **do** play with it, read and run the unit tests and provide -feedback to help make it waterproof and finally suitable for serious purposes. - -### Usage - -For manual evaluation of Ruby code and ERB templates see demo.rb - -You can use the ActionView template handlers by registering them, e.g., in -a config/initializer file like this: - - # in config/intializer/safemode_tempate_handlers.rb - ActionView::Template.register_template_handler :serb, ActionView::TemplateHandlers::SafeErb - ActionView::Template.register_template_handler :haml, ActionView::TemplateHandlers::SafeHaml - -If you register the ERB template handler for the file extension :erb be aware -that this most probably will break when your application tries to render an -error message in development mode (because Rails will try to use the handler -to render the error message itself). - -You will then have to "whitelist" all method calls to the objects that are -registered as template variables by explicitely allowing access to them. You -can do that by defining a Safemode::Jail class for your classes, like so: - - class User - class Jail < Safemode::Jail - allow :name - end - end - -This will allow your template users to access the name method on your User -objects. - -For more details about the concepts behind Safemode please refer to the -following blog posts until a more comprehensive writeup is available: - -* Initial reasoning: [http://www.artweb-design.de/2008/2/5/sexy-theme-templating-with-haml-safemode-finally](http://www.artweb-design.de/2008/2/5/sexy-theme-templating-with-haml-safemode-finally) -* Refined concept: [http://www.artweb-design.de/2008/2/17/sending-ruby-to-the-jail-an-attemp-on-a-haml-safemode](http://www.artweb-design.de/2008/2/17/sending-ruby-to-the-jail-an-attemp-on-a-haml-safemode) -* ActionView ERB handler: [http://www.artweb-design.de/2008/4/22/an-erb-safemode-handler-for-actionview](http://www.artweb-design.de/2008/4/22/an-erb-safemode-handler-for-actionview) - -### Dependencies - -Requires the gems: - -* RubyParser -* Ruby2Ruby - -As of writing RubyParser alters StringIO and thus breaks usage with Rails. -See [http://www.zenspider.com/pipermail/parsetree/2008-April/000026.html](http://www.zenspider.com/pipermail/parsetree/2008-April/000026.html) - -A patch is included that fixes this issue and can be applied to RubyParser. -See lib/ruby\_parser\_string\_io\_patch.diff - -### Credits - -* Sven Fuchs - Maintainer -* Peter Cooper - -This code and all of the Safemode library's code was initially written by -Sven Fuchs to allow Haml to have a safe mode. It was then modified and -re-structured by Peter Cooper and Sven Fuchs to extend the idea to generic -Ruby eval situations. diff --git a/vendor/gems/safemode-1.0/Rakefile b/vendor/gems/safemode-1.0/Rakefile deleted file mode 100644 index a51d1f75495..00000000000 --- a/vendor/gems/safemode-1.0/Rakefile +++ /dev/null @@ -1,15 +0,0 @@ -# optional libraries -%w[ redgreen ].each do |lib| - begin - require lib - rescue LoadError - end -end - -task :default => [:test] - -task :test do - ['test/unit', 'test/test_helper', 'test/test_all'].each do |file| - require file - end -end diff --git a/vendor/gems/safemode-1.0/demo.rb b/vendor/gems/safemode-1.0/demo.rb deleted file mode 100644 index b18b2e531da..00000000000 --- a/vendor/gems/safemode-1.0/demo.rb +++ /dev/null @@ -1,23 +0,0 @@ -require 'safemode' -require 'erb' - -erb_code = %q{<% 10.times do |i| %><%= i %><% end %>} - -raw_code = %q{ - (1..10).to_a.collect do |i| - puts i - i * 2 - end.join(', ') -} - -box = Safemode::Box.new - -puts "Doing the ERB code in safe mode\n-----" -puts box.eval(ERB.new(erb_code).src) - -puts "\nDoing the regular Ruby code in safe mode\n-----" -puts box.eval(raw_code) - -puts "\nOutput from regular Ruby code\n-----" -puts box.output - diff --git a/vendor/gems/safemode-1.0/init.rb b/vendor/gems/safemode-1.0/init.rb deleted file mode 100644 index 5e94a4a32b8..00000000000 --- a/vendor/gems/safemode-1.0/init.rb +++ /dev/null @@ -1 +0,0 @@ -require 'safemode' diff --git a/vendor/gems/safemode-1.0/lib/action_view/template_handlers/safe_erb.rb b/vendor/gems/safemode-1.0/lib/action_view/template_handlers/safe_erb.rb deleted file mode 100644 index 6c20a0b8073..00000000000 --- a/vendor/gems/safemode-1.0/lib/action_view/template_handlers/safe_erb.rb +++ /dev/null @@ -1,43 +0,0 @@ -require 'safemode' -require 'erb' - -module ActionView - module TemplateHandlers - class SafeErb < TemplateHandler - include Compilable rescue nil # does not exist prior Rails 2.1 - extend SafemodeHandler - - def self.line_offset - 0 - end - - def compile(template) - # Rails 2.0 passes the template source, while Rails 2.1 passes the - # template instance - src = template.respond_to?(:source) ? template.source : template - filename = template.filename rescue nil - erb_trim_mode = '-' - - # code = ::ERB.new(src, nil, @view.erb_trim_mode).src - code = ::ERB.new("<% __in_erb_template=true %>#{src}", nil, erb_trim_mode, '@output_buffer').src - # Ruby 1.9 prepends an encoding to the source. However this is - # useless because you can only set an encoding on the first line - RUBY_VERSION >= '1.9' ? src.sub(/\A#coding:.*\n/, '') : src - - code.gsub!('\\','\\\\\\') # backslashes would disappear in compile_template/modul_eval, so we escape them - - code = <<-CODE - handler = ActionView::TemplateHandlers::SafeHaml - assigns = handler.valid_assigns(@template.assigns) - methods = handler.delegate_methods(self) - code = %Q(#{code}); - - box = Safemode::Box.new(self, methods, #{filename.inspect}, 0) - box.eval(code, assigns, local_assigns, &lambda{ |*args| yield(*args) }) - CODE - # puts code - code - end - end - end -end diff --git a/vendor/gems/safemode-1.0/lib/action_view/template_handlers/safe_haml.rb b/vendor/gems/safemode-1.0/lib/action_view/template_handlers/safe_haml.rb deleted file mode 100644 index c9d6314cc8e..00000000000 --- a/vendor/gems/safemode-1.0/lib/action_view/template_handlers/safe_haml.rb +++ /dev/null @@ -1,27 +0,0 @@ -require 'safemode' -require 'haml/safemode' - -module ActionView - module TemplateHandlers - class SafeHaml < TemplateHandler - include Compilable rescue nil # does not exist prior Rails 2.1 - extend SafemodeHandler - - def self.line_offset - 3 - end - - def compile(template) - # Rails 2.0 passes the template source, while Rails 2.1 passes the - # template instance - src = template.respond_to?(:source) ? template.source : template - filename = template.filename rescue nil - - options = Haml::Template.options.dup - haml = Haml::Engine.new template, options - methods = delegate_methods + ActionController::Routing::Routes.named_routes.helpers - haml.precompile_for_safemode filename, ignore_assigns, methods - end - end - end -end \ No newline at end of file diff --git a/vendor/gems/safemode-1.0/lib/action_view/template_handlers/safemode_handler.rb b/vendor/gems/safemode-1.0/lib/action_view/template_handlers/safemode_handler.rb deleted file mode 100644 index 76174218b72..00000000000 --- a/vendor/gems/safemode-1.0/lib/action_view/template_handlers/safemode_handler.rb +++ /dev/null @@ -1,28 +0,0 @@ -module ActionView - module TemplateHandlers - module SafemodeHandler - - def valid_assigns(assigns) - assigns = assigns.reject{|key, value| skip_assigns.include?(key) } - end - - def delegate_methods(view) - [ :render, :params, :flash ] + - helper_methods(view) + - ActionController::Routing::Routes.named_routes.helpers - end - - def helper_methods(view) - view.class.included_modules.collect {|m| m.instance_methods(false) }.flatten.map(&:to_sym) - end - - def skip_assigns - [ "_cookies", "_flash", "_headers", "_params", "_request", - "_response", "_session", "before_filter_chain_aborted", - "ignore_missing_templates", "logger", "request_origin", - "template", "template_class", "url", "variables_added", - "view_paths" ] - end - end - end -end \ No newline at end of file diff --git a/vendor/gems/safemode-1.0/lib/haml/safemode.rb b/vendor/gems/safemode-1.0/lib/haml/safemode.rb deleted file mode 100644 index b6fc79955ae..00000000000 --- a/vendor/gems/safemode-1.0/lib/haml/safemode.rb +++ /dev/null @@ -1,41 +0,0 @@ -require 'haml' - -module Haml - class Buffer - class Jail < Safemode::Jail - allow :push_script, :push_text, :_hamlout, :open_tag - end - end -end - -module Haml - class Engine - def precompile_for_safemode(filename, ignore_assigns = [], delegate_methods = []) - @precompiled.gsub!('\\','\\\\\\') # backslashes would disappear in compile_template/modul_eval, so we escape them - - <<-CODE - buffer = Haml::Buffer.new(#{options_for_buffer.inspect}) - local_assigns = local_assigns.merge :_hamlout => buffer - - handler = ActionView::TemplateHandlers::SafeHaml - assigns = handler.valid_assigns(@template.assigns) - methods = handler.delegate_methods(self) - code = %Q(#{code}); - - box = Safemode::Box.new(self, methods, #{filename.inspect}, 0) - box.eval(code, assigns, local_assigns, &lambda{ yield }) - buffer.buffer - CODE - - # preamble = "buffer = Haml::Buffer.new(#{options_for_buffer.inspect}) - # local_assigns = local_assigns.merge :_hamlout => buffer - # assigns = @template.assigns.reject{|key, value| #{ignore_assigns.inspect}.include?(key) };".gsub("\n", ';') - # - # postamble = "box = Safemode::Box.new(self, #{delegate_methods.inspect}) - # box.eval(code, assigns, local_assigns, &lambda{ yield }) - # buffer.buffer".gsub("\n", ';') - # - # preamble + "code = %Q(#{@precompiled});" + postamble - end - end -end \ No newline at end of file diff --git a/vendor/gems/safemode-1.0/lib/ruby_parser_string_io_patch.diff b/vendor/gems/safemode-1.0/lib/ruby_parser_string_io_patch.diff deleted file mode 100644 index 6742168db65..00000000000 --- a/vendor/gems/safemode-1.0/lib/ruby_parser_string_io_patch.diff +++ /dev/null @@ -1,194 +0,0 @@ ---- lib/ruby_lexer.rb 2008-04-27 01:07:24.000000000 +0200 -+++ lib/ruby_lexer.rb 2008-04-27 01:07:03.000000000 +0200 -@@ -45,7 +45,7 @@ - raise "bad val: #{str.inspect}" unless String === str - - self.file = file -- self.lexer.src = StringIO.new(str) -+ self.lexer.src = RubyParser::StringIO.new(str) - - @yydebug = ENV.has_key? 'DEBUG' - -@@ -2604,104 +2604,106 @@ - end - end - --class StringIO # HACK: everything in here is a hack -- attr_accessor :begin_of_line, :was_begin_of_line -- alias :begin_of_line? :begin_of_line -- alias :read_all :read -+class RubyParser -+ class StringIO < StringIO # HACK: everything in here is a hack -+ attr_accessor :begin_of_line, :was_begin_of_line -+ alias :begin_of_line? :begin_of_line -+ alias :read_all :read - -- alias :old_initialize :initialize -+ alias :old_initialize :initialize - -- def initialize(*args) -- self.begin_of_line = true -- self.was_begin_of_line = false -- old_initialize(*args) -- @original_string = self.string.dup -- end -+ def initialize(*args) -+ self.begin_of_line = true -+ self.was_begin_of_line = false -+ old_initialize(*args) -+ @original_string = self.string.dup -+ end - -- def rest -- self.string[self.pos..-1] -- end -+ def rest -+ self.string[self.pos..-1] -+ end - -- def current_line # HAHA fuck you -- @original_string[0..self.pos][/\A.*__LINE__/m].split(/\n/).size -- end -+ def current_line # HAHA fuck you -+ @original_string[0..self.pos][/\A.*__LINE__/m].split(/\n/).size -+ end - -- def read -- c = self.getc -+ def read -+ c = self.getc - -- if c == ?\r then -- d = self.getc -- self.ungetc d if d and d != ?\n -- c = ?\n -- end -+ if c == ?\r then -+ d = self.getc -+ self.ungetc d if d and d != ?\n -+ c = ?\n -+ end - -- self.was_begin_of_line = self.begin_of_line -- self.begin_of_line = c == ?\n -- if c and c != 0 then -- c.chr -- else -- ::RubyLexer::EOF -+ self.was_begin_of_line = self.begin_of_line -+ self.begin_of_line = c == ?\n -+ if c and c != 0 then -+ c.chr -+ else -+ ::RubyLexer::EOF -+ end - end -- end - -- def match_string term, indent=false # TODO: add case insensitivity, or just remove -- buffer = [] -+ def match_string term, indent=false # TODO: add case insensitivity, or just remove -+ buffer = [] - -- if indent -- while c = self.read do -- if c !~ /\s/ or c == "\n" or c == "\r" then -- self.unread c -- break -+ if indent -+ while c = self.read do -+ if c !~ /\s/ or c == "\n" or c == "\r" then -+ self.unread c -+ break -+ end -+ buffer << c - end -- buffer << c - end -- end - -- term.each_byte do |c2| -- c = self.read -- c = self.read if c and c == "\r" -- buffer << c -- if c and c2 != c[0] then -- self.unread_many buffer.join # HACK omg -- return false -+ term.each_byte do |c2| -+ c = self.read -+ c = self.read if c and c == "\r" -+ buffer << c -+ if c and c2 != c[0] then -+ self.unread_many buffer.join # HACK omg -+ return false -+ end - end -+ -+ return true - end - -- return true -- end -+ def read_line -+ self.begin_of_line = true -+ self.was_begin_of_line = false -+ gets.sub(/\r\n?$/, "\n") # HACK -+ end - -- def read_line -- self.begin_of_line = true -- self.was_begin_of_line = false -- gets.sub(/\r\n?$/, "\n") # HACK -- end -- -- def peek expected = nil # FIX: barf -- c = self.getc -- return RubyLexer::EOF if c.nil? -- self.ungetc c if c -- c = c.chr if c -- if expected then -- c == expected -- else -- c -+ def peek expected = nil # FIX: barf -+ c = self.getc -+ return RubyLexer::EOF if c.nil? -+ self.ungetc c if c -+ c = c.chr if c -+ if expected then -+ c == expected -+ else -+ c -+ end - end -- end - -- def unread(c) -- return if c.nil? # UGH -+ def unread(c) -+ return if c.nil? # UGH - -- # HACK: only depth is 2... who cares? really I want to remove all of this -- self.begin_of_line = self.was_begin_of_line || true -- self.was_begin_of_line = nil -+ # HACK: only depth is 2... who cares? really I want to remove all of this -+ self.begin_of_line = self.was_begin_of_line || true -+ self.was_begin_of_line = nil - -- c = c[0] if String === c -- self.ungetc c -- end -+ c = c[0] if String === c -+ self.ungetc c -+ end - -- def unread_many str -- str.split(//).reverse.each do |c| -- unread c -+ def unread_many str -+ str.split(//).reverse.each do |c| -+ unread c -+ end - end - end - end diff --git a/vendor/gems/safemode-1.0/lib/rubyparser_bug.rb b/vendor/gems/safemode-1.0/lib/rubyparser_bug.rb deleted file mode 100644 index f5d1ba0d6aa..00000000000 --- a/vendor/gems/safemode-1.0/lib/rubyparser_bug.rb +++ /dev/null @@ -1,8 +0,0 @@ -require 'rubygems' -require 'ruby2ruby' - -sexp = ParseTree.translate('a') -puts Ruby2Ruby.new.process(sexp) - -# should work, but yields: -# UnknownNodeError: Bug! Unknown node-type :vcall to Ruby2Ruby \ No newline at end of file diff --git a/vendor/gems/safemode-1.0/lib/safemode.rb b/vendor/gems/safemode-1.0/lib/safemode.rb deleted file mode 100644 index d032b1f49b2..00000000000 --- a/vendor/gems/safemode-1.0/lib/safemode.rb +++ /dev/null @@ -1,58 +0,0 @@ -require 'rubygems' - -require 'ruby2ruby' -begin - require 'ruby_parser' # try to load RubyParser and use it if present -rescue LoadError => e -end -# this doesn't work somehow. Maybe something changed inside -# ParseTree or sexp_processor or so. -# (the require itself works, but ParseTree doesn't play nice) -# begin -# require 'parse_tree' -# rescue LoadError => e -# end - -require 'safemode/core_ext' -require 'safemode/blankslate' -require 'safemode/exceptions' -require 'safemode/jail' -require 'safemode/core_jails' -require 'safemode/parser' -require 'safemode/scope' - -module Safemode - class << self - def jail(obj) - find_jail_class(obj.class).new obj - end - - def find_jail_class(klass) - while klass != Object - return klass.const_get('Jail') if klass.const_defined?('Jail') - klass = klass.superclass - end - Jail - end - end - - define_core_jail_classes - - class Box - def initialize(delegate = nil, delegate_methods = [], filename = nil, line = nil) - @scope = Scope.new(delegate, delegate_methods) - @filename = filename - @line = line - end - - def eval(code, assigns = {}, locals = {}, &block) - code = Parser.jail(code) - binding = @scope.bind(assigns, locals, &block) - result = Kernel.eval(code, binding, @filename || __FILE__, @line || __LINE__) - end - - def output - @scope.output - end - end -end diff --git a/vendor/gems/safemode-1.0/lib/safemode/blankslate.rb b/vendor/gems/safemode-1.0/lib/safemode/blankslate.rb deleted file mode 100644 index d1a79548628..00000000000 --- a/vendor/gems/safemode-1.0/lib/safemode/blankslate.rb +++ /dev/null @@ -1,34 +0,0 @@ -module Safemode - class Blankslate - @@allow_instance_methods = ['class', 'inspect', 'methods', 'respond_to?', 'to_s', 'instance_variable_get'] - @@allow_class_methods = ['methods', 'new', 'name', 'inspect', '<', 'ancestors', '=='] # < needed in Rails Object#subclasses_of - - silently { undef_methods(*instance_methods - @@allow_instance_methods) } - class << self - silently { undef_methods(*instance_methods - @@allow_class_methods) } - - def method_added(name) end # ActiveSupport needs this - - def inherited(subclass) - subclass.init_allowed_methods(@allowed_methods) - end - - def init_allowed_methods(allowed_methods) - @allowed_methods = allowed_methods - end - - def allowed_methods - @allowed_methods ||= [] - end - - def allow(*names) - @allowed_methods = allowed_methods + names.map{|name| name.to_s} - @allowed_methods.uniq! - end - - def allowed?(name) - allowed_methods.include? name.to_s - end - end - end -end diff --git a/vendor/gems/safemode-1.0/lib/safemode/core_ext.rb b/vendor/gems/safemode-1.0/lib/safemode/core_ext.rb deleted file mode 100644 index 9d89be52ebf..00000000000 --- a/vendor/gems/safemode-1.0/lib/safemode/core_ext.rb +++ /dev/null @@ -1,39 +0,0 @@ -module Kernel - def silently(&blk) - old_verbose, $VERBOSE = $VERBOSE, nil - yield - $VERBOSE = old_verbose - end -end - -class Module - def undef_methods(*methods) - methods.each { |name| undef_method(name) } - end -end - -class Object - def to_jail - Safemode.jail self - end -end - -# As every call to an object in the eval'ed string will be jailed by the -# parser we don't need to "proactively" jail arrays and hashes. Likewise we -# don't need to jail objects returned from a jail. Doing so would provide -# "double" protection, but it also would break using a return value in an if -# statement, passing them to a Rails helper etc. - -# class Array -# def to_jail -# Safemode.jail collect{ |obj| obj.to_jail } -# end -# end -# -# class Hash -# def to_jail -# hash = {} -# collect{ |key, obj| hash[key] = obj.to_jail} -# Safemode.jail hash -# end -# end \ No newline at end of file diff --git a/vendor/gems/safemode-1.0/lib/safemode/core_jails.rb b/vendor/gems/safemode-1.0/lib/safemode/core_jails.rb deleted file mode 100644 index f6a04bfeeca..00000000000 --- a/vendor/gems/safemode-1.0/lib/safemode/core_jails.rb +++ /dev/null @@ -1,104 +0,0 @@ -module Safemode - class << self - def define_core_jail_classes - core_classes.each do |klass| - define_jail_class(klass).allow *core_jail_methods(klass).uniq - end - end - - def define_jail_class(klass) - unless klass.const_defined?("Jail") - klass.const_set("Jail", jail = Class.new(Safemode::Jail)) - end - klass.const_get('Jail') - end - - def core_classes - klasses = [ Array, Bignum, Fixnum, Float, Hash, - Range, String, Symbol, Time ] - klasses << Date if defined? Date - klasses << DateTime if defined? DateTime - klasses - end - - def core_jail_methods(klass) - @@methods_whitelist[klass.name] + (@@default_methods & klass.instance_methods) - end - end - - # these methods are allowed in all classes if they are present - @@default_methods = %w( % & * ** + +@ - -@ / < << <= <=> == === > >= >> ^ | ~ - eql? equal? new methods is_a? kind_of? nil? - [] []= to_a to_jail to_s inspect to_param ) - - # whitelisted methods for core classes ... kind of arbitrary selection - @@methods_whitelist = { - 'Array' => %w(assoc at blank? collect collect! compact compact! concat - delete delete_at delete_if each each_index empty? fetch - fill first flatten flatten! hash include? index indexes - indices inject insert join last length map map! nitems pop - push rassoc reject reject! reverse reverse! reverse_each - rindex select shift size slice slice! sort sort! transpose - uniq uniq! unshift values_at zip), - - 'Bignum' => %w(abs ceil chr coerce div divmod downto floor hash - integer? modulo next nonzero? quo remainder round - singleton_method_added size step succ times to_f to_i - to_int to_s truncate upto zero?), - - 'Fixnum' => %w(abs ceil chr coerce div divmod downto floor id2name - integer? modulo modulo next nonzero? quo remainder round - singleton_method_added size step succ times to_f to_i - to_int to_s to_sym truncate upto zero?), - - 'Float' => %w(abs ceil coerce div divmod finite? floor hash - infinite? integer? modulo nan? nonzero? quo remainder - round singleton_method_added step to_f to_i to_int to_s - truncate zero?), - - 'Hash' => %w(blank? clear delete delete_if each each_key each_pair - each_value empty? fetch has_key? has_value? include? index - invert key? keys length member? merge merge! rec_merge! rehash - reject reject! select shift size sort store - update value? values values_at), - - 'Range' => %w(begin each end exclude_end? first hash include? - include_without_range? last member? step), - - 'String' => %w(blank? capitalize capitalize! casecmp center chomp chomp! - chop chop! concat count crypt delete delete! downcase - downcase! dump each each_byte each_line empty? end_with? gsub - gsub! hash hex include? index insert intern iseuc issjis - isutf8 kconv length ljust lstrip lstrip! match next next! oct - reverse reverse! rindex rjust rstrip rstrip! scan size slice - slice! split squeeze squeeze! start_with? strip strip! sub - sub! succ succ! sum swapcase swapcase! to_f to_i to_str to_sym - to_xs toeuc tojis tosjis toutf16 toutf8 tr tr! tr_s tr_s! - upcase upcase! upto), - - 'Symbol' => %w(to_i to_int), - - 'Time' => %w(_dump asctime ctime day dst? getgm getlocal getutc gmt? - gmt_offset gmtime gmtoff hash hour httpdate isdst iso8601 - localtime mday min minus_without_duration mon month - plus_without_duration rfc2822 rfc822 sec strftime succ to_date - to_datetime to_f to_i tv_sec tv_usec usec utc utc? utc_offset - wday xmlschema yday year zone to_formatted_s), - - 'Date' => %w(ajd amjd asctime ctime cwday cweek cwyear day day_fraction - default_inspect downto england gregorian gregorian? hash italy - jd julian julian? ld leap? mday minus_without_duration mjd mon - month new_start newsg next ns? os? plus_without_duration sg - start step strftime succ upto wday yday year), - - 'DateTime' => %w(hour, min, new_offset, newof, of, offset, sec, - sec_fraction, strftime, to_datetime_default_s, to_json, zone), - - 'NilClass' => %w(blank? duplicable? to_f to_i), - - 'FalseClass' => %w(blank? duplicable?), - - 'TrueClass' => %w(blank? duplicable?) - - } -end \ No newline at end of file diff --git a/vendor/gems/safemode-1.0/lib/safemode/exceptions.rb b/vendor/gems/safemode-1.0/lib/safemode/exceptions.rb deleted file mode 100644 index dffadd39938..00000000000 --- a/vendor/gems/safemode-1.0/lib/safemode/exceptions.rb +++ /dev/null @@ -1,22 +0,0 @@ -module Safemode - class Error < RuntimeError; end - - class SecurityError < Error - @@types = { :const => 'constant', - :xstr => 'shell command', - :fcall => 'method', - :vcall => 'method', - :gvar => 'global variable' } - - def initialize(type, value = nil) - type = @@types[type] if @@types.include?(type) - super "Safemode doesn't allow to access '#{type}'" + (value ? " on #{value}" : '') - end - end - - class NoMethodError < Error - def initialize(method, jail, source = nil) - super "undefined method '#{method}' for #{jail}" + (source ? " (#{source})" : '') - end - end -end \ No newline at end of file diff --git a/vendor/gems/safemode-1.0/lib/safemode/jail.rb b/vendor/gems/safemode-1.0/lib/safemode/jail.rb deleted file mode 100644 index 1aeaabfc80e..00000000000 --- a/vendor/gems/safemode-1.0/lib/safemode/jail.rb +++ /dev/null @@ -1,28 +0,0 @@ -module Safemode - class Jail < Blankslate - def initialize(source = nil) - @source = source - end - - def to_jail - self - end - - def to_s - @source.to_s - end - - def method_missing(method, *args, &block) - unless self.class.allowed?(method) - raise Safemode::NoMethodError.new(method, self.class.name, @source.class.name) - end - - # As every call to an object in the eval'ed string will be jailed by the - # parser we don't need to "proactively" jail arrays and hashes. Likewise we - # don't need to jail objects returned from a jail. Doing so would provide - # "double" protection, but it also would break using a return value in an if - # statement, passing them to a Rails helper etc. - @source.send(method, *args, &block) - end - end -end \ No newline at end of file diff --git a/vendor/gems/safemode-1.0/lib/safemode/parser.rb b/vendor/gems/safemode-1.0/lib/safemode/parser.rb deleted file mode 100644 index a1516aa08dd..00000000000 --- a/vendor/gems/safemode-1.0/lib/safemode/parser.rb +++ /dev/null @@ -1,196 +0,0 @@ -module Safemode - class Parser < Ruby2Ruby - # @@parser = defined?(RubyParser) ? 'RubyParser' : 'ParseTree' - @@parser = 'RubyParser' - - class << self - def jail(code, allowed_fcalls = []) - @@allowed_fcalls = allowed_fcalls - tree = parse code - self.new.process(tree) - end - - def parse(code) - case @@parser - # when 'ParseTree' - # ParseTree.translate(code) - when 'RubyParser' - RubyParser.new.parse(code) - else - raise "unknown parser #{@@parser}" - end - end - - def parser=(parser) - @@parser = parser - end - end - - def jail(str, parentheses = false) - str = parentheses ? "(#{str})." : "#{str}." if str - "#{str}to_jail" - end - - # split up #process_call. see below ... - def process_call(exp) - receiver = jail process_call_receiver(exp) - name = exp.shift - args = process_call_args(exp) - process_call_code(receiver, name, args) - end - - def process_fcall(exp) - # using haml we probably never arrive here because :lasgn'ed :fcalls - # somehow seem to change to :calls somewhere during processing - # unless @@allowed_fcalls.include?(exp.first) - # code = Ruby2Ruby.new.process([:fcall, exp[1], exp[2]]) # wtf ... - # raise_security_error(exp.first, code) - # end - "to_jail.#{super}" - end - - def process_vcall(exp) - # unless @@allowed_fcalls.include?(exp.first) - # code = Ruby2Ruby.new.process([:fcall, exp[1], exp[2]]) # wtf ... - # raise_security_error(exp.first, code) - # end - name = exp[1] - exp.clear - "to_jail.#{name}" - end - - def process_iasgn(exp) - code = super - if code != '@output_buffer = ""' - raise_security_error(:iasgn, code) - else - code - end - end - - # see http://www.namikilab.tuat.ac.jp/~sasada/prog/rubynodes/nodes.html - - allowed = [ :call, :vcall, :evstr, - :lvar, :dvar, :ivar, :lasgn, :masgn, :dasgn, :dasgn_curr, - :lit, :str, :dstr, :dsym, :nil, :true, :false, - :array, :zarray, :hash, :dot2, :dot3, :flip2, :flip3, - :if, :case, :when, :while, :until, :iter, :for, :break, :next, :yield, - :and, :or, :not, - :iasgn, # iasgn is sometimes allowed - # not sure about self ... - :self, - # unnecessarily advanced? - :argscat, :argspush, :splat, :block_pass, - :op_asgn1, :op_asgn2, :op_asgn_and, :op_asgn_or, - # needed for haml - :block ] - - disallowed = [ # :self, # self doesn't seem to be needed for vcalls? - :const, :defn, :defs, :alias, :valias, :undef, :class, :attrset, - :module, :sclass, :colon2, :colon3, - :fbody, :scope, :args, :block_arg, :postexe, - :redo, :retry, :begin, :rescue, :resbody, :ensure, - :defined, :super, :zsuper, :return, - :dmethod, :bmethod, :to_ary, :svalue, :match, - :attrasgn, :cdecl, :cvasgn, :cvdecl, :cvar, :gvar, :gasgn, - :xstr, :dxstr, - # not sure how secure ruby regexp is, so leave it out for now - :dregx, :dregx_once, :match2, :match3, :nth_ref, :back_ref ] - - # SexpProcessor bails when we overwrite these ... but they are listed as - # "internal nodes that you can't get to" in sexp_processor.rb - # :ifunc, :method, :last, :opt_n, :cfunc, :newline, :alloca, :memo, :cref - - disallowed.each do |name| - define_method "process_#{name}" do - code = super - raise_security_error(name, code) - end - end - - def raise_security_error(type, info) - raise Safemode::SecurityError.new(type, info) - end - - # split up Ruby2Ruby#process_call monster method so we can hook into it - # in a more readable manner - - def process_call_receiver(exp) - receiver_node_type = exp.first.nil? ? nil : exp.first.first - receiver = process exp.shift - receiver = "(#{receiver})" if - Ruby2Ruby::ASSIGN_NODES.include? receiver_node_type - receiver - end - - def process_call_args(exp) - args_exp = exp.shift rescue nil - if args_exp && args_exp.first == :array # FIX - args = "#{process(args_exp)[1..-2]}" - else - args = process args_exp - args = nil if args.empty? - end - args - end - - def process_call_code(receiver, name, args) - case name - when :<=>, :==, :<, :>, :<=, :>=, :-, :+, :*, :/, :%, :<<, :>>, :** then - "(#{receiver} #{name} #{args})" - when :[] then - "#{receiver}[#{args}]" - when :"-@" then - "-#{receiver}" - when :"+@" then - "+#{receiver}" - else - unless receiver.nil? then - "#{receiver}.#{name}#{args ? "(#{args})" : args}" - else - "#{name}#{args ? "(#{args})" : args}" - end - end - end - - # Ruby2Ruby process_if rewrites if and unless statements in a way that - # makes the result unusable for evaluation in, e.g. ERB which appends a - # call to to_s when using <%= %> tags. We'd need to either enclose the - # result from process_if into parentheses like (1 if true) and - # (true ? (1) : (2)) or just use the plain if-then-else-end syntax (so - # that ERB can safely append to_s to the resulting block). - - def process_if(exp) - expand = Ruby2Ruby::ASSIGN_NODES.include? exp.first.first - c = process exp.shift - t = process exp.shift - f = process exp.shift - - c = "(#{c.chomp})" if c =~ /\n/ - - if t then - # unless expand then - # if f then - # r = "#{c} ? (#{t}) : (#{f})" - # r = nil if r =~ /return/ # HACK - need contextual awareness or something - # else - # r = "#{t} if #{c}" - # end - # return r if r and (@indent+r).size < LINE_LENGTH and r !~ /\n/ - # end - - r = "if #{c} then\n#{indent(t)}\n" - r << "else\n#{indent(f)}\n" if f - r << "end" - - r - else - # unless expand then - # r = "#{f} unless #{c}" - # return r if (@indent+r).size < LINE_LENGTH and r !~ /\n/ - # end - "unless #{c} then\n#{indent(f)}\nend" - end - end - end -end diff --git a/vendor/gems/safemode-1.0/lib/safemode/scope.rb b/vendor/gems/safemode-1.0/lib/safemode/scope.rb deleted file mode 100644 index a70a804964e..00000000000 --- a/vendor/gems/safemode-1.0/lib/safemode/scope.rb +++ /dev/null @@ -1,58 +0,0 @@ -module Safemode - class Scope < Blankslate - def initialize(delegate = nil, delegate_methods = []) - @delegate = delegate - @delegate_methods = delegate_methods - @locals = {} - end - - def bind(instance_vars = {}, locals = {}, &block) - @locals = symbolize_keys(locals) # why can't I just pull them to local scope in the same way like instance_vars? - instance_vars = symbolize_keys(instance_vars) - instance_vars.each {|key, obj| eval "@#{key} = instance_vars[:#{key}]" } - @_safemode_output = '' - binding - end - - def to_jail - self - end - - def puts(*args) - print args.to_s + "\n" - end - - def print(*args) - @_safemode_output += args.to_s - end - - def output - @_safemode_output - end - - def method_missing(method, *args, &block) - if @locals.has_key?(method) - @locals[method] - elsif @delegate_methods.include?(method) - @delegate.send method, *unjail_args(args), &block - else - raise Safemode::SecurityError.new(method, "#") - end - end - - private - - def symbolize_keys(hash) - hash.inject({}) do |hash, (key, value)| - hash[key.to_s.intern] = value - hash - end - end - - def unjail_args(args) - args.collect do |arg| - arg.class.name =~ /::Jail$/ ? arg.instance_variable_get(:@source) : arg - end - end - end -end diff --git a/vendor/gems/safemode-1.0/safemode.gemspec b/vendor/gems/safemode-1.0/safemode.gemspec deleted file mode 100644 index c544737a925..00000000000 --- a/vendor/gems/safemode-1.0/safemode.gemspec +++ /dev/null @@ -1,17 +0,0 @@ -require 'rake' - -Gem::Specification.new do |s| - s.name = %q{safemode} - s.version = 1.0 - s.date = %q{2010-11-30} - s.authors = %q{foobar} - s.email = %q{foo@foobar.org} - s.summary = %q{safemode does stuff that is safe} - s.homepage = %q{http://safemode.org} - s.description = %q{this is a desc} - s.add_dependency 'ruby2ruby' - s.add_dependency 'sexp' - s.add_dependency 'ruby_parser' - s.files = FileList["LICENCSE", "README.markdown", "init.rb", "lib/safemode.rb", "lib/**/*"].to_a -#"lib/safemode.rb", "lib/safemode/*", "lib/haml/*", "lib/action_view/*"].to_a -end diff --git a/vendor/gems/safemode-1.0/test/test_all.rb b/vendor/gems/safemode-1.0/test/test_all.rb deleted file mode 100644 index 961592d8423..00000000000 --- a/vendor/gems/safemode-1.0/test/test_all.rb +++ /dev/null @@ -1,14 +0,0 @@ -require File.join(File.dirname(__FILE__), 'test_helper') -Test::Unit.run = false - -require File.join(File.dirname(__FILE__), 'test_jail') -require File.join(File.dirname(__FILE__), 'test_safemode_parser') -require File.join(File.dirname(__FILE__), 'test_safemode_eval') -require File.join(File.dirname(__FILE__), 'test_erb_eval') - -# ['ParseTree', 'RubyParser'].each do |parser| -['RubyParser'].each do |parser| - Safemode::Parser.parser = parser - puts "Running suite with Safemode::Parser using #{parser}" - Test::Unit::AutoRunner.run -end diff --git a/vendor/gems/safemode-1.0/test/test_erb_eval.rb b/vendor/gems/safemode-1.0/test/test_erb_eval.rb deleted file mode 100644 index 409296d2b4b..00000000000 --- a/vendor/gems/safemode-1.0/test/test_erb_eval.rb +++ /dev/null @@ -1,76 +0,0 @@ -require File.join(File.dirname(__FILE__), 'test_helper') - -class TestSafemodeEval < Test::Unit::TestCase - include TestHelper - - def setup - @box = Safemode::Box.new - @locals = { :article => Article.new } - @assigns = { :article => Article.new } - @erb_parse = lambda {|code| ERB.new("<%= #{code} %>").src } - end - - def test_some_stuff_that_should_work - ['"test".upcase', '10.succ', '10.times{}', '[1,2,3].each{|a| a + 1}', 'true ? 1 : 0', 'a = 1'].each do |code| - code = ERB.new("<%= #{code} %>").src - assert_nothing_raised{ @box.eval code } - end - end - - def test_should_turn_assigns_to_jails - assert_raise_no_method "@article.system", @assigns, &@erb_parse - end - - def test_should_turn_locals_to_jails - code = @erb_parse.call "article.system" - assert_raise(Safemode::NoMethodError){ @box.eval code, {}, @locals } - end - - def test_should_allow_method_access_on_assigns - code = @erb_parse.call "@article.title" - assert_nothing_raised{ @box.eval code, @assigns } - end - - def test_should_allow_method_access_on_locals - code = @erb_parse.call "article.title" - assert_nothing_raised{ @box.eval code, {}, @locals } - end - - def test_should_not_raise_on_if_using_return_values - code = @erb_parse.call "if @article.is_article?\n 1\n end" - assert_nothing_raised{ @box.eval code, @assigns } - end - - def test_should_work_with_if_using_return_values - code = @erb_parse.call "if @article.is_article? then 1 end" - assert_equal @box.eval(code, @assigns), "1" # ERB calls to_s on the result of the if block - end - - def test__FILE__should_not_render_filename - code = @erb_parse.call "__FILE__" - assert_equal '(string)', @box.eval(code) - end - - def test_interpolated_xstr_should_raise_security - assert_raise_security '"#{`ls -a`}"' - end - - TestHelper.no_method_error_raising_calls.each do |call| - call.gsub!('"', '\\\\"') - class_eval %Q( - def test_calling_#{call.gsub(/[\W]/, '_')}_should_raise_no_method - assert_raise_no_method "#{call}" - end - ) - end - - TestHelper.security_error_raising_calls.each do |call| - call.gsub!('"', '\\\\"') - class_eval %Q( - def test_calling_#{call.gsub(/[\W]/, '_')}_should_raise_security - assert_raise_security "#{call}" - end - ) - end - -end \ No newline at end of file diff --git a/vendor/gems/safemode-1.0/test/test_helper.rb b/vendor/gems/safemode-1.0/test/test_helper.rb deleted file mode 100644 index 0a87c8d3f83..00000000000 --- a/vendor/gems/safemode-1.0/test/test_helper.rb +++ /dev/null @@ -1,130 +0,0 @@ -$LOAD_PATH << File.join(File.dirname(__FILE__), '..', 'lib') - -require 'rubygems' -require 'test/unit' -require 'safemode' -require 'erb' - -module TestHelper - class << self - def no_method_error_raising_calls - [ 'nil.eval("a = 1")', - 'true.eval("a = 1")', - 'false.eval("a = 1")', - '@article.is_article?.eval("a = 1")', - '@article.comments.map{|c| c.eval("a = 1")}' ] - end - - def security_error_raising_calls - [ "class A\n end", - 'File.open("/etc/passwd")', - '::File.open("/etc/passwd")', - 'defined? a', - # '"#{`ls -a`}"', # hu? testing this separately, see testcase - 'alias b instance_eval', - '@@a', - '@@a = 1', - '$LOAD_PATH', - '$LOAD_PATH = 1', - '@a = 1', - '$1', - 'public to_s', - 'protected to_s', - 'private to_s', - "attr_reader :a", - 'URI("http://google.com")', - "`ls -a`", "exec('echo *')", "syscall 4, 1, 'hello', 5", "system('touch /tmp/helloworld')", - "abort", - "exit(0)", "exit!(0)", "at_exit{'goodbye'}", - "autoload(::MyModule, 'my_module.rb')", - "binding", - "callcc{|cont| cont.call}", - 'eval %Q(send(:system, "ls -a"))', - "fork", - "gets", "readline", "readlines", - "global_variables", "local_variables", - "proc{}", - "lambda{}", - "load('/path/to/file')", "require 'something'", - "loop{}", - "open('/etc/passwd'){|f| f.read}", - "p 'text'", "pretty_inspect", - # "print 'text'", "puts 'text'", allowed and buffered these (see ScopeObject) - "printf 'text'", "putc 'a'", - "raise RuntimeError, 'should not happen'", - "rand(0)", "srand(0)", - "set_trace_func proc{|event| puts event}", "trace_var :$_, proc {|v| puts v }", "untrace_var :$_", - "sleep", "sleep(0)", - "test(1, a, b)", - "Signal.trap(0, proc { puts 'Terminating: #{$$}' })", - "warn 'warning'" ] - end - end - - def assert_raise_no_method(code = nil, assigns = {}, locals = {}, &block) - assert_raise_safemode_error(Safemode::NoMethodError, code, assigns, locals, &block) - end - - def assert_raise_security(code = nil, assigns = {}, locals = {}, &block) - assert_raise_safemode_error(Safemode::SecurityError, code, assigns, locals, &block) - end - - def assert_raise_safemode_error(error, code, assigns = {}, locals = {}) - code = yield(code) if block_given? - assert_raise(error, code) { safebox_eval(code, assigns, locals) } - end - - def safebox_eval(code, assigns = {}, locals = {}) - # puts Safemode::Parser.jail(code) - Safemode::Box.new.eval code, assigns, locals - end -end - -class Article - def is_article? - true - end - - def title - 'an article title' - end - - def to_jail - Article::Jail.new self - end - - def comments - [Comment.new(self), Comment.new(self)] - end -end - -class Comment - attr_reader :article - - def initialize(article) - @article = article - end - - def text - "comment #{object_id}" - end - - def to_jail - Comment::Jail.new self - end -end - -class Article::Jail < Safemode::Jail - allow :title, :comments, :is_article? - - def author_name - "this article's author name" - end -end - -class Article::ExtendedJail < Article::Jail -end - -class Comment::Jail < Safemode::Jail - allow :article, :text -end diff --git a/vendor/gems/safemode-1.0/test/test_jail.rb b/vendor/gems/safemode-1.0/test/test_jail.rb deleted file mode 100644 index f1926580db0..00000000000 --- a/vendor/gems/safemode-1.0/test/test_jail.rb +++ /dev/null @@ -1,53 +0,0 @@ -require File.join(File.dirname(__FILE__), 'test_helper') - -class TestJail < Test::Unit::TestCase - def setup - @article = Article.new.to_jail - @comment = @article.comments.first - end - - def test_explicitly_allowed_methods_should_be_accessible - assert_nothing_raised { @article.title } - end - - def test_jail_instance_methods_should_be_accessible - assert_nothing_raised { @article.author_name } - end - - def test_sending_to_jail_to_an_object_should_return_a_jail - assert_equal "Article::Jail", @article.class.name - end - - def test_jail_instances_should_have_limited_methods - expected = ["class", "inspect", "method_missing", "methods", "respond_to?", "to_jail", "to_s", "instance_variable_get"] - objects.each do |object| - assert_equal expected.sort, reject_pretty_methods(object.to_jail.methods.sort) - end - end - - def test_jail_classes_should_have_limited_methods - expected = ["new", "methods", "name", "inherited", "method_added", "inspect", - "allow", "allowed?", "allowed_methods", "init_allowed_methods", - "<", # < needed in Rails Object#subclasses_of - "ancestors", "==" # ancestors and == needed in Rails::Generator::Spec#lookup_class - ] - objects.each do |object| - assert_equal expected.sort, reject_pretty_methods(object.to_jail.class.methods.sort) - end - end - - def test_allowed_methods_should_be_propagated_to_subclasses - assert_equal Article::Jail.allowed_methods, Article::ExtendedJail.allowed_methods - end - - private - - def objects - [[], {}, 1..2, "a", :a, Time.now, 1, 1.0, nil, false, true] - end - - def reject_pretty_methods(methods) - methods.reject{ |method| method =~ /^pretty_/ } - end - -end diff --git a/vendor/gems/safemode-1.0/test/test_safemode_eval.rb b/vendor/gems/safemode-1.0/test/test_safemode_eval.rb deleted file mode 100644 index 3e84c8549ec..00000000000 --- a/vendor/gems/safemode-1.0/test/test_safemode_eval.rb +++ /dev/null @@ -1,68 +0,0 @@ -require File.join(File.dirname(__FILE__), 'test_helper') - -class TestSafemodeEval < Test::Unit::TestCase - include TestHelper - - def setup - @box = Safemode::Box.new - @locals = { :article => Article.new } - @assigns = { :article => Article.new } - end - - def test_some_stuff_that_should_work - ['"test".upcase', '10.succ', '10.times{}', '[1,2,3].each{|a| a + 1}', 'true ? 1 : 0', 'a = 1'].each do |code| - assert_nothing_raised{ @box.eval code } - end - end - - def test_should_turn_assigns_to_jails - assert_raise_no_method "@article.system", @assigns - end - - def test_should_turn_locals_to_jails - assert_raise(Safemode::NoMethodError){ @box.eval "article.system", {}, @locals } - end - - def test_should_allow_method_access_on_assigns - assert_nothing_raised{ @box.eval "@article.title", @assigns } - end - - def test_should_allow_method_access_on_locals - assert_nothing_raised{ @box.eval "article.title", {}, @locals } - end - - def test_should_not_raise_on_if_using_return_values - assert_nothing_raised{ @box.eval "if @article.is_article? then 1 end", @assigns } - end - - def test_should_work_with_if_using_return_values - assert_equal @box.eval("if @article.is_article? then 1 end", @assigns), 1 - end - - def test__FILE__should_not_render_filename - assert_equal '(string)', @box.eval("__FILE__") - end - - def test_interpolated_xstr_should_raise_security - assert_raise_security '"#{`ls -a`}"' - end - - TestHelper.no_method_error_raising_calls.each do |call| - call.gsub!('"', '\\\\"') - class_eval %Q( - def test_calling_#{call.gsub(/[\W]/, '_')}_should_raise_no_method - assert_raise_no_method "#{call}" - end - ) - end - - TestHelper.security_error_raising_calls.each do |call| - call.gsub!('"', '\\\\"') - class_eval %Q( - def test_calling_#{call.gsub(/[\W]/, '_')}_should_raise_security - assert_raise_security "#{call}" - end - ) - end - -end \ No newline at end of file diff --git a/vendor/gems/safemode-1.0/test/test_safemode_parser.rb b/vendor/gems/safemode-1.0/test/test_safemode_parser.rb deleted file mode 100644 index 3ff0005de73..00000000000 --- a/vendor/gems/safemode-1.0/test/test_safemode_parser.rb +++ /dev/null @@ -1,45 +0,0 @@ -require File.join(File.dirname(__FILE__), 'test_helper') - -class TestSafemodeParser < Test::Unit::TestCase - def test_vcall_should_be_jailed - assert_jailed 'to_jail.a.to_jail.class', 'a.class' - end - - def test_call_should_be_jailed - assert_jailed '(1.to_jail + 1).to_jail.class', '(1 + 1).class' - end - - def test_estr_should_be_jailed - assert_jailed '"#{1.to_jail.class}"', '"#{1.class}"' - end - - def test_if_should_be_usable_for_erb - assert_jailed "if true then\n 1\nend", "if true\n 1\n end" - end - - def test_if_else_should_be_usable_for_erb - assert_jailed "if true then\n 1\n else\n2\nend", "if true\n 1\n else\n2\n end" - end - - def test_ternary_should_be_usable_for_erb - assert_jailed "if true then\n 1\n else\n2\nend", "true ? 1 : 2" - end - - def test_output_buffer_should_be_assignable - assert_nothing_raised do - jail('@output_buffer = ""') - end - end - -private - - def assert_jailed(expected, code) - assert_equal expected.gsub(' ', ''), jail(code).gsub(' ', '') - end - - def jail(code) - Safemode::Parser.jail(code) - end -end - - diff --git a/vendor/gems/sexp-0.2.1/.specification b/vendor/gems/sexp-0.2.1/.specification deleted file mode 100644 index 1afef50917d..00000000000 --- a/vendor/gems/sexp-0.2.1/.specification +++ /dev/null @@ -1,82 +0,0 @@ ---- !ruby/object:Gem::Specification -name: sexp -version: !ruby/object:Gem::Version - hash: 21 - prerelease: false - segments: - - 0 - - 2 - - 1 - version: 0.2.1 -platform: ruby -authors: -- Topher Cyll -autorequire: -bindir: bin -cert_chain: [] - -date: 2008-08-29 00:00:00 +03:00 -default_executable: -dependencies: -- !ruby/object:Gem::Dependency - name: rparsec - prerelease: false - requirement: &id001 !ruby/object:Gem::Requirement - none: false - requirements: - - - ">=" - - !ruby/object:Gem::Version - hash: 15 - segments: - - 1 - - 0 - version: "1.0" - type: :runtime - version_requirements: *id001 -description: -email: christophercyll@gmail.com -executables: [] - -extensions: [] - -extra_rdoc_files: [] - -files: -- sexp.rb -- sexpressions.rb -has_rdoc: true -homepage: http://rubyforge.org/projects/sexp/ -licenses: [] - -post_install_message: -rdoc_options: [] - -require_paths: -- . -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: sexp -rubygems_version: 1.3.7 -signing_key: -specification_version: 2 -summary: SExpression Reading/Writing for Ruby -test_files: [] - diff --git a/vendor/gems/sexp-0.2.1/sexp.rb b/vendor/gems/sexp-0.2.1/sexp.rb deleted file mode 100644 index 3baf8562e00..00000000000 --- a/vendor/gems/sexp-0.2.1/sexp.rb +++ /dev/null @@ -1,5 +0,0 @@ -# This library used to supply 'sexp', but ParseTree also -# supplies a file named sexp.rb and comes earlier in the -# load order. I've switched this lib to the more verbose -# 'sexpressions', but this file is for compatibility. -require 'sexpressions' \ No newline at end of file diff --git a/vendor/gems/sexp-0.2.1/sexpressions.rb b/vendor/gems/sexp-0.2.1/sexpressions.rb deleted file mode 100644 index 2107d459488..00000000000 --- a/vendor/gems/sexp-0.2.1/sexpressions.rb +++ /dev/null @@ -1,39 +0,0 @@ -require 'rubygems' -require 'rparsec' - -module SExpressionParser - extend RParsec::Parsers - - def self.stringer(opener, closer=nil, translate={}) - closer = opener if closer.nil? - escape = (string('\\') >> any).map do |charnum| - escaped = charnum.chr - translate[escaped] || escaped - end - open = string(opener) - close = string(closer) - other = not_string(closer).map{|charnum| charnum.chr } - string = (open >> (escape|other).many << close).map {|strings| strings.to_s } - end - - Integer = integer.map{|x| x.to_i } - Float = number.map{|x| x.to_f } - Number = longest(Integer, Float) - Special = Regexp.escape('+-*/=<>?!@#$%^&:~') - Symbol = regexp(/[\w#{Special}]*[A-Za-z#{Special}][\w#{Special}]*/).map{|s| s.to_sym } - String = stringer(%q{"}, %q{"}, "n" => "\n", "t" => "\t") - List = char('(') >> lazy{Values} << char(')') - Quoted = char("'") >> lazy{Value}.map{|value| [:quote, value] } - Value = whitespace.many_ >> alt(Quoted, List, String, Symbol, Number) << whitespace.many_ - Values = Value.many - Parser = Values << eof - - def self.parse(text) - Parser.parse(text) - end -end - -class Object; def to_sexp; inspect(); end; end -class Symbol; def to_sexp; id2name(); end; end -class Array; def to_sexp; "(#{map{|x| x.to_sexp }.join(' ')})"; end; end -class String; def parse_sexp; SExpressionParser.parse(self) ; end; end diff --git a/vendor/gems/sexp_processor-3.0.5/.specification b/vendor/gems/sexp_processor-3.0.5/.specification deleted file mode 100644 index bc918f6018f..00000000000 --- a/vendor/gems/sexp_processor-3.0.5/.specification +++ /dev/null @@ -1,135 +0,0 @@ ---- !ruby/object:Gem::Specification -name: sexp_processor -version: !ruby/object:Gem::Version - hash: 13 - prerelease: false - segments: - - 3 - - 0 - - 5 - version: 3.0.5 -platform: ruby -authors: -- Ryan Davis -autorequire: -bindir: bin -cert_chain: [] - -date: 2010-09-01 00:00:00 +03:00 -default_executable: -dependencies: -- !ruby/object:Gem::Dependency - name: rubyforge - prerelease: false - requirement: &id001 !ruby/object:Gem::Requirement - none: false - requirements: - - - ">=" - - !ruby/object:Gem::Version - hash: 7 - segments: - - 2 - - 0 - - 4 - version: 2.0.4 - type: :development - version_requirements: *id001 -- !ruby/object:Gem::Dependency - name: minitest - prerelease: false - requirement: &id002 !ruby/object:Gem::Requirement - none: false - requirements: - - - ">=" - - !ruby/object:Gem::Version - hash: 15 - segments: - - 1 - - 6 - - 0 - version: 1.6.0 - type: :development - version_requirements: *id002 -- !ruby/object:Gem::Dependency - name: hoe - prerelease: false - requirement: &id003 !ruby/object:Gem::Requirement - none: false - requirements: - - - ">=" - - !ruby/object:Gem::Version - hash: 23 - segments: - - 2 - - 6 - - 0 - version: 2.6.0 - type: :development - version_requirements: *id003 -description: |- - sexp_processor branches from ParseTree bringing all the generic sexp - processing tools with it. Sexp, SexpProcessor, Environment, etc... all - for your language processing pleasure. -email: -- ryand-ruby@zenspider.com -executables: [] - -extensions: [] - -extra_rdoc_files: -- History.txt -- Manifest.txt -- README.txt -files: -- History.txt -- Manifest.txt -- README.txt -- Rakefile -- lib/composite_sexp_processor.rb -- lib/sexp.rb -- lib/sexp_processor.rb -- lib/unique.rb -- test/test_composite_sexp_processor.rb -- test/test_environment.rb -- test/test_sexp.rb -- test/test_sexp_processor.rb -has_rdoc: true -homepage: http://rubyforge.org/projects/parsetree/ -licenses: [] - -post_install_message: -rdoc_options: -- --main -- README.txt -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: parsetree -rubygems_version: 1.3.7 -signing_key: -specification_version: 3 -summary: sexp_processor branches from ParseTree bringing all the generic sexp processing tools with it -test_files: -- test/test_composite_sexp_processor.rb -- test/test_environment.rb -- test/test_sexp.rb -- test/test_sexp_processor.rb diff --git a/vendor/gems/sexp_processor-3.0.5/History.txt b/vendor/gems/sexp_processor-3.0.5/History.txt deleted file mode 100644 index 8415df487a8..00000000000 --- a/vendor/gems/sexp_processor-3.0.5/History.txt +++ /dev/null @@ -1,49 +0,0 @@ -=== 3.0.5 / 2010-09-01 - -* 2 minor enhancements: - - * Added in_context to clean up code. - * optimize inspect to avoid needlessly caching @line - -=== 3.0.4 / 2010-03-27 - -* 1 minor enhancement: - - * Added line number to pretty_print output if $VERBOSE - -=== 3.0.3 / 2009-08-14 - -* 1 minor enhancement: - - * Pulled #mass up from flog/flay - -=== 3.0.2 / 2009-06-23 - -* 2 minor enhancements: - - * Pulled unique.rb from ParseTree to sexp_processor. - * Switched to minitest. - -=== 3.0.1 / 2009-01-20 - -* 3 minor enhancements: - - * Filled out README - * Promoted file/line/comments from ruby_parser. - * Added sexp_type to compliment sexp_body. - -=== 3.0.0 / 2008-10-22 - -* 2 major enhancements: - - * Released as its own project, splitting from ParseTree - * Added Environment to SexpProcessor and built it in. YAY! - -* 6 minor enhancements: - - * Allowed CompositeSexpProcessor to be more ducktypey. - * Refactored Sexp#method_missing into find_node and find_nodes. - * Removed Sexp#for and other PT specific code. - * SexpProcessor#process now runs rewriters before everything else. - * SexpProcessor#rewrite context only for subs, EMPTY for top level rewrites. - * SexpProcessor#rewrite will stop iterating if the result isn't another Sexp. diff --git a/vendor/gems/sexp_processor-3.0.5/Manifest.txt b/vendor/gems/sexp_processor-3.0.5/Manifest.txt deleted file mode 100644 index 9c6ece5b04a..00000000000 --- a/vendor/gems/sexp_processor-3.0.5/Manifest.txt +++ /dev/null @@ -1,12 +0,0 @@ -History.txt -Manifest.txt -README.txt -Rakefile -lib/composite_sexp_processor.rb -lib/sexp.rb -lib/sexp_processor.rb -lib/unique.rb -test/test_composite_sexp_processor.rb -test/test_environment.rb -test/test_sexp.rb -test/test_sexp_processor.rb diff --git a/vendor/gems/sexp_processor-3.0.5/README.txt b/vendor/gems/sexp_processor-3.0.5/README.txt deleted file mode 100644 index b6b63e0af61..00000000000 --- a/vendor/gems/sexp_processor-3.0.5/README.txt +++ /dev/null @@ -1,61 +0,0 @@ -= SexpProcessor - -* http://rubyforge.org/projects/parsetree/ - -== DESCRIPTION: - -sexp_processor branches from ParseTree bringing all the generic sexp -processing tools with it. Sexp, SexpProcessor, Environment, etc... all -for your language processing pleasure. - -== FEATURES/PROBLEMS: - -* Includes SexpProcessor and CompositeSexpProcessor. - - * Allows you to write very clean filters. - -== SYNOPSIS: - - class MyProcessor < SexpProcessor - def initialize - super - self.strict = false - end - def process_lit(exp) - val = exp.shift - return val - end - end - -== REQUIREMENTS: - -* rubygems - -== INSTALL: - -* sudo gem install sexp_processor - -== LICENSE: - -(The MIT License) - -Copyright (c) 2008 Ryan Davis, Seattle.rb - -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/sexp_processor-3.0.5/Rakefile b/vendor/gems/sexp_processor-3.0.5/Rakefile deleted file mode 100644 index 37273973111..00000000000 --- a/vendor/gems/sexp_processor-3.0.5/Rakefile +++ /dev/null @@ -1,14 +0,0 @@ -# -*- ruby -*- - -require 'rubygems' -require 'hoe' - -Hoe.plugin :seattlerb - -Hoe.spec 'sexp_processor' do - developer 'Ryan Davis', 'ryand-ruby@zenspider.com' - - self.rubyforge_name = 'parsetree' -end - -# vim: syntax=ruby diff --git a/vendor/gems/sexp_processor-3.0.5/lib/composite_sexp_processor.rb b/vendor/gems/sexp_processor-3.0.5/lib/composite_sexp_processor.rb deleted file mode 100644 index caebe0e00de..00000000000 --- a/vendor/gems/sexp_processor-3.0.5/lib/composite_sexp_processor.rb +++ /dev/null @@ -1,49 +0,0 @@ -require 'sexp_processor' - -## -# Implements the Composite pattern on SexpProcessor. Need we say more? -# -# Yeah... probably. Implements a SexpProcessor of SexpProcessors so -# you can easily chain multiple to each other. At some stage we plan -# on having all of them run +process+ and but only ever output -# something when +generate+ is called, allowing for deferred final -# processing. - -class CompositeSexpProcessor < SexpProcessor - - ## - # The list o' processors to run. - - attr_reader :processors - - def initialize # :nodoc: - super - @processors = [] - end - - ## - # Add a +processor+ to the list of processors to run. - - def <<(processor) - raise ArgumentError, "Can only add sexp processors" unless - SexpProcessor === processor || processor.respond_to?(:process) - @processors << processor - end - - ## - # Run +exp+ through all of the processors, returning the final - # result. - - def process(exp) - @processors.each do |processor| - exp = processor.process(exp) - end - exp - end - - def on_error_in(node_type, &block) - @processors.each do |processor| - processor.on_error_in(node_type, &block) - end - end -end diff --git a/vendor/gems/sexp_processor-3.0.5/lib/sexp.rb b/vendor/gems/sexp_processor-3.0.5/lib/sexp.rb deleted file mode 100644 index b5256f0a85d..00000000000 --- a/vendor/gems/sexp_processor-3.0.5/lib/sexp.rb +++ /dev/null @@ -1,311 +0,0 @@ - -$TESTING ||= false # unless defined $TESTING - -## -# Sexps are the basic storage mechanism of SexpProcessor. Sexps have -# a +type+ (to be renamed +node_type+) which is the first element of -# the Sexp. The type is used by SexpProcessor to determine whom to -# dispatch the Sexp to for processing. - -class Sexp < Array # ZenTest FULL - - attr_writer :line - attr_accessor :file, :comments - - @@array_types = [ :array, :args, ] - - ## - # Create a new Sexp containing +args+. - - def initialize(*args) - super(args) - end - - ## - # Creates a new Sexp from Array +a+. - - def self.from_array(a) - ary = Array === a ? a : [a] - - result = self.new - - ary.each do |x| - case x - when Sexp - result << x - when Array - result << self.from_array(x) - else - result << x - end - end - - result - end - - def ==(obj) # :nodoc: - if obj.class == self.class then - super - else - false - end - end - - ## - # Returns true if this Sexp's pattern matches +sexp+. - - def ===(sexp) - return nil unless Sexp === sexp - pattern = self # this is just for my brain - - return true if pattern == sexp - - sexp.each do |subset| - return true if pattern === subset - end - - return nil - end - - ## - # Returns true if this Sexp matches +pattern+. (Opposite of #===.) - - def =~(pattern) - return pattern === self - end - - ## - # Returns true if the node_type is +array+ or +args+. - # - # REFACTOR: to TypedSexp - we only care when we have units. - - def array_type? - type = self.first - @@array_types.include? type - end - - def compact # :nodoc: - self.delete_if { |o| o.nil? } - end - - ## - # Enumeratates the sexp yielding to +b+ when the node_type == +t+. - - def each_of_type(t, &b) - each do | elem | - if Sexp === elem then - elem.each_of_type(t, &b) - b.call(elem) if elem.first == t - end - end - end - - ## - # Replaces all elements whose node_type is +from+ with +to+. Used - # only for the most trivial of rewrites. - - def find_and_replace_all(from, to) - each_with_index do | elem, index | - if Sexp === elem then - elem.find_and_replace_all(from, to) - else - self[index] = to if elem == from - end - end - end - - ## - # Replaces all Sexps matching +pattern+ with Sexp +repl+. - - def gsub(pattern, repl) - return repl if pattern == self - - new = self.map do |subset| - case subset - when Sexp then - subset.gsub(pattern, repl) - else - subset - end - end - - return Sexp.from_array(new) - end - - def inspect # :nodoc: - sexp_str = self.map {|x|x.inspect}.join(', ') - if ENV['VERBOSE'] && line then - "s(#{sexp_str}).line(#{line})" - else - "s(#{sexp_str})" - end - end - - def find_node name, delete = false - matches = find_nodes name - - case matches.size - when 0 then - nil - when 1 then - match = matches.first - delete match if delete - match - else - raise NoMethodError, "multiple nodes for #{name} were found in #{inspect}" - end - end - - ## - # Find every node with type +name+. - - def find_nodes name - find_all { | sexp | Sexp === sexp and sexp.first == name } - end - - ## - # If passed a line number, sets the line and returns self. Otherwise - # returns the line number. This allows you to do message cascades - # and still get the sexp back. - - def line(n=nil) - if n then - @line = n - self - else - @line ||= nil - end - end - - ## - # Returns the size of the sexp, flattened. - - def mass - @mass ||= self.structure.flatten.size - end - - ## - # Returns the node named +node+, deleting it if +delete+ is true. - - def method_missing meth, delete = false - find_node meth, delete - end - - def pretty_print(q) # :nodoc: - nnd = ')' - nnd << ".line(#{line})" if line && ENV['VERBOSE'] - - q.group(1, 's(', nnd) do - q.seplist(self) {|v| q.pp v } - end - end - - ## - # Returns the node type of the Sexp. - - def sexp_type - first - end - - ## - # Returns the Sexp body, ie the values without the node type. - - def sexp_body - self[1..-1] - end - - ## - # If run with debug, Sexp will raise if you shift on an empty - # Sexp. Helps with debugging. - - def shift - raise "I'm empty" if self.empty? - super - end if $DEBUG or $TESTING - - ## - # Returns the bare bones structure of the sexp. - # s(:a, :b, s(:c, :d), :e) => s(:a, s(:c)) - - def structure - result = self.class.new - if Array === self.first then - result = self.first.structure - else - result << self.first - self.grep(Array).each do |subexp| - result << subexp.structure - end - end - result - end - - ## - # Replaces the Sexp matching +pattern+ with +repl+. - - def sub(pattern, repl) - return repl.dup if pattern == self - - done = false - - new = self.map do |subset| - if done then - subset - else - case subset - when Sexp then - if pattern == subset then - done = true - repl.dup - elsif pattern === subset then - done = true - subset.sub pattern, repl - else - subset - end - else - subset - end - end - end - - return Sexp.from_array(new) - end - - def to_a # :nodoc: - self.map { |o| Sexp === o ? o.to_a : o } - end - - def to_s # :nodoc: - inspect - end - -end - -class SexpMatchSpecial < Sexp; end - -class SexpAny < SexpMatchSpecial - def ==(o) - Sexp === o - end - - def ===(o) - return Sexp === o - end - - def inspect - "ANY" - end -end - -module SexpMatchSpecials - def ANY(); return SexpAny.new; end -end - -## -# This is just a stupid shortcut to make indentation much cleaner. - -def s(*args) - Sexp.new(*args) -end - diff --git a/vendor/gems/sexp_processor-3.0.5/lib/sexp_processor.rb b/vendor/gems/sexp_processor-3.0.5/lib/sexp_processor.rb deleted file mode 100644 index e99d3d85e73..00000000000 --- a/vendor/gems/sexp_processor-3.0.5/lib/sexp_processor.rb +++ /dev/null @@ -1,412 +0,0 @@ - -$TESTING = false unless defined? $TESTING - -require 'sexp' - -## -# SexpProcessor provides a uniform interface to process Sexps. -# -# In order to create your own SexpProcessor subclass you'll need -# to call super in the initialize method, then set any of the -# Sexp flags you want to be different from the defaults. -# -# SexpProcessor uses a Sexp's type to determine which process method -# to call in the subclass. For Sexp s(:lit, 1) -# SexpProcessor will call #process_lit, if it is defined. -# -# You can also specify a default method to call for any Sexp types -# without a process_ method or use the default processor provided to -# skip over them. -# -# Here is a simple example: -# -# class MyProcessor < SexpProcessor -# def initialize -# super -# self.strict = false -# end -# -# def process_lit(exp) -# val = exp.shift -# return val -# end -# end - -class SexpProcessor - - VERSION = '3.0.5' - - ## - # Automatically shifts off the Sexp type before handing the - # Sexp to process_ - - attr_accessor :auto_shift_type - - ## - # Return a stack of contexts. Most recent node is first. - - attr_reader :context - - ## - # A Hash of Sexp types and Regexp. - # - # Print a debug message if the Sexp type matches the Hash key - # and the Sexp's #inspect output matches the Regexp. - - attr_accessor :debug - - ## - # A default method to call if a process_ method is not found - # for the Sexp type. - - attr_accessor :default_method - - ## - # Expected result class - - attr_accessor :expected - - ## - # Raise an exception if the Sexp is not empty after processing - - attr_accessor :require_empty - - ## - # Raise an exception if no process_ method is found for a Sexp. - - attr_accessor :strict - - ## - # An array that specifies node types that are unsupported by this - # processor. SexpProcessor will raise UnsupportedNodeError if you try - # to process one of those node types. - - attr_accessor :unsupported - - ## - # Emit a warning when the method in #default_method is called. - - attr_accessor :warn_on_default - - ## - # A scoped environment to make you happy. - - attr_reader :env - - ## - # Creates a new SexpProcessor. Use super to invoke this - # initializer from SexpProcessor subclasses, then use the - # attributes above to customize the functionality of the - # SexpProcessor - - def initialize - @default_method = nil - @warn_on_default = true - @auto_shift_type = false - @strict = false - @unsupported = [:alloca, :cfunc, :cref, :ifunc, :last, :memo, - :newline, :opt_n, :method] - @unsupported_checked = false - @debug = {} - @expected = Sexp - @require_empty = true - @exceptions = {} - - # we do this on an instance basis so we can subclass it for - # different processors. - @processors = {} - @rewriters = {} - @context = [] - - public_methods.each do |name| - case name - when /^process_(.*)/ then - @processors[$1.to_sym] = name.to_sym - when /^rewrite_(.*)/ then - @rewriters[$1.to_sym] = name.to_sym - end - end - end - - def assert_empty(meth, exp, exp_orig) - unless exp.empty? then - msg = "exp not empty after #{self.class}.#{meth} on #{exp.inspect}" - msg += " from #{exp_orig.inspect}" if $DEBUG - raise NotEmptyError, msg - end - end - - def rewrite(exp) - type = exp.first - - in_context type do - exp.map! { |sub| Array === sub ? rewrite(sub) : sub } - end - - begin - meth = @rewriters[type] - exp = self.send(meth, exp) if meth - break unless Sexp === exp - old_type, type = type, exp.first - end until old_type == type - - exp - end - - ## - # Default Sexp processor. Invokes process_ methods matching - # the Sexp type given. Performs additional checks as specified by - # the initializer. - - def process(exp) - return nil if exp.nil? - exp = self.rewrite(exp) if self.context.empty? - - unless @unsupported_checked then - m = public_methods.grep(/^process_/) { |o| o.to_s.sub(/^process_/, '').to_sym } - supported = m - (m - @unsupported) - - raise UnsupportedNodeError, "#{supported.inspect} shouldn't be in @unsupported" unless supported.empty? - - @unsupported_checked = true - end - - result = self.expected.new - - type = exp.first - raise "type should be a Symbol, not: #{exp.first.inspect}" unless - Symbol === type - - in_context type do - if @debug.has_key? type then - str = exp.inspect - puts "// DEBUG: #{str}" if str =~ @debug[type] - end - - exp_orig = nil - exp_orig = exp.deep_clone if $DEBUG or - @debug.has_key? type or @exceptions.has_key?(type) - - raise UnsupportedNodeError, "'#{type}' is not a supported node type" if - @unsupported.include? type - - if @debug.has_key? type then - str = exp.inspect - puts "// DEBUG (rewritten): #{str}" if str =~ @debug[type] - end - - # now do a pass with the real processor (or generic) - meth = @processors[type] || @default_method - if meth then - - if @warn_on_default and meth == @default_method then - warn "WARNING: Using default method #{meth} for #{type}" - end - - exp.shift if @auto_shift_type and meth != @default_method - - result = error_handler(type, exp_orig) do - self.send(meth, exp) - end - - raise SexpTypeError, "Result must be a #{@expected}, was #{result.class}:#{result.inspect}" unless @expected === result - - self.assert_empty(meth, exp, exp_orig) if @require_empty - else - unless @strict then - until exp.empty? do - sub_exp = exp.shift - sub_result = nil - if Array === sub_exp then - sub_result = error_handler(type, exp_orig) do - process(sub_exp) - end - raise "Result is a bad type" unless Array === sub_exp - raise "Result does not have a type in front: #{sub_exp.inspect}" unless Symbol === sub_exp.first unless sub_exp.empty? - else - sub_result = sub_exp - end - result << sub_result - end - - # NOTE: this is costly, but we are in the generic processor - # so we shouldn't hit it too much with RubyToC stuff at least. - #if Sexp === exp and not exp.sexp_type.nil? then - begin - result.sexp_type = exp.sexp_type - rescue Exception - # nothing to do, on purpose - end - else - msg = "Bug! Unknown node-type #{type.inspect} to #{self.class}" - msg += " in #{exp_orig.inspect} from #{caller.inspect}" if $DEBUG - raise UnknownNodeError, msg - end - end - end - - result - end - - ## - # Raises unless the Sexp type for +list+ matches +typ+ - - def assert_type(list, typ) - raise SexpTypeError, "Expected type #{typ.inspect} in #{list.inspect}" if - not Array === list or list.first != typ - end - - def error_handler(type, exp=nil) # :nodoc: - begin - return yield - rescue StandardError => err - if @exceptions.has_key? type then - return @exceptions[type].call(self, exp, err) - else - warn "#{err.class} Exception thrown while processing #{type} for sexp #{exp.inspect} #{caller.inspect}" if $DEBUG - raise - end - end - end - - ## - # Registers an error handler for +node+ - - def on_error_in(node_type, &block) - @exceptions[node_type] = block - end - - ## - # A fairly generic processor for a dummy node. Dummy nodes are used - # when your processor is doing a complicated rewrite that replaces - # the current sexp with multiple sexps. - # - # Bogus Example: - # - # def process_something(exp) - # return s(:dummy, process(exp), s(:extra, 42)) - # end - - def process_dummy(exp) - result = @expected.new(:dummy) rescue @expected.new - - until exp.empty? do - result << self.process(exp.shift) - end - - result - end - - ## - # Add a scope level to the current env. Eg: - # - # def process_defn exp - # name = exp.shift - # args = process(exp.shift) - # scope do - # body = process(exp.shift) - # # ... - # end - # end - # - # env[:x] = 42 - # scope do - # env[:x] # => 42 - # env[:y] = 24 - # end - # env[:y] # => nil - - def scope &block - env.scope(&block) - end - - def in_context type - self.context.unshift type - - yield - - self.context.shift - end - - ## - # I really hate this here, but I hate subdirs in my lib dir more... - # I guess it is kinda like shaving... I'll split this out when it - # itches too much... - - class Environment - def initialize - @env = [] - @env.unshift({}) - end - - def all - @env.reverse.inject { |env, scope| env.merge scope } - end - - def depth - @env.length - end - - # TODO: depth_of - - def [] name - hash = @env.find { |closure| closure.has_key? name } - hash[name] if hash - end - - def []= name, val - hash = @env.find { |closure| closure.has_key? name } || @env.first - hash[name] = val - end - - def scope - @env.unshift({}) - begin - yield - ensure - @env.shift - raise "You went too far unextending env" if @env.empty? - end - end - end -end - -class Object - - ## - # deep_clone is the usual Marshalling hack to make a deep copy. - # It is rather slow, so use it sparingly. Helps with debugging - # SexpProcessors since you usually shift off sexps. - - def deep_clone - Marshal.load(Marshal.dump(self)) - end -end - -## -# SexpProcessor base exception class. - -class SexpProcessorError < StandardError; end - -## -# Raised by SexpProcessor if it sees a node type listed in its -# unsupported list. - -class UnsupportedNodeError < SexpProcessorError; end - -## -# Raised by SexpProcessor if it is in strict mode and sees a node for -# which there is no processor available. - -class UnknownNodeError < SexpProcessorError; end - -## -# Raised by SexpProcessor if a processor did not process every node in -# a sexp and @require_empty is true. - -class NotEmptyError < SexpProcessorError; end - -## -# Raised if assert_type encounters an unexpected sexp type. - -class SexpTypeError < SexpProcessorError; end diff --git a/vendor/gems/sexp_processor-3.0.5/lib/unique.rb b/vendor/gems/sexp_processor-3.0.5/lib/unique.rb deleted file mode 100644 index 7ce2db1f491..00000000000 --- a/vendor/gems/sexp_processor-3.0.5/lib/unique.rb +++ /dev/null @@ -1,15 +0,0 @@ -## -# Unique creates unique variable names. - -class Unique - def self.reset # mostly for testing - @@curr = 0 - end - - def self.next - @@curr += 1 - "temp_#{@@curr}".intern - end - - reset -end diff --git a/vendor/gems/sexp_processor-3.0.5/test/test_composite_sexp_processor.rb b/vendor/gems/sexp_processor-3.0.5/test/test_composite_sexp_processor.rb deleted file mode 100755 index e8a671bd30e..00000000000 --- a/vendor/gems/sexp_processor-3.0.5/test/test_composite_sexp_processor.rb +++ /dev/null @@ -1,70 +0,0 @@ -#!/usr/local/bin/ruby -w - -$TESTING = true - -require 'composite_sexp_processor' -require 'minitest/autorun' - -class FakeProcessor1 < SexpProcessor # ZenTest SKIP - - def initialize - super - self.warn_on_default = false - self.default_method = :default_processor - self.expected = Array - end - - def default_processor(exp) - result = [] - result << exp.shift - until exp.empty? do - result << exp.shift.to_s + " woot" - end - result - end -end - -class TestCompositeSexpProcessor < MiniTest::Unit::TestCase - - def setup - @p = CompositeSexpProcessor.new - end - - def test_process_default - data = [1, 2, 3] - result = @p.process(data.dup) - assert_equal(data.dup, result) - end - - def test_process_fake1 - data = [:x, 1, 2, 3] - @p << FakeProcessor1.new - result = @p.process(data.dup) - assert_equal [:x, "1 woot", "2 woot", "3 woot"], result - end - - def test_process_fake1_twice - data = [:x, 1, 2, 3] - @p << FakeProcessor1.new - @p << FakeProcessor1.new - result = @p.process(data.dup) - assert_equal [:x, "1 woot woot", "2 woot woot", "3 woot woot"], result - end - - def test_processors - # everything is tested by test_append - end - - def test_append - assert_equal([], @p.processors) - - assert_raises(ArgumentError) do - @p << 42 - end - - fp1 = FakeProcessor1.new - @p << fp1 - assert_equal([fp1], @p.processors) - end - -end diff --git a/vendor/gems/sexp_processor-3.0.5/test/test_environment.rb b/vendor/gems/sexp_processor-3.0.5/test/test_environment.rb deleted file mode 100755 index e21c4f18b66..00000000000 --- a/vendor/gems/sexp_processor-3.0.5/test/test_environment.rb +++ /dev/null @@ -1,84 +0,0 @@ -#!/usr/local/bin/ruby -w - -$TESTING = true - -require 'minitest/autorun' -require 'sexp_processor' - -class TestEnvironment < MiniTest::Unit::TestCase - - def setup - @env = SexpProcessor::Environment.new - end - - def test_all - @env.scope do - @env[:x] = 42 - - @env.scope do - @env[:y] = 3 - @env[:x] = Math::PI - - expected = { :x => Math::PI, :y => 3 } - assert_equal expected, @env.all - end - - expected = { :x => Math::PI } - assert_equal expected, @env.all - end - end - - def test_depth - assert_equal 1, @env.depth - - @env.scope do - assert_equal 2, @env.depth - end - - assert_equal 1, @env.depth - end - - def test_index - test_index_equals - end - - def test_index_unknown - assert_nil @env[:unknown] - end - - def test_index_out_of_scope - @env.scope do - @env[:var] = 42 - assert_equal 42, @env[:var] - end - - assert_nil @env[:var] - end - - def test_index_equals - @env[:var] = 42 - - assert_equal 42, @env[:var] - end - - def test_lookup_scope - @env[:var] = 42 - assert_equal 42, @env[:var] - - @env.scope do - assert_equal 42, @env[:var] - end - end - - def test_scope - @env[:var] = 42 - assert_equal 42, @env[:var] - - @env.scope do - @env[:var] = Math::PI - assert_equal Math::PI, @env[:var] - end - - assert_equal Math::PI, @env[:var] - end -end diff --git a/vendor/gems/sexp_processor-3.0.5/test/test_sexp.rb b/vendor/gems/sexp_processor-3.0.5/test/test_sexp.rb deleted file mode 100755 index f7ddb4174ac..00000000000 --- a/vendor/gems/sexp_processor-3.0.5/test/test_sexp.rb +++ /dev/null @@ -1,309 +0,0 @@ -#!/usr/local/bin/ruby -w - -$TESTING = true - -require 'minitest/autorun' -require 'sexp_processor' -require 'stringio' -require 'pp' - -class SexpTestCase < MiniTest::Unit::TestCase - # KEY for regex tests - # :a == no change - # :b == will change (but sometimes ONLY once) - # :c == change to - - include SexpMatchSpecials - - def util_equals(x, y) - result = x == y - refute_nil result, "#{x.inspect} does not === #{y.inspect}" - end - - def util_equals3(x, y) - result = x === y - refute_nil result, "#{x.inspect} does not === #{y.inspect}" - end - - def setup - @any = ANY() - end - - def test_stupid - # shuts up test/unit - end -end - -class TestSexp < SexpTestCase # ZenTest FULL - - class SexpFor - def method - 1 - end - end - - def util_pretty_print(expect, input) - io = StringIO.new - PP.pp(input, io) - io.rewind - assert_equal(expect, io.read.chomp) - end - - def setup - super - @sexp_class = Object.const_get(self.class.name[4..-1]) - @processor = SexpProcessor.new - @sexp = @sexp_class.new(1, 2, 3) - @basic_sexp = s(:lasgn, :var, s(:lit, 42)) - @re = s(:lit, 42) - @bad1 = s(:lit, 24) - @bad1 = s(:blah, 42) - end - - def test_class_from_array -# raise NotImplementedError, 'Need to write test_class_from_array' - end - - def test_class_index -# raise NotImplementedError, 'Need to write test_class_index' - end - - def test_array_type_eh - assert_equal false, @sexp.array_type? - @sexp.unshift :array - assert_equal true, @sexp.array_type? - end - - def test_each_of_type - # TODO: huh... this tests fails if top level sexp :b is removed - @sexp = s(:b, s(:a, s(:b, s(:a), :a, s(:b, :a), s(:b, s(:a))))) - count = 0 - @sexp.each_of_type(:a) do |exp| - count += 1 - end - assert_equal(3, count, "must find 3 a's in #{@sexp.inspect}") - end - - def test_equals2_array - # can't use assert_equals because it uses array as receiver - refute_equal(@sexp, [1, 2, 3], - "Sexp must not be equal to equivalent array") - # both directions just in case - # HACK - this seems to be a bug in ruby as far as I'm concerned - # assert_not_equal([1, 2, 3], @sexp, - # "Sexp must not be equal to equivalent array") - end - - def test_equals2_not_body - sexp2 = s(1, 2, 5) - refute_equal(@sexp, sexp2) - end - - def test_equals2_sexp - sexp2 = s(1, 2, 3) - unless @sexp.class == Sexp then - refute_equal(@sexp, sexp2) - end - end - - def test_equals3_any - util_equals3 @any, s() - util_equals3 @any, s(:a) - util_equals3 @any, s(:a, :b, s(:c)) - end - - def test_equals3_full_match - util_equals3 s(), s() # 0 - util_equals3 s(:blah), s(:blah) # 1 - util_equals3 s(:a, :b), s(:a, :b) # 2 - util_equals3 @basic_sexp, @basic_sexp.dup # deeper structure - end - - def test_equals3_mismatch - assert_nil s() === s(:a) - assert_nil s(:a) === s() - assert_nil s(:blah1) === s(:blah2) - assert_nil s(:a) === s(:a, :b) - assert_nil s(:a, :b) === s(:a) - assert_nil s(:a1, :b) === s(:a2, :b) - assert_nil s(:a, :b1) === s(:a, :b2) - assert_nil @basic_sexp === @basic_sexp.dup.push(42) - assert_nil @basic_sexp.dup.push(42) === @basic_sexp - end - - def test_equals3_subset_match - util_equals3 s(:a), s(s(:a), s(:b)) # left - util_equals3 s(:a), s(:blah, s(:a ), s(:b)) # mid 1 - util_equals3 s(:a, 1), s(:blah, s(:a, 1), s(:b)) # mid 2 - util_equals3 @basic_sexp, s(:blah, @basic_sexp.dup, s(:b)) # mid deeper - util_equals3 @basic_sexp, s(@basic_sexp.dup, s(:a), s(:b)) # left deeper - - util_equals3 s(:a), s(:blah, s(:blah, s(:a))) # left deeper - end - -# def test_equalstilde_any -# result = @basic_sexp =~ s(:lit, ANY()) -# p result -# assert result -# end - - def test_equalstilde_fancy - assert_nil s(:b) =~ s(:a, s(:b), :c) - refute_nil s(:a, s(:b), :c) =~ s(:b) - end - - def test_equalstilde_plain - result = @basic_sexp =~ @re - assert result - end - - def test_find_and_replace_all - @sexp = s(:a, s(:b, s(:a), s(:b), s(:b, s(:a)))) - expected = s(:a, s(:a, s(:a), s(:a), s(:a, s(:a)))) - - @sexp.find_and_replace_all(:b, :a) - - assert_equal(expected, @sexp) - end - - def test_gsub - assert_equal s(:c), s().gsub(s(), s(:c)) - assert_equal s(:c), s(:b).gsub(s(:b), s(:c)) - assert_equal s(:a), s(:a).gsub(s(:b), s(:c)) - assert_equal s(:a, s(:c)), s(:a, s(:b)).gsub(s(:b), s(:c)) - - assert_equal(s(:a, s(:c), s(:c)), - s(:a, s(:b), s(:b)).gsub(s(:b), s(:c))) - assert_equal(s(:a, s(:c), s(:a, s(:c))), - s(:a, s(:b), s(:a, s(:b))).gsub(s(:b), s(:c))) - end - - def test_inspect - k = @sexp_class - n = k.name[0].chr.downcase - assert_equal("#{n}()", - k.new().inspect) - assert_equal("#{n}(:a)", - k.new(:a).inspect) - assert_equal("#{n}(:a, :b)", - k.new(:a, :b).inspect) - assert_equal("#{n}(:a, #{n}(:b))", - k.new(:a, k.new(:b)).inspect) - end - - def test_mass - assert_equal 1, s(:a).mass - assert_equal 3, s(:a, s(:b), s(:c)).mass - - s = s(:iter, - s(:call, nil, :a, s(:arglist, s(:lit, 1))), - s(:lasgn, :c), - s(:call, nil, :d, s(:arglist))) - - assert_equal 7, s.mass - end - - def test_method_missing - assert_nil @sexp.not_there - assert_equal s(:lit, 42), @basic_sexp.lit - end - - def test_method_missing_ambigious - assert_raises NoMethodError do - pirate = s(:says, s(:arrr!), s(:arrr!), s(:arrr!)) - pirate.arrr! - end - end - - def test_method_missing_deep - sexp = s(:blah, s(:a, s(:b, s(:c, :yay!)))) - assert_equal(s(:c, :yay!), sexp.a.b.c) - end - - def test_method_missing_delete - sexp = s(:blah, s(:a, s(:b, s(:c, :yay!)))) - - assert_equal(s(:c, :yay!), sexp.a.b.c(true)) - assert_equal(s(:blah, s(:a, s(:b))), sexp) - end - - def test_pretty_print - util_pretty_print("s()", - s()) - util_pretty_print("s(:a)", - s(:a)) - util_pretty_print("s(:a, :b)", - s(:a, :b)) - util_pretty_print("s(:a, s(:b))", - s(:a, s(:b))) - end - - def test_sexp_body - assert_equal [2, 3], @sexp.sexp_body - end - - def test_shift - assert_equal(1, @sexp.shift) - assert_equal(2, @sexp.shift) - assert_equal(3, @sexp.shift) - - assert_raises(RuntimeError) do - @sexp.shift - end - end - - def test_structure - @sexp = s(:a, 1, 2, s(:b, 3, 4), 5, 6) - backup = @sexp.deep_clone - expected = s(:a, s(:b)) - - assert_equal(expected, @sexp.structure) - assert_equal(backup, @sexp) - end - - def test_sub - assert_equal s(:c), s().sub(s(), s(:c)) - assert_equal s(:c), s(:b).sub(s(:b), s(:c)) - assert_equal s(:a), s(:a).sub(s(:b), s(:c)) - assert_equal s(:a, s(:c)), s(:a, s(:c)).sub(s(:b), s(:c)) - - assert_equal s(:a, s(:c), s(:b)), s(:a, s(:b), s(:b)).sub(s(:b), s(:c)) - - assert_equal(s(:a, s(:c), s(:a)), - s(:a, s(:b), s(:a)).sub(s(:b), s(:c))) - assert_equal(s(:a, s(:c), s(:a, s(:a))), - s(:a, s(:b), s(:a, s(:a))).sub(s(:b), s(:c))) - assert_equal(s(:a, s(:a), s(:a, s(:c), s(:b))), - s(:a, s(:a), s(:a, s(:b), s(:b))).sub(s(:b), s(:c))) - assert_equal(s(:a, s(:c, s(:b))), - s(:a, s(:b)).sub(s(:b), s(:c, s(:b)))) - end - - def test_to_a - assert_equal([1, 2, 3], @sexp.to_a) - end - - def test_to_s - test_inspect - end -end - -class TestSexpAny < SexpTestCase - - def setup - super - end - - def test_equals - util_equals @any, s() - util_equals @any, s(:a) - util_equals @any, s(:a, :b, s(:c)) - end - - def test_equals3 - util_equals3 @any, s() - util_equals3 @any, s(:a) - util_equals3 @any, s(:a, :b, s(:c)) - end - -end diff --git a/vendor/gems/sexp_processor-3.0.5/test/test_sexp_processor.rb b/vendor/gems/sexp_processor-3.0.5/test/test_sexp_processor.rb deleted file mode 100755 index 9a030ff51f8..00000000000 --- a/vendor/gems/sexp_processor-3.0.5/test/test_sexp_processor.rb +++ /dev/null @@ -1,297 +0,0 @@ -#!/usr/local/bin/ruby -w - -$TESTING = true - -require 'sexp_processor' -require 'stringio' -require 'minitest/autorun' -require 'pp' - -# Fake test classes: - -class TestProcessor < SexpProcessor # ZenTest SKIP - attr_accessor :auto_shift_type - - def process_acc1(exp) - out = self.expected.new(:acc2, exp.thing_three, exp.thing_two, exp.thing_one) - exp.clear - return out - end - - def process_acc2(exp) - out = [] - out << exp.thing_one - end - - def process_specific(exp) - name = exp.shift - result = s(:blah) - until exp.empty? - result.push process(exp.shift) - end - result - end - - def process_strip(exp) - result = exp.deep_clone - exp.clear - result - end - - def process_nonempty(exp) - s(*exp) - end - - def process_broken(exp) - result = [*exp] - exp.clear - result - end - - def process_expected(exp) - exp.clear - return {} - end - - def process_string(exp) - return exp.shift - end - - def rewrite_rewritable(exp) # (a b c) => (a c b) - return s(exp.shift, exp.pop, exp.shift) - end - - def process_rewritable(exp) - @n ||= 0 - exp.shift # name - result = s(:rewritten) - until exp.empty? - result.push process(exp.shift) - end - result.push @n - @n += 1 - result - end - - def rewrite_major_rewrite(exp) - exp[0] = :rewritable - exp - end -end - -class TestProcessorDefault < SexpProcessor # ZenTest SKIP - def initialize - super - self.default_method = :def_method - end - - def def_method(exp) - exp.clear - self.expected.new(42) - end -end - -# Real test classes: - -class TestSexpProcessor < MiniTest::Unit::TestCase - - def setup - @processor = TestProcessor.new - end - - def test_process_specific - a = [:specific, [:x, 1], [:y, 2], [:z, 3]] - expected = [:blah, [:x, 1], [:y, 2], [:z, 3]] - assert_equal(expected, @processor.process(a)) - end - - def test_process_generic - a = [:blah, 1, 2, 3] - expected = a.deep_clone - assert_equal(expected, @processor.process(a)) - end - - def test_process_default - @processor = TestProcessorDefault.new - @processor.warn_on_default = false - - a = s(:blah, 1, 2, 3) - assert_equal(@processor.expected.new(42), @processor.process(a)) - end - - def test_process_not_sexp - @processor = TestProcessor.new - @processor.warn_on_default = false - - assert_raises SexpTypeError do - @processor.process([:broken, 1, 2, 3]) - end - end - - def test_process_unsupported_wrong - @processor = TestProcessor.new - @processor.unsupported << :strip - - assert_raises UnsupportedNodeError do - @processor.process([:whatever]) - end - end - - def test_unsupported_equal - @processor.strict = true - @processor.unsupported = [ :unsupported ] - assert_raises UnsupportedNodeError do - @processor.process([:unsupported, 42]) - end - end - - def test_strict - @processor.strict = true - assert_raises UnknownNodeError do - @processor.process([:blah, 1, 2, 3]) - end - end - def test_strict=; end #Handled - - def test_require_empty_false - @processor.require_empty = false - - @processor.process([:nonempty, 1, 2, 3]) - end - - def test_require_empty_true - assert_raises NotEmptyError do - @processor.process([:nonempty, 1, 2, 3]) - end - end - def test_require_empty=; end # handled - - def test_process_strip - @processor.auto_shift_type = true - assert_equal([1, 2, 3], @processor.process(s(:strip, 1, 2, 3))) - end - - def test_rewrite - assert_equal(s(:rewritable, :b, :a), - @processor.rewrite(s(:rewritable, :a, :b))) - end - - def test_rewrite_different_type - assert_equal(s(:rewritable, :b, :a), - @processor.rewrite(s(:major_rewrite, :a, :b))) - end - - def test_rewrite_deep - assert_equal(s(:specific, s(:rewritable, :b, :a)), - @processor.rewrite(s(:specific, s(:rewritable, :a, :b)))) - end - - def test_rewrite_not_empty - insert = s(:rewritable, 1, 2, 2) - expect = s(:rewritable, 2, 1) - result = @processor.rewrite(insert) - assert_equal(expect, result) - assert_equal(s(2), insert) # post-processing - end - - def test_process_rewrite - assert_equal(s(:rewritten, s(:y, 2), s(:x, 1), 0), - @processor.process(s(:rewritable, s(:x, 1), s(:y, 2)))) - end - - def test_process_rewrite_deep - assert_equal(s(:blah, s(:rewritten, s(:b), s(:a), 0)), - @processor.process(s(:specific, s(:rewritable, s(:a), s(:b))))) - end - - def test_rewrite_depth_first - inn = s(:specific, - s(:rewritable, - s(:a), - s(:rewritable, - s(:rewritable, s(:b), s(:c)), - s(:d)))) - out = s(:specific, - s(:rewritable, - s(:rewritable, - s(:d), - s(:rewritable, s(:c), s(:b))), - s(:a))) - - assert_equal(out, @processor.rewrite(inn)) - end - - def test_process_rewrite_depth_first - inn = s(:specific, - s(:rewritable, - s(:a), - s(:rewritable, - s(:rewritable, s(:b), s(:c)), - s(:d)))) - out = s(:blah, - s(:rewritten, - s(:rewritten, - s(:d), - s(:rewritten, s(:c), s(:b), 0), 1), - s(:a), 2)) - - assert_equal(out, @processor.process(inn)) - end - - def test_assert_type_hit - @processor.assert_type([:blah, 1, 2, 3], :blah) - end - - def test_assert_type_miss - assert_raises SexpTypeError do - @processor.assert_type([:thingy, 1, 2, 3], :blah) - end - end - - def test_generate - # nothing to test at this time... soon. - end - - def test_auto_shift_type - @processor.auto_shift_type = false - assert_equal(false, @processor.auto_shift_type) - @processor.auto_shift_type = true - assert_equal(true, @processor.auto_shift_type) - end - def test_auto_shift_type_equal; end # handled - - def test_default_method - # default functionality tested in process_default - assert_nil @processor.default_method - @processor.default_method = :something - assert_equal :something, @processor.default_method - end - def test_default_method=; end # handled - - def test_expected - assert_equal Sexp, @processor.expected - assert_raises SexpTypeError do - @processor.process([:expected]) # should raise - end - - @processor.process(s(:str, "string")) # shouldn't raise - - @processor.expected = Hash - assert_equal Hash, @processor.expected - assert !(Hash === s()), "Hash === s() should not be true" - - assert_raises SexpTypeError do - @processor.process(s(:string, "string")) # should raise - end - - @processor.process([:expected]) # shouldn't raise - end - def test_expected=; end # handled - - # Not Testing: - def test_debug; end - def test_debug=; end - def test_warn_on_default; end - def test_warn_on_default=; end - -end diff --git a/vendor/plugins/.gitkeep b/vendor/plugins/.gitkeep new file mode 100644 index 00000000000..e69de29bb2d diff --git a/vendor/plugins/acts_as_audited b/vendor/plugins/acts_as_audited deleted file mode 160000 index de6031feaf1..00000000000 --- a/vendor/plugins/acts_as_audited +++ /dev/null @@ -1 +0,0 @@ -Subproject commit de6031feaf1e5d999f70265944d76758fc85b477 diff --git a/vendor/plugins/ancestry b/vendor/plugins/ancestry deleted file mode 160000 index 770f2e36eb8..00000000000 --- a/vendor/plugins/ancestry +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 770f2e36eb8b9865ee0ea1f81f5ca21068bebe3e diff --git a/vendor/plugins/has_many_polymorphs b/vendor/plugins/has_many_polymorphs deleted file mode 160000 index d637f999d25..00000000000 --- a/vendor/plugins/has_many_polymorphs +++ /dev/null @@ -1 +0,0 @@ -Subproject commit d637f999d256a32da27aedb7e8ccd70e2a90a636 diff --git a/vendor/plugins/jrails b/vendor/plugins/jrails deleted file mode 160000 index 712ccd1245d..00000000000 --- a/vendor/plugins/jrails +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 712ccd1245d2871c7018a1c095f27db243209c46 diff --git a/vendor/plugins/ruby-net-ldap b/vendor/plugins/ruby-net-ldap deleted file mode 160000 index ba08042d75a..00000000000 --- a/vendor/plugins/ruby-net-ldap +++ /dev/null @@ -1 +0,0 @@ -Subproject commit ba08042d75ae930578a96846ae7180e8bf450846 diff --git a/vendor/plugins/searchlogic b/vendor/plugins/searchlogic deleted file mode 160000 index a9e38877ba8..00000000000 --- a/vendor/plugins/searchlogic +++ /dev/null @@ -1 +0,0 @@ -Subproject commit a9e38877ba8d20cc8c78d8ebb8666d366e91e1d0 diff --git a/vendor/plugins/virt b/vendor/plugins/virt deleted file mode 160000 index d23bfc88b14..00000000000 --- a/vendor/plugins/virt +++ /dev/null @@ -1 +0,0 @@ -Subproject commit d23bfc88b1427643f2c9ef0c95597bfda823021b diff --git a/vendor/plugins/will_paginate b/vendor/plugins/will_paginate deleted file mode 160000 index 260c1c45ed8..00000000000 --- a/vendor/plugins/will_paginate +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 260c1c45ed8c31917614710015a9dcab7981943a diff --git a/vendor/rails b/vendor/rails deleted file mode 160000 index b0c3d451a24..00000000000 --- a/vendor/rails +++ /dev/null @@ -1 +0,0 @@ -Subproject commit b0c3d451a242b53c9992cafa9108d0df52b4f2f0