diff --git a/.document b/.document old mode 100644 new mode 100755 diff --git a/.gitignore b/.gitignore old mode 100644 new mode 100755 index db30aef9..33eed9a3 --- a/.gitignore +++ b/.gitignore @@ -3,4 +3,26 @@ coverage rdoc pkg -.sass-cache \ No newline at end of file +.sass-cache +bin/autospec +bin/compass +bin/css2sass +bin/cucumber +bin/edit_json.rb +bin/haml +bin/html2haml +bin/htmldiff +bin/launchy +bin/ldiff +bin/prettify_json.rb +bin/rackup +bin/rake +bin/ri +bin/sass +bin/sdoc +bin/sdoc-merge +bin/shotgun +bin/spec +bin/sprocketize +bin/thin +bin/tt diff --git a/Gemfile b/Gemfile new file mode 100755 index 00000000..c3b8af8e --- /dev/null +++ b/Gemfile @@ -0,0 +1,17 @@ +source "http://gemcutter.org" +disable_rubygems + +gem "thin" +gem "shotgun" +gem "templater" +gem "sprockets" +gem "sinatra" +gem "sinatra-content-for" +gem "rack-test" +gem "yui-compressor" +gem "haml" +gem "compass" + +gem "rspec" +gem "sdoc" +gem "cucumber" \ No newline at end of file diff --git a/LICENSE b/LICENSE old mode 100644 new mode 100755 diff --git a/README.rdoc b/README.rdoc old mode 100644 new mode 100755 diff --git a/Rakefile b/Rakefile old mode 100644 new mode 100755 index be52b2a1..6d51c2ec --- a/Rakefile +++ b/Rakefile @@ -1,4 +1,5 @@ require 'rubygems' +#require 'lib/middleman' require 'rake' require 'cucumber/rake/task' @@ -25,6 +26,9 @@ begin gem.add_development_dependency("rspec") gem.add_development_dependency("sdoc") gem.add_development_dependency("cucumber") + + # Ignore vendored files + #gem.files = gem.files.exclude("vendor/*") end Jeweler::GemcutterTasks.new diff --git a/VERSION b/VERSION old mode 100644 new mode 100755 diff --git a/bin/mm-init b/bin/mm-init index 99005033..37a1dfd7 100755 --- a/bin/mm-init +++ b/bin/mm-init @@ -1,4 +1,5 @@ #!/usr/bin/env ruby +require 'rubygems' require 'templater' module Generators diff --git a/deps.rip b/deps.rip old mode 100644 new mode 100755 diff --git a/lib/middleman.rb b/lib/middleman.rb old mode 100644 new mode 100755 index 158577dd..020d9a3c --- a/lib/middleman.rb +++ b/lib/middleman.rb @@ -1,4 +1,6 @@ libdir = File.dirname(__FILE__) $LOAD_PATH.unshift(libdir) unless $LOAD_PATH.include?(libdir) +# Bundler +#require File.join(File.dirname(libdir), "vendor", "gems", "environment") if ENV["RUN_CODE_RUN"] require 'middleman/base' \ No newline at end of file diff --git a/lib/middleman/base.rb b/lib/middleman/base.rb old mode 100644 new mode 100755 diff --git a/lib/middleman/builder.rb b/lib/middleman/builder.rb old mode 100644 new mode 100755 diff --git a/lib/middleman/config.ru b/lib/middleman/config.ru old mode 100644 new mode 100755 diff --git a/lib/middleman/fastimage.rb b/lib/middleman/fastimage.rb old mode 100644 new mode 100755 diff --git a/lib/middleman/features/automatic_image_sizes.rb b/lib/middleman/features/automatic_image_sizes.rb old mode 100644 new mode 100755 diff --git a/lib/middleman/features/cache_buster.rb b/lib/middleman/features/cache_buster.rb old mode 100644 new mode 100755 diff --git a/lib/middleman/features/growl.rb b/lib/middleman/features/growl.rb old mode 100644 new mode 100755 diff --git a/lib/middleman/features/maruku.rb b/lib/middleman/features/maruku.rb old mode 100644 new mode 100755 diff --git a/lib/middleman/features/minify_css.rb b/lib/middleman/features/minify_css.rb old mode 100644 new mode 100755 diff --git a/lib/middleman/features/minify_javascript.rb b/lib/middleman/features/minify_javascript.rb old mode 100644 new mode 100755 diff --git a/lib/middleman/features/relative_assets.rb b/lib/middleman/features/relative_assets.rb old mode 100644 new mode 100755 diff --git a/lib/middleman/features/slickmap.rb b/lib/middleman/features/slickmap.rb old mode 100644 new mode 100755 diff --git a/lib/middleman/features/smush_pngs.rb b/lib/middleman/features/smush_pngs.rb old mode 100644 new mode 100755 diff --git a/lib/middleman/features/sprockets.rb b/lib/middleman/features/sprockets.rb old mode 100644 new mode 100755 diff --git a/lib/middleman/haml.rb b/lib/middleman/haml.rb old mode 100644 new mode 100755 diff --git a/lib/middleman/helpers.rb b/lib/middleman/helpers.rb old mode 100644 new mode 100755 diff --git a/lib/middleman/rack/sprockets+ruby19.rb b/lib/middleman/rack/sprockets+ruby19.rb old mode 100644 new mode 100755 diff --git a/lib/middleman/rack/sprockets.rb b/lib/middleman/rack/sprockets.rb old mode 100644 new mode 100755 diff --git a/lib/middleman/rack/static.rb b/lib/middleman/rack/static.rb old mode 100644 new mode 100755 diff --git a/lib/middleman/sass.rb b/lib/middleman/sass.rb old mode 100644 new mode 100755 diff --git a/lib/middleman/template/init.rbt b/lib/middleman/template/init.rbt old mode 100644 new mode 100755 diff --git a/lib/middleman/template/views/index.html.haml b/lib/middleman/template/views/index.html.haml old mode 100644 new mode 100755 diff --git a/lib/middleman/template/views/layout.haml b/lib/middleman/template/views/layout.haml old mode 100644 new mode 100755 diff --git a/lib/middleman/template/views/stylesheets/site.css.sass b/lib/middleman/template/views/stylesheets/site.css.sass old mode 100644 new mode 100755 diff --git a/lib/middleman/templater+dynamic_renderer.rb b/lib/middleman/templater+dynamic_renderer.rb old mode 100644 new mode 100755 diff --git a/middleman.gemspec b/middleman.gemspec old mode 100644 new mode 100755 diff --git a/spec/auto_image_sizes.rb b/spec/auto_image_sizes.rb old mode 100644 new mode 100755 index b065a84b..a691fbf2 --- a/spec/auto_image_sizes.rb +++ b/spec/auto_image_sizes.rb @@ -1,4 +1,3 @@ -require 'rack/test' require File.join(File.dirname(__FILE__), "spec_helper") base = ::Middleman::Base diff --git a/spec/builder_spec.rb b/spec/builder_spec.rb old mode 100644 new mode 100755 diff --git a/spec/cache_buster_spec.rb b/spec/cache_buster_spec.rb old mode 100644 new mode 100755 index 9e89b781..c44fe6bc --- a/spec/cache_buster_spec.rb +++ b/spec/cache_buster_spec.rb @@ -1,4 +1,3 @@ -require 'rack/test' require File.join(File.dirname(__FILE__), "spec_helper") base = ::Middleman::Base diff --git a/spec/fixtures/sample/init.rb b/spec/fixtures/sample/init.rb old mode 100644 new mode 100755 diff --git a/spec/fixtures/sample/public/images/blank.gif b/spec/fixtures/sample/public/images/blank.gif old mode 100644 new mode 100755 diff --git a/spec/fixtures/sample/public/javascripts/to-be-included.js b/spec/fixtures/sample/public/javascripts/to-be-included.js old mode 100644 new mode 100755 diff --git a/spec/fixtures/sample/public/static.html b/spec/fixtures/sample/public/static.html old mode 100644 new mode 100755 diff --git a/spec/fixtures/sample/public/stylesheets/auto-css.css b/spec/fixtures/sample/public/stylesheets/auto-css.css old mode 100644 new mode 100755 diff --git a/spec/fixtures/sample/public/stylesheets/static.css b/spec/fixtures/sample/public/stylesheets/static.css old mode 100644 new mode 100755 diff --git a/spec/fixtures/sample/public/stylesheets/sub1/auto-css.css b/spec/fixtures/sample/public/stylesheets/sub1/auto-css.css old mode 100644 new mode 100755 diff --git a/spec/fixtures/sample/public/stylesheets/sub1/sub2/auto-css.css b/spec/fixtures/sample/public/stylesheets/sub1/sub2/auto-css.css old mode 100644 new mode 100755 diff --git a/spec/fixtures/sample/views/_partial.haml b/spec/fixtures/sample/views/_partial.haml old mode 100644 new mode 100755 diff --git a/spec/fixtures/sample/views/auto-css.html.haml b/spec/fixtures/sample/views/auto-css.html.haml old mode 100644 new mode 100755 diff --git a/spec/fixtures/sample/views/auto-image-sizes.html.haml b/spec/fixtures/sample/views/auto-image-sizes.html.haml old mode 100644 new mode 100755 diff --git a/spec/fixtures/sample/views/index.html.haml b/spec/fixtures/sample/views/index.html.haml old mode 100644 new mode 100755 diff --git a/spec/fixtures/sample/views/inline-js.html.haml b/spec/fixtures/sample/views/inline-js.html.haml old mode 100644 new mode 100755 diff --git a/spec/fixtures/sample/views/javascripts/empty-with-include.js b/spec/fixtures/sample/views/javascripts/empty-with-include.js old mode 100644 new mode 100755 diff --git a/spec/fixtures/sample/views/layout.haml b/spec/fixtures/sample/views/layout.haml old mode 100644 new mode 100755 diff --git a/spec/fixtures/sample/views/maruku.html.maruku b/spec/fixtures/sample/views/maruku.html.maruku old mode 100644 new mode 100755 diff --git a/spec/fixtures/sample/views/page-classes.html.haml b/spec/fixtures/sample/views/page-classes.html.haml old mode 100644 new mode 100755 diff --git a/spec/fixtures/sample/views/services/index.html.haml b/spec/fixtures/sample/views/services/index.html.haml old mode 100644 new mode 100755 diff --git a/spec/fixtures/sample/views/stylesheets/relative_assets.css.sass b/spec/fixtures/sample/views/stylesheets/relative_assets.css.sass old mode 100644 new mode 100755 diff --git a/spec/fixtures/sample/views/stylesheets/site.css.sass b/spec/fixtures/sample/views/stylesheets/site.css.sass old mode 100644 new mode 100755 diff --git a/spec/generator_spec.rb b/spec/generator_spec.rb old mode 100644 new mode 100755 diff --git a/spec/helpers_spec.rb b/spec/helpers_spec.rb old mode 100644 new mode 100755 index da15e8cb..c564a885 --- a/spec/helpers_spec.rb +++ b/spec/helpers_spec.rb @@ -1,4 +1,3 @@ -require 'rack/test' require File.join(File.dirname(__FILE__), "spec_helper") base = ::Middleman::Base diff --git a/spec/minify_javascript_spec.rb b/spec/minify_javascript_spec.rb old mode 100644 new mode 100755 index a1a06a91..0081d354 --- a/spec/minify_javascript_spec.rb +++ b/spec/minify_javascript_spec.rb @@ -1,4 +1,3 @@ -require 'rack/test' require File.join(File.dirname(__FILE__), "spec_helper") base = ::Middleman::Base diff --git a/spec/relative_assets_spec.rb b/spec/relative_assets_spec.rb old mode 100644 new mode 100755 index 5940a170..d982aedb --- a/spec/relative_assets_spec.rb +++ b/spec/relative_assets_spec.rb @@ -1,4 +1,3 @@ -require 'rack/test' require File.join(File.dirname(__FILE__), "spec_helper") base = ::Middleman::Base diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb old mode 100644 new mode 100755 index cfbd9d72..2ac601b5 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,9 +1,8 @@ require 'rubygems' require 'spec' +require 'rack/test' -$LOAD_PATH.unshift(File.dirname(__FILE__)) -$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib')) -require 'middleman' +require File.join(File.dirname(File.dirname(__FILE__)), 'lib', 'middleman') Spec::Runner.configure do |config| diff --git a/vendor/gems/cache/builder-2.1.2.gem b/vendor/gems/cache/builder-2.1.2.gem new file mode 100755 index 00000000..c9016972 Binary files /dev/null and b/vendor/gems/cache/builder-2.1.2.gem differ diff --git a/vendor/gems/cache/compass-0.8.17.gem b/vendor/gems/cache/compass-0.8.17.gem new file mode 100755 index 00000000..fcde600e Binary files /dev/null and b/vendor/gems/cache/compass-0.8.17.gem differ diff --git a/vendor/gems/cache/configuration-1.1.0.gem b/vendor/gems/cache/configuration-1.1.0.gem new file mode 100755 index 00000000..25cc4965 Binary files /dev/null and b/vendor/gems/cache/configuration-1.1.0.gem differ diff --git a/vendor/gems/cache/cucumber-0.4.4.gem b/vendor/gems/cache/cucumber-0.4.4.gem new file mode 100755 index 00000000..7447f604 Binary files /dev/null and b/vendor/gems/cache/cucumber-0.4.4.gem differ diff --git a/vendor/gems/cache/daemons-1.0.10.gem b/vendor/gems/cache/daemons-1.0.10.gem new file mode 100755 index 00000000..248c9507 Binary files /dev/null and b/vendor/gems/cache/daemons-1.0.10.gem differ diff --git a/vendor/gems/cache/diff-lcs-1.1.2.gem b/vendor/gems/cache/diff-lcs-1.1.2.gem new file mode 100755 index 00000000..aa0be73b Binary files /dev/null and b/vendor/gems/cache/diff-lcs-1.1.2.gem differ diff --git a/vendor/gems/cache/eventmachine-0.12.10.gem b/vendor/gems/cache/eventmachine-0.12.10.gem new file mode 100755 index 00000000..aa54c34a Binary files /dev/null and b/vendor/gems/cache/eventmachine-0.12.10.gem differ diff --git a/vendor/gems/cache/extlib-0.9.13.gem b/vendor/gems/cache/extlib-0.9.13.gem new file mode 100755 index 00000000..3ef00baa Binary files /dev/null and b/vendor/gems/cache/extlib-0.9.13.gem differ diff --git a/vendor/gems/cache/haml-2.2.13.gem b/vendor/gems/cache/haml-2.2.13.gem new file mode 100755 index 00000000..0785a0ec Binary files /dev/null and b/vendor/gems/cache/haml-2.2.13.gem differ diff --git a/vendor/gems/cache/highline-1.5.1.gem b/vendor/gems/cache/highline-1.5.1.gem new file mode 100755 index 00000000..e1a10f51 Binary files /dev/null and b/vendor/gems/cache/highline-1.5.1.gem differ diff --git a/vendor/gems/cache/json-1.2.0.gem b/vendor/gems/cache/json-1.2.0.gem new file mode 100755 index 00000000..0fefc67c Binary files /dev/null and b/vendor/gems/cache/json-1.2.0.gem differ diff --git a/vendor/gems/cache/launchy-0.3.3.gem b/vendor/gems/cache/launchy-0.3.3.gem new file mode 100755 index 00000000..b915520e Binary files /dev/null and b/vendor/gems/cache/launchy-0.3.3.gem differ diff --git a/vendor/gems/cache/polyglot-0.2.9.gem b/vendor/gems/cache/polyglot-0.2.9.gem new file mode 100755 index 00000000..29a97ee1 Binary files /dev/null and b/vendor/gems/cache/polyglot-0.2.9.gem differ diff --git a/vendor/gems/cache/rack-1.0.1.gem b/vendor/gems/cache/rack-1.0.1.gem new file mode 100755 index 00000000..bae1ede2 Binary files /dev/null and b/vendor/gems/cache/rack-1.0.1.gem differ diff --git a/vendor/gems/cache/rack-test-0.5.1.gem b/vendor/gems/cache/rack-test-0.5.1.gem new file mode 100755 index 00000000..ed57b845 Binary files /dev/null and b/vendor/gems/cache/rack-test-0.5.1.gem differ diff --git a/vendor/gems/cache/rake-0.8.7.gem b/vendor/gems/cache/rake-0.8.7.gem new file mode 100755 index 00000000..0740cec7 Binary files /dev/null and b/vendor/gems/cache/rake-0.8.7.gem differ diff --git a/vendor/gems/cache/rdoc-2.4.3.gem b/vendor/gems/cache/rdoc-2.4.3.gem new file mode 100755 index 00000000..8d24281d Binary files /dev/null and b/vendor/gems/cache/rdoc-2.4.3.gem differ diff --git a/vendor/gems/cache/rspec-1.2.9.gem b/vendor/gems/cache/rspec-1.2.9.gem new file mode 100755 index 00000000..4a712d64 Binary files /dev/null and b/vendor/gems/cache/rspec-1.2.9.gem differ diff --git a/vendor/gems/cache/sdoc-0.2.14.1.gem b/vendor/gems/cache/sdoc-0.2.14.1.gem new file mode 100755 index 00000000..4e894216 Binary files /dev/null and b/vendor/gems/cache/sdoc-0.2.14.1.gem differ diff --git a/vendor/gems/cache/shotgun-0.4.gem b/vendor/gems/cache/shotgun-0.4.gem new file mode 100755 index 00000000..1876bfb6 Binary files /dev/null and b/vendor/gems/cache/shotgun-0.4.gem differ diff --git a/vendor/gems/cache/sinatra-0.9.4.gem b/vendor/gems/cache/sinatra-0.9.4.gem new file mode 100755 index 00000000..c30a6f78 Binary files /dev/null and b/vendor/gems/cache/sinatra-0.9.4.gem differ diff --git a/vendor/gems/cache/sinatra-content-for-0.2.gem b/vendor/gems/cache/sinatra-content-for-0.2.gem new file mode 100755 index 00000000..f2e0528b Binary files /dev/null and b/vendor/gems/cache/sinatra-content-for-0.2.gem differ diff --git a/vendor/gems/cache/sprockets-1.0.2.gem b/vendor/gems/cache/sprockets-1.0.2.gem new file mode 100755 index 00000000..6e7b9b9e Binary files /dev/null and b/vendor/gems/cache/sprockets-1.0.2.gem differ diff --git a/vendor/gems/cache/templater-1.0.0.gem b/vendor/gems/cache/templater-1.0.0.gem new file mode 100755 index 00000000..58c86afb Binary files /dev/null and b/vendor/gems/cache/templater-1.0.0.gem differ diff --git a/vendor/gems/cache/term-ansicolor-1.0.4.gem b/vendor/gems/cache/term-ansicolor-1.0.4.gem new file mode 100755 index 00000000..11f724ba Binary files /dev/null and b/vendor/gems/cache/term-ansicolor-1.0.4.gem differ diff --git a/vendor/gems/cache/thin-1.2.5.gem b/vendor/gems/cache/thin-1.2.5.gem new file mode 100755 index 00000000..25fc506d Binary files /dev/null and b/vendor/gems/cache/thin-1.2.5.gem differ diff --git a/vendor/gems/cache/treetop-1.4.2.gem b/vendor/gems/cache/treetop-1.4.2.gem new file mode 100755 index 00000000..9e6f6272 Binary files /dev/null and b/vendor/gems/cache/treetop-1.4.2.gem differ diff --git a/vendor/gems/cache/yui-compressor-0.9.1.gem b/vendor/gems/cache/yui-compressor-0.9.1.gem new file mode 100755 index 00000000..1f1b7169 Binary files /dev/null and b/vendor/gems/cache/yui-compressor-0.9.1.gem differ diff --git a/vendor/gems/environment.rb b/vendor/gems/environment.rb new file mode 100755 index 00000000..a0d9f35c --- /dev/null +++ b/vendor/gems/environment.rb @@ -0,0 +1,205 @@ +# DO NOT MODIFY THIS FILE +module Bundler + file = File.expand_path(__FILE__) + dir = File.dirname(file) + + ENV["PATH"] = "#{dir}/../../bin:#{ENV["PATH"]}" + ENV["RUBYOPT"] = "-r#{file} #{ENV["RUBYOPT"]}" + + $LOAD_PATH.unshift File.expand_path("#{dir}/gems/rdoc-2.4.3/bin") + $LOAD_PATH.unshift File.expand_path("#{dir}/gems/rdoc-2.4.3/lib") + $LOAD_PATH.unshift File.expand_path("#{dir}/gems/configuration-1.1.0/bin") + $LOAD_PATH.unshift File.expand_path("#{dir}/gems/configuration-1.1.0/lib") + $LOAD_PATH.unshift File.expand_path("#{dir}/gems/builder-2.1.2/bin") + $LOAD_PATH.unshift File.expand_path("#{dir}/gems/builder-2.1.2/lib") + $LOAD_PATH.unshift File.expand_path("#{dir}/gems/daemons-1.0.10/bin") + $LOAD_PATH.unshift File.expand_path("#{dir}/gems/daemons-1.0.10/lib") + $LOAD_PATH.unshift File.expand_path("#{dir}/gems/extlib-0.9.13/bin") + $LOAD_PATH.unshift File.expand_path("#{dir}/gems/extlib-0.9.13/lib") + $LOAD_PATH.unshift File.expand_path("#{dir}/gems/json-1.2.0/bin") + $LOAD_PATH.unshift File.expand_path("#{dir}/gems/json-1.2.0/ext/json/ext") + $LOAD_PATH.unshift File.expand_path("#{dir}/gems/json-1.2.0/ext") + $LOAD_PATH.unshift File.expand_path("#{dir}/gems/json-1.2.0/lib") + $LOAD_PATH.unshift File.expand_path("#{dir}/gems/eventmachine-0.12.10/bin") + $LOAD_PATH.unshift File.expand_path("#{dir}/gems/eventmachine-0.12.10/lib") + $LOAD_PATH.unshift File.expand_path("#{dir}/gems/rack-1.0.1/bin") + $LOAD_PATH.unshift File.expand_path("#{dir}/gems/rack-1.0.1/lib") + $LOAD_PATH.unshift File.expand_path("#{dir}/gems/shotgun-0.4/bin") + $LOAD_PATH.unshift File.expand_path("#{dir}/gems/shotgun-0.4/lib") + $LOAD_PATH.unshift File.expand_path("#{dir}/gems/rack-test-0.5.1/bin") + $LOAD_PATH.unshift File.expand_path("#{dir}/gems/rack-test-0.5.1/lib") + $LOAD_PATH.unshift File.expand_path("#{dir}/gems/sinatra-0.9.4/bin") + $LOAD_PATH.unshift File.expand_path("#{dir}/gems/sinatra-0.9.4/lib") + $LOAD_PATH.unshift File.expand_path("#{dir}/gems/thin-1.2.5/bin") + $LOAD_PATH.unshift File.expand_path("#{dir}/gems/thin-1.2.5/lib") + $LOAD_PATH.unshift File.expand_path("#{dir}/gems/sdoc-0.2.14.1/bin") + $LOAD_PATH.unshift File.expand_path("#{dir}/gems/sdoc-0.2.14.1/lib") + $LOAD_PATH.unshift File.expand_path("#{dir}/gems/yui-compressor-0.9.1/bin") + $LOAD_PATH.unshift File.expand_path("#{dir}/gems/yui-compressor-0.9.1/lib") + $LOAD_PATH.unshift File.expand_path("#{dir}/gems/polyglot-0.2.9/bin") + $LOAD_PATH.unshift File.expand_path("#{dir}/gems/polyglot-0.2.9/lib") + $LOAD_PATH.unshift File.expand_path("#{dir}/gems/treetop-1.4.2/bin") + $LOAD_PATH.unshift File.expand_path("#{dir}/gems/treetop-1.4.2/lib") + $LOAD_PATH.unshift File.expand_path("#{dir}/gems/rake-0.8.7/bin") + $LOAD_PATH.unshift File.expand_path("#{dir}/gems/rake-0.8.7/lib") + $LOAD_PATH.unshift File.expand_path("#{dir}/gems/launchy-0.3.3/bin") + $LOAD_PATH.unshift File.expand_path("#{dir}/gems/launchy-0.3.3/lib") + $LOAD_PATH.unshift File.expand_path("#{dir}/gems/sprockets-1.0.2/bin") + $LOAD_PATH.unshift File.expand_path("#{dir}/gems/sprockets-1.0.2/lib") + $LOAD_PATH.unshift File.expand_path("#{dir}/gems/haml-2.2.13/bin") + $LOAD_PATH.unshift File.expand_path("#{dir}/gems/haml-2.2.13/lib") + $LOAD_PATH.unshift File.expand_path("#{dir}/gems/diff-lcs-1.1.2/bin") + $LOAD_PATH.unshift File.expand_path("#{dir}/gems/diff-lcs-1.1.2/lib") + $LOAD_PATH.unshift File.expand_path("#{dir}/gems/rspec-1.2.9/bin") + $LOAD_PATH.unshift File.expand_path("#{dir}/gems/rspec-1.2.9/lib") + $LOAD_PATH.unshift File.expand_path("#{dir}/gems/highline-1.5.1/bin") + $LOAD_PATH.unshift File.expand_path("#{dir}/gems/highline-1.5.1/lib") + $LOAD_PATH.unshift File.expand_path("#{dir}/gems/templater-1.0.0/bin") + $LOAD_PATH.unshift File.expand_path("#{dir}/gems/templater-1.0.0/lib") + $LOAD_PATH.unshift File.expand_path("#{dir}/gems/term-ansicolor-1.0.4/bin") + $LOAD_PATH.unshift File.expand_path("#{dir}/gems/term-ansicolor-1.0.4/lib") + $LOAD_PATH.unshift File.expand_path("#{dir}/gems/cucumber-0.4.4/bin") + $LOAD_PATH.unshift File.expand_path("#{dir}/gems/cucumber-0.4.4/lib") + $LOAD_PATH.unshift File.expand_path("#{dir}/gems/sinatra-content-for-0.2/bin") + $LOAD_PATH.unshift File.expand_path("#{dir}/gems/sinatra-content-for-0.2/lib") + $LOAD_PATH.unshift File.expand_path("#{dir}/gems/compass-0.8.17/bin") + $LOAD_PATH.unshift File.expand_path("#{dir}/gems/compass-0.8.17/lib") + + @gemfile = "#{dir}/../../Gemfile" + + require "rubygems" + + @bundled_specs = {} + @bundled_specs["rdoc"] = eval(File.read("#{dir}/specifications/rdoc-2.4.3.gemspec")) + @bundled_specs["rdoc"].loaded_from = "#{dir}/specifications/rdoc-2.4.3.gemspec" + @bundled_specs["configuration"] = eval(File.read("#{dir}/specifications/configuration-1.1.0.gemspec")) + @bundled_specs["configuration"].loaded_from = "#{dir}/specifications/configuration-1.1.0.gemspec" + @bundled_specs["builder"] = eval(File.read("#{dir}/specifications/builder-2.1.2.gemspec")) + @bundled_specs["builder"].loaded_from = "#{dir}/specifications/builder-2.1.2.gemspec" + @bundled_specs["daemons"] = eval(File.read("#{dir}/specifications/daemons-1.0.10.gemspec")) + @bundled_specs["daemons"].loaded_from = "#{dir}/specifications/daemons-1.0.10.gemspec" + @bundled_specs["extlib"] = eval(File.read("#{dir}/specifications/extlib-0.9.13.gemspec")) + @bundled_specs["extlib"].loaded_from = "#{dir}/specifications/extlib-0.9.13.gemspec" + @bundled_specs["json"] = eval(File.read("#{dir}/specifications/json-1.2.0.gemspec")) + @bundled_specs["json"].loaded_from = "#{dir}/specifications/json-1.2.0.gemspec" + @bundled_specs["eventmachine"] = eval(File.read("#{dir}/specifications/eventmachine-0.12.10.gemspec")) + @bundled_specs["eventmachine"].loaded_from = "#{dir}/specifications/eventmachine-0.12.10.gemspec" + @bundled_specs["rack"] = eval(File.read("#{dir}/specifications/rack-1.0.1.gemspec")) + @bundled_specs["rack"].loaded_from = "#{dir}/specifications/rack-1.0.1.gemspec" + @bundled_specs["shotgun"] = eval(File.read("#{dir}/specifications/shotgun-0.4.gemspec")) + @bundled_specs["shotgun"].loaded_from = "#{dir}/specifications/shotgun-0.4.gemspec" + @bundled_specs["rack-test"] = eval(File.read("#{dir}/specifications/rack-test-0.5.1.gemspec")) + @bundled_specs["rack-test"].loaded_from = "#{dir}/specifications/rack-test-0.5.1.gemspec" + @bundled_specs["sinatra"] = eval(File.read("#{dir}/specifications/sinatra-0.9.4.gemspec")) + @bundled_specs["sinatra"].loaded_from = "#{dir}/specifications/sinatra-0.9.4.gemspec" + @bundled_specs["thin"] = eval(File.read("#{dir}/specifications/thin-1.2.5.gemspec")) + @bundled_specs["thin"].loaded_from = "#{dir}/specifications/thin-1.2.5.gemspec" + @bundled_specs["sdoc"] = eval(File.read("#{dir}/specifications/sdoc-0.2.14.1.gemspec")) + @bundled_specs["sdoc"].loaded_from = "#{dir}/specifications/sdoc-0.2.14.1.gemspec" + @bundled_specs["yui-compressor"] = eval(File.read("#{dir}/specifications/yui-compressor-0.9.1.gemspec")) + @bundled_specs["yui-compressor"].loaded_from = "#{dir}/specifications/yui-compressor-0.9.1.gemspec" + @bundled_specs["polyglot"] = eval(File.read("#{dir}/specifications/polyglot-0.2.9.gemspec")) + @bundled_specs["polyglot"].loaded_from = "#{dir}/specifications/polyglot-0.2.9.gemspec" + @bundled_specs["treetop"] = eval(File.read("#{dir}/specifications/treetop-1.4.2.gemspec")) + @bundled_specs["treetop"].loaded_from = "#{dir}/specifications/treetop-1.4.2.gemspec" + @bundled_specs["rake"] = eval(File.read("#{dir}/specifications/rake-0.8.7.gemspec")) + @bundled_specs["rake"].loaded_from = "#{dir}/specifications/rake-0.8.7.gemspec" + @bundled_specs["launchy"] = eval(File.read("#{dir}/specifications/launchy-0.3.3.gemspec")) + @bundled_specs["launchy"].loaded_from = "#{dir}/specifications/launchy-0.3.3.gemspec" + @bundled_specs["sprockets"] = eval(File.read("#{dir}/specifications/sprockets-1.0.2.gemspec")) + @bundled_specs["sprockets"].loaded_from = "#{dir}/specifications/sprockets-1.0.2.gemspec" + @bundled_specs["haml"] = eval(File.read("#{dir}/specifications/haml-2.2.13.gemspec")) + @bundled_specs["haml"].loaded_from = "#{dir}/specifications/haml-2.2.13.gemspec" + @bundled_specs["diff-lcs"] = eval(File.read("#{dir}/specifications/diff-lcs-1.1.2.gemspec")) + @bundled_specs["diff-lcs"].loaded_from = "#{dir}/specifications/diff-lcs-1.1.2.gemspec" + @bundled_specs["rspec"] = eval(File.read("#{dir}/specifications/rspec-1.2.9.gemspec")) + @bundled_specs["rspec"].loaded_from = "#{dir}/specifications/rspec-1.2.9.gemspec" + @bundled_specs["highline"] = eval(File.read("#{dir}/specifications/highline-1.5.1.gemspec")) + @bundled_specs["highline"].loaded_from = "#{dir}/specifications/highline-1.5.1.gemspec" + @bundled_specs["templater"] = eval(File.read("#{dir}/specifications/templater-1.0.0.gemspec")) + @bundled_specs["templater"].loaded_from = "#{dir}/specifications/templater-1.0.0.gemspec" + @bundled_specs["term-ansicolor"] = eval(File.read("#{dir}/specifications/term-ansicolor-1.0.4.gemspec")) + @bundled_specs["term-ansicolor"].loaded_from = "#{dir}/specifications/term-ansicolor-1.0.4.gemspec" + @bundled_specs["cucumber"] = eval(File.read("#{dir}/specifications/cucumber-0.4.4.gemspec")) + @bundled_specs["cucumber"].loaded_from = "#{dir}/specifications/cucumber-0.4.4.gemspec" + @bundled_specs["sinatra-content-for"] = eval(File.read("#{dir}/specifications/sinatra-content-for-0.2.gemspec")) + @bundled_specs["sinatra-content-for"].loaded_from = "#{dir}/specifications/sinatra-content-for-0.2.gemspec" + @bundled_specs["compass"] = eval(File.read("#{dir}/specifications/compass-0.8.17.gemspec")) + @bundled_specs["compass"].loaded_from = "#{dir}/specifications/compass-0.8.17.gemspec" + + def self.add_specs_to_loaded_specs + Gem.loaded_specs.merge! @bundled_specs + end + + def self.add_specs_to_index + @bundled_specs.each do |name, spec| + Gem.source_index.add_spec spec + end + end + + add_specs_to_loaded_specs + add_specs_to_index + + def self.require_env(env = nil) + context = Class.new do + def initialize(env) @env = env && env.to_s ; end + def method_missing(*) ; yield if block_given? ; end + def only(*env) + old, @only = @only, _combine_only(env.flatten) + yield + @only = old + end + def except(*env) + old, @except = @except, _combine_except(env.flatten) + yield + @except = old + end + def gem(name, *args) + opt = args.last.is_a?(Hash) ? args.pop : {} + only = _combine_only(opt[:only] || opt["only"]) + except = _combine_except(opt[:except] || opt["except"]) + files = opt[:require_as] || opt["require_as"] || name + files = [files] unless files.respond_to?(:each) + + return unless !only || only.any? {|e| e == @env } + return if except && except.any? {|e| e == @env } + + if files = opt[:require_as] || opt["require_as"] + files = Array(files) + files.each { |f| require f } + else + begin + require name + rescue LoadError + # Do nothing + end + end + yield if block_given? + true + end + private + def _combine_only(only) + return @only unless only + only = [only].flatten.compact.uniq.map { |o| o.to_s } + only &= @only if @only + only + end + def _combine_except(except) + return @except unless except + except = [except].flatten.compact.uniq.map { |o| o.to_s } + except |= @except if @except + except + end + end + context.new(env && env.to_s).instance_eval(File.read(@gemfile), @gemfile, 1) + end +end + +module Gem + @loaded_stacks = Hash.new { |h,k| h[k] = [] } + + def source_index.refresh! + super + Bundler.add_specs_to_index + end +end diff --git a/vendor/gems/gems/builder-2.1.2/CHANGES b/vendor/gems/gems/builder-2.1.2/CHANGES new file mode 100755 index 00000000..4843141c --- /dev/null +++ b/vendor/gems/gems/builder-2.1.2/CHANGES @@ -0,0 +1,85 @@ += Change Log + +== Version 2.1.2 + +* Fixed bug where private methods in kernel could leak through using + tag!(). Thanks to Hagen Overdick for finding and diagnosing this + bug. + + +== Version 2.1.1 + +* Fixed typo in XmlMarkup class docs (ident => indent). (from Martin + Fowler). +* Removed extra directory indirection from legacy CVS to SVN move. +* Removed some extraneous tabs from source. +* Fixed test on private methods in blankslate to differentiate between + targetted and untargetted private methods. +* Removed legacy capture of @self in XmlBase (@self was used back when + we used instance eval). +* Added additional tests for global functions (both direct and included). + +== Version 2.1.0 + +* Fixed bug in BlankSlate where including a module into Object could + cause methods to leak into BlankSlate. +* Made BlankSlate available as its own gem. Currently the builder gem + still directly includes the BlankSlate code. +* Added reveal capability to BlankSlate. + +== Version 2.0.0 + +* Added doc directory +* Added unit tests for XmlEvents. +* Added XChar module and used it in the _escape method. +* Attributes are now quoted by default when strings. Use Symbol + attribute values for unquoted behavior. + +== Version 1.2.4 + +* Added a cdata! command to an XML Builder (from Josh Knowles). + +== Version 1.2.3 + +The attributes in the instruction will be ordered: +version, encoding, standalone. + +== Version 1.2.2 + +Another fix for BlankSlate. The Kernal/Object traps added in 1.2.1 +failed when a method was defined late more than once. Since the +method was already marked as removed, another attempt to undefine it +raised an error. The fix was to check the list of instance methods +before attempting the undef operation. Thanks to Florian Gross and +David Heinemeier Hansson for the patch. + +== Version 1.2.1 + +BlankSlate now traps method definitions in Kernel and Object to avoid +late method definitions inadvertently becoming part of the definition +of BlankSlate as well. + +== Version 1.2.0 + +Improved support for entity declarations by allowing nested +declarations and removal of the attribute processing. + +Added namespace support. + +== Version 1.1.0 + +Added support for comments, entity declarations and processing instructions. + +== Version 1.0.0 + +Removed use of instace_eval making the use of XmlMarkup much +less prone to error. + +== Version 0.1.1 + +Bug fix. + +== Version 0.1.0 + +Initial version release. + diff --git a/vendor/gems/gems/builder-2.1.2/README b/vendor/gems/gems/builder-2.1.2/README new file mode 100755 index 00000000..5ba72dff --- /dev/null +++ b/vendor/gems/gems/builder-2.1.2/README @@ -0,0 +1,210 @@ += Project: Builder + +== Goal + +Provide a simple way to create XML markup and data structures. + +== Classes + +Builder::XmlMarkup:: Generate XML markup notiation +Builder::XmlEvents:: Generate XML events (i.e. SAX-like) + +Notes:: + +* An Builder::XmlTree class to generate XML tree + (i.e. DOM-like) structures is also planned, but not yet implemented. + Also, the events builder is currently lagging the markup builder in + features. + +== Usage + + require 'rubygems' + require_gem 'builder', '~> 2.0' + + builder = Builder::XmlMarkup.new + xml = builder.person { |b| b.name("Jim"); b.phone("555-1234") } + xml #=> Jim555-1234 + +or + + require 'rubygems' + require_gem 'builder' + + builder = Builder::XmlMarkup.new(:target=>STDOUT, :indent=>2) + builder.person { |b| b.name("Jim"); b.phone("555-1234") } + # + # Prints: + # + # Jim + # 555-1234 + # + +== Compatibility + +=== Version 2.0.0 Compatibility Changes + +Version 2.0.0 introduces automatically escaped attribute values for +the first time. Versions prior to 2.0.0 did not insert escape +characters into attribute values in the XML markup. This allowed +attribute values to explicitly reference entities, which was +occasionally used by a small number of developers. Since strings +could always be explicitly escaped by hand, this was not a major +restriction in functionality. + +However, it did suprise most users of builder. Since the body text is +normally escaped, everybody expected the attribute values to be +escaped as well. Escaped attribute values were the number one support +request on the 1.x Builder series. + +Starting with Builder version 2.0.0, all attribute values expressed as +strings will be processed and the appropriate characters will be +escaped (e.g. "&" will be tranlated to "&"). Attribute values +that are expressed as Symbol values will not be processed for escaped +characters and will be unchanged in output. (Yes, this probably counts +as Symbol abuse, but the convention is convenient and flexible). + +Example: + + xml = Builder::XmlMarkup.new + xml.sample(:escaped=>"This&That", :unescaped=>:"Here&There") + xml.target! => + + +=== Version 1.0.0 Compatibility Changes + +Version 1.0.0 introduces some changes that are not backwards +compatible with earlier releases of builder. The main areas of +incompatibility are: + +* Keyword based arguments to +new+ (rather than positional based). It + was found that a developer would often like to specify indentation + without providing an explicit target, or specify a target without + indentation. Keyword based arguments handle this situation nicely. + +* Builder must now be an explicit target for markup tags. Instead of + writing + + xml_markup = Builder::XmlMarkup.new + xml_markup.div { strong("text") } + + you need to write + + xml_markup = Builder::XmlMarkup.new + xml_markup.div { xml_markup.strong("text") } + +* The builder object is passed as a parameter to all nested markup + blocks. This allows you to create a short alias for the builder + object that can be used within the block. For example, the previous + example can be written as: + + xml_markup = Builder::XmlMarkup.new + xml_markup.div { |xml| xml.strong("text") } + +* If you have both a pre-1.0 and a post-1.0 gem of builder installed, + you can choose which version to use through the RubyGems + +require_gem+ facility. + + require_gem 'builder', "~> 0.0" # Gets the old version + require_gem 'builder', "~> 1.0" # Gets the new version + +== Features + +* XML Comments are supported ... + + xml_markup.comment! "This is a comment" + #=> + +* XML processing instructions are supported ... + + xml_markup.instruct! :xml, :version=>"1.0", :encoding=>"UTF-8" + #=> + + If the processing instruction is omitted, it defaults to "xml". + When the processing instruction is "xml", the defaults attributes + are: + + version:: 1.0 + encoding:: "UTF-8" + +* XML entity declarations are now supported to a small degree. + + xml_markup.declare! :DOCTYPE, :chapter, :SYSTEM, "../dtds/chapter.dtd" + #=> + + The parameters to a declare! method must be either symbols or + strings. Symbols are inserted without quotes, and strings are + inserted with double quotes. Attribute-like arguments in hashes are + not allowed. + + If you need to have an argument to declare! be inserted without + quotes, but the arguement does not conform to the typical Ruby + syntax for symbols, then use the :"string" form to specify a symbol. + + For example: + + xml_markup.declare! :ELEMENT, :chapter, :"(title,para+)" + #=> + + Nested entity declarations are allowed. For example: + + @xml_markup.declare! :DOCTYPE, :chapter do |x| + x.declare! :ELEMENT, :chapter, :"(title,para+)" + x.declare! :ELEMENT, :title, :"(#PCDATA)" + x.declare! :ELEMENT, :para, :"(#PCDATA)" + end + + #=> + + + + + ]> + +* Some support for XML namespaces is now available. If the first + argument to a tag call is a symbol, it will be joined to the tag to + produce a namespace:tag combination. It is easier to show this than + describe it. + + xml.SOAP :Envelope do ... end + + Just put a space before the colon in a namespace to produce the + right form for builder (e.g. "SOAP:Envelope" => + "xml.SOAP :Envelope") + +* String attribute values are now escaped by default by + Builder (NOTE: this is _new_ behavior as of version 2.0). + + However, occasionally you need to use entities in attribute values. + Using a symbols (rather than a string) for an attribute value will + cause Builder to not run its quoting/escaping algorithm on that + particular value. + + (Note: The +escape_attrs+ option for builder is now + obsolete). + + Example: + + xml = Builder::XmlMarkup.new + xml.sample(:escaped=>"This&That", :unescaped=>:"Here&There") + xml.target! => + + +* UTF-8 Support + + Builder correctly translates UTF-8 characters into valid XML. (New + in version 2.0.0). Thanks to Sam Ruby for the translation code. + + Example: + + xml = Builder::Markup.new + xml.sample("Iñtërnâtiônàl") + xml.target! => + "Iñtërnâtiônàl" + +== Contact + +Author:: Jim Weirich +Email:: jim@weirichhouse.org +Home Page:: http://onestepback.org +License:: MIT Licence (http://www.opensource.org/licenses/mit-license.html) diff --git a/vendor/gems/gems/builder-2.1.2/Rakefile b/vendor/gems/gems/builder-2.1.2/Rakefile new file mode 100755 index 00000000..89e1ae2c --- /dev/null +++ b/vendor/gems/gems/builder-2.1.2/Rakefile @@ -0,0 +1,263 @@ +# Rakefile for rake -*- ruby -*- + +# Copyright 2004, 2005, 2006 by Jim Weirich (jim@weirichhouse.org). +# All rights reserved. + +# Permission is granted for use, copying, modification, distribution, +# and distribution of modified versions of this work as long as the +# above copyright notice is included. + +require 'rake/clean' +require 'rake/testtask' +require 'rake/rdoctask' +begin + require 'rubygems' + require 'rake/gempackagetask' +rescue Exception + nil +end + +# Determine the current version of the software + +CLOBBER.include('pkg') + +CURRENT_VERSION = '2.1.2' +PKG_VERSION = ENV['REL'] ? ENV['REL'] : CURRENT_VERSION + +SRC_RB = FileList['lib/**/*.rb'] + +# The default task is run if rake is given no explicit arguments. + +desc "Default Task" +task :default => :test_all + +# Test Tasks --------------------------------------------------------- + +desc "Run all tests" +task :test_all => [:test_units] +task :ta => [:test_all] + +task :tu => [:test_units] + +Rake::TestTask.new("test_units") do |t| + t.test_files = FileList['test/test*.rb'] + t.verbose = false +end + +# Create a task to build the RDOC documentation tree. + +rd = Rake::RDocTask.new("rdoc") { |rdoc| + rdoc.rdoc_dir = 'html' + rdoc.title = "Builder for Markup" + rdoc.options << '--line-numbers' << '--inline-source' << '--main' << 'README' + rdoc.rdoc_files.include('lib/**/*.rb', '[A-Z]*', 'doc/**/*.rdoc') + rdoc.template = 'doc/jamis.rb' +} + +# ==================================================================== +# Create a task that will package the Rake software into distributable +# gem files. + +PKG_FILES = FileList[ + 'lib/**/*.rb', + 'test/**/*.rb', + 'scripts/**/*.rb' +] +PKG_FILES.exclude('test/testcssbuilder.rb') +PKG_FILES.exclude('lib/builder/css.rb') + +BLANKSLATE_FILES = FileList[ + 'lib/blankslate.rb', + 'test/testblankslate.rb' +] + +if ! defined?(Gem) + puts "Package Target requires RubyGEMs" +else + spec = Gem::Specification.new do |s| + + #### Basic information. + + s.name = 'builder' + s.version = PKG_VERSION + s.summary = "Builders for MarkUp." + s.description = %{\ +Builder provides a number of builder objects that make creating structured data +simple to do. Currently the following builder objects are supported: + +* XML Markup +* XML Events +} + + s.files = PKG_FILES.to_a + s.require_path = 'lib' + s.autorequire = 'builder' + + s.test_files = PKG_FILES.select { |fn| fn =~ /^test\/test/ } + + s.has_rdoc = true + s.extra_rdoc_files = rd.rdoc_files.reject { |fn| fn =~ /\.rb$/ }.to_a + s.rdoc_options << + '--title' << 'Builder -- Easy XML Building' << + '--main' << 'README' << + '--line-numbers' + + s.author = "Jim Weirich" + s.email = "jim@weirichhouse.org" + s.homepage = "http://onestepback.org" + end + + blankslate_spec = Gem::Specification.new do |s| + + #### Basic information. + + s.name = 'blankslate' + s.version = PKG_VERSION + s.summary = "Blank Slate base class." + s.description = %{\ +BlankSlate provides a base class where almost all of the methods from Object and +Kernel have been removed. This is useful when providing proxy object and other +classes that make heavy use of method_missing. +} + + s.files = BLANKSLATE_FILES.to_a + s.require_path = 'lib' + s.autorequire = 'builder' + + s.test_files = PKG_FILES.select { |fn| fn =~ /^test\/test/ } + + s.has_rdoc = true + s.extra_rdoc_files = rd.rdoc_files.reject { |fn| fn =~ /\.rb$/ }.to_a + s.rdoc_options << + '--title' << 'BlankSlate -- Base Class for building proxies.' << + '--main' << 'README' << + '--line-numbers' + + s.author = "Jim Weirich" + s.email = "jim@weirichhouse.org" + s.homepage = "http://onestepback.org" + end + + namespace 'builder' do + Rake::GemPackageTask.new(spec) do |t| + t.need_tar = true + end + end + + namespace 'blankslate' do + Rake::GemPackageTask.new(blankslate_spec) do |t| + t.need_tar = true + end + end + + task :package => ['builder:package', 'blankslate:package'] +end + +desc "Look for Debugging print lines" +task :dbg do + FileList['**/*.rb'].egrep /\bDBG|\bbreakpoint\b/ +end + +# -------------------------------------------------------------------- +# Creating a release + +def announce(msg='') + STDERR.puts msg +end + +desc "Make a new release" +task :release => [ + :prerelease, + :clobber, + :test_all, + :update_version, + :package, + :tag] do + + announce + announce "**************************************************************" + announce "* Release #{PKG_VERSION} Complete." + announce "* Packages ready to upload." + announce "**************************************************************" + announce +end + +# Validate that everything is ready to go for a release. +task :prerelease do + announce + announce "**************************************************************" + announce "* Making RubyGem Release #{PKG_VERSION}" + announce "* (current version #{CURRENT_VERSION})" + announce "**************************************************************" + announce + + # Is a release number supplied? + unless ENV['REL'] + fail "Usage: rake release REL=x.y.z [REUSE=tag_suffix]" + end + + # Is the release different than the current release. + # (or is REUSE set?) + if PKG_VERSION == CURRENT_VERSION && ! ENV['REUSE'] + fail "Current version is #{PKG_VERSION}, must specify REUSE=tag_suffix to reuse version" + end + + # Are all source files checked in? + if ENV['RELTEST'] + announce "Release Task Testing, skipping checked-in file test" + else + announce "Checking for unchecked-in files..." + data = `cvs -q update` + unless data =~ /^$/ + fail "CVS update is not clean ... do you have unchecked-in files?" + end + announce "No outstanding checkins found ... OK" + end +end + +task :update_version => [:prerelease] do + if PKG_VERSION == CURRENT_VERSION + announce "No version change ... skipping version update" + else + announce "Updating Builder version to #{PKG_VERSION}" + open("Rakefile") do |rakein| + open("Rakefile.new", "w") do |rakeout| + rakein.each do |line| + if line =~ /^CURRENT_VERSION\s*=\s*/ + rakeout.puts "CURRENT_VERSION = '#{PKG_VERSION}'" + else + rakeout.puts line + end + end + end + end + mv "Rakefile.new", "Rakefile" + if ENV['RELTEST'] + announce "Release Task Testing, skipping commiting of new version" + else + sh %{cvs commit -m "Updated to version #{PKG_VERSION}" Rakefile} + end + end +end + +desc "Tag all the CVS files with the latest release number (REL=x.y.z)" +task :tag => [:prerelease] do + reltag = "REL_#{PKG_VERSION.gsub(/\./, '_')}" + reltag << ENV['REUSE'].gsub(/\./, '_') if ENV['REUSE'] + announce "Tagging CVS with [#{reltag}]" + if ENV['RELTEST'] + announce "Release Task Testing, skipping CVS tagging" + else + sh %{cvs tag #{reltag}} + end +end + +desc "Install the jamis RDoc template" +task :install_jamis_template do + require 'rbconfig' + dest_dir = File.join(Config::CONFIG['rubylibdir'], "rdoc/generators/template/html") + fail "Unabled to write to #{dest_dir}" unless File.writable?(dest_dir) + install "doc/jamis.rb", dest_dir, :verbose => true +end + +require 'scripts/publish' diff --git a/vendor/gems/gems/builder-2.1.2/doc/releases/builder-1.2.4.rdoc b/vendor/gems/gems/builder-2.1.2/doc/releases/builder-1.2.4.rdoc new file mode 100755 index 00000000..a1cf54fd --- /dev/null +++ b/vendor/gems/gems/builder-2.1.2/doc/releases/builder-1.2.4.rdoc @@ -0,0 +1,31 @@ += Builder 1.2.4 Released. + +Added a "CDATA" method to the XML Markup builder (from Josh Knowles). + +== What is Builder? + +Builder::XmlMarkup allows easy programmatic creation of XML markup. +For example: + + builder = Builder::XmlMarkup.new(:target=>STDOUT, :indent=>2) + builder.person { |b| b.name("Jim"); b.phone("555-1234") } + puts builder.target! + +will generate: + + + Jim + 555-1234 + + +== Availability + +The easiest way to get and install builder is via RubyGems ... + + gem install builder (you may need root/admin privileges) + +== Thanks + +* Josh Knowles for the cdata! patch. + +-- Jim Weirich diff --git a/vendor/gems/gems/builder-2.1.2/doc/releases/builder-2.0.0.rdoc b/vendor/gems/gems/builder-2.1.2/doc/releases/builder-2.0.0.rdoc new file mode 100755 index 00000000..ed9e086d --- /dev/null +++ b/vendor/gems/gems/builder-2.1.2/doc/releases/builder-2.0.0.rdoc @@ -0,0 +1,46 @@ += Builder 2.0.0 Released. + +== Changes in 2.0.0 + +* UTF-8 characters in data are now correctly translated to their XML + equivalents. (Thanks to Sam Ruby) + +* Attribute values are now escaped by default. See the README + file for details. + +NOTE: The escaping attribute values by default is different +than in previous releases of Builder. This makes version 2.0.0 +somewhat incompatible with the 1.x series of Builder. If you use "&", +"<", or ">" in attributes values, you may have to change your +code. (Essentially you remove the manual escaping. The new way is +easier, believe me). + +== What is Builder? + +Builder::XmlMarkup is a library that allows easy programmatic creation +of XML markup. For example: + + builder = Builder::XmlMarkup.new(:target=>STDOUT, :indent=>2) + builder.person { |b| b.name("Jim"); b.phone("555-1234") } + +will generate: + + + Jim + 555-1234 + + +== Availability + +The easiest way to get and install builder is via RubyGems ... + + gem install builder (you may need root/admin privileges) + +== Thanks + +* Sam Ruby for the XChar module and the related UTF-8 translation + tools. +* Also to Sam Ruby for gently persuading me to start quoting attribute + values. + +-- Jim Weirich diff --git a/vendor/gems/gems/builder-2.1.2/doc/releases/builder-2.1.1.rdoc b/vendor/gems/gems/builder-2.1.2/doc/releases/builder-2.1.1.rdoc new file mode 100755 index 00000000..dbbf1213 --- /dev/null +++ b/vendor/gems/gems/builder-2.1.2/doc/releases/builder-2.1.1.rdoc @@ -0,0 +1,58 @@ += Builder 2.1.1 Released. + +Release 2.1.1 of Builder is mainly a bug fix release. + +== Changes in 2.1.1 + +* Added reveal capability to BlankSlate. + +* Fixed a bug in BlankSlate where including a module into Object could + cause methods to leak into BlankSlate. + +* Fixed typo in XmlMarkup class docs (from Martin Fowler). + +* Fixed test on private methods to differentiate between targetted and + untargetted private methods. + +* Removed legacy capture of @self in XmlBase (@self was used back when + we used instance eval). + +* Added additional tests for global functions (both direct and + included). + +* Several misc internal cleanups, including rearranging the source + code tree. + +NOTE: The escaping attribute values by default is different +than in previous releases of Builder. This makes version 2.0.x +somewhat incompatible with the 1.x series of Builder. If you use "&", +"<", or ">" in attributes values, you may have to change your +code. (Essentially you remove the manual escaping. The new way is +easier, believe me). + +== What is Builder? + +Builder::XmlMarkup is a library that allows easy programmatic creation +of XML markup. For example: + + builder = Builder::XmlMarkup.new(:target=>STDOUT, :indent=>2) + builder.person { |b| b.name("Jim"); b.phone("555-1234") } + +will generate: + + + Jim + 555-1234 + + +== Availability + +The easiest way to get and install builder is via RubyGems ... + + gem install builder (you may need root/admin privileges) + +== Thanks + +* Martin Fowler for spotting some typos in the documentation. + +-- Jim Weirich diff --git a/vendor/gems/gems/builder-2.1.2/lib/blankslate.rb b/vendor/gems/gems/builder-2.1.2/lib/blankslate.rb new file mode 100755 index 00000000..0f30838f --- /dev/null +++ b/vendor/gems/gems/builder-2.1.2/lib/blankslate.rb @@ -0,0 +1,113 @@ +#!/usr/bin/env ruby +#-- +# Copyright 2004, 2006 by Jim Weirich (jim@weirichhouse.org). +# All rights reserved. + +# Permission is granted for use, copying, modification, distribution, +# and distribution of modified versions of this work as long as the +# above copyright notice is included. +#++ + +###################################################################### +# BlankSlate provides an abstract base class with no predefined +# methods (except for \_\_send__ and \_\_id__). +# BlankSlate is useful as a base class when writing classes that +# depend upon method_missing (e.g. dynamic proxies). +# +class BlankSlate + class << self + + # Hide the method named +name+ in the BlankSlate class. Don't + # hide +instance_eval+ or any method beginning with "__". + def hide(name) + if instance_methods.include?(name.to_s) and + name !~ /^(__|instance_eval)/ + @hidden_methods ||= {} + @hidden_methods[name.to_sym] = instance_method(name) + undef_method name + end + end + + def find_hidden_method(name) + @hidden_methods ||= {} + @hidden_methods[name] || superclass.find_hidden_method(name) + end + + # Redefine a previously hidden method so that it may be called on a blank + # slate object. + def reveal(name) + bound_method = nil + unbound_method = find_hidden_method(name) + fail "Don't know how to reveal method '#{name}'" unless unbound_method + define_method(name) do |*args| + bound_method ||= unbound_method.bind(self) + bound_method.call(*args) + end + end + end + + instance_methods.each { |m| hide(m) } +end + +###################################################################### +# Since Ruby is very dynamic, methods added to the ancestors of +# BlankSlate after BlankSlate is defined will show up in the +# list of available BlankSlate methods. We handle this by defining a +# hook in the Object and Kernel classes that will hide any method +# defined after BlankSlate has been loaded. +# +module Kernel + class << self + alias_method :blank_slate_method_added, :method_added + + # Detect method additions to Kernel and remove them in the + # BlankSlate class. + def method_added(name) + result = blank_slate_method_added(name) + return result if self != Kernel + BlankSlate.hide(name) + result + end + end +end + +###################################################################### +# Same as above, except in Object. +# +class Object + class << self + alias_method :blank_slate_method_added, :method_added + + # Detect method additions to Object and remove them in the + # BlankSlate class. + def method_added(name) + result = blank_slate_method_added(name) + return result if self != Object + BlankSlate.hide(name) + result + end + + def find_hidden_method(name) + nil + end + end +end + +###################################################################### +# Also, modules included into Object need to be scanned and have their +# instance methods removed from blank slate. In theory, modules +# included into Kernel would have to be removed as well, but a +# "feature" of Ruby prevents late includes into modules from being +# exposed in the first place. +# +class Module + alias blankslate_original_append_features append_features + def append_features(mod) + result = blankslate_original_append_features(mod) + return result if mod != Object + instance_methods.each do |name| + BlankSlate.hide(name) + end + result + end +end \ No newline at end of file diff --git a/vendor/gems/gems/builder-2.1.2/lib/builder.rb b/vendor/gems/gems/builder-2.1.2/lib/builder.rb new file mode 100755 index 00000000..97192776 --- /dev/null +++ b/vendor/gems/gems/builder-2.1.2/lib/builder.rb @@ -0,0 +1,13 @@ +#!/usr/bin/env ruby + +#-- +# Copyright 2004 by Jim Weirich (jim@weirichhouse.org). +# All rights reserved. + +# Permission is granted for use, copying, modification, distribution, +# and distribution of modified versions of this work as long as the +# above copyright notice is included. +#++ + +require 'builder/xmlmarkup' +require 'builder/xmlevents' diff --git a/vendor/gems/gems/builder-2.1.2/lib/builder/blankslate.rb b/vendor/gems/gems/builder-2.1.2/lib/builder/blankslate.rb new file mode 100755 index 00000000..2935b6f1 --- /dev/null +++ b/vendor/gems/gems/builder-2.1.2/lib/builder/blankslate.rb @@ -0,0 +1,20 @@ +#!/usr/bin/env ruby +#-- +# Copyright 2004, 2006 by Jim Weirich (jim@weirichhouse.org). +# All rights reserved. + +# Permission is granted for use, copying, modification, distribution, +# and distribution of modified versions of this work as long as the +# above copyright notice is included. +#++ + +require 'blankslate' + +###################################################################### +# BlankSlate has been promoted to a top level name and is now +# available as a standalone gem. We make the name available in the +# Builder namespace for compatibility. +# +module Builder + BlankSlate = ::BlankSlate +end diff --git a/vendor/gems/gems/builder-2.1.2/lib/builder/xchar.rb b/vendor/gems/gems/builder-2.1.2/lib/builder/xchar.rb new file mode 100755 index 00000000..3a752bab --- /dev/null +++ b/vendor/gems/gems/builder-2.1.2/lib/builder/xchar.rb @@ -0,0 +1,115 @@ +#!/usr/bin/env ruby + +# The XChar library is provided courtesy of Sam Ruby (See +# http://intertwingly.net/stories/2005/09/28/xchar.rb) + +# -------------------------------------------------------------------- + +# If the Builder::XChar module is not currently defined, fail on any +# name clashes in standard library classes. + +module Builder + def self.check_for_name_collision(klass, method_name, defined_constant=nil) + if klass.instance_methods.include?(method_name) + fail RuntimeError, + "Name Collision: Method '#{method_name}' is already defined in #{klass}" + end + end +end + +if ! defined?(Builder::XChar) + Builder.check_for_name_collision(String, "to_xs") + Builder.check_for_name_collision(Fixnum, "xchr") +end + +###################################################################### +module Builder + + #################################################################### + # XML Character converter, from Sam Ruby: + # (see http://intertwingly.net/stories/2005/09/28/xchar.rb). + # + module XChar # :nodoc: + + # See + # http://intertwingly.net/stories/2004/04/14/i18n.html#CleaningWindows + # for details. + CP1252 = { # :nodoc: + 128 => 8364, # euro sign + 130 => 8218, # single low-9 quotation mark + 131 => 402, # latin small letter f with hook + 132 => 8222, # double low-9 quotation mark + 133 => 8230, # horizontal ellipsis + 134 => 8224, # dagger + 135 => 8225, # double dagger + 136 => 710, # modifier letter circumflex accent + 137 => 8240, # per mille sign + 138 => 352, # latin capital letter s with caron + 139 => 8249, # single left-pointing angle quotation mark + 140 => 338, # latin capital ligature oe + 142 => 381, # latin capital letter z with caron + 145 => 8216, # left single quotation mark + 146 => 8217, # right single quotation mark + 147 => 8220, # left double quotation mark + 148 => 8221, # right double quotation mark + 149 => 8226, # bullet + 150 => 8211, # en dash + 151 => 8212, # em dash + 152 => 732, # small tilde + 153 => 8482, # trade mark sign + 154 => 353, # latin small letter s with caron + 155 => 8250, # single right-pointing angle quotation mark + 156 => 339, # latin small ligature oe + 158 => 382, # latin small letter z with caron + 159 => 376, # latin capital letter y with diaeresis + } + + # See http://www.w3.org/TR/REC-xml/#dt-chardata for details. + PREDEFINED = { + 38 => '&', # ampersand + 60 => '<', # left angle bracket + 62 => '>', # right angle bracket + } + + # See http://www.w3.org/TR/REC-xml/#charsets for details. + VALID = [ + 0x9, 0xA, 0xD, + (0x20..0xD7FF), + (0xE000..0xFFFD), + (0x10000..0x10FFFF) + ] + end + +end + + +###################################################################### +# Enhance the Fixnum class with a XML escaped character conversion. +# +class Fixnum + XChar = Builder::XChar if ! defined?(XChar) + + # XML escaped version of chr + def xchr + n = XChar::CP1252[self] || self + case n when *XChar::VALID + XChar::PREDEFINED[n] or (n<128 ? n.chr : "&##{n};") + else + '*' + end + end +end + + +###################################################################### +# Enhance the String class with a XML escaped character version of +# to_s. +# +class String + # XML escaped version of to_s + def to_xs + unpack('U*').map {|n| n.xchr}.join # ASCII, UTF-8 + rescue + unpack('C*').map {|n| n.xchr}.join # ISO-8859-1, WIN-1252 + end +end diff --git a/vendor/gems/gems/builder-2.1.2/lib/builder/xmlbase.rb b/vendor/gems/gems/builder-2.1.2/lib/builder/xmlbase.rb new file mode 100755 index 00000000..8e13483b --- /dev/null +++ b/vendor/gems/gems/builder-2.1.2/lib/builder/xmlbase.rb @@ -0,0 +1,139 @@ +#!/usr/bin/env ruby + +require 'builder/blankslate' + +module Builder + + # Generic error for builder + class IllegalBlockError < RuntimeError; end + + # XmlBase is a base class for building XML builders. See + # Builder::XmlMarkup and Builder::XmlEvents for examples. + class XmlBase < BlankSlate + + # Create an XML markup builder. + # + # out:: Object receiving the markup. +out+ must respond to + # <<. + # indent:: Number of spaces used for indentation (0 implies no + # indentation and no line breaks). + # initial:: Level of initial indentation. + # + def initialize(indent=0, initial=0) + @indent = indent + @level = initial + end + + # Create a tag named +sym+. Other than the first argument which + # is the tag name, the arguements are the same as the tags + # implemented via method_missing. + def tag!(sym, *args, &block) + method_missing(sym.to_sym, *args, &block) + end + + # Create XML markup based on the name of the method. This method + # is never invoked directly, but is called for each markup method + # in the markup block. + def method_missing(sym, *args, &block) + text = nil + attrs = nil + sym = "#{sym}:#{args.shift}" if args.first.kind_of?(Symbol) + args.each do |arg| + case arg + when Hash + attrs ||= {} + attrs.merge!(arg) + else + text ||= '' + text << arg.to_s + end + end + if block + unless text.nil? + raise ArgumentError, "XmlMarkup cannot mix a text argument with a block" + end + _indent + _start_tag(sym, attrs) + _newline + _nested_structures(block) + _indent + _end_tag(sym) + _newline + elsif text.nil? + _indent + _start_tag(sym, attrs, true) + _newline + else + _indent + _start_tag(sym, attrs) + text! text + _end_tag(sym) + _newline + end + @target + end + + # Append text to the output target. Escape any markup. May be + # used within the markup brakets as: + # + # builder.p { |b| b.br; b.text! "HI" } #=>


HI

+ def text!(text) + _text(_escape(text)) + end + + # Append text to the output target without escaping any markup. + # May be used within the markup brakets as: + # + # builder.p { |x| x << "
HI" } #=>


HI

+ # + # This is useful when using non-builder enabled software that + # generates strings. Just insert the string directly into the + # builder without changing the inserted markup. + # + # It is also useful for stacking builder objects. Builders only + # use << to append to the target, so by supporting this + # method/operation builders can use other builders as their + # targets. + def <<(text) + _text(text) + end + + # For some reason, nil? is sent to the XmlMarkup object. If nil? + # is not defined and method_missing is invoked, some strange kind + # of recursion happens. Since nil? won't ever be an XML tag, it + # is pretty safe to define it here. (Note: this is an example of + # cargo cult programming, + # cf. http://fishbowl.pastiche.org/2004/10/13/cargo_cult_programming). + def nil? + false + end + + private + + require 'builder/xchar' + def _escape(text) + text.to_xs + end + + def _escape_quote(text) + _escape(text).gsub(%r{"}, '"') # " WART + end + + def _newline + return if @indent == 0 + text! "\n" + end + + def _indent + return if @indent == 0 || @level == 0 + text!(" " * (@level * @indent)) + end + + def _nested_structures(block) + @level += 1 + block.call(self) + ensure + @level -= 1 + end + end +end diff --git a/vendor/gems/gems/builder-2.1.2/lib/builder/xmlevents.rb b/vendor/gems/gems/builder-2.1.2/lib/builder/xmlevents.rb new file mode 100755 index 00000000..91fcd21e --- /dev/null +++ b/vendor/gems/gems/builder-2.1.2/lib/builder/xmlevents.rb @@ -0,0 +1,63 @@ +#!/usr/bin/env ruby + +#-- +# Copyright 2004 by Jim Weirich (jim@weirichhouse.org). +# All rights reserved. + +# Permission is granted for use, copying, modification, distribution, +# and distribution of modified versions of this work as long as the +# above copyright notice is included. +#++ + +require 'builder/xmlmarkup' + +module Builder + + # Create a series of SAX-like XML events (e.g. start_tag, end_tag) + # from the markup code. XmlEvent objects are used in a way similar + # to XmlMarkup objects, except that a series of events are generated + # and passed to a handler rather than generating character-based + # markup. + # + # Usage: + # xe = Builder::XmlEvents.new(hander) + # xe.title("HI") # Sends start_tag/end_tag/text messages to the handler. + # + # Indentation may also be selected by providing value for the + # indentation size and initial indentation level. + # + # xe = Builder::XmlEvents.new(handler, indent_size, initial_indent_level) + # + # == XML Event Handler + # + # The handler object must expect the following events. + # + # [start_tag(tag, attrs)] + # Announces that a new tag has been found. +tag+ is the name of + # the tag and +attrs+ is a hash of attributes for the tag. + # + # [end_tag(tag)] + # Announces that an end tag for +tag+ has been found. + # + # [text(text)] + # Announces that a string of characters (+text+) has been found. + # A series of characters may be broken up into more than one + # +text+ call, so the client cannot assume that a single + # callback contains all the text data. + # + class XmlEvents < XmlMarkup + def text!(text) + @target.text(text) + end + + def _start_tag(sym, attrs, end_too=false) + @target.start_tag(sym, attrs) + _end_tag(sym) if end_too + end + + def _end_tag(sym) + @target.end_tag(sym) + end + end + +end diff --git a/vendor/gems/gems/builder-2.1.2/lib/builder/xmlmarkup.rb b/vendor/gems/gems/builder-2.1.2/lib/builder/xmlmarkup.rb new file mode 100755 index 00000000..abc5666a --- /dev/null +++ b/vendor/gems/gems/builder-2.1.2/lib/builder/xmlmarkup.rb @@ -0,0 +1,328 @@ +#!/usr/bin/env ruby +#-- +# Copyright 2004, 2005 by Jim Weirich (jim@weirichhouse.org). +# All rights reserved. + +# Permission is granted for use, copying, modification, distribution, +# and distribution of modified versions of this work as long as the +# above copyright notice is included. +#++ + +# Provide a flexible and easy to use Builder for creating XML markup. +# See XmlBuilder for usage details. + +require 'builder/xmlbase' + +module Builder + + # Create XML markup easily. All (well, almost all) methods sent to + # an XmlMarkup object will be translated to the equivalent XML + # markup. Any method with a block will be treated as an XML markup + # tag with nested markup in the block. + # + # Examples will demonstrate this easier than words. In the + # following, +xm+ is an +XmlMarkup+ object. + # + # xm.em("emphasized") # => emphasized + # xm.em { xmm.b("emp & bold") } # => emph & bold + # xm.a("A Link", "href"=>"http://onestepback.org") + # # => A Link + # xm.div { br } # =>

+ # xm.target("name"=>"compile", "option"=>"fast") + # # => + # # NOTE: order of attributes is not specified. + # + # xm.instruct! # + # xm.html { # + # xm.head { # + # xm.title("History") # History + # } # + # xm.body { # + # xm.comment! "HI" # + # xm.h1("Header") #

Header

+ # xm.p("paragraph") #

paragraph

+ # } # + # } # + # + # == Notes: + # + # * The order that attributes are inserted in markup tags is + # undefined. + # + # * Sometimes you wish to insert text without enclosing tags. Use + # the text! method to accomplish this. + # + # Example: + # + # xm.div { #
+ # xm.text! "line"; xm.br # line
+ # xm.text! "another line"; xmbr # another line
+ # } #
+ # + # * The special XML characters <, >, and & are converted to <, + # > and & automatically. Use the << operation to + # insert text without modification. + # + # * Sometimes tags use special characters not allowed in ruby + # identifiers. Use the tag! method to handle these + # cases. + # + # Example: + # + # xml.tag!("SOAP:Envelope") { ... } + # + # will produce ... + # + # ... " + # + # tag! will also take text and attribute arguments (after + # the tag name) like normal markup methods. (But see the next + # bullet item for a better way to handle XML namespaces). + # + # * Direct support for XML namespaces is now available. If the + # first argument to a tag call is a symbol, it will be joined to + # the tag to produce a namespace:tag combination. It is easier to + # show this than describe it. + # + # xml.SOAP :Envelope do ... end + # + # Just put a space before the colon in a namespace to produce the + # right form for builder (e.g. "SOAP:Envelope" => + # "xml.SOAP :Envelope") + # + # * XmlMarkup builds the markup in any object (called a _target_) + # that accepts the << method. If no target is given, + # then XmlMarkup defaults to a string target. + # + # Examples: + # + # xm = Builder::XmlMarkup.new + # result = xm.title("yada") + # # result is a string containing the markup. + # + # buffer = "" + # xm = Builder::XmlMarkup.new(buffer) + # # The markup is appended to buffer (using <<) + # + # xm = Builder::XmlMarkup.new(STDOUT) + # # The markup is written to STDOUT (using <<) + # + # xm = Builder::XmlMarkup.new + # x2 = Builder::XmlMarkup.new(:target=>xm) + # # Markup written to +x2+ will be send to +xm+. + # + # * Indentation is enabled by providing the number of spaces to + # indent for each level as a second argument to XmlBuilder.new. + # Initial indentation may be specified using a third parameter. + # + # Example: + # + # xm = Builder.new(:indent=>2) + # # xm will produce nicely formatted and indented XML. + # + # xm = Builder.new(:indent=>2, :margin=>4) + # # xm will produce nicely formatted and indented XML with 2 + # # spaces per indent and an over all indentation level of 4. + # + # builder = Builder::XmlMarkup.new(:target=>$stdout, :indent=>2) + # builder.name { |b| b.first("Jim"); b.last("Weirich) } + # # prints: + # # + # # Jim + # # Weirich + # # + # + # * The instance_eval implementation which forces self to refer to + # the message receiver as self is now obsolete. We now use normal + # block calls to execute the markup block. This means that all + # markup methods must now be explicitly send to the xml builder. + # For instance, instead of + # + # xml.div { strong("text") } + # + # you need to write: + # + # xml.div { xml.strong("text") } + # + # Although more verbose, the subtle change in semantics within the + # block was found to be prone to error. To make this change a + # little less cumbersome, the markup block now gets the markup + # object sent as an argument, allowing you to use a shorter alias + # within the block. + # + # For example: + # + # xml_builder = Builder::XmlMarkup.new + # xml_builder.div { |xml| + # xml.stong("text") + # } + # + class XmlMarkup < XmlBase + + # Create an XML markup builder. Parameters are specified by an + # option hash. + # + # :target=>target_object:: + # Object receiving the markup. +out+ must respond to the + # << operator. The default is a plain string target. + # + # :indent=>indentation:: + # Number of spaces used for indentation. The default is no + # indentation and no line breaks. + # + # :margin=>initial_indentation_level:: + # Amount of initial indentation (specified in levels, not + # spaces). + # + # :escape_attrs=>OBSOLETE:: + # The :escape_attrs option is no longer supported by builder + # (and will be quietly ignored). String attribute values are + # now automatically escaped. If you need unescaped attribute + # values (perhaps you are using entities in the attribute + # values), then give the value as a Symbol. This allows much + # finer control over escaping attribute values. + # + def initialize(options={}) + indent = options[:indent] || 0 + margin = options[:margin] || 0 + super(indent, margin) + @target = options[:target] || "" + end + + # Return the target of the builder. + def target! + @target + end + + def comment!(comment_text) + _ensure_no_block block_given? + _special("", comment_text, nil) + end + + # Insert an XML declaration into the XML markup. + # + # For example: + # + # xml.declare! :ELEMENT, :blah, "yada" + # # => + def declare!(inst, *args, &block) + _indent + @target << "" + _newline + end + + # Insert a processing instruction into the XML markup. E.g. + # + # For example: + # + # xml.instruct! + # #=> + # xml.instruct! :aaa, :bbb=>"ccc" + # #=> + # + def instruct!(directive_tag=:xml, attrs={}) + _ensure_no_block block_given? + if directive_tag == :xml + a = { :version=>"1.0", :encoding=>"UTF-8" } + attrs = a.merge attrs + end + _special( + "", + nil, + attrs, + [:version, :encoding, :standalone]) + end + + # Insert a CDATA section into the XML markup. + # + # For example: + # + # xml.cdata!("text to be included in cdata") + # #=> + # + def cdata!(text) + _ensure_no_block block_given? + _special("", text, nil) + end + + private + + # NOTE: All private methods of a builder object are prefixed when + # a "_" character to avoid possible conflict with XML tag names. + + # Insert text directly in to the builder's target. + def _text(text) + @target << text + end + + # Insert special instruction. + def _special(open, close, data=nil, attrs=nil, order=[]) + _indent + @target << open + @target << data if data + _insert_attributes(attrs, order) if attrs + @target << close + _newline + end + + # Start an XML tag. If end_too is true, then the start + # tag is also the end tag (e.g.
+ def _start_tag(sym, attrs, end_too=false) + @target << "<#{sym}" + _insert_attributes(attrs) + @target << "/" if end_too + @target << ">" + end + + # Insert an ending tag. + def _end_tag(sym) + @target << "" + end + + # Insert the attributes (given in the hash). + def _insert_attributes(attrs, order=[]) + return if attrs.nil? + order.each do |k| + v = attrs[k] + @target << %{ #{k}="#{_attr_value(v)}"} if v # " WART + end + attrs.each do |k, v| + @target << %{ #{k}="#{_attr_value(v)}"} unless order.member?(k) # " WART + end + end + + def _attr_value(value) + case value + when Symbol + value.to_s + else + _escape_quote(value.to_s) + end + end + + def _ensure_no_block(got_block) + if got_block + fail IllegalBlockError, + "Blocks are not allowed on XML instructions" + end + end + + end + +end diff --git a/vendor/gems/gems/builder-2.1.2/scripts/publish.rb b/vendor/gems/gems/builder-2.1.2/scripts/publish.rb new file mode 100755 index 00000000..76657c67 --- /dev/null +++ b/vendor/gems/gems/builder-2.1.2/scripts/publish.rb @@ -0,0 +1,17 @@ +# Optional publish task for Rake + +require 'rake/contrib/sshpublisher' +require 'rake/contrib/rubyforgepublisher' + +publisher = Rake::CompositePublisher.new +publisher.add Rake::RubyForgePublisher.new('builder', 'jimweirich') +publisher.add Rake::SshFilePublisher.new( + 'umlcoop', + 'htdocs/software/builder', + '.', + 'builder.blurb') + +desc "Publish the Documentation to RubyForge." +task :publish => [:rdoc] do + publisher.upload +end diff --git a/vendor/gems/gems/builder-2.1.2/test/performance.rb b/vendor/gems/gems/builder-2.1.2/test/performance.rb new file mode 100755 index 00000000..2d61bd53 --- /dev/null +++ b/vendor/gems/gems/builder-2.1.2/test/performance.rb @@ -0,0 +1,30 @@ +#!/usr/bin/env ruby + +require 'builder/xmlmarkup' +require 'benchmark' + +text = "This is a test of the new xml markup. Iñtërnâtiônàlizætiøn\n" * 10000 + +include Benchmark # we need the CAPTION and FMTSTR constants +include Builder +n = 50 +Benchmark.benchmark do |bm| + tf = bm.report("base") { + n.times do + x = XmlMarkup.new + x.text(text) + x.target! + end + } + def XmlMarkup._escape(text) + text.to_xs + end + tf = bm.report("to_xs") { + n.times do + x = XmlMarkup.new + x.text(text) + x.target! + end + } +end + diff --git a/vendor/gems/gems/builder-2.1.2/test/preload.rb b/vendor/gems/gems/builder-2.1.2/test/preload.rb new file mode 100755 index 00000000..daab3272 --- /dev/null +++ b/vendor/gems/gems/builder-2.1.2/test/preload.rb @@ -0,0 +1,29 @@ +#!/usr/bin/env ruby + +# We are defining method_added in Kernel and Object so that when +# BlankSlate overrides them later, we can verify that it correctly +# calls the older hooks. + +module Kernel + class << self + attr_reader :k_added_names + alias_method :preload_method_added, :method_added + def method_added(name) + preload_method_added(name) + @k_added_names ||= [] + @k_added_names << name + end + end +end + +class Object + class << self + attr_reader :o_added_names + alias_method :preload_method_added, :method_added + def method_added(name) + preload_method_added(name) + @o_added_names ||= [] + @o_added_names << name + end + end +end diff --git a/vendor/gems/gems/builder-2.1.2/test/test_xchar.rb b/vendor/gems/gems/builder-2.1.2/test/test_xchar.rb new file mode 100755 index 00000000..fb8c53a1 --- /dev/null +++ b/vendor/gems/gems/builder-2.1.2/test/test_xchar.rb @@ -0,0 +1,37 @@ +#!/usr/bin/env ruby + +require 'test/unit' +require 'builder/xchar' + +class TestXmlEscaping < Test::Unit::TestCase + def test_ascii + assert_equal 'abc', 'abc'.to_xs + end + + def test_predefined + assert_equal '&', '&'.to_xs # ampersand + assert_equal '<', '<'.to_xs # left angle bracket + assert_equal '>', '>'.to_xs # right angle bracket + end + + def test_invalid + assert_equal '*', "\x00".to_xs # null + assert_equal '*', "\x0C".to_xs # form feed + assert_equal '*', "\xEF\xBF\xBF".to_xs # U+FFFF + end + + def test_iso_8859_1 + assert_equal 'ç', "\xE7".to_xs # small c cedilla + assert_equal '©', "\xA9".to_xs # copyright symbol + end + + def test_win_1252 + assert_equal '’', "\x92".to_xs # smart quote + assert_equal '€', "\x80".to_xs # euro + end + + def test_utf8 + assert_equal '’', "\xE2\x80\x99".to_xs # right single quote + assert_equal '©', "\xC2\xA9".to_xs # copy + end +end diff --git a/vendor/gems/gems/builder-2.1.2/test/testblankslate.rb b/vendor/gems/gems/builder-2.1.2/test/testblankslate.rb new file mode 100755 index 00000000..ae5794ed --- /dev/null +++ b/vendor/gems/gems/builder-2.1.2/test/testblankslate.rb @@ -0,0 +1,183 @@ +#!/usr/bin/env ruby + +require 'test/unit' +require 'test/preload' +require 'builder/blankslate' +require 'stringio' + +# Methods to be introduced into the Object class late. +module LateObject + def late_object + 33 + end + def LateObject.included(mod) + # Modules defining an included method should not prevent blank + # slate erasure! + end +end + +# Methods to be introduced into the Kernel module late. +module LateKernel + def late_kernel + 44 + end + def LateKernel.included(mod) + # Modules defining an included method should not prevent blank + # slate erasure! + end +end + +# Introduce some late methods (both module and direct) into the Kernel +# module. +module Kernel + include LateKernel + + def late_addition + 1234 + end + + def double_late_addition + 11 + end + + def double_late_addition + 22 + end +end + + +# Introduce some late methods (both module and direct) into the Object +# class. +class Object + include LateObject + def another_late_addition + 4321 + end +end + +# Introduce some late methods by inclusion. +module GlobalModule + def global_inclusion + 42 + end +end +include GlobalModule + +def direct_global + 43 +end + +###################################################################### +# Test case for blank slate. +# +class TestBlankSlate < Test::Unit::TestCase + def setup + @bs = BlankSlate.new + end + + def test_undefined_methods_remain_undefined + assert_raise(NoMethodError) { @bs.no_such_method } + assert_raise(NoMethodError) { @bs.nil? } + end + + + # NOTE: NameError is acceptable because the lack of a '.' means that + # Ruby can't tell if it is a method or a local variable. + def test_undefined_methods_remain_undefined_during_instance_eval + assert_raise(NoMethodError, NameError) do + @bs.instance_eval do nil? end + end + assert_raise(NoMethodError, NameError) do + @bs.instance_eval do no_such_method end + end + end + + def test_private_methods_are_undefined + assert_raise(NoMethodError) do + @bs.puts "HI" + end + end + + def test_targetted_private_methods_are_undefined_during_instance_eval + assert_raise(NoMethodError, NameError) do + @bs.instance_eval do self.puts "HI" end + end + end + + def test_untargetted_private_methods_are_defined_during_instance_eval + oldstdout = $stdout + $stdout = StringIO.new + @bs.instance_eval do + puts "HI" + end + ensure + $stdout = oldstdout + end + + def test_methods_added_late_to_kernel_remain_undefined + assert_equal 1234, nil.late_addition + assert_raise(NoMethodError) { @bs.late_addition } + end + + def test_methods_added_late_to_object_remain_undefined + assert_equal 4321, nil.another_late_addition + assert_raise(NoMethodError) { @bs.another_late_addition } + end + + def test_methods_added_late_to_global_remain_undefined + assert_equal 42, global_inclusion + assert_raise(NoMethodError) { @bs.global_inclusion } + end + + def test_preload_method_added + assert Kernel.k_added_names.include?(:late_addition) + assert Object.o_added_names.include?(:another_late_addition) + end + + def test_method_defined_late_multiple_times_remain_undefined + assert_equal 22, nil.double_late_addition + assert_raise(NoMethodError) { @bs.double_late_addition } + end + + def test_late_included_module_in_object_is_ok + assert_equal 33, 1.late_object + assert_raise(NoMethodError) { @bs.late_object } + end + + def test_late_included_module_in_kernel_is_ok + assert_raise(NoMethodError) { @bs.late_kernel } + end + + def test_revealing_previously_hidden_methods_are_callable + with_to_s = Class.new(BlankSlate) do + reveal :to_s + end + assert_match /^#<.*>$/, with_to_s.new.to_s + end + + def test_revealing_a_hidden_method_twice_is_ok + with_to_s = Class.new(BlankSlate) do + reveal :to_s + reveal :to_s + end + assert_match /^#<.*>$/, with_to_s.new.to_s + end + + def test_revealing_unknown_hidden_method_is_an_error + assert_raises(RuntimeError) do + Class.new(BlankSlate) do + reveal :xyz + end + end + end + + def test_global_includes_still_work + assert_nothing_raised do + assert_equal 42, global_inclusion + assert_equal 42, Object.new.global_inclusion + assert_equal 42, "magic number".global_inclusion + assert_equal 43, direct_global + end + end +end + diff --git a/vendor/gems/gems/builder-2.1.2/test/testeventbuilder.rb b/vendor/gems/gems/builder-2.1.2/test/testeventbuilder.rb new file mode 100755 index 00000000..2d603717 --- /dev/null +++ b/vendor/gems/gems/builder-2.1.2/test/testeventbuilder.rb @@ -0,0 +1,133 @@ +class TestEvents < Test::Unit::TestCase + + class Target + attr_reader :events + + def initialize + @events = [] + end + + def start_tag(tag, attrs) + @events << [:start_tag, tag, attrs] + end + + def end_tag(tag) + @events << [:end_tag, tag] + end + + def text(string) + @events << [:text, string] + end + + end + + + def setup + @target = Target.new + @xml = Builder::XmlEvents.new(:target=>@target) + end + + def test_simple + @xml.one + expect [:start_tag, :one, nil] + expect [:end_tag, :one] + expect_done + end + + def test_nested + @xml.one { @xml.two } + expect [:start_tag, :one, nil] + expect [:start_tag, :two, nil] + expect [:end_tag, :two] + expect [:end_tag, :one] + expect_done + end + + def test_text + @xml.one("a") + expect [:start_tag, :one, nil] + expect [:text, "a"] + expect [:end_tag, :one] + expect_done + end + + def test_special_text + @xml.one("H&R") + expect [:start_tag, :one, nil] + expect [:text, "H&R"] + expect [:end_tag, :one] + expect_done + end + + def test_text_with_entity + @xml.one("H&R") + expect [:start_tag, :one, nil] + expect [:text, "H&R"] + expect [:end_tag, :one] + expect_done + end + + def test_attributes + @xml.a(:b=>"c", :x=>"y") + expect [:start_tag, :a, {:x => "y", :b => "c"}] + expect [:end_tag, :a] + expect_done + end + + def test_moderately_complex + @xml.tag! "address-book" do |x| + x.entry :id=>"1" do + x.name { + x.first "Bill" + x.last "Smith" + } + x.address "Cincinnati" + end + x.entry :id=>"2" do + x.name { + x.first "John" + x.last "Doe" + } + x.address "Columbus" + end + end + expect [:start_tag, "address-book".intern, nil] + expect [:start_tag, :entry, {:id => "1"}] + expect [:start_tag, :name, nil] + expect [:start_tag, :first, nil] + expect [:text, "Bill"] + expect [:end_tag, :first] + expect [:start_tag, :last, nil] + expect [:text, "Smith"] + expect [:end_tag, :last] + expect [:end_tag, :name] + expect [:start_tag, :address, nil] + expect [:text, "Cincinnati"] + expect [:end_tag, :address] + expect [:end_tag, :entry] + expect [:start_tag, :entry, {:id => "2"}] + expect [:start_tag, :name, nil] + expect [:start_tag, :first, nil] + expect [:text, "John"] + expect [:end_tag, :first] + expect [:start_tag, :last, nil] + expect [:text, "Doe"] + expect [:end_tag, :last] + expect [:end_tag, :name] + expect [:start_tag, :address, nil] + expect [:text, "Columbus"] + expect [:end_tag, :address] + expect [:end_tag, :entry] + expect [:end_tag, "address-book".intern] + expect_done + end + + def expect(value) + assert_equal value, @target.events.shift + end + + def expect_done + assert_nil @target.events.shift + end + +end diff --git a/vendor/gems/gems/builder-2.1.2/test/testmarkupbuilder.rb b/vendor/gems/gems/builder-2.1.2/test/testmarkupbuilder.rb new file mode 100755 index 00000000..ad173143 --- /dev/null +++ b/vendor/gems/gems/builder-2.1.2/test/testmarkupbuilder.rb @@ -0,0 +1,449 @@ +#!/usr/bin/env ruby + +#-- +# Portions copyright 2004 by Jim Weirich (jim@weirichhouse.org). +# Portions copyright 2005 by Sam Ruby (rubys@intertwingly.net). +# All rights reserved. + +# Permission is granted for use, copying, modification, distribution, +# and distribution of modified versions of this work as long as the +# above copyright notice is included. +#++ + +require 'test/unit' +require 'test/preload' +require 'builder' +require 'builder/xmlmarkup' + +class TestMarkup < Test::Unit::TestCase + def setup + @xml = Builder::XmlMarkup.new + end + + def test_create + assert_not_nil @xml + end + + def test_simple + @xml.simple + assert_equal "", @xml.target! + end + + def test_value + @xml.value("hi") + assert_equal "hi", @xml.target! + end + + def test_nested + @xml.outer { |x| x.inner("x") } + assert_equal "x", @xml.target! + end + + def test_attributes + @xml.ref(:id => 12) + assert_equal %{}, @xml.target! + end + + def test_string_attributes_are_quoted_by_default + @xml.ref(:id => "H&R") + assert_equal %{}, @xml.target! + end + + def test_symbol_attributes_are_unquoted_by_default + @xml.ref(:id => :"H&R") + assert_equal %{}, @xml.target! + end + + def test_attributes_quoted_can_be_turned_on + @xml = Builder::XmlMarkup.new + @xml.ref(:id => "") + assert_equal %{}, @xml.target! + end + + def test_mixed_attribute_quoting_with_nested_builders + x = Builder::XmlMarkup.new(:target=>@xml) + @xml.ref(:id=>:"H&R") { + x.element(:tag=>"Long&Short") + } + assert_equal "", + @xml.target! + end + + def test_multiple_attributes + @xml.ref(:id => 12, :name => "bill") + assert_match %r{^$}, @xml.target! + end + + def test_attributes_with_text + @xml.a("link", :href=>"http://onestepback.org") + assert_equal %{link}, @xml.target! + end + + def test_complex + @xml.body(:bg=>"#ffffff") { |x| + x.title("T", :style=>"red") + } + assert_equal %{T}, @xml.target! + end + + def test_funky_symbol + @xml.tag!("non-ruby-token", :id=>1) { |x| x.ok } + assert_equal %{}, @xml.target! + end + + def test_tag_can_handle_private_method + @xml.tag!("loop", :id=>1) { |x| x.ok } + assert_equal %{}, @xml.target! + end + + def test_no_explicit_marker + @xml.p { |x| x.b("HI") } + assert_equal "

HI

", @xml.target! + end + + def test_reference_local_vars + n = 3 + @xml.ol { |x| n.times { x.li(n) } } + assert_equal "
  1. 3
  2. 3
  3. 3
", @xml.target! + end + + def test_reference_methods + @xml.title { |x| x.a { x.b(name) } } + assert_equal "<a><b>bob</b></a>", @xml.target! + end + + def test_append_text + @xml.p { |x| x.br; x.text! "HI" } + assert_equal "


HI

", @xml.target! + end + + def test_ambiguous_markup + ex = assert_raises(ArgumentError) { + @xml.h1("data1") { b } + } + assert_match /\btext\b/, ex.message + assert_match /\bblock\b/, ex.message + end + + def test_capitalized_method + @xml.P { |x| x.B("hi"); x.BR(); x.EM { x.text! "world" } } + assert_equal "

hi
world

", @xml.target! + end + + def test_escaping + @xml.div { |x| x.text! ""; x.em("H&R Block") } + assert_equal %{
<hi>H&R Block
}, @xml.target! + end + + def test_non_escaping + @xml.div("ns:xml"=>:"&xml;") { |x| x << ""; x.em("H&R Block") } + assert_equal %{
H&R Block
}, @xml.target! + end + + def test_return_value + str = @xml.x("men") + assert_equal @xml.target!, str + end + + def test_stacked_builders + b = Builder::XmlMarkup.new( :target => @xml ) + b.div { @xml.span { @xml.a("text", :href=>"ref") } } + assert_equal "", @xml.target! + end + + def name + "bob" + end +end + +class TestAttributeEscaping < Test::Unit::TestCase + + def setup + @xml = Builder::XmlMarkup.new + end + + def test_element_gt + @xml.title('1<2') + assert_equal '1<2', @xml.target! + end + + def test_element_amp + @xml.title('AT&T') + assert_equal 'AT&T', @xml.target! + end + + def test_element_amp2 + @xml.title('&') + assert_equal '&amp;', @xml.target! + end + + def test_attr_less + @xml.a(:title => '2>1') + assert_equal '', @xml.target! + end + + def test_attr_amp + @xml.a(:title => 'AT&T') + assert_equal '', @xml.target! + end + + def test_attr_quot + @xml.a(:title => '"x"') + assert_equal '', @xml.target! + end + +end + +class TestNameSpaces < Test::Unit::TestCase + def setup + @xml = Builder::XmlMarkup.new(:indent=>2) + end + + def test_simple_name_spaces + @xml.rdf :RDF + assert_equal "\n", @xml.target! + end + + def test_long + xml = Builder::XmlMarkup.new(:indent=>2) + xml.instruct! + xml.rdf :RDF, + "xmlns:rdf" => :"&rdf;", + "xmlns:rdfs" => :"&rdfs;", + "xmlns:xsd" => :"&xsd;", + "xmlns:owl" => :"&owl;" do + xml.owl :Class, :'rdf:ID'=>'Bird' do + xml.rdfs :label, 'bird' + xml.rdfs :subClassOf do + xml.owl :Restriction do + xml.owl :onProperty, 'rdf:resource'=>'#wingspan' + xml.owl :maxCardinality,1,'rdf:datatype'=>'&xsd;nonNegativeInteger' + end + end + end + end + assert_match /^<\?xml/, xml.target! + assert_match /\n/m, xml.target! + end + +end + +class TestDeclarations < Test::Unit::TestCase + def setup + @xml = Builder::XmlMarkup.new(:indent=>2) + end + + def test_declare + @xml.declare! :element + assert_equal "\n", @xml.target! + end + + def test_bare_arg + @xml.declare! :element, :arg + assert_equal"\n", @xml.target! + end + + def test_string_arg + @xml.declare! :element, "string" + assert_equal"\n", @xml.target! + end + + def test_mixed_args + @xml.declare! :element, :x, "y", :z, "-//OASIS//DTD DocBook XML//EN" + assert_equal "\n", @xml.target! + end + + def test_nested_declarations + @xml = Builder::XmlMarkup.new + @xml.declare! :DOCTYPE, :chapter do |x| + x.declare! :ELEMENT, :chapter, "(title,para+)".intern + end + assert_equal "]>", @xml.target! + end + + def test_nested_indented_declarations + @xml.declare! :DOCTYPE, :chapter do |x| + x.declare! :ELEMENT, :chapter, "(title,para+)".intern + end + assert_equal "\n]>\n", @xml.target! + end + + def test_complex_declaration + @xml.declare! :DOCTYPE, :chapter do |x| + x.declare! :ELEMENT, :chapter, "(title,para+)".intern + x.declare! :ELEMENT, :title, "(#PCDATA)".intern + x.declare! :ELEMENT, :para, "(#PCDATA)".intern + end + expected = %{ + + +]> +} + assert_equal expected, @xml.target! + end +end + + +class TestSpecialMarkup < Test::Unit::TestCase + def setup + @xml = Builder::XmlMarkup.new(:indent=>2) + end + + def test_comment + @xml.comment!("COMMENT") + assert_equal "\n", @xml.target! + end + + def test_indented_comment + @xml.p { @xml.comment! "OK" } + assert_equal "

\n \n

\n", @xml.target! + end + + def test_instruct + @xml.instruct! :abc, :version=>"0.9" + assert_equal "\n", @xml.target! + end + + def test_indented_instruct + @xml.p { @xml.instruct! :xml } + assert_match %r{

\n <\?xml version="1.0" encoding="UTF-8"\?>\n

\n}, + @xml.target! + end + + def test_instruct_without_attributes + @xml.instruct! :zz + assert_equal "\n", @xml.target! + end + + def test_xml_instruct + @xml.instruct! + assert_match /^<\?xml version="1.0" encoding="UTF-8"\?>$/, @xml.target! + end + + def test_xml_instruct_with_overrides + @xml.instruct! :xml, :encoding=>"UCS-2" + assert_match /^<\?xml version="1.0" encoding="UCS-2"\?>$/, @xml.target! + end + + def test_xml_instruct_with_standalong + @xml.instruct! :xml, :encoding=>"UCS-2", :standalone=>"yes" + assert_match /^<\?xml version="1.0" encoding="UCS-2" standalone="yes"\?>$/, @xml.target! + end + + def test_no_blocks + assert_raises(Builder::IllegalBlockError) do + @xml.instruct! { |x| x.hi } + end + assert_raises(Builder::IllegalBlockError) do + @xml.comment!(:element) { |x| x.hi } + end + end + + def test_cdata + @xml.cdata!("TEST") + assert_equal "\n", @xml.target! + end + + def test_cdata_with_ampersand + @xml.cdata!("TEST&CHECK") + assert_equal "\n", @xml.target! + end +end + +class TestIndentedXmlMarkup < Test::Unit::TestCase + def setup + @xml = Builder::XmlMarkup.new(:indent=>2) + end + + def test_one_level + @xml.ol { |x| x.li "text" } + assert_equal "
    \n
  1. text
  2. \n
\n", @xml.target! + end + + def test_two_levels + @xml.p { |x| + x.ol { x.li "text" } + x.br + } + assert_equal "

\n

    \n
  1. text
  2. \n
\n
\n

\n", @xml.target! + end + + def test_initial_level + @xml = Builder::XmlMarkup.new(:indent=>2, :margin=>4) + @xml.name { |x| x.first("Jim") } + assert_equal " \n Jim\n \n", @xml.target! + end + + class TestXmlEvents < Test::Unit::TestCase + def setup + @handler = EventHandler.new + @xe = Builder::XmlEvents.new(:target=>@handler) + end + + def test_simple + @xe.p + assert_equal [:start, :p, nil], @handler.events.shift + assert_equal [:end, :p], @handler.events.shift + end + + def test_text + @xe.p("HI") + assert_equal [:start, :p, nil], @handler.events.shift + assert_equal [:text, "HI"], @handler.events.shift + assert_equal [:end, :p], @handler.events.shift + end + + def test_attributes + @xe.p("id"=>"2") + ev = @handler.events.shift + assert_equal [:start, :p], ev[0,2] + assert_equal "2", ev[2]['id'] + assert_equal [:end, :p], @handler.events.shift + end + + def test_indented + @xml = Builder::XmlEvents.new(:indent=>2, :target=>@handler) + @xml.p { |x| x.b("HI") } + assert_equal [:start, :p, nil], @handler.events.shift + assert_equal "\n ", pop_text + assert_equal [:start, :b, nil], @handler.events.shift + assert_equal "HI", pop_text + assert_equal [:end, :b], @handler.events.shift + assert_equal "\n", pop_text + assert_equal [:end, :p], @handler.events.shift + end + + def pop_text + result = '' + while ! @handler.events.empty? && @handler.events[0][0] == :text + result << @handler.events[0][1] + @handler.events.shift + end + result + end + + class EventHandler + attr_reader :events + def initialize + @events = [] + end + + def start_tag(sym, attrs) + @events << [:start, sym, attrs] + end + + def end_tag(sym) + @events << [:end, sym] + end + + def text(txt) + @events << [:text, txt] + end + end + end + +end + diff --git a/vendor/gems/gems/compass-0.8.17/CHANGELOG.markdown b/vendor/gems/gems/compass-0.8.17/CHANGELOG.markdown new file mode 100755 index 00000000..ce689ca3 --- /dev/null +++ b/vendor/gems/gems/compass-0.8.17/CHANGELOG.markdown @@ -0,0 +1,557 @@ +COMPASS CHANGELOG +================= + +0.8.17 (September 24, 2009) +--------------------------- + +* The enumerate function now accepts an optional fourth parameter that specifies the separator to be used. + Enables fixing a bug in the Compass 960 Plugin. + +0.8.16 (September 12, 2009) +--------------------------- + +* Fixed a bug in compass that assumed compass extensions would provide stylesheets. + +0.8.15 (September 5, 2009) +-------------------------- + +* Upgrade the FSSM library to 0.0.6 to fix bugs on windows. + + +0.8.14 (September 2, 2009) +-------------------------- + +* Upgrade the FSSM library to 0.0.4 to fix bugs and enable FS Events on Mac OS. + +0.8.13 (August 30, 2009) +------------------------ + +* [Blueprint] Mixins have been added for these as +prepend-top and +append-bottom and grid classes will be generated by +blueprint-grid. +* [Command Line] The watch mode has been re-implemented to use the FSSM library by Travis Tilley. OSX users will + now have support for filesystem monitoring. Fixes an infinite looping bug that occured with syntax users. + +0.8.12 (August 22, 2009) +------------------------ + +Bug Fix Release: + +* [Compass Core] Bug fix to sprites: fixed width and height assignments for x and y position variables +* Ruby 1.9.1 fix: binding for parse_string +* [Rails] Don't suggest creating a stylesheet link to partials. + + +0.8.10 (August 16, 2009) +------------------------ +Bug Fix Release: + +* Write files in binary mode to avoid data corruption when installing images on windows. + Fixes [Issue #39](http://github.com/chriseppstein/compass/issues/#issue/39) + +0.8.9 (August 9, 2009) +---------------------- +Bug Fix Release: + +* [Blueprint] The default screen.sass generated invalid selectors due to improper nesting. A better fix is coming in the next release. + +0.8.8 (July 21, 2009) +--------------------- + +Bug Fix Release: + +* [Compass Core] Fixed a bug in alternating_rows_and_columns. Improper nesting caused some styles to be improperly rendered. + [Commit](http://github.com/chriseppstein/compass/commit/e277ed2cd3fded0b98ddaa87fc4d3b9d37cb7354) +* [YUI] Fixed a bug in yui grids where the .first div wouldn't get the right styles in some rare cases due to incorrect nesting. + [Commit](http://github.com/chriseppstein/compass/commit/4bfcef4f376ee6e5d5a2b47419d2f21ef4c6eff8) + + +0.8.7 (July 09, 2009) +--------------------- + +Bug Fix Release: + +* Load haml-edge only if it's all new and shiny. Closes GH-26. + [Commit](http://github.com/chriseppstein/compass/commit/59a6067b3a67a79bfd9a5ce325fc1be4bb6c9e78) +* [Blueprint] Added more descriptive comments to the Blueprint IE template. + [Commit](http://github.com/chriseppstein/compass/commit/8684966be1e8166a986ae81abd3daf6c44ed4f94) +* [Rails] Fixed a bug in rails integration if the request is not set on the controller. + [Commit](http://github.com/chriseppstein/compass/commit/7fba6028d8073a9124a6505aab9246b5b459db34) +* [Blueprint] Fixed a bug in the calculations for the +colborder mixin. Closes GH-25. + [Commit](http://github.com/chriseppstein/compass/commit/d2b1370c80a32f70ae6ec94126b737f4f0fc0851) + +0.8.6 (July 08, 2009) +--------------------- + +### Rails + +* The rails installer now correctly references the haml 2.2 dependency. + [Commit](http://github.com/chriseppstein/compass/commit/85bb337f50a3a3dfaafa2820d5463f7296140c9e) + by [Filip Tepper][filiptepper]. +* When installing into a new rails project, set the http paths correctly for stylesheets and javascripts + in the configuration file. + [Commit](http://github.com/chriseppstein/compass/commit/94e9696b30a9a9fd750c45e6fe3c2bc93eba506a) +* Fixed a bug in asset hosts support when compiling outside the context of a controller. + [Commit](http://github.com/chriseppstein/compass/commit/6b8bbd22b13ef4c329777913a633948e66e3da99) + +### Command Line + +* Fixed a bug that caused the output after installing to not display the conditional comments. + [Commit](http://github.com/chriseppstein/compass/commit/48a0356ad8bc7b965e64f82498a9adcc1872abad) + +### Compass Core + +* Fixed a copy & paste error in image_url() that caused the http_images_path to not get picked up unless the + http_stylesheets_path was also set. + [Commit](http://github.com/chriseppstein/compass/commit/b7a9772efb89b2b882d3fafe02813c0fc650719a) + +0.8.5 (July 06, 2009) +--------------------- + +The Compass::TestCase class now inherits from ActiveSupport::TestCase if it exists. +[Commit](http://github.com/chriseppstein/compass/commit/71d5ae8544d1c5ae49e28dcd6b3768fc39d7f01c) + +0.8.4 (July 06, 2009) +--------------------- + +Fixed a bug in rails integration introduced in 0.8.3. + +0.8.3 (July 06, 2009) +--------------------- + +Note: Compass now depends on the stable release of haml with version 2.2.0 or greater. + +### Compass Core + +* A new helper function `stylesheet_url(path)` can now be used to refer to assets that are relative to the css directory. + [Commit](http://github.com/chriseppstein/compass/commit/ff5c8500144272ee2b94271b06cce1690cbbc000). +* Cross browser ellipsis mixin is now available. Use `compass -p ellipsis` to install it into your project since it + requires some additional assets. + [Commit](http://github.com/chriseppstein/compass/commit/3d909ceda997bdcde2aec09bd72e646098389e7d). + +### Blueprint + +* The +colruler mixin now accepts an argument for the color. + [Commit](http://github.com/chriseppstein/compass/commit/a5393bbb7cd0941ab8add5be188aea1d6f9d4b00) + by [Thomas Reynolds][tdreyno]. + +### Extensions + +* A bug was fixed related to how javascript installation as part of an extension manifest. + [Commit](http://github.com/chriseppstein/compass/commit/a5393bbb7cd0941ab8add5be188aea1d6f9d4b00) + by [dturnbull][dturnbull]. +* When installing a file, the :like option can now be set to have it installed into the + same location as what it is like. E.g. `file 'foo.xml', :like => :css` will install + the foo.xml file into the top level of the project's css directory. + [Commit](http://github.com/chriseppstein/compass/commit/21cfce33db81e185ce5517818844a9849b5a836e). + +### Configuration +* Setting `http_images_path` to `:relative` is now **deprecated**. Instead, please set `relative_assets` to + `true`. + [Commit](http://github.com/chriseppstein/compass/commit/956c437fe9ffaad08b6b34d91b6cfb80d6121a2f). +* New configuration option `http_path` can be used to set the project's path relative to the server's root. + Defaults to "/". The http paths to images, stylesheets, and javascripts are now assumed to be relative to that + path but can be overridden using the `http_images_path`, `http_css_path`, `http_javascripts_path`. + [Commit](http://github.com/chriseppstein/compass/commit/6555ab3952ae37d736d54f43ee7053c2a88f4a69). + +### Command Line + +* A new command line option `--relative-assets` can be used to cause links to assets generated + via compass helper functions to be relative to the target css file. + [Commit](http://github.com/chriseppstein/compass/commit/956c437fe9ffaad08b6b34d91b6cfb80d6121a2f). + +0.8.2 (July 04, 2009) +--------------------- + +Fixed a bug that caused touch to fail on windows due to open files. (Contributor: Joe Wasson) + +0.8.1 +----- + +Fixed some build issues and a bug in the rewritten --watch mode that caused changes to partials to go unnoticed. + +0.8.0 +----- + +### Rails + +* image_url() now integrates with the rails asset handling code when + stylesheets are generated within the rails container. + **This causes your rails configuration for cache busting and asset hosts + to be used when generating your stylesheets**. Unfortunately, all + that code runs within the context of a controller, so the stylesheets + have to be generated during first request to use this functionality. If you + need to compile stylesheets offline, use the compass configuration file to set + the asset_host and asset_cache_buster. + [Commit](http://github.com/chriseppstein/compass/commit/998168160b11c8702ded0a32820ea15b70d51e83). + +* An official Rails template for Compass is now [provided][rails_template]. + [Commit](http://github.com/chriseppstein/compass/commit/f6948d1d58818ef8babce8f8f9d775562d7cd7ef) + by [Derek Perez][perezd]. + +### Blueprint + +* The Blueprint port has been upgraded to match Blueprint 0.9. The following changes were made as part + of that project: + * Removed body margins from blueprint scaffolding by default. + The old body styles can be reinstated by mixing +blueprint-scaffolding-body into your body selector(s). + [Commit](http://github.com/chriseppstein/compass/commit/45af89d4c7a396fae5d14fab4ef3bab23bcdfb6a) + by [Enrico Bianco][enricob]. + * A bug in the calculations affecting the +colborder mixin has been fixed. + [Commit](http://github.com/chriseppstein/compass/commit/4b33fae5e5c5421580ba536116cb10194f1318d1) + by [Enrico Bianco][enricob]. + Related [commit](http://github.com/chriseppstein/compass/commit/0a0a14aab597d2ec31ff9d267f6ee8cfad878e10). + * Blueprint now has inline form support. Mix +blueprint-inline-form into a form selector to make it inline. + [Commit](http://github.com/chriseppstein/compass/commit/56c745b939c763cfcc5549b54979d48ab1309087) + by [Enrico Bianco][enricob]. + * Please update the conditional comment that surrounds your IE stylesheet to use "lt IE 8" as the condition + as these styles are not needed in IE8. New blueprint projects will now use this conditional as their default. + [Commit](http://github.com/chriseppstein/compass/commit/77f6e02c0ec80d2b6fd19e611ced02be003c98ae) + by [Enrico Bianco][enricob]. + * Explicitly define image interpolation mode for IE so that images aren't jagged when resizing. + [Commit](http://github.com/chriseppstein/compass/commit/63075f82db367913efcce5e1d0f5489888e86ca4) + by [Enrico Bianco][enricob]. + +* When starting a new project based on Blueprint, a more complete screen.sass file will be + provided that follows compass best practices instead of matching blueprint css exactly. A + partials/_base.sass file is provided and already set up for blueprint customization. + [Commit](http://github.com/chriseppstein/compass/commit/11b6ea14c3ee919711fa4bdce349f88b64b68d51) + +* The sizes and borders for form styling can now be altered via mixin arguments. + [Commit](http://github.com/chriseppstein/compass/commit/b84dd3031b82547cff8e1ef1f85de66d98cd162b) + by [Thomas Reynolds][tdreyno]. + +* Grid borders can now be altered via mixin arguments. + [Commit](http://github.com/chriseppstein/compass/commit/0a0a14aab597d2ec31ff9d267f6ee8cfad878e10) + by [Thomas Reynolds][tdreyno]. + +* The reset file for blueprint has moved from compass/reset.sass to blueprint/reset.sass. Please + update your imports accordingly. Also note that some of the reset mixin names have changed + (now prefixed with blueprint-*). + [Commit](http://github.com/chriseppstein/compass/commit/2126240a1a16edacb0a758d782334a9ced5d9116) + by [Noel Gomez][noel]. + +### Compass Core + +* **Sprites**. A basic sprite mixin is now available. Import compass/utilities/sprites.sass and use the +sprite-img + mixin to set the background image from a sprite image file. Assumes every sprite in the sprite image + file has the same dimensions. + [Commit](http://github.com/chriseppstein/compass/commit/1f21d6309140c009188d350ed911eed5d34bf02e) + by [Thomas Reynolds][tdreyno]. + +* **Reset**. The compass reset is now based on [Eric Meyer's reset](http://meyerweb.com/eric/thoughts/2007/05/01/reset-reloaded/). + which makes no attempt to apply base styles like the blueprint reset does. **Existing compass projects + will want to change their reset import to point to blueprint/reset.sass** -- which is where the old + default reset for compass projects now lives -- see the blueprint notes above for more information. + [Commit](http://github.com/chriseppstein/compass/commit/2126240a1a16edacb0a758d782334a9ced5d9116) + by [Noel Gomez][noel]. + +* A bug was fixed in the tag_cloud mixin so that it actually works. + [Commit](http://github.com/chriseppstein/compass/commit/be5c0ff6731ec5e0cdac73bc47f5603c3db899b5) + by [Bjørn Arild Mæland][Chrononaut]. + +### Sass Extensions + +* The inline_image(image_path) function can now be used to generate a data url that embeds the image data in + the generated css file -- avoiding the need for another request. + This function works like image_url() in that it expects the image to be a path + relative to the images directory. There are clear advantages and disadvantages to this approach. + See [Wikipedia](http://en.wikipedia.org/wiki/Data_URI_scheme) for more details. + NOTE: Neither IE6 nor IE7 support this feature. + [Commit](http://github.com/chriseppstein/compass/commit/5a015b3824f280af56f1265bf8c3a7c64a252621). + +### Configuration + +* **Asset Hosts**. You can now configure the asset host(s) used for images via the image_url() function. + Asset hosts are off unless configured and also off when relative urls are enabled. + [Commit](http://github.com/chriseppstein/compass/commit/ef47f3dd9dbfc087de8b12a90f9a82993bbb592e). + In your compass configuration file, you must define an asset_host algorithm to be used like so: + # Return the same host for all images: + asset_host {|path| "http://assets.example.com" } + # Return a different host based on the image path. + asset_host do |path| + "http://assets%d.example.com" % (path.hash % 4) + end + + +* **Configurable Cache Buster**. You can now configure the cache buster that gets placed at the end of + images via the image_url function. This might be useful if you need to coordinate the query string + or use something other than a timestamp. + [Commit](http://github.com/chriseppstein/compass/commit/ef47f3dd9dbfc087de8b12a90f9a82993bbb592e) + Example: + asset_cache_buster do |path, file| + "busted=true" + end + +* You can now set/override arbitrary sass options by setting the sass_options configuration property + to a hash. [Commit](http://github.com/chriseppstein/compass/commit/802bca61741db31da7131c82d31fff45f9323696). + +* You can now specify additional import paths to look for sass code outside the project. + [Commit](http://github.com/chriseppstein/compass/commit/047be06a0a63923846f53849fc220fb4be69513b). + This can be done in two ways: + 1. By setting additional_import_paths to an array of paths. + 2. By (repeatedly) calling add_import_path(path) + +* The compass configuration can now be placed in PROJECT_DIR/.compass/config.rb if you so choose. + [Commit](http://github.com/chriseppstein/compass/commit/69cf32f70ac79c155198d2dbf96f50856bee9504). + + +### Command Line + +* **Watch Improvements** The watch command was rewritten for robustness and reliability. The most + important change is that generated css files will be deleted if the originating sass file is removed while + watching the project. [Commit](http://github.com/chriseppstein/compass/commit/0a232bd922695f6f659fac9f90466745d4425839). + +* The images and javascripts directories may now be set via the command line. + [Commit](http://github.com/chriseppstein/compass/84aec053d0109923ea0208ac0847684cf09cefc1). + +* The usage output (-h) of the command-line has been reformatted to make it more readable and understandable. + [Commit](http://github.com/chriseppstein/compass/f742f26208f4c5c783ba63aa0cc509bb19e06ab9). + +* The configuration file being read can now be specified explicitly using the -c option. + This also affects the output location of the --write-configuration command. + NOTE: The -c option used to be for writing the configuration file, an infrequently used option. + [Commit](http://github.com/chriseppstein/compass/d2acd343b899db960c1d3a377e2ee6f58595c6b1). + +* You can now install into the current working directory by explicitly setting the command line mode to -i + and providing no project name. + [Commit](http://github.com/chriseppstein/compass/f742f26208f4c5c783ba63aa0cc509bb19e06ab9). + +### Compass Internals + +* Some internal code was reorganized to make managing sass extensions and functions more manageable. + +* Some internal code was reorganized to make managing ruby application integration more manageable. + +* The compass unit tests were reorganized to separate rails testing from other tests. + +* The [Rip Packaging System](http://hellorip.com) is now supported. + [Commit](http://github.com/chriseppstein/compass/commit/56f36577c7654b93a349f74abf274327df23402b) + by [Will Farrington](http://github.com/wfarr). + +* A [licence is now available](http://github.com/chriseppstein/compass/blob/master/LICENSE.markdown) + making the copyrights and terms of use clear for people who care about such things. + + +0.6.14 +------ + +Extracted the css validator to an external gem that is only required if you try to use the validation feature. +This makes the compass gem a lot smaller (0.37MB instead of 4MB). To install the validator: + + sudo gem install chriseppstein-compass-validator --source http://gems.github.com/ + +0.6.8 thru 0.6.13 +----------------- + +The compass gem is now built with Jeweler instead of Echoe. No changes to speak of. These versions were bug +fixes and working out the new release process. + +0.6.7 +----- + +Bug fix release. + +### Rails + +The output_style will no longer be set in the compass.config file. Instead compass will use the runtime rails environment to set a sensible default. + +### Command Line + +The Sass cache directory will be placed into the sass directory of the project instead of the directory from where the compass command was ran. + +### Compass Core + +Extracted two new mixins from +horizontal-list. The new +horizontal-list-container and +horizontal-list-item mixins can be used to build your +horizontal list when you need more control over the selectors (E.g. when working with nested lists). + +0.6.6 +----- + +The Haml project now releases a gem called haml-edge that is built from the haml master branch instead of stable. Compass now depends on this gem and will continue to do so until haml 2.2 is released. This should reduce the number of installation problems that have been encountered by new users. + +### Command Line + +* Fixed a bug that had broken the --write-configuration (-c) option. +* The --force option will now force recompilation. Useful when the stylesheets don't appear to need a recompile according to the file timestamps. + +### Unit tests + +* Some unit tests were cleaned up for clarity and to better take advantage of the compass project management facilities. + +0.6.5 +----- + +### Compass Core + +Converted all mixins definitions referencing images to use the new sass function image\_url(). The following mixins were affected: + +* +pretty-bullets +* +replace-text + +The calls to these mixins should now pass a path to the image that is relative to the images directory of the project. + +### Command Line + +* Required frameworks specified from the command line will now be added into the initial project configuration file. + +0.6.4 +----- + +### Command Line + +Added a command line option --install-dir that will emit the directory where compass is installed. Useful for debugging and drilling into the compass examples and libraries. + +0.6.3 +----- + +### Rails + +Bug fix: The http_images_path configuration default should be "/images" instead of "/public/images". + +### Command Line + +These changes, coupled with upcoming changes to Sass result in significantly reduced time spent on compilation for large projects. + +* The compass command line will no longer recompile sass files that haven't changed (taking import dependencies into account). +* The compass command line will now respect the -q (quiet) option during compilation. Additionally, the quiet option will be set by default when watching a project for changes. + +0.6.2 +----- + +### Blueprint + +Split the push and pull mixins into sub-mixins that separate the common styles from the ones that vary. The generated css when using presentational class names will be smaller as a result. The existing +push and +pull mixins continue to work as expected. The following mixins were added: + + +push-base + +push-margins + +pull-base + +pull-margins + +Additonally, the liquid plugin was updated to have a span mixin that matches elsewhere. + +### YUI + +Added Yahoo's version of the css reset. To use it, mix into the top level of your project: + + @import yui/modules/reset.sass + +reset + +### Rails + +* Conditionally defining #blank? on String/NilClass (Erik Bryn ) +* Set compass environment in plugin based on RAILS_ENV (Lee Nussbaum ) + +0.6.1 +----- + +Maintenance release that fixes several bugs in the handling of configuration files. + +0.6.0 +----- + +### New Core Functionality: **Patterns** + +Patterns give a framework or plugin access to the compass installer framework +to install customizable sass, html as well as image and javascript assets. + +A pattern is a folder in the plugin's templates directory. It must +have a manifest file that tells compass what to install and where. +Unlike the project template, a pattern can be stamped out any number of +times. + +It is best for pattern stylesheets to only provide example usage to get +the user started. All the core styles for the pattern should be +distributed as part of the framework's stylesheets as mixins to +facilitate easy upgrades and bug fixing on the part of the pattern's +maintainer. + +Example Usage: +compass --framework blueprint --pattern buttons + +Please read the +[Wiki Page](http://wiki.github.com/chriseppstein/compass/patterns) for more information. + +### New Command-line options: + +1. --validate
+ Validate your project's compiled css. Requires java and probably only works on Mac and Unix. +2. --grid-img [DIMENSIONS]
+ Generate a background image to test grid alignment. Dimension is given as + +. Defaults to 30+10. +3. -p, --pattern PATTERN
+ When combined with with the --framework option, will stamp a plugin's pattern named PATTERN. +4. -n, --pattern-name NAME
+ When combined with the --pattern option, the pattern that gets stamped out will + be isolated in subdirectories named NAME. +5. -c, --write-configuration
+ Emit a compass configuration file into the current directory, taking any existing configuration + file and any command line options provided into account. (command line options override + configuration file options). + +### New Sass Functions: + +Compass projects can call these sass functions within their sass files, if you find them useful. + +1. enumerate(prefix, start, end)
+ Generates selectors with a prefix and a numerical ending + counting from start to end. E.g. enumerate("foo", 1, 3) returns "foo-1, foo-2, foo-3" +2. image_url(path)
+ Uses the compass configuration to convert a path relative to the compass + project directory to a path that is either absolute for serving in an HTTP + context or that is relative to whatever css file the function was being + compiled into. In the future, this function may also tap into the rails + asset host configuration. + +### New Compass Core Mixins + +1. +float-left & +float-right
+ In order to include fixes for IE's double-margin bug universally, + floats were implemented as a utility mixins. These are available by importing + compass/utilities/general/float.sass which also imports the clearfix module. +2. +pie-clearfix
+ Implementation of the + [position-is-everything clearfix](http://www.positioniseverything.net/easyclearing.html) + that uses content :after. + +### Blueprint 0.8 + +The Compass port of Blueprint has been upgraded from 0.7.1 to 0.8.0. The 0.8.0 release +brings many bug fixes and a few backward incompatible changes if you use it's presentational +classnames (you don't do that, do you?). Upgrading to 0.8 is automatic when you upgrade to +compass 0.6.0. The Blueprint team didn't release a detailed changelog for me to point at here. +One of the key features of the release was the inclusion of three new core blueprint plugins +(a.k.a. folders you can copy). These are what prompted the development of the compass patterns +feature and two of them are packaged as patterns: + +1. Buttons
+ To install: compass --framework blueprint --pattern buttons
+ Then follow your nose. +2. Link Icons
+ To install: compass --framework blueprint --pattern link\_icons
+ Then follow your nose. + +The third plugin is the RTL (right-to-left) plugin. To use this one, simply import it after the import +of the blueprint grid and your mixins will be redefined to work in a left to right manner. Additionally, +it provides +rtl-typography mixin that works in conjunction with +blueprint-typography and should be mixed +in with it. + +Lastly, I've rewrote some of the presentational class name generation code so that it very nearly +matches the blueprint CSS. Please note that they are not 100% the same because we fix some bugs +that are not yet fixed in blueprint-css and we use a different clearfix implementation. + +### Bug Fixes + +1. A Safari bug related to the +clearfix mixin was resolved. +2. Running the compass command line installer a second time. + +### Bugs Introduced + +Almost definitely. Please let me know if you encounter any problems and I'll get a patch out + +[tdreyno]: http://github.com/tdreyno +[noel]: http://github.com/noel +[enricob]: http://github.com/enricob +[perezd]: http://github.com/perezd +[Chrononaut]: http://github.com/Chrononaut +[rails_template]: http://github.com/chriseppstein/compass/raw/4e7e51e2c5491851f66c77abf3f15194f2f8fb8d/lib/compass/app_integration/rails/templates/compass-install-rails.rb +[dturnbull]: http://github.com/dturnbull +[filiptepper]: http://github.com/filiptepper diff --git a/vendor/gems/gems/compass-0.8.17/LICENSE.markdown b/vendor/gems/gems/compass-0.8.17/LICENSE.markdown new file mode 100755 index 00000000..8e61ae60 --- /dev/null +++ b/vendor/gems/gems/compass-0.8.17/LICENSE.markdown @@ -0,0 +1,29 @@ +Copyright (c) 2009 Christopher M. Eppstein + +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. +No attribution is required by products that make use of this 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. + +Except as contained in this notice, the name(s) of the above copyright +holders shall not be used in advertising or otherwise to promote the sale, +use or other dealings in this Software without prior written authorization. + +Contributors to this project agree to grant all rights to the copyright +holder of the primary product. Attribution is maintained in the source +control history of the product. diff --git a/vendor/gems/gems/compass-0.8.17/README.markdown b/vendor/gems/gems/compass-0.8.17/README.markdown new file mode 100755 index 00000000..77c8de67 --- /dev/null +++ b/vendor/gems/gems/compass-0.8.17/README.markdown @@ -0,0 +1,44 @@ +# Compass +A [Sass][sass]-based CSS Meta-Framework that allows you to mix and match any of the following CSS frameworks: + +- [Compass Core][compass_core_website] - [Wiki Documentation][compass_core_wiki] +- [Blueprint][blueprint_website] - [Wiki Documentation][bleuprint_wiki] +- [YUI][yui_website] - [Wiki Documentation][yui_wiki] +- [960][ninesixty_website] - [Wiki Documentation][ninesixty_wiki] +- Other frameworks can be added relatively easily. Create your own! + +## Compass Provides + +1. A [command line tool][command_line_wiki] for managing your Sass projects. +2. Simple integration with [Ruby-on-Rails][ruby_on_rails_wiki], [Merb][merb_wiki], [StaticMatic][static_matic_wiki], and even [non-ruby application servers][command_line_wiki]. +3. Loads of Sass mixins to make building your website a snap. + +## More Information +Please see the [wiki][wiki] + +## Author +Compass is written by [Chris Eppstein][chris_eppstein].
+Chris is the Software Architect of [Caring.com][caring.com] and a member of the [Sass][sass] core team. + +## License +Copyright (c) 2008-2009 Christopher M. Eppstein
+All Rights Reserved.
+Released under a [slightly modified MIT License][license]. + +[sass]: http://haml.hamptoncatlin.com/docs/rdoc/classes/Sass.html "Syntactically Awesome StyleSheets" +[compass_core_website]: http://github.com/chriseppstein/compass/tree/master/frameworks/compass +[compass_core_wiki]: http://github.com/chriseppstein/compass/wikis/compass-core-documentation +[blueprint_website]: http://blueprintcss.org/ +[bleuprint_wiki]: http://github.com/chriseppstein/compass/wikis/blueprint-documentation +[yui_website]: http://developer.yahoo.com/yui/grids/ +[yui_wiki]: http://github.com/chriseppstein/compass/wikis/yui-documentation +[ninesixty_website]: http://960.gs/ +[ninesixty_wiki]: http://github.com/chriseppstein/compass/wikis/960gs-documentation +[command_line_wiki]: http://wiki.github.com/chriseppstein/compass/command-line-tool +[wiki]: http://github.com/chriseppstein/compass/wikis/home +[ruby_on_rails_wiki]: http://wiki.github.com/chriseppstein/compass/ruby-on-rails-integration +[merb_wiki]: http://wiki.github.com/chriseppstein/compass/merb-integration +[static_matic_wiki]: http://wiki.github.com/chriseppstein/compass/staticmatic-integration +[chris_eppstein]: http://acts-as-architect.blogspot.com +[caring.com]: http://www.caring.com/ "Senior Care Resources" +[license]: http://github.com/chriseppstein/compass/tree/master/LICENSE.markdown diff --git a/vendor/gems/gems/compass-0.8.17/REVISION b/vendor/gems/gems/compass-0.8.17/REVISION new file mode 100755 index 00000000..4519e373 --- /dev/null +++ b/vendor/gems/gems/compass-0.8.17/REVISION @@ -0,0 +1 @@ +2465baba525421ac9cac1774d940f9e27971710d \ No newline at end of file diff --git a/vendor/gems/gems/compass-0.8.17/Rakefile b/vendor/gems/gems/compass-0.8.17/Rakefile new file mode 100755 index 00000000..ac940261 --- /dev/null +++ b/vendor/gems/gems/compass-0.8.17/Rakefile @@ -0,0 +1,127 @@ +if ENV['RUN_CODE_RUN'] + # We need to checkout edge haml for the run>code>run test environment. + if File.directory?("haml") + Dir.chdir("haml") do + sh "git", "pull" + end + else + sh "git", "clone", "git://github.com/nex3/haml.git" + end + $LOAD_PATH.unshift "haml/lib" +end + +require 'rubygems' +require 'rake' +require 'lib/compass' + +# ----- Default: Testing ------ + +task :default => :run_tests + +require 'rake/testtask' +require 'fileutils' + +Rake::TestTask.new :run_tests do |t| + t.libs << 'lib' + t.libs << 'haml/lib' if ENV["RUN_CODE_RUN"] + test_files = FileList['test/**/*_test.rb'] + test_files.exclude('test/rails/*', 'test/haml/*') + t.test_files = test_files + t.verbose = true +end +Rake::Task[:test].send(:add_comment, <= 2.2.0') + gemspec.files = [] + gemspec.files << "CHANGELOG.markdown" + gemspec.files << "README.markdown" + gemspec.files << "LICENSE.markdown" + gemspec.files << "REVISION" + gemspec.files << "VERSION.yml" + gemspec.files << "Rakefile" + gemspec.files << "deps.rip" + gemspec.files += Dir.glob("bin/*") + gemspec.files += Dir.glob("examples/**/*.*") + gemspec.files -= Dir.glob("examples/**/*.css") + gemspec.files -= Dir.glob("examples/**/*.html") + gemspec.files += Dir.glob("frameworks/**/*.*") + gemspec.files += Dir.glob("lib/**/*") + gemspec.files += Dir.glob("test/**/*.*") + gemspec.files -= Dir.glob("test/fixtures/stylesheets/*/saved/**/*.*") + gemspec.test_files = Dir.glob("test/**/*.*") + gemspec.test_files -= Dir.glob("test/fixtures/stylesheets/*/saved/**/*.*") + end +rescue LoadError + puts "Jeweler not available. Install it with: sudo gem install technicalpickles-jeweler -s http://gems.github.com" +end + +desc "Record the current git revision." +task :REVISION do + require 'git' + + repo = Git.open('.') + open("REVISION", "w") do |f| + f.write(repo.object("HEAD").sha) + end +end + +desc "Commit the revision file." +task :commit_revision => :REVISION do + require 'git' + repo = Git.open('.') + repo.add("REVISION") + repo.commit("Record current revision for release.") +end + +task :release => :commit_revision + +desc "Compile Examples into HTML and CSS" +task :examples do + linked_haml = "tests/haml" + if File.exists?(linked_haml) && !$:.include?(linked_haml + '/lib') + puts "[ using linked Haml ]" + $:.unshift linked_haml + '/lib' + end + require 'haml' + require 'sass' + require 'pathname' + require 'lib/compass' + require 'lib/compass/exec' + FileList['examples/*'].each do |example| + next unless File.directory?(example) + puts "\nCompiling #{example}" + puts "=" * "Compiling #{example}".length + # compile any haml templates to html + FileList["#{example}/**/*.haml"].each do |haml_file| + basename = haml_file[0..-6] + engine = Haml::Engine.new(open(haml_file).read, :filename => haml_file) + puts " haml #{File.basename(basename)}" + output = open(basename,'w') + output.write(engine.render) + output.close + end + Dir.chdir example do + Compass::Exec::Compass.new(["--force"]).run! + end + end +end + +namespace :git do + task :clean do + sh "git", "clean", "-fdx" + end +end diff --git a/vendor/gems/gems/compass-0.8.17/VERSION.yml b/vendor/gems/gems/compass-0.8.17/VERSION.yml new file mode 100755 index 00000000..0bd37399 --- /dev/null +++ b/vendor/gems/gems/compass-0.8.17/VERSION.yml @@ -0,0 +1,4 @@ +--- +:patch: 17 +:major: 0 +:minor: 8 diff --git a/vendor/gems/gems/compass-0.8.17/bin/compass b/vendor/gems/gems/compass-0.8.17/bin/compass new file mode 100755 index 00000000..fb94e65f --- /dev/null +++ b/vendor/gems/gems/compass-0.8.17/bin/compass @@ -0,0 +1,8 @@ +#!/usr/bin/env ruby +# The compass command line utility + +require File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib', 'compass')) +require File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib', 'compass', 'exec')) + +command = Compass::Exec::Compass.new(ARGV) +exit command.run! diff --git a/vendor/gems/gems/compass-0.8.17/deps.rip b/vendor/gems/gems/compass-0.8.17/deps.rip new file mode 100755 index 00000000..71d1e8c1 --- /dev/null +++ b/vendor/gems/gems/compass-0.8.17/deps.rip @@ -0,0 +1 @@ +git://github.com/nex3/haml.git master diff --git a/vendor/gems/gems/compass-0.8.17/examples/README.markdown b/vendor/gems/gems/compass-0.8.17/examples/README.markdown new file mode 100755 index 00000000..b00d5709 --- /dev/null +++ b/vendor/gems/gems/compass-0.8.17/examples/README.markdown @@ -0,0 +1,4 @@ +To build the examples: + +1. You can run the compass command line from any particular compass example project +2. You can compile them all by running `rake examples` at the top of the project directory. \ No newline at end of file diff --git a/vendor/gems/gems/compass-0.8.17/examples/blueprint_default/config.rb b/vendor/gems/gems/compass-0.8.17/examples/blueprint_default/config.rb new file mode 100755 index 00000000..bbb651ed --- /dev/null +++ b/vendor/gems/gems/compass-0.8.17/examples/blueprint_default/config.rb @@ -0,0 +1,7 @@ +# Require any additional compass plugins here. +project_type = :stand_alone +css_dir = "stylesheets" +sass_dir = "src" +images_dir = "images" +output_style = :compact +relative_assets = true diff --git a/vendor/gems/gems/compass-0.8.17/examples/blueprint_default/images/grid.png b/vendor/gems/gems/compass-0.8.17/examples/blueprint_default/images/grid.png new file mode 100755 index 00000000..129d4a29 Binary files /dev/null and b/vendor/gems/gems/compass-0.8.17/examples/blueprint_default/images/grid.png differ diff --git a/vendor/gems/gems/compass-0.8.17/examples/blueprint_default/index.html.haml b/vendor/gems/gems/compass-0.8.17/examples/blueprint_default/index.html.haml new file mode 100755 index 00000000..8a59a9cf --- /dev/null +++ b/vendor/gems/gems/compass-0.8.17/examples/blueprint_default/index.html.haml @@ -0,0 +1,85 @@ +!!! +%html{ :lang => "en" } + %head + %meta{ :content => "text/html; charset=utf-8", "http-equiv" => "Content-Type" } + %title + Blueprint test pages + / + Framework CSS + %link{ :href => "stylesheets/screen.css", :rel => "stylesheet", :media => "screen, projection", :type => "text/css" } + %link{ :href => "stylesheets/index.css", :rel => "stylesheet", :media => "screen, projection", :type => "text/css" } + %link{ :href => "stylesheets/print.css", :rel => "stylesheet", :media => "print", :type => "text/css" } + / + [if IE]> "0", :border => "0", :cellpadding => "0" } + %tr + %th.span-6 + Test page + %th.span-8 + Main files tested + %th.span-10 + Description + %tr + %td + %a{ :href => "parts/grid.html" } + Grid + %td + %a{ :href => "../../frameworks/blueprint/stylesheets/blueprint/modules/_grid.sass" } + grid.sass + %td + Tests classes provided by the grid module. + %tr.even + %td + %a{ :href => "parts/elements.html" } + Typography + %td + %a{ :href => "../../frameworks/blueprint/stylesheets/blueprint/modules/_typography.sass" } + typography.sass + %td + Tests HTML elements which gets set in the typography module. + %tr + %td + %a{ :href => "parts/forms.html" } + Forms + %td + %a{ :href => "../../frameworks/blueprint/stylesheets/blueprint/modules/_form.sass" } + form.sass + %td + Tests classes and default look provided by the form module. + %p + %em + %strong + Note about the css files: + These test files utilize the css files that are generated from + %a{ :href => "http://haml.hamptoncatlin.com/docs/rdoc/classes/Sass.html" } + Sass templates + \. + In other words, if you change any of the source files, + you'll have to re-build them with + %code + rake examples + to see any changes. + .box + %p + For more information and help, try these resources: + %ul.bottom + %li + %a{ :href => "http://code.google.com/p/blueprintcss" } + The Blueprint home page. + %li + %a{ :href => "http://groups.google.com/group/blueprintcss" } + Our anything-goes mailing list. + %li + %a{ :href => "http://bjorkoy.com" } + The blog where news about Blueprint gets posted. + %p + %a{ :href => "http://validator.w3.org/check?uri=referer" } + %img.top{ :src => "parts/valid.png", :height => "31", :alt => "Valid HTML 4.01 Strict", :width => "88" } diff --git a/vendor/gems/gems/compass-0.8.17/examples/blueprint_default/parts/elements.html.haml b/vendor/gems/gems/compass-0.8.17/examples/blueprint_default/parts/elements.html.haml new file mode 100755 index 00000000..f6039e46 --- /dev/null +++ b/vendor/gems/gems/compass-0.8.17/examples/blueprint_default/parts/elements.html.haml @@ -0,0 +1,282 @@ +!!! +%html{ :lang => "en" } + %head + %meta{ :content => "text/html; charset=utf-8", "http-equiv" => "Content-Type" } + %title + Blueprint HTML Elements Tests + / + Framework CSS + %link{ :href => "../stylesheets/screen.css", :rel => "stylesheet", :media => "screen, projection", :type => "text/css" } + %link{ :href => "../stylesheets/print.css", :rel => "stylesheet", :media => "print", :type => "text/css" } + / + [if IE]> "http://www.google.com" } + \<a> a + href + %p + %abbr{ :title => "extended abbr text should show when mouse over" } + \<abbr> abbr - extended text when mouseover. + %br + %acronym{ :title => "extended acronym text should show when mouse over" } + \<acronym> acronym - extended text when mouseover. + %address + \<address> + %br + Donald Duck + %br + Box 555 + %br + Disneyland + %p + Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore dolore. + .span-8 + %table{ :cellspacing => "0", :border => "0", :summary => "This is the summary text for this table.", :cellpadding => "0" } + %caption + %em + A standard test table with a caption, tr, td elements + %tr + %th.span-4 + Table Header One + %th.span-4.last + Table Header Two + %tr + %td + TD One + %td + TD Two + %tr + %td{ :colspan => "2" } + TD colspan 2 + %table{ :cellspacing => "0", :border => "0", :summary => "This is the summary text for this table.", :cellpadding => "0" } + %caption + %em + A test table with a thead, tfoot, and tbody elements + %thead + %tr + %th.span-4 + Table Header One + %th.span-4.last + Table Header Two + %tfoot + %tr + %td{ :colspan => "2" } + tfoot footer + %tbody + %tr + %td + TD One + %td + TD Two + %tr + %td + TD One + %td + TD Two + %tbody + %tr + %td + TD One + %td + TD Two + %tr + %td + TD One + %td + TD Two + .span-8.last + %pre + \<pre> + pre space1 + pre space1 + pre space2 + pre space2 + pre tab + pre tab + %code + \<code> + Not indented + indent1 + indent1 + indent2 + indent3 + %tt + \<tt> + This tt text should be monospaced + and + wrap as if + one line of text + even though the code has newlines, spaces, and tabs. + It should be the same size as <p> text. + %hr + %p + %a{ :href => "http://validator.w3.org/check?uri=referer" } + %img.top{ :src => "valid.png", :height => "31", :alt => "Valid HTML 4.01 Strict", :width => "88" } diff --git a/vendor/gems/gems/compass-0.8.17/examples/blueprint_default/parts/forms.html.haml b/vendor/gems/gems/compass-0.8.17/examples/blueprint_default/parts/forms.html.haml new file mode 100755 index 00000000..647b5f52 --- /dev/null +++ b/vendor/gems/gems/compass-0.8.17/examples/blueprint_default/parts/forms.html.haml @@ -0,0 +1,190 @@ +!!! +%html{ :lang => "en" } + %head + %meta{ :content => "text/html; charset=utf-8", "http-equiv" => "Content-Type" } + %title + Blueprint Forms Tests + / + Framework CSS + %link{ :href => "../stylesheets/screen.css", :rel => "stylesheet", :media => "screen, projection", :type => "text/css" } + %link{ :href => "../stylesheets/print.css", :rel => "stylesheet", :media => "print", :type => "text/css" } + / + [if lt IE 8]> "", :method => "post" } + %fieldset + %legend + Simple sample form + %p + %label{ :for => "dummy0" } + Text input (title) + %br + %input#dummy0.title{ :name => "dummy0", :type => "text", :value => "Field with class .title" } + %p + %label{ :for => "dummy1" } + Another field + %br + %input#dummy1.text{ :name => "dummy1", :type => "text", :value => "Field with class .text" } + %p + %label{ :for => "dummy2" } + Textarea + %br + %textarea#dummy2{ :name => "dummy2", :rows => "5", :cols => "20" } + %p + %input{ :type => "submit", :value => "Submit" } + %input{ :type => "reset", :value => "Reset" } + .span-12.last + .error + This is a <div> with the class + %strong + \.error + \. + %a{ :href => "#" } + Link + \. + .notice + This is a <div> with the class + %strong + \.notice + \. + %a{ :href => "#" } + Link + \. + .success + This is a <div> with the class + %strong + \.success + \. + %a{ :href => "#" } + Link + \. + %fieldset + %legend + Select, checkboxes, lists + %p + %label{ :for => "dummy3" } + Select field + %br + %select#dummy3{ :name => "dummy3" } + %option{ :value => "1" } + Ottawa + %option{ :value => "2" } + Calgary + %option{ :value => "3" } + Moosejaw + %p + %label{ :for => "dummy4" } + Select with groups + %br + %select#dummy4{ :name => "dummy4" } + %option + Favorite pet + %optgroup{ :label => "mammals" } + %option + dog + %option + cat + %option + rabbit + %option + horse + %optgroup{ :label => "reptiles" } + %option + iguana + %option + snake + %p + %label + Radio buttons + %br + %input{ :name => "example", :type => "radio" } + Radio one + %br + %input{ :name => "example", :type => "radio" } + Radio two + %br + %input{ :name => "example", :type => "radio" } + Radio three + %br + %p + %label + Checkboxes + %br + %input{ :type => "checkbox" } + Check one + %br + %input{ :type => "checkbox" } + Check two + %br + %input{ :type => "checkbox" } + Check three + %br + .span-24.last + %fieldset + %legend + Alignment + %p + %label{ :for => "dummy5" } + Select field + %select#dummy5{ :name => "dummy5" } + %option{ :value => "1" } + Ottawa + %option{ :value => "2" } + Calgary + %option{ :value => "3" } + Moosejaw + %p + %label{ :for => "dummy6" } + Text input (title) + %input#dummy6.title{ :name => "dummy6", :type => "text", :value => "Field with class .title" } + %p + %label{ :for => "dummy7" } + Select field + %select#dummy7{ :name => "dummy7" } + %option{ :value => "1" } + Ottawa + %option{ :value => "2" } + Calgary + %option{ :value => "3" } + Moosejaw + %label{ :for => "dummy8" } + Another field + %input#dummy8.text{ :name => "dummy8", :type => "text", :value => "Field with class .text" } + .span-24.last + %form.inline{ :action => "", :method => "post" } + %fieldset + %legend + A form with class "inline" + .span-3 + %label{ :for => "a" } + Label A: + %select#a{ :name => "a" } + %option{ :value => "0" } + All + .span-2 + some text + .span-3 + %input#o.checkbox{ :type => "checkbox", :name => "o", :value => "true", :checked => "checked" } + checkbox one + .span-3 + %label{ :for => "b" } + Label B: + %select#b{ :name => "b" } + %option{ :value => "0" } + All + .span-2 + %a{ :href => "" } + A Hyperlink + .span-8 + %input#q.text{ :type => "text", :name => "q", :value => "Field with class .text" } + .span-2.last + %input.button{ :type => "submit", :value => "submit" } + %hr + %p + %a{ :href => "http://validator.w3.org/check?uri=referer" } + %img.top{ :src => "valid.png", :height => "31", :alt => "Valid HTML 4.01 Strict", :width => "88" } diff --git a/vendor/gems/gems/compass-0.8.17/examples/blueprint_default/parts/grid.html.haml b/vendor/gems/gems/compass-0.8.17/examples/blueprint_default/parts/grid.html.haml new file mode 100755 index 00000000..1e2f5f13 --- /dev/null +++ b/vendor/gems/gems/compass-0.8.17/examples/blueprint_default/parts/grid.html.haml @@ -0,0 +1,274 @@ +!!! +%html{ :lang => "en" } + %head + %meta{ :content => "text/html; charset=utf-8", "http-equiv" => "Content-Type" } + %title + Blueprint Grid Tests + / + Framework CSS + %link{ :href => "../stylesheets/screen.css", :rel => "stylesheet", :media => "screen, projection", :type => "text/css" } + %link{ :href => "../stylesheets/print.css", :rel => "stylesheet", :media => "print", :type => "text/css" } + / + [if IE]> "test-small.jpg" } + .span-10.last + %p + Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. + .span-2 + %img.push-2{ :src => "test-small.jpg" } + .span-10.last + %p + Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. + .span-2 + %img.push-3{ :src => "test-small.jpg" } + .span-10.last + %p + Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. + .span-2 + %img.push-4{ :src => "test-small.jpg" } + .span-10.last + %p + Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. + .span-2 + %img.push-5{ :src => "test-small.jpg" } + .span-10.last + %p + Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. + .span-12.last + %h5 + TESTING .PULL-1 TO .PULL-5 + .span-10 + %p + Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. + .span-2.last + %img.top.pull-1{ :src => "test-small.jpg" } + .span-10 + %p + Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. + .span-2.last + %img.top.pull-2{ :src => "test-small.jpg" } + .span-10 + %p + Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. + .span-2.last + %img.top.pull-3{ :src => "test-small.jpg" } + .span-10 + %p + Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. + .span-2.last + %img.top.pull-4{ :src => "test-small.jpg" } + .span-10 + %p + Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. + .span-2.last + %img.top.pull-5{ :src => "test-small.jpg" } + .span-24 + %p + %a{ :href => "http://validator.w3.org/check?uri=referer" } + %img.bottom{ :src => "valid.png", :height => "31", :alt => "Valid HTML 4.01 Strict", :width => "88" } diff --git a/vendor/gems/gems/compass-0.8.17/examples/blueprint_default/parts/test-small.jpg b/vendor/gems/gems/compass-0.8.17/examples/blueprint_default/parts/test-small.jpg new file mode 100755 index 00000000..aa599d99 Binary files /dev/null and b/vendor/gems/gems/compass-0.8.17/examples/blueprint_default/parts/test-small.jpg differ diff --git a/vendor/gems/gems/compass-0.8.17/examples/blueprint_default/parts/test.jpg b/vendor/gems/gems/compass-0.8.17/examples/blueprint_default/parts/test.jpg new file mode 100755 index 00000000..0107be27 Binary files /dev/null and b/vendor/gems/gems/compass-0.8.17/examples/blueprint_default/parts/test.jpg differ diff --git a/vendor/gems/gems/compass-0.8.17/examples/blueprint_default/parts/valid.png b/vendor/gems/gems/compass-0.8.17/examples/blueprint_default/parts/valid.png new file mode 100755 index 00000000..dd20e497 Binary files /dev/null and b/vendor/gems/gems/compass-0.8.17/examples/blueprint_default/parts/valid.png differ diff --git a/vendor/gems/gems/compass-0.8.17/examples/blueprint_default/src/ie.sass b/vendor/gems/gems/compass-0.8.17/examples/blueprint_default/src/ie.sass new file mode 100755 index 00000000..7af9162b --- /dev/null +++ b/vendor/gems/gems/compass-0.8.17/examples/blueprint_default/src/ie.sass @@ -0,0 +1,3 @@ +@import blueprint.sass + ++blueprint-ie \ No newline at end of file diff --git a/vendor/gems/gems/compass-0.8.17/examples/blueprint_default/src/images/grid.png b/vendor/gems/gems/compass-0.8.17/examples/blueprint_default/src/images/grid.png new file mode 100755 index 00000000..129d4a29 Binary files /dev/null and b/vendor/gems/gems/compass-0.8.17/examples/blueprint_default/src/images/grid.png differ diff --git a/vendor/gems/gems/compass-0.8.17/examples/blueprint_default/src/print.sass b/vendor/gems/gems/compass-0.8.17/examples/blueprint_default/src/print.sass new file mode 100755 index 00000000..8e5d49d8 --- /dev/null +++ b/vendor/gems/gems/compass-0.8.17/examples/blueprint_default/src/print.sass @@ -0,0 +1,3 @@ +@import blueprint.sass + ++blueprint-print \ No newline at end of file diff --git a/vendor/gems/gems/compass-0.8.17/examples/blueprint_default/src/screen.sass b/vendor/gems/gems/compass-0.8.17/examples/blueprint_default/src/screen.sass new file mode 100755 index 00000000..0ca30638 --- /dev/null +++ b/vendor/gems/gems/compass-0.8.17/examples/blueprint_default/src/screen.sass @@ -0,0 +1,8 @@ +@import blueprint.sass +@import blueprint/modules/scaffolding.sass +@import compass/reset.sass + ++blueprint +// Remove the scaffolding when you're ready to start doing visual design. +// Or leave it in if you're happy with how blueprint looks out-of-the-box ++blueprint-scaffolding diff --git a/vendor/gems/gems/compass-0.8.17/examples/blueprint_plugins/config.rb b/vendor/gems/gems/compass-0.8.17/examples/blueprint_plugins/config.rb new file mode 100755 index 00000000..16f4235d --- /dev/null +++ b/vendor/gems/gems/compass-0.8.17/examples/blueprint_plugins/config.rb @@ -0,0 +1,8 @@ +# Require any additional compass plugins here. +project_type = :stand_alone +css_dir = "stylesheets" +sass_dir = "src" +images_dir = "images" +output_style = :compact +relative_assets = true + diff --git a/vendor/gems/gems/compass-0.8.17/examples/blueprint_plugins/images/buttons/cross.png b/vendor/gems/gems/compass-0.8.17/examples/blueprint_plugins/images/buttons/cross.png new file mode 100755 index 00000000..1514d51a Binary files /dev/null and b/vendor/gems/gems/compass-0.8.17/examples/blueprint_plugins/images/buttons/cross.png differ diff --git a/vendor/gems/gems/compass-0.8.17/examples/blueprint_plugins/images/buttons/key.png b/vendor/gems/gems/compass-0.8.17/examples/blueprint_plugins/images/buttons/key.png new file mode 100755 index 00000000..a9d5e4f8 Binary files /dev/null and b/vendor/gems/gems/compass-0.8.17/examples/blueprint_plugins/images/buttons/key.png differ diff --git a/vendor/gems/gems/compass-0.8.17/examples/blueprint_plugins/images/buttons/tick.png b/vendor/gems/gems/compass-0.8.17/examples/blueprint_plugins/images/buttons/tick.png new file mode 100755 index 00000000..a9925a06 Binary files /dev/null and b/vendor/gems/gems/compass-0.8.17/examples/blueprint_plugins/images/buttons/tick.png differ diff --git a/vendor/gems/gems/compass-0.8.17/examples/blueprint_plugins/images/grid.png b/vendor/gems/gems/compass-0.8.17/examples/blueprint_plugins/images/grid.png new file mode 100755 index 00000000..129d4a29 Binary files /dev/null and b/vendor/gems/gems/compass-0.8.17/examples/blueprint_plugins/images/grid.png differ diff --git a/vendor/gems/gems/compass-0.8.17/examples/blueprint_plugins/images/link_icons/doc.png b/vendor/gems/gems/compass-0.8.17/examples/blueprint_plugins/images/link_icons/doc.png new file mode 100755 index 00000000..834cdfaf Binary files /dev/null and b/vendor/gems/gems/compass-0.8.17/examples/blueprint_plugins/images/link_icons/doc.png differ diff --git a/vendor/gems/gems/compass-0.8.17/examples/blueprint_plugins/images/link_icons/email.png b/vendor/gems/gems/compass-0.8.17/examples/blueprint_plugins/images/link_icons/email.png new file mode 100755 index 00000000..7348aed7 Binary files /dev/null and b/vendor/gems/gems/compass-0.8.17/examples/blueprint_plugins/images/link_icons/email.png differ diff --git a/vendor/gems/gems/compass-0.8.17/examples/blueprint_plugins/images/link_icons/external.png b/vendor/gems/gems/compass-0.8.17/examples/blueprint_plugins/images/link_icons/external.png new file mode 100755 index 00000000..cf1cfb42 Binary files /dev/null and b/vendor/gems/gems/compass-0.8.17/examples/blueprint_plugins/images/link_icons/external.png differ diff --git a/vendor/gems/gems/compass-0.8.17/examples/blueprint_plugins/images/link_icons/feed.png b/vendor/gems/gems/compass-0.8.17/examples/blueprint_plugins/images/link_icons/feed.png new file mode 100755 index 00000000..315c4f4f Binary files /dev/null and b/vendor/gems/gems/compass-0.8.17/examples/blueprint_plugins/images/link_icons/feed.png differ diff --git a/vendor/gems/gems/compass-0.8.17/examples/blueprint_plugins/images/link_icons/im.png b/vendor/gems/gems/compass-0.8.17/examples/blueprint_plugins/images/link_icons/im.png new file mode 100755 index 00000000..79f35ccb Binary files /dev/null and b/vendor/gems/gems/compass-0.8.17/examples/blueprint_plugins/images/link_icons/im.png differ diff --git a/vendor/gems/gems/compass-0.8.17/examples/blueprint_plugins/images/link_icons/pdf.png b/vendor/gems/gems/compass-0.8.17/examples/blueprint_plugins/images/link_icons/pdf.png new file mode 100755 index 00000000..8f8095e4 Binary files /dev/null and b/vendor/gems/gems/compass-0.8.17/examples/blueprint_plugins/images/link_icons/pdf.png differ diff --git a/vendor/gems/gems/compass-0.8.17/examples/blueprint_plugins/images/link_icons/visited.png b/vendor/gems/gems/compass-0.8.17/examples/blueprint_plugins/images/link_icons/visited.png new file mode 100755 index 00000000..ebf206de Binary files /dev/null and b/vendor/gems/gems/compass-0.8.17/examples/blueprint_plugins/images/link_icons/visited.png differ diff --git a/vendor/gems/gems/compass-0.8.17/examples/blueprint_plugins/images/link_icons/xls.png b/vendor/gems/gems/compass-0.8.17/examples/blueprint_plugins/images/link_icons/xls.png new file mode 100755 index 00000000..b977d7e5 Binary files /dev/null and b/vendor/gems/gems/compass-0.8.17/examples/blueprint_plugins/images/link_icons/xls.png differ diff --git a/vendor/gems/gems/compass-0.8.17/examples/blueprint_plugins/images/test-small.jpg b/vendor/gems/gems/compass-0.8.17/examples/blueprint_plugins/images/test-small.jpg new file mode 100755 index 00000000..aa599d99 Binary files /dev/null and b/vendor/gems/gems/compass-0.8.17/examples/blueprint_plugins/images/test-small.jpg differ diff --git a/vendor/gems/gems/compass-0.8.17/examples/blueprint_plugins/images/test.jpg b/vendor/gems/gems/compass-0.8.17/examples/blueprint_plugins/images/test.jpg new file mode 100755 index 00000000..0107be27 Binary files /dev/null and b/vendor/gems/gems/compass-0.8.17/examples/blueprint_plugins/images/test.jpg differ diff --git a/vendor/gems/gems/compass-0.8.17/examples/blueprint_plugins/images/valid.png b/vendor/gems/gems/compass-0.8.17/examples/blueprint_plugins/images/valid.png new file mode 100755 index 00000000..dd20e497 Binary files /dev/null and b/vendor/gems/gems/compass-0.8.17/examples/blueprint_plugins/images/valid.png differ diff --git a/vendor/gems/gems/compass-0.8.17/examples/blueprint_plugins/index.html.haml b/vendor/gems/gems/compass-0.8.17/examples/blueprint_plugins/index.html.haml new file mode 100755 index 00000000..2cdb7ba6 --- /dev/null +++ b/vendor/gems/gems/compass-0.8.17/examples/blueprint_plugins/index.html.haml @@ -0,0 +1,96 @@ +!!! +%html{ :lang => "en" } + %head + %meta{ :content => "text/html; charset=utf-8", "http-equiv" => "Content-Type" } + %title + Blueprint test pages + / + Framework CSS + %link{ :href => "stylesheets/screen.css", :rel => "stylesheet", :media => "screen, projection", :type => "text/css" } + %link{ :href => "stylesheets/print.css", :rel => "stylesheet", :media => "print", :type => "text/css" } + / + [if IE]> "0", :border => "0", :cellpadding => "0" } + %tr + %th.span-6 + Test page + %th.span-8 + Main files tested + %th.span-10 + Description + %tr + %td + %a{ :href => "plugins/fancy_type.html" } + Fancy Type + %td + %a{ :href => "http://github.com/chriseppstein/compass/blob/master/frameworks/blueprint/stylesheets/blueprint/modules/_grid.sass" } + grid.sass + , + %a{ :href => "http://github.com/chriseppstein/compass/blob/master/frameworks/blueprint/stylesheets/blueprint/modules/_typography.sass" } + typography.sass + , + %a{ :href => "http://github.com/chriseppstein/compass/blob/master/frameworks/blueprint/stylesheets/blueprint/modules/_fancy_type.sass" } + fancy_type.sass + %td + A simple sample page, with common elements and fancy type. + %tr + %td + %a{ :href => "plugins/buttons.html" } + Buttons + %td + %a{ :href => "http://github.com/chriseppstein/compass/blob/master/frameworks/blueprint/stylesheets/blueprint/modules/_buttons.sass" } + buttons.sass + %td + A simple page, showing links and buttons styled using the button plugin. + %tr + %td + %a{ :href => "plugins/link_icons.html" } + Link Icons + %td + %a{ :href => "http://github.com/chriseppstein/compass/blob/master/frameworks/blueprint/stylesheets/blueprint/modules/_link_icons.sass" } + link_icons.sass + %td + A simple page, showing links icons. + %tr + %td + %a{ :href => "plugins/rtl.html" } + RTL + %td + %a{ :href => "http://github.com/chriseppstein/compass/blob/master/frameworks/blueprint/stylesheets/blueprint/modules/_rtl.sass" } + rtl.sass + %td + A simple page, showing a right-to-left grid layout. + %p + %em + %strong + Note about the css files: + These test files utilize the css files that are generated from + %a{ :href => "http://haml.hamptoncatlin.com/docs/rdoc/classes/Sass.html" } + Sass templates + \. + In other words, if you change any of the source files, + you'll have to re-build them with + %code + rake examples + to see any changes. + .box + %p + For more information and help, try these resources: + %ul.bottom + %li + %a{ :href => "http://www.blueprintcss.org/" } + The Blueprint home page. + %li + %a{ :href => "http://groups.google.com/group/blueprintcss" } + Our anything-goes mailing list. + %p + %a{ :href => "http://validator.w3.org/check?uri=referer" } + %img.top{ :src => "images/valid.png", :height => "31", :alt => "Valid HTML 4.01 Strict", :width => "88" } diff --git a/vendor/gems/gems/compass-0.8.17/examples/blueprint_plugins/plugins/buttons.html.haml b/vendor/gems/gems/compass-0.8.17/examples/blueprint_plugins/plugins/buttons.html.haml new file mode 100755 index 00000000..331d378d --- /dev/null +++ b/vendor/gems/gems/compass-0.8.17/examples/blueprint_plugins/plugins/buttons.html.haml @@ -0,0 +1,67 @@ +!!! +%html{ :lang => "en" } + %head + %meta{ :content => "text/html; charset=utf-8", "http-equiv" => "Content-Type" } + %title + Blueprint Buttons Sample Page + / + Framework CSS + %link{ :href => "../stylesheets/screen.css", :rel => "stylesheet", :media => "screen, projection", :type => "text/css" } + %link{ :href => "../stylesheets/print.css", :rel => "stylesheet", :media => "print", :type => "text/css" } + / + [if IE]> "../stylesheets/buttons.css", :rel => "stylesheet", :media => "screen, projection", :type => "text/css" } + %body + .container + %h1 + A Button Example Page + %hr + %h2.alt + This sample page demonstrates what you can do with the Buttons plugin. + %hr + .span-12 + %h3 + Link Buttons + %a.button + Link Button + %a.button.positive + Positive Button + %a.button.negative + Negative Button + .span-12.last + %h3 + Real Buttons + %button + Normal Button + %button.positive + Positive Button + %button.negative + Negative Button + .span-12 + %h3 + Link Buttons with Images + %a.button + %img{ :src => "../images/buttons/tick.png", :alt => "" } + Save + %a.button.positive + %img{ :src => "../images/buttons/key.png", :alt => "" } + Change Password + %a.button.negative + %img{ :src => "../images/buttons/cross.png", :alt => "" } + Cancel + .span-12.last + %h3 + Real Buttons with Images + %button + %img{ :src => "../images/buttons/tick.png", :alt => "" } + Save + %button.positive + %img{ :src => "../images/buttons/key.png", :alt => "" } + Change Password + %button.negative + %img{ :src => "../images/buttons/cross.png", :alt => "" } + Cancel + .span-24 + %p + %a{ :href => "http://validator.w3.org/check?uri=referer" } + %img.top{ :src => "valid.png", :height => "31", :alt => "Valid HTML 4.01 Strict", :width => "88" } diff --git a/vendor/gems/gems/compass-0.8.17/examples/blueprint_plugins/plugins/fancy_type.html.haml b/vendor/gems/gems/compass-0.8.17/examples/blueprint_plugins/plugins/fancy_type.html.haml new file mode 100755 index 00000000..b17c1c28 --- /dev/null +++ b/vendor/gems/gems/compass-0.8.17/examples/blueprint_plugins/plugins/fancy_type.html.haml @@ -0,0 +1,100 @@ +!!! +%html{ :lang => "en" } + %head + %meta{ :content => "text/html; charset=utf-8", "http-equiv" => "Content-Type" } + %title + Blueprint Sample Page + / + Framework CSS + %link{ :href => "../stylesheets/screen.css", :rel => "stylesheet", :media => "screen, projection", :type => "text/css" } + %link{ :href => "../stylesheets/print.css", :rel => "stylesheet", :media => "print", :type => "text/css" } + / + [if IE]> "../images/test.jpg", :alt => "test" } + Lorem ipsum dolor sit amet, + %em + consectetuer adipiscing elit + \. Nunc congue ipsum vestibulum libero. Aenean vitae justo. Nam eget tellus. Etiam convallis, est eu lobortis mattis, lectus tellus tempus felis, a ultricies erat ipsum at metus. + %p + Lorem ipsum dolor sit amet, consectetuer adipiscing elit. + %a{ :href => "#" } + Morbi et risus + \. Aliquam nisl. Nulla facilisi. Cras accumsan vestibulum ante. Vestibulum sed tortor. Praesent + %span.caps + SMALL CAPS + tempus fringilla elit. Ut elit diam, sagittis in, nonummy in, gravida non, nunc. Ut orci. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos hymenaeos. Nam egestas, orci eu imperdiet malesuada, nisl purus fringilla odio, quis commodo est orci vitae justo. Aliquam placerat odio tincidunt nulla. Cras in libero. Aenean rutrum, magna non tristique posuere, erat odio eleifend nisl, non convallis est tortor blandit ligula. Nulla id augue. + %p + Nullam mattis, odio ut tempus facilisis, metus nisl facilisis metus, auctor consectetuer felis ligula nec mauris. Vestibulum odio erat, fermentum at, commodo vitae, ultrices et, urna. Mauris vulputate, mi pulvinar sagittis condimentum, sem nulla aliquam velit, sed imperdiet mi purus eu magna. Nulla varius metus ut eros. Aenean aliquet magna eget orci. Class aptent taciti sociosqu ad litora. + %p + Vivamus euismod. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Suspendisse vel nibh ut turpis dictum sagittis. Aliquam vel velit a elit auctor sollicitudin. Nam vel dui vel neque lacinia pretium. Quisque nunc erat, venenatis id, volutpat ut, scelerisque sed, diam. Mauris ante. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Donec mattis. Morbi dignissim sollicitudin libero. Nulla lorem. + %blockquote + %p + Integer cursus ornare mauris. Praesent nisl arcu, imperdiet eu, ornare id, scelerisque ut, nunc. Praesent sagittis erat sed velit tempus imperdiet. Ut tristique, ante in interdum hendrerit, erat enim faucibus felis, quis rutrum mauris lorem quis sem. Vestibulum ligula nisi, mattis nec, posuere et, blandit eu, ligula. Nam suscipit placerat odio. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos hymenaeos. Pellentesque tortor libero, venenatis vitae, rhoncus eu, placerat ut, mi. Nulla nulla. + %p + Maecenas vel metus quis magna pharetra fermentum. + %em + Integer sit amet tortor + \. Maecenas porttitor, pede sed gravida auctor, nulla augue aliquet elit, at pretium urna orci ut metus. Aliquam in dolor. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Sed aliquam, tellus id ornare posuere, quam nunc accumsan turpis, at convallis tellus orci et nisl. Phasellus congue neque a lorem. + %hr + .span-7.colborder + %h6 + This is a nested column + %p + Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. + .span-7.last + %h6 + This is another nested column + %p + Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. + .span-7.last + %h3 + A + %span.alt + Simple + Sidebar + %p + Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Cras ornare mattis nunc. Mauris venenatis, pede sed aliquet vehicula, lectus tellus pulvinar neque, non cursus sem nisi vel augue. + %p + Mauris a lectus. Aliquam erat volutpat. Phasellus ultrices mi a sapien. Nunc rutrum egestas lorem. Duis ac sem sagittis elit tincidunt gravida. Mauris a lectus. Aliquam erat volutpat. Phasellus ultrices mi a sapien. Nunc rutrum egestas lorem. Duis ac sem sagittis elit tincidunt gravida. + %p.quiet + Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Cras ornare mattis nunc. Mauris venenatis, pede sed aliquet vehicula, lectus tellus pulvinar neque, non cursus sem nisi vel augue. + %h5 + Incremental leading + %p.incr + Vestibulum ante ipsum primis in faucibus orci luctus vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Cras ornare mattis nunc. Mauris venenatis, pede sed aliquet vehicula, lectus tellus pulvinar neque, non cursus sem nisi vel augue. sed aliquet vehicula, lectus tellus. + %p.incr + Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Cras ornare mattis nunc. Mauris venenatis, pede sed aliquet vehicula, lectus tellus pulvinar neque, non cursus sem nisi vel augue. sed aliquet vehicula, lectus tellus pulvinar neque, non cursus sem nisi vel augue. ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Cras ornare mattis nunc. Mauris venenatis, pede sed aliquet vehicula, lectus tellus pulvinar neque, non cursus sem nisi vel augue. sed aliquet vehicula, lectus tellus pulvinar neque, non cursus sem nisi vel augue. + %hr + %h2.alt + You may pick and choose amongst these and many more features, so be bold. + %hr + %p + %a{ :href => "http://validator.w3.org/check?uri=referer" } + %img.top{ :src => "valid.png", :height => "31", :alt => "Valid HTML 4.01 Strict", :width => "88" } diff --git a/vendor/gems/gems/compass-0.8.17/examples/blueprint_plugins/plugins/link_icons.html.haml b/vendor/gems/gems/compass-0.8.17/examples/blueprint_plugins/plugins/link_icons.html.haml new file mode 100755 index 00000000..13e93f2f --- /dev/null +++ b/vendor/gems/gems/compass-0.8.17/examples/blueprint_plugins/plugins/link_icons.html.haml @@ -0,0 +1,61 @@ +!!! +%html{ :lang => "en" } + %head + %meta{ :content => "text/html; charset=utf-8", "http-equiv" => "Content-Type" } + %title + Blueprint Link Icons Sample Page + / + Framework CSS + %link{ :href => "../stylesheets/screen.css", :rel => "stylesheet", :media => "screen, projection", :type => "text/css" } + %link{ :href => "../stylesheets/print.css", :rel => "stylesheet", :media => "print", :type => "text/css" } + / + [if IE]> "../stylesheets/link_icons.css", :rel => "stylesheet", :media => "screen, projection", :type => "text/css" } + %body + .container + %h1 + A Link Icons Example Page + %hr + %h2.alt + This sample page demonstrates what you can do with the Link Icons plugin. + %hr + .span-12 + %h3 + External Links + %a{ :href => "http://www.no-such-website.com/" } + A Normal External Link + %a{ :href => "http://www.google.com" } + A Visited External Link + %a{ :href => "mailto:donald@duck.com" } + An Email Link + .span-12.last + %h3 + Document Links + %a{ :href => "http://www.no-such-website.com/sample.pdf" } + A .pdf Link + %a{ :href => "http://www.no-such-website.com/sample.doc" } + A .doc Link + %a{ :href => "http://www.no-such-website.com/sample.xls" } + A .xls Link + .span-12 + %h3 + Misc Links + %a{ :href => "http://www.no-such-website.com/sample.rss" } + An RSS Link + %a{ :href => "http://www.no-such-website.com/sample.rdf" } + An Atom Link + %a{ :href => "aim:chatmeup" } + A Instant Messenger Link + .span-12.last + %h3 + Turning Icons Off + %a.noicon{ :href => "http://www.no-such-website.com/" } + A Normal External Link + %a.noicon{ :href => "http://www.google.com" } + A Visited External Link + %a.noicon{ :href => "mailto:donald@duck.com" } + An Email Link + .span-24 + %p + %a.noicon{ :href => "http://validator.w3.org/check?uri=referer" } + %img.top{ :src => "valid.png", :height => "31", :alt => "Valid HTML 4.01 Strict", :width => "88" } diff --git a/vendor/gems/gems/compass-0.8.17/examples/blueprint_plugins/plugins/rtl.html.haml b/vendor/gems/gems/compass-0.8.17/examples/blueprint_plugins/plugins/rtl.html.haml new file mode 100755 index 00000000..58758202 --- /dev/null +++ b/vendor/gems/gems/compass-0.8.17/examples/blueprint_plugins/plugins/rtl.html.haml @@ -0,0 +1,100 @@ +!!! +%html{ :lang => "en" } + %head + %meta{ :content => "text/html; charset=utf-8", "http-equiv" => "Content-Type" } + %title + Blueprint Sample Page + / + Framework CSS + %link{ :href => "../stylesheets/rtl_screen.css", :rel => "stylesheet", :media => "screen, projection", :type => "text/css" } + %link{ :href => "../stylesheets/print.css", :rel => "stylesheet", :media => "print", :type => "text/css" } + / + [if IE]> "../images/test.jpg", :alt => "test" } + Lorem ipsum dolor sit amet, + %em + consectetuer adipiscing elit + \. Nunc congue ipsum vestibulum libero. Aenean vitae justo. Nam eget tellus. Etiam convallis, est eu lobortis mattis, lectus tellus tempus felis, a ultricies erat ipsum at metus. + %p + Lorem ipsum dolor sit amet, consectetuer adipiscing elit. + %a{ :href => "#" } + Morbi et risus + \. Aliquam nisl. Nulla facilisi. Cras accumsan vestibulum ante. Vestibulum sed tortor. Praesent + %span.caps + SMALL CAPS + tempus fringilla elit. Ut elit diam, sagittis in, nonummy in, gravida non, nunc. Ut orci. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos hymenaeos. Nam egestas, orci eu imperdiet malesuada, nisl purus fringilla odio, quis commodo est orci vitae justo. Aliquam placerat odio tincidunt nulla. Cras in libero. Aenean rutrum, magna non tristique posuere, erat odio eleifend nisl, non convallis est tortor blandit ligula. Nulla id augue. + %p + Nullam mattis, odio ut tempus facilisis, metus nisl facilisis metus, auctor consectetuer felis ligula nec mauris. Vestibulum odio erat, fermentum at, commodo vitae, ultrices et, urna. Mauris vulputate, mi pulvinar sagittis condimentum, sem nulla aliquam velit, sed imperdiet mi purus eu magna. Nulla varius metus ut eros. Aenean aliquet magna eget orci. Class aptent taciti sociosqu ad litora. + %p + Vivamus euismod. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Suspendisse vel nibh ut turpis dictum sagittis. Aliquam vel velit a elit auctor sollicitudin. Nam vel dui vel neque lacinia pretium. Quisque nunc erat, venenatis id, volutpat ut, scelerisque sed, diam. Mauris ante. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Donec mattis. Morbi dignissim sollicitudin libero. Nulla lorem. + %blockquote + %p + Integer cursus ornare mauris. Praesent nisl arcu, imperdiet eu, ornare id, scelerisque ut, nunc. Praesent sagittis erat sed velit tempus imperdiet. Ut tristique, ante in interdum hendrerit, erat enim faucibus felis, quis rutrum mauris lorem quis sem. Vestibulum ligula nisi, mattis nec, posuere et, blandit eu, ligula. Nam suscipit placerat odio. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos hymenaeos. Pellentesque tortor libero, venenatis vitae, rhoncus eu, placerat ut, mi. Nulla nulla. + %p + Maecenas vel metus quis magna pharetra fermentum. + %em + Integer sit amet tortor + \. Maecenas porttitor, pede sed gravida auctor, nulla augue aliquet elit, at pretium urna orci ut metus. Aliquam in dolor. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Sed aliquam, tellus id ornare posuere, quam nunc accumsan turpis, at convallis tellus orci et nisl. Phasellus congue neque a lorem. + %hr + .span-7.colborder + %h6 + This is a nested column + %p + Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. + .span-7.last + %h6 + This is another nested column + %p + Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. + .span-7.last + %h3 + A + %span.alt + Simple + Sidebar + %p + Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Cras ornare mattis nunc. Mauris venenatis, pede sed aliquet vehicula, lectus tellus pulvinar neque, non cursus sem nisi vel augue. + %p + Mauris a lectus. Aliquam erat volutpat. Phasellus ultrices mi a sapien. Nunc rutrum egestas lorem. Duis ac sem sagittis elit tincidunt gravida. Mauris a lectus. Aliquam erat volutpat. Phasellus ultrices mi a sapien. Nunc rutrum egestas lorem. Duis ac sem sagittis elit tincidunt gravida. + %p.quiet + Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Cras ornare mattis nunc. Mauris venenatis, pede sed aliquet vehicula, lectus tellus pulvinar neque, non cursus sem nisi vel augue. + %h5 + Incremental leading + %p.incr + Vestibulum ante ipsum primis in faucibus orci luctus vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Cras ornare mattis nunc. Mauris venenatis, pede sed aliquet vehicula, lectus tellus pulvinar neque, non cursus sem nisi vel augue. sed aliquet vehicula, lectus tellus. + %p.incr + Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Cras ornare mattis nunc. Mauris venenatis, pede sed aliquet vehicula, lectus tellus pulvinar neque, non cursus sem nisi vel augue. sed aliquet vehicula, lectus tellus pulvinar neque, non cursus sem nisi vel augue. ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Cras ornare mattis nunc. Mauris venenatis, pede sed aliquet vehicula, lectus tellus pulvinar neque, non cursus sem nisi vel augue. sed aliquet vehicula, lectus tellus pulvinar neque, non cursus sem nisi vel augue. + %hr + %h2.alt + You may pick and choose amongst these and many more features, so be bold. + %hr + %p + %a{ :href => "http://validator.w3.org/check?uri=referer" } + %img.top{ :src => "valid.png", :height => "31", :alt => "Valid HTML 4.01 Strict", :width => "88" } diff --git a/vendor/gems/gems/compass-0.8.17/examples/blueprint_plugins/src/buttons.sass b/vendor/gems/gems/compass-0.8.17/examples/blueprint_plugins/src/buttons.sass new file mode 100755 index 00000000..e8ca96e6 --- /dev/null +++ b/vendor/gems/gems/compass-0.8.17/examples/blueprint_plugins/src/buttons.sass @@ -0,0 +1,49 @@ +@import compass/utilities/general/float.sass +@import blueprint/modules/buttons.sass + +// + Use the following HTML code to place the buttons on your site: + + + +
+ Change Password + + + + Cancel + + +a.button + // you can pass "left" or "right" to +anchor-button to float it in that direction + // or you can pass no argument to leave it inline-block (cross browser safe!) within + // the flow of your page. + +anchor-button("left") + // All the button color mixins take 4 optional arguments: + // font color, background color, border color, border highlight color + // the first three default to constants set in blueprint/modules/buttons.sass + // the last one defaults to a shade lighter than the border color. + +button-colors + +button-hover-colors + +button-active-colors + +button + // The +button-button mixin is just like the +anchor-button mixin, but for + + + Change Password + + + + Cancel + + +a.button + // you can pass "left" or "right" to +anchor-button to float it in that direction + // or you can pass no argument to leave it inline-block (cross browser safe!) within + // the flow of your page. + +anchor-button("left") + // All the button color mixins take 4 optional arguments: + // font color, background color, border color, border highlight color + // the first three default to constants set in blueprint/modules/buttons.sass + // the last one defaults to a shade lighter than the border color. + +button-colors + +button-hover-colors + +button-active-colors + +button + // The +button-button mixin is just like the +anchor-button mixin, but for ".should have_button + end + end + """ + When I run "spec new_model_spec.rb --format specdoc" + Then the stdout should include "1 example, 0 failures" diff --git a/vendor/gems/gems/rspec-1.2.9/features/mock_framework_integration/use_flexmock.feature b/vendor/gems/gems/rspec-1.2.9/features/mock_framework_integration/use_flexmock.feature new file mode 100755 index 00000000..0a204dfc --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/features/mock_framework_integration/use_flexmock.feature @@ -0,0 +1,27 @@ +Feature: mock with flexmock + + As an RSpec user who prefers flexmock + I want to be able to use flexmock without rspec mocks interfering + + Scenario: Mock with flexmock + Given a file named "flexmock_example_spec.rb" with: + """ + Spec::Runner.configure do |config| + config.mock_with :flexmock + end + + describe "plugging in flexmock" do + it "allows flexmock to be used" do + target = Object.new + flexmock(target).should_receive(:foo).once + target.foo + end + + it "does not include rspec mocks" do + Spec.const_defined?(:Mocks).should be_false + end + end + """ + When I run "spec flexmock_example_spec.rb" + Then the exit code should be 0 + And the stdout should include "2 examples, 0 failures" diff --git a/vendor/gems/gems/rspec-1.2.9/features/mock_framework_integration/use_mocha.feature b/vendor/gems/gems/rspec-1.2.9/features/mock_framework_integration/use_mocha.feature new file mode 100755 index 00000000..d53b967c --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/features/mock_framework_integration/use_mocha.feature @@ -0,0 +1,27 @@ +Feature: mock with mocha + + As an RSpec user who prefers mocha + I want to be able to use mocha without rspec mocks interfering + + Scenario: Mock with mocha + Given a file named "mocha_example_spec.rb" with: + """ + Spec::Runner.configure do |config| + config.mock_with :mocha + end + + describe "plugging in mocha" do + it "allows mocha to be used" do + target = Object.new + target.expects(:foo).once + target.foo + end + + it "does not include rspec mocks" do + Spec.const_defined?(:Mocks).should be_false + end + end + """ + When I run "spec mocha_example_spec.rb" + Then the exit code should be 0 + And the stdout should include "2 examples, 0 failures" diff --git a/vendor/gems/gems/rspec-1.2.9/features/mock_framework_integration/use_rr.feature b/vendor/gems/gems/rspec-1.2.9/features/mock_framework_integration/use_rr.feature new file mode 100755 index 00000000..aa30882a --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/features/mock_framework_integration/use_rr.feature @@ -0,0 +1,27 @@ +Feature: mock with rr + + As an RSpec user who prefers rr + I want to be able to use rr without rspec mocks interfering + + Scenario: Mock with rr + Given a file named "rr_example_spec.rb" with: + """ + Spec::Runner.configure do |config| + config.mock_with :rr + end + + describe "plugging in rr" do + it "allows rr to be used" do + target = Object.new + mock(target).foo + target.foo + end + + it "does not include rspec mocks" do + Spec.const_defined?(:Mocks).should be_false + end + end + """ + When I run "spec rr_example_spec.rb" + Then the exit code should be 0 + And the stdout should include "2 examples, 0 failures" diff --git a/vendor/gems/gems/rspec-1.2.9/features/mocks/mix_stubs_and_mocks.feature b/vendor/gems/gems/rspec-1.2.9/features/mocks/mix_stubs_and_mocks.feature new file mode 100755 index 00000000..deaf84ec --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/features/mocks/mix_stubs_and_mocks.feature @@ -0,0 +1,22 @@ +Feature: stub and mock together + + As an RSpec user + I want to use stubs and mocks together + + Scenario: stub in before + Given a file named "stub_and_mocks_spec.rb" with: + """ + describe "a stub in before" do + before(:each) do + @messenger = mock('messenger').as_null_object + end + + it "a" do + @messenger.should_receive(:foo).with('first') + @messenger.foo('second') + @messenger.foo('third') + end + end + """ + When I run "spec stub_and_mocks_spec.rb --format nested" + Then the stdout should include "received :foo with unexpected arguments\n expected: (\"first\")\n got: ([\"second\"], [\"third\"])" diff --git a/vendor/gems/gems/rspec-1.2.9/features/mocks/stub_implementation.feature b/vendor/gems/gems/rspec-1.2.9/features/mocks/stub_implementation.feature new file mode 100755 index 00000000..269de474 --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/features/mocks/stub_implementation.feature @@ -0,0 +1,26 @@ +Feature: stub implementation + + As an rspec user, I want to stub a complete implementation, not just a + return value. + + Scenario: stub implementation + Given a file named "stub_implementation.rb" with: + """ + describe "a stubbed implementation" do + it "works" do + object = Object.new + object.stub(:foo) do |arg| + if arg == :this + "got this" + elsif arg == :that + "got that" + end + end + + object.foo(:this).should == "got this" + object.foo(:that).should == "got that" + end + end + """ + When I run "spec stub_implementation.rb" + Then the stdout should include "1 example, 0 failures" diff --git a/vendor/gems/gems/rspec-1.2.9/features/pending/pending_examples.feature b/vendor/gems/gems/rspec-1.2.9/features/pending/pending_examples.feature new file mode 100755 index 00000000..58273956 --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/features/pending/pending_examples.feature @@ -0,0 +1,81 @@ +Feature: pending examples + + RSpec offers three ways to indicate that an example is disabled pending + some action. + + Scenario: pending implementation + Given a file named "example_without_block_spec.rb" with: + """ + describe "an example" do + it "has not yet been implemented" + end + """ + When I run "spec example_without_block_spec.rb" + Then the exit code should be 0 + And the stdout should include "1 example, 0 failures, 1 pending" + And the stdout should include "Not Yet Implemented" + And the stdout should include "example_without_block_spec.rb:2" + + Scenario: pending implementation with spec/test/unit + Given a file named "example_without_block_spec.rb" with: + """ + require 'spec/test/unit' + describe "an example" do + it "has not yet been implemented" + end + """ + When I run "spec example_without_block_spec.rb" + Then the exit code should be 0 + And the stdout should include "1 example, 0 failures, 1 pending" + And the stdout should include "Not Yet Implemented" + And the stdout should include "example_without_block_spec.rb:3" + + Scenario: pending any arbitary reason, with no block + Given a file named "pending_without_block_spec.rb" with: + """ + describe "an example" do + it "is implemented but waiting" do + pending("something else getting finished") + end + end + """ + When I run "spec pending_without_block_spec.rb" + Then the exit code should be 0 + And the stdout should include "1 example, 0 failures, 1 pending" + And the stdout should include "(something else getting finished)" + And the stdout should include "pending_without_block_spec.rb:2" + + Scenario: pending any arbitary reason, with a block that fails + Given a file named "pending_with_failing_block_spec.rb" with: + """ + describe "an example" do + it "is implemented but waiting" do + pending("something else getting finished") do + raise "this is the failure" + end + end + end + """ + When I run "spec pending_with_failing_block_spec.rb" + Then the exit code should be 0 + And the stdout should include "1 example, 0 failures, 1 pending" + And the stdout should include "(something else getting finished)" + And the stdout should include "pending_with_failing_block_spec.rb:2" + + Scenario: pending any arbitary reason, with a block that passes + Given a file named "pending_with_passing_block_spec.rb" with: + """ + describe "an example" do + it "is implemented but waiting" do + pending("something else getting finished") do + true.should be(true) + end + end + end + """ + When I run "spec pending_with_passing_block_spec.rb" + Then the exit code should be 256 + And the stdout should include "1 example, 1 failure" + And the stdout should include "FIXED" + And the stdout should include "Expected pending 'something else getting finished' to fail. No Error was raised." + And the stdout should include "pending_with_passing_block_spec.rb:3" diff --git a/vendor/gems/gems/rspec-1.2.9/features/runner/specify_line_number.feature b/vendor/gems/gems/rspec-1.2.9/features/runner/specify_line_number.feature new file mode 100755 index 00000000..bf44f2c0 --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/features/runner/specify_line_number.feature @@ -0,0 +1,32 @@ +Feature: run specific examples by line number + + In order to run a single example from command line + RSpec allows you to specify the line number of the example(s) to run + + Scenario: --line syntax on single example + Given a file named "example_spec.rb" with: + """ + describe "an example" do + it "has not yet been implemented" + it "has been implemented" do + true + end + end + """ + When I run "spec example_spec.rb --line 2" + Then the stdout should include "1 example, 0 failures, 1 pending" + And the stdout should include "example_spec.rb:2" + + Scenario: colon line syntax on single example + Given a file named "example_spec.rb" with: + """ + describe "an example" do + it "has not yet been implemented" + it "has been implemented" do + true + end + end + """ + When I run "spec example_spec.rb:2" + Then the stdout should include "1 example, 0 failures, 1 pending" + And the stdout should include "example_spec.rb:2" diff --git a/vendor/gems/gems/rspec-1.2.9/features/spec_helper/spec_helper.feature b/vendor/gems/gems/rspec-1.2.9/features/spec_helper/spec_helper.feature new file mode 100755 index 00000000..2711e1a5 --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/features/spec_helper/spec_helper.feature @@ -0,0 +1,25 @@ +Feature: spec helper + In order to centralize code needed across most specs + As a spec author + I want to require 'spec_helper' + + Because rspec adds the PROJECT_ROOT/spec directory to the load path, we can + just require 'spec_helper' and it will be found. + + Scenario: spec helper + Given a directory named "spec" + And a file named "spec/spec_helper.rb" with: + """ + SOME_CONSTANT = 'some value' + """ + And a file named "example.rb" with: + """ + require 'spec_helper' + describe SOME_CONSTANT do + it { should == 'some value' } + end + """ + When I run "spec example.rb" + And the stdout should include "1 example, 0 failures" + And the exit code should be 0 + diff --git a/vendor/gems/gems/rspec-1.2.9/features/step_definitions/running_rspec_steps.rb b/vendor/gems/gems/rspec-1.2.9/features/step_definitions/running_rspec_steps.rb new file mode 100755 index 00000000..60f27fa8 --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/features/step_definitions/running_rspec_steps.rb @@ -0,0 +1,43 @@ +Given %r{^a file named "([^"]+)" with:$} do |file_name, code| + create_file(file_name, code) +end + +Given /^a directory named "([^\"]*)"$/ do |dirname| + create_directory(dirname) +end + +When %r{^I run "spec ([^"]+)"$} do |file_and_args| + spec(file_and_args) +end + +When %r{^I run "ruby ([^"]+)"$} do |file_and_args| + ruby(file_and_args) +end + +When %r{^I run "cmdline.rb ([^"]+)"$} do |file_and_args| + cmdline(file_and_args) +end + +Then /^the (.*) should include (.*)$/ do |stream, string_or_regex| + written = case(stream) + when 'stdout' then last_stdout + when 'stderr' then last_stderr + else raise "Unknown stream: #{stream}" + end + written.should smart_match(string_or_regex) +end + +Then /^the (.*) should not match (.*)$/ do |stream, string_or_regex| + written = case(stream) + when 'stdout' then last_stdout + when 'stderr' then last_stderr + else raise "Unknown stream: #{stream}" + end + written.should_not smart_match(string_or_regex) +end + +Then /^the exit code should be (\d+)$/ do |exit_code| + if last_exit_code != exit_code.to_i + raise "Did not exit with #{exit_code}, but with #{last_exit_code}. Standard error:\n#{last_stderr}" + end +end diff --git a/vendor/gems/gems/rspec-1.2.9/features/subject/explicit_subject.feature b/vendor/gems/gems/rspec-1.2.9/features/subject/explicit_subject.feature new file mode 100755 index 00000000..9fb68ad4 --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/features/subject/explicit_subject.feature @@ -0,0 +1,31 @@ +Feature: explicit subject + + You can override the implicit subject using the subject() method. + + Scenario: subject in top level group + Given a file named "top_level_subject_spec.rb" with: + """ + describe Array, "with some elements" do + subject { [1,2,3] } + it "should have the prescribed elements" do + subject.should == [1,2,3] + end + end + """ + When I run "spec top_level_subject_spec.rb" + Then the stdout should include "1 example, 0 failures" + + Scenario: subject in a nested group + Given a file named "nested_subject_spec.rb" with: + """ + describe Array do + subject { [1,2,3] } + describe "with some elements" do + it "should have the prescribed elements" do + subject.should == [1,2,3] + end + end + end + """ + When I run "spec nested_subject_spec.rb" + Then the stdout should include "1 example, 0 failures" diff --git a/vendor/gems/gems/rspec-1.2.9/features/subject/implicit_subject.feature b/vendor/gems/gems/rspec-1.2.9/features/subject/implicit_subject.feature new file mode 100755 index 00000000..bc57d2ba --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/features/subject/implicit_subject.feature @@ -0,0 +1,43 @@ +Feature: implicit subject + + The first argument to the outermost example group block is + made available to each example as an implicit subject of + that example. + + Scenario: subject in top level group + Given a file named "top_level_subject_spec.rb" with: + """ + describe Array, "when first created" do + it "should be empty" do + subject.should == [] + end + end + """ + When I run "spec top_level_subject_spec.rb" + Then the stdout should include "1 example, 0 failures" + + Scenario: subject in a nested group + Given a file named "nested_subject_spec.rb" with: + """ + describe Array do + describe "when first created" do + it "should be empty" do + subject.should == [] + end + end + end + """ + When I run "spec nested_subject_spec.rb" + Then the stdout should include "1 example, 0 failures" + + Scenario: subject with getters + Given a file named "subject_with_getter_spec.rb" with: + """ + describe Array do + describe "when first created" do + its(:length) { should == 0 } + end + end + """ + When I run "spec subject_with_getter_spec.rb" + Then the stdout should include "1 example, 0 failures" diff --git a/vendor/gems/gems/rspec-1.2.9/features/support/env.rb b/vendor/gems/gems/rspec-1.2.9/features/support/env.rb new file mode 100755 index 00000000..e11b3db2 --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/features/support/env.rb @@ -0,0 +1,82 @@ +$:.unshift File.join(File.dirname(__FILE__), "/../../lib") + +require 'spec/expectations' +require 'forwardable' +require 'tempfile' +require 'spec/ruby_forker' +require 'features/support/matchers/smart_match' + +class RspecWorld + include Spec::Expectations + include Spec::Matchers + include RubyForker + + extend Forwardable + def_delegators RspecWorld, :working_dir, :spec_command, :cmdline_file, :rspec_lib + + def self.working_dir + @working_dir ||= File.expand_path(File.join(File.dirname(__FILE__), "/../../tmp/cucumber-generated-files")) + end + + def self.spec_command + @spec_command ||= File.expand_path(File.join(File.dirname(__FILE__), "/../../bin/spec")) + end + + def self.cmdline_file + @cmdline_file ||= File.expand_path(File.join(File.dirname(__FILE__), "/../../resources/helpers/cmdline.rb")) + end + + def self.rspec_lib + @rspec_lib ||= File.join(working_dir, "/../../lib") + end + + def spec(args) + ruby("#{spec_command} #{args}") + end + + def cmdline(args) + ruby("#{cmdline_file} #{args}") + end + + def create_file(file_name, contents) + file_path = File.join(working_dir, file_name) + File.open(file_path, "w") { |f| f << contents } + end + + def create_directory(dirname) + FileUtils.mkdir_p File.join(working_dir, dirname) + end + + def last_stdout + @stdout + end + + def last_stderr + @stderr + end + + def last_exit_code + @exit_code + end + + # it seems like this, and the last_* methods, could be moved into RubyForker-- is that being used anywhere but the features? + def ruby(args) + stderr_file = Tempfile.new('rspec') + stderr_file.close + Dir.chdir(working_dir) do + @stdout = super("-I #{rspec_lib} #{args}", stderr_file.path) + end + @stderr = IO.read(stderr_file.path) + @exit_code = $?.to_i + end + +end + +Before do + FileUtils.rm_rf RspecWorld.working_dir if test ?d, RspecWorld.working_dir + FileUtils.mkdir_p RspecWorld.working_dir +end + +World do + RspecWorld.new +end diff --git a/vendor/gems/gems/rspec-1.2.9/features/support/matchers/smart_match.rb b/vendor/gems/gems/rspec-1.2.9/features/support/matchers/smart_match.rb new file mode 100755 index 00000000..74c50898 --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/features/support/matchers/smart_match.rb @@ -0,0 +1,12 @@ +Spec::Matchers.define :smart_match do |expected| + match do |actual| + case expected + when /^\/.*\/?$/ + actual =~ eval(expected) + when /^".*"$/ + actual.index(eval(expected)) + else + false + end + end +end diff --git a/vendor/gems/gems/rspec-1.2.9/init.rb b/vendor/gems/gems/rspec-1.2.9/init.rb new file mode 100755 index 00000000..6262f036 --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/init.rb @@ -0,0 +1,9 @@ +# Placeholder to satisfy Rails. +# +# Do NOT add any require statements to this file. Doing +# so will cause Rails to load this plugin all of the time. +# +# Running 'ruby script/generate rspec' will +# generate spec/spec_helper.rb, which includes the necessary +# require statements and configuration. This file should +# be required by all of your spec files. \ No newline at end of file diff --git a/vendor/gems/gems/rspec-1.2.9/lib/autotest/discover.rb b/vendor/gems/gems/rspec-1.2.9/lib/autotest/discover.rb new file mode 100755 index 00000000..3ac51c13 --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/lib/autotest/discover.rb @@ -0,0 +1,3 @@ +Autotest.add_discovery do + "rspec" if File.directory?('spec') && ENV['RSPEC'] +end diff --git a/vendor/gems/gems/rspec-1.2.9/lib/autotest/rspec.rb b/vendor/gems/gems/rspec-1.2.9/lib/autotest/rspec.rb new file mode 100755 index 00000000..625e340b --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/lib/autotest/rspec.rb @@ -0,0 +1,47 @@ +require 'autotest' + +Autotest.add_hook :initialize do |at| + at.clear_mappings + # watch out: Ruby bug (1.8.6): + # %r(/) != /\// + at.add_mapping(%r%^spec/.*_spec.rb$%) { |filename, _| + filename + } + at.add_mapping(%r%^lib/(.*)\.rb$%) { |_, m| + ["spec/#{m[1]}_spec.rb"] + } + at.add_mapping(%r%^spec/(spec_helper|shared/.*)\.rb$%) { + at.files_matching %r%^spec/.*_spec\.rb$% + } +end + +class RspecCommandError < StandardError; end + +class Autotest::Rspec < Autotest + + def initialize + super + self.failed_results_re = /^\d+\)\n(?:\e\[\d*m)?(?:.*?in )?'([^\n]*)'(?: FAILED)?(?:\e\[\d*m)?\n\n?(.*?(\n\n\(.*?)?)\n\n/m + self.completed_re = /\n(?:\e\[\d*m)?\d* examples?/m + end + + def consolidate_failures(failed) + filters = new_hash_of_arrays + failed.each do |spec, trace| + if trace =~ /\n(\.\/)?(.*spec\.rb):[\d]+:/ + filters[$2] << spec + end + end + return filters + end + + def make_test_cmd(files_to_test) + return '' if files_to_test.empty? + spec_program = File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'bin', 'spec')) + return "#{ruby} #{spec_program} --autospec #{files_to_test.keys.flatten.join(' ')} #{add_options_if_present}" + end + + def add_options_if_present # :nodoc: + File.exist?("spec/spec.opts") ? "-O spec/spec.opts " : "" + end +end diff --git a/vendor/gems/gems/rspec-1.2.9/lib/spec.rb b/vendor/gems/gems/rspec-1.2.9/lib/spec.rb new file mode 100755 index 00000000..879c373e --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/lib/spec.rb @@ -0,0 +1,8 @@ +require 'spec/deprecation' +require 'spec/ruby' +require 'spec/matchers' +require 'spec/expectations' +require 'spec/example' +require 'spec/runner' +require 'spec/version' +require 'spec/dsl' diff --git a/vendor/gems/gems/rspec-1.2.9/lib/spec/adapters/mock_frameworks/flexmock.rb b/vendor/gems/gems/rspec-1.2.9/lib/spec/adapters/mock_frameworks/flexmock.rb new file mode 100755 index 00000000..18dd453d --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/lib/spec/adapters/mock_frameworks/flexmock.rb @@ -0,0 +1,24 @@ +#!/usr/bin/env ruby +# +# Created by Jim Weirich on 2007-04-10. +# Copyright (c) 2007. All rights reserved. + +require 'rubygems' unless ENV['NO_RUBYGEMS'] +require 'flexmock/rspec' + +module Spec + module Adapters + module MockFramework + include FlexMock::MockContainer + def setup_mocks_for_rspec + # No setup required + end + def verify_mocks_for_rspec + flexmock_verify + end + def teardown_mocks_for_rspec + flexmock_close + end + end + end +end diff --git a/vendor/gems/gems/rspec-1.2.9/lib/spec/adapters/mock_frameworks/mocha.rb b/vendor/gems/gems/rspec-1.2.9/lib/spec/adapters/mock_frameworks/mocha.rb new file mode 100755 index 00000000..4c97c139 --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/lib/spec/adapters/mock_frameworks/mocha.rb @@ -0,0 +1,25 @@ +require 'rubygems' unless ENV['NO_RUBYGEMS'] +require 'mocha/standalone' +require 'mocha/object' + +module Spec + module Adapters + module MockFramework + # Mocha::Standalone was deprecated as of Mocha 0.9.7. + begin + include Mocha::API + rescue NameError + include Mocha::Standalone + end + def setup_mocks_for_rspec + mocha_setup + end + def verify_mocks_for_rspec + mocha_verify + end + def teardown_mocks_for_rspec + mocha_teardown + end + end + end +end diff --git a/vendor/gems/gems/rspec-1.2.9/lib/spec/adapters/mock_frameworks/rr.rb b/vendor/gems/gems/rspec-1.2.9/lib/spec/adapters/mock_frameworks/rr.rb new file mode 100755 index 00000000..758ddf61 --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/lib/spec/adapters/mock_frameworks/rr.rb @@ -0,0 +1,22 @@ +require 'rubygems' unless ENV['NO_RUBYGEMS'] +require 'rr' + +patterns = ::Spec::Runner::QuietBacktraceTweaker::IGNORE_PATTERNS +patterns.push(RR::Errors::BACKTRACE_IDENTIFIER) + +module Spec + module Adapters + module MockFramework + include RR::Extensions::InstanceMethods + def setup_mocks_for_rspec + RR::Space.instance.reset + end + def verify_mocks_for_rspec + RR::Space.instance.verify_doubles + end + def teardown_mocks_for_rspec + RR::Space.instance.reset + end + end + end +end diff --git a/vendor/gems/gems/rspec-1.2.9/lib/spec/adapters/mock_frameworks/rspec.rb b/vendor/gems/gems/rspec-1.2.9/lib/spec/adapters/mock_frameworks/rspec.rb new file mode 100755 index 00000000..b159f8bf --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/lib/spec/adapters/mock_frameworks/rspec.rb @@ -0,0 +1,21 @@ +require 'spec/mocks/framework' +require 'spec/mocks/extensions' + +module Spec + module Adapters + unless defined?(MockFramework) + module MockFramework + include Spec::Mocks::ExampleMethods + def setup_mocks_for_rspec + $rspec_mocks ||= Spec::Mocks::Space.new + end + def verify_mocks_for_rspec + $rspec_mocks.verify_all + end + def teardown_mocks_for_rspec + $rspec_mocks.reset_all + end + end + end + end +end diff --git a/vendor/gems/gems/rspec-1.2.9/lib/spec/autorun.rb b/vendor/gems/gems/rspec-1.2.9/lib/spec/autorun.rb new file mode 100755 index 00000000..f29b8196 --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/lib/spec/autorun.rb @@ -0,0 +1,3 @@ +require 'spec' + +Spec::Runner.autorun diff --git a/vendor/gems/gems/rspec-1.2.9/lib/spec/deprecation.rb b/vendor/gems/gems/rspec-1.2.9/lib/spec/deprecation.rb new file mode 100755 index 00000000..ebab7894 --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/lib/spec/deprecation.rb @@ -0,0 +1,40 @@ +module Spec + class << self + def deprecate(method, alternate_method=nil) + message = <<-NOTICE + +***************************************************************** +DEPRECATION WARNING: you are using deprecated behaviour that will +be removed from a future version of RSpec. + +#{caller(0)[2]} + +* #{method} is deprecated. +NOTICE + if alternate_method + message << <<-ADDITIONAL +* please use #{alternate_method} instead. +ADDITIONAL + end + + message << "*****************************************************************" + warn(message) + end + + def warn(message) + Kernel.warn(message) + end + + end + + class HashWithDeprecationNotice < Hash + def initialize(method, alternate_method=nil, &block) + @method, @alternate_method = method, alternate_method + end + def []=(k,v) + Spec.deprecate(@method, @alternate_method) + super + end + end +end + diff --git a/vendor/gems/gems/rspec-1.2.9/lib/spec/dsl.rb b/vendor/gems/gems/rspec-1.2.9/lib/spec/dsl.rb new file mode 100755 index 00000000..d93e90d8 --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/lib/spec/dsl.rb @@ -0,0 +1 @@ +require 'spec/dsl/main' diff --git a/vendor/gems/gems/rspec-1.2.9/lib/spec/dsl/main.rb b/vendor/gems/gems/rspec-1.2.9/lib/spec/dsl/main.rb new file mode 100755 index 00000000..3459275b --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/lib/spec/dsl/main.rb @@ -0,0 +1,92 @@ +module Spec + module DSL + module Main + include Spec::Example::ArgsAndOptions + + # Creates and returns a class that includes the ExampleGroupMethods + # module. Which ExampleGroup type is created depends on the directory of the file + # calling this method. For example, Spec::Rails will use different + # classes for specs living in spec/models, + # spec/helpers, spec/views and + # spec/controllers. + # + # It is also possible to override autodiscovery of the example group + # type with an options Hash as the last argument: + # + # describe "name", :type => :something_special do ... + # + # The reason for using different example group classes is to have different + # matcher methods available from within the describe block. + # + # See Spec::Example::ExampleGroupFactory#register for details about how to + # register special implementations. + # + def describe(*args, &block) + raise Spec::Example::NoDescriptionError.new("example group", caller(0)[1]) if args.empty? + add_options(args, :scope => self) + set_location(args.options, caller(0)[1]) + Spec::Example::ExampleGroupFactory.create_example_group(*args, &block) + end + alias :context :describe + + # Creates an example group that can be shared by other example groups + # + # == Examples + # + # share_examples_for "All Editions" do + # it "all editions behaviour" ... + # end + # + # describe SmallEdition do + # it_should_behave_like "All Editions" + # + # it "should do small edition stuff" do + # ... + # end + # end + def share_examples_for(*args, &block) + add_options(args) + set_location(args.options, caller(0)[1]) + Spec::Example::ExampleGroupFactory.create_shared_example_group(*args, &block) + end + alias :shared_examples_for :share_examples_for + + # Creates a Shared Example Group and assigns it to a constant + # + # share_as :AllEditions do + # it "should do all editions stuff" ... + # end + # + # describe SmallEdition do + # it_should_behave_like AllEditions + # + # it "should do small edition stuff" do + # ... + # end + # end + # + # And, for those of you who prefer to use something more like Ruby, you + # can just include the module directly + # + # describe SmallEdition do + # include AllEditions + # + # it "should do small edition stuff" do + # ... + # end + # end + def share_as(name, &block) + begin + args = [name] + add_options(args) + set_location(args.options, caller(0)[1]) + Object.const_set(name, Spec::Example::ExampleGroupFactory.create_shared_example_group(*args, &block)) + rescue NameError => e + raise NameError.new(e.message + "\nThe first argument to share_as must be a legal name for a constant\n") + end + end + end + end +end + +include Spec::DSL::Main diff --git a/vendor/gems/gems/rspec-1.2.9/lib/spec/example.rb b/vendor/gems/gems/rspec-1.2.9/lib/spec/example.rb new file mode 100755 index 00000000..afbf4128 --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/lib/spec/example.rb @@ -0,0 +1,164 @@ +module Spec + # == Example Groups and Code Examples + # + # A Code Example is an executable example of how a bit of code is expected + # to behave. + # + # An Example Group is a group of code examples. + # + # RSpec exposes a DSL to describe groups of examples. + # + # describe Account do + # it "should have a balance of $0" do + # account = Account.new + # account.balance.should == Money.new(0, :dollars) + # end + # end + # + # == Before and After + # + # You can use the before() and after() methods to extract + # common code within an Example Group. Both methods take an optional scope + # argument so you can run the block before :each example or before :all + # examples + # + # describe "..." do + # before :all do + # ... + # end + # + # before :each do + # ... + # end + # + # it "should do something" do + # ... + # end + # + # it "should do something else" do + # ... + # end + # + # after :each do + # ... + # end + # + # after :all do + # ... + # end + # + # end + # + # The before :each block will run before each of the examples, once + # for each example. Likewise, the after :each block will run after + # each of the examples. + # + # It is also possible to specify a before :all and after + # :all block that will run only once for each example group, before the + # first before :each and after the last after + # :each respectively. The use of these is generally discouraged, + # because it introduces dependencies between the examples. Still, it might + # prove useful for very expensive operations if you know what you are doing. + # + # == Local helper methods + # + # You can include local helper methods by simply expressing them within an + # example group: + # + # describe "..." do + # + # it "..." do + # helper_method + # end + # + # def helper_method + # ... + # end + # + # end + # + # == Included helper methods + # + # You can include helper methods in multiple example groups by expressing + # them within a module, and then including that module in your example + # groups: + # + # module AccountExampleHelperMethods + # def helper_method + # ... + # end + # end + # + # describe "A new account" do + # include AccountExampleHelperMethods + # before do + # @account = Account.new + # end + # + # it "should have a balance of $0" do + # helper_method + # @account.balance.should eql(Money.new(0, :dollars)) + # end + # end + # + # == Shared Example Groups + # + # You can define a shared example group, that may be used on other groups + # + # share_examples_for "All Editions" do + # it "all editions behaviour" ... + # end + # + # describe SmallEdition do + # it_should_behave_like "All Editions" + # + # it "should do small edition stuff" do + # ... + # end + # end + # + # You can also assign the shared group to a module and include that + # + # share_as :AllEditions do + # it "should do all editions stuff" ... + # end + # + # describe SmallEdition do + # it_should_behave_like AllEditions + # + # it "should do small edition stuff" do + # ... + # end + # end + # + # And, for those of you who prefer to use something more like Ruby, you can + # just include the module directly + # + # describe SmallEdition do + # include AllEditions + # + # it "should do small edition stuff" do + # ... + # end + # end + module Example + end +end + +require 'timeout' +require 'spec/example/args_and_options' +require 'spec/example/predicate_matchers' +require 'spec/example/example_group_proxy' +require 'spec/example/example_proxy' +require 'spec/example/subject' +require 'spec/example/before_and_after_hooks' +require 'spec/example/pending' +require 'spec/example/module_reopening_fix' +require 'spec/example/example_group_hierarchy' +require 'spec/example/example_group_methods' +require 'spec/example/example_methods' +require 'spec/example/example_group' +require 'spec/example/shared_example_group' +require 'spec/example/example_group_factory' +require 'spec/example/errors' +require 'spec/example/example_matcher' diff --git a/vendor/gems/gems/rspec-1.2.9/lib/spec/example/args_and_options.rb b/vendor/gems/gems/rspec-1.2.9/lib/spec/example/args_and_options.rb new file mode 100755 index 00000000..b74fddd8 --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/lib/spec/example/args_and_options.rb @@ -0,0 +1,27 @@ +module Spec + module Example + module ArgsAndOptions + def args_and_options(*args) # :nodoc: + options = Hash === args.last ? args.pop : {} + return args, options + end + + def add_options(args, options={}) # :nodoc: + args << {} unless Hash === args.last + args.extend WithOptions + args.options.merge!(options) + args.options + end + + def set_location(options, location) # :nodoc: + options[:location] ||= location + end + + module WithOptions # :nodoc: + def options + last + end + end + end + end +end diff --git a/vendor/gems/gems/rspec-1.2.9/lib/spec/example/before_and_after_hooks.rb b/vendor/gems/gems/rspec-1.2.9/lib/spec/example/before_and_after_hooks.rb new file mode 100755 index 00000000..9f5039d1 --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/lib/spec/example/before_and_after_hooks.rb @@ -0,0 +1,93 @@ +module Spec + module Example + module BeforeAndAfterHooks + class << self + def before_suite_parts # :nodoc: + @before_suite_parts ||= [] + end + + def after_suite_parts # :nodoc: + @after_suite_parts ||= [] + end + end + + # Registers a block to be executed before examples. scope can be + # :each (default), :all, or :suite. When + # :each, the block is executed before each example. When + # :all, the block is executed only once before any examples are + # run. + def append_before(scope = :each, &block) + before_parts(scope) << block + end + alias_method :before, :append_before + + # Registers a block to be executed before each example. + # This method prepends +block+ to existing before blocks. + # + # See append_before for scoping semantics. + def prepend_before(scope = :each, &block) + before_parts(scope).unshift(block) + end + + # Registers a block to be executed after each example. + # This method prepends +block+ to existing after blocks. + # + # See append_before for scoping semantics. + def prepend_after(scope = :each, &block) + after_parts(scope).unshift(block) + end + alias_method :after, :prepend_after + + # Registers a block to be executed after each example. + # This method appends +block+ to existing after blocks. + # + # See append_before for scoping semantics. + def append_after(scope = :each, &block) + after_parts(scope) << block + end + + def before_each_parts # :nodoc: + @before_each_parts ||= [] + end + + def after_each_parts # :nodoc: + @after_each_parts ||= [] + end + + def before_all_parts # :nodoc: + @before_all_parts ||= [] + end + + def after_all_parts # :nodoc: + @after_all_parts ||= [] + end + + def before_suite_parts # :nodoc: + BeforeAndAfterHooks.before_suite_parts + end + + def after_suite_parts # :nodoc: + BeforeAndAfterHooks.after_suite_parts + end + + private + + def before_parts(scope) + case scope + when :each; before_each_parts + when :all; before_all_parts + when :suite; before_suite_parts + end + end + + def after_parts(scope) + case scope + when :each; after_each_parts + when :all; after_all_parts + when :suite; after_suite_parts + end + end + + end + end +end diff --git a/vendor/gems/gems/rspec-1.2.9/lib/spec/example/errors.rb b/vendor/gems/gems/rspec-1.2.9/lib/spec/example/errors.rb new file mode 100755 index 00000000..157b669b --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/lib/spec/example/errors.rb @@ -0,0 +1,25 @@ +module Spec + module Example + class ExamplePendingError < StandardError; end + + class NotYetImplementedError < ExamplePendingError + MESSAGE = "Not Yet Implemented" + def initialize + super(MESSAGE) + end + end + + class PendingExampleFixedError < StandardError; end + + class NoDescriptionError < ArgumentError + class << self + def message(kind, location) + "No description supplied for #{kind} declared on #{location}" + end + end + def initialize(kind, location) + super(self.class.message(kind, location)) + end + end + end +end diff --git a/vendor/gems/gems/rspec-1.2.9/lib/spec/example/example_group.rb b/vendor/gems/gems/rspec-1.2.9/lib/spec/example/example_group.rb new file mode 100755 index 00000000..983be9a2 --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/lib/spec/example/example_group.rb @@ -0,0 +1,10 @@ +module Spec + module Example + # Base class for customized example groups. Use this if you + # want to make a custom example group. + class ExampleGroup + extend Spec::Example::ExampleGroupMethods + include Spec::Example::ExampleMethods + end + end +end diff --git a/vendor/gems/gems/rspec-1.2.9/lib/spec/example/example_group_factory.rb b/vendor/gems/gems/rspec-1.2.9/lib/spec/example/example_group_factory.rb new file mode 100755 index 00000000..1d662782 --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/lib/spec/example/example_group_factory.rb @@ -0,0 +1,82 @@ +module Spec + module Example + + class ExampleGroupFactory + module ClassMethods + include Spec::Example::ArgsAndOptions + + def reset + @example_group_types = nil + default(ExampleGroup) + end + + def example_group_creation_listeners + @example_group_creation_listeners ||= [] + end + + def register_example_group(klass) + example_group_creation_listeners.each do |listener| + listener.register_example_group(klass) + end + end + + def create_shared_example_group(*args, &example_group_block) # :nodoc: + ::Spec::Example::SharedExampleGroup.register(*args, &example_group_block) + end + + def create_example_group(*args, &block) + raise ArgumentError if args.empty? || block.nil? + add_options(args) + superclass = determine_superclass(args.last) + superclass.describe(*args, &block) + end + + # Registers an example group class +klass+ with the symbol +type+. For + # example: + # + # Spec::Example::ExampleGroupFactory.register(:farm, FarmExampleGroup) + # + # With that you can append a hash with :type => :farm to the describe + # method and it will load an instance of FarmExampleGroup. + # + # describe Pig, :type => :farm do + # ... + # + # If you don't use the hash explicitly, describe will + # implicitly use an instance of FarmExampleGroup for any file loaded + # from the ./spec/farm directory. + def register(key, example_group_class) + @example_group_types[key.to_sym] = example_group_class + end + + # Sets the default ExampleGroup class + def default(example_group_class) + Spec.__send__ :remove_const, :ExampleGroup if Spec.const_defined?(:ExampleGroup) + Spec.const_set(:ExampleGroup, example_group_class) + old = @example_group_types + @example_group_types = Hash.new(example_group_class) + @example_group_types.merge!(old) if old + end + + def [](key) + @example_group_types[key] + end + + protected + + def determine_superclass(opts) + if type = opts[:type] + self[type] + elsif opts[:location] =~ /spec(\\|\/)(#{@example_group_types.keys.sort_by{|k| k.to_s.length}.reverse.join('|')})/ + self[$2 == '' ? nil : $2.to_sym] + else + self[nil] + end + end + + end + extend ClassMethods + self.reset + end + end +end diff --git a/vendor/gems/gems/rspec-1.2.9/lib/spec/example/example_group_hierarchy.rb b/vendor/gems/gems/rspec-1.2.9/lib/spec/example/example_group_hierarchy.rb new file mode 100755 index 00000000..f2c9fb5c --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/lib/spec/example/example_group_hierarchy.rb @@ -0,0 +1,53 @@ +module Spec + module Example + class ExampleGroupHierarchy < Array + def initialize(example_group_class) + push example_group_class + if example_group_class.respond_to?(:superclass) && example_group_class.superclass.respond_to?(:example_group_hierarchy) + unshift example_group_class.superclass.example_group_hierarchy + flatten! + end + end + + def run_before_all(example) + example.eval_each_fail_fast(before_all_parts) + end + + def run_before_each(example) + example.eval_each_fail_fast(before_each_parts) + end + + def run_after_each(example) + example.eval_each_fail_slow(after_each_parts) + end + + def run_after_all(example) + example.eval_each_fail_slow(after_all_parts) + end + + def before_all_parts + @before_all_parts ||= collect {|klass| klass.before_all_parts}.flatten + end + + def before_each_parts + @before_each_parts ||= collect {|klass| klass.before_each_parts}.flatten + end + + def after_each_parts + @after_each_parts ||= reverse.collect {|klass| klass.after_each_parts}.flatten + end + + def after_all_parts + @after_all_parts ||= reverse.collect {|klass| klass.after_all_parts}.flatten + end + + def nested_descriptions + @nested_descriptions ||= collect {|eg| nested_description_from(eg) == "" ? nil : nested_description_from(eg) }.compact + end + + def nested_description_from(example_group) + example_group.description_args.join + end + end + end +end diff --git a/vendor/gems/gems/rspec-1.2.9/lib/spec/example/example_group_methods.rb b/vendor/gems/gems/rspec-1.2.9/lib/spec/example/example_group_methods.rb new file mode 100755 index 00000000..3862fdef --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/lib/spec/example/example_group_methods.rb @@ -0,0 +1,282 @@ +module Spec + module Example + + module ExampleGroupMethods + class << self + attr_accessor :matcher_class + + def build_description_from(*args) + text = args.inject("") do |description, arg| + description << " " unless (description == "" || arg.to_s =~ /^(\s|\.|#)/) + description << arg.to_s + end + text == "" ? nil : text + end + end + + include Spec::Example::BeforeAndAfterHooks + include Spec::Example::Subject::ExampleGroupMethods + include Spec::Example::PredicateMatchers + include Spec::Example::ArgsAndOptions + + attr_reader :location + + def options # :nodoc: + @options ||= {} + end + + def inherited(klass) # :nodoc: + super + ExampleGroupFactory.register_example_group(klass) + end + + # Makes the describe/it syntax available from a class. For example: + # + # class StackSpec < Spec::ExampleGroup + # describe Stack, "with no elements" + # + # before + # @stack = Stack.new + # end + # + # it "should raise on pop" do + # lambda{ @stack.pop }.should raise_error + # end + # end + # + def describe(*args, &example_group_block) + raise Spec::Example::NoDescriptionError.new("example group", caller(0)[1]) if args.empty? + if example_group_block + options = add_options(args) + set_location(options, caller(0)[1]) + if options[:shared] + ExampleGroupFactory.create_shared_example_group(*args, &example_group_block) + else + subclass(*args, &example_group_block) + end + else + set_description(*args) + end + end + alias :context :describe + + # Use this to pull in examples from shared example groups. + def it_should_behave_like(*shared_example_groups) + shared_example_groups.each do |group| + include_shared_example_group(group) + end + end + + # Creates an instance of the current example group class and adds it to + # a collection of examples of the current example group. + def example(description=nil, options={}, backtrace=nil, &implementation) + example_proxy = ExampleProxy.new(description, options, backtrace || caller(0)[1]) + example_proxies << example_proxy + example_implementations[example_proxy] = implementation || pending_implementation + example_proxy + end + + def pending_implementation + lambda { raise(Spec::Example::NotYetImplementedError) } + end + + alias_method :it, :example + alias_method :specify, :example + + # Use this to temporarily disable an example. + def xexample(description=nil, opts={}, &block) + Kernel.warn("Example disabled: #{description}") + end + + alias_method :xit, :xexample + alias_method :xspecify, :xexample + + def run(run_options) + examples = examples_to_run(run_options) + notify(run_options.reporter) unless examples.empty? + return true if examples.empty? + return dry_run(examples, run_options) if run_options.dry_run? + + define_methods_from_predicate_matchers + + success, before_all_instance_variables = run_before_all(run_options) + success, after_all_instance_variables = run_examples(success, before_all_instance_variables, examples, run_options) + success = run_after_all(success, after_all_instance_variables, run_options) + end + + def set_description(*args) + @description_args, @options = args_and_options(*args) + @backtrace = caller(1) + @location = File.expand_path(options[:location]) if options[:location] + self + end + + def notify(reporter) # :nodoc: + reporter.example_group_started(ExampleGroupProxy.new(self)) + end + + def description + @description ||= ExampleGroupMethods.build_description_from(*description_parts) || to_s + end + + def described_type + @described_type ||= description_parts.reverse.find {|part| part.is_a?(Module)} + end + + def described_class + @described_class ||= Class === described_type ? described_type : nil + end + + def description_args + @description_args ||= [] + end + + def description_parts #:nodoc: + @description_parts ||= example_group_hierarchy.inject([]) do |parts, example_group_class| + [parts << example_group_class.description_args].flatten + end + end + + def example_proxies # :nodoc: + @example_proxies ||= [] + end + + def example_implementations # :nodoc: + @example_implementations ||= {} + end + + def examples(run_options=nil) #:nodoc: + (run_options && run_options.reverse) ? example_proxies.reverse : example_proxies + end + + def number_of_examples #:nodoc: + example_proxies.length + end + + def example_group_hierarchy + @example_group_hierarchy ||= ExampleGroupHierarchy.new(self) + end + + def nested_descriptions + example_group_hierarchy.nested_descriptions + end + + def include_constants_in(mod) + include mod if (Spec::Ruby.version.to_f >= 1.9) & (Module === mod) & !(Class === mod) + end + + def let(name, &block) + define_method name do + @assignments ||= {} + @assignments[name] ||= instance_eval(&block) + end + end + + private + + def subclass(*args, &example_group_block) + @class_count ||= 0 + @class_count += 1 + klass = const_set("Subclass_#{@class_count}", Class.new(self)) + klass.set_description(*args) + klass.include_constants_in(args.last[:scope]) + klass.module_eval(&example_group_block) + klass + end + + def dry_run(examples, run_options) + examples.each do |example| + run_options.reporter.example_started(example) + run_options.reporter.example_finished(example) + end + end + + def run_before_all(run_options) + return [true,{}] if example_group_hierarchy.before_all_parts.empty? + example_proxy = ExampleProxy.new("before(:all)") + before_all = new(example_proxy) + begin + example_group_hierarchy.run_before_all(before_all) + return [true, before_all.instance_variable_hash] + rescue Exception => e + run_options.reporter.example_failed(example_proxy, e) + return [false, before_all.instance_variable_hash] + end + end + + def run_examples(success, instance_variables, examples, run_options) + return [success, instance_variables] unless success + + after_all_instance_variables = instance_variables + + examples.each do |example| + example_group_instance = new(example, &example_implementations[example]) + success &= example_group_instance.execute(run_options, instance_variables) + after_all_instance_variables = example_group_instance.instance_variable_hash + end + + return [success, after_all_instance_variables] + end + + def run_after_all(success, instance_variables, run_options) + return success if example_group_hierarchy.after_all_parts.empty? + example_proxy = ExampleProxy.new("after(:all)") + after_all = new(example_proxy) + after_all.set_instance_variables_from_hash(instance_variables) + example_group_hierarchy.run_after_all(after_all) + success + rescue Exception => e + run_options.reporter.example_failed(example_proxy, e) + false + end + + def examples_to_run(run_options) + return example_proxies unless examples_were_specified?(run_options) + if run_options.line_number_requested? + if location =~ /:#{run_options.example_line}:?/ + example_proxies + else + example_proxies.select {|proxy| proxy.location =~ /:#{run_options.example_line}:?/} + end + else + example_proxies.reject do |proxy| + matcher = ExampleGroupMethods.matcher_class. + new(description.to_s, proxy.description) + !matcher.matches?(run_options.examples) + end + end + end + + def examples_were_specified?(run_options) + !run_options.examples.empty? + end + + def method_added(name) # :nodoc: + example(name.to_s, {}, caller(0)[1]) {__send__ name.to_s} if example_method?(name.to_s) + end + + def example_method?(method_name) + should_method?(method_name) + end + + def should_method?(method_name) + !(method_name =~ /^should(_not)?$/) && + method_name =~ /^should/ && + instance_method(method_name).arity < 1 + end + + def include_shared_example_group(shared_example_group) + case shared_example_group + when SharedExampleGroup + include shared_example_group + else + unless example_group = SharedExampleGroup.find(shared_example_group) + raise RuntimeError.new("Shared Example Group '#{shared_example_group}' can not be found") + end + include(example_group) + end + end + end + + end +end diff --git a/vendor/gems/gems/rspec-1.2.9/lib/spec/example/example_group_proxy.rb b/vendor/gems/gems/rspec-1.2.9/lib/spec/example/example_group_proxy.rb new file mode 100755 index 00000000..3c258d61 --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/lib/spec/example/example_group_proxy.rb @@ -0,0 +1,61 @@ +module Spec + module Example + # Lightweight proxy for an example group. This is the object that is passed + # to Spec::Runner::Formatter::BaseFormatter#example_group_started + class ExampleGroupProxy + + def initialize(example_group) # :nodoc: + @description = example_group.description + @nested_descriptions = example_group.nested_descriptions + @examples = example_group.example_proxies + @location = example_group.location + @backtrace = example_group.location # deprecated - see the backtrace method below + @options = example_group.options.dup + @options.delete(:location) + @options.delete(:scope) + end + + # Optional hash passed to the example group declaration. Note that RSpec uses + # this hash internally and reserves the keys :location and :scope for its own + # use (and removes them from this hash) + attr_reader :options + + # This is the description passed to the describe() method or any + # of its aliases + attr_reader :description + + # Used by Spec::Runner::Formatter::NestedTextFormatter to access the + # description of each example group in a nested group separately. + attr_reader :nested_descriptions + + # A collection of ExampleGroupProxy objects, one for each example + # declared in this group. + attr_reader :examples + + # The file and line number at which the proxied example group + # was declared. This is extracted from caller, and is therefore + # formatted as an individual line in a backtrace. + attr_reader :location + + # Deprecated - use location() instead + def backtrace + Spec::deprecate("ExampleGroupProxy#backtrace","ExampleGroupProxy#location") + @backtrace + end + + # Deprecated - just use gsub on the description instead. + def filtered_description(regexp) + Spec::deprecate("ExampleGroupProxy#filtered_description","gsub (or similar) to modify ExampleGroupProxy#description") + ExampleGroupMethods.build_description_from( + *nested_descriptions.collect do |description| + description =~ regexp ? description.gsub($1, "") : description + end + ) + end + + def ==(other) # :nodoc: + other.description == description + end + end + end +end diff --git a/vendor/gems/gems/rspec-1.2.9/lib/spec/example/example_matcher.rb b/vendor/gems/gems/rspec-1.2.9/lib/spec/example/example_matcher.rb new file mode 100755 index 00000000..3acd7e14 --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/lib/spec/example/example_matcher.rb @@ -0,0 +1,43 @@ +module Spec + module Example + class ExampleMatcher + def initialize(example_group_description, example_name) + @example_group_description = example_group_description + @example_name = example_name + end + + def matches?(specified_examples) + specified_examples.any? do |specified_example| + matches_literal_example?(specified_example) || matches_example_not_considering_modules?(specified_example) + end + end + + protected + def matches_literal_example?(specified_example) + specified_example =~ /(^#{example_group_regex} #{example_regexp}$|^#{example_group_regex}$|^#{example_group_with_before_all_regexp}$|^#{example_regexp}$)/ + end + + def matches_example_not_considering_modules?(specified_example) + specified_example =~ /(^#{example_group_regex_not_considering_modules} #{example_regexp}$|^#{example_group_regex_not_considering_modules}$|^#{example_regexp}$)/ + end + + def example_group_regex + Regexp.escape(@example_group_description) + end + + def example_group_with_before_all_regexp + Regexp.escape("#{@example_group_description} before(:all)") + end + + def example_group_regex_not_considering_modules + Regexp.escape(@example_group_description.split('::').last) + end + + def example_regexp + Regexp.escape(@example_name) if @example_name + end + end + + ExampleGroupMethods.matcher_class = ExampleMatcher + end +end diff --git a/vendor/gems/gems/rspec-1.2.9/lib/spec/example/example_methods.rb b/vendor/gems/gems/rspec-1.2.9/lib/spec/example/example_methods.rb new file mode 100755 index 00000000..ca81a937 --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/lib/spec/example/example_methods.rb @@ -0,0 +1,148 @@ +module Spec + module Example + module ExampleMethods + + extend Spec::Example::ModuleReopeningFix + include Spec::Example::Subject::ExampleMethods + + def violated(message="") + raise Spec::Expectations::ExpectationNotMetError.new(message) + end + + # Declared description for this example: + # + # describe Account do + # it "should start with a balance of 0" do + # ... + # + # description + # => "should start with a balance of 0" + def description + if description = @_proxy.description || ::Spec::Matchers.generated_description + description + else + Spec.warn Spec::Example::NoDescriptionError.message("example", @_proxy.location) + end + end + + def options # :nodoc: + @_proxy.options + end + + def execute(run_options, instance_variables) # :nodoc: + run_options.reporter.example_started(@_proxy) + set_instance_variables_from_hash(instance_variables) + + execution_error = nil + Timeout.timeout(run_options.timeout) do + begin + before_each_example + instance_eval(&@_implementation) + rescue Exception => e + execution_error ||= e + end + begin + after_each_example + rescue Exception => e + execution_error ||= e + end + end + + run_options.reporter.example_finished(@_proxy.update(description), execution_error) + success = execution_error.nil? || ExamplePendingError === execution_error + end + + module BlockAliases + alias_method :to, :should + alias_method :to_not, :should_not + end + + # Extends the submitted block with aliases to and to_not + # for should and should_not. Allows expectations like this: + # + # expect { this_block }.to change{this.expression}.from(old_value).to(new_value) + # expect { this_block }.to raise_error + def expect(&block) + block.extend BlockAliases + end + + def eval_each_fail_fast(blocks) # :nodoc: + blocks.each {|block| instance_eval(&block)} + end + + def eval_each_fail_slow(blocks) # :nodoc: + first_exception = nil + blocks.each do |block| + begin + instance_eval(&block) + rescue Exception => e + first_exception ||= e + end + end + raise first_exception if first_exception + end + + def instance_variable_hash # :nodoc: + instance_variables.inject({}) do |variable_hash, variable_name| + variable_hash[variable_name] = instance_variable_get(variable_name) + variable_hash + end + end + + def set_instance_variables_from_hash(ivars) # :nodoc: + ivars.each do |variable_name, value| + # Ruby 1.9 requires variable.to_s on the next line + unless ['@_proxy', '@_implementation', '@method_name'].include?(variable_name.to_s) + instance_variable_set variable_name, value + end + end + end + + # Run all the before(:each) blocks for this example + def run_before_each + example_group_hierarchy.run_before_each(self) + end + + # Run all the after(:each) blocks for this example + def run_after_each + example_group_hierarchy.run_after_each(self) + end + + def initialize(example_proxy, &implementation) + @_proxy = example_proxy + @_implementation = implementation + @_backtrace = caller + end + + private + + include Matchers + include Pending + + def before_each_example + setup_mocks_for_rspec + run_before_each + end + + def after_each_example + run_after_each + verify_mocks_for_rspec + ensure + teardown_mocks_for_rspec + end + + def described_class + self.class.described_class + end + + def description_args + self.class.description_args + end + + def example_group_hierarchy + self.class.example_group_hierarchy + end + + end + end +end diff --git a/vendor/gems/gems/rspec-1.2.9/lib/spec/example/example_proxy.rb b/vendor/gems/gems/rspec-1.2.9/lib/spec/example/example_proxy.rb new file mode 100755 index 00000000..f726d0e7 --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/lib/spec/example/example_proxy.rb @@ -0,0 +1,41 @@ +module Spec + module Example + # Lightweight proxy for an example. This is the object that is passed to + # example-related methods in Spec::Runner::Formatter::BaseFormatter + class ExampleProxy + + def initialize(description=nil, options={}, location=nil) # :nodoc: + @description, @options, @location = description, options, location + end + + # Optional hash passed to the example declaration + attr_reader :options + + # This is the docstring passed to the it() method or any + # of its aliases + attr_reader :description + + # The file and line number at which the represented example + # was declared. This is extracted from caller, and is therefore + # formatted as an individual line in a backtrace. + attr_reader :location + + # Deprecated - use location() + def backtrace + Spec.deprecate("ExampleProxy#backtrace","ExampleProxy#location") + location + end + + # Convenience method for example group - updates the value of + # description and returns self. + def update(description) # :nodoc: + @description = description + self + end + + def ==(other) # :nodoc: + (other.description == description) & (other.location == location) + end + end + end +end diff --git a/vendor/gems/gems/rspec-1.2.9/lib/spec/example/module_reopening_fix.rb b/vendor/gems/gems/rspec-1.2.9/lib/spec/example/module_reopening_fix.rb new file mode 100755 index 00000000..9ea088a2 --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/lib/spec/example/module_reopening_fix.rb @@ -0,0 +1,43 @@ +module Spec + module Example + # When you reopen a module that is included in another module that is included in a class, + # the new material you define does not make it to the class. This fixes that. + # + # == Example + # + # module M1; end + # + # module M2 + # def foo; "FOO"; end + # end + # + # class C + # include M1 + # end + # + # module M1 + # include M2 + # end + # + # c = C.new + # c.foo + # NoMethodError: undefined method `foo' for # + # from (irb):12 + module ModuleReopeningFix + def child_modules + @child_modules ||= [] + end + + def included(mod) + child_modules << mod + end + + def include(mod) + super + child_modules.each do |child_module| + child_module.__send__(:include, mod) + end + end + end + end +end diff --git a/vendor/gems/gems/rspec-1.2.9/lib/spec/example/pending.rb b/vendor/gems/gems/rspec-1.2.9/lib/spec/example/pending.rb new file mode 100755 index 00000000..9aad1aab --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/lib/spec/example/pending.rb @@ -0,0 +1,18 @@ +module Spec + module Example + module Pending + def pending(message = "TODO") + if block_given? + begin + yield + rescue Exception + raise Spec::Example::ExamplePendingError.new(message) + end + raise Spec::Example::PendingExampleFixedError.new("Expected pending '#{message}' to fail. No Error was raised.") + else + raise Spec::Example::ExamplePendingError.new(message) + end + end + end + end +end diff --git a/vendor/gems/gems/rspec-1.2.9/lib/spec/example/predicate_matchers.rb b/vendor/gems/gems/rspec-1.2.9/lib/spec/example/predicate_matchers.rb new file mode 100755 index 00000000..c3c31951 --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/lib/spec/example/predicate_matchers.rb @@ -0,0 +1,46 @@ +module Spec + module Example + module PredicateMatchers + # :call-seq: + # predicate_matchers[matcher_name] = method_on_object + # predicate_matchers[matcher_name] = [method1_on_object, method2_on_object] + # + # Dynamically generates a custom matcher that will match + # a predicate on your class. RSpec provides a couple of these + # out of the box: + # + # exist (for state expectations) + # File.should exist("path/to/file") + # + # an_instance_of (for mock argument matchers) + # mock.should_receive(:message).with(an_instance_of(String)) + # + # == Examples + # + # class Fish + # def can_swim? + # true + # end + # end + # + # describe Fish do + # predicate_matchers[:swim] = :can_swim? + # it "should swim" do + # Fish.new.should swim + # end + # end + def predicate_matchers + @predicate_matchers ||= Spec::HashWithDeprecationNotice.new("predicate_matchers", "the new Matcher DSL") + end + + def define_methods_from_predicate_matchers # :nodoc: + predicate_matchers.each_pair do |matcher_method, method_on_object| + define_method matcher_method do |*args| + eval("be_#{method_on_object.to_s.gsub('?','')}(*args)") + end + end + end + + end + end +end diff --git a/vendor/gems/gems/rspec-1.2.9/lib/spec/example/shared_example_group.rb b/vendor/gems/gems/rspec-1.2.9/lib/spec/example/shared_example_group.rb new file mode 100755 index 00000000..33694491 --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/lib/spec/example/shared_example_group.rb @@ -0,0 +1,59 @@ +module Spec + module Example + class SharedExampleGroup < Module + module ClassMethods + def register(*args, &block) + new_example_group = new(*args, &block) + shared_example_groups << new_example_group unless already_registered?(new_example_group) + new_example_group + end + + def find(example_group_description) + shared_example_groups.find {|b| b.description == example_group_description} + end + + def clear + shared_example_groups.clear + end + + def include?(group) + shared_example_groups.include?(group) + end + + def count + shared_example_groups.length + end + + private + + def shared_example_groups + @shared_example_groups ||= [] + end + + def already_registered?(new_example_group) + existing_example_group = find(new_example_group.description) + return false unless existing_example_group + return true if new_example_group.equal?(existing_example_group) + return true if expanded_path(new_example_group) == expanded_path(existing_example_group) + raise ArgumentError.new("Shared Example '#{existing_example_group.description}' already exists") + end + + def expanded_path(example_group) + File.expand_path(example_group.location) + end + end + + extend ClassMethods + include ExampleGroupMethods + + def initialize(*args, &example_group_block) + set_description(*args) + @example_group_block = example_group_block + end + + def included(mod) # :nodoc: + mod.module_eval(&@example_group_block) + end + end + end +end diff --git a/vendor/gems/gems/rspec-1.2.9/lib/spec/example/subject.rb b/vendor/gems/gems/rspec-1.2.9/lib/spec/example/subject.rb new file mode 100755 index 00000000..944edca4 --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/lib/spec/example/subject.rb @@ -0,0 +1,108 @@ +module Spec + module Example + module Subject + module ExampleGroupMethods + # Defines an explicit subject for an example group which can then be the + # implicit receiver (through delegation) of calls to +should+. + # + # == Examples + # + # describe CheckingAccount, "with $50" do + # subject { CheckingAccount.new(:amount => 50, :currency => :USD) } + # it { should have_a_balance_of(50, :USD) } + # it { should_not be_overdrawn } + # its(:currency) { should == :USD } + # end + # + # See +ExampleMethods#should+ for more information about this approach. + def subject(&block) + block.nil? ? + explicit_subject || implicit_subject : @explicit_subject_block = block + end + + def its(attribute, &block) + describe(attribute) do + define_method(:subject) { super().send(attribute) } + it(&block) + end + end + + attr_reader :explicit_subject_block # :nodoc: + + private + + def explicit_subject + group = self + while group.respond_to?(:explicit_subject_block) + return group.explicit_subject_block if group.explicit_subject_block + group = group.superclass + end + end + + def implicit_subject + (described_class ? lambda {described_class.new} : lambda {description_args.first}) + end + end + + module ExampleMethods + + alias_method :__should_for_example_group__, :should + alias_method :__should_not_for_example_group__, :should_not + + # Returns the subject defined in ExampleGroupMethods#subject. The + # subject block is only executed once per example, the result of which + # is cached and returned by any subsequent calls to +subject+. + # + # If a class is passed to +describe+ and no subject is explicitly + # declared in the example group, then +subject+ will return a new + # instance of that class. + # + # == Examples + # + # # explicit subject defined by the subject method + # describe Person do + # subject { Person.new(:birthdate => 19.years.ago) } + # it "should be eligible to vote" do + # subject.should be_eligible_to_vote + # end + # end + # + # # implicit subject => { Person.new } + # describe Person do + # it "should be eligible to vote" do + # subject.should be_eligible_to_vote + # end + # end + def subject + @subject ||= instance_eval(&self.class.subject) + end + + # When +should+ is called with no explicit receiver, the call is + # delegated to the object returned by +subject+. Combined with + # an implicit subject (see +subject+), this supports very concise + # expressions. + # + # == Examples + # + # describe Person do + # it { should be_eligible_to_vote } + # end + def should(matcher=nil, message=nil) + self == subject ? self.__should_for_example_group__(matcher) : subject.should(matcher,message) + end + + # Just like +should+, +should_not+ delegates to the subject (implicit or + # explicit) of the example group. + # + # == Examples + # + # describe Person do + # it { should_not be_eligible_to_vote } + # end + def should_not(matcher=nil, message=nil) + self == subject ? self.__should_not_for_example_group__(matcher) : subject.should_not(matcher,message) + end + end + end + end +end diff --git a/vendor/gems/gems/rspec-1.2.9/lib/spec/expectations.rb b/vendor/gems/gems/rspec-1.2.9/lib/spec/expectations.rb new file mode 100755 index 00000000..13cf59b2 --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/lib/spec/expectations.rb @@ -0,0 +1,35 @@ +require 'spec/matchers' +require 'spec/expectations/fail_with' +require 'spec/expectations/errors' +require 'spec/expectations/extensions' +require 'spec/expectations/handler' + +module Spec + + # Spec::Expectations lets you set expectations on your objects. + # + # result.should == 37 + # team.should have(11).players_on_the_field + # + # == How Expectations work. + # + # Spec::Expectations adds two methods to Object: + # + # should(matcher=nil) + # should_not(matcher=nil) + # + # Both methods take an optional Expression Matcher (See Spec::Matchers). + # + # When +should+ receives an Expression Matcher, it calls matches?(self). If + # it returns +true+, the spec passes and execution continues. If it returns + # +false+, then the spec fails with the message returned by matcher.failure_message. + # + # Similarly, when +should_not+ receives a matcher, it calls matches?(self). If + # it returns +false+, the spec passes and execution continues. If it returns + # +true+, then the spec fails with the message returned by matcher.negative_failure_message. + # + # RSpec ships with a standard set of useful matchers, and writing your own + # matchers is quite simple. See Spec::Matchers for details. + module Expectations + end +end diff --git a/vendor/gems/gems/rspec-1.2.9/lib/spec/expectations/errors.rb b/vendor/gems/gems/rspec-1.2.9/lib/spec/expectations/errors.rb new file mode 100755 index 00000000..1fabd105 --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/lib/spec/expectations/errors.rb @@ -0,0 +1,12 @@ +module Spec + module Expectations + # If Test::Unit is loaed, we'll use its error as baseclass, so that Test::Unit + # will report unmet RSpec expectations as failures rather than errors. + superclass = ['Test::Unit::AssertionFailedError', '::StandardError'].map do |c| + eval(c) rescue nil + end.compact.first + + class ExpectationNotMetError < superclass + end + end +end diff --git a/vendor/gems/gems/rspec-1.2.9/lib/spec/expectations/extensions.rb b/vendor/gems/gems/rspec-1.2.9/lib/spec/expectations/extensions.rb new file mode 100755 index 00000000..d68212e4 --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/lib/spec/expectations/extensions.rb @@ -0,0 +1 @@ +require 'spec/expectations/extensions/kernel' diff --git a/vendor/gems/gems/rspec-1.2.9/lib/spec/expectations/extensions/kernel.rb b/vendor/gems/gems/rspec-1.2.9/lib/spec/expectations/extensions/kernel.rb new file mode 100755 index 00000000..7d884922 --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/lib/spec/expectations/extensions/kernel.rb @@ -0,0 +1,52 @@ +module Kernel + # :call-seq: + # should(matcher) + # should == expected + # should === expected + # should =~ expected + # + # receiver.should(matcher) + # => Passes if matcher.matches?(receiver) + # + # receiver.should == expected #any value + # => Passes if (receiver == expected) + # + # receiver.should === expected #any value + # => Passes if (receiver === expected) + # + # receiver.should =~ regexp + # => Passes if (receiver =~ regexp) + # + # See Spec::Matchers for more information about matchers + # + # == Warning + # + # NOTE that this does NOT support receiver.should != expected. + # Instead, use receiver.should_not == expected + def should(matcher=nil, message=nil, &block) + Spec::Expectations::PositiveExpectationHandler.handle_matcher(self, matcher, message, &block) + end + + # :call-seq: + # should_not(matcher) + # should_not == expected + # should_not === expected + # should_not =~ expected + # + # receiver.should_not(matcher) + # => Passes unless matcher.matches?(receiver) + # + # receiver.should_not == expected + # => Passes unless (receiver == expected) + # + # receiver.should_not === expected + # => Passes unless (receiver === expected) + # + # receiver.should_not =~ regexp + # => Passes unless (receiver =~ regexp) + # + # See Spec::Matchers for more information about matchers + def should_not(matcher=nil, message=nil, &block) + Spec::Expectations::NegativeExpectationHandler.handle_matcher(self, matcher, message, &block) + end +end diff --git a/vendor/gems/gems/rspec-1.2.9/lib/spec/expectations/fail_with.rb b/vendor/gems/gems/rspec-1.2.9/lib/spec/expectations/fail_with.rb new file mode 100755 index 00000000..5e01f99d --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/lib/spec/expectations/fail_with.rb @@ -0,0 +1,45 @@ +module Spec + module Expectations + class << self + attr_accessor :differ + + # raises a Spec::Expectations::ExpectationNotMetError with message + # + # When a differ has been assigned and fail_with is passed + # expected and target, passes them + # to the differ to append a diff message to the failure message. + def fail_with(message, expected=nil, target=nil) # :nodoc: + if message.nil? + raise ArgumentError, "Failure message is nil. Does your matcher define the " + + "appropriate failure_message_for_* method to return a string?" + end + if (Array === message) & (message.length == 3) + ::Spec.warn(<<-NOTICE + +***************************************************************** +DEPRECATION WARNING: you are using deprecated behaviour that will +be removed from a future version of RSpec. + +* Support for matchers that return arrays from failure message +methods is deprecated. +* Instead, the matcher should return a string, and expose methods +for the expected() and actual() values. +***************************************************************** +NOTICE + ) + message, expected, target = message[0], message[1], message[2] + end + unless (differ.nil? || expected.nil? || target.nil?) + if expected.is_a?(String) + message << "\n\n Diff:" << self.differ.diff_as_string(target.to_s, expected) + elsif expected.is_a?(Hash) && target.is_a?(Hash) + message << "\n\n Diff:" << self.differ.diff_as_hash(target, expected) + elsif !target.is_a?(Proc) + message << "\n\n Diff:" << self.differ.diff_as_object(target, expected) + end + end + Kernel::raise(Spec::Expectations::ExpectationNotMetError.new(message)) + end + end + end +end \ No newline at end of file diff --git a/vendor/gems/gems/rspec-1.2.9/lib/spec/expectations/handler.rb b/vendor/gems/gems/rspec-1.2.9/lib/spec/expectations/handler.rb new file mode 100755 index 00000000..c059637c --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/lib/spec/expectations/handler.rb @@ -0,0 +1,50 @@ +module Spec + module Expectations + class InvalidMatcherError < ArgumentError; end + + class PositiveExpectationHandler + def self.handle_matcher(actual, matcher, message=nil, &block) + ::Spec::Matchers.last_should = :should + ::Spec::Matchers.last_matcher = matcher + return ::Spec::Matchers::PositiveOperatorMatcher.new(actual) if matcher.nil? + + match = matcher.matches?(actual, &block) + return match if match + + message ||= matcher.respond_to?(:failure_message_for_should) ? + matcher.failure_message_for_should : + matcher.failure_message + + if matcher.respond_to?(:diffable?) && matcher.diffable? + ::Spec::Expectations.fail_with message, matcher.expected.first, matcher.actual + else + ::Spec::Expectations.fail_with message + end + end + end + + class NegativeExpectationHandler + def self.handle_matcher(actual, matcher, message=nil, &block) + ::Spec::Matchers.last_should = :should_not + ::Spec::Matchers.last_matcher = matcher + return ::Spec::Matchers::NegativeOperatorMatcher.new(actual) if matcher.nil? + + match = matcher.respond_to?(:does_not_match?) ? + !matcher.does_not_match?(actual, &block) : + matcher.matches?(actual, &block) + return match unless match + + message ||= matcher.respond_to?(:failure_message_for_should_not) ? + matcher.failure_message_for_should_not : + matcher.negative_failure_message + + if matcher.respond_to?(:diffable?) && matcher.diffable? + ::Spec::Expectations.fail_with message, matcher.expected.first, matcher.actual + else + ::Spec::Expectations.fail_with message + end + end + end + end +end + diff --git a/vendor/gems/gems/rspec-1.2.9/lib/spec/interop/test.rb b/vendor/gems/gems/rspec-1.2.9/lib/spec/interop/test.rb new file mode 100755 index 00000000..284eb32c --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/lib/spec/interop/test.rb @@ -0,0 +1,44 @@ +require 'spec' + +if Spec::Ruby.version.to_f >= 1.9 + gem 'test-unit','= 1.2.3' +end + +require 'test/unit' + +if Spec::Ruby.version.to_f >= 1.9 + require 'test/unit/version' + if Test::Unit::VERSION > '1.2.3' + raise <<-MESSAGE +#{'*' * 50} +Required: test-unit-1.2.3 +Loaded: test-unit-#{Test::Unit::VERSION} + +With ruby-1.9, rspec-#{Spec::VERSION::STRING} requires test-unit-1.2.3, and +tries to force it with "gem 'test-unit', '= 1.2.3'" in: + + #{__FILE__} + +Unfortunately, test-unit-#{Test::Unit::VERSION} was loaded anyway. While we are +aware of this bug we have not been able to track down its source. +Until we do, you have two alternatives: + +* uninstall test-unit-2.0.3 +* use 'script/spec' instead of 'rake spec' +#{'*' * 50} +MESSAGE + end +end + + +require 'test/unit/testresult' + +require 'spec/interop/test/unit/testcase' +require 'spec/interop/test/unit/testsuite_adapter' +require 'spec/interop/test/unit/autorunner' +require 'spec/interop/test/unit/testresult' +require 'spec/interop/test/unit/ui/console/testrunner' + +Spec::Example::ExampleGroupFactory.default(Test::Unit::TestCase) + +Test::Unit.run = true diff --git a/vendor/gems/gems/rspec-1.2.9/lib/spec/interop/test/unit/autorunner.rb b/vendor/gems/gems/rspec-1.2.9/lib/spec/interop/test/unit/autorunner.rb new file mode 100755 index 00000000..3944e699 --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/lib/spec/interop/test/unit/autorunner.rb @@ -0,0 +1,6 @@ +class Test::Unit::AutoRunner + remove_method :process_args + def process_args(argv) + true + end +end diff --git a/vendor/gems/gems/rspec-1.2.9/lib/spec/interop/test/unit/testcase.rb b/vendor/gems/gems/rspec-1.2.9/lib/spec/interop/test/unit/testcase.rb new file mode 100755 index 00000000..dc10a2a6 --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/lib/spec/interop/test/unit/testcase.rb @@ -0,0 +1,56 @@ +require 'test/unit/testcase' + +module Test + module Unit + # This extension of the standard Test::Unit::TestCase makes RSpec + # available from within, so that you can do things like: + # + # require 'spec/test/unit' + # + # class MyTest < Test::Unit::TestCase + # it "should work with Test::Unit assertions" do + # assert_equal 4, 2+1 + # end + # + # def test_should_work_with_rspec_expectations + # (3+1).should == 5 + # end + # end + # + # See also Spec::Example::ExampleGroup + class TestCase + extend Spec::Example::ExampleGroupMethods + include Spec::Example::ExampleMethods + + def self.suite + Test::Unit::TestSuiteAdapter.new(self) + end + + def self.example_method?(method_name) + should_method?(method_name) || test_method?(method_name) + end + + def self.test_method?(method_name) + method_name =~ /^test./ && ( + instance_method(method_name).arity == 0 || + instance_method(method_name).arity == -1 + ) + end + + before(:each) {setup} + after(:each) {teardown} + + def initialize(description, &implementation) + super + # Some Test::Unit extensions depend on @method_name being present. + @method_name = description.description + @_result = ::Test::Unit::TestResult.new + end + + def run(ignore_this_argument=nil) + super() + end + + end + end +end diff --git a/vendor/gems/gems/rspec-1.2.9/lib/spec/interop/test/unit/testresult.rb b/vendor/gems/gems/rspec-1.2.9/lib/spec/interop/test/unit/testresult.rb new file mode 100755 index 00000000..dddcfe86 --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/lib/spec/interop/test/unit/testresult.rb @@ -0,0 +1,6 @@ +class Test::Unit::TestResult + alias_method :tu_passed?, :passed? + def passed? + return tu_passed? & ::Spec::Runner.run + end +end \ No newline at end of file diff --git a/vendor/gems/gems/rspec-1.2.9/lib/spec/interop/test/unit/testsuite_adapter.rb b/vendor/gems/gems/rspec-1.2.9/lib/spec/interop/test/unit/testsuite_adapter.rb new file mode 100755 index 00000000..912762f1 --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/lib/spec/interop/test/unit/testsuite_adapter.rb @@ -0,0 +1,34 @@ +module Test + module Unit + class TestSuiteAdapter < TestSuite + attr_reader :example_group, :examples + alias_method :tests, :examples + def initialize(example_group) + @example_group = example_group + @examples = example_group.examples + end + + def name + example_group.description + end + + def run(*args) + return true unless args.empty? + example_group.run(Spec::Runner.options) + end + + def size + example_group.number_of_examples + end + + def delete(example) + examples.delete example + end + + def empty? + examples.empty? + end + end + end +end + diff --git a/vendor/gems/gems/rspec-1.2.9/lib/spec/interop/test/unit/ui/console/testrunner.rb b/vendor/gems/gems/rspec-1.2.9/lib/spec/interop/test/unit/ui/console/testrunner.rb new file mode 100755 index 00000000..8e9995e0 --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/lib/spec/interop/test/unit/ui/console/testrunner.rb @@ -0,0 +1,61 @@ +require 'test/unit/ui/console/testrunner' + +module Test + module Unit + module UI + module Console + class TestRunner + + alias_method :started_without_rspec, :started + def started_with_rspec(result) + @result = result + @need_to_output_started = true + end + alias_method :started, :started_with_rspec + + alias_method :test_started_without_rspec, :test_started + def test_started_with_rspec(name) + if @need_to_output_started + if @rspec_io + @rspec_io.rewind + output(@rspec_io.read) + end + output("Started") + @need_to_output_started = false + end + test_started_without_rspec(name) + end + alias_method :test_started, :test_started_with_rspec + + alias_method :test_finished_without_rspec, :test_finished + def test_finished_with_rspec(name) + test_finished_without_rspec(name) + @ran_test = true + end + alias_method :test_finished, :test_finished_with_rspec + + alias_method :finished_without_rspec, :finished + def finished_with_rspec(elapsed_time) + @ran_test ||= false + if @ran_test + finished_without_rspec(elapsed_time) + end + end + alias_method :finished, :finished_with_rspec + + alias_method :setup_mediator_without_rspec, :setup_mediator + def setup_mediator_with_rspec + orig_io = @io + @io = StringIO.new + setup_mediator_without_rspec + ensure + @rspec_io = @io + @io = orig_io + end + alias_method :setup_mediator, :setup_mediator_with_rspec + + end + end + end + end +end diff --git a/vendor/gems/gems/rspec-1.2.9/lib/spec/matchers.rb b/vendor/gems/gems/rspec-1.2.9/lib/spec/matchers.rb new file mode 100755 index 00000000..4ef83293 --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/lib/spec/matchers.rb @@ -0,0 +1,195 @@ +require 'spec/matchers/extensions/instance_exec' +require 'spec/matchers/pretty' +require 'spec/matchers/matcher' +require 'spec/matchers/operator_matcher' +require 'spec/matchers/be' +require 'spec/matchers/be_close' +require 'spec/matchers/be_instance_of' +require 'spec/matchers/be_kind_of' +require 'spec/matchers/change' +require 'spec/matchers/eql' +require 'spec/matchers/equal' +require 'spec/matchers/errors' +require 'spec/matchers/exist' +require 'spec/matchers/generated_descriptions' +require 'spec/matchers/has' +require 'spec/matchers/have' +require 'spec/matchers/include' +require 'spec/matchers/match' +require 'spec/matchers/match_array' +require 'spec/matchers/method_missing' +require 'spec/matchers/raise_error' +require 'spec/matchers/respond_to' +require 'spec/matchers/satisfy' +require 'spec/matchers/simple_matcher' +require 'spec/matchers/throw_symbol' +require 'spec/matchers/wrap_expectation' +require 'spec/matchers/compatibility' +require 'spec/matchers/dsl' + +module Spec + + # RSpec ships with a number of useful Expression Matchers. An Expression Matcher + # is any object that responds to the following methods: + # + # matches?(actual) + # failure_message_for_should + # + # These methods are also part of the matcher protocol, but are optional: + # + # does_not_match?(actual) + # failure_message_for_should_not + # description #optional + # + # These methods are from older versions of the protocol. They are still supported, + # but are not recommended: + # + # failure_message (use failure_message_for_should instead) + # negative_failure_message (use failure_message_for_should_not instead) + # + # See Spec::Expectations to learn how to use these as Expectation Matchers. + # + # == Predicates + # + # In addition to those Expression Matchers that are defined explicitly, RSpec will + # create custom Matchers on the fly for any arbitrary predicate, giving your specs + # a much more natural language feel. + # + # A Ruby predicate is a method that ends with a "?" and returns true or false. + # Common examples are +empty?+, +nil?+, and +instance_of?+. + # + # All you need to do is write +should be_+ followed by the predicate without + # the question mark, and RSpec will figure it out from there. For example: + # + # [].should be_empty => [].empty? #passes + # [].should_not be_empty => [].empty? #fails + # + # In addtion to prefixing the predicate matchers with "be_", you can also use "be_a_" + # and "be_an_", making your specs read much more naturally: + # + # "a string".should be_an_instance_of(String) =>"a string".instance_of?(String) #passes + # + # 3.should be_a_kind_of(Fixnum) => 3.kind_of?(Numeric) #passes + # 3.should be_a_kind_of(Numeric) => 3.kind_of?(Numeric) #passes + # 3.should be_an_instance_of(Fixnum) => 3.instance_of?(Fixnum) #passes + # 3.should_not be_instance_of(Numeric) => 3.instance_of?(Numeric) #fails + # + # RSpec will also create custom matchers for predicates like +has_key?+. To + # use this feature, just state that the object should have_key(:key) and RSpec will + # call has_key?(:key) on the target. For example: + # + # {:a => "A"}.should have_key(:a) => {:a => "A"}.has_key?(:a) #passes + # {:a => "A"}.should have_key(:b) => {:a => "A"}.has_key?(:b) #fails + # + # You can use this feature to invoke any predicate that begins with "has_", whether it is + # part of the Ruby libraries (like +Hash#has_key?+) or a method you wrote on your own class. + # + # == Custom Matchers + # + # When you find that none of the stock Expectation Matchers provide a natural + # feeling expectation, you can very easily write your own using RSpec's matcher + # DSL or writing one from scratch. + # + # === Matcher DSL + # + # Imagine that you are writing a game in which players can be in various + # zones on a virtual board. To specify that bob should be in zone 4, you + # could say: + # + # bob.current_zone.should eql(Zone.new("4")) + # + # But you might find it more expressive to say: + # + # bob.should be_in_zone("4") + # + # and/or + # + # bob.should_not be_in_zone("3") + # + # You can create such a matcher like so: + # + # Spec::Matchers.define :be_in_zone do |zone| + # match do |player| + # player.in_zone?(zone) + # end + # end + # + # This will generate a be_in_zone method that returns a matcher + # with logical default messages for failures. You can override the failure + # messages and the generated description as follows: + # + # Spec::Matchers.define :be_in_zone do |zone| + # match do |player| + # player.in_zone?(zone) + # end + # failure_message_for_should do |player| + # # generate and return the appropriate string. + # end + # failure_message_for_should_not do |player| + # # generate and return the appropriate string. + # end + # description do + # # generate and return the appropriate string. + # end + # end + # + # Each of the message-generation methods has access to the block arguments + # passed to the create method (in this case, zone). The + # failure message methods (failure_message_for_should and + # failure_message_for_should_not) are passed the actual value (the + # receiver of should or should_not). + # + # === Custom Matcher from scratch + # + # You could also write a custom matcher from scratch, as follows: + # + # class BeInZone + # def initialize(expected) + # @expected = expected + # end + # def matches?(target) + # @target = target + # @target.current_zone.eql?(Zone.new(@expected)) + # end + # def failure_message_for_should + # "expected #{@target.inspect} to be in Zone #{@expected}" + # end + # def failure_message_for_should_not + # "expected #{@target.inspect} not to be in Zone #{@expected}" + # end + # end + # + # ... and a method like this: + # + # def be_in_zone(expected) + # BeInZone.new(expected) + # end + # + # And then expose the method to your specs. This is normally done + # by including the method and the class in a module, which is then + # included in your spec: + # + # module CustomGameMatchers + # class BeInZone + # ... + # end + # + # def be_in_zone(expected) + # ... + # end + # end + # + # describe "Player behaviour" do + # include CustomGameMatchers + # ... + # end + # + # or you can include in globally in a spec_helper.rb file required + # from your spec file(s): + # + # Spec::Runner.configure do |config| + # config.include(CustomGameMatchers) + # end + # + module Matchers; end +end diff --git a/vendor/gems/gems/rspec-1.2.9/lib/spec/matchers/be.rb b/vendor/gems/gems/rspec-1.2.9/lib/spec/matchers/be.rb new file mode 100755 index 00000000..242f7c5c --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/lib/spec/matchers/be.rb @@ -0,0 +1,210 @@ +module Spec + module Matchers + + class Be #:nodoc: + include Spec::Matchers::Pretty + + def initialize(*args) + @expected = args.empty? ? true : set_expected(args.shift) + @args = args + @comparison_method = nil + end + + def matches?(actual) + @actual = actual + handling_predicate? ? run_predicate_on(actual) : match_or_compare(actual) + end + + def run_predicate_on(actual) + begin + return @result = actual.__send__(predicate, *@args) + rescue NameError => predicate_missing_error + "this needs to be here or rcov will not count this branch even though it's executed in a code example" + end + + begin + return @result = actual.__send__(present_tense_predicate, *@args) + rescue NameError + raise predicate_missing_error + end + end + + def failure_message_for_should + if handling_predicate? + if predicate == :nil? + "expected nil, got #{@actual.inspect}" + else + "expected #{predicate}#{args_to_s} to return true, got #{@result.inspect}" + end + else + "expected #{@comparison_method} #{expected}, got #{@actual.inspect}".gsub(' ',' ') + end + end + + def failure_message_for_should_not + if handling_predicate? + if predicate == :nil? + "expected not nil, got nil" + else + "expected #{predicate}#{args_to_s} to return false, got #{@result.inspect}" + end + else + message = <<-MESSAGE +'should_not be #{@comparison_method} #{expected}' not only FAILED, +it is a bit confusing. + MESSAGE + + raise message << ([:===,:==].include?(@comparison_method) ? + "It might be more clearly expressed without the \"be\"?" : + "It might be more clearly expressed in the positive?") + end + end + + def description + "#{prefix_to_sentence}#{comparison} #{expected_to_sentence}#{args_to_sentence}".gsub(/\s+/,' ') + end + + [:==, :<, :<=, :>=, :>, :===].each do |method| + define_method method do |expected| + compare_to(expected, :using => method) + self + end + end + + private + def match_or_compare(actual) + TrueClass === @expected ? @actual : @actual.__send__(comparison_method, @expected) + end + + def comparison_method + @comparison_method || :equal? + end + + def expected + @expected + end + + def compare_to(expected, opts) + @expected, @comparison_method = expected, opts[:using] + end + + def set_expected(expected) + Symbol === expected ? parse_expected(expected) : expected + end + + def parse_expected(expected) + ["be_an_","be_a_","be_"].each do |prefix| + handling_predicate! + if expected.to_s =~ /^#{prefix}/ + set_prefix(prefix) + expected = expected.to_s.sub(prefix,"") + [true, false, nil].each do |val| + return val if val.to_s == expected + end + return expected.to_sym + end + end + end + + def set_prefix(prefix) + @prefix = prefix + end + + def prefix + # FIXME - this is a bit goofy - but we get failures + # if just defining @prefix = nil in initialize + @prefix = nil unless defined?(@prefix) + @prefix + end + + def handling_predicate! + @handling_predicate = true + end + + def handling_predicate? + return false if [true, false, nil].include?(expected) + # FIXME - this is a bit goofy - but we get failures + # if just defining @handling_predicate = nil or false in initialize + return defined?(@handling_predicate) ? @handling_predicate : nil + end + + def predicate + "#{@expected.to_s}?".to_sym + end + + def present_tense_predicate + "#{@expected.to_s}s?".to_sym + end + + def args_to_s + @args.empty? ? "" : parenthesize(inspected_args.join(', ')) + end + + def parenthesize(string) + return "(#{string})" + end + + def inspected_args + @args.collect{|a| a.inspect} + end + + def comparison + @comparison_method.nil? ? " " : "be #{@comparison_method.to_s} " + end + + def expected_to_sentence + split_words(expected) + end + + def prefix_to_sentence + split_words(prefix) + end + + def args_to_sentence + to_sentence(@args) + end + + end + + # :call-seq: + # should be_true + # should be_false + # should be_nil + # should be_[arbitrary_predicate](*args) + # should_not be_nil + # should_not be_[arbitrary_predicate](*args) + # + # Given true, false, or nil, will pass if actual value is + # true, false or nil (respectively). Given no args means + # the caller should satisfy an if condition (to be or not to be). + # + # Predicates are any Ruby method that ends in a "?" and returns true or false. + # Given be_ followed by arbitrary_predicate (without the "?"), RSpec will match + # convert that into a query against the target object. + # + # The arbitrary_predicate feature will handle any predicate + # prefixed with "be_an_" (e.g. be_an_instance_of), "be_a_" (e.g. be_a_kind_of) + # or "be_" (e.g. be_empty), letting you choose the prefix that best suits the predicate. + # + # == Examples + # + # target.should be_true + # target.should be_false + # target.should be_nil + # target.should_not be_nil + # + # collection.should be_empty #passes if target.empty? + # target.should_not be_empty #passes unless target.empty? + # target.should_not be_old_enough(16) #passes unless target.old_enough?(16) + def be(*args) + Matchers::Be.new(*args) + end + + # passes if target.kind_of?(klass) + def be_a(klass) + be_a_kind_of(klass) + end + + alias_method :be_an, :be_a + end +end diff --git a/vendor/gems/gems/rspec-1.2.9/lib/spec/matchers/be_close.rb b/vendor/gems/gems/rspec-1.2.9/lib/spec/matchers/be_close.rb new file mode 100755 index 00000000..28015f5f --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/lib/spec/matchers/be_close.rb @@ -0,0 +1,32 @@ +module Spec + module Matchers + # :call-seq: + # should be_close(expected, delta) + # should_not be_close(expected, delta) + # + # Passes if actual == expected +/- delta + # + # == Example + # + # result.should be_close(3.0, 0.5) + def be_close(expected, delta) + Matcher.new :be_close, expected, delta do |_expected_, _delta_| + match do |actual| + (actual - _expected_).abs < _delta_ + end + + failure_message_for_should do |actual| + "expected #{_expected_} +/- (< #{_delta_}), got #{actual}" + end + + failure_message_for_should_not do |actual| + "expected #{_expected_} +/- (< #{_delta_}), got #{actual}" + end + + description do + "be close to #{_expected_} (within +- #{_delta_})" + end + end + end + end +end diff --git a/vendor/gems/gems/rspec-1.2.9/lib/spec/matchers/be_instance_of.rb b/vendor/gems/gems/rspec-1.2.9/lib/spec/matchers/be_instance_of.rb new file mode 100755 index 00000000..ffc23840 --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/lib/spec/matchers/be_instance_of.rb @@ -0,0 +1,26 @@ +module Spec + module Matchers + # :call-seq: + # should be_instance_of(expected) + # should be_an_instance_of(expected) + # should_not be_instance_of(expected) + # should_not be_an_instance_of(expected) + # + # Passes if actual.instance_of?(expected) + # + # == Examples + # + # 5.should be_instance_of(Fixnum) + # 5.should_not be_instance_of(Numeric) + # 5.should_not be_instance_of(Float) + def be_an_instance_of(expected) + Matcher.new :be_an_instance_of, expected do |_expected_| + match do |actual| + actual.instance_of?(_expected_) + end + end + end + + alias_method :be_instance_of, :be_an_instance_of + end +end diff --git a/vendor/gems/gems/rspec-1.2.9/lib/spec/matchers/be_kind_of.rb b/vendor/gems/gems/rspec-1.2.9/lib/spec/matchers/be_kind_of.rb new file mode 100755 index 00000000..6a1fddc1 --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/lib/spec/matchers/be_kind_of.rb @@ -0,0 +1,26 @@ +module Spec + module Matchers + # :call-seq: + # should be_kind_of(expected) + # should be_a_kind_of(expected) + # should_not be_kind_of(expected) + # should_not be_a_kind_of(expected) + # + # Passes if actual.kind_of?(expected) + # + # == Examples + # + # 5.should be_kind_of(Fixnum) + # 5.should be_kind_of(Numeric) + # 5.should_not be_kind_of(Float) + def be_a_kind_of(expected) + Matcher.new :be_a_kind_of, expected do |_expected_| + match do |actual| + actual.kind_of?(_expected_) + end + end + end + + alias_method :be_kind_of, :be_a_kind_of + end +end diff --git a/vendor/gems/gems/rspec-1.2.9/lib/spec/matchers/change.rb b/vendor/gems/gems/rspec-1.2.9/lib/spec/matchers/change.rb new file mode 100755 index 00000000..c8ab9e5c --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/lib/spec/matchers/change.rb @@ -0,0 +1,151 @@ +module Spec + module Matchers + + #Based on patch from Wilson Bilkovich + class Change #:nodoc: + def initialize(receiver=nil, message=nil, &block) + @message = message || "result" + @value_proc = block || lambda {receiver.__send__(message)} + @to = @from = @minimum = @maximum = @amount = nil + end + + def matches?(event_proc) + raise_block_syntax_error if block_given? + + @before = evaluate_value_proc + event_proc.call + @after = evaluate_value_proc + + return (@to = false) if @from unless @from == @before + return false if @to unless @to == @after + return (@before + @amount == @after) if @amount + return ((@after - @before) >= @minimum) if @minimum + return ((@after - @before) <= @maximum) if @maximum + return @before != @after + end + + def raise_block_syntax_error + raise MatcherError.new(<<-MESSAGE +block passed to should or should_not change must use {} instead of do/end +MESSAGE + ) + end + + def evaluate_value_proc + @value_proc.call + end + + def failure_message_for_should + if @to + "#{@message} should have been changed to #{@to.inspect}, but is now #{@after.inspect}" + elsif @from + "#{@message} should have initially been #{@from.inspect}, but was #{@before.inspect}" + elsif @amount + "#{@message} should have been changed by #{@amount.inspect}, but was changed by #{actual_delta.inspect}" + elsif @minimum + "#{@message} should have been changed by at least #{@minimum.inspect}, but was changed by #{actual_delta.inspect}" + elsif @maximum + "#{@message} should have been changed by at most #{@maximum.inspect}, but was changed by #{actual_delta.inspect}" + else + "#{@message} should have changed, but is still #{@before.inspect}" + end + end + + def actual_delta + @after - @before + end + + def failure_message_for_should_not + "#{@message} should not have changed, but did change from #{@before.inspect} to #{@after.inspect}" + end + + def by(amount) + @amount = amount + self + end + + def by_at_least(minimum) + @minimum = minimum + self + end + + def by_at_most(maximum) + @maximum = maximum + self + end + + def to(to) + @to = to + self + end + + def from (from) + @from = from + self + end + + def description + "change ##{@message}" + end + end + + # :call-seq: + # should change(receiver, message, &block) + # should change(receiver, message, &block).by(value) + # should change(receiver, message, &block).from(old).to(new) + # should_not change(receiver, message, &block) + # + # Allows you to specify that a Proc will cause some value to change. + # + # == Examples + # + # lambda { + # team.add_player(player) + # }.should change(roster, :count) + # + # lambda { + # team.add_player(player) + # }.should change(roster, :count).by(1) + # + # lambda { + # team.add_player(player) + # }.should change(roster, :count).by_at_least(1) + # + # lambda { + # team.add_player(player) + # }.should change(roster, :count).by_at_most(1) + # + # string = "string" + # lambda { + # string.reverse! + # }.should change { string }.from("string").to("gnirts") + # + # lambda { + # person.happy_birthday + # }.should change(person, :birthday).from(32).to(33) + # + # lambda { + # employee.develop_great_new_social_networking_app + # }.should change(employee, :title).from("Mail Clerk").to("CEO") + # + # Evaluates receiver.message or block before and after + # it evaluates the c object (generated by the lambdas in the examples + # above). + # + # Then compares the values before and after the receiver.message + # and evaluates the difference compared to the expected difference. + # + # == WARNING + # should_not change only supports the form with no + # subsequent calls to by, by_at_least, + # by_at_most, to or from. + # + # blocks passed to should change and should_not + # change must use the {} form (do/end is not + # supported). + # + def change(receiver=nil, message=nil, &block) + Matchers::Change.new(receiver, message, &block) + end + end +end diff --git a/vendor/gems/gems/rspec-1.2.9/lib/spec/matchers/compatibility.rb b/vendor/gems/gems/rspec-1.2.9/lib/spec/matchers/compatibility.rb new file mode 100755 index 00000000..3b3ddb9b --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/lib/spec/matchers/compatibility.rb @@ -0,0 +1,14 @@ +Spec::Matchers.constants.each do |c| + if Class === (klass = Spec::Matchers.const_get(c)) + if klass.public_instance_methods.any? {|m| ['failure_message_for_should',:failure_message_for_should].include?(m)} + klass.class_eval do + alias_method :failure_message, :failure_message_for_should + end + end + if klass.public_instance_methods.any? {|m| ['failure_message_for_should_not',:failure_message_for_should_not].include?(m)} + klass.class_eval do + alias_method :negative_failure_message, :failure_message_for_should_not + end + end + end +end diff --git a/vendor/gems/gems/rspec-1.2.9/lib/spec/matchers/dsl.rb b/vendor/gems/gems/rspec-1.2.9/lib/spec/matchers/dsl.rb new file mode 100755 index 00000000..73f36345 --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/lib/spec/matchers/dsl.rb @@ -0,0 +1,20 @@ +module Spec + module Matchers + module DSL + # See Spec::Matchers + def define(name, &declarations) + define_method name do |*expected| + Spec::Matchers::Matcher.new name, *expected, &declarations + end + end + + # Deprecated - use define + def create(name, &declarations) + Spec.deprecate("Spec::Matchers.create","Spec::Matchers.define") + define(name, &declarations) + end + end + end +end + +Spec::Matchers.extend Spec::Matchers::DSL diff --git a/vendor/gems/gems/rspec-1.2.9/lib/spec/matchers/eql.rb b/vendor/gems/gems/rspec-1.2.9/lib/spec/matchers/eql.rb new file mode 100755 index 00000000..98ab198d --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/lib/spec/matchers/eql.rb @@ -0,0 +1,42 @@ +module Spec + module Matchers + # :call-seq: + # should eql(expected) + # should_not eql(expected) + # + # Passes if actual and expected are of equal value, but not necessarily the same object. + # + # See http://www.ruby-doc.org/core/classes/Object.html#M001057 for more information about equality in Ruby. + # + # == Examples + # + # 5.should eql(5) + # 5.should_not eql(3) + def eql(expected) + Matcher.new :eql, expected do |_expected_| + match do |actual| + actual.eql?(_expected_) + end + + failure_message_for_should do |actual| + <<-MESSAGE + +expected #{_expected_.inspect} + got #{actual.inspect} + +(compared using eql?) +MESSAGE + end + + failure_message_for_should_not do |actual| + <<-MESSAGE + +expected #{actual.inspect} not to equal #{_expected_.inspect} + +(compared using eql?) +MESSAGE + end + end + end + end +end diff --git a/vendor/gems/gems/rspec-1.2.9/lib/spec/matchers/equal.rb b/vendor/gems/gems/rspec-1.2.9/lib/spec/matchers/equal.rb new file mode 100755 index 00000000..3580a95a --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/lib/spec/matchers/equal.rb @@ -0,0 +1,53 @@ +module Spec + module Matchers + + # :call-seq: + # should equal(expected) + # should_not equal(expected) + # + # Passes if actual and expected are the same object (object identity). + # + # See http://www.ruby-doc.org/core/classes/Object.html#M001057 for more information about equality in Ruby. + # + # == Examples + # + # 5.should equal(5) #Fixnums are equal + # "5".should_not equal("5") #Strings that look the same are not the same object + def equal(expected) + Matcher.new :equal, expected do |_expected_| + match do |actual| + actual.equal?(_expected_) + end + + def inspect_object(o) + "#<#{o.class}:#{o.object_id}> => #{o.inspect}" + end + + failure_message_for_should do |actual| + <<-MESSAGE + +expected #{inspect_object(_expected_)} + got #{inspect_object(actual)} + +Compared using equal?, which compares object identity, +but expected and actual are not the same object. Use +'actual.should == expected' if you don't care about +object identity in this example. + +MESSAGE + end + + failure_message_for_should_not do |actual| + <<-MESSAGE + +expected not #{inspect_object(actual)} + got #{inspect_object(_expected_)} + +Compared using equal?, which compares object identity. + +MESSAGE + end + end + end + end +end diff --git a/vendor/gems/gems/rspec-1.2.9/lib/spec/matchers/errors.rb b/vendor/gems/gems/rspec-1.2.9/lib/spec/matchers/errors.rb new file mode 100755 index 00000000..49c26779 --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/lib/spec/matchers/errors.rb @@ -0,0 +1,5 @@ +module Spec + module Matchers + class MatcherError < StandardError; end + end +end \ No newline at end of file diff --git a/vendor/gems/gems/rspec-1.2.9/lib/spec/matchers/exist.rb b/vendor/gems/gems/rspec-1.2.9/lib/spec/matchers/exist.rb new file mode 100755 index 00000000..dc69c683 --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/lib/spec/matchers/exist.rb @@ -0,0 +1,16 @@ +module Spec + module Matchers + # :call-seq: + # should exist + # should_not exist + # + # Passes if actual.exist? + def exist(arg=nil) + Matcher.new :exist do + match do |actual| + arg ? actual.exist?(arg) : actual.exist? + end + end + end + end +end diff --git a/vendor/gems/gems/rspec-1.2.9/lib/spec/matchers/extensions/instance_exec.rb b/vendor/gems/gems/rspec-1.2.9/lib/spec/matchers/extensions/instance_exec.rb new file mode 100755 index 00000000..ca7e14ea --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/lib/spec/matchers/extensions/instance_exec.rb @@ -0,0 +1,31 @@ +module Spec + module Matchers + module InstanceExec + unless respond_to?(:instance_exec) + # based on Bounded Spec InstanceExec (Mauricio Fernandez) + # http://eigenclass.org/hiki/bounded+space+instance_exec + # - uses singleton_class of matcher instead of global + # InstanceExecHelper module + # - this keeps it scoped to this class only, which is the + # only place we need it + # - only necessary for ruby 1.8.6 + def instance_exec(*args, &block) + singleton_class = (class << self; self; end) + begin + orig_critical, Thread.critical = Thread.critical, true + n = 0 + n += 1 while respond_to?(method_name="__instance_exec#{n}") + singleton_class.module_eval{ define_method(:__instance_exec, &block) } + ensure + Thread.critical = orig_critical + end + begin + return send(:__instance_exec, *args) + ensure + singleton_class.module_eval{ remove_method(:__instance_exec) } rescue nil + end + end + end + end + end +end \ No newline at end of file diff --git a/vendor/gems/gems/rspec-1.2.9/lib/spec/matchers/generated_descriptions.rb b/vendor/gems/gems/rspec-1.2.9/lib/spec/matchers/generated_descriptions.rb new file mode 100755 index 00000000..2340f57d --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/lib/spec/matchers/generated_descriptions.rb @@ -0,0 +1,36 @@ +module Spec + module Matchers + class << self + attr_accessor :last_matcher, :last_should # :nodoc: + end + + def self.clear_generated_description + self.last_matcher = nil + self.last_should = nil + end + + def self.generated_description + return nil if last_should.nil? + "#{last_should.to_s.gsub('_',' ')} #{last_description}" + end + + private + + def self.last_description + last_matcher.respond_to?(:description) ? last_matcher.description : <<-MESSAGE +When you call a matcher in an example without a String, like this: + +specify { object.should matcher } + +or this: + +it { should matcher } + +RSpec expects the matcher to have a #description method. You should either +add a String to the example this matcher is being used in, or give it a +description method. Then you won't have to suffer this lengthy warning again. +MESSAGE + end + end +end + diff --git a/vendor/gems/gems/rspec-1.2.9/lib/spec/matchers/has.rb b/vendor/gems/gems/rspec-1.2.9/lib/spec/matchers/has.rb new file mode 100755 index 00000000..7073e0a8 --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/lib/spec/matchers/has.rb @@ -0,0 +1,35 @@ +module Spec + module Matchers + + class Has + + def initialize(expected, *args) + @expected, @args = expected, args + end + + def matches?(actual) + actual.__send__(predicate(@expected), *@args) + end + + def failure_message_for_should + "expected ##{predicate(@expected)}(#{@args[0].inspect}) to return true, got false" + end + + def failure_message_for_should_not + "expected ##{predicate(@expected)}(#{@args[0].inspect}) to return false, got true" + end + + def description + "have key #{@args[0].inspect}" + end + + private + + def predicate(sym) + "#{sym.to_s.sub("have_","has_")}?".to_sym + end + + end + + end +end diff --git a/vendor/gems/gems/rspec-1.2.9/lib/spec/matchers/have.rb b/vendor/gems/gems/rspec-1.2.9/lib/spec/matchers/have.rb new file mode 100755 index 00000000..2975ee12 --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/lib/spec/matchers/have.rb @@ -0,0 +1,151 @@ +module Spec + module Matchers + class Have #:nodoc: + def initialize(expected, relativity=:exactly) + @expected = (expected == :no ? 0 : expected) + @relativity = relativity + @actual = nil + end + + def relativities + @relativities ||= { + :exactly => "", + :at_least => "at least ", + :at_most => "at most " + } + end + + def matches?(collection_owner) + if collection_owner.respond_to?(@collection_name) + collection = collection_owner.__send__(@collection_name, *@args, &@block) + elsif (@plural_collection_name && collection_owner.respond_to?(@plural_collection_name)) + collection = collection_owner.__send__(@plural_collection_name, *@args, &@block) + elsif (collection_owner.respond_to?(:length) || collection_owner.respond_to?(:size)) + collection = collection_owner + else + collection_owner.__send__(@collection_name, *@args, &@block) + end + @actual = collection.size if collection.respond_to?(:size) + @actual = collection.length if collection.respond_to?(:length) + raise not_a_collection if @actual.nil? + return @actual >= @expected if @relativity == :at_least + return @actual <= @expected if @relativity == :at_most + return @actual == @expected + end + + def not_a_collection + "expected #{@collection_name} to be a collection but it does not respond to #length or #size" + end + + def failure_message_for_should + "expected #{relative_expectation} #{@collection_name}, got #{@actual}" + end + + def failure_message_for_should_not + if @relativity == :exactly + return "expected target not to have #{@expected} #{@collection_name}, got #{@actual}" + elsif @relativity == :at_most + return <<-EOF +Isn't life confusing enough? +Instead of having to figure out the meaning of this: + should_not have_at_most(#{@expected}).#{@collection_name} +We recommend that you use this instead: + should have_at_least(#{@expected + 1}).#{@collection_name} +EOF + elsif @relativity == :at_least + return <<-EOF +Isn't life confusing enough? +Instead of having to figure out the meaning of this: + should_not have_at_least(#{@expected}).#{@collection_name} +We recommend that you use this instead: + should have_at_most(#{@expected - 1}).#{@collection_name} +EOF + end + end + + def description + "have #{relative_expectation} #{@collection_name}" + end + + def respond_to?(sym) + @expected.respond_to?(sym) || super + end + + private + + def method_missing(sym, *args, &block) + @collection_name = sym + if inflector = (defined?(ActiveSupport::Inflector) ? ActiveSupport::Inflector : (defined?(Inflector) ? Inflector : nil)) + @plural_collection_name = inflector.pluralize(sym.to_s) + end + @args = args + @block = block + self + end + + def relative_expectation + "#{relativities[@relativity]}#{@expected}" + end + end + + # :call-seq: + # should have(number).named_collection__or__sugar + # should_not have(number).named_collection__or__sugar + # + # Passes if receiver is a collection with the submitted + # number of items OR if the receiver OWNS a collection + # with the submitted number of items. + # + # If the receiver OWNS the collection, you must use the name + # of the collection. So if a Team instance has a + # collection named #players, you must use that name + # to set the expectation. + # + # If the receiver IS the collection, you can use any name + # you like for named_collection. We'd recommend using + # either "elements", "members", or "items" as these are all + # standard ways of describing the things IN a collection. + # + # This also works for Strings, letting you set an expectation + # about its length + # + # == Examples + # + # # Passes if team.players.size == 11 + # team.should have(11).players + # + # # Passes if [1,2,3].length == 3 + # [1,2,3].should have(3).items #"items" is pure sugar + # + # # Passes if "this string".length == 11 + # "this string".should have(11).characters #"characters" is pure sugar + def have(n) + Matchers::Have.new(n) + end + alias :have_exactly :have + + # :call-seq: + # should have_at_least(number).items + # + # Exactly like have() with >=. + # + # == Warning + # + # +should_not+ +have_at_least+ is not supported + def have_at_least(n) + Matchers::Have.new(n, :at_least) + end + + # :call-seq: + # should have_at_most(number).items + # + # Exactly like have() with <=. + # + # == Warning + # + # +should_not+ +have_at_most+ is not supported + def have_at_most(n) + Matchers::Have.new(n, :at_most) + end + end +end diff --git a/vendor/gems/gems/rspec-1.2.9/lib/spec/matchers/include.rb b/vendor/gems/gems/rspec-1.2.9/lib/spec/matchers/include.rb new file mode 100755 index 00000000..a2a7fe3d --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/lib/spec/matchers/include.rb @@ -0,0 +1,44 @@ +module Spec + module Matchers + # :call-seq: + # should include(expected) + # should_not include(expected) + # + # Passes if actual includes expected. This works for + # collections and Strings. You can also pass in multiple args + # and it will only pass if all args are found in collection. + # + # == Examples + # + # [1,2,3].should include(3) + # [1,2,3].should include(2,3) #would pass + # [1,2,3].should include(2,3,4) #would fail + # [1,2,3].should_not include(4) + # "spread".should include("read") + # "spread".should_not include("red") + def include(*expected) + Matcher.new :include, *expected do |*_expected_| + match do |actual| + helper(actual, *_expected_) + end + + def helper(actual, *_expected_) + _expected_.each do |expected| + if actual.is_a?(Hash) + if expected.is_a?(Hash) + expected.each_pair do |k,v| + return false unless actual[k] == v + end + else + return false unless actual.has_key?(expected) + end + else + return false unless actual.include?(expected) + end + end + true + end + end + end + end +end diff --git a/vendor/gems/gems/rspec-1.2.9/lib/spec/matchers/match.rb b/vendor/gems/gems/rspec-1.2.9/lib/spec/matchers/match.rb new file mode 100755 index 00000000..b4b9ea86 --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/lib/spec/matchers/match.rb @@ -0,0 +1,21 @@ +module Spec + module Matchers + # :call-seq: + # should match(pattern) + # should_not match(pattern) + # + # Given a Regexp or String, passes if actual.match(pattern) + # + # == Examples + # + # email.should match(/^([^\s]+)((?:[-a-z0-9]+\.)+[a-z]{2,})$/i) + # email.should match("@example.com") + def match(expected) + Matcher.new :match, expected do |_expected_| + match do |actual| + actual.match(_expected_) + end + end + end + end +end diff --git a/vendor/gems/gems/rspec-1.2.9/lib/spec/matchers/match_array.rb b/vendor/gems/gems/rspec-1.2.9/lib/spec/matchers/match_array.rb new file mode 100755 index 00000000..51b4f392 --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/lib/spec/matchers/match_array.rb @@ -0,0 +1,71 @@ +module Spec + module Matchers + + class MatchArray #:nodoc: + include Spec::Matchers::Pretty + + def initialize(expected) + @expected = expected + end + + def matches?(actual) + @actual = actual + @extra_items = difference_between_arrays(@actual, @expected) + @missing_items = difference_between_arrays(@expected, @actual) + @extra_items.empty? & @missing_items.empty? + end + + def failure_message_for_should + message = "expected collection contained: #{safe_sort(@expected).inspect}\n" + message += "actual collection contained: #{safe_sort(@actual).inspect}\n" + message += "the missing elements were: #{safe_sort(@missing_items).inspect}\n" unless @missing_items.empty? + message += "the extra elements were: #{safe_sort(@extra_items).inspect}\n" unless @extra_items.empty? + message + end + + def failure_message_for_should_not + "Matcher does not support should_not" + end + + def description + "contain exactly #{_pretty_print(@expected)}" + end + + private + + def safe_sort(array) + array.all?{|item| item.respond_to?(:<=>)} ? array.sort : array + end + + def difference_between_arrays(array_1, array_2) + difference = array_1.dup + array_2.each do |element| + if index = difference.index(element) + difference.delete_at(index) + end + end + difference + end + + + end + + # :call-seq: + # should =~ expected + # + # Passes if actual contains all of the expected regardless of order. + # This works for collections. Pass in multiple args and it will only + # pass if all args are found in collection. + # + # NOTE: there is no should_not version of array.should =~ other_array + # + # == Examples + # + # [1,2,3].should =~ [1,2,3] # => would pass + # [1,2,3].should =~ [2,3,1] # => would pass + # [1,2,3,4].should =~ [1,2,3] # => would fail + # [1,2,2,3].should =~ [1,2,3] # => would fail + # [1,2,3].should =~ [1,2,3,4] # => would fail + OperatorMatcher.register(Array, '=~', Spec::Matchers::MatchArray) + end +end diff --git a/vendor/gems/gems/rspec-1.2.9/lib/spec/matchers/matcher.rb b/vendor/gems/gems/rspec-1.2.9/lib/spec/matchers/matcher.rb new file mode 100755 index 00000000..165ddffb --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/lib/spec/matchers/matcher.rb @@ -0,0 +1,87 @@ +module Spec + module Matchers + class Matcher + include Spec::Matchers::InstanceExec + include Spec::Matchers::Pretty + include Spec::Matchers + + attr_reader :expected, :actual + + def initialize(name, *expected, &declarations) + @name = name + @expected = expected + @actual = nil + @diffable = false + @messages = { + :description => lambda {"#{name_to_sentence}#{expected_to_sentence}"}, + :failure_message_for_should => lambda {|actual| "expected #{actual.inspect} to #{name_to_sentence}#{expected_to_sentence}"}, + :failure_message_for_should_not => lambda {|actual| "expected #{actual.inspect} not to #{name_to_sentence}#{expected_to_sentence}"} + } + making_declared_methods_public do + instance_exec(*@expected, &declarations) + end + end + + def matches?(actual) + instance_exec(@actual = actual, &@match_block) + end + + def description(&block) + cache_or_call_cached(:description, &block) + end + + def failure_message_for_should(&block) + cache_or_call_cached(:failure_message_for_should, actual, &block) + end + + def failure_message_for_should_not(&block) + cache_or_call_cached(:failure_message_for_should_not, actual, &block) + end + + def match(&block) + @match_block = block + end + + def diffable? + @diffable + end + + def diffable + @diffable = true + end + + private + + def making_declared_methods_public # :nodoc: + # Our home-grown instance_exec in ruby 1.8.6 results in any methods + # declared in the block eval'd by instance_exec in the block to which we + # are yielding here are scoped private. This is NOT the case for Ruby + # 1.8.7 or 1.9. + # + # Also, due some crazy scoping that I don't understand, these methods + # are actually available in the specs (something about the matcher being + # defined in the scope of Spec::Matchers or within an example), so not + # doing the following will not cause specs to fail, but they *will* + # cause features to fail and that will make users unhappy. So don't. + orig_private_methods = private_methods + yield + st = (class << self; self; end) + (private_methods - orig_private_methods).each {|m| st.__send__ :public, m} + end + + def cache_or_call_cached(key, actual=nil, &block) + block ? @messages[key] = block : + actual.nil? ? @messages[key].call : @messages[key].call(actual) + end + + def name_to_sentence + split_words(@name) + end + + def expected_to_sentence + to_sentence(@expected) + end + + end + end +end diff --git a/vendor/gems/gems/rspec-1.2.9/lib/spec/matchers/method_missing.rb b/vendor/gems/gems/rspec-1.2.9/lib/spec/matchers/method_missing.rb new file mode 100755 index 00000000..ae7f3979 --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/lib/spec/matchers/method_missing.rb @@ -0,0 +1,9 @@ +module Spec + module Matchers + def method_missing(sym, *args, &block) # :nodoc: + return Matchers::Be.new(sym, *args) if sym.to_s =~ /^be_/ + return Matchers::Has.new(sym, *args) if sym.to_s =~ /^have_/ + super + end + end +end diff --git a/vendor/gems/gems/rspec-1.2.9/lib/spec/matchers/operator_matcher.rb b/vendor/gems/gems/rspec-1.2.9/lib/spec/matchers/operator_matcher.rb new file mode 100755 index 00000000..30295be0 --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/lib/spec/matchers/operator_matcher.rb @@ -0,0 +1,78 @@ +module Spec + module Matchers + + class OperatorMatcher + class << self + def registry + @registry ||= {} + end + + def register(klass, operator, matcher) + registry[klass] ||= {} + registry[klass][operator] = matcher + end + + def get(klass, operator) + registry[klass] && registry[klass][operator] + end + end + + def initialize(actual) + @actual = actual + end + + def self.use_custom_matcher_or_delegate(operator) + define_method(operator) do |expected| + if matcher = OperatorMatcher.get(@actual.class, operator) + @actual.send(::Spec::Matchers.last_should, matcher.new(expected)) + else + eval_match(@actual, operator, expected) + end + end + end + + ['==', '===', '=~', '>', '>=', '<', '<='].each do |operator| + use_custom_matcher_or_delegate operator + end + + def fail_with_message(message) + Spec::Expectations.fail_with(message, @expected, @actual) + end + + def description + "#{@operator} #{@expected.inspect}" + end + + private + + def eval_match(actual, operator, expected) + ::Spec::Matchers.last_matcher = self + @operator, @expected = operator, expected + __delegate_operator(actual, operator, expected) + end + + end + + class PositiveOperatorMatcher < OperatorMatcher #:nodoc: + def __delegate_operator(actual, operator, expected) + if actual.__send__(operator, expected) + true + elsif ['==','===', '=~'].include?(operator) + fail_with_message("expected: #{expected.inspect},\n got: #{actual.inspect} (using #{operator})") + else + fail_with_message("expected: #{operator} #{expected.inspect},\n got: #{operator.gsub(/./, ' ')} #{actual.inspect}") + end + end + + end + + class NegativeOperatorMatcher < OperatorMatcher #:nodoc: + def __delegate_operator(actual, operator, expected) + return false unless actual.__send__(operator, expected) + return fail_with_message("expected not: #{operator} #{expected.inspect},\n got: #{operator.gsub(/./, ' ')} #{actual.inspect}") + end + + end + + end +end diff --git a/vendor/gems/gems/rspec-1.2.9/lib/spec/matchers/pretty.rb b/vendor/gems/gems/rspec-1.2.9/lib/spec/matchers/pretty.rb new file mode 100755 index 00000000..15205837 --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/lib/spec/matchers/pretty.rb @@ -0,0 +1,37 @@ +module Spec + module Matchers + module Pretty + def split_words(sym) + sym.to_s.gsub(/_/,' ') + end + + def to_sentence(words) + words = words.map{|w| w.inspect} + case words.length + when 0 + "" + when 1 + " #{words[0]}" + when 2 + " #{words[0]} and #{words[1]}" + else + " #{words[0...-1].join(', ')}, and #{words[-1]}" + end + end + + def _pretty_print(array) + result = "" + array.each_with_index do |item, index| + if index < (array.length - 2) + result << "#{item.inspect}, " + elsif index < (array.length - 1) + result << "#{item.inspect} and " + else + result << "#{item.inspect}" + end + end + result + end + end + end +end \ No newline at end of file diff --git a/vendor/gems/gems/rspec-1.2.9/lib/spec/matchers/raise_error.rb b/vendor/gems/gems/rspec-1.2.9/lib/spec/matchers/raise_error.rb new file mode 100755 index 00000000..65bdf237 --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/lib/spec/matchers/raise_error.rb @@ -0,0 +1,129 @@ +module Spec + module Matchers + class RaiseError #:nodoc: + def initialize(expected_error_or_message=Exception, expected_message=nil, &block) + @block = block + @actual_error = nil + case expected_error_or_message + when String, Regexp + @expected_error, @expected_message = Exception, expected_error_or_message + else + @expected_error, @expected_message = expected_error_or_message, expected_message + end + end + + def matches?(given_proc) + @raised_expected_error = false + @with_expected_message = false + @eval_block = false + @eval_block_passed = false + begin + given_proc.call + rescue @expected_error => @actual_error + @raised_expected_error = true + @with_expected_message = verify_message + rescue Exception => @actual_error + # This clause should be empty, but rcov will not report it as covered + # unless something (anything) is executed within the clause + rcov_error_report = "http://eigenclass.org/hiki.rb?rcov-0.8.0" + end + + unless negative_expectation? + eval_block if @raised_expected_error && @with_expected_message && @block + end + ensure + return (@raised_expected_error & @with_expected_message) ? (@eval_block ? @eval_block_passed : true) : false + end + + def eval_block + @eval_block = true + begin + @block[@actual_error] + @eval_block_passed = true + rescue Exception => err + @actual_error = err + end + end + + def verify_message + case @expected_message + when nil + true + when Regexp + @expected_message =~ @actual_error.message + else + @expected_message == @actual_error.message + end + end + + def failure_message_for_should + @eval_block ? @actual_error.message : "expected #{expected_error}#{given_error}" + end + + def failure_message_for_should_not + "expected no #{expected_error}#{given_error}" + end + + def description + "raise #{expected_error}" + end + + private + def expected_error + case @expected_message + when nil + @expected_error + when Regexp + "#{@expected_error} with message matching #{@expected_message.inspect}" + else + "#{@expected_error} with #{@expected_message.inspect}" + end + end + + def given_error + @actual_error.nil? ? " but nothing was raised" : ", got #{@actual_error.inspect}" + end + + def negative_expectation? + # YES - I'm a bad person... help me find a better way - ryand + caller.first(3).find { |s| s =~ /should_not/ } + end + end + + # :call-seq: + # should raise_error() + # should raise_error(NamedError) + # should raise_error(NamedError, String) + # should raise_error(NamedError, Regexp) + # should raise_error() { |error| ... } + # should raise_error(NamedError) { |error| ... } + # should raise_error(NamedError, String) { |error| ... } + # should raise_error(NamedError, Regexp) { |error| ... } + # should_not raise_error() + # should_not raise_error(NamedError) + # should_not raise_error(NamedError, String) + # should_not raise_error(NamedError, Regexp) + # + # With no args, matches if any error is raised. + # With a named error, matches only if that specific error is raised. + # With a named error and messsage specified as a String, matches only if both match. + # With a named error and messsage specified as a Regexp, matches only if both match. + # Pass an optional block to perform extra verifications on the exception matched + # + # == Examples + # + # lambda { do_something_risky }.should raise_error + # lambda { do_something_risky }.should raise_error(PoorRiskDecisionError) + # lambda { do_something_risky }.should raise_error(PoorRiskDecisionError) { |error| error.data.should == 42 } + # lambda { do_something_risky }.should raise_error(PoorRiskDecisionError, "that was too risky") + # lambda { do_something_risky }.should raise_error(PoorRiskDecisionError, /oo ri/) + # + # lambda { do_something_risky }.should_not raise_error + # lambda { do_something_risky }.should_not raise_error(PoorRiskDecisionError) + # lambda { do_something_risky }.should_not raise_error(PoorRiskDecisionError, "that was too risky") + # lambda { do_something_risky }.should_not raise_error(PoorRiskDecisionError, /oo ri/) + def raise_error(error=Exception, message=nil, &block) + Matchers::RaiseError.new(error, message, &block) + end + end +end diff --git a/vendor/gems/gems/rspec-1.2.9/lib/spec/matchers/respond_to.rb b/vendor/gems/gems/rspec-1.2.9/lib/spec/matchers/respond_to.rb new file mode 100755 index 00000000..9161cb94 --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/lib/spec/matchers/respond_to.rb @@ -0,0 +1,71 @@ +module Spec + module Matchers + + class RespondTo #:nodoc: + def initialize(*names) + @names = names + @expected_arity = nil + @names_not_responded_to = [] + end + + def matches?(actual) + @actual = actual + @names.each do |name| + @names_not_responded_to << name unless actual.respond_to?(name) && matches_arity?(actual, name) + end + return @names_not_responded_to.empty? + end + + def failure_message_for_should + "expected #{@actual.inspect} to respond to #{@names_not_responded_to.collect {|name| name.inspect }.join(', ')}#{with_arity}" + end + + def failure_message_for_should_not + "expected #{@actual.inspect} not to respond to #{@names.collect {|name| name.inspect }.join(', ')}" + end + + def description + "respond to #{pp_names}#{with_arity}" + end + + def with(n) + @expected_arity = n + self + end + + def argument + self + end + alias :arguments :argument + + private + + def matches_arity?(actual, name) + @expected_arity.nil?? true : @expected_arity == actual.method(name).arity + end + + def with_arity + @expected_arity.nil?? "" : + " with #{@expected_arity} argument#{@expected_arity == 1 ? '' : 's'}" + end + + def pp_names + # Ruby 1.9 returns the same thing for array.to_s as array.inspect, so just use array.inspect here + @names.length == 1 ? "##{@names.first}" : @names.inspect + end + end + + # :call-seq: + # should respond_to(*names) + # should_not respond_to(*names) + # + # Matches if the target object responds to all of the names + # provided. Names can be Strings or Symbols. + # + # == Examples + # + def respond_to(*names) + Matchers::RespondTo.new(*names) + end + end +end diff --git a/vendor/gems/gems/rspec-1.2.9/lib/spec/matchers/satisfy.rb b/vendor/gems/gems/rspec-1.2.9/lib/spec/matchers/satisfy.rb new file mode 100755 index 00000000..58e3f56a --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/lib/spec/matchers/satisfy.rb @@ -0,0 +1,47 @@ +module Spec + module Matchers + + class Satisfy #:nodoc: + def initialize(&block) + @block = block + end + + def matches?(actual, &block) + @block = block if block + @actual = actual + @block.call(actual) + end + + def failure_message_for_should + "expected #{@actual} to satisfy block" + end + + def failure_message_for_should_not + "expected #{@actual} not to satisfy block" + end + end + + # :call-seq: + # should satisfy {} + # should_not satisfy {} + # + # Passes if the submitted block returns true. Yields target to the + # block. + # + # Generally speaking, this should be thought of as a last resort when + # you can't find any other way to specify the behaviour you wish to + # specify. + # + # If you do find yourself in such a situation, you could always write + # a custom matcher, which would likely make your specs more expressive. + # + # == Examples + # + # 5.should satisfy { |n| + # n > 3 + # } + def satisfy(&block) + Matchers::Satisfy.new(&block) + end + end +end diff --git a/vendor/gems/gems/rspec-1.2.9/lib/spec/matchers/simple_matcher.rb b/vendor/gems/gems/rspec-1.2.9/lib/spec/matchers/simple_matcher.rb new file mode 100755 index 00000000..5ab7f306 --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/lib/spec/matchers/simple_matcher.rb @@ -0,0 +1,133 @@ +module Spec + module Matchers + class SimpleMatcher + attr_writer :failure_message, :negative_failure_message, :description + + def initialize(description, &match_block) + @description = description + @match_block = match_block + @failure_message = @negative_failure_message = nil + end + + def matches?(given) + @given = given + case @match_block.arity + when 2 + @match_block.call(@given, self) + else + @match_block.call(@given) + end + end + + def description + @description || explanation + end + + def failure_message_for_should + @failure_message || (@description.nil? ? explanation : %[expected #{@description.inspect} but got #{@given.inspect}]) + end + + def failure_message_for_should_not + @negative_failure_message || (@description.nil? ? explanation : %[expected not to get #{@description.inspect}, but got #{@given.inspect}]) + end + + def explanation + "No description provided. See RDoc for simple_matcher()" + end + end + + # simple_matcher makes it easy for you to create your own custom matchers + # in just a few lines of code when you don't need all the power of a + # completely custom matcher object. + # + # The description argument will appear as part of any failure + # message, and is also the source for auto-generated descriptions. + # + # The match_block can have an arity of 1 or 2. The first block + # argument will be the given value. The second, if the block accepts it + # will be the matcher itself, giving you access to set custom failure + # messages in favor of the defaults. + # + # The match_block should return a boolean: true + # indicates a match, which will pass if you use should and fail + # if you use should_not. false (or nil) indicates no match, + # which will do the reverse: fail if you use should and pass if + # you use should_not. + # + # An error in the match_block will bubble up, resulting in a + # failure. + # + # == Example with default messages + # + # def be_even + # simple_matcher("an even number") { |given| given % 2 == 0 } + # end + # + # describe 2 do + # it "should be even" do + # 2.should be_even + # end + # end + # + # Given an odd number, this example would produce an error message stating: + # expected "an even number", got 3. + # + # Unfortunately, if you're a fan of auto-generated descriptions, this will + # produce "should an even number." Not the most desirable result. You can + # control that using custom messages: + # + # == Example with custom messages + # + # def rhyme_with(expected) + # simple_matcher("rhyme with #{expected.inspect}") do |given, matcher| + # matcher.failure_message = "expected #{given.inspect} to rhyme with #{expected.inspect}" + # matcher.negative_failure_message = "expected #{given.inspect} not to rhyme with #{expected.inspect}" + # given.rhymes_with? expected + # end + # end + # + # # OR + # + # def rhyme_with(expected) + # simple_matcher do |given, matcher| + # matcher.description = "rhyme with #{expected.inspect}" + # matcher.failure_message = "expected #{given.inspect} to rhyme with #{expected.inspect}" + # matcher.negative_failure_message = "expected #{given.inspect} not to rhyme with #{expected.inspect}" + # given.rhymes_with? expected + # end + # end + # + # describe "pecan" do + # it "should rhyme with 'be gone'" do + # nut = "pecan" + # nut.extend Rhymer + # nut.should rhyme_with("be gone") + # end + # end + # + # The resulting messages would be: + # description: rhyme with "be gone" + # failure_message: expected "pecan" to rhyme with "be gone" + # negative failure_message: expected "pecan" not to rhyme with "be gone" + # + # == Wrapped Expectations + # + # Because errors will bubble up, it is possible to wrap other expectations + # in a SimpleMatcher. + # + # def be_even + # simple_matcher("an even number") { |given| (given % 2).should == 0 } + # end + # + # BE VERY CAREFUL when you do this. Only use wrapped expectations for + # matchers that will always be used in only the positive + # (should) or negative (should_not), but not both. + # The reason is that is you wrap a should and call the wrapper + # with should_not, the correct result (the should + # failing), will fail when you want it to pass. + # + def simple_matcher(description=nil, &match_block) + SimpleMatcher.new(description, &match_block) + end + end +end \ No newline at end of file diff --git a/vendor/gems/gems/rspec-1.2.9/lib/spec/matchers/throw_symbol.rb b/vendor/gems/gems/rspec-1.2.9/lib/spec/matchers/throw_symbol.rb new file mode 100755 index 00000000..da16bb65 --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/lib/spec/matchers/throw_symbol.rb @@ -0,0 +1,104 @@ +module Spec + module Matchers + + class ThrowSymbol #:nodoc: + def initialize(expected_symbol = nil, expected_arg=nil) + @expected_symbol = expected_symbol + @expected_arg = expected_arg + @caught_symbol = @caught_arg = nil + end + + def matches?(given_proc) + begin + if @expected_symbol.nil? + given_proc.call + else + @caught_arg = catch :proc_did_not_throw_anything do + catch @expected_symbol do + given_proc.call + throw :proc_did_not_throw_anything, :nothing_thrown + end + end + @caught_symbol = @expected_symbol unless @caught_arg == :nothing_thrown + end + + # Ruby 1.8 uses NameError with `symbol' + # Ruby 1.9 uses ArgumentError with :symbol + rescue NameError, ArgumentError => e + raise e unless e.message =~ /uncaught throw (`|\:)([a-zA-Z0-9_]*)(')?/ + @caught_symbol = $2.to_sym + + ensure + if @expected_symbol.nil? + return !@caught_symbol.nil? + else + if @expected_arg.nil? + return @caught_symbol == @expected_symbol + else + return (@caught_symbol == @expected_symbol) & (@caught_arg == @expected_arg) + end + end + end + end + + def failure_message_for_should + if @caught_symbol + "expected #{expected}, got #{@caught_symbol.inspect}" + else + "expected #{expected} but nothing was thrown" + end + end + + def failure_message_for_should_not + if @expected_symbol + "expected #{expected} not to be thrown" + else + "expected no Symbol, got :#{@caught_symbol}" + end + end + + def description + "throw #{expected}" + end + + private + + def expected + @expected_symbol.nil? ? "a Symbol" : "#{@expected_symbol.inspect}#{args}" + end + + def args + @expected_arg.nil? ? "" : " with #{@expected_arg.inspect}" + end + + end + + # :call-seq: + # should throw_symbol() + # should throw_symbol(:sym) + # should throw_symbol(:sym, arg) + # should_not throw_symbol() + # should_not throw_symbol(:sym) + # should_not throw_symbol(:sym, arg) + # + # Given no argument, matches if a proc throws any Symbol. + # + # Given a Symbol, matches if the given proc throws the specified Symbol. + # + # Given a Symbol and an arg, matches if the given proc throws the + # specified Symbol with the specified arg. + # + # == Examples + # + # lambda { do_something_risky }.should throw_symbol + # lambda { do_something_risky }.should throw_symbol(:that_was_risky) + # lambda { do_something_risky }.should throw_symbol(:that_was_risky, culprit) + # + # lambda { do_something_risky }.should_not throw_symbol + # lambda { do_something_risky }.should_not throw_symbol(:that_was_risky) + # lambda { do_something_risky }.should_not throw_symbol(:that_was_risky, culprit) + def throw_symbol(sym=nil) + Matchers::ThrowSymbol.new(sym) + end + end +end diff --git a/vendor/gems/gems/rspec-1.2.9/lib/spec/matchers/wrap_expectation.rb b/vendor/gems/gems/rspec-1.2.9/lib/spec/matchers/wrap_expectation.rb new file mode 100755 index 00000000..95162cae --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/lib/spec/matchers/wrap_expectation.rb @@ -0,0 +1,55 @@ +module Spec + module Matchers + # wraps an expectation in a block that will return true if the + # expectation passes and false if it fails (without bubbling up + # the failure). + # + # This is intended to be used in the context of a simple matcher, + # and is especially useful for wrapping multiple expectations or + # one or more assertions from test/unit extensions when running + # with test/unit. + # + # == Examples + # + # def eat_cheese(cheese) + # simple_matcher do |mouse, matcher| + # matcher.failure_message = "expected #{mouse} to eat cheese" + # wrap_expectation do |matcher| + # assert_eats_cheese(mouse) + # end + # end + # end + # + # describe Mouse do + # it "eats cheese" do + # Mouse.new.should eat_cheese + # end + # end + # + # You might be wondering "why would I do this if I could just say" + # assert_eats_cheese?", a fair question, indeed. You might prefer + # to replace the word assert with something more aligned with the + # rest of your code examples. You are using rspec, after all. + # + # The other benefit you get is that you can use the negative version + # of the matcher: + # + # describe Cat do + # it "does not eat cheese" do + # Cat.new.should_not eat_cheese + # end + # end + # + # So in the event there is no assert_does_not_eat_cheese available, + # you're all set! + def wrap_expectation(matcher, &block) + begin + block.call(matcher) + return true + rescue Exception => e + matcher.failure_message = e.message + return false + end + end + end +end diff --git a/vendor/gems/gems/rspec-1.2.9/lib/spec/mocks.rb b/vendor/gems/gems/rspec-1.2.9/lib/spec/mocks.rb new file mode 100755 index 00000000..339c0cc5 --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/lib/spec/mocks.rb @@ -0,0 +1,200 @@ +require 'spec/mocks/framework' +require 'spec/mocks/extensions/object' + +module Spec + # == Mocks and Stubs + # + # RSpec will create Mock Objects and Stubs for you at runtime, or attach stub/mock behaviour + # to any of your real objects (Partial Mock/Stub). Because the underlying implementation + # for mocks and stubs is the same, you can intermingle mock and stub + # behaviour in either dynamically generated mocks or your pre-existing classes. + # There is a semantic difference in how they are created, however, + # which can help clarify the role it is playing within a given spec. + # + # == Mock Objects + # + # Mocks are objects that allow you to set and verify expectations that they will + # receive specific messages during run time. They are very useful for specifying how the subject of + # the spec interacts with its collaborators. This approach is widely known as "interaction + # testing". + # + # Mocks are also very powerful as a design tool. As you are + # driving the implementation of a given class, Mocks provide an anonymous + # collaborator that can change in behaviour as quickly as you can write an expectation in your + # spec. This flexibility allows you to design the interface of a collaborator that often + # does not yet exist. As the shape of the class being specified becomes more clear, so do the + # requirements for its collaborators - often leading to the discovery of new types that are + # needed in your system. + # + # Read Endo-Testing[http://www.mockobjects.com/files/endotesting.pdf] for a much + # more in depth description of this process. + # + # == Stubs + # + # Stubs are objects that allow you to set "stub" responses to + # messages. As Martin Fowler points out on his site, + # mocks_arent_stubs[http://www.martinfowler.com/articles/mocksArentStubs.html]. + # Paraphrasing Fowler's paraphrasing + # of Gerard Meszaros: Stubs provide canned responses to messages they might receive in a test, while + # mocks allow you to specify and, subsquently, verify that certain messages should be received during + # the execution of a test. + # + # == Partial Mocks/Stubs + # + # RSpec also supports partial mocking/stubbing, allowing you to add stub/mock behaviour + # to instances of your existing classes. This is generally + # something to be avoided, because changes to the class can have ripple effects on + # seemingly unrelated specs. When specs fail due to these ripple effects, the fact + # that some methods are being mocked can make it difficult to understand why a + # failure is occurring. + # + # That said, partials do allow you to expect and + # verify interactions with class methods such as +#find+ and +#create+ + # on Ruby on Rails model classes. + # + # == Further Reading + # + # There are many different viewpoints about the meaning of mocks and stubs. If you are interested + # in learning more, here is some recommended reading: + # + # * Mock Objects: http://www.mockobjects.com/ + # * Endo-Testing: http://www.mockobjects.com/files/endotesting.pdf + # * Mock Roles, Not Objects: http://www.mockobjects.com/files/mockrolesnotobjects.pdf + # * Test Double Patterns: http://xunitpatterns.com/Test%20Double%20Patterns.html + # * Mocks aren't stubs: http://www.martinfowler.com/articles/mocksArentStubs.html + # + # == Creating a Mock + # + # You can create a mock in any specification (or setup) using: + # + # mock(name, options={}) + # + # The optional +options+ argument is a +Hash+. Currently the only supported + # option is +:null_object+. Setting this to true instructs the mock to ignore + # any messages it hasn’t been told to expect – and quietly return itself. For example: + # + # mock("person", :null_object => true) + # + # == Creating a Stub + # + # You can create a stub in any specification (or setup) using: + # + # stub(name, stub_methods_and_values_hash) + # + # For example, if you wanted to create an object that always returns + # "More?!?!?!" to "please_sir_may_i_have_some_more" you would do this: + # + # stub("Mr Sykes", :please_sir_may_i_have_some_more => "More?!?!?!") + # + # == Creating a Partial Mock + # + # You don't really "create" a partial mock, you simply add method stubs and/or + # mock expectations to existing classes and objects: + # + # Factory.should_receive(:find).with(id).and_return(value) + # obj.stub!(:to_i).and_return(3) + # etc ... + # + # == Expecting Messages + # + # my_mock.should_receive(:sym) + # my_mock.should_not_receive(:sym) + # + # == Expecting Arguments + # + # my_mock.should_receive(:sym).with(*args) + # my_mock.should_not_receive(:sym).with(*args) + # + # == Argument Matchers + # + # Arguments that are passed to #with are compared with actual arguments received + # using == by default. In cases in which you want to specify things about the arguments + # rather than the arguments themselves, you can use any of RSpec's Expression Matchers. + # They don't all make syntactic sense (they were primarily designed for use with + # Spec::Expectations), but you are free to create your own custom Spec::Matchers. + # + # Spec::Mocks does provide one additional Matcher method named #ducktype. + # + # In addition, Spec::Mocks adds some keyword Symbols that you can use to + # specify certain kinds of arguments: + # + # my_mock.should_receive(:sym).with(no_args()) + # my_mock.should_receive(:sym).with(any_args()) + # my_mock.should_receive(:sym).with(1, kind_of(Numeric), "b") #2nd argument can any kind of Numeric + # my_mock.should_receive(:sym).with(1, boolean(), "b") #2nd argument can true or false + # my_mock.should_receive(:sym).with(1, /abc/, "b") #2nd argument can be any String matching the submitted Regexp + # my_mock.should_receive(:sym).with(1, anything(), "b") #2nd argument can be anything at all + # my_mock.should_receive(:sym).with(1, ducktype(:abs, :div), "b") + # #2nd argument can be object that responds to #abs and #div + # + # == Receive Counts + # + # my_mock.should_receive(:sym).once + # my_mock.should_receive(:sym).twice + # my_mock.should_receive(:sym).exactly(n).times + # my_mock.should_receive(:sym).at_least(:once) + # my_mock.should_receive(:sym).at_least(:twice) + # my_mock.should_receive(:sym).at_least(n).times + # my_mock.should_receive(:sym).at_most(:once) + # my_mock.should_receive(:sym).at_most(:twice) + # my_mock.should_receive(:sym).at_most(n).times + # my_mock.should_receive(:sym).any_number_of_times + # + # == Ordering + # + # my_mock.should_receive(:sym).ordered + # my_mock.should_receive(:other_sym).ordered + # #This will fail if the messages are received out of order + # + # == Setting Reponses + # + # Whether you are setting a mock expectation or a simple stub, you can tell the + # object precisely how to respond: + # + # my_mock.should_receive(:sym).and_return(value) + # my_mock.should_receive(:sym).exactly(3).times.and_return(value1, value2, value3) + # # returns value1 the first time, value2 the second, etc + # my_mock.should_receive(:sym).and_return { ... } #returns value returned by the block + # my_mock.should_receive(:sym).and_raise(error) + # #error can be an instantiated object or a class + # #if it is a class, it must be instantiable with no args + # my_mock.should_receive(:sym).and_throw(:sym) + # my_mock.should_receive(:sym).and_yield(values,to,yield) + # my_mock.should_receive(:sym).and_yield(values,to,yield).and_yield(some,other,values,this,time) + # # for methods that yield to a block multiple times + # + # Any of these responses can be applied to a stub as well, but stubs do + # not support any qualifiers about the message received (i.e. you can't specify arguments + # or receive counts): + # + # my_mock.stub!(:sym).and_return(value) + # my_mock.stub!(:sym).and_return(value1, value2, value3) + # my_mock.stub!(:sym).and_raise(error) + # my_mock.stub!(:sym).and_throw(:sym) + # my_mock.stub!(:sym).and_yield(values,to,yield) + # my_mock.stub!(:sym).and_yield(values,to,yield).and_yield(some,other,values,this,time) + # + # == Arbitrary Handling + # + # Once in a while you'll find that the available expectations don't solve the + # particular problem you are trying to solve. Imagine that you expect the message + # to come with an Array argument that has a specific length, but you don't care + # what is in it. You could do this: + # + # my_mock.should_receive(:sym) do |arg| + # arg.should be_an_istance_of(Array) + # arg.length.should == 7 + # end + # + # Note that this would fail if the number of arguments received was different from + # the number of block arguments (in this case 1). + # + # == Combining Expectation Details + # + # Combining the message name with specific arguments, receive counts and responses + # you can get quite a bit of detail in your expectations: + # + # my_mock.should_receive(:<<).with("illegal value").once.and_raise(ArgumentError) + module Mocks + end +end diff --git a/vendor/gems/gems/rspec-1.2.9/lib/spec/mocks/argument_expectation.rb b/vendor/gems/gems/rspec-1.2.9/lib/spec/mocks/argument_expectation.rb new file mode 100755 index 00000000..b51b7bae --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/lib/spec/mocks/argument_expectation.rb @@ -0,0 +1,51 @@ +module Spec + module Mocks + + class ArgumentExpectation + attr_reader :args + + def initialize(args, &block) + @args = args + @matchers_block = block + @match_any_args = false + @matchers = nil + + if ArgumentMatchers::AnyArgsMatcher === args.first + @match_any_args = true + elsif ArgumentMatchers::NoArgsMatcher === args.first + @matchers = [] + else + @matchers = args.collect {|arg| matcher_for(arg)} + end + end + + def matcher_for(arg) + return ArgumentMatchers::MatcherMatcher.new(arg) if is_matcher?(arg) + return ArgumentMatchers::RegexpMatcher.new(arg) if arg.is_a?(Regexp) + return ArgumentMatchers::EqualityProxy.new(arg) + end + + def is_matcher?(obj) + return obj.respond_to?(:matches?) & obj.respond_to?(:description) + end + + def args_match?(given_args) + match_any_args? || matchers_block_matches?(given_args) || matchers_match?(given_args) + end + + def matchers_block_matches?(given_args) + @matchers_block ? @matchers_block.call(*given_args) : nil + end + + def matchers_match?(given_args) + @matchers == given_args + end + + def match_any_args? + @match_any_args + end + + end + + end +end diff --git a/vendor/gems/gems/rspec-1.2.9/lib/spec/mocks/argument_matchers.rb b/vendor/gems/gems/rspec-1.2.9/lib/spec/mocks/argument_matchers.rb new file mode 100755 index 00000000..f56551f2 --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/lib/spec/mocks/argument_matchers.rb @@ -0,0 +1,237 @@ +module Spec + module Mocks + + # ArgumentMatchers are messages that you can include in message + # expectations to match arguments against a broader check than simple + # equality. + # + # With the exception of any_args() and no_args(), the matchers + # are all positional - they match against the arg in the given position. + module ArgumentMatchers + + class AnyArgsMatcher + def description + "any args" + end + end + + class NoArgsMatcher + def description + "no args" + end + end + + class AnyArgMatcher + def initialize(ignore) + end + + def ==(other) + true + end + + def description + "anything" + end + end + + class RegexpMatcher + def initialize(regexp) + @regexp = regexp + end + + def ==(value) + return value =~ @regexp unless value.is_a?(Regexp) + value == @regexp + end + end + + class BooleanMatcher + def initialize(ignore) + end + + def ==(value) + TrueClass === value || FalseClass === value + end + end + + class HashIncludingMatcher + def initialize(expected) + @expected = expected + end + + def ==(actual) + @expected.each do | key, value | + return false unless actual.has_key?(key) && value == actual[key] + end + true + rescue NoMethodError => ex + return false + end + + def description + "hash_including(#{@expected.inspect.sub(/^\{/,"").sub(/\}$/,"")})" + end + end + + class HashNotIncludingMatcher + def initialize(expected) + @expected = expected + end + + def ==(actual) + @expected.each do | key, value | + return false if actual.has_key?(key) && value == actual[key] + end + true + rescue NoMethodError => ex + return false + end + + def description + "hash_not_including(#{@expected.inspect.sub(/^\{/,"").sub(/\}$/,"")})" + end + end + + class DuckTypeMatcher + def initialize(*methods_to_respond_to) + @methods_to_respond_to = methods_to_respond_to + end + + def ==(value) + @methods_to_respond_to.all? { |sym| value.respond_to?(sym) } + end + end + + class MatcherMatcher + def initialize(matcher) + @matcher = matcher + end + + def ==(value) + @matcher.matches?(value) + end + end + + class EqualityProxy + def initialize(given) + @given = given + end + + def ==(expected) + @given == expected + end + end + + class InstanceOf + def initialize(klass) + @klass = klass + end + + def ==(actual) + actual.instance_of?(@klass) + end + end + + class KindOf + def initialize(klass) + @klass = klass + end + + def ==(actual) + actual.kind_of?(@klass) + end + end + + # :call-seq: + # object.should_receive(:message).with(no_args()) + # + # Passes if no arguments are passed along with the message + def no_args + NoArgsMatcher.new + end + + # :call-seq: + # object.should_receive(:message).with(any_args()) + # + # Passes if object receives :message with any args at all. This is + # really a more explicit variation of object.should_receive(:message) + def any_args + AnyArgsMatcher.new + end + + # :call-seq: + # object.should_receive(:message).with(anything()) + # + # Passes as long as there is an argument. + def anything + AnyArgMatcher.new(nil) + end + + # :call-seq: + # object.should_receive(:message).with(duck_type(:hello)) + # object.should_receive(:message).with(duck_type(:hello, :goodbye)) + # + # Passes if the argument responds to the specified messages. + # + # == Examples + # + # array = [] + # display = mock('display') + # display.should_receive(:present_names).with(duck_type(:length, :each)) + # => passes + def duck_type(*args) + DuckTypeMatcher.new(*args) + end + + # :call-seq: + # object.should_receive(:message).with(boolean()) + # + # Passes if the argument is boolean. + def boolean + BooleanMatcher.new(nil) + end + + # :call-seq: + # object.should_receive(:message).with(hash_including(:key => val)) + # object.should_receive(:message).with(hash_including(:key)) + # object.should_receive(:message).with(hash_including(:key, :key2 => val2)) + # Passes if the argument is a hash that includes the specified key(s) or key/value + # pairs. If the hash includes other keys, it will still pass. + def hash_including(*args) + HashIncludingMatcher.new(anythingize_lonely_keys(*args)) + end + + # :call-seq: + # object.should_receive(:message).with(hash_not_including(:key => val)) + # object.should_receive(:message).with(hash_not_including(:key)) + # object.should_receive(:message).with(hash_not_including(:key, :key2 => :val2)) + # + # Passes if the argument is a hash that doesn't include the specified key(s) or key/value + def hash_not_including(*args) + HashNotIncludingMatcher.new(anythingize_lonely_keys(*args)) + end + + # Passes if arg.instance_of?(klass) + def instance_of(klass) + InstanceOf.new(klass) + end + + alias_method :an_instance_of, :instance_of + + # Passes if arg.kind_of?(klass) + def kind_of(klass) + KindOf.new(klass) + end + + alias_method :a_kind_of, :kind_of + + private + + def anythingize_lonely_keys(*args) + hash = args.last.class == Hash ? args.delete_at(-1) : {} + args.each { | arg | hash[arg] = anything } + hash + end + end + end +end diff --git a/vendor/gems/gems/rspec-1.2.9/lib/spec/mocks/error_generator.rb b/vendor/gems/gems/rspec-1.2.9/lib/spec/mocks/error_generator.rb new file mode 100755 index 00000000..f63811fe --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/lib/spec/mocks/error_generator.rb @@ -0,0 +1,92 @@ +module Spec + module Mocks + class ErrorGenerator + attr_writer :opts + + def initialize(target, name, options={}) + @declared_as = options[:__declared_as] || 'Mock' + @target = target + @name = name + end + + def opts + @opts ||= {} + end + + def raise_unexpected_message_error(sym, *args) + __raise "#{intro} received unexpected message :#{sym}#{arg_message(*args)}" + end + + def raise_unexpected_message_args_error(expectation, *args) + expected_args = format_args(*expectation.expected_args) + actual_args = args.empty? ? "(no args)" : format_args(*args) + __raise "#{intro} received #{expectation.sym.inspect} with unexpected arguments\n expected: #{expected_args}\n got: #{actual_args}" + end + + def raise_expectation_error(sym, expected_received_count, actual_received_count, *args) + __raise "#{intro} expected :#{sym}#{arg_message(*args)} #{count_message(expected_received_count)}, but received it #{count_message(actual_received_count)}" + end + + def raise_out_of_order_error(sym) + __raise "#{intro} received :#{sym} out of order" + end + + def raise_block_failed_error(sym, detail) + __raise "#{intro} received :#{sym} but passed block failed with: #{detail}" + end + + def raise_missing_block_error(args_to_yield) + __raise "#{intro} asked to yield |#{arg_list(*args_to_yield)}| but no block was passed" + end + + def raise_wrong_arity_error(args_to_yield, arity) + __raise "#{intro} yielded |#{arg_list(*args_to_yield)}| to block with arity of #{arity}" + end + + private + + def intro + if @name + "#{@declared_as} #{@name.inspect}" + elsif Mock === @target + @declared_as + elsif Class === @target + "<#{@target.inspect} (class)>" + elsif @target + @target + else + "nil" + end + end + + def __raise(message) + message = opts[:message] unless opts[:message].nil? + Kernel::raise(Spec::Mocks::MockExpectationError, message) + end + + def arg_message(*args) + " with " + format_args(*args) + end + + def format_args(*args) + args.empty? ? "(no args)" : "(" + arg_list(*args) + ")" + end + + def arg_list(*args) + args.collect {|arg| arg.respond_to?(:description) ? arg.description : arg.inspect}.join(", ") + end + + def count_message(count) + return "at least #{pretty_print(count.abs)}" if count < 0 + return pretty_print(count) + end + + def pretty_print(count) + return "once" if count == 1 + return "twice" if count == 2 + return "#{count} times" + end + + end + end +end diff --git a/vendor/gems/gems/rspec-1.2.9/lib/spec/mocks/errors.rb b/vendor/gems/gems/rspec-1.2.9/lib/spec/mocks/errors.rb new file mode 100755 index 00000000..560b66a9 --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/lib/spec/mocks/errors.rb @@ -0,0 +1,10 @@ +module Spec + module Mocks + class MockExpectationError < Exception + end + + class AmbiguousReturnError < StandardError + end + end +end + diff --git a/vendor/gems/gems/rspec-1.2.9/lib/spec/mocks/example_methods.rb b/vendor/gems/gems/rspec-1.2.9/lib/spec/mocks/example_methods.rb new file mode 100755 index 00000000..f6c68ab6 --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/lib/spec/mocks/example_methods.rb @@ -0,0 +1,69 @@ +module Spec + module Mocks + module ExampleMethods + include Spec::Mocks::ArgumentMatchers + + # Shortcut for creating an instance of Spec::Mocks::Mock. + # + # +name+ is used for failure reporting, so you should use the + # role that the double is playing in the example. + # + # +stubs_and_options+ lets you assign options and stub values + # at the same time. The only option available is :null_object. + # Anything else is treated as a stub value. + # + # == Examples + # + # thing = double("thing", :a => "A") + # thing.a == "A" => true + # + # person = double("thing", :name => "Joe", :email => "joe@domain.com") + # person.name => "Joe" + # person.email => "joe@domain.com" + def double(*args) + __declare_double('Double', *args) + end + + # Alias for double + def mock(*args) + __declare_double('Mock', *args) + end + + # Alias for double + def stub(*args) + __declare_double('Stub', *args) + end + + def __declare_double(declared_as, *args) # :nodoc: + args << {} unless Hash === args.last + args.last[:__declared_as] = declared_as + Spec::Mocks::Mock.new(*args) + end + + # DEPRECATED - use double('name').as_null_object instead + # + # Shortcut for creating a mock object that will return itself in response + # to any message it receives that it hasn't been explicitly instructed + # to respond to. + def stub_everything(name = 'stub') + Spec.warn(<<-WARNING) + +DEPRECATION: stub_everything('#{name}') is deprecated and will be removed +from a future version of rspec. Please use double('#{name}').as_null_object +(or stub('#{name}').as_null_object or mock('#{name}').as_null_object instead. + +WARNING + mock(name, :null_object => true) + end + + # Disables warning messages about expectations being set on nil. + # + # By default warning messages are issued when expectations are set on nil. This is to + # prevent false-positives and to catch potential bugs early on. + def allow_message_expectations_on_nil + Proxy.allow_message_expectations_on_nil + end + + end + end +end diff --git a/vendor/gems/gems/rspec-1.2.9/lib/spec/mocks/extensions.rb b/vendor/gems/gems/rspec-1.2.9/lib/spec/mocks/extensions.rb new file mode 100755 index 00000000..6fd51a27 --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/lib/spec/mocks/extensions.rb @@ -0,0 +1 @@ +require 'spec/mocks/extensions/object' diff --git a/vendor/gems/gems/rspec-1.2.9/lib/spec/mocks/extensions/object.rb b/vendor/gems/gems/rspec-1.2.9/lib/spec/mocks/extensions/object.rb new file mode 100755 index 00000000..4b753106 --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/lib/spec/mocks/extensions/object.rb @@ -0,0 +1,3 @@ +class Object + include Spec::Mocks::Methods +end diff --git a/vendor/gems/gems/rspec-1.2.9/lib/spec/mocks/framework.rb b/vendor/gems/gems/rspec-1.2.9/lib/spec/mocks/framework.rb new file mode 100755 index 00000000..e2577865 --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/lib/spec/mocks/framework.rb @@ -0,0 +1,15 @@ +# Require everything except the global extensions of class and object. This +# supports wrapping rspec's mocking functionality without invading every +# object in the system. + +require 'spec/mocks/methods' +require 'spec/mocks/argument_matchers' +require 'spec/mocks/example_methods' +require 'spec/mocks/proxy' +require 'spec/mocks/mock' +require 'spec/mocks/argument_expectation' +require 'spec/mocks/message_expectation' +require 'spec/mocks/order_group' +require 'spec/mocks/errors' +require 'spec/mocks/error_generator' +require 'spec/mocks/space' diff --git a/vendor/gems/gems/rspec-1.2.9/lib/spec/mocks/message_expectation.rb b/vendor/gems/gems/rspec-1.2.9/lib/spec/mocks/message_expectation.rb new file mode 100755 index 00000000..8a8133f6 --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/lib/spec/mocks/message_expectation.rb @@ -0,0 +1,329 @@ +module Spec + module Mocks + + class BaseExpectation + attr_reader :sym + attr_writer :expected_received_count, :method_block, :expected_from + protected :expected_received_count=, :method_block=, :expected_from= + attr_accessor :error_generator + protected :error_generator, :error_generator= + + def initialize(error_generator, expectation_ordering, expected_from, sym, method_block, expected_received_count=1, opts={}, &implementation) + @error_generator = error_generator + @error_generator.opts = opts + @expected_from = expected_from + @sym = sym + @method_block = method_block + @actual_received_count = 0 + @expected_received_count = expected_received_count + @args_expectation = ArgumentExpectation.new([ArgumentMatchers::AnyArgsMatcher.new]) + @consecutive = false + @exception_to_raise = nil + @symbol_to_throw = nil + @order_group = expectation_ordering + @at_least = nil + @at_most = nil + @args_to_yield = [] + @failed_fast = nil + @args_to_yield_were_cloned = false + @return_block = implementation + end + + def build_child(expected_from, method_block, expected_received_count, opts={}) + child = clone + child.expected_from = expected_from + child.method_block = method_block + child.expected_received_count = expected_received_count + child.clear_actual_received_count! + new_gen = error_generator.clone + new_gen.opts = opts + child.error_generator = new_gen + child.clone_args_to_yield @args_to_yield + child + end + + def expected_args + @args_expectation.args + end + + def and_return(*values, &return_block) + Kernel::raise AmbiguousReturnError unless @method_block.nil? + case values.size + when 0 then value = nil + when 1 then value = values[0] + else + value = values + @consecutive = true + @expected_received_count = values.size if !ignoring_args? && + @expected_received_count < values.size + end + @return_block = block_given? ? return_block : lambda { value } + end + + # :call-seq: + # and_raise() + # and_raise(Exception) #any exception class + # and_raise(exception) #any exception object + # + # == Warning + # + # When you pass an exception class, the MessageExpectation will + # raise an instance of it, creating it with +new+. If the exception + # class initializer requires any parameters, you must pass in an + # instance and not the class. + def and_raise(exception=Exception) + @exception_to_raise = exception + end + + def and_throw(symbol) + @symbol_to_throw = symbol + end + + def and_yield(*args) + if @args_to_yield_were_cloned + @args_to_yield.clear + @args_to_yield_were_cloned = false + end + + @args_to_yield << args + self + end + + def matches(sym, args) + @sym == sym and @args_expectation.args_match?(args) + end + + def invoke(*args, &block) + if @expected_received_count == 0 + @failed_fast = true + @actual_received_count += 1 + @error_generator.raise_expectation_error @sym, @expected_received_count, @actual_received_count, *args + end + + @order_group.handle_order_constraint self + + begin + Kernel::raise @exception_to_raise unless @exception_to_raise.nil? + Kernel::throw @symbol_to_throw unless @symbol_to_throw.nil? + + + if !@method_block.nil? + default_return_val = invoke_method_block(*args) + elsif @args_to_yield.size > 0 + default_return_val = invoke_with_yield(&block) + else + default_return_val = nil + end + + if @consecutive + return invoke_consecutive_return_block(*args, &block) + elsif @return_block + return invoke_return_block(*args, &block) + else + return default_return_val + end + ensure + @actual_received_count += 1 + end + end + + def called_max_times? + @expected_received_count != :any && @expected_received_count > 0 && + @actual_received_count >= @expected_received_count + end + + def invoke_return_block(*args, &block) + args << block unless block.nil? + # Ruby 1.9 - when we set @return_block to return values + # regardless of arguments, any arguments will result in + # a "wrong number of arguments" error + @return_block.arity == 0 ? @return_block.call : @return_block.call(*args) + end + + protected + + def invoke_method_block(*args) + begin + @method_block.call(*args) + rescue => detail + @error_generator.raise_block_failed_error @sym, detail.message + end + end + + def invoke_with_yield(&block) + if block.nil? + @error_generator.raise_missing_block_error @args_to_yield + end + value = nil + @args_to_yield.each do |args_to_yield_this_time| + if block.arity > -1 && args_to_yield_this_time.length != block.arity + @error_generator.raise_wrong_arity_error args_to_yield_this_time, block.arity + end + value = block.call(*args_to_yield_this_time) + end + value + end + + def invoke_consecutive_return_block(*args, &block) + value = invoke_return_block(*args, &block) + index = [@actual_received_count, value.size-1].min + value[index] + end + + def clone_args_to_yield(args) + @args_to_yield = args.clone + @args_to_yield_were_cloned = true + end + + def failed_fast? + @failed_fast + end + end + + class MessageExpectation < BaseExpectation + + def matches_name?(sym) + @sym == sym + end + + def matches_name_but_not_args(sym, args) + matches_name?(sym) and not @args_expectation.args_match?(args) + end + + def verify_messages_received + return if expected_messages_received? || failed_fast? + + generate_error + rescue Spec::Mocks::MockExpectationError => error + error.backtrace.insert(0, @expected_from) + Kernel::raise error + end + + def expected_messages_received? + ignoring_args? || matches_exact_count? || + matches_at_least_count? || matches_at_most_count? + end + + def ignoring_args? + @expected_received_count == :any + end + + def matches_at_least_count? + @at_least && @actual_received_count >= @expected_received_count + end + + def matches_at_most_count? + @at_most && @actual_received_count <= @expected_received_count + end + + def matches_exact_count? + @expected_received_count == @actual_received_count + end + + def similar_messages + @similar_messages ||= [] + end + + def advise(args, block) + similar_messages << args + end + + def generate_error + if similar_messages.empty? + @error_generator.raise_expectation_error(@sym, @expected_received_count, @actual_received_count, *@args_expectation.args) + else + @error_generator.raise_unexpected_message_args_error(self, *@similar_messages) + end + end + + def with(*args, &block) + @args_expectation = ArgumentExpectation.new(args, &block) + self + end + + def exactly(n) + set_expected_received_count :exactly, n + self + end + + def at_least(n) + set_expected_received_count :at_least, n + self + end + + def at_most(n) + set_expected_received_count :at_most, n + self + end + + def times(&block) + @method_block = block if block + self + end + + def any_number_of_times(&block) + @method_block = block if block + @expected_received_count = :any + self + end + + def never + @expected_received_count = 0 + self + end + + def once(&block) + @method_block = block if block + @expected_received_count = 1 + self + end + + def twice(&block) + @method_block = block if block + @expected_received_count = 2 + self + end + + def ordered(&block) + @method_block = block if block + @order_group.register(self) + @ordered = true + self + end + + def negative_expectation_for?(sym) + return false + end + + protected + def set_expected_received_count(relativity, n) + @at_least = (relativity == :at_least) + @at_most = (relativity == :at_most) + @expected_received_count = case n + when Numeric + n + when :once + 1 + when :twice + 2 + end + end + + def clear_actual_received_count! + @actual_received_count = 0 + end + + end + + class NegativeMessageExpectation < MessageExpectation + def initialize(message, expectation_ordering, expected_from, sym, method_block) + super(message, expectation_ordering, expected_from, sym, method_block, 0) + end + + def negative_expectation_for?(sym) + return @sym == sym + end + end + + end +end diff --git a/vendor/gems/gems/rspec-1.2.9/lib/spec/mocks/methods.rb b/vendor/gems/gems/rspec-1.2.9/lib/spec/mocks/methods.rb new file mode 100755 index 00000000..16dd6e84 --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/lib/spec/mocks/methods.rb @@ -0,0 +1,89 @@ +module Spec + module Mocks + module Methods + def should_receive(sym, opts={}, &block) + __mock_proxy.add_message_expectation(opts[:expected_from] || caller(1)[0], sym.to_sym, opts, &block) + end + + def should_not_receive(sym, &block) + __mock_proxy.add_negative_message_expectation(caller(1)[0], sym.to_sym, &block) + end + + def stub!(sym_or_hash, opts={}, &block) + if Hash === sym_or_hash + sym_or_hash.each {|method, value| stub!(method).and_return value } + else + __mock_proxy.add_stub(caller(1)[0], sym_or_hash.to_sym, opts, &block) + end + end + + alias_method :stub, :stub! + + def unstub!(message) + __mock_proxy.remove_stub(message) + end + + alias_method :unstub, :unstub! + + # :call-seq: + # object.stub_chain(:first, :second, :third).and_return(:this) + # + # Supports stubbing a chain of methods. Each argument represents + # a method name to stub, and each one returns a proxy object that + # can accept more stubs, until the last, which returns whatever + # is passed to +and_return_. + # + # == Examples + # + # # with this in an example ... + # article = double('article') + # Article.stub_chain(:authored_by, :published, :recent).and_return([article]) + # # then this will return an Array with the article double in it: + # Article.authored_by(params[:author_id]).published.recent + def stub_chain(*methods) + if methods.length > 1 + if matching_stub = __mock_proxy.find_matching_method_stub(methods[0]) + methods.shift + matching_stub.invoke_return_block.stub_chain(*methods) + else + next_in_chain = Object.new + stub!(methods.shift) {next_in_chain} + next_in_chain.stub_chain(*methods) + end + else + stub!(methods.shift) + end + end + + def received_message?(sym, *args, &block) #:nodoc: + __mock_proxy.received_message?(sym.to_sym, *args, &block) + end + + def rspec_verify #:nodoc: + __mock_proxy.verify + end + + def rspec_reset #:nodoc: + __mock_proxy.reset + end + + def as_null_object + __mock_proxy.as_null_object + end + + def null_object? + __mock_proxy.null_object? + end + + private + + def __mock_proxy + if Mock === self + @mock_proxy ||= Proxy.new(self, @name, @options) + else + @mock_proxy ||= Proxy.new(self) + end + end + end + end +end diff --git a/vendor/gems/gems/rspec-1.2.9/lib/spec/mocks/mock.rb b/vendor/gems/gems/rspec-1.2.9/lib/spec/mocks/mock.rb new file mode 100755 index 00000000..35a6c798 --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/lib/spec/mocks/mock.rb @@ -0,0 +1,71 @@ +module Spec + module Mocks + class Mock + include Methods + + # Creates a new mock with a +name+ (that will be used in error messages + # only) == Options: + # * :null_object - if true, the mock object acts as a forgiving + # null object allowing any message to be sent to it. + def initialize(name=nil, stubs_and_options={}) + if name.is_a?(Hash) && stubs_and_options.empty? + stubs_and_options = name + @name = nil + else + @name = name + end + @options = extract_options(stubs_and_options) + assign_stubs(stubs_and_options) + end + + # This allows for comparing the mock to other objects that proxy such as + # ActiveRecords belongs_to proxy objects. By making the other object run + # the comparison, we're sure the call gets delegated to the proxy + # target. + def ==(other) + other == __mock_proxy + end + + def inspect + "#<#{self.class}:#{sprintf '0x%x', self.object_id} @name=#{@name.inspect}>" + end + + def to_s + inspect.gsub('<','[').gsub('>',']') + end + + private + + def method_missing(sym, *args, &block) + __mock_proxy.record_message_received(sym, args, block) + begin + return self if __mock_proxy.null_object? + super(sym, *args, &block) + rescue NameError + __mock_proxy.raise_unexpected_message_error sym, *args + end + end + + def extract_options(stubs_and_options) + options = {} + extract_option(stubs_and_options, options, :null_object) + extract_option(stubs_and_options, options, :__declared_as, 'Mock') + options + end + + def extract_option(source, target, key, default=nil) + if source[key] + target[key] = source.delete(key) + elsif default + target[key] = default + end + end + + def assign_stubs(stubs) + stubs.each_pair do |message, response| + stub!(message).and_return(response) + end + end + end + end +end diff --git a/vendor/gems/gems/rspec-1.2.9/lib/spec/mocks/order_group.rb b/vendor/gems/gems/rspec-1.2.9/lib/spec/mocks/order_group.rb new file mode 100755 index 00000000..9983207e --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/lib/spec/mocks/order_group.rb @@ -0,0 +1,29 @@ +module Spec + module Mocks + class OrderGroup + def initialize error_generator + @error_generator = error_generator + @ordering = Array.new + end + + def register(expectation) + @ordering << expectation + end + + def ready_for?(expectation) + return @ordering.first == expectation + end + + def consume + @ordering.shift + end + + def handle_order_constraint expectation + return unless @ordering.include? expectation + return consume if ready_for?(expectation) + @error_generator.raise_out_of_order_error expectation.sym + end + + end + end +end diff --git a/vendor/gems/gems/rspec-1.2.9/lib/spec/mocks/proxy.rb b/vendor/gems/gems/rspec-1.2.9/lib/spec/mocks/proxy.rb new file mode 100755 index 00000000..acf72e0f --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/lib/spec/mocks/proxy.rb @@ -0,0 +1,245 @@ +module Spec + module Mocks + class Proxy + DEFAULT_OPTIONS = { + :null_object => false, + } + + @@warn_about_expectations_on_nil = true + + def self.allow_message_expectations_on_nil + @@warn_about_expectations_on_nil = false + + # ensure nil.rspec_verify is called even if an expectation is not set in the example + # otherwise the allowance would effect subsequent examples + $rspec_mocks.add(nil) unless $rspec_mocks.nil? + end + + def initialize(target, name=nil, options={}) + @target = target + @name = name + @error_generator = ErrorGenerator.new target, name, options + @expectation_ordering = OrderGroup.new @error_generator + @expectations = [] + @messages_received = [] + @stubs = [] + @proxied_methods = [] + @options = options ? DEFAULT_OPTIONS.dup.merge(options) : DEFAULT_OPTIONS + @already_proxied_respond_to = false + end + + def null_object? + @options[:null_object] + end + + def as_null_object + @options[:null_object] = true + @target + end + + def add_message_expectation(expected_from, sym, opts={}, &block) + __add sym + warn_if_nil_class sym + if existing_stub = @stubs.detect {|s| s.sym == sym } + expectation = existing_stub.build_child(expected_from, block_given?? block : nil, 1, opts) + else + expectation = MessageExpectation.new(@error_generator, @expectation_ordering, expected_from, sym, block_given? ? block : nil, 1, opts) + end + @expectations << expectation + @expectations.last + end + + def add_negative_message_expectation(expected_from, sym, &block) + __add sym + warn_if_nil_class sym + @expectations << NegativeMessageExpectation.new(@error_generator, @expectation_ordering, expected_from, sym, block_given? ? block : nil) + @expectations.last + end + + def add_stub(expected_from, sym, opts={}, &implementation) + __add sym + @stubs.unshift MessageExpectation.new(@error_generator, @expectation_ordering, expected_from, sym, nil, :any, opts, &implementation) + @stubs.first + end + + def remove_stub(message) + message = message.to_sym + + if stub_to_remove = @stubs.detect { |s| s.matches_name?(message) } + reset_proxied_method(message) + @stubs.delete(stub_to_remove) + else + raise MockExpectationError, "The method `#{message}` was not stubbed or was already unstubbed" + end + end + + def verify #:nodoc: + verify_expectations + ensure + reset + end + + def reset + clear_expectations + clear_stubs + reset_proxied_methods + clear_proxied_methods + reset_nil_expectations_warning + end + + def received_message?(sym, *args, &block) + @messages_received.any? {|array| array == [sym, args, block]} + end + + def has_negative_expectation?(sym) + @expectations.detect {|expectation| expectation.negative_expectation_for?(sym)} + end + + def record_message_received(sym, args, block) + @messages_received << [sym, args, block] + end + + def message_received(sym, *args, &block) + expectation = find_matching_expectation(sym, *args) + stub = find_matching_method_stub(sym, *args) + + if (stub && expectation && expectation.called_max_times?) || (stub && !expectation) + if expectation = find_almost_matching_expectation(sym, *args) + expectation.advise(args, block) unless expectation.expected_messages_received? + end + stub.invoke(*args, &block) + elsif expectation + expectation.invoke(*args, &block) + elsif expectation = find_almost_matching_expectation(sym, *args) + expectation.advise(args, block) if null_object? unless expectation.expected_messages_received? + raise_unexpected_message_args_error(expectation, *args) unless (has_negative_expectation?(sym) or null_object?) + else + @target.__send__ :method_missing, sym, *args, &block + end + end + + def raise_unexpected_message_args_error(expectation, *args) + @error_generator.raise_unexpected_message_args_error expectation, *args + end + + def raise_unexpected_message_error(sym, *args) + @error_generator.raise_unexpected_message_error sym, *args + end + + def find_matching_method_stub(sym, *args) + @stubs.find {|stub| stub.matches(sym, args)} + end + + private + + def __add(sym) + $rspec_mocks.add(@target) unless $rspec_mocks.nil? + define_expected_method(sym) + end + + def warn_if_nil_class(sym) + if proxy_for_nil_class? & @@warn_about_expectations_on_nil + Kernel.warn("An expectation of :#{sym} was set on nil. Called from #{caller[2]}. Use allow_message_expectations_on_nil to disable warnings.") + end + end + + def define_expected_method(sym) + unless @proxied_methods.include?(sym) + visibility_string = "#{visibility(sym)} :#{sym}" + if target_responds_to?(sym) + munged_sym = munge(sym) + target_metaclass.instance_eval do + alias_method munged_sym, sym if method_defined?(sym) + end + @proxied_methods << sym + end + target_metaclass.class_eval(<<-EOF, __FILE__, __LINE__) + def #{sym}(*args, &block) + __mock_proxy.message_received :#{sym}, *args, &block + end + #{visibility_string} + EOF + end + end + + def target_responds_to?(sym) + return @target.__send__(munge(:respond_to?),sym) if @already_proxied_respond_to + return @already_proxied_respond_to = true if sym == :respond_to? + return @target.respond_to?(sym, true) + end + + def visibility(sym) + if Mock === @target + 'public' + elsif target_metaclass.private_method_defined?(sym) + 'private' + elsif target_metaclass.protected_method_defined?(sym) + 'protected' + else + 'public' + end + end + + def munge(sym) + "proxied_by_rspec__#{sym}" + end + + def clear_expectations + @expectations.clear + end + + def clear_stubs + @stubs.clear + end + + def clear_proxied_methods + @proxied_methods.clear + end + + def target_metaclass + class << @target; self; end + end + + def verify_expectations + @expectations.each do |expectation| + expectation.verify_messages_received + end + end + + def reset_proxied_methods + @proxied_methods.each do |sym| + reset_proxied_method(sym) + end + end + + def reset_proxied_method(sym) + munged_sym = munge(sym) + target_metaclass.instance_eval do + remove_method sym + if method_defined?(munged_sym) + alias_method sym, munged_sym + remove_method munged_sym + end + end + end + + def proxy_for_nil_class? + @target.nil? + end + + def reset_nil_expectations_warning + @@warn_about_expectations_on_nil = true if proxy_for_nil_class? + end + + def find_matching_expectation(sym, *args) + @expectations.find {|expectation| expectation.matches(sym, args) && !expectation.called_max_times?} || + @expectations.find {|expectation| expectation.matches(sym, args)} + end + + def find_almost_matching_expectation(sym, *args) + @expectations.find {|expectation| expectation.matches_name_but_not_args(sym, args)} + end + + end + end +end diff --git a/vendor/gems/gems/rspec-1.2.9/lib/spec/mocks/space.rb b/vendor/gems/gems/rspec-1.2.9/lib/spec/mocks/space.rb new file mode 100755 index 00000000..3e13224c --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/lib/spec/mocks/space.rb @@ -0,0 +1,28 @@ +module Spec + module Mocks + class Space + def add(obj) + mocks << obj unless mocks.detect {|m| m.equal? obj} + end + + def verify_all + mocks.each do |mock| + mock.rspec_verify + end + end + + def reset_all + mocks.each do |mock| + mock.rspec_reset + end + mocks.clear + end + + private + + def mocks + @mocks ||= [] + end + end + end +end diff --git a/vendor/gems/gems/rspec-1.2.9/lib/spec/rake/spectask.rb b/vendor/gems/gems/rspec-1.2.9/lib/spec/rake/spectask.rb new file mode 100755 index 00000000..9049fd08 --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/lib/spec/rake/spectask.rb @@ -0,0 +1,230 @@ +#!/usr/bin/env ruby + +# Define a task library for running RSpec contexts. + +require 'rake' +require 'rake/tasklib' + +module Spec + module Rake + + # A Rake task that runs a set of specs. + # + # Example: + # + # Spec::Rake::SpecTask.new do |t| + # t.warning = true + # t.rcov = true + # end + # + # This will create a task that can be run with: + # + # rake spec + # + # If rake is invoked with a "SPEC=filename" command line option, + # then the list of spec files will be overridden to include only the + # filename specified on the command line. This provides an easy way + # to run just one spec. + # + # If rake is invoked with a "SPEC_OPTS=options" command line option, + # then the given options will override the value of the +spec_opts+ + # attribute. + # + # If rake is invoked with a "RCOV_OPTS=options" command line option, + # then the given options will override the value of the +rcov_opts+ + # attribute. + # + # Examples: + # + # rake spec # run specs normally + # rake spec SPEC=just_one_file.rb # run just one spec file. + # rake spec SPEC_OPTS="--diff" # enable diffing + # rake spec RCOV_OPTS="--aggregate myfile.txt" # see rcov --help for details + # + # Each attribute of this task may be a proc. This allows for lazy evaluation, + # which is sometimes handy if you want to defer the evaluation of an attribute value + # until the task is run (as opposed to when it is defined). + # + # This task can also be used to run existing Test::Unit tests and get RSpec + # output, for example like this: + # + # require 'spec/rake/spectask' + # Spec::Rake::SpecTask.new do |t| + # t.ruby_opts = ['-rtest/unit'] + # t.spec_files = FileList['test/**/*_test.rb'] + # end + # + class SpecTask < ::Rake::TaskLib + def self.attr_accessor(*names) + super(*names) + names.each do |name| + module_eval "def #{name}() evaluate(@#{name}) end" # Allows use of procs + end + end + + # Name of spec task. (default is :spec) + attr_accessor :name + + # Array of directories to be added to $LOAD_PATH before running the + # specs. Defaults to [''] + attr_accessor :libs + + # If true, requests that the specs be run with the warning flag set. + # E.g. warning=true implies "ruby -w" used to run the specs. Defaults to false. + attr_accessor :warning + + # Glob pattern to match spec files. (default is 'spec/**/*_spec.rb') + # Setting the SPEC environment variable overrides this. + attr_accessor :pattern + + # Array of commandline options to pass to RSpec. Defaults to []. + # Setting the SPEC_OPTS environment variable overrides this. + attr_accessor :spec_opts + + # Whether or not to use RCov (default is false) + # See http://eigenclass.org/hiki.rb?rcov + attr_accessor :rcov + + # Array of commandline options to pass to RCov. Defaults to ['--exclude', 'lib\/spec,bin\/spec']. + # Ignored if rcov=false + # Setting the RCOV_OPTS environment variable overrides this. + attr_accessor :rcov_opts + + # Directory where the RCov report is written. Defaults to "coverage" + # Ignored if rcov=false + attr_accessor :rcov_dir + + # Array of commandline options to pass to ruby. Defaults to []. + attr_accessor :ruby_opts + + # Whether or not to fail Rake when an error occurs (typically when specs fail). + # Defaults to true. + attr_accessor :fail_on_error + + # A message to print to stderr when there are failures. + attr_accessor :failure_message + + # Where RSpec's output is written. Defaults to $stdout. + # DEPRECATED. Use --format FORMAT:WHERE in spec_opts. + attr_accessor :out + + # Explicitly define the list of spec files to be included in a + # spec. +spec_files+ is expected to be an array of file names (a + # FileList is acceptable). If both +pattern+ and +spec_files+ are + # used, then the list of spec files is the union of the two. + # Setting the SPEC environment variable overrides this. + attr_accessor :spec_files + + # Use verbose output. If this is set to true, the task will print + # the executed spec command to stdout. Defaults to false. + attr_accessor :verbose + + # Explicitly define the path to the ruby binary, or its proxy (e.g. multiruby) + attr_accessor :ruby_cmd + + # Defines a new task, using the name +name+. + def initialize(name=:spec) + @name = name + @libs = ['lib'] + @pattern = nil + @spec_files = nil + @spec_opts = [] + @warning = false + @ruby_opts = [] + @fail_on_error = true + @rcov = false + @rcov_opts = ['--exclude', 'lib\/spec,bin\/spec,config\/boot.rb'] + @rcov_dir = "coverage" + + yield self if block_given? + @pattern = 'spec/**/*_spec.rb' if pattern.nil? && spec_files.nil? + define + end + + def define # :nodoc: + spec_script = File.expand_path(File.join(File.dirname(__FILE__),"..","..","..","bin","spec")) + + lib_path = libs.join(File::PATH_SEPARATOR) + actual_name = Hash === name ? name.keys.first : name + unless ::Rake.application.last_comment + desc "Run specs" + (rcov ? " using RCov" : "") + end + task name do + RakeFileUtils.verbose(verbose) do + unless spec_file_list.empty? + # ruby [ruby_opts] -Ilib -S rcov [rcov_opts] bin/spec -- examples [spec_opts] + # or + # ruby [ruby_opts] -Ilib bin/spec examples [spec_opts] + cmd_parts = [ruby_cmd || RUBY] + cmd_parts += ruby_opts + cmd_parts << %[-I"#{lib_path}"] + cmd_parts << "-S rcov" if rcov + cmd_parts << "-w" if warning + cmd_parts << rcov_option_list + cmd_parts << %[-o "#{rcov_dir}"] if rcov + cmd_parts << %["#{spec_script}"] + cmd_parts << "--" if rcov + cmd_parts += spec_file_list.collect { |fn| %["#{fn}"] } + cmd_parts << spec_option_list + if out + cmd_parts << %[> "#{out}"] + STDERR.puts "The Spec::Rake::SpecTask#out attribute is DEPRECATED and will be removed in a future version. Use --format FORMAT:WHERE instead." + end + cmd = cmd_parts.join(" ") + puts cmd if verbose + unless system(cmd) + STDERR.puts failure_message if failure_message + raise("Command #{cmd} failed") if fail_on_error + end + end + end + end + + if rcov + desc "Remove rcov products for #{actual_name}" + task paste("clobber_", actual_name) do + rm_r rcov_dir rescue nil + end + + clobber_task = paste("clobber_", actual_name) + task :clobber => [clobber_task] + + task actual_name => clobber_task + end + self + end + + def rcov_option_list # :nodoc: + if rcov + ENV['RCOV_OPTS'] || rcov_opts.join(" ") || "" + else + "" + end + end + + def spec_option_list # :nodoc: + STDERR.puts "RSPECOPTS is DEPRECATED and will be removed in a future version. Use SPEC_OPTS instead." if ENV['RSPECOPTS'] + ENV['SPEC_OPTS'] || ENV['RSPECOPTS'] || spec_opts.join(" ") || "" + end + + def evaluate(o) # :nodoc: + case o + when Proc then o.call + else o + end + end + + def spec_file_list # :nodoc: + if ENV['SPEC'] + FileList[ ENV['SPEC'] ] + else + result = [] + result += spec_files.to_a if spec_files + result += FileList[ pattern ].to_a if pattern + FileList[result] + end + end + + end + end +end diff --git a/vendor/gems/gems/rspec-1.2.9/lib/spec/rake/verify_rcov.rb b/vendor/gems/gems/rspec-1.2.9/lib/spec/rake/verify_rcov.rb new file mode 100755 index 00000000..199bd854 --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/lib/spec/rake/verify_rcov.rb @@ -0,0 +1,52 @@ +module RCov + # A task that can verify that the RCov coverage doesn't + # drop below a certain threshold. It should be run after + # running Spec::Rake::SpecTask. + class VerifyTask < Rake::TaskLib + # Name of the task. Defaults to :verify_rcov + attr_accessor :name + + # Path to the index.html file generated by RCov, which + # is the file containing the total coverage. + # Defaults to 'coverage/index.html' + attr_accessor :index_html + + # Whether or not to output details. Defaults to true. + attr_accessor :verbose + + # The threshold value (in percent) for coverage. If the + # actual coverage is not equal to this value, the task will raise an + # exception. + attr_accessor :threshold + + # Require the threshold value be met exactly. This is the default. + attr_accessor :require_exact_threshold + + def initialize(name=:verify_rcov) + @name = name + @index_html = 'coverage/index.html' + @verbose = true + @require_exact_threshold = true + yield self if block_given? + raise "Threshold must be set" if @threshold.nil? + define + end + + def define + desc "Verify that rcov coverage is at least #{threshold}%" + task @name do + total_coverage = 0 + + File.open(index_html).each_line do |line| + if line =~ /\s*(\d+\.\d+)%\s*<\/tt>/ + total_coverage = $1.to_f + break + end + end + puts "Coverage: #{total_coverage}% (threshold: #{threshold}%)" if verbose + raise "Coverage must be at least #{threshold}% but was #{total_coverage}%" if total_coverage < threshold + raise "Coverage has increased above the threshold of #{threshold}% to #{total_coverage}%. You should update your threshold value." if (total_coverage > threshold) and require_exact_threshold + end + end + end +end diff --git a/vendor/gems/gems/rspec-1.2.9/lib/spec/ruby.rb b/vendor/gems/gems/rspec-1.2.9/lib/spec/ruby.rb new file mode 100755 index 00000000..863877c7 --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/lib/spec/ruby.rb @@ -0,0 +1,9 @@ +module Spec + module Ruby + class << self + def version + RUBY_VERSION + end + end + end +end diff --git a/vendor/gems/gems/rspec-1.2.9/lib/spec/runner.rb b/vendor/gems/gems/rspec-1.2.9/lib/spec/runner.rb new file mode 100755 index 00000000..519b536e --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/lib/spec/runner.rb @@ -0,0 +1,66 @@ +require 'spec/runner/configuration' +require 'spec/runner/options' +require 'spec/runner/option_parser' +require 'spec/runner/example_group_runner' +require 'spec/runner/command_line' +require 'spec/runner/drb_command_line' +require 'spec/runner/backtrace_tweaker' +require 'spec/runner/reporter' +require 'spec/runner/line_number_query' +require 'spec/runner/class_and_arguments_parser' +require 'spec/runner/extensions/kernel' + +module Spec + module Runner + + class ExampleGroupCreationListener + def register_example_group(klass) + Spec::Runner.options.add_example_group klass + end + end + + Spec::Example::ExampleGroupFactory.example_group_creation_listeners << ExampleGroupCreationListener.new + + class << self + def configuration # :nodoc: + @configuration ||= Spec::Runner::Configuration.new + end + + # Use this to configure various configurable aspects of + # RSpec: + # + # Spec::Runner.configure do |configuration| + # # Configure RSpec here + # end + # + # The yielded configuration object is a + # Spec::Runner::Configuration instance. See its RDoc + # for details about what you can do with it. + # + def configure + yield configuration + end + + def autorun # :nodoc: + at_exit {exit run unless $!} + end + + def options # :nodoc: + @options ||= begin + parser = ::Spec::Runner::OptionParser.new($stderr, $stdout) + parser.order!(ARGV) + parser.options + end + end + + def use options + @options = options + end + + def run + options.examples_run? || options.run_examples + end + + end + end +end \ No newline at end of file diff --git a/vendor/gems/gems/rspec-1.2.9/lib/spec/runner/backtrace_tweaker.rb b/vendor/gems/gems/rspec-1.2.9/lib/spec/runner/backtrace_tweaker.rb new file mode 100755 index 00000000..a3cb7d9b --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/lib/spec/runner/backtrace_tweaker.rb @@ -0,0 +1,77 @@ +module Spec + module Runner + class BacktraceTweaker + def initialize(*patterns) + @ignore_patterns = [] + end + + def clean_up_double_slashes(line) + line.gsub!('//','/') + end + + def ignore_patterns(*patterns) + # do nothing. Only QuietBacktraceTweaker ignores patterns. + end + + def ignored_patterns + [] + end + + def tweak_backtrace(error) + return if error.backtrace.nil? + tweaked = error.backtrace.collect do |message| + clean_up_double_slashes(message) + kept_lines = message.split("\n").select do |line| + ignored_patterns.each do |ignore| + break if line =~ ignore + end + end + kept_lines.empty?? nil : kept_lines.join("\n") + end + error.set_backtrace(tweaked.select {|line| line}) + end + end + + class NoisyBacktraceTweaker < BacktraceTweaker + end + + # Tweaks raised Exceptions to mask noisy (unneeded) parts of the backtrace + class QuietBacktraceTweaker < BacktraceTweaker + unless defined?(IGNORE_PATTERNS) + spec_files = Dir["lib/*"].map do |path| + subpath = path[1..-1] + /#{subpath}/ + end + IGNORE_PATTERNS = spec_files + [ + /\/rspec-[^\/]*\/lib\/spec\//, + /\/spork-[^\/]*\/lib\/spork\//, + /\/lib\/ruby\//, + /bin\/spec:/, + /bin\/spork:/, + /bin\/rcov:/, + /lib\/rspec-rails/, + /vendor\/rails/, + # TextMate's Ruby and RSpec plugins + /Ruby\.tmbundle\/Support\/tmruby.rb:/, + /RSpec\.tmbundle\/Support\/lib/, + /temp_textmate\./, + /mock_frameworks\/rspec/, + /spec_server/ + ] + end + + def initialize(*patterns) + super + ignore_patterns(*patterns) + end + + def ignore_patterns(*patterns) + @ignore_patterns += patterns.flatten.map { |pattern| Regexp.new(pattern) } + end + + def ignored_patterns + IGNORE_PATTERNS + @ignore_patterns + end + end + end +end diff --git a/vendor/gems/gems/rspec-1.2.9/lib/spec/runner/class_and_arguments_parser.rb b/vendor/gems/gems/rspec-1.2.9/lib/spec/runner/class_and_arguments_parser.rb new file mode 100755 index 00000000..a49ade26 --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/lib/spec/runner/class_and_arguments_parser.rb @@ -0,0 +1,14 @@ +module Spec + module Runner + class ClassAndArgumentsParser + def self.parse(s) + if s =~ /([a-zA-Z_]+(?:::[a-zA-Z_]+)*):?(.*)/ + arg = $2 == "" ? nil : $2 + [$1, arg] + else + raise "Couldn't parse #{s.inspect}" + end + end + end + end +end diff --git a/vendor/gems/gems/rspec-1.2.9/lib/spec/runner/command_line.rb b/vendor/gems/gems/rspec-1.2.9/lib/spec/runner/command_line.rb new file mode 100755 index 00000000..35a7e315 --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/lib/spec/runner/command_line.rb @@ -0,0 +1,15 @@ +require 'spec/runner/option_parser' + +module Spec + module Runner + class CommandLine + def self.run(tmp_options=Spec::Runner.options) + orig_options = Spec::Runner.options + Spec::Runner.use tmp_options + tmp_options.run_examples + ensure + Spec::Runner.use orig_options + end + end + end +end diff --git a/vendor/gems/gems/rspec-1.2.9/lib/spec/runner/configuration.rb b/vendor/gems/gems/rspec-1.2.9/lib/spec/runner/configuration.rb new file mode 100755 index 00000000..d211565d --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/lib/spec/runner/configuration.rb @@ -0,0 +1,194 @@ +module Spec + module Runner + class Configuration + include Spec::Example::ArgsAndOptions + + # Chooses what mock framework to use. Example: + # + # Spec::Runner.configure do |config| + # config.mock_with :rspec, :mocha, :flexmock, or :rr + # end + # + # To use any other mock framework, you'll have to provide your own + # adapter. This is simply a module that responds to the following + # methods: + # + # setup_mocks_for_rspec + # verify_mocks_for_rspec + # teardown_mocks_for_rspec. + # + # These are your hooks into the lifecycle of a given example. RSpec will + # call setup_mocks_for_rspec before running anything else in each + # Example. After executing the #after methods, RSpec will then call + # verify_mocks_for_rspec and teardown_mocks_for_rspec (this is + # guaranteed to run even if there are failures in + # verify_mocks_for_rspec). + # + # Once you've defined this module, you can pass that to mock_with: + # + # Spec::Runner.configure do |config| + # config.mock_with MyMockFrameworkAdapter + # end + # + def mock_with(mock_framework) + @mock_framework = case mock_framework + when Symbol + mock_framework_path(mock_framework.to_s) + else + mock_framework + end + end + + def mock_framework # :nodoc: + @mock_framework ||= mock_framework_path("rspec") + end + + # :call-seq: + # include(Some::Helpers) + # include(Some::Helpers, More::Helpers) + # include(My::Helpers, :type => :key) + # + # Declares modules to be included in multiple example groups + # (describe blocks). With no :type, the modules listed + # will be included in all example groups. + # + # Use :type to restrict + # the inclusion to a subset of example groups. The value assigned to + # :type should be a key that maps to a class that is either a + # subclass of Spec::Example::ExampleGroup or extends + # Spec::Example::ExampleGroupMethods and includes + # Spec::Example::ExampleMethods. + # + # For example, the rspec-rails gem/plugin extends Test::Unit::TestCase + # with Spec::Example::ExampleGroupMethods and includes + # Spec::Example::ExampleMethods in it. So if you have a module of helper + # methods for controller examples, you could do this: + # + # config.include(ControllerExampleHelpers, :type => :controller) + # + # Only example groups that have that type will get the modules included: + # + # describe Account, :type => :model do + # # Will *not* include ControllerExampleHelpers + # end + # + # describe AccountsController, :type => :controller do + # # *Will* include ControllerExampleHelpers + # end + # + def include(*modules_and_options) + include_or_extend(:include, *modules_and_options) + end + + # :call-seq: + # extend(Some::Helpers) + # extend(Some::Helpers, More::Helpers) + # extend(My::Helpers, :type => :key) + # + # Works just like #include, but extends the example groups + # with the modules rather than including them. + def extend(*modules_and_options) + include_or_extend(:extend, *modules_and_options) + end + + # Appends a global before block to all example groups. + # scope can be any of :each (default), :all, or + # :suite. When :each, the block is executed before each + # example. When :all, the block is executed once per example + # group, before any of its examples are run. When :suite the + # block is run once before the entire suite is run. + def append_before(scope = :each, options={}, &proc) + add_callback(:append_before, scope, options, &proc) + end + alias_method :before, :append_before + + # Prepends a global before block to all example groups. + # + # See append_before for scoping semantics. + def prepend_before(scope = :each, options={}, &proc) + add_callback(:prepend_before, scope, options, &proc) + end + + # Prepends a global after block to all example groups. + # + # See append_before for scoping semantics. + def prepend_after(scope = :each, options={}, &proc) + add_callback(:prepend_after, scope, options, &proc) + end + alias_method :after, :prepend_after + + # Appends a global after block to all example groups. + # + # See append_before for scoping semantics. + def append_after(scope = :each, options={}, &proc) + add_callback(:append_after, scope, options, &proc) + end + + # DEPRECATED - use Spec::Matchers::DSL instead + # + # Defines global predicate matchers. Example: + # + # config.predicate_matchers[:swim] = :can_swim? + # + # This makes it possible to say: + # + # person.should swim # passes if person.can_swim? returns true + # + def predicate_matchers + @predicate_matchers ||= Spec::HashWithDeprecationNotice.new("predicate_matchers", "the new Matcher DSL") + end + + # Adds patterns to the list of patterns ignored in the backtrace when a + # failure is output by rspec. Example: + # + # config.ignore_backtrace_patterns /spork/, /shoulda/, "/some/weird/path/" + # + # When quiet backtraces are turned on (default), this will exclude any + # lines that match any of the Regexps and Strings passed. + # + def ignore_backtrace_patterns(*patterns) + @ignored_backtrace_patterns ||= [] + @ignored_backtrace_patterns += patterns + end + + def ignored_backtrace_patterns # :nodoc: + @ignored_backtrace_patterns ||= [] + end + + private + + def include_or_extend(action, *args) + modules, options = args_and_options(*args) + [get_type_from_options(options)].flatten.each do |required_example_group| + required_example_group = required_example_group.to_sym if required_example_group + modules.each do |mod| + Spec::Example::ExampleGroupFactory[required_example_group].__send__(action, mod) + end + end + end + + def add_callback(sym, *args, &proc) + scope, options = scope_and_options(*args) + example_group = Spec::Example::ExampleGroupFactory[get_type_from_options(options)] + example_group.__send__(sym, scope, &proc) + end + + def get_type_from_options(options) + options[:type] || options[:behaviour_type] + end + + def mock_framework_path(framework_name) + "spec/adapters/mock_frameworks/#{framework_name}" + end + + def scope_and_options(*args) # :nodoc: + args, options = args_and_options(*args) + return scope_from(*args), options + end + + def scope_from(*args) # :nodoc: + args[0] || :each + end + end + end +end diff --git a/vendor/gems/gems/rspec-1.2.9/lib/spec/runner/differs/default.rb b/vendor/gems/gems/rspec-1.2.9/lib/spec/runner/differs/default.rb new file mode 100755 index 00000000..7f0a7e64 --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/lib/spec/runner/differs/default.rb @@ -0,0 +1,93 @@ +require 'spec/runner/differs/load-diff-lcs' +require 'pp' + +module Spec + module Expectations + module Differs + unless defined?(Default) + class Default + def initialize(options) + @options = options + end + + # This is snagged from diff/lcs/ldiff.rb (which is a commandline tool) + def diff_as_string(data_new, data_old) + data_old = data_old.split(/\n/).map! { |e| e.chomp } + data_new = data_new.split(/\n/).map! { |e| e.chomp } + output = "" + diffs = Diff::LCS.diff(data_old, data_new) + return output if diffs.empty? + oldhunk = hunk = nil + file_length_difference = 0 + diffs.each do |piece| + begin + hunk = Diff::LCS::Hunk.new(data_old, data_new, piece, context_lines, + file_length_difference) + file_length_difference = hunk.file_length_difference + next unless oldhunk + # Hunks may overlap, which is why we need to be careful when our + # diff includes lines of context. Otherwise, we might print + # redundant lines. + if (context_lines > 0) and hunk.overlaps?(oldhunk) + hunk.unshift(oldhunk) + else + output << oldhunk.diff(format) + end + ensure + oldhunk = hunk + output << "\n" + end + end + #Handle the last remaining hunk + output << oldhunk.diff(format) << "\n" + end + + def diff_as_object(target,expected) + diff_as_string(PP.pp(target,""), PP.pp(expected,"")) + end + + def diff_as_hash(target, expected) + contains_hash = false + contains_array = false + + extra_expected_keys = expected.keys - target.keys + extra_target_keys = target.keys - expected.keys + + o = "\n" + + o << "Expected hash contains keys that target hash does not: " << extra_expected_keys.inspect << "\n" if !extra_expected_keys.empty? + o << "Target hash contains keys that expected hash does not: " << extra_target_keys.inspect << "\n" if !extra_target_keys.empty? + + expected.delete_if do |key, value| + contains_hash = true if value.is_a?(Hash) + contains_array = true if value.is_a?(Array) + target[key] == value + end + + expected.keys.sort { |a,b| a.to_s <=> b.to_s }.each do |key| + o << "Expected the key #{key.inspect} to be #{expected[key].inspect}, but was #{target[key].inspect}\n" + end + + o << "\n" + + if contains_hash || contains_array + o << diff_as_object(target, expected) + else + o + end + end + + protected + def format + @options.diff_format + end + + def context_lines + @options.context_lines + end + end + + end + end + end +end diff --git a/vendor/gems/gems/rspec-1.2.9/lib/spec/runner/differs/load-diff-lcs.rb b/vendor/gems/gems/rspec-1.2.9/lib/spec/runner/differs/load-diff-lcs.rb new file mode 100755 index 00000000..f708bc9b --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/lib/spec/runner/differs/load-diff-lcs.rb @@ -0,0 +1,12 @@ +begin + require 'diff/lcs' +rescue LoadError + begin + require 'rubygems' unless ENV['NO_RUBYGEMS'] + require 'diff/lcs' + rescue LoadError + raise "You must gem install diff-lcs to use diffing" + end +end + +require 'diff/lcs/hunk' diff --git a/vendor/gems/gems/rspec-1.2.9/lib/spec/runner/drb_command_line.rb b/vendor/gems/gems/rspec-1.2.9/lib/spec/runner/drb_command_line.rb new file mode 100755 index 00000000..058a8e1d --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/lib/spec/runner/drb_command_line.rb @@ -0,0 +1,26 @@ +require "drb/drb" + +module Spec + module Runner + # Facade to run specs by connecting to a DRB server + class DrbCommandLine + # Runs specs on a DRB server. Note that this API is similar to that of + # CommandLine - making it possible for clients to use both interchangeably. + def self.run(options) + begin + begin; \ + DRb.start_service("druby://localhost:0"); \ + rescue SocketError; \ + DRb.start_service("druby://:0"); \ + end + spec_server = DRbObject.new_with_uri("druby://127.0.0.1:8989") + spec_server.run(options.argv, options.error_stream, options.output_stream) + true + rescue DRb::DRbConnError + options.error_stream.puts "No server is running" + false + end + end + end + end +end diff --git a/vendor/gems/gems/rspec-1.2.9/lib/spec/runner/example_group_runner.rb b/vendor/gems/gems/rspec-1.2.9/lib/spec/runner/example_group_runner.rb new file mode 100755 index 00000000..67dc9950 --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/lib/spec/runner/example_group_runner.rb @@ -0,0 +1,59 @@ +module Spec + module Runner + class ExampleGroupRunner + def initialize(options) + @options = options + end + + def load_files(files) + $KCODE = 'u' if RUBY_VERSION.to_f < 1.9 + # It's important that loading files (or choosing not to) stays the + # responsibility of the ExampleGroupRunner. Some implementations (like) + # the one using DRb may choose *not* to load files, but instead tell + # someone else to do it over the wire. + files.each do |file| + load file + end + end + + def run + prepare + success = true + example_groups.each do |example_group| + success = success & example_group.run(@options) + end + return success + ensure + finish + end + + protected + + def prepare + reporter.start(number_of_examples) + example_groups.reverse! if reverse + end + + def finish + reporter.end + reporter.dump + end + + def reporter + @options.reporter + end + + def reverse + @options.reverse + end + + def example_groups + @options.example_groups + end + + def number_of_examples + @options.number_of_examples + end + end + end +end diff --git a/vendor/gems/gems/rspec-1.2.9/lib/spec/runner/extensions/kernel.rb b/vendor/gems/gems/rspec-1.2.9/lib/spec/runner/extensions/kernel.rb new file mode 100755 index 00000000..4e23cdf2 --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/lib/spec/runner/extensions/kernel.rb @@ -0,0 +1,9 @@ +module Kernel + unless respond_to?(:debugger) + # Start a debugging session if ruby-debug is loaded with the -u/--debugger option + def debugger(steps=1) + # If not then just comment and proceed + $stderr.puts "debugger statement ignored, use -u or --debugger option on rspec to enable debugging" + end + end +end diff --git a/vendor/gems/gems/rspec-1.2.9/lib/spec/runner/formatter/base_formatter.rb b/vendor/gems/gems/rspec-1.2.9/lib/spec/runner/formatter/base_formatter.rb new file mode 100755 index 00000000..0fbc12ce --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/lib/spec/runner/formatter/base_formatter.rb @@ -0,0 +1,139 @@ +module Spec + module Runner + module Formatter + # Formatter base-class, which implements all required methods as no-ops, with the exception + class BaseFormatter + # Formatters are initialized with options and output + # arguments. RSpec's built-in formatters already expect this, and any + # custom formatters should as well. + # + # ==== Parameters + # options:: + # A struct containing boolean values for colour, autospec, + # and dry_run + # output:: + # Used by RSpec's built-in formatters to determine where to + # write the output. Default is STDOUT, otherwise a + # filename is expected. + # + # === Example + # If you invoke the spec command with: + # + # --format progress:progress_report.txt + # + # ... the value of output will be progress_report.txt. If you + # don't identify an output destination, the default is STDOUT. + def initialize(options, output) + end + + # This method is invoked before any examples are run, right after + # they have all been collected. This can be useful for special + # formatters that need to provide progress on feedback (graphical ones) + # + # This method will only be invoked once, and the next one to be invoked + # is #example_group_started + # + # ==== Parameters + # example_count:: the total number of examples to be run + def start(example_count) + end + + # This method is invoked at the beginning of the execution of each + # example_group. The next method to be invoked after this is + # #example_started + # + # ==== Parameters + # example_group_proxy:: instance of Spec::Example::ExampleGroupProxy + def example_group_started(example_group_proxy) + end + + # Deprecated - use example_group_started instead + def add_example_group(example_group_proxy) + Spec.deprecate("BaseFormatter#add_example_group", "BaseFormatter#example_group_started") + example_group_started(example_group_proxy) + end + + # This method is invoked when an +example+ starts. The next method to be + # invoked after this is #example_passed, #example_failed, or + # #example_pending + # + # ==== Parameters + # example_proxy:: instance of Spec::Example::ExampleProxy + def example_started(example_proxy) + end + + # This method is invoked when an +example+ passes. + # +example_proxy+ is the same instance of Spec::Example::ExampleProxy + # that was passed to example_started + # + # ==== Parameters + # example_proxy:: instance of Spec::Example::ExampleProxy + def example_passed(example_proxy) + end + + # This method is invoked when an +example+ fails, i.e. an exception occurred + # inside it (such as a failed should or other exception). + # + # ==== Parameters + # example_proxy:: + # The same instance of Spec::Example::ExampleProxy that was passed + # to example_started + # + # counter:: the sequential number of this failure + # + # failure:: instance of Spec::Runner::Reporter::Failure + def example_failed(example_proxy, counter, failure) + end + + # This method is invoked when an example is not yet implemented (i.e. has not + # been provided a block), or when an ExamplePendingError is raised. + # +message+ is the message from the ExamplePendingError, if it exists, or the + # default value of "Not Yet Implemented". +deprecated_pending_location+ is + # deprecated - use example_proxy.location instead + # + # ==== Parameters + # example_proxy:: instance of Spec::Example::ExampleProxy + # message:: + # the message passed to the pending message, or an internal + # default + # + def example_pending(example_proxy, message, deprecated_pending_location=nil) + end + + # This method is invoked after all of the examples have executed. The next method + # to be invoked after this one is #dump_failure (once for each failed example) + def start_dump + end + + # Dumps detailed information about an example failure. + # This method is invoked for each failed example after all examples have run. +counter+ is the sequence number + # of the associated example. +failure+ is a Failure object, which contains detailed + # information about the failure. + # + # ==== Parameters + # counter:: the sequential number of this failure + # failure:: instance of Spec::Runner::Reporter::Failure + def dump_failure(counter, failure) + end + + # This method is invoked after the dumping of examples and failures. + # + # ==== Parameters + # duration:: the total time for the entire run + # example_count:: the number of examples run + # failure_count:: the number of examples that failed + # pending_count:: the number of examples that are pending + def dump_summary(duration, example_count, failure_count, pending_count) + end + + # This gets invoked after the summary + def dump_pending + end + + # This method is invoked at the very end. Allows the formatter to clean up, like closing open streams. + def close + end + end + end + end +end diff --git a/vendor/gems/gems/rspec-1.2.9/lib/spec/runner/formatter/base_text_formatter.rb b/vendor/gems/gems/rspec-1.2.9/lib/spec/runner/formatter/base_text_formatter.rb new file mode 100755 index 00000000..ee8db75a --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/lib/spec/runner/formatter/base_text_formatter.rb @@ -0,0 +1,142 @@ +require 'spec/runner/formatter/base_formatter' +require 'fileutils' + +module Spec + module Runner + module Formatter + # Baseclass for text-based formatters. Can in fact be used for + # non-text based ones too - just ignore the +output+ constructor + # argument. + class BaseTextFormatter < BaseFormatter + attr_reader :output, :example_group + # Creates a new instance that will write to +output+. If +output+ is a + # String, output will be written to the File with that name, otherwise + # +output+ is exected to be an IO (or an object that responds to #puts + # and #write). + def initialize(options, output) + @options = options + if String === output + FileUtils.mkdir_p(File.dirname(output)) + @output = File.open(output, 'w') + else + @output = output + end + @pending_examples = [] + end + + def example_group_started(example_group_proxy) + @example_group = example_group_proxy + end + + def example_pending(example, message, deprecated_pending_location=nil) + @pending_examples << ["#{@example_group.description} #{example.description}", message, example.location] + end + + def dump_failure(counter, failure) + @output.puts + @output.puts "#{counter.to_s})" + @output.puts colorize_failure("#{failure.header}\n#{failure.exception.message}", failure) + @output.puts format_backtrace(failure.exception.backtrace) + @output.flush + end + + def colorize_failure(message, failure) + failure.pending_fixed? ? blue(message) : red(message) + end + + def colourise(message, failure) + Spec::deprecate("BaseTextFormatter#colourise", "colorize_failure") + colorize_failure(message, failure) + end + + def dump_summary(duration, example_count, failure_count, pending_count) + return if dry_run? + @output.puts + @output.puts "Finished in #{duration} seconds" + @output.puts + + summary = "#{example_count} example#{'s' unless example_count == 1}, #{failure_count} failure#{'s' unless failure_count == 1}" + summary << ", #{pending_count} pending" if pending_count > 0 + + if failure_count == 0 + if pending_count > 0 + @output.puts yellow(summary) + else + @output.puts green(summary) + end + else + @output.puts red(summary) + end + @output.flush + end + + def dump_pending + unless @pending_examples.empty? + @output.puts + @output.puts "Pending:" + @pending_examples.each do |pending_example| + @output.puts "\n#{pending_example[0]} (#{pending_example[1]})" + @output.puts "#{pending_example[2]}\n" + end + end + @output.flush + end + + def close + @output.close if (IO === @output) & (@output != $stdout) + end + + def format_backtrace(backtrace) + return "" if backtrace.nil? + backtrace.map { |line| backtrace_line(line) }.join("\n") + end + + protected + + def colour? + !!@options.colour + end + + def dry_run? + !!@options.dry_run + end + + def autospec? + !!@options.autospec || ENV.has_key?("AUTOTEST") + end + + def backtrace_line(line) + line.sub(/\A([^:]+:\d+)$/, '\\1:') + end + + def colour(text, colour_code) + return text if output_to_file? + return text unless ENV['RSPEC_COLOR'] || (colour? & (autospec? || output_to_tty?)) + "#{colour_code}#{text}\e[0m" + end + + def output_to_file? + File === @output + end + + def output_to_tty? + begin + @output.tty? + rescue NoMethodError + false + end + end + + def green(text); colour(text, "\e[32m"); end + def red(text); colour(text, "\e[31m"); end + def yellow(text); colour(text, "\e[33m"); end + def blue(text); colour(text, "\e[34m"); end + + def magenta(text) + Spec::deprecate("BaseTextFormatter#magenta") + red(text) + end + end + end + end +end diff --git a/vendor/gems/gems/rspec-1.2.9/lib/spec/runner/formatter/failing_example_groups_formatter.rb b/vendor/gems/gems/rspec-1.2.9/lib/spec/runner/formatter/failing_example_groups_formatter.rb new file mode 100755 index 00000000..31729438 --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/lib/spec/runner/formatter/failing_example_groups_formatter.rb @@ -0,0 +1,25 @@ +require 'spec/runner/formatter/base_text_formatter' + +module Spec + module Runner + module Formatter + class FailingExampleGroupsFormatter < BaseTextFormatter + def example_failed(example, counter, failure) + if @example_group + @output.puts @example_group.description.gsub(/ \(druby.*\)/,"") + + @output.flush + @example_group = nil + end + end + + def dump_failure(counter, failure) + end + + def dump_summary(duration, example_count, failure_count, pending_count) + end + + end + end + end +end diff --git a/vendor/gems/gems/rspec-1.2.9/lib/spec/runner/formatter/failing_examples_formatter.rb b/vendor/gems/gems/rspec-1.2.9/lib/spec/runner/formatter/failing_examples_formatter.rb new file mode 100755 index 00000000..e3a271c8 --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/lib/spec/runner/formatter/failing_examples_formatter.rb @@ -0,0 +1,20 @@ +require 'spec/runner/formatter/base_text_formatter' + +module Spec + module Runner + module Formatter + class FailingExamplesFormatter < BaseTextFormatter + def example_failed(example, counter, failure) + @output.puts "#{example_group.description} #{example.description}" + @output.flush + end + + def dump_failure(counter, failure) + end + + def dump_summary(duration, example_count, failure_count, pending_count) + end + end + end + end +end diff --git a/vendor/gems/gems/rspec-1.2.9/lib/spec/runner/formatter/html_formatter.rb b/vendor/gems/gems/rspec-1.2.9/lib/spec/runner/formatter/html_formatter.rb new file mode 100755 index 00000000..2d0c65d1 --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/lib/spec/runner/formatter/html_formatter.rb @@ -0,0 +1,338 @@ +require 'erb' +require 'spec/runner/formatter/base_text_formatter' +require 'spec/runner/formatter/no_op_method_missing' + +module Spec + module Runner + module Formatter + class HtmlFormatter < BaseTextFormatter + include ERB::Util # for the #h method + include NOOPMethodMissing + + def initialize(options, output) + super + @example_group_number = 0 + @example_number = 0 + @header_red = nil + end + + # The number of the currently running example_group + def example_group_number + @example_group_number + end + + # The number of the currently running example (a global counter) + def example_number + @example_number + end + + def start(example_count) + @example_count = example_count + + @output.puts html_header + @output.puts report_header + @output.flush + end + + def example_group_started(example_group) + super + @example_group_red = false + @example_group_number += 1 + unless example_group_number == 1 + @output.puts " " + @output.puts "" + end + @output.puts "
" + @output.puts "
" + @output.puts "
#{h(example_group.description)}
" + @output.flush + end + + def start_dump + @output.puts "
" + @output.puts "
" + @output.flush + end + + def example_started(example) + @example_number += 1 + end + + def example_passed(example) + move_progress + @output.puts "
#{h(example.description)}
" + @output.flush + end + + def example_failed(example, counter, failure) + extra = extra_failure_content(failure) + failure_style = failure.pending_fixed? ? 'pending_fixed' : 'failed' + @output.puts " " unless @header_red + @header_red = true + @output.puts " " unless @example_group_red + @example_group_red = true + move_progress + @output.puts "
" + @output.puts " #{h(example.description)}" + @output.puts "
" + @output.puts "
#{h(failure.exception.message)}
" unless failure.exception.nil? + @output.puts "
#{format_backtrace(failure.exception.backtrace)}
" unless failure.exception.nil? + @output.puts extra unless extra == "" + @output.puts "
" + @output.puts "
" + @output.flush + end + + def example_pending(example, message, deprecated_pending_location=nil) + @output.puts " " unless @header_red + @output.puts " " unless @example_group_red + move_progress + @output.puts "
#{h(example.description)} (PENDING: #{h(message)})
" + @output.flush + end + + # Override this method if you wish to output extra HTML for a failed spec. For example, you + # could output links to images or other files produced during the specs. + # + def extra_failure_content(failure) + require 'spec/runner/formatter/snippet_extractor' + @snippet_extractor ||= SnippetExtractor.new + "
#{@snippet_extractor.snippet(failure.exception)}
" + end + + def move_progress + @output.puts " " + @output.flush + end + + def percent_done + result = 100.0 + if @example_count != 0 + result = ((example_number).to_f / @example_count.to_f * 1000).to_i / 10.0 + end + result + end + + def dump_failure(counter, failure) + end + + def dump_summary(duration, example_count, failure_count, pending_count) + if dry_run? + totals = "This was a dry-run" + else + totals = "#{example_count} example#{'s' unless example_count == 1}, #{failure_count} failure#{'s' unless failure_count == 1}" + totals << ", #{pending_count} pending" if pending_count > 0 + end + @output.puts "" + @output.puts "" + @output.puts "" + @output.puts "" + @output.puts "" + @output.puts "" + @output.flush + end + + def html_header + <<-EOF + + + + + RSpec results + + + + + + + + +EOF + end + + def report_header + <<-EOF +
+ +
+
+

RSpec Code Examples

+
+ +
+

 

+

 

+
+
+ +
+EOF + end + + def global_scripts + <<-EOF +function moveProgressBar(percentDone) { + document.getElementById("rspec-header").style.width = percentDone +"%"; +} +function makeRed(element_id) { + document.getElementById(element_id).style.background = '#C40D0D'; + document.getElementById(element_id).style.color = '#FFFFFF'; +} + +function makeYellow(element_id) { + if (element_id == "rspec-header" && document.getElementById(element_id).style.background != '#C40D0D') + { + document.getElementById(element_id).style.background = '#FAF834'; + document.getElementById(element_id).style.color = '#000000'; + } + else + { + document.getElementById(element_id).style.background = '#FAF834'; + document.getElementById(element_id).style.color = '#000000'; + } +} +EOF + end + + def global_styles + <<-EOF +#rspec-header { + background: #65C400; color: #fff; height: 4em; +} + +.rspec-report h1 { + margin: 0px 10px 0px 10px; + padding: 10px; + font-family: "Lucida Grande", Helvetica, sans-serif; + font-size: 1.8em; + position: absolute; +} + +#summary { + margin: 0; padding: 5px 10px; + font-family: "Lucida Grande", Helvetica, sans-serif; + text-align: right; + top: 0px; + right: 0px; + float:right; +} + +#summary p { + margin: 0 0 0 2px; +} + +#summary #totals { + font-size: 1.2em; +} + +.example_group { + margin: 0 10px 5px; + background: #fff; +} + +dl { + margin: 0; padding: 0 0 5px; + font: normal 11px "Lucida Grande", Helvetica, sans-serif; +} + +dt { + padding: 3px; + background: #65C400; + color: #fff; + font-weight: bold; +} + +dd { + margin: 5px 0 5px 5px; + padding: 3px 3px 3px 18px; +} + +dd.spec.passed { + border-left: 5px solid #65C400; + border-bottom: 1px solid #65C400; + background: #DBFFB4; color: #3D7700; +} + +dd.spec.failed { + border-left: 5px solid #C20000; + border-bottom: 1px solid #C20000; + color: #C20000; background: #FFFBD3; +} + +dd.spec.not_implemented { + border-left: 5px solid #FAF834; + border-bottom: 1px solid #FAF834; + background: #FCFB98; color: #131313; +} + +dd.spec.pending_fixed { + border-left: 5px solid #0000C2; + border-bottom: 1px solid #0000C2; + color: #0000C2; background: #D3FBFF; +} + +.backtrace { + color: #000; + font-size: 12px; +} + +a { + color: #BE5C00; +} + +/* Ruby code, style similar to vibrant ink */ +.ruby { + font-size: 12px; + font-family: monospace; + color: white; + background-color: black; + padding: 0.1em 0 0.2em 0; +} + +.ruby .keyword { color: #FF6600; } +.ruby .constant { color: #339999; } +.ruby .attribute { color: white; } +.ruby .global { color: white; } +.ruby .module { color: white; } +.ruby .class { color: white; } +.ruby .string { color: #66FF00; } +.ruby .ident { color: white; } +.ruby .method { color: #FFCC00; } +.ruby .number { color: white; } +.ruby .char { color: white; } +.ruby .comment { color: #9933CC; } +.ruby .symbol { color: white; } +.ruby .regex { color: #44B4CC; } +.ruby .punct { color: white; } +.ruby .escape { color: white; } +.ruby .interp { color: white; } +.ruby .expr { color: white; } + +.ruby .offending { background-color: gray; } +.ruby .linenum { + width: 75px; + padding: 0.1em 1em 0.2em 0; + color: #000000; + background-color: #FFFBD3; +} +EOF + end + end + end + end +end diff --git a/vendor/gems/gems/rspec-1.2.9/lib/spec/runner/formatter/nested_text_formatter.rb b/vendor/gems/gems/rspec-1.2.9/lib/spec/runner/formatter/nested_text_formatter.rb new file mode 100755 index 00000000..5caec5a4 --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/lib/spec/runner/formatter/nested_text_formatter.rb @@ -0,0 +1,47 @@ +require 'spec/runner/formatter/base_text_formatter' + +module Spec + module Runner + module Formatter + class NestedTextFormatter < BaseTextFormatter + def initialize(options, where) + super + @last_nested_descriptions = [] + end + + def example_group_started(example_group) + super + + example_group.nested_descriptions.each_with_index do |nested_description, i| + unless nested_description == @last_nested_descriptions[i] + output.puts "#{' ' * i}#{nested_description}" + end + end + + @last_nested_descriptions = example_group.nested_descriptions + end + + def example_failed(example, counter, failure) + output.puts(red("#{current_indentation}#{example.description} (FAILED - #{counter})")) + output.flush + end + + def example_passed(example) + message = "#{current_indentation}#{example.description}" + output.puts green(message) + output.flush + end + + def example_pending(example, message, deprecated_pending_location=nil) + super + output.puts yellow("#{current_indentation}#{example.description} (PENDING: #{message})") + output.flush + end + + def current_indentation + ' ' * @last_nested_descriptions.length + end + end + end + end +end diff --git a/vendor/gems/gems/rspec-1.2.9/lib/spec/runner/formatter/no_op_method_missing.rb b/vendor/gems/gems/rspec-1.2.9/lib/spec/runner/formatter/no_op_method_missing.rb new file mode 100755 index 00000000..350e29f7 --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/lib/spec/runner/formatter/no_op_method_missing.rb @@ -0,0 +1,21 @@ +module Spec + module Runner + module Formatter + module NOOPMethodMissing + def respond_to?(message, include_private = false) + if include_private + true + else + !private_methods.any? {|m| [message.to_s, message.to_sym].include?(m)} + end + end + + private + + def method_missing(sym, *args) + # a no-op + end + end + end + end +end diff --git a/vendor/gems/gems/rspec-1.2.9/lib/spec/runner/formatter/profile_formatter.rb b/vendor/gems/gems/rspec-1.2.9/lib/spec/runner/formatter/profile_formatter.rb new file mode 100755 index 00000000..3784f3ac --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/lib/spec/runner/formatter/profile_formatter.rb @@ -0,0 +1,47 @@ +require 'spec/runner/formatter/progress_bar_formatter' + +module Spec + module Runner + module Formatter + class ProfileFormatter < ProgressBarFormatter + + def initialize(options, where) + super + @example_times = [] + end + + def start(count) + @output.puts "Profiling enabled." + end + + def example_started(example) + @time = Time.now + end + + def example_passed(example) + super + @example_times << [ + example_group.description, + example.description, + Time.now - @time + ] + end + + def start_dump + super + @output.puts "\n\nTop 10 slowest examples:\n" + + @example_times = @example_times.sort_by do |description, example, time| + time + end.reverse + + @example_times[0..9].each do |description, example, time| + @output.print red(sprintf("%.7f", time)) + @output.puts " #{description} #{example}" + end + @output.flush + end + end + end + end +end diff --git a/vendor/gems/gems/rspec-1.2.9/lib/spec/runner/formatter/progress_bar_formatter.rb b/vendor/gems/gems/rspec-1.2.9/lib/spec/runner/formatter/progress_bar_formatter.rb new file mode 100755 index 00000000..862f87a4 --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/lib/spec/runner/formatter/progress_bar_formatter.rb @@ -0,0 +1,33 @@ +require 'spec/runner/formatter/base_text_formatter' +require 'spec/runner/formatter/no_op_method_missing' + +module Spec + module Runner + module Formatter + class ProgressBarFormatter < BaseTextFormatter + include NOOPMethodMissing + + def example_failed(example, counter, failure) + @output.print colorize_failure('F', failure) + @output.flush + end + + def example_passed(example) + @output.print green('.') + @output.flush + end + + def example_pending(example, message, deprecated_pending_location=nil) + super + @output.print yellow('*') + @output.flush + end + + def start_dump + @output.puts + @output.flush + end + end + end + end +end diff --git a/vendor/gems/gems/rspec-1.2.9/lib/spec/runner/formatter/silent_formatter.rb b/vendor/gems/gems/rspec-1.2.9/lib/spec/runner/formatter/silent_formatter.rb new file mode 100755 index 00000000..43cce33b --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/lib/spec/runner/formatter/silent_formatter.rb @@ -0,0 +1,10 @@ +require 'spec/runner/formatter/base_formatter' + +module Spec + module Runner + module Formatter + class SilentFormatter < BaseFormatter + end + end + end +end diff --git a/vendor/gems/gems/rspec-1.2.9/lib/spec/runner/formatter/snippet_extractor.rb b/vendor/gems/gems/rspec-1.2.9/lib/spec/runner/formatter/snippet_extractor.rb new file mode 100755 index 00000000..4f34e5fe --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/lib/spec/runner/formatter/snippet_extractor.rb @@ -0,0 +1,52 @@ +module Spec + module Runner + module Formatter + # This class extracts code snippets by looking at the backtrace of the passed error + class SnippetExtractor #:nodoc: + class NullConverter; def convert(code, pre); code; end; end #:nodoc: + begin; require 'syntax/convertors/html'; @@converter = Syntax::Convertors::HTML.for_syntax "ruby"; rescue LoadError => e; @@converter = NullConverter.new; end + + def snippet(error) + raw_code, line = snippet_for(error.backtrace[0]) + highlighted = @@converter.convert(raw_code, false) + highlighted << "\n# gem install syntax to get syntax highlighting" if @@converter.is_a?(NullConverter) + post_process(highlighted, line) + end + + def snippet_for(error_line) + if error_line =~ /(.*):(\d+)/ + file = $1 + line = $2.to_i + [lines_around(file, line), line] + else + ["# Couldn't get snippet for #{error_line}", 1] + end + end + + def lines_around(file, line) + if File.file?(file) + lines = File.open(file).read.split("\n") + min = [0, line-3].max + max = [line+1, lines.length-1].min + selected_lines = [] + selected_lines.join("\n") + lines[min..max].join("\n") + else + "# Couldn't get snippet for #{file}" + end + end + + def post_process(highlighted, offending_line) + new_lines = [] + highlighted.split("\n").each_with_index do |line, i| + new_line = "#{offending_line+i-2}#{line}" + new_line = "#{new_line}" if i == 2 + new_lines << new_line + end + new_lines.join("\n") + end + + end + end + end +end diff --git a/vendor/gems/gems/rspec-1.2.9/lib/spec/runner/formatter/specdoc_formatter.rb b/vendor/gems/gems/rspec-1.2.9/lib/spec/runner/formatter/specdoc_formatter.rb new file mode 100755 index 00000000..7204f214 --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/lib/spec/runner/formatter/specdoc_formatter.rb @@ -0,0 +1,33 @@ +require 'spec/runner/formatter/base_text_formatter' + +module Spec + module Runner + module Formatter + class SpecdocFormatter < BaseTextFormatter + def example_group_started(example_group) + super + output.puts + output.puts example_group.description + output.flush + end + + def example_failed(example, counter, failure) + output.puts(red("- #{example.description} (FAILED - #{counter})")) + output.flush + end + + def example_passed(example) + message = "- #{example.description}" + output.puts green(message) + output.flush + end + + def example_pending(example, message, deprecated_pending_location=nil) + super + output.puts yellow("- #{example.description} (PENDING: #{message})") + output.flush + end + end + end + end +end diff --git a/vendor/gems/gems/rspec-1.2.9/lib/spec/runner/formatter/text_mate_formatter.rb b/vendor/gems/gems/rspec-1.2.9/lib/spec/runner/formatter/text_mate_formatter.rb new file mode 100755 index 00000000..4c0a9c7d --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/lib/spec/runner/formatter/text_mate_formatter.rb @@ -0,0 +1,16 @@ +require 'spec/runner/formatter/html_formatter' + +module Spec + module Runner + module Formatter + # Formats backtraces so they're clickable by TextMate + class TextMateFormatter < HtmlFormatter + def backtrace_line(line) + line.gsub(/([^:]*\.rb):(\d*)/) do + "#{$1}:#{$2} " + end + end + end + end + end +end diff --git a/vendor/gems/gems/rspec-1.2.9/lib/spec/runner/heckle_runner.rb b/vendor/gems/gems/rspec-1.2.9/lib/spec/runner/heckle_runner.rb new file mode 100755 index 00000000..5c81ea84 --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/lib/spec/runner/heckle_runner.rb @@ -0,0 +1,72 @@ +if Spec::Ruby.version.to_f < 1.9 + begin + require 'rubygems' unless ENV['NO_RUBYGEMS'] + require 'heckle' + rescue LoadError ; raise "You must gem install heckle to use --heckle" ; end + + module Spec + module Runner + # Creates a new Heckler configured to heckle all methods in the classes + # whose name matches +filter+ + class HeckleRunner + def initialize(filter, heckle_class=Heckler) + @filter = filter + @heckle_class = heckle_class + end + + # Runs all the example groups held by +rspec_options+ once for each of the + # methods in the matched classes. + def heckle_with + if @filter =~ /(.*)[#\.](.*)/ + heckle_method($1, $2) + else + heckle_class_or_module(@filter) + end + end + + def heckle_method(class_name, method_name) + verify_constant(class_name) + heckle = @heckle_class.new(class_name, method_name, Spec::Runner.options) + heckle.validate + end + + def heckle_class_or_module(class_or_module_name) + verify_constant(class_or_module_name) + pattern = /^#{class_or_module_name}/ + classes = [] + ObjectSpace.each_object(Class) do |klass| + classes << klass if klass.name =~ pattern + end + + classes.each do |klass| + klass.instance_methods(false).each do |method_name| + heckle = @heckle_class.new(klass.name, method_name, Spec::Runner.options) + heckle.validate + end + end + end + + def verify_constant(name) + begin + # This is defined in Heckle + name.to_class + rescue + raise "Heckling failed - \"#{name}\" is not a known class or module" + end + end + end + + class Heckler < Heckle + def initialize(klass_name, method_name, rspec_options) + super(klass_name, method_name) + @rspec_options = rspec_options + end + + def tests_pass? + @rspec_options.run_examples + end + + end + end + end +end \ No newline at end of file diff --git a/vendor/gems/gems/rspec-1.2.9/lib/spec/runner/heckle_runner_unsupported.rb b/vendor/gems/gems/rspec-1.2.9/lib/spec/runner/heckle_runner_unsupported.rb new file mode 100755 index 00000000..35ff86e1 --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/lib/spec/runner/heckle_runner_unsupported.rb @@ -0,0 +1,10 @@ +module Spec + module Runner + # Dummy implementation for Windows that just fails (Heckle is not supported on Windows) + class HeckleRunner + def initialize(filter) + raise "Heckle is not supported on Windows or Ruby 1.9" + end + end + end +end diff --git a/vendor/gems/gems/rspec-1.2.9/lib/spec/runner/line_number_query.rb b/vendor/gems/gems/rspec-1.2.9/lib/spec/runner/line_number_query.rb new file mode 100755 index 00000000..0a907d3f --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/lib/spec/runner/line_number_query.rb @@ -0,0 +1,78 @@ +module Spec + module Runner + # Parses a spec file and finds the nearest example for a given line number. + class LineNumberQuery + attr_reader :best_match + + def initialize(run_options) + @best_match = {} + @run_options = run_options + end + + def spec_name_for(file, line_number) + best_match.clear + file = File.expand_path(file) + determine_best_match(file, line_number) + if best_match[:example_group] + if best_match[:example] + "#{best_match[:example_group].description} #{best_match[:example].description}" + else + best_match[:example_group].description + end + else + nil + end + end + + def example_line_for(file, line_number) + determine_best_match(file, line_number) + best_match[:line] + end + + protected + + def determine_best_match(file, line_number) + best_match.clear + file = File.expand_path(file) + @run_options.example_groups.each do |example_group| + next unless example_group.location + consider_example_group_for_best_match(example_group, file, line_number) + + example_group.examples.each do |example| + consider_example_for_best_match(example, example_group, file, line_number) + end + end + end + + def consider_example_group_for_best_match(example_group, file, line_number) + example_group_file, example_group_line = parse_location(example_group.location) + if is_best_match?(file, line_number, example_group_file, example_group_line) + best_match.clear + best_match[:example_group] = example_group + best_match[:line] = example_group_line + end + end + + def consider_example_for_best_match(example, example_group, file, line_number) + example_file, example_line = parse_location(example.location) + if is_best_match?(file, line_number, example_file, example_line) + best_match.clear + best_match[:example_group] = example_group + best_match[:example] = example + best_match[:line] = example_line + end + end + + def is_best_match?(file, line_number, example_file, example_line) + file == File.expand_path(example_file) && + example_line <= line_number && + example_line > best_match[:line].to_i + end + + def parse_location(location) + location =~ /(.*)\:(\d*)(\:|$)/ + return $1, Integer($2) + end + end + end +end diff --git a/vendor/gems/gems/rspec-1.2.9/lib/spec/runner/option_parser.rb b/vendor/gems/gems/rspec-1.2.9/lib/spec/runner/option_parser.rb new file mode 100755 index 00000000..fbbf444a --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/lib/spec/runner/option_parser.rb @@ -0,0 +1,223 @@ +require 'optparse' +require 'stringio' + +module Spec + module Runner + class OptionParser < ::OptionParser + class << self + def parse(args, err, out) + parser = new(err, out) + parser.parse(args) + parser.options + end + + def spec_command? + $0.split('/').last == 'spec' + end + end + + attr_reader :options + + OPTIONS = { + :pattern => ["-p", "--pattern [PATTERN]","Limit files loaded to those matching this pattern. Defaults to '**/*_spec.rb'", + "Separate multiple patterns with commas.", + "Applies only to directories named on the command line (files", + "named explicitly on the command line will be loaded regardless)."], + :diff => ["-D", "--diff [FORMAT]","Show diff of objects that are expected to be equal when they are not", + "Builtin formats: unified|u|context|c", + "You can also specify a custom differ class", + "(in which case you should also specify --require)"], + :colour => ["-c", "--colour", "--color", "Show coloured (red/green) output"], + :example => ["-e", "--example [NAME|FILE_NAME]", "Execute example(s) with matching name(s). If the argument is", + "the path to an existing file (typically generated by a previous", + "run using --format failing_examples:file.txt), then the examples", + "on each line of that file will be executed. If the file is empty,", + "all examples will be run (as if --example was not specified).", + " ", + "If the argument is not an existing file, then it is treated as", + "an example name directly, causing RSpec to run just the example", + "matching that name"], + :specification => ["-s", "--specification [NAME]", "DEPRECATED - use -e instead", "(This will be removed when autotest works with -e)"], + :line => ["-l", "--line LINE_NUMBER", Integer, "Execute example group or example at given line.", + "(does not work for dynamically generated examples)"], + :format => ["-f", "--format FORMAT[:WHERE]","Specifies what format to use for output. Specify WHERE to tell", + "the formatter where to write the output. All built-in formats", + "expect WHERE to be a file name, and will write to $stdout if it's", + "not specified. The --format option may be specified several times", + "if you want several outputs", + " ", + "Builtin formats:", + "silent|l : No output", "progress|p : Text-based progress bar", + "profile|o : Text-based progress bar with profiling of 10 slowest examples", + "specdoc|s : Code example doc strings", + "nested|n : Code example doc strings with nested groups indented", + "html|h : A nice HTML report", + "failing_examples|e : Write all failing examples - input for --example", + "failing_example_groups|g : Write all failing example groups - input for --example", + " ", + "FORMAT can also be the name of a custom formatter class", + "(in which case you should also specify --require to load it)"], + :require => ["-r", "--require FILE", "Require FILE before running specs", + "Useful for loading custom formatters or other extensions.", + "If this option is used it must come before the others"], + :backtrace => ["-b", "--backtrace", "Output full backtrace"], + :loadby => ["-L", "--loadby STRATEGY", "Specify the strategy by which spec files should be loaded.", + "STRATEGY can currently only be 'mtime' (File modification time)", + "By default, spec files are loaded in alphabetical order if --loadby", + "is not specified."], + :reverse => ["-R", "--reverse", "Run examples in reverse order"], + :timeout => ["-t", "--timeout FLOAT", "Interrupt and fail each example that doesn't complete in the", + "specified time"], + :heckle => ["-H", "--heckle CODE", "If all examples pass, this will mutate the classes and methods", + "identified by CODE little by little and run all the examples again", + "for each mutation. The intent is that for each mutation, at least", + "one example *should* fail, and RSpec will tell you if this is not the", + "case. CODE should be either Some::Module, Some::Class or", + "Some::Fabulous#method}"], + :dry_run => ["-d", "--dry-run", "Invokes formatters without executing the examples."], + :options_file => ["-O", "--options PATH", "Read options from a file"], + :generate_options => ["-G", "--generate-options PATH", "Generate an options file for --options"], + :runner => ["-U", "--runner RUNNER", "Use a custom Runner."], + :debug => ["-u", "--debugger", "Enable ruby-debugging."], + :drb => ["-X", "--drb", "Run examples via DRb. (For example against script/spec_server)"], + :version => ["-v", "--version", "Show version"], + :help => ["-h", "--help", "You're looking at it"] + } + + def initialize(err, out) + super() + @error_stream = err + @out_stream = out + @options = Options.new(@error_stream, @out_stream) + + @file_factory = File + + self.banner = "Usage: spec (FILE(:LINE)?|DIRECTORY|GLOB)+ [options]" + self.separator "" + on(*OPTIONS[:pattern]) {|pattern| @options.filename_pattern = pattern} + on(*OPTIONS[:diff]) {|diff| @options.parse_diff(diff)} + on(*OPTIONS[:colour]) {@options.colour = true} + on(*OPTIONS[:example]) {|example| @options.parse_example(example)} + on(*OPTIONS[:specification]) {|example| @options.parse_example(example)} + on(*OPTIONS[:line]) {|line_number| @options.line_number = line_number.to_i} + on(*OPTIONS[:format]) {|format| @options.parse_format(format)} + on(*OPTIONS[:require]) {|requires| invoke_requires(requires)} + on(*OPTIONS[:backtrace]) {@options.backtrace_tweaker = NoisyBacktraceTweaker.new} + on(*OPTIONS[:loadby]) {|loadby| @options.loadby = loadby} + on(*OPTIONS[:reverse]) {@options.reverse = true} + on(*OPTIONS[:timeout]) {|timeout| @options.timeout = timeout.to_f} + on(*OPTIONS[:heckle]) {|heckle| @options.load_heckle_runner(heckle)} + on(*OPTIONS[:dry_run]) {@options.dry_run = true} + on(*OPTIONS[:options_file]) {|options_file|} + on(*OPTIONS[:generate_options]) {|options_file|} + on(*OPTIONS[:runner]) {|runner| @options.user_input_for_runner = runner} + on(*OPTIONS[:debug]) {@options.debug = true} + on(*OPTIONS[:drb]) {} + on(*OPTIONS[:version]) {parse_version} + on("--autospec") {@options.autospec = true} + on_tail(*OPTIONS[:help]) {parse_help} + end + + def order!(argv, &blk) + @argv = argv.dup + @argv = (@argv.empty? & self.class.spec_command?) ? ['--help'] : @argv + + # Parse options file first + parse_file_options(:options_file, :parse_options_file) + + @options.argv = @argv.dup + return if parse_file_options(:generate_options, :write_options_file) + return if parse_drb + + super(@argv) do |file| + if file =~ /^(.+):(\d+)$/ + file = $1 + @options.line_number = $2.to_i + end + + @options.files << file + blk.call(file) if blk + end + + @options + end + + protected + + def invoke_requires(requires) + requires.split(",").each do |file| + require file + end + end + + def parse_file_options(option_name, action) + # Remove the file option and the argument before handling the file + options_file = nil + options_list = OPTIONS[option_name][0..1] + options_list[1].gsub!(" PATH", "") + options_list.each do |option| + if index = @argv.index(option) + @argv.delete_at(index) + options_file = @argv.delete_at(index) + end + end + + if options_file.nil? && + File.exist?('spec/spec.opts') && + !@argv.any?{|a| a =~ /^\-/ } + options_file = 'spec/spec.opts' + end + + if options_file + send(action, options_file) + return true + else + return false + end + end + + def parse_options_file(options_file) + option_file_args = File.readlines(options_file).map {|l| l.chomp.split " "}.flatten + @argv.push(*option_file_args) + end + + def write_options_file(options_file) + File.open(options_file, 'w') do |io| + io.puts @argv.join("\n") + end + @out_stream.puts "\nOptions written to #{options_file}. You can now use these options with:" + @out_stream.puts "spec --options #{options_file}" + @options.examples_should_not_be_run + end + + def parse_drb + argv = @options.argv + is_drb = false + is_drb ||= argv.delete(OPTIONS[:drb][0]) + is_drb ||= argv.delete(OPTIONS[:drb][1]) + return false unless is_drb + if DrbCommandLine.run(self.class.parse(argv, @error_stream, @out_stream)) + @options.examples_should_not_be_run + true + else + @error_stream.puts "Running specs locally:" + false + end + end + + def parse_version + @out_stream.puts ::Spec::VERSION::SUMMARY + exit if stdout? + end + + def parse_help + @out_stream.puts self + exit if stdout? + end + + def stdout? + @out_stream == $stdout + end + end + end +end diff --git a/vendor/gems/gems/rspec-1.2.9/lib/spec/runner/options.rb b/vendor/gems/gems/rspec-1.2.9/lib/spec/runner/options.rb new file mode 100755 index 00000000..e0179e80 --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/lib/spec/runner/options.rb @@ -0,0 +1,400 @@ +require 'ostruct' + +module Spec + module Runner + class Options + FILE_SORTERS = { + 'mtime' => lambda {|file_a, file_b| File.mtime(file_b) <=> File.mtime(file_a)} + } + + EXAMPLE_FORMATTERS = { # Load these lazily for better speed + 'silent' => ['spec/runner/formatter/silent_formatter', 'Formatter::SilentFormatter'], + 'l' => ['spec/runner/formatter/silent_formatter', 'Formatter::SilentFormatter'], + 'specdoc' => ['spec/runner/formatter/specdoc_formatter', 'Formatter::SpecdocFormatter'], + 's' => ['spec/runner/formatter/specdoc_formatter', 'Formatter::SpecdocFormatter'], + 'nested' => ['spec/runner/formatter/nested_text_formatter', 'Formatter::NestedTextFormatter'], + 'n' => ['spec/runner/formatter/nested_text_formatter', 'Formatter::NestedTextFormatter'], + 'html' => ['spec/runner/formatter/html_formatter', 'Formatter::HtmlFormatter'], + 'h' => ['spec/runner/formatter/html_formatter', 'Formatter::HtmlFormatter'], + 'progress' => ['spec/runner/formatter/progress_bar_formatter', 'Formatter::ProgressBarFormatter'], + 'p' => ['spec/runner/formatter/progress_bar_formatter', 'Formatter::ProgressBarFormatter'], + 'failing_examples' => ['spec/runner/formatter/failing_examples_formatter', 'Formatter::FailingExamplesFormatter'], + 'e' => ['spec/runner/formatter/failing_examples_formatter', 'Formatter::FailingExamplesFormatter'], +'failing_example_groups' => ['spec/runner/formatter/failing_example_groups_formatter', 'Formatter::FailingExampleGroupsFormatter'], + 'g' => ['spec/runner/formatter/failing_example_groups_formatter', 'Formatter::FailingExampleGroupsFormatter'], + 'profile' => ['spec/runner/formatter/profile_formatter', 'Formatter::ProfileFormatter'], + 'o' => ['spec/runner/formatter/profile_formatter', 'Formatter::ProfileFormatter'], + 'textmate' => ['spec/runner/formatter/text_mate_formatter', 'Formatter::TextMateFormatter'] + } + + attr_accessor( + :autospec, # hack to tell + :filename_pattern, + :backtrace_tweaker, + :context_lines, + :diff_format, + :dry_run, + :profile, + :heckle_runner, + :debug, + :line_number, + :loadby, + :reporter, + :reverse, + :timeout, + :verbose, + :user_input_for_runner, + :error_stream, + :output_stream, + # TODO: BT - Figure out a better name + :argv + ) + attr_reader :colour, :differ_class, :files, :examples, :example_groups + + def initialize(error_stream, output_stream) + @error_stream = error_stream + @output_stream = output_stream + @filename_pattern = "**/*_spec.rb" + @backtrace_tweaker = QuietBacktraceTweaker.new + @examples = [] + @colour = false + @profile = false + @dry_run = false + @debug = false + @reporter = Reporter.new(self) + @context_lines = 3 + @diff_format = :unified + @files = [] + @example_groups = [] + @result = nil + @examples_run = false + @examples_should_be_run = nil + @user_input_for_runner = nil + @after_suite_parts = [] + @files_loaded = false + @out_used = nil + end + + def add_example_group(example_group) + @example_groups << example_group + end + + def line_number_requested? + !!line_number + end + + def example_line + Spec::Runner::LineNumberQuery.new(self).example_line_for(files.first, line_number) + end + + def remove_example_group(example_group) + @example_groups.delete(example_group) + end + + def require_ruby_debug + require 'rubygems' unless ENV['NO_RUBYGEMS'] + require 'ruby-debug' + end + + def project_root # :nodoc: + require 'pathname' + @project_root ||= determine_project_root + end + + def determine_project_root # :nodoc: + # This is borrowed (slightly modified) from Scott Taylors + # project_path project: + # http://github.com/smtlaissezfaire/project_path + Pathname(File.expand_path('.')).ascend do |path| + if File.exists?(File.join(path, "spec")) + return path + end + end + end + + def add_dir_from_project_root_to_load_path(dir, load_path=$LOAD_PATH) # :nodoc: + return if project_root.nil? + full_dir = File.join(project_root, dir) + load_path.unshift full_dir unless load_path.include?(full_dir) + end + + def run_examples + require_ruby_debug if debug + return true unless examples_should_be_run? + success = true + begin + runner = custom_runner || ExampleGroupRunner.new(self) + + unless @files_loaded + ['spec','lib'].each do |dir| + add_dir_from_project_root_to_load_path(dir) + end + runner.load_files(files_to_load) + @files_loaded = true + end + + define_predicate_matchers + plugin_mock_framework + ignore_backtrace_patterns + + # TODO - this has to happen after the files get loaded, + # otherwise the before_suite_parts are not populated + # from the configuration. There is no spec for this + # directly, but features/before_and_after_blocks/before_and_after_blocks.story + # will fail if this happens before the files are loaded. + before_suite_parts.each { |part| part.call } + + if example_groups.empty? + true + else + set_spec_from_line_number if line_number + success = runner.run + @examples_run = true + heckle if heckle_runner + success + end + ensure + after_suite_parts.each do |part| + part.arity < 1 ? part.call : part.call(success) + end + end + end + + def before_suite_parts + Spec::Example::BeforeAndAfterHooks.before_suite_parts + end + + def after_suite_parts + Spec::Example::BeforeAndAfterHooks.after_suite_parts + end + + def examples_run? + @examples_run + end + + def examples_should_not_be_run + @examples_should_be_run = false + end + + def mock_framework + # TODO - don't like this dependency - perhaps store this in here instead? + Spec::Runner.configuration.mock_framework + end + + def colour=(colour) + @colour = colour + if @colour && RUBY_PLATFORM =~ /mswin|mingw/ ;\ + begin ;\ + replace_output = @output_stream.equal?($stdout) ;\ + require 'rubygems' unless ENV['NO_RUBYGEMS'] ;\ + require 'Win32/Console/ANSI' ;\ + @output_stream = $stdout if replace_output ;\ + rescue LoadError ;\ + warn "You must 'gem install win32console' to use colour on Windows" ;\ + @colour = false ;\ + end + end + end + + def parse_diff(format) + case format + when :context, 'context', 'c' + @diff_format = :context + default_differ + when :unified, 'unified', 'u', '', nil + @diff_format = :unified + default_differ + else + @diff_format = :custom + self.differ_class = load_class(format, 'differ', '--diff') + end + end + + def parse_example(example) + if(File.file?(example)) + @examples = [File.open(example).read.split("\n")].flatten + else + @examples = [example] + end + end + + def parse_format(format_arg) + format, where = ClassAndArgumentsParser.parse(format_arg) + unless where + raise "When using several --format options only one of them can be without a file" if @out_used + where = @output_stream + @out_used = true + end + @format_options ||= [] + @format_options << [format, where] + end + + def formatters + @format_options ||= [['progress', @output_stream]] + @formatters ||= load_formatters(@format_options, EXAMPLE_FORMATTERS) + end + + def load_formatters(format_options, formatters) + format_options.map do |format, where| + formatter_type = if formatters[format] + require formatters[format][0] + eval(formatters[format][1], binding, __FILE__, __LINE__) + else + load_class(format, 'formatter', '--format') + end + formatter_type.new(formatter_options, where) + end + end + + def formatter_options + @formatter_options ||= OpenStruct.new( + :colour => colour, + :autospec => autospec, + :dry_run => dry_run + ) + end + + def which_heckle_runner + ([/mswin/, /java/].detect{|p| p =~ RUBY_PLATFORM} || Spec::Ruby.version.to_f == 1.9) ? "spec/runner/heckle_runner_unsupported" : "spec/runner/heckle_runner" + end + + def load_heckle_runner(heckle) + @format_options ||= [['silent', @output_stream]] + require which_heckle_runner + @heckle_runner = ::Spec::Runner::HeckleRunner.new(heckle) + end + + def number_of_examples + return examples.size unless examples.empty? + @example_groups.inject(0) {|sum, group| sum + group.number_of_examples} + end + + def files_to_load + result = [] + sorted_files.each do |file| + if File.directory?(file) + filename_pattern.split(",").each do |pattern| + result += Dir[File.expand_path("#{file}/#{pattern.strip}")] + end + elsif File.file?(file) + result << file + else + raise "File or directory not found: #{file}" + end + end + result + end + + def dry_run? + @dry_run == true + end + + protected + + def define_predicate_matchers + Spec::Runner.configuration.predicate_matchers.each_pair do |matcher_method, method_on_object| + Spec::Example::ExampleMethods::__send__ :define_method, matcher_method do |*args| + eval("be_#{method_on_object.to_s.gsub('?','')}(*args)") + end + end + end + + def plugin_mock_framework + case mock_framework + when Module + Spec::Example::ExampleMethods.__send__ :include, mock_framework + else + require mock_framework + Spec::Example::ExampleMethods.__send__ :include, Spec::Adapters::MockFramework + end + end + + def ignore_backtrace_patterns + @backtrace_tweaker.ignore_patterns Spec::Runner.configuration.ignored_backtrace_patterns + end + + def examples_should_be_run? + return @examples_should_be_run unless @examples_should_be_run.nil? + @examples_should_be_run = true + end + + def differ_class=(klass) + return unless klass + @differ_class = klass + Spec::Expectations.differ = self.differ_class.new(self) + end + + def load_class(name, kind, option) + if name =~ /\A(?:::)?([A-Z]\w*(?:::[A-Z]\w*)*)\z/ + arg = $2 == "" ? nil : $2 + [$1, arg] + else + m = "#{name.inspect} is not a valid class name" + @error_stream.puts m + raise m + end + begin + eval(name, binding, __FILE__, __LINE__) + rescue NameError => e + @error_stream.puts "Couldn't find #{kind} class #{name}" + @error_stream.puts "Make sure the --require option is specified *before* #{option}" + if $_spec_spec ; raise e ; else exit(1) ; end + end + end + + def custom_runner + return nil unless custom_runner? + klass_name, arg = ClassAndArgumentsParser.parse(user_input_for_runner) + runner_type = load_class(klass_name, 'example group runner', '--runner') + return runner_type.new(self, arg) + end + + def custom_runner? + return user_input_for_runner ? true : false + end + + def heckle + heckle_runner = self.heckle_runner + self.heckle_runner = nil + heckle_runner.heckle_with + end + + def sorted_files + return sorter ? files.sort(&sorter) : files + end + + def sorter + FILE_SORTERS[loadby] + end + + def default_differ + require 'spec/runner/differs/default' + self.differ_class = ::Spec::Expectations::Differs::Default + end + + def set_spec_from_line_number + if examples.empty? + if files.length == 1 + if File.directory?(files[0]) + error_stream.puts "You must specify one file, not a directory when providing a line number" + exit(1) if stderr? + else + example = LineNumberQuery.new(self).spec_name_for(files[0], line_number) + @examples = [example] + end + else + error_stream.puts "Only one file can be specified when providing a line number: #{files.inspect}" + exit(3) if stderr? + end + else + error_stream.puts "You cannot use --example and specify a line number" + exit(4) if stderr? + end + end + + def stderr? + @error_stream == $stderr + end + end + end +end diff --git a/vendor/gems/gems/rspec-1.2.9/lib/spec/runner/reporter.rb b/vendor/gems/gems/rspec-1.2.9/lib/spec/runner/reporter.rb new file mode 100755 index 00000000..0fae7d13 --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/lib/spec/runner/reporter.rb @@ -0,0 +1,171 @@ +module Spec + module Runner + class Reporter + attr_reader :options + + def initialize(options) + @options = options + @options.reporter = self + @failures = [] + @pending_count = 0 + @example_count = 0 + @start_time = nil + @end_time = nil + end + + def example_group_started(example_group) + @example_group = example_group + formatters.each do |f| + f.example_group_started(example_group) + end + end + + def example_started(example) + formatters.each{|f| f.example_started(example)} + end + + def example_finished(example, error=nil) + @example_count += 1 + + if error.nil? + example_passed(example) + elsif Spec::Example::ExamplePendingError === error + example_pending(example, example.location, error.message) + else + example_failed(example, error) + end + end + + def example_failed(example, error) + backtrace_tweaker.tweak_backtrace(error) + failure = Failure.new(@example_group.description, example.description, error) + @failures << failure + formatters.each do |f| + f.example_failed(example, @failures.length, failure) + end + end + + def start(number_of_examples) + @start_time = Time.new + formatters.each{|f| f.start(number_of_examples)} + end + + def end + @end_time = Time.new + end + + # Dumps the summary and returns the total number of failures + def dump + formatters.each{|f| f.start_dump} + dump_pending + dump_failures + formatters.each do |f| + f.dump_summary(duration, @example_count, @failures.length, @pending_count) + f.close + end + @failures.length + end + + class Failure + def initialize(group_description, example_description, exception) # :nodoc: + @example_name = "#{group_description} #{example_description}" + @exception = exception + end + + # The Exception object raised + attr_reader :exception + + # Header messsage for reporting this failure, including the name of the + # example and an indicator of the type of failure. FAILED indicates a + # failed expectation. FIXED indicates a pending example that passes, and + # no longer needs to be pending. RuntimeError indicates that a + # RuntimeError occured. + # + # == Examples + # + # 'A new account should have a zero balance' FAILED + # 'A new account should have a zero balance' FIXED + # RuntimeError in 'A new account should have a zero balance' + def header + if expectation_not_met? + "'#{@example_name}' FAILED" + elsif pending_fixed? + "'#{@example_name}' FIXED" + else + "#{@exception.class.name} in '#{@example_name}'" + end + end + + def pending_fixed? # :nodoc: + @exception.is_a?(Spec::Example::PendingExampleFixedError) + end + + def expectation_not_met? # :nodoc: + @exception.is_a?(Spec::Expectations::ExpectationNotMetError) + end + end + + private + + def formatters + @options.formatters + end + + def backtrace_tweaker + @options.backtrace_tweaker + end + + def dump_failures + return if @failures.empty? + @failures.inject(1) do |index, failure| + formatters.each{|f| f.dump_failure(index, failure)} + index + 1 + end + end + + def dump_pending + formatters.each{|f| f.dump_pending} + end + + def duration + return @end_time - @start_time unless (@end_time.nil? or @start_time.nil?) + return "0.0" + end + + def example_passed(example) + formatters.each{|f| f.example_passed(example)} + end + + EXAMPLE_PENDING_DEPRECATION_WARNING = <<-WARNING + +********************************************************************* +DEPRECATION WARNING: RSpec's formatters have changed example_pending +to accept two arguments instead of three. Please see the rdoc +for Spec::Runner::Formatter::BaseFormatter#example_pending +for more information. + +Please update any custom formatters to accept only two arguments +to example_pending. Support for example_pending with two arguments +and this warning message will be removed after the RSpec 2.0 release. +********************************************************************* +WARNING + + def example_pending(example, ignore, message="Not Yet Implemented") + @pending_count += 1 + formatters.each do |formatter| + if formatter_uses_deprecated_example_pending_method?(formatter) + Spec.warn EXAMPLE_PENDING_DEPRECATION_WARNING + formatter.example_pending(example, message, example.location) + else + formatter.example_pending(example, message) + end + end + end + + def formatter_uses_deprecated_example_pending_method?(formatter) + formatter.method(:example_pending).arity == 3 + end + + end + end +end diff --git a/vendor/gems/gems/rspec-1.2.9/lib/spec/stubs/cucumber.rb b/vendor/gems/gems/rspec-1.2.9/lib/spec/stubs/cucumber.rb new file mode 100755 index 00000000..b801ef44 --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/lib/spec/stubs/cucumber.rb @@ -0,0 +1,5 @@ +# This plugs RSpec's mocking/stubbing framework into cucumber +require 'spec/mocks' +Before {$rspec_stubs ||= Spec::Mocks::Space.new} +After {$rspec_stubs.reset_all} +World(Spec::Mocks::ExampleMethods) diff --git a/vendor/gems/gems/rspec-1.2.9/lib/spec/test/unit.rb b/vendor/gems/gems/rspec-1.2.9/lib/spec/test/unit.rb new file mode 100755 index 00000000..fb4eb493 --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/lib/spec/test/unit.rb @@ -0,0 +1,10 @@ +require 'spec/interop/test' + +# Hack to stop active_support/dependencies from complaining about +# 'spec/test/unit' not defining Spec::Test::Unit +module Spec + module Test + module Unit + end + end +end diff --git a/vendor/gems/gems/rspec-1.2.9/lib/spec/version.rb b/vendor/gems/gems/rspec-1.2.9/lib/spec/version.rb new file mode 100755 index 00000000..b1088cd6 --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/lib/spec/version.rb @@ -0,0 +1,14 @@ +module Spec # :nodoc: + module VERSION # :nodoc: + unless defined? MAJOR + MAJOR = 1 + MINOR = 2 + TINY = 9 + PRE = nil + + STRING = [MAJOR, MINOR, TINY, PRE].compact.join('.') + + SUMMARY = "rspec #{STRING}" + end + end +end diff --git a/vendor/gems/gems/rspec-1.2.9/resources/helpers/cmdline.rb b/vendor/gems/gems/rspec-1.2.9/resources/helpers/cmdline.rb new file mode 100755 index 00000000..0e337579 --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/resources/helpers/cmdline.rb @@ -0,0 +1,8 @@ +require 'spec' + +# Uncommenting next line will break the output feature (no output!!) +# rspec_options +options = Spec::Runner::OptionParser.parse( + ARGV, $stderr, $stdout +) +Spec::Runner::CommandLine.run(options) diff --git a/vendor/gems/gems/rspec-1.2.9/resources/rake/examples.rake b/vendor/gems/gems/rspec-1.2.9/resources/rake/examples.rake new file mode 100755 index 00000000..32d0ad0e --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/resources/rake/examples.rake @@ -0,0 +1,7 @@ +require 'rake' +require 'spec/rake/spectask' + +desc "Run all examples" +Spec::Rake::SpecTask.new('examples') do |t| + t.spec_files = FileList['examples/**/*.rb'] +end diff --git a/vendor/gems/gems/rspec-1.2.9/resources/rake/examples_with_rcov.rake b/vendor/gems/gems/rspec-1.2.9/resources/rake/examples_with_rcov.rake new file mode 100755 index 00000000..4bf35c6b --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/resources/rake/examples_with_rcov.rake @@ -0,0 +1,9 @@ +require 'rake' +require 'spec/rake/spectask' + +desc "Run all examples with RCov" +Spec::Rake::SpecTask.new('examples_with_rcov') do |t| + t.spec_files = FileList['examples/**/*.rb'] + t.rcov = true + t.rcov_opts = ['--exclude', 'examples'] +end \ No newline at end of file diff --git a/vendor/gems/gems/rspec-1.2.9/resources/rake/failing_examples_with_html.rake b/vendor/gems/gems/rspec-1.2.9/resources/rake/failing_examples_with_html.rake new file mode 100755 index 00000000..6e53551f --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/resources/rake/failing_examples_with_html.rake @@ -0,0 +1,9 @@ +require 'rake' +require 'spec/rake/spectask' + +desc "Generate HTML report for failing examples" +Spec::Rake::SpecTask.new('failing_examples_with_html') do |t| + t.spec_files = FileList['failing_examples/**/*.rb'] + t.spec_opts = ["--format", "html:doc/reports/tools/failing_examples.html", "--diff"] + t.fail_on_error = false +end \ No newline at end of file diff --git a/vendor/gems/gems/rspec-1.2.9/resources/rake/verify_rcov.rake b/vendor/gems/gems/rspec-1.2.9/resources/rake/verify_rcov.rake new file mode 100755 index 00000000..a2fab00b --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/resources/rake/verify_rcov.rake @@ -0,0 +1,7 @@ +require 'rake' +require 'spec/rake/verify_rcov' + +RCov::VerifyTask.new(:verify_rcov => 'spec:rcov') do |t| + t.threshold = 100.0 + t.index_html = 'coverage/index.html' +end diff --git a/vendor/gems/gems/rspec-1.2.9/spec/README.jruby b/vendor/gems/gems/rspec-1.2.9/spec/README.jruby new file mode 100755 index 00000000..7eddb567 --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/spec/README.jruby @@ -0,0 +1,15 @@ += Running specs on JRuby = + +svn co http://svn.codehaus.org/jruby/trunk jruby +cd jruby/jruby +ant clean +ant +# put JRuby's bin dir on your PATH +jruby -S gem install rake --no-ri --no-rdoc +jruby -S gem install diff-lcs +jruby -S gem install syntax +cd ../testsuites/rspec +mkdir target +jruby -S rake checkout_code +cd target/rspec +jruby bin/spec spec -c diff --git a/vendor/gems/gems/rspec-1.2.9/spec/autotest/autotest_helper.rb b/vendor/gems/gems/rspec-1.2.9/spec/autotest/autotest_helper.rb new file mode 100755 index 00000000..b7b873d9 --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/spec/autotest/autotest_helper.rb @@ -0,0 +1,8 @@ +require 'spec_helper' +begin + require 'autotest' +rescue LoadError + raise "You must install ZenTest to use autotest" +end +require 'autotest/rspec' +require 'spec/autotest/autotest_matchers' diff --git a/vendor/gems/gems/rspec-1.2.9/spec/autotest/autotest_matchers.rb b/vendor/gems/gems/rspec-1.2.9/spec/autotest/autotest_matchers.rb new file mode 100755 index 00000000..2bfca4ac --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/spec/autotest/autotest_matchers.rb @@ -0,0 +1,38 @@ +module Spec + module Matchers + class AutotestMappingMatcher + def initialize(specs) + @specs = specs + end + + def to(file) + @file = file + self + end + + def matches?(autotest) + @autotest = prepare(autotest) + @actual = autotest.test_files_for(@file) + @actual == @specs + end + + def failure_message + "expected #{@autotest.class} to map #{@specs.inspect} to #{@file.inspect}\ngot #{@actual.inspect}" + end + + private + + def prepare(autotest) + find_order = @specs.dup << @file + autotest.instance_eval { @find_order = find_order } + autotest + end + + end + + def map_specs(specs) + AutotestMappingMatcher.new(specs) + end + + end +end \ No newline at end of file diff --git a/vendor/gems/gems/rspec-1.2.9/spec/autotest/discover_spec.rb b/vendor/gems/gems/rspec-1.2.9/spec/autotest/discover_spec.rb new file mode 100755 index 00000000..fc8d483a --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/spec/autotest/discover_spec.rb @@ -0,0 +1,8 @@ +require 'spec/autotest/autotest_helper' + +describe Autotest::Rspec, "discovery" do + it "adds the rspec autotest plugin" do + Autotest.should_receive(:add_discovery) + load File.expand_path(File.dirname(__FILE__) + "/../../lib/autotest/discover.rb") + end +end diff --git a/vendor/gems/gems/rspec-1.2.9/spec/autotest/failed_results_re_spec.rb b/vendor/gems/gems/rspec-1.2.9/spec/autotest/failed_results_re_spec.rb new file mode 100755 index 00000000..f4a1488e --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/spec/autotest/failed_results_re_spec.rb @@ -0,0 +1,31 @@ +require 'spec/autotest/autotest_helper' + +describe "failed_results_re" do + it "should match a failure" do + re = Autotest::Rspec.new.failed_results_re + re =~ "1)\n'this example' FAILED\nreason\n/path.rb:37:\n\n" + $1.should == "this example" + $2.should == "reason\n/path.rb:37:" + end + + it "should match a failure when matcher outputs multiple lines" do + re = Autotest::Rspec.new.failed_results_re + re =~ "1)\n'other example' FAILED\n\nreason line 1\nreason line 2\n\n(additional info)\n/path.rb:37:\n\n" + $1.should == "other example" + $2.should == "reason line 1\nreason line 2\n\n(additional info)\n/path.rb:37:" + end + + it "should match an Error" do + re = Autotest::Rspec.new.failed_results_re + re =~ "1)\nRuntimeError in 'this example'\nreason\n/path.rb:37:\n\n" + $1.should == "this example" + $2.should == "reason\n/path.rb:37:" + end + + it "should match an Error that doesn't end in Error" do + re = Autotest::Rspec.new.failed_results_re + re =~ "1)\nInvalidArgument in 'this example'\nreason\n/path.rb:37:\n\n" + $1.should == "this example" + $2.should == "reason\n/path.rb:37:" + end +end \ No newline at end of file diff --git a/vendor/gems/gems/rspec-1.2.9/spec/autotest/rspec_spec.rb b/vendor/gems/gems/rspec-1.2.9/spec/autotest/rspec_spec.rb new file mode 100755 index 00000000..6dea29dd --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/spec/autotest/rspec_spec.rb @@ -0,0 +1,111 @@ +require 'spec/autotest/autotest_helper' + +describe Autotest::Rspec do + describe "adding spec.opts --options" do + before(:each) do + @rspec_autotest = Autotest::Rspec.new + end + + it "should return the command line option to add spec.opts if the options file exists" do + File.stub!(:exist?).and_return true + @rspec_autotest.add_options_if_present.should == "-O spec/spec.opts " + end + + it "should return an empty string if no spec.opts exists" do + File.stub!(:exist?).and_return false + Autotest::Rspec.new.add_options_if_present.should == "" + end + end + + describe "commands" do + before(:each) do + @rspec_autotest = Autotest::Rspec.new + @rspec_autotest.stub!(:ruby).and_return "ruby" + @rspec_autotest.stub!(:add_options_if_present).and_return "-O spec/spec.opts" + + @ruby = @rspec_autotest.ruby + @spec_cmd = File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'bin', 'spec')) + @options = @rspec_autotest.add_options_if_present + @files_to_test = { + :spec => ["file_one", "file_two"] + } + # this is not the inner representation of Autotest! + @rspec_autotest.stub!(:files_to_test).and_return @files_to_test + @files_to_test.stub!(:keys).and_return @files_to_test[:spec] + @to_test = @files_to_test.keys.flatten.join ' ' + end + + it "should make the appropriate test command" do + @rspec_autotest.make_test_cmd(@files_to_test).should == "#{@ruby} #{@spec_cmd} --autospec #{@to_test} #{@options}" + end + + it "should return a blank command for no files" do + @rspec_autotest.make_test_cmd({}).should == '' + end + end + + describe "mappings" do + + before(:each) do + @lib_file = "lib/something.rb" + @spec_file = "spec/something_spec.rb" + @rspec_autotest = Autotest::Rspec.new + @rspec_autotest.hook :initialize + end + + it "should find the spec file for a given lib file" do + @rspec_autotest.should map_specs([@spec_file]).to(@lib_file) + end + + it "should find the spec file if given a spec file" do + @rspec_autotest.should map_specs([@spec_file]).to(@spec_file) + end + + it "should ignore files in spec dir that aren't specs" do + @rspec_autotest.should map_specs([]).to("spec/spec_helper.rb") + end + + it "should ignore untracked files (in @file)" do + @rspec_autotest.should map_specs([]).to("lib/untracked_file") + end + end + + describe "consolidating failures" do + before(:each) do + @rspec_autotest = Autotest::Rspec.new + + @spec_file = "spec/autotest/some_spec.rb" + @rspec_autotest.instance_variable_set("@files", {@spec_file => Time.now}) + @rspec_autotest.stub!(:find_files_to_test).and_return true + end + + it "should return no failures if no failures were given in the output" do + @rspec_autotest.consolidate_failures([[]]).should == {} + end + + it "should return a hash with the spec filename => spec name for each failure or error" do + @rspec_autotest.stub!(:test_files_for).and_return "spec/autotest/some_spec.rb" + failures = [ + [ + "false should be false", + "expected: true,\n got: false (using ==)\n#{@spec_file}:203:" + ] + ] + @rspec_autotest.consolidate_failures(failures).should == { + @spec_file => ["false should be false"] + } + end + + it "should not include the subject file" do + subject_file = "lib/autotest/some.rb" + @rspec_autotest.stub!(:test_files_for).and_return "spec/autotest/some_spec.rb" + failures = [ + [ + "false should be false", + "expected: true,\n got: false (using ==)\n#{subject_file}:143:\n#{@spec_file}:203:" + ] + ] + @rspec_autotest.consolidate_failures(failures).keys.should_not include(subject_file) + end + end +end diff --git a/vendor/gems/gems/rspec-1.2.9/spec/ruby_forker.rb b/vendor/gems/gems/rspec-1.2.9/spec/ruby_forker.rb new file mode 100755 index 00000000..6ab03875 --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/spec/ruby_forker.rb @@ -0,0 +1,13 @@ +require 'rbconfig' + +module RubyForker + # Forks a ruby interpreter with same type as ourself. + # juby will fork jruby, ruby will fork ruby etc. + def ruby(args, stderr=nil) + config = ::Config::CONFIG + interpreter = File::join(config['bindir'], config['ruby_install_name']) + config['EXEEXT'] + cmd = "#{interpreter} #{args}" + cmd << " 2> #{stderr}" unless stderr.nil? + `#{cmd}` + end +end \ No newline at end of file diff --git a/vendor/gems/gems/rspec-1.2.9/spec/spec.opts b/vendor/gems/gems/rspec-1.2.9/spec/spec.opts new file mode 100755 index 00000000..48e51f93 --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/spec/spec.opts @@ -0,0 +1,6 @@ +--colour +--format +profile +--timeout +20 +--diff \ No newline at end of file diff --git a/vendor/gems/gems/rspec-1.2.9/spec/spec/dsl/main_spec.rb b/vendor/gems/gems/rspec-1.2.9/spec/spec/dsl/main_spec.rb new file mode 100755 index 00000000..752b07f8 --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/spec/spec/dsl/main_spec.rb @@ -0,0 +1,95 @@ +require 'spec_helper' + +module Spec + module DSL + describe Main do + before(:each) do + @main = Class.new do; include Spec::DSL::Main; end + end + + [:describe, :context].each do |method| + describe "##{method}" do + it "should delegate to Spec::Example::ExampleGroupFactory.create_example_group" do + block = lambda {|a,b|} + Spec::Example::ExampleGroupFactory.should_receive(:create_example_group).with( + "The ExampleGroup", hash_including(:location), &block + ) + @main.__send__ method, "The ExampleGroup", &block + end + + it "raises with no description" do + block = lambda {|a,b|} + lambda do + @main.__send__ method, &block + end.should raise_error(ArgumentError, /No description supplied for example group declared on #{__FILE__}:#{__LINE__ - 1}/) + end + end + end + + [:share_examples_for, :shared_examples_for].each do |method| + describe "##{method}" do + it "should create a shared ExampleGroup" do + block = lambda {|a,b|} + Spec::Example::ExampleGroupFactory.should_receive(:create_shared_example_group).with( + "shared group", hash_including(:location), &block + ) + @main.__send__ method, "shared group", &block + end + end + end + + describe "#describe; with RUBY_VERSION = 1.9" do + it "includes an enclosing module into the block's scope" do + Spec::Ruby.stub!(:version).and_return("1.9") + + module Foo; module Bar; end; end + + Foo::Bar.should_receive(:included).with do |*args| + included_by = args.last + included_by.description.should == "this example group" + end + + module Foo + module Bar + describe("this example group") do; end + end + end + end + end + + + describe "#share_as" do + def self.next_group_name + @group_number ||= 0 + @group_number += 1 + "Group#{@group_number}" + end + + def group_name + @group_name ||= self.class.next_group_name + end + + it "registers a shared ExampleGroup" do + block = lambda {|a,b|} + Spec::Example::ExampleGroupFactory.should_receive(:create_shared_example_group).with( + group_name, hash_including(:location), &block + ) + @main.share_as group_name, &block + end + + it "creates a constant that points to a Module" do + group = @main.share_as group_name do end + Object.const_get(group_name).should equal(group) + end + + it "complains if you pass it a not-constantizable name" do + lambda do + @group = @main.share_as "Non Constant" do end + end.should raise_error(NameError, /The first argument to share_as must be a legal name for a constant/) + end + + end + end + end +end + \ No newline at end of file diff --git a/vendor/gems/gems/rspec-1.2.9/spec/spec/example/example_group_class_definition_spec.rb b/vendor/gems/gems/rspec-1.2.9/spec/spec/example/example_group_class_definition_spec.rb new file mode 100755 index 00000000..96bd2111 --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/spec/spec/example/example_group_class_definition_spec.rb @@ -0,0 +1,51 @@ +require 'spec_helper' + +module Spec + module Example + class ExampleGroupSubclass < ExampleGroup + class << self + attr_accessor :examples_ran + end + + @@class_variable = :class_variable + CONSTANT = :constant + + before(:each) do + @instance_variable = :instance_variable + end + + after(:all) do + self.class.examples_ran = true + end + + def a_method + 22 + end + + it "can access instance variables defined before(:each)" do + @instance_variable.should == :instance_variable + end + + it "can access class variables (Ruby 1.8 only)" do + with_ruby 1.8 do + @@class_variable.should == :class_variable + end + end + + it "can access constants" do + CONSTANT.should == :constant + end + + it "can access methods defined in the Example Group" do + a_method.should == 22 + end + + end + + describe ExampleGroupSubclass do + it "should run" do + ExampleGroupSubclass.examples_ran.should be_true + end + end + end +end \ No newline at end of file diff --git a/vendor/gems/gems/rspec-1.2.9/spec/spec/example/example_group_factory_spec.rb b/vendor/gems/gems/rspec-1.2.9/spec/spec/example/example_group_factory_spec.rb new file mode 100755 index 00000000..0819d3a3 --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/spec/spec/example/example_group_factory_spec.rb @@ -0,0 +1,180 @@ +require 'spec_helper' + +module Spec + module Example + describe ExampleGroupFactory do + describe "#get" do + attr_reader :example_group + before(:each) do + @example_group_class = Class.new(ExampleGroupDouble) + ExampleGroupFactory.register(:registered_type, @example_group_class) + end + + after(:each) do + ExampleGroupFactory.reset + end + + it "should return the default ExampleGroup type for nil" do + ExampleGroupFactory[nil].should == ExampleGroup + end + + it "should return the default ExampleGroup for an unregistered non-nil value" do + ExampleGroupFactory[:does_not_exist].should == ExampleGroup + end + + it "should return custom type if registered" do + ExampleGroupFactory[:registered_type].should == @example_group_class + end + + it "should get the custom type after setting the default" do + @alternate_example_group_class = Class.new(ExampleGroupDouble) + ExampleGroupFactory.default(@alternate_example_group_class) + ExampleGroupFactory[:registered_type].should == @example_group_class + end + end + + describe "#create_example_group" do + attr_reader :parent_example_group + before do + @parent_example_group = Class.new(ExampleGroupDouble) do + def initialize(*args, &block) + ; + end + end + end + + it "should create a uniquely named class" do + example_group = Spec::Example::ExampleGroupFactory.create_example_group("example_group") {} + example_group.name.should =~ /Spec::Example::ExampleGroup::Subclass_\d+/ + end + + it "should create a Spec::Example::Example subclass by default" do + example_group = Spec::Example::ExampleGroupFactory.create_example_group("example_group") {} + example_group.superclass.should == Spec::Example::ExampleGroup + end + + it "should raise when no description is given" do + lambda { + Spec::Example::ExampleGroupFactory.create_example_group do; end + }.should raise_error(ArgumentError) + end + + it "should raise when no block is given" do + lambda { Spec::Example::ExampleGroupFactory.create_example_group "foo" }.should raise_error(ArgumentError) + end + + it "should run registered ExampleGroups" do + example_group = Spec::Example::ExampleGroupFactory.create_example_group "The ExampleGroup" do end + Spec::Runner.options.example_groups.should include(example_group) + end + + it "should not run unregistered ExampleGroups" do + example_group = Spec::Example::ExampleGroupFactory.create_example_group "The ExampleGroup" do Spec::Runner.options.remove_example_group self; end + Spec::Runner.options.example_groups.should_not include(example_group) + end + + describe "with :type => :default" do + it "should create a Spec::Example::ExampleGroup" do + example_group = Spec::Example::ExampleGroupFactory.create_example_group( + "example_group", :type => :default + ) {} + example_group.superclass.should == Spec::Example::ExampleGroup + end + end + + describe "with :type => :something_other_than_default" do + it "should create the specified type" do + Spec::Example::ExampleGroupFactory.register(:something_other_than_default, parent_example_group) + non_default_example_group = Spec::Example::ExampleGroupFactory.create_example_group( + "example_group", :type => :something_other_than_default + ) {} + non_default_example_group.superclass.should == parent_example_group + end + end + + it "should create a type indicated by :location" do + Spec::Example::ExampleGroupFactory.register(:something_other_than_default, parent_example_group) + custom_example_group = Spec::Example::ExampleGroupFactory.create_example_group( + "example_group", :location => "./spec/something_other_than_default/some_spec.rb" + ) {} + custom_example_group.superclass.should == parent_example_group + end + + it "should create a type indicated by :location (with location generated by caller on windows)" do + Spec::Example::ExampleGroupFactory.register(:something_other_than_default, parent_example_group) + custom_example_group = Spec::Example::ExampleGroupFactory.create_example_group( + "example_group", + :location => "./spec\\something_other_than_default\\some_spec.rb" + ) {} + custom_example_group.superclass.should == parent_example_group + end + + it "should create a type indicated by location for a path-like key" do + Spec::Example::ExampleGroupFactory.register('path/to/custom/', parent_example_group) + custom_example_group = Spec::Example::ExampleGroupFactory.create_example_group( + "example_group", :location => "./spec/path/to/custom/some_spec.rb" + ) {} + custom_example_group.superclass.should == parent_example_group + end + + it "should use the longest key that matches when creating a type indicated by location" do + longer = Class.new parent_example_group + Spec::Example::ExampleGroupFactory.register(:longer, longer) + long = Class.new parent_example_group + Spec::Example::ExampleGroupFactory.register(:long, long) + custom_example_group = Spec::Example::ExampleGroupFactory.create_example_group( + "example_group", :location => "./spec/longer/some_spec.rb" + ) {} + custom_example_group.superclass.should == longer + end + + describe "with :shared => true" do + def shared_example_group + @shared_example_group ||= Spec::Example::ExampleGroupFactory.create_example_group( + "name", :location => '/blah/spec/models/blah.rb', :type => :controller, :shared => true + ) {} + end + + it "should create and register a Spec::Example::SharedExampleGroup" do + shared_example_group.should be_an_instance_of(Spec::Example::SharedExampleGroup) + SharedExampleGroup.should include(shared_example_group) + end + end + + it "should favor the :type over the :location" do + Spec::Example::ExampleGroupFactory.register(:something_other_than_default, parent_example_group) + custom_example_group = Spec::Example::ExampleGroupFactory.create_example_group( + "name", :location => '/blah/spec/models/blah.rb', :type => :something_other_than_default + ) {} + custom_example_group.superclass.should == parent_example_group + end + + it "should register ExampleGroup by default" do + example_group = Spec::Example::ExampleGroupFactory.create_example_group("The ExampleGroup") do + end + Spec::Runner.options.example_groups.should include(example_group) + end + + it "should enable unregistering of ExampleGroups" do + example_group = Spec::Example::ExampleGroupFactory.create_example_group("The ExampleGroup") do + Spec::Runner.options.remove_example_group self + end + Spec::Runner.options.example_groups.should_not include(example_group) + end + + after(:each) do + Spec::Example::ExampleGroupFactory.reset + end + end + + describe "#create_shared_example_group" do + it "registers a new shared example group" do + shared_example_group = Spec::Example::ExampleGroupFactory.create_shared_example_group("something shared") {} + shared_example_group.should be_an_instance_of(Spec::Example::SharedExampleGroup) + SharedExampleGroup.should include(shared_example_group) + end + end + + end + end +end diff --git a/vendor/gems/gems/rspec-1.2.9/spec/spec/example/example_group_methods_spec.rb b/vendor/gems/gems/rspec-1.2.9/spec/spec/example/example_group_methods_spec.rb new file mode 100755 index 00000000..c9f10b8c --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/spec/spec/example/example_group_methods_spec.rb @@ -0,0 +1,758 @@ +require 'spec_helper' + +module Spec + module Example + describe 'ExampleGroupMethods' do + with_sandboxed_options do + attr_reader :example_group, :result, :reporter + before(:each) do + # See http://rspec.lighthouseapp.com/projects/5645-rspec/tickets/525-arity-changed-on-partial-mocks#ticket-525-2 + method_with_three_args = lambda { |arg1, arg2, arg3| } + options.formatters << mock("formatter", :null_object => true, :example_pending => method_with_three_args) + options.backtrace_tweaker = mock("backtrace_tweaker", :null_object => true) + @reporter = FakeReporter.new(@options) + options.reporter = reporter + @example_group = Class.new(ExampleGroupDouble) do + describe("ExampleGroup") + it "does nothing" + end + end + + after(:each) do + ExampleGroupDouble.reset + end + + ["describe","context"].each do |method| + describe "##{method}" do + describe "when creating an ExampleGroup" do + before(:each) do + @parent_example_group = Class.new(ExampleGroupDouble) do + example "first example" do; end + end + @child_example_group = @parent_example_group.__send__ method, "Child" do + example "second example" do; end + end + end + + it "should create a subclass of the ExampleGroup when passed a block" do + @child_example_group.superclass.should == @parent_example_group + options.example_groups.should include(@child_example_group) + end + + it "should not inherit examples" do + @child_example_group.should have(1).examples + end + + it "records the spec path" do + @child_example_group.location.should =~ /#{__FILE__}:#{__LINE__ - 15}/ + end + end + + describe "when creating an example group with no description" do + it "raises an ArgumentError" do + lambda do + Class.new(ExampleGroupDouble).describe + end.should raise_error(Spec::Example::NoDescriptionError, /No description supplied for example group declared on #{__FILE__}:#{__LINE__ - 1}/) + end + end + + describe "when creating a SharedExampleGroup" do + before(:each) do + @shared_example_group = @example_group.__send__ method, "A Shared ExampleGroup", :shared => true do; end + end + + after(:each) do + SharedExampleGroup.instance_eval{@shared_example_groups}.delete @shared_example_group + end + + it "should create a SharedExampleGroup" do + @shared_example_group.should_not be_nil + SharedExampleGroup.find("A Shared ExampleGroup").should == @shared_example_group + end + end + + end + end + + [:example, :specify, :it].each do |method| + describe "##{method.to_s}" do + it "should add an example" do + lambda { + @example_group.__send__(method, "") + }.should change { @example_group.examples.length }.by(1) + end + + describe "with no location supplied" do + describe "creates an ExampleProxy" do + before(:all) do + @example_group = Class.new(ExampleGroupDouble).describe("bar") + @example_proxy = @example_group.__send__(method, "foo", {:this => :that}) {} + @location = "#{__FILE__}:#{__LINE__ - 1}" + end + + specify "with a description" do + @example_proxy.description.should == "foo" + end + + specify "with options" do + @example_proxy.options.should == {:this => :that} + end + + specify "with a default backtrace (DEPRECATED)" do + Spec.stub!(:deprecate) + @example_proxy.backtrace.should =~ /#{@location}/ + end + + specify "with a default location" do + @example_proxy.location.should =~ /#{@location}/ + end + end + end + + describe "with a location supplied" do + describe "creates an ExampleProxy" do + before(:all) do + @example_group = Class.new(ExampleGroupDouble).describe("bar") + @example_proxy = @example_group.__send__(method, "foo", {:this => :that}, "the location") {} + end + + specify "with the supplied location as #backtrace (DEPRECATED)" do + Spec.stub!(:deprecate) + @example_proxy.backtrace.should == "the location" + end + + specify "with the supplied location as #location" do + @example_proxy.location.should == "the location" + end + end + end + + + end + end + + [:xexample, :xit, :xspecify].each do |method| + describe "##{method.to_s}" do + before(:each) do + Kernel.stub!(:warn) + end + + it "should NOT create an example" do + lambda { + @example_group.__send__(method,"") + }.should_not change(@example_group.examples, :length) + end + + it "should warn that the example is disabled" do + Kernel.should_receive(:warn).with("Example disabled: foo") + @example_group.__send__(method,"foo") + end + end + end + + describe "#examples" do + it "should have Examples" do + example_group = Class.new(ExampleGroupDouble) do + it "should exist" do; end + end + example_group.examples.length.should == 1 + example_group.examples.first.description.should == "should exist" + end + + it "should not include methods that begin with test (only when TU interop is loaded)" do + example_group = Class.new(ExampleGroupDouble) do + def test_any_args(*args) + true.should be_true + end + def test_something + 1.should == 1 + end + def test + raise "This is not a real test" + end + def testify + raise "This is not a real test" + end + def should_something + # forces the run + end + end + + example_group.examples.length.should == 1 + example_group.run(options).should be_true + end + + it "should include methods that begin with should and has an arity of 0 in suite" do + example_group = Class.new(ExampleGroupDouble) do + def shouldCamelCase + true.should be_true + end + def should_any_args(*args) + true.should be_true + end + def should_something + 1.should == 1 + end + def should_not_something + 1.should_not == 2 + end + def should + raise "This is not a real example" + end + def should_not + raise "This is not a real example" + end + end + example_group.should have(4).examples + descriptions = example_group.examples.collect {|e| e.description} + descriptions.should include( + "shouldCamelCase", + "should_any_args", + "should_something", + "should_not_something") + descriptions.should_not include( + "should", + "should_not" + ) + end + + it "should not include methods that begin with test_ and has an arity > 0 in suite" do + example_group = Class.new(ExampleGroupDouble) do + def test_invalid(foo) + 1.should == 1 + end + def testInvalidCamelCase(foo) + 1.should == 1 + end + end + example_group.should have(:no).examples + end + + it "should not include methods that begin with should_ and has an arity > 0 in suite" do + example_group = Class.new(ExampleGroupDouble) do + def should_invalid(foo) + 1.should == 2 + end + def shouldInvalidCamelCase(foo) + 1.should == 3 + end + def should_not_invalid(foo) + 1.should == 4 + end + def should_valid + 1.should == 1 + end + end + example_group.should have(1).examples + example_group.run(options).should be_true + end + + it "should run should_methods" do + example_group = Class.new(ExampleGroupDouble) do + def should_valid + 1.should == 2 + end + end + example_group.should have(1).examples + example_group.run(options).should be_false + end + end + + describe "#set_description" do + attr_reader :example_group + before do + class << example_group + public :set_description + end + end + + describe "given a String" do + before(:each) do + example_group.set_description("abc") + end + + specify ".description should return the String passed into .set_description" do + example_group.description.should == "abc" + end + + specify ".described_type should provide nil as its type" do + example_group.described_type.should be_nil + end + end + + describe "given a Class" do + before(:each) do + example_group.set_description(ExampleGroup) + end + + specify ".description should return a String representation of that type (fully qualified) as its name" do + example_group.description.should == "Spec::Example::ExampleGroup" + end + + specify ".described_type should return the passed in type" do + example_group.described_type.should == Spec::Example::ExampleGroup + end + end + + describe "given a String and a Class" do + before(:each) do + example_group.set_description("behaving", ExampleGroup) + end + + specify ".description should return String then space then Type" do + example_group.description.should == "behaving Spec::Example::ExampleGroup" + end + + specify ".described_type should return the passed in type" do + example_group.described_type.should == Spec::Example::ExampleGroup + end + end + + describe "given a Class and a String (starting with an alpha char)" do + before(:each) do + example_group.set_description(ExampleGroup, "behaving") + end + + specify ".description should return the Type then space then String" do + example_group.description.should == "Spec::Example::ExampleGroup behaving" + end + end + + describe "given a Class and a String (starting with a '.')" do + before(:each) do + example_group.set_description(ExampleGroup, ".behaving") + end + + specify ".description should return the Type then String" do + example_group.description.should == "Spec::Example::ExampleGroup.behaving" + end + end + + describe "#set_description(Class, String starting with #)" do + before(:each) do + example_group.set_description(ExampleGroup, "#behaving") + end + + specify "should return the Class then String" do + example_group.description.should == "Spec::Example::ExampleGroup#behaving" + end + end + + describe "#set_description(Class, String containing .)" do + before(:each) do + example_group.set_description(ExampleGroup, "calling a.b") + end + + specify ".description should return the Type then space then String" do + example_group.description.should == "Spec::Example::ExampleGroup calling a.b" + end + end + + describe "#set_description(Class, String containing #)" do + before(:each) do + example_group.set_description(ExampleGroup, "is #1") + end + + specify ".description should return the Type then space then String" do + example_group.description.should == "Spec::Example::ExampleGroup is #1" + end + end + + describe "#set_description(String, Type, String)" do + before(:each) do + example_group.set_description("A", Hash, "with one entry") + end + + specify ".description should return the first String then space then Type then second String" do + example_group.description.should == "A Hash with one entry" + end + end + + describe "#set_description(Hash representing options)" do + before(:each) do + example_group.set_description(:a => "b", :location => "blah") + end + + it ".location should expand the passed in :location option passed into the constructor" do + example_group.location.should == File.expand_path("blah") + end + + it ".options should return all the options passed in" do + example_group.options.should == {:a => "b", :location => "blah"} + end + + end + end + + describe "#description" do + it "should return the same description instance for each call" do + example_group.description.should eql(example_group.description) + end + + it "should not add a space when description begins with #" do + child_example_group = Class.new(example_group) do + describe("#foobar", "Does something") + end + child_example_group.description.should == "ExampleGroup#foobar Does something" + end + + it "should not add a space when description begins with ." do + child_example_group = Class.new(example_group) do + describe(".foobar", "Does something") + end + child_example_group.description.should == "ExampleGroup.foobar Does something" + end + + it "should return the class name if nil" do + example_group.set_description(nil) + example_group.description.should =~ /Class:/ + end + + it "should return the class name if nil" do + example_group.set_description("") + example_group.description.should =~ /Class:/ + end + + it "is cached" do + example_group.set_description("describe me") + example_group.description.should be(example_group.description) + end + end + + describe "#description_parts" do + it "should return an Array of the current class description args" do + example_group.description_parts.should == [example_group.description] + end + + it "should return an Array of the description args from each class in the hierarchy" do + parent_example_group = Class.new(ExampleGroupDouble) do + describe("Parent") + end + + child_example_group = Class.new(parent_example_group) + child_example_group.describe("Child", ExampleGroup) + child_example_group.description.should_not be_empty + + grand_child_example_group = Class.new(child_example_group) + grand_child_example_group.describe("GrandChild", ExampleGroup) + grand_child_example_group.description.should_not be_empty + + grand_child_example_group.description_parts.should == [ + "Parent", + "Child", + Spec::Example::ExampleGroup, + "GrandChild", + Spec::Example::ExampleGroup + ] + end + + it "caches the description parts" do + example_group.description_parts.should equal(example_group.description_parts) + end + end + + describe "#described_type" do + it "should return passed in type" do + child_example_group = Class.new(example_group) do + describe Object + end + child_example_group.described_type.should == Object + end + + it "should return #described_type of superclass when no passed in type" do + parent_example_group = Class.new(ExampleGroupDouble) do + describe Object, "#foobar" + end + child_example_group = Class.new(parent_example_group) do + describe "not a type" + end + child_example_group.described_type.should == Object + end + + it "is cached per example group" do + klass = Class.new + group = Class.new(ExampleGroupDouble) do + describe(klass) + end + group.should_receive(:description_parts).once.and_return([klass]) + group.described_type + group.described_type + end + end + + describe "#include" do + it "should have accessible class methods from included module" do + mod_method_called = false + mod = Module.new do + class_methods = Module.new do + define_method :mod_method do + mod_method_called = true + end + end + + self.class.class_eval do + define_method(:included) do |receiver| + receiver.extend class_methods + end + end + end + + @example_group.__send__ :include, mod + + @example_group.mod_method + mod_method_called.should be_true + end + end + + describe "#number_of_examples" do + it "should count number of examples" do + proc do + @example_group.it("one") {} + @example_group.it("two") {} + @example_group.it("three") {} + @example_group.it("four") {} + end.should change {@example_group.number_of_examples}.by(4) + end + end + + describe "#class_eval" do + it "should allow constants to be defined" do + example_group = Class.new(ExampleGroupDouble) do + FOO = 1 + it "should reference FOO" do + FOO.should == 1 + end + end + success = example_group.run(options) + success.should be_true + Object.const_defined?(:FOO).should == false + end + end + + describe '#register' do + after(:each) do + Spec::Runner.options.remove_example_group example_group + end + it "should add ExampleGroup to set of ExampleGroups to be run" do + Spec::Runner.options.add_example_group example_group + options.example_groups.should include(example_group) + end + end + + describe '#remove_example_group' do + before(:each) do + Spec::Runner.options.add_example_group example_group + end + it "should remove ExampleGroup from set of ExampleGroups to be run" do + Spec::Runner.options.remove_example_group example_group + options.example_groups.should_not include(example_group) + end + end + + describe "#run" do + describe "given an example group with at least one example" do + it "should call add_example_group" do + example_group = Class.new(ExampleGroupDouble) do + example("anything") {} + end + reporter.should_receive(:add_example_group) + example_group.run(options) + end + end + + describe "given an example group with no examples" do + it "should NOT call add_example_group" do + example_group = Class.new(ExampleGroupDouble) do end + reporter.should_not_receive(:add_example_group) + example_group.run(options) + end + end + end + + describe "#matcher_class=" do + it "should call new and matches? on the class used for matching examples" do + example_group = Class.new(ExampleGroupDouble) do + it "should do something" do end + def self.specified_examples + ["something"] + end + def self.to_s + "TestMatcher" + end + end + + matcher = mock("matcher") + matcher.should_receive(:matches?).with(["something"]).any_number_of_times + + matcher_class = Class.new + matcher_class.should_receive(:new).with("TestMatcher", "should do something").and_return(matcher) + + begin + ExampleGroupMethods.matcher_class = matcher_class + + example_group.run(options) + ensure + ExampleGroupMethods.matcher_class = ExampleMatcher + end + end + end + + describe "#options" do + it "should expose the options hash" do + group = describe("group", :this => 'hash') {} + group.options[:this].should == 'hash' + end + end + + describe "#before" do + it "stores before(:each) blocks" do + example_group = Class.new(ExampleGroupDouble) {} + block = lambda {} + example_group.before(:each, &block) + example_group.before_each_parts.should include(block) + end + + it "stores before(:all) blocks" do + example_group = Class.new(ExampleGroupDouble) {} + block = lambda {} + example_group.before(:all, &block) + example_group.before_all_parts.should include(block) + end + + it "stores before(:suite) blocks" do + example_group = Class.new(ExampleGroupDouble) {} + parts = [] + ExampleGroupMethods.stub!(:before_suite_parts).and_return(parts) + block = lambda {} + example_group.before(:suite, &block) + example_group.before_suite_parts.should include(block) + end + end + + + describe "#after" do + it "stores after(:each) blocks" do + example_group = Class.new(ExampleGroupDouble) {} + block = lambda {} + example_group.after(:each, &block) + example_group.after_each_parts.should include(block) + end + + it "stores after(:all) blocks" do + example_group = Class.new(ExampleGroupDouble) {} + block = lambda {} + example_group.after(:all, &block) + example_group.after_all_parts.should include(block) + end + + it "stores after(:suite) blocks" do + example_group = Class.new(ExampleGroupDouble) {} + parts = [] + ExampleGroupMethods.stub!(:after_suite_parts).and_return(parts) + block = lambda {} + example_group.after(:suite, &block) + example_group.after_suite_parts.should include(block) + end + end + + describe "#run_before_all" do + it "does not create an instance if before_all_parts are empty" do + example_group = Class.new(ExampleGroupDouble) { example("one example") {} } + example_group.should_not_receive(:new) + example_group.__send__ :run_before_all, nil + end + end + + describe "#run_after_all" do + it "does not create an instance if after_all_parts are empty" do + example_group = Class.new(ExampleGroupDouble) { example("one example") {} } + example_group.should_not_receive(:new) + example_group.__send__ :run_after_all, true, {}, nil + end + end + + describe "#examples_to_run" do + it "runs only the example identified by a line number" do + example_group = Class.new(ExampleGroupDouble).describe("this") do + it { 3.should == 3 } + it "has another example which raises" do + raise "this shouldn't have run" + end + end + options.examples << :ignore + options.line_number = __LINE__ - 6 + options.files << __FILE__ + example_group.run(options).should be_true + end + + it "runs the example identified by a line number even if it's not the example line number" do + example_group = Class.new(ExampleGroupDouble).describe("this") do + + it { raise "foo" } + + end + options.examples << :ignore + options.line_number = __LINE__ - 3 + options.files << __FILE__ + example_group.run(options).should be_false + end + + it "runs all the examples in the group " do + first_example_ran = false + second_example_ran = false + example_group = Class.new(ExampleGroupDouble).describe("this") do + + it { first_example_ran = true } + it { second_example_ran = true } + + end + options.line_number = __LINE__ - 6 + options.files << __FILE__ + options.examples << :ignore + example_group.run(options) + first_example_ran.should be_true + second_example_ran.should be_true + end + + it "doesn't run any examples in another group" do + example_ran = false + example_group_1 = Class.new(ExampleGroupDouble).describe("this") do + it "ignore" do + example_ran = true + end + end + example_group_2 = Class.new(ExampleGroupDouble).describe("that") do + end + options.examples << :ignore + options.line_number = __LINE__ - 3 + options.files << __FILE__ + example_group_1.run(options) + example_group_2.run(options) + example_ran.should be_false + end + end + + describe "#define" do + let(:counter) do + Class.new do + def initialize + @count = 0 + end + def count + @count += 1 + end + end.new + end + it "generates an instance method" do + counter.count.should == 1 + end + + it "caches the value" do + counter.count.should == 1 + counter.count.should == 2 + end + end + end + end + end +end diff --git a/vendor/gems/gems/rspec-1.2.9/spec/spec/example/example_group_proxy_spec.rb b/vendor/gems/gems/rspec-1.2.9/spec/spec/example/example_group_proxy_spec.rb new file mode 100755 index 00000000..6af4ef18 --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/spec/spec/example/example_group_proxy_spec.rb @@ -0,0 +1,107 @@ +require 'spec_helper' + +module Spec + module Example + describe ExampleGroupProxy do + before(:each) do + @group = stub("example group").as_null_object + end + + attr_reader :group + def proxy + @proxy ||= ExampleGroupProxy.new(@group) + end + + describe "#description" do + it "provides the example group's description" do + group.stub!(:description => "the description") + proxy.description.should == "the description" + end + end + + describe "#nested_descriptions" do + it "provides the example group's nested_descriptions" do + group.stub!(:nested_descriptions => ["the description"]) + proxy.nested_descriptions.should == ["the description"] + end + end + + describe "#filtered_description (DEPRECATED)" do + before(:each) do + Spec.stub!(:deprecate) + end + + it "is deprecated" do + Spec.should_receive(:deprecate) + proxy.filtered_description(/(ignore)/) + end + + it "builds the description from the group's nested_descriptions" do + group.stub!(:nested_descriptions => ["ignore","the","description"]) + proxy.filtered_description(/(ignore)/).should == "the description" + end + + it "filters out description parts that match the supplied regexp" do + group.stub!(:nested_descriptions => ["ignore the","description"]) + proxy.filtered_description(/(ignore )/).should == "the description" + end + end + + describe "#examples" do + it "provides a collection of example group proxies" do + group.stub!(:example_proxies => ["array","of","proxies"]) + proxy.examples.should == ["array","of","proxies"] + end + end + + describe "#backtrace (deprecated - use #location)" do + before(:each) do + Spec.stub!(:deprecate) + end + + it "provides the location of the declaration of this group" do + group.stub!(:location => "path/to/location:37") + proxy.backtrace.should == "path/to/location:37" + end + + it "warns deprecation" do + Spec.should_receive(:deprecate) + group.stub!(:location => "path/to/location:37") + proxy.backtrace + end + end + + describe "#location" do + it "provides the location of the declaration of this group" do + group.stub!(:location => "path/to/location:37") + proxy.location.should == "path/to/location:37" + end + end + + describe "#options" do + it "provides the options passed to the example group declaration" do + group.stub!(:options => {:a => 'b'}) + proxy.options.should == {:a => 'b'} + end + + it "excludes :location" do + group.stub!(:options => {:location => 'b'}) + proxy.options.should == {} + end + + it "excludes :scope" do + group.stub!(:options => {:scope => 'b'}) + proxy.options.should == {} + end + + it "preserves the original hash" do + hash = {:a => 'b', :location => 'here', :scope => 'tiny'} + group.stub!(:options => hash) + proxy.options.should == {:a => 'b'} + hash.should == {:a => 'b', :location => 'here', :scope => 'tiny'} + end + end + + end + end +end diff --git a/vendor/gems/gems/rspec-1.2.9/spec/spec/example/example_group_spec.rb b/vendor/gems/gems/rspec-1.2.9/spec/spec/example/example_group_spec.rb new file mode 100755 index 00000000..086c166c --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/spec/spec/example/example_group_spec.rb @@ -0,0 +1,643 @@ +require 'spec_helper' + +module Spec + module Example + class ExampleModuleScopingSpec < ExampleGroup + describe ExampleGroup, "via a class definition" + + module Foo + module Bar + def self.loaded?; true; end + end + end + include Foo + + it "should understand module scoping" do + Bar.should be_loaded + end + + @@class_variable = "a class variable" + + it "can access class variables in examples in Ruby 1.8" do + with_ruby 1.8 do + @@class_variable.should == "a class variable" + end + end + + it "can NOT access class variables in examples in Ruby 1.9" do + with_ruby 1.9 do + lambda do + @@class_variable.should == "a class variable" + end.should raise_error(NameError) + end + end + + + end + + class ExampleClassVariablePollutionSpec < ExampleGroup + describe ExampleGroup, "via a class definition without a class variable" + + it "should not retain class variables from other Example classes" do + proc do + @@class_variable + end.should raise_error + end + end + + describe ExampleGroup, "#pending" do + it "should raise a Pending error when its block fails" do + block_ran = false + lambda { + pending("something") do + block_ran = true + raise "something wrong with my example" + end + }.should raise_error(Spec::Example::ExamplePendingError, "something") + block_ran.should == true + end + + it "should raise Spec::Example::PendingExampleFixedError when its block does not fail" do + block_ran = false + lambda { + pending("something") do + block_ran = true + end + }.should raise_error(Spec::Example::PendingExampleFixedError, "Expected pending 'something' to fail. No Error was raised.") + block_ran.should == true + end + end + + describe ExampleGroup, "#run with failure in example", :shared => true do + it "should add an example failure to the TestResult" do + example_group.run(options).should be_false + end + end + + describe ExampleGroup, "#run" do + with_sandboxed_options do + attr_reader :example_group, :formatter, :reporter + before :each do + method_with_three_args = lambda { |arg1, arg2, arg3| } + @formatter = mock("formatter", :null_object => true, :example_pending => method_with_three_args) + options.formatters << formatter + options.backtrace_tweaker = mock("backtrace_tweaker", :null_object => true) + @reporter = FakeReporter.new(options) + options.reporter = reporter + @example_group = Class.new(ExampleGroupDouble) do + describe("example") + it "does nothing" do + end + end + class << example_group + public :include + end + end + + after :each do + ExampleGroup.reset + end + + it "should not run when there are no examples" do + example_group = Class.new(ExampleGroupDouble) do + describe("Foobar") + end + example_group.examples.should be_empty + + reporter = mock("Reporter") + reporter.should_not_receive(:add_example_group) + example_group.run(options) + end + + it "should report the start of an example run" do + reporter.should_receive(:example_started) do |example| + example.should equal(example_group.examples[0]) + end + example_group.run(options) + end + + it "should report the end of an example run" do + reporter.should_receive(:example_finished) do |example, execution_error| + example.should equal(example_group.examples[0]) + execution_error.should be_nil + end + example_group.run(options) + end + + describe "when before_each fails" do + before(:each) do + $example_ran = $after_each_ran = false + @example_group = describe("Foobar") do + before(:each) {raise} + it "should not be run" do + $example_ran = true + end + after(:each) do + $after_each_ran = true + end + end + end + + it "should not run example block" do + example_group.run(options) + $example_ran.should be_false + end + + it "should run after_each" do + example_group.run(options) + $after_each_ran.should be_true + end + + it "should report failure location when in before_each" do + reporter.should_receive(:example_finished) do |example_group, error| + error.message.should eql("in before_each") + end + example_group.run(options) + end + end + + describe ExampleGroup, "#run on dry run" do + before do + @options.dry_run = true + end + + it "should not run before(:all) or after(:all)" do + before_all_ran = false + after_all_ran = false + ExampleGroup.before(:all) { before_all_ran = true } + ExampleGroup.after(:all) { after_all_ran = true } + example_group.it("should") {} + example_group.run(options) + before_all_ran.should be_false + after_all_ran.should be_false + end + + it "should not run example" do + example_ran = false + example_group.it("should") {example_ran = true} + example_group.run(options) + example_ran.should be_false + end + end + + describe ExampleGroup, "#run with specified examples" do + attr_reader :examples_that_were_run + before do + @examples_that_were_run = [] + end + + describe "when specified_examples matches entire ExampleGroup" do + before do + examples_that_were_run = @examples_that_were_run + @example_group = Class.new(ExampleGroupDouble) do + describe("the ExampleGroup") + it("should be run") do + examples_that_were_run << 'should be run' + end + + it("should also be run") do + examples_that_were_run << 'should also be run' + end + end + options.parse_example "the ExampleGroup" + end + + it "should not run the Examples in the ExampleGroup" do + example_group.run(options) + examples_that_were_run.should == ['should be run', 'should also be run'] + end + end + + describe ExampleGroup, "#run when specified_examples matches only Example description" do + before do + examples_that_were_run = @examples_that_were_run + @example_group = Class.new(ExampleGroupDouble) do + describe("example") + it("should be run") do + examples_that_were_run << 'should be run' + end + end + options.parse_example "should be run" + end + + it "should not run the example" do + example_group.run(options) + examples_that_were_run.should == ['should be run'] + end + end + + describe ExampleGroup, "#run when specified_examples does not match an Example description" do + before do + examples_that_were_run = @examples_that_were_run + @example_group = Class.new(ExampleGroupDouble) do + describe("example") + it("should be something else") do + examples_that_were_run << 'should be something else' + end + end + options.parse_example "does not match anything" + end + + it "should not run the example" do + example_group.run(options) + examples_that_were_run.should == [] + end + end + + describe ExampleGroup, "#run when specified_examples matches an Example description" do + before do + examples_that_were_run = @examples_that_were_run + @example_group = Class.new(ExampleGroupDouble) do + describe("example") + it("should be run") do + examples_that_were_run << 'should be run' + end + it("should not be run") do + examples_that_were_run << 'should not be run' + end + end + options.parse_example "should be run" + end + + it "should run only the example" do + example_group.run(options) + examples_that_were_run.should == ["should be run"] + end + end + end + + describe ExampleGroup, "#run with success" do + before do + @special_example_group = Class.new(ExampleGroupDouble) + ExampleGroupFactory.register(:special, @special_example_group) + @not_special_example_group = Class.new(ExampleGroupDouble) + ExampleGroupFactory.register(:not_special, @not_special_example_group) + end + + after do + ExampleGroupFactory.reset + end + + it "should send reporter example_group_started" do + reporter.should_receive(:example_group_started) + example_group.run(options) + end + + it "should run example on run" do + example_ran = false + example_group.it("should") {example_ran = true} + example_group.run(options) + example_ran.should be_true + end + + it "should run before(:all) block only once" do + before_all_run_count_run_count = 0 + example_group.before(:all) {before_all_run_count_run_count += 1} + example_group.it("test") {true} + example_group.it("test2") {true} + example_group.run(options) + before_all_run_count_run_count.should == 1 + end + + it "should run after(:all) block only once" do + after_all_run_count = 0 + example_group.after(:all) {after_all_run_count += 1} + example_group.it("test") {true} + example_group.it("test2") {true} + example_group.run(options) + after_all_run_count.should == 1 + @reporter.rspec_verify + end + + it "after(:all) should have access to all instance variables defined in before(:all)" do + context_instance_value_in = "Hello there" + context_instance_value_out = "" + example_group.before(:all) { @instance_var = context_instance_value_in } + example_group.after(:all) { context_instance_value_out = @instance_var } + example_group.it("test") {true} + example_group.run(options) + context_instance_value_in.should == context_instance_value_out + end + + it "should copy instance variables from before(:all)'s execution context into spec's execution context" do + context_instance_value_in = "Hello there" + context_instance_value_out = "" + example_group.before(:all) { @instance_var = context_instance_value_in } + example_group.it("test") {context_instance_value_out = @instance_var} + example_group.run(options) + context_instance_value_in.should == context_instance_value_out + end + + it "should not add global before callbacks for untargetted example_group" do + fiddle = [] + + ExampleGroup.before(:all) { fiddle << "Example.before(:all)" } + ExampleGroup.prepend_before(:all) { fiddle << "Example.prepend_before(:all)" } + @special_example_group.before(:each) { fiddle << "Example.before(:each, :type => :special)" } + @special_example_group.prepend_before(:each) { fiddle << "Example.prepend_before(:each, :type => :special)" } + @special_example_group.before(:all) { fiddle << "Example.before(:all, :type => :special)" } + @special_example_group.prepend_before(:all) { fiddle << "Example.prepend_before(:all, :type => :special)" } + + example_group = Class.new(ExampleGroupDouble) do + describe("I'm not special", :type => :not_special) + it "does nothing" + end + example_group.run(options) + fiddle.should == [ + 'Example.prepend_before(:all)', + 'Example.before(:all)', + ] + end + + it "should add global before callbacks for targetted example_groups" do + fiddle = [] + + ExampleGroup.before(:all) { fiddle << "Example.before(:all)" } + ExampleGroup.prepend_before(:all) { fiddle << "Example.prepend_before(:all)" } + @special_example_group.before(:each) { fiddle << "special.before(:each, :type => :special)" } + @special_example_group.prepend_before(:each) { fiddle << "special.prepend_before(:each, :type => :special)" } + @special_example_group.before(:all) { fiddle << "special.before(:all, :type => :special)" } + @special_example_group.prepend_before(:all) { fiddle << "special.prepend_before(:all, :type => :special)" } + @special_example_group.append_before(:each) { fiddle << "special.append_before(:each, :type => :special)" } + + example_group = Class.new(@special_example_group).describe("I'm a special example_group") {} + example_group.it("test") {true} + example_group.run(options) + fiddle.should == [ + 'Example.prepend_before(:all)', + 'Example.before(:all)', + 'special.prepend_before(:all, :type => :special)', + 'special.before(:all, :type => :special)', + 'special.prepend_before(:each, :type => :special)', + 'special.before(:each, :type => :special)', + 'special.append_before(:each, :type => :special)', + ] + end + + it "should order before callbacks from global to local" do + fiddle = [] + ExampleGroup.prepend_before(:all) { fiddle << "Example.prepend_before(:all)" } + ExampleGroup.before(:all) { fiddle << "Example.before(:all)" } + example_group.prepend_before(:all) { fiddle << "prepend_before(:all)" } + example_group.before(:all) { fiddle << "before(:all)" } + example_group.prepend_before(:each) { fiddle << "prepend_before(:each)" } + example_group.before(:each) { fiddle << "before(:each)" } + example_group.run(options) + fiddle.should == [ + 'Example.prepend_before(:all)', + 'Example.before(:all)', + 'prepend_before(:all)', + 'before(:all)', + 'prepend_before(:each)', + 'before(:each)' + ] + end + + it "should order after callbacks from local to global" do + fiddle = [] + example_group.after(:each) { fiddle << "after(:each)" } + example_group.append_after(:each) { fiddle << "append_after(:each)" } + example_group.after(:all) { fiddle << "after(:all)" } + example_group.append_after(:all) { fiddle << "append_after(:all)" } + ExampleGroup.after(:all) { fiddle << "Example.after(:all)" } + ExampleGroup.append_after(:all) { fiddle << "Example.append_after(:all)" } + example_group.run(options) + fiddle.should == [ + 'after(:each)', + 'append_after(:each)', + 'after(:all)', + 'append_after(:all)', + 'Example.after(:all)', + 'Example.append_after(:all)' + ] + end + + it "should have accessible instance methods from included module" do + mod1_method_called = false + mod1 = Module.new do + define_method :mod1_method do + mod1_method_called = true + end + end + + mod2_method_called = false + mod2 = Module.new do + define_method :mod2_method do + mod2_method_called = true + end + end + + example_group.include mod1, mod2 + + example_group.it("test") do + mod1_method + mod2_method + end + example_group.run(options) + mod1_method_called.should be_true + mod2_method_called.should be_true + end + + it "should include targetted modules included using configuration" do + mod1 = Module.new + mod2 = Module.new + mod3 = Module.new + Spec::Runner.configuration.include(mod1, mod2) + Spec::Runner.configuration.include(mod3, :type => :not_special) + + example_group = Class.new(@special_example_group).describe("I'm special", :type => :special) do + it "does nothing" + end + example_group.run(options) + + example_group.included_modules.should include(mod1) + example_group.included_modules.should include(mod2) + example_group.included_modules.should_not include(mod3) + end + + end + + describe ExampleGroup, "#run with pending example that has a failing assertion" do + before do + example_group.it("should be pending") do + pending("Example fails") {false.should be_true} + end + end + + it "should send example_pending to formatter" do + @formatter.should_receive(:example_pending).with("example", "should be pending", "Example fails") + example_group.run(options) + end + end + + describe ExampleGroup, "#run with pending example that does not have a failing assertion" do + it_should_behave_like "Spec::Example::ExampleGroup#run with failure in example" + + before do + example_group.it("should be pending") do + pending("Example passes") {true.should be_true} + end + end + + it "should send example_pending to formatter" do + @formatter.should_receive(:example_pending).with("example", "should be pending", "Example passes") + example_group.run(options) + end + end + + describe ExampleGroup, "#run when before(:all) fails" do + it_should_behave_like "Spec::Example::ExampleGroup#run with failure in example" + + before do + ExampleGroup.before(:all) { raise NonStandardError, "before(:all) failure" } + end + + it "should not run any example" do + spec_ran = false + example_group.it("test") {spec_ran = true} + example_group.run(options) + spec_ran.should be_false + end + + it "should run ExampleGroup after(:all)" do + after_all_ran = false + ExampleGroup.after(:all) { after_all_ran = true } + example_group.run(options) + after_all_ran.should be_true + end + + it "should run example_group after(:all)" do + after_all_ran = false + example_group.after(:all) { after_all_ran = true } + example_group.run(options) + after_all_ran.should be_true + end + + it "should supply before(:all) as description" do + @reporter.should_receive(:example_failed) do |example, error| + example.description.should eql("before(:all)") + error.message.should eql("before(:all) failure") + end + + example_group.it("test") {true} + example_group.run(options) + end + end + + describe ExampleGroup, "#run when before(:each) fails" do + it_should_behave_like "Spec::Example::ExampleGroup#run with failure in example" + + before do + ExampleGroup.before(:each) { raise NonStandardError } + end + + it "should run after(:all)" do + after_all_ran = false + ExampleGroup.after(:all) { after_all_ran = true } + example_group.run(options) + after_all_ran.should be_true + end + end + + describe ExampleGroup, "#run when any example fails" do + it_should_behave_like "Spec::Example::ExampleGroup#run with failure in example" + + before do + example_group.it("should") { raise NonStandardError } + end + + it "should run after(:all)" do + after_all_ran = false + ExampleGroup.after(:all) { after_all_ran = true } + example_group.run(options) + after_all_ran.should be_true + end + end + + describe ExampleGroup, "#run when first after(:each) block fails" do + it_should_behave_like "Spec::Example::ExampleGroup#run with failure in example" + + before do + class << example_group + attr_accessor :first_after_ran, :second_after_ran + end + example_group.first_after_ran = false + example_group.second_after_ran = false + + example_group.after(:each) do + self.class.second_after_ran = true + end + example_group.after(:each) do + self.class.first_after_ran = true + raise "first" + end + end + + it "should run second after(:each) block" do + reporter.should_receive(:example_finished) do |example, error| + example.should equal(example) + error.message.should eql("first") + end + example_group.run(options) + example_group.first_after_ran.should be_true + example_group.second_after_ran.should be_true + end + end + + describe ExampleGroup, "#run when first before(:each) block fails" do + it_should_behave_like "Spec::Example::ExampleGroup#run with failure in example" + + before do + class << example_group + attr_accessor :first_before_ran, :second_before_ran + end + example_group.first_before_ran = false + example_group.second_before_ran = false + + example_group.before(:each) do + self.class.first_before_ran = true + raise "first" + end + example_group.before(:each) do + self.class.second_before_ran = true + end + end + + it "should not run second before(:each)" do + reporter.should_receive(:example_finished) do |name, error| + error.message.should eql("first") + end + example_group.run(options) + example_group.first_before_ran.should be_true + example_group.second_before_ran.should be_false + end + end + + describe ExampleGroup, "#run when failure in after(:all)" do + it_should_behave_like "Spec::Example::ExampleGroup#run with failure in example" + + before do + ExampleGroup.after(:all) { raise NonStandardError, "in after(:all)" } + end + + it "should return false" do + example_group.run(options).should be_false + end + end + end + end + + describe ExampleGroup, "subclasses" do + it "should have access to the described_type" do + example_group = Class.new(ExampleGroupDouble).describe(Array) + example_group.__send__(:described_type).should == Array + end + + it "should concat descriptions when nested" do + example_group = Class.new(ExampleGroupDouble).describe(Array) + nested_group = example_group.describe("when empty") do; end + nested_group.description.to_s.should == "Array when empty" + end + end + end +end diff --git a/vendor/gems/gems/rspec-1.2.9/spec/spec/example/example_matcher_spec.rb b/vendor/gems/gems/rspec-1.2.9/spec/spec/example/example_matcher_spec.rb new file mode 100755 index 00000000..1a7e5da2 --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/spec/spec/example/example_matcher_spec.rb @@ -0,0 +1,86 @@ +require 'spec_helper' + +module Spec + module Example + describe ExampleMatcher, "#matches?" do + def match_examples(examples) + simple_matcher do |actual, matcher| + matcher.failure_message = "expected matcher.matches?(#{description.inspect}) to return true, got false" + matcher.negative_failure_message = "expected matcher.matches?(#{description.inspect}) to return false, got true" + actual.matches?(examples) + end + end + + it "should match correct example_group and example" do + matcher = ExampleMatcher.new("example_group", "example") + matcher.should match_examples(["example_group example"]) + end + + it "should not match wrong example" do + matcher = ExampleMatcher.new("example_group", "other example") + matcher.should_not match_examples(["example_group example"]) + end + + it "should not match wrong example_group" do + matcher = ExampleMatcher.new("other example_group", "example") + matcher.should_not match_examples(["example_group example"]) + end + + it "should match example only" do + matcher = ExampleMatcher.new("example_group", "example") + matcher.should match_examples(["example"]) + end + + it "should match example_group only" do + matcher = ExampleMatcher.new("example_group", "example") + matcher.should match_examples(["example_group"]) + end + + it "should match example_group ending with before(:all)" do + matcher = ExampleMatcher.new("example_group", "example") + matcher.should match_examples(["example_group before(:all)"]) + end + + it "should escape regexp chars" do + matcher = ExampleMatcher.new("(con|text)", "[example]") + matcher.should_not match_examples(["con p"]) + end + + it "should match when example_group is modularized" do + matcher = ExampleMatcher.new("MyModule::MyClass", "example") + matcher.should match_examples(["MyClass example"]) + end + end + + describe ExampleMatcher, "#matches? normal case" do + it "matches when passed in example matches" do + matcher = ExampleMatcher.new("Foo", "bar") + matcher.matches?(["no match", "Foo bar"]).should == true + end + + it "does not match when no passed in examples match" do + matcher = ExampleMatcher.new("Foo", "bar") + matcher.matches?(["no match1", "no match2"]).should == false + end + end + + describe ExampleMatcher, "#matches? where description has '::' in it" do + it "matches when passed in example matches" do + matcher = ExampleMatcher.new("Foo::Bar", "baz") + matcher.matches?(["no match", "Foo::Bar baz"]).should == true + end + + it "does not match when no passed in examples match" do + matcher = ExampleMatcher.new("Foo::Bar", "baz") + matcher.matches?(["no match1", "no match2"]).should == false + end + end + + describe ExampleMatcher, "called with nil example" do + it "does not puke" do + matcher = ExampleMatcher.new("Foo::Bar", nil) + matcher.matches?(["anything"]).should == false + end + end + end +end diff --git a/vendor/gems/gems/rspec-1.2.9/spec/spec/example/example_methods_spec.rb b/vendor/gems/gems/rspec-1.2.9/spec/spec/example/example_methods_spec.rb new file mode 100755 index 00000000..9a681095 --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/spec/spec/example/example_methods_spec.rb @@ -0,0 +1,162 @@ +require 'spec_helper' + +class Thing + attr_reader :arg + def initialize(arg=nil) + @arg = arg || :default + end + def ==(other) + @arg == other.arg + end + def eql?(other) + @arg == other.arg + end +end + +module Spec + module Example + describe ExampleMethods do + module ModuleThatIsReopened; end + + module Spec::Example::ExampleMethods + include ModuleThatIsReopened + end + + module ModuleThatIsReopened + def module_that_is_reopened_method; end + end + + describe "with an included module that is reopened" do + it "should have reopened methods" do + method(:module_that_is_reopened_method).should_not be_nil + end + end + + describe "#should" do + before(:each) do + @example_group = Class.new(ExampleGroupDouble) + @options = ::Spec::Runner::Options.new(StringIO.new, StringIO.new) + end + + context "in an ExampleGroup with an implicit subject" do + it "delegates matcher to the implied subject" do + @example_group.describe(::Thing) + @example_group.example { should == ::Thing.new(:default) } + @example_group.example { should eql(::Thing.new(:default)) } + @example_group.run(@options).should be_true + end + end + + context "in an ExampleGroup using an explicit subject" do + it "delegates matcher to the declared subject" do + @example_group.describe(::Thing) + @example_group.subject { ::Thing.new(:other) } + @example_group.example { should == ::Thing.new(:other) } + @example_group.example { should eql(::Thing.new(:other)) } + @example_group.run(@options).should be_true + end + end + + context "in an ExampleGroup using 'self' as an explicit subject" do + it "delegates matcher to the ExampleGroup" do + @example_group.describe(::Thing) + @example_group.subject { self } + @example_group.example { should == self } + @example_group.example { should eql(self) } + @example_group.example do + self.instance_eval("def method_ok?; true end") + should be_method_ok + end + @example_group.run(@options).should be_true + end + end + end + + describe "#should_not" do + before(:each) do + @example_group = Class.new(ExampleGroupDouble) + @options = ::Spec::Runner::Options.new(StringIO.new, StringIO.new) + end + + context "in an ExampleGroup with an implicit subject" do + it "delegates matcher to the implied subject" do + @example_group.describe(::Thing) + @example_group.example { should_not == ::Thing.new(:other) } + @example_group.example { should_not eql(::Thing.new(:other)) } + @example_group.run(@options).should be_true + end + end + + context "in an ExampleGroup using an explicit subject" do + it "delegates matcher to the declared subject" do + @example_group.describe(::Thing) + @example_group.subject { ::Thing.new(:other) } + @example_group.example { should_not == ::Thing.new(:default) } + @example_group.example { should_not eql(::Thing.new(:default)) } + @example_group.run(@options).should be_true + end + end + + context "in an ExampleGroup using 'self' as an explicit subject" do + it "delegates matcher to the ExampleGroup" do + @example_group.describe(::Thing) + @example_group.subject { self } + @example_group.example { should_not == ::Thing.new(:default) } + @example_group.example { should_not eql(::Thing.new(:default)) } + @example_group.example do + self.instance_eval("def method_ok?; false end") + should_not be_method_ok + end + @example_group.run(@options).should be_true + end + end + end + end + + describe "#options" do + it "should expose the options hash" do + example = ExampleGroupDouble.new ExampleProxy.new("name", :this => 'that') do; end + example.options[:this].should == 'that' + end + end + + describe "#set_instance_variables_from_hash" do + it "preserves the options" do + example = ExampleGroupDouble.new ExampleProxy.new("name", :this => 'that') do; end + example.set_instance_variables_from_hash({:@_options => {}}) + example.options[:this].should == 'that' + end + end + + describe "#description" do + it "returns the supplied description" do + example = ExampleGroupDouble.new ExampleProxy.new("name") do; end + example.description.should == "name" + end + it "returns the generated description if there is no description supplied" do + example = ExampleGroupDouble.new ExampleProxy.new do; end + Spec::Matchers.stub!(:generated_description).and_return('this message') + example.description.should == "this message" + end + it "warns if there is no supplied or generated description" do + example = ExampleGroupDouble.new ExampleProxy.new(nil, {}, "this backtrace") do; end + Spec::Matchers.stub!(:generated_description).and_return(nil) + Spec.should_receive(:warn).with("No description supplied for example declared on this backtrace") + example.description + end + end + + describe "#expect" do + it "aliases #should with #to on the proc" do + a = 3 + expect { a += 1 }.to change{a}.from(3).to(4) + end + + it "aliases #should_not with #to_not on the proc" do + a = 3 + expect { nil }.to_not change{a} + end + end + + end +end diff --git a/vendor/gems/gems/rspec-1.2.9/spec/spec/example/example_proxy_spec.rb b/vendor/gems/gems/rspec-1.2.9/spec/spec/example/example_proxy_spec.rb new file mode 100755 index 00000000..de845c9e --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/spec/spec/example/example_proxy_spec.rb @@ -0,0 +1,57 @@ +require 'spec_helper' + +module Spec + module Example + + describe ExampleProxy do + + describe "#description" do + it "provides the submitted description" do + proxy = ExampleProxy.new("the description") + proxy.description.should == "the description" + end + end + + describe "#update" do + it "updates the description" do + proxy = ExampleProxy.new("old description") + proxy.update("new description") + proxy.description.should == "new description" + end + end + + describe "#options" do + it "provides the submitted options" do + proxy = ExampleProxy.new(:ignore, {:these => :options}) + proxy.options.should == {:these => :options} + end + end + + describe "#backtrace (DEPRECATED - use #location)" do + before(:each) do + Spec.stub!(:deprecate) + end + + it "is deprecated" do + Spec.should_receive(:deprecate) + proxy = ExampleProxy.new(:ignore, {}, "path/to/location:37") + proxy.backtrace + end + + it "provides the location of the declaration of this group" do + proxy = ExampleProxy.new(:ignore, {}, "path/to/location:37") + proxy.backtrace.should == "path/to/location:37" + end + end + + describe "#location" do + it "provides the location of the declaration of this group" do + proxy = ExampleProxy.new(:ignore, {}, "path/to/location:37") + proxy.location.should == "path/to/location:37" + end + end + + end + + end +end diff --git a/vendor/gems/gems/rspec-1.2.9/spec/spec/example/helper_method_spec.rb b/vendor/gems/gems/rspec-1.2.9/spec/spec/example/helper_method_spec.rb new file mode 100755 index 00000000..3653aec7 --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/spec/spec/example/helper_method_spec.rb @@ -0,0 +1,24 @@ +require 'spec_helper' + +# This was added to prove that http://rspec.lighthouseapp.com/projects/5645/tickets/211 +# was fixed in ruby 1.9.1 + +module HelperMethodExample + describe "a helper method" do + def helper_method + "received call" + end + + it "is available to examples in the same group" do + helper_method.should == "received call" + end + + describe "from a nested group" do + it "is available to examples in a nested group" do + helper_method.should == "received call" + end + end + + end +end + diff --git a/vendor/gems/gems/rspec-1.2.9/spec/spec/example/nested_example_group_spec.rb b/vendor/gems/gems/rspec-1.2.9/spec/spec/example/nested_example_group_spec.rb new file mode 100755 index 00000000..83e4a9d7 --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/spec/spec/example/nested_example_group_spec.rb @@ -0,0 +1,71 @@ +require 'spec_helper' + +module Spec + module Example + describe 'Nested Example Groups' do + parent = self + + def count + @count ||= 0 + @count = @count + 1 + @count + end + + before(:all) do + count.should == 1 + end + + before(:all) do + count.should == 2 + end + + before(:each) do + count.should == 3 + end + + before(:each) do + count.should == 4 + end + + it "should run before(:all), before(:each), example, after(:each), after(:all) in order" do + count.should == 5 + end + + after(:each) do + count.should == 7 + end + + after(:each) do + count.should == 6 + end + + after(:all) do + count.should == 9 + end + + after(:all) do + count.should == 8 + end + + describe 'nested example group' do + self.superclass.should == parent + + it "should run all before and after callbacks" do + count.should == 5 + end + end + end + + describe "Nested Example Groups" do + describe "description options", :other_options => "other options" do + it "includes :location" do + self.class.options[:location].should match(/#{__FILE__}/) + end + + it "includes any other options" do + self.class.options[:other_options].should == "other options" + end + end + end + end +end diff --git a/vendor/gems/gems/rspec-1.2.9/spec/spec/example/pending_module_spec.rb b/vendor/gems/gems/rspec-1.2.9/spec/spec/example/pending_module_spec.rb new file mode 100755 index 00000000..275abc7d --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/spec/spec/example/pending_module_spec.rb @@ -0,0 +1,58 @@ +module Spec + module Example + describe Pending do + + context "when no block is supplied" do + it "raises an ExamplePendingError if no block is supplied" do + lambda { + pending "TODO" + }.should raise_error(ExamplePendingError, /TODO/) + end + end + + context "when the supplied block fails" do + it "raises an ExamplePendingError if a supplied block fails as expected" do + lambda { + pending "TODO" do + raise "oops" + end + }.should raise_error(ExamplePendingError, /TODO/) + end + end + + context "when the supplied block fails with a mock" do + it "raises an ExamplePendingError if a supplied block fails as expected with a mock" do + lambda { + pending "TODO" do + m = mock("thing") + m.should_receive(:foo) + m.rspec_verify + end + }.should raise_error(ExamplePendingError, /TODO/) + end + end + + context "when the supplied block passes" do + it "raises a PendingExampleFixedError" do + lambda { + pending "TODO" do + # success! + end + }.should raise_error(PendingExampleFixedError, /TODO/) + end + end + end + + describe ExamplePendingError do + it "should have the message provided" do + ExamplePendingError.new("a message").message.should == "a message" + end + end + + describe NotYetImplementedError do + it "should have the message 'Not Yet Implemented'" do + NotYetImplementedError.new.message.should == "Not Yet Implemented" + end + end + end +end diff --git a/vendor/gems/gems/rspec-1.2.9/spec/spec/example/predicate_matcher_spec.rb b/vendor/gems/gems/rspec-1.2.9/spec/spec/example/predicate_matcher_spec.rb new file mode 100755 index 00000000..a0185850 --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/spec/spec/example/predicate_matcher_spec.rb @@ -0,0 +1,41 @@ +require 'spec_helper' + +module Spec + module Example + class Fish + def can_swim?(distance_in_yards) + distance_in_yards < 1000 + end + end + + describe "predicate_matcher[method_on_object] = matcher_method" do + before(:each) do + Spec.stub!(:deprecate) + end + + it "is deprecated" do + Spec.should_receive(:deprecate) + group = ExampleGroupDouble.describe("foo") do + predicate_matchers[:swim] = :can_swim? + end + group.run(Spec::Runner::Options.new(StringIO.new, StringIO.new)) + end + + it "should match matcher_method if method_on_object returns true" do + group = ExampleGroupDouble.describe(Fish) do + predicate_matchers[:swim] = :can_swim? + it { should swim(100) } + end + group.run(Spec::Runner::Options.new(StringIO.new, StringIO.new)) + end + + it "should not match matcher_method if method_on_object returns false" do + group = ExampleGroupDouble.describe(Fish) do + predicate_matchers[:swim] = :can_swim? + it { should_not swim(1000) } + end + group.run(Spec::Runner::Options.new(StringIO.new, StringIO.new)) + end + end + end +end diff --git a/vendor/gems/gems/rspec-1.2.9/spec/spec/example/shared_example_group_spec.rb b/vendor/gems/gems/rspec-1.2.9/spec/spec/example/shared_example_group_spec.rb new file mode 100755 index 00000000..bbebbf15 --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/spec/spec/example/shared_example_group_spec.rb @@ -0,0 +1,257 @@ +require 'spec_helper' + +module Spec + module Example + describe ExampleGroup, "with :shared => true" do + with_sandboxed_options do + attr_reader :formatter, :example_group + before(:each) do + @formatter = Spec::Mocks::Mock.new("formatter", :null_object => true) + options.formatters << formatter + @example_group = Class.new(ExampleGroupDouble).describe("example_group") + class << example_group + public :include + end + end + + after(:each) do + @formatter.rspec_verify + @example_group = nil + Spec::Example::SharedExampleGroup.clear + end + + describe "#register" do + it "creates a new shared example group with the submitted args" do + block = lambda {|a|} + group = SharedExampleGroup.new("shared group") do end + Spec::Example::SharedExampleGroup.should_receive(:new).with("share me", &block).and_return(group) + Spec::Example::SharedExampleGroup.register("share me", &block) + end + + it "registers the shared example group" do + lambda do + Spec::Example::SharedExampleGroup.register "share me" do end + end.should change {Spec::Example::SharedExampleGroup.count}.by(1) + end + end + + it "complains when adding a second shared example_group with the same description" do + describe "shared example_group", :shared => true do + end + lambda do + describe "shared example_group", :shared => true do + end + end.should raise_error(ArgumentError) + end + + it "does NOT add the same group twice" do + lambda do + 2.times do + describe "shared example_group which gets loaded twice", :shared => true do + end + end + end.should change {Spec::Example::SharedExampleGroup.count}.by(1) + end + + it "does NOT complain when adding the same shared example_group again (i.e. file gets reloaded)" do + lambda do + 2.times do + describe "shared example_group which gets loaded twice", :shared => true do + end + end + end.should_not raise_error(ArgumentError) + end + + it "does NOT complain when adding the same shared example_group in same file with different absolute path" do + SharedExampleGroup.register( + "shared example_group", + :shared => true, + :location => "/my/spec/a/../shared.rb" + ) + SharedExampleGroup.register( + "shared example_group", + :shared => true, + :location => "/my/spec/b/../shared.rb" + ) + end + + it "complains when adding a different shared example_group with the same name in a different file with the same basename" do + SharedExampleGroup.register( + "shared example_group", + :shared => true, + :location => "/my/spec/a/shared.rb" + ) + lambda do + SharedExampleGroup.register( + "shared example_group", + :shared => true, + :location => "/my/spec/b/shared.rb" + ) + end.should raise_error(ArgumentError, /already exists/) + end + + it "adds examples to current example_group using it_should_behave_like" do + shared_example_group = SharedExampleGroup.register("shared example_group") do + it("shared example") {} + it("shared example 2") {} + end + + example_group.it("example") {} + example_group.number_of_examples.should == 1 + example_group.it_should_behave_like("shared example_group") + example_group.number_of_examples.should == 3 + end + + it "adds examples to from two shared groups" do + shared_example_group_1 = SharedExampleGroup.register("shared example_group 1") do + it("shared example 1") {} + end + + shared_example_group_1 = SharedExampleGroup.register("shared example_group 2") do + it("shared example 2") {} + end + + example_group.it("example") {} + example_group.number_of_examples.should == 1 + example_group.it_should_behave_like("shared example_group 1", "shared example_group 2") + example_group.number_of_examples.should == 3 + end + + it "adds examples to current example_group using include" do + shared_example_group = describe "all things", :shared => true do + it "should do stuff" do end + end + + example_group = describe "one thing" do + include shared_example_group + end + + example_group.number_of_examples.should == 1 + end + + it "adds examples to current example_group using it_should_behave_like with a module" do + ::AllThings = describe "all things", :shared => true do + it "should do stuff" do end + end + + example_group = describe "one thing" do + it_should_behave_like ::AllThings + end + + example_group.number_of_examples.should == 1 + end + + it "runs shared examples" do + shared_example_ran = false + shared_example_group = SharedExampleGroup.register("shared example_group") do + it("shared example") { shared_example_ran = true } + end + + example_ran = false + + example_group.it_should_behave_like("shared example_group") + example_group.it("example") {example_ran = true} + example_group.run(options) + example_ran.should be_true + shared_example_ran.should be_true + end + + it "runs before(:each) and after(:each) from shared example_group" do + shared_setup_ran = false + shared_teardown_ran = false + shared_example_group = SharedExampleGroup.register("shared example_group") do + before(:each) { shared_setup_ran = true } + after(:each) { shared_teardown_ran = true } + it("shared example") { shared_example_ran = true } + end + + example_ran = false + + example_group.it_should_behave_like("shared example_group") + example_group.it("example") {example_ran = true} + example_group.run(options) + example_ran.should be_true + shared_setup_ran.should be_true + shared_teardown_ran.should be_true + end + + it "should run before(:all) and after(:all) only once from shared example_group" do + shared_before_all_run_count = 0 + shared_after_all_run_count = 0 + shared_example_group = SharedExampleGroup.register("shared example_group") do + before(:all) { shared_before_all_run_count += 1} + after(:all) { shared_after_all_run_count += 1} + it("shared example") { shared_example_ran = true } + end + + example_ran = false + + example_group.it_should_behave_like("shared example_group") + example_group.it("example") {example_ran = true} + example_group.run(options) + example_ran.should be_true + shared_before_all_run_count.should == 1 + shared_after_all_run_count.should == 1 + end + + it "should include modules, included into shared example_group, into current example_group" do + @formatter.should_receive(:add_example_group).with(any_args) + + shared_example_group = SharedExampleGroup.register("shared example_group") do + it("shared example") { shared_example_ran = true } + end + + mod1_method_called = false + mod1 = Module.new do + define_method :mod1_method do + mod1_method_called = true + end + end + + mod2_method_called = false + mod2 = Module.new do + define_method :mod2_method do + mod2_method_called = true + end + end + + shared_example_group.__send__ :include, mod2 + + example_group.it_should_behave_like("shared example_group") + example_group.include mod1 + + example_group.it("test") do + mod1_method + mod2_method + end + example_group.run(options) + mod1_method_called.should be_true + mod2_method_called.should be_true + end + + it "should make methods defined in the shared example_group available in consuming example_group" do + shared_example_group = SharedExampleGroup.register("shared example_group xyz") do + def a_shared_helper_method + "this got defined in a shared example_group" + end + end + example_group.it_should_behave_like("shared example_group xyz") + success = false + example_group.it("should access a_shared_helper_method") do + a_shared_helper_method + success = true + end + example_group.run(options) + success.should be_true + end + + it "should raise when named shared example_group can not be found" do + lambda { + example_group.it_should_behave_like("non-existent shared example group") + violated + }.should raise_error("Shared Example Group 'non-existent shared example group' can not be found") + end + end + end + end +end diff --git a/vendor/gems/gems/rspec-1.2.9/spec/spec/example/subclassing_example_group_spec.rb b/vendor/gems/gems/rspec-1.2.9/spec/spec/example/subclassing_example_group_spec.rb new file mode 100755 index 00000000..969014a7 --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/spec/spec/example/subclassing_example_group_spec.rb @@ -0,0 +1,25 @@ +require 'spec_helper' + +module Spec + module Example + class GrandParentExampleGroup < Spec::Example::ExampleGroup + describe "Grandparent ExampleGroup" + end + + class ParentExampleGroup < GrandParentExampleGroup + describe "Parent ExampleGroup" + it "should bar" do + end + end + + class ChildExampleGroup < ParentExampleGroup + describe "Child ExampleGroup" + it "should bam" do + end + end + + describe ChildExampleGroup do + + end + end +end diff --git a/vendor/gems/gems/rspec-1.2.9/spec/spec/example/subject_spec.rb b/vendor/gems/gems/rspec-1.2.9/spec/spec/example/subject_spec.rb new file mode 100755 index 00000000..c0e4fd80 --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/spec/spec/example/subject_spec.rb @@ -0,0 +1,103 @@ +require 'spec_helper' + +module Spec + module Example + describe "implicit subject" do + describe "with a class" do + it "returns an instance of the class" do + group = Class.new(ExampleGroupDouble).describe(Array) + example = group.new(ExampleProxy.new) + example.subject.should == [] + end + end + + describe "with a Module" do + it "returns the Module" do + group = Class.new(ExampleGroupDouble).describe(Enumerable) + example = group.new(ExampleProxy.new) + example.subject.should == Enumerable + end + end + + describe "with a string" do + it "return the string" do + group = Class.new(ExampleGroupDouble).describe('foo') + example = group.new(ExampleProxy.new) + example.subject.should == 'foo' + end + end + + describe "with a number" do + it "returns the number" do + group = Class.new(ExampleGroupDouble).describe(15) + example = group.new(ExampleProxy.new) + example.subject.should == 15 + end + end + + end + + describe "explicit subject" do + describe "defined in a top level group" do + it "replaces the implicit subject in that group" do + group = Class.new(ExampleGroupDouble).describe(Array) + group.subject { [1,2,3] } + example = group.new(ExampleProxy.new) + example.subject.should == [1,2,3] + end + end + + describe "defined in a top level group" do + before(:each) do + @group = Class.new do + extend Spec::Example::Subject::ExampleGroupMethods + include Spec::Example::Subject::ExampleMethods + class << self + def described_class + Array + end + end + def described_class + self.class.described_class + end + + subject { + [1,2,3] + } + end + end + + it "is available in a nested group (subclass)" do + nested_group = Class.new(@group) + + example = nested_group.new + example.subject.should == [1,2,3] + end + + it "is available in a doubly nested group (subclass)" do + nested_group = Class.new(@group) + doubly_nested_group = Class.new(nested_group) + + example = doubly_nested_group.new + example.subject.should == [1,2,3] + end + end + end + + describe ".its (to access subject's attributes)" do + with_sandboxed_options do + it "passes when expectation should pass" do + group = Class.new(ExampleGroupDouble).describe(Array) + child = group.its(:length) { should == 0 } + child.run(options).should == true + end + + it "fails when expectation should fail" do + group = Class.new(ExampleGroupDouble).describe(Array) + child = group.its(:length) { should == 1 } + child.run(options).should == false + end + end + end + end +end diff --git a/vendor/gems/gems/rspec-1.2.9/spec/spec/expectations/differs/default_spec.rb b/vendor/gems/gems/rspec-1.2.9/spec/spec/expectations/differs/default_spec.rb new file mode 100755 index 00000000..3bc3c45a --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/spec/spec/expectations/differs/default_spec.rb @@ -0,0 +1,194 @@ +require 'spec_helper' + +module Spec + module Fixtures + class Animal + def initialize(name,species) + @name,@species = name,species + end + + def inspect + <<-EOA + + EOA + end + end + end +end + +describe "Diff" do + before(:each) do + @options = ::Spec::Runner::Options.new(StringIO.new, StringIO.new) + @differ = Spec::Expectations::Differs::Default.new(@options) + end + + it "should output unified diff of two strings" do + expected="foo\nbar\nzap\nthis\nis\nsoo\nvery\nvery\nequal\ninsert\na\nline\n" + actual="foo\nzap\nbar\nthis\nis\nsoo\nvery\nvery\nequal\ninsert\na\nanother\nline\n" + expected_diff= <<'EOD' + + +@@ -1,6 +1,6 @@ + foo +-zap + bar ++zap + this + is + soo +@@ -9,6 +9,5 @@ + equal + insert + a +-another + line +EOD + + diff = @differ.diff_as_string(expected, actual) + diff.should eql(expected_diff) + end + + it "should output unified diff message of two arrays" do + expected = [ :foo, 'bar', :baz, 'quux', :metasyntactic, 'variable', :delta, 'charlie', :width, 'quite wide' ] + actual = [ :foo, 'bar', :baz, 'quux', :metasyntactic, 'variable', :delta, 'tango' , :width, 'very wide' ] + + expected_diff = <<'EOD' + + +@@ -5,7 +5,7 @@ + :metasyntactic, + "variable", + :delta, +- "tango", ++ "charlie", + :width, +- "very wide"] ++ "quite wide"] +EOD + + + diff = @differ.diff_as_object(expected,actual) + diff.should == expected_diff + end + + it "should output a friendly message if comparing simple hashes" do + expected = { "foo" => "bar" } + actual = { "foo" => "baz" } + + expected_diff = <<'EOD' + +Expected the key "foo" to be "bar", but was "baz" + +EOD + + + diff = @differ.diff_as_hash(actual, expected) + diff.should == expected_diff + end + + + it "should output a friendly message if comparing simple hashes that contain different keys" do + expected = { "bar" => "foo" } + actual = { "foo" => "baz" } + + expected_diff = <<'EOD' + +Expected hash contains keys that target hash does not: ["bar"] +Target hash contains keys that expected hash does not: ["foo"] +Expected the key "bar" to be "foo", but was nil + +EOD + + + diff = @differ.diff_as_hash(actual, expected) + diff.should == expected_diff + end + + it "should output diff message if the hash is complex (containing Array or Hash)" do + expected = { "foo" => "bar", "fizz" => [1, 2, 3] } + actual = { "foo" => "baz", "fizz" => [1, 2] } + + # UGH - 1.8.7 seems to order hash keys differently than the others + if RUBY_VERSION =~ /^1.8.7/ + expected_diff = <<'EOD' + +Expected the key "fizz" to be [1, 2, 3], but was [1, 2] +Expected the key "foo" to be "bar", but was "baz" + + +@@ -1,2 +1,2 @@ +-{"fizz"=>[1, 2, 3], "foo"=>"bar"} ++{"fizz"=>[1, 2], "foo"=>"baz"} +EOD + else + expected_diff = <<'EOD' + +Expected the key "fizz" to be [1, 2, 3], but was [1, 2] +Expected the key "foo" to be "bar", but was "baz" + + +@@ -1,2 +1,2 @@ +-{"foo"=>"bar", "fizz"=>[1, 2, 3]} ++{"foo"=>"baz", "fizz"=>[1, 2]} +EOD + end + + diff = @differ.diff_as_hash(actual, expected) + diff.should == expected_diff + end + + + it "should output unified diff message of two objects" do + expected = Spec::Fixtures::Animal.new "bob", "giraffe" + actual = Spec::Fixtures::Animal.new "bob", "tortoise" + + expected_diff = <<'EOD' + +@@ -1,5 +1,5 @@ + +EOD + + diff = @differ.diff_as_object(expected,actual) + diff.should == expected_diff + end + +end + + +describe "Diff in context format" do + before(:each) do + @options = Spec::Runner::Options.new(StringIO.new, StringIO.new) + @options.diff_format = :context + @differ = Spec::Expectations::Differs::Default.new(@options) + end + + it "should output unified diff message of two objects" do + expected = Spec::Fixtures::Animal.new "bob", "giraffe" + actual = Spec::Fixtures::Animal.new "bob", "tortoise" + + expected_diff = <<'EOD' + +*************** +*** 1,5 **** + +--- 1,5 ---- + +EOD + + diff = @differ.diff_as_object(expected,actual) + diff.should == expected_diff + end +end diff --git a/vendor/gems/gems/rspec-1.2.9/spec/spec/expectations/extensions/kernel_spec.rb b/vendor/gems/gems/rspec-1.2.9/spec/spec/expectations/extensions/kernel_spec.rb new file mode 100755 index 00000000..9a0ed3ce --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/spec/spec/expectations/extensions/kernel_spec.rb @@ -0,0 +1,45 @@ +require 'spec_helper' + +describe Object, "#should" do + before(:each) do + @target = "target" + @matcher = mock("matcher") + @matcher.stub!(:matches?).and_return(true) + @matcher.stub!(:failure_message_for_should) + end + + it "accepts and interacts with a matcher" do + @matcher.should_receive(:matches?).with(@target).and_return(true) + @target.should @matcher + end + + it "asks for a failure_message_for_should when matches? returns false" do + @matcher.should_receive(:matches?).with(@target).and_return(false) + @matcher.should_receive(:failure_message_for_should).and_return("the failure message") + lambda { + @target.should @matcher + }.should fail_with("the failure message") + end +end + +describe Object, "#should_not" do + before(:each) do + @target = "target" + @matcher = mock("matcher") + end + + it "accepts and interacts with a matcher" do + @matcher.should_receive(:matches?).with(@target).and_return(false) + @matcher.stub!(:failure_message_for_should_not) + + @target.should_not @matcher + end + + it "asks for a failure_message_for_should_not when matches? returns true" do + @matcher.should_receive(:matches?).with(@target).and_return(true) + @matcher.should_receive(:failure_message_for_should_not).and_return("the failure message for should not") + lambda { + @target.should_not @matcher + }.should fail_with("the failure message for should not") + end +end diff --git a/vendor/gems/gems/rspec-1.2.9/spec/spec/expectations/fail_with_spec.rb b/vendor/gems/gems/rspec-1.2.9/spec/spec/expectations/fail_with_spec.rb new file mode 100755 index 00000000..639b7f95 --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/spec/spec/expectations/fail_with_spec.rb @@ -0,0 +1,96 @@ +require 'spec_helper' + +describe Spec::Expectations, "#fail_with with no diff" do + before(:each) do + @old_differ = Spec::Expectations.differ + Spec::Expectations.differ = nil + end + + it "should handle just a message" do + lambda { + Spec::Expectations.fail_with "the message" + }.should fail_with("the message") + end + + after(:each) do + Spec::Expectations.differ = @old_differ + end +end + +describe Spec::Expectations, "#fail_with with Array" do + before(:each) do + Spec.stub!(:warn) + end + + it "is deprecated" do + Spec.should_receive(:warn) + lambda { + Spec::Expectations.fail_with ["message", "expected", "actual"] + }.should raise_error + end +end + +describe Spec::Expectations, "#fail_with with diff" do + before(:each) do + @old_differ = Spec::Expectations.differ + @differ = mock("differ") + Spec::Expectations.differ = @differ + end + + it "should not call differ if no expected/actual" do + lambda { + Spec::Expectations.fail_with "the message" + }.should fail_with("the message") + end + + it "should call differ if expected/actual are presented separately" do + @differ.should_receive(:diff_as_string).and_return("diff") + lambda { + Spec::Expectations.fail_with "the message", "expected", "actual" + }.should fail_with("the message\n\n Diff:diff") + end + + it "should call differ if expected/actual are not strings" do + @differ.should_receive(:diff_as_object).and_return("diff") + lambda { + Spec::Expectations.fail_with "the message", :expected, :actual + }.should fail_with("the message\n\n Diff:diff") + end + + it "should call differ if expected/actual are both hashes" do + @differ.should_receive(:diff_as_hash).and_return("diff") + lambda { + Spec::Expectations.fail_with "the message", {:a => :b}, {:a => 'b'} + }.should fail_with("the message\n\n Diff:diff") + end + + it "should not call differ if expected or actual are procs" do + @differ.should_not_receive(:diff_as_string) + @differ.should_not_receive(:diff_as_object) + @differ.should_not_receive(:diff_as_hash) + lambda { + Spec::Expectations.fail_with "the message", lambda {}, lambda {} + }.should fail_with("the message") + end + + after(:each) do + Spec::Expectations.differ = @old_differ + end +end + +describe Spec::Expectations, "#fail_with with a nil message" do + before(:each) do + @old_differ = Spec::Expectations.differ + Spec::Expectations.differ = nil + end + + it "should handle just a message" do + lambda { + Spec::Expectations.fail_with nil + }.should raise_error(ArgumentError, /Failure message is nil\. Does your matcher define the appropriate failure_message_for_\* method to return a string\?/) + end + + after(:each) do + Spec::Expectations.differ = @old_differ + end +end diff --git a/vendor/gems/gems/rspec-1.2.9/spec/spec/expectations/handler_spec.rb b/vendor/gems/gems/rspec-1.2.9/spec/spec/expectations/handler_spec.rb new file mode 100755 index 00000000..e7d6a6ed --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/spec/spec/expectations/handler_spec.rb @@ -0,0 +1,206 @@ +require 'spec_helper' + +module ExampleExpectations + + class ArbitraryMatcher + def initialize(*args, &block) + if args.last.is_a? Hash + @expected = args.last[:expected] + end + @expected = block.call if block + @block = block + end + + def matches?(target) + @target = target + return @expected == target + end + + def with(new_value) + @expected = new_value + self + end + + def failure_message + "expected #{@expected}, got #{@target}" + end + + def negative_failure_message + "expected not #{@expected}, got #{@target}" + end + end + + class PositiveOnlyMatcher < ArbitraryMatcher + undef negative_failure_message rescue nil + end + + def arbitrary_matcher(*args, &block) + ArbitraryMatcher.new(*args, &block) + end + + def positive_only_matcher(*args, &block) + PositiveOnlyMatcher.new(*args, &block) + end + +end + +module Spec + module Expectations + describe PositiveExpectationHandler do + describe "#handle_matcher" do + it "asks the matcher if it matches" do + matcher = mock("matcher") + actual = Object.new + matcher.should_receive(:matches?).with(actual).and_return(true) + Spec::Expectations::PositiveExpectationHandler.handle_matcher(actual, matcher) + end + + it "returns the match value" do + matcher = mock("matcher") + actual = Object.new + matcher.should_receive(:matches?).with(actual).and_return(:this_value) + Spec::Expectations::PositiveExpectationHandler.handle_matcher(actual, matcher).should == :this_value + end + + it "calls failure_message_for_should if the matcher implements it" do + matcher = mock("matcher", :failure_message_for_should => "message", :matches? => false) + actual = Object.new + + ::Spec::Expectations.should_receive(:fail_with).with("message") + + Spec::Expectations::PositiveExpectationHandler.handle_matcher(actual, matcher) + end + + it "calls fail if matcher.diffable?" do + matcher = mock("matcher", + :diffable? => true, + :failure_message_for_should => "message", + :matches? => false, + :expected => [1], + :actual => 2 + ) + actual = Object.new + + ::Spec::Expectations.should_receive(:fail_with).with("message", 1, 2) + + Spec::Expectations::PositiveExpectationHandler.handle_matcher(actual, matcher) + end + + it "calls failure_message if the matcher does not implement failure_message_for_should" do + matcher = mock("matcher", :failure_message => "message", :matches? => false) + actual = Object.new + + ::Spec::Expectations.should_receive(:fail_with).with("message") + + Spec::Expectations::PositiveExpectationHandler.handle_matcher(actual, matcher) + + end + + it "appends the :or message in the options hash passed to should" do + matcher = mock("matcher", :failure_message_for_should => "message", :matches? => false) + actual = Object.new + + ::Spec::Expectations.should_receive(:fail_with).with("custom") + + Spec::Expectations::PositiveExpectationHandler.handle_matcher(actual, matcher, "custom") + end + end + end + + describe NegativeExpectationHandler do + describe "#handle_matcher" do + it "asks the matcher if it doesn't match when the matcher responds to #does_not_match?" do + matcher = mock("matcher", :does_not_match? => true, :negative_failure_message => nil) + actual = Object.new + matcher.should_receive(:does_not_match?).with(actual).and_return(true) + Spec::Expectations::NegativeExpectationHandler.handle_matcher(actual, matcher) + end + + it "asks the matcher if it matches when the matcher doesn't respond to #does_not_match?" do + matcher = mock("matcher") + actual = Object.new + matcher.stub!(:negative_failure_message) + matcher.should_receive(:matches?).with(actual).and_return(false) + Spec::Expectations::NegativeExpectationHandler.handle_matcher(actual, matcher) + end + + it "returns the match value" do + matcher = mock("matcher") + actual = Object.new + matcher.should_receive(:matches?).with(actual).and_return(false) + matcher.stub!(:negative_failure_message).and_return("ignore") + Spec::Expectations::NegativeExpectationHandler.handle_matcher(actual, matcher).should be_false + end + + + it "calls failure_message_for_should_not if the matcher implements it" do + matcher = mock("matcher", :failure_message_for_should_not => "message", :matches? => true) + actual = Object.new + + ::Spec::Expectations.should_receive(:fail_with).with("message") + + Spec::Expectations::NegativeExpectationHandler.handle_matcher(actual, matcher) + + end + + it "calls negative_failure_message if the matcher does not implement failure_message_for_should_not" do + matcher = mock("matcher", :negative_failure_message => "message", :matches? => true) + actual = Object.new + + ::Spec::Expectations.should_receive(:fail_with).with("message") + + Spec::Expectations::NegativeExpectationHandler.handle_matcher(actual, matcher) + + end + + + it "calls fail if matcher.diffable?" do + matcher = mock("matcher", + :diffable? => true, + :failure_message_for_should_not => "message", + :matches? => true, + :expected => [1], + :actual => 2 + ) + actual = Object.new + + ::Spec::Expectations.should_receive(:fail_with).with("message", 1, 2) + + Spec::Expectations::NegativeExpectationHandler.handle_matcher(actual, matcher) + end + + it "appends the :or message in the options hash passed to should" do + matcher = mock("matcher", :failure_message_for_should_not => "message", :matches? => true) + actual = Object.new + + ::Spec::Expectations.should_receive(:fail_with).with("custom") + + Spec::Expectations::NegativeExpectationHandler.handle_matcher(actual, matcher, "custom") + end + + end + end + + describe PositiveExpectationHandler do + include ExampleExpectations + + it "should handle submitted args" do + 5.should arbitrary_matcher(:expected => 5) + 5.should arbitrary_matcher(:expected => "wrong").with(5) + lambda { 5.should arbitrary_matcher(:expected => 4) }.should fail_with("expected 4, got 5") + lambda { 5.should arbitrary_matcher(:expected => 5).with(4) }.should fail_with("expected 4, got 5") + 5.should_not arbitrary_matcher(:expected => 4) + 5.should_not arbitrary_matcher(:expected => 5).with(4) + lambda { 5.should_not arbitrary_matcher(:expected => 5) }.should fail_with("expected not 5, got 5") + lambda { 5.should_not arbitrary_matcher(:expected => 4).with(5) }.should fail_with("expected not 5, got 5") + end + + it "should handle the submitted block" do + 5.should arbitrary_matcher { 5 } + 5.should arbitrary_matcher(:expected => 4) { 5 } + 5.should arbitrary_matcher(:expected => 4).with(5) { 3 } + end + + end + end +end diff --git a/vendor/gems/gems/rspec-1.2.9/spec/spec/expectations/wrap_expectation_spec.rb b/vendor/gems/gems/rspec-1.2.9/spec/spec/expectations/wrap_expectation_spec.rb new file mode 100755 index 00000000..9ef7d007 --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/spec/spec/expectations/wrap_expectation_spec.rb @@ -0,0 +1,30 @@ +require 'spec_helper' + +module Spec + module Matchers + describe "wrap_expectation" do + + def stub_matcher + @_stub_matcher ||= simple_matcher do + end + end + + def failing_matcher + @_failing_matcher ||= simple_matcher do + 1.should == 2 + end + end + + it "should return true if there is no error" do + wrap_expectation stub_matcher do + end.should be_true + end + + it "should return false if there is an error" do + wrap_expectation failing_matcher do + raise "error" + end.should be_false + end + end + end +end \ No newline at end of file diff --git a/vendor/gems/gems/rspec-1.2.9/spec/spec/interop/test/unit/resources/spec_that_fails.rb b/vendor/gems/gems/rspec-1.2.9/spec/spec/interop/test/unit/resources/spec_that_fails.rb new file mode 100755 index 00000000..b2c48410 --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/spec/spec/interop/test/unit/resources/spec_that_fails.rb @@ -0,0 +1,10 @@ +rspec_lib = File.dirname(__FILE__) + "/../../../../../../lib" +$:.unshift rspec_lib unless $:.include?(rspec_lib) +require 'spec/autorun' +require 'spec/test/unit' + +describe "example group with failures" do + it "should fail" do + false.should be_true + end +end \ No newline at end of file diff --git a/vendor/gems/gems/rspec-1.2.9/spec/spec/interop/test/unit/resources/spec_that_passes.rb b/vendor/gems/gems/rspec-1.2.9/spec/spec/interop/test/unit/resources/spec_that_passes.rb new file mode 100755 index 00000000..4203af3a --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/spec/spec/interop/test/unit/resources/spec_that_passes.rb @@ -0,0 +1,10 @@ +rspec_lib = File.dirname(__FILE__) + "/../../../../../../lib" +$:.unshift rspec_lib unless $:.include?(rspec_lib) +require 'spec/autorun' +require 'spec/test/unit' + +describe "example group with passing examples" do + it "should pass" do + true.should be_true + end +end \ No newline at end of file diff --git a/vendor/gems/gems/rspec-1.2.9/spec/spec/interop/test/unit/resources/spec_with_errors.rb b/vendor/gems/gems/rspec-1.2.9/spec/spec/interop/test/unit/resources/spec_with_errors.rb new file mode 100755 index 00000000..a18ce72f --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/spec/spec/interop/test/unit/resources/spec_with_errors.rb @@ -0,0 +1,10 @@ +rspec_lib = File.dirname(__FILE__) + "/../../../../../../lib" +$:.unshift rspec_lib unless $:.include?(rspec_lib) +require 'spec/autorun' +require 'spec/test/unit' + +describe "example group with errors" do + it "should raise errors" do + raise "error raised in example group with errors" + end +end \ No newline at end of file diff --git a/vendor/gems/gems/rspec-1.2.9/spec/spec/interop/test/unit/resources/spec_with_options_hash.rb b/vendor/gems/gems/rspec-1.2.9/spec/spec/interop/test/unit/resources/spec_with_options_hash.rb new file mode 100755 index 00000000..7dc344bd --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/spec/spec/interop/test/unit/resources/spec_with_options_hash.rb @@ -0,0 +1,13 @@ +rspec_lib = File.dirname(__FILE__) + "/../../../../../../lib" +$:.unshift rspec_lib unless $:.include?(rspec_lib) +require 'spec/autorun' +require 'spec/test/unit' + +describe "options hash" do + describe "#options" do + it "should expose the options hash" do + group = describe("group", :this => 'hash') {} + group.options[:this].should == 'hash' + end + end +end \ No newline at end of file diff --git a/vendor/gems/gems/rspec-1.2.9/spec/spec/interop/test/unit/resources/test_case_that_fails.rb b/vendor/gems/gems/rspec-1.2.9/spec/spec/interop/test/unit/resources/test_case_that_fails.rb new file mode 100755 index 00000000..0a977cb1 --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/spec/spec/interop/test/unit/resources/test_case_that_fails.rb @@ -0,0 +1,10 @@ +rspec_lib = File.dirname(__FILE__) + "/../../../../../../lib" +$:.unshift rspec_lib unless $:.include?(rspec_lib) +require 'spec/autorun' +require 'spec/test/unit' + +class TestCaseThatFails < Test::Unit::TestCase + def test_that_fails + false.should be_true + end +end \ No newline at end of file diff --git a/vendor/gems/gems/rspec-1.2.9/spec/spec/interop/test/unit/resources/test_case_that_passes.rb b/vendor/gems/gems/rspec-1.2.9/spec/spec/interop/test/unit/resources/test_case_that_passes.rb new file mode 100755 index 00000000..078a5f77 --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/spec/spec/interop/test/unit/resources/test_case_that_passes.rb @@ -0,0 +1,10 @@ +rspec_lib = File.dirname(__FILE__) + "/../../../../../../lib" +$:.unshift rspec_lib unless $:.include?(rspec_lib) +require 'spec/autorun' +require 'spec/test/unit' + +class TestCaseThatPasses < Test::Unit::TestCase + def test_that_passes + true.should be_true + end +end \ No newline at end of file diff --git a/vendor/gems/gems/rspec-1.2.9/spec/spec/interop/test/unit/resources/test_case_with_errors.rb b/vendor/gems/gems/rspec-1.2.9/spec/spec/interop/test/unit/resources/test_case_with_errors.rb new file mode 100755 index 00000000..dc5f52e4 --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/spec/spec/interop/test/unit/resources/test_case_with_errors.rb @@ -0,0 +1,10 @@ +rspec_lib = File.dirname(__FILE__) + "/../../../../../../lib" +$:.unshift rspec_lib unless $:.include?(rspec_lib) +require 'spec/autorun' +require 'spec/test/unit' + +class TestCaseWithErrors < Test::Unit::TestCase + def test_with_error + raise "error raised in TestCaseWithErrors" + end +end \ No newline at end of file diff --git a/vendor/gems/gems/rspec-1.2.9/spec/spec/interop/test/unit/resources/test_case_with_various_names.rb b/vendor/gems/gems/rspec-1.2.9/spec/spec/interop/test/unit/resources/test_case_with_various_names.rb new file mode 100755 index 00000000..186db49d --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/spec/spec/interop/test/unit/resources/test_case_with_various_names.rb @@ -0,0 +1,22 @@ +rspec_lib = File.dirname(__FILE__) + "/../../../../../../lib" +$:.unshift rspec_lib unless $:.include?(rspec_lib) +require 'spec/autorun' +require 'spec/test/unit' + +class TestCaseThatPasses < Test::Unit::TestCase + def test_should_allow_underscore + assert true + end + + def testShouldAllowUppercaseLetter + assert true + end + + def testshouldallowlowercaseletter + assert true + end + + define_method :"test: should allow punctuation" do + assert true + end +end diff --git a/vendor/gems/gems/rspec-1.2.9/spec/spec/interop/test/unit/resources/testsuite_adapter_spec_with_test_unit.rb b/vendor/gems/gems/rspec-1.2.9/spec/spec/interop/test/unit/resources/testsuite_adapter_spec_with_test_unit.rb new file mode 100755 index 00000000..5182b820 --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/spec/spec/interop/test/unit/resources/testsuite_adapter_spec_with_test_unit.rb @@ -0,0 +1,38 @@ +rspec_lib = File.dirname(__FILE__) + "/../../../../../../lib" +$:.unshift rspec_lib unless $:.include?(rspec_lib) +require 'spec/autorun' +require 'spec/test/unit' + +module Test + module Unit + describe TestSuiteAdapter do + def create_adapter(group) + TestSuiteAdapter.new(group) + end + + describe "#size" do + it "should return the number of examples in the example group" do + group = Class.new(Spec::ExampleGroup) do + describe("some examples") + it("bar") {} + it("baz") {} + end + adapter = create_adapter(group) + adapter.size.should == 2 + end + end + + describe "#delete" do + it "should do nothing" do + group = Class.new(Spec::ExampleGroup) do + describe("Some Examples") + it("does something") {} + end + adapter = create_adapter(group) + adapter.delete(adapter.examples.first) + adapter.should be_empty + end + end + end + end +end diff --git a/vendor/gems/gems/rspec-1.2.9/spec/spec/interop/test/unit/spec_spec.rb b/vendor/gems/gems/rspec-1.2.9/spec/spec/interop/test/unit/spec_spec.rb new file mode 100755 index 00000000..83ff5226 --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/spec/spec/interop/test/unit/spec_spec.rb @@ -0,0 +1,48 @@ +require 'spec/interop/test/unit/test_unit_spec_helper' + +describe "ExampleGroup with test/unit/interop" do + include TestUnitSpecHelper + + describe "with passing examples" do + it "should output 0 failures" do + output = ruby("#{resources}/spec_that_passes.rb") + output.should include("1 example, 0 failures") + end + + it "should return an exit code of 0" do + ruby("#{resources}/spec_that_passes.rb") + $?.should == 0 + end + end + + describe "with failing examples" do + it "should output 1 failure" do + output = ruby("#{resources}/spec_that_fails.rb") + output.should include("1 example, 1 failure") + end + + it "should return an exit code of 256" do + ruby("#{resources}/spec_that_fails.rb") + $?.should == 256 + end + end + + describe "with example that raises an error" do + it "should output 1 failure" do + output = ruby("#{resources}/spec_with_errors.rb") + output.should include("1 example, 1 failure") + end + + it "should return an exit code of 256" do + ruby("#{resources}/spec_with_errors.rb") + $?.should == 256 + end + end + + describe "options hash" do + it "should be exposed" do + output = ruby("#{resources}/spec_with_options_hash.rb") + output.should include("1 example, 0 failures") + end + end +end \ No newline at end of file diff --git a/vendor/gems/gems/rspec-1.2.9/spec/spec/interop/test/unit/test_unit_spec_helper.rb b/vendor/gems/gems/rspec-1.2.9/spec/spec/interop/test/unit/test_unit_spec_helper.rb new file mode 100755 index 00000000..1f6c223e --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/spec/spec/interop/test/unit/test_unit_spec_helper.rb @@ -0,0 +1,18 @@ +require 'spec_helper' +require 'ruby_forker' + +module TestUnitSpecHelper + include RubyForker + + def resources + File.dirname(__FILE__) + "/resources" + end + + def run_script(file_name) + output = ruby(file_name) + if !$?.success? || output.include?("FAILED") || output.include?("Error") + raise output + end + output + end +end \ No newline at end of file diff --git a/vendor/gems/gems/rspec-1.2.9/spec/spec/interop/test/unit/testcase_spec.rb b/vendor/gems/gems/rspec-1.2.9/spec/spec/interop/test/unit/testcase_spec.rb new file mode 100755 index 00000000..c1b25260 --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/spec/spec/interop/test/unit/testcase_spec.rb @@ -0,0 +1,50 @@ +require 'spec/interop/test/unit/test_unit_spec_helper' + +describe "Test::Unit::TestCase" do + include TestUnitSpecHelper + + before(:each) do + @dir = File.dirname(__FILE__) + "/resources" + end + + describe "with passing test case" do + it "should output 0 failures" do + output = ruby("#{@dir}/test_case_that_passes.rb") + output.should include("1 example, 0 failures") + end + + it "should return an exit code of 0" do + ruby("#{@dir}/test_case_that_passes.rb") + $?.should == 0 + end + end + + describe "with failing test case" do + it "should output 1 failure" do + output = ruby("#{@dir}/test_case_that_fails.rb") + output.should include("1 example, 1 failure") + end + + it "should return an exit code of 256" do + ruby("#{@dir}/test_case_that_fails.rb") + $?.should == 256 + end + end + + describe "with test case that raises an error" do + it "should output 1 failure" do + output = ruby("#{@dir}/test_case_with_errors.rb") + output.should include("1 example, 1 failure") + end + + it "should return an exit code of 256" do + ruby("#{@dir}/test_case_with_errors.rb") + $?.should == 256 + end + end + + it "should find all Test::Unit test methods" do + output = ruby("#{@dir}/test_case_with_various_names.rb") + output.should include("4 examples, 0 failures") + end +end diff --git a/vendor/gems/gems/rspec-1.2.9/spec/spec/interop/test/unit/testsuite_adapter_spec.rb b/vendor/gems/gems/rspec-1.2.9/spec/spec/interop/test/unit/testsuite_adapter_spec.rb new file mode 100755 index 00000000..59743039 --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/spec/spec/interop/test/unit/testsuite_adapter_spec.rb @@ -0,0 +1,9 @@ +require 'spec/interop/test/unit/test_unit_spec_helper' + +describe "TestSuiteAdapter" do + include TestUnitSpecHelper + it "should pass" do + dir = File.dirname(__FILE__) + run_script "#{dir}/resources/testsuite_adapter_spec_with_test_unit.rb" + end +end \ No newline at end of file diff --git a/vendor/gems/gems/rspec-1.2.9/spec/spec/matchers/be_close_spec.rb b/vendor/gems/gems/rspec-1.2.9/spec/spec/matchers/be_close_spec.rb new file mode 100755 index 00000000..cc0e5bd4 --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/spec/spec/matchers/be_close_spec.rb @@ -0,0 +1,50 @@ +require 'spec_helper' +module Spec + module Matchers + describe "[actual.should] be_close(expected, delta)" do + it "matches when actual == expected" do + be_close(5.0, 0.5).matches?(5.0).should be_true + end + it "matches when actual < (expected + delta)" do + be_close(5.0, 0.5).matches?(5.49).should be_true + end + it "matches when actual > (expected - delta)" do + be_close(5.0, 0.5).matches?(4.51).should be_true + end + it "does not match when actual == (expected - delta)" do + be_close(5.0, 0.5).matches?(4.5).should be_false + end + it "does not match when actual < (expected - delta)" do + be_close(5.0, 0.5).matches?(4.49).should be_false + end + it "does not match when actual == (expected + delta)" do + be_close(5.0, 0.5).matches?(5.5).should be_false + end + it "does not match when actual > (expected + delta)" do + be_close(5.0, 0.5).matches?(5.51).should be_false + end + it "provides a failure message for should" do + #given + matcher = be_close(5.0, 0.5) + #when + matcher.matches?(5.51) + #then + matcher.failure_message_for_should.should == "expected 5.0 +/- (< 0.5), got 5.51" + end + + it "provides a failure message for should tno" do + #given + matcher = be_close(5.0, 0.5) + #when + matcher.matches?(5.49) + #then + matcher.failure_message_for_should_not.should == "expected 5.0 +/- (< 0.5), got 5.49" + end + it "provides a description" do + matcher = be_close(5.0, 0.5) + matcher.matches?(5.1) + matcher.description.should == "be close to 5.0 (within +- 0.5)" + end + end + end +end diff --git a/vendor/gems/gems/rspec-1.2.9/spec/spec/matchers/be_instance_of_spec.rb b/vendor/gems/gems/rspec-1.2.9/spec/spec/matchers/be_instance_of_spec.rb new file mode 100755 index 00000000..e6abd0b1 --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/spec/spec/matchers/be_instance_of_spec.rb @@ -0,0 +1,36 @@ +require 'spec_helper' + +module Spec + module Matchers + [:be_an_instance_of, :be_instance_of].each do |method| + describe "actual.should #{method}(expected)" do + it "passes if actual is instance of expected class" do + 5.should send(method, Fixnum) + end + + it "fails if actual is instance of subclass of expected class" do + lambda { 5.should send(method, Numeric) }.should fail_with(%Q{expected 5 to be an instance of Numeric}) + end + + it "fails with failure message for should unless actual is instance of expected class" do + lambda { "foo".should send(method, Array) }.should fail_with(%Q{expected "foo" to be an instance of Array}) + end + + it "provides a description" do + matcher = be_an_instance_of(Fixnum) + matcher.matches?(Numeric) + matcher.description.should == "be an instance of Fixnum" + end + end + + describe "actual.should_not #{method}(expected)" do + + it "fails with failure message for should_not if actual is instance of expected class" do + lambda { "foo".should_not send(method, String) }.should fail_with(%Q{expected "foo" not to be an instance of String}) + end + + end + + end + end +end diff --git a/vendor/gems/gems/rspec-1.2.9/spec/spec/matchers/be_kind_of_spec.rb b/vendor/gems/gems/rspec-1.2.9/spec/spec/matchers/be_kind_of_spec.rb new file mode 100755 index 00000000..d3f05e80 --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/spec/spec/matchers/be_kind_of_spec.rb @@ -0,0 +1,33 @@ +require 'spec_helper' + +module Spec + module Matchers + [:be_a_kind_of, :be_kind_of].each do |method| + describe "actual.should #{method}(expected)" do + it "passes if actual is instance of expected class" do + 5.should send(method, Fixnum) + end + + it "passes if actual is instance of subclass of expected class" do + 5.should send(method, Numeric) + end + + it "fails with failure message for should unless actual is kind of expected class" do + lambda { "foo".should send(method, Array) }.should fail_with(%Q{expected "foo" to be a kind of Array}) + end + + it "provides a description" do + matcher = be_a_kind_of(String) + matcher.matches?("this") + matcher.description.should == "be a kind of String" + end + end + + describe "actual.should_not #{method}(expected)" do + it "fails with failure message for should_not if actual is kind of expected class" do + lambda { "foo".should_not send(method, String) }.should fail_with(%Q{expected "foo" not to be a kind of String}) + end + end + end + end +end diff --git a/vendor/gems/gems/rspec-1.2.9/spec/spec/matchers/be_spec.rb b/vendor/gems/gems/rspec-1.2.9/spec/spec/matchers/be_spec.rb new file mode 100755 index 00000000..db6258ab --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/spec/spec/matchers/be_spec.rb @@ -0,0 +1,311 @@ +require 'spec_helper' + +describe "should be_predicate" do + it "should pass when actual returns true for :predicate?" do + actual = stub("actual", :happy? => true) + actual.should be_happy + end + + it "should pass when actual returns true for :predicates? (present tense)" do + actual = stub("actual", :exists? => true, :exist? => true) + actual.should be_exist + end + + it "should fail when actual returns false for :predicate?" do + actual = stub("actual", :happy? => false) + lambda { + actual.should be_happy + }.should fail_with("expected happy? to return true, got false") + end + + it "should fail when actual returns false for :predicate?" do + actual = stub("actual", :happy? => nil) + lambda { + actual.should be_happy + }.should fail_with("expected happy? to return true, got nil") + end + + it "should fail when actual does not respond to :predicate?" do + lambda { + Object.new.should be_happy + }.should raise_error(NameError, /happy\?/) + end + + it "should fail on error other than NameError" do + actual = stub("actual") + actual.should_receive(:foo?).and_raise("aaaah") + lambda { + actual.should be_foo + }.should raise_error(/aaaah/) + end + + it "should fail on error other than NameError (with the present tense predicate)" do + actual = Object.new + actual.should_receive(:foos?).and_raise("aaaah") + lambda { + actual.should be_foo + }.should raise_error(/aaaah/) + end +end + +describe "should_not be_predicate" do + it "should pass when actual returns false for :sym?" do + actual = stub("actual", :happy? => false) + actual.should_not be_happy + end + + it "should pass when actual returns nil for :sym?" do + actual = stub("actual", :happy? => nil) + actual.should_not be_happy + end + + it "should fail when actual returns true for :sym?" do + actual = stub("actual", :happy? => true) + lambda { + actual.should_not be_happy + }.should fail_with("expected happy? to return false, got true") + end + + it "should fail when actual does not respond to :sym?" do + lambda { + Object.new.should_not be_happy + }.should raise_error(NameError) + end +end + +describe "should be_predicate(*args)" do + it "should pass when actual returns true for :predicate?(*args)" do + actual = mock("actual") + actual.should_receive(:older_than?).with(3).and_return(true) + actual.should be_older_than(3) + end + + it "should fail when actual returns false for :predicate?(*args)" do + actual = mock("actual") + actual.should_receive(:older_than?).with(3).and_return(false) + lambda { + actual.should be_older_than(3) + }.should fail_with("expected older_than?(3) to return true, got false") + end + + it "should fail when actual does not respond to :predicate?" do + lambda { + Object.new.should be_older_than(3) + }.should raise_error(NameError) + end +end + +describe "should_not be_predicate(*args)" do + it "should pass when actual returns false for :predicate?(*args)" do + actual = mock("actual") + actual.should_receive(:older_than?).with(3).and_return(false) + actual.should_not be_older_than(3) + end + + it "should fail when actual returns true for :predicate?(*args)" do + actual = mock("actual") + actual.should_receive(:older_than?).with(3).and_return(true) + lambda { + actual.should_not be_older_than(3) + }.should fail_with("expected older_than?(3) to return false, got true") + end + + it "should fail when actual does not respond to :predicate?" do + lambda { + Object.new.should_not be_older_than(3) + }.should raise_error(NameError) + end +end + +describe "should be_true" do + it "should pass when actual equal(true)" do + true.should be_true + end + + it "should fail when actual equal(false)" do + lambda { + false.should be_true + }.should fail_with("expected true, got false") + end +end + +describe "should be_false" do + it "should pass when actual equal(false)" do + false.should be_false + end + + it "should fail when actual equal(true)" do + lambda { + true.should be_false + }.should fail_with("expected false, got true") + end +end + +describe "should be_nil" do + it "should pass when actual is nil" do + nil.should be_nil + end + + it "should fail when actual is not nil" do + lambda { + :not_nil.should be_nil + }.should fail_with("expected nil, got :not_nil") + end +end + +describe "should_not be_nil" do + it "should pass when actual is not nil" do + :not_nil.should_not be_nil + end + + it "should fail when actual is nil" do + lambda { + nil.should_not be_nil + }.should fail_with("expected not nil, got nil") + end +end + +describe "should be <" do + it "should pass when < operator returns true" do + 3.should be < 4 + end + + it "should fail when < operator returns false" do + lambda { 3.should be < 3 }.should fail_with("expected < 3, got 3") + end +end + +describe "should be <=" do + it "should pass when <= operator returns true" do + 3.should be <= 4 + 4.should be <= 4 + end + + it "should fail when <= operator returns false" do + lambda { 3.should be <= 2 }.should fail_with("expected <= 2, got 3") + end +end + +describe "should be >=" do + it "should pass when >= operator returns true" do + 4.should be >= 4 + 5.should be >= 4 + end + + it "should fail when >= operator returns false" do + lambda { 3.should be >= 4 }.should fail_with("expected >= 4, got 3") + end +end + +describe "should be >" do + it "should pass when > operator returns true" do + 5.should be > 4 + end + + it "should fail when > operator returns false" do + lambda { 3.should be > 4 }.should fail_with("expected > 4, got 3") + end +end + +describe "should be ==" do + it "should pass when == operator returns true" do + 5.should be == 5 + end + + it "should fail when == operator returns false" do + lambda { 3.should be == 4 }.should fail_with("expected == 4, got 3") + end +end + +describe "should be ===" do + it "should pass when === operator returns true" do + Hash.should be === Hash.new + end + + it "should fail when === operator returns false" do + lambda { Hash.should be === "not a hash" }.should fail_with(%[expected === not a hash, got Hash]) + end +end + +describe "should_not with operators" do + it "should coach user to stop using operators with should_not" do + lambda { + 5.should_not be < 6 + }.should raise_error(/not only FAILED,\nit is a bit confusing./m) + end +end + +describe "should be" do + it "should pass if actual is true or a set value" do + true.should be + 1.should be + end + + it "should fail if actual is false" do + lambda {false.should be}.should fail_with("expected true, got false") + end + + it "should fail if actual is nil" do + lambda {nil.should be}.should fail_with("expected true, got nil") + end +end + +describe "should be(value)" do + it "should pass if actual.equal?(value)" do + 5.should be(5) + end + it "should fail if !actual.equal?(value)" do + lambda { 5.should be(6) }.should fail_with("expected 6, got 5") + end +end + +describe "'should be' with operator" do + it "should include 'be' in the description" do + (be > 6).description.should =~ /be > 6/ + (be >= 6).description.should =~ /be >= 6/ + (be <= 6).description.should =~ /be <= 6/ + (be < 6).description.should =~ /be < 6/ + end +end + + +describe "arbitrary predicate with DelegateClass" do + it "should access methods defined in the delegating class (LH[#48])" do + require 'delegate' + class ArrayDelegate < DelegateClass(Array) + def initialize(array) + @internal_array = array + super(@internal_array) + end + + def large? + @internal_array.size >= 5 + end + end + + delegate = ArrayDelegate.new([1,2,3,4,5,6]) + delegate.should be_large + end +end + +describe "be_a, be_an" do + it "should pass when class matches" do + "foobar".should be_a(String) + [1,2,3].should be_an(Array) + end + + it "should fail when class does not match" do + "foobar".should_not be_a(Hash) + [1,2,3].should_not be_an(Integer) + end +end + +describe "be_an_instance_of" do + it "passes when direct class matches" do + 5.should be_an_instance_of(Fixnum) + end + + it "fails when class is higher up hierarchy" do + 5.should_not be_an_instance_of(Numeric) + end +end \ No newline at end of file diff --git a/vendor/gems/gems/rspec-1.2.9/spec/spec/matchers/change_spec.rb b/vendor/gems/gems/rspec-1.2.9/spec/spec/matchers/change_spec.rb new file mode 100755 index 00000000..e70daf37 --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/spec/spec/matchers/change_spec.rb @@ -0,0 +1,349 @@ +#Based on patch from Wilson Bilkovich + +require 'spec_helper' +class SomethingExpected + attr_accessor :some_value +end + +describe "should change(actual, message)" do + before(:each) do + @instance = SomethingExpected.new + @instance.some_value = 5 + end + + it "should pass when actual is modified by the block" do + expect {@instance.some_value = 6}.to change(@instance, :some_value) + end + + it "should fail when actual is not modified by the block" do + expect do + expect {}.to change(@instance, :some_value) + end.to fail_with("some_value should have changed, but is still 5") + end + + it "provides a #description" do + change(@instance, :some_value).description.should == "change #some_value" + end +end + +describe "should_not change(actual, message)" do + before(:each) do + @instance = SomethingExpected.new + @instance.some_value = 5 + end + + it "should pass when actual is not modified by the block" do + expect { }.to_not change(@instance, :some_value) + end + + it "should fail when actual is not modified by the block" do + expect do + expect {@instance.some_value = 6}.to_not change(@instance, :some_value) + end.to fail_with("some_value should not have changed, but did change from 5 to 6") + end +end + +describe "should change { block }" do + before(:each) do + @instance = SomethingExpected.new + @instance.some_value = 5 + end + + it "should pass when actual is modified by the block" do + expect {@instance.some_value = 6}.to change { @instance.some_value } + end + + it "should fail when actual is not modified by the block" do + expect do + expect {}.to change{ @instance.some_value } + end.to fail_with("result should have changed, but is still 5") + end + + it "should warn if passed a block using do/end instead of {}" do + expect do + expect {}.to change do; end + end.to raise_error(Spec::Matchers::MatcherError, /block passed to should or should_not/) + end + + it "provides a #description" do + change { @instance.some_value }.description.should == "change #result" + end +end + +describe "should_not change { block }" do + before(:each) do + @instance = SomethingExpected.new + @instance.some_value = 5 + end + + it "should pass when actual is modified by the block" do + expect {}.to_not change{ @instance.some_value } + end + + it "should fail when actual is not modified by the block" do + expect do + expect {@instance.some_value = 6}.to_not change { @instance.some_value } + end.to fail_with("result should not have changed, but did change from 5 to 6") + end + + it "should warn if passed a block using do/end instead of {}" do + expect do + expect {}.to_not change do; end + end.to raise_error(Spec::Matchers::MatcherError, /block passed to should or should_not/) + end +end + +describe "should change(actual, message).by(expected)" do + before(:each) do + @instance = SomethingExpected.new + @instance.some_value = 5 + end + + it "should pass when attribute is changed by expected amount" do + expect { @instance.some_value += 1 }.to change(@instance, :some_value).by(1) + end + + it "should fail when the attribute is changed by unexpected amount" do + expect do + expect { @instance.some_value += 2 }.to change(@instance, :some_value).by(1) + end.to fail_with("some_value should have been changed by 1, but was changed by 2") + end + + it "should fail when the attribute is changed by unexpected amount in the opposite direction" do + expect do + expect { @instance.some_value -= 1 }.to change(@instance, :some_value).by(1) + end.to fail_with("some_value should have been changed by 1, but was changed by -1") + end +end + +describe "should change{ block }.by(expected)" do + before(:each) do + @instance = SomethingExpected.new + @instance.some_value = 5 + end + + it "should pass when attribute is changed by expected amount" do + expect { @instance.some_value += 1 }.to change{@instance.some_value}.by(1) + end + + it "should fail when the attribute is changed by unexpected amount" do + expect do + expect { @instance.some_value += 2 }.to change{@instance.some_value}.by(1) + end.to fail_with("result should have been changed by 1, but was changed by 2") + end + + it "should fail when the attribute is changed by unexpected amount in the opposite direction" do + expect do + expect { @instance.some_value -= 1 }.to change{@instance.some_value}.by(1) + end.to fail_with("result should have been changed by 1, but was changed by -1") + end +end + +describe "should change(actual, message).by_at_least(expected)" do + before(:each) do + @instance = SomethingExpected.new + @instance.some_value = 5 + end + + it "should pass when attribute is changed by greater than the expected amount" do + expect { @instance.some_value += 2 }.to change(@instance, :some_value).by_at_least(1) + end + + it "should pass when attribute is changed by the expected amount" do + expect { @instance.some_value += 2 }.to change(@instance, :some_value).by_at_least(2) + end + + it "should fail when the attribute is changed by less than the expected amount" do + expect do + expect { @instance.some_value += 1 }.to change(@instance, :some_value).by_at_least(2) + end.to fail_with("some_value should have been changed by at least 2, but was changed by 1") + end + +end + +describe "should change{ block }.by_at_least(expected)" do + before(:each) do + @instance = SomethingExpected.new + @instance.some_value = 5 + end + + it "should pass when attribute is changed by greater than expected amount" do + expect { @instance.some_value += 2 }.to change{@instance.some_value}.by_at_least(1) + end + + it "should pass when attribute is changed by the expected amount" do + expect { @instance.some_value += 2 }.to change{@instance.some_value}.by_at_least(2) + end + + it "should fail when the attribute is changed by less than the unexpected amount" do + expect do + expect { @instance.some_value += 1 }.to change{@instance.some_value}.by_at_least(2) + end.to fail_with("result should have been changed by at least 2, but was changed by 1") + end +end + + +describe "should change(actual, message).by_at_most(expected)" do + before(:each) do + @instance = SomethingExpected.new + @instance.some_value = 5 + end + + it "should pass when attribute is changed by less than the expected amount" do + expect { @instance.some_value += 2 }.to change(@instance, :some_value).by_at_most(3) + end + + it "should pass when attribute is changed by the expected amount" do + expect { @instance.some_value += 2 }.to change(@instance, :some_value).by_at_most(2) + end + + it "should fail when the attribute is changed by greater than the expected amount" do + expect do + expect { @instance.some_value += 2 }.to change(@instance, :some_value).by_at_most(1) + end.to fail_with("some_value should have been changed by at most 1, but was changed by 2") + end + +end + +describe "should change{ block }.by_at_most(expected)" do + before(:each) do + @instance = SomethingExpected.new + @instance.some_value = 5 + end + + it "should pass when attribute is changed by less than expected amount" do + expect { @instance.some_value += 2 }.to change{@instance.some_value}.by_at_most(3) + end + + it "should pass when attribute is changed by the expected amount" do + expect { @instance.some_value += 2 }.to change{@instance.some_value}.by_at_most(2) + end + + it "should fail when the attribute is changed by greater than the unexpected amount" do + expect do + expect { @instance.some_value += 2 }.to change{@instance.some_value}.by_at_most(1) + end.to fail_with("result should have been changed by at most 1, but was changed by 2") + end +end + +describe "should change(actual, message).from(old)" do + before(:each) do + @instance = SomethingExpected.new + @instance.some_value = 'string' + end + + it "should pass when attribute is == to expected value before executing block" do + expect { @instance.some_value = "astring" }.to change(@instance, :some_value).from("string") + end + + it "should fail when attribute is not == to expected value before executing block" do + expect do + expect { @instance.some_value = "knot" }.to change(@instance, :some_value).from("cat") + end.to fail_with("some_value should have initially been \"cat\", but was \"string\"") + end +end + +describe "should change{ block }.from(old)" do + before(:each) do + @instance = SomethingExpected.new + @instance.some_value = 'string' + end + + it "should pass when attribute is == to expected value before executing block" do + expect { @instance.some_value = "astring" }.to change{@instance.some_value}.from("string") + end + + it "should fail when attribute is not == to expected value before executing block" do + expect do + expect { @instance.some_value = "knot" }.to change{@instance.some_value}.from("cat") + end.to fail_with("result should have initially been \"cat\", but was \"string\"") + end +end + +describe "should change(actual, message).to(new)" do + before(:each) do + @instance = SomethingExpected.new + @instance.some_value = 'string' + end + + it "should pass when attribute is == to expected value after executing block" do + expect { @instance.some_value = "cat" }.to change(@instance, :some_value).to("cat") + end + + it "should fail when attribute is not == to expected value after executing block" do + expect do + expect { @instance.some_value = "cat" }.to change(@instance, :some_value).from("string").to("dog") + end.to fail_with("some_value should have been changed to \"dog\", but is now \"cat\"") + end +end + +describe "should change{ block }.to(new)" do + before(:each) do + @instance = SomethingExpected.new + @instance.some_value = 'string' + end + + it "should pass when attribute is == to expected value after executing block" do + expect { @instance.some_value = "cat" }.to change{@instance.some_value}.to("cat") + end + + it "should fail when attribute is not == to expected value after executing block" do + expect do + expect { @instance.some_value = "cat" }.to change{@instance.some_value}.from("string").to("dog") + end.to fail_with("result should have been changed to \"dog\", but is now \"cat\"") + end +end + +describe "should change(actual, message).from(old).to(new)" do + before(:each) do + @instance = SomethingExpected.new + @instance.some_value = 'string' + end + + it "should pass when #to comes before #from" do + expect { @instance.some_value = "cat" }.to change(@instance, :some_value).to("cat").from("string") + end + + it "should pass when #from comes before #to" do + expect { @instance.some_value = "cat" }.to change(@instance, :some_value).from("string").to("cat") + end + + it "should show the correct messaging when #after and #to are different" do + expect do + expect { @instance.some_value = "cat" }.to change(@instance, :some_value).from("string").to("dog") + end.to fail_with("some_value should have been changed to \"dog\", but is now \"cat\"") + end + + it "should show the correct messaging when #before and #from are different" do + expect do + expect { @instance.some_value = "cat" }.to change(@instance, :some_value).from("not_string").to("cat") + end.to fail_with("some_value should have initially been \"not_string\", but was \"string\"") + end +end + +describe "should change{ block }.from(old).to(new)" do + before(:each) do + @instance = SomethingExpected.new + @instance.some_value = 'string' + end + + it "should pass when #to comes before #from" do + expect { @instance.some_value = "cat" }.to change{@instance.some_value}.to("cat").from("string") + end + + it "should pass when #from comes before #to" do + expect { @instance.some_value = "cat" }.to change{@instance.some_value}.from("string").to("cat") + end +end + +describe Spec::Matchers::Change do + it "should work when the receiver has implemented #send" do + @instance = SomethingExpected.new + @instance.some_value = "string" + def @instance.send(*args); raise "DOH! Library developers shouldn't use #send!" end + + expect { + expect { @instance.some_value = "cat" }.to change(@instance, :some_value) + }.to_not raise_error + end +end diff --git a/vendor/gems/gems/rspec-1.2.9/spec/spec/matchers/compatibility_spec.rb b/vendor/gems/gems/rspec-1.2.9/spec/spec/matchers/compatibility_spec.rb new file mode 100755 index 00000000..3987e590 --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/spec/spec/matchers/compatibility_spec.rb @@ -0,0 +1,28 @@ +require 'spec_helper' + +Spec::Matchers.define :have_public_instance_method do |method| + match do |klass| + klass.public_instance_methods.any? {|m| [method, method.to_sym].include?(m)} + end +end + +(Spec::Matchers.constants.sort).each do |c| + if (Class === (klass = Spec::Matchers.const_get(c))) + describe klass do + if klass.public_instance_methods.any? {|m| ['failure_message_for_should',:failure_message_for_should].include?(m)} + describe "called with should" do + subject { klass } + it { should have_public_instance_method('failure_message_for_should')} + it { should have_public_instance_method('failure_message')} + end + end + if klass.public_instance_methods.any? {|m| ['failure_message_for_should_not',:failure_message_for_should_not].include?(m)} + describe "called with should not" do + subject { klass } + it { should have_public_instance_method('failure_message_for_should_not')} + it { should have_public_instance_method('negative_failure_message')} + end + end + end + end +end diff --git a/vendor/gems/gems/rspec-1.2.9/spec/spec/matchers/description_generation_spec.rb b/vendor/gems/gems/rspec-1.2.9/spec/spec/matchers/description_generation_spec.rb new file mode 100755 index 00000000..51b483c7 --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/spec/spec/matchers/description_generation_spec.rb @@ -0,0 +1,160 @@ +require 'spec_helper' + +describe "Matchers should be able to generate their own descriptions" do + after(:each) do + Spec::Matchers.clear_generated_description + end + + it "should == expected" do + "this".should == "this" + Spec::Matchers.generated_description.should == "should == \"this\"" + end + + it "should not == expected" do + "this".should_not == "that" + Spec::Matchers.generated_description.should == "should not == \"that\"" + end + + it "should be empty (arbitrary predicate)" do + [].should be_empty + Spec::Matchers.generated_description.should == "should be empty" + end + + it "should not be empty (arbitrary predicate)" do + [1].should_not be_empty + Spec::Matchers.generated_description.should == "should not be empty" + end + + it "should be true" do + true.should be_true + Spec::Matchers.generated_description.should == "should be true" + end + + it "should be false" do + false.should be_false + Spec::Matchers.generated_description.should == "should be false" + end + + it "should be nil" do + nil.should be_nil + Spec::Matchers.generated_description.should == "should be nil" + end + + it "should be > n" do + 5.should be > 3 + Spec::Matchers.generated_description.should == "should be > 3" + end + + it "should be predicate arg1, arg2 and arg3" do + 5.0.should be_between(0,10) + Spec::Matchers.generated_description.should == "should be between 0 and 10" + end + + it "should equal" do + expected = "expected" + expected.should equal(expected) + Spec::Matchers.generated_description.should == "should equal \"expected\"" + end + + it "should_not equal" do + 5.should_not equal(37) + Spec::Matchers.generated_description.should == "should not equal 37" + end + + it "should eql" do + "string".should eql("string") + Spec::Matchers.generated_description.should == "should eql \"string\"" + end + + it "should not eql" do + "a".should_not eql(:a) + Spec::Matchers.generated_description.should == "should not eql :a" + end + + it "should have_key" do + {:a => "a"}.should have_key(:a) + Spec::Matchers.generated_description.should == "should have key :a" + end + + it "should have n items" do + team.should have(3).players + Spec::Matchers.generated_description.should == "should have 3 players" + end + + it "should have at least n items" do + team.should have_at_least(2).players + Spec::Matchers.generated_description.should == "should have at least 2 players" + end + + it "should have at most n items" do + team.should have_at_most(4).players + Spec::Matchers.generated_description.should == "should have at most 4 players" + end + + it "should include" do + [1,2,3].should include(3) + Spec::Matchers.generated_description.should == "should include 3" + end + + it "array.should =~ [1,2,3]" do + [1,2,3].should =~ [1,2,3] + Spec::Matchers.generated_description.should == "should contain exactly 1, 2 and 3" + end + + it "should match" do + "this string".should match(/this string/) + Spec::Matchers.generated_description.should == "should match /this string/" + end + + it "should raise_error" do + lambda { raise }.should raise_error + Spec::Matchers.generated_description.should == "should raise Exception" + end + + it "should raise_error with type" do + lambda { raise }.should raise_error(RuntimeError) + Spec::Matchers.generated_description.should == "should raise RuntimeError" + end + + it "should raise_error with type and message" do + lambda { raise "there was an error" }.should raise_error(RuntimeError, "there was an error") + Spec::Matchers.generated_description.should == "should raise RuntimeError with \"there was an error\"" + end + + it "should respond_to" do + [].should respond_to(:insert) + Spec::Matchers.generated_description.should == "should respond to #insert" + end + + it "should throw symbol" do + lambda { throw :what_a_mess }.should throw_symbol + Spec::Matchers.generated_description.should == "should throw a Symbol" + end + + it "should throw symbol (with named symbol)" do + lambda { throw :what_a_mess }.should throw_symbol(:what_a_mess) + Spec::Matchers.generated_description.should == "should throw :what_a_mess" + end + + def team + Class.new do + def players + [1,2,3] + end + end.new + end +end + +describe "a Matcher with no description" do + def matcher + Class.new do + def matches?(ignore); true; end + def failure_message; ""; end + end.new + end + + it "should provide a helpful message when used in a string-less example block" do + 5.should matcher + Spec::Matchers.generated_description.should =~ /When you call.*description method/m + end +end diff --git a/vendor/gems/gems/rspec-1.2.9/spec/spec/matchers/dsl_spec.rb b/vendor/gems/gems/rspec-1.2.9/spec/spec/matchers/dsl_spec.rb new file mode 100755 index 00000000..9c280e5a --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/spec/spec/matchers/dsl_spec.rb @@ -0,0 +1,34 @@ +require 'spec_helper' + +module Spec + module Matchers + module DSL + describe "#create" do + it "is deprecated" do + Spec.should_receive(:deprecate) + mod = Module.new + mod.extend Spec::Matchers::DSL + mod.create(:foo) + end + end + + describe "#define" do + it "creates a method that initializes a new matcher with the submitted name and expected arg" do + # FIXME - this expects new to be called, but we need something + # more robust - that expects new to be called with a specific + # block (lambda, proc, whatever) + mod = Module.new + mod.extend Spec::Matchers::DSL + mod.define(:foo) + + obj = Object.new + obj.extend mod + + Spec::Matchers::Matcher.should_receive(:new).with(:foo, 3) + + obj.foo(3) + end + end + end + end +end diff --git a/vendor/gems/gems/rspec-1.2.9/spec/spec/matchers/eql_spec.rb b/vendor/gems/gems/rspec-1.2.9/spec/spec/matchers/eql_spec.rb new file mode 100755 index 00000000..5cdf541e --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/spec/spec/matchers/eql_spec.rb @@ -0,0 +1,33 @@ +require 'spec_helper' + +module Spec + module Matchers + describe "eql" do + it "should match when actual.eql?(expected)" do + 1.should eql(1) + end + + it "should not match when !actual.eql?(expected)" do + 1.should_not eql(2) + end + + it "should describe itself" do + matcher = eql(1) + matcher.matches?(1) + matcher.description.should == "eql 1" + end + + it "should provide message, expected and actual on #failure_message" do + matcher = eql("1") + matcher.matches?(1) + matcher.failure_message_for_should.should == "\nexpected \"1\"\n got 1\n\n(compared using eql?)\n" + end + + it "should provide message, expected and actual on #negative_failure_message" do + matcher = eql(1) + matcher.matches?(1) + matcher.failure_message_for_should_not.should == "\nexpected 1 not to equal 1\n\n(compared using eql?)\n" + end + end + end +end diff --git a/vendor/gems/gems/rspec-1.2.9/spec/spec/matchers/equal_spec.rb b/vendor/gems/gems/rspec-1.2.9/spec/spec/matchers/equal_spec.rb new file mode 100755 index 00000000..cb2fc1e5 --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/spec/spec/matchers/equal_spec.rb @@ -0,0 +1,57 @@ +require 'spec_helper' +module Spec + module Matchers + describe "equal" do + + def inspect_object(o) + "#<#{o.class}:#{o.object_id}> => #{o.inspect}" + end + + it "should match when actual.equal?(expected)" do + 1.should equal(1) + end + + it "should not match when !actual.equal?(expected)" do + 1.should_not equal("1") + end + + it "should describe itself" do + matcher = equal(1) + matcher.matches?(1) + matcher.description.should == "equal 1" + end + + it "should provide message on #failure_message" do + expected, actual = "1", "1" + matcher = equal(expected) + matcher.matches?(actual) + + matcher.failure_message_for_should.should == <<-MESSAGE + +expected #{inspect_object(expected)} + got #{inspect_object(actual)} + +Compared using equal?, which compares object identity, +but expected and actual are not the same object. Use +'actual.should == expected' if you don't care about +object identity in this example. + +MESSAGE + end + + it "should provide message on #negative_failure_message" do + expected = actual = "1" + matcher = equal(expected) + matcher.matches?(actual) + matcher.failure_message_for_should_not.should == <<-MESSAGE + +expected not #{inspect_object(expected)} + got #{inspect_object(actual)} + +Compared using equal?, which compares object identity. + +MESSAGE + end + end + end +end diff --git a/vendor/gems/gems/rspec-1.2.9/spec/spec/matchers/exist_spec.rb b/vendor/gems/gems/rspec-1.2.9/spec/spec/matchers/exist_spec.rb new file mode 100755 index 00000000..f95c86ff --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/spec/spec/matchers/exist_spec.rb @@ -0,0 +1,65 @@ +require 'spec_helper' + +class Substance + def initialize exists, description + @exists = exists + @description = description + end + def exist?(arg=nil) + @exists + end + def inspect + @description + end +end + +class SubstanceTester + include Spec::Matchers + def initialize substance + @substance = substance + end + def should_exist + @substance.should exist + end +end + +describe "should exist" do + + before(:each) do + @real = Substance.new true, 'something real' + @imaginary = Substance.new false, 'something imaginary' + end + + describe "within an example group" do + + it "passes if target exists" do + @real.should exist + end + + it "passes if target exists with args" do + @real.should exist('this arg') + end + + it "fails if target does not exist" do + lambda { @imaginary.should exist }.should fail + end + + it "describes itself" do + exist.description.should == "exist" + end + + it "passes should_not exist if target doesn't exist" do + lambda { @real.should_not exist }.should fail + end + end + + describe "outside of an example group" do + + it "should pass if target exists" do + real_tester = SubstanceTester.new @real + real_tester.should_exist + end + + end + +end diff --git a/vendor/gems/gems/rspec-1.2.9/spec/spec/matchers/has_spec.rb b/vendor/gems/gems/rspec-1.2.9/spec/spec/matchers/has_spec.rb new file mode 100755 index 00000000..b6f25991 --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/spec/spec/matchers/has_spec.rb @@ -0,0 +1,81 @@ +require 'spec_helper' + +describe "should have_sym(*args)" do + it "should pass if #has_sym?(*args) returns true" do + {:a => "A"}.should have_key(:a) + end + + it "should fail if #has_sym?(*args) returns false" do + lambda { + {:b => "B"}.should have_key(:a) + }.should fail_with("expected #has_key?(:a) to return true, got false") + end + + it "should fail if #has_sym?(*args) returns nil" do + klass = Class.new do + def has_foo? + end + end + lambda { + klass.new.should have_foo + }.should fail_with("expected #has_foo?(nil) to return true, got false") + end + + it "should fail if target does not respond to #has_sym?" do + lambda { + Object.new.should have_key(:a) + }.should raise_error(NoMethodError) + end + + it "should reraise an exception thrown in #has_sym?(*args)" do + o = Object.new + def o.has_sym?(*args) + raise "Funky exception" + end + lambda { o.should have_sym(:foo) }.should raise_error("Funky exception") + end +end + +describe "should_not have_sym(*args)" do + it "should pass if #has_sym?(*args) returns false" do + {:a => "A"}.should_not have_key(:b) + end + + it "should pass if #has_sym?(*args) returns nil" do + klass = Class.new do + def has_foo? + end + end + klass.new.should_not have_foo + end + + it "should fail if #has_sym?(*args) returns true" do + lambda { + {:a => "A"}.should_not have_key(:a) + }.should fail_with("expected #has_key?(:a) to return false, got true") + end + + it "should fail if target does not respond to #has_sym?" do + lambda { + Object.new.should have_key(:a) + }.should raise_error(NoMethodError) + end + + it "should reraise an exception thrown in #has_sym?(*args)" do + o = Object.new + def o.has_sym?(*args) + raise "Funky exception" + end + lambda { o.should_not have_sym(:foo) }.should raise_error("Funky exception") + end +end + +describe "has" do + it "should work when the target implements #send" do + o = {:a => "A"} + def o.send(*args); raise "DOH! Library developers shouldn't use #send!" end + lambda { + o.should have_key(:a) + }.should_not raise_error + end +end diff --git a/vendor/gems/gems/rspec-1.2.9/spec/spec/matchers/have_spec.rb b/vendor/gems/gems/rspec-1.2.9/spec/spec/matchers/have_spec.rb new file mode 100755 index 00000000..07c29497 --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/spec/spec/matchers/have_spec.rb @@ -0,0 +1,396 @@ +require 'spec_helper' + +share_as :HaveSpecHelper do + def create_collection_owner_with(n) + owner = Spec::Expectations::Helper::CollectionOwner.new + (1..n).each do |number| + owner.add_to_collection_with_length_method(number) + owner.add_to_collection_with_size_method(number) + end + owner + end + before(:each) do + if defined?(::ActiveSupport::Inflector) + @active_support_was_defined = true + else + @active_support_was_defined = false + module ::ActiveSupport + class Inflector + def self.pluralize(string) + string.to_s + 's' + end + end + end + end + end +end + + +describe "should have(n).items" do + include HaveSpecHelper + + it "should pass if target has a collection of items with n members" do + owner = create_collection_owner_with(3) + owner.should have(3).items_in_collection_with_length_method + owner.should have(3).items_in_collection_with_size_method + end + + it "should convert :no to 0" do + owner = create_collection_owner_with(0) + owner.should have(:no).items_in_collection_with_length_method + owner.should have(:no).items_in_collection_with_size_method + end + + it "should fail if target has a collection of items with < n members" do + owner = create_collection_owner_with(3) + lambda { + owner.should have(4).items_in_collection_with_length_method + }.should fail_with("expected 4 items_in_collection_with_length_method, got 3") + lambda { + owner.should have(4).items_in_collection_with_size_method + }.should fail_with("expected 4 items_in_collection_with_size_method, got 3") + end + + it "should fail if target has a collection of items with > n members" do + owner = create_collection_owner_with(3) + lambda { + owner.should have(2).items_in_collection_with_length_method + }.should fail_with("expected 2 items_in_collection_with_length_method, got 3") + lambda { + owner.should have(2).items_in_collection_with_size_method + }.should fail_with("expected 2 items_in_collection_with_size_method, got 3") + end +end + +describe 'should have(1).item when ActiveSupport::Inflector is defined' do + include HaveSpecHelper + + it 'should pluralize the collection name' do + owner = create_collection_owner_with(1) + owner.should have(1).item + end + + after(:each) do + unless @active_support_was_defined + Object.__send__ :remove_const, :ActiveSupport + end + end +end + +describe 'should have(1).item when Inflector is defined' do + include HaveSpecHelper + + before(:each) do + if defined?(Inflector) + @inflector_was_defined = true + else + @inflector_was_defined = false + class ::Inflector + def self.pluralize(string) + string.to_s + 's' + end + end + end + end + + it 'should pluralize the collection name' do + owner = create_collection_owner_with(1) + owner.should have(1).item + end + + after(:each) do + unless @inflector_was_defined + Object.__send__ :remove_const, :Inflector + end + end +end + +describe "should have(n).items where result responds to items but returns something other than a collection" do + it "should provide a meaningful error" do + owner = Class.new do + def items + Object.new + end + end.new + lambda do + owner.should have(3).items + end.should raise_error("expected items to be a collection but it does not respond to #length or #size") + end +end + +describe "should_not have(n).items" do + include HaveSpecHelper + + it "should pass if target has a collection of items with < n members" do + owner = create_collection_owner_with(3) + owner.should_not have(4).items_in_collection_with_length_method + owner.should_not have(4).items_in_collection_with_size_method + end + + it "should pass if target has a collection of items with > n members" do + owner = create_collection_owner_with(3) + owner.should_not have(2).items_in_collection_with_length_method + owner.should_not have(2).items_in_collection_with_size_method + end + + it "should fail if target has a collection of items with n members" do + owner = create_collection_owner_with(3) + lambda { + owner.should_not have(3).items_in_collection_with_length_method + }.should fail_with("expected target not to have 3 items_in_collection_with_length_method, got 3") + lambda { + owner.should_not have(3).items_in_collection_with_size_method + }.should fail_with("expected target not to have 3 items_in_collection_with_size_method, got 3") + end +end + +describe "should have_exactly(n).items" do + include HaveSpecHelper + + it "should pass if target has a collection of items with n members" do + owner = create_collection_owner_with(3) + owner.should have_exactly(3).items_in_collection_with_length_method + owner.should have_exactly(3).items_in_collection_with_size_method + end + + it "should convert :no to 0" do + owner = create_collection_owner_with(0) + owner.should have_exactly(:no).items_in_collection_with_length_method + owner.should have_exactly(:no).items_in_collection_with_size_method + end + + it "should fail if target has a collection of items with < n members" do + owner = create_collection_owner_with(3) + lambda { + owner.should have_exactly(4).items_in_collection_with_length_method + }.should fail_with("expected 4 items_in_collection_with_length_method, got 3") + lambda { + owner.should have_exactly(4).items_in_collection_with_size_method + }.should fail_with("expected 4 items_in_collection_with_size_method, got 3") + end + + it "should fail if target has a collection of items with > n members" do + owner = create_collection_owner_with(3) + lambda { + owner.should have_exactly(2).items_in_collection_with_length_method + }.should fail_with("expected 2 items_in_collection_with_length_method, got 3") + lambda { + owner.should have_exactly(2).items_in_collection_with_size_method + }.should fail_with("expected 2 items_in_collection_with_size_method, got 3") + end +end + +describe "should have_at_least(n).items" do + include HaveSpecHelper + + it "should pass if target has a collection of items with n members" do + owner = create_collection_owner_with(3) + owner.should have_at_least(3).items_in_collection_with_length_method + owner.should have_at_least(3).items_in_collection_with_size_method + end + + it "should pass if target has a collection of items with > n members" do + owner = create_collection_owner_with(3) + owner.should have_at_least(2).items_in_collection_with_length_method + owner.should have_at_least(2).items_in_collection_with_size_method + end + + it "should fail if target has a collection of items with < n members" do + owner = create_collection_owner_with(3) + lambda { + owner.should have_at_least(4).items_in_collection_with_length_method + }.should fail_with("expected at least 4 items_in_collection_with_length_method, got 3") + lambda { + owner.should have_at_least(4).items_in_collection_with_size_method + }.should fail_with("expected at least 4 items_in_collection_with_size_method, got 3") + end + + it "should provide educational negative failure messages" do + #given + owner = create_collection_owner_with(3) + length_matcher = have_at_least(3).items_in_collection_with_length_method + size_matcher = have_at_least(3).items_in_collection_with_size_method + + #when + length_matcher.matches?(owner) + size_matcher.matches?(owner) + + #then + length_matcher.failure_message_for_should_not.should == <<-EOF +Isn't life confusing enough? +Instead of having to figure out the meaning of this: + should_not have_at_least(3).items_in_collection_with_length_method +We recommend that you use this instead: + should have_at_most(2).items_in_collection_with_length_method +EOF + + size_matcher.failure_message_for_should_not.should == <<-EOF +Isn't life confusing enough? +Instead of having to figure out the meaning of this: + should_not have_at_least(3).items_in_collection_with_size_method +We recommend that you use this instead: + should have_at_most(2).items_in_collection_with_size_method +EOF + end +end + +describe "should have_at_most(n).items" do + include HaveSpecHelper + + it "should pass if target has a collection of items with n members" do + owner = create_collection_owner_with(3) + owner.should have_at_most(3).items_in_collection_with_length_method + owner.should have_at_most(3).items_in_collection_with_size_method + end + + it "should fail if target has a collection of items with > n members" do + owner = create_collection_owner_with(3) + lambda { + owner.should have_at_most(2).items_in_collection_with_length_method + }.should fail_with("expected at most 2 items_in_collection_with_length_method, got 3") + lambda { + owner.should have_at_most(2).items_in_collection_with_size_method + }.should fail_with("expected at most 2 items_in_collection_with_size_method, got 3") + end + + it "should pass if target has a collection of items with < n members" do + owner = create_collection_owner_with(3) + owner.should have_at_most(4).items_in_collection_with_length_method + owner.should have_at_most(4).items_in_collection_with_size_method + end + + it "should provide educational negative failure messages" do + #given + owner = create_collection_owner_with(3) + length_matcher = have_at_most(3).items_in_collection_with_length_method + size_matcher = have_at_most(3).items_in_collection_with_size_method + + #when + length_matcher.matches?(owner) + size_matcher.matches?(owner) + + #then + length_matcher.failure_message_for_should_not.should == <<-EOF +Isn't life confusing enough? +Instead of having to figure out the meaning of this: + should_not have_at_most(3).items_in_collection_with_length_method +We recommend that you use this instead: + should have_at_least(4).items_in_collection_with_length_method +EOF + + size_matcher.failure_message_for_should_not.should == <<-EOF +Isn't life confusing enough? +Instead of having to figure out the meaning of this: + should_not have_at_most(3).items_in_collection_with_size_method +We recommend that you use this instead: + should have_at_least(4).items_in_collection_with_size_method +EOF + end +end + +describe "have(n).items(args, block)" do + it "should pass args to target" do + target = mock("target") + target.should_receive(:items).with("arg1","arg2").and_return([1,2,3]) + target.should have(3).items("arg1","arg2") + end + + it "should pass block to target" do + target = mock("target") + block = lambda { 5 } + target.should_receive(:items).with("arg1","arg2", block).and_return([1,2,3]) + target.should have(3).items("arg1","arg2", block) + end +end + +describe "have(n).items where target IS a collection" do + it "should reference the number of items IN the collection" do + [1,2,3].should have(3).items + end + + it "should fail when the number of items IN the collection is not as expected" do + lambda { [1,2,3].should have(7).items }.should fail_with("expected 7 items, got 3") + end +end + +describe "have(n).characters where target IS a String" do + it "should pass if the length is correct" do + "this string".should have(11).characters + end + + it "should fail if the length is incorrect" do + lambda { "this string".should have(12).characters }.should fail_with("expected 12 characters, got 11") + end +end + +describe "have(n).things on an object which is not a collection nor contains one" do + it "should fail" do + lambda { Object.new.should have(2).things }.should raise_error(NoMethodError, /undefined method `things' for # false + + describe "respond_to?" do + before :each do + @have = Have.new(:foo) + @a_method_which_have_defines = Have.instance_methods.first + @a_method_which_object_defines = Object.instance_methods.first + end + + it "should be true for a method which Have defines" do + @have.should respond_to(@a_method_which_have_defines) + end + + it "should be true for a method that it's superclass (Object) defines" do + @have.should respond_to(@a_method_which_object_defines) + end + + it "should be false for a method which neither Object nor nor Have defines" do + @have.should_not respond_to(:foo_bar_baz) + end + + it "should be false if the owner doesn't respond to the method" do + have = Have.new(99) + have.should_not respond_to(:problems) + end + + it "should be true if the owner responds to the method" do + have = Have.new(:a_symbol) + have.should respond_to(:to_sym) + end + end + end + end +end diff --git a/vendor/gems/gems/rspec-1.2.9/spec/spec/matchers/include_spec.rb b/vendor/gems/gems/rspec-1.2.9/spec/spec/matchers/include_spec.rb new file mode 100755 index 00000000..2b959b58 --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/spec/spec/matchers/include_spec.rb @@ -0,0 +1,88 @@ +require 'spec_helper' + +describe "should include(expected)" do + it "should pass if target includes expected" do + [1,2,3].should include(3) + "abc".should include("a") + end + + it 'should pass if target is a Hash and has the expected as a key' do + {:key => 'value'}.should include(:key) + end + + it "should fail if target does not include expected" do + lambda { + [1,2,3].should include(4) + }.should fail_with("expected [1, 2, 3] to include 4") + lambda { + "abc".should include("d") + }.should fail_with("expected \"abc\" to include \"d\"") + lambda { + {:key => 'value'}.should include(:other) + }.should fail_with(%Q|expected {:key=>"value"} to include :other|) + end +end + +describe "should include(with, multiple, args)" do + it "should pass if target includes all items" do + [1,2,3].should include(1,2,3) + end + + it 'should pass if target is a Hash including all items as keys' do + {:key => 'value', :other => 'value'}.should include(:key, :other) + end + + it "should fail if target does not include any one of the items" do + lambda { + [1,2,3].should include(1,2,4) + }.should fail_with("expected [1, 2, 3] to include 1, 2, and 4") + end + + it 'should pass if target is a Hash missing any item as a key' do + lambda { + {:key => 'value'}.should include(:key, :other) + }.should fail_with(%Q|expected {:key=>"value"} to include :key and :other|) + end +end + +describe "should_not include(expected)" do + it "should pass if target does not include expected" do + [1,2,3].should_not include(4) + "abc".should_not include("d") + end + + it 'should pass if target is a Hash and does not have the expected as a key' do + {:other => 'value'}.should_not include(:key) + end + + it "should fail if target includes expected" do + lambda { + [1,2,3].should_not include(3) + }.should fail_with("expected [1, 2, 3] not to include 3") + lambda { + "abc".should_not include("c") + }.should fail_with("expected \"abc\" not to include \"c\"") + lambda { + {:key => 'value'}.should_not include(:key) + }.should fail_with(%Q|expected {:key=>"value"} not to include :key|) + end +end + +describe "should include(:key => value)" do + it "should pass if target is a Hash and includes the key/value pair" do + {:key => 'value'}.should include(:key => 'value') + end + it "should pass if target is a Hash and includes the key/value pair among others" do + {:key => 'value', :other => 'different'}.should include(:key => 'value') + end + it "should fail if target is a Hash and has a different value for key" do + lambda { + {:key => 'different'}.should include(:key => 'value') + }.should fail_with(%Q|expected {:key=>"different"} to include {:key=>"value"}|) + end + it "should fail if target is a Hash and has a different key" do + lambda { + {:other => 'value'}.should include(:key => 'value') + }.should fail_with(%Q|expected {:other=>"value"} to include {:key=>"value"}|) + end +end diff --git a/vendor/gems/gems/rspec-1.2.9/spec/spec/matchers/match_array_spec.rb b/vendor/gems/gems/rspec-1.2.9/spec/spec/matchers/match_array_spec.rb new file mode 100755 index 00000000..be75ec16 --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/spec/spec/matchers/match_array_spec.rb @@ -0,0 +1,108 @@ +require 'spec_helper' + +class UnsortableObject + def initialize(id) + @id = id + end + + def inspect + @id.to_s + end + + def ==(other) + false + end +end + +describe "array.should =~ other_array" do + it "should pass if target contains all items" do + [1,2,3].should =~ [1,2,3] + end + + it "should pass if target contains all items out of order" do + [1,3,2].should =~ [1,2,3] + end + + it "should fail if target includes extra items" do + lambda { + [1,2,3,4].should =~ [1,2,3] + }.should fail_with(<<-MESSAGE) +expected collection contained: [1, 2, 3] +actual collection contained: [1, 2, 3, 4] +the extra elements were: [4] +MESSAGE + end + + it "should fail if target is missing items" do + lambda { + [1,2].should =~ [1,2,3] + }.should fail_with(<<-MESSAGE) +expected collection contained: [1, 2, 3] +actual collection contained: [1, 2] +the missing elements were: [3] +MESSAGE + end + + it "should fail if target is missing items and has extra items" do + + lambda { + [1,2,4].should =~ [1,2,3] + }.should fail_with(<<-MESSAGE) +expected collection contained: [1, 2, 3] +actual collection contained: [1, 2, 4] +the missing elements were: [3] +the extra elements were: [4] +MESSAGE + end + + it "should sort items in the error message if they all respond to <=>" do + lambda { + [6,2,1,5].should =~ [4,1,2,3] + }.should fail_with(<<-MESSAGE) +expected collection contained: [1, 2, 3, 4] +actual collection contained: [1, 2, 5, 6] +the missing elements were: [3, 4] +the extra elements were: [5, 6] +MESSAGE + end + + it "should not sort items in the error message if they don't all respond to <=>" do + lambda { + [UnsortableObject.new(2), UnsortableObject.new(1)].should =~ [UnsortableObject.new(4), UnsortableObject.new(3)] + }.should fail_with(<<-MESSAGE) +expected collection contained: [4, 3] +actual collection contained: [2, 1] +the missing elements were: [4, 3] +the extra elements were: [2, 1] +MESSAGE + end + + it "should accurately report extra elements when there are duplicates" do + lambda { + [1,1,1,5].should =~ [1,5] + }.should fail_with(<<-MESSAGE) +expected collection contained: [1, 5] +actual collection contained: [1, 1, 1, 5] +the extra elements were: [1, 1] +MESSAGE + end + + it "should accurately report missing elements when there are duplicates" do + lambda { + [1,5].should =~ [1,1,5] + }.should fail_with(<<-MESSAGE) +expected collection contained: [1, 1, 5] +actual collection contained: [1, 5] +the missing elements were: [1] +MESSAGE + end + +end + +describe "should_not =~ [:with, :multiple, :args]" do + it "should not be supported" do + lambda { + [1,2,3].should_not =~ [1,2,3] + }.should fail_with(/Matcher does not support should_not/) + end +end diff --git a/vendor/gems/gems/rspec-1.2.9/spec/spec/matchers/match_spec.rb b/vendor/gems/gems/rspec-1.2.9/spec/spec/matchers/match_spec.rb new file mode 100755 index 00000000..e5dc800a --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/spec/spec/matchers/match_spec.rb @@ -0,0 +1,57 @@ +require 'spec_helper' + +describe "should match(expected)" do + it "should pass when target (String) matches expected (Regexp)" do + "string".should match(/tri/) + end + + it "should pass when target (String) matches expected (String)" do + "string".should match("tri") + end + + it "should fail when target (String) does not match expected (Regexp)" do + lambda { + "string".should match(/rings/) + }.should fail + end + + it "should fail when target (String) does not match expected (String)" do + lambda { + "string".should match("rings") + }.should fail + end + + it "should provide message, expected and actual on failure" do + matcher = match(/rings/) + matcher.matches?("string") + matcher.failure_message_for_should.should == "expected \"string\" to match /rings/" + end +end + +describe "should_not match(expected)" do + it "should pass when target (String) matches does not match (Regexp)" do + "string".should_not match(/rings/) + end + + it "should pass when target (String) matches does not match (String)" do + "string".should_not match("rings") + end + + it "should fail when target (String) matches expected (Regexp)" do + lambda { + "string".should_not match(/tri/) + }.should fail + end + + it "should fail when target (String) matches expected (String)" do + lambda { + "string".should_not match("tri") + }.should fail + end + + it "should provide message, expected and actual on failure" do + matcher = match(/tri/) + matcher.matches?("string") + matcher.failure_message_for_should_not.should == "expected \"string\" not to match /tri/" + end +end diff --git a/vendor/gems/gems/rspec-1.2.9/spec/spec/matchers/matcher_methods_spec.rb b/vendor/gems/gems/rspec-1.2.9/spec/spec/matchers/matcher_methods_spec.rb new file mode 100755 index 00000000..291a2afa --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/spec/spec/matchers/matcher_methods_spec.rb @@ -0,0 +1,63 @@ +require 'spec_helper' + +module Spec + module Matchers + context %Q{The Spec::Matchers module gets included in the execution context of every spec. +This module should provide the following methods, each of which returns a Matcher object.} do + it "be_true" do + be_true.should be_an_instance_of(Be) + end + it "be_false" do + be_false.should be_an_instance_of(Be) + end + it "be_nil" do + be_nil.should be_an_instance_of(Be) + end + it "be_arbitrary_predicate" do + be_arbitrary_predicate.should be_an_instance_of(Be) + end + it "change" do + change("target", :message).should be_an_instance_of(Change) + end + it "have" do + have(0).should be_an_instance_of(Have) + end + it "have_exactly" do + have_exactly(0).should be_an_instance_of(Have) + end + it "have_at_least" do + have_at_least(0).should be_an_instance_of(Have) + end + it "have_at_most" do + have_at_most(0).should be_an_instance_of(Have) + end + it "raise_error" do + raise_error.should be_an_instance_of(RaiseError) + raise_error(NoMethodError).should be_an_instance_of(RaiseError) + raise_error(NoMethodError, "message").should be_an_instance_of(RaiseError) + end + it "satisfy" do + satisfy{}.should be_an_instance_of(Satisfy) + end + it "throw_symbol" do + throw_symbol.should be_an_instance_of(ThrowSymbol) + throw_symbol(:sym).should be_an_instance_of(ThrowSymbol) + end + it "respond_to" do + respond_to(:sym).should be_an_instance_of(RespondTo) + end + end + + describe "Spec::Matchers#method_missing" do + it "should convert be_xyz to Be(:be_xyz)" do + Be.should_receive(:new).with(:be_whatever) + be_whatever + end + + it "should convert have_xyz to Has(:have_xyz)" do + Has.should_receive(:new).with(:have_whatever) + have_whatever + end + end + end +end diff --git a/vendor/gems/gems/rspec-1.2.9/spec/spec/matchers/matcher_spec.rb b/vendor/gems/gems/rspec-1.2.9/spec/spec/matchers/matcher_spec.rb new file mode 100755 index 00000000..76b2e260 --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/spec/spec/matchers/matcher_spec.rb @@ -0,0 +1,228 @@ +require 'spec_helper' + +module Spec + module Matchers + describe Matcher do + context "without overrides" do + before(:each) do + @matcher = Spec::Matchers::Matcher.new(:be_a_multiple_of, 3) do |multiple| + match do |actual| + actual % multiple == 0 + end + end + end + + it "provides a default description" do + @matcher.description.should == "be a multiple of 3" + end + + it "provides a default failure message for #should" do + @matcher.matches?(8) + @matcher.failure_message_for_should.should == "expected 8 to be a multiple of 3" + end + + it "provides a default failure message for #should_not" do + @matcher.matches?(9) + @matcher.failure_message_for_should_not.should == "expected 9 not to be a multiple of 3" + end + end + + it "is not diffable by default" do + matcher = Spec::Matchers::Matcher.new(:name) {} + matcher.should_not be_diffable + end + + it "is diffable when told to be" do + matcher = Spec::Matchers::Matcher.new(:name) { diffable } + matcher.should be_diffable + end + + it "provides expected" do + matcher = Spec::Matchers::Matcher.new(:name, 'expected string') {} + matcher.expected.should == ['expected string'] + end + + it "provides actual" do + matcher = Spec::Matchers::Matcher.new(:name, 'expected string') do + match {|actual|} + end + + matcher.matches?('actual string') + + matcher.actual.should == 'actual string' + end + + context "with overrides" do + before(:each) do + @matcher = Spec::Matchers::Matcher.new(:be_boolean, true) do |boolean| + match do |actual| + actual + end + description do + "be the boolean #{boolean}" + end + failure_message_for_should do |actual| + "expected #{actual} to be the boolean #{boolean}" + end + failure_message_for_should_not do |actual| + "expected #{actual} not to be the boolean #{boolean}" + end + end + end + + it "does not hide result of match block when true" do + @matcher.matches?(true).should be_true + end + + it "does not hide result of match block when false" do + @matcher.matches?(false).should be_false + end + + it "overrides the description" do + @matcher.description.should == "be the boolean true" + end + + it "overrides the failure message for #should" do + @matcher.matches?(false) + @matcher.failure_message_for_should.should == "expected false to be the boolean true" + end + + it "overrides the failure message for #should_not" do + @matcher.matches?(true) + @matcher.failure_message_for_should_not.should == "expected true not to be the boolean true" + end + end + + context "#new" do + it "passes matches? arg to match block" do + matcher = Spec::Matchers::Matcher.new(:ignore) do + match do |actual| + actual == 5 + end + end + matcher.matches?(5).should be_true + end + + it "exposes arg submitted through #new to matcher block" do + matcher = Spec::Matchers::Matcher.new(:ignore, 4) do |expected| + match do |actual| + actual > expected + end + end + matcher.matches?(5).should be_true + end + end + + context "with no args" do + before(:each) do + @matcher = Spec::Matchers::Matcher.new(:matcher_name) do + match do |actual| + actual == 5 + end + end + end + + it "matches" do + @matcher.matches?(5).should be_true + end + + it "describes" do + @matcher.description.should == "matcher name" + end + end + + context "with 1 arg" do + before(:each) do + @matcher = Spec::Matchers::Matcher.new(:matcher_name, 1) do |expected| + match do |actual| + actual == 5 && expected == 1 + end + end + end + + it "matches" do + @matcher.matches?(5).should be_true + end + + it "describes" do + @matcher.description.should == "matcher name 1" + end + end + + context "with multiple args" do + before(:each) do + @matcher = Spec::Matchers::Matcher.new(:matcher_name, 1, 2, 3, 4) do |a,b,c,d| + match do |sum| + a + b + c + d == sum + end + end + end + + it "matches" do + @matcher.matches?(10).should be_true + end + + it "describes" do + @matcher.description.should == "matcher name 1, 2, 3, and 4" + end + end + + it "supports helper methods" do + matcher = Spec::Matchers::Matcher.new(:be_similar_to, [1,2,3]) do |sample| + match do |actual| + similar?(sample, actual) + end + + def similar?(a, b) + a.sort == b.sort + end + end + + matcher.matches?([2,3,1]).should be_true + end + + it "supports fluent interface" do + matcher = Spec::Matchers::Matcher.new(:first_word) do + def second_word + self + end + end + + matcher.second_word.should == matcher + end + + it "treats method missing normally for undeclared methods" do + matcher = Spec::Matchers::Matcher.new(:ignore) { } + expect { matcher.non_existent_method }.to raise_error(NoMethodError) + end + + it "has access to other matchers" do + matcher = Spec::Matchers::Matcher.new(:ignore, 3) do |expected| + match do |actual| + extend Spec::Matchers + actual.should eql(5 + expected) + end + end + + matcher.matches?(8).should be_true + end + + it "lets you override the actual() in messages" do + matcher = Spec::Matchers::Matcher.new(:be_foo) do + match do |actual| + @submitted = actual + false + end + + def actual + "replaced" + end + end + + matcher.matches?("foo") + matcher.failure_message_for_should.should =~ /replaced/ + end + + end + end +end diff --git a/vendor/gems/gems/rspec-1.2.9/spec/spec/matchers/matchers_spec.rb b/vendor/gems/gems/rspec-1.2.9/spec/spec/matchers/matchers_spec.rb new file mode 100755 index 00000000..51f5efc4 --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/spec/spec/matchers/matchers_spec.rb @@ -0,0 +1,2 @@ +require 'spec_helper' + diff --git a/vendor/gems/gems/rspec-1.2.9/spec/spec/matchers/operator_matcher_spec.rb b/vendor/gems/gems/rspec-1.2.9/spec/spec/matchers/operator_matcher_spec.rb new file mode 100755 index 00000000..86e637e0 --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/spec/spec/matchers/operator_matcher_spec.rb @@ -0,0 +1,191 @@ +require 'spec_helper' + +require 'spec/runner/differs/default' + +describe "should ==" do + + it "should delegate message to target" do + subject = "apple" + subject.should_receive(:==).with("apple").and_return(true) + subject.should == "apple" + end + + it "should return true on success" do + subject = "apple" + (subject.should == "apple").should be_true + end + + it "should fail when target.==(actual) returns false" do + subject = "apple" + Spec::Expectations.should_receive(:fail_with).with(%[expected: "orange",\n got: "apple" (using ==)], "orange", "apple") + subject.should == "orange" + end + +end + +describe "should_not ==" do + + it "should delegate message to target" do + subject = "orange" + subject.should_receive(:==).with("apple").and_return(false) + subject.should_not == "apple" + end + + it "should return true on success" do + subject = "apple" + (subject.should_not == "orange").should be_false + end + + it "should fail when target.==(actual) returns false" do + subject = "apple" + Spec::Expectations.should_receive(:fail_with).with(%[expected not: == "apple",\n got: "apple"], "apple", "apple") + subject.should_not == "apple" + end + +end + +describe "should ===" do + + it "should delegate message to target" do + subject = "apple" + subject.should_receive(:===).with("apple").and_return(true) + subject.should === "apple" + end + + it "should fail when target.===(actual) returns false" do + subject = "apple" + subject.should_receive(:===).with("orange").and_return(false) + Spec::Expectations.should_receive(:fail_with).with(%[expected: "orange",\n got: "apple" (using ===)], "orange", "apple") + subject.should === "orange" + end + +end + +describe "should_not ===" do + + it "should delegate message to target" do + subject = "orange" + subject.should_receive(:===).with("apple").and_return(false) + subject.should_not === "apple" + end + + it "should fail when target.===(actual) returns false" do + subject = "apple" + subject.should_receive(:===).with("apple").and_return(true) + Spec::Expectations.should_receive(:fail_with).with(%[expected not: === "apple",\n got: "apple"], "apple", "apple") + subject.should_not === "apple" + end + +end + +describe "should =~" do + + it "should delegate message to target" do + subject = "foo" + subject.should_receive(:=~).with(/oo/).and_return(true) + subject.should =~ /oo/ + end + + it "should fail when target.=~(actual) returns false" do + subject = "fu" + subject.should_receive(:=~).with(/oo/).and_return(false) + Spec::Expectations.should_receive(:fail_with).with(%[expected: /oo/,\n got: "fu" (using =~)], /oo/, "fu") + subject.should =~ /oo/ + end + +end + +describe "should_not =~" do + + it "should delegate message to target" do + subject = "fu" + subject.should_receive(:=~).with(/oo/).and_return(false) + subject.should_not =~ /oo/ + end + + it "should fail when target.=~(actual) returns false" do + subject = "foo" + subject.should_receive(:=~).with(/oo/).and_return(true) + Spec::Expectations.should_receive(:fail_with).with(%[expected not: =~ /oo/,\n got: "foo"], /oo/, "foo") + subject.should_not =~ /oo/ + end + +end + +describe "should >" do + + it "should pass if > passes" do + 4.should > 3 + end + + it "should fail if > fails" do + Spec::Expectations.should_receive(:fail_with).with(%[expected: > 5,\n got: 4], 5, 4) + 4.should > 5 + end + +end + +describe "should >=" do + + it "should pass if >= passes" do + 4.should > 3 + 4.should >= 4 + end + + it "should fail if > fails" do + Spec::Expectations.should_receive(:fail_with).with(%[expected: >= 5,\n got: 4], 5, 4) + 4.should >= 5 + end + +end + +describe "should <" do + + it "should pass if < passes" do + 4.should < 5 + end + + it "should fail if > fails" do + Spec::Expectations.should_receive(:fail_with).with(%[expected: < 3,\n got: 4], 3, 4) + 4.should < 3 + end + +end + +describe "should <=" do + + it "should pass if <= passes" do + 4.should <= 5 + 4.should <= 4 + end + + it "should fail if > fails" do + Spec::Expectations.should_receive(:fail_with).with(%[expected: <= 3,\n got: 4], 3, 4) + 4.should <= 3 + end + +end + +describe Spec::Matchers::PositiveOperatorMatcher do + + it "should work when the target has implemented #send" do + o = Object.new + def o.send(*args); raise "DOH! Library developers shouldn't use #send!" end + lambda { + o.should == o + }.should_not raise_error + end + +end + +describe Spec::Matchers::NegativeOperatorMatcher do + + it "should work when the target has implemented #send" do + o = Object.new + def o.send(*args); raise "DOH! Library developers shouldn't use #send!" end + lambda { + o.should_not == :foo + }.should_not raise_error + end + +end diff --git a/vendor/gems/gems/rspec-1.2.9/spec/spec/matchers/raise_error_spec.rb b/vendor/gems/gems/rspec-1.2.9/spec/spec/matchers/raise_error_spec.rb new file mode 100755 index 00000000..785065ad --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/spec/spec/matchers/raise_error_spec.rb @@ -0,0 +1,333 @@ +require 'spec_helper' + +describe "should raise_error" do + it "should pass if anything is raised" do + lambda {raise}.should raise_error + end + + it "should fail if nothing is raised" do + lambda { + lambda {}.should raise_error + }.should fail_with("expected Exception but nothing was raised") + end +end + +describe "should raise_error {|err| ... }" do + it "passes if there is an error" do + ran = false + lambda { non_existent_method }.should raise_error {|e| + ran = true + } + ran.should be_true + end + + it "passes the error to the block" do + error = nil + lambda { non_existent_method }.should raise_error {|e| + error = e + } + error.should be_kind_of(NameError) + end +end + +describe "should_not raise_error" do + it "should pass if nothing is raised" do + lambda {}.should_not raise_error + end + + it "should fail if anything is raised" do + lambda { + lambda {raise}.should_not raise_error + }.should fail_with("expected no Exception, got RuntimeError") + end +end + +describe "should raise_error(message)" do + it "should pass if RuntimeError is raised with the right message" do + lambda {raise 'blah'}.should raise_error('blah') + end + it "should pass if RuntimeError is raised with a matching message" do + lambda {raise 'blah'}.should raise_error(/blah/) + end + it "should pass if any other error is raised with the right message" do + lambda {raise NameError.new('blah')}.should raise_error('blah') + end + it "should fail if RuntimeError error is raised with the wrong message" do + lambda do + lambda {raise 'blarg'}.should raise_error('blah') + end.should fail_with("expected Exception with \"blah\", got #") + end + it "should fail if any other error is raised with the wrong message" do + lambda do + lambda {raise NameError.new('blarg')}.should raise_error('blah') + end.should fail_with("expected Exception with \"blah\", got #") + end +end + +describe "should_not raise_error(message)" do + it "should pass if RuntimeError error is raised with the different message" do + lambda {raise 'blarg'}.should_not raise_error('blah') + end + it "should pass if any other error is raised with the wrong message" do + lambda {raise NameError.new('blarg')}.should_not raise_error('blah') + end + it "should fail if RuntimeError is raised with message" do + lambda do + lambda {raise 'blah'}.should_not raise_error('blah') + end.should fail_with(%Q|expected no Exception with "blah", got #|) + end + it "should fail if any other error is raised with message" do + lambda do + lambda {raise NameError.new('blah')}.should_not raise_error('blah') + end.should fail_with(%Q|expected no Exception with "blah", got #|) + end +end + +describe "should raise_error(NamedError)" do + it "should pass if named error is raised" do + lambda { non_existent_method }.should raise_error(NameError) + end + + it "should fail if nothing is raised" do + lambda { + lambda { }.should raise_error(NameError) + }.should fail_with("expected NameError but nothing was raised") + end + + it "should fail if another error is raised (NameError)" do + lambda { + lambda { raise }.should raise_error(NameError) + }.should fail_with("expected NameError, got RuntimeError") + end + + it "should fail if another error is raised (NameError)" do + lambda { + lambda { load "non/existent/file" }.should raise_error(NameError) + }.should fail_with(/expected NameError, got #") + + ran.should == false + end + + it "should NOT yield exception if error message is not matched" do + ran = false + + lambda { + lambda { + raise "example message" + }.should raise_error(RuntimeError, "different message") { |err| + ran = true + } + }.should fail_with("expected RuntimeError with \"different message\", got #") + + ran.should == false + end +end + +describe "should_not raise_error(NamedError, error_message) { |err| ... }" do + it "should pass if nothing is raised" do + ran = false + + lambda {}.should_not raise_error(RuntimeError, "example message") { |err| + ran = true + } + + ran.should == false + end + + it "should pass if a different error is raised" do + ran = false + + lambda { raise }.should_not raise_error(NameError, "example message") { |err| + ran = true + } + + ran.should == false + end + + it "should pass if same error is raised with different message" do + ran = false + + lambda { + raise RuntimeError.new("not the example message") + }.should_not raise_error(RuntimeError, "example message") { |err| + ran = true + } + + ran.should == false + end + + it "should fail if named error is raised with same message" do + ran = false + + lambda { + lambda { + raise "example message" + }.should_not raise_error(RuntimeError, "example message") { |err| + ran = true + } + }.should fail_with("expected no RuntimeError with \"example message\", got #") + + ran.should == false + end +end + +describe "should_not raise_error(NamedError, error_message) with String" do + it "should pass if nothing is raised" do + lambda {}.should_not raise_error(RuntimeError, "example message") + end + + it "should pass if a different error is raised" do + lambda { raise }.should_not raise_error(NameError, "example message") + end + + it "should pass if same error is raised with different message" do + lambda { raise RuntimeError.new("not the example message") }.should_not raise_error(RuntimeError, "example message") + end + + it "should fail if named error is raised with same message" do + lambda { + lambda { raise "example message" }.should_not raise_error(RuntimeError, "example message") + }.should fail_with("expected no RuntimeError with \"example message\", got #") + end +end + +describe "should raise_error(NamedError, error_message) with Regexp" do + it "should pass if named error is raised with matching message" do + lambda { raise "example message" }.should raise_error(RuntimeError, /ample mess/) + end + + it "should fail if nothing is raised" do + lambda { + lambda {}.should raise_error(RuntimeError, /ample mess/) + }.should fail_with("expected RuntimeError with message matching /ample mess/ but nothing was raised") + end + + it "should fail if incorrect error is raised" do + lambda { + lambda { raise }.should raise_error(NameError, /ample mess/) + }.should fail_with("expected NameError with message matching /ample mess/, got RuntimeError") + end + + it "should fail if correct error is raised with incorrect message" do + lambda { + lambda { raise RuntimeError.new("not the example message") }.should raise_error(RuntimeError, /less than ample mess/) + }.should fail_with("expected RuntimeError with message matching /less than ample mess/, got #") + end +end + +describe "should_not raise_error(NamedError, error_message) with Regexp" do + it "should pass if nothing is raised" do + lambda {}.should_not raise_error(RuntimeError, /ample mess/) + end + + it "should pass if a different error is raised" do + lambda { raise }.should_not raise_error(NameError, /ample mess/) + end + + it "should pass if same error is raised with non-matching message" do + lambda { raise RuntimeError.new("non matching message") }.should_not raise_error(RuntimeError, /ample mess/) + end + + it "should fail if named error is raised with matching message" do + lambda { + lambda { raise "example message" }.should_not raise_error(RuntimeError, /ample mess/) + }.should fail_with("expected no RuntimeError with message matching /ample mess/, got #") + end +end diff --git a/vendor/gems/gems/rspec-1.2.9/spec/spec/matchers/respond_to_spec.rb b/vendor/gems/gems/rspec-1.2.9/spec/spec/matchers/respond_to_spec.rb new file mode 100755 index 00000000..8d8f3c1a --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/spec/spec/matchers/respond_to_spec.rb @@ -0,0 +1,116 @@ +require 'spec_helper' + +describe "should respond_to(:sym)" do + + it "passes if target responds to :sym" do + Object.new.should respond_to(:methods) + end + + it "fails if target does not respond to :sym" do + lambda { + "this string".should respond_to(:some_method) + }.should fail_with(%q|expected "this string" to respond to :some_method|) + end + +end + +describe "should respond_to(:sym).with(1).argument" do + it "passes if target responds to :sym with 1 arg" do + obj = Object.new + def obj.foo(arg); end + obj.should respond_to(:foo).with(1).argument + end + + it "fails if target does not respond to :sym" do + obj = Object.new + lambda { + obj.should respond_to(:some_method).with(1).argument + }.should fail_with(/expected .* to respond to :some_method/) + end + + it "fails if :sym expects 0 args" do + obj = Object.new + def obj.foo; end + lambda { + obj.should respond_to(:foo).with(1).argument + }.should fail_with(/expected # to respond to :foo with 1 argument/) + end + + it "fails if :sym expects 2 args" do + obj = Object.new + def obj.foo(arg, arg2); end + lambda { + obj.should respond_to(:foo).with(1).argument + }.should fail_with(/expected # to respond to :foo with 1 argument/) + end +end + +describe "should respond_to(message1, message2)" do + + it "passes if target responds to both messages" do + Object.new.should respond_to('methods', 'inspect') + end + + it "fails if target does not respond to first message" do + lambda { + Object.new.should respond_to('method_one', 'inspect') + }.should fail_with(/expected # to respond to "method_one"/) + end + + it "fails if target does not respond to second message" do + lambda { + Object.new.should respond_to('inspect', 'method_one') + }.should fail_with(/expected # to respond to "method_one"/) + end + + it "fails if target does not respond to either message" do + lambda { + Object.new.should respond_to('method_one', 'method_two') + }.should fail_with(/expected # to respond to "method_one", "method_two"/) + end +end + +describe "should respond_to(:sym).with(2).arguments" do + it "passes if target responds to :sym with 2 args" do + obj = Object.new + def obj.foo(a1, a2); end + obj.should respond_to(:foo).with(2).arguments + end + + it "fails if target does not respond to :sym" do + obj = Object.new + lambda { + obj.should respond_to(:some_method).with(2).arguments + }.should fail_with(/expected .* to respond to :some_method/) + end + + it "fails if :sym expects 0 args" do + obj = Object.new + def obj.foo; end + lambda { + obj.should respond_to(:foo).with(2).arguments + }.should fail_with(/expected # to respond to :foo with 2 arguments/) + end + + it "fails if :sym expects 2 args" do + obj = Object.new + def obj.foo(arg); end + lambda { + obj.should respond_to(:foo).with(2).arguments + }.should fail_with(/expected # to respond to :foo with 2 arguments/) + end +end + +describe "should_not respond_to(:sym)" do + + it "passes if target does not respond to :sym" do + Object.new.should_not respond_to(:some_method) + end + + it "fails if target responds to :sym" do + lambda { + Object.new.should_not respond_to(:methods) + }.should fail_with(/expected # not to respond to :methods/) + end + +end diff --git a/vendor/gems/gems/rspec-1.2.9/spec/spec/matchers/satisfy_spec.rb b/vendor/gems/gems/rspec-1.2.9/spec/spec/matchers/satisfy_spec.rb new file mode 100755 index 00000000..e50c395a --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/spec/spec/matchers/satisfy_spec.rb @@ -0,0 +1,36 @@ +require 'spec_helper' + +describe "should satisfy { block }" do + it "should pass if block returns true" do + true.should satisfy { |val| val } + true.should satisfy do |val| + val + end + end + + it "should fail if block returns false" do + lambda { + false.should satisfy { |val| val } + }.should fail_with("expected false to satisfy block") + lambda do + false.should satisfy do |val| + val + end + end.should fail_with("expected false to satisfy block") + end +end + +describe "should_not satisfy { block }" do + it "should pass if block returns false" do + false.should_not satisfy { |val| val } + false.should_not satisfy do |val| + val + end + end + + it "should fail if block returns true" do + lambda { + true.should_not satisfy { |val| val } + }.should fail_with("expected true not to satisfy block") + end +end diff --git a/vendor/gems/gems/rspec-1.2.9/spec/spec/matchers/simple_matcher_spec.rb b/vendor/gems/gems/rspec-1.2.9/spec/spec/matchers/simple_matcher_spec.rb new file mode 100755 index 00000000..8071a9f3 --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/spec/spec/matchers/simple_matcher_spec.rb @@ -0,0 +1,93 @@ +require 'spec_helper' + +module Spec + module Matchers + describe SimpleMatcher do + it "should pass match arg to block" do + actual = nil + matcher = simple_matcher("message") do |given| actual = given end + matcher.matches?("foo") + actual.should == "foo" + end + + it "should provide a stock failure message" do + matcher = simple_matcher("thing") do end + matcher.matches?("other") + matcher.failure_message.should =~ /expected \"thing\" but got \"other\"/ + end + + it "should provide a stock negative failure message" do + matcher = simple_matcher("thing") do end + matcher.matches?("other") + matcher.negative_failure_message.should =~ /expected not to get \"thing\", but got \"other\"/ + end + + it "should provide the given description" do + matcher = simple_matcher("thing") do end + matcher.description.should =="thing" + end + + it "should fail if a wrapped 'should' fails" do + matcher = simple_matcher("should fail") do + 2.should == 3 + end + lambda do + matcher.matches?("anything").should be_true + end.should fail_with(/expected: 3/) + end + end + + describe "with arity of 2" do + it "should provide the matcher so you can access its messages" do + provided_matcher = nil + matcher = simple_matcher("thing") do |given, matcher| + provided_matcher = matcher + end + matcher.matches?("anything") + provided_matcher.should equal(matcher) + end + + it "should support a custom failure message" do + matcher = simple_matcher("thing") do |given, matcher| + matcher.failure_message = "custom message" + end + matcher.matches?("other") + matcher.failure_message.should == "custom message" + end + + it "should complain when asked for a failure message if you don't give it a description or a message" do + matcher = simple_matcher do |given, matcher| end + matcher.matches?("other") + matcher.failure_message.should =~ /No description provided/ + end + + it "should support a custom negative failure message" do + matcher = simple_matcher("thing") do |given, matcher| + matcher.negative_failure_message = "custom message" + end + matcher.matches?("other") + matcher.negative_failure_message.should == "custom message" + end + + it "should complain when asked for a negative failure message if you don't give it a description or a message" do + matcher = simple_matcher do |given, matcher| end + matcher.matches?("other") + matcher.negative_failure_message.should =~ /No description provided/ + end + + it "should support a custom description" do + matcher = simple_matcher("thing") do |given, matcher| + matcher.description = "custom message" + end + matcher.matches?("description") + matcher.description.should == "custom message" + end + + it "should tell you no description was provided when it doesn't receive one" do + matcher = simple_matcher do end + matcher.description.should =~ /No description provided/ + end + end + + end +end \ No newline at end of file diff --git a/vendor/gems/gems/rspec-1.2.9/spec/spec/matchers/throw_symbol_spec.rb b/vendor/gems/gems/rspec-1.2.9/spec/spec/matchers/throw_symbol_spec.rb new file mode 100755 index 00000000..402f812f --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/spec/spec/matchers/throw_symbol_spec.rb @@ -0,0 +1,96 @@ +require 'spec_helper' + +module Spec + module Matchers + describe ThrowSymbol do + describe "with no args" do + before(:each) { @matcher = ThrowSymbol.new } + + it "should match if any Symbol is thrown" do + @matcher.matches?(lambda{ throw :sym }).should be_true + end + it "should match if any Symbol is thrown with an arg" do + @matcher.matches?(lambda{ throw :sym, "argument" }).should be_true + end + it "should not match if no Symbol is thrown" do + @matcher.matches?(lambda{ }).should be_false + end + it "should provide a failure message" do + @matcher.matches?(lambda{}) + @matcher.failure_message_for_should.should == "expected a Symbol but nothing was thrown" + end + it "should provide a negative failure message" do + @matcher.matches?(lambda{ throw :sym}) + @matcher.failure_message_for_should_not.should == "expected no Symbol, got :sym" + end + end + + describe "with a symbol" do + before(:each) { @matcher = ThrowSymbol.new(:sym) } + + it "should match if correct Symbol is thrown" do + @matcher.matches?(lambda{ throw :sym }).should be_true + end + it "should match if correct Symbol is thrown with an arg" do + @matcher.matches?(lambda{ throw :sym, "argument" }).should be_true + end + it "should not match if no Symbol is thrown" do + @matcher.matches?(lambda{ }).should be_false + end + it "should not match if correct Symbol is thrown" do + @matcher.matches?(lambda{ throw :other_sym }).should be_false + end + it "should provide a failure message when no Symbol is thrown" do + @matcher.matches?(lambda{}) + @matcher.failure_message_for_should.should == "expected :sym but nothing was thrown" + end + it "should provide a failure message when wrong Symbol is thrown" do + @matcher.matches?(lambda{ throw :other_sym }) + @matcher.failure_message_for_should.should == "expected :sym, got :other_sym" + end + it "should provide a negative failure message" do + @matcher.matches?(lambda{ throw :sym }) + @matcher.failure_message_for_should_not.should == "expected :sym not to be thrown" + end + it "should only match NameErrors raised by uncaught throws" do + @matcher.matches?(lambda{ sym }).should be_false + end + end + + describe "with a symbol and an arg" do + before(:each) { @matcher = ThrowSymbol.new(:sym, "a") } + + it "should match if correct Symbol and args are thrown" do + @matcher.matches?(lambda{ throw :sym, "a" }).should be_true + end + it "should not match if nothing is thrown" do + @matcher.matches?(lambda{ }).should be_false + end + it "should not match if other Symbol is thrown" do + @matcher.matches?(lambda{ throw :other_sym, "a" }).should be_false + end + it "should not match if no arg is thrown" do + @matcher.matches?(lambda{ throw :sym }).should be_false + end + it "should not match if wrong arg is thrown" do + @matcher.matches?(lambda{ throw :sym, "b" }).should be_false + end + it "should provide a failure message when no Symbol is thrown" do + @matcher.matches?(lambda{}) + @matcher.failure_message_for_should.should == %q[expected :sym with "a" but nothing was thrown] + end + it "should provide a failure message when wrong Symbol is thrown" do + @matcher.matches?(lambda{ throw :other_sym }) + @matcher.failure_message_for_should.should == %q[expected :sym with "a", got :other_sym] + end + it "should provide a negative failure message" do + @matcher.matches?(lambda{ throw :sym }) + @matcher.failure_message_for_should_not.should == %q[expected :sym with "a" not to be thrown] + end + it "should only match NameErrors raised by uncaught throws" do + @matcher.matches?(lambda{ sym }).should be_false + end + end + end + end +end diff --git a/vendor/gems/gems/rspec-1.2.9/spec/spec/mocks/any_number_of_times_spec.rb b/vendor/gems/gems/rspec-1.2.9/spec/spec/mocks/any_number_of_times_spec.rb new file mode 100755 index 00000000..9a3f6eda --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/spec/spec/mocks/any_number_of_times_spec.rb @@ -0,0 +1,36 @@ +require 'spec_helper' + +module Spec + module Mocks + + describe "AnyNumberOfTimes" do + before(:each) do + @mock = Mock.new("test mock") + end + + it "should pass if any number of times method is called many times" do + @mock.should_receive(:random_call).any_number_of_times + (1..10).each do + @mock.random_call + end + end + + it "should pass if any number of times method is called once" do + @mock.should_receive(:random_call).any_number_of_times + @mock.random_call + end + + it "should pass if any number of times method is not called" do + @mock.should_receive(:random_call).any_number_of_times + end + + it "should return the mocked value when called after a similar stub" do + @mock.stub!(:message).and_return :stub_value + @mock.should_receive(:message).any_number_of_times.and_return(:mock_value) + @mock.message.should == :mock_value + @mock.message.should == :mock_value + end + end + + end +end diff --git a/vendor/gems/gems/rspec-1.2.9/spec/spec/mocks/argument_expectation_spec.rb b/vendor/gems/gems/rspec-1.2.9/spec/spec/mocks/argument_expectation_spec.rb new file mode 100755 index 00000000..496f7507 --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/spec/spec/mocks/argument_expectation_spec.rb @@ -0,0 +1,23 @@ +require 'spec_helper' + +module Spec + module Mocks + describe ArgumentExpectation do + it "should consider an object that responds to #matches? and #description to be a matcher" do + argument_expecatation = Spec::Mocks::ArgumentExpectation.new([]) + obj = mock("matcher") + obj.should_receive(:respond_to?).with(:matches?).and_return(true) + obj.should_receive(:respond_to?).with(:description).and_return(true) + argument_expecatation.is_matcher?(obj).should be_true + end + + it "should NOT consider an object that only responds to #matches? to be a matcher" do + argument_expecatation = Spec::Mocks::ArgumentExpectation.new([]) + obj = mock("matcher") + obj.should_receive(:respond_to?).with(:matches?).and_return(true) + obj.should_receive(:respond_to?).with(:description).and_return(false) + argument_expecatation.is_matcher?(obj).should be_false + end + end + end +end diff --git a/vendor/gems/gems/rspec-1.2.9/spec/spec/mocks/argument_matchers_spec.rb b/vendor/gems/gems/rspec-1.2.9/spec/spec/mocks/argument_matchers_spec.rb new file mode 100755 index 00000000..fc816558 --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/spec/spec/mocks/argument_matchers_spec.rb @@ -0,0 +1,19 @@ +require 'spec_helper' + +module Spec + module Mocks + module ArgumentMatchers + describe AnyArgsMatcher do + it "represents itself nicely for failure messages" do + AnyArgsMatcher.new.description.should == "any args" + end + end + + describe AnyArgMatcher do + it "represents itself nicely for failure messages" do + AnyArgMatcher.new(nil).description.should == "anything" + end + end + end + end +end \ No newline at end of file diff --git a/vendor/gems/gems/rspec-1.2.9/spec/spec/mocks/at_least_spec.rb b/vendor/gems/gems/rspec-1.2.9/spec/spec/mocks/at_least_spec.rb new file mode 100755 index 00000000..0b76d321 --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/spec/spec/mocks/at_least_spec.rb @@ -0,0 +1,97 @@ +require 'spec_helper' + +module Spec + module Mocks + describe "at_least" do + before(:each) do + @mock = Mock.new("test mock") + end + + it "should fail if method is never called" do + @mock.should_receive(:random_call).at_least(4).times + lambda do + @mock.rspec_verify + end.should raise_error(MockExpectationError) + end + + it "should fail when called less than n times" do + @mock.should_receive(:random_call).at_least(4).times + @mock.random_call + @mock.random_call + @mock.random_call + lambda do + @mock.rspec_verify + end.should raise_error(MockExpectationError) + end + + it "should fail when at least once method is never called" do + @mock.should_receive(:random_call).at_least(:once) + lambda do + @mock.rspec_verify + end.should raise_error(MockExpectationError) + end + + it "should fail when at least twice method is called once" do + @mock.should_receive(:random_call).at_least(:twice) + @mock.random_call + lambda do + @mock.rspec_verify + end.should raise_error(MockExpectationError) + end + + it "should fail when at least twice method is never called" do + @mock.should_receive(:random_call).at_least(:twice) + lambda do + @mock.rspec_verify + end.should raise_error(MockExpectationError) + end + + it "should pass when at least n times method is called exactly n times" do + @mock.should_receive(:random_call).at_least(4).times + @mock.random_call + @mock.random_call + @mock.random_call + @mock.random_call + @mock.rspec_verify + end + + it "should pass when at least n times method is called n plus 1 times" do + @mock.should_receive(:random_call).at_least(4).times + @mock.random_call + @mock.random_call + @mock.random_call + @mock.random_call + @mock.random_call + @mock.rspec_verify + end + + it "should pass when at least once method is called once" do + @mock.should_receive(:random_call).at_least(:once) + @mock.random_call + @mock.rspec_verify + end + + it "should pass when at least once method is called twice" do + @mock.should_receive(:random_call).at_least(:once) + @mock.random_call + @mock.random_call + @mock.rspec_verify + end + + it "should pass when at least twice method is called three times" do + @mock.should_receive(:random_call).at_least(:twice) + @mock.random_call + @mock.random_call + @mock.random_call + @mock.rspec_verify + end + + it "should pass when at least twice method is called twice" do + @mock.should_receive(:random_call).at_least(:twice) + @mock.random_call + @mock.random_call + @mock.rspec_verify + end + end + end +end diff --git a/vendor/gems/gems/rspec-1.2.9/spec/spec/mocks/at_most_spec.rb b/vendor/gems/gems/rspec-1.2.9/spec/spec/mocks/at_most_spec.rb new file mode 100755 index 00000000..744c9ff1 --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/spec/spec/mocks/at_most_spec.rb @@ -0,0 +1,93 @@ +require 'spec_helper' + +module Spec + module Mocks + describe "at_most" do + before(:each) do + @mock = Mock.new("test mock") + end + + it "should fail when at most n times method is called n plus 1 times" do + @mock.should_receive(:random_call).at_most(4).times + @mock.random_call + @mock.random_call + @mock.random_call + @mock.random_call + @mock.random_call + lambda do + @mock.rspec_verify + end.should raise_error(MockExpectationError) + end + + it "should fail when at most once method is called twice" do + @mock.should_receive(:random_call).at_most(:once) + @mock.random_call + @mock.random_call + lambda do + @mock.rspec_verify + end.should raise_error(MockExpectationError) + end + + it "should fail when at most twice method is called three times" do + @mock.should_receive(:random_call).at_most(:twice) + @mock.random_call + @mock.random_call + @mock.random_call + lambda do + @mock.rspec_verify + end.should raise_error(MockExpectationError) + end + + it "should pass when at most n times method is called exactly n times" do + @mock.should_receive(:random_call).at_most(4).times + @mock.random_call + @mock.random_call + @mock.random_call + @mock.random_call + @mock.rspec_verify + end + + it "should pass when at most n times method is called less than n times" do + @mock.should_receive(:random_call).at_most(4).times + @mock.random_call + @mock.random_call + @mock.random_call + @mock.rspec_verify + end + + it "should pass when at most n times method is never called" do + @mock.should_receive(:random_call).at_most(4).times + @mock.rspec_verify + end + + it "should pass when at most once method is called once" do + @mock.should_receive(:random_call).at_most(:once) + @mock.random_call + @mock.rspec_verify + end + + it "should pass when at most once method is never called" do + @mock.should_receive(:random_call).at_most(:once) + @mock.rspec_verify + end + + it "should pass when at most twice method is called once" do + @mock.should_receive(:random_call).at_most(:twice) + @mock.random_call + @mock.rspec_verify + end + + it "should pass when at most twice method is called twice" do + @mock.should_receive(:random_call).at_most(:twice) + @mock.random_call + @mock.random_call + @mock.rspec_verify + end + + it "should pass when at most twice method is never called" do + @mock.should_receive(:random_call).at_most(:twice) + @mock.rspec_verify + end + end + end +end diff --git a/vendor/gems/gems/rspec-1.2.9/spec/spec/mocks/bug_report_10260_spec.rb b/vendor/gems/gems/rspec-1.2.9/spec/spec/mocks/bug_report_10260_spec.rb new file mode 100755 index 00000000..783782f6 --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/spec/spec/mocks/bug_report_10260_spec.rb @@ -0,0 +1,8 @@ +require 'spec_helper' + +describe "An RSpec Mock" do + it "should hide internals in its inspect representation" do + m = mock('cup') + m.inspect.should =~ /#/ + end +end diff --git a/vendor/gems/gems/rspec-1.2.9/spec/spec/mocks/bug_report_10263_spec.rb b/vendor/gems/gems/rspec-1.2.9/spec/spec/mocks/bug_report_10263_spec.rb new file mode 100755 index 00000000..8a0bc505 --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/spec/spec/mocks/bug_report_10263_spec.rb @@ -0,0 +1,27 @@ +describe "Mock" do + before do + @mock = mock("test mock") + end + + specify "when one example has an expectation (non-mock) inside the block passed to the mock" do + @mock.should_receive(:msg) do |b| + b.should be_true #this call exposes the problem + end + begin + @mock.msg(false) + rescue Exception + end + end + + specify "then the next example should behave as expected instead of saying" do + @mock.should_receive(:foobar) + @mock.foobar + @mock.rspec_verify + begin + @mock.foobar + rescue Exception => e + e.message.should == "Mock \"test mock\" received unexpected message :foobar with (no args)" + end + end +end + diff --git a/vendor/gems/gems/rspec-1.2.9/spec/spec/mocks/bug_report_11545_spec.rb b/vendor/gems/gems/rspec-1.2.9/spec/spec/mocks/bug_report_11545_spec.rb new file mode 100755 index 00000000..7eb7c6e4 --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/spec/spec/mocks/bug_report_11545_spec.rb @@ -0,0 +1,32 @@ +require 'spec_helper' + +class LiarLiarPantsOnFire + def respond_to?(sym, incl_private=false) + true + end + + def self.respond_to?(sym, incl_private=false) + true + end +end + +describe 'should_receive' do + before(:each) do + @liar = LiarLiarPantsOnFire.new + end + + it "should work when object lies about responding to a method" do + @liar.should_receive(:something) + @liar.something + end + + it 'should work when class lies about responding to a method' do + LiarLiarPantsOnFire.should_receive(:something) + LiarLiarPantsOnFire.something + end + + it 'should cleanup after itself' do + (class << LiarLiarPantsOnFire; self; end).instance_methods.should_not include("something") + end +end + diff --git a/vendor/gems/gems/rspec-1.2.9/spec/spec/mocks/bug_report_15719_spec.rb b/vendor/gems/gems/rspec-1.2.9/spec/spec/mocks/bug_report_15719_spec.rb new file mode 100755 index 00000000..efd7a782 --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/spec/spec/mocks/bug_report_15719_spec.rb @@ -0,0 +1,30 @@ +require 'spec_helper' + +module Spec + module Mocks + describe "mock failure" do + + it "should tell you when it receives the right message with the wrong args" do + m = mock("foo") + m.should_receive(:bar).with("message") + lambda { + m.bar("different message") + }.should raise_error(Spec::Mocks::MockExpectationError, %Q{Mock "foo" received :bar with unexpected arguments\n expected: ("message")\n got: ("different message")}) + m.bar("message") # allows the spec to pass + end + + it "should tell you when it receives the right message with the wrong args if you stub the method" do + pending("fix bug 15719") + # NOTE - for whatever reason, if you use a the block style of pending here, + # rcov gets unhappy. Don't know why yet. + m = mock("foo") + m.stub!(:bar) + m.should_receive(:bar).with("message") + lambda { + m.bar("different message") + }.should raise_error(Spec::Mocks::MockExpectationError, %Q{Mock "foo" received :bar with unexpected arguments\n expected: ("message")\n got: ("different message")}) + m.bar("message") # allows the spec to pass + end + end + end +end \ No newline at end of file diff --git a/vendor/gems/gems/rspec-1.2.9/spec/spec/mocks/bug_report_496_spec.rb b/vendor/gems/gems/rspec-1.2.9/spec/spec/mocks/bug_report_496_spec.rb new file mode 100755 index 00000000..fb172a6b --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/spec/spec/mocks/bug_report_496_spec.rb @@ -0,0 +1,19 @@ +require 'spec_helper' + +module BugReport496 + class BaseClass + end + + class SubClass < BaseClass + end + + describe "a message expectation on a base class object" do + it "should correctly pick up message sent to it subclass" do + pending("fix for http://rspec.lighthouseapp.com/projects/5645/tickets/496") do + BaseClass.should_receive(:new).once + SubClass.new + end + end + end +end + diff --git a/vendor/gems/gems/rspec-1.2.9/spec/spec/mocks/bug_report_600_spec.rb b/vendor/gems/gems/rspec-1.2.9/spec/spec/mocks/bug_report_600_spec.rb new file mode 100755 index 00000000..c5c50d5a --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/spec/spec/mocks/bug_report_600_spec.rb @@ -0,0 +1,22 @@ +require 'spec_helper' + +module BugReport600 + class ExampleClass + def self.method_that_uses_define_method + define_method "defined_method" do |attributes| + load_address(address, attributes) + end + end + end + + describe "stubbing a class method" do + it "should work" do + ExampleClass.should_receive(:define_method).with("defined_method") + ExampleClass.method_that_uses_define_method + end + + it "should restore the original method" do + ExampleClass.method_that_uses_define_method + end + end +end \ No newline at end of file diff --git a/vendor/gems/gems/rspec-1.2.9/spec/spec/mocks/bug_report_7611_spec.rb b/vendor/gems/gems/rspec-1.2.9/spec/spec/mocks/bug_report_7611_spec.rb new file mode 100755 index 00000000..ff1ef879 --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/spec/spec/mocks/bug_report_7611_spec.rb @@ -0,0 +1,19 @@ +require 'spec_helper' + +module Bug7611 + class Foo + end + + class Bar < Foo + end + + describe "A Partial Mock" do + it "should respect subclasses" do + Foo.stub!(:new).and_return(Object.new) + end + + it "should" do + Bar.new.class.should == Bar + end + end +end diff --git a/vendor/gems/gems/rspec-1.2.9/spec/spec/mocks/bug_report_7805_spec.rb b/vendor/gems/gems/rspec-1.2.9/spec/spec/mocks/bug_report_7805_spec.rb new file mode 100755 index 00000000..9a3d493d --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/spec/spec/mocks/bug_report_7805_spec.rb @@ -0,0 +1,22 @@ +require 'spec_helper' + +module Bug7805 + #This is really a duplicate of 8302 + + describe "Stubs should correctly restore module methods" do + it "1 - stub the open method" do + File.stub!(:open).and_return("something") + File.open.should == "something" + end + it "2 - use File.open to create example.txt" do + filename = "#{File.dirname(__FILE__)}/example-#{Time.new.to_i}.txt" + File.exist?(filename).should be_false + file = File.open(filename,'w') + file.close + File.exist?(filename).should be_true + File.delete(filename) + File.exist?(filename).should be_false + end + end + +end diff --git a/vendor/gems/gems/rspec-1.2.9/spec/spec/mocks/bug_report_8165_spec.rb b/vendor/gems/gems/rspec-1.2.9/spec/spec/mocks/bug_report_8165_spec.rb new file mode 100755 index 00000000..8d8d0177 --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/spec/spec/mocks/bug_report_8165_spec.rb @@ -0,0 +1,31 @@ +require 'spec_helper' + +describe "An object where respond_to? is true and does not have method" do + # When should_receive(:sym) is sent to any object, the Proxy sends + # respond_to?(:sym) to that object to see if the method should be proxied. + # + # If respond_to? itself is proxied, then when the Proxy sends respond_to? + # to the object, the proxy is invoked and responds yes (if so set in the spec). + # When the object does NOT actually respond to :sym, an exception is thrown + # when trying to proxy it. + # + # The fix was to keep track of whether :respond_to? had been proxied and, if + # so, call the munged copy of :respond_to? on the object. + + it "should not raise an exception for Object" do + obj = Object.new + obj.should_receive(:respond_to?).with(:foobar).and_return(true) + obj.should_receive(:foobar).and_return(:baz) + obj.respond_to?(:foobar).should be_true + obj.foobar.should == :baz + end + + it "should not raise an exception for mock" do + obj = mock("obj") + obj.should_receive(:respond_to?).with(:foobar).and_return(true) + obj.should_receive(:foobar).and_return(:baz) + obj.respond_to?(:foobar).should be_true + obj.foobar.should == :baz + end + +end diff --git a/vendor/gems/gems/rspec-1.2.9/spec/spec/mocks/bug_report_8302_spec.rb b/vendor/gems/gems/rspec-1.2.9/spec/spec/mocks/bug_report_8302_spec.rb new file mode 100755 index 00000000..55d8d3ac --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/spec/spec/mocks/bug_report_8302_spec.rb @@ -0,0 +1,26 @@ +require 'spec_helper' + +module Bug8302 + class Foo + def Foo.class_method(arg) + end + + def instance_bar(arg) + end + end + + describe "Bug report 8302:" do + it "class method is not restored correctly when proxied" do + Foo.should_not_receive(:class_method).with(Array.new) + Foo.rspec_verify + Foo.class_method(Array.new) + end + + it "instance method is not restored correctly when proxied" do + foo = Foo.new + foo.should_not_receive(:instance_bar).with(Array.new) + foo.rspec_verify + foo.instance_bar(Array.new) + end + end +end diff --git a/vendor/gems/gems/rspec-1.2.9/spec/spec/mocks/bug_report_830_spec.rb b/vendor/gems/gems/rspec-1.2.9/spec/spec/mocks/bug_report_830_spec.rb new file mode 100755 index 00000000..ed16f419 --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/spec/spec/mocks/bug_report_830_spec.rb @@ -0,0 +1,21 @@ +require 'spec_helper' + +module Spec + module Mocks + describe 'Calling a method that catches StandardError' do + class Foo + def self.foo + bar + rescue StandardError + end + end + + it 'still reports mock failures' do + Foo.should_not_receive :bar + lambda do + Foo.foo + end.should raise_error(MockExpectationError) + end + end + end +end diff --git a/vendor/gems/gems/rspec-1.2.9/spec/spec/mocks/double_spec.rb b/vendor/gems/gems/rspec-1.2.9/spec/spec/mocks/double_spec.rb new file mode 100755 index 00000000..0d6ee982 --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/spec/spec/mocks/double_spec.rb @@ -0,0 +1,12 @@ +require 'spec_helper' + +describe "double" do + it "is an alias for stub and mock" do + double().should be_a(Spec::Mocks::Mock) + end + + it "uses 'Double' in failure messages" do + double = double('name') + expect {double.foo}.to raise_error(/Double "name" received/) + end +end \ No newline at end of file diff --git a/vendor/gems/gems/rspec-1.2.9/spec/spec/mocks/failing_argument_matchers_spec.rb b/vendor/gems/gems/rspec-1.2.9/spec/spec/mocks/failing_argument_matchers_spec.rb new file mode 100755 index 00000000..30742157 --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/spec/spec/mocks/failing_argument_matchers_spec.rb @@ -0,0 +1,95 @@ +require 'spec_helper' + +module Spec + module Mocks + describe "failing MockArgumentMatchers" do + before(:each) do + @mock = mock("test mock") + @reporter = Mock.new("reporter", :null_object => true) + end + + after(:each) do + @mock.rspec_reset + end + + it "should reject non boolean" do + @mock.should_receive(:random_call).with(boolean()) + lambda do + @mock.random_call("false") + end.should raise_error(MockExpectationError) + end + + it "should reject non numeric" do + @mock.should_receive(:random_call).with(an_instance_of(Numeric)) + lambda do + @mock.random_call("1") + end.should raise_error(MockExpectationError) + end + + it "should reject non string" do + @mock.should_receive(:random_call).with(an_instance_of(String)) + lambda do + @mock.random_call(123) + end.should raise_error(MockExpectationError) + end + + it "should reject goose when expecting a duck" do + @mock.should_receive(:random_call).with(duck_type(:abs, :div)) + lambda { @mock.random_call("I don't respond to :abs or :div") }.should raise_error(MockExpectationError) + end + + it "should fail if regexp does not match submitted string" do + @mock.should_receive(:random_call).with(/bcd/) + lambda { @mock.random_call("abc") }.should raise_error(MockExpectationError) + end + + it "should fail if regexp does not match submitted regexp" do + @mock.should_receive(:random_call).with(/bcd/) + lambda { @mock.random_call(/bcde/) }.should raise_error(MockExpectationError) + end + + it "should fail for a hash w/ wrong values" do + @mock.should_receive(:random_call).with(:a => "b", :c => "d") + lambda do + @mock.random_call(:a => "b", :c => "e") + end.should raise_error(MockExpectationError, /Mock "test mock" received :random_call with unexpected arguments\n expected: \(\{(:a=>\"b\", :c=>\"d\"|:c=>\"d\", :a=>\"b\")\}\)\n got: \(\{(:a=>\"b\", :c=>\"e\"|:c=>\"e\", :a=>\"b\")\}\)/) + end + + it "should fail for a hash w/ wrong keys" do + @mock.should_receive(:random_call).with(:a => "b", :c => "d") + lambda do + @mock.random_call("a" => "b", "c" => "d") + end.should raise_error(MockExpectationError, /Mock "test mock" received :random_call with unexpected arguments\n expected: \(\{(:a=>\"b\", :c=>\"d\"|:c=>\"d\", :a=>\"b\")\}\)\n got: \(\{(\"a\"=>\"b\", \"c\"=>\"d\"|\"c\"=>\"d\", \"a\"=>\"b\")\}\)/) + end + + it "should match against a Matcher" do + lambda do + @mock.should_receive(:msg).with(equal(3)) + @mock.msg(37) + end.should raise_error(MockExpectationError, "Mock \"test mock\" received :msg with unexpected arguments\n expected: (equal 3)\n got: (37)") + end + + it "should fail no_args with one arg" do + lambda do + @mock.should_receive(:msg).with(no_args) + @mock.msg(37) + end.should raise_error(MockExpectationError, "Mock \"test mock\" received :msg with unexpected arguments\n expected: (no args)\n got: (37)") + end + + it "should fail hash_including with missing key" do + lambda do + @mock.should_receive(:msg).with(hash_including(:a => 1)) + @mock.msg({}) + end.should raise_error(MockExpectationError, "Mock \"test mock\" received :msg with unexpected arguments\n expected: (hash_including(:a=>1))\n got: ({})") + end + + it "should fail with block matchers" do + lambda do + @mock.should_receive(:msg).with {|arg| arg.should == :received } + @mock.msg :no_msg_for_you + end.should raise_error(Spec::Expectations::ExpectationNotMetError, /expected: :received.*\s*.*got: :no_msg_for_you/) + end + + end + end +end diff --git a/vendor/gems/gems/rspec-1.2.9/spec/spec/mocks/hash_including_matcher_spec.rb b/vendor/gems/gems/rspec-1.2.9/spec/spec/mocks/hash_including_matcher_spec.rb new file mode 100755 index 00000000..d757f619 --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/spec/spec/mocks/hash_including_matcher_spec.rb @@ -0,0 +1,90 @@ +require 'spec_helper' + +module Spec + module Mocks + module ArgumentMatchers + describe HashIncludingMatcher do + + it "should describe itself properly" do + HashIncludingMatcher.new(:a => 1).description.should == "hash_including(:a=>1)" + end + + describe "passing" do + it "should match the same hash" do + hash_including(:a => 1).should == {:a => 1} + end + + it "should match a hash with extra stuff" do + hash_including(:a => 1).should == {:a => 1, :b => 2} + end + + describe "when matching against other matchers" do + it "should match an int against anything()" do + hash_including(:a => anything, :b => 2).should == {:a => 1, :b => 2} + end + + it "should match a string against anything()" do + hash_including(:a => anything, :b => 2).should == {:a => "1", :b => 2} + end + end + + describe "when passed only keys or keys mixed with key/value pairs" do + it "should match if the key is present" do + hash_including(:a).should == {:a => 1, :b => 2} + end + + it "should match if more keys are present" do + hash_including(:a, :b).should == {:a => 1, :b => 2, :c => 3} + end + + it "should match a string against a given key" do + hash_including(:a).should == {:a => "1", :b => 2} + end + + it "should match if passed one key and one key/value pair" do + hash_including(:a, :b => 2).should == {:a => 1, :b => 2} + end + + it "should match if passed many keys and one key/value pair" do + hash_including(:a, :b, :c => 3).should == {:a => 1, :b => 2, :c => 3, :d => 4} + end + + it "should match if passed many keys and many key/value pairs" do + hash_including(:a, :b, :c => 3, :e => 5).should == {:a => 1, :b => 2, :c => 3, :d => 4, :e => 5} + end + end + end + + describe "failing" do + it "should not match a non-hash" do + hash_including(:a => 1).should_not == 1 + end + + it "should not match a hash with a missing key" do + hash_including(:a => 1).should_not == {:b => 2} + end + + it "should not match a hash with a missing key" do + hash_including(:a).should_not == {:b => 2} + end + + it "should not match an empty hash with a given key" do + hash_including(:a).should_not == {} + end + + it "should not match a hash with a missing key when one pair is matching" do + hash_including(:a, :b => 2).should_not == {:b => 2} + end + + it "should not match a hash with an incorrect value" do + hash_including(:a => 1, :b => 2).should_not == {:a => 1, :b => 3} + end + + it "should not match when values are nil but keys are different" do + hash_including(:a => nil).should_not == {:b => nil} + end + end + end + end + end +end diff --git a/vendor/gems/gems/rspec-1.2.9/spec/spec/mocks/hash_not_including_matcher_spec.rb b/vendor/gems/gems/rspec-1.2.9/spec/spec/mocks/hash_not_including_matcher_spec.rb new file mode 100755 index 00000000..9df69fe6 --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/spec/spec/mocks/hash_not_including_matcher_spec.rb @@ -0,0 +1,67 @@ +require 'spec_helper' + +module Spec + module Mocks + module ArgumentMatchers + describe HashNotIncludingMatcher do + + it "should describe itself properly" do + HashNotIncludingMatcher.new(:a => 5).description.should == "hash_not_including(:a=>5)" + end + + describe "passing" do + it "should match a hash without the specified key" do + hash_not_including(:c).should == {:a => 1, :b => 2} + end + + it "should match a hash with the specified key, but different value" do + hash_not_including(:b => 3).should == {:a => 1, :b => 2} + end + + it "should match a hash without the specified key, given as anything()" do + hash_not_including(:c => anything).should == {:a => 1, :b => 2} + end + + it "should match an empty hash" do + hash_not_including(:a).should == {} + end + + it "should match a hash without any of the specified keys" do + hash_not_including(:a, :b, :c).should == { :d => 7} + end + + end + + describe "failing" do + it "should not match a non-hash" do + hash_not_including(:a => 1).should_not == 1 + end + + it "should not match a hash with a specified key" do + hash_not_including(:b).should_not == {:b => 2} + end + + it "should not match a hash with the specified key/value pair" do + hash_not_including(:b => 2).should_not == {:a => 1, :b => 2} + end + + it "should not match a hash with the specified key" do + hash_not_including(:a, :b => 3).should_not == {:a => 1, :b => 2} + end + + it "should not match a hash with one of the specified keys" do + hash_not_including(:a, :b).should_not == {:b => 2} + end + + it "should not match a hash with some of the specified keys" do + hash_not_including(:a, :b, :c).should_not == {:a => 1, :b => 2} + end + + it "should not match a hash with one key/value pair included" do + hash_not_including(:a, :b, :c, :d => 7).should_not == { :d => 7} + end + end + end + end + end +end diff --git a/vendor/gems/gems/rspec-1.2.9/spec/spec/mocks/mock_ordering_spec.rb b/vendor/gems/gems/rspec-1.2.9/spec/spec/mocks/mock_ordering_spec.rb new file mode 100755 index 00000000..4bd15478 --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/spec/spec/mocks/mock_ordering_spec.rb @@ -0,0 +1,94 @@ +require 'spec_helper' + +module Spec + module Mocks + + describe "Mock ordering" do + + before do + @mock = mock("test mock") + end + + after do + @mock.rspec_reset + end + + it "should pass two calls in order" do + @mock.should_receive(:one).ordered + @mock.should_receive(:two).ordered + @mock.one + @mock.two + @mock.rspec_verify + end + + it "should pass three calls in order" do + @mock.should_receive(:one).ordered + @mock.should_receive(:two).ordered + @mock.should_receive(:three).ordered + @mock.one + @mock.two + @mock.three + @mock.rspec_verify + end + + it "should fail if second call comes first" do + @mock.should_receive(:one).ordered + @mock.should_receive(:two).ordered + lambda do + @mock.two + end.should raise_error(MockExpectationError, "Mock \"test mock\" received :two out of order") + end + + it "should fail if third call comes first" do + @mock.should_receive(:one).ordered + @mock.should_receive(:two).ordered + @mock.should_receive(:three).ordered + @mock.one + lambda do + @mock.three + end.should raise_error(MockExpectationError, "Mock \"test mock\" received :three out of order") + end + + it "should fail if third call comes second" do + @mock.should_receive(:one).ordered + @mock.should_receive(:two).ordered + @mock.should_receive(:three).ordered + @mock.one + lambda do + @mock.three + end.should raise_error(MockExpectationError, "Mock \"test mock\" received :three out of order") + end + + it "should ignore order of non ordered calls" do + @mock.should_receive(:ignored_0) + @mock.should_receive(:ordered_1).ordered + @mock.should_receive(:ignored_1) + @mock.should_receive(:ordered_2).ordered + @mock.should_receive(:ignored_2) + @mock.should_receive(:ignored_3) + @mock.should_receive(:ordered_3).ordered + @mock.should_receive(:ignored_4) + @mock.ignored_3 + @mock.ordered_1 + @mock.ignored_0 + @mock.ordered_2 + @mock.ignored_4 + @mock.ignored_2 + @mock.ordered_3 + @mock.ignored_1 + @mock.rspec_verify + end + + it "should pass when duplicates exist" do + @mock.should_receive(:a).ordered + @mock.should_receive(:b).ordered + @mock.should_receive(:a).ordered + + @mock.a + @mock.b + @mock.a + end + + end + end +end diff --git a/vendor/gems/gems/rspec-1.2.9/spec/spec/mocks/mock_space_spec.rb b/vendor/gems/gems/rspec-1.2.9/spec/spec/mocks/mock_space_spec.rb new file mode 100755 index 00000000..87823930 --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/spec/spec/mocks/mock_space_spec.rb @@ -0,0 +1,54 @@ +require 'spec_helper' +require 'spec/mocks' + +module Spec + module Mocks + describe Space do + before :each do + @space = Space.new + klazz = Class.new do + def rspec_verify + @verified = true + end + def verified? + @verified + end + def rspec_reset + @reset = true + end + def reset? + @reset + end + end + @m1 = klazz.new + @m2 = klazz.new + end + it "should verify all mocks within" do + @space.add(@m1) + @space.add(@m2) + @space.verify_all + @m1.should be_verified + @m2.should be_verified + end + it "should reset all mocks within" do + @space.add(m1 = mock("mock1")) + @space.add(m2 = mock("mock2")) + m1.should_receive(:rspec_reset) + m2.should_receive(:rspec_reset) + @space.reset_all + end + it "should clear internal mocks on reset_all" do + @space.add(m = mock("mock")) + @space.reset_all + @space.instance_eval { mocks.empty? }.should be_true + end + it "should only add an instance once" do + @space.add(m1 = mock("mock1")) + @space.add(m1) + m1.should_receive(:rspec_verify) + @space.verify_all + end + end + end +end + diff --git a/vendor/gems/gems/rspec-1.2.9/spec/spec/mocks/mock_spec.rb b/vendor/gems/gems/rspec-1.2.9/spec/spec/mocks/mock_spec.rb new file mode 100755 index 00000000..9c636a33 --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/spec/spec/mocks/mock_spec.rb @@ -0,0 +1,594 @@ +require 'spec_helper' + +module Spec + module Mocks + describe Mock do + treats_method_missing_as_private :subject => Mock.new, :noop => false + + before(:each) do + @mock = mock("test mock") + end + + after(:each) do + @mock.rspec_reset + end + + describe "deprecated #stub_everything method" do + before(:each) do + Kernel.stub!(:warn) + end + + it "creates a mock that behaves as a null object" do + stub_everything.should be_null_object + end + + it "provides deprecation warning" do + Kernel.should_receive(:warn).with(/DEPRECATION: stub_everything.* is deprecated./) + stub_everything + end + end + + it "should report line number of expectation of unreceived message" do + expected_error_line = __LINE__; @mock.should_receive(:wont_happen).with("x", 3) + begin + @mock.rspec_verify + violated + rescue MockExpectationError => e + # NOTE - this regexp ended w/ $, but jruby adds extra info at the end of the line + e.backtrace[0].should match(/#{File.basename(__FILE__)}:#{expected_error_line}/) + end + end + + it "should report line number of expectation of unreceived message after #should_receive after similar stub" do + @mock.stub!(:wont_happen) + expected_error_line = __LINE__; @mock.should_receive(:wont_happen).with("x", 3) + begin + @mock.rspec_verify + violated + rescue MockExpectationError => e + # NOTE - this regexp ended w/ $, but jruby adds extra info at the end of the line + e.backtrace[0].should match(/#{File.basename(__FILE__)}:#{expected_error_line}/) + end + end + + it "should pass when not receiving message specified as not to be received" do + @mock.should_not_receive(:not_expected) + @mock.rspec_verify + end + + it "should pass when receiving message specified as not to be received with different args" do + @mock.should_not_receive(:message).with("unwanted text") + @mock.should_receive(:message).with("other text") + @mock.message "other text" + @mock.rspec_verify + end + + it "should fail when receiving message specified as not to be received" do + @mock.should_not_receive(:not_expected) + lambda { + @mock.not_expected + violated + }.should raise_error(MockExpectationError, "Mock \"test mock\" expected :not_expected with (no args) 0 times, but received it once") + end + + it "should fail when receiving message specified as not to be received with args" do + @mock.should_not_receive(:not_expected).with("unexpected text") + lambda { + @mock.not_expected("unexpected text") + violated + }.should raise_error(MockExpectationError, "Mock \"test mock\" expected :not_expected with (\"unexpected text\") 0 times, but received it once") + end + + it "should pass when receiving message specified as not to be received with wrong args" do + @mock.should_not_receive(:not_expected).with("unexpected text") + @mock.not_expected "really unexpected text" + @mock.rspec_verify + end + + it "should allow block to calculate return values" do + @mock.should_receive(:something).with("a","b","c").and_return { |a,b,c| c+b+a } + @mock.something("a","b","c").should == "cba" + @mock.rspec_verify + end + + it "should allow parameter as return value" do + @mock.should_receive(:something).with("a","b","c").and_return("booh") + @mock.something("a","b","c").should == "booh" + @mock.rspec_verify + end + + it "should return nil if no return value set" do + @mock.should_receive(:something).with("a","b","c") + @mock.something("a","b","c").should be_nil + @mock.rspec_verify + end + + it "should raise exception if args don't match when method called" do + @mock.should_receive(:something).with("a","b","c").and_return("booh") + lambda { + @mock.something("a","d","c") + violated + }.should raise_error(MockExpectationError, "Mock \"test mock\" received :something with unexpected arguments\n expected: (\"a\", \"b\", \"c\")\n got: (\"a\", \"d\", \"c\")") + end + + it "should raise exception if args don't match when method called even when the method is stubbed" do + @mock.stub!(:something) + @mock.should_receive(:something).with("a","b","c") + lambda { + @mock.something("a","d","c") + @mock.rspec_verify + }.should raise_error(MockExpectationError, "Mock \"test mock\" received :something with unexpected arguments\n expected: (\"a\", \"b\", \"c\")\n got: ([\"a\", \"d\", \"c\"])") + end + + it "should raise exception if args don't match when method called even when using null_object" do + @mock = mock("test mock", :null_object => true) + @mock.should_receive(:something).with("a","b","c") + lambda { + @mock.something("a","d","c") + @mock.rspec_verify + }.should raise_error(MockExpectationError, "Mock \"test mock\" received :something with unexpected arguments\n expected: (\"a\", \"b\", \"c\")\n got: ([\"a\", \"d\", \"c\"])") + end + + it "should fail if unexpected method called" do + lambda { + @mock.something("a","b","c") + violated + }.should raise_error(MockExpectationError, "Mock \"test mock\" received unexpected message :something with (\"a\", \"b\", \"c\")") + end + + it "should use block for expectation if provided" do + @mock.should_receive(:something) do | a, b | + a.should == "a" + b.should == "b" + "booh" + end + @mock.something("a", "b").should == "booh" + @mock.rspec_verify + end + + it "should fail if expectation block fails" do + @mock.should_receive(:something) {| bool | bool.should be_true} + lambda { + @mock.something false + }.should raise_error(MockExpectationError, /Mock "test mock" received :something but passed block failed with: expected true, got false/) + end + + it "should fail right away when method defined as never is received" do + @mock.should_receive(:not_expected).never + lambda { + @mock.not_expected + }.should raise_error(MockExpectationError, "Mock \"test mock\" expected :not_expected with (no args) 0 times, but received it once") + end + + it "should eventually fail when method defined as never is received" do + @mock.should_receive(:not_expected).never + lambda { + @mock.not_expected + }.should raise_error(MockExpectationError, "Mock \"test mock\" expected :not_expected with (no args) 0 times, but received it once") + end + + it "should raise when told to" do + @mock.should_receive(:something).and_raise(RuntimeError) + lambda do + @mock.something + end.should raise_error(RuntimeError) + end + + it "should raise passed an Exception instance" do + error = RuntimeError.new("error message") + @mock.should_receive(:something).and_raise(error) + lambda { + @mock.something + }.should raise_error(RuntimeError, "error message") + end + + it "should raise RuntimeError with passed message" do + @mock.should_receive(:something).and_raise("error message") + lambda { + @mock.something + }.should raise_error(RuntimeError, "error message") + end + + it "should not raise when told to if args dont match" do + @mock.should_receive(:something).with(2).and_raise(RuntimeError) + lambda { + @mock.something 1 + }.should raise_error(MockExpectationError) + end + + it "should throw when told to" do + @mock.should_receive(:something).and_throw(:blech) + lambda { + @mock.something + }.should throw_symbol(:blech) + end + + it "should raise when explicit return and block constrained" do + lambda { + @mock.should_receive(:fruit) do |colour| + :strawberry + end.and_return :apple + }.should raise_error(AmbiguousReturnError) + end + + it "should ignore args on any args" do + @mock.should_receive(:something).at_least(:once).with(any_args) + @mock.something + @mock.something 1 + @mock.something "a", 2 + @mock.something [], {}, "joe", 7 + @mock.rspec_verify + end + + it "should fail on no args if any args received" do + @mock.should_receive(:something).with(no_args()) + lambda { + @mock.something 1 + }.should raise_error(MockExpectationError, "Mock \"test mock\" received :something with unexpected arguments\n expected: (no args)\n got: (1)") + end + + it "should fail when args are expected but none are received" do + @mock.should_receive(:something).with(1) + lambda { + @mock.something + }.should raise_error(MockExpectationError, "Mock \"test mock\" received :something with unexpected arguments\n expected: (1)\n got: (no args)") + end + + it "should return value from block by default" do + @mock.stub!(:method_that_yields).and_yield + @mock.method_that_yields { :returned_obj }.should == :returned_obj + @mock.rspec_verify + end + + it "should yield 0 args to blocks that take a variable number of arguments" do + @mock.should_receive(:yield_back).with(no_args()).once.and_yield + a = nil + @mock.yield_back {|*x| a = x} + a.should == [] + @mock.rspec_verify + end + + it "should yield 0 args multiple times to blocks that take a variable number of arguments" do + @mock.should_receive(:yield_back).once.with(no_args()).once.and_yield. + and_yield + a = nil + b = [] + @mock.yield_back {|*a| b << a} + b.should == [ [], [] ] + @mock.rspec_verify + end + + it "should yield one arg to blocks that take a variable number of arguments" do + @mock.should_receive(:yield_back).with(no_args()).once.and_yield(99) + a = nil + @mock.yield_back {|*x| a = x} + a.should == [99] + @mock.rspec_verify + end + + it "should yield one arg 3 times consecutively to blocks that take a variable number of arguments" do + @mock.should_receive(:yield_back).once.with(no_args()).once.and_yield(99). + and_yield(43). + and_yield("something fruity") + a = nil + b = [] + @mock.yield_back {|*a| b << a} + b.should == [[99], [43], ["something fruity"]] + @mock.rspec_verify + end + + it "should yield many args to blocks that take a variable number of arguments" do + @mock.should_receive(:yield_back).with(no_args()).once.and_yield(99, 27, "go") + a = nil + @mock.yield_back {|*x| a = x} + a.should == [99, 27, "go"] + @mock.rspec_verify + end + + it "should yield many args 3 times consecutively to blocks that take a variable number of arguments" do + @mock.should_receive(:yield_back).once.with(no_args()).once.and_yield(99, :green, "go"). + and_yield("wait", :amber). + and_yield("stop", 12, :red) + a = nil + b = [] + @mock.yield_back {|*a| b << a} + b.should == [[99, :green, "go"], ["wait", :amber], ["stop", 12, :red]] + @mock.rspec_verify + end + + it "should yield single value" do + @mock.should_receive(:yield_back).with(no_args()).once.and_yield(99) + a = nil + @mock.yield_back {|x| a = x} + a.should == 99 + @mock.rspec_verify + end + + it "should yield single value 3 times consecutively" do + @mock.should_receive(:yield_back).once.with(no_args()).once.and_yield(99). + and_yield(43). + and_yield("something fruity") + a = nil + b = [] + @mock.yield_back {|a| b << a} + b.should == [99, 43, "something fruity"] + @mock.rspec_verify + end + + it "should yield two values" do + @mock.should_receive(:yield_back).with(no_args()).once.and_yield('wha', 'zup') + a, b = nil + @mock.yield_back {|x,y| a=x; b=y} + a.should == 'wha' + b.should == 'zup' + @mock.rspec_verify + end + + it "should yield two values 3 times consecutively" do + @mock.should_receive(:yield_back).once.with(no_args()).once.and_yield('wha', 'zup'). + and_yield('not', 'down'). + and_yield(14, 65) + a, b = nil + c = [] + @mock.yield_back {|a,b| c << [a, b]} + c.should == [['wha', 'zup'], ['not', 'down'], [14, 65]] + @mock.rspec_verify + end + + it "should fail when calling yielding method with wrong arity" do + @mock.should_receive(:yield_back).with(no_args()).once.and_yield('wha', 'zup') + lambda { + @mock.yield_back {|a|} + }.should raise_error(MockExpectationError, "Mock \"test mock\" yielded |\"wha\", \"zup\"| to block with arity of 1") + end + + it "should fail when calling yielding method consecutively with wrong arity" do + @mock.should_receive(:yield_back).once.with(no_args()).once.and_yield('wha', 'zup'). + and_yield('down'). + and_yield(14, 65) + lambda { + a, b = nil + c = [] + @mock.yield_back {|a,b| c << [a, b]} + }.should raise_error(MockExpectationError, "Mock \"test mock\" yielded |\"down\"| to block with arity of 2") + end + + it "should fail when calling yielding method without block" do + @mock.should_receive(:yield_back).with(no_args()).once.and_yield('wha', 'zup') + lambda { + @mock.yield_back + }.should raise_error(MockExpectationError, "Mock \"test mock\" asked to yield |[\"wha\", \"zup\"]| but no block was passed") + end + + it "should be able to mock send" do + @mock.should_receive(:send).with(any_args) + @mock.send 'hi' + @mock.rspec_verify + end + + it "should be able to raise from method calling yielding mock" do + @mock.should_receive(:yield_me).and_yield 44 + + lambda { + @mock.yield_me do |x| + raise "Bang" + end + }.should raise_error(StandardError, "Bang") + + @mock.rspec_verify + end + + it "should clear expectations after verify" do + @mock.should_receive(:foobar) + @mock.foobar + @mock.rspec_verify + lambda { + @mock.foobar + }.should raise_error(MockExpectationError, "Mock \"test mock\" received unexpected message :foobar with (no args)") + end + + it "should restore objects to their original state on rspec_reset" do + mock = mock("this is a mock") + mock.should_receive(:blah) + mock.rspec_reset + mock.rspec_verify #should throw if reset didn't work + end + + it "should work even after method_missing starts raising NameErrors instead of NoMethodErrors" do + # Object#method_missing throws either NameErrors or NoMethodErrors. + # + # On a fresh ruby program Object#method_missing: + # * raises a NoMethodError when called directly + # * raises a NameError when called indirectly + # + # Once Object#method_missing has been called at least once (on any object) + # it starts behaving differently: + # * raises a NameError when called directly + # * raises a NameError when called indirectly + # + # There was a bug in Mock#method_missing that relied on the fact + # that calling Object#method_missing directly raises a NoMethodError. + # This example tests that the bug doesn't exist anymore. + + + # Ensures that method_missing always raises NameErrors. + a_method_that_doesnt_exist rescue + + + @mock.should_receive(:foobar) + @mock.foobar + @mock.rspec_verify + + lambda { @mock.foobar }.should_not raise_error(NameError) + lambda { @mock.foobar }.should raise_error(MockExpectationError) + end + + it "should temporarily replace a method stub on a mock" do + @mock.stub!(:msg).and_return(:stub_value) + @mock.should_receive(:msg).with(:arg).and_return(:mock_value) + @mock.msg(:arg).should equal(:mock_value) + @mock.msg.should equal(:stub_value) + @mock.msg.should equal(:stub_value) + @mock.rspec_verify + end + + it "should not require a different signature to replace a method stub" do + @mock.stub!(:msg).and_return(:stub_value) + @mock.should_receive(:msg).and_return(:mock_value) + @mock.msg(:arg).should equal(:mock_value) + @mock.msg.should equal(:stub_value) + @mock.msg.should equal(:stub_value) + @mock.rspec_verify + end + + it "should raise an error when a previously stubbed method has a negative expectation" do + @mock.stub!(:msg).and_return(:stub_value) + @mock.should_not_receive(:msg).and_return(:mock_value) + lambda {@mock.msg(:arg)}.should raise_error(MockExpectationError) + end + + it "should temporarily replace a method stub on a non-mock" do + non_mock = Object.new + non_mock.stub!(:msg).and_return(:stub_value) + non_mock.should_receive(:msg).with(:arg).and_return(:mock_value) + non_mock.msg(:arg).should equal(:mock_value) + non_mock.msg.should equal(:stub_value) + non_mock.msg.should equal(:stub_value) + non_mock.rspec_verify + end + + it "should return the stubbed value when no new value specified" do + @mock.stub!(:msg).and_return(:stub_value) + @mock.should_receive(:msg) + @mock.msg.should equal(:stub_value) + @mock.rspec_verify + end + + it "should not mess with the stub's yielded values when also mocked" do + @mock.stub!(:yield_back).and_yield(:stub_value) + @mock.should_receive(:yield_back).and_yield(:mock_value) + @mock.yield_back{|v| v.should == :mock_value } + @mock.yield_back{|v| v.should == :stub_value } + @mock.rspec_verify + end + + it "should yield multiple values after a similar stub" do + File.stub!(:open).and_yield(:stub_value) + File.should_receive(:open).and_yield(:first_call).and_yield(:second_call) + yielded_args = [] + File.open {|v| yielded_args << v } + yielded_args.should == [:first_call, :second_call] + File.open {|v| v.should == :stub_value } + File.rspec_verify + end + + it "should assign stub return values" do + mock = Mock.new('name', :message => :response) + mock.message.should == :response + end + + end + + describe "a mock message receiving a block" do + before(:each) do + @mock = mock("mock") + @calls = 0 + end + + def add_call + @calls = @calls + 1 + end + + it "should call the block after #should_receive" do + @mock.should_receive(:foo) { add_call } + + @mock.foo + + @calls.should == 1 + end + + it "should call the block after #should_receive after a similar stub" do + @mock.stub!(:foo).and_return(:bar) + @mock.should_receive(:foo) { add_call } + + @mock.foo + + @calls.should == 1 + end + + it "should call the block after #once" do + @mock.should_receive(:foo).once { add_call } + + @mock.foo + + @calls.should == 1 + end + + it "should call the block after #twice" do + @mock.should_receive(:foo).twice { add_call } + + @mock.foo + @mock.foo + + @calls.should == 2 + end + + it "should call the block after #times" do + @mock.should_receive(:foo).exactly(10).times { add_call } + + (1..10).each { @mock.foo } + + @calls.should == 10 + end + + it "should call the block after #any_number_of_times" do + @mock.should_receive(:foo).any_number_of_times { add_call } + + (1..7).each { @mock.foo } + + @calls.should == 7 + end + + it "should call the block after #ordered" do + @mock.should_receive(:foo).ordered { add_call } + @mock.should_receive(:bar).ordered { add_call } + + @mock.foo + @mock.bar + + @calls.should == 2 + end + end + + describe 'string representation generated by #to_s' do + it 'should not contain < because that might lead to invalid HTML in some situations' do + mock = mock("Dog") + valid_html_str = "#{mock}" + valid_html_str.should_not include('<') + end + end + + describe "mock created with no name" do + it "should not use a name in a failure message" do + mock = mock() + expect {mock.foo}.to raise_error(/Mock received/) + end + + it "should respond to initially stubbed methods" do + mock = mock(:foo => "woo", :bar => "car") + mock.foo.should == "woo" + mock.bar.should == "car" + end + end + + describe "==" do + it "sends '== self' to the comparison object" do + first = mock('first') + second = mock('second') + + first.should_receive(:==).with(second) + second == first + end + end + end +end diff --git a/vendor/gems/gems/rspec-1.2.9/spec/spec/mocks/multiple_return_value_spec.rb b/vendor/gems/gems/rspec-1.2.9/spec/spec/mocks/multiple_return_value_spec.rb new file mode 100755 index 00000000..08a6b066 --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/spec/spec/mocks/multiple_return_value_spec.rb @@ -0,0 +1,113 @@ +require 'spec_helper' + +module Spec + module Mocks + describe "a Mock expectation with multiple return values and no specified count" do + before(:each) do + @mock = Mock.new("mock") + @return_values = ["1",2,Object.new] + @mock.should_receive(:message).and_return(@return_values[0],@return_values[1],@return_values[2]) + end + + it "should return values in order to consecutive calls" do + @mock.message.should == @return_values[0] + @mock.message.should == @return_values[1] + @mock.message.should == @return_values[2] + @mock.rspec_verify + end + + it "should complain when there are too few calls" do + third = Object.new + @mock.message.should == @return_values[0] + @mock.message.should == @return_values[1] + lambda { @mock.rspec_verify }.should raise_error(MockExpectationError, "Mock \"mock\" expected :message with (any args) 3 times, but received it twice") + end + + it "should complain when there are too many calls" do + third = Object.new + @mock.message.should == @return_values[0] + @mock.message.should == @return_values[1] + @mock.message.should == @return_values[2] + @mock.message.should == @return_values[2] + lambda { @mock.rspec_verify }.should raise_error(MockExpectationError, "Mock \"mock\" expected :message with (any args) 3 times, but received it 4 times") + end + end + + describe "a Mock expectation with multiple return values with a specified count equal to the number of values" do + before(:each) do + @mock = Mock.new("mock") + @return_values = ["1",2,Object.new] + @mock.should_receive(:message).exactly(3).times.and_return(@return_values[0],@return_values[1],@return_values[2]) + end + + it "should return values in order to consecutive calls" do + @mock.message.should == @return_values[0] + @mock.message.should == @return_values[1] + @mock.message.should == @return_values[2] + @mock.rspec_verify + end + + it "should complain when there are too few calls" do + third = Object.new + @mock.message.should == @return_values[0] + @mock.message.should == @return_values[1] + lambda { @mock.rspec_verify }.should raise_error(MockExpectationError, "Mock \"mock\" expected :message with (any args) 3 times, but received it twice") + end + + it "should complain when there are too many calls" do + third = Object.new + @mock.message.should == @return_values[0] + @mock.message.should == @return_values[1] + @mock.message.should == @return_values[2] + @mock.message.should == @return_values[2] + lambda { @mock.rspec_verify }.should raise_error(MockExpectationError, "Mock \"mock\" expected :message with (any args) 3 times, but received it 4 times") + end + end + + describe "a Mock expectation with multiple return values specifying at_least less than the number of values" do + before(:each) do + @mock = Mock.new("mock") + @mock.should_receive(:message).at_least(:twice).with(no_args).and_return(11, 22) + end + + it "should use last return value for subsequent calls" do + @mock.message.should equal(11) + @mock.message.should equal(22) + @mock.message.should equal(22) + @mock.rspec_verify + end + + it "should fail when called less than the specified number" do + @mock.message.should equal(11) + lambda { @mock.rspec_verify }.should raise_error(MockExpectationError, "Mock \"mock\" expected :message with (no args) twice, but received it once") + end + end + describe "a Mock expectation with multiple return values with a specified count larger than the number of values" do + before(:each) do + @mock = Mock.new("mock") + @mock.should_receive(:message).exactly(3).times.and_return(11, 22) + end + + it "should use last return value for subsequent calls" do + @mock.message.should equal(11) + @mock.message.should equal(22) + @mock.message.should equal(22) + @mock.rspec_verify + end + + it "should fail when called less than the specified number" do + @mock.message.should equal(11) + lambda { @mock.rspec_verify }.should raise_error(MockExpectationError, "Mock \"mock\" expected :message with (any args) 3 times, but received it once") + end + + it "should fail when called greater than the specified number" do + @mock.message.should equal(11) + @mock.message.should equal(22) + @mock.message.should equal(22) + @mock.message.should equal(22) + lambda { @mock.rspec_verify }.should raise_error(MockExpectationError, "Mock \"mock\" expected :message with (any args) 3 times, but received it 4 times") + end + end + end +end + diff --git a/vendor/gems/gems/rspec-1.2.9/spec/spec/mocks/nil_expectation_warning_spec.rb b/vendor/gems/gems/rspec-1.2.9/spec/spec/mocks/nil_expectation_warning_spec.rb new file mode 100755 index 00000000..f8f72baf --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/spec/spec/mocks/nil_expectation_warning_spec.rb @@ -0,0 +1,53 @@ +require 'spec_helper' + +module Spec + module Mocks + + describe "an expectation set on nil" do + + it "should issue a warning with file and line number information" do + expected_warning = %r%An expectation of :foo was set on nil. Called from #{__FILE__}:#{__LINE__+3}(:in `block \(2 levels\) in ')?. Use allow_message_expectations_on_nil to disable warnings.% + Kernel.should_receive(:warn).with(expected_warning) + + nil.should_receive(:foo) + nil.foo + end + + it "should issue a warning when the expectation is negative" do + Kernel.should_receive(:warn) + + nil.should_not_receive(:foo) + end + + it "should not issue a warning when expectations are set to be allowed" do + allow_message_expectations_on_nil + Kernel.should_not_receive(:warn) + + nil.should_receive(:foo) + nil.should_not_receive(:bar) + nil.foo + end + + end + + describe "#allow_message_expectations_on_nil" do + + it "should not effect subsequent examples" do + example_group = Class.new(::Spec::Example::ExampleGroupDouble) + example_group.it("when called in one example that doesn't end up setting an expectation on nil") do + allow_message_expectations_on_nil + end + example_group.it("should not effect the next exapmle ran") do + Kernel.should_receive(:warn) + nil.should_receive(:foo) + nil.foo + end + + example_group.run(Spec::Runner.options).should be_true + + end + + end + + end +end diff --git a/vendor/gems/gems/rspec-1.2.9/spec/spec/mocks/null_object_mock_spec.rb b/vendor/gems/gems/rspec-1.2.9/spec/spec/mocks/null_object_mock_spec.rb new file mode 100755 index 00000000..8af6b49d --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/spec/spec/mocks/null_object_mock_spec.rb @@ -0,0 +1,54 @@ +require 'spec_helper' + +module Spec + module Mocks + describe "a mock acting as a NullObject" do + before(:each) do + @mock = Mock.new("null_object", :null_object => true) + end + + it "should allow explicit expectation" do + @mock.should_receive(:something) + @mock.something + end + + it "should fail verification when explicit exception not met" do + lambda do + @mock.should_receive(:something) + @mock.rspec_verify + end.should raise_error(MockExpectationError) + end + + it "should ignore unexpected methods" do + @mock.random_call("a", "d", "c") + @mock.rspec_verify + end + + it "should expected message with different args first" do + @mock.should_receive(:message).with(:expected_arg) + @mock.message(:unexpected_arg) + @mock.message(:expected_arg) + end + + it "should expected message with different args second" do + @mock.should_receive(:message).with(:expected_arg) + @mock.message(:expected_arg) + @mock.message(:unexpected_arg) + end + end + + describe "#null_object?" do + it "should default to false" do + obj = mock('anything') + obj.should_not be_null_object + end + end + + describe "#as_null_object" do + it "should set the object to null_object" do + obj = mock('anything').as_null_object + obj.should be_null_object + end + end + end +end diff --git a/vendor/gems/gems/rspec-1.2.9/spec/spec/mocks/once_counts_spec.rb b/vendor/gems/gems/rspec-1.2.9/spec/spec/mocks/once_counts_spec.rb new file mode 100755 index 00000000..95129832 --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/spec/spec/mocks/once_counts_spec.rb @@ -0,0 +1,53 @@ +require 'spec_helper' + +module Spec + module Mocks + describe "OnceCounts" do + before(:each) do + @mock = mock("test mock") + end + + it "once should fail when called once with wrong args" do + @mock.should_receive(:random_call).once.with("a", "b", "c") + lambda do + @mock.random_call("d", "e", "f") + end.should raise_error(MockExpectationError) + @mock.rspec_reset + end + + it "once should fail when called twice" do + @mock.should_receive(:random_call).once + @mock.random_call + @mock.random_call + lambda do + @mock.rspec_verify + end.should raise_error(MockExpectationError) + end + + it "once should fail when not called" do + @mock.should_receive(:random_call).once + lambda do + @mock.rspec_verify + end.should raise_error(MockExpectationError) + end + + it "once should pass when called once" do + @mock.should_receive(:random_call).once + @mock.random_call + @mock.rspec_verify + end + + it "once should pass when called once with specified args" do + @mock.should_receive(:random_call).once.with("a", "b", "c") + @mock.random_call("a", "b", "c") + @mock.rspec_verify + end + + it "once should pass when called once with unspecified args" do + @mock.should_receive(:random_call).once + @mock.random_call("a", "b", "c") + @mock.rspec_verify + end + end + end +end diff --git a/vendor/gems/gems/rspec-1.2.9/spec/spec/mocks/options_hash_spec.rb b/vendor/gems/gems/rspec-1.2.9/spec/spec/mocks/options_hash_spec.rb new file mode 100755 index 00000000..f8275782 --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/spec/spec/mocks/options_hash_spec.rb @@ -0,0 +1,35 @@ +require 'spec_helper' + +module Spec + module Mocks + describe "calling :should_receive with an options hash" do + it "should report the file and line submitted with :expected_from" do + begin + mock = Spec::Mocks::Mock.new("a mock") + mock.should_receive(:message, :expected_from => "/path/to/blah.ext:37") + mock.rspec_verify + rescue Exception => e + ensure + e.backtrace.to_s.should =~ /\/path\/to\/blah.ext:37/m + end + end + + it "should use the message supplied with :message" do + lambda { + m = Spec::Mocks::Mock.new("a mock") + m.should_receive(:message, :message => "recebi nada") + m.rspec_verify + }.should raise_error("recebi nada") + end + + it "should use the message supplied with :message after a similar stub" do + lambda { + m = Spec::Mocks::Mock.new("a mock") + m.stub!(:message) + m.should_receive(:message, :message => "from mock") + m.rspec_verify + }.should raise_error("from mock") + end + end + end +end diff --git a/vendor/gems/gems/rspec-1.2.9/spec/spec/mocks/partial_mock_spec.rb b/vendor/gems/gems/rspec-1.2.9/spec/spec/mocks/partial_mock_spec.rb new file mode 100755 index 00000000..c19ecd30 --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/spec/spec/mocks/partial_mock_spec.rb @@ -0,0 +1,164 @@ +require 'spec_helper' + +module Spec + module Mocks + describe "using a Partial Mock," do + before(:each) do + @object = Object.new + end + + it "should name the class in the failure message" do + @object.should_receive(:foo) + lambda do + @object.rspec_verify + end.should raise_error(Spec::Mocks::MockExpectationError, / expected/) + end + + it "should name the class in the failure message when expectation is on class" do + Object.should_receive(:foo) + lambda do + Object.rspec_verify + end.should raise_error(Spec::Mocks::MockExpectationError, //) + end + + it "should not conflict with @options in the object" do + @object.instance_eval { @options = Object.new } + @object.should_receive(:blah) + @object.blah + end + + it "should_not_receive should mock out the method" do + @object.should_not_receive(:fuhbar) + lambda do + @object.fuhbar + end.should raise_error(MockExpectationError, / expected :fuhbar with \(no args\) 0 times/) + end + + it "should_not_receive should return a negative message expectation" do + @object.should_not_receive(:foobar).should be_kind_of(NegativeMessageExpectation) + end + + it "should_receive should mock out the method" do + @object.should_receive(:foobar).with(:test_param).and_return(1) + @object.foobar(:test_param).should equal(1) + end + + it "should_receive should handle a hash" do + @object.should_receive(:foobar).with(:key => "value").and_return(1) + @object.foobar(:key => "value").should equal(1) + end + + it "should_receive should handle an inner hash" do + hash = {:a => {:key => "value"}} + @object.should_receive(:foobar).with(:key => "value").and_return(1) + @object.foobar(hash[:a]).should equal(1) + end + + it "should_receive should return a message expectation" do + @object.should_receive(:foobar).should be_kind_of(MessageExpectation) + @object.foobar + end + + it "should_receive should verify method was called" do + @object.should_receive(:foobar).with(:test_param).and_return(1) + lambda do + @object.rspec_verify + end.should raise_error(Spec::Mocks::MockExpectationError) + end + + it "should_receive should also take a String argument" do + @object.should_receive('foobar') + @object.foobar + end + + it "should_not_receive should also take a String argument" do + @object.should_not_receive('foobar') + lambda do + @object.foobar + end.should raise_error(Spec::Mocks::MockExpectationError) + end + + it "should use report nil in the error message" do + allow_message_expectations_on_nil + + @this_will_resolve_to_nil.should_receive(:foobar) + lambda do + @this_will_resolve_to_nil.rspec_verify + end.should raise_error(Spec::Mocks::MockExpectationError, /nil expected :foobar with/) + end + end + + describe "Partially mocking an object that defines ==, after another mock has been defined" do + before(:each) do + stub("existing mock", :foo => :foo) + end + + class PartiallyMockedEquals + attr_reader :val + def initialize(val) + @val = val + end + + def ==(other) + @val == other.val + end + end + + it "should not raise an error when stubbing the object" do + o = PartiallyMockedEquals.new :foo + lambda { o.stub!(:bar) }.should_not raise_error(NoMethodError) + end + end + + describe "Method visibility when using partial mocks" do + class MockableClass + def public_method + private_method + protected_method + end + protected + def protected_method; end + private + def private_method; end + end + + before(:each) do + @object = MockableClass.new + end + + it 'should keep public methods public' do + @object.should_receive(:public_method) + with_ruby('1.9') do + @object.public_methods.should include(:public_method) + end + with_ruby('1.8') do + @object.public_methods.should include('public_method') + end + @object.public_method + end + + it 'should keep private methods private' do + @object.should_receive(:private_method) + with_ruby('1.9') do + @object.private_methods.should include(:private_method) + end + with_ruby('1.8') do + @object.private_methods.should include('private_method') + end + @object.public_method + end + + it 'should keep protected methods protected' do + @object.should_receive(:protected_method) + with_ruby('1.9') do + @object.protected_methods.should include(:protected_method) + end + with_ruby('1.8') do + @object.protected_methods.should include('protected_method') + end + @object.public_method + end + + end + end +end diff --git a/vendor/gems/gems/rspec-1.2.9/spec/spec/mocks/partial_mock_using_mocks_directly_spec.rb b/vendor/gems/gems/rspec-1.2.9/spec/spec/mocks/partial_mock_using_mocks_directly_spec.rb new file mode 100755 index 00000000..a69aa6ac --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/spec/spec/mocks/partial_mock_using_mocks_directly_spec.rb @@ -0,0 +1,66 @@ +require 'spec_helper' + +module Spec +module Mocks +describe "PartialMockUsingMocksDirectly" do + before(:each) do + + klass=Class.new + klass.class_eval do + def existing_method + :original_value + end + end + @obj = klass.new + + end + + # See http://rubyforge.org/tracker/index.php?func=detail&aid=10263&group_id=797&atid=3149 + # specify "should clear expectations on verify" do + # @obj.should_receive(:msg) + # @obj.msg + # @obj.rspec_verify + # lambda do + # @obj.msg + # end.should raise_error(NoMethodError) + # + # end + it "should fail when expected message is not received" do + @obj.should_receive(:msg) + lambda do + @obj.rspec_verify + end.should raise_error(MockExpectationError) + + end + it "should fail when message is received with incorrect args" do + @obj.should_receive(:msg).with(:correct_arg) + lambda do + @obj.msg(:incorrect_arg) + end.should raise_error(MockExpectationError) + @obj.msg(:correct_arg) + + end + it "should pass when expected message is received" do + @obj.should_receive(:msg) + @obj.msg + @obj.rspec_verify + + end + it "should pass when message is received with correct args" do + @obj.should_receive(:msg).with(:correct_arg) + @obj.msg(:correct_arg) + @obj.rspec_verify + + end + it "should revert to original method if existed" do + @obj.existing_method.should equal(:original_value) + @obj.should_receive(:existing_method).and_return(:mock_value) + @obj.existing_method.should equal(:mock_value) + @obj.rspec_verify + @obj.existing_method.should equal(:original_value) + + end + +end +end +end diff --git a/vendor/gems/gems/rspec-1.2.9/spec/spec/mocks/passing_argument_matchers_spec.rb b/vendor/gems/gems/rspec-1.2.9/spec/spec/mocks/passing_argument_matchers_spec.rb new file mode 100755 index 00000000..a364df0a --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/spec/spec/mocks/passing_argument_matchers_spec.rb @@ -0,0 +1,145 @@ +require 'spec_helper' + +module Spec + module Mocks + describe "mock argument matchers", :shared => true do + before(:each) do + @mock = Mock.new("test mock") + Kernel.stub!(:warn) + end + + after(:each) do + @mock.rspec_verify + end + end + + describe Methods, "handling argument matchers" do + it_should_behave_like "mock argument matchers" + + it "should accept true as boolean()" do + @mock.should_receive(:random_call).with(boolean()) + @mock.random_call(true) + end + + it "should accept false as boolean()" do + @mock.should_receive(:random_call).with(boolean()) + @mock.random_call(false) + end + + it "should accept fixnum as kind_of(Numeric)" do + @mock.should_receive(:random_call).with(kind_of(Numeric)) + @mock.random_call(1) + end + + it "should accept float as an_instance_of(Numeric)" do + @mock.should_receive(:random_call).with(kind_of(Numeric)) + @mock.random_call(1.5) + end + + it "accepts fixnum as instance_of(Fixnum)" do + @mock.should_receive(:random_call).with(instance_of(Fixnum)) + @mock.random_call(1) + end + + it "should NOT accept fixnum as instance_of(Numeric)" do + @mock.should_not_receive(:random_call).with(instance_of(Numeric)) + @mock.random_call(1) + end + + it "should NOT accept float as instance_of(Numeric)" do + @mock.should_not_receive(:random_call).with(instance_of(Numeric)) + @mock.random_call(1.5) + end + + it "should accept string as anything()" do + @mock.should_receive(:random_call).with("a", anything(), "c") + @mock.random_call("a", "whatever", "c") + end + + it "should match duck type with one method" do + @mock.should_receive(:random_call).with(duck_type(:length)) + @mock.random_call([]) + end + + it "should match duck type with two methods" do + @mock.should_receive(:random_call).with(duck_type(:abs, :div)) + @mock.random_call(1) + end + + it "should match no args against any_args()" do + @mock.should_receive(:random_call).with(any_args) + @mock.random_call() + end + + it "should match one arg against any_args()" do + @mock.should_receive(:random_call).with(any_args) + @mock.random_call("a string") + end + + it "should match no args against no_args()" do + @mock.should_receive(:random_call).with(no_args) + @mock.random_call() + end + + it "should match hash with hash_including same hash" do + @mock.should_receive(:random_call).with(hash_including(:a => 1)) + @mock.random_call(:a => 1) + end + + end + + describe Methods, "handling block matchers" do + it_should_behave_like "mock argument matchers" + + it "should match arguments against RSpec expectations" do + @mock.should_receive(:random_call).with {|arg1, arg2, arr, *rest| + arg1.should == 5 + arg2.should have_at_least(3).characters + arg2.should have_at_most(10).characters + arr.map {|i| i * 2}.should == [2,4,6] + rest.should == [:fee, "fi", 4] + } + @mock.random_call 5, "hello", [1,2,3], :fee, "fi", 4 + end + end + + describe Methods, "handling non-matcher arguments" do + + before(:each) do + @mock = Mock.new("test mock") + end + + it "should match non special symbol (can be removed when deprecated symbols are removed)" do + @mock.should_receive(:random_call).with(:some_symbol) + @mock.random_call(:some_symbol) + end + + it "should match string against regexp" do + @mock.should_receive(:random_call).with(/bcd/) + @mock.random_call("abcde") + end + + it "should match regexp against regexp" do + @mock.should_receive(:random_call).with(/bcd/) + @mock.random_call(/bcd/) + end + + it "should match against a hash submitted and received by value" do + @mock.should_receive(:random_call).with(:a => "a", :b => "b") + @mock.random_call(:a => "a", :b => "b") + end + + it "should match against a hash submitted by reference and received by value" do + opts = {:a => "a", :b => "b"} + @mock.should_receive(:random_call).with(opts) + @mock.random_call(:a => "a", :b => "b") + end + + it "should match against a hash submitted by value and received by reference" do + opts = {:a => "a", :b => "b"} + @mock.should_receive(:random_call).with(:a => "a", :b => "b") + @mock.random_call(opts) + end + end + end +end diff --git a/vendor/gems/gems/rspec-1.2.9/spec/spec/mocks/precise_counts_spec.rb b/vendor/gems/gems/rspec-1.2.9/spec/spec/mocks/precise_counts_spec.rb new file mode 100755 index 00000000..5b64ef28 --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/spec/spec/mocks/precise_counts_spec.rb @@ -0,0 +1,52 @@ +require 'spec_helper' + +module Spec + module Mocks + describe "PreciseCounts" do + before(:each) do + @mock = mock("test mock") + end + + it "should fail when exactly n times method is called less than n times" do + @mock.should_receive(:random_call).exactly(3).times + @mock.random_call + @mock.random_call + lambda do + @mock.rspec_verify + end.should raise_error(MockExpectationError) + end + + it "should fail when exactly n times method is never called" do + @mock.should_receive(:random_call).exactly(3).times + lambda do + @mock.rspec_verify + end.should raise_error(MockExpectationError) + end + + it "should pass if exactly n times method is called exactly n times" do + @mock.should_receive(:random_call).exactly(3).times + @mock.random_call + @mock.random_call + @mock.random_call + @mock.rspec_verify + end + + it "should pass multiple calls with different args and counts" do + @mock.should_receive(:random_call).twice.with(1) + @mock.should_receive(:random_call).once.with(2) + @mock.random_call(1) + @mock.random_call(2) + @mock.random_call(1) + @mock.rspec_verify + end + + it "should pass mutiple calls with different args" do + @mock.should_receive(:random_call).once.with(1) + @mock.should_receive(:random_call).once.with(2) + @mock.random_call(1) + @mock.random_call(2) + @mock.rspec_verify + end + end + end +end diff --git a/vendor/gems/gems/rspec-1.2.9/spec/spec/mocks/record_messages_spec.rb b/vendor/gems/gems/rspec-1.2.9/spec/spec/mocks/record_messages_spec.rb new file mode 100755 index 00000000..bed2fbff --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/spec/spec/mocks/record_messages_spec.rb @@ -0,0 +1,26 @@ +require 'spec_helper' + +module Spec + module Mocks + describe "a mock" do + before(:each) do + @mock = mock("mock", :null_object => true) + end + it "should answer false for received_message? when no messages received" do + @mock.received_message?(:message).should be_false + end + it "should answer true for received_message? when message received" do + @mock.message + @mock.received_message?(:message).should be_true + end + it "should answer true for received_message? when message received with correct args" do + @mock.message 1,2,3 + @mock.received_message?(:message, 1,2,3).should be_true + end + it "should answer false for received_message? when message received with incorrect args" do + @mock.message 1,2,3 + @mock.received_message?(:message, 1,2).should be_false + end + end + end +end diff --git a/vendor/gems/gems/rspec-1.2.9/spec/spec/mocks/stub_chain_spec.rb b/vendor/gems/gems/rspec-1.2.9/spec/spec/mocks/stub_chain_spec.rb new file mode 100755 index 00000000..3536e176 --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/spec/spec/mocks/stub_chain_spec.rb @@ -0,0 +1,42 @@ +require 'spec_helper' + +module Spec + module Mocks + describe "A chained method stub" do + before(:each) do + @subject = Object.new + end + + it "returns expected value from chaining only one method call" do + @subject.stub_chain(:msg1).and_return(:return_value) + @subject.msg1.should equal(:return_value) + end + + it "returns expected value from chaining two method calls" do + @subject.stub_chain(:msg1, :msg2).and_return(:return_value) + @subject.msg1.msg2.should equal(:return_value) + end + + it "returns expected value from chaining four method calls" do + @subject.stub_chain(:msg1, :msg2, :msg3, :msg4).and_return(:return_value) + @subject.msg1.msg2.msg3.msg4.should equal(:return_value) + end + + it "returns expected value from two chains with shared messages at the end" do + @subject.stub_chain(:msg1, :msg2, :msg3, :msg4).and_return(:first) + @subject.stub_chain(:msg5, :msg2, :msg3, :msg4).and_return(:second) + + @subject.msg1.msg2.msg3.msg4.should equal(:first) + @subject.msg5.msg2.msg3.msg4.should equal(:second) + end + + it "returns expected value from two chains with shared messages at the beginning" do + @subject.stub_chain(:msg1, :msg2, :msg3, :msg4).and_return(:first) + @subject.stub_chain(:msg1, :msg2, :msg3, :msg5).and_return(:second) + + @subject.msg1.msg2.msg3.msg4.should equal(:first) + @subject.msg1.msg2.msg3.msg5.should equal(:second) + end + end + end +end diff --git a/vendor/gems/gems/rspec-1.2.9/spec/spec/mocks/stub_implementation_spec.rb b/vendor/gems/gems/rspec-1.2.9/spec/spec/mocks/stub_implementation_spec.rb new file mode 100755 index 00000000..1487277f --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/spec/spec/mocks/stub_implementation_spec.rb @@ -0,0 +1,31 @@ +require 'spec_helper' + +module Spec + module Mocks + describe "stub implementation" do + context "with no args" do + it "execs the block when called" do + obj = stub() + obj.stub(:foo) { :bar } + obj.foo.should == :bar + end + end + + context "with one arg" do + it "execs the block with that arg when called" do + obj = stub() + obj.stub(:foo) {|given| given} + obj.foo(:bar).should == :bar + end + end + + context "with variable args" do + it "execs the block when called" do + obj = stub() + obj.stub(:foo) {|*given| given.first} + obj.foo(:bar).should == :bar + end + end + end + end +end \ No newline at end of file diff --git a/vendor/gems/gems/rspec-1.2.9/spec/spec/mocks/stub_spec.rb b/vendor/gems/gems/rspec-1.2.9/spec/spec/mocks/stub_spec.rb new file mode 100755 index 00000000..e0b7b264 --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/spec/spec/mocks/stub_spec.rb @@ -0,0 +1,203 @@ +require 'spec_helper' + +module Spec + module Mocks + describe "A method stub" do + before(:each) do + @class = Class.new do + def self.existing_class_method + :original_value + end + + def existing_instance_method + :original_value + end + end + @instance = @class.new + @stub = Object.new + end + + [:stub!, :stub].each do |method| + context "using #{method}" do + it "should return expected value when expected message is received" do + @instance.send(method, :msg).and_return(:return_value) + @instance.msg.should equal(:return_value) + @instance.rspec_verify + end + end + end + + it "should ignore when expected message is received" do + @instance.stub!(:msg) + @instance.msg + lambda do + @instance.rspec_verify + end.should_not raise_error + end + + it "should ignore when message is received with args" do + @instance.stub!(:msg) + @instance.msg(:an_arg) + lambda do + @instance.rspec_verify + end.should_not raise_error + end + + it "should ignore when expected message is not received" do + @instance.stub!(:msg) + lambda do + @instance.rspec_verify + end.should_not raise_error + end + + it "should handle multiple stubbed methods" do + @instance.stub!(:msg1 => 1, :msg2 => 2) + @instance.msg1.should == 1 + @instance.msg2.should == 2 + end + + it "should clear itself when verified" do + @instance.stub!(:this_should_go).and_return(:blah) + @instance.this_should_go.should == :blah + @instance.rspec_verify + lambda do + @instance.this_should_go + end.should raise_error(NameError) + end + + it "should return values in order to consecutive calls" do + return_values = ["1",2,Object.new] + @instance.stub!(:msg).and_return(return_values[0],return_values[1],return_values[2]) + @instance.msg.should == return_values[0] + @instance.msg.should == return_values[1] + @instance.msg.should == return_values[2] + end + + it "should keep returning last value in consecutive calls" do + return_values = ["1",2,Object.new] + @instance.stub!(:msg).and_return(return_values[0],return_values[1],return_values[2]) + @instance.msg.should == return_values[0] + @instance.msg.should == return_values[1] + @instance.msg.should == return_values[2] + @instance.msg.should == return_values[2] + @instance.msg.should == return_values[2] + end + + it "should revert to original instance method if there is one" do + @instance.existing_instance_method.should equal(:original_value) + @instance.stub!(:existing_instance_method).and_return(:mock_value) + @instance.existing_instance_method.should equal(:mock_value) + @instance.rspec_verify + @instance.existing_instance_method.should equal(:original_value) + end + + it "should revert to original class method if there is one" do + @class.existing_class_method.should equal(:original_value) + @class.stub!(:existing_class_method).and_return(:mock_value) + @class.existing_class_method.should equal(:mock_value) + @class.rspec_verify + @class.existing_class_method.should equal(:original_value) + end + + it "should yield a specified object" do + @instance.stub!(:method_that_yields).and_yield(:yielded_obj) + current_value = :value_before + @instance.method_that_yields {|val| current_value = val} + current_value.should == :yielded_obj + @instance.rspec_verify + end + + it "should yield multiple times with multiple calls to and_yield" do + @instance.stub!(:method_that_yields_multiple_times).and_yield(:yielded_value). + and_yield(:another_value) + current_value = [] + @instance.method_that_yields_multiple_times {|val| current_value << val} + current_value.should == [:yielded_value, :another_value] + @instance.rspec_verify + end + + it "should yield a specified object and return another specified object" do + yielded_obj = mock("my mock") + yielded_obj.should_receive(:foo).with(:bar) + @instance.stub!(:method_that_yields_and_returns).and_yield(yielded_obj).and_return(:baz) + @instance.method_that_yields_and_returns { |o| o.foo :bar }.should == :baz + end + + it "should throw when told to" do + @mock.stub!(:something).and_throw(:up) + lambda do + @mock.something + end.should throw_symbol(:up) + end + + it "should override a pre-existing stub" do + @stub.stub!(:existing_instance_method).and_return(:updated_stub_value) + @stub.existing_instance_method.should == :updated_stub_value + end + + it "should limit " do + @stub.stub!(:foo).with("bar") + @stub.should_receive(:foo).with("baz") + @stub.foo("bar") + @stub.foo("baz") + end + + it "calculates return value by executing block passed to #and_return" do + @mock.stub!(:something).with("a","b","c").and_return { |a,b,c| c+b+a } + @mock.something("a","b","c").should == "cba" + @mock.rspec_verify + end + end + + describe "A method stub with args" do + before(:each) do + @stub = Object.new + @stub.stub!(:foo).with("bar") + end + + it "should not complain if not called" do + end + + it "should not complain if called with arg" do + @stub.foo("bar") + end + + it "should complain if called with no arg" do + lambda do + @stub.foo + end.should raise_error + end + + it "should complain if called with other arg" do + lambda do + @stub.foo("other") + end.should raise_error + end + + it "should not complain if also mocked w/ different args" do + @stub.should_receive(:foo).with("baz") + @stub.foo("bar") + @stub.foo("baz") + end + + it "should complain if also mocked w/ different args AND called w/ a 3rd set of args" do + @stub.should_receive(:foo).with("baz") + @stub.foo("bar") + @stub.foo("baz") + lambda do + @stub.foo("other") + end.should raise_error + end + + it "should support options" do + @stub.stub!(:foo, :expected_from => "bar") + end + + it "should use 'Stub' in the failure message" do + stub = stub('name') + expect {stub.foo}.to raise_error(/Stub "name" received/) + end + end + + end +end diff --git a/vendor/gems/gems/rspec-1.2.9/spec/spec/mocks/stubbed_message_expectations_spec.rb b/vendor/gems/gems/rspec-1.2.9/spec/spec/mocks/stubbed_message_expectations_spec.rb new file mode 100755 index 00000000..03c8fecd --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/spec/spec/mocks/stubbed_message_expectations_spec.rb @@ -0,0 +1,26 @@ +require 'spec_helper' + +module Spec + module Mocks + describe "Example with stubbed and then called message" do + it "fails if the message is expected and then subsequently not called again" do + mock_obj = mock("mock", :msg => nil) + mock_obj.msg + mock_obj.should_receive(:msg) + lambda { mock_obj.rspec_verify }.should raise_error(Spec::Mocks::MockExpectationError) + end + + it "outputs arguments of all similar calls" do + m = mock('mock', :foo => true) + m.should_receive(:foo).with('first') + m.foo('second') + m.foo('third') + lambda do + m.rspec_verify + end.should raise_error(%Q|Mock "mock" received :foo with unexpected arguments\n expected: ("first")\n got: (["second"], ["third"])|) + m.rspec_reset + end + end + + end +end \ No newline at end of file diff --git a/vendor/gems/gems/rspec-1.2.9/spec/spec/mocks/twice_counts_spec.rb b/vendor/gems/gems/rspec-1.2.9/spec/spec/mocks/twice_counts_spec.rb new file mode 100755 index 00000000..4538eb8f --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/spec/spec/mocks/twice_counts_spec.rb @@ -0,0 +1,67 @@ +require 'spec_helper' + +module Spec + module Mocks + describe "TwiceCounts" do + before(:each) do + @mock = mock("test mock") + end + + it "twice should fail when call count is higher than expected" do + @mock.should_receive(:random_call).twice + @mock.random_call + @mock.random_call + @mock.random_call + lambda do + @mock.rspec_verify + end.should raise_error(MockExpectationError) + end + + it "twice should fail when call count is lower than expected" do + @mock.should_receive(:random_call).twice + @mock.random_call + lambda do + @mock.rspec_verify + end.should raise_error(MockExpectationError) + end + + it "twice should fail when called twice with wrong args on the first call" do + @mock.should_receive(:random_call).twice.with("1", 1) + lambda do + @mock.random_call(1, "1") + end.should raise_error(MockExpectationError) + @mock.rspec_reset + end + + it "twice should fail when called twice with wrong args on the second call" do + @mock.should_receive(:random_call).twice.with("1", 1) + @mock.random_call("1", 1) + lambda do + @mock.random_call(1, "1") + end.should raise_error(MockExpectationError) + @mock.rspec_reset + end + + it "twice should pass when called twice" do + @mock.should_receive(:random_call).twice + @mock.random_call + @mock.random_call + @mock.rspec_verify + end + + it "twice should pass when called twice with specified args" do + @mock.should_receive(:random_call).twice.with("1", 1) + @mock.random_call("1", 1) + @mock.random_call("1", 1) + @mock.rspec_verify + end + + it "twice should pass when called twice with unspecified args" do + @mock.should_receive(:random_call).twice + @mock.random_call("1") + @mock.random_call(1) + @mock.rspec_verify + end + end + end +end diff --git a/vendor/gems/gems/rspec-1.2.9/spec/spec/mocks/unstub_spec.rb b/vendor/gems/gems/rspec-1.2.9/spec/spec/mocks/unstub_spec.rb new file mode 100755 index 00000000..89e5ac38 --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/spec/spec/mocks/unstub_spec.rb @@ -0,0 +1,127 @@ +require 'spec_helper' + +module Spec + module Mocks + describe Mock do + context "unstubbing a mock object with a stub" do + it "should remove the stub" do + a_mock = mock 'an object', :foo => :bar + + a_mock.unstub! :foo + a_mock.should_not respond_to(:foo) + end + end + + context "unstubbing a real object with a stub" do + before do + @obj = Object.new + end + + it "should raise a NoMethodError if the message is called after unstubbing" do + @obj.stub!(:foo).and_return :bar + @obj.unstub!(:foo) + + lambda { + @obj.foo + }.should raise_error(NoMethodError) + end + + it "should only clear the stub specified" do + @obj.stub!(:foo).and_return :bar + @obj.stub!(:other).and_return :baz + + @obj.unstub!(:foo) + + @obj.other.should == :baz + end + + it "should no longer respond_to? the method" do + @obj.stub!(:foo).and_return :bar + @obj.unstub!(:foo) + + @obj.should_not respond_to(:foo) + end + + it "should unstub using a string (should convert the string to a symbol)" do + @obj.stub!(:foo) + + @obj.unstub!("foo") + + @obj.should_not respond_to(:foo) + end + + it "should restore a previous method definition" do + def @obj.foo + :a_result + end + + @obj.stub!(:foo).and_return :stubbed_result + @obj.unstub!(:foo) + + @obj.foo.should == :a_result + end + + it "should have unstub as an alias of unstub!" do + @obj.stub!(:foo).and_return :bar + + @obj.unstub(:foo) + + lambda { + @obj.foo + }.should raise_error(NoMethodError) + end + + it "should raise a MockExpectationError if it is not stubbed" do + lambda { + @obj.unstub!(:foo) + }.should raise_error(MockExpectationError, "The method `foo` was not stubbed or was already unstubbed") + end + + it "should raise a MockExpectationError if it was already unstubbed" do + @obj.stub!(:foo) + @obj.unstub!(:foo) + + lambda { + @obj.unstub!(:foo) + }.should raise_error(MockExpectationError, "The method `foo` was not stubbed or was already unstubbed") + end + + it "should use the correct message name in the error" do + @obj.stub!(:bar) + @obj.unstub!(:bar) + + lambda { + @obj.unstub!(:bar) + }.should raise_error(MockExpectationError, "The method `bar` was not stubbed or was already unstubbed") + end + + it "should raise a MockExpectationError if the method is defined, but not stubbed" do + def @obj.meth; end + + lambda { + @obj.unstub!(:meth) + }.should raise_error(MockExpectationError) + end + + it "should be able to restub a after unstubbing" do + @obj.stub!(:foo).and_return :bar + + @obj.unstub!(:foo) + + @obj.stub!(:foo).and_return :baz + + @obj.foo.should == :baz + end + + it "should remove only the first stub if multiple stubs have been defined" do + @obj.stub!(:foo).and_return :first + @obj.stub!(:foo).and_return :second + + @obj.unstub!(:foo) + + @obj.foo.should == :first + end + end + end + end +end diff --git a/vendor/gems/gems/rspec-1.2.9/spec/spec/package/bin_spec_spec.rb b/vendor/gems/gems/rspec-1.2.9/spec/spec/package/bin_spec_spec.rb new file mode 100755 index 00000000..6628fad7 --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/spec/spec/package/bin_spec_spec.rb @@ -0,0 +1,16 @@ +require 'spec_helper' +require 'ruby_forker' + +describe "The bin/spec script" do + include RubyForker + + it "should have no warnings" do + output = ruby "-w -Ilib bin/spec --help" + output.should_not =~ /warning/n + end + + it "should show the help w/ no args" do + output = ruby "-w -Ilib bin/spec" + output.should =~ /^Usage: spec/ + end +end diff --git a/vendor/gems/gems/rspec-1.2.9/spec/spec/rake/spectask_spec.rb b/vendor/gems/gems/rspec-1.2.9/spec/spec/rake/spectask_spec.rb new file mode 100755 index 00000000..ea834bad --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/spec/spec/rake/spectask_spec.rb @@ -0,0 +1,150 @@ +require 'spec_helper' +require 'spec/rake/spectask' + +module Spec + module Rake + + class MockTask + class << self + attr_accessor :last_instance, :last_cmd + end + + def self.tasks + @tasks ||= {} + end + + def self.reset_tasks + @tasks = {} + end + + def self.task(name) + tasks[name] + end + + def self.register_task(name, block) + tasks[name] = block + end + + def initialize(name, &block) + MockTask.register_task(name, block) + MockTask.last_instance = block + end + + def self.create_task(name, &block) + new(name, &block) + end + end + + class SpecTask + def task(name, &block) + MockTask.create_task(name, &block) + end + + def system(cmd) + MockTask.last_cmd = cmd + true + end + + def default_ruby_path + RUBY + end + end + + describe SpecTask do + + before(:each) do + MockTask.reset_tasks + end + + it "should execute rake's ruby path by default" do + task = SpecTask.new + MockTask.last_instance.call + MockTask.last_cmd.should match(/^#{task.default_ruby_path} /) + end + + it "should execute the command with system if ruby_cmd is specified" do + task = SpecTask.new {|t| t.ruby_cmd = "path_to_multiruby"} + task.should_receive(:system).and_return(true) + MockTask.last_instance.call + end + + it "should execute the ruby_cmd path if specified" do + SpecTask.new {|t| t.ruby_cmd = "path_to_multiruby"} + MockTask.last_instance.call + MockTask.last_cmd.should match(/^path_to_multiruby /) + end + + it "should produce a deprecation warning if the out option is used" do + SpecTask.new {|t| t.out = "somewhere_over_the_rainbow"} + STDERR.should_receive(:puts).with("The Spec::Rake::SpecTask#out attribute is DEPRECATED and will be removed in a future version. Use --format FORMAT:WHERE instead.") + MockTask.last_instance.call + end + + it "should produce an error if failure_message is set and the command fails" do + task = SpecTask.new {|t| t.failure_message = "oops"; t.fail_on_error = false} + STDERR.should_receive(:puts).with("oops") + task.stub(:system).and_return(false) + MockTask.last_instance.call + end + + it "should raise if fail_on_error is set and the command fails" do + task = SpecTask.new + task.stub(:system).and_return(false) + lambda {MockTask.last_instance.call}.should raise_error + end + + it "should not raise if fail_on_error is not set and the command fails" do + task = SpecTask.new {|t| t.fail_on_error = false} + task.stub(:system).and_return(false) + lambda {MockTask.last_instance.call}.should_not raise_error + end + + context "with ENV['SPEC'] set" do + before(:each) do + @orig_env_spec = ENV['SPEC'] + ENV['SPEC'] = 'foo.rb' + end + after(:each) do + ENV['SPEC'] = @orig_env_spec + end + it "should use the provided file list" do + task = SpecTask.new + task.spec_file_list.should == ["foo.rb"] + end + end + + context "with the rcov option" do + + it "should create a clobber_rcov task" do + MockTask.stub!(:create_task) + MockTask.should_receive(:create_task).with(:clobber_rcov) + SpecTask.new(:rcov) {|t| t.rcov = true} + end + + it "should setup the clobber_rcov task to remove the rcov directory" do + task = SpecTask.new(:rcov) {|t| t.rcov = true; t.rcov_dir = "path_to_rcov_directory"} + task.should_receive(:rm_r).with("path_to_rcov_directory") + MockTask.task(:clobber_rcov).call + end + + it "should make the clobber task depend on clobber_rcov" do + MockTask.stub!(:create_task) + MockTask.should_receive(:create_task).with(:clobber => [:clobber_rcov]) + SpecTask.new(:rcov) {|t| t.rcov = true} + end + + it "should make the rcov task depend on clobber_rcov" do + MockTask.stub!(:create_task) + MockTask.should_receive(:create_task).with(:rcov => :clobber_rcov) + SpecTask.new(:rcov) {|t| t.rcov = true} + end + + it "creates an rcov options list" do + MockTask.stub!(:create_task) + task = SpecTask.new(:rcov) {|t| t.rcov = true, t.rcov_opts = ['a','b']} + task.rcov_option_list.should == "a b" + end + end + end + end +end \ No newline at end of file diff --git a/vendor/gems/gems/rspec-1.2.9/spec/spec/runner/class_and_argument_parser_spec.rb b/vendor/gems/gems/rspec-1.2.9/spec/spec/runner/class_and_argument_parser_spec.rb new file mode 100755 index 00000000..1168818f --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/spec/spec/runner/class_and_argument_parser_spec.rb @@ -0,0 +1,23 @@ +require 'spec_helper' + +module Spec + module Runner + describe ClassAndArgumentsParser, ".parse" do + + it "should use a single : to separate class names from arguments" do + ClassAndArgumentsParser.parse('Foo').should == ['Foo', nil] + ClassAndArgumentsParser.parse('Foo:arg').should == ['Foo', 'arg'] + ClassAndArgumentsParser.parse('Foo::Bar::Zap:arg').should == ['Foo::Bar::Zap', 'arg'] + ClassAndArgumentsParser.parse('Foo:arg1,arg2').should == ['Foo', 'arg1,arg2'] + ClassAndArgumentsParser.parse('Foo::Bar::Zap:arg1,arg2').should == ['Foo::Bar::Zap', 'arg1,arg2'] + ClassAndArgumentsParser.parse('Foo::Bar::Zap:drb://foo,drb://bar').should == ['Foo::Bar::Zap', 'drb://foo,drb://bar'] + end + + it "should raise an error when passed an empty string" do + lambda do + ClassAndArgumentsParser.parse('') + end.should raise_error("Couldn't parse \"\"") + end + end + end +end diff --git a/vendor/gems/gems/rspec-1.2.9/spec/spec/runner/command_line_spec.rb b/vendor/gems/gems/rspec-1.2.9/spec/spec/runner/command_line_spec.rb new file mode 100755 index 00000000..c22b3066 --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/spec/spec/runner/command_line_spec.rb @@ -0,0 +1,141 @@ +require 'spec_helper' + +module Spec + module Runner + describe CommandLine, ".run" do + with_sandboxed_options do + attr_reader :err, :out + before do + @err = options.error_stream + @out = options.output_stream + end + + it "should run directory" do + file = File.dirname(__FILE__) + '/../../../examples/passing' + run_with(OptionParser.parse([file,"-p","**/*_spec.rb,**/*_example.rb"], @err, @out)) + + @out.rewind + @out.read.should =~ /\d+ examples, 0 failures, 3 pending/n + end + + it "should run file" do + file = File.dirname(__FILE__) + '/../../../examples/failing/predicate_example.rb' + run_with(OptionParser.parse([file], @err, @out)) + + @out.rewind + @out.read.should =~ /3 examples, 2 failures/n + end + + it "should raise when file does not exist" do + file = File.dirname(__FILE__) + '/doesntexist' + + lambda { + Spec::Runner::CommandLine.run(OptionParser.parse([file], @err, @out)) + }.should raise_error + end + + it "should return true when in --generate-options mode" do + # NOTE - this used to say /dev/null but jruby hangs on that for some reason + Spec::Runner::CommandLine.run( + OptionParser.parse(['--generate-options', '/tmp/foo'], @err, @out) + ).should be_true + end + + it "should dump even if Interrupt exception is occurred" do + example_group = Class.new(::Spec::Example::ExampleGroup) do + describe("example_group") + it "no error" do + end + + it "should interrupt" do + raise Interrupt, "I'm interrupting" + end + end + + options = ::Spec::Runner::Options.new(@err, @out) + ::Spec::Runner::Options.should_receive(:new).with(@err, @out).and_return(options) + options.reporter.should_receive(:dump) + options.add_example_group(example_group) + + Spec::Runner::CommandLine.run(OptionParser.parse([], @err, @out)) + end + + it "should heckle when options have heckle_runner" do + example_group = Class.new(::Spec::Example::ExampleGroup).describe("example_group") do + it "no error" do + end + end + options = ::Spec::Runner::Options.new(@err, @out) + ::Spec::Runner::Options.should_receive(:new).with(@err, @out).and_return(options) + options.add_example_group example_group + + heckle_runner = mock("heckle_runner") + heckle_runner.should_receive(:heckle_with) + $rspec_mocks.__send__(:mocks).delete(heckle_runner) + + options.heckle_runner = heckle_runner + options.add_example_group(example_group) + + Spec::Runner::CommandLine.run(OptionParser.parse([], @err, @out)) + heckle_runner.rspec_verify + end + + it "should run examples backwards if options.reverse is true" do + options = ::Spec::Runner::Options.new(@err, @out) + ::Spec::Runner::Options.should_receive(:new).with(@err, @out).and_return(options) + options.reverse = true + + b1 = Class.new(Spec::Example::ExampleGroup) + b2 = Class.new(Spec::Example::ExampleGroup) + + b2.should_receive(:run).ordered + b1.should_receive(:run).ordered + + options.add_example_group(b1) + options.add_example_group(b2) + + Spec::Runner::CommandLine.run(OptionParser.parse([], @err, @out)) + end + + it "should pass its ExampleGroup to the reporter" do + example_group = describe("example_group") do + it "should" do + end + end + options = ::Spec::Runner::Options.new(@err, @out) + options.add_example_group(example_group) + + ::Spec::Runner::Options.should_receive(:new).with(@err, @out).and_return(options) + options.reporter.should_receive(:add_example_group).with(Spec::Example::ExampleGroupProxy.new(example_group)) + + Spec::Runner::CommandLine.run(OptionParser.parse([], @err, @out)) + end + + it "runs only selected Examples when options.examples is set" do + options = ::Spec::Runner::Options.new(@err, @out) + ::Spec::Runner::Options.should_receive(:new).with(@err, @out).and_return(options) + + options.examples << "example group expected example" + expected_example_was_run = false + unexpected_example_was_run = false + example_group = describe("example group") do + it "expected example" do + expected_example_was_run = true + end + it "unexpected example" do + unexpected_example_was_run = true + end + end + + options.reporter.should_receive(:add_example_group).with(Spec::Example::ExampleGroupProxy.new(example_group)) + + options.add_example_group example_group + run_with(options) + + expected_example_was_run.should be_true + unexpected_example_was_run.should be_false + end + end + end + end +end \ No newline at end of file diff --git a/vendor/gems/gems/rspec-1.2.9/spec/spec/runner/configuration_spec.rb b/vendor/gems/gems/rspec-1.2.9/spec/spec/runner/configuration_spec.rb new file mode 100755 index 00000000..ea545d64 --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/spec/spec/runner/configuration_spec.rb @@ -0,0 +1,320 @@ +require 'spec_helper' + +module Spec + module Runner + describe Configuration do + with_sandboxed_options do + with_sandboxed_config do + + describe "#mock_with" do + it "should default mock framework to rspec" do + config.mock_framework.should =~ /^spec\/adapters\/mock_frameworks\/rspec$/ + end + + it "should set rspec mocking explicitly" do + config.mock_with(:rspec) + config.mock_framework.should =~ /^spec\/adapters\/mock_frameworks\/rspec$/ + end + + it "should set mocha" do + config.mock_with(:mocha) + config.mock_framework.should =~ /^spec\/adapters\/mock_frameworks\/mocha$/ + end + + it "should set flexmock" do + config.mock_with(:flexmock) + config.mock_framework.should =~ /^spec\/adapters\/mock_frameworks\/flexmock$/ + end + + it "should set rr" do + config.mock_with(:rr) + config.mock_framework.should =~ /^spec\/adapters\/mock_frameworks\/rr$/ + end + + it "should set an arbitrary adapter module" do + adapter = Module.new + config.mock_with(adapter) + config.mock_framework.should == adapter + end + end + + describe "#include" do + + before(:each) do + @example_group_class = Class.new(::Spec::Example::ExampleGroupDouble) {} + Spec::Example::ExampleGroupFactory.register(:foobar, @example_group_class) + end + + it "should include the submitted module in ExampleGroup subclasses" do + mod = Module.new + config.include mod + Class.new(@example_group_class).included_modules.should include(mod) + end + + it "should scope modules to be included for a specific type" do + mod = Module.new + config.include mod, :type => :foobar + Class.new(@example_group_class).included_modules.should include(mod) + end + + it "should not include modules in a type they are not intended for" do + mod = Module.new + @other_example_group_class = Class.new(::Spec::Example::ExampleGroupDouble) + Spec::Example::ExampleGroupFactory.register(:baz, @other_example_group_class) + + config.include mod, :type => :foobar + + Class.new(@other_example_group_class).included_modules.should_not include(mod) + end + + it "accepts an Array of types" do + mod = Module.new + @other_example_group_class = Class.new(::Spec::Example::ExampleGroupDouble) + Spec::Example::ExampleGroupFactory.register(:baz, @other_example_group_class) + + config.include mod, :type => [:foobar, :baz] + + Class.new(@example_group_class).included_modules.should include(mod) + Class.new(@other_example_group_class).included_modules.should include(mod) + end + + end + + describe "#extend" do + + before(:each) do + @example_group_class = Class.new(::Spec::Example::ExampleGroupDouble) {} + Spec::Example::ExampleGroupFactory.register(:foobar, @example_group_class) + end + + it "should extend all groups" do + mod = Module.new + ExampleGroup.should_receive(:extend).with(mod) + Spec::Runner.configuration.extend mod + end + + it "should extend specified groups" do + mod = Module.new + @example_group_class.should_receive(:extend).with(mod) + Spec::Runner.configuration.extend mod, :type => :foobar + end + + it "should not extend non-specified groups" do + @other_example_group_class = Class.new(::Spec::Example::ExampleGroupDouble) + Spec::Example::ExampleGroupFactory.register(:baz, @other_example_group_class) + + mod = Module.new + @other_example_group_class.should_not_receive(:extend) + + Spec::Runner.configuration.extend mod, :type => :foobar + end + + end + end + + describe "ordering methods: " do + + before(:each) do + @special_example_group = Class.new(::Spec::Example::ExampleGroupDouble).describe("special_example_group") + @special_child_example_group = Class.new(@special_example_group).describe("special_child_example_group") + @nonspecial_example_group = Class.new(::Spec::Example::ExampleGroupDouble).describe("nonspecial_example_group") + Spec::Example::ExampleGroupFactory.register(:special, @special_example_group) + Spec::Example::ExampleGroupFactory.register(:special_child, @special_child_example_group) + Spec::Example::ExampleGroupFactory.register(:non_special, @nonspecial_example_group) + @example_group = @special_child_example_group.describe "Special Example Group" + @unselected_example_group = Class.new(@nonspecial_example_group).describe "Non Special Example Group" + end + + describe "#prepend_before" do + it "prepends the before block on all instances of the passed in type" do + order = [] + config.prepend_before(:all) do + order << :prepend__before_all + end + config.prepend_before(:all, :type => :special) do + order << :special_prepend__before_all + end + config.prepend_before(:all, :type => :special_child) do + order << :special_child_prepend__before_all + end + config.prepend_before(:each) do + order << :prepend__before_each + end + config.prepend_before(:each, :type => :special) do + order << :special_prepend__before_each + end + config.prepend_before(:each, :type => :special_child) do + order << :special_child_prepend__before_each + end + config.prepend_before(:all, :type => :non_special) do + order << :special_prepend__before_all + end + config.prepend_before(:each, :type => :non_special) do + order << :special_prepend__before_each + end + @example_group.it "calls prepend_before" do + end + + @example_group.run(options) + order.should == [ + :prepend__before_all, + :special_prepend__before_all, + :special_child_prepend__before_all, + :prepend__before_each, + :special_prepend__before_each, + :special_child_prepend__before_each + ] + end + end + + describe "#append_before" do + + it "calls append_before on the type" do + order = [] + config.append_before(:all) do + order << :append_before_all + end + config.append_before(:all, :type => :special) do + order << :special_append_before_all + end + config.append_before(:all, :type => :special_child) do + order << :special_child_append_before_all + end + config.append_before do # default is :each + order << :append_before_each + end + config.append_before(:each, :type => :special) do + order << :special_append_before_each + end + config.append_before(:each, :type => :special_child) do + order << :special_child_append_before_each + end + config.append_before(:all, :type => :non_special) do + order << :special_append_before_all + end + config.append_before(:each, :type => :non_special) do + order << :special_append_before_each + end + @example_group.it "calls append_before" do + end + + @example_group.run(options) + order.should == [ + :append_before_all, + :special_append_before_all, + :special_child_append_before_all, + :append_before_each, + :special_append_before_each, + :special_child_append_before_each + ] + end + end + + describe "#prepend_after" do + + it "prepends the after block on all instances of the passed in type" do + order = [] + config.prepend_after(:all) do + order << :prepend__after_all + end + config.prepend_after(:all, :type => :special) do + order << :special_prepend__after_all + end + config.prepend_after(:all, :type => :special) do + order << :special_child_prepend__after_all + end + config.prepend_after(:each) do + order << :prepend__after_each + end + config.prepend_after(:each, :type => :special) do + order << :special_prepend__after_each + end + config.prepend_after(:each, :type => :special) do + order << :special_child_prepend__after_each + end + config.prepend_after(:all, :type => :non_special) do + order << :special_prepend__after_all + end + config.prepend_after(:each, :type => :non_special) do + order << :special_prepend__after_each + end + @example_group.it "calls prepend_after" do + end + + @example_group.run(options) + order.should == [ + :special_child_prepend__after_each, + :special_prepend__after_each, + :prepend__after_each, + :special_child_prepend__after_all, + :special_prepend__after_all, + :prepend__after_all + ] + end + end + + describe "#append_after" do + + it "calls append_after on the type" do + order = [] + config.append_after(:all) do + order << :append__after_all + end + config.append_after(:all, :type => :special) do + order << :special_append__after_all + end + config.append_after(:all, :type => :special_child) do + order << :special_child_append__after_all + end + config.append_after(:each) do + order << :append__after_each + end + config.append_after(:each, :type => :special) do + order << :special_append__after_each + end + config.append_after(:each, :type => :special_child) do + order << :special_child_append__after_each + end + config.append_after(:all, :type => :non_special) do + order << :non_special_append_after_all + end + config.append_after(:each, :type => :non_special) do + order << :non_special_append_after_each + end + @example_group.it "calls append_after" do + end + + @example_group.run(options) + order.should == [ + :special_child_append__after_each, + :special_append__after_each, + :append__after_each, + :special_child_append__after_all, + :special_append__after_all, + :append__after_all + ] + end + + end + + describe "#ignore_backtrace_patterns" do + it "adds patterns to ignore in backtrace" do + config.ignore_backtrace_patterns /custom_pattern/, /shoulda/, /spork/ + config.ignored_backtrace_patterns.should include(/custom_pattern/) + config.ignored_backtrace_patterns.should include(/shoulda/) + config.ignored_backtrace_patterns.should include(/spork/) + end + end + + describe "#predicate_matchers (DEPRECATED)" do + it "is deprecated" do + Spec.should_receive(:deprecate) + config.predicate_matchers[:foo] = :bar? + end + end + + end + end + end + end +end diff --git a/vendor/gems/gems/rspec-1.2.9/spec/spec/runner/drb_command_line_spec.rb b/vendor/gems/gems/rspec-1.2.9/spec/spec/runner/drb_command_line_spec.rb new file mode 100755 index 00000000..0c17a7f6 --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/spec/spec/runner/drb_command_line_spec.rb @@ -0,0 +1,107 @@ +require 'spec_helper' + +module Spec + module Runner + unless jruby? + describe DrbCommandLine do + + context "without server running" do + it "prints error" do + err = out = StringIO.new + DrbCommandLine.run(OptionParser.parse(['--version'], err, out)) + + err.rewind + err.read.should =~ /No server is running/ + end + + it "returns nil" do + err = out = StringIO.new + result = DrbCommandLine.run(OptionParser.parse(['--version'], err, out)) + result.should be_false + end + end + + context "with server running" do + class ::CommandLineForDrbSpec + def self.run(argv, stderr, stdout) + orig_options = Spec::Runner.options + tmp_options = Spec::Runner::OptionParser.parse(argv, stderr, stdout) + Spec::Runner.use tmp_options + Spec::Runner::CommandLine.run(tmp_options) + ensure + Spec::Runner.use orig_options + end + end + + before(:all) do + DRb.start_service("druby://127.0.0.1:8989", ::CommandLineForDrbSpec) + @@drb_example_file_counter = 0 + end + + before(:each) do + create_dummy_spec_file + @@drb_example_file_counter = @@drb_example_file_counter + 1 + end + + after(:each) do + File.delete(@dummy_spec_filename) + end + + after(:all) do + DRb.stop_service + end + + it "returns true" do + err = out = StringIO.new + result = DrbCommandLine.run(OptionParser.parse(['--version'], err, out)) + result.should be_true + end + + it "should run against local server" do + out = run_spec_via_druby(['--version']) + out.should =~ /rspec \d+\.\d+\.\d+.*/n + end + + it "should output green colorized text when running with --colour option" do + out = run_spec_via_druby(["--colour", @dummy_spec_filename]) + out.should =~ /\e\[32m/n + end + + it "should output red colorized text when running with -c option" do + out = run_spec_via_druby(["-c", @dummy_spec_filename]) + out.should =~ /\e\[31m/n + end + + def create_dummy_spec_file + @dummy_spec_filename = File.expand_path(File.dirname(__FILE__)) + "/_dummy_spec#{@@drb_example_file_counter}.rb" + File.open(@dummy_spec_filename, 'w') do |f| + f.write %{ + describe "DUMMY CONTEXT for 'DrbCommandLine with -c option'" do + it "should be output with green bar" do + true.should be_true + end + + it "should be output with red bar" do + violated("I want to see a red bar!") + end + end + } + end + end + + def run_spec_via_druby(argv) + err, out = StringIO.new, StringIO.new + out.instance_eval do + def tty?; true end + end + options = ::Spec::Runner::Options.new(err, out) + options.argv = argv + Spec::Runner::DrbCommandLine.run(options) + out.rewind; out.read + end + end + + end + end + end +end diff --git a/vendor/gems/gems/rspec-1.2.9/spec/spec/runner/empty_file.txt b/vendor/gems/gems/rspec-1.2.9/spec/spec/runner/empty_file.txt new file mode 100755 index 00000000..e69de29b diff --git a/vendor/gems/gems/rspec-1.2.9/spec/spec/runner/example_group_runner_spec.rb b/vendor/gems/gems/rspec-1.2.9/spec/spec/runner/example_group_runner_spec.rb new file mode 100755 index 00000000..2b1601ac --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/spec/spec/runner/example_group_runner_spec.rb @@ -0,0 +1,26 @@ +require 'spec_helper' + +module Spec + module Runner + describe ExampleGroupRunner do + before(:each) do + err = StringIO.new('') + out = StringIO.new('') + @options = Options.new(err, out) + @runner = Spec::Runner::ExampleGroupRunner.new(@options) + end + + after(:each) do + Spec::Expectations.differ = nil + end + + describe "#load_files" do + it "should load UTF-8 encoded files" do + file = File.expand_path(File.dirname(__FILE__) + "/resources/utf8_encoded.rb") + @options.files << file + @runner.load_files(@options.files_to_load).should == @options.files_to_load + end + end + end + end +end diff --git a/vendor/gems/gems/rspec-1.2.9/spec/spec/runner/examples.txt b/vendor/gems/gems/rspec-1.2.9/spec/spec/runner/examples.txt new file mode 100755 index 00000000..2fcbd355 --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/spec/spec/runner/examples.txt @@ -0,0 +1,2 @@ +Sir, if you were my husband, I would poison your drink. +Madam, if you were my wife, I would drink it. \ No newline at end of file diff --git a/vendor/gems/gems/rspec-1.2.9/spec/spec/runner/failed.txt b/vendor/gems/gems/rspec-1.2.9/spec/spec/runner/failed.txt new file mode 100755 index 00000000..07c5442c --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/spec/spec/runner/failed.txt @@ -0,0 +1,3 @@ +heckler_spec.rb +command_line_spec.rb +reporter_spec.rb \ No newline at end of file diff --git a/vendor/gems/gems/rspec-1.2.9/spec/spec/runner/formatter/base_formatter_spec.rb b/vendor/gems/gems/rspec-1.2.9/spec/spec/runner/formatter/base_formatter_spec.rb new file mode 100755 index 00000000..a904bf38 --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/spec/spec/runner/formatter/base_formatter_spec.rb @@ -0,0 +1,30 @@ +require 'spec_helper' + +module Spec + module Runner + module Formatter + describe BaseFormatter do + subject { BaseFormatter.new(nil,nil) } + it {should respond_to(:start ).with(1).argument } + it {should respond_to(:example_group_started).with(1).argument } + it {should respond_to(:example_started ).with(1).argument } + # -3 indicates that one of the arguments is optional, with a default + # value assigned. This is due to deprecated_pending_location. Once + # that is removed, this should be changed to 2. + it {should respond_to(:example_pending ).with(-3).arguments} + it {should respond_to(:example_passed ).with(1).argument } + it {should respond_to(:example_failed ).with(3).arguments} + it {should respond_to(:start_dump ).with(0).arguments} + it {should respond_to(:dump_failure ).with(2).arguments} + it {should respond_to(:dump_summary ).with(4).arguments} + it {should respond_to(:dump_pending ).with(0).arguments} + it {should respond_to(:close ).with(0).arguments} + + it "deprecates add_example_group" do + Spec.should_receive(:deprecate) + subject.add_example_group(stub('example group')) + end + end + end + end +end diff --git a/vendor/gems/gems/rspec-1.2.9/spec/spec/runner/formatter/base_text_formatter_spec.rb b/vendor/gems/gems/rspec-1.2.9/spec/spec/runner/formatter/base_text_formatter_spec.rb new file mode 100755 index 00000000..e3677ad4 --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/spec/spec/runner/formatter/base_text_formatter_spec.rb @@ -0,0 +1,113 @@ +require 'spec_helper' +require 'spec/runner/formatter/base_text_formatter' + +module Spec + module Runner + module Formatter + describe BaseTextFormatter do + + before :all do + @sandbox = "spec/sandbox" + end + + it "should create the directory contained in WHERE if it does not exist" do + FileUtils.should_receive(:mkdir_p).with(@sandbox) + File.stub!(:open) + BaseTextFormatter.new({},"#{@sandbox}/temp.rb") + end + + context "(deprecations)" do + before(:each) do + Kernel.stub!(:warn) + @io = StringIO.new + @options = mock('options') + @options.stub!(:dry_run).and_return(false) + @options.stub!(:colour).and_return(false) + @options.stub!(:autospec).and_return(false) + @formatter = Class.new(BaseTextFormatter) do + def method_that_class_magenta(message) + magenta(message) + end + def method_that_class_colourise(message, failure) + colourise(message, failure) + end + end.new(@options, @io) + @failure = stub('failure', :pending_fixed? => false) + end + + context "#colourise" do + it "warns when subclasses call colourise" do + Spec.should_receive(:deprecate) + @formatter.method_that_class_colourise('this message', @failure) + end + + it "delegates to colorize_failure" do + @formatter.should_receive(:colorize_failure).with('this message', @failure) + @formatter.colourise('this message', @failure) + end + end + + context "#magenta" do + it "warns when subclasses call magenta" do + Spec.should_receive(:deprecate).with(/#magenta/) + @formatter.method_that_class_magenta('this message') + end + + it "delegates to red" do + @formatter.should_receive(:red).with('this message') + @formatter.method_that_class_magenta('this message') + end + end + + end + + describe "#colour (protected)" do + before(:each) do + @original_RSPEC_COLOR = ENV['RSPEC_COLOR'] + end + + it "does not colorize when output_to_file? returns true" do + out = StringIO.new + options = stub('options', :colour => true, :autospec => false) + formatter = BaseTextFormatter.new(options,out) + formatter.stub!(:output_to_tty?).and_return(true) + formatter.stub!(:output_to_file?).and_return(true) + formatter.__send__(:colour, 'foo', "\e[32m").should == "foo" + end + + it "colorizes when colour? and output_to_tty? return true" do + out = StringIO.new + options = stub('options', :colour => true, :autospec => false) + formatter = BaseTextFormatter.new(options,out) + formatter.stub!(:output_to_tty?).and_return(true) + formatter.__send__(:colour, 'foo', "\e[32m").should == "\e[32mfoo\e[0m" + end + + it "colorizes when ENV['RSPEC_COLOR'] is set even if colour? and output_to_tty? return false" do + out = StringIO.new + options = stub('options', :colour => false) + formatter = BaseTextFormatter.new(options,out) + formatter.stub!(:output_to_tty?).and_return(false) + + ENV['RSPEC_COLOR'] = 'true' + + formatter.__send__(:colour, 'foo', "\e[32m").should == "\e[32mfoo\e[0m" + end + + it "colorizes when autospec? is true even if colour? and output_to_tty? return false" do + out = StringIO.new + options = stub('options', :colour => true, :autospec => true) + formatter = BaseTextFormatter.new(options,out) + formatter.stub!(:output_to_tty?).and_return(false) + + formatter.__send__(:colour, 'foo', "\e[32m").should == "\e[32mfoo\e[0m" + end + + after(:each) do + ENV['RSPEC_COLOR'] = @original_RSPEC_COLOR + end + end + end + end + end +end diff --git a/vendor/gems/gems/rspec-1.2.9/spec/spec/runner/formatter/failing_example_groups_formatter_spec.rb b/vendor/gems/gems/rspec-1.2.9/spec/spec/runner/formatter/failing_example_groups_formatter_spec.rb new file mode 100755 index 00000000..b390131a --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/spec/spec/runner/formatter/failing_example_groups_formatter_spec.rb @@ -0,0 +1,45 @@ +require 'spec_helper' +require 'spec/runner/formatter/failing_example_groups_formatter' + +module Spec + module Runner + module Formatter + describe FailingExampleGroupsFormatter do + attr_reader :example_group, :formatter, :io + + before(:each) do + @io = StringIO.new + options = mock('options') + @formatter = FailingExampleGroupsFormatter.new(options, io) + @example_group = Class.new(::Spec::Example::ExampleGroup) + end + + it "should add example name for each failure" do + formatter.example_group_started(Spec::Example::ExampleGroupProxy.new(Class.new(::Spec::Example::ExampleGroupDouble).describe("b 1"))) + formatter.example_failed("e 1", nil, Spec::Runner::Reporter::Failure.new("g", nil, RuntimeError.new)) + formatter.example_group_started(Spec::Example::ExampleGroupProxy.new(Class.new(::Spec::Example::ExampleGroupDouble).describe("b 2"))) + formatter.example_failed("e 2", nil, Spec::Runner::Reporter::Failure.new("g", nil, RuntimeError.new)) + formatter.example_failed("e 3", nil, Spec::Runner::Reporter::Failure.new("g", nil, RuntimeError.new)) + io.string.should include("b 1") + io.string.should include("b 2") + end + + it "should delimit ExampleGroup superclass descriptions with :" do + parent_example_group = Class.new(example_group).describe("Parent") + child_example_group = Class.new(parent_example_group).describe("#child_method") + grand_child_example_group = Class.new(child_example_group).describe("GrandChild") + + formatter.example_group_started(Spec::Example::ExampleGroupProxy.new(grand_child_example_group)) + formatter.example_failed("failure", nil, ::Spec::Runner::Reporter::Failure.new("g", nil, RuntimeError.new)) + io.string.should == "Parent#child_method GrandChild\n" + end + + it "should remove druby url, which is used by Spec::Distributed" do + @formatter.example_group_started(Spec::Example::ExampleGroupProxy.new(Class.new(::Spec::Example::ExampleGroupDouble).describe("something something (druby://99.99.99.99:99)"))) + @formatter.example_failed("e 1", nil, ::Spec::Runner::Reporter::Failure.new("g", nil, RuntimeError.new)) + io.string.should == "something something\n" + end + end + end + end +end diff --git a/vendor/gems/gems/rspec-1.2.9/spec/spec/runner/formatter/failing_examples_formatter_spec.rb b/vendor/gems/gems/rspec-1.2.9/spec/spec/runner/formatter/failing_examples_formatter_spec.rb new file mode 100755 index 00000000..76d03fa3 --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/spec/spec/runner/formatter/failing_examples_formatter_spec.rb @@ -0,0 +1,33 @@ +require 'spec_helper' +require 'spec/runner/formatter/failing_examples_formatter' + +module Spec + module Runner + module Formatter + describe FailingExamplesFormatter do + before(:each) do + @io = StringIO.new + options = mock('options') + @formatter = FailingExamplesFormatter.new(options, @io) + end + + it "should add example name for each failure" do + example_group_1 = Class.new(::Spec::Example::ExampleGroupDouble).describe("A") + example_group_2 = Class.new(example_group_1).describe("B") + + @formatter.example_group_started(Spec::Example::ExampleGroupProxy.new(example_group_1)) + @formatter.example_failed(example_group_1.it("a1"){}, nil, ::Spec::Runner::Reporter::Failure.new("g", nil, RuntimeError.new)) + @formatter.example_group_started(Spec::Example::ExampleGroupProxy.new(example_group_2)) + @formatter.example_failed(example_group_2.it("b2"){}, nil, ::Spec::Runner::Reporter::Failure.new("g", nil, RuntimeError.new)) + @formatter.example_failed(example_group_2.it("b3"){}, nil, ::Spec::Runner::Reporter::Failure.new("g", nil, RuntimeError.new)) + @io.string.should eql(<<-EOF +A a1 +A B b2 +A B b3 +EOF +) + end + end + end + end +end diff --git a/vendor/gems/gems/rspec-1.2.9/spec/spec/runner/formatter/html_formatted-1.8.6-jruby.html b/vendor/gems/gems/rspec-1.2.9/spec/spec/runner/formatter/html_formatted-1.8.6-jruby.html new file mode 100755 index 00000000..029cee62 --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/spec/spec/runner/formatter/html_formatted-1.8.6-jruby.html @@ -0,0 +1,377 @@ + + + + + RSpec results + + + + + + + + +
+ +
+
+

RSpec Code Examples

+
+ +
+

 

+

 

+
+
+ +
+
+
+
Mocker
+ +
should be able to call mock()
+ + + +
+ should fail when expected message not received +
+
Mock "poke me" expected :poke with (any args) once, but received it 0 times
+
examples/failing/mocking_example.rb:11:
+spec/spec_helper.rb:42:in `run_with'
+./spec/spec/runner/formatter/html_formatter_spec.rb:41:
+./spec/spec/runner/formatter/html_formatter_spec.rb:29:in `chdir'
+./spec/spec/runner/formatter/html_formatter_spec.rb:29:
+
9  it "should fail when expected message not received" do
+10    mock = mock("poke me")
+11    mock.should_receive(:poke)
+12  end
+13  
+
+
+ +
+ should fail when messages are received out of order +
+
Mock "one two three" received :three out of order
+
examples/failing/mocking_example.rb:20:
+spec/spec_helper.rb:42:in `run_with'
+./spec/spec/runner/formatter/html_formatter_spec.rb:41:
+./spec/spec/runner/formatter/html_formatter_spec.rb:29:in `chdir'
+./spec/spec/runner/formatter/html_formatter_spec.rb:29:
+
18    mock.should_receive(:three).ordered
+19    mock.one
+20    mock.three
+21    mock.two
+22  end
+
+
+ +
+ should get yelled at when sending unexpected messages +
+
Mock "don't talk to me" expected :any_message_at_all with (no args) 0 times, but received it once
+
examples/failing/mocking_example.rb:27:
+spec/spec_helper.rb:42:in `run_with'
+./spec/spec/runner/formatter/html_formatter_spec.rb:41:
+./spec/spec/runner/formatter/html_formatter_spec.rb:29:in `chdir'
+./spec/spec/runner/formatter/html_formatter_spec.rb:29:
+
25    mock = mock("don't talk to me")
+26    mock.should_not_receive(:any_message_at_all)
+27    mock.any_message_at_all
+28  end
+
+
+ +
+ has a bug we need to fix +
+
Expected pending 'here is the bug' to fail. No Error was raised.
+
examples/failing/mocking_example.rb:31:
+spec/spec_helper.rb:42:in `run_with'
+./spec/spec/runner/formatter/html_formatter_spec.rb:41:
+./spec/spec/runner/formatter/html_formatter_spec.rb:29:in `chdir'
+./spec/spec/runner/formatter/html_formatter_spec.rb:29:
+
29
+30  it "has a bug we need to fix" do
+31    pending "here is the bug" do
+32      # Actually, no. It's fixed. This will fail because it passes :-)
+33      mock = mock("Bug")
+
+
+
+
+
+
+
Running specs with --diff
+ + +
+ should print diff of different strings +
+
expected: "RSpec is a\nbehaviour driven development\nframework for Ruby\n",
+     got: "RSpec is a\nbehavior driven development\nframework for Ruby\n" (using ==)
+
+ Diff:
+@@ -1,4 +1,4 @@
+ RSpec is a
+-behaviour driven development
++behavior driven development
+ framework for Ruby
+
+
examples/failing/diffing_spec.rb:13:
+spec/spec_helper.rb:42:in `run_with'
+./spec/spec/runner/formatter/html_formatter_spec.rb:41:
+./spec/spec/runner/formatter/html_formatter_spec.rb:29:in `chdir'
+./spec/spec/runner/formatter/html_formatter_spec.rb:29:
+
11framework for Ruby
+12EOF
+13    usa.should == uk
+14  end
+
+
+ +
+ should print diff of different objects' pretty representation +
+
+expected <Animal
+name=bob,
+species=tortoise
+>
+
+     got <Animal
+name=bob,
+species=giraffe
+>
+
+
+(compared using eql?)
+
+
examples/failing/diffing_spec.rb:34:
+spec/spec_helper.rb:42:in `run_with'
+./spec/spec/runner/formatter/html_formatter_spec.rb:41:
+./spec/spec/runner/formatter/html_formatter_spec.rb:29:in `chdir'
+./spec/spec/runner/formatter/html_formatter_spec.rb:29:
+
32    expected = Animal.new "bob", "giraffe"
+33    actual   = Animal.new "bob", "tortoise"
+34    expected.should eql(actual)
+35  end
+36end
+
+
+
+
+
+
+
A consumer of a stub
+ +
should be able to stub methods on any Object
+
+
+
+
+
A stubbed method on a class
+ +
should return the stubbed value
+ +
should revert to the original method after each spec
+ +
can stub! and mock the same message
+
+
+
+
+
A mock
+ +
can stub!
+ +
can stub! and mock
+ +
can stub! and mock the same message
+
+
+
+
+
pending example (using pending method)
+ + +
should be reported as "PENDING: for some reason" (PENDING: for some reason)
+
+
+
+
+
pending example (with no block)
+ + +
should be reported as "PENDING: Not Yet Implemented" (PENDING: Not Yet Implemented)
+
+
+
+
+
pending example (with block for pending)
+ + +
should have a failing block, passed to pending, reported as "PENDING: for some reason" (PENDING: for some reason)
+
+
+ + +
+
+ + diff --git a/vendor/gems/gems/rspec-1.2.9/spec/spec/runner/formatter/html_formatted-1.8.6.html b/vendor/gems/gems/rspec-1.2.9/spec/spec/runner/formatter/html_formatted-1.8.6.html new file mode 100755 index 00000000..1461d03e --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/spec/spec/runner/formatter/html_formatted-1.8.6.html @@ -0,0 +1,377 @@ + + + + + RSpec results + + + + + + + + +
+ +
+
+

RSpec Code Examples

+
+ +
+

 

+

 

+
+
+ +
+
+
+
Mocker
+ +
should be able to call mock()
+ + + +
+ should fail when expected message not received +
+
Mock "poke me" expected :poke with (any args) once, but received it 0 times
+
./examples/failing/mocking_example.rb:11:
+./spec/spec_helper.rb:44:in `run_with'
+./spec/spec/runner/formatter/html_formatter_spec.rb:41:
+./spec/spec/runner/formatter/html_formatter_spec.rb:29:in `chdir'
+./spec/spec/runner/formatter/html_formatter_spec.rb:29:
+
9  it "should fail when expected message not received" do
+10    mock = mock("poke me")
+11    mock.should_receive(:poke)
+12  end
+13  
+
+
+ +
+ should fail when messages are received out of order +
+
Mock "one two three" received :three out of order
+
./examples/failing/mocking_example.rb:20:
+./spec/spec_helper.rb:44:in `run_with'
+./spec/spec/runner/formatter/html_formatter_spec.rb:41:
+./spec/spec/runner/formatter/html_formatter_spec.rb:29:in `chdir'
+./spec/spec/runner/formatter/html_formatter_spec.rb:29:
+
18    mock.should_receive(:three).ordered
+19    mock.one
+20    mock.three
+21    mock.two
+22  end
+
+
+ +
+ should get yelled at when sending unexpected messages +
+
Mock "don't talk to me" expected :any_message_at_all with (no args) 0 times, but received it once
+
./examples/failing/mocking_example.rb:27:
+./spec/spec_helper.rb:44:in `run_with'
+./spec/spec/runner/formatter/html_formatter_spec.rb:41:
+./spec/spec/runner/formatter/html_formatter_spec.rb:29:in `chdir'
+./spec/spec/runner/formatter/html_formatter_spec.rb:29:
+
25    mock = mock("don't talk to me")
+26    mock.should_not_receive(:any_message_at_all)
+27    mock.any_message_at_all
+28  end
+
+
+ +
+ has a bug we need to fix +
+
Expected pending 'here is the bug' to fail. No Error was raised.
+
./examples/failing/mocking_example.rb:31:
+./spec/spec_helper.rb:44:in `run_with'
+./spec/spec/runner/formatter/html_formatter_spec.rb:41:
+./spec/spec/runner/formatter/html_formatter_spec.rb:29:in `chdir'
+./spec/spec/runner/formatter/html_formatter_spec.rb:29:
+
29
+30  it "has a bug we need to fix" do
+31    pending "here is the bug" do
+32      # Actually, no. It's fixed. This will fail because it passes :-)
+33      mock = mock("Bug")
+
+
+
+
+
+
+
Running specs with --diff
+ + +
+ should print diff of different strings +
+
expected: "RSpec is a\nbehaviour driven development\nframework for Ruby\n",
+     got: "RSpec is a\nbehavior driven development\nframework for Ruby\n" (using ==)
+
+ Diff:
+@@ -1,4 +1,4 @@
+ RSpec is a
+-behaviour driven development
++behavior driven development
+ framework for Ruby
+
+
./examples/failing/diffing_spec.rb:13:
+./spec/spec_helper.rb:44:in `run_with'
+./spec/spec/runner/formatter/html_formatter_spec.rb:41:
+./spec/spec/runner/formatter/html_formatter_spec.rb:29:in `chdir'
+./spec/spec/runner/formatter/html_formatter_spec.rb:29:
+
11framework for Ruby
+12EOF
+13    usa.should == uk
+14  end
+
+
+ +
+ should print diff of different objects' pretty representation +
+
+expected <Animal
+name=bob,
+species=tortoise
+>
+
+     got <Animal
+name=bob,
+species=giraffe
+>
+
+
+(compared using eql?)
+
+
./examples/failing/diffing_spec.rb:34:
+./spec/spec_helper.rb:44:in `run_with'
+./spec/spec/runner/formatter/html_formatter_spec.rb:41:
+./spec/spec/runner/formatter/html_formatter_spec.rb:29:in `chdir'
+./spec/spec/runner/formatter/html_formatter_spec.rb:29:
+
32    expected = Animal.new "bob", "giraffe"
+33    actual   = Animal.new "bob", "tortoise"
+34    expected.should eql(actual)
+35  end
+36end
+
+
+
+
+
+
+
A consumer of a stub
+ +
should be able to stub methods on any Object
+
+
+
+
+
A stubbed method on a class
+ +
should return the stubbed value
+ +
should revert to the original method after each spec
+ +
can stub! and mock the same message
+
+
+
+
+
A mock
+ +
can stub!
+ +
can stub! and mock
+ +
can stub! and mock the same message
+
+
+
+
+
pending example (using pending method)
+ + +
should be reported as "PENDING: for some reason" (PENDING: for some reason)
+
+
+
+
+
pending example (with no block)
+ + +
should be reported as "PENDING: Not Yet Implemented" (PENDING: Not Yet Implemented)
+
+
+
+
+
pending example (with block for pending)
+ + +
should have a failing block, passed to pending, reported as "PENDING: for some reason" (PENDING: for some reason)
+
+
+ + +
+
+ + diff --git a/vendor/gems/gems/rspec-1.2.9/spec/spec/runner/formatter/html_formatted-1.8.7.html b/vendor/gems/gems/rspec-1.2.9/spec/spec/runner/formatter/html_formatted-1.8.7.html new file mode 100755 index 00000000..5e489bba --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/spec/spec/runner/formatter/html_formatted-1.8.7.html @@ -0,0 +1,377 @@ + + + + + RSpec results + + + + + + + + +
+ +
+
+

RSpec Code Examples

+
+ +
+

 

+

 

+
+
+ +
+
+
+
Mocker
+ +
should be able to call mock()
+ + + +
+ should fail when expected message not received +
+
Mock "poke me" expected :poke with (any args) once, but received it 0 times
+
./examples/failing/mocking_example.rb:11:
+./spec/spec_helper.rb:42:in `run_with'
+./spec/spec/runner/formatter/html_formatter_spec.rb:41:
+./spec/spec/runner/formatter/html_formatter_spec.rb:29:in `chdir'
+./spec/spec/runner/formatter/html_formatter_spec.rb:29:
+
9  it "should fail when expected message not received" do
+10    mock = mock("poke me")
+11    mock.should_receive(:poke)
+12  end
+13  
+
+
+ +
+ should fail when messages are received out of order +
+
Mock "one two three" received :three out of order
+
./examples/failing/mocking_example.rb:20:
+./spec/spec_helper.rb:42:in `run_with'
+./spec/spec/runner/formatter/html_formatter_spec.rb:41:
+./spec/spec/runner/formatter/html_formatter_spec.rb:29:in `chdir'
+./spec/spec/runner/formatter/html_formatter_spec.rb:29:
+
18    mock.should_receive(:three).ordered
+19    mock.one
+20    mock.three
+21    mock.two
+22  end
+
+
+ +
+ should get yelled at when sending unexpected messages +
+
Mock "don't talk to me" expected :any_message_at_all with (no args) 0 times, but received it once
+
./examples/failing/mocking_example.rb:27:
+./spec/spec_helper.rb:42:in `run_with'
+./spec/spec/runner/formatter/html_formatter_spec.rb:41:
+./spec/spec/runner/formatter/html_formatter_spec.rb:29:in `chdir'
+./spec/spec/runner/formatter/html_formatter_spec.rb:29:
+
25    mock = mock("don't talk to me")
+26    mock.should_not_receive(:any_message_at_all)
+27    mock.any_message_at_all
+28  end
+
+
+ +
+ has a bug we need to fix +
+
Expected pending 'here is the bug' to fail. No Error was raised.
+
./examples/failing/mocking_example.rb:31:
+./spec/spec_helper.rb:42:in `run_with'
+./spec/spec/runner/formatter/html_formatter_spec.rb:41:
+./spec/spec/runner/formatter/html_formatter_spec.rb:29:in `chdir'
+./spec/spec/runner/formatter/html_formatter_spec.rb:29:
+
29
+30  it "has a bug we need to fix" do
+31    pending "here is the bug" do
+32      # Actually, no. It's fixed. This will fail because it passes :-)
+33      mock = mock("Bug")
+
+
+
+
+
+
+
Running specs with --diff
+ + +
+ should print diff of different strings +
+
expected: "RSpec is a\nbehaviour driven development\nframework for Ruby\n",
+     got: "RSpec is a\nbehavior driven development\nframework for Ruby\n" (using ==)
+
+ Diff:
+@@ -1,4 +1,4 @@
+ RSpec is a
+-behaviour driven development
++behavior driven development
+ framework for Ruby
+
+
./examples/failing/diffing_spec.rb:13:
+./spec/spec_helper.rb:42:in `run_with'
+./spec/spec/runner/formatter/html_formatter_spec.rb:41:
+./spec/spec/runner/formatter/html_formatter_spec.rb:29:in `chdir'
+./spec/spec/runner/formatter/html_formatter_spec.rb:29:
+
11framework for Ruby
+12EOF
+13    usa.should == uk
+14  end
+
+
+ +
+ should print diff of different objects' pretty representation +
+
+expected <Animal
+name=bob,
+species=tortoise
+>
+
+     got <Animal
+name=bob,
+species=giraffe
+>
+
+
+(compared using eql?)
+
+
./examples/failing/diffing_spec.rb:34:
+./spec/spec_helper.rb:42:in `run_with'
+./spec/spec/runner/formatter/html_formatter_spec.rb:41:
+./spec/spec/runner/formatter/html_formatter_spec.rb:29:in `chdir'
+./spec/spec/runner/formatter/html_formatter_spec.rb:29:
+
32    expected = Animal.new "bob", "giraffe"
+33    actual   = Animal.new "bob", "tortoise"
+34    expected.should eql(actual)
+35  end
+36end
+
+
+
+
+
+
+
A consumer of a stub
+ +
should be able to stub methods on any Object
+
+
+
+
+
A stubbed method on a class
+ +
should return the stubbed value
+ +
should revert to the original method after each spec
+ +
can stub! and mock the same message
+
+
+
+
+
A mock
+ +
can stub!
+ +
can stub! and mock
+ +
can stub! and mock the same message
+
+
+
+
+
pending example (using pending method)
+ + +
should be reported as "PENDING: for some reason" (PENDING: for some reason)
+
+
+
+
+
pending example (with no block)
+ + +
should be reported as "PENDING: Not Yet Implemented" (PENDING: Not Yet Implemented)
+
+
+
+
+
pending example (with block for pending)
+ + +
should have a failing block, passed to pending, reported as "PENDING: for some reason" (PENDING: for some reason)
+
+
+ + +
+
+ + diff --git a/vendor/gems/gems/rspec-1.2.9/spec/spec/runner/formatter/html_formatted-1.9.1.html b/vendor/gems/gems/rspec-1.2.9/spec/spec/runner/formatter/html_formatted-1.9.1.html new file mode 100755 index 00000000..5d0be3bf --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/spec/spec/runner/formatter/html_formatted-1.9.1.html @@ -0,0 +1,377 @@ + + + + + RSpec results + + + + + + + + +
+ +
+
+

RSpec Code Examples

+
+ +
+

 

+

 

+
+
+ +
+
+
+
Mocker
+ +
should be able to call mock()
+ + + +
+ should fail when expected message not received +
+
Mock "poke me" expected :poke with (any args) once, but received it 0 times
+
./examples/failing/mocking_example.rb:11:in `block (2 levels) in '
+./spec/spec_helper.rb:42:in `run_with'
+./spec/spec/runner/formatter/html_formatter_spec.rb:41:in `block (4 levels) in '
+./spec/spec/runner/formatter/html_formatter_spec.rb:29:in `chdir'
+./spec/spec/runner/formatter/html_formatter_spec.rb:29:in `block (3 levels) in '
+
9  it "should fail when expected message not received" do
+10    mock = mock("poke me")
+11    mock.should_receive(:poke)
+12  end
+13  
+
+
+ +
+ should fail when messages are received out of order +
+
Mock "one two three" received :three out of order
+
./examples/failing/mocking_example.rb:20:in `block (2 levels) in '
+./spec/spec_helper.rb:42:in `run_with'
+./spec/spec/runner/formatter/html_formatter_spec.rb:41:in `block (4 levels) in '
+./spec/spec/runner/formatter/html_formatter_spec.rb:29:in `chdir'
+./spec/spec/runner/formatter/html_formatter_spec.rb:29:in `block (3 levels) in '
+
18    mock.should_receive(:three).ordered
+19    mock.one
+20    mock.three
+21    mock.two
+22  end
+
+
+ +
+ should get yelled at when sending unexpected messages +
+
Mock "don't talk to me" expected :any_message_at_all with (no args) 0 times, but received it once
+
./examples/failing/mocking_example.rb:27:in `block (2 levels) in '
+./spec/spec_helper.rb:42:in `run_with'
+./spec/spec/runner/formatter/html_formatter_spec.rb:41:in `block (4 levels) in '
+./spec/spec/runner/formatter/html_formatter_spec.rb:29:in `chdir'
+./spec/spec/runner/formatter/html_formatter_spec.rb:29:in `block (3 levels) in '
+
25    mock = mock("don't talk to me")
+26    mock.should_not_receive(:any_message_at_all)
+27    mock.any_message_at_all
+28  end
+
+
+ +
+ has a bug we need to fix +
+
Expected pending 'here is the bug' to fail. No Error was raised.
+
./examples/failing/mocking_example.rb:31:in `block (2 levels) in '
+./spec/spec_helper.rb:42:in `run_with'
+./spec/spec/runner/formatter/html_formatter_spec.rb:41:in `block (4 levels) in '
+./spec/spec/runner/formatter/html_formatter_spec.rb:29:in `chdir'
+./spec/spec/runner/formatter/html_formatter_spec.rb:29:in `block (3 levels) in '
+
29
+30  it "has a bug we need to fix" do
+31    pending "here is the bug" do
+32      # Actually, no. It's fixed. This will fail because it passes :-)
+33      mock = mock("Bug")
+
+
+
+
+
+
+
Running specs with --diff
+ + +
+ should print diff of different strings +
+
expected: "RSpec is a\nbehaviour driven development\nframework for Ruby\n",
+     got: "RSpec is a\nbehavior driven development\nframework for Ruby\n" (using ==)
+
+ Diff:
+@@ -1,4 +1,4 @@
+ RSpec is a
+-behaviour driven development
++behavior driven development
+ framework for Ruby
+
+
./examples/failing/diffing_spec.rb:13:in `block (2 levels) in '
+./spec/spec_helper.rb:42:in `run_with'
+./spec/spec/runner/formatter/html_formatter_spec.rb:41:in `block (4 levels) in '
+./spec/spec/runner/formatter/html_formatter_spec.rb:29:in `chdir'
+./spec/spec/runner/formatter/html_formatter_spec.rb:29:in `block (3 levels) in '
+
11framework for Ruby
+12EOF
+13    usa.should == uk
+14  end
+
+
+ +
+ should print diff of different objects' pretty representation +
+
+expected <Animal
+name=bob,
+species=tortoise
+>
+
+     got <Animal
+name=bob,
+species=giraffe
+>
+
+
+(compared using eql?)
+
+
./examples/failing/diffing_spec.rb:34:in `block (2 levels) in '
+./spec/spec_helper.rb:42:in `run_with'
+./spec/spec/runner/formatter/html_formatter_spec.rb:41:in `block (4 levels) in '
+./spec/spec/runner/formatter/html_formatter_spec.rb:29:in `chdir'
+./spec/spec/runner/formatter/html_formatter_spec.rb:29:in `block (3 levels) in '
+
32    expected = Animal.new "bob", "giraffe"
+33    actual   = Animal.new "bob", "tortoise"
+34    expected.should eql(actual)
+35  end
+36end
+
+
+
+
+
+
+
A consumer of a stub
+ +
should be able to stub methods on any Object
+
+
+
+
+
A stubbed method on a class
+ +
should return the stubbed value
+ +
should revert to the original method after each spec
+ +
can stub! and mock the same message
+
+
+
+
+
A mock
+ +
can stub!
+ +
can stub! and mock
+ +
can stub! and mock the same message
+
+
+
+
+
pending example (using pending method)
+ + +
should be reported as "PENDING: for some reason" (PENDING: for some reason)
+
+
+
+
+
pending example (with no block)
+ + +
should be reported as "PENDING: Not Yet Implemented" (PENDING: Not Yet Implemented)
+
+
+
+
+
pending example (with block for pending)
+ + +
should have a failing block, passed to pending, reported as "PENDING: for some reason" (PENDING: for some reason)
+
+
+ + +
+
+ + diff --git a/vendor/gems/gems/rspec-1.2.9/spec/spec/runner/formatter/html_formatter_spec.rb b/vendor/gems/gems/rspec-1.2.9/spec/spec/runner/formatter/html_formatter_spec.rb new file mode 100755 index 00000000..bbff1ef4 --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/spec/spec/runner/formatter/html_formatter_spec.rb @@ -0,0 +1,118 @@ +# require 'spec_helper' + +begin # See rescue all the way at the bottom + +require 'nokogiri' # Needed to compare generated with wanted HTML +require 'spec/runner/formatter/html_formatter' + +module Spec + module Runner + module Formatter + describe HtmlFormatter do + + treats_method_missing_as_private + + attr_reader :root, :expected_file, :expected_html + + before do + @root = File.expand_path("#{File.dirname(__FILE__)}/../../../..") + suffix = jruby? ? '-jruby' : '' + @expected_file = "#{File.dirname(__FILE__)}/html_formatted-#{::RUBY_VERSION}#{suffix}.html" + raise "There is no HTML file with expected content for this platform: #{expected_file}" unless File.file?(expected_file) + @expected_html = File.read(expected_file) + end + + # Uncomment this line temporarily in order to overwrite the expected with actual. + # Use with care!!! + # describe "file generator" do + # it "generates a new comparison file" do + # Dir.chdir(root) do + # args = [ + # 'examples/failing/mocking_example.rb', + # 'examples/failing/diffing_spec.rb', + # 'examples/passing/stubbing_example.rb', + # 'examples/passing/pending_example.rb', + # '--format', + # 'html', + # "--diff" + # ] + # err = StringIO.new + # out = StringIO.new + # run_with ::Spec::Runner::OptionParser.parse(args, err, out) + # + # seconds = /\d+\.\d+ seconds/ + # html = out.string.gsub seconds, 'x seconds' + # + # File.open(expected_file, 'w') {|io| io.write(html)} + # end + # end + # end + + it "should produce HTML identical to the one we designed manually with --diff" do + Dir.chdir(root) do + args = [ + 'examples/failing/mocking_example.rb', + 'examples/failing/diffing_spec.rb', + 'examples/passing/stubbing_example.rb', + 'examples/passing/pending_example.rb', + '--format', + 'html', + "--diff" + ] + err = StringIO.new + out = StringIO.new + run_with ::Spec::Runner::OptionParser.parse(args, err, out) + + seconds = /\d+\.\d+ seconds/ + html = out.string.gsub seconds, 'x seconds' + expected_html.gsub! seconds, 'x seconds' + + doc = Nokogiri::HTML(html) + backtraces = doc.search("div.backtrace").collect {|e| e.at("pre").inner_html} + doc.css("div.backtrace").remove + + expected_doc = Nokogiri::HTML(expected_html) + expected_backtraces = expected_doc.search("div.backtrace").collect {|e| e.at("pre").inner_html} + expected_doc.search("div.backtrace").remove + + doc.inner_html.should == expected_doc.inner_html + + expected_backtraces.each_with_index do |expected_line, i| + expected_path, expected_line_number, expected_suffix = expected_line.split(':') + actual_path, actual_line_number, actual_suffix = backtraces[i].split(':') + File.expand_path(actual_path).should == File.expand_path(expected_path) + actual_line_number.should == expected_line_number + end + end + end + + it "should produce HTML identical to the one we designed manually with --dry-run" do + Dir.chdir(root) do + args = [ + 'examples/failing/mocking_example.rb', + 'examples/failing/diffing_spec.rb', + 'examples/passing/stubbing_example.rb', + 'examples/passing/pending_example.rb', + '--format', + 'html', + "--dry-run" + ] + err = StringIO.new + out = StringIO.new + run_with ::Spec::Runner::OptionParser.parse(args, err, out) + + seconds = /\d+\.\d+ seconds/ + html = out.string.gsub seconds, 'x seconds' + expected_html.gsub! seconds, 'x seconds' + + html.should =~ /This was a dry-run/m + end + end + end + end + end +end + +rescue LoadError + warn "nokogiri not loaded -- skipping HtmlFormatter specs" +end diff --git a/vendor/gems/gems/rspec-1.2.9/spec/spec/runner/formatter/nested_text_formatter_spec.rb b/vendor/gems/gems/rspec-1.2.9/spec/spec/runner/formatter/nested_text_formatter_spec.rb new file mode 100755 index 00000000..29e96ff5 --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/spec/spec/runner/formatter/nested_text_formatter_spec.rb @@ -0,0 +1,305 @@ +require 'spec_helper' +require 'spec/runner/formatter/nested_text_formatter' + +module Spec + module Runner + module Formatter + describe NestedTextFormatter do + with_sandboxed_options do + attr_reader :io, :options, :formatter, :example_group + before(:each) do + @io = StringIO.new + options.stub!(:dry_run).and_return(false) + options.stub!(:colour).and_return(false) + @formatter = NestedTextFormatter.new(options, io) + @example_group = Class.new(::Spec::Example::ExampleGroupDouble).describe("ExampleGroup") + @example_group.example("example") {} + end + + describe "where ExampleGroup has no superclass with a description" do + def example_group_started + formatter.example_group_started(Spec::Example::ExampleGroupProxy.new(example_group)) + end + + before do + example_group_started + end + + describe "#dump_summary" do + it "should produce standard summary without pending when pending has a 0 count" do + formatter.dump_summary(3, 2, 1, 0) + io.string.should == <<-OUT +ExampleGroup + +Finished in 3 seconds + +2 examples, 1 failure +OUT + end + + it "should produce standard summary" do + formatter.dump_summary(3, 2, 1, 4) + io.string.should == <<-OUT +ExampleGroup + +Finished in 3 seconds + +2 examples, 1 failure, 4 pending +OUT + end + end + + describe "#example_group_started" do + describe "when ExampleGroup has a nested description" do + + describe "when ExampleGroup has no parents with nested description" do + it "should push ExampleGroup name" do + io.string.should eql("ExampleGroup\n") + end + end + + describe "when ExampleGroup has one parent with nested description" do + attr_reader :child_example_group + def example_group_started + @child_example_group = Class.new(example_group).describe("Child ExampleGroup") + end + + describe "and parent ExampleGroups have not been printed" do + before do + formatter.example_group_started(Spec::Example::ExampleGroupProxy.new(child_example_group)) + end + + it "should push ExampleGroup name with two spaces of indentation" do + io.string.should == <<-OUT +ExampleGroup + Child ExampleGroup +OUT + end + end + + describe "and parent ExampleGroups have been printed" do + before do + formatter.example_group_started(Spec::Example::ExampleGroupProxy.new(example_group)) + io.string = "" + formatter.example_group_started(Spec::Example::ExampleGroupProxy.new(child_example_group)) + end + + it "should print only the indented ExampleGroup" do + io.string.should == <<-OUT + Child ExampleGroup +OUT + end + end + end + + describe "when ExampleGroup has two parents with nested description" do + attr_reader :child_example_group, :grand_child_example_group + def example_group_started + @child_example_group = Class.new(example_group).describe("Child ExampleGroup") + @grand_child_example_group = Class.new(child_example_group).describe("GrandChild ExampleGroup") + end + + describe "and parent ExampleGroups have not been printed" do + before do + formatter.example_group_started(Spec::Example::ExampleGroupProxy.new(grand_child_example_group)) + + end + + it "should print the entire nested ExampleGroup heirarchy" do + io.string.should == <<-OUT +ExampleGroup + Child ExampleGroup + GrandChild ExampleGroup +OUT + end + end + + describe "and parent ExampleGroups have been printed" do + before do + formatter.example_group_started(Spec::Example::ExampleGroupProxy.new(child_example_group)) + io.string = "" + formatter.example_group_started(Spec::Example::ExampleGroupProxy.new(grand_child_example_group)) + end + + it "should print only the indented ExampleGroup" do + io.string.should == <<-OUT + GrandChild ExampleGroup +OUT + end + end + end + end + + describe "when ExampleGroup nested description is blank" do + attr_reader :child_example_group + + describe "and parent ExampleGroups have not been printed" do + def example_group_started + @child_example_group = Class.new(example_group) + formatter.example_group_started(Spec::Example::ExampleGroupProxy.new(child_example_group)) + end + + it "should render only the parent ExampleGroup" do + io.string.should == <<-OUT +ExampleGroup +OUT + end + end + + describe "and parent ExampleGroups have been printed" do + def example_group_started + @child_example_group = Class.new(example_group) + formatter.example_group_started(Spec::Example::ExampleGroupProxy.new(example_group)) + io.string = "" + formatter.example_group_started(Spec::Example::ExampleGroupProxy.new(child_example_group)) + end + + it "should not render anything" do + io.string.should == "" + end + end + end + + describe "when ExampleGroup nested description is blank" do + def example_group_started + example_group.set_description + super + end + + it "should not render anything" do + io.string.should == "" + end + end + end + + describe "#example_failed" do + describe "where ExampleGroup has no superclasss with a description" do + describe "when having an error" do + it "should push failing spec name and failure number" do + formatter.example_failed( + example_group.it("spec"), + 98, + ::Spec::Runner::Reporter::Failure.new("g", "c s", RuntimeError.new) + ) + io.string.should == <<-OUT +ExampleGroup + spec (FAILED - 98) +OUT + end + end + + describe "when having an expectation failure" do + it "should push failing spec name and failure number" do + formatter.example_failed( + example_group.it("spec"), + 98, + ::Spec::Runner::Reporter::Failure.new("g", "c s", Spec::Expectations::ExpectationNotMetError.new) + ) + io.string.should == <<-OUT +ExampleGroup + spec (FAILED - 98) +OUT + end + end + end + + describe "where ExampleGroup has two superclasses with a description" do + attr_reader :child_example_group, :grand_child_example_group + + def example_group_started + @child_example_group = Class.new(example_group).describe("Child ExampleGroup") + @grand_child_example_group = Class.new(child_example_group).describe("GrandChild ExampleGroup") + formatter.example_group_started(Spec::Example::ExampleGroupProxy.new(grand_child_example_group)) + end + + describe "when having an error" do + it "should push failing spec name and failure number" do + formatter.example_failed( + grand_child_example_group.it("spec"), + 98, + ::Spec::Runner::Reporter::Failure.new("g", "c s", RuntimeError.new) + ) + io.string.should == <<-OUT +ExampleGroup + Child ExampleGroup + GrandChild ExampleGroup + spec (FAILED - 98) +OUT + end + end + + describe "when having an expectation" do + it "should push failing spec name and failure number" do + formatter.example_failed( + grand_child_example_group.it("spec"), + 98, + ::Spec::Runner::Reporter::Failure.new("g", "c s", Spec::Expectations::ExpectationNotMetError.new) + ) + io.string.should == <<-OUT +ExampleGroup + Child ExampleGroup + GrandChild ExampleGroup + spec (FAILED - 98) +OUT + end + end + end + end + + describe "#start" do + it "should push nothing on start" do + formatter.start(5) + io.string.should == <<-OUT +ExampleGroup +OUT + end + end + + describe "#start_dump" do + it "should push nothing on start dump" do + formatter.start_dump + io.string.should == <<-OUT +ExampleGroup +OUT + end + end + + describe "#example_passed" do + it "should push passing spec name" do + formatter.example_passed(example_group.it("spec")) + io.string.should == <<-OUT +ExampleGroup + spec +OUT + end + end + + describe "#example_pending" do + it "should push pending example name and message" do + formatter.example_pending(example_group.examples.first, 'reason', "#{__FILE__}:#{__LINE__}") + io.string.should == <<-OUT +ExampleGroup + example (PENDING: reason) +OUT + end + + it "should dump pending" do + formatter.example_pending(example_group.examples.first, 'reason', "#{__FILE__}:#{__LINE__}") + io.rewind + formatter.dump_pending + io.string.should =~ /Pending\:\n\nExampleGroup example \(reason\)\n/ + end + end + + def have_single_level_example_group_output(expected_output) + expected = "ExampleGroup\n #{expected_output}" + ::Spec::Matchers::SimpleMatcher.new(expected) do |actual| + actual == expected + end + end + end + end + end + end + end +end \ No newline at end of file diff --git a/vendor/gems/gems/rspec-1.2.9/spec/spec/runner/formatter/profile_formatter_spec.rb b/vendor/gems/gems/rspec-1.2.9/spec/spec/runner/formatter/profile_formatter_spec.rb new file mode 100755 index 00000000..338df708 --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/spec/spec/runner/formatter/profile_formatter_spec.rb @@ -0,0 +1,70 @@ +require 'spec_helper' +require 'spec/runner/formatter/profile_formatter' + +module Spec + module Runner + module Formatter + describe ProfileFormatter do + + treats_method_missing_as_private + + attr_reader :io, :formatter + before(:each) do + @io = StringIO.new + options = mock('options') + options.stub!(:colour).and_return(true) + options.stub!(:autospec).and_return(true) + @formatter = ProfileFormatter.new(options, io) + end + + it "should print a heading" do + formatter.start(0) + io.string.should eql("Profiling enabled.\n") + end + + it "should record the current time when starting a new example" do + now = Time.now + Time.stub!(:now).and_return(now) + formatter.example_started('should foo') + formatter.instance_variable_get("@time").should == now + end + + it "should correctly record a passed example" do + now = Time.now + Time.stub!(:now).and_return(now) + parent_example_group = Class.new(::Spec::Example::ExampleGroupDouble).describe('Parent') + child_example_group = Class.new(parent_example_group).describe('Child') + + formatter.example_group_started(Spec::Example::ExampleGroupProxy.new(child_example_group)) + + formatter.example_started('when foo') + Time.stub!(:now).and_return(now+1) + formatter.example_passed(stub('foo', :description => 'i like ice cream')) + + formatter.start_dump + io.string.should include('Parent Child') + end + + it "should sort the results in descending order" do + formatter.instance_variable_set("@example_times", [['a', 'a', 0.1], ['b', 'b', 0.3], ['c', 'c', 0.2]]) + formatter.start_dump + formatter.instance_variable_get("@example_times").should == [ ['b', 'b', 0.3], ['c', 'c', 0.2], ['a', 'a', 0.1]] + end + + it "should print the top 10 results" do + example_group = Class.new(::Spec::Example::ExampleGroup).describe("ExampleGroup") + formatter.example_group_started(Spec::Example::ExampleGroupProxy.new(example_group)) + formatter.instance_variable_set("@time", Time.now) + + 15.times do + formatter.example_passed(stub('foo', :description => 'i like ice cream')) + end + + io.should_receive(:print).exactly(10) + formatter.start_dump + end + + end + end + end +end diff --git a/vendor/gems/gems/rspec-1.2.9/spec/spec/runner/formatter/progress_bar_formatter_spec.rb b/vendor/gems/gems/rspec-1.2.9/spec/spec/runner/formatter/progress_bar_formatter_spec.rb new file mode 100755 index 00000000..ea96ca6c --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/spec/spec/runner/formatter/progress_bar_formatter_spec.rb @@ -0,0 +1,149 @@ +require 'spec_helper' +require 'spec/runner/formatter/progress_bar_formatter' + +module Spec + module Runner + module Formatter + describe ProgressBarFormatter do + + treats_method_missing_as_private + + before(:each) do + @io = StringIO.new + @options = mock('options') + @options.stub!(:dry_run).and_return(false) + @options.stub!(:colour).and_return(false) + @options.stub!(:autospec).and_return(false) + @formatter = ProgressBarFormatter.new(@options, @io) + end + + it "should produce line break on start dump" do + @formatter.start_dump + @io.string.should eql("\n") + end + + it "should produce standard summary without pending when pending has a 0 count" do + @formatter.dump_summary(3, 2, 1, 0) + @io.string.should eql("\nFinished in 3 seconds\n\n2 examples, 1 failure\n") + end + + it "should produce standard summary" do + example_group = ExampleGroup.describe("example_group") do + specify "example" do + end + end + example = example_group.examples.first + @formatter.example_group_started(Spec::Example::ExampleGroupProxy.new(example_group)) + @formatter.example_pending(example, "message", "#{__FILE__}:#{__LINE__}") + @io.rewind + @formatter.dump_summary(3, 2, 1, 1) + @io.string.should eql(%Q| +Finished in 3 seconds + +2 examples, 1 failure, 1 pending +|) + end + + it "should push green dot for passing spec" do + @formatter.stub(:output_to_file?) {false} + @io.stub(:tty?) {true} + @options.stub(:colour) {true} + @formatter.example_passed("spec") + @io.string.should == "\e[32m.\e[0m" + end + + it "should push red F for failure spec" do + @formatter.stub(:output_to_file?) {false} + @io.stub(:tty?) {true} + @options.stub(:colour) {true} + @formatter.example_failed("spec", 98, Spec::Runner::Reporter::Failure.new("g", "c s", Spec::Expectations::ExpectationNotMetError.new)) + @io.string.should eql("\e[31mF\e[0m") + end + + it "should push red F for error spec" do + @formatter.stub(:output_to_file?) {false} + @io.stub(:tty?) {true} + @options.stub(:colour) {true} + @formatter.example_failed("spec", 98, Spec::Runner::Reporter::Failure.new("g", "c s", RuntimeError.new)) + @io.string.should eql("\e[31mF\e[0m") + end + + it "should push blue F for fixed pending spec" do + @formatter.stub(:output_to_file?) {false} + @io.stub(:tty?) {true} + @options.stub(:colour) {true} + @formatter.example_failed("spec", 98, Spec::Runner::Reporter::Failure.new("g", "c s", Spec::Example::PendingExampleFixedError.new)) + @io.string.should eql("\e[34mF\e[0m") + end + + it "should push nothing on start" do + @formatter.start(4) + @io.string.should eql("") + end + + it "should ensure two ':' in the first backtrace" do + backtrace = ["/tmp/x.rb:1", "/tmp/x.rb:2", "/tmp/x.rb:3"] + @formatter.format_backtrace(backtrace).should eql(<<-EOE.rstrip) +/tmp/x.rb:1: +/tmp/x.rb:2: +/tmp/x.rb:3: +EOE + + backtrace = ["/tmp/x.rb:1: message", "/tmp/x.rb:2", "/tmp/x.rb:3"] + @formatter.format_backtrace(backtrace).should eql(<<-EOE.rstrip) +/tmp/x.rb:1: message +/tmp/x.rb:2: +/tmp/x.rb:3: +EOE + end + + it "should dump pending with file and line number" do + example_group = ExampleGroup.describe("example_group") do + specify "example" do + end + end + example = example_group.examples.first + file = __FILE__ + line = __LINE__ - 5 + @formatter.example_group_started(Spec::Example::ExampleGroupProxy.new(example_group)) + @formatter.example_pending(example, "message", "#{__FILE__}:#{__LINE__}") + @formatter.dump_pending + @io.string.should =~ /Pending:\n\nexample_group example \(message\)\n#{file}:#{line}/m + end + end + + describe "ProgressBarFormatter outputting to custom out" do + before(:each) do + @out = mock("out") + @options = mock('options') + @out.stub!(:puts) + @formatter = ProgressBarFormatter.new(@options, @out) + @formatter.class.__send__ :public, :output_to_tty? + end + + after(:each) do + @formatter.class.__send__ :protected, :output_to_tty? + end + + it "should not throw NoMethodError on output_to_tty?" do + @out.should_receive(:tty?).and_raise(NoMethodError) + @formatter.output_to_tty?.should be_false + end + end + + describe ProgressBarFormatter, "dry run" do + before(:each) do + @io = StringIO.new + options = mock('options') + options.stub!(:dry_run).and_return(true) + @formatter = ProgressBarFormatter.new(options, @io) + end + + it "should not produce summary on dry run" do + @formatter.dump_summary(3, 2, 1, 0) + @io.string.should eql("") + end + end + end + end +end diff --git a/vendor/gems/gems/rspec-1.2.9/spec/spec/runner/formatter/snippet_extractor_spec.rb b/vendor/gems/gems/rspec-1.2.9/spec/spec/runner/formatter/snippet_extractor_spec.rb new file mode 100755 index 00000000..c683c39a --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/spec/spec/runner/formatter/snippet_extractor_spec.rb @@ -0,0 +1,18 @@ +require 'spec_helper' +require 'spec/runner/formatter/snippet_extractor' + +module Spec + module Runner + module Formatter + describe SnippetExtractor do + it "should fall back on a default message when it doesn't understand a line" do + SnippetExtractor.new.snippet_for("blech").should == ["# Couldn't get snippet for blech", 1] + end + + it "should fall back on a default message when it doesn't find the file" do + SnippetExtractor.new.lines_around("blech", 8).should == "# Couldn't get snippet for blech" + end + end + end + end +end \ No newline at end of file diff --git a/vendor/gems/gems/rspec-1.2.9/spec/spec/runner/formatter/specdoc_formatter_spec.rb b/vendor/gems/gems/rspec-1.2.9/spec/spec/runner/formatter/specdoc_formatter_spec.rb new file mode 100755 index 00000000..ac4e0eee --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/spec/spec/runner/formatter/specdoc_formatter_spec.rb @@ -0,0 +1,159 @@ +require 'spec_helper' +require 'spec/runner/formatter/specdoc_formatter' + +module Spec + module Runner + module Formatter + describe SpecdocFormatter do + with_sandboxed_options do + attr_reader :io, :formatter, :example_group + before(:each) do + @io = StringIO.new + options.stub!(:dry_run).and_return(false) + options.stub!(:colour).and_return(false) + @formatter = SpecdocFormatter.new(options, io) + @example_group = ::Spec::Example::ExampleGroup.describe("ExampleGroup") do + specify "example" do + end + end + end + + describe "where ExampleGroup has no superclasss with a description" do + before do + example_group_started + end + + def example_group_started + formatter.example_group_started(Spec::Example::ExampleGroupProxy.new(example_group)) + end + + describe "#dump_summary" do + it "should produce standard summary without pending when pending has a 0 count" do + formatter.dump_summary(3, 2, 1, 0) + io.string.should have_example_group_output("\nFinished in 3 seconds\n\n2 examples, 1 failure\n") + end + + it "should produce standard summary" do + formatter.dump_summary(3, 2, 1, 4) + io.string.should have_example_group_output("\nFinished in 3 seconds\n\n2 examples, 1 failure, 4 pending\n") + end + end + + describe "#example_group_started" do + it "should push ExampleGroup name" do + io.string.should eql("\nExampleGroup\n") + end + end + + describe "#example_failed" do + describe "where ExampleGroup has no superclasss with a description" do + describe "when having an error" do + it "should push failing spec name and failure number" do + formatter.example_failed( + example_group.it("spec"), + 98, + Spec::Runner::Reporter::Failure.new("g", "c s", RuntimeError.new) + ) + io.string.should have_example_group_output("- spec (FAILED - 98)\n") + end + end + + describe "when having an expectation failure" do + it "should push failing spec name and failure number" do + formatter.example_failed( + example_group.it("spec"), + 98, + Spec::Runner::Reporter::Failure.new("g", "c s", Spec::Expectations::ExpectationNotMetError.new) + ) + io.string.should have_example_group_output("- spec (FAILED - 98)\n") + end + end + end + + describe "where ExampleGroup has two superclasses with a description" do + attr_reader :child_example_group, :grand_child_example_group + + def example_group_started + @child_example_group = Class.new(example_group).describe("Child ExampleGroup") + @grand_child_example_group = Class.new(child_example_group).describe("GrandChild ExampleGroup") + formatter.example_group_started(Spec::Example::ExampleGroupProxy.new(grand_child_example_group)) + end + + describe "when having an error" do + it "should push failing spec name and failure number" do + formatter.example_failed( + example_group.it("spec"), + 98, + Spec::Runner::Reporter::Failure.new("g", "c s", RuntimeError.new) + ) + io.string.should have_nested_example_group_output("- spec (FAILED - 98)\n") + end + end + + describe "when having an expectation" do + it "should push failing spec name and failure number" do + formatter.example_failed( + example_group.it("spec"), + 98, + Spec::Runner::Reporter::Failure.new("g", "c s", Spec::Expectations::ExpectationNotMetError.new) + ) + io.string.should have_nested_example_group_output("- spec (FAILED - 98)\n") + end + end + + def have_nested_example_group_output(expected_output) + expected_full_output = "\nExampleGroup Child ExampleGroup GrandChild ExampleGroup\n#{expected_output}" + ::Spec::Matchers::SimpleMatcher.new(expected_full_output) do |actual| + actual == expected_full_output + end + end + end + end + + describe "#start" do + it "should push nothing on start" do + formatter.start(5) + io.string.should have_example_group_output("") + end + end + + describe "#start_dump" do + it "should push nothing on start dump" do + formatter.start_dump + io.string.should have_example_group_output("") + end + end + + describe "#example_passed" do + it "should push passing spec name" do + formatter.example_passed(example_group.it("spec")) + io.string.should have_example_group_output("- spec\n") + end + end + + describe "#example_pending" do + it "should push pending example name and message" do + formatter.example_pending(example_group.examples.first, 'reason', "#{__FILE__}:#{__LINE__}") + io.string.should have_example_group_output("- example (PENDING: reason)\n") + end + + it "should dump pending" do + formatter.example_pending(example_group.examples.first, 'reason', "#{__FILE__}:#{__LINE__}") + io.rewind + formatter.dump_pending + io.string.should =~ /Pending\:\n\nExampleGroup example \(reason\)\n/ + end + end + + def have_example_group_output(expected_output) + expected = "\nExampleGroup\n#{expected_output}" + ::Spec::Matchers::SimpleMatcher.new(expected) do |actual| + actual == expected + end + end + end + end + end + end + end +end diff --git a/vendor/gems/gems/rspec-1.2.9/spec/spec/runner/formatter/text_mate_formatted-1.8.6-jruby.html b/vendor/gems/gems/rspec-1.2.9/spec/spec/runner/formatter/text_mate_formatted-1.8.6-jruby.html new file mode 100755 index 00000000..bbef5eb8 --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/spec/spec/runner/formatter/text_mate_formatted-1.8.6-jruby.html @@ -0,0 +1,371 @@ + + + + + RSpec results + + + + + + + + +
+ +
+
+

RSpec Code Examples

+
+ +
+

 

+

 

+
+
+ +
+
+
+
Mocker
+ +
should be able to call mock()
+ + + +
+ should fail when expected message not received +
+
Mock "poke me" expected :poke with (any args) once, but received it 0 times
+ +
9  it "should fail when expected message not received" do
+10    mock = mock("poke me")
+11    mock.should_receive(:poke)
+12  end
+13  
+
+
+ +
+ should fail when messages are received out of order +
+
Mock "one two three" received :three out of order
+ +
18    mock.should_receive(:three).ordered
+19    mock.one
+20    mock.three
+21    mock.two
+22  end
+
+
+ +
+ should get yelled at when sending unexpected messages +
+
Mock "don't talk to me" expected :any_message_at_all with (no args) 0 times, but received it once
+ +
25    mock = mock("don't talk to me")
+26    mock.should_not_receive(:any_message_at_all)
+27    mock.any_message_at_all
+28  end
+
+
+ +
+ has a bug we need to fix +
+
Expected pending 'here is the bug' to fail. No Error was raised.
+ +
29
+30  it "has a bug we need to fix" do
+31    pending "here is the bug" do
+32      # Actually, no. It's fixed. This will fail because it passes :-)
+33      mock = mock("Bug")
+
+
+
+
+
+
+
Running specs with --diff
+ + +
+ should print diff of different strings +
+
expected: "RSpec is a\nbehaviour driven development\nframework for Ruby\n",
+     got: "RSpec is a\nbehavior driven development\nframework for Ruby\n" (using ==)
+
+ Diff:
+@@ -1,4 +1,4 @@
+ RSpec is a
+-behaviour driven development
++behavior driven development
+ framework for Ruby
+
+ +
11framework for Ruby
+12EOF
+13    usa.should == uk
+14  end
+
+
+ +
+ should print diff of different objects' pretty representation +
+
+expected <Animal
+name=bob,
+species=tortoise
+>
+
+     got <Animal
+name=bob,
+species=giraffe
+>
+
+
+(compared using eql?)
+
+ +
32    expected = Animal.new "bob", "giraffe"
+33    actual   = Animal.new "bob", "tortoise"
+34    expected.should eql(actual)
+35  end
+36end
+
+
+
+
+
+
+
A consumer of a stub
+ +
should be able to stub methods on any Object
+
+
+
+
+
A stubbed method on a class
+ +
should return the stubbed value
+ +
should revert to the original method after each spec
+ +
can stub! and mock the same message
+
+
+
+
+
A mock
+ +
can stub!
+ +
can stub! and mock
+ +
can stub! and mock the same message
+
+
+
+
+
pending example (using pending method)
+ + +
should be reported as "PENDING: for some reason" (PENDING: for some reason)
+
+
+
+
+
pending example (with no block)
+ + +
should be reported as "PENDING: Not Yet Implemented" (PENDING: Not Yet Implemented)
+
+
+
+
+
pending example (with block for pending)
+ + +
should have a failing block, passed to pending, reported as "PENDING: for some reason" (PENDING: for some reason)
+
+
+ + +
+
+ + diff --git a/vendor/gems/gems/rspec-1.2.9/spec/spec/runner/formatter/text_mate_formatted-1.8.6.html b/vendor/gems/gems/rspec-1.2.9/spec/spec/runner/formatter/text_mate_formatted-1.8.6.html new file mode 100755 index 00000000..54d76190 --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/spec/spec/runner/formatter/text_mate_formatted-1.8.6.html @@ -0,0 +1,371 @@ + + + + + RSpec results + + + + + + + + +
+ +
+
+

RSpec Code Examples

+
+ +
+

 

+

 

+
+
+ +
+
+
+
Mocker
+ +
should be able to call mock()
+ + + +
+ should fail when expected message not received +
+
Mock "poke me" expected :poke with (any args) once, but received it 0 times
+ +
9  it "should fail when expected message not received" do
+10    mock = mock("poke me")
+11    mock.should_receive(:poke)
+12  end
+13  
+
+
+ +
+ should fail when messages are received out of order +
+
Mock "one two three" received :three out of order
+ +
18    mock.should_receive(:three).ordered
+19    mock.one
+20    mock.three
+21    mock.two
+22  end
+
+
+ +
+ should get yelled at when sending unexpected messages +
+
Mock "don't talk to me" expected :any_message_at_all with (no args) 0 times, but received it once
+ +
25    mock = mock("don't talk to me")
+26    mock.should_not_receive(:any_message_at_all)
+27    mock.any_message_at_all
+28  end
+
+
+ +
+ has a bug we need to fix +
+
Expected pending 'here is the bug' to fail. No Error was raised.
+ +
29
+30  it "has a bug we need to fix" do
+31    pending "here is the bug" do
+32      # Actually, no. It's fixed. This will fail because it passes :-)
+33      mock = mock("Bug")
+
+
+
+
+
+
+
Running specs with --diff
+ + +
+ should print diff of different strings +
+
expected: "RSpec is a\nbehaviour driven development\nframework for Ruby\n",
+     got: "RSpec is a\nbehavior driven development\nframework for Ruby\n" (using ==)
+
+ Diff:
+@@ -1,4 +1,4 @@
+ RSpec is a
+-behaviour driven development
++behavior driven development
+ framework for Ruby
+
+ +
11framework for Ruby
+12EOF
+13    usa.should == uk
+14  end
+
+
+ +
+ should print diff of different objects' pretty representation +
+
+expected <Animal
+name=bob,
+species=tortoise
+>
+
+     got <Animal
+name=bob,
+species=giraffe
+>
+
+
+(compared using eql?)
+
+ +
32    expected = Animal.new "bob", "giraffe"
+33    actual   = Animal.new "bob", "tortoise"
+34    expected.should eql(actual)
+35  end
+36end
+
+
+
+
+
+
+
A consumer of a stub
+ +
should be able to stub methods on any Object
+
+
+
+
+
A stubbed method on a class
+ +
should return the stubbed value
+ +
should revert to the original method after each spec
+ +
can stub! and mock the same message
+
+
+
+
+
A mock
+ +
can stub!
+ +
can stub! and mock
+ +
can stub! and mock the same message
+
+
+
+
+
pending example (using pending method)
+ + +
should be reported as "PENDING: for some reason" (PENDING: for some reason)
+
+
+
+
+
pending example (with no block)
+ + +
should be reported as "PENDING: Not Yet Implemented" (PENDING: Not Yet Implemented)
+
+
+
+
+
pending example (with block for pending)
+ + +
should have a failing block, passed to pending, reported as "PENDING: for some reason" (PENDING: for some reason)
+
+
+ + +
+
+ + diff --git a/vendor/gems/gems/rspec-1.2.9/spec/spec/runner/formatter/text_mate_formatted-1.8.7.html b/vendor/gems/gems/rspec-1.2.9/spec/spec/runner/formatter/text_mate_formatted-1.8.7.html new file mode 100755 index 00000000..54d76190 --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/spec/spec/runner/formatter/text_mate_formatted-1.8.7.html @@ -0,0 +1,371 @@ + + + + + RSpec results + + + + + + + + +
+ +
+
+

RSpec Code Examples

+
+ +
+

 

+

 

+
+
+ +
+
+
+
Mocker
+ +
should be able to call mock()
+ + + +
+ should fail when expected message not received +
+
Mock "poke me" expected :poke with (any args) once, but received it 0 times
+ +
9  it "should fail when expected message not received" do
+10    mock = mock("poke me")
+11    mock.should_receive(:poke)
+12  end
+13  
+
+
+ +
+ should fail when messages are received out of order +
+
Mock "one two three" received :three out of order
+ +
18    mock.should_receive(:three).ordered
+19    mock.one
+20    mock.three
+21    mock.two
+22  end
+
+
+ +
+ should get yelled at when sending unexpected messages +
+
Mock "don't talk to me" expected :any_message_at_all with (no args) 0 times, but received it once
+ +
25    mock = mock("don't talk to me")
+26    mock.should_not_receive(:any_message_at_all)
+27    mock.any_message_at_all
+28  end
+
+
+ +
+ has a bug we need to fix +
+
Expected pending 'here is the bug' to fail. No Error was raised.
+ +
29
+30  it "has a bug we need to fix" do
+31    pending "here is the bug" do
+32      # Actually, no. It's fixed. This will fail because it passes :-)
+33      mock = mock("Bug")
+
+
+
+
+
+
+
Running specs with --diff
+ + +
+ should print diff of different strings +
+
expected: "RSpec is a\nbehaviour driven development\nframework for Ruby\n",
+     got: "RSpec is a\nbehavior driven development\nframework for Ruby\n" (using ==)
+
+ Diff:
+@@ -1,4 +1,4 @@
+ RSpec is a
+-behaviour driven development
++behavior driven development
+ framework for Ruby
+
+ +
11framework for Ruby
+12EOF
+13    usa.should == uk
+14  end
+
+
+ +
+ should print diff of different objects' pretty representation +
+
+expected <Animal
+name=bob,
+species=tortoise
+>
+
+     got <Animal
+name=bob,
+species=giraffe
+>
+
+
+(compared using eql?)
+
+ +
32    expected = Animal.new "bob", "giraffe"
+33    actual   = Animal.new "bob", "tortoise"
+34    expected.should eql(actual)
+35  end
+36end
+
+
+
+
+
+
+
A consumer of a stub
+ +
should be able to stub methods on any Object
+
+
+
+
+
A stubbed method on a class
+ +
should return the stubbed value
+ +
should revert to the original method after each spec
+ +
can stub! and mock the same message
+
+
+
+
+
A mock
+ +
can stub!
+ +
can stub! and mock
+ +
can stub! and mock the same message
+
+
+
+
+
pending example (using pending method)
+ + +
should be reported as "PENDING: for some reason" (PENDING: for some reason)
+
+
+
+
+
pending example (with no block)
+ + +
should be reported as "PENDING: Not Yet Implemented" (PENDING: Not Yet Implemented)
+
+
+
+
+
pending example (with block for pending)
+ + +
should have a failing block, passed to pending, reported as "PENDING: for some reason" (PENDING: for some reason)
+
+
+ + +
+
+ + diff --git a/vendor/gems/gems/rspec-1.2.9/spec/spec/runner/formatter/text_mate_formatted-1.9.1.html b/vendor/gems/gems/rspec-1.2.9/spec/spec/runner/formatter/text_mate_formatted-1.9.1.html new file mode 100755 index 00000000..24c98046 --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/spec/spec/runner/formatter/text_mate_formatted-1.9.1.html @@ -0,0 +1,371 @@ + + + + + RSpec results + + + + + + + + +
+ +
+
+

RSpec Code Examples

+
+ +
+

 

+

 

+
+
+ +
+
+
+
Mocker
+ +
should be able to call mock()
+ + + +
+ should fail when expected message not received +
+
Mock "poke me" expected :poke with (any args) once, but received it 0 times
+ +
9  it "should fail when expected message not received" do
+10    mock = mock("poke me")
+11    mock.should_receive(:poke)
+12  end
+13  
+
+
+ +
+ should fail when messages are received out of order +
+
Mock "one two three" received :three out of order
+ +
18    mock.should_receive(:three).ordered
+19    mock.one
+20    mock.three
+21    mock.two
+22  end
+
+
+ +
+ should get yelled at when sending unexpected messages +
+
Mock "don't talk to me" expected :any_message_at_all with (no args) 0 times, but received it once
+ +
25    mock = mock("don't talk to me")
+26    mock.should_not_receive(:any_message_at_all)
+27    mock.any_message_at_all
+28  end
+
+
+ +
+ has a bug we need to fix +
+
Expected pending 'here is the bug' to fail. No Error was raised.
+ +
29
+30  it "has a bug we need to fix" do
+31    pending "here is the bug" do
+32      # Actually, no. It's fixed. This will fail because it passes :-)
+33      mock = mock("Bug")
+
+
+
+
+
+
+
Running specs with --diff
+ + +
+ should print diff of different strings +
+
expected: "RSpec is a\nbehaviour driven development\nframework for Ruby\n",
+     got: "RSpec is a\nbehavior driven development\nframework for Ruby\n" (using ==)
+
+ Diff:
+@@ -1,4 +1,4 @@
+ RSpec is a
+-behaviour driven development
++behavior driven development
+ framework for Ruby
+
+ +
11framework for Ruby
+12EOF
+13    usa.should == uk
+14  end
+
+
+ +
+ should print diff of different objects' pretty representation +
+
+expected <Animal
+name=bob,
+species=tortoise
+>
+
+     got <Animal
+name=bob,
+species=giraffe
+>
+
+
+(compared using eql?)
+
+ +
32    expected = Animal.new "bob", "giraffe"
+33    actual   = Animal.new "bob", "tortoise"
+34    expected.should eql(actual)
+35  end
+36end
+
+
+
+
+
+
+
A consumer of a stub
+ +
should be able to stub methods on any Object
+
+
+
+
+
A stubbed method on a class
+ +
should return the stubbed value
+ +
should revert to the original method after each spec
+ +
can stub! and mock the same message
+
+
+
+
+
A mock
+ +
can stub!
+ +
can stub! and mock
+ +
can stub! and mock the same message
+
+
+
+
+
pending example (using pending method)
+ + +
should be reported as "PENDING: for some reason" (PENDING: for some reason)
+
+
+
+
+
pending example (with no block)
+ + +
should be reported as "PENDING: Not Yet Implemented" (PENDING: Not Yet Implemented)
+
+
+
+
+
pending example (with block for pending)
+ + +
should have a failing block, passed to pending, reported as "PENDING: for some reason" (PENDING: for some reason)
+
+
+ + +
+
+ + diff --git a/vendor/gems/gems/rspec-1.2.9/spec/spec/runner/formatter/text_mate_formatter_spec.rb b/vendor/gems/gems/rspec-1.2.9/spec/spec/runner/formatter/text_mate_formatter_spec.rb new file mode 100755 index 00000000..a35ad89f --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/spec/spec/runner/formatter/text_mate_formatter_spec.rb @@ -0,0 +1,106 @@ +require 'spec_helper' + +begin # See rescue all the way at the bottom + +require 'nokogiri' # Needed to compare generated with wanted HTML +require 'spec/runner/formatter/text_mate_formatter' + +module Spec + module Runner + module Formatter + describe TextMateFormatter do + attr_reader :root, :suffix, :expected_file + before do + @root = File.expand_path(File.dirname(__FILE__) + '/../../../..') + @suffix = jruby? ? '-jruby' : '' + @expected_file = File.dirname(__FILE__) + "/text_mate_formatted-#{::RUBY_VERSION}#{suffix}.html" + end + + def produces_html_identical_to_manually_designed_document(opt) + root = File.expand_path(File.dirname(__FILE__) + '/../../../..') + + Dir.chdir(root) do + args = [ + 'examples/failing/mocking_example.rb', + 'examples/failing/diffing_spec.rb', + 'examples/passing/stubbing_example.rb', + 'examples/passing/pending_example.rb', + '--format', + 'textmate', + opt + ] + err = StringIO.new + out = StringIO.new + + run_with ::Spec::Runner::OptionParser.parse(args, err, out) + + yield(out.string) + end + end + + # Uncomment this spec temporarily in order to overwrite the expected with actual. + # Use with care!!! + # describe "functional spec file generator" do + # it "generates a new comparison file" do + # Dir.chdir(root) do + # args = ['examples/failing/mocking_example.rb', 'examples/failing/diffing_spec.rb', 'examples/passing/stubbing_example.rb', 'examples/passing/pending_example.rb', '--format', 'textmate', '--diff'] + # err = StringIO.new + # out = StringIO.new + # Spec::Runner::CommandLine.run( + # ::Spec::Runner::OptionParser.parse(args, err, out) + # ) + # + # seconds = /\d+\.\d+ seconds/ + # html = out.string.gsub seconds, 'x seconds' + # + # File.open(expected_file, 'w') {|io| io.write(html)} + # end + # end + # end + + describe "functional spec using --diff" do + it "should produce HTML identical to the one we designed manually with --diff" do + produces_html_identical_to_manually_designed_document("--diff") do |html| + suffix = jruby? ? '-jruby' : '' + expected_file = File.dirname(__FILE__) + "/text_mate_formatted-#{::RUBY_VERSION}#{suffix}.html" + unless File.file?(expected_file) + raise "There is no HTML file with expected content for this platform: #{expected_file}" + end + expected_html = File.read(expected_file) + + seconds = /\d+\.\d+ seconds/ + html.gsub! seconds, 'x seconds' + expected_html.gsub! seconds, 'x seconds' + + doc = Nokogiri::HTML(html) + backtraces = doc.search("div.backtrace a") + doc.search("div.backtrace").remove + + expected_doc = Nokogiri::HTML(expected_html) + expected_doc.search("div.backtrace").remove + + doc.inner_html.should == expected_doc.inner_html + + backtraces.each do |backtrace_link| + backtrace_link['href'].should include("txmt://open?url=") + end + end + end + + end + + describe "functional spec using --dry-run" do + it "should produce HTML identical to the one we designed manually with --dry-run" do + produces_html_identical_to_manually_designed_document("--dry-run") do |html, expected_html| + html.should =~ /This was a dry-run/m + end + end + end + end + end + end +end + +rescue LoadError + warn "nokogiri not loaded -- skipping TextMateFormatter specs" +end diff --git a/vendor/gems/gems/rspec-1.2.9/spec/spec/runner/heckle_runner_spec.rb b/vendor/gems/gems/rspec-1.2.9/spec/spec/runner/heckle_runner_spec.rb new file mode 100755 index 00000000..287ff856 --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/spec/spec/runner/heckle_runner_spec.rb @@ -0,0 +1,78 @@ +require 'spec_helper' +unless [/mswin/, /java/].detect{|p| p =~ RUBY_PLATFORM} || Spec::Ruby.version.to_f == 1.9 + require 'spec/runner/heckle_runner' + + module Foo + class Bar + def one; end + def two; end + end + + class Zap + def three; end + def four; end + end + end + + describe "HeckleRunner" do + before(:each) do + @heckle = mock("heckle", :null_object => true) + @heckle_class = mock("heckle_class") + end + + it "should heckle all methods in all classes in a module" do + @heckle_class.should_receive(:new).with("Foo::Bar", "one", Spec::Runner.options).and_return(@heckle) + @heckle_class.should_receive(:new).with("Foo::Bar", "two", Spec::Runner.options).and_return(@heckle) + @heckle_class.should_receive(:new).with("Foo::Zap", "three", Spec::Runner.options).and_return(@heckle) + @heckle_class.should_receive(:new).with("Foo::Zap", "four", Spec::Runner.options).and_return(@heckle) + + heckle_runner = Spec::Runner::HeckleRunner.new("Foo", @heckle_class) + heckle_runner.heckle_with + end + + it "should heckle all methods in a class" do + @heckle_class.should_receive(:new).with("Foo::Bar", "one", Spec::Runner.options).and_return(@heckle) + @heckle_class.should_receive(:new).with("Foo::Bar", "two", Spec::Runner.options).and_return(@heckle) + + heckle_runner = Spec::Runner::HeckleRunner.new("Foo::Bar", @heckle_class) + heckle_runner.heckle_with + end + + it "should fail heckling when the class is not found" do + lambda do + heckle_runner = Spec::Runner::HeckleRunner.new("Foo::Bob", @heckle_class) + heckle_runner.heckle_with + end.should raise_error(StandardError, "Heckling failed - \"Foo::Bob\" is not a known class or module") + end + + it "should heckle specific method in a class (with #)" do + @heckle_class.should_receive(:new).with("Foo::Bar", "two", Spec::Runner.options).and_return(@heckle) + + heckle_runner = Spec::Runner::HeckleRunner.new("Foo::Bar#two", @heckle_class) + heckle_runner.heckle_with + end + + it "should heckle specific method in a class (with .)" do + @heckle_class.should_receive(:new).with("Foo::Bar", "two", Spec::Runner.options).and_return(@heckle) + + heckle_runner = Spec::Runner::HeckleRunner.new("Foo::Bar.two", @heckle_class) + heckle_runner.heckle_with + end + end + + describe "Heckler" do + it "should say yes to tests_pass? if specs pass" do + options = mock("options", :null_object => true) + options.should_receive(:run_examples).and_return(true) + heckler = Spec::Runner::Heckler.new("Foo", nil, options) + heckler.tests_pass?.should be_true + end + + it "should say no to tests_pass? if specs fail" do + options = mock("options", :null_object => true) + options.should_receive(:run_examples).and_return(false) + heckler = Spec::Runner::Heckler.new("Foo", nil, options) + heckler.tests_pass?.should be_false + end + end +end diff --git a/vendor/gems/gems/rspec-1.2.9/spec/spec/runner/heckler_spec.rb b/vendor/gems/gems/rspec-1.2.9/spec/spec/runner/heckler_spec.rb new file mode 100755 index 00000000..00869df6 --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/spec/spec/runner/heckler_spec.rb @@ -0,0 +1,20 @@ +if Spec::Ruby.version.to_f < 1.9 + require 'spec_helper' + unless [/mswin/, /java/].detect{|p| p =~ RUBY_PLATFORM} + require 'spec/runner/heckle_runner' + + describe "Heckler" do + it "should run examples on tests_pass?" do + sub = Class.new(Spec::Runner::Heckler) do + def initialize(klass_name, method_name, rspec_options) + @rspec_options = rspec_options + end + end + opts = mock('options') + opts.should_receive(:run_examples).and_return(true) + heckler = sub.new('klass','method',opts) + heckler.tests_pass? + end + end + end +end diff --git a/vendor/gems/gems/rspec-1.2.9/spec/spec/runner/line_number_query/line_number_query_fixture.rb b/vendor/gems/gems/rspec-1.2.9/spec/spec/runner/line_number_query/line_number_query_fixture.rb new file mode 100755 index 00000000..82a257d3 --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/spec/spec/runner/line_number_query/line_number_query_fixture.rb @@ -0,0 +1,70 @@ +require 'spec_helper' + +describe "c" do + + it "1" do + end + + it "2" do + end + +end + +describe "d" do + + it "3" do + end + + it "4" do + end + +end + +class LineNumberQuerySubject +end + +describe LineNumberQuerySubject do + + it "5" do + end + +end + +describe LineNumberQuerySubject, "described" do + + it "6" do + end + +end + +describe LineNumberQuerySubject, "described", :something => :something_else do + + it "7" do + end + +end + +describe "described", :something => :something_else do + + it "8" do + end + +end + +describe "e" do + + it "9" do + end + + it "10" do + end + + describe "f" do + it "11" do + end + + it "12" do + end + end + +end diff --git a/vendor/gems/gems/rspec-1.2.9/spec/spec/runner/line_number_query_spec.rb b/vendor/gems/gems/rspec-1.2.9/spec/spec/runner/line_number_query_spec.rb new file mode 100755 index 00000000..e4e11050 --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/spec/spec/runner/line_number_query_spec.rb @@ -0,0 +1,129 @@ +require 'spec_helper' + +describe "LineNumberQuery" do + with_sandboxed_options do + attr_reader :parser, :file + + before do + @parser = Spec::Runner::LineNumberQuery.new(options) + @file = "#{File.dirname(__FILE__)}/line_number_query/line_number_query_fixture.rb" + load file + end + + it "should find spec name for 'specify' at same line" do + parser.spec_name_for(file, 5).should == "c 1" + end + + it "should find spec name for 'specify' at end of spec line" do + parser.spec_name_for(file, 6).should == "c 1" + end + + it "should find context for 'context' above all specs" do + parser.spec_name_for(file, 4).should == "c" + end + + it "should find spec name for 'it' at same line" do + parser.spec_name_for(file, 15).should == "d 3" + end + + it "should find spec name for 'it' at end of spec line" do + parser.spec_name_for(file, 16).should == "d 3" + end + + it "should find context for 'describe' above all specs" do + parser.spec_name_for(file, 14).should == "d" + end + + it "should find nearest example name between examples" do + parser.spec_name_for(file, 7).should == "c 1" + end + + it "should find nothing outside a context" do + parser.spec_name_for(file, 2).should be_nil + end + + it "should find context name for type" do + parser.spec_name_for(file, 26).should == "LineNumberQuerySubject" + end + + it "should find context and spec name for type" do + parser.spec_name_for(file, 28).should == "LineNumberQuerySubject 5" + end + + it "should find context and description for type" do + parser.spec_name_for(file, 33).should == "LineNumberQuerySubject described" + end + + it "should find context and description and example for type" do + parser.spec_name_for(file, 36).should == "LineNumberQuerySubject described 6" + end + + it "should find context and description for type with modifications" do + parser.spec_name_for(file, 40).should == "LineNumberQuerySubject described" + end + + it "should find context and described and example for type with modifications" do + parser.spec_name_for(file, 43).should == "LineNumberQuerySubject described 7" + end + + it "should find example group" do + parser.spec_name_for(file, 47).should == "described" + end + + it "should find example" do + parser.spec_name_for(file, 50).should == "described 8" + end + + it "should find nested example" do + parser.spec_name_for(file, 63).should == "e f 11" + end + + it "should handle paths which contain colons" do + fixture = + { "c:/somepath/somefile.rb:999:in 'method'" => "c:/somepath/somefile.rb", + "./somepath/somefile:999" => "./somepath/somefile" } + fixture.each_pair do |input, expected| + parser.send(:parse_location, input ).should == [expected, 999] + end + end + + it "should handle paths which contain colons and backslashes" do + fixture = + { "c:\\somepath\\somefile.rb:999:in 'method'" => "c:\\somepath\\somefile.rb", + ".\\somepath\\somefile:999" => ".\\somepath\\somefile" } + fixture.each_pair do |input, expected| + parser.send(:parse_location, input ).should == [expected, 999] + end + end + + it "ignores example group base classes which have no location" do + options = stub('options', :example_groups => [ + stub('example_group', :location => nil) + ]) + parser = Spec::Runner::LineNumberQuery.new(options) + parser.spec_name_for('foo',37).should == nil + end + + describe "#example_line_for" do + it "should find example declared on same line" do + parser.example_line_for(file, 5).should == 5 + end + + it "should find example declared on the line above, while still inside the example" do + parser.example_line_for(file, 6).should == 5 + end + + it "should find example declared from empty line below the example" do + parser.example_line_for(file, 7).should == 5 + end + + it "should find the group declared on the same line" do + parser.example_line_for(file, 3).should == 3 + end + + it "should find the group declared above the first example" do + parser.example_line_for(file, 4).should == 3 + end + end + end +end diff --git a/vendor/gems/gems/rspec-1.2.9/spec/spec/runner/noisy_backtrace_tweaker_spec.rb b/vendor/gems/gems/rspec-1.2.9/spec/spec/runner/noisy_backtrace_tweaker_spec.rb new file mode 100755 index 00000000..13b79432 --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/spec/spec/runner/noisy_backtrace_tweaker_spec.rb @@ -0,0 +1,51 @@ +require 'spec_helper' + +module Spec + module Runner + describe NoisyBacktraceTweaker do + before(:each) do + @error = RuntimeError.new + @tweaker = NoisyBacktraceTweaker.new + end + + it "gracefully handles nil backtrace" do + lambda do + @tweaker.tweak_backtrace(@error) + end.should_not raise_error + end + + it "cleans up double slashes" do + @error.set_backtrace(["/a//b/c//d.rb"]) + @tweaker.tweak_backtrace(@error) + @error.backtrace.should include("/a/b/c/d.rb") + end + + it "preserves lines in lib/spec" do + ["expectations", "mocks", "runner", "stubs"].each do |child| + @error.set_backtrace(["/lib/spec/#{child}/anything.rb"]) + @tweaker.tweak_backtrace(@error) + @error.backtrace.should_not be_empty + end + end + + it "preserves lines in spec/" do + @error.set_backtrace(["/lib/spec/expectations/anything.rb"]) + @tweaker.tweak_backtrace(@error) + @error.backtrace.should_not be_empty + end + + it "preserves lines in bin/spec" do + @error.set_backtrace(["bin/spec:"]) + @tweaker.tweak_backtrace(@error) + @error.backtrace.should_not be_empty + end + + it "ignores custom patterns" do + @tweaker.ignore_patterns(/custom_pattern/) + @error.set_backtrace(["custom_pattern"]) + @tweaker.tweak_backtrace(@error) + @error.backtrace.should_not be_empty + end + end + end +end diff --git a/vendor/gems/gems/rspec-1.2.9/spec/spec/runner/option_parser_spec.rb b/vendor/gems/gems/rspec-1.2.9/spec/spec/runner/option_parser_spec.rb new file mode 100755 index 00000000..a516bc68 --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/spec/spec/runner/option_parser_spec.rb @@ -0,0 +1,545 @@ +require 'spec_helper' +require 'spec/runner/resources/custom_example_group_runner' +require 'fakefs/safe' +require 'fakefs/spec_helpers' + +describe "OptionParser" do + before(:each) do + @out = StringIO.new + @err = StringIO.new + @parser = Spec::Runner::OptionParser.new(@err, @out) + end + + def parse(args) + @parser.parse(args) + @parser.options + end + + # FIXME - this entire file should run w/ fakefs + describe "with fakefs" do + extend FakeFS::SpecHelpers + use_fakefs + + it "should not use colour by default" do + options = parse([]) + options.colour.should == false + end + + it "should use progress bar formatter by default" do + options = parse([]) + options.formatters[0].class.should equal(Spec::Runner::Formatter::ProgressBarFormatter) + end + end + + it "should leave the submitted argv alone" do + args = ["--pattern", "foo"] + @parser.order!(args) + args.should == ["--pattern", "foo"] + end + + it "should accept files to include" do + options = parse(["--pattern", "foo"]) + options.filename_pattern.should == "foo" + end + + it "should accept debugger option" do + options = parse(["--debugger"]) + options.debug.should be_true + end + + it "should accept -u form of debugger option" do + options = parse(["-u"]) + options.debug.should be_true + end + + it "should turn off the debugger option if drb is specified later" do + @parser.stub!(:parse_drb).with(no_args).and_return(true) + options = parse(["-u", "--drb"]) + options.debug.should be_false + end + + it "should turn off the debugger option if drb is specified first" do + @parser.stub!(:parse_drb).with(no_args).and_return(true) + options = parse(["--drb", "-u"]) + options.debug.should be_false + end + + it "should accept dry run option" do + options = parse(["--dry-run"]) + options.dry_run.should be_true + end + + it "should eval and use custom formatter when none of the builtins" do + options = parse(["--format", "Custom::Formatter"]) + options.formatters[0].class.should be(Custom::Formatter) + end + + it "should support formatters with relative and absolute paths, even on windows" do + options = parse([ + "--format", "Custom::Formatter:C:\\foo\\bar", + "--format", "Custom::Formatter:foo/bar", + "--format", "Custom::Formatter:foo\\bar", + "--format", "Custom::Formatter:/foo/bar" + ]) + options.formatters[0].where.should eql("C:\\foo\\bar") + options.formatters[1].where.should eql("foo/bar") + options.formatters[2].where.should eql("foo\\bar") + options.formatters[3].where.should eql("/foo/bar") + end + + it "should not be verbose by default" do + options = parse([]) + options.verbose.should be_nil + end + + it "should print help to stdout if no args and spec_comand?" do + Spec::Runner::OptionParser.stub!(:spec_command?).and_return(true) + options = parse([]) + @out.rewind + @out.read.should match(/Usage: spec \(FILE\(:LINE\)\?\|DIRECTORY\|GLOB\)\+ \[options\]/m) + end + + it "should not print help to stdout if no args and NOT spec_command?" do + Spec::Runner::OptionParser.stub!(:spec_command?).and_return(false) + options = parse([]) + @out.rewind + @out.read.should == "" + end + + it "should print help to stdout" do + options = parse(["--help"]) + @out.rewind + @out.read.should match(/Usage: spec \(FILE\(:LINE\)\?\|DIRECTORY\|GLOB\)\+ \[options\]/m) + end + + it "should print instructions about how to require missing formatter" do + lambda do + options = parse(["--format", "Custom::MissingFormatter"]) + options.formatters + end.should raise_error(NameError) + @err.string.should match(/Couldn't find formatter class Custom::MissingFormatter/n) + end + + it "should print version to stdout" do + options = parse(["--version"]) + @out.rewind + @out.read.should match(/rspec \d+\.\d+\.\d+/n) + end + + it "should require file when require specified" do + lambda do + parse(["--require", "whatever"]) + end.should raise_error(LoadError) + end + + it "should support c option" do + options = parse(["-c"]) + options.colour.should be_true + end + + it "should support queens colour option" do + options = parse(["--colour"]) + options.colour.should be_true + end + + it "should support us color option" do + options = parse(["--color"]) + options.colour.should be_true + end + + it "should support single example with -e option" do + options = parse(["-e", "something or other"]) + options.examples.should eql(["something or other"]) + end + + it "should support single example with -s option (will be removed when autotest supports -e)" do + options = parse(["-s", "something or other"]) + options.examples.should eql(["something or other"]) + end + + it "should support single example with --example option" do + options = parse(["--example", "something or other"]) + options.examples.should eql(["something or other"]) + end + + it "should read several example names from file if --example is given an existing file name" do + options = parse(["--example", File.dirname(__FILE__) + '/examples.txt']) + options.examples.should eql([ + "Sir, if you were my husband, I would poison your drink.", + "Madam, if you were my wife, I would drink it."]) + end + + it "should read no examples if given an empty file" do + options = parse(["--example", File.dirname(__FILE__) + '/empty_file.txt']) + options.examples.should eql([]) + end + + it "should use html formatter when format is h" do + options = parse(["--format", "h"]) + options.formatters[0].class.should equal(Spec::Runner::Formatter::HtmlFormatter) + end + + it "should use html formatter when format is html" do + options = parse(["--format", "html"]) + options.formatters[0].class.should equal(Spec::Runner::Formatter::HtmlFormatter) + end + + it "should use silent formatter when format is s" do + options = parse(["--format", "l"]) + options.formatters[0].class.should equal(Spec::Runner::Formatter::SilentFormatter) + end + + it "should use silent formatter when format is silent" do + options = parse(["--format", "silent"]) + options.formatters[0].class.should equal(Spec::Runner::Formatter::SilentFormatter) + end + + it "should use html formatter with explicit output when format is html:test.html" do + FileUtils.rm 'test.html' if File.exist?('test.html') + options = parse(["--format", "html:test.html"]) + options.formatters # creates the file + File.should exist('test.html') + options.formatters[0].class.should equal(Spec::Runner::Formatter::HtmlFormatter) + options.formatters[0].close + FileUtils.rm 'test.html' + end + + it "should use noisy backtrace tweaker with b option" do + options = parse(["-b"]) + options.backtrace_tweaker.should be_instance_of(Spec::Runner::NoisyBacktraceTweaker) + end + + it "should use noisy backtrace tweaker with backtrace option" do + options = parse(["--backtrace"]) + options.backtrace_tweaker.should be_instance_of(Spec::Runner::NoisyBacktraceTweaker) + end + + it "should use quiet backtrace tweaker by default" do + options = parse([]) + options.backtrace_tweaker.should be_instance_of(Spec::Runner::QuietBacktraceTweaker) + end + + it "should use specdoc formatter when format is s" do + options = parse(["--format", "s"]) + options.formatters[0].class.should equal(Spec::Runner::Formatter::SpecdocFormatter) + end + + it "should use specdoc formatter when format is specdoc" do + options = parse(["--format", "specdoc"]) + options.formatters[0].class.should equal(Spec::Runner::Formatter::SpecdocFormatter) + end + + it "should use nested text formatter when format is s" do + options = parse(["--format", "n"]) + options.formatters[0].class.should equal(Spec::Runner::Formatter::NestedTextFormatter) + end + + it "should use nested text formatter when format is nested" do + options = parse(["--format", "nested"]) + options.formatters[0].class.should equal(Spec::Runner::Formatter::NestedTextFormatter) + end + + it "should support diff option when format is not specified" do + options = parse(["--diff"]) + options.diff_format.should == :unified + end + + it "should use unified diff format option when format is unified" do + options = parse(["--diff", "unified"]) + options.diff_format.should == :unified + options.differ_class.should equal(Spec::Expectations::Differs::Default) + end + + it "should use context diff format option when format is context" do + options = parse(["--diff", "context"]) + options.diff_format.should == :context + options.differ_class.should == Spec::Expectations::Differs::Default + end + + it "should use custom diff format option when format is a custom format" do + Spec::Expectations.differ.should_not be_instance_of(Custom::Differ) + + options = parse(["--diff", "Custom::Differ"]) + options.parse_diff "Custom::Differ" + options.diff_format.should == :custom + options.differ_class.should == Custom::Differ + Spec::Expectations.differ.should be_instance_of(Custom::Differ) + end + + it "should print instructions about how to fix missing differ" do + lambda { parse(["--diff", "Custom::MissingFormatter"]) }.should raise_error(NameError) + @err.string.should match(/Couldn't find differ class Custom::MissingFormatter/n) + end + + describe "when attempting a focussed spec" do + attr_reader :file, :dir + before(:each) do + @original_rspec_options = Spec::Runner.options + @file = "#{File.dirname(__FILE__)}/line_number_query/line_number_query_fixture.rb" + @dir = File.dirname(file) + end + + after(:each) do + Spec::Runner.use @original_rspec_options + end + + def parse(args) + options = super + Spec::Runner.use options + options.filename_pattern = "*_fixture.rb" + options + end + + describe 'with the --line flag' do + it "should correctly identify the spec" do + options = parse([file, "--line", "13"]) + options.line_number.should == 13 + options.examples.should be_empty + options.run_examples + options.examples.should eql(["d"]) + end + + it "should fail with error message if specified file is a dir" do + options = parse([dir, "--line", "169"]) + options.line_number.should == 169 + options.run_examples + @err.string.should match(/You must specify one file, not a directory when providing a line number/n) + end + + + it "should fail with error message if file does not exist" do + options = parse(["some file", "--line", "169"]) + proc do + options.run_examples + end.should raise_error + end + + it "should fail with error message if more than one files are specified" do + options = parse([file, file, "--line", "169"]) + options.run_examples + @err.string.should match(/Only one file can be specified when providing a line number/n) + end + + it "should fail with error message if using simultaneously with --example" do + options = parse([file, "--example", "some example", "--line", "169"]) + options.run_examples + @err.string.should match(/You cannot use --example and specify a line number/n) + end + end + + describe 'with the colon syntax (filename:LINE_NUMBER)' do + + it "should strip the line number from the file name" do + options = parse(["#{file}:13"]) + options.files.should include(file) + end + + it "should correctly identify the spec" do + options = parse(["#{file}:13"]) + options.line_number.should == 13 + options.examples.should be_empty + options.run_examples + options.examples.should eql(["d"]) + end + + it "should fail with error message if specified file is a dir" do + options = parse(["#{dir}:169"]) + options.line_number.should == 169 + options.run_examples + @err.string.should match(/You must specify one file, not a directory when providing a line number/n) + end + + + it "should fail with error message if file does not exist" do + options = parse(["some file:169"]) + proc do + options.run_examples + end.should raise_error + end + + it "should fail with error message if more than one files are specified" do + options = parse([file, "#{file}:169"]) + options.run_examples + @err.string.should match(/Only one file can be specified when providing a line number/n) + end + + it "should fail with error message if using simultaneously with --example" do + options = parse(["#{file}:169", "--example", "some example"]) + options.run_examples + @err.string.should match(/You cannot use --example and specify a line number/n) + end + end + + end + + if [/mswin/, /java/].detect{|p| p =~ RUBY_PLATFORM} + it "should barf when --heckle is specified (and platform is windows)" do + lambda do + options = parse(["--heckle", "Spec"]) + end.should raise_error(StandardError, /Heckle is not supported/) + end + elsif Spec::Ruby.version.to_f == 1.9 + it "should barf when --heckle is specified (and platform is Ruby 1.9)" do + lambda do + options = parse(["--heckle", "Spec"]) + end.should raise_error(StandardError, /Heckle is not supported/) + end + else + it "should heckle when --heckle is specified (and platform is not windows)" do + options = parse(["--heckle", "Spec"]) + options.heckle_runner.should be_instance_of(Spec::Runner::HeckleRunner) + end + end + + it "should read options from file when --options is specified" do + options = parse(["--options", File.dirname(__FILE__) + "/spec.opts"]) + options.diff_format.should_not be_nil + options.colour.should be_true + end + + it "should default the formatter to ProgressBarFormatter when using options file" do + options = parse(["--options", File.dirname(__FILE__) + "/spec.opts"]) + options.formatters.first.should be_instance_of(::Spec::Runner::Formatter::ProgressBarFormatter) + end + + it "should run parse drb after parsing options" do + @parser.should_receive(:parse_drb).with(no_args).and_return(true) + options = parse(["--options", File.dirname(__FILE__) + "/spec_drb.opts"]) + end + + it "should send all the arguments other than --drb back to the parser after parsing options" do + Spec::Runner::DrbCommandLine.should_receive(:run).and_return do |options| + options.argv.should == ["example_file.rb", "--colour"] + end + options = parse(["example_file.rb", "--options", File.dirname(__FILE__) + "/spec_drb.opts"]) + end + + it "runs specs locally if no drb is running when --drb is specified" do + Spec::Runner::DrbCommandLine.should_receive(:run).and_return(false) + options = parse(["example_file.rb", "--options", File.dirname(__FILE__) + "/spec_drb.opts"]) + options.__send__(:examples_should_be_run?).should be_true + end + + it "says its running specs locally if no drb is running when --drb is specified" do + Spec::Runner::DrbCommandLine.should_receive(:run).and_return(false) + options = parse(["example_file.rb", "--options", File.dirname(__FILE__) + "/spec_drb.opts"]) + options.error_stream.rewind + options.error_stream.string.should =~ /Running specs locally/ + end + + it "does not run specs locally if drb is running when --drb is specified" do + Spec::Runner::DrbCommandLine.should_receive(:run).and_return(true) + options = parse(["example_file.rb", "--options", File.dirname(__FILE__) + "/spec_drb.opts"]) + options.__send__(:examples_should_be_run?).should be_false + end + + it "should read spaced and multi-line options from file when --options is specified" do + options = parse(["--options", File.dirname(__FILE__) + "/spec_spaced.opts"]) + options.diff_format.should_not be_nil + options.colour.should be_true + options.formatters.first.should be_instance_of(::Spec::Runner::Formatter::SpecdocFormatter) + end + + it "should save config to file when --generate-options is specified" do + FileUtils.rm 'test.spec.opts' if File.exist?('test.spec.opts') + options = parse(["--colour", "--generate-options", "test.spec.opts", "--diff"]) + IO.read('test.spec.opts').should == "--colour\n--diff\n" + FileUtils.rm 'test.spec.opts' + end + + it "should save config to file when -G is specified" do + FileUtils.rm 'test.spec.opts' if File.exist?('test.spec.opts') + options = parse(["--colour", "-G", "test.spec.opts", "--diff"]) + IO.read('test.spec.opts').should == "--colour\n--diff\n" + FileUtils.rm 'test.spec.opts' + end + + it "when --drb is specified, calls DrbCommandLine all of the other ARGV arguments" do + options = Spec::Runner::OptionParser.parse([ + "some/spec.rb", "--diff", "--colour" + ], @err, @out) + Spec::Runner::DrbCommandLine.should_receive(:run).and_return do |options| + options.argv.should == ["some/spec.rb", "--diff", "--colour"] + end + parse(["some/spec.rb", "--diff", "--drb", "--colour"]) + end + + it "should reverse spec order when --reverse is specified" do + options = parse(["some/spec.rb", "--reverse"]) + end + + it "should set an mtime comparator when --loadby mtime" do + options = parse(["--loadby", 'mtime']) + runner = Spec::Runner::ExampleGroupRunner.new(options) + Spec::Runner::ExampleGroupRunner.should_receive(:new). + with(options). + and_return(runner) + runner.should_receive(:load_files).with(["most_recent_spec.rb", "command_line_spec.rb"]) + + Dir.chdir(File.dirname(__FILE__)) do + options.files << 'command_line_spec.rb' + options.files << 'most_recent_spec.rb' + FileUtils.touch "most_recent_spec.rb" + options.run_examples + FileUtils.rm "most_recent_spec.rb" + end + end + + it "should use the standard runner by default" do + runner = ::Spec::Runner::ExampleGroupRunner.new(@parser.options) + ::Spec::Runner::ExampleGroupRunner.should_receive(:new). + with(@parser.options). + and_return(runner) + options = parse([]) + options.run_examples + end + + it "should use a custom runner when given" do + runner = Custom::ExampleGroupRunner.new(@parser.options, nil) + Custom::ExampleGroupRunner.should_receive(:new). + with(@parser.options, nil). + and_return(runner) + options = parse(["--runner", "Custom::ExampleGroupRunner"]) + options.run_examples + end + + it "should use a custom runner with extra options" do + runner = Custom::ExampleGroupRunner.new(@parser.options, 'something') + Custom::ExampleGroupRunner.should_receive(:new). + with(@parser.options, 'something'). + and_return(runner) + options = parse(["--runner", "Custom::ExampleGroupRunner:something"]) + options.run_examples + end + + it "sets options.autospec to true with --autospec" do + options = parse(["--autospec"]) + options.autospec.should be(true) + end + + describe "implicitly loading spec/spec.opts" do + extend FakeFS::SpecHelpers + use_fakefs + it "uses spec/spec.opts if present" do + File.open('spec/spec.opts', 'w') { |f| f.write "--colour" } + options = parse(['ignore.rb']) + options.colour.should be(true) + end + + it "does not try to load spec/spec.opts if not present" do + FileUtils.rm 'spec/spec.opts' + options = parse(['ignore.rb']) + options.colour.should be(false) + end + + it "uses specified opts if supplied" do + options = nil + File.open("spec/spec.opts",'w') { |f| f.write "" } + File.open("spec/alternate.opts",'w') { |f| f.write "--colour" } + options = parse(['-O','spec/alternate.opts']) + options.colour.should be(true) + end + end + + +end diff --git a/vendor/gems/gems/rspec-1.2.9/spec/spec/runner/options_spec.rb b/vendor/gems/gems/rspec-1.2.9/spec/spec/runner/options_spec.rb new file mode 100755 index 00000000..bb1e0e8c --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/spec/spec/runner/options_spec.rb @@ -0,0 +1,547 @@ +require 'spec_helper' +require 'spec/runner/resources/custom_example_group_runner' + +module Spec + module Runner + describe Options do + before(:each) do + @err = StringIO.new('') + @out = StringIO.new('') + @options = Options.new(@err, @out) + + before_suite_parts = [] + after_suite_parts = [] + @options.stub!(:before_suite_parts).and_return(before_suite_parts) + @options.stub!(:after_suite_parts).and_return(after_suite_parts) + end + + after(:each) do + Spec::Expectations.differ = nil + end + + describe "#require_ruby_debug" do + it "should require ruby-debug" do + @options.stub!(:require) + @options.should_receive(:require).with("ruby-debug") + @options.require_ruby_debug + end + end + + describe "#examples" do + it "should default to empty array" do + @options.examples.should == [] + end + end + + describe "#include_pattern" do + it "should default to '**/*_spec.rb'" do + @options.filename_pattern.should == "**/*_spec.rb" + end + end + + describe "#files_to_load" do + + it "should load files not following pattern if named explicitly" do + file = File.expand_path(File.dirname(__FILE__) + "/resources/a_bar.rb") + @options.files << file + @options.files_to_load.should include(file) + end + + describe "with default --pattern" do + it "should load files named _spec.rb" do + dir = File.expand_path(File.dirname(__FILE__) + "/resources/") + @options.files << dir + @options.files_to_load.should == ["#{dir}/a_spec.rb"] + end + end + + describe "with explicit pattern (single)" do + before(:each) do + @options.filename_pattern = "**/*_foo.rb" + end + + it "should load files following pattern" do + file = File.expand_path(File.dirname(__FILE__) + "/resources/a_foo.rb") + @options.files << file + @options.files_to_load.should include(file) + end + + it "should load files in directories following pattern" do + dir = File.expand_path(File.dirname(__FILE__) + "/resources") + @options.files << dir + @options.files_to_load.should include("#{dir}/a_foo.rb") + end + + it "should not load files in directories not following pattern" do + dir = File.expand_path(File.dirname(__FILE__) + "/resources") + @options.files << dir + @options.files_to_load.should_not include("#{dir}/a_bar.rb") + end + end + + describe "with explicit pattern (comma,separated,values)" do + + before(:each) do + @options.filename_pattern = "**/*_foo.rb,**/*_bar.rb" + end + + it "should support comma separated values" do + dir = File.expand_path(File.dirname(__FILE__) + "/resources") + @options.files << dir + @options.files_to_load.should include("#{dir}/a_foo.rb") + @options.files_to_load.should include("#{dir}/a_bar.rb") + end + + it "should support comma separated values with spaces" do + dir = File.expand_path(File.dirname(__FILE__) + "/resources") + @options.files << dir + @options.files_to_load.should include("#{dir}/a_foo.rb") + @options.files_to_load.should include("#{dir}/a_bar.rb") + end + + end + + end + + describe "#backtrace_tweaker" do + it "should default to QuietBacktraceTweaker" do + @options.backtrace_tweaker.class.should == QuietBacktraceTweaker + end + + it "adds custom ignored backtrace patterns" do + Spec::Runner.configuration.stub!(:ignored_backtrace_patterns).and_return([/custom_pattern/]) + @options.run_examples + @options.backtrace_tweaker.ignored_patterns.should include(/custom_pattern/) + end + end + + describe "#dry_run" do + it "should default to false" do + @options.dry_run.should == false + end + end + + describe "#debug" do + it "should default to false" do + @options.debug.should == false + end + end + + describe "#context_lines" do + it "should default to 3" do + @options.context_lines.should == 3 + end + end + + describe "#parse_diff with nil" do + before(:each) do + @options.parse_diff nil + end + + it "should make diff_format unified" do + @options.diff_format.should == :unified + end + + it "should set Spec::Expectations.differ to be a default differ" do + Spec::Expectations.differ.class.should == + ::Spec::Expectations::Differs::Default + end + end + + describe "#parse_diff with 'unified'" do + before(:each) do + @options.parse_diff 'unified' + end + + it "should make diff_format unified and uses default differ_class" do + @options.diff_format.should == :unified + @options.differ_class.should equal(Spec::Expectations::Differs::Default) + end + + it "should set Spec::Expectations.differ to be a default differ" do + Spec::Expectations.differ.class.should == + ::Spec::Expectations::Differs::Default + end + end + + describe "#parse_diff with 'context'" do + before(:each) do + @options.parse_diff 'context' + end + + it "should make diff_format context and uses default differ_class" do + @options.diff_format.should == :context + @options.differ_class.should == Spec::Expectations::Differs::Default + end + + it "should set Spec::Expectations.differ to be a default differ" do + Spec::Expectations.differ.class.should == + ::Spec::Expectations::Differs::Default + end + end + + describe "#parse_diff with Custom::Differ" do + before(:each) do + @options.parse_diff 'Custom::Differ' + end + + it "should use custom differ_class" do + @options.diff_format.should == :custom + @options.differ_class.should == Custom::Differ + Spec::Expectations.differ.should be_instance_of(Custom::Differ) + end + + it "should set Spec::Expectations.differ to be a default differ" do + Spec::Expectations.differ.class.should == + ::Custom::Differ + end + end + + describe "#parse_diff with missing class name" do + it "should raise error" do + lambda { @options.parse_diff "Custom::MissingDiffer" }.should raise_error(NameError) + @err.string.should match(/Couldn't find differ class Custom::MissingDiffer/n) + end + end + + describe "#parse_example" do + it "with argument thats not a file path, sets argument as the example" do + example = "something or other" + File.file?(example).should == false + @options.parse_example example + @options.examples.should eql(["something or other"]) + end + + it "with argument that is a file path, sets examples to contents of the file" do + example = "#{File.dirname(__FILE__)}/examples.txt" + File.should_receive(:file?).with(example).and_return(true) + file = StringIO.new("Sir, if you were my husband, I would poison your drink.\nMadam, if you were my wife, I would drink it.") + File.should_receive(:open).with(example).and_return(file) + + @options.parse_example example + @options.examples.should eql([ + "Sir, if you were my husband, I would poison your drink.", + "Madam, if you were my wife, I would drink it." + ]) + end + end + + describe "#examples_should_not_be_run" do + it "should cause #run_examples to return true and do nothing" do + @options.examples_should_not_be_run + ExampleGroupRunner.should_not_receive(:new) + + @options.run_examples.should be_true + end + end + + describe "debug option specified" do + it "should cause ruby_debug to be required and do nothing" do + @options.debug = true + @options.should_receive(:require_ruby_debug) + @options.run_examples.should be_true + end + end + + describe "debug option not specified" do + it "should not cause ruby_debug to be required" do + @options.debug = false + @options.should_not_receive(:require_ruby_debug) + @options.run_examples.should be_true + end + end + + describe "#load_class" do + it "should raise error when not class name" do + lambda do + @options.__send__(:load_class, 'foo', 'fruit', '--food') + end.should raise_error('"foo" is not a valid class name') + end + end + + describe "#reporter" do + it "returns a Reporter" do + @options.reporter.should be_instance_of(Reporter) + @options.reporter.options.should === @options + end + end + + describe "#number_of_examples" do + context "when --example is parsed" do + it "provides the number of examples parsed instead of the total number of examples collected" do + @example_group = Class.new(::Spec::Example::ExampleGroup).describe("Some Examples") do + it "uses this example_group 1" do; end + it "uses this example_group 2" do; end + it "uses this example_group 3" do; end + end + @options.add_example_group @example_group + @options.parse_example("an example") + @options.number_of_examples.should == 1 + end + end + end + + describe "#add_example_group affecting passed in example_group" do + it "runs all examples when options.examples is empty" do + example_1_has_run = false + example_2_has_run = false + @example_group = Class.new(::Spec::Example::ExampleGroup).describe("Some Examples") do + it "runs 1" do + example_1_has_run = true + end + it "runs 2" do + example_2_has_run = true + end + end + + @options.examples.clear + + @options.add_example_group @example_group + @options.run_examples + example_1_has_run.should be_true + example_2_has_run.should be_true + end + + it "keeps all example_definitions when options.examples is empty" do + example_1_has_run = false + example_2_has_run = false + @example_group = Class.new(::Spec::Example::ExampleGroup).describe("Some Examples") do + it "runs 1" do + example_1_has_run = true + end + it "runs 2" do + example_2_has_run = true + end + end + + @options.add_example_group @example_group + @options.run_examples + example_1_has_run.should be_true + example_2_has_run.should be_true + end + end + + describe "#add_example_group affecting example_group" do + it "adds example_group when example_group has example_definitions and is not shared" do + @example_group = Class.new(::Spec::Example::ExampleGroup).describe("Some Examples") do + it "uses this example_group" do + end + end + + @options.number_of_examples.should == 0 + @options.add_example_group @example_group + @options.number_of_examples.should == 1 + @options.example_groups.length.should == 1 + end + end + + describe "#remove_example_group" do + it "should remove the ExampleGroup from the list of ExampleGroups" do + @example_group = Class.new(::Spec::Example::ExampleGroup).describe("Some Examples") do + end + @options.add_example_group @example_group + @options.example_groups.should include(@example_group) + + @options.remove_example_group @example_group + @options.example_groups.should_not include(@example_group) + end + end + + describe "#run_examples" do + describe "with global predicate matchers" do + it "defines global predicate matcher methods on ExampleMethods" do + Spec::Runner.configuration.stub!(:predicate_matchers).and_return({:this => :that?}) + group = Class.new(::Spec::Example::ExampleGroupDouble).describe("Some Examples") + example = group.new(::Spec::Example::ExampleProxy.new) + + @options.run_examples + example.this + end + + after(:each) do + Spec::Example::ExampleMethods.class_eval "undef :this" + end + end + + describe "with a mock framework defined as a Symbol" do + it "includes Spec::Adapters::MockFramework" do + Spec::Runner.configuration.stub!(:mock_framework).and_return('spec/adapters/mock_frameworks/rspec') + + Spec::Example::ExampleMethods.should_receive(:include).with(Spec::Adapters::MockFramework) + + @options.run_examples + end + end + + describe "with a mock framework defined as a Module" do + it "includes the module in ExampleMethods" do + mod = Module.new + Spec::Runner.configuration.stub!(:mock_framework).and_return(mod) + Spec::Example::ExampleMethods.should_receive(:include).with(mod) + @options.run_examples + end + end + + describe "when not given a custom runner" do + it "should use the standard" do + runner = ::Spec::Runner::ExampleGroupRunner.new(@options) + ::Spec::Runner::ExampleGroupRunner.should_receive(:new). + with(@options). + and_return(runner) + @options.user_input_for_runner = nil + + @options.run_examples + end + end + + describe "when given a custom runner" do + it "should use the custom runner" do + runner = Custom::ExampleGroupRunner.new(@options, nil) + Custom::ExampleGroupRunner.should_receive(:new). + with(@options, nil). + and_return(runner) + @options.user_input_for_runner = "Custom::ExampleGroupRunner" + + @options.run_examples + end + + it "should use the custom runner with extra options" do + runner = Custom::ExampleGroupRunner.new(@options, 'something') + Custom::ExampleGroupRunner.should_receive(:new). + with(@options, 'something'). + and_return(runner) + @options.user_input_for_runner = "Custom::ExampleGroupRunner:something" + + @options.run_examples + end + end + + describe "when there are examples" do + before(:each) do + @example_group = Class.new(::Spec::Example::ExampleGroup) + @options.add_example_group @example_group + @options.formatters << Formatter::BaseTextFormatter.new(@options, @out) + end + + it "runs the Examples and outputs the result" do + @options.run_examples + @out.string.should include("0 examples, 0 failures") + end + + it "sets #examples_run? to true" do + @options.examples_run?.should be_false + @options.run_examples + @options.examples_run?.should be_true + end + + describe "and the suite passes" do + before do + @example_group.should_receive(:run).and_return(true) + end + + it "invokes after_suite_parts with true" do + success_result = nil + @options.after_suite_parts << lambda do |success| + success_result = success + end + + @options.run_examples + success_result.should be_true + end + end + + describe "and the suite fails" do + before(:each) do + @example_group.should_receive(:run).and_return(false) + end + + it "invokes after_suite_parts with false" do + success_result = nil + @options.after_suite_parts << lambda do |success| + success_result = success + end + + @options.run_examples + success_result.should be_false + end + end + + describe "when using heckle runner" do + before(:each) do + @heckle_runner_mock = mock("HeckleRunner") + @options.heckle_runner = @heckle_runner_mock + end + + it "should heckle" do + @heckle_runner_mock.should_receive(:heckle_with) + @options.run_examples + end + + it "shouldn't heckle recursively" do + heckled = false + @heckle_runner_mock.should_receive(:heckle_with) { + heckled.should == false + heckled = true + @options.run_examples + } + @options.run_examples + end + + it "shouldn't load spec files twice" do + example_runner = mock("ExampleGroupRunner") + example_runner_inside_heckle = mock("ExampleGroupRunner inside Heckle") + + ExampleGroupRunner.should_receive(:new).twice.and_return( + example_runner, example_runner_inside_heckle + ) + + example_runner.stub!(:run) + example_runner.should_receive(:load_files) + @heckle_runner_mock.stub!(:heckle_with).and_return { @options.run_examples } + example_runner_inside_heckle.stub!(:run) + example_runner_inside_heckle.should_not_receive(:load_files) + + @options.run_examples + end + end + end + + describe "when there are no examples" do + before(:each) do + @options.formatters << Formatter::BaseTextFormatter.new(@options, @out) + end + + it "does not run Examples and does not output a result" do + @options.run_examples + @out.string.should_not include("examples") + @out.string.should_not include("failures") + end + + it "sets #examples_run? to false" do + @options.examples_run?.should be_false + @options.run_examples + @options.examples_run?.should be_false + end + + it "invokes after_suite_parts with true" do + success_result = nil + @options.after_suite_parts << lambda do |success| + success_result = success + end + + @options.run_examples + success_result.should be_true + end + end + end + + describe "#add_dir_from_project_root_to_load_path" do + it "handles nil gracefully" do + load_path = double().as_null_object + @options.stub(:project_root).and_return(nil) + @options.add_dir_from_project_root_to_load_path(nil,load_path) + end + end + end + end +end diff --git a/vendor/gems/gems/rspec-1.2.9/spec/spec/runner/output_one_time_fixture.rb b/vendor/gems/gems/rspec-1.2.9/spec/spec/runner/output_one_time_fixture.rb new file mode 100755 index 00000000..8a3a9fc7 --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/spec/spec/runner/output_one_time_fixture.rb @@ -0,0 +1,7 @@ +require 'spec_helper' + +describe "Running an Example" do + it "should not output twice" do + true.should be_true + end +end \ No newline at end of file diff --git a/vendor/gems/gems/rspec-1.2.9/spec/spec/runner/output_one_time_fixture_runner.rb b/vendor/gems/gems/rspec-1.2.9/spec/spec/runner/output_one_time_fixture_runner.rb new file mode 100755 index 00000000..b6b3761e --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/spec/spec/runner/output_one_time_fixture_runner.rb @@ -0,0 +1,7 @@ +require "spec_helper" + +triggering_double_output = Spec::Runner.options +options = Spec::Runner::OptionParser.parse( + [File.dirname(__FILE__) + "/output_one_time_fixture.rb"], $stderr, $stdout +) +Spec::Runner::CommandLine.run(options) diff --git a/vendor/gems/gems/rspec-1.2.9/spec/spec/runner/output_one_time_spec.rb b/vendor/gems/gems/rspec-1.2.9/spec/spec/runner/output_one_time_spec.rb new file mode 100755 index 00000000..c91bb0ff --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/spec/spec/runner/output_one_time_spec.rb @@ -0,0 +1,15 @@ +require 'spec_helper' +require 'ruby_forker' + +module Spec + module Runner + describe CommandLine do + include RubyForker + it "should not output twice" do + output = ruby "-Ilib bin/spec spec/spec/runner/output_one_time_fixture_runner.rb" + output.should include("1 example, 0 failures") + output.should_not include("0 examples, 0 failures") + end + end + end +end \ No newline at end of file diff --git a/vendor/gems/gems/rspec-1.2.9/spec/spec/runner/quiet_backtrace_tweaker_spec.rb b/vendor/gems/gems/rspec-1.2.9/spec/spec/runner/quiet_backtrace_tweaker_spec.rb new file mode 100755 index 00000000..30eaa736 --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/spec/spec/runner/quiet_backtrace_tweaker_spec.rb @@ -0,0 +1,105 @@ +require 'spec_helper' + +module Spec + module Runner + describe QuietBacktraceTweaker do + before(:each) do + @error = RuntimeError.new + @tweaker = QuietBacktraceTweaker.new + end + + it "gracefully handles nil backtrace" do + lambda do + @tweaker.tweak_backtrace(@error) + end.should_not raise_error + end + + it "gracefully handle backtraces with newlines" do + @error.set_backtrace(["we like\nbin/spec:\nnewlines"]) + @tweaker.tweak_backtrace(@error) + @error.backtrace.should include("we like\nnewlines") + end + + it "cleans up double slashes" do + @error.set_backtrace(["/a//b/c//d.rb"]) + @tweaker.tweak_backtrace(@error) + @error.backtrace.should include("/a/b/c/d.rb") + end + + it "preserves lines from textmate ruby bundle" do + @error.set_backtrace(["/Applications/TextMate.app/Contents/SharedSupport/Bundles/Ruby.tmbundle/Support/tmruby.rb:147"]) + @tweaker.tweak_backtrace(@error) + @error.backtrace.should be_empty + end + + it "removes lines in lib/spec" do + ["expectations", "mocks", "runner"].each do |child| + element="/lib/spec/#{child}/anything.rb" + @error.set_backtrace([element]) + @tweaker.tweak_backtrace(@error) + @error.backtrace.should be_empty, "Should have removed line with '#{element}'" + end + end + + it "removes lines in bin/spec" do + @error.set_backtrace(["bin/spec:"]) + @tweaker.tweak_backtrace(@error) + @error.backtrace.should be_empty + end + + it "removes lines in mock_frameworks/rspec" do + element = "mock_frameworks/rspec" + @error.set_backtrace([element]) + @tweaker.tweak_backtrace(@error) + @error.backtrace.should be_empty, "Should have removed line with '#{element}'" + end + + it "removes custom patterns" do + element = "/vendor/lib/custom_pattern/" + @tweaker.ignore_patterns /custom_pattern/ + @error.set_backtrace([element]) + @tweaker.tweak_backtrace(@error) + @error.backtrace.should be_empty, "Should have removed line with '#{element}'" + end + + it "removes custom patterns added as a string" do + element = "/vendor/lib/custom_pattern/" + @tweaker.ignore_patterns "custom_pattern" + @error.set_backtrace([element]) + @tweaker.tweak_backtrace(@error) + @error.backtrace.should be_empty, "Should have removed line with '#{element}'" + end + + it "removes lines in mock_frameworks/rspec" do + element = "mock_frameworks/rspec" + @error.set_backtrace([element]) + @tweaker.tweak_backtrace(@error) + @error.backtrace.should be_empty, "Should have removed line with '#{element}'" + end + + it "removes lines in rspec gem" do + ["/rspec-1.2.3/lib/spec.rb","/rspec-1.2.3/lib/spec/anything.rb","bin/spec:123"].each do |element| + @error.set_backtrace([element]) + @tweaker.tweak_backtrace(@error) + @error.backtrace.should be_empty, "Should have removed line with '#{element}'" + end + end + + it "removes lines in pre-release rspec gems" do + ["/rspec-1.2.3.a1.gem/lib/spec.rb","/rspec-1.2.3.b1.gem/lib/spec.rb","/rspec-1.2.3.rc1.gem/lib/spec.rb"].each do |element| + @error.set_backtrace([element]) + @tweaker.tweak_backtrace(@error) + @error.backtrace.should be_empty, "Should have removed line with '#{element}'" + end + end + + it "removes lines in spork gem" do + ["/spork-1.2.3/lib/spec.rb","/spork-1.2.3/lib/spec/anything.rb","bin/spork:123"].each do |element| + @error.set_backtrace([element]) + @tweaker.tweak_backtrace(@error) + @error.backtrace.should be_empty, "Should have removed line with '#{element}'" + end + end + end + end +end diff --git a/vendor/gems/gems/rspec-1.2.9/spec/spec/runner/reporter_spec.rb b/vendor/gems/gems/rspec-1.2.9/spec/spec/runner/reporter_spec.rb new file mode 100755 index 00000000..556387dc --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/spec/spec/runner/reporter_spec.rb @@ -0,0 +1,244 @@ +require 'spec_helper' + +module Spec + module Runner + describe Reporter do + attr_reader :formatter_output, :options, :backtrace_tweaker, :formatter, :reporter, :example_group, :example_group_proxy, :example_proxy + before(:each) do + @formatter_output = StringIO.new + @options = Options.new(StringIO.new, StringIO.new) + @backtrace_tweaker = stub("backtrace tweaker", :tweak_backtrace => nil) + options.backtrace_tweaker = backtrace_tweaker + @formatter = ::Spec::Runner::Formatter::BaseTextFormatter.new(options, formatter_output) + options.formatters << formatter + @reporter = Reporter.new(options) + @example_group = create_example_group("example_group") + @example_group_proxy = Spec::Example::ExampleGroupProxy.new(@example_group) + @example_proxy = Spec::Example::ExampleProxy.new + example_group.notify(reporter) + end + + def failure + Mocks::ArgumentMatchers::DuckTypeMatcher.new(:header, :exception) + end + + def create_example_group(text) + example_group = Spec::Example::ExampleGroup.describe(text) do + it "should do something" do + end + end + example_group + end + + it "should assign itself as the reporter to options" do + options.reporter.should equal(@reporter) + end + + it "should tell formatter when example_group is added" do + formatter.should_receive(:example_group_started).with(example_group_proxy) + example_group.notify(reporter) + end + + it "should handle multiple example_groups with same name" do + formatter.should_receive(:example_group_started).exactly(3).times + formatter.should_receive(:example_started).exactly(3).times + formatter.should_receive(:example_passed).exactly(3).times + formatter.should_receive(:start_dump) + formatter.should_receive(:dump_pending) + formatter.should_receive(:close).with(no_args) + formatter.should_receive(:dump_summary).with(anything(), 3, 0, 0) + create_example_group("example_group").notify(reporter) + reporter.example_started(description_of("spec 1")) + reporter.example_finished(description_of("spec 1")) + create_example_group("example_group").notify(reporter) + reporter.example_started(description_of("spec 2")) + reporter.example_finished(description_of("spec 2")) + create_example_group("example_group").notify(reporter) + reporter.example_started(description_of("spec 3")) + reporter.example_finished(description_of("spec 3")) + reporter.dump + end + + def description_of(example) + ::Spec::Example::ExampleProxy.new(String === example ? example : example.description) + end + + it "should handle multiple examples with the same name" do + error=RuntimeError.new + passing = ::Spec::Example::ExampleGroupDouble.new(example_proxy) + failing = ::Spec::Example::ExampleGroupDouble.new(example_proxy) + + formatter.should_receive(:example_group_started).exactly(2).times + formatter.should_receive(:example_passed).with(description_of(passing)).exactly(2).times + formatter.should_receive(:example_failed).with(description_of(failing), 1, failure) + formatter.should_receive(:example_failed).with(description_of(failing), 2, failure) + formatter.should_receive(:dump_failure).exactly(2).times + formatter.should_receive(:start_dump) + formatter.should_receive(:dump_pending) + formatter.should_receive(:close).with(no_args) + formatter.should_receive(:dump_summary).with(anything(), 4, 2, 0) + backtrace_tweaker.should_receive(:tweak_backtrace).twice + + create_example_group("example_group").notify(reporter) + reporter.example_finished(description_of(passing)) + reporter.example_finished(description_of(failing), error) + + create_example_group("example_group").notify(reporter) + reporter.example_finished(description_of(passing)) + reporter.example_finished(description_of(failing), error) + reporter.dump + end + + it "should push stats to formatter even with no data" do + formatter.should_receive(:start_dump) + formatter.should_receive(:dump_pending) + formatter.should_receive(:dump_summary).with(anything(), 0, 0, 0) + formatter.should_receive(:close).with(no_args) + reporter.dump + end + + it "should push time to formatter" do + formatter.should_receive(:start).with(5) + formatter.should_receive(:start_dump) + formatter.should_receive(:dump_pending) + formatter.should_receive(:close).with(no_args) + formatter.should_receive(:dump_summary) do |time, a, b| + time.to_s.should match(/[0-9].[0-9|e|-]+/) + end + reporter.start(5) + reporter.end + reporter.dump + end + + describe "reporting one passing example" do + it "should tell formatter example passed" do + formatter.should_receive(:example_passed) + reporter.example_finished(description_of("example")) + end + + it "should not delegate to backtrace tweaker" do + formatter.should_receive(:example_passed) + backtrace_tweaker.should_not_receive(:tweak_backtrace) + reporter.example_finished(description_of("example")) + end + + it "should account for passing example in stats" do + formatter.should_receive(:example_passed) + formatter.should_receive(:start_dump) + formatter.should_receive(:dump_pending) + formatter.should_receive(:dump_summary).with(anything(), 1, 0, 0) + formatter.should_receive(:close).with(no_args) + reporter.example_finished(description_of("example")) + reporter.dump + end + end + + describe "reporting one failing example" do + it "should tell formatter that example failed" do + example = example_group.it("should do something") {} + formatter.should_receive(:example_failed) + reporter.example_finished(description_of(example), RuntimeError.new) + end + + it "should delegate to backtrace tweaker" do + formatter.should_receive(:example_failed) + backtrace_tweaker.should_receive(:tweak_backtrace) + reporter.example_finished(example_proxy, RuntimeError.new) + end + + it "should account for failing example in stats" do + example = ::Spec::Example::ExampleGroupDouble.new(example_proxy) + formatter.should_receive(:example_failed).with(description_of(example), 1, failure) + formatter.should_receive(:start_dump) + formatter.should_receive(:dump_pending) + formatter.should_receive(:dump_failure).with(1, anything()) + formatter.should_receive(:dump_summary).with(anything(), 1, 1, 0) + formatter.should_receive(:close).with(no_args) + reporter.example_finished(description_of(example), RuntimeError.new) + reporter.dump + end + + end + + describe "reporting one pending example (ExamplePendingError)" do + before :each do + @pending_error = Spec::Example::ExamplePendingError.new("reason") + end + + it "should tell formatter example is pending" do + example = ExampleGroup.new(example_proxy) + formatter.should_receive(:example_pending).with(description_of(example), "reason") + formatter.should_receive(:example_group_started).with(example_group_proxy) + example_group.notify(reporter) + reporter.example_finished(description_of(example), @pending_error) + end + + it "should account for pending example in stats" do + example = ExampleGroup.new(example_proxy) + formatter.should_receive(:example_pending).with(description_of(example), "reason") + formatter.should_receive(:start_dump) + formatter.should_receive(:dump_pending) + formatter.should_receive(:dump_summary).with(anything(), 1, 0, 1) + formatter.should_receive(:close).with(no_args) + formatter.should_receive(:example_group_started).with(example_group_proxy) + example_group.notify(reporter) + reporter.example_finished(description_of(example), @pending_error) + reporter.dump + end + + describe "to formatters which have example_pending's arity of 3 (which is now deprecated)" do + before :each do + Spec.stub!(:warn) + + @deprecated_formatter = Class.new(@formatter.class) do + attr_reader :example_passed_to_method, :message_passed_to_method + + def example_pending(example_passed_to_method, message_passed_to_method, deprecated_pending_location) + @example_passed_to_method = example_passed_to_method + @message_passed_to_method = message_passed_to_method + end + end.new(options, formatter_output) + + options.formatters << @deprecated_formatter + end + + it "should pass the correct example description to the formatter" do + proxy = Spec::Example::ExampleProxy.new("name") + example = ExampleGroup.new(proxy) + example_group.notify(reporter) + reporter.example_finished(description_of(example), @pending_error) + + @deprecated_formatter.example_passed_to_method.should == proxy + end + + it "should pass the correct pending error message to the formatter" do + example = ExampleGroup.new(example_proxy) + example_group.notify(reporter) + reporter.example_finished(description_of(example), @pending_error) + + @deprecated_formatter.message_passed_to_method.should == @pending_error.message + end + + it "should raise a deprecation warning" do + Spec.should_receive(:warn) + + example = ExampleGroup.new(example_proxy) + example_group.notify(reporter) + reporter.example_finished(description_of(example), @pending_error) + end + end + end + + describe "reporting one pending example (PendingExampleFixedError)" do + it "should tell formatter pending example is fixed" do + formatter.should_receive(:example_failed) do |name, counter, failure| + failure.header.should == "'example_group should do something' FIXED" + end + formatter.should_receive(:example_group_started).with(example_group_proxy) + example_group.notify(reporter) + reporter.example_finished(description_of(example_group.examples.first), Spec::Example::PendingExampleFixedError.new("reason")) + end + end + end + end +end diff --git a/vendor/gems/gems/rspec-1.2.9/spec/spec/runner/resources/a_bar.rb b/vendor/gems/gems/rspec-1.2.9/spec/spec/runner/resources/a_bar.rb new file mode 100755 index 00000000..e69de29b diff --git a/vendor/gems/gems/rspec-1.2.9/spec/spec/runner/resources/a_foo.rb b/vendor/gems/gems/rspec-1.2.9/spec/spec/runner/resources/a_foo.rb new file mode 100755 index 00000000..e69de29b diff --git a/vendor/gems/gems/rspec-1.2.9/spec/spec/runner/resources/a_spec.rb b/vendor/gems/gems/rspec-1.2.9/spec/spec/runner/resources/a_spec.rb new file mode 100755 index 00000000..d9b67cc7 --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/spec/spec/runner/resources/a_spec.rb @@ -0,0 +1 @@ +# Empty - used by ../options_spec.rb \ No newline at end of file diff --git a/vendor/gems/gems/rspec-1.2.9/spec/spec/runner/resources/custom_example_group_runner.rb b/vendor/gems/gems/rspec-1.2.9/spec/spec/runner/resources/custom_example_group_runner.rb new file mode 100755 index 00000000..edcf54e9 --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/spec/spec/runner/resources/custom_example_group_runner.rb @@ -0,0 +1,14 @@ +module Custom + class ExampleGroupRunner + attr_reader :options, :arg + def initialize(options, arg) + @options, @arg = options, arg + end + + def load_files(files) + end + + def run + end + end +end diff --git a/vendor/gems/gems/rspec-1.2.9/spec/spec/runner/resources/utf8_encoded.rb b/vendor/gems/gems/rspec-1.2.9/spec/spec/runner/resources/utf8_encoded.rb new file mode 100755 index 00000000..7cbdd690 --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/spec/spec/runner/resources/utf8_encoded.rb @@ -0,0 +1,8 @@ +# encoding: utf-8 +module Custom + class ExampleUTF8ClassNameVarietà + def self.è + così = :però + end + end +end diff --git a/vendor/gems/gems/rspec-1.2.9/spec/spec/runner/spec.opts b/vendor/gems/gems/rspec-1.2.9/spec/spec/runner/spec.opts new file mode 100755 index 00000000..fd816a42 --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/spec/spec/runner/spec.opts @@ -0,0 +1,2 @@ +--diff +--colour \ No newline at end of file diff --git a/vendor/gems/gems/rspec-1.2.9/spec/spec/runner/spec_drb.opts b/vendor/gems/gems/rspec-1.2.9/spec/spec/runner/spec_drb.opts new file mode 100755 index 00000000..61f260b7 --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/spec/spec/runner/spec_drb.opts @@ -0,0 +1,2 @@ +--colour +--drb diff --git a/vendor/gems/gems/rspec-1.2.9/spec/spec/runner/spec_spaced.opts b/vendor/gems/gems/rspec-1.2.9/spec/spec/runner/spec_spaced.opts new file mode 100755 index 00000000..6b3efd20 --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/spec/spec/runner/spec_spaced.opts @@ -0,0 +1,2 @@ +--diff --colour +--format s \ No newline at end of file diff --git a/vendor/gems/gems/rspec-1.2.9/spec/spec/runner_spec.rb b/vendor/gems/gems/rspec-1.2.9/spec/spec/runner_spec.rb new file mode 100755 index 00000000..3b55be7a --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/spec/spec/runner_spec.rb @@ -0,0 +1,13 @@ +require 'spec_helper' + +module Spec + describe Runner do + describe ".configure" do + it "should yield global configuration" do + Spec::Runner.configure do |config| + config.should equal(Spec::Runner.configuration) + end + end + end + end +end diff --git a/vendor/gems/gems/rspec-1.2.9/spec/spec_helper.rb b/vendor/gems/gems/rspec-1.2.9/spec/spec_helper.rb new file mode 100755 index 00000000..3cffe875 --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/spec/spec_helper.rb @@ -0,0 +1,112 @@ +require 'stringio' + +$_spec_spec = true # Prevents Kernel.exit in various places + +require 'spec' +require 'spec/mocks' +require 'spec/runner/differs/default' +require 'spec/autorun' + +require 'support/spec_classes' +require 'support/macros' + +def jruby? + ::RUBY_PLATFORM == 'java' +end + +module Spec + module Example + class NonStandardError < Exception; end + end + + module Matchers + def fail + raise_error(Spec::Expectations::ExpectationNotMetError) + end + + def fail_with(message) + raise_error(Spec::Expectations::ExpectationNotMetError, message) + end + + def exception_from(&block) + exception = nil + begin + yield + rescue StandardError => e + exception = e + end + exception + end + + def run_with(options) + ::Spec::Runner::CommandLine.run(options) + end + + def with_ruby(version) + yield if RUBY_VERSION =~ Regexp.compile("^#{version.to_s}") + end + end +end + +def with_sandboxed_options + attr_reader :options + + before(:each) do + @original_rspec_options = ::Spec::Runner.options + ::Spec::Runner.use(@options = ::Spec::Runner::Options.new(StringIO.new, StringIO.new)) + end + + after(:each) do + ::Spec::Runner.use(@original_rspec_options) + end + + yield +end + +def with_sandboxed_config + attr_reader :config + + before(:each) do + @config = ::Spec::Runner::Configuration.new + @original_configuration = ::Spec::Runner.configuration + spec_configuration = @config + ::Spec::Runner.instance_eval {@configuration = spec_configuration} + end + + after(:each) do + original_configuration = @original_configuration + ::Spec::Runner.instance_eval {@configuration = original_configuration} + ::Spec::Example::ExampleGroupFactory.reset + end + + yield +end + +module Spec + module Example + module Resettable + def reset # :nodoc: + @before_all_parts = nil + @after_all_parts = nil + @before_each_parts = nil + @after_each_parts = nil + end + end + class ExampleGroup + extend Resettable + end + class ExampleGroupDouble < ExampleGroup + ::Spec::Runner.options.remove_example_group self + def register_example_group(klass) + #ignore + end + def initialize(proxy=nil, &block) + super(proxy || ExampleProxy.new, &block) + end + end + end +end + +Spec::Runner.configure do |config| + config.extend(Macros) +end \ No newline at end of file diff --git a/vendor/gems/gems/rspec-1.2.9/spec/support/macros.rb b/vendor/gems/gems/rspec-1.2.9/spec/support/macros.rb new file mode 100755 index 00000000..6322060b --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/spec/support/macros.rb @@ -0,0 +1,29 @@ +module Macros + def treats_method_missing_as_private(options = {:noop => true, :subject => nil}) + it "should have method_missing as private" do + with_ruby 1.8 do + described_class.private_instance_methods.should include("method_missing") + end + with_ruby 1.9 do + described_class.private_instance_methods.should include(:method_missing) + end + end + + it "should not respond_to? method_missing (because it's private)" do + formatter = options[:subject] || described_class.new({ }, StringIO.new) + formatter.should_not respond_to(:method_missing) + end + + if options[:noop] + it "should respond_to? all messages" do + formatter = described_class.new({ }, StringIO.new) + formatter.should respond_to(:just_about_anything) + end + + it "should respond_to? anything, when given the private flag" do + formatter = described_class.new({ }, StringIO.new) + formatter.respond_to?(:method_missing, true).should be_true + end + end + end +end diff --git a/vendor/gems/gems/rspec-1.2.9/spec/support/spec_classes.rb b/vendor/gems/gems/rspec-1.2.9/spec/support/spec_classes.rb new file mode 100755 index 00000000..c8900a78 --- /dev/null +++ b/vendor/gems/gems/rspec-1.2.9/spec/support/spec_classes.rb @@ -0,0 +1,133 @@ +# This file contains various classes used by the specs. +module Spec + module Expectations + class Person + attr_reader :name + def initialize name + @name = name + end + def == other + return @name == other.name + end + end + + class ClassWithMultiWordPredicate + def multi_word_predicate? + true + end + end + + module Helper + class CollectionWithSizeMethod + def initialize; @list = []; end + def size; @list.size; end + def push(item); @list.push(item); end + end + + class CollectionWithLengthMethod + def initialize; @list = []; end + def length; @list.size; end + def push(item); @list.push(item); end + end + + class CollectionOwner + attr_reader :items_in_collection_with_size_method, :items_in_collection_with_length_method + + def initialize + @items_in_collection_with_size_method = CollectionWithSizeMethod.new + @items_in_collection_with_length_method = CollectionWithLengthMethod.new + end + + def add_to_collection_with_size_method(item) + @items_in_collection_with_size_method.push(item) + end + + def add_to_collection_with_length_method(item) + @items_in_collection_with_length_method.push(item) + end + + def items_for(arg) + return [1, 2, 3] if arg == 'a' + [1] + end + + def items + @items_in_collection_with_size_method + end + end + + class HandCodedMock + include Spec::Matchers + def initialize(return_val) + @return_val = return_val + @funny_called = false + end + + def funny? + @funny_called = true + @return_val + end + + def hungry?(a, b, c) + a.should equal(1) + b.should equal(2) + c.should equal(3) + @funny_called = true + @return_val + end + + def exists? + @return_val + end + + def multi_word_predicate? + @return_val + end + + def rspec_verify + @funny_called.should be_true + end + end + class ClassWithUnqueriedPredicate + attr_accessor :foo + def initialize(foo) + @foo = foo + end + end + end + end +end + +module Custom + require 'spec/runner/formatter/base_text_formatter' + class Formatter < Spec::Runner::Formatter::BaseTextFormatter + attr_reader :options, :where + + def initialize(options, where) + @options = options + @where = where + end + end + + class BadFormatter < Spec::Runner::Formatter::BaseTextFormatter + attr_reader :where + + def initialize(options, where) + bad_method + end + end + + class Differ + attr_reader :options + def initialize(options) + @options = options + end + + def diff_as_object(target, expected) + "" + end + end +end + +class FakeReporter < Spec::Runner::Reporter +end diff --git a/vendor/gems/gems/sdoc-0.2.14.1/.gitignore b/vendor/gems/gems/sdoc-0.2.14.1/.gitignore new file mode 100755 index 00000000..cc4adf63 --- /dev/null +++ b/vendor/gems/gems/sdoc-0.2.14.1/.gitignore @@ -0,0 +1,3 @@ +pkg +doc +/test.rb \ No newline at end of file diff --git a/vendor/gems/gems/sdoc-0.2.14.1/LICENSE b/vendor/gems/gems/sdoc-0.2.14.1/LICENSE new file mode 100755 index 00000000..bbb8a1a3 --- /dev/null +++ b/vendor/gems/gems/sdoc-0.2.14.1/LICENSE @@ -0,0 +1,21 @@ +Copyright (c) 2009 Vladimir Kolesnikov + +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/gems/sdoc-0.2.14.1/README.rdoc b/vendor/gems/gems/sdoc-0.2.14.1/README.rdoc new file mode 100755 index 00000000..23a22fbe --- /dev/null +++ b/vendor/gems/gems/sdoc-0.2.14.1/README.rdoc @@ -0,0 +1,38 @@ += SDoc +== What's in? +- shtml - RDoc's generator to build searchable documentation +- sdoc-merge - comand line tool to build merge multiple sdoc documentations + packages into a single one +- sdoc - command line tool to run rdoc with generator=shtml + +== Getting Started + gem sources -a http://gems.github.com + sudo gem install voloko-sdoc + sdoc -N projectdir + +== Command line sdoc +sdoc is simply a wrapper to rdoc command line tool. see sdoc --help +for more details. --fmt is set to shtml by default. +Default template -T is shtml. You can also use 'direct' template. +Example: +sdoc -o doc/rails -T direct rails + +== Rake + # Rakefile + require 'sdoc' # and use your RDoc task the same way you used it before + + Rake::RDocTask.new do |rdoc| + rdoc.rdoc_dir = 'doc/rdoc' + rdoc.options << '--fmt' << 'shtml' # explictly set shtml generator + rdoc.template = 'direct' # lighter template used on railsapi.com + ... + end + +== sdoc-merge + Usage: sdoc-merge [options] directories + -n, --names [NAMES] Names of merged repositories. Comma separated + -o, --op [DIRECTORY] Set the output directory + -t, --title [TITLE] Set the title of merged file + +Example: +sdoc-merge --title "Ruby v1.9, Rails v2.3.2.1" --op merged --names "Ruby,Rails" ruby-v1.9 rails-v2.3.2.1 \ No newline at end of file diff --git a/vendor/gems/gems/sdoc-0.2.14.1/Rakefile b/vendor/gems/gems/sdoc-0.2.14.1/Rakefile new file mode 100755 index 00000000..c5b526bb --- /dev/null +++ b/vendor/gems/gems/sdoc-0.2.14.1/Rakefile @@ -0,0 +1,44 @@ +require 'rake/testtask' +require 'rake/gempackagetask' + +task :default => :test + +Rake::TestTask.new("test") do |t| + t.libs << 'test' + t.pattern = 'test/**/*_test.rb' + t.warning = true + t.verbose = true +end + +desc "Generate file list for .gemspec" +task :gem_file_list do + f = FileList.new + f.include('lib/**/**') + f.include('rdoc/**/**') + f.exclude('rdoc/test/**/**') + print "%w(" + f.to_a.select{|file| !File.directory? file }.join(' ') + ")\n" +end + +begin + require 'jeweler' + jewler = Jeweler::Tasks.new do |gem| + gem.name = "sdoc" + gem.summary = "rdoc html with javascript search index." + gem.email = "voloko@gmail.com" + gem.homepage = "http://github.com/voloko/sdoc" + gem.authors = ["Volodya Kolesnikov"] + gem.add_dependency("json", ">= 1.1.3") + gem.add_dependency("rdoc", ">= 2.4.2") + + # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings + end + + desc "Replace system gem with symlink to this folder" + task 'ghost' do + path = Gem.searcher.find(jewler.gemspec.name).full_gem_path + system 'sudo', 'rm', '-r', path + symlink File.expand_path('.'), path + end +rescue LoadError + puts "Jeweler not available. Install it with: sudo gem install technicalpickles-jeweler -s http://gems.github.com" +end diff --git a/vendor/gems/gems/sdoc-0.2.14.1/VERSION.yml b/vendor/gems/gems/sdoc-0.2.14.1/VERSION.yml new file mode 100755 index 00000000..1a8ea358 --- /dev/null +++ b/vendor/gems/gems/sdoc-0.2.14.1/VERSION.yml @@ -0,0 +1,4 @@ +--- +:major: 0 +:minor: 2 +:patch: 14 diff --git a/vendor/gems/gems/sdoc-0.2.14.1/bin/sdoc b/vendor/gems/gems/sdoc-0.2.14.1/bin/sdoc new file mode 100755 index 00000000..215a06ac --- /dev/null +++ b/vendor/gems/gems/sdoc-0.2.14.1/bin/sdoc @@ -0,0 +1,11 @@ +#!/usr/bin/env ruby -KU + +require File.dirname(__FILE__) + '/../lib/sdoc' # add extensions + +begin + r = RDoc::RDoc.new + r.document(ARGV) +rescue RDoc::RDocError => e + $stderr.puts e.message + exit(1) +end diff --git a/vendor/gems/gems/sdoc-0.2.14.1/bin/sdoc-merge b/vendor/gems/gems/sdoc-0.2.14.1/bin/sdoc-merge new file mode 100755 index 00000000..88e00cd1 --- /dev/null +++ b/vendor/gems/gems/sdoc-0.2.14.1/bin/sdoc-merge @@ -0,0 +1,12 @@ +#!/usr/bin/env ruby -KU + +require File.dirname(__FILE__) + '/../lib/sdoc' # add extensions +require 'sdoc/merge' + +begin + m = SDoc::Merge.new + m.merge(ARGV) +rescue RDoc::RDocError => e + $stderr.puts e.message + exit(1) +end diff --git a/vendor/gems/gems/sdoc-0.2.14.1/lib/sdoc.rb b/vendor/gems/gems/sdoc-0.2.14.1/lib/sdoc.rb new file mode 100755 index 00000000..23acc747 --- /dev/null +++ b/vendor/gems/gems/sdoc-0.2.14.1/lib/sdoc.rb @@ -0,0 +1,23 @@ +$:.unshift File.dirname(__FILE__) +require "rubygems" +gem "rdoc", ">= 2.4.2" + +require "rdoc/rdoc" + +module SDoc +end + +require "sdoc/generator/shtml" +require "sdoc/c_parser_fix" + +unless defined? SDOC_FIXED_RDOC_OPTIONS + SDOC_FIXED_RDOC_OPTIONS = 1 + class RDoc::Options + alias_method :rdoc_initialize, :initialize + + def initialize + rdoc_initialize + @generator = RDoc::Generator::SHtml + end + end +end diff --git a/vendor/gems/gems/sdoc-0.2.14.1/lib/sdoc/c_parser_fix.rb b/vendor/gems/gems/sdoc-0.2.14.1/lib/sdoc/c_parser_fix.rb new file mode 100755 index 00000000..7cae0188 --- /dev/null +++ b/vendor/gems/gems/sdoc-0.2.14.1/lib/sdoc/c_parser_fix.rb @@ -0,0 +1,31 @@ +require "rdoc/parser/c" + +# New RDoc somehow misses class comemnts. +# copyied this function from "2.2.2" +if ['2.4.2', '2.4.3'].include? RDoc::VERSION + + class RDoc::Parser::C + def find_class_comment(class_name, class_meth) + comment = nil + if @content =~ %r{((?>/\*.*?\*/\s+)) + (static\s+)?void\s+Init_#{class_name}\s*(?:_\(\s*)?\(\s*(?:void\s*)\)}xmi then + comment = $1 + elsif @content =~ %r{Document-(?:class|module):\s#{class_name}\s*?(?:<\s+[:,\w]+)?\n((?>.*?\*/))}m + comment = $1 + else + if @content =~ /rb_define_(class|module)/m then + class_name = class_name.split("::").last + comments = [] + @content.split(/(\/\*.*?\*\/)\s*?\n/m).each_with_index do |chunk, index| + comments[index] = chunk + if chunk =~ /rb_define_(class|module).*?"(#{class_name})"/m then + comment = comments[index-1] + break + end + end + end + end + class_meth.comment = mangle_comment(comment) if comment + end + end +end \ No newline at end of file diff --git a/vendor/gems/gems/sdoc-0.2.14.1/lib/sdoc/generator/shtml.rb b/vendor/gems/gems/sdoc-0.2.14.1/lib/sdoc/generator/shtml.rb new file mode 100755 index 00000000..5be784fd --- /dev/null +++ b/vendor/gems/gems/sdoc-0.2.14.1/lib/sdoc/generator/shtml.rb @@ -0,0 +1,356 @@ +require 'rubygems' +gem "rdoc", ">= 2.4.2" +if Gem.available? "json" + gem "json", ">= 1.1.3" +else + gem "json_pure", ">= 1.1.3" +end + +require 'iconv' +require 'json' +require 'pathname' +require 'fileutils' +require 'erb' + +require 'rdoc/rdoc' +require 'rdoc/generator' +require 'rdoc/generator/markup' + +require 'sdoc/github' +require 'sdoc/templatable' +require 'sdoc/helpers' + +class RDoc::ClassModule + def document_self_or_methods + document_self || method_list.any?{ |m| m.document_self } + end + + def with_documentation? + document_self_or_methods || classes_and_modules.any?{ |c| c.with_documentation? } + end +end + +class RDoc::Generator::SHtml + RDoc::RDoc.add_generator( self ) + include ERB::Util + include SDoc::GitHub + include SDoc::Templatable + include SDoc::Helpers + + GENERATOR_DIRS = [File.join('sdoc', 'generator'), File.join('rdoc', 'generator')] + + # Used in js to reduce index sizes + TYPE_CLASS = 1 + TYPE_METHOD = 2 + TYPE_FILE = 3 + + TREE_FILE = File.join 'panel', 'tree.js' + SEARCH_INDEX_FILE = File.join 'panel', 'search_index.js' + + FILE_DIR = 'files' + CLASS_DIR = 'classes' + + RESOURCES_DIR = File.join('resources', '.') + + attr_reader :basedir + + def self.for(options) + self.new(options) + end + + def self.template_dir template + $LOAD_PATH.map do |path| + GENERATOR_DIRS.map do |dir| + File.join path, dir, 'template', template + end + end.flatten.find do |dir| + File.directory? dir + end + end + + def initialize(options) + @options = options + @options.diagram = false + @github_url_cache = {} + + template = @options.template || 'direct' + + templ_dir = self.class.template_dir template + + raise RDoc::Error, "could not find template #{template.inspect}" unless + templ_dir + + @template_dir = Pathname.new File.expand_path(templ_dir) + @basedir = Pathname.pwd.expand_path + end + + def generate( top_levels ) + @outputdir = Pathname.new( @options.op_dir ).expand_path( @basedir ) + @files = top_levels.sort + @classes = RDoc::TopLevel.all_classes_and_modules.sort + + # Now actually write the output + copy_resources + generate_class_tree + generate_search_index + generate_file_files + generate_class_files + generate_index_file + end + + def class_dir + CLASS_DIR + end + + def file_dir + FILE_DIR + end + + + protected + ### Output progress information if debugging is enabled + def debug_msg( *msg ) + return unless $DEBUG_RDOC + $stderr.puts( *msg ) + end + + ### Create class tree structure and write it as json + def generate_class_tree + debug_msg "Generating class tree" + topclasses = @classes.select {|klass| !(RDoc::ClassModule === klass.parent) } + tree = generate_file_tree + generate_class_tree_level(topclasses) + debug_msg " writing class tree to %s" % TREE_FILE + File.open(TREE_FILE, "w", 0644) do |f| + f.write('var tree = '); f.write(tree.to_json) + end unless $dryrun + end + + ### Recursivly build class tree structure + def generate_class_tree_level(classes) + tree = [] + classes.select{|c| c.with_documentation? }.sort.each do |klass| + item = [ + klass.name, + klass.document_self_or_methods ? klass.path : '', + klass.module? ? '' : (klass.superclass ? " < #{String === klass.superclass ? klass.superclass : klass.superclass.full_name}" : ''), + generate_class_tree_level(klass.classes_and_modules) + ] + tree << item + end + tree + end + + ### Create search index for all classes, methods and files + ### Wite it as json + def generate_search_index + debug_msg "Generating search index" + + index = { + :searchIndex => [], + :longSearchIndex => [], + :info => [] + } + + add_class_search_index(index) + add_method_search_index(index) + add_file_search_index(index) + + debug_msg " writing search index to %s" % SEARCH_INDEX_FILE + data = { + :index => index + } + File.open(SEARCH_INDEX_FILE, "w", 0644) do |f| + f.write('var search_data = '); f.write(data.to_json) + end unless $dryrun + end + + ### Add files to search +index+ array + def add_file_search_index(index) + debug_msg " generating file search index" + + @files.select { |file| + file.document_self + }.sort.each do |file| + index[:searchIndex].push( search_string(file.name) ) + index[:longSearchIndex].push( search_string(file.path) ) + index[:info].push([ + file.name, + file.path, + file.path, + '', + snippet(file.comment), + TYPE_FILE + ]) + end + end + + ### Add classes to search +index+ array + def add_class_search_index(index) + debug_msg " generating class search index" + + @classes.select { |klass| + klass.document_self_or_methods + }.sort.each do |klass| + modulename = klass.module? ? '' : (klass.superclass ? (String === klass.superclass ? klass.superclass : klass.superclass.full_name) : '') + index[:searchIndex].push( search_string(klass.name) ) + index[:longSearchIndex].push( search_string(klass.parent.full_name) ) + index[:info].push([ + klass.name, + klass.parent.full_name, + klass.path, + modulename ? " < #{modulename}" : '', + snippet(klass.comment), + TYPE_CLASS + ]) + end + end + + ### Add methods to search +index+ array + def add_method_search_index(index) + debug_msg " generating method search index" + + list = @classes.map { |klass| + klass.method_list + }.flatten.sort{ |a, b| a.name == b.name ? a.parent.full_name <=> b.parent.full_name : a.name <=> b.name }.select { |method| + method.document_self + } + unless @options.show_all + list = list.find_all {|m| m.visibility == :public || m.visibility == :protected || m.force_documentation } + end + + list.each do |method| + index[:searchIndex].push( search_string(method.name) + '()' ) + index[:longSearchIndex].push( search_string(method.parent.full_name) ) + index[:info].push([ + method.name, + method.parent.full_name, + method.path, + method.params, + snippet(method.comment), + TYPE_METHOD + ]) + end + end + + ### Generate a documentation file for each class + def generate_class_files + debug_msg "Generating class documentation in #@outputdir" + templatefile = @template_dir + 'class.rhtml' + + @classes.each do |klass| + debug_msg " working on %s (%s)" % [ klass.full_name, klass.path ] + outfile = @outputdir + klass.path + rel_prefix = @outputdir.relative_path_from( outfile.dirname ) + + debug_msg " rendering #{outfile}" + self.render_template( templatefile, binding(), outfile ) + end + end + + ### Generate a documentation file for each file + def generate_file_files + debug_msg "Generating file documentation in #@outputdir" + templatefile = @template_dir + 'file.rhtml' + + @files.each do |file| + outfile = @outputdir + file.path + debug_msg " working on %s (%s)" % [ file.full_name, outfile ] + rel_prefix = @outputdir.relative_path_from( outfile.dirname ) + + debug_msg " rendering #{outfile}" + self.render_template( templatefile, binding(), outfile ) + end + end + + def index_file + if @options.main_page && file = @files.find { |f| f.full_name == @options.main_page } + file + else + @files.first + end + end + + ### Create index.html with frameset + def generate_index_file + debug_msg "Generating index file in #@outputdir" + templatefile = @template_dir + 'index.rhtml' + outfile = @outputdir + 'index.html' + index_path = index_file.path + + self.render_template( templatefile, binding(), outfile ) + end + + ### Strip comments on a space after 100 chars + def snippet(str) + str ||= '' + if str =~ /^(?>\s*)[^\#]/ + content = str + else + content = str.gsub(/^\s*(#+)\s*/, '') + end + + content = content.sub(/^(.{100,}?)\s.*/m, "\\1").gsub(/\r?\n/m, ' ') + + begin + content.to_json + rescue # might fail on non-unicode string + begin + content = Iconv.conv('latin1//ignore', "UTF8", content) # remove all non-unicode chars + content.to_json + rescue + content = '' # something hugely wrong happend + end + end + content + end + + ### Build search index key + def search_string(string) + string ||= '' + string.downcase.gsub(/\s/,'') + end + + ### Copy all the resource files to output dir + def copy_resources + resoureces_path = @template_dir + RESOURCES_DIR + debug_msg "Copying #{resoureces_path}/** to #{@outputdir}/**" + FileUtils.cp_r resoureces_path.to_s, @outputdir.to_s, :preserve => true unless $dryrun + end + + class FilesTree + attr_reader :children + def add(path, url) + path = path.split(File::SEPARATOR) unless Array === path + @children ||= {} + if path.length == 1 + @children[path.first] = url + else + @children[path.first] ||= FilesTree.new + @children[path.first].add(path[1, path.length], url) + end + end + end + + def generate_file_tree + if @files.length > 1 + @files_tree = FilesTree.new + @files.each do |file| + @files_tree.add(file.relative_name, file.path) + end + [['', '', 'files', generate_file_tree_level(@files_tree)]] + else + [] + end + end + + def generate_file_tree_level(tree) + tree.children.keys.sort.map do |name| + child = tree.children[name] + if String === child + [name, child, '', []] + else + ['', '', name, generate_file_tree_level(child)] + end + end + end +end diff --git a/vendor/gems/gems/sdoc-0.2.14.1/lib/sdoc/generator/template/direct/_context.rhtml b/vendor/gems/gems/sdoc-0.2.14.1/lib/sdoc/generator/template/direct/_context.rhtml new file mode 100755 index 00000000..c79cf3b2 --- /dev/null +++ b/vendor/gems/gems/sdoc-0.2.14.1/lib/sdoc/generator/template/direct/_context.rhtml @@ -0,0 +1,172 @@ +
+ <% unless (desc = context.description).empty? %> +
+ <%= desc %> +
+ <% end %> + + <% unless context.requires.empty? %> +
Required Files
+
    + <% context.requires.each do |req| %> +
  • <%= h req.name %>
  • + <% end %> +
+ <% end %> + + <% sections = context.sections.select { |section| section.title } %> + <% unless sections.empty? %> +
Contents
+ + <% end %> + + <% + list = context.method_list + unless @options.show_all + list = list.find_all {|m| m.visibility == :public || m.visibility == :protected || m.force_documentation } + end + %> + <% unless list.empty? %> +
Methods
+
+ <% each_letter_group(list) do |group| %> +
<%= group[:name] %>
+
+
    + <% group[:methods].each_with_index do |method, i| %> +
  • <%= method.name %><%= ',' unless group[:methods].size == i+1 %>
  • + <% end %> +
+
+ <% end %> +
+ <% end %> + + <% unless context.includes.empty? %> +
Included Modules
+
    + <% context.includes.each do |inc| %> +
  • + <% unless String === inc.module %> + <%= h inc.module.full_name %> + <% else %> + <%= h inc.name %> + <% end %> + START:includes +
  • + <% end %> +
+ <% end %> + + <% sections.each do |section| %> + + <% unless (description = section.description).empty? %> +
+ <%= description %> +
+ <% end %> + <% end %> + + <% unless context.classes_and_modules.empty? %> +
Classes and Modules
+
    + <% (context.modules.sort + context.classes.sort).each do |mod| %> +
  • <%= mod.type.upcase %> <%= mod.full_name %>
  • + <% end %> +
+ <% end %> + + <% unless context.constants.empty? %> +
Constants
+ + <% context.each_constant do |const| %> + + + + + + <% unless (description = const.description).empty? %> + + + + + <% end %> + <% end %> +
<%= h const.name %>=<%= h const.value %>
 <%= description %>
+ <% end %> + + <% unless context.attributes.empty? %> +
Attributes
+ + <% context.each_attribute do |attrib| %> + + + + + + <% end %> +
+ [<%= attrib.rw %>] + <%= h attrib.name %><%= attrib.description.strip %>
+ <% end %> + + <% context.methods_by_type.each do |type, visibilities| + next if visibilities.empty? + visibilities.each do |visibility, methods| + next if methods.empty? + next unless @options.show_all || visibility == :public || visibility == :protected || methods.any? {|m| m.force_documentation } + %> +
<%= type.capitalize %> <%= visibility.to_s.capitalize %> methods
+ <% methods.each do |method| %> +
+
+ <% if method.call_seq %> + <%= method.call_seq.gsub(/->/, '→') %> + <% else %> + <%= h method.name %><%= h method.params %> + <% end %> +
+ <% unless (description = method.description).empty? %> +
+ <%= description %> +
+ <% end %> + <% unless method.aliases.empty? %> +
+ This method is also aliased as + <% method.aliases.each do |aka| %> + <%= h aka.name %> + <% end %> +
+ <% end %> + <% if method.token_stream %> + <% markup = method.markup_code %> +
+ +
+
<%= method.markup_code %>
+
+
+ <% end %> +
+ <% end + end + end + %> +
\ No newline at end of file diff --git a/vendor/gems/gems/sdoc-0.2.14.1/lib/sdoc/generator/template/direct/class.rhtml b/vendor/gems/gems/sdoc-0.2.14.1/lib/sdoc/generator/template/direct/class.rhtml new file mode 100755 index 00000000..032f407a --- /dev/null +++ b/vendor/gems/gems/sdoc-0.2.14.1/lib/sdoc/generator/template/direct/class.rhtml @@ -0,0 +1,40 @@ + + + + + <%= h klass.full_name %> + + " type="text/css" media="screen" /> + " type="text/css" media="screen" /> + + + + + + + +
+ <%= include_template '_context.rhtml', {:context => klass, :rel_prefix => rel_prefix} %> +
+ + \ No newline at end of file diff --git a/vendor/gems/gems/sdoc-0.2.14.1/lib/sdoc/generator/template/direct/file.rhtml b/vendor/gems/gems/sdoc-0.2.14.1/lib/sdoc/generator/template/direct/file.rhtml new file mode 100755 index 00000000..ba85bec4 --- /dev/null +++ b/vendor/gems/gems/sdoc-0.2.14.1/lib/sdoc/generator/template/direct/file.rhtml @@ -0,0 +1,30 @@ + + + + + <%= h file.name %> + + " type="text/css" media="screen" /> + " type="text/css" media="screen" /> + + + + + + + + +
+ <%= include_template '_context.rhtml', {:context => file, :rel_prefix => rel_prefix} %> +
+ + \ No newline at end of file diff --git a/vendor/gems/gems/sdoc-0.2.14.1/lib/sdoc/generator/template/direct/index.rhtml b/vendor/gems/gems/sdoc-0.2.14.1/lib/sdoc/generator/template/direct/index.rhtml new file mode 100755 index 00000000..4d0c4a69 --- /dev/null +++ b/vendor/gems/gems/sdoc-0.2.14.1/lib/sdoc/generator/template/direct/index.rhtml @@ -0,0 +1,14 @@ + + + + + + <%= @options.title %> + + + + + + diff --git a/vendor/gems/gems/sdoc-0.2.14.1/lib/sdoc/generator/template/direct/resources/apple-touch-icon.png b/vendor/gems/gems/sdoc-0.2.14.1/lib/sdoc/generator/template/direct/resources/apple-touch-icon.png new file mode 100755 index 00000000..50f98b0f Binary files /dev/null and b/vendor/gems/gems/sdoc-0.2.14.1/lib/sdoc/generator/template/direct/resources/apple-touch-icon.png differ diff --git a/vendor/gems/gems/sdoc-0.2.14.1/lib/sdoc/generator/template/direct/resources/css/main.css b/vendor/gems/gems/sdoc-0.2.14.1/lib/sdoc/generator/template/direct/resources/css/main.css new file mode 100755 index 00000000..e2209386 --- /dev/null +++ b/vendor/gems/gems/sdoc-0.2.14.1/lib/sdoc/generator/template/direct/resources/css/main.css @@ -0,0 +1,263 @@ +body { + font-family: "Helvetica Neue", Arial, sans-serif; + background: #FFF; + color: #000; + margin: 0px; + font-size: 0.82em; + line-height: 1.25em; +} + +a { + color: #00F; + text-decoration: none; +} + +a:hover { + color: #333; + background: #FE8; +} + +p { + margin-bottom: 1em; +} + +h1 { + font-size: 2.1em; + font-weight: normal; + line-height: 1.2em; + margin: 1.4em 0 0.7em 0; +} + +h2 { + font-size: 1.6em; + margin: 1.8em 0 0.8em 0; + font-weight: normal; + line-height: 1.2em; +} + +h3 { + font-size: 1.4em; + color:#555; + margin: 1.4em 0 0.7em 0; + font-weight: normal; +} + +h4 { + margin: 1.4em 0 0.5em 0; + font-size: 1em; +} + +.clear +{ + clear: both; + width: 0; height: 0; +} + +dt +{ + margin-bottom: 0.3em; + font-weight: bold; +} + +dd +{ + margin-left: 2em; + margin-bottom: 1em; +} + +dd p +{ + margin-top: 0.6em; +} + +li +{ + margin: 0 0 0.5em 2em; +} + +ul li +{ + list-style: disc; +} + +ol li +{ + list-style: decimal; +} + +.banner +{ + background: #EDF3FE; + border-bottom: 1px solid #ccc; + padding: 1em 2em 0.5em 2em; +} +.banner h1 +{ + font-size: 1.2em; + margin: 0; +} + +.banner h1 .type +{ + font-size: 0.833em; + display:block; +} + +.banner h1 .type, +.banner h1 .parent +{ + color: #666; +} + +.banner ul +{ + margin-top: 0.3em; + margin-bottom: 0; + font-size: 0.85em; +} + +.banner li +{ + list-style: none; + margin-left: 0; + margin-bottom: 0; +} + +pre +{ + margin-bottom: 1em; +} + +.methods dt +{ + width: 1em; + font-size: 1.5em; + color:#AAA; + position: absolute; + font-weight: normal; + margin: 0; +} + +.methods dd +{ + margin-left: 2.5em; + min-height: 1.8em; + -height: 1.8em; + padding-bottom: 0.8em; +} + + +.methods ul li +{ + margin-right: 0.7em; + margin-left: 0; + list-style: none; + display: inline; +} + +#content { + margin: 2em; + margin-left: 3.5em; + margin-right: 3.5em; +} + + +.sectiontitle { + margin-top: 2em; + margin-bottom: 1.3em; + margin-left: -1.2em; + font-size: 1.2em; + padding: 0 0 0.25em 0; + font-weight: bold; + border-bottom: 1px solid #000; +} + +.attr-rw { + padding-right: 1em; + text-align: center; + color: #055; +} + +.attr-name { + font-weight: bold; + padding-right: 1em; +} + +.attr-desc { +} + +tt { + font-size: 1.15em; +} + +.attr-value { + font-family: monospace; + padding-left: 1em; + font-size: 1.15em; +} + +.dyn-source { + display: none; + background: #fffde8; + color: #000; + border: #ffe0bb dotted 1px; + margin: 0.5em 2em 0.5em 0; + padding: 0.5em; +} + +.dyn-source .cmt { + color: #00F; + font-style: italic; +} + +.dyn-source .kw { + color: #070; + font-weight: bold; +} + +.description pre { + padding: 0.5em; + border: #ffe0bb dotted 1px; + background: #fffde8; +} + +.method { + margin-bottom: 2em; +} +.method .description, +.method .sourcecode +{ + margin-left: 1.2em; +} +.method h4 +{ + border-bottom: 1px dotted #999; + padding: 0 0 0.2em 0; + margin-bottom: 0.8em; + font-size: 1.1em; + color:#333; +} +.method .title { + border-bottom: 1px dotted #666; + padding: 0 0 0.15em 0; + margin: 0 0 0.5em 0; + font-size: 1.2em; + line-height: 1.25em; +} + +.method .sourcecode p.source-link { + text-indent: 0em; + margin-top: 0.5em; +} + +.method .aka { + margin-top: 0.3em; + margin-left: 1em; + font-style: italic; + text-indent: 2em; +} + +.method .source-link +{ + font-size: 0.85em; +} \ No newline at end of file diff --git a/vendor/gems/gems/sdoc-0.2.14.1/lib/sdoc/generator/template/direct/resources/css/panel.css b/vendor/gems/gems/sdoc-0.2.14.1/lib/sdoc/generator/template/direct/resources/css/panel.css new file mode 100755 index 00000000..5390c923 --- /dev/null +++ b/vendor/gems/gems/sdoc-0.2.14.1/lib/sdoc/generator/template/direct/resources/css/panel.css @@ -0,0 +1,383 @@ +/* Panel (begin) */ + .panel + { + position: absolute; + width: 100%; + height: 100%; + top: 0; + left: 0; + background: #FFF; + z-index: 2; + font-family: "Helvetica Neue", "Arial", sans-serif; + //zoom: 1; + } + + .panel_tree .results, + .panel_results .tree + { + display: none; + } + + /* Header with search box (begin) */ + .panel .header + { + width: 100%; + height: 29px; + border-bottom: 1px solid #666; + position: relative; + left: 0; top: 0; + background: #e8e8e8; + } + + .panel .header div + { + margin: 0 7px; + } + .panel .header table + { + height: 29px; + width: 100%; + } + + .panel .header table td + { + vertical-align: middle; + text-align: middle; + } + + .panel .header label + { + position: absolute; + font-size: 12px; + line-height: 29px; + margin-left: 3px; + color: #999; + cursor: text; + } + + .panel .header table input + { + width: 100%; + box-sizing: border-box; + -moz-box-sizing: border-box; + -webkit-box-sizing: border-box; + display: inline-block; + -webkit-appearance: searchfield; + height: 22px; + //height: auto; + } + + /* Header with search box (end) */ + + + /* Results (begin) */ + .panel .result + { + position: absolute; + top: 30px; + bottom: 0; + left: 0; + width: 100%; + //height: expression((this.parentNode.offsetHeight - 31)); + overflow-y: scroll; + overflow-x: hidden; + -overflow-y: hidden; + background: #EDF3FE url(../i/results_bg.png); + z-index: 2; + //zoom:1; + } + + .panel .result ul + { + font-size: 0.8em; + width: 100%; + background: #EDF3FE url(../i/results_bg.png); + //zoom:1; + } + + .panel .result ul li + { + height: 46px; + -height: 50px; + //display: inline; + //width: 100%; + //zoom: 1; + overflow: hidden; + padding: 4px 10px 0 10px; + cursor: pointer; + } + + .panel .result ul li h1 + { + font-size: 13px; + font-weight: normal; + color: #333; + margin-bottom: 2px; + white-space: nowrap; + } + + .panel .result ul li p + { + font-size: 11px; + color: #333; + margin-bottom: 2px; + white-space: nowrap; + } + + .panel .result ul li h1 i, + .panel .result ul li p.snippet + { + color: #999; + } + + .panel .result ul li b + { + color: #000; + } + + .panel .result ul li.current + { + background: #3875D7; + } + + .panel .result ul li.current h1, + .panel .result ul li.current p + { + color: #DDD; + } + + .panel .result ul li.current h1 i, + .panel .result ul li.current p.snippet + { + color: #AAA; + } + + .panel .result ul li.current b + { + color: #FFF; + } + + + .panel .result ul li:hover, + .panel .result ul li.selected + { + background: #d0d0d0; + } + + .panel .result ul li.current:hover + { + background: #2965C0; + } + + .panel .result ul li .badge + { + margin-right: 0.4em; + margin-left: -0.2em; + padding: 0 0.2em; + color: #000; + } + + .panel .result ul li .badge_1 + { + background: #ACDBF4; + } + + .panel .result ul li.current .badge_1 + { + background: #97BFD7; + } + + .panel .result ul li .badge_2 + { + background: #ACF3C3; + } + + .panel .result ul li.current .badge_2 + { + background: #98D7AC; + } + + .panel .result ul li .badge_3 + { + background: #E0F3AC; + } + + .panel .result ul li.current .badge_3 + { + background: #C4D798; + } + + .panel .result ul li .badge_4 + { + background: #D7CA98; + } + + .panel .result ul li.current .badge_4 + { + background: #A6B0AC; + } + + .panel .result ul li .badge_5 + { + background: #F3C8AC; + } + + .panel .result ul li.current .badge_5 + { + background: #D7B198; + } + + .panel .result ul li .badge_6 + { + background: #F3ACC3; + } + + .panel .result ul li.current .badge_6 + { + background: #D798AB; + } + + /* Results (end) */ + + /* Tree (begin) */ /**/ + .panel .tree + { + position: absolute; + top: 30px; + bottom: 0; + left: 0; + width: 100%; + //zoom: 1; + //height: expression((this.parentNode.offsetHeight - 31)); + overflow-y: scroll; + overflow-x: hidden; + -overflow-y: hidden; + background: #EDF3FE url(../i/tree_bg.png); + z-index: 30; + } + + .panel .tree ul + { + background: #EDF3FE url(../i/tree_bg.png); + } + + .panel .tree li + { + cursor: pointer; + overflow: hidden; + //height: 23px; + //display: inline; + //zoom: 1; + //width: 100%; + } + + + .panel .tree li .content + { + padding-left: 18px; + padding-top: 5px; + height: 18px; + overflow: hidden; + position: relative; + } + + .panel .tree li .icon + { + width: 10px; + height: 9px; + background: url(../i/arrows.png); + background-position: 0 -9px; + position: absolute; + left: 1px; + top: 8px; + cursor: default; + } + + .panel .tree li.closed .icon + { + background-position: 0 0; + } + + .panel .tree ul li h1 + { + font-size: 13px; + font-weight: normal; + color: #000; + margin-bottom: 2px; + white-space: nowrap; + } + + .panel .tree ul li p + { + font-size: 11px; + color: #666; + margin-bottom: 2px; + white-space: nowrap; + } + + .panel .tree ul li h1 i + { + color: #999; + font-style: normal; + } + + .panel .tree ul li.empty + { + cursor: text; + } + + .panel .tree ul li.empty h1, + .panel .tree ul li.empty p + { + color: #666; + font-style: italic; + } + + .panel .tree ul li.current + { + background: #3875D7; + } + + .panel .tree ul li.current .icon + { + background-position: -10px -9px; + } + + .panel .tree ul li.current.closed .icon + { + background-position: -10px 0; + } + + .panel .tree ul li.current h1 + { + color: #FFF; + } + + .panel .tree ul li.current p + { + color: #CCC; + } + + .panel .tree ul li.current.empty h1, + .panel .tree ul li.current.empty p + { + color: #999; + } + + .panel .tree ul li:hover + { + background: #d0d0d0; + } + + .panel .tree ul li.current:hover + { + background: #2965C0; + } + + .panel .tree .stopper + { + display: none; + } + /* Tree (end) */ /**/ + +/* Panel (end) */ \ No newline at end of file diff --git a/vendor/gems/gems/sdoc-0.2.14.1/lib/sdoc/generator/template/direct/resources/css/reset.css b/vendor/gems/gems/sdoc-0.2.14.1/lib/sdoc/generator/template/direct/resources/css/reset.css new file mode 100755 index 00000000..13f8e0a1 --- /dev/null +++ b/vendor/gems/gems/sdoc-0.2.14.1/lib/sdoc/generator/template/direct/resources/css/reset.css @@ -0,0 +1,53 @@ +/* http://meyerweb.com/eric/tools/css/reset/ */ +/* v1.0 | 20080212 */ + +html, body, div, span, applet, object, iframe, +h1, h2, h3, h4, h5, h6, p, blockquote, pre, +a, abbr, acronym, address, big, cite, code, +del, dfn, em, font, img, ins, kbd, q, s, samp, +small, strike, strong, sub, sup, tt, var, +b, u, i, center, +dl, dt, dd, ol, ul, li, +fieldset, form, label, legend, +table, caption, tbody, tfoot, thead, tr, th, td { + margin: 0; + padding: 0; + border: 0; + outline: 0; + font-size: 100%; + vertical-align: baseline; + background: transparent; +} +body { + line-height: 1; +} +ol, ul { + list-style: none; +} +blockquote, q { + quotes: none; +} +blockquote:before, blockquote:after, +q:before, q:after { + content: ''; + content: none; +} + +/* remember to define focus styles! */ +:focus { + outline: 0; +} + +/* remember to highlight inserts somehow! */ +ins { + text-decoration: none; +} +del { + text-decoration: line-through; +} + +/* tables still need 'cellspacing="0"' in the markup */ +table { + border-collapse: collapse; + border-spacing: 0; +} \ No newline at end of file diff --git a/vendor/gems/gems/sdoc-0.2.14.1/lib/sdoc/generator/template/direct/resources/favicon.ico b/vendor/gems/gems/sdoc-0.2.14.1/lib/sdoc/generator/template/direct/resources/favicon.ico new file mode 100755 index 00000000..e0e80cf8 Binary files /dev/null and b/vendor/gems/gems/sdoc-0.2.14.1/lib/sdoc/generator/template/direct/resources/favicon.ico differ diff --git a/vendor/gems/gems/sdoc-0.2.14.1/lib/sdoc/generator/template/direct/resources/i/arrows.png b/vendor/gems/gems/sdoc-0.2.14.1/lib/sdoc/generator/template/direct/resources/i/arrows.png new file mode 100755 index 00000000..e54060f4 Binary files /dev/null and b/vendor/gems/gems/sdoc-0.2.14.1/lib/sdoc/generator/template/direct/resources/i/arrows.png differ diff --git a/vendor/gems/gems/sdoc-0.2.14.1/lib/sdoc/generator/template/direct/resources/i/results_bg.png b/vendor/gems/gems/sdoc-0.2.14.1/lib/sdoc/generator/template/direct/resources/i/results_bg.png new file mode 100755 index 00000000..199ba692 Binary files /dev/null and b/vendor/gems/gems/sdoc-0.2.14.1/lib/sdoc/generator/template/direct/resources/i/results_bg.png differ diff --git a/vendor/gems/gems/sdoc-0.2.14.1/lib/sdoc/generator/template/direct/resources/i/tree_bg.png b/vendor/gems/gems/sdoc-0.2.14.1/lib/sdoc/generator/template/direct/resources/i/tree_bg.png new file mode 100755 index 00000000..7d236633 Binary files /dev/null and b/vendor/gems/gems/sdoc-0.2.14.1/lib/sdoc/generator/template/direct/resources/i/tree_bg.png differ diff --git a/vendor/gems/gems/sdoc-0.2.14.1/lib/sdoc/generator/template/direct/resources/js/jquery-1.3.2.min.js b/vendor/gems/gems/sdoc-0.2.14.1/lib/sdoc/generator/template/direct/resources/js/jquery-1.3.2.min.js new file mode 100755 index 00000000..b1ae21d8 --- /dev/null +++ b/vendor/gems/gems/sdoc-0.2.14.1/lib/sdoc/generator/template/direct/resources/js/jquery-1.3.2.min.js @@ -0,0 +1,19 @@ +/* + * jQuery JavaScript Library v1.3.2 + * http://jquery.com/ + * + * Copyright (c) 2009 John Resig + * Dual licensed under the MIT and GPL licenses. + * http://docs.jquery.com/License + * + * Date: 2009-02-19 17:34:21 -0500 (Thu, 19 Feb 2009) + * Revision: 6246 + */ +(function(){var l=this,g,y=l.jQuery,p=l.$,o=l.jQuery=l.$=function(E,F){return new o.fn.init(E,F)},D=/^[^<]*(<(.|\s)+>)[^>]*$|^#([\w-]+)$/,f=/^.[^:#\[\.,]*$/;o.fn=o.prototype={init:function(E,H){E=E||document;if(E.nodeType){this[0]=E;this.length=1;this.context=E;return this}if(typeof E==="string"){var G=D.exec(E);if(G&&(G[1]||!H)){if(G[1]){E=o.clean([G[1]],H)}else{var I=document.getElementById(G[3]);if(I&&I.id!=G[3]){return o().find(E)}var F=o(I||[]);F.context=document;F.selector=E;return F}}else{return o(H).find(E)}}else{if(o.isFunction(E)){return o(document).ready(E)}}if(E.selector&&E.context){this.selector=E.selector;this.context=E.context}return this.setArray(o.isArray(E)?E:o.makeArray(E))},selector:"",jquery:"1.3.2",size:function(){return this.length},get:function(E){return E===g?Array.prototype.slice.call(this):this[E]},pushStack:function(F,H,E){var G=o(F);G.prevObject=this;G.context=this.context;if(H==="find"){G.selector=this.selector+(this.selector?" ":"")+E}else{if(H){G.selector=this.selector+"."+H+"("+E+")"}}return G},setArray:function(E){this.length=0;Array.prototype.push.apply(this,E);return this},each:function(F,E){return o.each(this,F,E)},index:function(E){return o.inArray(E&&E.jquery?E[0]:E,this)},attr:function(F,H,G){var E=F;if(typeof F==="string"){if(H===g){return this[0]&&o[G||"attr"](this[0],F)}else{E={};E[F]=H}}return this.each(function(I){for(F in E){o.attr(G?this.style:this,F,o.prop(this,E[F],G,I,F))}})},css:function(E,F){if((E=="width"||E=="height")&&parseFloat(F)<0){F=g}return this.attr(E,F,"curCSS")},text:function(F){if(typeof F!=="object"&&F!=null){return this.empty().append((this[0]&&this[0].ownerDocument||document).createTextNode(F))}var E="";o.each(F||this,function(){o.each(this.childNodes,function(){if(this.nodeType!=8){E+=this.nodeType!=1?this.nodeValue:o.fn.text([this])}})});return E},wrapAll:function(E){if(this[0]){var F=o(E,this[0].ownerDocument).clone();if(this[0].parentNode){F.insertBefore(this[0])}F.map(function(){var G=this;while(G.firstChild){G=G.firstChild}return G}).append(this)}return this},wrapInner:function(E){return this.each(function(){o(this).contents().wrapAll(E)})},wrap:function(E){return this.each(function(){o(this).wrapAll(E)})},append:function(){return this.domManip(arguments,true,function(E){if(this.nodeType==1){this.appendChild(E)}})},prepend:function(){return this.domManip(arguments,true,function(E){if(this.nodeType==1){this.insertBefore(E,this.firstChild)}})},before:function(){return this.domManip(arguments,false,function(E){this.parentNode.insertBefore(E,this)})},after:function(){return this.domManip(arguments,false,function(E){this.parentNode.insertBefore(E,this.nextSibling)})},end:function(){return this.prevObject||o([])},push:[].push,sort:[].sort,splice:[].splice,find:function(E){if(this.length===1){var F=this.pushStack([],"find",E);F.length=0;o.find(E,this[0],F);return F}else{return this.pushStack(o.unique(o.map(this,function(G){return o.find(E,G)})),"find",E)}},clone:function(G){var E=this.map(function(){if(!o.support.noCloneEvent&&!o.isXMLDoc(this)){var I=this.outerHTML;if(!I){var J=this.ownerDocument.createElement("div");J.appendChild(this.cloneNode(true));I=J.innerHTML}return o.clean([I.replace(/ jQuery\d+="(?:\d+|null)"/g,"").replace(/^\s*/,"")])[0]}else{return this.cloneNode(true)}});if(G===true){var H=this.find("*").andSelf(),F=0;E.find("*").andSelf().each(function(){if(this.nodeName!==H[F].nodeName){return}var I=o.data(H[F],"events");for(var K in I){for(var J in I[K]){o.event.add(this,K,I[K][J],I[K][J].data)}}F++})}return E},filter:function(E){return this.pushStack(o.isFunction(E)&&o.grep(this,function(G,F){return E.call(G,F)})||o.multiFilter(E,o.grep(this,function(F){return F.nodeType===1})),"filter",E)},closest:function(E){var G=o.expr.match.POS.test(E)?o(E):null,F=0;return this.map(function(){var H=this;while(H&&H.ownerDocument){if(G?G.index(H)>-1:o(H).is(E)){o.data(H,"closest",F);return H}H=H.parentNode;F++}})},not:function(E){if(typeof E==="string"){if(f.test(E)){return this.pushStack(o.multiFilter(E,this,true),"not",E)}else{E=o.multiFilter(E,this)}}var F=E.length&&E[E.length-1]!==g&&!E.nodeType;return this.filter(function(){return F?o.inArray(this,E)<0:this!=E})},add:function(E){return this.pushStack(o.unique(o.merge(this.get(),typeof E==="string"?o(E):o.makeArray(E))))},is:function(E){return !!E&&o.multiFilter(E,this).length>0},hasClass:function(E){return !!E&&this.is("."+E)},val:function(K){if(K===g){var E=this[0];if(E){if(o.nodeName(E,"option")){return(E.attributes.value||{}).specified?E.value:E.text}if(o.nodeName(E,"select")){var I=E.selectedIndex,L=[],M=E.options,H=E.type=="select-one";if(I<0){return null}for(var F=H?I:0,J=H?I+1:M.length;F=0||o.inArray(this.name,K)>=0)}else{if(o.nodeName(this,"select")){var N=o.makeArray(K);o("option",this).each(function(){this.selected=(o.inArray(this.value,N)>=0||o.inArray(this.text,N)>=0)});if(!N.length){this.selectedIndex=-1}}else{this.value=K}}})},html:function(E){return E===g?(this[0]?this[0].innerHTML.replace(/ jQuery\d+="(?:\d+|null)"/g,""):null):this.empty().append(E)},replaceWith:function(E){return this.after(E).remove()},eq:function(E){return this.slice(E,+E+1)},slice:function(){return this.pushStack(Array.prototype.slice.apply(this,arguments),"slice",Array.prototype.slice.call(arguments).join(","))},map:function(E){return this.pushStack(o.map(this,function(G,F){return E.call(G,F,G)}))},andSelf:function(){return this.add(this.prevObject)},domManip:function(J,M,L){if(this[0]){var I=(this[0].ownerDocument||this[0]).createDocumentFragment(),F=o.clean(J,(this[0].ownerDocument||this[0]),I),H=I.firstChild;if(H){for(var G=0,E=this.length;G1||G>0?I.cloneNode(true):I)}}if(F){o.each(F,z)}}return this;function K(N,O){return M&&o.nodeName(N,"table")&&o.nodeName(O,"tr")?(N.getElementsByTagName("tbody")[0]||N.appendChild(N.ownerDocument.createElement("tbody"))):N}}};o.fn.init.prototype=o.fn;function z(E,F){if(F.src){o.ajax({url:F.src,async:false,dataType:"script"})}else{o.globalEval(F.text||F.textContent||F.innerHTML||"")}if(F.parentNode){F.parentNode.removeChild(F)}}function e(){return +new Date}o.extend=o.fn.extend=function(){var J=arguments[0]||{},H=1,I=arguments.length,E=false,G;if(typeof J==="boolean"){E=J;J=arguments[1]||{};H=2}if(typeof J!=="object"&&!o.isFunction(J)){J={}}if(I==H){J=this;--H}for(;H-1}},swap:function(H,G,I){var E={};for(var F in G){E[F]=H.style[F];H.style[F]=G[F]}I.call(H);for(var F in G){H.style[F]=E[F]}},css:function(H,F,J,E){if(F=="width"||F=="height"){var L,G={position:"absolute",visibility:"hidden",display:"block"},K=F=="width"?["Left","Right"]:["Top","Bottom"];function I(){L=F=="width"?H.offsetWidth:H.offsetHeight;if(E==="border"){return}o.each(K,function(){if(!E){L-=parseFloat(o.curCSS(H,"padding"+this,true))||0}if(E==="margin"){L+=parseFloat(o.curCSS(H,"margin"+this,true))||0}else{L-=parseFloat(o.curCSS(H,"border"+this+"Width",true))||0}})}if(H.offsetWidth!==0){I()}else{o.swap(H,G,I)}return Math.max(0,Math.round(L))}return o.curCSS(H,F,J)},curCSS:function(I,F,G){var L,E=I.style;if(F=="opacity"&&!o.support.opacity){L=o.attr(E,"opacity");return L==""?"1":L}if(F.match(/float/i)){F=w}if(!G&&E&&E[F]){L=E[F]}else{if(q.getComputedStyle){if(F.match(/float/i)){F="float"}F=F.replace(/([A-Z])/g,"-$1").toLowerCase();var M=q.getComputedStyle(I,null);if(M){L=M.getPropertyValue(F)}if(F=="opacity"&&L==""){L="1"}}else{if(I.currentStyle){var J=F.replace(/\-(\w)/g,function(N,O){return O.toUpperCase()});L=I.currentStyle[F]||I.currentStyle[J];if(!/^\d+(px)?$/i.test(L)&&/^\d/.test(L)){var H=E.left,K=I.runtimeStyle.left;I.runtimeStyle.left=I.currentStyle.left;E.left=L||0;L=E.pixelLeft+"px";E.left=H;I.runtimeStyle.left=K}}}}return L},clean:function(F,K,I){K=K||document;if(typeof K.createElement==="undefined"){K=K.ownerDocument||K[0]&&K[0].ownerDocument||document}if(!I&&F.length===1&&typeof F[0]==="string"){var H=/^<(\w+)\s*\/?>$/.exec(F[0]);if(H){return[K.createElement(H[1])]}}var G=[],E=[],L=K.createElement("div");o.each(F,function(P,S){if(typeof S==="number"){S+=""}if(!S){return}if(typeof S==="string"){S=S.replace(/(<(\w+)[^>]*?)\/>/g,function(U,V,T){return T.match(/^(abbr|br|col|img|input|link|meta|param|hr|area|embed)$/i)?U:V+">"});var O=S.replace(/^\s+/,"").substring(0,10).toLowerCase();var Q=!O.indexOf("",""]||!O.indexOf("",""]||O.match(/^<(thead|tbody|tfoot|colg|cap)/)&&[1,"","
"]||!O.indexOf("",""]||(!O.indexOf("",""]||!O.indexOf("",""]||!o.support.htmlSerialize&&[1,"div
","
"]||[0,"",""];L.innerHTML=Q[1]+S+Q[2];while(Q[0]--){L=L.lastChild}if(!o.support.tbody){var R=/"&&!R?L.childNodes:[];for(var M=N.length-1;M>=0;--M){if(o.nodeName(N[M],"tbody")&&!N[M].childNodes.length){N[M].parentNode.removeChild(N[M])}}}if(!o.support.leadingWhitespace&&/^\s/.test(S)){L.insertBefore(K.createTextNode(S.match(/^\s*/)[0]),L.firstChild)}S=o.makeArray(L.childNodes)}if(S.nodeType){G.push(S)}else{G=o.merge(G,S)}});if(I){for(var J=0;G[J];J++){if(o.nodeName(G[J],"script")&&(!G[J].type||G[J].type.toLowerCase()==="text/javascript")){E.push(G[J].parentNode?G[J].parentNode.removeChild(G[J]):G[J])}else{if(G[J].nodeType===1){G.splice.apply(G,[J+1,0].concat(o.makeArray(G[J].getElementsByTagName("script"))))}I.appendChild(G[J])}}return E}return G},attr:function(J,G,K){if(!J||J.nodeType==3||J.nodeType==8){return g}var H=!o.isXMLDoc(J),L=K!==g;G=H&&o.props[G]||G;if(J.tagName){var F=/href|src|style/.test(G);if(G=="selected"&&J.parentNode){J.parentNode.selectedIndex}if(G in J&&H&&!F){if(L){if(G=="type"&&o.nodeName(J,"input")&&J.parentNode){throw"type property can't be changed"}J[G]=K}if(o.nodeName(J,"form")&&J.getAttributeNode(G)){return J.getAttributeNode(G).nodeValue}if(G=="tabIndex"){var I=J.getAttributeNode("tabIndex");return I&&I.specified?I.value:J.nodeName.match(/(button|input|object|select|textarea)/i)?0:J.nodeName.match(/^(a|area)$/i)&&J.href?0:g}return J[G]}if(!o.support.style&&H&&G=="style"){return o.attr(J.style,"cssText",K)}if(L){J.setAttribute(G,""+K)}var E=!o.support.hrefNormalized&&H&&F?J.getAttribute(G,2):J.getAttribute(G);return E===null?g:E}if(!o.support.opacity&&G=="opacity"){if(L){J.zoom=1;J.filter=(J.filter||"").replace(/alpha\([^)]*\)/,"")+(parseInt(K)+""=="NaN"?"":"alpha(opacity="+K*100+")")}return J.filter&&J.filter.indexOf("opacity=")>=0?(parseFloat(J.filter.match(/opacity=([^)]*)/)[1])/100)+"":""}G=G.replace(/-([a-z])/ig,function(M,N){return N.toUpperCase()});if(L){J[G]=K}return J[G]},trim:function(E){return(E||"").replace(/^\s+|\s+$/g,"")},makeArray:function(G){var E=[];if(G!=null){var F=G.length;if(F==null||typeof G==="string"||o.isFunction(G)||G.setInterval){E[0]=G}else{while(F){E[--F]=G[F]}}}return E},inArray:function(G,H){for(var E=0,F=H.length;E0?this.clone(true):this).get();o.fn[F].apply(o(L[K]),I);J=J.concat(I)}return this.pushStack(J,E,G)}});o.each({removeAttr:function(E){o.attr(this,E,"");if(this.nodeType==1){this.removeAttribute(E)}},addClass:function(E){o.className.add(this,E)},removeClass:function(E){o.className.remove(this,E)},toggleClass:function(F,E){if(typeof E!=="boolean"){E=!o.className.has(this,F)}o.className[E?"add":"remove"](this,F)},remove:function(E){if(!E||o.filter(E,[this]).length){o("*",this).add([this]).each(function(){o.event.remove(this);o.removeData(this)});if(this.parentNode){this.parentNode.removeChild(this)}}},empty:function(){o(this).children().remove();while(this.firstChild){this.removeChild(this.firstChild)}}},function(E,F){o.fn[E]=function(){return this.each(F,arguments)}});function j(E,F){return E[0]&&parseInt(o.curCSS(E[0],F,true),10)||0}var h="jQuery"+e(),v=0,A={};o.extend({cache:{},data:function(F,E,G){F=F==l?A:F;var H=F[h];if(!H){H=F[h]=++v}if(E&&!o.cache[H]){o.cache[H]={}}if(G!==g){o.cache[H][E]=G}return E?o.cache[H][E]:H},removeData:function(F,E){F=F==l?A:F;var H=F[h];if(E){if(o.cache[H]){delete o.cache[H][E];E="";for(E in o.cache[H]){break}if(!E){o.removeData(F)}}}else{try{delete F[h]}catch(G){if(F.removeAttribute){F.removeAttribute(h)}}delete o.cache[H]}},queue:function(F,E,H){if(F){E=(E||"fx")+"queue";var G=o.data(F,E);if(!G||o.isArray(H)){G=o.data(F,E,o.makeArray(H))}else{if(H){G.push(H)}}}return G},dequeue:function(H,G){var E=o.queue(H,G),F=E.shift();if(!G||G==="fx"){F=E[0]}if(F!==g){F.call(H)}}});o.fn.extend({data:function(E,G){var H=E.split(".");H[1]=H[1]?"."+H[1]:"";if(G===g){var F=this.triggerHandler("getData"+H[1]+"!",[H[0]]);if(F===g&&this.length){F=o.data(this[0],E)}return F===g&&H[1]?this.data(H[0]):F}else{return this.trigger("setData"+H[1]+"!",[H[0],G]).each(function(){o.data(this,E,G)})}},removeData:function(E){return this.each(function(){o.removeData(this,E)})},queue:function(E,F){if(typeof E!=="string"){F=E;E="fx"}if(F===g){return o.queue(this[0],E)}return this.each(function(){var G=o.queue(this,E,F);if(E=="fx"&&G.length==1){G[0].call(this)}})},dequeue:function(E){return this.each(function(){o.dequeue(this,E)})}}); +/* + * Sizzle CSS Selector Engine - v0.9.3 + * Copyright 2009, The Dojo Foundation + * Released under the MIT, BSD, and GPL Licenses. + * More information: http://sizzlejs.com/ + */ +(function(){var R=/((?:\((?:\([^()]+\)|[^()]+)+\)|\[(?:\[[^[\]]*\]|['"][^'"]*['"]|[^[\]'"]+)+\]|\\.|[^ >+~,(\[\\]+)+|[>+~])(\s*,\s*)?/g,L=0,H=Object.prototype.toString;var F=function(Y,U,ab,ac){ab=ab||[];U=U||document;if(U.nodeType!==1&&U.nodeType!==9){return[]}if(!Y||typeof Y!=="string"){return ab}var Z=[],W,af,ai,T,ad,V,X=true;R.lastIndex=0;while((W=R.exec(Y))!==null){Z.push(W[1]);if(W[2]){V=RegExp.rightContext;break}}if(Z.length>1&&M.exec(Y)){if(Z.length===2&&I.relative[Z[0]]){af=J(Z[0]+Z[1],U)}else{af=I.relative[Z[0]]?[U]:F(Z.shift(),U);while(Z.length){Y=Z.shift();if(I.relative[Y]){Y+=Z.shift()}af=J(Y,af)}}}else{var ae=ac?{expr:Z.pop(),set:E(ac)}:F.find(Z.pop(),Z.length===1&&U.parentNode?U.parentNode:U,Q(U));af=F.filter(ae.expr,ae.set);if(Z.length>0){ai=E(af)}else{X=false}while(Z.length){var ah=Z.pop(),ag=ah;if(!I.relative[ah]){ah=""}else{ag=Z.pop()}if(ag==null){ag=U}I.relative[ah](ai,ag,Q(U))}}if(!ai){ai=af}if(!ai){throw"Syntax error, unrecognized expression: "+(ah||Y)}if(H.call(ai)==="[object Array]"){if(!X){ab.push.apply(ab,ai)}else{if(U.nodeType===1){for(var aa=0;ai[aa]!=null;aa++){if(ai[aa]&&(ai[aa]===true||ai[aa].nodeType===1&&K(U,ai[aa]))){ab.push(af[aa])}}}else{for(var aa=0;ai[aa]!=null;aa++){if(ai[aa]&&ai[aa].nodeType===1){ab.push(af[aa])}}}}}else{E(ai,ab)}if(V){F(V,U,ab,ac);if(G){hasDuplicate=false;ab.sort(G);if(hasDuplicate){for(var aa=1;aa":function(Z,U,aa){var X=typeof U==="string";if(X&&!/\W/.test(U)){U=aa?U:U.toUpperCase();for(var V=0,T=Z.length;V=0)){if(!V){T.push(Y)}}else{if(V){U[X]=false}}}}return false},ID:function(T){return T[1].replace(/\\/g,"")},TAG:function(U,T){for(var V=0;T[V]===false;V++){}return T[V]&&Q(T[V])?U[1]:U[1].toUpperCase()},CHILD:function(T){if(T[1]=="nth"){var U=/(-?)(\d*)n((?:\+|-)?\d*)/.exec(T[2]=="even"&&"2n"||T[2]=="odd"&&"2n+1"||!/\D/.test(T[2])&&"0n+"+T[2]||T[2]);T[2]=(U[1]+(U[2]||1))-0;T[3]=U[3]-0}T[0]=L++;return T},ATTR:function(X,U,V,T,Y,Z){var W=X[1].replace(/\\/g,"");if(!Z&&I.attrMap[W]){X[1]=I.attrMap[W]}if(X[2]==="~="){X[4]=" "+X[4]+" "}return X},PSEUDO:function(X,U,V,T,Y){if(X[1]==="not"){if(X[3].match(R).length>1||/^\w/.test(X[3])){X[3]=F(X[3],null,null,U)}else{var W=F.filter(X[3],U,V,true^Y);if(!V){T.push.apply(T,W)}return false}}else{if(I.match.POS.test(X[0])||I.match.CHILD.test(X[0])){return true}}return X},POS:function(T){T.unshift(true);return T}},filters:{enabled:function(T){return T.disabled===false&&T.type!=="hidden"},disabled:function(T){return T.disabled===true},checked:function(T){return T.checked===true},selected:function(T){T.parentNode.selectedIndex;return T.selected===true},parent:function(T){return !!T.firstChild},empty:function(T){return !T.firstChild},has:function(V,U,T){return !!F(T[3],V).length},header:function(T){return/h\d/i.test(T.nodeName)},text:function(T){return"text"===T.type},radio:function(T){return"radio"===T.type},checkbox:function(T){return"checkbox"===T.type},file:function(T){return"file"===T.type},password:function(T){return"password"===T.type},submit:function(T){return"submit"===T.type},image:function(T){return"image"===T.type},reset:function(T){return"reset"===T.type},button:function(T){return"button"===T.type||T.nodeName.toUpperCase()==="BUTTON"},input:function(T){return/input|select|textarea|button/i.test(T.nodeName)}},setFilters:{first:function(U,T){return T===0},last:function(V,U,T,W){return U===W.length-1},even:function(U,T){return T%2===0},odd:function(U,T){return T%2===1},lt:function(V,U,T){return UT[3]-0},nth:function(V,U,T){return T[3]-0==U},eq:function(V,U,T){return T[3]-0==U}},filter:{PSEUDO:function(Z,V,W,aa){var U=V[1],X=I.filters[U];if(X){return X(Z,W,V,aa)}else{if(U==="contains"){return(Z.textContent||Z.innerText||"").indexOf(V[3])>=0}else{if(U==="not"){var Y=V[3];for(var W=0,T=Y.length;W=0)}}},ID:function(U,T){return U.nodeType===1&&U.getAttribute("id")===T},TAG:function(U,T){return(T==="*"&&U.nodeType===1)||U.nodeName===T},CLASS:function(U,T){return(" "+(U.className||U.getAttribute("class"))+" ").indexOf(T)>-1},ATTR:function(Y,W){var V=W[1],T=I.attrHandle[V]?I.attrHandle[V](Y):Y[V]!=null?Y[V]:Y.getAttribute(V),Z=T+"",X=W[2],U=W[4];return T==null?X==="!=":X==="="?Z===U:X==="*="?Z.indexOf(U)>=0:X==="~="?(" "+Z+" ").indexOf(U)>=0:!U?Z&&T!==false:X==="!="?Z!=U:X==="^="?Z.indexOf(U)===0:X==="$="?Z.substr(Z.length-U.length)===U:X==="|="?Z===U||Z.substr(0,U.length+1)===U+"-":false},POS:function(X,U,V,Y){var T=U[2],W=I.setFilters[T];if(W){return W(X,V,U,Y)}}}};var M=I.match.POS;for(var O in I.match){I.match[O]=RegExp(I.match[O].source+/(?![^\[]*\])(?![^\(]*\))/.source)}var E=function(U,T){U=Array.prototype.slice.call(U);if(T){T.push.apply(T,U);return T}return U};try{Array.prototype.slice.call(document.documentElement.childNodes)}catch(N){E=function(X,W){var U=W||[];if(H.call(X)==="[object Array]"){Array.prototype.push.apply(U,X)}else{if(typeof X.length==="number"){for(var V=0,T=X.length;V";var T=document.documentElement;T.insertBefore(U,T.firstChild);if(!!document.getElementById(V)){I.find.ID=function(X,Y,Z){if(typeof Y.getElementById!=="undefined"&&!Z){var W=Y.getElementById(X[1]);return W?W.id===X[1]||typeof W.getAttributeNode!=="undefined"&&W.getAttributeNode("id").nodeValue===X[1]?[W]:g:[]}};I.filter.ID=function(Y,W){var X=typeof Y.getAttributeNode!=="undefined"&&Y.getAttributeNode("id");return Y.nodeType===1&&X&&X.nodeValue===W}}T.removeChild(U)})();(function(){var T=document.createElement("div");T.appendChild(document.createComment(""));if(T.getElementsByTagName("*").length>0){I.find.TAG=function(U,Y){var X=Y.getElementsByTagName(U[1]);if(U[1]==="*"){var W=[];for(var V=0;X[V];V++){if(X[V].nodeType===1){W.push(X[V])}}X=W}return X}}T.innerHTML="";if(T.firstChild&&typeof T.firstChild.getAttribute!=="undefined"&&T.firstChild.getAttribute("href")!=="#"){I.attrHandle.href=function(U){return U.getAttribute("href",2)}}})();if(document.querySelectorAll){(function(){var T=F,U=document.createElement("div");U.innerHTML="

";if(U.querySelectorAll&&U.querySelectorAll(".TEST").length===0){return}F=function(Y,X,V,W){X=X||document;if(!W&&X.nodeType===9&&!Q(X)){try{return E(X.querySelectorAll(Y),V)}catch(Z){}}return T(Y,X,V,W)};F.find=T.find;F.filter=T.filter;F.selectors=T.selectors;F.matches=T.matches})()}if(document.getElementsByClassName&&document.documentElement.getElementsByClassName){(function(){var T=document.createElement("div");T.innerHTML="
";if(T.getElementsByClassName("e").length===0){return}T.lastChild.className="e";if(T.getElementsByClassName("e").length===1){return}I.order.splice(1,0,"CLASS");I.find.CLASS=function(U,V,W){if(typeof V.getElementsByClassName!=="undefined"&&!W){return V.getElementsByClassName(U[1])}}})()}function P(U,Z,Y,ad,aa,ac){var ab=U=="previousSibling"&&!ac;for(var W=0,V=ad.length;W0){X=T;break}}}T=T[U]}ad[W]=X}}}var K=document.compareDocumentPosition?function(U,T){return U.compareDocumentPosition(T)&16}:function(U,T){return U!==T&&(U.contains?U.contains(T):true)};var Q=function(T){return T.nodeType===9&&T.documentElement.nodeName!=="HTML"||!!T.ownerDocument&&Q(T.ownerDocument)};var J=function(T,aa){var W=[],X="",Y,V=aa.nodeType?[aa]:aa;while((Y=I.match.PSEUDO.exec(T))){X+=Y[0];T=T.replace(I.match.PSEUDO,"")}T=I.relative[T]?T+"*":T;for(var Z=0,U=V.length;Z0||T.offsetHeight>0};F.selectors.filters.animated=function(T){return o.grep(o.timers,function(U){return T===U.elem}).length};o.multiFilter=function(V,T,U){if(U){V=":not("+V+")"}return F.matches(V,T)};o.dir=function(V,U){var T=[],W=V[U];while(W&&W!=document){if(W.nodeType==1){T.push(W)}W=W[U]}return T};o.nth=function(X,T,V,W){T=T||1;var U=0;for(;X;X=X[V]){if(X.nodeType==1&&++U==T){break}}return X};o.sibling=function(V,U){var T=[];for(;V;V=V.nextSibling){if(V.nodeType==1&&V!=U){T.push(V)}}return T};return;l.Sizzle=F})();o.event={add:function(I,F,H,K){if(I.nodeType==3||I.nodeType==8){return}if(I.setInterval&&I!=l){I=l}if(!H.guid){H.guid=this.guid++}if(K!==g){var G=H;H=this.proxy(G);H.data=K}var E=o.data(I,"events")||o.data(I,"events",{}),J=o.data(I,"handle")||o.data(I,"handle",function(){return typeof o!=="undefined"&&!o.event.triggered?o.event.handle.apply(arguments.callee.elem,arguments):g});J.elem=I;o.each(F.split(/\s+/),function(M,N){var O=N.split(".");N=O.shift();H.type=O.slice().sort().join(".");var L=E[N];if(o.event.specialAll[N]){o.event.specialAll[N].setup.call(I,K,O)}if(!L){L=E[N]={};if(!o.event.special[N]||o.event.special[N].setup.call(I,K,O)===false){if(I.addEventListener){I.addEventListener(N,J,false)}else{if(I.attachEvent){I.attachEvent("on"+N,J)}}}}L[H.guid]=H;o.event.global[N]=true});I=null},guid:1,global:{},remove:function(K,H,J){if(K.nodeType==3||K.nodeType==8){return}var G=o.data(K,"events"),F,E;if(G){if(H===g||(typeof H==="string"&&H.charAt(0)==".")){for(var I in G){this.remove(K,I+(H||""))}}else{if(H.type){J=H.handler;H=H.type}o.each(H.split(/\s+/),function(M,O){var Q=O.split(".");O=Q.shift();var N=RegExp("(^|\\.)"+Q.slice().sort().join(".*\\.")+"(\\.|$)");if(G[O]){if(J){delete G[O][J.guid]}else{for(var P in G[O]){if(N.test(G[O][P].type)){delete G[O][P]}}}if(o.event.specialAll[O]){o.event.specialAll[O].teardown.call(K,Q)}for(F in G[O]){break}if(!F){if(!o.event.special[O]||o.event.special[O].teardown.call(K,Q)===false){if(K.removeEventListener){K.removeEventListener(O,o.data(K,"handle"),false)}else{if(K.detachEvent){K.detachEvent("on"+O,o.data(K,"handle"))}}}F=null;delete G[O]}}})}for(F in G){break}if(!F){var L=o.data(K,"handle");if(L){L.elem=null}o.removeData(K,"events");o.removeData(K,"handle")}}},trigger:function(I,K,H,E){var G=I.type||I;if(!E){I=typeof I==="object"?I[h]?I:o.extend(o.Event(G),I):o.Event(G);if(G.indexOf("!")>=0){I.type=G=G.slice(0,-1);I.exclusive=true}if(!H){I.stopPropagation();if(this.global[G]){o.each(o.cache,function(){if(this.events&&this.events[G]){o.event.trigger(I,K,this.handle.elem)}})}}if(!H||H.nodeType==3||H.nodeType==8){return g}I.result=g;I.target=H;K=o.makeArray(K);K.unshift(I)}I.currentTarget=H;var J=o.data(H,"handle");if(J){J.apply(H,K)}if((!H[G]||(o.nodeName(H,"a")&&G=="click"))&&H["on"+G]&&H["on"+G].apply(H,K)===false){I.result=false}if(!E&&H[G]&&!I.isDefaultPrevented()&&!(o.nodeName(H,"a")&&G=="click")){this.triggered=true;try{H[G]()}catch(L){}}this.triggered=false;if(!I.isPropagationStopped()){var F=H.parentNode||H.ownerDocument;if(F){o.event.trigger(I,K,F,true)}}},handle:function(K){var J,E;K=arguments[0]=o.event.fix(K||l.event);K.currentTarget=this;var L=K.type.split(".");K.type=L.shift();J=!L.length&&!K.exclusive;var I=RegExp("(^|\\.)"+L.slice().sort().join(".*\\.")+"(\\.|$)");E=(o.data(this,"events")||{})[K.type];for(var G in E){var H=E[G];if(J||I.test(H.type)){K.handler=H;K.data=H.data;var F=H.apply(this,arguments);if(F!==g){K.result=F;if(F===false){K.preventDefault();K.stopPropagation()}}if(K.isImmediatePropagationStopped()){break}}}},props:"altKey attrChange attrName bubbles button cancelable charCode clientX clientY ctrlKey currentTarget data detail eventPhase fromElement handler keyCode metaKey newValue originalTarget pageX pageY prevValue relatedNode relatedTarget screenX screenY shiftKey srcElement target toElement view wheelDelta which".split(" "),fix:function(H){if(H[h]){return H}var F=H;H=o.Event(F);for(var G=this.props.length,J;G;){J=this.props[--G];H[J]=F[J]}if(!H.target){H.target=H.srcElement||document}if(H.target.nodeType==3){H.target=H.target.parentNode}if(!H.relatedTarget&&H.fromElement){H.relatedTarget=H.fromElement==H.target?H.toElement:H.fromElement}if(H.pageX==null&&H.clientX!=null){var I=document.documentElement,E=document.body;H.pageX=H.clientX+(I&&I.scrollLeft||E&&E.scrollLeft||0)-(I.clientLeft||0);H.pageY=H.clientY+(I&&I.scrollTop||E&&E.scrollTop||0)-(I.clientTop||0)}if(!H.which&&((H.charCode||H.charCode===0)?H.charCode:H.keyCode)){H.which=H.charCode||H.keyCode}if(!H.metaKey&&H.ctrlKey){H.metaKey=H.ctrlKey}if(!H.which&&H.button){H.which=(H.button&1?1:(H.button&2?3:(H.button&4?2:0)))}return H},proxy:function(F,E){E=E||function(){return F.apply(this,arguments)};E.guid=F.guid=F.guid||E.guid||this.guid++;return E},special:{ready:{setup:B,teardown:function(){}}},specialAll:{live:{setup:function(E,F){o.event.add(this,F[0],c)},teardown:function(G){if(G.length){var E=0,F=RegExp("(^|\\.)"+G[0]+"(\\.|$)");o.each((o.data(this,"events").live||{}),function(){if(F.test(this.type)){E++}});if(E<1){o.event.remove(this,G[0],c)}}}}}};o.Event=function(E){if(!this.preventDefault){return new o.Event(E)}if(E&&E.type){this.originalEvent=E;this.type=E.type}else{this.type=E}this.timeStamp=e();this[h]=true};function k(){return false}function u(){return true}o.Event.prototype={preventDefault:function(){this.isDefaultPrevented=u;var E=this.originalEvent;if(!E){return}if(E.preventDefault){E.preventDefault()}E.returnValue=false},stopPropagation:function(){this.isPropagationStopped=u;var E=this.originalEvent;if(!E){return}if(E.stopPropagation){E.stopPropagation()}E.cancelBubble=true},stopImmediatePropagation:function(){this.isImmediatePropagationStopped=u;this.stopPropagation()},isDefaultPrevented:k,isPropagationStopped:k,isImmediatePropagationStopped:k};var a=function(F){var E=F.relatedTarget;while(E&&E!=this){try{E=E.parentNode}catch(G){E=this}}if(E!=this){F.type=F.data;o.event.handle.apply(this,arguments)}};o.each({mouseover:"mouseenter",mouseout:"mouseleave"},function(F,E){o.event.special[E]={setup:function(){o.event.add(this,F,a,E)},teardown:function(){o.event.remove(this,F,a)}}});o.fn.extend({bind:function(F,G,E){return F=="unload"?this.one(F,G,E):this.each(function(){o.event.add(this,F,E||G,E&&G)})},one:function(G,H,F){var E=o.event.proxy(F||H,function(I){o(this).unbind(I,E);return(F||H).apply(this,arguments)});return this.each(function(){o.event.add(this,G,E,F&&H)})},unbind:function(F,E){return this.each(function(){o.event.remove(this,F,E)})},trigger:function(E,F){return this.each(function(){o.event.trigger(E,F,this)})},triggerHandler:function(E,G){if(this[0]){var F=o.Event(E);F.preventDefault();F.stopPropagation();o.event.trigger(F,G,this[0]);return F.result}},toggle:function(G){var E=arguments,F=1;while(F=0){var E=G.slice(I,G.length);G=G.slice(0,I)}var H="GET";if(J){if(o.isFunction(J)){K=J;J=null}else{if(typeof J==="object"){J=o.param(J);H="POST"}}}var F=this;o.ajax({url:G,type:H,dataType:"html",data:J,complete:function(M,L){if(L=="success"||L=="notmodified"){F.html(E?o("
").append(M.responseText.replace(//g,"")).find(E):M.responseText)}if(K){F.each(K,[M.responseText,L,M])}}});return this},serialize:function(){return o.param(this.serializeArray())},serializeArray:function(){return this.map(function(){return this.elements?o.makeArray(this.elements):this}).filter(function(){return this.name&&!this.disabled&&(this.checked||/select|textarea/i.test(this.nodeName)||/text|hidden|password|search/i.test(this.type))}).map(function(E,F){var G=o(this).val();return G==null?null:o.isArray(G)?o.map(G,function(I,H){return{name:F.name,value:I}}):{name:F.name,value:G}}).get()}});o.each("ajaxStart,ajaxStop,ajaxComplete,ajaxError,ajaxSuccess,ajaxSend".split(","),function(E,F){o.fn[F]=function(G){return this.bind(F,G)}});var r=e();o.extend({get:function(E,G,H,F){if(o.isFunction(G)){H=G;G=null}return o.ajax({type:"GET",url:E,data:G,success:H,dataType:F})},getScript:function(E,F){return o.get(E,null,F,"script")},getJSON:function(E,F,G){return o.get(E,F,G,"json")},post:function(E,G,H,F){if(o.isFunction(G)){H=G;G={}}return o.ajax({type:"POST",url:E,data:G,success:H,dataType:F})},ajaxSetup:function(E){o.extend(o.ajaxSettings,E)},ajaxSettings:{url:location.href,global:true,type:"GET",contentType:"application/x-www-form-urlencoded",processData:true,async:true,xhr:function(){return l.ActiveXObject?new ActiveXObject("Microsoft.XMLHTTP"):new XMLHttpRequest()},accepts:{xml:"application/xml, text/xml",html:"text/html",script:"text/javascript, application/javascript",json:"application/json, text/javascript",text:"text/plain",_default:"*/*"}},lastModified:{},ajax:function(M){M=o.extend(true,M,o.extend(true,{},o.ajaxSettings,M));var W,F=/=\?(&|$)/g,R,V,G=M.type.toUpperCase();if(M.data&&M.processData&&typeof M.data!=="string"){M.data=o.param(M.data)}if(M.dataType=="jsonp"){if(G=="GET"){if(!M.url.match(F)){M.url+=(M.url.match(/\?/)?"&":"?")+(M.jsonp||"callback")+"=?"}}else{if(!M.data||!M.data.match(F)){M.data=(M.data?M.data+"&":"")+(M.jsonp||"callback")+"=?"}}M.dataType="json"}if(M.dataType=="json"&&(M.data&&M.data.match(F)||M.url.match(F))){W="jsonp"+r++;if(M.data){M.data=(M.data+"").replace(F,"="+W+"$1")}M.url=M.url.replace(F,"="+W+"$1");M.dataType="script";l[W]=function(X){V=X;I();L();l[W]=g;try{delete l[W]}catch(Y){}if(H){H.removeChild(T)}}}if(M.dataType=="script"&&M.cache==null){M.cache=false}if(M.cache===false&&G=="GET"){var E=e();var U=M.url.replace(/(\?|&)_=.*?(&|$)/,"$1_="+E+"$2");M.url=U+((U==M.url)?(M.url.match(/\?/)?"&":"?")+"_="+E:"")}if(M.data&&G=="GET"){M.url+=(M.url.match(/\?/)?"&":"?")+M.data;M.data=null}if(M.global&&!o.active++){o.event.trigger("ajaxStart")}var Q=/^(\w+:)?\/\/([^\/?#]+)/.exec(M.url);if(M.dataType=="script"&&G=="GET"&&Q&&(Q[1]&&Q[1]!=location.protocol||Q[2]!=location.host)){var H=document.getElementsByTagName("head")[0];var T=document.createElement("script");T.src=M.url;if(M.scriptCharset){T.charset=M.scriptCharset}if(!W){var O=false;T.onload=T.onreadystatechange=function(){if(!O&&(!this.readyState||this.readyState=="loaded"||this.readyState=="complete")){O=true;I();L();T.onload=T.onreadystatechange=null;H.removeChild(T)}}}H.appendChild(T);return g}var K=false;var J=M.xhr();if(M.username){J.open(G,M.url,M.async,M.username,M.password)}else{J.open(G,M.url,M.async)}try{if(M.data){J.setRequestHeader("Content-Type",M.contentType)}if(M.ifModified){J.setRequestHeader("If-Modified-Since",o.lastModified[M.url]||"Thu, 01 Jan 1970 00:00:00 GMT")}J.setRequestHeader("X-Requested-With","XMLHttpRequest");J.setRequestHeader("Accept",M.dataType&&M.accepts[M.dataType]?M.accepts[M.dataType]+", */*":M.accepts._default)}catch(S){}if(M.beforeSend&&M.beforeSend(J,M)===false){if(M.global&&!--o.active){o.event.trigger("ajaxStop")}J.abort();return false}if(M.global){o.event.trigger("ajaxSend",[J,M])}var N=function(X){if(J.readyState==0){if(P){clearInterval(P);P=null;if(M.global&&!--o.active){o.event.trigger("ajaxStop")}}}else{if(!K&&J&&(J.readyState==4||X=="timeout")){K=true;if(P){clearInterval(P);P=null}R=X=="timeout"?"timeout":!o.httpSuccess(J)?"error":M.ifModified&&o.httpNotModified(J,M.url)?"notmodified":"success";if(R=="success"){try{V=o.httpData(J,M.dataType,M)}catch(Z){R="parsererror"}}if(R=="success"){var Y;try{Y=J.getResponseHeader("Last-Modified")}catch(Z){}if(M.ifModified&&Y){o.lastModified[M.url]=Y}if(!W){I()}}else{o.handleError(M,J,R)}L();if(X){J.abort()}if(M.async){J=null}}}};if(M.async){var P=setInterval(N,13);if(M.timeout>0){setTimeout(function(){if(J&&!K){N("timeout")}},M.timeout)}}try{J.send(M.data)}catch(S){o.handleError(M,J,null,S)}if(!M.async){N()}function I(){if(M.success){M.success(V,R)}if(M.global){o.event.trigger("ajaxSuccess",[J,M])}}function L(){if(M.complete){M.complete(J,R)}if(M.global){o.event.trigger("ajaxComplete",[J,M])}if(M.global&&!--o.active){o.event.trigger("ajaxStop")}}return J},handleError:function(F,H,E,G){if(F.error){F.error(H,E,G)}if(F.global){o.event.trigger("ajaxError",[H,F,G])}},active:0,httpSuccess:function(F){try{return !F.status&&location.protocol=="file:"||(F.status>=200&&F.status<300)||F.status==304||F.status==1223}catch(E){}return false},httpNotModified:function(G,E){try{var H=G.getResponseHeader("Last-Modified");return G.status==304||H==o.lastModified[E]}catch(F){}return false},httpData:function(J,H,G){var F=J.getResponseHeader("content-type"),E=H=="xml"||!H&&F&&F.indexOf("xml")>=0,I=E?J.responseXML:J.responseText;if(E&&I.documentElement.tagName=="parsererror"){throw"parsererror"}if(G&&G.dataFilter){I=G.dataFilter(I,H)}if(typeof I==="string"){if(H=="script"){o.globalEval(I)}if(H=="json"){I=l["eval"]("("+I+")")}}return I},param:function(E){var G=[];function H(I,J){G[G.length]=encodeURIComponent(I)+"="+encodeURIComponent(J)}if(o.isArray(E)||E.jquery){o.each(E,function(){H(this.name,this.value)})}else{for(var F in E){if(o.isArray(E[F])){o.each(E[F],function(){H(F,this)})}else{H(F,o.isFunction(E[F])?E[F]():E[F])}}}return G.join("&").replace(/%20/g,"+")}});var m={},n,d=[["height","marginTop","marginBottom","paddingTop","paddingBottom"],["width","marginLeft","marginRight","paddingLeft","paddingRight"],["opacity"]];function t(F,E){var G={};o.each(d.concat.apply([],d.slice(0,E)),function(){G[this]=F});return G}o.fn.extend({show:function(J,L){if(J){return this.animate(t("show",3),J,L)}else{for(var H=0,F=this.length;H").appendTo("body");K=I.css("display");if(K==="none"){K="block"}I.remove();m[G]=K}o.data(this[H],"olddisplay",K)}}for(var H=0,F=this.length;H=0;H--){if(G[H].elem==this){if(E){G[H](true)}G.splice(H,1)}}});if(!E){this.dequeue()}return this}});o.each({slideDown:t("show",1),slideUp:t("hide",1),slideToggle:t("toggle",1),fadeIn:{opacity:"show"},fadeOut:{opacity:"hide"}},function(E,F){o.fn[E]=function(G,H){return this.animate(F,G,H)}});o.extend({speed:function(G,H,F){var E=typeof G==="object"?G:{complete:F||!F&&H||o.isFunction(G)&&G,duration:G,easing:F&&H||H&&!o.isFunction(H)&&H};E.duration=o.fx.off?0:typeof E.duration==="number"?E.duration:o.fx.speeds[E.duration]||o.fx.speeds._default;E.old=E.complete;E.complete=function(){if(E.queue!==false){o(this).dequeue()}if(o.isFunction(E.old)){E.old.call(this)}};return E},easing:{linear:function(G,H,E,F){return E+F*G},swing:function(G,H,E,F){return((-Math.cos(G*Math.PI)/2)+0.5)*F+E}},timers:[],fx:function(F,E,G){this.options=E;this.elem=F;this.prop=G;if(!E.orig){E.orig={}}}});o.fx.prototype={update:function(){if(this.options.step){this.options.step.call(this.elem,this.now,this)}(o.fx.step[this.prop]||o.fx.step._default)(this);if((this.prop=="height"||this.prop=="width")&&this.elem.style){this.elem.style.display="block"}},cur:function(F){if(this.elem[this.prop]!=null&&(!this.elem.style||this.elem.style[this.prop]==null)){return this.elem[this.prop]}var E=parseFloat(o.css(this.elem,this.prop,F));return E&&E>-10000?E:parseFloat(o.curCSS(this.elem,this.prop))||0},custom:function(I,H,G){this.startTime=e();this.start=I;this.end=H;this.unit=G||this.unit||"px";this.now=this.start;this.pos=this.state=0;var E=this;function F(J){return E.step(J)}F.elem=this.elem;if(F()&&o.timers.push(F)&&!n){n=setInterval(function(){var K=o.timers;for(var J=0;J=this.options.duration+this.startTime){this.now=this.end;this.pos=this.state=1;this.update();this.options.curAnim[this.prop]=true;var E=true;for(var F in this.options.curAnim){if(this.options.curAnim[F]!==true){E=false}}if(E){if(this.options.display!=null){this.elem.style.overflow=this.options.overflow;this.elem.style.display=this.options.display;if(o.css(this.elem,"display")=="none"){this.elem.style.display="block"}}if(this.options.hide){o(this.elem).hide()}if(this.options.hide||this.options.show){for(var I in this.options.curAnim){o.attr(this.elem.style,I,this.options.orig[I])}}this.options.complete.call(this.elem)}return false}else{var J=G-this.startTime;this.state=J/this.options.duration;this.pos=o.easing[this.options.easing||(o.easing.swing?"swing":"linear")](this.state,J,0,1,this.options.duration);this.now=this.start+((this.end-this.start)*this.pos);this.update()}return true}};o.extend(o.fx,{speeds:{slow:600,fast:200,_default:400},step:{opacity:function(E){o.attr(E.elem.style,"opacity",E.now)},_default:function(E){if(E.elem.style&&E.elem.style[E.prop]!=null){E.elem.style[E.prop]=E.now+E.unit}else{E.elem[E.prop]=E.now}}}});if(document.documentElement.getBoundingClientRect){o.fn.offset=function(){if(!this[0]){return{top:0,left:0}}if(this[0]===this[0].ownerDocument.body){return o.offset.bodyOffset(this[0])}var G=this[0].getBoundingClientRect(),J=this[0].ownerDocument,F=J.body,E=J.documentElement,L=E.clientTop||F.clientTop||0,K=E.clientLeft||F.clientLeft||0,I=G.top+(self.pageYOffset||o.boxModel&&E.scrollTop||F.scrollTop)-L,H=G.left+(self.pageXOffset||o.boxModel&&E.scrollLeft||F.scrollLeft)-K;return{top:I,left:H}}}else{o.fn.offset=function(){if(!this[0]){return{top:0,left:0}}if(this[0]===this[0].ownerDocument.body){return o.offset.bodyOffset(this[0])}o.offset.initialized||o.offset.initialize();var J=this[0],G=J.offsetParent,F=J,O=J.ownerDocument,M,H=O.documentElement,K=O.body,L=O.defaultView,E=L.getComputedStyle(J,null),N=J.offsetTop,I=J.offsetLeft;while((J=J.parentNode)&&J!==K&&J!==H){M=L.getComputedStyle(J,null);N-=J.scrollTop,I-=J.scrollLeft;if(J===G){N+=J.offsetTop,I+=J.offsetLeft;if(o.offset.doesNotAddBorder&&!(o.offset.doesAddBorderForTableAndCells&&/^t(able|d|h)$/i.test(J.tagName))){N+=parseInt(M.borderTopWidth,10)||0,I+=parseInt(M.borderLeftWidth,10)||0}F=G,G=J.offsetParent}if(o.offset.subtractsBorderForOverflowNotVisible&&M.overflow!=="visible"){N+=parseInt(M.borderTopWidth,10)||0,I+=parseInt(M.borderLeftWidth,10)||0}E=M}if(E.position==="relative"||E.position==="static"){N+=K.offsetTop,I+=K.offsetLeft}if(E.position==="fixed"){N+=Math.max(H.scrollTop,K.scrollTop),I+=Math.max(H.scrollLeft,K.scrollLeft)}return{top:N,left:I}}}o.offset={initialize:function(){if(this.initialized){return}var L=document.body,F=document.createElement("div"),H,G,N,I,M,E,J=L.style.marginTop,K='
';M={position:"absolute",top:0,left:0,margin:0,border:0,width:"1px",height:"1px",visibility:"hidden"};for(E in M){F.style[E]=M[E]}F.innerHTML=K;L.insertBefore(F,L.firstChild);H=F.firstChild,G=H.firstChild,I=H.nextSibling.firstChild.firstChild;this.doesNotAddBorder=(G.offsetTop!==5);this.doesAddBorderForTableAndCells=(I.offsetTop===5);H.style.overflow="hidden",H.style.position="relative";this.subtractsBorderForOverflowNotVisible=(G.offsetTop===-5);L.style.marginTop="1px";this.doesNotIncludeMarginInBodyOffset=(L.offsetTop===0);L.style.marginTop=J;L.removeChild(F);this.initialized=true},bodyOffset:function(E){o.offset.initialized||o.offset.initialize();var G=E.offsetTop,F=E.offsetLeft;if(o.offset.doesNotIncludeMarginInBodyOffset){G+=parseInt(o.curCSS(E,"marginTop",true),10)||0,F+=parseInt(o.curCSS(E,"marginLeft",true),10)||0}return{top:G,left:F}}};o.fn.extend({position:function(){var I=0,H=0,F;if(this[0]){var G=this.offsetParent(),J=this.offset(),E=/^body|html$/i.test(G[0].tagName)?{top:0,left:0}:G.offset();J.top-=j(this,"marginTop");J.left-=j(this,"marginLeft");E.top+=j(G,"borderTopWidth");E.left+=j(G,"borderLeftWidth");F={top:J.top-E.top,left:J.left-E.left}}return F},offsetParent:function(){var E=this[0].offsetParent||document.body;while(E&&(!/^body|html$/i.test(E.tagName)&&o.css(E,"position")=="static")){E=E.offsetParent}return o(E)}});o.each(["Left","Top"],function(F,E){var G="scroll"+E;o.fn[G]=function(H){if(!this[0]){return null}return H!==g?this.each(function(){this==l||this==document?l.scrollTo(!F?H:o(l).scrollLeft(),F?H:o(l).scrollTop()):this[G]=H}):this[0]==l||this[0]==document?self[F?"pageYOffset":"pageXOffset"]||o.boxModel&&document.documentElement[G]||document.body[G]:this[0][G]}});o.each(["Height","Width"],function(I,G){var E=I?"Left":"Top",H=I?"Right":"Bottom",F=G.toLowerCase();o.fn["inner"+G]=function(){return this[0]?o.css(this[0],F,false,"padding"):null};o.fn["outer"+G]=function(K){return this[0]?o.css(this[0],F,false,K?"margin":"border"):null};var J=G.toLowerCase();o.fn[J]=function(K){return this[0]==l?document.compatMode=="CSS1Compat"&&document.documentElement["client"+G]||document.body["client"+G]:this[0]==document?Math.max(document.documentElement["client"+G],document.body["scroll"+G],document.documentElement["scroll"+G],document.body["offset"+G],document.documentElement["offset"+G]):K===g?(this.length?o.css(this[0],J):null):this.css(J,typeof K==="string"?K:K+"px")}})})(); \ No newline at end of file diff --git a/vendor/gems/gems/sdoc-0.2.14.1/lib/sdoc/generator/template/direct/resources/js/jquery-effect.js b/vendor/gems/gems/sdoc-0.2.14.1/lib/sdoc/generator/template/direct/resources/js/jquery-effect.js new file mode 100755 index 00000000..5b25307c --- /dev/null +++ b/vendor/gems/gems/sdoc-0.2.14.1/lib/sdoc/generator/template/direct/resources/js/jquery-effect.js @@ -0,0 +1,593 @@ +/* + * jQuery UI Effects 1.6rc6 + * + * Copyright (c) 2009 AUTHORS.txt (http://ui.jquery.com/about) + * Dual licensed under the MIT (MIT-LICENSE.txt) + * and GPL (GPL-LICENSE.txt) licenses. + * + * http://docs.jquery.com/UI/Effects/ + */ +;(function($) { + +$.effects = $.effects || {}; //Add the 'effects' scope + +$.extend($.effects, { + version: "1.6rc6", + + // Saves a set of properties in a data storage + save: function(element, set) { + for(var i=0; i < set.length; i++) { + if(set[i] !== null) element.data("ec.storage."+set[i], element[0].style[set[i]]); + } + }, + + // Restores a set of previously saved properties from a data storage + restore: function(element, set) { + for(var i=0; i < set.length; i++) { + if(set[i] !== null) element.css(set[i], element.data("ec.storage."+set[i])); + } + }, + + setMode: function(el, mode) { + if (mode == 'toggle') mode = el.is(':hidden') ? 'show' : 'hide'; // Set for toggle + return mode; + }, + + getBaseline: function(origin, original) { // Translates a [top,left] array into a baseline value + // this should be a little more flexible in the future to handle a string & hash + var y, x; + switch (origin[0]) { + case 'top': y = 0; break; + case 'middle': y = 0.5; break; + case 'bottom': y = 1; break; + default: y = origin[0] / original.height; + }; + switch (origin[1]) { + case 'left': x = 0; break; + case 'center': x = 0.5; break; + case 'right': x = 1; break; + default: x = origin[1] / original.width; + }; + return {x: x, y: y}; + }, + + // Wraps the element around a wrapper that copies position properties + createWrapper: function(element) { + + //if the element is already wrapped, return it + if (element.parent().is('.ui-effects-wrapper')) + return element.parent(); + + //Cache width,height and float properties of the element, and create a wrapper around it + var props = { width: element.outerWidth(true), height: element.outerHeight(true), 'float': element.css('float') }; + element.wrap('
'); + var wrapper = element.parent(); + + //Transfer the positioning of the element to the wrapper + if (element.css('position') == 'static') { + wrapper.css({ position: 'relative' }); + element.css({ position: 'relative'} ); + } else { + var top = element.css('top'); if(isNaN(parseInt(top,10))) top = 'auto'; + var left = element.css('left'); if(isNaN(parseInt(left,10))) left = 'auto'; + wrapper.css({ position: element.css('position'), top: top, left: left, zIndex: element.css('z-index') }).show(); + element.css({position: 'relative', top: 0, left: 0 }); + } + + wrapper.css(props); + return wrapper; + }, + + removeWrapper: function(element) { + if (element.parent().is('.ui-effects-wrapper')) + return element.parent().replaceWith(element); + return element; + }, + + setTransition: function(element, list, factor, value) { + value = value || {}; + $.each(list, function(i, x){ + unit = element.cssUnit(x); + if (unit[0] > 0) value[x] = unit[0] * factor + unit[1]; + }); + return value; + }, + + //Base function to animate from one class to another in a seamless transition + animateClass: function(value, duration, easing, callback) { + + var cb = (typeof easing == "function" ? easing : (callback ? callback : null)); + var ea = (typeof easing == "string" ? easing : null); + + return this.each(function() { + + var offset = {}; var that = $(this); var oldStyleAttr = that.attr("style") || ''; + if(typeof oldStyleAttr == 'object') oldStyleAttr = oldStyleAttr["cssText"]; /* Stupidly in IE, style is a object.. */ + if(value.toggle) { that.hasClass(value.toggle) ? value.remove = value.toggle : value.add = value.toggle; } + + //Let's get a style offset + var oldStyle = $.extend({}, (document.defaultView ? document.defaultView.getComputedStyle(this,null) : this.currentStyle)); + if(value.add) that.addClass(value.add); if(value.remove) that.removeClass(value.remove); + var newStyle = $.extend({}, (document.defaultView ? document.defaultView.getComputedStyle(this,null) : this.currentStyle)); + if(value.add) that.removeClass(value.add); if(value.remove) that.addClass(value.remove); + + // The main function to form the object for animation + for(var n in newStyle) { + if( typeof newStyle[n] != "function" && newStyle[n] /* No functions and null properties */ + && n.indexOf("Moz") == -1 && n.indexOf("length") == -1 /* No mozilla spezific render properties. */ + && newStyle[n] != oldStyle[n] /* Only values that have changed are used for the animation */ + && (n.match(/color/i) || (!n.match(/color/i) && !isNaN(parseInt(newStyle[n],10)))) /* Only things that can be parsed to integers or colors */ + && (oldStyle.position != "static" || (oldStyle.position == "static" && !n.match(/left|top|bottom|right/))) /* No need for positions when dealing with static positions */ + ) offset[n] = newStyle[n]; + } + + that.animate(offset, duration, ea, function() { // Animate the newly constructed offset object + // Change style attribute back to original. For stupid IE, we need to clear the damn object. + if(typeof $(this).attr("style") == 'object') { $(this).attr("style")["cssText"] = ""; $(this).attr("style")["cssText"] = oldStyleAttr; } else $(this).attr("style", oldStyleAttr); + if(value.add) $(this).addClass(value.add); if(value.remove) $(this).removeClass(value.remove); + if(cb) cb.apply(this, arguments); + }); + + }); + } +}); + + +function _normalizeArguments(a, m) { + + var o = a[1] && a[1].constructor == Object ? a[1] : {}; if(m) o.mode = m; + var speed = a[1] && a[1].constructor != Object ? a[1] : o.duration; //either comes from options.duration or the second argument + speed = $.fx.off ? 0 : typeof speed === "number" ? speed : $.fx.speeds[speed] || $.fx.speeds._default; + var callback = o.callback || ( $.isFunction(a[2]) && a[2] ) || ( $.isFunction(a[3]) && a[3] ); + + return [a[0], o, speed, callback]; + +} + +//Extend the methods of jQuery +$.fn.extend({ + + //Save old methods + _show: $.fn.show, + _hide: $.fn.hide, + __toggle: $.fn.toggle, + _addClass: $.fn.addClass, + _removeClass: $.fn.removeClass, + _toggleClass: $.fn.toggleClass, + + // New effect methods + effect: function(fx, options, speed, callback) { + return $.effects[fx] ? $.effects[fx].call(this, {method: fx, options: options || {}, duration: speed, callback: callback }) : null; + }, + + show: function() { + if(!arguments[0] || (arguments[0].constructor == Number || (/(slow|normal|fast)/).test(arguments[0]))) + return this._show.apply(this, arguments); + else { + return this.effect.apply(this, _normalizeArguments(arguments, 'show')); + } + }, + + hide: function() { + if(!arguments[0] || (arguments[0].constructor == Number || (/(slow|normal|fast)/).test(arguments[0]))) + return this._hide.apply(this, arguments); + else { + return this.effect.apply(this, _normalizeArguments(arguments, 'hide')); + } + }, + + toggle: function(){ + if(!arguments[0] || (arguments[0].constructor == Number || (/(slow|normal|fast)/).test(arguments[0])) || (arguments[0].constructor == Function)) + return this.__toggle.apply(this, arguments); + else { + return this.effect.apply(this, _normalizeArguments(arguments, 'toggle')); + } + }, + + addClass: function(classNames, speed, easing, callback) { + return speed ? $.effects.animateClass.apply(this, [{ add: classNames },speed,easing,callback]) : this._addClass(classNames); + }, + removeClass: function(classNames,speed,easing,callback) { + return speed ? $.effects.animateClass.apply(this, [{ remove: classNames },speed,easing,callback]) : this._removeClass(classNames); + }, + toggleClass: function(classNames,speed,easing,callback) { + return ( (typeof speed !== "boolean") && speed ) ? $.effects.animateClass.apply(this, [{ toggle: classNames },speed,easing,callback]) : this._toggleClass(classNames, speed); + }, + morph: function(remove,add,speed,easing,callback) { + return $.effects.animateClass.apply(this, [{ add: add, remove: remove },speed,easing,callback]); + }, + switchClass: function() { + return this.morph.apply(this, arguments); + }, + + // helper functions + cssUnit: function(key) { + var style = this.css(key), val = []; + $.each( ['em','px','%','pt'], function(i, unit){ + if(style.indexOf(unit) > 0) + val = [parseFloat(style), unit]; + }); + return val; + } +}); + +/* + * jQuery Color Animations + * Copyright 2007 John Resig + * Released under the MIT and GPL licenses. + */ + +// We override the animation for all of these color styles +$.each(['backgroundColor', 'borderBottomColor', 'borderLeftColor', 'borderRightColor', 'borderTopColor', 'color', 'outlineColor'], function(i,attr){ + $.fx.step[attr] = function(fx) { + if ( fx.state == 0 ) { + fx.start = getColor( fx.elem, attr ); + fx.end = getRGB( fx.end ); + } + + fx.elem.style[attr] = "rgb(" + [ + Math.max(Math.min( parseInt((fx.pos * (fx.end[0] - fx.start[0])) + fx.start[0],10), 255), 0), + Math.max(Math.min( parseInt((fx.pos * (fx.end[1] - fx.start[1])) + fx.start[1],10), 255), 0), + Math.max(Math.min( parseInt((fx.pos * (fx.end[2] - fx.start[2])) + fx.start[2],10), 255), 0) + ].join(",") + ")"; + }; +}); + +// Color Conversion functions from highlightFade +// By Blair Mitchelmore +// http://jquery.offput.ca/highlightFade/ + +// Parse strings looking for color tuples [255,255,255] +function getRGB(color) { + var result; + + // Check if we're already dealing with an array of colors + if ( color && color.constructor == Array && color.length == 3 ) + return color; + + // Look for rgb(num,num,num) + if (result = /rgb\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*\)/.exec(color)) + return [parseInt(result[1],10), parseInt(result[2],10), parseInt(result[3],10)]; + + // Look for rgb(num%,num%,num%) + if (result = /rgb\(\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*\)/.exec(color)) + return [parseFloat(result[1])*2.55, parseFloat(result[2])*2.55, parseFloat(result[3])*2.55]; + + // Look for #a0b1c2 + if (result = /#([a-fA-F0-9]{2})([a-fA-F0-9]{2})([a-fA-F0-9]{2})/.exec(color)) + return [parseInt(result[1],16), parseInt(result[2],16), parseInt(result[3],16)]; + + // Look for #fff + if (result = /#([a-fA-F0-9])([a-fA-F0-9])([a-fA-F0-9])/.exec(color)) + return [parseInt(result[1]+result[1],16), parseInt(result[2]+result[2],16), parseInt(result[3]+result[3],16)]; + + // Look for rgba(0, 0, 0, 0) == transparent in Safari 3 + if (result = /rgba\(0, 0, 0, 0\)/.exec(color)) + return colors['transparent']; + + // Otherwise, we're most likely dealing with a named color + return colors[$.trim(color).toLowerCase()]; +} + +function getColor(elem, attr) { + var color; + + do { + color = $.curCSS(elem, attr); + + // Keep going until we find an element that has color, or we hit the body + if ( color != '' && color != 'transparent' || $.nodeName(elem, "body") ) + break; + + attr = "backgroundColor"; + } while ( elem = elem.parentNode ); + + return getRGB(color); +}; + +// Some named colors to work with +// From Interface by Stefan Petre +// http://interface.eyecon.ro/ + +var colors = { + aqua:[0,255,255], + azure:[240,255,255], + beige:[245,245,220], + black:[0,0,0], + blue:[0,0,255], + brown:[165,42,42], + cyan:[0,255,255], + darkblue:[0,0,139], + darkcyan:[0,139,139], + darkgrey:[169,169,169], + darkgreen:[0,100,0], + darkkhaki:[189,183,107], + darkmagenta:[139,0,139], + darkolivegreen:[85,107,47], + darkorange:[255,140,0], + darkorchid:[153,50,204], + darkred:[139,0,0], + darksalmon:[233,150,122], + darkviolet:[148,0,211], + fuchsia:[255,0,255], + gold:[255,215,0], + green:[0,128,0], + indigo:[75,0,130], + khaki:[240,230,140], + lightblue:[173,216,230], + lightcyan:[224,255,255], + lightgreen:[144,238,144], + lightgrey:[211,211,211], + lightpink:[255,182,193], + lightyellow:[255,255,224], + lime:[0,255,0], + magenta:[255,0,255], + maroon:[128,0,0], + navy:[0,0,128], + olive:[128,128,0], + orange:[255,165,0], + pink:[255,192,203], + purple:[128,0,128], + violet:[128,0,128], + red:[255,0,0], + silver:[192,192,192], + white:[255,255,255], + yellow:[255,255,0], + transparent: [255,255,255] +}; + +/* + * jQuery Easing v1.3 - http://gsgd.co.uk/sandbox/jquery/easing/ + * + * Uses the built in easing capabilities added In jQuery 1.1 + * to offer multiple easing options + * + * TERMS OF USE - jQuery Easing + * + * Open source under the BSD License. + * + * Copyright 2008 George McGinley Smith + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * Neither the name of the author nor the names of contributors may be used to endorse + * or promote products derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + * +*/ + +// t: current time, b: begInnIng value, c: change In value, d: duration +$.easing.jswing = $.easing.swing; + +$.extend($.easing, +{ + def: 'easeOutQuad', + swing: function (x, t, b, c, d) { + //alert($.easing.default); + return $.easing[$.easing.def](x, t, b, c, d); + }, + easeInQuad: function (x, t, b, c, d) { + return c*(t/=d)*t + b; + }, + easeOutQuad: function (x, t, b, c, d) { + return -c *(t/=d)*(t-2) + b; + }, + easeInOutQuad: function (x, t, b, c, d) { + if ((t/=d/2) < 1) return c/2*t*t + b; + return -c/2 * ((--t)*(t-2) - 1) + b; + }, + easeInCubic: function (x, t, b, c, d) { + return c*(t/=d)*t*t + b; + }, + easeOutCubic: function (x, t, b, c, d) { + return c*((t=t/d-1)*t*t + 1) + b; + }, + easeInOutCubic: function (x, t, b, c, d) { + if ((t/=d/2) < 1) return c/2*t*t*t + b; + return c/2*((t-=2)*t*t + 2) + b; + }, + easeInQuart: function (x, t, b, c, d) { + return c*(t/=d)*t*t*t + b; + }, + easeOutQuart: function (x, t, b, c, d) { + return -c * ((t=t/d-1)*t*t*t - 1) + b; + }, + easeInOutQuart: function (x, t, b, c, d) { + if ((t/=d/2) < 1) return c/2*t*t*t*t + b; + return -c/2 * ((t-=2)*t*t*t - 2) + b; + }, + easeInQuint: function (x, t, b, c, d) { + return c*(t/=d)*t*t*t*t + b; + }, + easeOutQuint: function (x, t, b, c, d) { + return c*((t=t/d-1)*t*t*t*t + 1) + b; + }, + easeInOutQuint: function (x, t, b, c, d) { + if ((t/=d/2) < 1) return c/2*t*t*t*t*t + b; + return c/2*((t-=2)*t*t*t*t + 2) + b; + }, + easeInSine: function (x, t, b, c, d) { + return -c * Math.cos(t/d * (Math.PI/2)) + c + b; + }, + easeOutSine: function (x, t, b, c, d) { + return c * Math.sin(t/d * (Math.PI/2)) + b; + }, + easeInOutSine: function (x, t, b, c, d) { + return -c/2 * (Math.cos(Math.PI*t/d) - 1) + b; + }, + easeInExpo: function (x, t, b, c, d) { + return (t==0) ? b : c * Math.pow(2, 10 * (t/d - 1)) + b; + }, + easeOutExpo: function (x, t, b, c, d) { + return (t==d) ? b+c : c * (-Math.pow(2, -10 * t/d) + 1) + b; + }, + easeInOutExpo: function (x, t, b, c, d) { + if (t==0) return b; + if (t==d) return b+c; + if ((t/=d/2) < 1) return c/2 * Math.pow(2, 10 * (t - 1)) + b; + return c/2 * (-Math.pow(2, -10 * --t) + 2) + b; + }, + easeInCirc: function (x, t, b, c, d) { + return -c * (Math.sqrt(1 - (t/=d)*t) - 1) + b; + }, + easeOutCirc: function (x, t, b, c, d) { + return c * Math.sqrt(1 - (t=t/d-1)*t) + b; + }, + easeInOutCirc: function (x, t, b, c, d) { + if ((t/=d/2) < 1) return -c/2 * (Math.sqrt(1 - t*t) - 1) + b; + return c/2 * (Math.sqrt(1 - (t-=2)*t) + 1) + b; + }, + easeInElastic: function (x, t, b, c, d) { + var s=1.70158;var p=0;var a=c; + if (t==0) return b; if ((t/=d)==1) return b+c; if (!p) p=d*.3; + if (a < Math.abs(c)) { a=c; var s=p/4; } + else var s = p/(2*Math.PI) * Math.asin (c/a); + return -(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )) + b; + }, + easeOutElastic: function (x, t, b, c, d) { + var s=1.70158;var p=0;var a=c; + if (t==0) return b; if ((t/=d)==1) return b+c; if (!p) p=d*.3; + if (a < Math.abs(c)) { a=c; var s=p/4; } + else var s = p/(2*Math.PI) * Math.asin (c/a); + return a*Math.pow(2,-10*t) * Math.sin( (t*d-s)*(2*Math.PI)/p ) + c + b; + }, + easeInOutElastic: function (x, t, b, c, d) { + var s=1.70158;var p=0;var a=c; + if (t==0) return b; if ((t/=d/2)==2) return b+c; if (!p) p=d*(.3*1.5); + if (a < Math.abs(c)) { a=c; var s=p/4; } + else var s = p/(2*Math.PI) * Math.asin (c/a); + if (t < 1) return -.5*(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )) + b; + return a*Math.pow(2,-10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )*.5 + c + b; + }, + easeInBack: function (x, t, b, c, d, s) { + if (s == undefined) s = 1.70158; + return c*(t/=d)*t*((s+1)*t - s) + b; + }, + easeOutBack: function (x, t, b, c, d, s) { + if (s == undefined) s = 1.70158; + return c*((t=t/d-1)*t*((s+1)*t + s) + 1) + b; + }, + easeInOutBack: function (x, t, b, c, d, s) { + if (s == undefined) s = 1.70158; + if ((t/=d/2) < 1) return c/2*(t*t*(((s*=(1.525))+1)*t - s)) + b; + return c/2*((t-=2)*t*(((s*=(1.525))+1)*t + s) + 2) + b; + }, + easeInBounce: function (x, t, b, c, d) { + return c - $.easing.easeOutBounce (x, d-t, 0, c, d) + b; + }, + easeOutBounce: function (x, t, b, c, d) { + if ((t/=d) < (1/2.75)) { + return c*(7.5625*t*t) + b; + } else if (t < (2/2.75)) { + return c*(7.5625*(t-=(1.5/2.75))*t + .75) + b; + } else if (t < (2.5/2.75)) { + return c*(7.5625*(t-=(2.25/2.75))*t + .9375) + b; + } else { + return c*(7.5625*(t-=(2.625/2.75))*t + .984375) + b; + } + }, + easeInOutBounce: function (x, t, b, c, d) { + if (t < d/2) return $.easing.easeInBounce (x, t*2, 0, c, d) * .5 + b; + return $.easing.easeOutBounce (x, t*2-d, 0, c, d) * .5 + c*.5 + b; + } +}); +/* + * + * TERMS OF USE - EASING EQUATIONS + * + * Open source under the BSD License. + * + * Copyright 2001 Robert Penner + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, + * are permitted provided that the following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * Neither the name of the author nor the names of contributors may be used to endorse + * or promote products derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY + * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE + * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED + * OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +})(jQuery); + +/* + * jQuery UI Effects Highlight 1.6rc6 + * + * Copyright (c) 2009 AUTHORS.txt (http://ui.jquery.com/about) + * Dual licensed under the MIT (MIT-LICENSE.txt) + * and GPL (GPL-LICENSE.txt) licenses. + * + * http://docs.jquery.com/UI/Effects/Highlight + * + * Depends: + * effects.core.js + */ +(function($) { + +$.effects.highlight = function(o) { + + return this.queue(function() { + + // Create element + var el = $(this), props = ['backgroundImage','backgroundColor','opacity']; + + // Set options + var mode = $.effects.setMode(el, o.options.mode || 'show'); // Set Mode + var color = o.options.color || "#ffff99"; // Default highlight color + var oldColor = el.css("backgroundColor"); + + // Adjust + $.effects.save(el, props); el.show(); // Save & Show + el.css({backgroundImage: 'none', backgroundColor: color}); // Shift + + // Animation + var animation = {backgroundColor: oldColor }; + if (mode == "hide") animation['opacity'] = 0; + + // Animate + el.animate(animation, { queue: false, duration: o.duration, easing: o.options.easing, complete: function() { + if(mode == "hide") el.hide(); + $.effects.restore(el, props); + if (mode == "show" && $.browser.msie) this.style.removeAttribute('filter'); + if(o.callback) o.callback.apply(this, arguments); + el.dequeue(); + }}); + + }); + +}; + +})(jQuery); \ No newline at end of file diff --git a/vendor/gems/gems/sdoc-0.2.14.1/lib/sdoc/generator/template/direct/resources/js/main.js b/vendor/gems/gems/sdoc-0.2.14.1/lib/sdoc/generator/template/direct/resources/js/main.js new file mode 100755 index 00000000..31e96c3a --- /dev/null +++ b/vendor/gems/gems/sdoc-0.2.14.1/lib/sdoc/generator/template/direct/resources/js/main.js @@ -0,0 +1,22 @@ +function toggleSource( id ) +{ + var $src = $('#' + id).toggle(); + $('#l_' + id).html($src.css('display') == 'none' ? 'show' : 'hide'); +} + +function openCode( url ) +{ + window.open( url, "SOURCE_CODE", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=480,width=750" ).focus(); +} + + +window.highlight = function(url) { + var hash = url.match(/#([^#]+)$/) + if(hash) { + $('a[name=' + hash[1] + ']').parent().effect('highlight', {}, 'slow') + } +} + +$(function() { + highlight('#' + location.hash); +}); diff --git a/vendor/gems/gems/sdoc-0.2.14.1/lib/sdoc/generator/template/direct/resources/js/searchdoc.js b/vendor/gems/gems/sdoc-0.2.14.1/lib/sdoc/generator/template/direct/resources/js/searchdoc.js new file mode 100755 index 00000000..06b278ec --- /dev/null +++ b/vendor/gems/gems/sdoc-0.2.14.1/lib/sdoc/generator/template/direct/resources/js/searchdoc.js @@ -0,0 +1,628 @@ +Searchdoc = {}; + +// navigation.js ------------------------------------------ + +Searchdoc.Navigation = new function() { + this.initNavigation = function() { + var _this = this; + + $(document).keydown(function(e) { + _this.onkeydown(e); + }).keyup(function(e) { + _this.onkeyup(e); + }); + + this.navigationActive = true; + } + + this.setNavigationActive = function(state) { + this.navigationActive = state; + this.clearMoveTimeout(); + } + + + this.onkeyup = function(e) { + if (!this.navigationActive) return; + switch(e.keyCode) { + case 37: //Event.KEY_LEFT: + case 38: //Event.KEY_UP: + case 39: //Event.KEY_RIGHT: + case 40: //Event.KEY_DOWN: + case 73: // i - qwerty + case 74: // j + case 75: // k + case 76: // l + case 67: // c - dvorak + case 72: // h + case 84: // t + case 78: // n + this.clearMoveTimeout(); + break; + } + } + + this.onkeydown = function(e) { + if (!this.navigationActive) return; + switch(e.keyCode) { + case 37: //Event.KEY_LEFT: + case 74: // j (qwerty) + case 72: // h (dvorak) + if (this.moveLeft()) e.preventDefault(); + break; + case 38: //Event.KEY_UP: + case 73: // i (qwerty) + case 67: // c (dvorak) + if (e.keyCode == 38 || e.ctrlKey) { + if (this.moveUp()) e.preventDefault(); + this.startMoveTimeout(false); + } + break; + case 39: //Event.KEY_RIGHT: + case 76: // l (qwerty) + case 78: // n (dvorak) + if (this.moveRight()) e.preventDefault(); + break; + case 40: //Event.KEY_DOWN: + case 75: // k (qwerty) + case 84: // t (dvorak) + if (e.keyCode == 40 || e.ctrlKey) { + if (this.moveDown()) e.preventDefault(); + this.startMoveTimeout(true); + } + break; + case 9: //Event.KEY_TAB: + case 13: //Event.KEY_RETURN: + if (this.$current) this.select(this.$current); + break; + } + if (e.ctrlKey && e.shiftKey) this.select(this.$current); + } + + this.clearMoveTimeout = function() { + clearTimeout(this.moveTimeout); + this.moveTimeout = null; + } + + this.startMoveTimeout = function(isDown) { + if (!$.browser.mozilla && !$.browser.opera) return; + if (this.moveTimeout) this.clearMoveTimeout(); + var _this = this; + + var go = function() { + if (!_this.moveTimeout) return; + _this[isDown ? 'moveDown' : 'moveUp'](); + _this.moveTimout = setTimeout(go, 100); + } + this.moveTimeout = setTimeout(go, 200); + } + + this.moveRight = function() { + } + + this.moveLeft = function() { + } + + this.move = function(isDown) { + } + + this.moveUp = function() { + return this.move(false); + } + + this.moveDown = function() { + return this.move(true); + } +} + + +// scrollIntoView.js -------------------------------------- + +function scrollIntoView(element, view) { + var offset, viewHeight, viewScroll, height; + offset = element.offsetTop; + height = element.offsetHeight; + viewHeight = view.offsetHeight; + viewScroll = view.scrollTop; + if (offset - viewScroll + height > viewHeight) { + view.scrollTop = offset - viewHeight + height; + } + if (offset < viewScroll) { + view.scrollTop = offset; + } +} + + +// searcher.js -------------------------------------------- + +Searchdoc.Searcher = function(data) { + this.data = data; + this.handlers = []; +} + +Searchdoc.Searcher.prototype = new function() { + var CHUNK_SIZE = 1000, // search is performed in chunks of 1000 for non-bloking user input + MAX_RESULTS = 100, // do not try to find more than 100 results + huid = 1, suid = 1, + runs = 0; + + + this.find = function(query) { + var queries = splitQuery(query), + regexps = buildRegexps(queries), + highlighters = buildHilighters(queries), + state = { from: 0, pass: 0, limit: MAX_RESULTS, n: suid++}, + _this = this; + this.currentSuid = state.n; + + if (!query) return; + + var run = function() { + // stop current search thread if new search started + if (state.n != _this.currentSuid) return; + + var results = performSearch(_this.data, regexps, queries, highlighters, state), + hasMore = (state.limit > 0 && state.pass < 3); + + triggerResults.call(_this, results, !hasMore); + if (hasMore) { + setTimeout(run, 2); + } + runs++; + }; + runs = 0; + + // start search thread + run(); + } + + /* ----- Events ------ */ + this.ready = function(fn) { + fn.huid = huid; + this.handlers.push(fn); + } + + /* ----- Utilities ------ */ + function splitQuery(query) { + return jQuery.grep(query.split(/(\s+|\(\)?)/), function(string) { return string.match(/\S/) }); + } + + function buildRegexps(queries) { + return jQuery.map(queries, function(query) { return new RegExp(query.replace(/(.)/g, '([$1])([^$1]*?)'), 'i') }); + } + + function buildHilighters(queries) { + return jQuery.map(queries, function(query) { + return jQuery.map( query.split(''), function(l, i){ return '\u0001$' + (i*2+1) + '\u0002$' + (i*2+2) } ).join('') + }); + } + + // function longMatchRegexp(index, longIndex, regexps) { + // for (var i = regexps.length - 1; i >= 0; i--){ + // if (!index.match(regexps[i]) && !longIndex.match(regexps[i])) return false; + // }; + // return true; + // } + + + /* ----- Mathchers ------ */ + function matchPass1(index, longIndex, queries, regexps) { + if (index.indexOf(queries[0]) != 0) return false; + for (var i=1, l = regexps.length; i < l; i++) { + if (!index.match(regexps[i]) && !longIndex.match(regexps[i])) return false; + }; + return true; + } + + function matchPass2(index, longIndex, queries, regexps) { + if (index.indexOf(queries[0]) == -1) return false; + for (var i=1, l = regexps.length; i < l; i++) { + if (!index.match(regexps[i]) && !longIndex.match(regexps[i])) return false; + }; + return true; + } + + function matchPassRegexp(index, longIndex, queries, regexps) { + if (!index.match(regexps[0])) return false; + for (var i=1, l = regexps.length; i < l; i++) { + if (!index.match(regexps[i]) && !longIndex.match(regexps[i])) return false; + }; + return true; + } + + + /* ----- Highlighters ------ */ + function highlightRegexp(info, queries, regexps, highlighters) { + var result = createResult(info); + for (var i=0, l = regexps.length; i < l; i++) { + result.title = result.title.replace(regexps[i], highlighters[i]); + if (i > 0) + result.namespace = result.namespace.replace(regexps[i], highlighters[i]); + }; + return result; + } + + function hltSubstring(string, pos, length) { + return string.substring(0, pos) + '\u0001' + string.substring(pos, pos + length) + '\u0002' + string.substring(pos + length); + } + + function highlightQuery(info, queries, regexps, highlighters) { + var result = createResult(info), pos = 0, lcTitle = result.title.toLowerCase(); + pos = lcTitle.indexOf(queries[0]); + if (pos != -1) { + result.title = hltSubstring(result.title, pos, queries[0].length); + } + for (var i=1, l = regexps.length; i < l; i++) { + result.title = result.title.replace(regexps[i], highlighters[i]); + result.namespace = result.namespace.replace(regexps[i], highlighters[i]); + }; + return result; + } + + function createResult(info) { + var result = {}; + result.title = info[0]; + result.namespace = info[1]; + result.path = info[2]; + result.params = info[3]; + result.snippet = info[4]; + result.badge = info[6]; + return result; + } + + /* ----- Searching ------ */ + function performSearch(data, regexps, queries, highlighters, state) { + var searchIndex = data.searchIndex, // search by title first and then by source + longSearchIndex = data.longSearchIndex, + info = data.info, + result = [], + i = state.from, + l = searchIndex.length, + togo = CHUNK_SIZE, + matchFunc, hltFunc; + + while (state.pass < 3 && state.limit > 0 && togo > 0) { + if (state.pass == 0) { + matchFunc = matchPass1; + hltFunc = highlightQuery; + } else if (state.pass == 1) { + matchFunc = matchPass2; + hltFunc = highlightQuery; + } else if (state.pass == 2) { + matchFunc = matchPassRegexp; + hltFunc = highlightRegexp; + } + + for (; togo > 0 && i < l && state.limit > 0; i++, togo--) { + if (info[i].n == state.n) continue; + if (matchFunc(searchIndex[i], longSearchIndex[i], queries, regexps)) { + info[i].n = state.n; + result.push(hltFunc(info[i], queries, regexps, highlighters)); + state.limit--; + } + }; + if (searchIndex.length <= i) { + state.pass++; + i = state.from = 0; + } else { + state.from = i; + } + } + return result; + } + + function triggerResults(results, isLast) { + jQuery.each(this.handlers, function(i, fn) { fn.call(this, results, isLast) }) + } +} + + + + +// panel.js ----------------------------------------------- + +Searchdoc.Panel = function(element, data, tree, frame) { + this.$element = $(element); + this.$input = $('input', element).eq(0); + this.$result = $('.result ul', element).eq(0); + this.frame = frame; + this.$current = null; + this.$view = this.$result.parent(); + this.data = data; + this.searcher = new Searchdoc.Searcher(data.index); + this.tree = new Searchdoc.Tree($('.tree', element), tree, this); + this.init(); +} + +Searchdoc.Panel.prototype = $.extend({}, Searchdoc.Navigation, new function() { + var suid = 1; + + this.init = function() { + var _this = this; + var observer = function() { + _this.search(_this.$input[0].value); + }; + this.$input.keyup(observer); + this.$input.click(observer); // mac's clear field + + this.searcher.ready(function(results, isLast) { + _this.addResults(results, isLast); + }) + + this.$result.click(function(e) { + _this.$current.removeClass('current'); + _this.$current = $(e.target).closest('li').addClass('current'); + _this.select(); + _this.$input.focus(); + }); + + this.initNavigation(); + this.setNavigationActive(false); + } + + this.search = function(value, selectFirstMatch) { + value = jQuery.trim(value).toLowerCase(); + this.selectFirstMatch = selectFirstMatch; + if (value) { + this.$element.removeClass('panel_tree').addClass('panel_results'); + this.tree.setNavigationActive(false); + this.setNavigationActive(true); + } else { + this.$element.addClass('panel_tree').removeClass('panel_results'); + this.tree.setNavigationActive(true); + this.setNavigationActive(false); + } + if (value != this.lastQuery) { + this.lastQuery = value; + this.firstRun = true; + this.searcher.find(value); + } + } + + this.addResults = function(results, isLast) { + var target = this.$result.get(0); + if (this.firstRun && (results.length > 0 || isLast)) { + this.$current = null; + this.$result.empty(); + } + for (var i=0, l = results.length; i < l; i++) { + target.appendChild(renderItem.call(this, results[i])); + }; + if (this.firstRun && results.length > 0) { + this.firstRun = false; + this.$current = $(target.firstChild); + this.$current.addClass('current'); + if (this.selectFirstMatch) this.select(); + scrollIntoView(this.$current[0], this.$view[0]) + } + if (jQuery.browser.msie) this.$element[0].className += ''; + } + + this.open = function(src) { + this.frame.location.href = '../' + src; + if (this.frame.highlight) this.frame.highlight(src); + } + + this.select = function() { + this.open(this.$current.data('path')); + } + + this.move = function(isDown) { + if (!this.$current) return; + var $next = this.$current[isDown ? 'next' : 'prev'](); + if ($next.length) { + this.$current.removeClass('current'); + $next.addClass('current'); + scrollIntoView($next[0], this.$view[0]); + this.$current = $next; + } + return true; + } + + function renderItem(result) { + var li = document.createElement('li'), + html = '', badge = result.badge; + html += '

' + hlt(result.title); + if (result.params) html += '' + result.params + ''; + html += '

'; + html += '

'; + if (typeof badge != 'undefined') { + html += '' + escapeHTML(this.data.badges[badge] || 'unknown') + ''; + } + html += hlt(result.namespace) + '

'; + if (result.snippet) html += '

' + escapeHTML(result.snippet) + '

'; + li.innerHTML = html; + jQuery.data(li, 'path', result.path); + return li; + } + + function hlt(html) { + return escapeHTML(html).replace(/\u0001/g, '').replace(/\u0002/g, '') + } + + function escapeHTML(html) { + return html.replace(/[&<>]/g, function(c) { + return '&#' + c.charCodeAt(0) + ';'; + }); + } + +}); + +// tree.js ------------------------------------------------ + +Searchdoc.Tree = function(element, tree, panel) { + this.$element = $(element); + this.$list = $('ul', element); + this.tree = tree; + this.panel = panel; + this.init(); +} + +Searchdoc.Tree.prototype = $.extend({}, Searchdoc.Navigation, new function() { + this.init = function() { + var stopper = document.createElement('li'); + stopper.className = 'stopper'; + this.$list[0].appendChild(stopper); + for (var i=0, l = this.tree.length; i < l; i++) { + buildAndAppendItem.call(this, this.tree[i], 0, stopper); + }; + var _this = this; + this.$list.click(function(e) { + var $target = $(e.target), + $li = $target.closest('li'); + if ($target.hasClass('icon')) { + _this.toggle($li); + } else { + _this.select($li); + } + }) + + this.initNavigation(); + if (jQuery.browser.msie) document.body.className += ''; + } + + this.select = function($li) { + this.highlight($li); + var path = $li[0].searchdoc_tree_data.path; + if (path) this.panel.open(path); + } + + this.highlight = function($li) { + if (this.$current) this.$current.removeClass('current'); + this.$current = $li.addClass('current'); + } + + this.toggle = function($li) { + var closed = !$li.hasClass('closed'), + children = $li[0].searchdoc_tree_data.children; + $li.toggleClass('closed'); + for (var i=0, l = children.length; i < l; i++) { + toggleVis.call(this, $(children[i].li), !closed); + }; + } + + this.moveRight = function() { + if (!this.$current) { + this.highlight(this.$list.find('li:first')); + return; + } + if (this.$current.hasClass('closed')) { + this.toggle(this.$current); + } + } + + this.moveLeft = function() { + if (!this.$current) { + this.highlight(this.$list.find('li:first')); + return; + } + if (!this.$current.hasClass('closed')) { + this.toggle(this.$current); + } else { + var level = this.$current[0].searchdoc_tree_data.level; + if (level == 0) return; + var $next = this.$current.prevAll('li.level_' + (level - 1) + ':visible:first'); + this.$current.removeClass('current'); + $next.addClass('current'); + scrollIntoView($next[0], this.$element[0]); + this.$current = $next; + } + } + + this.move = function(isDown) { + if (!this.$current) { + this.highlight(this.$list.find('li:first')); + return true; + } + var next = this.$current[0]; + if (isDown) { + do { + next = next.nextSibling; + if (next && next.style && next.style.display != 'none') break; + } while(next); + } else { + do { + next = next.previousSibling; + if (next && next.style && next.style.display != 'none') break; + } while(next); + } + if (next && next.className.indexOf('stopper') == -1) { + this.$current.removeClass('current'); + $(next).addClass('current'); + scrollIntoView(next, this.$element[0]); + this.$current = $(next); + } + return true; + } + + function toggleVis($li, show) { + var closed = $li.hasClass('closed'), + children = $li[0].searchdoc_tree_data.children; + $li.css('display', show ? '' : 'none') + if (!show && this.$current && $li[0] == this.$current[0]) { + this.$current.removeClass('current'); + this.$current = null; + } + for (var i=0, l = children.length; i < l; i++) { + toggleVis.call(this, $(children[i].li), show && !closed); + }; + } + + function buildAndAppendItem(item, level, before) { + var li = renderItem(item, level), + list = this.$list[0]; + item.li = li; + list.insertBefore(li, before); + for (var i=0, l = item[3].length; i < l; i++) { + buildAndAppendItem.call(this, item[3][i], level + 1, before); + }; + return li; + } + + function renderItem(item, level) { + var li = document.createElement('li'), + cnt = document.createElement('div'), + h1 = document.createElement('h1'), + p = document.createElement('p'), + icon, i; + + li.appendChild(cnt); + li.style.paddingLeft = getOffset(level); + cnt.className = 'content'; + if (!item[1]) li.className = 'empty '; + cnt.appendChild(h1); + // cnt.appendChild(p); + h1.appendChild(document.createTextNode(item[0])); + // p.appendChild(document.createTextNode(item[4])); + if (item[2]) { + i = document.createElement('i'); + i.appendChild(document.createTextNode(item[2])); + h1.appendChild(i); + } + if (item[3].length > 0) { + icon = document.createElement('div'); + icon.className = 'icon'; + cnt.appendChild(icon); + } + + // user direct assignement instead of $() + // it's 8x faster + // $(li).data('path', item[1]) + // .data('children', item[3]) + // .data('level', level) + // .css('display', level == 0 ? '' : 'none') + // .addClass('level_' + level) + // .addClass('closed'); + li.searchdoc_tree_data = { + path: item[1], + children: item[3], + level: level + } + li.style.display = level == 0 ? '' : 'none'; + li.className += 'level_' + level + ' closed'; + return li; + } + + function getOffset(level) { + return 5 + 18*level + 'px'; + } +}); diff --git a/vendor/gems/gems/sdoc-0.2.14.1/lib/sdoc/generator/template/direct/resources/panel/index.html b/vendor/gems/gems/sdoc-0.2.14.1/lib/sdoc/generator/template/direct/resources/panel/index.html new file mode 100755 index 00000000..683c6269 --- /dev/null +++ b/vendor/gems/gems/sdoc-0.2.14.1/lib/sdoc/generator/template/direct/resources/panel/index.html @@ -0,0 +1,71 @@ + + + + + + layout + + + + + + + + + +
+
+
+ + + +
+ +
+
+
+
    +
+
+
+
    +
+
+
+ + diff --git a/vendor/gems/gems/sdoc-0.2.14.1/lib/sdoc/generator/template/merge/index.rhtml b/vendor/gems/gems/sdoc-0.2.14.1/lib/sdoc/generator/template/merge/index.rhtml new file mode 100755 index 00000000..3a7e0cb7 --- /dev/null +++ b/vendor/gems/gems/sdoc-0.2.14.1/lib/sdoc/generator/template/merge/index.rhtml @@ -0,0 +1,14 @@ + + + + + + <%= @title %> + + + + + + diff --git a/vendor/gems/gems/sdoc-0.2.14.1/lib/sdoc/generator/template/shtml/_context.rhtml b/vendor/gems/gems/sdoc-0.2.14.1/lib/sdoc/generator/template/shtml/_context.rhtml new file mode 100755 index 00000000..984a40ea --- /dev/null +++ b/vendor/gems/gems/sdoc-0.2.14.1/lib/sdoc/generator/template/shtml/_context.rhtml @@ -0,0 +1,164 @@ +
+ <% unless (desc = context.description).empty? %> +
<%= desc %>
+ <% end %> + + <% unless context.requires.empty? %> +
Required Files
+
    + <% context.requires.each do |req| %> +
  • <%= h req.name %>
  • + <% end %> +
+ <% end %> + + <% sections = context.sections.select { |section| section.title } %> + <% unless sections.empty? %> +
Contents
+ + <% end %> + + <% + list = context.method_list + unless @options.show_all + list = list.find_all {|m| m.visibility == :public || m.visibility == :protected || m.force_documentation } + end + %> + <% unless list.empty? %> +
Methods
+
    + <% list.sort{ |a, b| a.name <=> b.name }.each do |method| %> +
  • <%= method.name %>
  • + <% end %> +
+ <% end %> + + <% unless context.includes.empty? %> +
Included Modules
+
    + <% context.includes.each do |inc| %> +
  • + <% unless String === inc.module %> + <%= h inc.module.full_name %> + <% else %> + <%= h inc.name %> + <% end %> + START:includes +
  • + <% end %> +
+ <% end %> + + <% sections.each do |section| %> + + <% unless (description = section.description).empty? %> +
+ <%= description %> +
+ <% end %> + <% end %> + + <% unless context.classes_and_modules.empty? %> +
Classes and Modules
+
    + <% (context.modules.sort + context.classes.sort).each do |mod| %> +
  • <%= mod.type.upcase %> <%= mod.full_name %>
  • + <% end %> +
+ <% end %> + + <% unless context.constants.empty? %> +
Constants
+ + <% context.each_constant do |const| %> + + + + + + <% unless (description = const.description).empty? %> + + + + + <% end %> + <% end %> +
<%= h const.name %>=<%= h const.value %>
 <%= description %>
+ <% end %> + + <% unless context.attributes.empty? %> +
Attributes
+ + <% context.each_attribute do |attrib| %> + + + + + + <% end %> +
+ [<%= attrib.rw %>] + <%= h attrib.name %><%= attrib.description.strip %>
+ <% end %> + + <% context.methods_by_type.each do |type, visibilities| + next if visibilities.empty? + visibilities.each do |visibility, methods| + next if methods.empty? + next unless @options.show_all || visibility == :public || visibility == :protected || methods.any? {|m| m.force_documentation } + %> +
<%= type.capitalize %> <%= visibility.to_s.capitalize %> methods
+ <% methods.each do |method| %> +
+
+ <% if method.call_seq %> + <%= method.call_seq.gsub(/->/, '→') %> + <% else %> + <%= h method.name %><%= h method.params %> + <% end %> +
+ <% unless (description = method.description).empty? %> +
+ <%# TODO delete this dirty hack when documentation for example for JavaScriptHelper will not be cutted off by + + + + + + + + + +
+ <%= include_template '_context.rhtml', {:context => klass, :rel_prefix => rel_prefix} %> +
+ + \ No newline at end of file diff --git a/vendor/gems/gems/sdoc-0.2.14.1/lib/sdoc/generator/template/shtml/file.rhtml b/vendor/gems/gems/sdoc-0.2.14.1/lib/sdoc/generator/template/shtml/file.rhtml new file mode 100755 index 00000000..9d8113e7 --- /dev/null +++ b/vendor/gems/gems/sdoc-0.2.14.1/lib/sdoc/generator/template/shtml/file.rhtml @@ -0,0 +1,37 @@ + + + + + <%= h file.name %> + + " type="text/css" media="screen" /> + + + + + + +
+ +
+ <%= include_template '_context.rhtml', {:context => file, :rel_prefix => rel_prefix} %> +
+ + \ No newline at end of file diff --git a/vendor/gems/gems/sdoc-0.2.14.1/lib/sdoc/generator/template/shtml/index.rhtml b/vendor/gems/gems/sdoc-0.2.14.1/lib/sdoc/generator/template/shtml/index.rhtml new file mode 100755 index 00000000..4d0c4a69 --- /dev/null +++ b/vendor/gems/gems/sdoc-0.2.14.1/lib/sdoc/generator/template/shtml/index.rhtml @@ -0,0 +1,14 @@ + + + + + + <%= @options.title %> + + + + + + diff --git a/vendor/gems/gems/sdoc-0.2.14.1/lib/sdoc/generator/template/shtml/resources/apple-touch-icon.png b/vendor/gems/gems/sdoc-0.2.14.1/lib/sdoc/generator/template/shtml/resources/apple-touch-icon.png new file mode 100755 index 00000000..50f98b0f Binary files /dev/null and b/vendor/gems/gems/sdoc-0.2.14.1/lib/sdoc/generator/template/shtml/resources/apple-touch-icon.png differ diff --git a/vendor/gems/gems/sdoc-0.2.14.1/lib/sdoc/generator/template/shtml/resources/css/main.css b/vendor/gems/gems/sdoc-0.2.14.1/lib/sdoc/generator/template/shtml/resources/css/main.css new file mode 100755 index 00000000..d1a1c244 --- /dev/null +++ b/vendor/gems/gems/sdoc-0.2.14.1/lib/sdoc/generator/template/shtml/resources/css/main.css @@ -0,0 +1,191 @@ +a { + color: #00F; + text-decoration: none; +} + +a:hover { + color: #77F; + text-decoration: underline; +} + +body, td, p { + font-family: "Bitstream Vera Sans", Verdana, Arial, Helvetica, sans-serif; + background: #FFF; + color: #000; + margin: 0px; + font-size: small; +} + +p { + margin-top: 0.5em; + margin-bottom: 0.5em; +} + +#content { + margin: 2em; + margin-left: 3.5em; + margin-right: 3.5em; +} + +#description p { + margin-bottom: 0.5em; +} + +.sectiontitle { + margin-top: 1em; + margin-bottom: 1em; + padding: 0.5em; + padding-left: 2em; + background: #005; + color: #FFF; + font-weight: bold; +} + +.attr-rw { + padding-left: 1em; + padding-right: 1em; + text-align: center; + color: #055; +} + +.attr-name { + font-weight: bold; +} + +.attr-desc { +} + +.attr-desc p { + margin-top: 0; +} + +.attr-value { + font-family: monospace; +} + +.file-title-prefix { + font-size: large; +} + +.file-title { + font-size: large; + font-weight: bold; + background: #005; + color: #FFF; +} + +.banner { + background: #005; + color: #FFF; + border: 1px solid black; + padding: 1em; +} + +.banner td { + background: transparent; + color: #FFF; +} + +h1 a, h2 a, .sectiontitle a, .banner a { + color: #FF0; +} + +h1 a:hover, h2 a:hover, .sectiontitle a:hover, .banner a:hover { + color: #FF7; +} + +.dyn-source { + display: none; + background: #fffde8; + color: #000; + border: #ffe0bb dotted 1px; + margin: 0.5em 2em 0.5em 2em; + padding: 0.5em; +} + +.dyn-source .cmt { + color: #00F; + font-style: italic; +} + +.dyn-source .kw { + color: #070; + font-weight: bold; +} + +.method { + margin-left: 1em; + margin-right: 1em; + margin-bottom: 1em; +} + +.description pre { + padding: 0.5em; + border: #ffe0bb dotted 1px; + background: #fffde8; +} + +.method .title { + font-family: monospace; + font-size: large; + border-bottom: 1px dashed black; + margin-bottom: 0.3em; + padding-bottom: 0.1em; +} + +.method .description, .method .sourcecode { + margin-left: 1em; +} + +.description p, .sourcecode p { + margin-bottom: 0.5em; +} + +.method .sourcecode p.source-link { + text-indent: 0em; + margin-top: 0.5em; +} + +.method .aka { + margin-top: 0.3em; + margin-left: 1em; + font-style: italic; + text-indent: 2em; +} + +h1 { + padding: 1em; + margin-left: -1.5em; + font-size: x-large; + font-weight: bold; + color: #FFF; + background: #007; +} + +h2 { + padding: 0.5em 1em 0.5em 1em; + margin-left: -1.5em; + font-size: large; + font-weight: bold; + color: #FFF; + background: #009; +} + +h3, h4, h5, h6 { + color: #220088; + border-bottom: #5522bb solid 1px; +} + +.sourcecode > pre { + padding: 0.5em; + border: 1px dotted black; + background: #FFE; +} + +dt { + font-weight: bold +} + +dd { + margin-bottom: 0.7em; +} \ No newline at end of file diff --git a/vendor/gems/gems/sdoc-0.2.14.1/lib/sdoc/generator/template/shtml/resources/css/panel.css b/vendor/gems/gems/sdoc-0.2.14.1/lib/sdoc/generator/template/shtml/resources/css/panel.css new file mode 100755 index 00000000..5390c923 --- /dev/null +++ b/vendor/gems/gems/sdoc-0.2.14.1/lib/sdoc/generator/template/shtml/resources/css/panel.css @@ -0,0 +1,383 @@ +/* Panel (begin) */ + .panel + { + position: absolute; + width: 100%; + height: 100%; + top: 0; + left: 0; + background: #FFF; + z-index: 2; + font-family: "Helvetica Neue", "Arial", sans-serif; + //zoom: 1; + } + + .panel_tree .results, + .panel_results .tree + { + display: none; + } + + /* Header with search box (begin) */ + .panel .header + { + width: 100%; + height: 29px; + border-bottom: 1px solid #666; + position: relative; + left: 0; top: 0; + background: #e8e8e8; + } + + .panel .header div + { + margin: 0 7px; + } + .panel .header table + { + height: 29px; + width: 100%; + } + + .panel .header table td + { + vertical-align: middle; + text-align: middle; + } + + .panel .header label + { + position: absolute; + font-size: 12px; + line-height: 29px; + margin-left: 3px; + color: #999; + cursor: text; + } + + .panel .header table input + { + width: 100%; + box-sizing: border-box; + -moz-box-sizing: border-box; + -webkit-box-sizing: border-box; + display: inline-block; + -webkit-appearance: searchfield; + height: 22px; + //height: auto; + } + + /* Header with search box (end) */ + + + /* Results (begin) */ + .panel .result + { + position: absolute; + top: 30px; + bottom: 0; + left: 0; + width: 100%; + //height: expression((this.parentNode.offsetHeight - 31)); + overflow-y: scroll; + overflow-x: hidden; + -overflow-y: hidden; + background: #EDF3FE url(../i/results_bg.png); + z-index: 2; + //zoom:1; + } + + .panel .result ul + { + font-size: 0.8em; + width: 100%; + background: #EDF3FE url(../i/results_bg.png); + //zoom:1; + } + + .panel .result ul li + { + height: 46px; + -height: 50px; + //display: inline; + //width: 100%; + //zoom: 1; + overflow: hidden; + padding: 4px 10px 0 10px; + cursor: pointer; + } + + .panel .result ul li h1 + { + font-size: 13px; + font-weight: normal; + color: #333; + margin-bottom: 2px; + white-space: nowrap; + } + + .panel .result ul li p + { + font-size: 11px; + color: #333; + margin-bottom: 2px; + white-space: nowrap; + } + + .panel .result ul li h1 i, + .panel .result ul li p.snippet + { + color: #999; + } + + .panel .result ul li b + { + color: #000; + } + + .panel .result ul li.current + { + background: #3875D7; + } + + .panel .result ul li.current h1, + .panel .result ul li.current p + { + color: #DDD; + } + + .panel .result ul li.current h1 i, + .panel .result ul li.current p.snippet + { + color: #AAA; + } + + .panel .result ul li.current b + { + color: #FFF; + } + + + .panel .result ul li:hover, + .panel .result ul li.selected + { + background: #d0d0d0; + } + + .panel .result ul li.current:hover + { + background: #2965C0; + } + + .panel .result ul li .badge + { + margin-right: 0.4em; + margin-left: -0.2em; + padding: 0 0.2em; + color: #000; + } + + .panel .result ul li .badge_1 + { + background: #ACDBF4; + } + + .panel .result ul li.current .badge_1 + { + background: #97BFD7; + } + + .panel .result ul li .badge_2 + { + background: #ACF3C3; + } + + .panel .result ul li.current .badge_2 + { + background: #98D7AC; + } + + .panel .result ul li .badge_3 + { + background: #E0F3AC; + } + + .panel .result ul li.current .badge_3 + { + background: #C4D798; + } + + .panel .result ul li .badge_4 + { + background: #D7CA98; + } + + .panel .result ul li.current .badge_4 + { + background: #A6B0AC; + } + + .panel .result ul li .badge_5 + { + background: #F3C8AC; + } + + .panel .result ul li.current .badge_5 + { + background: #D7B198; + } + + .panel .result ul li .badge_6 + { + background: #F3ACC3; + } + + .panel .result ul li.current .badge_6 + { + background: #D798AB; + } + + /* Results (end) */ + + /* Tree (begin) */ /**/ + .panel .tree + { + position: absolute; + top: 30px; + bottom: 0; + left: 0; + width: 100%; + //zoom: 1; + //height: expression((this.parentNode.offsetHeight - 31)); + overflow-y: scroll; + overflow-x: hidden; + -overflow-y: hidden; + background: #EDF3FE url(../i/tree_bg.png); + z-index: 30; + } + + .panel .tree ul + { + background: #EDF3FE url(../i/tree_bg.png); + } + + .panel .tree li + { + cursor: pointer; + overflow: hidden; + //height: 23px; + //display: inline; + //zoom: 1; + //width: 100%; + } + + + .panel .tree li .content + { + padding-left: 18px; + padding-top: 5px; + height: 18px; + overflow: hidden; + position: relative; + } + + .panel .tree li .icon + { + width: 10px; + height: 9px; + background: url(../i/arrows.png); + background-position: 0 -9px; + position: absolute; + left: 1px; + top: 8px; + cursor: default; + } + + .panel .tree li.closed .icon + { + background-position: 0 0; + } + + .panel .tree ul li h1 + { + font-size: 13px; + font-weight: normal; + color: #000; + margin-bottom: 2px; + white-space: nowrap; + } + + .panel .tree ul li p + { + font-size: 11px; + color: #666; + margin-bottom: 2px; + white-space: nowrap; + } + + .panel .tree ul li h1 i + { + color: #999; + font-style: normal; + } + + .panel .tree ul li.empty + { + cursor: text; + } + + .panel .tree ul li.empty h1, + .panel .tree ul li.empty p + { + color: #666; + font-style: italic; + } + + .panel .tree ul li.current + { + background: #3875D7; + } + + .panel .tree ul li.current .icon + { + background-position: -10px -9px; + } + + .panel .tree ul li.current.closed .icon + { + background-position: -10px 0; + } + + .panel .tree ul li.current h1 + { + color: #FFF; + } + + .panel .tree ul li.current p + { + color: #CCC; + } + + .panel .tree ul li.current.empty h1, + .panel .tree ul li.current.empty p + { + color: #999; + } + + .panel .tree ul li:hover + { + background: #d0d0d0; + } + + .panel .tree ul li.current:hover + { + background: #2965C0; + } + + .panel .tree .stopper + { + display: none; + } + /* Tree (end) */ /**/ + +/* Panel (end) */ \ No newline at end of file diff --git a/vendor/gems/gems/sdoc-0.2.14.1/lib/sdoc/generator/template/shtml/resources/css/reset.css b/vendor/gems/gems/sdoc-0.2.14.1/lib/sdoc/generator/template/shtml/resources/css/reset.css new file mode 100755 index 00000000..13f8e0a1 --- /dev/null +++ b/vendor/gems/gems/sdoc-0.2.14.1/lib/sdoc/generator/template/shtml/resources/css/reset.css @@ -0,0 +1,53 @@ +/* http://meyerweb.com/eric/tools/css/reset/ */ +/* v1.0 | 20080212 */ + +html, body, div, span, applet, object, iframe, +h1, h2, h3, h4, h5, h6, p, blockquote, pre, +a, abbr, acronym, address, big, cite, code, +del, dfn, em, font, img, ins, kbd, q, s, samp, +small, strike, strong, sub, sup, tt, var, +b, u, i, center, +dl, dt, dd, ol, ul, li, +fieldset, form, label, legend, +table, caption, tbody, tfoot, thead, tr, th, td { + margin: 0; + padding: 0; + border: 0; + outline: 0; + font-size: 100%; + vertical-align: baseline; + background: transparent; +} +body { + line-height: 1; +} +ol, ul { + list-style: none; +} +blockquote, q { + quotes: none; +} +blockquote:before, blockquote:after, +q:before, q:after { + content: ''; + content: none; +} + +/* remember to define focus styles! */ +:focus { + outline: 0; +} + +/* remember to highlight inserts somehow! */ +ins { + text-decoration: none; +} +del { + text-decoration: line-through; +} + +/* tables still need 'cellspacing="0"' in the markup */ +table { + border-collapse: collapse; + border-spacing: 0; +} \ No newline at end of file diff --git a/vendor/gems/gems/sdoc-0.2.14.1/lib/sdoc/generator/template/shtml/resources/favicon.ico b/vendor/gems/gems/sdoc-0.2.14.1/lib/sdoc/generator/template/shtml/resources/favicon.ico new file mode 100755 index 00000000..e0e80cf8 Binary files /dev/null and b/vendor/gems/gems/sdoc-0.2.14.1/lib/sdoc/generator/template/shtml/resources/favicon.ico differ diff --git a/vendor/gems/gems/sdoc-0.2.14.1/lib/sdoc/generator/template/shtml/resources/i/arrows.png b/vendor/gems/gems/sdoc-0.2.14.1/lib/sdoc/generator/template/shtml/resources/i/arrows.png new file mode 100755 index 00000000..e54060f4 Binary files /dev/null and b/vendor/gems/gems/sdoc-0.2.14.1/lib/sdoc/generator/template/shtml/resources/i/arrows.png differ diff --git a/vendor/gems/gems/sdoc-0.2.14.1/lib/sdoc/generator/template/shtml/resources/i/results_bg.png b/vendor/gems/gems/sdoc-0.2.14.1/lib/sdoc/generator/template/shtml/resources/i/results_bg.png new file mode 100755 index 00000000..199ba692 Binary files /dev/null and b/vendor/gems/gems/sdoc-0.2.14.1/lib/sdoc/generator/template/shtml/resources/i/results_bg.png differ diff --git a/vendor/gems/gems/sdoc-0.2.14.1/lib/sdoc/generator/template/shtml/resources/i/tree_bg.png b/vendor/gems/gems/sdoc-0.2.14.1/lib/sdoc/generator/template/shtml/resources/i/tree_bg.png new file mode 100755 index 00000000..7d236633 Binary files /dev/null and b/vendor/gems/gems/sdoc-0.2.14.1/lib/sdoc/generator/template/shtml/resources/i/tree_bg.png differ diff --git a/vendor/gems/gems/sdoc-0.2.14.1/lib/sdoc/generator/template/shtml/resources/js/jquery-1.3.2.min.js b/vendor/gems/gems/sdoc-0.2.14.1/lib/sdoc/generator/template/shtml/resources/js/jquery-1.3.2.min.js new file mode 100755 index 00000000..b1ae21d8 --- /dev/null +++ b/vendor/gems/gems/sdoc-0.2.14.1/lib/sdoc/generator/template/shtml/resources/js/jquery-1.3.2.min.js @@ -0,0 +1,19 @@ +/* + * jQuery JavaScript Library v1.3.2 + * http://jquery.com/ + * + * Copyright (c) 2009 John Resig + * Dual licensed under the MIT and GPL licenses. + * http://docs.jquery.com/License + * + * Date: 2009-02-19 17:34:21 -0500 (Thu, 19 Feb 2009) + * Revision: 6246 + */ +(function(){var l=this,g,y=l.jQuery,p=l.$,o=l.jQuery=l.$=function(E,F){return new o.fn.init(E,F)},D=/^[^<]*(<(.|\s)+>)[^>]*$|^#([\w-]+)$/,f=/^.[^:#\[\.,]*$/;o.fn=o.prototype={init:function(E,H){E=E||document;if(E.nodeType){this[0]=E;this.length=1;this.context=E;return this}if(typeof E==="string"){var G=D.exec(E);if(G&&(G[1]||!H)){if(G[1]){E=o.clean([G[1]],H)}else{var I=document.getElementById(G[3]);if(I&&I.id!=G[3]){return o().find(E)}var F=o(I||[]);F.context=document;F.selector=E;return F}}else{return o(H).find(E)}}else{if(o.isFunction(E)){return o(document).ready(E)}}if(E.selector&&E.context){this.selector=E.selector;this.context=E.context}return this.setArray(o.isArray(E)?E:o.makeArray(E))},selector:"",jquery:"1.3.2",size:function(){return this.length},get:function(E){return E===g?Array.prototype.slice.call(this):this[E]},pushStack:function(F,H,E){var G=o(F);G.prevObject=this;G.context=this.context;if(H==="find"){G.selector=this.selector+(this.selector?" ":"")+E}else{if(H){G.selector=this.selector+"."+H+"("+E+")"}}return G},setArray:function(E){this.length=0;Array.prototype.push.apply(this,E);return this},each:function(F,E){return o.each(this,F,E)},index:function(E){return o.inArray(E&&E.jquery?E[0]:E,this)},attr:function(F,H,G){var E=F;if(typeof F==="string"){if(H===g){return this[0]&&o[G||"attr"](this[0],F)}else{E={};E[F]=H}}return this.each(function(I){for(F in E){o.attr(G?this.style:this,F,o.prop(this,E[F],G,I,F))}})},css:function(E,F){if((E=="width"||E=="height")&&parseFloat(F)<0){F=g}return this.attr(E,F,"curCSS")},text:function(F){if(typeof F!=="object"&&F!=null){return this.empty().append((this[0]&&this[0].ownerDocument||document).createTextNode(F))}var E="";o.each(F||this,function(){o.each(this.childNodes,function(){if(this.nodeType!=8){E+=this.nodeType!=1?this.nodeValue:o.fn.text([this])}})});return E},wrapAll:function(E){if(this[0]){var F=o(E,this[0].ownerDocument).clone();if(this[0].parentNode){F.insertBefore(this[0])}F.map(function(){var G=this;while(G.firstChild){G=G.firstChild}return G}).append(this)}return this},wrapInner:function(E){return this.each(function(){o(this).contents().wrapAll(E)})},wrap:function(E){return this.each(function(){o(this).wrapAll(E)})},append:function(){return this.domManip(arguments,true,function(E){if(this.nodeType==1){this.appendChild(E)}})},prepend:function(){return this.domManip(arguments,true,function(E){if(this.nodeType==1){this.insertBefore(E,this.firstChild)}})},before:function(){return this.domManip(arguments,false,function(E){this.parentNode.insertBefore(E,this)})},after:function(){return this.domManip(arguments,false,function(E){this.parentNode.insertBefore(E,this.nextSibling)})},end:function(){return this.prevObject||o([])},push:[].push,sort:[].sort,splice:[].splice,find:function(E){if(this.length===1){var F=this.pushStack([],"find",E);F.length=0;o.find(E,this[0],F);return F}else{return this.pushStack(o.unique(o.map(this,function(G){return o.find(E,G)})),"find",E)}},clone:function(G){var E=this.map(function(){if(!o.support.noCloneEvent&&!o.isXMLDoc(this)){var I=this.outerHTML;if(!I){var J=this.ownerDocument.createElement("div");J.appendChild(this.cloneNode(true));I=J.innerHTML}return o.clean([I.replace(/ jQuery\d+="(?:\d+|null)"/g,"").replace(/^\s*/,"")])[0]}else{return this.cloneNode(true)}});if(G===true){var H=this.find("*").andSelf(),F=0;E.find("*").andSelf().each(function(){if(this.nodeName!==H[F].nodeName){return}var I=o.data(H[F],"events");for(var K in I){for(var J in I[K]){o.event.add(this,K,I[K][J],I[K][J].data)}}F++})}return E},filter:function(E){return this.pushStack(o.isFunction(E)&&o.grep(this,function(G,F){return E.call(G,F)})||o.multiFilter(E,o.grep(this,function(F){return F.nodeType===1})),"filter",E)},closest:function(E){var G=o.expr.match.POS.test(E)?o(E):null,F=0;return this.map(function(){var H=this;while(H&&H.ownerDocument){if(G?G.index(H)>-1:o(H).is(E)){o.data(H,"closest",F);return H}H=H.parentNode;F++}})},not:function(E){if(typeof E==="string"){if(f.test(E)){return this.pushStack(o.multiFilter(E,this,true),"not",E)}else{E=o.multiFilter(E,this)}}var F=E.length&&E[E.length-1]!==g&&!E.nodeType;return this.filter(function(){return F?o.inArray(this,E)<0:this!=E})},add:function(E){return this.pushStack(o.unique(o.merge(this.get(),typeof E==="string"?o(E):o.makeArray(E))))},is:function(E){return !!E&&o.multiFilter(E,this).length>0},hasClass:function(E){return !!E&&this.is("."+E)},val:function(K){if(K===g){var E=this[0];if(E){if(o.nodeName(E,"option")){return(E.attributes.value||{}).specified?E.value:E.text}if(o.nodeName(E,"select")){var I=E.selectedIndex,L=[],M=E.options,H=E.type=="select-one";if(I<0){return null}for(var F=H?I:0,J=H?I+1:M.length;F=0||o.inArray(this.name,K)>=0)}else{if(o.nodeName(this,"select")){var N=o.makeArray(K);o("option",this).each(function(){this.selected=(o.inArray(this.value,N)>=0||o.inArray(this.text,N)>=0)});if(!N.length){this.selectedIndex=-1}}else{this.value=K}}})},html:function(E){return E===g?(this[0]?this[0].innerHTML.replace(/ jQuery\d+="(?:\d+|null)"/g,""):null):this.empty().append(E)},replaceWith:function(E){return this.after(E).remove()},eq:function(E){return this.slice(E,+E+1)},slice:function(){return this.pushStack(Array.prototype.slice.apply(this,arguments),"slice",Array.prototype.slice.call(arguments).join(","))},map:function(E){return this.pushStack(o.map(this,function(G,F){return E.call(G,F,G)}))},andSelf:function(){return this.add(this.prevObject)},domManip:function(J,M,L){if(this[0]){var I=(this[0].ownerDocument||this[0]).createDocumentFragment(),F=o.clean(J,(this[0].ownerDocument||this[0]),I),H=I.firstChild;if(H){for(var G=0,E=this.length;G1||G>0?I.cloneNode(true):I)}}if(F){o.each(F,z)}}return this;function K(N,O){return M&&o.nodeName(N,"table")&&o.nodeName(O,"tr")?(N.getElementsByTagName("tbody")[0]||N.appendChild(N.ownerDocument.createElement("tbody"))):N}}};o.fn.init.prototype=o.fn;function z(E,F){if(F.src){o.ajax({url:F.src,async:false,dataType:"script"})}else{o.globalEval(F.text||F.textContent||F.innerHTML||"")}if(F.parentNode){F.parentNode.removeChild(F)}}function e(){return +new Date}o.extend=o.fn.extend=function(){var J=arguments[0]||{},H=1,I=arguments.length,E=false,G;if(typeof J==="boolean"){E=J;J=arguments[1]||{};H=2}if(typeof J!=="object"&&!o.isFunction(J)){J={}}if(I==H){J=this;--H}for(;H-1}},swap:function(H,G,I){var E={};for(var F in G){E[F]=H.style[F];H.style[F]=G[F]}I.call(H);for(var F in G){H.style[F]=E[F]}},css:function(H,F,J,E){if(F=="width"||F=="height"){var L,G={position:"absolute",visibility:"hidden",display:"block"},K=F=="width"?["Left","Right"]:["Top","Bottom"];function I(){L=F=="width"?H.offsetWidth:H.offsetHeight;if(E==="border"){return}o.each(K,function(){if(!E){L-=parseFloat(o.curCSS(H,"padding"+this,true))||0}if(E==="margin"){L+=parseFloat(o.curCSS(H,"margin"+this,true))||0}else{L-=parseFloat(o.curCSS(H,"border"+this+"Width",true))||0}})}if(H.offsetWidth!==0){I()}else{o.swap(H,G,I)}return Math.max(0,Math.round(L))}return o.curCSS(H,F,J)},curCSS:function(I,F,G){var L,E=I.style;if(F=="opacity"&&!o.support.opacity){L=o.attr(E,"opacity");return L==""?"1":L}if(F.match(/float/i)){F=w}if(!G&&E&&E[F]){L=E[F]}else{if(q.getComputedStyle){if(F.match(/float/i)){F="float"}F=F.replace(/([A-Z])/g,"-$1").toLowerCase();var M=q.getComputedStyle(I,null);if(M){L=M.getPropertyValue(F)}if(F=="opacity"&&L==""){L="1"}}else{if(I.currentStyle){var J=F.replace(/\-(\w)/g,function(N,O){return O.toUpperCase()});L=I.currentStyle[F]||I.currentStyle[J];if(!/^\d+(px)?$/i.test(L)&&/^\d/.test(L)){var H=E.left,K=I.runtimeStyle.left;I.runtimeStyle.left=I.currentStyle.left;E.left=L||0;L=E.pixelLeft+"px";E.left=H;I.runtimeStyle.left=K}}}}return L},clean:function(F,K,I){K=K||document;if(typeof K.createElement==="undefined"){K=K.ownerDocument||K[0]&&K[0].ownerDocument||document}if(!I&&F.length===1&&typeof F[0]==="string"){var H=/^<(\w+)\s*\/?>$/.exec(F[0]);if(H){return[K.createElement(H[1])]}}var G=[],E=[],L=K.createElement("div");o.each(F,function(P,S){if(typeof S==="number"){S+=""}if(!S){return}if(typeof S==="string"){S=S.replace(/(<(\w+)[^>]*?)\/>/g,function(U,V,T){return T.match(/^(abbr|br|col|img|input|link|meta|param|hr|area|embed)$/i)?U:V+">"});var O=S.replace(/^\s+/,"").substring(0,10).toLowerCase();var Q=!O.indexOf("",""]||!O.indexOf("",""]||O.match(/^<(thead|tbody|tfoot|colg|cap)/)&&[1,"","
"]||!O.indexOf("",""]||(!O.indexOf("",""]||!O.indexOf("",""]||!o.support.htmlSerialize&&[1,"div
","
"]||[0,"",""];L.innerHTML=Q[1]+S+Q[2];while(Q[0]--){L=L.lastChild}if(!o.support.tbody){var R=/"&&!R?L.childNodes:[];for(var M=N.length-1;M>=0;--M){if(o.nodeName(N[M],"tbody")&&!N[M].childNodes.length){N[M].parentNode.removeChild(N[M])}}}if(!o.support.leadingWhitespace&&/^\s/.test(S)){L.insertBefore(K.createTextNode(S.match(/^\s*/)[0]),L.firstChild)}S=o.makeArray(L.childNodes)}if(S.nodeType){G.push(S)}else{G=o.merge(G,S)}});if(I){for(var J=0;G[J];J++){if(o.nodeName(G[J],"script")&&(!G[J].type||G[J].type.toLowerCase()==="text/javascript")){E.push(G[J].parentNode?G[J].parentNode.removeChild(G[J]):G[J])}else{if(G[J].nodeType===1){G.splice.apply(G,[J+1,0].concat(o.makeArray(G[J].getElementsByTagName("script"))))}I.appendChild(G[J])}}return E}return G},attr:function(J,G,K){if(!J||J.nodeType==3||J.nodeType==8){return g}var H=!o.isXMLDoc(J),L=K!==g;G=H&&o.props[G]||G;if(J.tagName){var F=/href|src|style/.test(G);if(G=="selected"&&J.parentNode){J.parentNode.selectedIndex}if(G in J&&H&&!F){if(L){if(G=="type"&&o.nodeName(J,"input")&&J.parentNode){throw"type property can't be changed"}J[G]=K}if(o.nodeName(J,"form")&&J.getAttributeNode(G)){return J.getAttributeNode(G).nodeValue}if(G=="tabIndex"){var I=J.getAttributeNode("tabIndex");return I&&I.specified?I.value:J.nodeName.match(/(button|input|object|select|textarea)/i)?0:J.nodeName.match(/^(a|area)$/i)&&J.href?0:g}return J[G]}if(!o.support.style&&H&&G=="style"){return o.attr(J.style,"cssText",K)}if(L){J.setAttribute(G,""+K)}var E=!o.support.hrefNormalized&&H&&F?J.getAttribute(G,2):J.getAttribute(G);return E===null?g:E}if(!o.support.opacity&&G=="opacity"){if(L){J.zoom=1;J.filter=(J.filter||"").replace(/alpha\([^)]*\)/,"")+(parseInt(K)+""=="NaN"?"":"alpha(opacity="+K*100+")")}return J.filter&&J.filter.indexOf("opacity=")>=0?(parseFloat(J.filter.match(/opacity=([^)]*)/)[1])/100)+"":""}G=G.replace(/-([a-z])/ig,function(M,N){return N.toUpperCase()});if(L){J[G]=K}return J[G]},trim:function(E){return(E||"").replace(/^\s+|\s+$/g,"")},makeArray:function(G){var E=[];if(G!=null){var F=G.length;if(F==null||typeof G==="string"||o.isFunction(G)||G.setInterval){E[0]=G}else{while(F){E[--F]=G[F]}}}return E},inArray:function(G,H){for(var E=0,F=H.length;E0?this.clone(true):this).get();o.fn[F].apply(o(L[K]),I);J=J.concat(I)}return this.pushStack(J,E,G)}});o.each({removeAttr:function(E){o.attr(this,E,"");if(this.nodeType==1){this.removeAttribute(E)}},addClass:function(E){o.className.add(this,E)},removeClass:function(E){o.className.remove(this,E)},toggleClass:function(F,E){if(typeof E!=="boolean"){E=!o.className.has(this,F)}o.className[E?"add":"remove"](this,F)},remove:function(E){if(!E||o.filter(E,[this]).length){o("*",this).add([this]).each(function(){o.event.remove(this);o.removeData(this)});if(this.parentNode){this.parentNode.removeChild(this)}}},empty:function(){o(this).children().remove();while(this.firstChild){this.removeChild(this.firstChild)}}},function(E,F){o.fn[E]=function(){return this.each(F,arguments)}});function j(E,F){return E[0]&&parseInt(o.curCSS(E[0],F,true),10)||0}var h="jQuery"+e(),v=0,A={};o.extend({cache:{},data:function(F,E,G){F=F==l?A:F;var H=F[h];if(!H){H=F[h]=++v}if(E&&!o.cache[H]){o.cache[H]={}}if(G!==g){o.cache[H][E]=G}return E?o.cache[H][E]:H},removeData:function(F,E){F=F==l?A:F;var H=F[h];if(E){if(o.cache[H]){delete o.cache[H][E];E="";for(E in o.cache[H]){break}if(!E){o.removeData(F)}}}else{try{delete F[h]}catch(G){if(F.removeAttribute){F.removeAttribute(h)}}delete o.cache[H]}},queue:function(F,E,H){if(F){E=(E||"fx")+"queue";var G=o.data(F,E);if(!G||o.isArray(H)){G=o.data(F,E,o.makeArray(H))}else{if(H){G.push(H)}}}return G},dequeue:function(H,G){var E=o.queue(H,G),F=E.shift();if(!G||G==="fx"){F=E[0]}if(F!==g){F.call(H)}}});o.fn.extend({data:function(E,G){var H=E.split(".");H[1]=H[1]?"."+H[1]:"";if(G===g){var F=this.triggerHandler("getData"+H[1]+"!",[H[0]]);if(F===g&&this.length){F=o.data(this[0],E)}return F===g&&H[1]?this.data(H[0]):F}else{return this.trigger("setData"+H[1]+"!",[H[0],G]).each(function(){o.data(this,E,G)})}},removeData:function(E){return this.each(function(){o.removeData(this,E)})},queue:function(E,F){if(typeof E!=="string"){F=E;E="fx"}if(F===g){return o.queue(this[0],E)}return this.each(function(){var G=o.queue(this,E,F);if(E=="fx"&&G.length==1){G[0].call(this)}})},dequeue:function(E){return this.each(function(){o.dequeue(this,E)})}}); +/* + * Sizzle CSS Selector Engine - v0.9.3 + * Copyright 2009, The Dojo Foundation + * Released under the MIT, BSD, and GPL Licenses. + * More information: http://sizzlejs.com/ + */ +(function(){var R=/((?:\((?:\([^()]+\)|[^()]+)+\)|\[(?:\[[^[\]]*\]|['"][^'"]*['"]|[^[\]'"]+)+\]|\\.|[^ >+~,(\[\\]+)+|[>+~])(\s*,\s*)?/g,L=0,H=Object.prototype.toString;var F=function(Y,U,ab,ac){ab=ab||[];U=U||document;if(U.nodeType!==1&&U.nodeType!==9){return[]}if(!Y||typeof Y!=="string"){return ab}var Z=[],W,af,ai,T,ad,V,X=true;R.lastIndex=0;while((W=R.exec(Y))!==null){Z.push(W[1]);if(W[2]){V=RegExp.rightContext;break}}if(Z.length>1&&M.exec(Y)){if(Z.length===2&&I.relative[Z[0]]){af=J(Z[0]+Z[1],U)}else{af=I.relative[Z[0]]?[U]:F(Z.shift(),U);while(Z.length){Y=Z.shift();if(I.relative[Y]){Y+=Z.shift()}af=J(Y,af)}}}else{var ae=ac?{expr:Z.pop(),set:E(ac)}:F.find(Z.pop(),Z.length===1&&U.parentNode?U.parentNode:U,Q(U));af=F.filter(ae.expr,ae.set);if(Z.length>0){ai=E(af)}else{X=false}while(Z.length){var ah=Z.pop(),ag=ah;if(!I.relative[ah]){ah=""}else{ag=Z.pop()}if(ag==null){ag=U}I.relative[ah](ai,ag,Q(U))}}if(!ai){ai=af}if(!ai){throw"Syntax error, unrecognized expression: "+(ah||Y)}if(H.call(ai)==="[object Array]"){if(!X){ab.push.apply(ab,ai)}else{if(U.nodeType===1){for(var aa=0;ai[aa]!=null;aa++){if(ai[aa]&&(ai[aa]===true||ai[aa].nodeType===1&&K(U,ai[aa]))){ab.push(af[aa])}}}else{for(var aa=0;ai[aa]!=null;aa++){if(ai[aa]&&ai[aa].nodeType===1){ab.push(af[aa])}}}}}else{E(ai,ab)}if(V){F(V,U,ab,ac);if(G){hasDuplicate=false;ab.sort(G);if(hasDuplicate){for(var aa=1;aa":function(Z,U,aa){var X=typeof U==="string";if(X&&!/\W/.test(U)){U=aa?U:U.toUpperCase();for(var V=0,T=Z.length;V=0)){if(!V){T.push(Y)}}else{if(V){U[X]=false}}}}return false},ID:function(T){return T[1].replace(/\\/g,"")},TAG:function(U,T){for(var V=0;T[V]===false;V++){}return T[V]&&Q(T[V])?U[1]:U[1].toUpperCase()},CHILD:function(T){if(T[1]=="nth"){var U=/(-?)(\d*)n((?:\+|-)?\d*)/.exec(T[2]=="even"&&"2n"||T[2]=="odd"&&"2n+1"||!/\D/.test(T[2])&&"0n+"+T[2]||T[2]);T[2]=(U[1]+(U[2]||1))-0;T[3]=U[3]-0}T[0]=L++;return T},ATTR:function(X,U,V,T,Y,Z){var W=X[1].replace(/\\/g,"");if(!Z&&I.attrMap[W]){X[1]=I.attrMap[W]}if(X[2]==="~="){X[4]=" "+X[4]+" "}return X},PSEUDO:function(X,U,V,T,Y){if(X[1]==="not"){if(X[3].match(R).length>1||/^\w/.test(X[3])){X[3]=F(X[3],null,null,U)}else{var W=F.filter(X[3],U,V,true^Y);if(!V){T.push.apply(T,W)}return false}}else{if(I.match.POS.test(X[0])||I.match.CHILD.test(X[0])){return true}}return X},POS:function(T){T.unshift(true);return T}},filters:{enabled:function(T){return T.disabled===false&&T.type!=="hidden"},disabled:function(T){return T.disabled===true},checked:function(T){return T.checked===true},selected:function(T){T.parentNode.selectedIndex;return T.selected===true},parent:function(T){return !!T.firstChild},empty:function(T){return !T.firstChild},has:function(V,U,T){return !!F(T[3],V).length},header:function(T){return/h\d/i.test(T.nodeName)},text:function(T){return"text"===T.type},radio:function(T){return"radio"===T.type},checkbox:function(T){return"checkbox"===T.type},file:function(T){return"file"===T.type},password:function(T){return"password"===T.type},submit:function(T){return"submit"===T.type},image:function(T){return"image"===T.type},reset:function(T){return"reset"===T.type},button:function(T){return"button"===T.type||T.nodeName.toUpperCase()==="BUTTON"},input:function(T){return/input|select|textarea|button/i.test(T.nodeName)}},setFilters:{first:function(U,T){return T===0},last:function(V,U,T,W){return U===W.length-1},even:function(U,T){return T%2===0},odd:function(U,T){return T%2===1},lt:function(V,U,T){return UT[3]-0},nth:function(V,U,T){return T[3]-0==U},eq:function(V,U,T){return T[3]-0==U}},filter:{PSEUDO:function(Z,V,W,aa){var U=V[1],X=I.filters[U];if(X){return X(Z,W,V,aa)}else{if(U==="contains"){return(Z.textContent||Z.innerText||"").indexOf(V[3])>=0}else{if(U==="not"){var Y=V[3];for(var W=0,T=Y.length;W=0)}}},ID:function(U,T){return U.nodeType===1&&U.getAttribute("id")===T},TAG:function(U,T){return(T==="*"&&U.nodeType===1)||U.nodeName===T},CLASS:function(U,T){return(" "+(U.className||U.getAttribute("class"))+" ").indexOf(T)>-1},ATTR:function(Y,W){var V=W[1],T=I.attrHandle[V]?I.attrHandle[V](Y):Y[V]!=null?Y[V]:Y.getAttribute(V),Z=T+"",X=W[2],U=W[4];return T==null?X==="!=":X==="="?Z===U:X==="*="?Z.indexOf(U)>=0:X==="~="?(" "+Z+" ").indexOf(U)>=0:!U?Z&&T!==false:X==="!="?Z!=U:X==="^="?Z.indexOf(U)===0:X==="$="?Z.substr(Z.length-U.length)===U:X==="|="?Z===U||Z.substr(0,U.length+1)===U+"-":false},POS:function(X,U,V,Y){var T=U[2],W=I.setFilters[T];if(W){return W(X,V,U,Y)}}}};var M=I.match.POS;for(var O in I.match){I.match[O]=RegExp(I.match[O].source+/(?![^\[]*\])(?![^\(]*\))/.source)}var E=function(U,T){U=Array.prototype.slice.call(U);if(T){T.push.apply(T,U);return T}return U};try{Array.prototype.slice.call(document.documentElement.childNodes)}catch(N){E=function(X,W){var U=W||[];if(H.call(X)==="[object Array]"){Array.prototype.push.apply(U,X)}else{if(typeof X.length==="number"){for(var V=0,T=X.length;V";var T=document.documentElement;T.insertBefore(U,T.firstChild);if(!!document.getElementById(V)){I.find.ID=function(X,Y,Z){if(typeof Y.getElementById!=="undefined"&&!Z){var W=Y.getElementById(X[1]);return W?W.id===X[1]||typeof W.getAttributeNode!=="undefined"&&W.getAttributeNode("id").nodeValue===X[1]?[W]:g:[]}};I.filter.ID=function(Y,W){var X=typeof Y.getAttributeNode!=="undefined"&&Y.getAttributeNode("id");return Y.nodeType===1&&X&&X.nodeValue===W}}T.removeChild(U)})();(function(){var T=document.createElement("div");T.appendChild(document.createComment(""));if(T.getElementsByTagName("*").length>0){I.find.TAG=function(U,Y){var X=Y.getElementsByTagName(U[1]);if(U[1]==="*"){var W=[];for(var V=0;X[V];V++){if(X[V].nodeType===1){W.push(X[V])}}X=W}return X}}T.innerHTML="";if(T.firstChild&&typeof T.firstChild.getAttribute!=="undefined"&&T.firstChild.getAttribute("href")!=="#"){I.attrHandle.href=function(U){return U.getAttribute("href",2)}}})();if(document.querySelectorAll){(function(){var T=F,U=document.createElement("div");U.innerHTML="

";if(U.querySelectorAll&&U.querySelectorAll(".TEST").length===0){return}F=function(Y,X,V,W){X=X||document;if(!W&&X.nodeType===9&&!Q(X)){try{return E(X.querySelectorAll(Y),V)}catch(Z){}}return T(Y,X,V,W)};F.find=T.find;F.filter=T.filter;F.selectors=T.selectors;F.matches=T.matches})()}if(document.getElementsByClassName&&document.documentElement.getElementsByClassName){(function(){var T=document.createElement("div");T.innerHTML="
";if(T.getElementsByClassName("e").length===0){return}T.lastChild.className="e";if(T.getElementsByClassName("e").length===1){return}I.order.splice(1,0,"CLASS");I.find.CLASS=function(U,V,W){if(typeof V.getElementsByClassName!=="undefined"&&!W){return V.getElementsByClassName(U[1])}}})()}function P(U,Z,Y,ad,aa,ac){var ab=U=="previousSibling"&&!ac;for(var W=0,V=ad.length;W0){X=T;break}}}T=T[U]}ad[W]=X}}}var K=document.compareDocumentPosition?function(U,T){return U.compareDocumentPosition(T)&16}:function(U,T){return U!==T&&(U.contains?U.contains(T):true)};var Q=function(T){return T.nodeType===9&&T.documentElement.nodeName!=="HTML"||!!T.ownerDocument&&Q(T.ownerDocument)};var J=function(T,aa){var W=[],X="",Y,V=aa.nodeType?[aa]:aa;while((Y=I.match.PSEUDO.exec(T))){X+=Y[0];T=T.replace(I.match.PSEUDO,"")}T=I.relative[T]?T+"*":T;for(var Z=0,U=V.length;Z0||T.offsetHeight>0};F.selectors.filters.animated=function(T){return o.grep(o.timers,function(U){return T===U.elem}).length};o.multiFilter=function(V,T,U){if(U){V=":not("+V+")"}return F.matches(V,T)};o.dir=function(V,U){var T=[],W=V[U];while(W&&W!=document){if(W.nodeType==1){T.push(W)}W=W[U]}return T};o.nth=function(X,T,V,W){T=T||1;var U=0;for(;X;X=X[V]){if(X.nodeType==1&&++U==T){break}}return X};o.sibling=function(V,U){var T=[];for(;V;V=V.nextSibling){if(V.nodeType==1&&V!=U){T.push(V)}}return T};return;l.Sizzle=F})();o.event={add:function(I,F,H,K){if(I.nodeType==3||I.nodeType==8){return}if(I.setInterval&&I!=l){I=l}if(!H.guid){H.guid=this.guid++}if(K!==g){var G=H;H=this.proxy(G);H.data=K}var E=o.data(I,"events")||o.data(I,"events",{}),J=o.data(I,"handle")||o.data(I,"handle",function(){return typeof o!=="undefined"&&!o.event.triggered?o.event.handle.apply(arguments.callee.elem,arguments):g});J.elem=I;o.each(F.split(/\s+/),function(M,N){var O=N.split(".");N=O.shift();H.type=O.slice().sort().join(".");var L=E[N];if(o.event.specialAll[N]){o.event.specialAll[N].setup.call(I,K,O)}if(!L){L=E[N]={};if(!o.event.special[N]||o.event.special[N].setup.call(I,K,O)===false){if(I.addEventListener){I.addEventListener(N,J,false)}else{if(I.attachEvent){I.attachEvent("on"+N,J)}}}}L[H.guid]=H;o.event.global[N]=true});I=null},guid:1,global:{},remove:function(K,H,J){if(K.nodeType==3||K.nodeType==8){return}var G=o.data(K,"events"),F,E;if(G){if(H===g||(typeof H==="string"&&H.charAt(0)==".")){for(var I in G){this.remove(K,I+(H||""))}}else{if(H.type){J=H.handler;H=H.type}o.each(H.split(/\s+/),function(M,O){var Q=O.split(".");O=Q.shift();var N=RegExp("(^|\\.)"+Q.slice().sort().join(".*\\.")+"(\\.|$)");if(G[O]){if(J){delete G[O][J.guid]}else{for(var P in G[O]){if(N.test(G[O][P].type)){delete G[O][P]}}}if(o.event.specialAll[O]){o.event.specialAll[O].teardown.call(K,Q)}for(F in G[O]){break}if(!F){if(!o.event.special[O]||o.event.special[O].teardown.call(K,Q)===false){if(K.removeEventListener){K.removeEventListener(O,o.data(K,"handle"),false)}else{if(K.detachEvent){K.detachEvent("on"+O,o.data(K,"handle"))}}}F=null;delete G[O]}}})}for(F in G){break}if(!F){var L=o.data(K,"handle");if(L){L.elem=null}o.removeData(K,"events");o.removeData(K,"handle")}}},trigger:function(I,K,H,E){var G=I.type||I;if(!E){I=typeof I==="object"?I[h]?I:o.extend(o.Event(G),I):o.Event(G);if(G.indexOf("!")>=0){I.type=G=G.slice(0,-1);I.exclusive=true}if(!H){I.stopPropagation();if(this.global[G]){o.each(o.cache,function(){if(this.events&&this.events[G]){o.event.trigger(I,K,this.handle.elem)}})}}if(!H||H.nodeType==3||H.nodeType==8){return g}I.result=g;I.target=H;K=o.makeArray(K);K.unshift(I)}I.currentTarget=H;var J=o.data(H,"handle");if(J){J.apply(H,K)}if((!H[G]||(o.nodeName(H,"a")&&G=="click"))&&H["on"+G]&&H["on"+G].apply(H,K)===false){I.result=false}if(!E&&H[G]&&!I.isDefaultPrevented()&&!(o.nodeName(H,"a")&&G=="click")){this.triggered=true;try{H[G]()}catch(L){}}this.triggered=false;if(!I.isPropagationStopped()){var F=H.parentNode||H.ownerDocument;if(F){o.event.trigger(I,K,F,true)}}},handle:function(K){var J,E;K=arguments[0]=o.event.fix(K||l.event);K.currentTarget=this;var L=K.type.split(".");K.type=L.shift();J=!L.length&&!K.exclusive;var I=RegExp("(^|\\.)"+L.slice().sort().join(".*\\.")+"(\\.|$)");E=(o.data(this,"events")||{})[K.type];for(var G in E){var H=E[G];if(J||I.test(H.type)){K.handler=H;K.data=H.data;var F=H.apply(this,arguments);if(F!==g){K.result=F;if(F===false){K.preventDefault();K.stopPropagation()}}if(K.isImmediatePropagationStopped()){break}}}},props:"altKey attrChange attrName bubbles button cancelable charCode clientX clientY ctrlKey currentTarget data detail eventPhase fromElement handler keyCode metaKey newValue originalTarget pageX pageY prevValue relatedNode relatedTarget screenX screenY shiftKey srcElement target toElement view wheelDelta which".split(" "),fix:function(H){if(H[h]){return H}var F=H;H=o.Event(F);for(var G=this.props.length,J;G;){J=this.props[--G];H[J]=F[J]}if(!H.target){H.target=H.srcElement||document}if(H.target.nodeType==3){H.target=H.target.parentNode}if(!H.relatedTarget&&H.fromElement){H.relatedTarget=H.fromElement==H.target?H.toElement:H.fromElement}if(H.pageX==null&&H.clientX!=null){var I=document.documentElement,E=document.body;H.pageX=H.clientX+(I&&I.scrollLeft||E&&E.scrollLeft||0)-(I.clientLeft||0);H.pageY=H.clientY+(I&&I.scrollTop||E&&E.scrollTop||0)-(I.clientTop||0)}if(!H.which&&((H.charCode||H.charCode===0)?H.charCode:H.keyCode)){H.which=H.charCode||H.keyCode}if(!H.metaKey&&H.ctrlKey){H.metaKey=H.ctrlKey}if(!H.which&&H.button){H.which=(H.button&1?1:(H.button&2?3:(H.button&4?2:0)))}return H},proxy:function(F,E){E=E||function(){return F.apply(this,arguments)};E.guid=F.guid=F.guid||E.guid||this.guid++;return E},special:{ready:{setup:B,teardown:function(){}}},specialAll:{live:{setup:function(E,F){o.event.add(this,F[0],c)},teardown:function(G){if(G.length){var E=0,F=RegExp("(^|\\.)"+G[0]+"(\\.|$)");o.each((o.data(this,"events").live||{}),function(){if(F.test(this.type)){E++}});if(E<1){o.event.remove(this,G[0],c)}}}}}};o.Event=function(E){if(!this.preventDefault){return new o.Event(E)}if(E&&E.type){this.originalEvent=E;this.type=E.type}else{this.type=E}this.timeStamp=e();this[h]=true};function k(){return false}function u(){return true}o.Event.prototype={preventDefault:function(){this.isDefaultPrevented=u;var E=this.originalEvent;if(!E){return}if(E.preventDefault){E.preventDefault()}E.returnValue=false},stopPropagation:function(){this.isPropagationStopped=u;var E=this.originalEvent;if(!E){return}if(E.stopPropagation){E.stopPropagation()}E.cancelBubble=true},stopImmediatePropagation:function(){this.isImmediatePropagationStopped=u;this.stopPropagation()},isDefaultPrevented:k,isPropagationStopped:k,isImmediatePropagationStopped:k};var a=function(F){var E=F.relatedTarget;while(E&&E!=this){try{E=E.parentNode}catch(G){E=this}}if(E!=this){F.type=F.data;o.event.handle.apply(this,arguments)}};o.each({mouseover:"mouseenter",mouseout:"mouseleave"},function(F,E){o.event.special[E]={setup:function(){o.event.add(this,F,a,E)},teardown:function(){o.event.remove(this,F,a)}}});o.fn.extend({bind:function(F,G,E){return F=="unload"?this.one(F,G,E):this.each(function(){o.event.add(this,F,E||G,E&&G)})},one:function(G,H,F){var E=o.event.proxy(F||H,function(I){o(this).unbind(I,E);return(F||H).apply(this,arguments)});return this.each(function(){o.event.add(this,G,E,F&&H)})},unbind:function(F,E){return this.each(function(){o.event.remove(this,F,E)})},trigger:function(E,F){return this.each(function(){o.event.trigger(E,F,this)})},triggerHandler:function(E,G){if(this[0]){var F=o.Event(E);F.preventDefault();F.stopPropagation();o.event.trigger(F,G,this[0]);return F.result}},toggle:function(G){var E=arguments,F=1;while(F=0){var E=G.slice(I,G.length);G=G.slice(0,I)}var H="GET";if(J){if(o.isFunction(J)){K=J;J=null}else{if(typeof J==="object"){J=o.param(J);H="POST"}}}var F=this;o.ajax({url:G,type:H,dataType:"html",data:J,complete:function(M,L){if(L=="success"||L=="notmodified"){F.html(E?o("
").append(M.responseText.replace(//g,"")).find(E):M.responseText)}if(K){F.each(K,[M.responseText,L,M])}}});return this},serialize:function(){return o.param(this.serializeArray())},serializeArray:function(){return this.map(function(){return this.elements?o.makeArray(this.elements):this}).filter(function(){return this.name&&!this.disabled&&(this.checked||/select|textarea/i.test(this.nodeName)||/text|hidden|password|search/i.test(this.type))}).map(function(E,F){var G=o(this).val();return G==null?null:o.isArray(G)?o.map(G,function(I,H){return{name:F.name,value:I}}):{name:F.name,value:G}}).get()}});o.each("ajaxStart,ajaxStop,ajaxComplete,ajaxError,ajaxSuccess,ajaxSend".split(","),function(E,F){o.fn[F]=function(G){return this.bind(F,G)}});var r=e();o.extend({get:function(E,G,H,F){if(o.isFunction(G)){H=G;G=null}return o.ajax({type:"GET",url:E,data:G,success:H,dataType:F})},getScript:function(E,F){return o.get(E,null,F,"script")},getJSON:function(E,F,G){return o.get(E,F,G,"json")},post:function(E,G,H,F){if(o.isFunction(G)){H=G;G={}}return o.ajax({type:"POST",url:E,data:G,success:H,dataType:F})},ajaxSetup:function(E){o.extend(o.ajaxSettings,E)},ajaxSettings:{url:location.href,global:true,type:"GET",contentType:"application/x-www-form-urlencoded",processData:true,async:true,xhr:function(){return l.ActiveXObject?new ActiveXObject("Microsoft.XMLHTTP"):new XMLHttpRequest()},accepts:{xml:"application/xml, text/xml",html:"text/html",script:"text/javascript, application/javascript",json:"application/json, text/javascript",text:"text/plain",_default:"*/*"}},lastModified:{},ajax:function(M){M=o.extend(true,M,o.extend(true,{},o.ajaxSettings,M));var W,F=/=\?(&|$)/g,R,V,G=M.type.toUpperCase();if(M.data&&M.processData&&typeof M.data!=="string"){M.data=o.param(M.data)}if(M.dataType=="jsonp"){if(G=="GET"){if(!M.url.match(F)){M.url+=(M.url.match(/\?/)?"&":"?")+(M.jsonp||"callback")+"=?"}}else{if(!M.data||!M.data.match(F)){M.data=(M.data?M.data+"&":"")+(M.jsonp||"callback")+"=?"}}M.dataType="json"}if(M.dataType=="json"&&(M.data&&M.data.match(F)||M.url.match(F))){W="jsonp"+r++;if(M.data){M.data=(M.data+"").replace(F,"="+W+"$1")}M.url=M.url.replace(F,"="+W+"$1");M.dataType="script";l[W]=function(X){V=X;I();L();l[W]=g;try{delete l[W]}catch(Y){}if(H){H.removeChild(T)}}}if(M.dataType=="script"&&M.cache==null){M.cache=false}if(M.cache===false&&G=="GET"){var E=e();var U=M.url.replace(/(\?|&)_=.*?(&|$)/,"$1_="+E+"$2");M.url=U+((U==M.url)?(M.url.match(/\?/)?"&":"?")+"_="+E:"")}if(M.data&&G=="GET"){M.url+=(M.url.match(/\?/)?"&":"?")+M.data;M.data=null}if(M.global&&!o.active++){o.event.trigger("ajaxStart")}var Q=/^(\w+:)?\/\/([^\/?#]+)/.exec(M.url);if(M.dataType=="script"&&G=="GET"&&Q&&(Q[1]&&Q[1]!=location.protocol||Q[2]!=location.host)){var H=document.getElementsByTagName("head")[0];var T=document.createElement("script");T.src=M.url;if(M.scriptCharset){T.charset=M.scriptCharset}if(!W){var O=false;T.onload=T.onreadystatechange=function(){if(!O&&(!this.readyState||this.readyState=="loaded"||this.readyState=="complete")){O=true;I();L();T.onload=T.onreadystatechange=null;H.removeChild(T)}}}H.appendChild(T);return g}var K=false;var J=M.xhr();if(M.username){J.open(G,M.url,M.async,M.username,M.password)}else{J.open(G,M.url,M.async)}try{if(M.data){J.setRequestHeader("Content-Type",M.contentType)}if(M.ifModified){J.setRequestHeader("If-Modified-Since",o.lastModified[M.url]||"Thu, 01 Jan 1970 00:00:00 GMT")}J.setRequestHeader("X-Requested-With","XMLHttpRequest");J.setRequestHeader("Accept",M.dataType&&M.accepts[M.dataType]?M.accepts[M.dataType]+", */*":M.accepts._default)}catch(S){}if(M.beforeSend&&M.beforeSend(J,M)===false){if(M.global&&!--o.active){o.event.trigger("ajaxStop")}J.abort();return false}if(M.global){o.event.trigger("ajaxSend",[J,M])}var N=function(X){if(J.readyState==0){if(P){clearInterval(P);P=null;if(M.global&&!--o.active){o.event.trigger("ajaxStop")}}}else{if(!K&&J&&(J.readyState==4||X=="timeout")){K=true;if(P){clearInterval(P);P=null}R=X=="timeout"?"timeout":!o.httpSuccess(J)?"error":M.ifModified&&o.httpNotModified(J,M.url)?"notmodified":"success";if(R=="success"){try{V=o.httpData(J,M.dataType,M)}catch(Z){R="parsererror"}}if(R=="success"){var Y;try{Y=J.getResponseHeader("Last-Modified")}catch(Z){}if(M.ifModified&&Y){o.lastModified[M.url]=Y}if(!W){I()}}else{o.handleError(M,J,R)}L();if(X){J.abort()}if(M.async){J=null}}}};if(M.async){var P=setInterval(N,13);if(M.timeout>0){setTimeout(function(){if(J&&!K){N("timeout")}},M.timeout)}}try{J.send(M.data)}catch(S){o.handleError(M,J,null,S)}if(!M.async){N()}function I(){if(M.success){M.success(V,R)}if(M.global){o.event.trigger("ajaxSuccess",[J,M])}}function L(){if(M.complete){M.complete(J,R)}if(M.global){o.event.trigger("ajaxComplete",[J,M])}if(M.global&&!--o.active){o.event.trigger("ajaxStop")}}return J},handleError:function(F,H,E,G){if(F.error){F.error(H,E,G)}if(F.global){o.event.trigger("ajaxError",[H,F,G])}},active:0,httpSuccess:function(F){try{return !F.status&&location.protocol=="file:"||(F.status>=200&&F.status<300)||F.status==304||F.status==1223}catch(E){}return false},httpNotModified:function(G,E){try{var H=G.getResponseHeader("Last-Modified");return G.status==304||H==o.lastModified[E]}catch(F){}return false},httpData:function(J,H,G){var F=J.getResponseHeader("content-type"),E=H=="xml"||!H&&F&&F.indexOf("xml")>=0,I=E?J.responseXML:J.responseText;if(E&&I.documentElement.tagName=="parsererror"){throw"parsererror"}if(G&&G.dataFilter){I=G.dataFilter(I,H)}if(typeof I==="string"){if(H=="script"){o.globalEval(I)}if(H=="json"){I=l["eval"]("("+I+")")}}return I},param:function(E){var G=[];function H(I,J){G[G.length]=encodeURIComponent(I)+"="+encodeURIComponent(J)}if(o.isArray(E)||E.jquery){o.each(E,function(){H(this.name,this.value)})}else{for(var F in E){if(o.isArray(E[F])){o.each(E[F],function(){H(F,this)})}else{H(F,o.isFunction(E[F])?E[F]():E[F])}}}return G.join("&").replace(/%20/g,"+")}});var m={},n,d=[["height","marginTop","marginBottom","paddingTop","paddingBottom"],["width","marginLeft","marginRight","paddingLeft","paddingRight"],["opacity"]];function t(F,E){var G={};o.each(d.concat.apply([],d.slice(0,E)),function(){G[this]=F});return G}o.fn.extend({show:function(J,L){if(J){return this.animate(t("show",3),J,L)}else{for(var H=0,F=this.length;H").appendTo("body");K=I.css("display");if(K==="none"){K="block"}I.remove();m[G]=K}o.data(this[H],"olddisplay",K)}}for(var H=0,F=this.length;H=0;H--){if(G[H].elem==this){if(E){G[H](true)}G.splice(H,1)}}});if(!E){this.dequeue()}return this}});o.each({slideDown:t("show",1),slideUp:t("hide",1),slideToggle:t("toggle",1),fadeIn:{opacity:"show"},fadeOut:{opacity:"hide"}},function(E,F){o.fn[E]=function(G,H){return this.animate(F,G,H)}});o.extend({speed:function(G,H,F){var E=typeof G==="object"?G:{complete:F||!F&&H||o.isFunction(G)&&G,duration:G,easing:F&&H||H&&!o.isFunction(H)&&H};E.duration=o.fx.off?0:typeof E.duration==="number"?E.duration:o.fx.speeds[E.duration]||o.fx.speeds._default;E.old=E.complete;E.complete=function(){if(E.queue!==false){o(this).dequeue()}if(o.isFunction(E.old)){E.old.call(this)}};return E},easing:{linear:function(G,H,E,F){return E+F*G},swing:function(G,H,E,F){return((-Math.cos(G*Math.PI)/2)+0.5)*F+E}},timers:[],fx:function(F,E,G){this.options=E;this.elem=F;this.prop=G;if(!E.orig){E.orig={}}}});o.fx.prototype={update:function(){if(this.options.step){this.options.step.call(this.elem,this.now,this)}(o.fx.step[this.prop]||o.fx.step._default)(this);if((this.prop=="height"||this.prop=="width")&&this.elem.style){this.elem.style.display="block"}},cur:function(F){if(this.elem[this.prop]!=null&&(!this.elem.style||this.elem.style[this.prop]==null)){return this.elem[this.prop]}var E=parseFloat(o.css(this.elem,this.prop,F));return E&&E>-10000?E:parseFloat(o.curCSS(this.elem,this.prop))||0},custom:function(I,H,G){this.startTime=e();this.start=I;this.end=H;this.unit=G||this.unit||"px";this.now=this.start;this.pos=this.state=0;var E=this;function F(J){return E.step(J)}F.elem=this.elem;if(F()&&o.timers.push(F)&&!n){n=setInterval(function(){var K=o.timers;for(var J=0;J=this.options.duration+this.startTime){this.now=this.end;this.pos=this.state=1;this.update();this.options.curAnim[this.prop]=true;var E=true;for(var F in this.options.curAnim){if(this.options.curAnim[F]!==true){E=false}}if(E){if(this.options.display!=null){this.elem.style.overflow=this.options.overflow;this.elem.style.display=this.options.display;if(o.css(this.elem,"display")=="none"){this.elem.style.display="block"}}if(this.options.hide){o(this.elem).hide()}if(this.options.hide||this.options.show){for(var I in this.options.curAnim){o.attr(this.elem.style,I,this.options.orig[I])}}this.options.complete.call(this.elem)}return false}else{var J=G-this.startTime;this.state=J/this.options.duration;this.pos=o.easing[this.options.easing||(o.easing.swing?"swing":"linear")](this.state,J,0,1,this.options.duration);this.now=this.start+((this.end-this.start)*this.pos);this.update()}return true}};o.extend(o.fx,{speeds:{slow:600,fast:200,_default:400},step:{opacity:function(E){o.attr(E.elem.style,"opacity",E.now)},_default:function(E){if(E.elem.style&&E.elem.style[E.prop]!=null){E.elem.style[E.prop]=E.now+E.unit}else{E.elem[E.prop]=E.now}}}});if(document.documentElement.getBoundingClientRect){o.fn.offset=function(){if(!this[0]){return{top:0,left:0}}if(this[0]===this[0].ownerDocument.body){return o.offset.bodyOffset(this[0])}var G=this[0].getBoundingClientRect(),J=this[0].ownerDocument,F=J.body,E=J.documentElement,L=E.clientTop||F.clientTop||0,K=E.clientLeft||F.clientLeft||0,I=G.top+(self.pageYOffset||o.boxModel&&E.scrollTop||F.scrollTop)-L,H=G.left+(self.pageXOffset||o.boxModel&&E.scrollLeft||F.scrollLeft)-K;return{top:I,left:H}}}else{o.fn.offset=function(){if(!this[0]){return{top:0,left:0}}if(this[0]===this[0].ownerDocument.body){return o.offset.bodyOffset(this[0])}o.offset.initialized||o.offset.initialize();var J=this[0],G=J.offsetParent,F=J,O=J.ownerDocument,M,H=O.documentElement,K=O.body,L=O.defaultView,E=L.getComputedStyle(J,null),N=J.offsetTop,I=J.offsetLeft;while((J=J.parentNode)&&J!==K&&J!==H){M=L.getComputedStyle(J,null);N-=J.scrollTop,I-=J.scrollLeft;if(J===G){N+=J.offsetTop,I+=J.offsetLeft;if(o.offset.doesNotAddBorder&&!(o.offset.doesAddBorderForTableAndCells&&/^t(able|d|h)$/i.test(J.tagName))){N+=parseInt(M.borderTopWidth,10)||0,I+=parseInt(M.borderLeftWidth,10)||0}F=G,G=J.offsetParent}if(o.offset.subtractsBorderForOverflowNotVisible&&M.overflow!=="visible"){N+=parseInt(M.borderTopWidth,10)||0,I+=parseInt(M.borderLeftWidth,10)||0}E=M}if(E.position==="relative"||E.position==="static"){N+=K.offsetTop,I+=K.offsetLeft}if(E.position==="fixed"){N+=Math.max(H.scrollTop,K.scrollTop),I+=Math.max(H.scrollLeft,K.scrollLeft)}return{top:N,left:I}}}o.offset={initialize:function(){if(this.initialized){return}var L=document.body,F=document.createElement("div"),H,G,N,I,M,E,J=L.style.marginTop,K='
';M={position:"absolute",top:0,left:0,margin:0,border:0,width:"1px",height:"1px",visibility:"hidden"};for(E in M){F.style[E]=M[E]}F.innerHTML=K;L.insertBefore(F,L.firstChild);H=F.firstChild,G=H.firstChild,I=H.nextSibling.firstChild.firstChild;this.doesNotAddBorder=(G.offsetTop!==5);this.doesAddBorderForTableAndCells=(I.offsetTop===5);H.style.overflow="hidden",H.style.position="relative";this.subtractsBorderForOverflowNotVisible=(G.offsetTop===-5);L.style.marginTop="1px";this.doesNotIncludeMarginInBodyOffset=(L.offsetTop===0);L.style.marginTop=J;L.removeChild(F);this.initialized=true},bodyOffset:function(E){o.offset.initialized||o.offset.initialize();var G=E.offsetTop,F=E.offsetLeft;if(o.offset.doesNotIncludeMarginInBodyOffset){G+=parseInt(o.curCSS(E,"marginTop",true),10)||0,F+=parseInt(o.curCSS(E,"marginLeft",true),10)||0}return{top:G,left:F}}};o.fn.extend({position:function(){var I=0,H=0,F;if(this[0]){var G=this.offsetParent(),J=this.offset(),E=/^body|html$/i.test(G[0].tagName)?{top:0,left:0}:G.offset();J.top-=j(this,"marginTop");J.left-=j(this,"marginLeft");E.top+=j(G,"borderTopWidth");E.left+=j(G,"borderLeftWidth");F={top:J.top-E.top,left:J.left-E.left}}return F},offsetParent:function(){var E=this[0].offsetParent||document.body;while(E&&(!/^body|html$/i.test(E.tagName)&&o.css(E,"position")=="static")){E=E.offsetParent}return o(E)}});o.each(["Left","Top"],function(F,E){var G="scroll"+E;o.fn[G]=function(H){if(!this[0]){return null}return H!==g?this.each(function(){this==l||this==document?l.scrollTo(!F?H:o(l).scrollLeft(),F?H:o(l).scrollTop()):this[G]=H}):this[0]==l||this[0]==document?self[F?"pageYOffset":"pageXOffset"]||o.boxModel&&document.documentElement[G]||document.body[G]:this[0][G]}});o.each(["Height","Width"],function(I,G){var E=I?"Left":"Top",H=I?"Right":"Bottom",F=G.toLowerCase();o.fn["inner"+G]=function(){return this[0]?o.css(this[0],F,false,"padding"):null};o.fn["outer"+G]=function(K){return this[0]?o.css(this[0],F,false,K?"margin":"border"):null};var J=G.toLowerCase();o.fn[J]=function(K){return this[0]==l?document.compatMode=="CSS1Compat"&&document.documentElement["client"+G]||document.body["client"+G]:this[0]==document?Math.max(document.documentElement["client"+G],document.body["scroll"+G],document.documentElement["scroll"+G],document.body["offset"+G],document.documentElement["offset"+G]):K===g?(this.length?o.css(this[0],J):null):this.css(J,typeof K==="string"?K:K+"px")}})})(); \ No newline at end of file diff --git a/vendor/gems/gems/sdoc-0.2.14.1/lib/sdoc/generator/template/shtml/resources/js/main.js b/vendor/gems/gems/sdoc-0.2.14.1/lib/sdoc/generator/template/shtml/resources/js/main.js new file mode 100755 index 00000000..3a2b8aee --- /dev/null +++ b/vendor/gems/gems/sdoc-0.2.14.1/lib/sdoc/generator/template/shtml/resources/js/main.js @@ -0,0 +1,34 @@ +function toggleSource( id ) +{ + var elem + var link + + if( document.getElementById ) + { + elem = document.getElementById( id ) + link = document.getElementById( "l_" + id ) + } + else if ( document.all ) + { + elem = eval( "document.all." + id ) + link = eval( "document.all.l_" + id ) + } + else + return false; + + if( elem.style.display == "block" ) + { + elem.style.display = "none" + link.innerHTML = "show" + } + else + { + elem.style.display = "block" + link.innerHTML = "hide" + } +} + +function openCode( url ) +{ + window.open( url, "SOURCE_CODE", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=480,width=750" ).focus(); +} \ No newline at end of file diff --git a/vendor/gems/gems/sdoc-0.2.14.1/lib/sdoc/generator/template/shtml/resources/js/searchdoc.js b/vendor/gems/gems/sdoc-0.2.14.1/lib/sdoc/generator/template/shtml/resources/js/searchdoc.js new file mode 100755 index 00000000..06b278ec --- /dev/null +++ b/vendor/gems/gems/sdoc-0.2.14.1/lib/sdoc/generator/template/shtml/resources/js/searchdoc.js @@ -0,0 +1,628 @@ +Searchdoc = {}; + +// navigation.js ------------------------------------------ + +Searchdoc.Navigation = new function() { + this.initNavigation = function() { + var _this = this; + + $(document).keydown(function(e) { + _this.onkeydown(e); + }).keyup(function(e) { + _this.onkeyup(e); + }); + + this.navigationActive = true; + } + + this.setNavigationActive = function(state) { + this.navigationActive = state; + this.clearMoveTimeout(); + } + + + this.onkeyup = function(e) { + if (!this.navigationActive) return; + switch(e.keyCode) { + case 37: //Event.KEY_LEFT: + case 38: //Event.KEY_UP: + case 39: //Event.KEY_RIGHT: + case 40: //Event.KEY_DOWN: + case 73: // i - qwerty + case 74: // j + case 75: // k + case 76: // l + case 67: // c - dvorak + case 72: // h + case 84: // t + case 78: // n + this.clearMoveTimeout(); + break; + } + } + + this.onkeydown = function(e) { + if (!this.navigationActive) return; + switch(e.keyCode) { + case 37: //Event.KEY_LEFT: + case 74: // j (qwerty) + case 72: // h (dvorak) + if (this.moveLeft()) e.preventDefault(); + break; + case 38: //Event.KEY_UP: + case 73: // i (qwerty) + case 67: // c (dvorak) + if (e.keyCode == 38 || e.ctrlKey) { + if (this.moveUp()) e.preventDefault(); + this.startMoveTimeout(false); + } + break; + case 39: //Event.KEY_RIGHT: + case 76: // l (qwerty) + case 78: // n (dvorak) + if (this.moveRight()) e.preventDefault(); + break; + case 40: //Event.KEY_DOWN: + case 75: // k (qwerty) + case 84: // t (dvorak) + if (e.keyCode == 40 || e.ctrlKey) { + if (this.moveDown()) e.preventDefault(); + this.startMoveTimeout(true); + } + break; + case 9: //Event.KEY_TAB: + case 13: //Event.KEY_RETURN: + if (this.$current) this.select(this.$current); + break; + } + if (e.ctrlKey && e.shiftKey) this.select(this.$current); + } + + this.clearMoveTimeout = function() { + clearTimeout(this.moveTimeout); + this.moveTimeout = null; + } + + this.startMoveTimeout = function(isDown) { + if (!$.browser.mozilla && !$.browser.opera) return; + if (this.moveTimeout) this.clearMoveTimeout(); + var _this = this; + + var go = function() { + if (!_this.moveTimeout) return; + _this[isDown ? 'moveDown' : 'moveUp'](); + _this.moveTimout = setTimeout(go, 100); + } + this.moveTimeout = setTimeout(go, 200); + } + + this.moveRight = function() { + } + + this.moveLeft = function() { + } + + this.move = function(isDown) { + } + + this.moveUp = function() { + return this.move(false); + } + + this.moveDown = function() { + return this.move(true); + } +} + + +// scrollIntoView.js -------------------------------------- + +function scrollIntoView(element, view) { + var offset, viewHeight, viewScroll, height; + offset = element.offsetTop; + height = element.offsetHeight; + viewHeight = view.offsetHeight; + viewScroll = view.scrollTop; + if (offset - viewScroll + height > viewHeight) { + view.scrollTop = offset - viewHeight + height; + } + if (offset < viewScroll) { + view.scrollTop = offset; + } +} + + +// searcher.js -------------------------------------------- + +Searchdoc.Searcher = function(data) { + this.data = data; + this.handlers = []; +} + +Searchdoc.Searcher.prototype = new function() { + var CHUNK_SIZE = 1000, // search is performed in chunks of 1000 for non-bloking user input + MAX_RESULTS = 100, // do not try to find more than 100 results + huid = 1, suid = 1, + runs = 0; + + + this.find = function(query) { + var queries = splitQuery(query), + regexps = buildRegexps(queries), + highlighters = buildHilighters(queries), + state = { from: 0, pass: 0, limit: MAX_RESULTS, n: suid++}, + _this = this; + this.currentSuid = state.n; + + if (!query) return; + + var run = function() { + // stop current search thread if new search started + if (state.n != _this.currentSuid) return; + + var results = performSearch(_this.data, regexps, queries, highlighters, state), + hasMore = (state.limit > 0 && state.pass < 3); + + triggerResults.call(_this, results, !hasMore); + if (hasMore) { + setTimeout(run, 2); + } + runs++; + }; + runs = 0; + + // start search thread + run(); + } + + /* ----- Events ------ */ + this.ready = function(fn) { + fn.huid = huid; + this.handlers.push(fn); + } + + /* ----- Utilities ------ */ + function splitQuery(query) { + return jQuery.grep(query.split(/(\s+|\(\)?)/), function(string) { return string.match(/\S/) }); + } + + function buildRegexps(queries) { + return jQuery.map(queries, function(query) { return new RegExp(query.replace(/(.)/g, '([$1])([^$1]*?)'), 'i') }); + } + + function buildHilighters(queries) { + return jQuery.map(queries, function(query) { + return jQuery.map( query.split(''), function(l, i){ return '\u0001$' + (i*2+1) + '\u0002$' + (i*2+2) } ).join('') + }); + } + + // function longMatchRegexp(index, longIndex, regexps) { + // for (var i = regexps.length - 1; i >= 0; i--){ + // if (!index.match(regexps[i]) && !longIndex.match(regexps[i])) return false; + // }; + // return true; + // } + + + /* ----- Mathchers ------ */ + function matchPass1(index, longIndex, queries, regexps) { + if (index.indexOf(queries[0]) != 0) return false; + for (var i=1, l = regexps.length; i < l; i++) { + if (!index.match(regexps[i]) && !longIndex.match(regexps[i])) return false; + }; + return true; + } + + function matchPass2(index, longIndex, queries, regexps) { + if (index.indexOf(queries[0]) == -1) return false; + for (var i=1, l = regexps.length; i < l; i++) { + if (!index.match(regexps[i]) && !longIndex.match(regexps[i])) return false; + }; + return true; + } + + function matchPassRegexp(index, longIndex, queries, regexps) { + if (!index.match(regexps[0])) return false; + for (var i=1, l = regexps.length; i < l; i++) { + if (!index.match(regexps[i]) && !longIndex.match(regexps[i])) return false; + }; + return true; + } + + + /* ----- Highlighters ------ */ + function highlightRegexp(info, queries, regexps, highlighters) { + var result = createResult(info); + for (var i=0, l = regexps.length; i < l; i++) { + result.title = result.title.replace(regexps[i], highlighters[i]); + if (i > 0) + result.namespace = result.namespace.replace(regexps[i], highlighters[i]); + }; + return result; + } + + function hltSubstring(string, pos, length) { + return string.substring(0, pos) + '\u0001' + string.substring(pos, pos + length) + '\u0002' + string.substring(pos + length); + } + + function highlightQuery(info, queries, regexps, highlighters) { + var result = createResult(info), pos = 0, lcTitle = result.title.toLowerCase(); + pos = lcTitle.indexOf(queries[0]); + if (pos != -1) { + result.title = hltSubstring(result.title, pos, queries[0].length); + } + for (var i=1, l = regexps.length; i < l; i++) { + result.title = result.title.replace(regexps[i], highlighters[i]); + result.namespace = result.namespace.replace(regexps[i], highlighters[i]); + }; + return result; + } + + function createResult(info) { + var result = {}; + result.title = info[0]; + result.namespace = info[1]; + result.path = info[2]; + result.params = info[3]; + result.snippet = info[4]; + result.badge = info[6]; + return result; + } + + /* ----- Searching ------ */ + function performSearch(data, regexps, queries, highlighters, state) { + var searchIndex = data.searchIndex, // search by title first and then by source + longSearchIndex = data.longSearchIndex, + info = data.info, + result = [], + i = state.from, + l = searchIndex.length, + togo = CHUNK_SIZE, + matchFunc, hltFunc; + + while (state.pass < 3 && state.limit > 0 && togo > 0) { + if (state.pass == 0) { + matchFunc = matchPass1; + hltFunc = highlightQuery; + } else if (state.pass == 1) { + matchFunc = matchPass2; + hltFunc = highlightQuery; + } else if (state.pass == 2) { + matchFunc = matchPassRegexp; + hltFunc = highlightRegexp; + } + + for (; togo > 0 && i < l && state.limit > 0; i++, togo--) { + if (info[i].n == state.n) continue; + if (matchFunc(searchIndex[i], longSearchIndex[i], queries, regexps)) { + info[i].n = state.n; + result.push(hltFunc(info[i], queries, regexps, highlighters)); + state.limit--; + } + }; + if (searchIndex.length <= i) { + state.pass++; + i = state.from = 0; + } else { + state.from = i; + } + } + return result; + } + + function triggerResults(results, isLast) { + jQuery.each(this.handlers, function(i, fn) { fn.call(this, results, isLast) }) + } +} + + + + +// panel.js ----------------------------------------------- + +Searchdoc.Panel = function(element, data, tree, frame) { + this.$element = $(element); + this.$input = $('input', element).eq(0); + this.$result = $('.result ul', element).eq(0); + this.frame = frame; + this.$current = null; + this.$view = this.$result.parent(); + this.data = data; + this.searcher = new Searchdoc.Searcher(data.index); + this.tree = new Searchdoc.Tree($('.tree', element), tree, this); + this.init(); +} + +Searchdoc.Panel.prototype = $.extend({}, Searchdoc.Navigation, new function() { + var suid = 1; + + this.init = function() { + var _this = this; + var observer = function() { + _this.search(_this.$input[0].value); + }; + this.$input.keyup(observer); + this.$input.click(observer); // mac's clear field + + this.searcher.ready(function(results, isLast) { + _this.addResults(results, isLast); + }) + + this.$result.click(function(e) { + _this.$current.removeClass('current'); + _this.$current = $(e.target).closest('li').addClass('current'); + _this.select(); + _this.$input.focus(); + }); + + this.initNavigation(); + this.setNavigationActive(false); + } + + this.search = function(value, selectFirstMatch) { + value = jQuery.trim(value).toLowerCase(); + this.selectFirstMatch = selectFirstMatch; + if (value) { + this.$element.removeClass('panel_tree').addClass('panel_results'); + this.tree.setNavigationActive(false); + this.setNavigationActive(true); + } else { + this.$element.addClass('panel_tree').removeClass('panel_results'); + this.tree.setNavigationActive(true); + this.setNavigationActive(false); + } + if (value != this.lastQuery) { + this.lastQuery = value; + this.firstRun = true; + this.searcher.find(value); + } + } + + this.addResults = function(results, isLast) { + var target = this.$result.get(0); + if (this.firstRun && (results.length > 0 || isLast)) { + this.$current = null; + this.$result.empty(); + } + for (var i=0, l = results.length; i < l; i++) { + target.appendChild(renderItem.call(this, results[i])); + }; + if (this.firstRun && results.length > 0) { + this.firstRun = false; + this.$current = $(target.firstChild); + this.$current.addClass('current'); + if (this.selectFirstMatch) this.select(); + scrollIntoView(this.$current[0], this.$view[0]) + } + if (jQuery.browser.msie) this.$element[0].className += ''; + } + + this.open = function(src) { + this.frame.location.href = '../' + src; + if (this.frame.highlight) this.frame.highlight(src); + } + + this.select = function() { + this.open(this.$current.data('path')); + } + + this.move = function(isDown) { + if (!this.$current) return; + var $next = this.$current[isDown ? 'next' : 'prev'](); + if ($next.length) { + this.$current.removeClass('current'); + $next.addClass('current'); + scrollIntoView($next[0], this.$view[0]); + this.$current = $next; + } + return true; + } + + function renderItem(result) { + var li = document.createElement('li'), + html = '', badge = result.badge; + html += '

' + hlt(result.title); + if (result.params) html += '' + result.params + ''; + html += '

'; + html += '

'; + if (typeof badge != 'undefined') { + html += '' + escapeHTML(this.data.badges[badge] || 'unknown') + ''; + } + html += hlt(result.namespace) + '

'; + if (result.snippet) html += '

' + escapeHTML(result.snippet) + '

'; + li.innerHTML = html; + jQuery.data(li, 'path', result.path); + return li; + } + + function hlt(html) { + return escapeHTML(html).replace(/\u0001/g, '').replace(/\u0002/g, '') + } + + function escapeHTML(html) { + return html.replace(/[&<>]/g, function(c) { + return '&#' + c.charCodeAt(0) + ';'; + }); + } + +}); + +// tree.js ------------------------------------------------ + +Searchdoc.Tree = function(element, tree, panel) { + this.$element = $(element); + this.$list = $('ul', element); + this.tree = tree; + this.panel = panel; + this.init(); +} + +Searchdoc.Tree.prototype = $.extend({}, Searchdoc.Navigation, new function() { + this.init = function() { + var stopper = document.createElement('li'); + stopper.className = 'stopper'; + this.$list[0].appendChild(stopper); + for (var i=0, l = this.tree.length; i < l; i++) { + buildAndAppendItem.call(this, this.tree[i], 0, stopper); + }; + var _this = this; + this.$list.click(function(e) { + var $target = $(e.target), + $li = $target.closest('li'); + if ($target.hasClass('icon')) { + _this.toggle($li); + } else { + _this.select($li); + } + }) + + this.initNavigation(); + if (jQuery.browser.msie) document.body.className += ''; + } + + this.select = function($li) { + this.highlight($li); + var path = $li[0].searchdoc_tree_data.path; + if (path) this.panel.open(path); + } + + this.highlight = function($li) { + if (this.$current) this.$current.removeClass('current'); + this.$current = $li.addClass('current'); + } + + this.toggle = function($li) { + var closed = !$li.hasClass('closed'), + children = $li[0].searchdoc_tree_data.children; + $li.toggleClass('closed'); + for (var i=0, l = children.length; i < l; i++) { + toggleVis.call(this, $(children[i].li), !closed); + }; + } + + this.moveRight = function() { + if (!this.$current) { + this.highlight(this.$list.find('li:first')); + return; + } + if (this.$current.hasClass('closed')) { + this.toggle(this.$current); + } + } + + this.moveLeft = function() { + if (!this.$current) { + this.highlight(this.$list.find('li:first')); + return; + } + if (!this.$current.hasClass('closed')) { + this.toggle(this.$current); + } else { + var level = this.$current[0].searchdoc_tree_data.level; + if (level == 0) return; + var $next = this.$current.prevAll('li.level_' + (level - 1) + ':visible:first'); + this.$current.removeClass('current'); + $next.addClass('current'); + scrollIntoView($next[0], this.$element[0]); + this.$current = $next; + } + } + + this.move = function(isDown) { + if (!this.$current) { + this.highlight(this.$list.find('li:first')); + return true; + } + var next = this.$current[0]; + if (isDown) { + do { + next = next.nextSibling; + if (next && next.style && next.style.display != 'none') break; + } while(next); + } else { + do { + next = next.previousSibling; + if (next && next.style && next.style.display != 'none') break; + } while(next); + } + if (next && next.className.indexOf('stopper') == -1) { + this.$current.removeClass('current'); + $(next).addClass('current'); + scrollIntoView(next, this.$element[0]); + this.$current = $(next); + } + return true; + } + + function toggleVis($li, show) { + var closed = $li.hasClass('closed'), + children = $li[0].searchdoc_tree_data.children; + $li.css('display', show ? '' : 'none') + if (!show && this.$current && $li[0] == this.$current[0]) { + this.$current.removeClass('current'); + this.$current = null; + } + for (var i=0, l = children.length; i < l; i++) { + toggleVis.call(this, $(children[i].li), show && !closed); + }; + } + + function buildAndAppendItem(item, level, before) { + var li = renderItem(item, level), + list = this.$list[0]; + item.li = li; + list.insertBefore(li, before); + for (var i=0, l = item[3].length; i < l; i++) { + buildAndAppendItem.call(this, item[3][i], level + 1, before); + }; + return li; + } + + function renderItem(item, level) { + var li = document.createElement('li'), + cnt = document.createElement('div'), + h1 = document.createElement('h1'), + p = document.createElement('p'), + icon, i; + + li.appendChild(cnt); + li.style.paddingLeft = getOffset(level); + cnt.className = 'content'; + if (!item[1]) li.className = 'empty '; + cnt.appendChild(h1); + // cnt.appendChild(p); + h1.appendChild(document.createTextNode(item[0])); + // p.appendChild(document.createTextNode(item[4])); + if (item[2]) { + i = document.createElement('i'); + i.appendChild(document.createTextNode(item[2])); + h1.appendChild(i); + } + if (item[3].length > 0) { + icon = document.createElement('div'); + icon.className = 'icon'; + cnt.appendChild(icon); + } + + // user direct assignement instead of $() + // it's 8x faster + // $(li).data('path', item[1]) + // .data('children', item[3]) + // .data('level', level) + // .css('display', level == 0 ? '' : 'none') + // .addClass('level_' + level) + // .addClass('closed'); + li.searchdoc_tree_data = { + path: item[1], + children: item[3], + level: level + } + li.style.display = level == 0 ? '' : 'none'; + li.className += 'level_' + level + ' closed'; + return li; + } + + function getOffset(level) { + return 5 + 18*level + 'px'; + } +}); diff --git a/vendor/gems/gems/sdoc-0.2.14.1/lib/sdoc/generator/template/shtml/resources/panel/index.html b/vendor/gems/gems/sdoc-0.2.14.1/lib/sdoc/generator/template/shtml/resources/panel/index.html new file mode 100755 index 00000000..683c6269 --- /dev/null +++ b/vendor/gems/gems/sdoc-0.2.14.1/lib/sdoc/generator/template/shtml/resources/panel/index.html @@ -0,0 +1,71 @@ + + + + + + layout + + + + + + + + + +
+
+
+ + + +
+ +
+
+
+
    +
+
+
+
    +
+
+
+ + diff --git a/vendor/gems/gems/sdoc-0.2.14.1/lib/sdoc/github.rb b/vendor/gems/gems/sdoc-0.2.14.1/lib/sdoc/github.rb new file mode 100755 index 00000000..e275a31d --- /dev/null +++ b/vendor/gems/gems/sdoc-0.2.14.1/lib/sdoc/github.rb @@ -0,0 +1,64 @@ +module SDoc::GitHub + def github_url(path) + unless @github_url_cache.has_key? path + @github_url_cache[path] = false + file = RDoc::TopLevel.find_file_named(path) + if file + base_url = repository_url(path) + if base_url + sha1 = commit_sha1(path) + if sha1 + relative_url = path_relative_to_repository(path) + @github_url_cache[path] = "#{base_url}#{sha1}#{relative_url}" + end + end + end + end + @github_url_cache[path] + end + + protected + + def commit_sha1(path) + name = File.basename(path) + s = in_dir(File.join(basedir, File.dirname(path))) do + `git log -1 --pretty=format:"commit %H" #{name}` + end + m = s.match(/commit\s+(\S+)/) + m ? m[1] : false + end + + def repository_url(path) + s = in_dir(File.join(basedir, File.dirname(path))) do + `git config --get remote.origin.url` + end + m = s.match(%r{github.com[/:](.*)\.git$}) + m ? "http://github.com/#{m[1]}/blob/" : false + end + + def path_relative_to_repository(path) + absolute_path = File.join(basedir, path) + root = path_to_git_dir(File.dirname(absolute_path)) + absolute_path[root.size..absolute_path.size] + end + + def path_to_git_dir(path) + while !path.empty? && path != '.' + if (File.exists? File.join(path, '.git')) + return path + end + path = File.dirname(path) + end + '' + end + + def in_dir(dir) + pwd = Dir.pwd + Dir.chdir dir + return yield + rescue Exception => e + return '' + ensure + Dir.chdir pwd + end +end diff --git a/vendor/gems/gems/sdoc-0.2.14.1/lib/sdoc/helpers.rb b/vendor/gems/gems/sdoc-0.2.14.1/lib/sdoc/helpers.rb new file mode 100755 index 00000000..c7ee5ce1 --- /dev/null +++ b/vendor/gems/gems/sdoc-0.2.14.1/lib/sdoc/helpers.rb @@ -0,0 +1,26 @@ +module SDoc::Helpers + def each_letter_group(methods, &block) + group = {:name => '', :methods => []} + methods.sort{ |a, b| a.name <=> b.name }.each do |method| + gname = group_name method.name + if gname != group[:name] + yield group unless group[:methods].size == 0 + group = { + :name => gname, + :methods => [] + } + end + group[:methods].push(method) + end + yield group unless group[:methods].size == 0 + end + +protected + def group_name name + if match = name.match(/^([a-z])/i) + match[1].upcase + else + '#' + end + end +end \ No newline at end of file diff --git a/vendor/gems/gems/sdoc-0.2.14.1/lib/sdoc/merge.rb b/vendor/gems/gems/sdoc-0.2.14.1/lib/sdoc/merge.rb new file mode 100755 index 00000000..10445ddb --- /dev/null +++ b/vendor/gems/gems/sdoc-0.2.14.1/lib/sdoc/merge.rb @@ -0,0 +1,217 @@ +require 'optparse' +require 'pathname' +require 'fileutils' +require 'json' + +require 'sdoc/templatable' + +class SDoc::Merge + include SDoc::Templatable + + FLAG_FILE = "created.rid" + + def initialize() + @names = [] + @urls = [] + @op_dir = 'doc' + @title = '' + @directories = [] + template_dir = RDoc::Generator::SHtml.template_dir('merge') + @template_dir = Pathname.new File.expand_path(template_dir) + end + + def merge(options) + parse_options options + + @outputdir = Pathname.new( @op_dir ) + + check_directories + setup_output_dir + setup_names + copy_files + copy_docs if @urls.empty? + merge_search_index + merge_tree + generate_index_file + end + + def parse_options(options) + opts = OptionParser.new do |opt| + opt.banner = "Usage: sdoc-merge [options] directories" + + opt.on("-n", "--names [NAMES]", "Names of merged repositories. Comma separated") do |v| + @names = v.split(',').map{|name| name.strip } + end + + opt.on("-o", "--op [DIRECTORY]", "Set the output directory") do |v| + @op_dir = v + end + + opt.on("-t", "--title [TITLE]", "Set the title of merged file") do |v| + @title = v + end + + opt.on("-u", "--urls [URLS]", "Paths to merged docs. If you \n" + + "set this files and classes won't be actualy copied to merged build") do |v| + @urls = v.split(' ').map{|name| name.strip } + end + end + opts.parse! options + @directories = options.dup + end + + def merge_tree + tree = [] + @directories.each_with_index do |dir, i| + name = @names[i] + url = @urls.empty? ? name : @urls[i] + filename = File.join dir, RDoc::Generator::SHtml::TREE_FILE + data = open(filename).read.sub(/var tree =\s*/, '') + subtree = JSON.parse data, :max_nesting => 35 + item = [ + name, + url + '/' + extract_index_path(dir), + '', + append_path(subtree, url) + ] + tree << item + end + + dst = File.join @op_dir, RDoc::Generator::SHtml::TREE_FILE + FileUtils.mkdir_p File.dirname(dst) + File.open(dst, "w", 0644) do |f| + f.write('var tree = '); f.write(tree.to_json) + end + end + + def append_path subtree, path + subtree.map do |item| + item[1] = path + '/' + item[1] unless item[1].empty? + item[3] = append_path item[3], path + item + end + end + + def merge_search_index + items = [] + @indexes = {} + @directories.each_with_index do |dir, i| + name = @names[i] + url = @urls.empty? ? name : @urls[i] + filename = File.join dir, RDoc::Generator::SHtml::SEARCH_INDEX_FILE + data = open(filename).read.sub(/var search_data =\s*/, '') + subindex = JSON.parse data, :max_nesting => 35 + @indexes[name] = subindex + + searchIndex = subindex["index"]["searchIndex"] + longSearchIndex = subindex["index"]["longSearchIndex"] + subindex["index"]["info"].each_with_index do |info, j| + info[2] = url + '/' + info[2] + info[6] = i + items << { + :info => info, + :searchIndex => searchIndex[j], + :longSearchIndex => name + ' ' + longSearchIndex[j] + } + end + end + items.sort! do |a, b| + # type (class/method/file) or name or doc part or namespace + [a[:info][5], a[:info][0], a[:info][6], a[:info][1]] <=> [b[:info][5], b[:info][0], b[:info][6], b[:info][1]] + end + + index = { + :searchIndex => items.map{|item| item[:searchIndex]}, + :longSearchIndex => items.map{|item| item[:longSearchIndex]}, + :info => items.map{|item| item[:info]} + } + search_data = { + :index => index, + :badges => @names + } + + dst = File.join @op_dir, RDoc::Generator::SHtml::SEARCH_INDEX_FILE + FileUtils.mkdir_p File.dirname(dst) + File.open(dst, "w", 0644) do |f| + f.write('var search_data = '); f.write(search_data.to_json) + end + end + + def extract_index_path dir + filename = File.join dir, 'index.html' + content = File.open(filename) { |f| f.read } + match = content.match(/ 0 + @directories.each do |dir| + name = File.basename dir + name = File.basename File.dirname(dir) if name == 'doc' + @names << name + end + end + end + + def copy_docs + @directories.each_with_index do |dir, i| + name = @names[i] + index_dir = File.dirname(RDoc::Generator::SHtml::TREE_FILE) + FileUtils.mkdir_p(File.join(@op_dir, name)) + + Dir.new(dir).each do |item| + if File.directory?(File.join(dir, item)) && item != '.' && item != '..' && item != index_dir + FileUtils.cp_r File.join(dir, item), File.join(@op_dir, name, item), :preserve => true + end + end + end + end + + def copy_files + dir = @directories.first + Dir.new(dir).each do |item| + if item != '.' && item != '..' && item != RDoc::Generator::SHtml::FILE_DIR && item != RDoc::Generator::SHtml::CLASS_DIR + FileUtils.cp_r File.join(dir, item), @op_dir, :preserve => true + end + end + end + + def setup_output_dir + if File.exists? @op_dir + error "#{@op_dir} allready exists" + end + FileUtils.mkdir_p @op_dir + end + + def check_directories + @directories.each do |dir| + unless File.exists?(File.join(dir, FLAG_FILE)) && + File.exists?(File.join(dir, RDoc::Generator::SHtml::TREE_FILE)) && + File.exists?(File.join(dir, RDoc::Generator::SHtml::SEARCH_INDEX_FILE)) + error "#{dir} does not seem to be an sdoc directory" + end + end + end + + ## + # Report an error message and exit + + def error(msg) + raise RDoc::Error, msg + end + +end \ No newline at end of file diff --git a/vendor/gems/gems/sdoc-0.2.14.1/lib/sdoc/templatable.rb b/vendor/gems/gems/sdoc-0.2.14.1/lib/sdoc/templatable.rb new file mode 100755 index 00000000..412e0da8 --- /dev/null +++ b/vendor/gems/gems/sdoc-0.2.14.1/lib/sdoc/templatable.rb @@ -0,0 +1,58 @@ +require "sdoc" + +module SDoc::Templatable + ### Load and render the erb template in the given +templatefile+ within the + ### specified +context+ (a Binding object) and return output + ### Both +templatefile+ and +outfile+ should be Pathname-like objects. + def eval_template(templatefile, context) + template_src = templatefile.read + template = ERB.new( template_src, nil, '<>' ) + template.filename = templatefile.to_s + + begin + template.result( context ) + rescue NoMethodError => err + raise RDoc::Error, "Error while evaluating %s: %s (at %p)" % [ + templatefile.to_s, + err.message, + eval( "_erbout[-50,50]", context ) + ], err.backtrace + end + end + + ### Load and render the erb template with the given +template_name+ within + ### current context. Adds all +local_assigns+ to context + def include_template(template_name, local_assigns = {}) + source = local_assigns.keys.map { |key| "#{key} = local_assigns[:#{key}];" }.join + eval("#{source};templatefile = @template_dir + template_name;eval_template(templatefile, binding)") + end + + ### Load and render the erb template in the given +templatefile+ within the + ### specified +context+ (a Binding object) and write it out to +outfile+. + ### Both +templatefile+ and +outfile+ should be Pathname-like objects. + def render_template( templatefile, context, outfile ) + output = eval_template(templatefile, context) + + # TODO delete this dirty hack when documentation for example for GeneratorMethods will not be cutted off by + + + + +
+ + +
+

BACKTRACE

+

(expand)

+ +
+ +
    + + <% id = 1 %> + <% frames.each do |frame| %> + <% if frame.context_line && frame.context_line != "#" %> + +
  • + <%=h frame.filename %> in + <%=h frame.function %> +
  • + +
  • + <% if frame.pre_context %> +
      + <% frame.pre_context.each do |line| %> +
    1. <%=h line %>
    2. + <% end %> +
    + <% end %> + +
      +
    1. <%= + h frame.context_line %>
    2. +
    + + <% if frame.post_context %> +
      + <% frame.post_context.each do |line| %> +
    1. <%=h line %>
    2. + <% end %> +
    + <% end %> +
    +
  • + + <% end %> + + <% id += 1 %> + <% end %> + +
+
+ +
+

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 you have +enabled the show_exceptions option.

+
+ + +HTML + end +end diff --git a/vendor/gems/gems/sinatra-0.9.4/lib/sinatra/test.rb b/vendor/gems/gems/sinatra-0.9.4/lib/sinatra/test.rb new file mode 100755 index 00000000..6954eb59 --- /dev/null +++ b/vendor/gems/gems/sinatra-0.9.4/lib/sinatra/test.rb @@ -0,0 +1,128 @@ +require 'sinatra/base' + +warn 'Sinatra::Test is deprecated; use Rack::Test instead.' + +module Sinatra + module Test + include Rack::Utils + + def self.included(base) + Sinatra::Default.set(:environment, :test) + end + + attr_reader :app, :request, :response + + def self.deprecate(framework) + warn <<-EOF +Warning: support for the #{framework} testing framework is deprecated and +will be dropped in Sinatra 1.0. See +for more information. + EOF + end + + def make_request(verb, path, body=nil, options={}) + @app = Sinatra::Application if @app.nil? && defined?(Sinatra::Application) + fail "@app not set - cannot make request" if @app.nil? + + @request = Rack::MockRequest.new(@app) + options = { :lint => true }.merge(options || {}) + + case + when body.respond_to?(:to_hash) + options.merge! body.delete(:env) if body.key?(:env) + options[:input] = param_string(body) + when body.respond_to?(:to_str) + options[:input] = body + when body.nil? + options[:input] = '' + else + raise ArgumentError, "body must be a Hash, String, or nil" + end + + yield @request if block_given? + @response = @request.request(verb, path, rack_options(options)) + end + + def get(path, *args, &b) ; make_request('GET', path, *args, &b) ; end + def head(path, *args, &b) ; make_request('HEAD', path, *args, &b) ; end + def post(path, *args, &b) ; make_request('POST', path, *args, &b) ; end + def put(path, *args, &b) ; make_request('PUT', path, *args, &b) ; end + def delete(path, *args, &b) ; make_request('DELETE', path, *args, &b) ; end + + def follow! + make_request 'GET', @response.location + end + + def body ; @response.body ; end + def status ; @response.status ; end + + # Delegate other missing methods to @response. + def method_missing(name, *args, &block) + if @response && @response.respond_to?(name) + @response.send(name, *args, &block) + else + super + end + end + + # Also check @response since we delegate there. + def respond_to?(symbol, include_private=false) + super || (@response && @response.respond_to?(symbol, include_private)) + end + + private + + RACK_OPTIONS = { + :accept => 'HTTP_ACCEPT', + :agent => 'HTTP_USER_AGENT', + :host => 'HTTP_HOST', + :session => 'rack.session', + :cookies => 'HTTP_COOKIE', + :content_type => 'CONTENT_TYPE' + } + + def rack_options(opts) + opts.merge(:lint => true).inject({}) do |hash,(key,val)| + key = RACK_OPTIONS[key] || key + hash[key] = val + hash + end + end + + def param_string(value, prefix = nil) + case value + when Array + value.map { |v| + param_string(v, "#{prefix}[]") + } * "&" + when Hash + value.map { |k, v| + param_string(v, prefix ? "#{prefix}[#{escape(k)}]" : escape(k)) + } * "&" + else + "#{prefix}=#{escape(value)}" + end + end + + if defined? Sinatra::Compat + # Deprecated. Use: "get" instead of "get_it". + %w(get head post put delete).each do |verb| + eval <<-RUBY, binding, __FILE__, __LINE__ + def #{verb}_it(*args, &block) + sinatra_warn "The #{verb}_it method is deprecated; use #{verb} instead." + make_request('#{verb.upcase}', *args, &block) + end + RUBY + end + end + end + + class TestHarness + include Test + + def initialize(app=nil) + @app = app || Sinatra::Application + @app.set(:environment, :test) + end + end +end diff --git a/vendor/gems/gems/sinatra-0.9.4/lib/sinatra/test/bacon.rb b/vendor/gems/gems/sinatra-0.9.4/lib/sinatra/test/bacon.rb new file mode 100755 index 00000000..66c0b135 --- /dev/null +++ b/vendor/gems/gems/sinatra-0.9.4/lib/sinatra/test/bacon.rb @@ -0,0 +1,19 @@ +require 'bacon' +require 'sinatra/test' + +Sinatra::Test.deprecate('Bacon') + +Sinatra::Default.set( + :environment => :test, + :run => false, + :raise_errors => true, + :logging => false +) + +module Sinatra::Test + def should + @response.should + end +end + +Bacon::Context.send(:include, Sinatra::Test) diff --git a/vendor/gems/gems/sinatra-0.9.4/lib/sinatra/test/rspec.rb b/vendor/gems/gems/sinatra-0.9.4/lib/sinatra/test/rspec.rb new file mode 100755 index 00000000..971b96f6 --- /dev/null +++ b/vendor/gems/gems/sinatra-0.9.4/lib/sinatra/test/rspec.rb @@ -0,0 +1,13 @@ +require 'sinatra/test' +require 'sinatra/test/unit' +require 'spec' +require 'spec/interop/test' + +Sinatra::Test.deprecate('RSpec') + +Sinatra::Default.set( + :environment => :test, + :run => false, + :raise_errors => true, + :logging => false +) diff --git a/vendor/gems/gems/sinatra-0.9.4/lib/sinatra/test/spec.rb b/vendor/gems/gems/sinatra-0.9.4/lib/sinatra/test/spec.rb new file mode 100755 index 00000000..daffe32c --- /dev/null +++ b/vendor/gems/gems/sinatra-0.9.4/lib/sinatra/test/spec.rb @@ -0,0 +1,11 @@ +require 'test/spec' +require 'sinatra/test' +require 'sinatra/test/unit' + +Sinatra::Test.deprecate('test/spec') + +module Sinatra::Test + def should + @response.should + end +end diff --git a/vendor/gems/gems/sinatra-0.9.4/lib/sinatra/test/unit.rb b/vendor/gems/gems/sinatra-0.9.4/lib/sinatra/test/unit.rb new file mode 100755 index 00000000..a7e60b3a --- /dev/null +++ b/vendor/gems/gems/sinatra-0.9.4/lib/sinatra/test/unit.rb @@ -0,0 +1,13 @@ +require 'sinatra/test' +require 'test/unit' + +Sinatra::Test.deprecate('test/unit') + +Test::Unit::TestCase.send :include, Sinatra::Test + +Sinatra::Default.set( + :environment => :test, + :run => false, + :raise_errors => true, + :logging => false +) diff --git a/vendor/gems/gems/sinatra-0.9.4/sinatra.gemspec b/vendor/gems/gems/sinatra-0.9.4/sinatra.gemspec new file mode 100755 index 00000000..7269c4cd --- /dev/null +++ b/vendor/gems/gems/sinatra-0.9.4/sinatra.gemspec @@ -0,0 +1,125 @@ +Gem::Specification.new do |s| + s.specification_version = 2 if s.respond_to? :specification_version= + s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version= + + s.name = 'sinatra' + s.version = '0.9.4' + s.date = '2009-07-26' + + s.description = "Classy web-development dressed in a DSL" + s.summary = "Classy web-development dressed in a DSL" + + s.authors = ["Blake Mizerany"] + s.email = "sinatrarb@googlegroups.com" + + # = MANIFEST = + s.files = %w[ + AUTHORS + CHANGES + LICENSE + README.rdoc + Rakefile + compat/app_test.rb + compat/application_test.rb + compat/builder_test.rb + compat/compat_test.rb + compat/custom_error_test.rb + compat/erb_test.rb + compat/events_test.rb + compat/filter_test.rb + compat/haml_test.rb + compat/helper.rb + compat/mapped_error_test.rb + compat/pipeline_test.rb + compat/public/foo.xml + compat/sass_test.rb + compat/sessions_test.rb + compat/streaming_test.rb + compat/sym_params_test.rb + compat/template_test.rb + compat/use_in_file_templates_test.rb + compat/views/foo.builder + compat/views/foo.erb + compat/views/foo.haml + compat/views/foo.sass + compat/views/foo_layout.erb + compat/views/foo_layout.haml + compat/views/layout_test/foo.builder + compat/views/layout_test/foo.erb + compat/views/layout_test/foo.haml + compat/views/layout_test/foo.sass + compat/views/layout_test/layout.builder + compat/views/layout_test/layout.erb + compat/views/layout_test/layout.haml + compat/views/layout_test/layout.sass + compat/views/no_layout/no_layout.builder + compat/views/no_layout/no_layout.haml + lib/sinatra.rb + lib/sinatra/base.rb + lib/sinatra/compat.rb + lib/sinatra/images/404.png + lib/sinatra/images/500.png + lib/sinatra/main.rb + lib/sinatra/showexceptions.rb + lib/sinatra/test.rb + lib/sinatra/test/bacon.rb + lib/sinatra/test/rspec.rb + lib/sinatra/test/spec.rb + lib/sinatra/test/unit.rb + sinatra.gemspec + test/base_test.rb + test/builder_test.rb + test/contest.rb + test/data/reload_app_file.rb + test/erb_test.rb + test/extensions_test.rb + test/filter_test.rb + test/haml_test.rb + test/helper.rb + test/helpers_test.rb + test/mapped_error_test.rb + test/middleware_test.rb + test/options_test.rb + test/render_backtrace_test.rb + test/request_test.rb + test/response_test.rb + test/result_test.rb + test/route_added_hook_test.rb + test/routing_test.rb + test/sass_test.rb + test/server_test.rb + test/sinatra_test.rb + test/static_test.rb + test/templates_test.rb + test/test_test.rb + test/views/error.builder + test/views/error.erb + test/views/error.haml + test/views/error.sass + test/views/foo/hello.test + test/views/hello.builder + test/views/hello.erb + test/views/hello.haml + test/views/hello.sass + test/views/hello.test + test/views/layout2.builder + test/views/layout2.erb + test/views/layout2.haml + test/views/layout2.test + ] + # = MANIFEST = + + s.test_files = s.files.select {|path| path =~ /^test\/.*_test.rb/} + + s.extra_rdoc_files = %w[README.rdoc LICENSE] + s.add_dependency 'rack', '>= 0.9.1' + s.add_development_dependency 'shotgun', '>= 0.2', '< 1.0' + s.add_development_dependency 'rack-test', '>= 0.3.0' + + s.has_rdoc = true + s.homepage = "http://sinatra.rubyforge.org" + s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Sinatra", "--main", "README.rdoc"] + s.require_paths = %w[lib] + s.rubyforge_project = 'sinatra' + s.rubygems_version = '1.1.1' +end diff --git a/vendor/gems/gems/sinatra-0.9.4/test/base_test.rb b/vendor/gems/gems/sinatra-0.9.4/test/base_test.rb new file mode 100755 index 00000000..7a5d1130 --- /dev/null +++ b/vendor/gems/gems/sinatra-0.9.4/test/base_test.rb @@ -0,0 +1,160 @@ +require File.dirname(__FILE__) + '/helper' + +class BaseTest < Test::Unit::TestCase + def test_default + assert true + end + + describe 'Sinatra::Base subclasses' do + class TestApp < Sinatra::Base + get '/' do + 'Hello World' + end + end + + it 'include Rack::Utils' do + assert TestApp.included_modules.include?(Rack::Utils) + end + + it 'processes requests with #call' do + assert TestApp.respond_to?(:call) + + request = Rack::MockRequest.new(TestApp) + response = request.get('/') + assert response.ok? + assert_equal 'Hello World', response.body + end + + class TestApp < Sinatra::Base + get '/state' do + @foo ||= "new" + body = "Foo: #{@foo}" + @foo = 'discard' + body + end + end + + it 'does not maintain state between requests' do + request = Rack::MockRequest.new(TestApp) + 2.times do + response = request.get('/state') + assert response.ok? + assert_equal 'Foo: new', response.body + end + end + + it "passes the subclass to configure blocks" do + ref = nil + TestApp.configure { |app| ref = app } + assert_equal TestApp, ref + end + + it "allows the configure block arg to be omitted and does not change context" do + context = nil + TestApp.configure { context = self } + assert_equal self, context + end + end + + describe "Sinatra::Base as Rack middleware" do + app = lambda { |env| + headers = {'X-Downstream' => 'true'} + headers['X-Route-Missing'] = env['sinatra.route-missing'] || '' + [210, headers, ['Hello from downstream']] } + + class TestMiddleware < Sinatra::Base + end + + it 'creates a middleware that responds to #call with .new' do + middleware = TestMiddleware.new(app) + assert middleware.respond_to?(:call) + end + + it 'exposes the downstream app' do + middleware = TestMiddleware.new(app) + assert_same app, middleware.app + end + + class TestMiddleware < Sinatra::Base + def route_missing + env['sinatra.route-missing'] = '1' + super + end + + get '/' do + 'Hello from middleware' + end + end + + middleware = TestMiddleware.new(app) + request = Rack::MockRequest.new(middleware) + + it 'intercepts requests' do + response = request.get('/') + assert response.ok? + assert_equal 'Hello from middleware', response.body + end + + it 'automatically forwards requests downstream when no matching route found' do + response = request.get('/missing') + assert_equal 210, response.status + assert_equal 'Hello from downstream', response.body + end + + it 'calls #route_missing before forwarding downstream' do + response = request.get('/missing') + assert_equal '1', response['X-Route-Missing'] + end + + class TestMiddleware < Sinatra::Base + get '/low-level-forward' do + app.call(env) + end + end + + it 'can call the downstream app directly and return result' do + response = request.get('/low-level-forward') + assert_equal 210, response.status + assert_equal 'true', response['X-Downstream'] + assert_equal 'Hello from downstream', response.body + end + + class TestMiddleware < Sinatra::Base + get '/explicit-forward' do + response['X-Middleware'] = 'true' + res = forward + assert_nil res + assert_equal 210, response.status + assert_equal 'true', response['X-Downstream'] + assert_equal ['Hello from downstream'], response.body + 'Hello after explicit forward' + end + end + + it 'forwards the request downstream and integrates the response into the current context' do + response = request.get('/explicit-forward') + assert_equal 210, response.status + assert_equal 'true', response['X-Downstream'] + assert_equal 'Hello after explicit forward', response.body + assert_equal '28', response['Content-Length'] + end + + app_content_length = lambda {|env| + [200, {'Content-Length' => '16'}, 'From downstream!']} + + class TestMiddlewareContentLength < Sinatra::Base + get '/forward' do + res = forward + 'From after explicit forward!' + end + end + + middleware_content_length = TestMiddlewareContentLength.new(app_content_length) + request_content_length = Rack::MockRequest.new(middleware_content_length) + + it "sets content length for last response" do + response = request_content_length.get('/forward') + assert_equal '28', response['Content-Length'] + end + end +end diff --git a/vendor/gems/gems/sinatra-0.9.4/test/builder_test.rb b/vendor/gems/gems/sinatra-0.9.4/test/builder_test.rb new file mode 100755 index 00000000..04ab3a58 --- /dev/null +++ b/vendor/gems/gems/sinatra-0.9.4/test/builder_test.rb @@ -0,0 +1,65 @@ +require File.dirname(__FILE__) + '/helper' +require 'builder' + +class BuilderTest < Test::Unit::TestCase + def builder_app(&block) + mock_app { + set :views, File.dirname(__FILE__) + '/views' + get '/', &block + } + get '/' + end + + it 'renders inline Builder strings' do + builder_app { builder 'xml.instruct!' } + assert ok? + assert_equal %{\n}, body + end + + it 'renders inline blocks' do + builder_app { + @name = "Frank & Mary" + builder do |xml| + xml.couple @name + end + } + assert ok? + assert_equal "Frank & Mary\n", body + end + + it 'renders .builder files in views path' do + builder_app { + @name = "Blue" + builder :hello + } + assert ok? + assert_equal %(You're my boy, Blue!\n), body + end + + it "renders with inline layouts" do + mock_app { + layout do + %(xml.layout { xml << yield }) + end + get('/') { builder %(xml.em 'Hello World') } + } + get '/' + assert ok? + assert_equal "\nHello World\n\n", body + end + + it "renders with file layouts" do + builder_app { + builder %(xml.em 'Hello World'), :layout => :layout2 + } + assert ok? + assert_equal "\nHello World\n\n", body + end + + it "raises error if template not found" do + mock_app { + get('/') { builder :no_such_template } + } + assert_raise(Errno::ENOENT) { get('/') } + end +end diff --git a/vendor/gems/gems/sinatra-0.9.4/test/contest.rb b/vendor/gems/gems/sinatra-0.9.4/test/contest.rb new file mode 100755 index 00000000..de716010 --- /dev/null +++ b/vendor/gems/gems/sinatra-0.9.4/test/contest.rb @@ -0,0 +1,64 @@ +require "test/unit" + +# Test::Unit loads a default test if the suite is empty, and the only +# purpose of that test is to fail. As having empty contexts is a common +# practice, we decided to overwrite TestSuite#empty? in order to +# allow them. Having a failure when no tests have been defined seems +# counter-intuitive. +class Test::Unit::TestSuite + unless method_defined?(:empty?) + def empty? + false + end + end +end + +# We added setup, test and context as class methods, and the instance +# method setup now iterates on the setup blocks. Note that all setup +# blocks must be defined with the block syntax. Adding a setup instance +# method defeats the purpose of this library. +class Test::Unit::TestCase + def self.setup(&block) + setup_blocks << block + end + + def setup + self.class.setup_blocks.each do |block| + instance_eval(&block) + end + end + + def self.context(name, &block) + subclass = Class.new(self.superclass) + subclass.setup_blocks.unshift(*setup_blocks) + subclass.class_eval(&block) + const_set(context_name(name), subclass) + end + + def self.test(name, &block) + define_method(test_name(name), &block) + end + + class << self + alias_method :should, :test + alias_method :describe, :context + end + +private + + def self.setup_blocks + @setup_blocks ||= [] + end + + def self.context_name(name) + "Test#{sanitize_name(name).gsub(/(^| )(\w)/) { $2.upcase }}".to_sym + end + + def self.test_name(name) + "test_#{sanitize_name(name).gsub(/\s+/,'_')}".to_sym + end + + def self.sanitize_name(name) + name.gsub(/\W+/, ' ').strip + end +end diff --git a/vendor/gems/gems/sinatra-0.9.4/test/data/reload_app_file.rb b/vendor/gems/gems/sinatra-0.9.4/test/data/reload_app_file.rb new file mode 100755 index 00000000..673ab7cd --- /dev/null +++ b/vendor/gems/gems/sinatra-0.9.4/test/data/reload_app_file.rb @@ -0,0 +1,3 @@ +$reload_count += 1 + +$reload_app.get('/') { 'Hello from reload file' } diff --git a/vendor/gems/gems/sinatra-0.9.4/test/erb_test.rb b/vendor/gems/gems/sinatra-0.9.4/test/erb_test.rb new file mode 100755 index 00000000..cc68c5ce --- /dev/null +++ b/vendor/gems/gems/sinatra-0.9.4/test/erb_test.rb @@ -0,0 +1,81 @@ +require File.dirname(__FILE__) + '/helper' + +class ERBTest < Test::Unit::TestCase + def erb_app(&block) + mock_app { + set :views, File.dirname(__FILE__) + '/views' + get '/', &block + } + get '/' + end + + it 'renders inline ERB strings' do + erb_app { erb '<%= 1 + 1 %>' } + assert ok? + assert_equal '2', body + end + + it 'renders .erb files in views path' do + erb_app { erb :hello } + assert ok? + assert_equal "Hello World\n", body + end + + it 'takes a :locals option' do + erb_app { + locals = {:foo => 'Bar'} + erb '<%= foo %>', :locals => locals + } + assert ok? + assert_equal 'Bar', body + end + + it "renders with inline layouts" do + mock_app { + layout { 'THIS. IS. <%= yield.upcase %>!' } + get('/') { erb 'Sparta' } + } + get '/' + assert ok? + assert_equal 'THIS. IS. SPARTA!', body + end + + it "renders with file layouts" do + erb_app { + erb 'Hello World', :layout => :layout2 + } + assert ok? + assert_equal "ERB Layout!\nHello World\n", body + end + + it "renders erb with blocks" do + mock_app { + def container + @_out_buf << "THIS." + yield + @_out_buf << "SPARTA!" + end + def is; "IS." end + get '/' do + erb '<% container do %> <%= is %> <% end %>' + end + } + get '/' + assert ok? + assert_equal 'THIS. IS. SPARTA!', body + end + + it "can be used in a nested fashion for partials and whatnot" do + mock_app { + template(:inner) { "<%= 'hi' %>" } + template(:outer) { "<%= erb :inner %>" } + get '/' do + erb :outer + end + } + + get '/' + assert ok? + assert_equal 'hi', body + end +end diff --git a/vendor/gems/gems/sinatra-0.9.4/test/extensions_test.rb b/vendor/gems/gems/sinatra-0.9.4/test/extensions_test.rb new file mode 100755 index 00000000..7977c29a --- /dev/null +++ b/vendor/gems/gems/sinatra-0.9.4/test/extensions_test.rb @@ -0,0 +1,100 @@ +require File.dirname(__FILE__) + '/helper' + +class ExtensionsTest < Test::Unit::TestCase + module FooExtensions + def foo + end + + private + def im_hiding_in_ur_foos + end + end + + module BarExtensions + def bar + end + end + + module BazExtensions + def baz + end + end + + module QuuxExtensions + def quux + end + end + + module PainExtensions + def foo=(name); end + def bar?(name); end + def fizz!(name); end + end + + it 'will add the methods to the DSL for the class in which you register them and its subclasses' do + Sinatra::Base.register FooExtensions + assert Sinatra::Base.respond_to?(:foo) + + Sinatra::Default.register BarExtensions + assert Sinatra::Default.respond_to?(:bar) + assert Sinatra::Default.respond_to?(:foo) + assert !Sinatra::Base.respond_to?(:bar) + end + + it 'allows extending by passing a block' do + Sinatra::Base.register { + def im_in_ur_anonymous_module; end + } + assert Sinatra::Base.respond_to?(:im_in_ur_anonymous_module) + end + + it 'will make sure any public methods added via Default#register are delegated to Sinatra::Delegator' do + Sinatra::Default.register FooExtensions + assert Sinatra::Delegator.private_instance_methods. + map { |m| m.to_sym }.include?(:foo) + assert !Sinatra::Delegator.private_instance_methods. + map { |m| m.to_sym }.include?(:im_hiding_in_ur_foos) + end + + it 'will handle special method names' do + Sinatra::Default.register PainExtensions + assert Sinatra::Delegator.private_instance_methods. + map { |m| m.to_sym }.include?(:foo=) + assert Sinatra::Delegator.private_instance_methods. + map { |m| m.to_sym }.include?(:bar?) + assert Sinatra::Delegator.private_instance_methods. + map { |m| m.to_sym }.include?(:fizz!) + end + + it 'will not delegate methods on Base#register' do + Sinatra::Base.register QuuxExtensions + assert !Sinatra::Delegator.private_instance_methods.include?("quux") + end + + it 'will extend the Sinatra::Default application by default' do + Sinatra.register BazExtensions + assert !Sinatra::Base.respond_to?(:baz) + assert Sinatra::Default.respond_to?(:baz) + end + + module BizzleExtension + def bizzle + bizzle_option + end + + def self.registered(base) + fail "base should be BizzleApp" unless base == BizzleApp + fail "base should have already extended BizzleExtension" unless base.respond_to?(:bizzle) + base.set :bizzle_option, 'bizzle!' + end + end + + class BizzleApp < Sinatra::Base + end + + it 'sends .registered to the extension module after extending the class' do + BizzleApp.register BizzleExtension + assert_equal 'bizzle!', BizzleApp.bizzle_option + assert_equal 'bizzle!', BizzleApp.bizzle + end +end diff --git a/vendor/gems/gems/sinatra-0.9.4/test/filter_test.rb b/vendor/gems/gems/sinatra-0.9.4/test/filter_test.rb new file mode 100755 index 00000000..38f0495b --- /dev/null +++ b/vendor/gems/gems/sinatra-0.9.4/test/filter_test.rb @@ -0,0 +1,99 @@ +require File.dirname(__FILE__) + '/helper' + +class FilterTest < Test::Unit::TestCase + it "executes filters in the order defined" do + count = 0 + mock_app do + get('/') { 'Hello World' } + before { + assert_equal 0, count + count = 1 + } + before { + assert_equal 1, count + count = 2 + } + end + + get '/' + assert ok? + assert_equal 2, count + assert_equal 'Hello World', body + end + + it "allows filters to modify the request" do + mock_app { + get('/foo') { 'foo' } + get('/bar') { 'bar' } + before { request.path_info = '/bar' } + } + + get '/foo' + assert ok? + assert_equal 'bar', body + end + + it "can modify instance variables available to routes" do + mock_app { + before { @foo = 'bar' } + get('/foo') { @foo } + } + + get '/foo' + assert ok? + assert_equal 'bar', body + end + + it "allows redirects in filters" do + mock_app { + before { redirect '/bar' } + get('/foo') do + fail 'before block should have halted processing' + 'ORLY?!' + end + } + + get '/foo' + assert redirect? + assert_equal '/bar', response['Location'] + assert_equal '', body + end + + it "does not modify the response with its return value" do + mock_app { + before { 'Hello World!' } + get '/foo' do + assert_equal [], response.body + 'cool' + end + } + + get '/foo' + assert ok? + assert_equal 'cool', body + end + + it "does modify the response with halt" do + mock_app { + before { halt 302, 'Hi' } + get '/foo' do + "should not happen" + end + } + + get '/foo' + assert_equal 302, response.status + assert_equal 'Hi', body + end + + it "gives you access to params" do + mock_app { + before { @foo = params['foo'] } + get('/foo') { @foo } + } + + get '/foo?foo=cool' + assert ok? + assert_equal 'cool', body + end +end diff --git a/vendor/gems/gems/sinatra-0.9.4/test/haml_test.rb b/vendor/gems/gems/sinatra-0.9.4/test/haml_test.rb new file mode 100755 index 00000000..3d6ed69e --- /dev/null +++ b/vendor/gems/gems/sinatra-0.9.4/test/haml_test.rb @@ -0,0 +1,90 @@ +require File.dirname(__FILE__) + '/helper' +require 'haml' + +class HAMLTest < Test::Unit::TestCase + def haml_app(&block) + mock_app { + set :views, File.dirname(__FILE__) + '/views' + get '/', &block + } + get '/' + end + + it 'renders inline HAML strings' do + haml_app { haml '%h1 Hiya' } + assert ok? + assert_equal "

Hiya

\n", body + end + + it 'renders .haml files in views path' do + haml_app { haml :hello } + assert ok? + assert_equal "

Hello From Haml

\n", body + end + + it "renders with inline layouts" do + mock_app { + layout { %q(%h1= 'THIS. IS. ' + yield.upcase) } + get('/') { haml '%em Sparta' } + } + get '/' + assert ok? + assert_equal "

THIS. IS. SPARTA

\n", body + end + + it "renders with file layouts" do + haml_app { + haml 'Hello World', :layout => :layout2 + } + assert ok? + assert_equal "

HAML Layout!

\n

Hello World

\n", body + end + + it "raises error if template not found" do + mock_app { + get('/') { haml :no_such_template } + } + assert_raise(Errno::ENOENT) { get('/') } + end + + it "passes HAML options to the Haml engine" do + mock_app { + get '/' do + haml "!!!\n%h1 Hello World", :format => :html5 + end + } + get '/' + assert ok? + assert_equal "\n

Hello World

\n", body + end + + it "passes default HAML options to the Haml engine" do + mock_app { + set :haml, {:format => :html5} + get '/' do + haml "!!!\n%h1 Hello World" + end + } + get '/' + assert ok? + assert_equal "\n

Hello World

\n", body + end + + it "merges the default HAML options with the overrides and passes them to the Haml engine" do + mock_app { + set :haml, {:format => :html5, :attr_wrapper => '"'} # default HAML attr are + get '/' do + haml "!!!\n%h1{:class => :header} Hello World" + end + get '/html4' do + haml "!!!\n%h1{:class => 'header'} Hello World", :format => :html4 + end + } + get '/' + assert ok? + assert_equal "\n

Hello World

\n", body + get '/html4' + assert ok? + assert_match(/^ '/foo') + assert_equal 302, response.status + assert_equal '/foo', response['Location'] + end + end + + describe 'error' do + it 'sets a status code and halts' do + mock_app { + get '/' do + error 501 + fail 'error should halt' + end + } + + get '/' + assert_equal 501, status + assert_equal '', body + end + + it 'takes an optional body' do + mock_app { + get '/' do + error 501, 'FAIL' + fail 'error should halt' + end + } + + get '/' + assert_equal 501, status + assert_equal 'FAIL', body + end + + it 'uses a 500 status code when first argument is a body' do + mock_app { + get '/' do + error 'FAIL' + fail 'error should halt' + end + } + + get '/' + assert_equal 500, status + assert_equal 'FAIL', body + end + end + + describe 'not_found' do + it 'halts with a 404 status' do + mock_app { + get '/' do + not_found + fail 'not_found should halt' + end + } + + get '/' + assert_equal 404, status + assert_equal '', body + end + end + + describe 'headers' do + it 'sets headers on the response object when given a Hash' do + mock_app { + get '/' do + headers 'X-Foo' => 'bar', 'X-Baz' => 'bling' + 'kthx' + end + } + + get '/' + assert ok? + assert_equal 'bar', response['X-Foo'] + assert_equal 'bling', response['X-Baz'] + assert_equal 'kthx', body + end + + it 'returns the response headers hash when no hash provided' do + mock_app { + get '/' do + headers['X-Foo'] = 'bar' + 'kthx' + end + } + + get '/' + assert ok? + assert_equal 'bar', response['X-Foo'] + end + end + + describe 'session' do + it 'uses the existing rack.session' do + mock_app { + get '/' do + session[:foo] + end + } + + get '/', {}, { 'rack.session' => { :foo => 'bar' } } + assert_equal 'bar', body + end + + it 'creates a new session when none provided' do + mock_app { + get '/' do + assert session.empty? + session[:foo] = 'bar' + 'Hi' + end + } + + get '/' + assert_equal 'Hi', body + end + end + + describe 'media_type' do + include Sinatra::Helpers + + it "looks up media types in Rack's MIME registry" do + Rack::Mime::MIME_TYPES['.foo'] = 'application/foo' + assert_equal 'application/foo', media_type('foo') + assert_equal 'application/foo', media_type('.foo') + assert_equal 'application/foo', media_type(:foo) + end + + it 'returns nil when given nil' do + assert media_type(nil).nil? + end + + it 'returns nil when media type not registered' do + assert media_type(:bizzle).nil? + end + + it 'returns the argument when given a media type string' do + assert_equal 'text/plain', media_type('text/plain') + end + end + + describe 'content_type' do + it 'sets the Content-Type header' do + mock_app { + get '/' do + content_type 'text/plain' + 'Hello World' + end + } + + get '/' + assert_equal 'text/plain', response['Content-Type'] + assert_equal 'Hello World', body + end + + it 'takes media type parameters (like charset=)' do + mock_app { + get '/' do + content_type 'text/html', :charset => 'utf-8' + "

Hello, World

" + end + } + + get '/' + assert ok? + assert_equal 'text/html;charset=utf-8', response['Content-Type'] + assert_equal "

Hello, World

", body + end + + it "looks up symbols in Rack's mime types dictionary" do + Rack::Mime::MIME_TYPES['.foo'] = 'application/foo' + mock_app { + get '/foo.xml' do + content_type :foo + "I AM FOO" + end + } + + get '/foo.xml' + assert ok? + assert_equal 'application/foo', response['Content-Type'] + assert_equal 'I AM FOO', body + end + + it 'fails when no mime type is registered for the argument provided' do + mock_app { + get '/foo.xml' do + content_type :bizzle + "I AM FOO" + end + } + + assert_raise(RuntimeError) { get '/foo.xml' } + end + end + + describe 'send_file' do + setup do + @file = File.dirname(__FILE__) + '/file.txt' + File.open(@file, 'wb') { |io| io.write('Hello World') } + end + + def teardown + File.unlink @file + @file = nil + end + + def send_file_app(opts={}) + path = @file + mock_app { + get '/file.txt' do + send_file path, opts + end + } + end + + it "sends the contents of the file" do + send_file_app + get '/file.txt' + assert ok? + assert_equal 'Hello World', body + end + + it 'sets the Content-Type response header if a mime-type can be located' do + send_file_app + get '/file.txt' + assert_equal 'text/plain', response['Content-Type'] + end + + it 'sets the Content-Length response header' do + send_file_app + get '/file.txt' + assert_equal 'Hello World'.length.to_s, response['Content-Length'] + end + + it 'sets the Last-Modified response header' do + send_file_app + get '/file.txt' + assert_equal File.mtime(@file).httpdate, response['Last-Modified'] + end + + it "returns a 404 when not found" do + mock_app { + get '/' do + send_file 'this-file-does-not-exist.txt' + end + } + get '/' + assert not_found? + end + + it "does not set the Content-Disposition header by default" do + send_file_app + get '/file.txt' + assert_nil response['Content-Disposition'] + end + + it "sets the Content-Disposition header when :disposition set to 'attachment'" do + send_file_app :disposition => 'attachment' + get '/file.txt' + assert_equal 'attachment; filename="file.txt"', response['Content-Disposition'] + end + + it "sets the Content-Disposition header when :filename provided" do + send_file_app :filename => 'foo.txt' + get '/file.txt' + assert_equal 'attachment; filename="foo.txt"', response['Content-Disposition'] + end + end + + describe 'last_modified' do + setup do + now = Time.now + mock_app { + get '/' do + body { 'Hello World' } + last_modified now + 'Boo!' + end + } + @now = now + end + + it 'sets the Last-Modified header to a valid RFC 2616 date value' do + get '/' + assert_equal @now.httpdate, response['Last-Modified'] + end + + it 'returns a body when conditional get misses' do + get '/' + assert_equal 200, status + assert_equal 'Boo!', body + end + + it 'halts when a conditional GET matches' do + get '/', {}, { 'HTTP_IF_MODIFIED_SINCE' => @now.httpdate } + assert_equal 304, status + assert_equal '', body + end + end + + describe 'etag' do + setup do + mock_app { + get '/' do + body { 'Hello World' } + etag 'FOO' + 'Boo!' + end + } + end + + it 'sets the ETag header' do + get '/' + assert_equal '"FOO"', response['ETag'] + end + + it 'returns a body when conditional get misses' do + get '/' + assert_equal 200, status + assert_equal 'Boo!', body + end + + it 'halts when a conditional GET matches' do + get '/', {}, { 'HTTP_IF_NONE_MATCH' => '"FOO"' } + assert_equal 304, status + assert_equal '', body + end + + it 'should handle multiple ETag values in If-None-Match header' do + get '/', {}, { 'HTTP_IF_NONE_MATCH' => '"BAR", *' } + assert_equal 304, status + assert_equal '', body + end + + it 'uses a weak etag with the :weak option' do + mock_app { + get '/' do + etag 'FOO', :weak + "that's weak, dude." + end + } + get '/' + assert_equal 'W/"FOO"', response['ETag'] + end + end + + describe 'back' do + it "makes redirecting back pretty" do + mock_app { + get '/foo' do + redirect back + end + } + + get '/foo', {}, 'HTTP_REFERER' => 'http://github.com' + assert redirect? + assert_equal "http://github.com", response.location + end + end + + module ::HelperOne; def one; '1'; end; end + module ::HelperTwo; def two; '2'; end; end + + describe 'Adding new helpers' do + it 'takes a list of modules to mix into the app' do + mock_app { + helpers ::HelperOne, ::HelperTwo + + get '/one' do + one + end + + get '/two' do + two + end + } + + get '/one' + assert_equal '1', body + + get '/two' + assert_equal '2', body + end + + it 'takes a block to mix into the app' do + mock_app { + helpers do + def foo + 'foo' + end + end + + get '/' do + foo + end + } + + get '/' + assert_equal 'foo', body + end + + it 'evaluates the block in class context so that methods can be aliased' do + mock_app { + helpers do + alias_method :h, :escape_html + end + + get '/' do + h('42 < 43') + end + } + + get '/' + assert ok? + assert_equal '42 < 43', body + end + end +end diff --git a/vendor/gems/gems/sinatra-0.9.4/test/mapped_error_test.rb b/vendor/gems/gems/sinatra-0.9.4/test/mapped_error_test.rb new file mode 100755 index 00000000..fa57d9a1 --- /dev/null +++ b/vendor/gems/gems/sinatra-0.9.4/test/mapped_error_test.rb @@ -0,0 +1,155 @@ +require File.dirname(__FILE__) + '/helper' + +class FooError < RuntimeError +end + +class FooNotFound < Sinatra::NotFound +end + +class MappedErrorTest < Test::Unit::TestCase + def test_default + assert true + end + + describe 'Exception Mappings' do + it 'invokes handlers registered with ::error when raised' do + mock_app { + set :raise_errors, false + error(FooError) { 'Foo!' } + get '/' do + raise FooError + end + } + get '/' + assert_equal 500, status + assert_equal 'Foo!', body + end + + it 'uses the Exception handler if no matching handler found' do + mock_app { + set :raise_errors, false + error(Exception) { 'Exception!' } + get '/' do + raise FooError + end + } + + get '/' + assert_equal 500, status + assert_equal 'Exception!', body + end + + it "sets env['sinatra.error'] to the rescued exception" do + mock_app { + set :raise_errors, false + error(FooError) { + assert env.include?('sinatra.error') + assert env['sinatra.error'].kind_of?(FooError) + 'looks good' + } + get '/' do + raise FooError + end + } + get '/' + assert_equal 'looks good', body + end + + it "raises without calling the handler when the raise_errors options is set" do + mock_app { + set :raise_errors, true + error(FooError) { "she's not there." } + get '/' do + raise FooError + end + } + assert_raise(FooError) { get '/' } + end + + it "never raises Sinatra::NotFound beyond the application" do + mock_app { + set :raise_errors, true + get '/' do + raise Sinatra::NotFound + end + } + assert_nothing_raised { get '/' } + assert_equal 404, status + end + + it "cascades for subclasses of Sinatra::NotFound" do + mock_app { + set :raise_errors, true + error(FooNotFound) { "foo! not found." } + get '/' do + raise FooNotFound + end + } + assert_nothing_raised { get '/' } + assert_equal 404, status + assert_equal 'foo! not found.', body + end + + it 'has a not_found method for backwards compatibility' do + mock_app { + not_found do + "Lost, are we?" + end + } + + get '/test' + assert_equal 404, status + assert_equal "Lost, are we?", body + end + end + + describe 'Custom Error Pages' do + it 'allows numeric status code mappings to be registered with ::error' do + mock_app { + set :raise_errors, false + error(500) { 'Foo!' } + get '/' do + [500, {}, 'Internal Foo Error'] + end + } + get '/' + assert_equal 500, status + assert_equal 'Foo!', body + end + + it 'allows ranges of status code mappings to be registered with :error' do + mock_app { + set :raise_errors, false + error(500..550) { "Error: #{response.status}" } + get '/' do + [507, {}, 'A very special error'] + end + } + get '/' + assert_equal 507, status + assert_equal 'Error: 507', body + end + + class FooError < RuntimeError + end + + it 'runs after exception mappings and overwrites body' do + mock_app { + set :raise_errors, false + error FooError do + response.status = 502 + 'from exception mapping' + end + error(500) { 'from 500 handler' } + error(502) { 'from custom error page' } + + get '/' do + raise FooError + end + } + get '/' + assert_equal 502, status + assert_equal 'from custom error page', body + end + end +end diff --git a/vendor/gems/gems/sinatra-0.9.4/test/middleware_test.rb b/vendor/gems/gems/sinatra-0.9.4/test/middleware_test.rb new file mode 100755 index 00000000..2ebef29a --- /dev/null +++ b/vendor/gems/gems/sinatra-0.9.4/test/middleware_test.rb @@ -0,0 +1,68 @@ +require File.dirname(__FILE__) + '/helper' + +class MiddlewareTest < Test::Unit::TestCase + setup do + @app = mock_app(Sinatra::Default) { + get '/*' do + response.headers['X-Tests'] = env['test.ran']. + map { |n| n.split('::').last }. + join(', ') + env['PATH_INFO'] + end + } + end + + class MockMiddleware < Struct.new(:app) + def call(env) + (env['test.ran'] ||= []) << self.class.to_s + app.call(env) + end + end + + class UpcaseMiddleware < MockMiddleware + def call(env) + env['PATH_INFO'] = env['PATH_INFO'].upcase + super + end + end + + it "is added with Sinatra::Application.use" do + @app.use UpcaseMiddleware + get '/hello-world' + assert ok? + assert_equal '/HELLO-WORLD', body + end + + class DowncaseMiddleware < MockMiddleware + def call(env) + env['PATH_INFO'] = env['PATH_INFO'].downcase + super + end + end + + it "runs in the order defined" do + @app.use UpcaseMiddleware + @app.use DowncaseMiddleware + get '/Foo' + assert_equal "/foo", body + assert_equal "UpcaseMiddleware, DowncaseMiddleware", response['X-Tests'] + end + + it "resets the prebuilt pipeline when new middleware is added" do + @app.use UpcaseMiddleware + get '/Foo' + assert_equal "/FOO", body + @app.use DowncaseMiddleware + get '/Foo' + assert_equal '/foo', body + assert_equal "UpcaseMiddleware, DowncaseMiddleware", response['X-Tests'] + end + + it "works when app is used as middleware" do + @app.use UpcaseMiddleware + @app = @app.new + get '/Foo' + assert_equal "/FOO", body + assert_equal "UpcaseMiddleware", response['X-Tests'] + end +end diff --git a/vendor/gems/gems/sinatra-0.9.4/test/options_test.rb b/vendor/gems/gems/sinatra-0.9.4/test/options_test.rb new file mode 100755 index 00000000..19f5ea2d --- /dev/null +++ b/vendor/gems/gems/sinatra-0.9.4/test/options_test.rb @@ -0,0 +1,372 @@ +require File.dirname(__FILE__) + '/helper' + +class OptionsTest < Test::Unit::TestCase + setup do + @base = Sinatra.new(Sinatra::Base) + @default = Sinatra.new(Sinatra::Default) + @base.set :environment, :development + @default.set :environment, :development + end + + it 'sets options to literal values' do + @base.set(:foo, 'bar') + assert @base.respond_to?(:foo) + assert_equal 'bar', @base.foo + end + + it 'sets options to Procs' do + @base.set(:foo, Proc.new { 'baz' }) + assert @base.respond_to?(:foo) + assert_equal 'baz', @base.foo + end + + it "sets multiple options with a Hash" do + @base.set :foo => 1234, + :bar => 'Hello World', + :baz => Proc.new { 'bizzle' } + assert_equal 1234, @base.foo + assert_equal 'Hello World', @base.bar + assert_equal 'bizzle', @base.baz + end + + it 'inherits option methods when subclassed' do + @base.set :foo, 'bar' + @base.set :biz, Proc.new { 'baz' } + + sub = Class.new(@base) + assert sub.respond_to?(:foo) + assert_equal 'bar', sub.foo + assert sub.respond_to?(:biz) + assert_equal 'baz', sub.biz + end + + it 'overrides options in subclass' do + @base.set :foo, 'bar' + @base.set :biz, Proc.new { 'baz' } + sub = Class.new(@base) + sub.set :foo, 'bling' + assert_equal 'bling', sub.foo + assert_equal 'bar', @base.foo + end + + it 'creates setter methods when first defined' do + @base.set :foo, 'bar' + assert @base.respond_to?('foo=') + @base.foo = 'biz' + assert_equal 'biz', @base.foo + end + + it 'creates predicate methods when first defined' do + @base.set :foo, 'hello world' + assert @base.respond_to?(:foo?) + assert @base.foo? + @base.set :foo, nil + assert !@base.foo? + end + + it 'uses existing setter methods if detected' do + class << @base + def foo + @foo + end + def foo=(value) + @foo = 'oops' + end + end + + @base.set :foo, 'bam' + assert_equal 'oops', @base.foo + end + + it "sets multiple options to true with #enable" do + @base.enable :sessions, :foo, :bar + assert @base.sessions + assert @base.foo + assert @base.bar + end + + it "sets multiple options to false with #disable" do + @base.disable :sessions, :foo, :bar + assert !@base.sessions + assert !@base.foo + assert !@base.bar + end + + it 'enables MethodOverride middleware when :methodoverride is enabled' do + @base.set :methodoverride, true + @base.put('/') { 'okay' } + @app = @base + post '/', {'_method'=>'PUT'}, {} + assert_equal 200, status + assert_equal 'okay', body + end + + describe 'clean_trace' do + def clean_backtrace(trace) + Sinatra::Base.new.send(:clean_backtrace, trace) + end + + it 'is enabled on Base' do + assert @base.clean_trace? + end + + it 'is enabled on Default' do + assert @default.clean_trace? + end + + it 'does nothing when disabled' do + backtrace = [ + "./lib/sinatra/base.rb", + "./myapp:42", + ("#{Gem.dir}/some/lib.rb" if defined?(Gem)) + ].compact + + klass = Class.new(Sinatra::Base) + klass.disable :clean_trace + + assert_equal backtrace, klass.new.send(:clean_backtrace, backtrace) + end + + it 'removes sinatra lib paths from backtrace when enabled' do + backtrace = [ + "./lib/sinatra/base.rb", + "./lib/sinatra/compat.rb:42", + "./lib/sinatra/main.rb:55 in `foo'" + ] + assert clean_backtrace(backtrace).empty? + end + + it 'removes ./ prefix from backtrace paths when enabled' do + assert_equal ['myapp.rb:42'], clean_backtrace(['./myapp.rb:42']) + end + + if defined?(Gem) + it 'removes gem lib paths from backtrace when enabled' do + assert clean_backtrace(["#{Gem.dir}/some/lib"]).empty? + end + end + end + + describe 'run' do + it 'is disabled on Base' do + assert ! @base.run? + end + + it 'is enabled on Default when not in test environment' do + @default.set :environment, :development + assert @default.development? + assert @default.run? + + @default.set :environment, :development + assert @default.run? + end + + # TODO: it 'is enabled when $0 == app_file' + end + + describe 'raise_errors' do + it 'is enabled on Base' do + assert @base.raise_errors? + end + + it 'is enabled on Default only in test' do + @default.set(:environment, :development) + assert @default.development? + assert ! @default.raise_errors? + + @default.set(:environment, :production) + assert ! @default.raise_errors? + + @default.set(:environment, :test) + assert @default.raise_errors? + end + end + + describe 'show_exceptions' do + %w[development test production none].each do |environment| + it "is disabled on Base in #{environment} environments" do + @base.set(:environment, environment) + assert ! @base.show_exceptions? + end + end + + it 'is enabled on Default only in development' do + @base.set(:environment, :development) + assert @default.development? + assert @default.show_exceptions? + + @default.set(:environment, :test) + assert ! @default.show_exceptions? + + @base.set(:environment, :production) + assert ! @base.show_exceptions? + end + + it 'returns a friendly 500' do + klass = Sinatra.new(Sinatra::Default) + mock_app(klass) { + enable :show_exceptions + + get '/' do + raise StandardError + end + } + + get '/' + assert_equal 500, status + assert body.include?("StandardError") + assert body.include?("show_exceptions option") + end + end + + describe 'dump_errors' do + it 'is disabled on Base' do + assert ! @base.dump_errors? + end + + it 'is enabled on Default' do + assert @default.dump_errors? + end + + it 'dumps exception with backtrace to rack.errors' do + klass = Sinatra.new(Sinatra::Default) + + mock_app(klass) { + disable :raise_errors + + error do + error = @env['rack.errors'].instance_variable_get(:@error) + error.rewind + + error.read + end + + get '/' do + raise + end + } + + get '/' + assert body.include?("RuntimeError") && body.include?("options_test.rb") + end + end + + describe 'sessions' do + it 'is disabled on Base' do + assert ! @base.sessions? + end + + it 'is disabled on Default' do + assert ! @default.sessions? + end + + # TODO: it 'uses Rack::Session::Cookie when enabled' do + end + + describe 'logging' do + it 'is disabled on Base' do + assert ! @base.logging? + end + + it 'is enabled on Default when not in test environment' do + assert @default.logging? + + @default.set :environment, :test + assert ! @default.logging + end + + # TODO: it 'uses Rack::CommonLogger when enabled' do + end + + describe 'static' do + it 'is disabled on Base' do + assert ! @base.static? + end + + it 'is enabled on Default' do + assert @default.static? + end + + # TODO: it setup static routes if public is enabled + # TODO: however, that's already tested in static_test so... + end + + describe 'host' do + it 'defaults to 0.0.0.0' do + assert_equal '0.0.0.0', @base.host + assert_equal '0.0.0.0', @default.host + end + end + + describe 'port' do + it 'defaults to 4567' do + assert_equal 4567, @base.port + assert_equal 4567, @default.port + end + end + + describe 'server' do + it 'is one of thin, mongrel, webrick' do + assert_equal %w[thin mongrel webrick], @base.server + assert_equal %w[thin mongrel webrick], @default.server + end + end + + describe 'app_file' do + it 'is nil' do + assert @base.app_file.nil? + assert @default.app_file.nil? + end + end + + describe 'root' do + it 'is nil if app_file is not set' do + assert @base.root.nil? + assert @default.root.nil? + end + + it 'is equal to the expanded basename of app_file' do + @base.app_file = __FILE__ + assert_equal File.expand_path(File.dirname(__FILE__)), @base.root + + @default.app_file = __FILE__ + assert_equal File.expand_path(File.dirname(__FILE__)), @default.root + end + end + + describe 'views' do + it 'is nil if root is not set' do + assert @base.views.nil? + assert @default.views.nil? + end + + it 'is set to root joined with views/' do + @base.root = File.dirname(__FILE__) + assert_equal File.dirname(__FILE__) + "/views", @base.views + + @default.root = File.dirname(__FILE__) + assert_equal File.dirname(__FILE__) + "/views", @default.views + end + end + + describe 'public' do + it 'is nil if root is not set' do + assert @base.public.nil? + assert @default.public.nil? + end + + it 'is set to root joined with public/' do + @base.root = File.dirname(__FILE__) + assert_equal File.dirname(__FILE__) + "/public", @base.public + + @default.root = File.dirname(__FILE__) + assert_equal File.dirname(__FILE__) + "/public", @default.public + end + end + + describe 'lock' do + it 'is disabled by default' do + assert ! @base.lock? + end + end +end diff --git a/vendor/gems/gems/sinatra-0.9.4/test/render_backtrace_test.rb b/vendor/gems/gems/sinatra-0.9.4/test/render_backtrace_test.rb new file mode 100755 index 00000000..350beba4 --- /dev/null +++ b/vendor/gems/gems/sinatra-0.9.4/test/render_backtrace_test.rb @@ -0,0 +1,145 @@ +require File.dirname(__FILE__) + '/helper' + +require 'sass/error' + +class RenderBacktraceTest < Test::Unit::TestCase + VIEWS = File.dirname(__FILE__) + '/views' + + def assert_raise_at(filename, line, exception = RuntimeError) + f, l = nil + assert_raise(exception) do + begin + get('/') + rescue => e + f, l = e.backtrace.first.split(':') + raise + end + end + assert_equal(filename, f, "expected #{exception.name} in #{filename}, was #{f}") + assert_equal(line, l.to_i, "expected #{exception.name} in #{filename} at line #{line}, was at line #{l}") + end + + def backtrace_app(&block) + mock_app { + use_in_file_templates! + set :views, RenderBacktraceTest::VIEWS + template :builder_template do + 'raise "error"' + end + template :erb_template do + '<% raise "error" %>' + end + template :haml_template do + '%h1= raise "error"' + end + template :sass_template do + '+syntax-error' + end + get '/', &block + } + end + + it "provides backtrace for Builder template" do + backtrace_app { builder :error } + assert_raise_at(File.join(VIEWS,'error.builder'), 2) + end + + it "provides backtrace for ERB template" do + backtrace_app { erb :error } + assert_raise_at(File.join(VIEWS,'error.erb'), 2) + end + + it "provides backtrace for HAML template" do + backtrace_app { haml :error } + assert_raise_at(File.join(VIEWS,'error.haml'), 2) + end + + it "provides backtrace for Sass template" do + backtrace_app { sass :error } + assert_raise_at(File.join(VIEWS,'error.sass'), 2, Sass::SyntaxError) + end + + it "provides backtrace for ERB template with locals" do + backtrace_app { erb :error, {}, :french => true } + assert_raise_at(File.join(VIEWS,'error.erb'), 3) + end + + it "provides backtrace for HAML template with locals" do + backtrace_app { haml :error, {}, :french => true } + assert_raise_at(File.join(VIEWS,'error.haml'), 3) + end + + it "provides backtrace for inline Builder string" do + backtrace_app { builder "raise 'Ack! Thbbbt!'"} + assert_raise_at(__FILE__, (__LINE__-1)) + end + + it "provides backtrace for inline ERB string" do + backtrace_app { erb "<% raise 'bidi-bidi-bidi' %>" } + assert_raise_at(__FILE__, (__LINE__-1)) + end + + it "provides backtrace for inline HAML string" do + backtrace_app { haml "%h1= raise 'Lions and tigers and bears! Oh, my!'" } + assert_raise_at(__FILE__, (__LINE__-1)) + end + + # it "provides backtrace for inline Sass string" do + # backtrace_app { sass '+buh-bye' } + # assert_raise_at(__FILE__, (__LINE__-1), Sass::SyntaxError) + # end + + it "provides backtrace for named Builder template" do + backtrace_app { builder :builder_template } + assert_raise_at(__FILE__, (__LINE__-68)) + end + + it "provides backtrace for named ERB template" do + backtrace_app { erb :erb_template } + assert_raise_at(__FILE__, (__LINE__-70)) + end + + it "provides backtrace for named HAML template" do + backtrace_app { haml :haml_template } + assert_raise_at(__FILE__, (__LINE__-72)) + end + + # it "provides backtrace for named Sass template" do + # backtrace_app { sass :sass_template } + # assert_raise_at(__FILE__, (__LINE__-74), Sass::SyntaxError) + # end + + it "provides backtrace for in file Builder template" do + backtrace_app { builder :builder_in_file } + assert_raise_at(__FILE__, (__LINE__+22)) + end + + it "provides backtrace for in file ERB template" do + backtrace_app { erb :erb_in_file } + assert_raise_at(__FILE__, (__LINE__+20)) + end + + it "provides backtrace for in file HAML template" do + backtrace_app { haml :haml_in_file } + assert_raise_at(__FILE__, (__LINE__+18)) + end + + # it "provides backtrace for in file Sass template" do + # backtrace_app { sass :sass_in_file } + # assert_raise_at(__FILE__, (__LINE__+16), Sass::SyntaxError) + # end +end + +__END__ + +@@ builder_in_file +raise "bif" + +@@ erb_in_file +<% raise "bam" %> + +@@ haml_in_file +%h1= raise "pow" + +@@ sass_in_file ++blam diff --git a/vendor/gems/gems/sinatra-0.9.4/test/request_test.rb b/vendor/gems/gems/sinatra-0.9.4/test/request_test.rb new file mode 100755 index 00000000..44dac6cb --- /dev/null +++ b/vendor/gems/gems/sinatra-0.9.4/test/request_test.rb @@ -0,0 +1,18 @@ +require File.dirname(__FILE__) + '/helper' + +class RequestTest < Test::Unit::TestCase + it 'responds to #user_agent' do + request = Sinatra::Request.new({'HTTP_USER_AGENT' => 'Test'}) + assert request.respond_to?(:user_agent) + assert_equal 'Test', request.user_agent + end + + it 'parses POST params when Content-Type is form-dataish' do + request = Sinatra::Request.new( + 'REQUEST_METHOD' => 'PUT', + 'CONTENT_TYPE' => 'application/x-www-form-urlencoded', + 'rack.input' => StringIO.new('foo=bar') + ) + assert_equal 'bar', request.params['foo'] + end +end diff --git a/vendor/gems/gems/sinatra-0.9.4/test/response_test.rb b/vendor/gems/gems/sinatra-0.9.4/test/response_test.rb new file mode 100755 index 00000000..5aa5f4e6 --- /dev/null +++ b/vendor/gems/gems/sinatra-0.9.4/test/response_test.rb @@ -0,0 +1,42 @@ +# encoding: utf-8 + +require File.dirname(__FILE__) + '/helper' + +class ResponseTest < Test::Unit::TestCase + setup do + @response = Sinatra::Response.new + end + + it "initializes with 200, text/html, and empty body" do + assert_equal 200, @response.status + assert_equal 'text/html', @response['Content-Type'] + assert_equal [], @response.body + end + + it 'uses case insensitive headers' do + @response['content-type'] = 'application/foo' + assert_equal 'application/foo', @response['Content-Type'] + assert_equal 'application/foo', @response['CONTENT-TYPE'] + end + + it 'writes to body' do + @response.body = 'Hello' + @response.write ' World' + assert_equal 'Hello World', @response.body + end + + [204, 304].each do |status_code| + it "removes the Content-Type header and body when response status is #{status_code}" do + @response.status = status_code + @response.body = ['Hello World'] + assert_equal [status_code, {}, []], @response.finish + end + end + + it 'Calculates the Content-Length using the bytesize of the body' do + @response.body = ['Hello', 'World!', '✈'] + status, headers, body = @response.finish + assert_equal '14', headers['Content-Length'] + assert_equal @response.body, body + end +end diff --git a/vendor/gems/gems/sinatra-0.9.4/test/result_test.rb b/vendor/gems/gems/sinatra-0.9.4/test/result_test.rb new file mode 100755 index 00000000..5100abf4 --- /dev/null +++ b/vendor/gems/gems/sinatra-0.9.4/test/result_test.rb @@ -0,0 +1,98 @@ +require File.dirname(__FILE__) + '/helper' + +class ResultTest < Test::Unit::TestCase + it "sets response.body when result is a String" do + mock_app { + get '/' do + 'Hello World' + end + } + + get '/' + assert ok? + assert_equal 'Hello World', body + end + + it "sets response.body when result is an Array of Strings" do + mock_app { + get '/' do + ['Hello', 'World'] + end + } + + get '/' + assert ok? + assert_equal 'HelloWorld', body + end + + it "sets response.body when result responds to #each" do + mock_app { + get '/' do + res = lambda { 'Hello World' } + def res.each ; yield call ; end + res + end + } + + get '/' + assert ok? + assert_equal 'Hello World', body + end + + it "sets response.body to [] when result is nil" do + mock_app { + get '/' do + nil + end + } + + get '/' + assert ok? + assert_equal '', body + end + + it "sets status, headers, and body when result is a Rack response tuple" do + mock_app { + get '/' do + [205, {'Content-Type' => 'foo/bar'}, 'Hello World'] + end + } + + get '/' + assert_equal 205, status + assert_equal 'foo/bar', response['Content-Type'] + assert_equal 'Hello World', body + end + + it "sets status and body when result is a two-tuple" do + mock_app { + get '/' do + [409, 'formula of'] + end + } + + get '/' + assert_equal 409, status + assert_equal 'formula of', body + end + + it "raises a TypeError when result is a non two or three tuple Array" do + mock_app { + get '/' do + [409, 'formula of', 'something else', 'even more'] + end + } + + assert_raise(TypeError) { get '/' } + end + + it "sets status when result is a Fixnum status code" do + mock_app { + get('/') { 205 } + } + + get '/' + assert_equal 205, status + assert_equal '', body + end +end diff --git a/vendor/gems/gems/sinatra-0.9.4/test/route_added_hook_test.rb b/vendor/gems/gems/sinatra-0.9.4/test/route_added_hook_test.rb new file mode 100755 index 00000000..08fdd925 --- /dev/null +++ b/vendor/gems/gems/sinatra-0.9.4/test/route_added_hook_test.rb @@ -0,0 +1,59 @@ +require File.dirname(__FILE__) + '/helper' + +module RouteAddedTest + @routes, @procs = [], [] + def self.routes ; @routes ; end + def self.procs ; @procs ; end + def self.route_added(verb, path, proc) + @routes << [verb, path] + @procs << proc + end +end + +class RouteAddedHookTest < Test::Unit::TestCase + setup { + RouteAddedTest.routes.clear + RouteAddedTest.procs.clear + } + + it "should be notified of an added route" do + mock_app(Class.new(Sinatra::Base)) { + register RouteAddedTest + get('/') {} + } + + assert_equal [["GET", "/"], ["HEAD", "/"]], + RouteAddedTest.routes + end + + it "should include hooks from superclass" do + a = Class.new(Class.new(Sinatra::Base)) + b = Class.new(a) + + a.register RouteAddedTest + b.class_eval { post("/sub_app_route") {} } + + assert_equal [["POST", "/sub_app_route"]], + RouteAddedTest.routes + end + + it "should only run once per extension" do + mock_app(Class.new(Sinatra::Base)) { + register RouteAddedTest + register RouteAddedTest + get('/') {} + } + + assert_equal [["GET", "/"], ["HEAD", "/"]], + RouteAddedTest.routes + end + + it "should pass route blocks as an argument" do + mock_app(Class.new(Sinatra::Base)) { + register RouteAddedTest + get('/') {} + } + + assert_kind_of Proc, RouteAddedTest.procs.first + end +end diff --git a/vendor/gems/gems/sinatra-0.9.4/test/routing_test.rb b/vendor/gems/gems/sinatra-0.9.4/test/routing_test.rb new file mode 100755 index 00000000..a8591cae --- /dev/null +++ b/vendor/gems/gems/sinatra-0.9.4/test/routing_test.rb @@ -0,0 +1,784 @@ +require File.dirname(__FILE__) + '/helper' + +# Helper method for easy route pattern matching testing +def route_def(pattern) + mock_app { get(pattern) { } } +end + +class RegexpLookAlike + class MatchData + def captures + ["this", "is", "a", "test"] + end + end + + def match(string) + ::RegexpLookAlike::MatchData.new if string == "/this/is/a/test/" + end + + def keys + ["one", "two", "three", "four"] + end +end + +class RoutingTest < Test::Unit::TestCase + %w[get put post delete].each do |verb| + it "defines #{verb.upcase} request handlers with #{verb}" do + mock_app { + send verb, '/hello' do + 'Hello World' + end + } + + request = Rack::MockRequest.new(@app) + response = request.request(verb.upcase, '/hello', {}) + assert response.ok? + assert_equal 'Hello World', response.body + end + end + + it "defines HEAD request handlers with HEAD" do + mock_app { + head '/hello' do + response['X-Hello'] = 'World!' + 'remove me' + end + } + + request = Rack::MockRequest.new(@app) + response = request.request('HEAD', '/hello', {}) + assert response.ok? + assert_equal 'World!', response['X-Hello'] + assert_equal '', response.body + end + + it "404s when no route satisfies the request" do + mock_app { + get('/foo') { } + } + get '/bar' + assert_equal 404, status + end + + it "overrides the content-type in error handlers" do + mock_app { + before { content_type 'text/plain' } + error Sinatra::NotFound do + content_type "text/html" + "

Not Found

" + end + } + + get '/foo' + assert_equal 404, status + assert_equal 'text/html', response["Content-Type"] + assert_equal "

Not Found

", response.body + end + + it 'takes multiple definitions of a route' do + mock_app { + user_agent(/Foo/) + get '/foo' do + 'foo' + end + + get '/foo' do + 'not foo' + end + } + + get '/foo', {}, 'HTTP_USER_AGENT' => 'Foo' + assert ok? + assert_equal 'foo', body + + get '/foo' + assert ok? + assert_equal 'not foo', body + end + + it "exposes params with indifferent hash" do + mock_app { + get '/:foo' do + assert_equal 'bar', params['foo'] + assert_equal 'bar', params[:foo] + 'well, alright' + end + } + get '/bar' + assert_equal 'well, alright', body + end + + it "merges named params and query string params in params" do + mock_app { + get '/:foo' do + assert_equal 'bar', params['foo'] + assert_equal 'biz', params['baz'] + end + } + get '/bar?baz=biz' + assert ok? + end + + it "supports named params like /hello/:person" do + mock_app { + get '/hello/:person' do + "Hello #{params['person']}" + end + } + get '/hello/Frank' + assert_equal 'Hello Frank', body + end + + it "supports optional named params like /?:foo?/?:bar?" do + mock_app { + get '/?:foo?/?:bar?' do + "foo=#{params[:foo]};bar=#{params[:bar]}" + end + } + + get '/hello/world' + assert ok? + assert_equal "foo=hello;bar=world", body + + get '/hello' + assert ok? + assert_equal "foo=hello;bar=", body + + get '/' + assert ok? + assert_equal "foo=;bar=", body + end + + it "supports single splat params like /*" do + mock_app { + get '/*' do + assert params['splat'].kind_of?(Array) + params['splat'].join "\n" + end + } + + get '/foo' + assert_equal "foo", body + + get '/foo/bar/baz' + assert_equal "foo/bar/baz", body + end + + it "supports mixing multiple splat params like /*/foo/*/*" do + mock_app { + get '/*/foo/*/*' do + assert params['splat'].kind_of?(Array) + params['splat'].join "\n" + end + } + + get '/bar/foo/bling/baz/boom' + assert_equal "bar\nbling\nbaz/boom", body + + get '/bar/foo/baz' + assert not_found? + end + + it "supports mixing named and splat params like /:foo/*" do + mock_app { + get '/:foo/*' do + assert_equal 'foo', params['foo'] + assert_equal ['bar/baz'], params['splat'] + end + } + + get '/foo/bar/baz' + assert ok? + end + + it "matches a dot ('.') as part of a named param" do + mock_app { + get '/:foo/:bar' do + params[:foo] + end + } + + get '/user@example.com/name' + assert_equal 200, response.status + assert_equal 'user@example.com', body + end + + it "matches a literal dot ('.') outside of named params" do + mock_app { + get '/:file.:ext' do + assert_equal 'pony', params[:file] + assert_equal 'jpg', params[:ext] + 'right on' + end + } + + get '/pony.jpg' + assert_equal 200, response.status + assert_equal 'right on', body + end + + it "literally matches . in paths" do + route_def '/test.bar' + + get '/test.bar' + assert ok? + get 'test0bar' + assert not_found? + end + + it "literally matches $ in paths" do + route_def '/test$/' + + get '/test$/' + assert ok? + end + + it "literally matches + in paths" do + route_def '/te+st/' + + get '/te%2Bst/' + assert ok? + get '/teeeeeeest/' + assert not_found? + end + + it "literally matches () in paths" do + route_def '/test(bar)/' + + get '/test(bar)/' + assert ok? + end + + it "supports basic nested params" do + mock_app { + get '/hi' do + params["person"]["name"] + end + } + + get "/hi?person[name]=John+Doe" + assert ok? + assert_equal "John Doe", body + end + + it "exposes nested params with indifferent hash" do + mock_app { + get '/testme' do + assert_equal 'baz', params['bar']['foo'] + assert_equal 'baz', params['bar'][:foo] + 'well, alright' + end + } + get '/testme?bar[foo]=baz' + assert_equal 'well, alright', body + end + + it "supports deeply nested params" do + expected_params = { + "emacs" => { + "map" => { "goto-line" => "M-g g" }, + "version" => "22.3.1" + }, + "browser" => { + "firefox" => {"engine" => {"name"=>"spidermonkey", "version"=>"1.7.0"}}, + "chrome" => {"engine" => {"name"=>"V8", "version"=>"1.0"}} + }, + "paste" => {"name"=>"hello world", "syntax"=>"ruby"} + } + mock_app { + get '/foo' do + assert_equal expected_params, params + 'looks good' + end + } + get '/foo', expected_params + assert ok? + assert_equal 'looks good', body + end + + it "preserves non-nested params" do + mock_app { + get '/foo' do + assert_equal "2", params["article_id"] + assert_equal "awesome", params['comment']['body'] + assert_nil params['comment[body]'] + 'looks good' + end + } + + get '/foo?article_id=2&comment[body]=awesome' + assert ok? + assert_equal 'looks good', body + end + + it "matches paths that include spaces encoded with %20" do + mock_app { + get '/path with spaces' do + 'looks good' + end + } + + get '/path%20with%20spaces' + assert ok? + assert_equal 'looks good', body + end + + it "matches paths that include spaces encoded with +" do + mock_app { + get '/path with spaces' do + 'looks good' + end + } + + get '/path+with+spaces' + assert ok? + assert_equal 'looks good', body + end + + it "URL decodes named parameters and splats" do + mock_app { + get '/:foo/*' do + assert_equal 'hello world', params['foo'] + assert_equal ['how are you'], params['splat'] + nil + end + } + + get '/hello%20world/how%20are%20you' + assert ok? + end + + it 'supports regular expressions' do + mock_app { + get(/^\/foo...\/bar$/) do + 'Hello World' + end + } + + get '/foooom/bar' + assert ok? + assert_equal 'Hello World', body + end + + it 'makes regular expression captures available in params[:captures]' do + mock_app { + get(/^\/fo(.*)\/ba(.*)/) do + assert_equal ['orooomma', 'f'], params[:captures] + 'right on' + end + } + + get '/foorooomma/baf' + assert ok? + assert_equal 'right on', body + end + + it 'supports regular expression look-alike routes' do + mock_app { + get(RegexpLookAlike.new) do + assert_equal 'this', params[:one] + assert_equal 'is', params[:two] + assert_equal 'a', params[:three] + assert_equal 'test', params[:four] + 'right on' + end + } + + get '/this/is/a/test/' + assert ok? + assert_equal 'right on', body + end + + it 'raises a TypeError when pattern is not a String or Regexp' do + assert_raise(TypeError) { + mock_app { get(42){} } + } + end + + it "returns response immediately on halt" do + mock_app { + get '/' do + halt 'Hello World' + 'Boo-hoo World' + end + } + + get '/' + assert ok? + assert_equal 'Hello World', body + end + + it "halts with a response tuple" do + mock_app { + get '/' do + halt 295, {'Content-Type' => 'text/plain'}, 'Hello World' + end + } + + get '/' + assert_equal 295, status + assert_equal 'text/plain', response['Content-Type'] + assert_equal 'Hello World', body + end + + it "halts with an array of strings" do + mock_app { + get '/' do + halt %w[Hello World How Are You] + end + } + + get '/' + assert_equal 'HelloWorldHowAreYou', body + end + + it "transitions to the next matching route on pass" do + mock_app { + get '/:foo' do + pass + 'Hello Foo' + end + + get '/*' do + assert !params.include?('foo') + 'Hello World' + end + } + + get '/bar' + assert ok? + assert_equal 'Hello World', body + end + + it "transitions to 404 when passed and no subsequent route matches" do + mock_app { + get '/:foo' do + pass + 'Hello Foo' + end + } + + get '/bar' + assert not_found? + end + + it "passes when matching condition returns false" do + mock_app { + condition { params[:foo] == 'bar' } + get '/:foo' do + 'Hello World' + end + } + + get '/bar' + assert ok? + assert_equal 'Hello World', body + + get '/foo' + assert not_found? + end + + it "does not pass when matching condition returns nil" do + mock_app { + condition { nil } + get '/:foo' do + 'Hello World' + end + } + + get '/bar' + assert ok? + assert_equal 'Hello World', body + end + + it "passes to next route when condition calls pass explicitly" do + mock_app { + condition { pass unless params[:foo] == 'bar' } + get '/:foo' do + 'Hello World' + end + } + + get '/bar' + assert ok? + assert_equal 'Hello World', body + + get '/foo' + assert not_found? + end + + it "passes to the next route when host_name does not match" do + mock_app { + host_name 'example.com' + get '/foo' do + 'Hello World' + end + } + get '/foo' + assert not_found? + + get '/foo', {}, { 'HTTP_HOST' => 'example.com' } + assert_equal 200, status + assert_equal 'Hello World', body + end + + it "passes to the next route when user_agent does not match" do + mock_app { + user_agent(/Foo/) + get '/foo' do + 'Hello World' + end + } + get '/foo' + assert not_found? + + get '/foo', {}, { 'HTTP_USER_AGENT' => 'Foo Bar' } + assert_equal 200, status + assert_equal 'Hello World', body + end + + it "makes captures in user agent pattern available in params[:agent]" do + mock_app { + user_agent(/Foo (.*)/) + get '/foo' do + 'Hello ' + params[:agent].first + end + } + get '/foo', {}, { 'HTTP_USER_AGENT' => 'Foo Bar' } + assert_equal 200, status + assert_equal 'Hello Bar', body + end + + it "filters by accept header" do + mock_app { + get '/', :provides => :xml do + request.env['HTTP_ACCEPT'] + end + } + + get '/', {}, { 'HTTP_ACCEPT' => 'application/xml' } + assert ok? + assert_equal 'application/xml', body + assert_equal 'application/xml', response.headers['Content-Type'] + + get '/', {}, { :accept => 'text/html' } + assert !ok? + end + + it "allows multiple mime types for accept header" do + types = ['image/jpeg', 'image/pjpeg'] + + mock_app { + get '/', :provides => types do + request.env['HTTP_ACCEPT'] + end + } + + types.each do |type| + get '/', {}, { 'HTTP_ACCEPT' => type } + assert ok? + assert_equal type, body + assert_equal type, response.headers['Content-Type'] + end + end + + it 'degrades gracefully when optional accept header is not provided' do + mock_app { + get '/', :provides => :xml do + request.env['HTTP_ACCEPT'] + end + get '/' do + 'default' + end + } + get '/' + assert ok? + assert_equal 'default', body + end + + it 'passes a single url param as block parameters when one param is specified' do + mock_app { + get '/:foo' do |foo| + assert_equal 'bar', foo + end + } + + get '/bar' + assert ok? + end + + it 'passes multiple params as block parameters when many are specified' do + mock_app { + get '/:foo/:bar/:baz' do |foo, bar, baz| + assert_equal 'abc', foo + assert_equal 'def', bar + assert_equal 'ghi', baz + end + } + + get '/abc/def/ghi' + assert ok? + end + + it 'passes regular expression captures as block parameters' do + mock_app { + get(/^\/fo(.*)\/ba(.*)/) do |foo, bar| + assert_equal 'orooomma', foo + assert_equal 'f', bar + 'looks good' + end + } + + get '/foorooomma/baf' + assert ok? + assert_equal 'looks good', body + end + + it "supports mixing multiple splat params like /*/foo/*/* as block parameters" do + mock_app { + get '/*/foo/*/*' do |foo, bar, baz| + assert_equal 'bar', foo + assert_equal 'bling', bar + assert_equal 'baz/boom', baz + 'looks good' + end + } + + get '/bar/foo/bling/baz/boom' + assert ok? + assert_equal 'looks good', body + end + + it 'raises an ArgumentError with block arity > 1 and too many values' do + mock_app { + get '/:foo/:bar/:baz' do |foo, bar| + 'quux' + end + } + + assert_raise(ArgumentError) { get '/a/b/c' } + end + + it 'raises an ArgumentError with block param arity > 1 and too few values' do + mock_app { + get '/:foo/:bar' do |foo, bar, baz| + 'quux' + end + } + + assert_raise(ArgumentError) { get '/a/b' } + end + + it 'succeeds if no block parameters are specified' do + mock_app { + get '/:foo/:bar' do + 'quux' + end + } + + get '/a/b' + assert ok? + assert_equal 'quux', body + end + + it 'passes all params with block param arity -1 (splat args)' do + mock_app { + get '/:foo/:bar' do |*args| + args.join + end + } + + get '/a/b' + assert ok? + assert_equal 'ab', body + end + + it 'allows custom route-conditions to be set via route options' do + protector = Module.new { + def protect(*args) + condition { + unless authorize(params["user"], params["password"]) + halt 403, "go away" + end + } + end + } + + mock_app { + register protector + + helpers do + def authorize(username, password) + username == "foo" && password == "bar" + end + end + + get "/", :protect => true do + "hey" + end + } + + get "/" + assert forbidden? + assert_equal "go away", body + + get "/", :user => "foo", :password => "bar" + assert ok? + assert_equal "hey", body + end + + # NOTE Block params behaves differently under 1.8 and 1.9. Under 1.8, block + # param arity is lax: declaring a mismatched number of block params results + # in a warning. Under 1.9, block param arity is strict: mismatched block + # arity raises an ArgumentError. + + if RUBY_VERSION >= '1.9' + + it 'raises an ArgumentError with block param arity 1 and no values' do + mock_app { + get '/foo' do |foo| + 'quux' + end + } + + assert_raise(ArgumentError) { get '/foo' } + end + + it 'raises an ArgumentError with block param arity 1 and too many values' do + mock_app { + get '/:foo/:bar/:baz' do |foo| + 'quux' + end + } + + assert_raise(ArgumentError) { get '/a/b/c' } + end + + else + + it 'does not raise an ArgumentError with block param arity 1 and no values' do + mock_app { + get '/foo' do |foo| + 'quux' + end + } + + silence_warnings { get '/foo' } + assert ok? + assert_equal 'quux', body + end + + it 'does not raise an ArgumentError with block param arity 1 and too many values' do + mock_app { + get '/:foo/:bar/:baz' do |foo| + 'quux' + end + } + + silence_warnings { get '/a/b/c' } + assert ok? + assert_equal 'quux', body + end + + end +end diff --git a/vendor/gems/gems/sinatra-0.9.4/test/sass_test.rb b/vendor/gems/gems/sinatra-0.9.4/test/sass_test.rb new file mode 100755 index 00000000..c8d6a731 --- /dev/null +++ b/vendor/gems/gems/sinatra-0.9.4/test/sass_test.rb @@ -0,0 +1,79 @@ +require File.dirname(__FILE__) + '/helper' +require 'sass' + +class SassTest < Test::Unit::TestCase + def sass_app(&block) + mock_app { + set :views, File.dirname(__FILE__) + '/views' + get '/', &block + } + get '/' + end + + it 'renders inline Sass strings' do + sass_app { sass "#sass\n :background-color #FFF\n" } + assert ok? + assert_equal "#sass {\n background-color: #FFF; }\n", body + end + + it 'renders .sass files in views path' do + sass_app { sass :hello } + assert ok? + assert_equal "#sass {\n background-color: #FFF; }\n", body + end + + it 'ignores the layout option' do + sass_app { sass :hello, :layout => :layout2 } + assert ok? + assert_equal "#sass {\n background-color: #FFF; }\n", body + end + + it "raises error if template not found" do + mock_app { + get('/') { sass :no_such_template } + } + assert_raise(Errno::ENOENT) { get('/') } + end + + it "passes SASS options to the Sass engine" do + sass_app { + sass "#sass\n :background-color #FFF\n :color #000\n", :style => :compact + } + assert ok? + assert_equal "#sass { background-color: #FFF; color: #000; }\n", body + end + + it "passes default SASS options to the Sass engine" do + mock_app { + set :sass, {:style => :compact} # default Sass style is :nested + get '/' do + sass "#sass\n :background-color #FFF\n :color #000\n" + end + } + get '/' + assert ok? + assert_equal "#sass { background-color: #FFF; color: #000; }\n", body + end + + it "merges the default SASS options with the overrides and passes them to the Sass engine" do + mock_app { + set :sass, {:style => :compact, :attribute_syntax => :alternate } # default Sass attribute_syntax is :normal (with : in front) + get '/' do + sass "#sass\n background-color: #FFF\n color: #000\n" + end + get '/raised' do + sass "#sass\n :background-color #FFF\n :color #000\n", :style => :expanded # retains global attribute_syntax settings + end + get '/expanded_normal' do + sass "#sass\n :background-color #FFF\n :color #000\n", :style => :expanded, :attribute_syntax => :normal + end + } + get '/' + assert ok? + assert_equal "#sass { background-color: #FFF; color: #000; }\n", body + assert_raise(Sass::SyntaxError) { get('/raised') } + get '/expanded_normal' + assert ok? + assert_equal "#sass {\n background-color: #FFF;\n color: #000;\n}\n", body + end +end diff --git a/vendor/gems/gems/sinatra-0.9.4/test/server_test.rb b/vendor/gems/gems/sinatra-0.9.4/test/server_test.rb new file mode 100755 index 00000000..76d4ef97 --- /dev/null +++ b/vendor/gems/gems/sinatra-0.9.4/test/server_test.rb @@ -0,0 +1,47 @@ +require File.dirname(__FILE__) + '/helper' + +module Rack::Handler + class Mock + extend Test::Unit::Assertions + + def self.run(app, options={}) + assert(app < Sinatra::Base) + assert_equal 9001, options[:Port] + assert_equal 'foo.local', options[:Host] + yield new + end + + def stop + end + end + + register 'mock', 'Rack::Handler::Mock' +end + +class ServerTest < Test::Unit::TestCase + setup do + mock_app { + set :server, 'mock' + set :host, 'foo.local' + set :port, 9001 + } + $stdout = File.open('/dev/null', 'wb') + end + + def teardown + $stdout = STDOUT + end + + it "locates the appropriate Rack handler and calls ::run" do + @app.run! + end + + it "sets options on the app before running" do + @app.run! :sessions => true + assert @app.sessions? + end + + it "falls back on the next server handler when not found" do + @app.run! :server => %w[foo bar mock] + end +end diff --git a/vendor/gems/gems/sinatra-0.9.4/test/sinatra_test.rb b/vendor/gems/gems/sinatra-0.9.4/test/sinatra_test.rb new file mode 100755 index 00000000..5c695b22 --- /dev/null +++ b/vendor/gems/gems/sinatra-0.9.4/test/sinatra_test.rb @@ -0,0 +1,13 @@ +require File.dirname(__FILE__) + '/helper' + +class SinatraTest < Test::Unit::TestCase + it 'creates a new Sinatra::Base subclass on new' do + app = + Sinatra.new do + get '/' do + 'Hello World' + end + end + assert_same Sinatra::Base, app.superclass + end +end diff --git a/vendor/gems/gems/sinatra-0.9.4/test/static_test.rb b/vendor/gems/gems/sinatra-0.9.4/test/static_test.rb new file mode 100755 index 00000000..896d46c1 --- /dev/null +++ b/vendor/gems/gems/sinatra-0.9.4/test/static_test.rb @@ -0,0 +1,80 @@ +require File.dirname(__FILE__) + '/helper' + +class StaticTest < Test::Unit::TestCase + setup do + mock_app { + set :static, true + set :public, File.dirname(__FILE__) + } + end + + it 'serves GET requests for files in the public directory' do + get "/#{File.basename(__FILE__)}" + assert ok? + assert_equal File.read(__FILE__), body + assert_equal File.size(__FILE__).to_s, response['Content-Length'] + assert response.headers.include?('Last-Modified') + end + + it 'produces a body that can be iterated over multiple times' do + env = Rack::MockRequest.env_for("/#{File.basename(__FILE__)}") + status, headers, body = @app.call(env) + buf1, buf2 = [], [] + body.each { |part| buf1 << part } + body.each { |part| buf2 << part } + assert_equal buf1.join, buf2.join + assert_equal File.read(__FILE__), buf1.join + end + + it 'serves HEAD requests for files in the public directory' do + head "/#{File.basename(__FILE__)}" + assert ok? + assert_equal '', body + assert_equal File.size(__FILE__).to_s, response['Content-Length'] + assert response.headers.include?('Last-Modified') + end + + it 'serves files in preference to custom routes' do + @app.get("/#{File.basename(__FILE__)}") { 'Hello World' } + get "/#{File.basename(__FILE__)}" + assert ok? + assert body != 'Hello World' + end + + it 'does not serve directories' do + get "/" + assert not_found? + end + + it 'passes to the next handler when the static option is disabled' do + @app.set :static, false + get "/#{File.basename(__FILE__)}" + assert not_found? + end + + it 'passes to the next handler when the public option is nil' do + @app.set :public, nil + get "/#{File.basename(__FILE__)}" + assert not_found? + end + + it '404s when a file is not found' do + get "/foobarbaz.txt" + assert not_found? + end + + it 'serves files when .. path traverses within public directory' do + get "/data/../#{File.basename(__FILE__)}" + assert ok? + assert_equal File.read(__FILE__), body + end + + it '404s when .. path traverses outside of public directory' do + mock_app { + set :static, true + set :public, File.dirname(__FILE__) + '/data' + } + get "/../#{File.basename(__FILE__)}" + assert not_found? + end +end diff --git a/vendor/gems/gems/sinatra-0.9.4/test/templates_test.rb b/vendor/gems/gems/sinatra-0.9.4/test/templates_test.rb new file mode 100755 index 00000000..d2febc91 --- /dev/null +++ b/vendor/gems/gems/sinatra-0.9.4/test/templates_test.rb @@ -0,0 +1,122 @@ +require File.dirname(__FILE__) + '/helper' + +class TemplatesTest < Test::Unit::TestCase + def render_app(&block) + mock_app { + def render_test(template, data, options, locals, &block) + inner = block ? block.call : '' + data + inner + end + set :views, File.dirname(__FILE__) + '/views' + get '/', &block + template(:layout3) { "Layout 3!\n" } + } + get '/' + end + + def with_default_layout + layout = File.dirname(__FILE__) + '/views/layout.test' + File.open(layout, 'wb') { |io| io.write "Layout!\n" } + yield + ensure + File.unlink(layout) rescue nil + end + + it 'renders String templates directly' do + render_app { render :test, 'Hello World' } + assert ok? + assert_equal 'Hello World', body + end + + it 'renders Proc templates using the call result' do + render_app { render :test, Proc.new {'Hello World'} } + assert ok? + assert_equal 'Hello World', body + end + + it 'looks up Symbol templates in views directory' do + render_app { render :test, :hello } + assert ok? + assert_equal "Hello World!\n", body + end + + it 'uses the default layout template if not explicitly overridden' do + with_default_layout do + render_app { render :test, :hello } + assert ok? + assert_equal "Layout!\nHello World!\n", body + end + end + + it 'uses the default layout template if not really overriden' do + with_default_layout do + render_app { render :test, :hello, :layout => true } + assert ok? + assert_equal "Layout!\nHello World!\n", body + end + end + + it 'uses the layout template specified' do + render_app { render :test, :hello, :layout => :layout2 } + assert ok? + assert_equal "Layout 2!\nHello World!\n", body + end + + it 'uses layout templates defined with the #template method' do + render_app { render :test, :hello, :layout => :layout3 } + assert ok? + assert_equal "Layout 3!\nHello World!\n", body + end + + it 'loads templates from source file with use_in_file_templates!' do + mock_app { + use_in_file_templates! + } + assert_equal "this is foo\n\n", @app.templates[:foo][:template] + assert_equal "X\n= yield\nX\n", @app.templates[:layout][:template] + end + + it 'loads templates from specified views directory' do + render_app { render :test, :hello, :views => options.views + '/foo' } + + assert_equal "from another views directory\n", body + end + + test 'use_in_file_templates simply ignores IO errors' do + assert_nothing_raised { + mock_app { + use_in_file_templates!('/foo/bar') + } + } + + assert @app.templates.empty? + end + + it 'passes locals to the layout' do + mock_app { + template :my_layout do + 'Hello <%= name %>!<%= yield %>' + end + + get '/' do + erb '

content

', { :layout => :my_layout }, { :name => 'Mike'} + end + } + + get '/' + assert ok? + assert_equal 'Hello Mike!

content

', body + end +end + +# __END__ : this is not the real end of the script. + +__END__ + +@@ foo +this is foo + +@@ layout +X += yield +X diff --git a/vendor/gems/gems/sinatra-0.9.4/test/test_test.rb b/vendor/gems/gems/sinatra-0.9.4/test/test_test.rb new file mode 100755 index 00000000..23527e40 --- /dev/null +++ b/vendor/gems/gems/sinatra-0.9.4/test/test_test.rb @@ -0,0 +1,152 @@ +require File.dirname(__FILE__) + '/helper' + +require 'yaml' + +# silence deprecation warning when requiring sinatra/test +$VERBOSE, v = nil, $VERBOSE +require 'sinatra/test' +$VERBOSE = v + +class TestTest < Test::Unit::TestCase + include Sinatra::Test + + def request + YAML.load(body) + end + + def request_body + request['test.body'] + end + + def request_params + YAML.load(request['test.params']) + end + + setup do + mock_app { + %w[get head post put delete].each { |verb| + send(verb, '/') do + redirect '/redirected' if params[:redirect] + env.update('test.body' => request.body.read) + env.update('test.params' => params.to_yaml) + env.to_yaml + end + } + + get '/redirected' do + "you've been redirected" + end + } + end + + it 'allows GET/HEAD/POST/PUT/DELETE' do + get '/' + assert_equal('GET', request['REQUEST_METHOD']) + + post '/' + assert_equal('POST', request['REQUEST_METHOD']) + + put '/' + assert_equal('PUT', request['REQUEST_METHOD']) + + delete '/' + assert_equal('DELETE', request['REQUEST_METHOD']) + + head '/' + assert response.headers['Content-Length'].to_i > 0 + assert_equal('', body) + end + + it 'allows to specify a body' do + post '/', '42' + assert_equal '42', request_body + end + + it 'allows to specify params' do + get '/', :foo => 'bar' + assert_equal 'bar', request_params['foo'] + end + + it 'supports nested params' do + get '/', :foo => { :x => 'y', :chunky => 'bacon' } + assert_equal "y", request_params['foo']['x'] + assert_equal "bacon", request_params['foo']['chunky'] + end + + it 'provides easy access to response status and body' do + get '/' + assert_equal 200, status + assert body =~ /^---/ + end + + it 'delegates methods to @response' do + get '/' + assert ok? + end + + it 'follows redirect' do + get '/', :redirect => true + follow! + assert_equal "you've been redirected", body + end + + it 'provides sugar for common HTTP headers' do + get '/', :env => { :accept => 'text/plain' } + assert_equal 'text/plain', request['HTTP_ACCEPT'] + + get '/', :env => { :agent => 'TATFT' } + assert_equal 'TATFT', request['HTTP_USER_AGENT'] + + get '/', :env => { :host => '1.2.3.4' } + assert_equal '1.2.3.4', request['HTTP_HOST'] + + get '/', :env => { :session => {'foo' => 'bar'} } + assert_equal({'foo' => 'bar'}, request['rack.session']) + + get '/', :env => { :cookies => 'foo' } + assert_equal 'foo', request['HTTP_COOKIE'] + + get '/', :env => { :content_type => 'text/plain' } + assert_equal 'text/plain', request['CONTENT_TYPE'] + end + + it 'allow to test session easily' do + app = mock_app(Sinatra::Default) { + get '/' do + session['foo'] = 'bar' + 200 + end + + post '/' do + assert_equal 'bar', session['foo'] + session['foo'] || "blah" + end + } + + browser = Sinatra::TestHarness.new(app) + browser.get '/' + browser.post '/', {}, :session => { 'foo' => 'bar' } + assert_equal 'bar', browser.response.body + end + + it 'yields the request object to the block before invoking the application' do + called = false + get '/' do |req| + called = true + assert req.kind_of?(Rack::MockRequest) + end + assert called + end + + it 'sets the environment to :test on include' do + Sinatra::Default.set(:environment, :production) + Class.new { include Sinatra::Test } + assert_equal :test, Sinatra::Default.environment + end + + def test_TestHarness + session = Sinatra::TestHarness.new(@app) + response = session.get('/') + assert_equal 200, response.status + end +end diff --git a/vendor/gems/gems/sinatra-0.9.4/test/views/error.builder b/vendor/gems/gems/sinatra-0.9.4/test/views/error.builder new file mode 100755 index 00000000..9cf87d5e --- /dev/null +++ b/vendor/gems/gems/sinatra-0.9.4/test/views/error.builder @@ -0,0 +1,3 @@ +xml.error do + raise "goodbye" +end diff --git a/vendor/gems/gems/sinatra-0.9.4/test/views/error.erb b/vendor/gems/gems/sinatra-0.9.4/test/views/error.erb new file mode 100755 index 00000000..b48d1f06 --- /dev/null +++ b/vendor/gems/gems/sinatra-0.9.4/test/views/error.erb @@ -0,0 +1,3 @@ +Hello <%= 'World' %> +<% raise 'Goodbye' unless defined?(french) && french %> +<% raise 'Au revoir' if defined?(french) && french %> diff --git a/vendor/gems/gems/sinatra-0.9.4/test/views/error.haml b/vendor/gems/gems/sinatra-0.9.4/test/views/error.haml new file mode 100755 index 00000000..6019007b --- /dev/null +++ b/vendor/gems/gems/sinatra-0.9.4/test/views/error.haml @@ -0,0 +1,3 @@ +%h1 Hello From Haml += raise 'goodbye' unless defined?(french) && french += raise 'au revoir' if defined?(french) && french diff --git a/vendor/gems/gems/sinatra-0.9.4/test/views/error.sass b/vendor/gems/gems/sinatra-0.9.4/test/views/error.sass new file mode 100755 index 00000000..42fc56b3 --- /dev/null +++ b/vendor/gems/gems/sinatra-0.9.4/test/views/error.sass @@ -0,0 +1,2 @@ +#sass + +argle-bargle diff --git a/vendor/gems/gems/sinatra-0.9.4/test/views/foo/hello.test b/vendor/gems/gems/sinatra-0.9.4/test/views/foo/hello.test new file mode 100755 index 00000000..2aba6341 --- /dev/null +++ b/vendor/gems/gems/sinatra-0.9.4/test/views/foo/hello.test @@ -0,0 +1 @@ +from another views directory diff --git a/vendor/gems/gems/sinatra-0.9.4/test/views/hello.builder b/vendor/gems/gems/sinatra-0.9.4/test/views/hello.builder new file mode 100755 index 00000000..16b86d03 --- /dev/null +++ b/vendor/gems/gems/sinatra-0.9.4/test/views/hello.builder @@ -0,0 +1 @@ +xml.exclaim "You're my boy, #{@name}!" diff --git a/vendor/gems/gems/sinatra-0.9.4/test/views/hello.erb b/vendor/gems/gems/sinatra-0.9.4/test/views/hello.erb new file mode 100755 index 00000000..bcbbc926 --- /dev/null +++ b/vendor/gems/gems/sinatra-0.9.4/test/views/hello.erb @@ -0,0 +1 @@ +Hello <%= 'World' %> diff --git a/vendor/gems/gems/sinatra-0.9.4/test/views/hello.haml b/vendor/gems/gems/sinatra-0.9.4/test/views/hello.haml new file mode 100755 index 00000000..d6852a60 --- /dev/null +++ b/vendor/gems/gems/sinatra-0.9.4/test/views/hello.haml @@ -0,0 +1 @@ +%h1 Hello From Haml diff --git a/vendor/gems/gems/sinatra-0.9.4/test/views/hello.sass b/vendor/gems/gems/sinatra-0.9.4/test/views/hello.sass new file mode 100755 index 00000000..5a4fd574 --- /dev/null +++ b/vendor/gems/gems/sinatra-0.9.4/test/views/hello.sass @@ -0,0 +1,2 @@ +#sass + :background-color #FFF diff --git a/vendor/gems/gems/sinatra-0.9.4/test/views/hello.test b/vendor/gems/gems/sinatra-0.9.4/test/views/hello.test new file mode 100755 index 00000000..980a0d5f --- /dev/null +++ b/vendor/gems/gems/sinatra-0.9.4/test/views/hello.test @@ -0,0 +1 @@ +Hello World! diff --git a/vendor/gems/gems/sinatra-0.9.4/test/views/layout2.builder b/vendor/gems/gems/sinatra-0.9.4/test/views/layout2.builder new file mode 100755 index 00000000..9491f574 --- /dev/null +++ b/vendor/gems/gems/sinatra-0.9.4/test/views/layout2.builder @@ -0,0 +1,3 @@ +xml.layout do + xml << yield +end diff --git a/vendor/gems/gems/sinatra-0.9.4/test/views/layout2.erb b/vendor/gems/gems/sinatra-0.9.4/test/views/layout2.erb new file mode 100755 index 00000000..e097f3b6 --- /dev/null +++ b/vendor/gems/gems/sinatra-0.9.4/test/views/layout2.erb @@ -0,0 +1,2 @@ +ERB Layout! +<%= yield %> diff --git a/vendor/gems/gems/sinatra-0.9.4/test/views/layout2.haml b/vendor/gems/gems/sinatra-0.9.4/test/views/layout2.haml new file mode 100755 index 00000000..58bfc04d --- /dev/null +++ b/vendor/gems/gems/sinatra-0.9.4/test/views/layout2.haml @@ -0,0 +1,2 @@ +%h1 HAML Layout! +%p= yield diff --git a/vendor/gems/gems/sinatra-0.9.4/test/views/layout2.test b/vendor/gems/gems/sinatra-0.9.4/test/views/layout2.test new file mode 100755 index 00000000..fb432e3a --- /dev/null +++ b/vendor/gems/gems/sinatra-0.9.4/test/views/layout2.test @@ -0,0 +1 @@ +Layout 2! diff --git a/vendor/gems/gems/sinatra-content-for-0.2/.gitignore b/vendor/gems/gems/sinatra-content-for-0.2/.gitignore new file mode 100755 index 00000000..18977f8b --- /dev/null +++ b/vendor/gems/gems/sinatra-content-for-0.2/.gitignore @@ -0,0 +1,3 @@ +doc +dist +tmp diff --git a/vendor/gems/gems/sinatra-content-for-0.2/LICENSE b/vendor/gems/gems/sinatra-content-for-0.2/LICENSE new file mode 100755 index 00000000..3eb6c2f4 --- /dev/null +++ b/vendor/gems/gems/sinatra-content-for-0.2/LICENSE @@ -0,0 +1,22 @@ +(The MIT License) + +Copyright (c) 2008-2009 Nicolas Sanguinetti, entp.com + +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/gems/sinatra-content-for-0.2/README.rdoc b/vendor/gems/gems/sinatra-content-for-0.2/README.rdoc new file mode 100755 index 00000000..12022a7b --- /dev/null +++ b/vendor/gems/gems/sinatra-content-for-0.2/README.rdoc @@ -0,0 +1,41 @@ += ContentFor + +Small extension for the Sinatra[http://sinatrarb.com] web framework +that allows you to use the following helpers in your views: + + <% content_for :some_key do %> + ... + <% end %> + + <% yield_content :some_key %> + +This allows you to capture blocks inside views to be rendered later +in this request. For example, to populate different parts of your +layout from your view. + +== Usage + +If you're writing "classic" style apps, then requring +sinatra/content_for should be enough. If you're writing +"classy" apps, then you also need to call +helpers Sinatra::ContentFor in your app definition. + +== And how is this useful? + +For example, some of your views might need a few javascript tags and +stylesheets, but you don't want to force this files in all your pages. +Then you can put <% yield_content :scripts_and_styles %> on +your layout, inside the tag, and each view can call +content_for setting the appropriate set of tags that should +be added to the layout. + +== Warning + +This only works with ERB as a rendering mechanism. I haven't figured +how to make it work with Haml. If you find a way, contact me and I'll +include it. + +== Credits + +Code by foca[http://github.com/foca], inspired on the Ruby on Rails +helpers with the same name. diff --git a/vendor/gems/gems/sinatra-content-for-0.2/lib/sinatra/content_for.rb b/vendor/gems/gems/sinatra-content-for-0.2/lib/sinatra/content_for.rb new file mode 100755 index 00000000..31848c63 --- /dev/null +++ b/vendor/gems/gems/sinatra-content-for-0.2/lib/sinatra/content_for.rb @@ -0,0 +1,58 @@ +module Sinatra + module ContentFor + # Capture a block of content to be rendered later. For example: + # + # <% content_for :head do %> + # + # <% end %> + # + # You can call +content_for+ multiple times with the same key + # (in the example +:head+), and when you render the blocks for + # that key all of them will be rendered, in the same order you + # captured them. + # + # Your blocks can also receive values, which are passed to them + # by yield_content + def content_for(key, &block) + content_blocks[key.to_sym] << block + end + + # Render the captured blocks for a given key. For example: + # + # + # Example + # <% yield_content :head %> + # + # + # Would render everything you declared with content_for + # :head before closing the tag. + # + # You can also pass values to the content blocks by passing them + # as arguments after the key: + # + # <% yield_content :head, 1, 2 %> + # + # Would pass 1 and 2 to all the blocks registered + # for :head. + # + # *NOTICE* that you call this without an = sign. IE, + # in a <% %> block, and not in a <%= %> block. + def yield_content(key, *args) + content_blocks[key.to_sym].map do |content| + if respond_to?(:block_is_haml?) && block_is_haml?(content) + capture_haml(*args, &content) + else + content.call(*args) + end + end.join + end + + private + + def content_blocks + @content_blocks ||= Hash.new {|h,k| h[k] = [] } + end + end + + helpers ContentFor +end diff --git a/vendor/gems/gems/sinatra-content-for-0.2/sinatra-content-for.gemspec b/vendor/gems/gems/sinatra-content-for-0.2/sinatra-content-for.gemspec new file mode 100755 index 00000000..63242e6b --- /dev/null +++ b/vendor/gems/gems/sinatra-content-for-0.2/sinatra-content-for.gemspec @@ -0,0 +1,34 @@ +Gem::Specification.new do |s| + s.name = "sinatra-content-for" + s.version = "0.2" + s.date = "2009-05-09" + + s.description = "Small Sinatra extension to add a content_for helper similar to Rails'" + s.summary = "Small Sinatra extension to add a content_for helper similar to Rails'" + s.homepage = "http://sinatrarb.com" + + s.authors = ["Nicolás Sanguinetti"] + s.email = "contacto@nicolassanguinetti.info" + + s.require_paths = ["lib"] + s.rubyforge_project = "sinatra-ditties" + s.has_rdoc = true + s.rubygems_version = "1.3.1" + + s.add_dependency "sinatra" + + if s.respond_to?(:add_development_dependency) + s.add_development_dependency "contest" + s.add_development_dependency "sr-mg" + s.add_development_dependency "redgreen" + end + + s.files = %w[ +.gitignore +LICENSE +README.rdoc +sinatra-content-for.gemspec +lib/sinatra/content_for.rb +test/content_for_test.rb +] +end diff --git a/vendor/gems/gems/sinatra-content-for-0.2/test/content_for_test.rb b/vendor/gems/gems/sinatra-content-for-0.2/test/content_for_test.rb new file mode 100755 index 00000000..c9560f22 --- /dev/null +++ b/vendor/gems/gems/sinatra-content-for-0.2/test/content_for_test.rb @@ -0,0 +1,156 @@ +ENV['RACK_ENV'] = 'test' + +begin + require 'rack' +rescue LoadError + require 'rubygems' + require 'rack' +end + +require 'contest' +require 'sinatra/test' +require 'haml' + +begin + require 'redgreen' +rescue LoadError +end + +require File.dirname(__FILE__) + '/../lib/sinatra/content_for' + +Sinatra::Base.set :environment, :test + +module Sinatra + class Base + set :environment, :test + helpers ContentFor + end +end + +class Test::Unit::TestCase + include Sinatra::Test + + class << self + alias_method :it, :test + end + + def mock_app(base=Sinatra::Base, &block) + @app = Sinatra.new(base, &block) + end +end + +class ContentForTest < Test::Unit::TestCase + context 'using erb' do + def erb_app(view) + mock_app { + layout { '<% yield_content :foo %>' } + get('/') { erb view } + } + end + + it 'renders blocks declared with the same key you use when rendering' do + erb_app '<% content_for :foo do %>foo<% end %>' + + get '/' + assert ok? + assert_equal 'foo', body + end + + it 'does not render a block with a different key' do + erb_app '<% content_for :bar do %>bar<% end %>' + + get '/' + assert ok? + assert_equal '', body + end + + it 'renders multiple blocks with the same key' do + erb_app <<-erb_snippet + <% content_for :foo do %>foo<% end %> + <% content_for :foo do %>bar<% end %> + <% content_for :baz do %>WON'T RENDER ME<% end %> + <% content_for :foo do %>baz<% end %> + erb_snippet + + get '/' + assert ok? + assert_equal 'foobarbaz', body + end + + it 'passes values to the blocks' do + mock_app { + layout { '<% yield_content :foo, 1, 2 %>' } + get('/') { erb '<% content_for :foo do |a, b| %><%= a %> <%= b %><% end %>' } + } + + get '/' + assert ok? + assert_equal '1 2', body + end + end + + context 'with haml' do + def haml_app(view) + mock_app { + layout { '= yield_content :foo' } + get('/') { haml view } + } + end + + it 'renders blocks declared with the same key you use when rendering' do + haml_app <<-haml_end +- content_for :foo do + foo +haml_end + + get '/' + assert ok? + assert_equal "foo\n", body + end + + it 'does not render a block with a different key' do + haml_app <<-haml_end +- content_for :bar do + bar +haml_end + + get '/' + assert ok? + assert_equal "\n", body + end + + it 'renders multiple blocks with the same key' do + haml_app <<-haml_end +- content_for :foo do + foo +- content_for :foo do + bar +- content_for :baz do + WON'T RENDER ME +- content_for :foo do + baz +haml_end + + get '/' + assert ok? + assert_equal "foo\nbar\nbaz\n", body + end + + it 'passes values to the blocks' do + mock_app { + layout { '= yield_content :foo, 1, 2' } + get('/') { + haml <<-haml_end +- content_for :foo do |a, b| + %i= a + =b +haml_end + } + } + + get '/' + assert ok? + assert_equal "1\n2\n", body + end + end +end diff --git a/vendor/gems/gems/sprockets-1.0.2/Rakefile b/vendor/gems/gems/sprockets-1.0.2/Rakefile new file mode 100755 index 00000000..414d7b90 --- /dev/null +++ b/vendor/gems/gems/sprockets-1.0.2/Rakefile @@ -0,0 +1,19 @@ +require "rubygems" +require "rake/testtask" +require "rake/gempackagetask" + +task :default => :test + +Rake::TestTask.new do |t| + t.libs << "test" + t.test_files = FileList["test/test_*.rb"] + t.verbose = true +end + +Rake::GemPackageTask.new(eval(IO.read(File.join(File.dirname(__FILE__), "sprockets.gemspec")))) do |pkg| + require File.join(File.dirname(__FILE__), "lib", "sprockets", "version") + raise "Error: Sprockets::Version doesn't match gemspec" if Sprockets::Version::STRING != pkg.version.to_s + + pkg.need_zip = true + pkg.need_tar = true +end diff --git a/vendor/gems/gems/sprockets-1.0.2/bin/sprocketize b/vendor/gems/gems/sprockets-1.0.2/bin/sprocketize new file mode 100755 index 00000000..c65e4a13 --- /dev/null +++ b/vendor/gems/gems/sprockets-1.0.2/bin/sprocketize @@ -0,0 +1,54 @@ +#!/usr/bin/env ruby + +require File.join(File.dirname(__FILE__), *%w".. lib sprockets") +require "optparse" + +load_path = (ENV["SPROCKETS_PATH"] || "").split(":") +filenames = [] +options = { :load_path => load_path, :source_files => filenames, :expand_paths => false } + +OptionParser.new do |opts| + opts.summary_width = 28 + opts.banner = "Usage: sprocketize [options] filename [filename ...]" + + def opts.show_usage + puts self + exit + end + + opts.on("-C DIRECTORY", "--directory=DIRECTORY", "Change to DIRECTORY before doing anything") do |directory| + Dir.chdir(directory) + end + + opts.on("-I DIRECTORY", "--include-dir=DIRECTORY", "Adds the directory to the Sprockets load path") do |directory| + load_path << directory + end + + opts.on("-a DIRECTORY", "--asset-root=DIRECTORY", "Copy provided assets into DIRECTORY") do |directory| + options[:asset_root] = directory + end + + opts.on_tail("-h", "--help", "Shows this help message") do + opts.show_usage + end + + opts.on_tail("-v", "--version", "Shows version") do + puts Sprockets::Version::STRING + exit + end + + opts.show_usage if ARGV.empty? + + begin + opts.order(ARGV) do |filename| + filenames << filename + end + rescue OptionParser::ParseError => e + opts.warn e.message + opts.show_usage + end +end + +secretary = Sprockets::Secretary.new(options) +secretary.install_assets if options[:asset_root] +print secretary.concatenation diff --git a/vendor/gems/gems/sprockets-1.0.2/ext/nph-sprockets.cgi b/vendor/gems/gems/sprockets-1.0.2/ext/nph-sprockets.cgi new file mode 100755 index 00000000..f1e85fef --- /dev/null +++ b/vendor/gems/gems/sprockets-1.0.2/ext/nph-sprockets.cgi @@ -0,0 +1,127 @@ +#!/usr/bin/env ruby + +# This is a simple CGI wrapper around Sprockets. +# +# Copy it into a directory on your site with CGI enabled. When invoked, the +# script will search its directory and parent directories for a YAML file named +# "config/sprockets.yml" in order to load configuration information. +# +# If you set the environment variable "sprockets_generate_output_file" to +# "true" the concatenation will be cached to disk. Use it in conjunction with +# URL rewriting to cache your Sprockets output on the first request. +# +# Assuming a site layout like this: +# +# mysite/ +# config/ +# sprockets.yml +# javascripts/ +# mysite.js +# ... +# public/ +# index.html +# nph-sprockets.cgi (this file) +# vendor/ +# sprockets/ +# prototype/ -> ... +# scriptaculous/ -> ... +# +# mysite/config/sprockets.yml might look like this: +# +# :load_path: +# - javascripts +# - vendor/sprockets/*/src +# :source_files: +# - javascripts/mysite.js +# - javascripts/*.js +# :output_file: public/sprockets.js +# +# The +# +# And you might have the following Apache configuration: +# +# +# ServerName mysite.example.org +# DocumentRoot "/path/to/mysite/public" +# +# +# Options +ExecCGI +FollowSymLinks +# AddHandler cgi-script .cgi +# +# RewriteEngine on +# RewriteCond /sprockets.js !-f +# RewriteRule ^sprockets\.js /nph-sprockets.cgi [P,L] +# +# +# +# All requests to /sprockets.js will transparently proxy /nph-sprockets.cgi if +# mysite/public/sprockets.js does not exist. In production, you can add +# +# SetEnv sprockets_generate_output_file true +# +# to your Apache configuration and mysites/public/sprockets.js will be cached +# on the first request to /sprockets.js. + +require "yaml" +require "fileutils" + +def respond_with(options = {}) + options = { :code => 200, :content => "", :type => "text/plain" }.merge(options) + print "HTTP/1.0 #{options[:code]}\r\n" + print "Content-Type: #{options[:type]}\r\n" + print "Content-Length: #{options[:content].length}\r\n" + print "\r\n#{options[:content]}" + $stdout.flush + exit! +end + +def search_upwards_for(filename) + pwd = original_pwd = Dir.pwd + loop do + return File.expand_path(filename) if File.file?(filename) + Dir.chdir("..") + respond_with(:code => 500, :content => "couldn't find config/sprockets.yml") if Dir.pwd == pwd + pwd = Dir.pwd + end +ensure + Dir.chdir(original_pwd) +end + +def generate_output_file? + (ENV["REDIRECT_sprockets_generate_output_file"] || ENV["sprockets_generate_output_file"]) =~ /true/i +end + +configuration_file = search_upwards_for("config/sprockets.yml") +sprockets_root = File.dirname(File.dirname(configuration_file)) +configuration = YAML.load(IO.read(configuration_file)) + +begin + if File.directory?(sprockets_dir = File.join(sprockets_root, "vendor/gems/sprockets/lib")) + $:.unshift sprockets_dir + elsif File.directory?(sprockets_dir = File.join(sprockets_root, "vendor/sprockets/lib")) + $:.unshift sprockets_dir + else + require "rubygems" + end + + require "sprockets" + +rescue Exception => e + respond_with(:code => 500, :content => "couldn't find sprockets: #{e}") +end + +begin + secretary = Sprockets::Secretary.new( + :root => sprockets_root, + :load_path => configuration[:load_path], + :source_files => configuration[:source_files] + ) + + secretary.concatenation.save_to(File.join(sprockets_root, configuration[:output_file])) if generate_output_file? + respond_with(:content => secretary.concatenation.to_s, :type => "text/javascript") + +rescue Exception => e + respond_with(:code => 500, :content => "couldn't generate concatenated javascript: #{e}") +end diff --git a/vendor/gems/gems/sprockets-1.0.2/lib/sprockets.rb b/vendor/gems/gems/sprockets-1.0.2/lib/sprockets.rb new file mode 100755 index 00000000..6271f035 --- /dev/null +++ b/vendor/gems/gems/sprockets-1.0.2/lib/sprockets.rb @@ -0,0 +1,42 @@ +$:.unshift File.dirname(__FILE__) + +require "yaml" +require "fileutils" + +module Sprockets + class << self + def running_on_windows? + RUBY_PLATFORM =~ /(win|w)32$/ + end + + def absolute?(location) + same_when_expanded?(location) || platform_absolute_path?(location) + end + + protected + def same_when_expanded?(location) + location[0, 1] == File.expand_path(location)[0, 1] + end + + def platform_absolute_path?(location) + false + end + + if Sprockets.running_on_windows? + def platform_absolute_path?(location) + location[0, 1] == File::SEPARATOR && File.expand_path(location) =~ /[A-Za-z]:[\/\\]/ + end + end + end +end + +require "sprockets/version" +require "sprockets/error" +require "sprockets/environment" +require "sprockets/pathname" +require "sprockets/source_line" +require "sprockets/source_file" +require "sprockets/concatenation" +require "sprockets/preprocessor" +require "sprockets/secretary" + diff --git a/vendor/gems/gems/sprockets-1.0.2/lib/sprockets/concatenation.rb b/vendor/gems/gems/sprockets-1.0.2/lib/sprockets/concatenation.rb new file mode 100755 index 00000000..3ea7abc6 --- /dev/null +++ b/vendor/gems/gems/sprockets-1.0.2/lib/sprockets/concatenation.rb @@ -0,0 +1,36 @@ +module Sprockets + class Concatenation + attr_reader :source_lines + + def initialize + @source_lines = [] + @source_file_mtimes = {} + end + + def record(source_line) + source_lines << source_line + record_mtime_for(source_line.source_file) + source_line + end + + def to_s + source_lines.join + end + + def mtime + @source_file_mtimes.values.max + end + + def save_to(filename) + timestamp = mtime + File.open(filename, "w") { |file| file.write(to_s) } + File.utime(timestamp, timestamp, filename) + true + end + + protected + def record_mtime_for(source_file) + @source_file_mtimes[source_file] ||= source_file.mtime + end + end +end diff --git a/vendor/gems/gems/sprockets-1.0.2/lib/sprockets/environment.rb b/vendor/gems/gems/sprockets-1.0.2/lib/sprockets/environment.rb new file mode 100755 index 00000000..29f7daec --- /dev/null +++ b/vendor/gems/gems/sprockets-1.0.2/lib/sprockets/environment.rb @@ -0,0 +1,52 @@ +module Sprockets + class Environment + attr_reader :root, :load_path + + def initialize(root, load_path = []) + @load_path = [@root = Pathname.new(self, root)] + + load_path.reverse_each do |location| + register_load_location(location) + end + end + + def pathname_from(location) + Pathname.new(self, absolute_location_from(location)) + end + + def register_load_location(location) + pathname = pathname_from(location) + load_path.delete(pathname) + load_path.unshift(pathname) + location + end + + def find(location) + if Sprockets.absolute?(location) && File.exists?(location) + pathname_from(location) + else + find_all(location).first + end + end + + def constants(reload = false) + @constants = nil if reload + @constants ||= find_all("constants.yml").inject({}) do |constants, pathname| + contents = YAML.load(pathname.contents) rescue nil + contents = {} unless contents.is_a?(Hash) + constants.merge(contents) + end + end + + protected + def absolute_location_from(location) + location = location.to_s + location = File.join(root.absolute_location, location) unless Sprockets.absolute?(location) + File.expand_path(location) + end + + def find_all(location) + load_path.map { |pathname| pathname.find(location) }.compact + end + end +end diff --git a/vendor/gems/gems/sprockets-1.0.2/lib/sprockets/error.rb b/vendor/gems/gems/sprockets-1.0.2/lib/sprockets/error.rb new file mode 100755 index 00000000..31a3b673 --- /dev/null +++ b/vendor/gems/gems/sprockets-1.0.2/lib/sprockets/error.rb @@ -0,0 +1,5 @@ +module Sprockets + class Error < ::StandardError; end + class LoadError < Error; end + class UndefinedConstantError < Error; end +end diff --git a/vendor/gems/gems/sprockets-1.0.2/lib/sprockets/pathname.rb b/vendor/gems/gems/sprockets-1.0.2/lib/sprockets/pathname.rb new file mode 100755 index 00000000..8d3b0860 --- /dev/null +++ b/vendor/gems/gems/sprockets-1.0.2/lib/sprockets/pathname.rb @@ -0,0 +1,37 @@ +module Sprockets + class Pathname + attr_reader :environment, :absolute_location + + def initialize(environment, absolute_location) + @environment = environment + @absolute_location = File.expand_path(absolute_location) + end + + # Returns a Pathname for the location relative to this pathname's absolute location. + def find(location, kind = :file) + location = File.join(absolute_location, location) + File.send("#{kind}?", location) ? Pathname.new(environment, location) : nil + end + + def parent_pathname + Pathname.new(environment, File.dirname(absolute_location)) + end + + def source_file + SourceFile.new(environment, self) + end + + def contents + IO.read(absolute_location) + end + + def ==(pathname) + environment == pathname.environment && + absolute_location == pathname.absolute_location + end + + def to_s + absolute_location + end + end +end diff --git a/vendor/gems/gems/sprockets-1.0.2/lib/sprockets/preprocessor.rb b/vendor/gems/gems/sprockets-1.0.2/lib/sprockets/preprocessor.rb new file mode 100755 index 00000000..ed9a636d --- /dev/null +++ b/vendor/gems/gems/sprockets-1.0.2/lib/sprockets/preprocessor.rb @@ -0,0 +1,91 @@ +module Sprockets + class Preprocessor + attr_reader :environment, :concatenation, :source_files, :asset_paths + + def initialize(environment, options = {}) + @environment = environment + @concatenation = Concatenation.new + @source_files = [] + @asset_paths = [] + @options = options + end + + def require(source_file) + return if source_files.include?(source_file) + source_files << source_file + + source_file.each_source_line do |source_line| + if source_line.require? + require_from_source_line(source_line) + elsif source_line.provide? + provide_from_source_line(source_line) + else + record_source_line(source_line) + end + end + end + + def provide(asset_path) + return if !asset_path || asset_paths.include?(asset_path) + asset_paths << asset_path + end + + protected + attr_reader :options + + def require_from_source_line(source_line) + require pathname_from(source_line).source_file + end + + def provide_from_source_line(source_line) + provide asset_path_from(source_line) + end + + def record_source_line(source_line) + unless source_line.comment? && strip_comments? + concatenation.record(source_line) + end + end + + def strip_comments? + options[:strip_comments] != false + end + + def pathname_from(source_line) + pathname = send(pathname_finder_from(source_line), source_line) + raise_load_error_for(source_line) unless pathname + pathname + end + + def pathname_for_require_from(source_line) + environment.find(location_from(source_line)) + end + + def pathname_for_relative_require_from(source_line) + source_line.source_file.find(location_from(source_line)) + end + + def pathname_finder_from(source_line) + "pathname_for_#{kind_of_require_from(source_line)}_from" + end + + def kind_of_require_from(source_line) + source_line.require[/^(.)/, 1] == '"' ? :relative_require : :require + end + + def location_from(source_line) + location = source_line.require[/^.(.*).$/, 1] + File.join(File.dirname(location), File.basename(location, ".js") + ".js") + end + + def asset_path_from(source_line) + source_line.source_file.find(source_line.provide, :directory) + end + + def raise_load_error_for(source_line) + kind = kind_of_require_from(source_line).to_s.tr("_", " ") + file = File.split(location_from(source_line)).last + raise LoadError, "can't find file for #{kind} `#{file}' (#{source_line.inspect})" + end + end +end diff --git a/vendor/gems/gems/sprockets-1.0.2/lib/sprockets/secretary.rb b/vendor/gems/gems/sprockets-1.0.2/lib/sprockets/secretary.rb new file mode 100755 index 00000000..ded5acca --- /dev/null +++ b/vendor/gems/gems/sprockets-1.0.2/lib/sprockets/secretary.rb @@ -0,0 +1,106 @@ +module Sprockets + class Secretary + DEFAULT_OPTIONS = { + :root => ".", + :load_path => [], + :source_files => [], + :expand_paths => true + } + + attr_reader :environment, :preprocessor + + def initialize(options = {}) + reset!(options) + end + + def reset!(options = @options) + @options = DEFAULT_OPTIONS.merge(options) + @environment = Sprockets::Environment.new(@options[:root]) + @preprocessor = Sprockets::Preprocessor.new(@environment) + + add_load_locations(@options[:load_path]) + add_source_files(@options[:source_files]) + end + + def add_load_location(load_location, options = {}) + add_load_locations([load_location], options) + end + + def add_load_locations(load_locations, options = {}) + expand_paths(load_locations, options).each do |load_location| + environment.register_load_location(load_location) + end + end + + def add_source_file(source_file, options = {}) + add_source_files([source_file], options) + end + + def add_source_files(source_files, options = {}) + expand_paths(source_files, options).each do |source_file| + if pathname = environment.find(source_file) + preprocessor.require(pathname.source_file) + else + raise Sprockets::LoadError, "no such file `#{source_file}'" + end + end + end + + def concatenation + preprocessor.concatenation + end + + def install_assets + if @options[:asset_root] + preprocessor.asset_paths.each do |asset_path| + copy_assets_from(asset_path.absolute_location) + end + end + end + + def source_last_modified + preprocessor.source_files.map { |s| s.mtime }.max + end + + protected + def expand_paths(paths, options = {}) + if options.has_key?(:expand_paths) ? options[:expand_paths] : @options[:expand_paths] + paths.map { |path| Dir[from_root(path)].sort }.flatten.compact + else + paths.map { |path| from_root(path) } + end + end + + def from_root(path) + if Sprockets.absolute?(path) + path + else + File.join(@options[:root], path) + end + end + + def copy_assets_from(asset_path) + relative_file_paths_beneath(asset_path).each do |filename| + source, destination = File.join(asset_path, filename), File.join(asset_root, File.dirname(filename)) + if !File.directory?(source) + FileUtils.mkdir_p(destination) + FileUtils.cp(source, destination) + end + end + end + + def relative_file_paths_beneath(path) + Dir[File.join(path, "**", "*")].map do |filename| + File.join(*path_pieces(filename)[path_pieces(path).length..-1]) + end + end + + def asset_root + from_root(@options[:asset_root]) + end + + def path_pieces(path) + path.split(File::SEPARATOR) + end + end +end diff --git a/vendor/gems/gems/sprockets-1.0.2/lib/sprockets/source_file.rb b/vendor/gems/gems/sprockets-1.0.2/lib/sprockets/source_file.rb new file mode 100755 index 00000000..8dfa5253 --- /dev/null +++ b/vendor/gems/gems/sprockets-1.0.2/lib/sprockets/source_file.rb @@ -0,0 +1,54 @@ +module Sprockets + class SourceFile + attr_reader :environment, :pathname + + def initialize(environment, pathname) + @environment = environment + @pathname = pathname + end + + def source_lines + @lines ||= begin + lines = [] + + comments = [] + File.open(pathname.absolute_location) do |file| + file.each do |line| + lines << line = SourceLine.new(self, line, file.lineno) + + if line.begins_pdoc_comment? || comments.any? + comments << line + end + + if line.ends_multiline_comment? + if line.ends_pdoc_comment? + comments.each { |l| l.comment! } + end + comments.clear + end + end + end + + lines + end + end + + def each_source_line(&block) + source_lines.each(&block) + end + + def find(location, kind = :file) + pathname.parent_pathname.find(location, kind) + end + + def ==(source_file) + pathname == source_file.pathname + end + + def mtime + File.mtime(pathname.absolute_location) + rescue Errno::ENOENT + Time.now + end + end +end diff --git a/vendor/gems/gems/sprockets-1.0.2/lib/sprockets/source_line.rb b/vendor/gems/gems/sprockets-1.0.2/lib/sprockets/source_line.rb new file mode 100755 index 00000000..76c8ee69 --- /dev/null +++ b/vendor/gems/gems/sprockets-1.0.2/lib/sprockets/source_line.rb @@ -0,0 +1,82 @@ +module Sprockets + class SourceLine + attr_reader :source_file, :line, :number + + def initialize(source_file, line, number) + @source_file = source_file + @line = line + @number = number + end + + def comment + @comment ||= line[/^\s*\/\/(.*)/, 1] + end + + def comment? + !!comment + end + + def comment! + @comment = line + end + + def begins_multiline_comment? + line =~ /^\s*\/\*(.*)/ + end + + def begins_pdoc_comment? + line =~ /^\s*\/\*\*(.*)/ + end + + def ends_multiline_comment? + line =~ /^(.*)\*\/\s*/ + end + + def ends_pdoc_comment? + line =~ /^(.*)\*\*\/\s*/ + end + + def require + @require ||= (comment || "")[/^=\s+require\s+(\"(.*?)\"|<(.*?)>)\s*$/, 1] + end + + def require? + !!require + end + + def provide + @provide ||= (comment || "")[/^=\s+provide\s+\"(.*?)\"\s*$/, 1] + end + + def provide? + !!provide + end + + def inspect + "line #@number of #{@source_file.pathname}" + end + + def to_s(constants = source_file.environment.constants) + result = line.chomp + interpolate_constants!(result, constants) + strip_trailing_whitespace!(result) + result + $/ + end + + protected + def interpolate_constants!(result, constants) + result.gsub!(/<%=(.*?)%>/) do + constant = $1.strip + if value = constants[constant] + value + else + raise UndefinedConstantError, "couldn't find constant `#{constant}' in #{inspect}" + end + end + end + + def strip_trailing_whitespace!(result) + result.gsub!(/\s+$/, "") + end + end +end diff --git a/vendor/gems/gems/sprockets-1.0.2/lib/sprockets/version.rb b/vendor/gems/gems/sprockets-1.0.2/lib/sprockets/version.rb new file mode 100755 index 00000000..f9303add --- /dev/null +++ b/vendor/gems/gems/sprockets-1.0.2/lib/sprockets/version.rb @@ -0,0 +1,9 @@ +module Sprockets + module Version + MAJOR = 1 + MINOR = 0 + TINY = 2 + + STRING = [MAJOR, MINOR, TINY].join(".") + end +end diff --git a/vendor/gems/gems/sprockets-1.0.2/test/fixtures/assets/images/script_with_assets/one.png b/vendor/gems/gems/sprockets-1.0.2/test/fixtures/assets/images/script_with_assets/one.png new file mode 100755 index 00000000..5626abf0 --- /dev/null +++ b/vendor/gems/gems/sprockets-1.0.2/test/fixtures/assets/images/script_with_assets/one.png @@ -0,0 +1 @@ +one diff --git a/vendor/gems/gems/sprockets-1.0.2/test/fixtures/assets/images/script_with_assets/two.png b/vendor/gems/gems/sprockets-1.0.2/test/fixtures/assets/images/script_with_assets/two.png new file mode 100755 index 00000000..f719efd4 --- /dev/null +++ b/vendor/gems/gems/sprockets-1.0.2/test/fixtures/assets/images/script_with_assets/two.png @@ -0,0 +1 @@ +two diff --git a/vendor/gems/gems/sprockets-1.0.2/test/fixtures/assets/stylesheets/script_with_assets.css b/vendor/gems/gems/sprockets-1.0.2/test/fixtures/assets/stylesheets/script_with_assets.css new file mode 100755 index 00000000..da84fa5f --- /dev/null +++ b/vendor/gems/gems/sprockets-1.0.2/test/fixtures/assets/stylesheets/script_with_assets.css @@ -0,0 +1 @@ +/* nothing */ diff --git a/vendor/gems/gems/sprockets-1.0.2/test/fixtures/constants.yml b/vendor/gems/gems/sprockets-1.0.2/test/fixtures/constants.yml new file mode 100755 index 00000000..9ea45ed8 --- /dev/null +++ b/vendor/gems/gems/sprockets-1.0.2/test/fixtures/constants.yml @@ -0,0 +1 @@ +VERSION: 1.0 diff --git a/vendor/gems/gems/sprockets-1.0.2/test/fixtures/double_slash_comments_that_are_not_requires_should_be_ignored_when_strip_comments_is_false.js b/vendor/gems/gems/sprockets-1.0.2/test/fixtures/double_slash_comments_that_are_not_requires_should_be_ignored_when_strip_comments_is_false.js new file mode 100755 index 00000000..43fc8474 --- /dev/null +++ b/vendor/gems/gems/sprockets-1.0.2/test/fixtures/double_slash_comments_that_are_not_requires_should_be_ignored_when_strip_comments_is_false.js @@ -0,0 +1,8 @@ +// This is a double-slash comment that should appear in the resulting output file. +/* This is a slash-star comment that should appear in the resulting output file. */ +/* This is multiline slash-star comment +* that should appear in the resulting +* output file */ +/** + This is not a PDoc comment that should appear in the resulting output file. +*/ diff --git a/vendor/gems/gems/sprockets-1.0.2/test/fixtures/double_slash_comments_that_are_not_requires_should_be_removed_by_default.js b/vendor/gems/gems/sprockets-1.0.2/test/fixtures/double_slash_comments_that_are_not_requires_should_be_removed_by_default.js new file mode 100755 index 00000000..d87c260d --- /dev/null +++ b/vendor/gems/gems/sprockets-1.0.2/test/fixtures/double_slash_comments_that_are_not_requires_should_be_removed_by_default.js @@ -0,0 +1,2 @@ +// This is a double-slash comment that should not appear in the resulting output file. +/* This is a slash-star comment that should not appear in the resulting output file. */ diff --git a/vendor/gems/gems/sprockets-1.0.2/test/fixtures/multiline_comments_should_be_removed_by_default.js b/vendor/gems/gems/sprockets-1.0.2/test/fixtures/multiline_comments_should_be_removed_by_default.js new file mode 100755 index 00000000..8b169adb --- /dev/null +++ b/vendor/gems/gems/sprockets-1.0.2/test/fixtures/multiline_comments_should_be_removed_by_default.js @@ -0,0 +1,4 @@ +/** + * This is a PDoc comment + * that should appear in the resulting output file. +**/ diff --git a/vendor/gems/gems/sprockets-1.0.2/test/fixtures/requiring_a_file_after_it_has_already_been_required_should_do_nothing.js b/vendor/gems/gems/sprockets-1.0.2/test/fixtures/requiring_a_file_after_it_has_already_been_required_should_do_nothing.js new file mode 100755 index 00000000..497a4c1b --- /dev/null +++ b/vendor/gems/gems/sprockets-1.0.2/test/fixtures/requiring_a_file_after_it_has_already_been_required_should_do_nothing.js @@ -0,0 +1,5 @@ +var before_first_require; +//= require +var after_first_require_and_before_second_require; +//= require +var after_second_require; diff --git a/vendor/gems/gems/sprockets-1.0.2/test/fixtures/requiring_a_file_that_does_not_exist_should_raise_an_error.js b/vendor/gems/gems/sprockets-1.0.2/test/fixtures/requiring_a_file_that_does_not_exist_should_raise_an_error.js new file mode 100755 index 00000000..cd8230d2 --- /dev/null +++ b/vendor/gems/gems/sprockets-1.0.2/test/fixtures/requiring_a_file_that_does_not_exist_should_raise_an_error.js @@ -0,0 +1 @@ +//= require diff --git a/vendor/gems/gems/sprockets-1.0.2/test/fixtures/requiring_a_single_file_should_replace_the_require_comment_with_the_file_contents.js b/vendor/gems/gems/sprockets-1.0.2/test/fixtures/requiring_a_single_file_should_replace_the_require_comment_with_the_file_contents.js new file mode 100755 index 00000000..86d8a974 --- /dev/null +++ b/vendor/gems/gems/sprockets-1.0.2/test/fixtures/requiring_a_single_file_should_replace_the_require_comment_with_the_file_contents.js @@ -0,0 +1,3 @@ +var before_require; +//= require +var after_require; diff --git a/vendor/gems/gems/sprockets-1.0.2/test/fixtures/requiring_the_current_file_should_do_nothing.js b/vendor/gems/gems/sprockets-1.0.2/test/fixtures/requiring_the_current_file_should_do_nothing.js new file mode 100755 index 00000000..d9305bd5 --- /dev/null +++ b/vendor/gems/gems/sprockets-1.0.2/test/fixtures/requiring_the_current_file_should_do_nothing.js @@ -0,0 +1 @@ +//= require "requiring_the_current_file_should_do_nothing" diff --git a/vendor/gems/gems/sprockets-1.0.2/test/fixtures/src/constants.yml b/vendor/gems/gems/sprockets-1.0.2/test/fixtures/src/constants.yml new file mode 100755 index 00000000..baf4edb9 --- /dev/null +++ b/vendor/gems/gems/sprockets-1.0.2/test/fixtures/src/constants.yml @@ -0,0 +1,3 @@ +ONE: one +TWO: two +HELLO: Hello world! diff --git a/vendor/gems/gems/sprockets-1.0.2/test/fixtures/src/foo.js b/vendor/gems/gems/sprockets-1.0.2/test/fixtures/src/foo.js new file mode 100755 index 00000000..b8514fef --- /dev/null +++ b/vendor/gems/gems/sprockets-1.0.2/test/fixtures/src/foo.js @@ -0,0 +1 @@ +var Foo = { }; diff --git a/vendor/gems/gems/sprockets-1.0.2/test/fixtures/src/foo/bar.js b/vendor/gems/gems/sprockets-1.0.2/test/fixtures/src/foo/bar.js new file mode 100755 index 00000000..dd4d767d --- /dev/null +++ b/vendor/gems/gems/sprockets-1.0.2/test/fixtures/src/foo/bar.js @@ -0,0 +1,4 @@ +//= require "bar" +var FooBar = { }; + +/* Hello! */ diff --git a/vendor/gems/gems/sprockets-1.0.2/test/fixtures/src/foo/foo.js b/vendor/gems/gems/sprockets-1.0.2/test/fixtures/src/foo/foo.js new file mode 100755 index 00000000..290e951e --- /dev/null +++ b/vendor/gems/gems/sprockets-1.0.2/test/fixtures/src/foo/foo.js @@ -0,0 +1 @@ +var FooFoo = { }; diff --git a/vendor/gems/gems/sprockets-1.0.2/test/fixtures/src/script_with_assets.js b/vendor/gems/gems/sprockets-1.0.2/test/fixtures/src/script_with_assets.js new file mode 100755 index 00000000..91aa4298 --- /dev/null +++ b/vendor/gems/gems/sprockets-1.0.2/test/fixtures/src/script_with_assets.js @@ -0,0 +1,3 @@ +//= provide "../assets" + +var ScriptWithAssets = { }; diff --git a/vendor/gems/gems/sprockets-1.0.2/test/test_concatenation.rb b/vendor/gems/gems/sprockets-1.0.2/test/test_concatenation.rb new file mode 100755 index 00000000..18c490c0 --- /dev/null +++ b/vendor/gems/gems/sprockets-1.0.2/test/test_concatenation.rb @@ -0,0 +1,28 @@ +require "test_helper" + +class ConcatenationTest < Test::Unit::TestCase + def setup + @concatenation = Sprockets::Concatenation.new + @environment = environment_for_fixtures + end + + def test_record + assert_equal [], @concatenation.source_lines + assert_equal "hello\n", @concatenation.record(source_line("hello\n")).to_s + assert_equal "world\n", @concatenation.record(source_line("world\n")).to_s + assert_equal ["hello\n", "world\n"], @concatenation.source_lines.map { |source_line| source_line.to_s } + end + + def test_to_s + @concatenation.record(source_line("hello\n")) + @concatenation.record(source_line("world\n")) + assert_equal "hello\nworld\n", @concatenation.to_s + end + + def test_save_to + filename = File.join(FIXTURES_PATH, "output.js") + @concatenation.save_to(filename) + assert_equal @concatenation.to_s, IO.read(filename) + File.unlink(filename) + end +end diff --git a/vendor/gems/gems/sprockets-1.0.2/test/test_environment.rb b/vendor/gems/gems/sprockets-1.0.2/test/test_environment.rb new file mode 100755 index 00000000..a65e3bf7 --- /dev/null +++ b/vendor/gems/gems/sprockets-1.0.2/test/test_environment.rb @@ -0,0 +1,64 @@ +require "test_helper" + +class EnvironmentTest < Test::Unit::TestCase + def test_load_path_locations_become_pathnames_for_absolute_locations_from_the_root + environment = Sprockets::Environment.new("/root", ["/a", "b"]) + assert_load_path_equals ["/a", "/root/b", "/root"], environment + end + + def test_pathname_from_for_location_with_leading_slash_should_return_a_pathname_with_the_location_unchanged + environment = Sprockets::Environment.new("/root") + assert_absolute_location "/a", environment.pathname_from("/a") + end + + def test_pathname_from_for_relative_location_should_return_a_pathname_for_the_expanded_absolute_location_from_root + environment = Sprockets::Environment.new("/root") + assert_absolute_location "/root/a", environment.pathname_from("a") + assert_absolute_location "/root/a", environment.pathname_from("./a") + assert_absolute_location "/a", environment.pathname_from("../a") + end + + def test_register_load_location_should_unshift_the_location_onto_the_load_path + environment = Sprockets::Environment.new("/root") + environment.register_load_location("a") + assert_load_path_equals ["/root/a", "/root"], environment + environment.register_load_location("b") + assert_load_path_equals ["/root/b", "/root/a", "/root"], environment + end + + def test_register_load_location_should_remove_already_existing_locations_before_unshifting + environment = Sprockets::Environment.new("/root") + environment.register_load_location("a") + environment.register_load_location("b") + assert_load_path_equals ["/root/b", "/root/a", "/root"], environment + environment.register_load_location("a") + assert_load_path_equals ["/root/a", "/root/b", "/root"], environment + end + + def test_find_should_return_the_first_matching_pathname_in_the_load_path + environment = environment_for_fixtures + first_pathname = environment.find("foo.js") + assert_absolute_location_ends_with "src/foo.js", first_pathname + + environment.register_load_location(File.join(FIXTURES_PATH, "src", "foo")) + second_pathname = environment.find("foo.js") + assert_not_equal first_pathname, second_pathname + assert_absolute_location_ends_with "foo/foo.js", second_pathname + end + + def test_find_should_return_nil_when_no_matching_source_file_is_found + environment = environment_for_fixtures + assert_nil environment.find("nonexistent.js") + end + + def test_constants_should_return_a_hash_of_all_constants_defined_in_the_load_path + constants = environment_for_fixtures.constants + assert_kind_of Hash, constants + assert_equal %w(HELLO ONE TWO VERSION), constants.keys.sort + end + + protected + def assert_load_path_equals(load_path_absolute_locations, environment) + assert load_path_absolute_locations.zip(environment.load_path).map { |location, pathname| File.expand_path(location) == pathname.absolute_location }.all? + end +end diff --git a/vendor/gems/gems/sprockets-1.0.2/test/test_helper.rb b/vendor/gems/gems/sprockets-1.0.2/test/test_helper.rb new file mode 100755 index 00000000..fcb2ad44 --- /dev/null +++ b/vendor/gems/gems/sprockets-1.0.2/test/test_helper.rb @@ -0,0 +1,55 @@ +require File.join(File.dirname(__FILE__), *%w".. lib sprockets") +require "test/unit" +require "fileutils" +require "tmpdir" + +class Test::Unit::TestCase + FIXTURES_PATH = File.expand_path(File.join(File.dirname(__FILE__), "fixtures")) unless defined?(FIXTURES_PATH) + + protected + def location_for_fixture(fixture) + File.join(FIXTURES_PATH, fixture) + end + + def content_of_fixture(fixture) + IO.read(location_for_fixture(fixture)) + end + + def environment_for_fixtures + Sprockets::Environment.new(FIXTURES_PATH, source_directories_in_fixtures_path) + end + + def source_directories_in_fixtures_path + Dir[File.join(FIXTURES_PATH, "**", "src")] + end + + def assert_absolute_location(location, pathname) + assert_equal File.expand_path(location), pathname.absolute_location + end + + def assert_absolute_location_ends_with(location_ending, pathname) + assert pathname.absolute_location[/#{Regexp.escape(location_ending)}$/] + end + + def pathname(location, environment = @environment) + Sprockets::Pathname.new(environment, File.join(FIXTURES_PATH, location)) + end + + def source_file(location, environment = @environment) + Sprockets::SourceFile.new(environment, pathname(location, environment)) + end + + def source_line(line, source_file = nil, line_number = 1) + Sprockets::SourceLine.new(source_file || source_file("dummy"), line, line_number) + end + + def with_temporary_directory + path = File.join(Dir.tmpdir, [caller[0][/`(.*)'/, 1], Time.now.to_f].join("_")) + begin + FileUtils.mkdir(path) + yield path + ensure + FileUtils.rm_rf(path) + end + end +end diff --git a/vendor/gems/gems/sprockets-1.0.2/test/test_pathname.rb b/vendor/gems/gems/sprockets-1.0.2/test/test_pathname.rb new file mode 100755 index 00000000..7860a704 --- /dev/null +++ b/vendor/gems/gems/sprockets-1.0.2/test/test_pathname.rb @@ -0,0 +1,43 @@ +require "test_helper" + +class PathnameTest < Test::Unit::TestCase + def setup + @environment = environment_for_fixtures + end + + def test_absolute_location_is_automatically_expanded + expanded_location = File.expand_path(File.join(FIXTURES_PATH, "foo")) + assert_absolute_location expanded_location, pathname("foo") + assert_absolute_location expanded_location, pathname("./foo") + assert_absolute_location expanded_location, pathname("./foo/../foo") + end + + def test_find_should_return_a_pathname_for_the_location_relative_to_the_absolute_location_of_the_pathname + assert_absolute_location_ends_with "src/foo/bar.js", pathname("src/foo").find("bar.js") + end + + def test_find_should_return_nil_when_the_location_relative_to_the_absolute_location_of_the_pathname_is_not_a_file_or_does_not_exist + assert_nil pathname("src/foo").find("nonexistent.js") + end + + def test_parent_pathname_should_return_a_pathname_for_the_parent_directory + assert_absolute_location_ends_with "src", pathname("src/foo").parent_pathname + assert_absolute_location_ends_with "foo", pathname("src/foo/foo.js").parent_pathname + end + + def test_source_file_should_return_a_source_file_for_the_pathname + source_file = pathname("src/foo.js").source_file + assert_kind_of Sprockets::SourceFile, source_file + assert_equal pathname("src/foo.js"), source_file.pathname + end + + def test_equality_of_pathnames + assert_equal pathname("src/foo.js"), pathname("src/foo.js") + assert_equal pathname("src/foo.js"), pathname("src/foo/../foo.js") + assert_not_equal pathname("src/foo.js"), pathname("src/foo/foo.js") + end + + def test_to_s_should_return_absolute_location + assert_equal pathname("src/foo.js").to_s, pathname("src/foo.js").absolute_location + end +end diff --git a/vendor/gems/gems/sprockets-1.0.2/test/test_preprocessor.rb b/vendor/gems/gems/sprockets-1.0.2/test/test_preprocessor.rb new file mode 100755 index 00000000..1933767f --- /dev/null +++ b/vendor/gems/gems/sprockets-1.0.2/test/test_preprocessor.rb @@ -0,0 +1,107 @@ +require "test_helper" + +class PreprocessorTest < Test::Unit::TestCase + def setup + @environment = environment_for_fixtures + @preprocessor = Sprockets::Preprocessor.new(@environment) + end + + def test_double_slash_comments_that_are_not_requires_should_be_removed_by_default + require_file_for_this_test + assert_concatenation_does_not_contain_line "// This is a double-slash comment that should not appear in the resulting output file." + assert_concatenation_contains_line "/* This is a slash-star comment that should not appear in the resulting output file. */" + end + + def test_double_slash_comments_that_are_not_requires_should_be_ignored_when_strip_comments_is_false + @preprocessor = Sprockets::Preprocessor.new(@environment, :strip_comments => false) + require_file_for_this_test + assert_concatenation_contains_line "// This is a double-slash comment that should appear in the resulting output file." + assert_concatenation_contains_line "/* This is a slash-star comment that should appear in the resulting output file. */" + + assert_concatenation_contains_line "/* This is multiline slash-star comment" + assert_concatenation_contains_line "* that should appear in the resulting" + assert_concatenation_contains_line "* output file */" + + assert_concatenation_contains_line "This is not a PDoc comment that should appear in the resulting output file." + end + + def test_multiline_comments_should_be_removed_by_default + require_file_for_this_test + assert_concatenation_does_not_contain_line "/**" + assert_concatenation_does_not_contain_line " * This is a PDoc comment" + assert_concatenation_does_not_contain_line " * that should appear in the resulting output file." + assert_concatenation_does_not_contain_line "**/" + end + + def test_requiring_a_single_file_should_replace_the_require_comment_with_the_file_contents + require_file_for_this_test + assert_concatenation_contains <<-LINES + var before_require; + var Foo = { }; + var after_require; + LINES + end + + def test_requiring_a_file_that_does_not_exist_should_raise_an_error + assert_raises(Sprockets::LoadError) do + require_file_for_this_test + end + end + + def test_requiring_the_current_file_should_do_nothing + require_file_for_this_test + assert_equal "", output_text + end + + def test_requiring_a_file_after_it_has_already_been_required_should_do_nothing + require_file_for_this_test + assert_concatenation_contains <<-LINES + var before_first_require; + var Foo = { }; + var after_first_require_and_before_second_require; + var after_second_require; + LINES + end + + protected + attr_reader :environment, :preprocessor + + def concatenation + preprocessor.concatenation + end + + def output_text + preprocessor.concatenation.to_s + end + + def source_lines_matching(line) + concatenation.source_lines.select { |source_line| source_line.line.strip == line } + end + + def require_file(location) + preprocessor.require(environment.find(location).source_file) + end + + def require_file_for_this_test + require_file(file_for_this_test) + end + + def file_for_this_test + caller.map { |c| c[/`(.*?)'$/, 1] }.grep(/^test_/).first[5..-1] + ".js" + end + + def assert_concatenation_does_not_contain_line(line) + assert source_lines_matching(line).empty?, "Expected #{line.inspect} to not exist" + end + + def assert_concatenation_contains_line(line) + assert source_lines_matching(line).any?, "Expected #{line.inspect} to exist" + end + + def assert_concatenation_contains(indented_text) + lines = indented_text.split($/) + initial_indent = lines.first[/^\s*/].length + unindented_text = lines.map { |line| line[initial_indent..-1] }.join($/) + assert output_text[unindented_text] + end +end diff --git a/vendor/gems/gems/sprockets-1.0.2/test/test_secretary.rb b/vendor/gems/gems/sprockets-1.0.2/test/test_secretary.rb new file mode 100755 index 00000000..a2e33250 --- /dev/null +++ b/vendor/gems/gems/sprockets-1.0.2/test/test_secretary.rb @@ -0,0 +1,83 @@ +require "test_helper" + +class SecretaryTest < Test::Unit::TestCase + def test_load_locations_are_not_expanded_when_expand_paths_is_false + secretary = Sprockets::Secretary.new(:root => FIXTURES_PATH) + secretary.add_load_location("src/**/", :expand_paths => false) + + assert_equal [File.join(FIXTURES_PATH, "src/**"), FIXTURES_PATH], + secretary.environment.load_path.map { |pathname| pathname.absolute_location } + end + + def test_load_locations_are_expanded_when_expand_paths_is_true + secretary = Sprockets::Secretary.new(:root => FIXTURES_PATH) + secretary.add_load_location("src/**/", :expand_paths => true) + + assert_equal [File.join(FIXTURES_PATH, "src", "foo"), File.join(FIXTURES_PATH, "src"), FIXTURES_PATH], + secretary.environment.load_path.map { |pathname| pathname.absolute_location } + end + + def test_source_files_are_not_expanded_when_expand_paths_is_false + secretary = Sprockets::Secretary.new(:root => FIXTURES_PATH) + assert_raises(Sprockets::LoadError) do + secretary.add_source_file("src/f*.js", :expand_paths => false) + end + end + + def test_source_files_are_expanded_when_expand_paths_is_true + secretary = Sprockets::Secretary.new(:root => FIXTURES_PATH) + secretary.add_source_file("src/f*.js", :expand_paths => true) + + assert_equal [File.join(FIXTURES_PATH, "src", "foo.js")], + secretary.preprocessor.source_files.map { |source_file| source_file.pathname.absolute_location } + end + + def test_install_assets_into_empty_directory + with_temporary_directory do |temp| + secretary = Sprockets::Secretary.new(:root => FIXTURES_PATH, :asset_root => temp) + secretary.add_source_file("src/script_with_assets.js") + + assert_equal [], Dir[File.join(temp, "**", "*")] + secretary.install_assets + assert_equal paths_relative_to(temp, + "images", "images/script_with_assets", "images/script_with_assets/one.png", + "images/script_with_assets/two.png", "stylesheets", "stylesheets/script_with_assets.css"), + Dir[File.join(temp, "**", "*")].sort + end + end + + def test_install_assets_into_nonexistent_directory + with_temporary_directory do |temp| + temp = File.join(temp, "assets") + secretary = Sprockets::Secretary.new(:root => FIXTURES_PATH, :asset_root => temp) + secretary.add_source_file("src/script_with_assets.js") + + assert_equal [], Dir[File.join(temp, "**", "*")] + secretary.install_assets + assert_equal paths_relative_to(temp, + "images", "images/script_with_assets", "images/script_with_assets/one.png", + "images/script_with_assets/two.png", "stylesheets", "stylesheets/script_with_assets.css"), + Dir[File.join(temp, "**", "*")].sort + end + end + + def test_install_assets_into_subdirectories_that_already_exist + with_temporary_directory do |temp| + secretary = Sprockets::Secretary.new(:root => FIXTURES_PATH, :asset_root => temp) + secretary.add_source_file("src/script_with_assets.js") + + FileUtils.mkdir_p(File.join(temp, "images", "script_with_assets")) + assert_equal paths_relative_to(temp, "images", "images/script_with_assets"), Dir[File.join(temp, "**", "*")] + secretary.install_assets + assert_equal paths_relative_to(temp, + "images", "images/script_with_assets", "images/script_with_assets/one.png", + "images/script_with_assets/two.png", "stylesheets", "stylesheets/script_with_assets.css"), + Dir[File.join(temp, "**", "*")].sort + end + end + + protected + def paths_relative_to(root, *paths) + paths.map { |path| File.join(root, path) } + end +end diff --git a/vendor/gems/gems/sprockets-1.0.2/test/test_source_file.rb b/vendor/gems/gems/sprockets-1.0.2/test/test_source_file.rb new file mode 100755 index 00000000..6c3d8945 --- /dev/null +++ b/vendor/gems/gems/sprockets-1.0.2/test/test_source_file.rb @@ -0,0 +1,34 @@ +require "test_helper" +require "enumerator" +Enumerator = Enumerable::Enumerator unless defined?(Enumerator) # for 1.9.1 compatibility + +class SourceFileTest < Test::Unit::TestCase + def setup + @environment = environment_for_fixtures + end + + def test_each_source_line + source_file_lines = Enumerator.new(source_file("src/foo/bar.js"), :each_source_line).to_a + assert_equal content_of_fixture("src/foo/bar.js"), source_file_lines.map { |line| line.line }.join + assert_equal 4, source_file_lines.length + end + + def test_find_should_return_pathname_for_file_relative_to_the_current_pathname + assert_absolute_location_ends_with "test/fixtures/src/foo/bar.js", source_file("src/foo/foo.js").find("bar.js") + end + + def test_find_should_return_nil_for_nonexistent_file + assert_nil source_file("src/foo/foo.js").find("nonexistent.js") + end + + def test_equality_of_source_files + assert_equal source_file("src/foo/foo.js"), source_file("src/foo/foo.js") + assert_equal source_file("src/foo/foo.js"), source_file("src/foo/../foo/foo.js") + assert_not_equal source_file("src/foo/foo.js"), source_file("src/foo.js") + assert_not_equal source_file("src/foo/foo.js"), source_file("src/foo/bar.js") + end + + def test_mtime_should_return_now_if_file_does_not_exist + assert source_file("src/foo/nonexistent.js").mtime.instance_of?(Time) + end +end diff --git a/vendor/gems/gems/sprockets-1.0.2/test/test_source_line.rb b/vendor/gems/gems/sprockets-1.0.2/test/test_source_line.rb new file mode 100755 index 00000000..bd2d8181 --- /dev/null +++ b/vendor/gems/gems/sprockets-1.0.2/test/test_source_line.rb @@ -0,0 +1,89 @@ +require "test_helper" + +class SourceLineTest < Test::Unit::TestCase + def test_line_that_begins_with_double_slash_should_be_a_comment + assert source_line("//").comment? + assert source_line("//test").comment? + assert source_line("//= require").comment? + assert source_line("//= require ").comment? + assert source_line(" //").comment? + assert source_line("\t//").comment? + end + + def test_line_that_begins_a_multiline_comment + assert source_line(" /*").begins_multiline_comment? + assert source_line(" /**").begins_multiline_comment? + end + + def test_line_that_begins_a_pdoc_comment + assert !source_line(" /*").begins_pdoc_comment? + assert source_line(" /**").begins_pdoc_comment? + end + + def test_line_that_ends_a_multiline_comment + assert source_line(" */").ends_multiline_comment? + assert source_line(" **/").ends_multiline_comment? + end + + def test_line_that_ends_a_pdoc_comment + assert !source_line(" */").ends_pdoc_comment? + assert source_line(" **/").ends_pdoc_comment? + end + + def test_line_that_contains_but_does_not_begin_with_double_slash_should_not_be_a_comment + assert !source_line("f //").comment? + assert !source_line("f //= require ").comment? + end + + def test_comment_should_be_extracted_from_comment_lines + assert_equal "test", source_line("//test").comment + assert_equal " test", source_line("// test").comment + assert_equal nil, source_line("f //test").comment + end + + def test_line_that_contains_require_comment_should_be_a_require + assert source_line("//= require ").require? + assert !source_line("//= require").require? + assert source_line("//= require \"foo\"").require? + assert !source_line("//= require f").require? + end + + def test_require_should_be_extracted_from_require_lines + assert_nil source_line("//= require").require + assert_equal "", source_line("//= require ").require + assert_equal "", source_line("//= require ").require + assert_equal "\"foo\"", source_line("//= require \"foo\"").require + end + + def test_line_that_contains_a_provide_comment_should_be_a_provide + assert source_line("//= provide \"../assets\"").provide? + assert !source_line("//= provide").provide? + assert !source_line("//= provide <../assets>").provide? + end + + def test_provide_should_be_extracted_from_provide_lines + assert_nil source_line("//= provide").provide + assert_equal "../assets", source_line("//= provide \"../assets\"").provide + end + + def test_inspect_should_include_source_file_location_and_line_number + environment = environment_for_fixtures + pathname = Sprockets::Pathname.new(environment, "/a/b/c.js") + source_file = Sprockets::SourceFile.new(environment, pathname) + assert_equal "line 25 of #{File.expand_path("/a/b/c.js")}", source_line("hello", source_file, 25).inspect + end + + def test_interpolation_of_constants + assert_equal %(var VERSION = "1.0";\n), source_line('var VERSION = "<%= VERSION %>";').to_s("VERSION" => "1.0") + end + + def test_interpolation_of_missing_constant_raises_undefined_constant_error + assert_raises(Sprockets::UndefinedConstantError) do + source_line('<%= NONEXISTENT %>').to_s("VERSION" => "1.0") + end + end + + def test_to_s_should_strip_trailing_whitespace_before_adding_line_ending + assert_equal "hello();\n", source_line("hello(); \t \r\n").to_s({}) + end +end diff --git a/vendor/gems/gems/templater-1.0.0/History.txt b/vendor/gems/gems/templater-1.0.0/History.txt new file mode 100755 index 00000000..cd4a548e --- /dev/null +++ b/vendor/gems/gems/templater-1.0.0/History.txt @@ -0,0 +1,3 @@ +=== 1.0.0 2009-08-27 + +* Ruby 1.9 compatibility diff --git a/vendor/gems/gems/templater-1.0.0/Manifest.txt b/vendor/gems/gems/templater-1.0.0/Manifest.txt new file mode 100755 index 00000000..50b749dd --- /dev/null +++ b/vendor/gems/gems/templater-1.0.0/Manifest.txt @@ -0,0 +1,64 @@ +History.txt +Manifest.txt +README.rdoc +Rakefile +lib/templater.rb +lib/templater/actions/action.rb +lib/templater/actions/directory.rb +lib/templater/actions/empty_directory.rb +lib/templater/actions/file.rb +lib/templater/actions/template.rb +lib/templater/capture_helpers.rb +lib/templater/cli/generator.rb +lib/templater/cli/manifold.rb +lib/templater/cli/parser.rb +lib/templater/core_ext/kernel.rb +lib/templater/core_ext/string.rb +lib/templater/description.rb +lib/templater/discovery.rb +lib/templater/generator.rb +lib/templater/manifold.rb +lib/templater/spec/helpers.rb +script/console +script/destroy +script/generate +spec/actions/directory_spec.rb +spec/actions/empty_directory_spec.rb +spec/actions/file_spec.rb +spec/actions/template_spec.rb +spec/core_ext/string_spec.rb +spec/generator/actions_spec.rb +spec/generator/arguments_spec.rb +spec/generator/desc_spec.rb +spec/generator/destination_root_spec.rb +spec/generator/empty_directories_spec.rb +spec/generator/files_spec.rb +spec/generator/generators_spec.rb +spec/generator/glob_spec.rb +spec/generator/invocations_spec.rb +spec/generator/invoke_spec.rb +spec/generator/options_spec.rb +spec/generator/render_spec.rb +spec/generator/source_root_spec.rb +spec/generator/templates_spec.rb +spec/manifold_spec.rb +spec/options_parser_spec.rb +spec/results/erb.rbs +spec/results/file.rbs +spec/results/random.rbs +spec/results/simple_erb.rbs +spec/spec_helper.rb +spec/spec_helpers_spec.rb +spec/templater_spec.rb +spec/templates/erb.rbt +spec/templates/glob/README +spec/templates/glob/arg.js +spec/templates/glob/hellothar.%feh% +spec/templates/glob/hellothar.html.%feh% +spec/templates/glob/subfolder/jessica_alba.jpg +spec/templates/glob/subfolder/monkey.rb +spec/templates/glob/test.rb +spec/templates/literals_erb.rbt +spec/templates/simple.rbt +spec/templates/simple_erb.rbt +templater.gemspec diff --git a/vendor/gems/gems/templater-1.0.0/README.rdoc b/vendor/gems/gems/templater-1.0.0/README.rdoc new file mode 100755 index 00000000..8072eef9 --- /dev/null +++ b/vendor/gems/gems/templater-1.0.0/README.rdoc @@ -0,0 +1,266 @@ += Templater + +* http://github.com/jnicklas/templater + +== Summary + +Templater is a Ruby framework for building code generators. + +== Description + +Templater has the ability to both copy files from A to B and also to render templates using ERB. Templater consists of four parts: + +- Actions (File copying routines, templates generation and directories creation routines). +- Generators (set of rules). +- Manifolds (generator suites). +- The command line interface. + +Hierarchy is pretty simple: manifold has one or many public and private generators. Public ones are supposed to be called +by end user. Generators have one or more action that specify what they do, where they take files, how they name resulting +files and so forth. + +== Idea behind Templater + +Templater is designed to be flexible and designed to be reflective. Generators created with templater are definitions of what goes where, they provide no interface for the user. This allows you to use templater generators inside your own code, or with the bundled CLI interface, or with your own interface. + +== Example + +This is how to create a very simple system for generating things: + + module MyGenerators + + extend Templater::Manifold + + class BlogGenerator < Templater::Generator + # directory this generator uses as source root when searching + # for files, directories, templates + def self.source_root + File.join(File.dirname(__FILE__), 'templates') + end + + # uses blog.rbt template (note conventional trailing t) + # placing resulting file to blog.rb relatively to + # destination root + template :blog, 'blog.rb' + + # does simple copy of me.jpg placing resulting file to me.jpg relatively to + # destination root + file :me, 'me.jpg' + + # creates empty directory public/javascripts relatively to + # destination root + empty_directory :javascripts, File.join("public", "javascripts") + end + + class WikiGenerator < Templater::Generator + + def self.source_root + File.join(File.dirname(__FILE__), 'templates') + end + + template :wiki, 'wiki.rb' + file :img, 'wiki.jpg' + + end + + # The generators are added to the manifold, and assigned the names 'wiki' and 'blog'. + # So you can call them + + Async Chat + + + +
+ Your first message will become your nickname! + Users: #{@users.map{|k,u|u.username}.join(', ')} +
+
+ +
+ + + + EOPAGE + end + + def register_user(user_id, renderer) + body = create_user(user_id) + body.call render_page + body.errback { delete_user user_id } + body.callback { delete_user user_id } + + EventMachine::next_tick do + renderer.call [200, {'Content-Type' => 'text/html'}, body] + end + end + + def new_message(user_id, message) + return unless @users[user_id] + if @users[user_id].username == :anonymous + username = unique_username(message) + log "User: #{user_id} is #{username}" + @users[user_id].username = message + message = "-> #{username} signed on." + end + username ||= @users[user_id].username + log "User: #{username} sent: #{message}" + @users.each do |id, body| + EventMachine::next_tick { body.call [js_message(username, message)] } + end + end + + private + def unique_username(name) + name.concat('_') while @users.any? { |id,u| name == u.username } + name + end + + def log(str) + print str, "\n" + end + + def add_user(id, body) + @users[id] = body + end + + def delete_user(id) + message = "User: #{id} - #{@users[id].username if @users[id]} disconnected." + log message + new_message(id, message) + @users.delete id + end + + def js_message(username, message) + %() + end + + def create_user(id) + message = "User: #{id} connected." + log message + new_message(id, message) + body = DeferrableBody.new + body.extend UserBody + body.username = :anonymous + add_user(id, body) + body + end + +end + +class AsyncChat + + AsyncResponse = [-1, {}, []].freeze + AjaxResponse = [200, {}, []].freeze + + def initialize + @chat = Chat.new + end + + def call(env) + request = Rack::Request.new(env) + # TODO - cookie me, baby + user_id = request.env['REMOTE_ADDR'] + if request.xhr? + message = request['message'] + @chat.new_message(user_id, Rack::Utils.escape_html(message)) + AjaxResponse + else + renderer = request.env['async.callback'] + @chat.register_user(user_id, renderer) + AsyncResponse + end + end + +end + +run AsyncChat.new diff --git a/vendor/gems/gems/thin-1.2.5/example/async_tailer.ru b/vendor/gems/gems/thin-1.2.5/example/async_tailer.ru new file mode 100755 index 00000000..467f0df6 --- /dev/null +++ b/vendor/gems/gems/thin-1.2.5/example/async_tailer.ru @@ -0,0 +1,100 @@ +#!/usr/bin/env rackup -s thin +# +# async_tailer.ru +# raggi/thin +# +# Tested with 150 spawned tails on OS X +# +# Created by James Tucker on 2008-06-18. +# Copyright 2008 James Tucker . + +# Uncomment if appropriate for you.. +# EM.epoll +# EM.kqueue + +class DeferrableBody + include EventMachine::Deferrable + + def initialize + @queue = [] + # make sure to flush out the queue before closing the connection + callback{ + until @queue.empty? + @queue.shift.each{|chunk| @body_callback.call(chunk) } + end + } + end + + def schedule_dequeue + return unless @body_callback + EventMachine::next_tick do + next unless body = @queue.shift + body.each do |chunk| + @body_callback.call(chunk) + end + schedule_dequeue unless @queue.empty? + end + end + + def call(body) + @queue << body + schedule_dequeue + end + + def each &blk + @body_callback = blk + schedule_dequeue + end + +end + +module TailRenderer + attr_accessor :callback + + def receive_data(data) + @callback.call([data]) + end + + def unbind + @callback.succeed + end +end + +class AsyncTailer + + AsyncResponse = [-1, {}, []].freeze + + def call(env) + + body = DeferrableBody.new + + EventMachine::next_tick do + + env['async.callback'].call [200, {'Content-Type' => 'text/html'}, body] + + body.call ["

Async Tailer

"]
+      
+    end
+    
+    EventMachine::popen('tail -f /var/log/system.log', TailRenderer) do |t|
+      
+      t.callback = body
+      
+      # If for some reason we 'complete' body, close the tail.
+      body.callback do
+        t.close_connection
+      end
+      
+      # If for some reason the client disconnects, close the tail.
+      body.errback do
+        t.close_connection
+      end
+      
+    end
+    
+    AsyncResponse
+  end
+  
+end
+
+run AsyncTailer.new
diff --git a/vendor/gems/gems/thin-1.2.5/example/config.ru b/vendor/gems/gems/thin-1.2.5/example/config.ru
new file mode 100755
index 00000000..bc655f85
--- /dev/null
+++ b/vendor/gems/gems/thin-1.2.5/example/config.ru
@@ -0,0 +1,22 @@
+# Run with: rackup -s thin
+# then browse to http://localhost:9292
+# Or with: thin start -R config.ru
+# then browse to http://localhost:3000
+# 
+# Check Rack::Builder doc for more details on this file format:
+#  http://rack.rubyforge.org/doc/classes/Rack/Builder.html
+require 'thin'
+
+app = proc do |env|
+  # Response body has to respond to each and yield strings
+  # See Rack specs for more info: http://rack.rubyforge.org/doc/files/SPEC.html
+  body = ['hi!']
+  
+  [
+    200,                                        # Status code
+    { 'Content-Type' => 'text/html' },          # Reponse headers
+    body                                        # Body of the response
+  ]
+end
+
+run app
\ No newline at end of file
diff --git a/vendor/gems/gems/thin-1.2.5/example/monit_sockets b/vendor/gems/gems/thin-1.2.5/example/monit_sockets
new file mode 100755
index 00000000..0af51e91
--- /dev/null
+++ b/vendor/gems/gems/thin-1.2.5/example/monit_sockets
@@ -0,0 +1,20 @@
+check process blog1
+    with pidfile /u/apps/blog/shared/pids/thin.14000.pid
+    start program = "/usr/local/bin/ruby /usr/local/bin/thin start -d -e production -u nobody -g nobody -p 14000 -a 127.0.0.1 -P tmp/pids/thin.14000.pid -c /u/apps/blog/current"
+    stop program  = "/usr/local/bin/ruby /usr/local/bin/thin stop -P /u/apps/blog/shared/pids/thin.14000.pid"
+    if totalmem > 90.0 MB for 5 cycles then restart
+    if failed port 14000 then restart
+    if cpu usage > 95% for 3 cycles then restart
+    if 5 restarts within 5 cycles then timeout
+		group blog
+
+check process blog2
+    with pidfile /u/apps/blog/shared/pids/thin.14001.pid
+    start program = "/usr/local/bin/ruby /usr/local/bin/thin start -d -e production -u nobody -g nobody -p 14001 -a 127.0.0.1 -P tmp/pids/thin.14001.pid -c /u/apps/blog/current"
+    stop program  = "/usr/local/bin/ruby /usr/local/bin/thin stop -P /u/apps/blog/shared/pids/thin.14001.pid"
+    if totalmem > 90.0 MB for 5 cycles then restart
+    if failed port 14001 then restart
+    if cpu usage > 95% for 3 cycles then restart
+    if 5 restarts within 5 cycles then timeout
+		group blog
+
diff --git a/vendor/gems/gems/thin-1.2.5/example/monit_unixsock b/vendor/gems/gems/thin-1.2.5/example/monit_unixsock
new file mode 100755
index 00000000..445bffac
--- /dev/null
+++ b/vendor/gems/gems/thin-1.2.5/example/monit_unixsock
@@ -0,0 +1,20 @@
+check process blog1
+    with pidfile /u/apps/blog/shared/pids/thin.1.pid
+    start program = "/usr/local/bin/ruby /usr/local/bin/thin start -d -e production -S /u/apps/blog/shared/pids/thin.1.sock -P tmp/pids/thin.1.pid -c /u/apps/blog/current"
+    stop program  = "/usr/local/bin/ruby /usr/local/bin/thin stop -P /u/apps/blog/shared/pids/thin.1.pid"
+    if totalmem > 90.0 MB for 5 cycles then restart
+		if failed unixsocket /u/apps/blog/shared/pids/thin.1.sock then restart
+    if cpu usage > 95% for 3 cycles then restart
+    if 5 restarts within 5 cycles then timeout
+		group blog
+
+check process blog2
+    with pidfile /u/apps/blog/shared/pids/thin.2.pid
+    start program = "/usr/local/bin/ruby /usr/local/bin/thin start -d -e production -S /u/apps/blog/shared/pids/thin.2.sock -P tmp/pids/thin.2.pid -c /u/apps/blog/current"
+    stop program  = "/usr/local/bin/ruby /usr/local/bin/thin stop -P /u/apps/blog/shared/pids/thin.2.pid"
+    if totalmem > 90.0 MB for 5 cycles then restart
+		if failed unixsocket /u/apps/blog/shared/pids/thin.2.sock then restart
+    if cpu usage > 95% for 3 cycles then restart
+    if 5 restarts within 5 cycles then timeout
+		group blog
+
diff --git a/vendor/gems/gems/thin-1.2.5/example/myapp.rb b/vendor/gems/gems/thin-1.2.5/example/myapp.rb
new file mode 100755
index 00000000..02e617f3
--- /dev/null
+++ b/vendor/gems/gems/thin-1.2.5/example/myapp.rb
@@ -0,0 +1 @@
+Myapp = lambda { |env| [200, {}, 'this is my app!'] }
\ No newline at end of file
diff --git a/vendor/gems/gems/thin-1.2.5/example/ramaze.ru b/vendor/gems/gems/thin-1.2.5/example/ramaze.ru
new file mode 100755
index 00000000..2a19ffbc
--- /dev/null
+++ b/vendor/gems/gems/thin-1.2.5/example/ramaze.ru
@@ -0,0 +1,12 @@
+# Ramaze Rackup config file.
+# by tmm1
+# Use with --rackup option:
+# 
+#   thin start -r ramaze.ru
+# 
+require 'start'
+
+Ramaze.trait[:essentials].delete Ramaze::Adapter
+Ramaze.start :force => true
+
+run Ramaze::Adapter::Base
diff --git a/vendor/gems/gems/thin-1.2.5/example/thin.god b/vendor/gems/gems/thin-1.2.5/example/thin.god
new file mode 100755
index 00000000..468ef94d
--- /dev/null
+++ b/vendor/gems/gems/thin-1.2.5/example/thin.god
@@ -0,0 +1,80 @@
+# == God config file
+# http://god.rubyforge.org/
+# Authors: Gump and michael@glauche.de
+#
+# Config file for god that configures watches for each instance of a thin server for
+# each thin configuration file found in /etc/thin.
+# In order to get it working on Ubuntu, I had to make a change to god as noted at
+# the following blog:
+# http://blog.alexgirard.com/2007/10/25/ruby-one-line-to-save-god/
+#
+require 'yaml'
+
+config_path = "/etc/thin"
+
+Dir[config_path + "/*.yml"].each do |file|
+  config = YAML.load_file(file)
+  num_servers = config["servers"] ||= 1
+
+  (0...num_servers).each do |i|
+    # UNIX socket cluster use number 0 to 2 (for 3 servers)
+    # and tcp cluster use port number 3000 to 3002.
+    number = config['socket'] ? i : (config['port'] + i)
+    
+    God.watch do |w|
+      w.group = "thin-" + File.basename(file, ".yml")
+      w.name = w.group + "-#{number}"
+      
+      w.interval = 30.seconds
+      
+      w.uid = config["user"]
+      w.gid = config["group"]
+      
+      w.start = "thin start -C #{file} -o #{number}"
+      w.start_grace = 10.seconds
+      
+      w.stop = "thin stop -C #{file} -o #{number}"
+      w.stop_grace = 10.seconds
+      
+      w.restart = "thin restart -C #{file} -o #{number}"
+
+      pid_path = config["chdir"] + "/" + config["pid"]
+      ext = File.extname(pid_path)
+
+      w.pid_file = pid_path.gsub(/#{ext}$/, ".#{number}#{ext}")
+      
+      w.behavior(:clean_pid_file)
+
+      w.start_if do |start|
+        start.condition(:process_running) do |c|
+          c.interval = 5.seconds
+          c.running = false
+        end
+      end
+
+      w.restart_if do |restart|
+        restart.condition(:memory_usage) do |c|
+          c.above = 150.megabytes
+          c.times = [3,5] # 3 out of 5 intervals
+        end
+
+        restart.condition(:cpu_usage) do |c|
+          c.above = 50.percent
+          c.times = 5
+        end
+      end
+
+      w.lifecycle do |on|
+        on.condition(:flapping) do |c|
+          c.to_state = [:start, :restart]
+          c.times = 5
+          c.within = 5.minutes
+          c.transition = :unmonitored
+          c.retry_in = 10.minutes
+          c.retry_times = 5
+          c.retry_within = 2.hours
+        end
+      end
+    end
+  end
+end
\ No newline at end of file
diff --git a/vendor/gems/gems/thin-1.2.5/example/thin_solaris_smf.erb b/vendor/gems/gems/thin-1.2.5/example/thin_solaris_smf.erb
new file mode 100755
index 00000000..c96ac88e
--- /dev/null
+++ b/vendor/gems/gems/thin-1.2.5/example/thin_solaris_smf.erb
@@ -0,0 +1,36 @@
+
+
+
+  
+    
+    
+      
+    
+    
+      
+      
+      
+    
+    <% 0.upto(thin_max_instances - 1) do |instance| %>
+    
+    
+      
+      
+        
+      
+      
+        
+          
+          
+            
+          
+        
+      
+      
+    
+    <% end %>
+  
+
+
diff --git a/vendor/gems/gems/thin-1.2.5/example/thin_solaris_smf.readme.txt b/vendor/gems/gems/thin-1.2.5/example/thin_solaris_smf.readme.txt
new file mode 100755
index 00000000..aea4e938
--- /dev/null
+++ b/vendor/gems/gems/thin-1.2.5/example/thin_solaris_smf.readme.txt
@@ -0,0 +1,150 @@
+Using Thin with Solaris' SMF Monitoring Framework
+- - - - - - - - - - - - - - - - - - - - - - - - -
+
+Solaris uses the Service Management Framework (SMF) at the OS level to manage, monitor, and restart long running processes.  This replaces init scripts, and tools like monit and god.
+
+The sample XML file (thin_solaris_smf.erb) is an example SMF manifest which I use on a Joyent accelerator which runs on OpenSolaris.
+
+This setup will:
+
+- ensure the right dependencies are loaded
+- start n instances of Thin, and monitor each individually.  If any single one dies it will be restarted instantly (test it by killing a single thin instance and it will be back alive before you can type 'ps -ef').
+
+This is better than using clustering since if you start the cluster with SMF it will only notice a problem and restart individual Thin's if ALL of them are dead, at which point it will restart the whole cluster.  This approach makes sure that all of your Thins start together and are monitored and managed independant of each other.  This problem likely exists if you are using god or monit to monitor only the start of the master cluster, and don't then monitor the individual processes started.
+
+This example is in .erb format instead of plain XML since I dynamically generate this file as part of a Capistrano deployment.  In my deploy.rb file I define the variables found in this erb.  Of course you don't need to use this with Capistrano.  Just replace the few ERB variables from the xml file, change its extension, and load that directly in Solaris if you prefer.
+
+Here are some examples for usage to get you started with Capistrano, and Thin:
+
+FILE : config/deploy.rb
+--
+
+  require 'config/accelerator/accelerator_tasks'
+
+  set :application, "yourapp"
+  set :svcadm_bin, "/usr/sbin/svcadm"
+  set :svccfg_bin, "/usr/sbin/svccfg"
+  set :svcs_bin, "/usr/bin/svcs"
+
+  # gets the list of remote service SMF names that we need to start
+  # like (depending on thin_max_instances settings):
+  # svc:/network/thin/yourapp-production:i_0
+  # svc:/network/thin/yourapp-production:i_1
+  # svc:/network/thin/yourapp-production:i_2
+  set :service_list, "`svcs -H -o FMRI svc:network/thin/#{application}-production`"
+
+  # how many Thin instances should be setup to run?
+  # this affects the generated thin smf file, and the nginx vhost conf
+  # need to re-run setup for thin smf and nginx vhost conf when changed
+  set :thin_max_instances, 3
+
+  # OVERRIDE STANDARD TASKS
+  desc "Restart the entire application"
+  deploy.task :restart do
+    accelerator.thin.restart
+    accelerator.nginx.restart
+  end
+
+  desc "Start the entire application"
+  deploy.task :start do
+    accelerator.thin.restart
+    accelerator.nginx.restart
+  end
+
+  desc "Stop the entire application"
+  deploy.task :stop do
+    accelerator.thin.disable
+    accelerator.nginx.disable
+  end
+
+
+FILE : config/accelerator/accelerator_tasks.rb
+--
+
+    desc "Create and deploy Thin SMF config"
+    task :create_thin_smf, :roles => :app do
+      service_name = application
+      working_directory = current_path
+      template = File.read("config/accelerator/thin_solaris_smf.erb")
+      buffer = ERB.new(template).result(binding)
+      put buffer, "#{shared_path}/#{application}-thin-smf.xml"
+      sudo "#{svccfg_bin} import #{shared_path}/#{application}-thin-smf.xml"
+    end
+
+    desc "Delete Thin SMF config"
+    task :delete_thin_smf, :roles => :app do
+      accelerator.thin.disable
+      sudo "#{svccfg_bin} delete /network/thin/#{application}-production"
+    end
+
+    desc "Show all SMF services"
+    task :svcs do
+      run "#{svcs_bin} -a" do |ch, st, data|
+        puts data
+      end
+    end
+
+    desc "Shows all non-functional SMF services"
+    task :svcs_broken do
+      run "#{svcs_bin} -vx" do |ch, st, data|
+        puts data
+      end
+    end
+
+
+    namespace :thin do
+
+      desc "Disable all Thin servers"
+      task :disable, :roles => :app do
+        # temporarily disable, until next reboot (-t)
+        sudo "#{svcadm_bin} disable -t #{service_list}"
+      end
+
+      desc "Enable all Thin servers"
+      task :enable, :roles => :app do
+        # start the app with all recursive dependencies
+        sudo "#{svcadm_bin} enable -r #{service_list}"
+      end
+
+      desc "Restart all Thin servers"
+      task :restart, :roles => :app do
+        # svcadm restart doesn't seem to work right, so we'll brute force it
+        disable
+        enable
+      end
+
+    end # namespace thin
+
+
+FILE : config/thin.yml
+--
+
+---
+pid: tmp/pids/thin.pid
+socket: /tmp/thin.sock
+log: log/thin.log
+max_conns: 1024
+timeout: 30
+chdir: /your/app/dir/rails/root
+environment: production
+max_persistent_conns: 512
+daemonize: true
+servers: 3
+
+
+FILE : config/accelerator/thin_solaris_smf.erb
+--
+This is of course an example.  It works for me, but YMMV
+
+You may need to change this line to match your environment and config:
+  exec='/opt/csw/bin/thin -C config/thin.yml --only <%= instance.to_s %> start'
+
+
+CONTRIBUTE:
+
+If you see problems or enhancements for this approach please send me an email at glenn [at] rempe dot us.  Sadly, I won't be able to provide support for this example as time and my limited Solaris admin skills won't allow.
+
+Cheers,
+
+Glenn Rempe
+2008/03/20
diff --git a/vendor/gems/gems/thin-1.2.5/example/vlad.rake b/vendor/gems/gems/thin-1.2.5/example/vlad.rake
new file mode 100755
index 00000000..51b4ae69
--- /dev/null
+++ b/vendor/gems/gems/thin-1.2.5/example/vlad.rake
@@ -0,0 +1,64 @@
+# $GEM_HOME/gems/vlad-1.2.0/lib/vlad/thin.rb
+# Thin tasks for Vlad the Deployer
+# By cnantais
+require 'vlad'
+
+namespace :vlad do
+  ##
+  # Thin app server
+
+  set :thin_address,       "127.0.0.1"
+  set :thin_command,       'thin'
+  set(:thin_conf)          { "#{shared_path}/thin_cluster.conf" }
+  set :thin_environment,   "production"
+  set :thin_group,         nil
+  set :thin_log_file,      nil
+  set :thin_pid_file,      nil
+  set :thin_port,          nil
+  set :thin_socket,        nil
+  set :thin_prefix,        nil
+  set :thin_servers,       2
+  set :thin_user,          nil
+
+  desc "Prepares application servers for deployment. thin
+configuration is set via the thin_* variables.".cleanup
+
+  remote_task :setup_app, :roles => :app do
+  
+    raise(ArgumentError, "Please provide either thin_socket or thin_port") if thin_port.nil? && thin_socket.nil?
+  
+    cmd = [
+           "#{thin_command} config",
+           "-s #{thin_servers}",
+           ("-S #{thin_socket}" if thin_socket),
+           "-e #{thin_environment}",
+           "-a #{thin_address}",
+           "-c #{current_path}",
+           "-C #{thin_conf}",
+           ("-P #{thin_pid_file}" if thin_pid_file),
+           ("-l #{thin_log_file}" if thin_log_file),
+           ("--user #{thin_user}" if thin_user),
+           ("--group #{thin_group}" if thin_group),
+           ("--prefix #{thin_prefix}" if thin_prefix),
+           ("-p #{thin_port}" if thin_port),
+          ].compact.join ' '
+
+    run cmd
+  end
+
+  def thin(cmd) # :nodoc:
+    "#{thin_command} #{cmd} -C #{thin_conf}"
+  end
+
+  desc "Restart the app servers"
+
+  remote_task :start_app, :roles => :app do
+    run thin("restart -s #{thin_servers}")
+  end
+
+  desc "Stop the app servers"
+
+  remote_task :stop_app, :roles => :app do
+    run thin("stop -s #{thin_servers}")
+  end
+end
diff --git a/vendor/gems/gems/thin-1.2.5/ext/thin_parser/Makefile b/vendor/gems/gems/thin-1.2.5/ext/thin_parser/Makefile
new file mode 100755
index 00000000..046b5426
--- /dev/null
+++ b/vendor/gems/gems/thin-1.2.5/ext/thin_parser/Makefile
@@ -0,0 +1,157 @@
+
+SHELL = /bin/sh
+
+#### Start of system configuration section. ####
+
+srcdir = .
+topdir = /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/universal-darwin10.0
+hdrdir = $(topdir)
+VPATH = $(srcdir):$(topdir):$(hdrdir)
+exec_prefix = $(prefix)
+prefix = $(DESTDIR)/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr
+sharedstatedir = $(prefix)/com
+mandir = $(DESTDIR)/usr/share/man
+psdir = $(docdir)
+oldincludedir = $(DESTDIR)/usr/include
+localedir = $(datarootdir)/locale
+bindir = $(exec_prefix)/bin
+libexecdir = $(exec_prefix)/libexec
+sitedir = $(DESTDIR)/Library/Ruby/Site
+htmldir = $(docdir)
+vendorarchdir = $(vendorlibdir)/$(sitearch)
+includedir = $(prefix)/include
+infodir = $(DESTDIR)/usr/share/info
+vendorlibdir = $(vendordir)/$(ruby_version)
+sysconfdir = $(prefix)/etc
+libdir = $(exec_prefix)/lib
+sbindir = $(exec_prefix)/sbin
+rubylibdir = $(libdir)/ruby/$(ruby_version)
+docdir = $(datarootdir)/doc/$(PACKAGE)
+dvidir = $(docdir)
+vendordir = $(libdir)/ruby/vendor_ruby
+datarootdir = $(prefix)/share
+pdfdir = $(docdir)
+archdir = $(rubylibdir)/$(arch)
+sitearchdir = $(sitelibdir)/$(sitearch)
+datadir = $(datarootdir)
+localstatedir = $(prefix)/var
+sitelibdir = $(sitedir)/$(ruby_version)
+
+CC = gcc
+LIBRUBY = $(LIBRUBY_SO)
+LIBRUBY_A = lib$(RUBY_SO_NAME)-static.a
+LIBRUBYARG_SHARED = -l$(RUBY_SO_NAME)
+LIBRUBYARG_STATIC = -l$(RUBY_SO_NAME)
+
+RUBY_EXTCONF_H = 
+CFLAGS   =  -fno-common -arch i386 -arch x86_64 -g -Os -pipe -fno-common -DENABLE_DTRACE  -fno-common  -pipe -fno-common $(cflags) 
+INCFLAGS = -I. -I. -I/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/universal-darwin10.0 -I.
+DEFS     = 
+CPPFLAGS =   -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE  
+CXXFLAGS = $(CFLAGS) 
+ldflags  = -L. -arch i386 -arch x86_64 
+dldflags = 
+archflag = 
+DLDFLAGS = $(ldflags) $(dldflags) $(archflag)
+LDSHARED = cc -arch i386 -arch x86_64 -pipe -bundle -undefined dynamic_lookup
+AR = ar
+EXEEXT = 
+
+RUBY_INSTALL_NAME = ruby
+RUBY_SO_NAME = ruby
+arch = universal-darwin10.0
+sitearch = universal-darwin10.0
+ruby_version = 1.8
+ruby = /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby
+RUBY = $(ruby)
+RM = rm -f
+MAKEDIRS = mkdir -p
+INSTALL = /usr/bin/install -c
+INSTALL_PROG = $(INSTALL) -m 0755
+INSTALL_DATA = $(INSTALL) -m 644
+COPY = cp
+
+#### End of system configuration section. ####
+
+preload = 
+
+libpath = . $(libdir)
+LIBPATH =  -L. -L$(libdir)
+DEFFILE = 
+
+CLEANFILES = mkmf.log
+DISTCLEANFILES = 
+
+extout = 
+extout_prefix = 
+target_prefix = 
+LOCAL_LIBS = 
+LIBS = $(LIBRUBYARG_SHARED) -lc  -lpthread -ldl  
+SRCS = parser.c thin.c
+OBJS = parser.o thin.o
+TARGET = thin_parser
+DLLIB = $(TARGET).bundle
+EXTSTATIC = 
+STATIC_LIB = 
+
+BINDIR        = $(bindir)
+RUBYCOMMONDIR = $(sitedir)$(target_prefix)
+RUBYLIBDIR = /Users/tdreyno/Dropbox/Sites/middleman/vendor/gems/gems/thin-1.2.5/lib$(target_prefix)
+RUBYARCHDIR = /Users/tdreyno/Dropbox/Sites/middleman/vendor/gems/gems/thin-1.2.5/lib$(target_prefix)
+
+TARGET_SO     = $(DLLIB)
+CLEANLIBS     = $(TARGET).bundle $(TARGET).il? $(TARGET).tds $(TARGET).map
+CLEANOBJS     = *.o *.a *.s[ol] *.pdb *.exp *.bak
+
+all:		$(DLLIB)
+static:		$(STATIC_LIB)
+
+clean:
+		@-$(RM) $(CLEANLIBS) $(CLEANOBJS) $(CLEANFILES)
+
+distclean:	clean
+		@-$(RM) Makefile $(RUBY_EXTCONF_H) conftest.* mkmf.log
+		@-$(RM) core ruby$(EXEEXT) *~ $(DISTCLEANFILES)
+
+realclean:	distclean
+install: install-so install-rb
+
+install-so: $(RUBYARCHDIR)
+install-so: $(RUBYARCHDIR)/$(DLLIB)
+$(RUBYARCHDIR)/$(DLLIB): $(DLLIB)
+	$(INSTALL_PROG) $(DLLIB) $(RUBYARCHDIR)
+install-rb: pre-install-rb install-rb-default
+install-rb-default: pre-install-rb-default
+pre-install-rb: Makefile
+pre-install-rb-default: Makefile
+$(RUBYARCHDIR):
+	$(MAKEDIRS) $@
+
+site-install: site-install-so site-install-rb
+site-install-so: install-so
+site-install-rb: install-rb
+
+.SUFFIXES: .c .m .cc .cxx .cpp .C .o
+
+.cc.o:
+	$(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) -c $<
+
+.cxx.o:
+	$(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) -c $<
+
+.cpp.o:
+	$(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) -c $<
+
+.C.o:
+	$(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) -c $<
+
+.c.o:
+	$(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) -c $<
+
+$(DLLIB): $(OBJS)
+	@-$(RM) $@
+	$(LDSHARED) -o $@ $(OBJS) $(LIBPATH) $(DLDFLAGS) $(LOCAL_LIBS) $(LIBS)
+
+
+
+$(OBJS): ruby.h defines.h
diff --git a/vendor/gems/gems/thin-1.2.5/ext/thin_parser/common.rl b/vendor/gems/gems/thin-1.2.5/ext/thin_parser/common.rl
new file mode 100755
index 00000000..46fe2293
--- /dev/null
+++ b/vendor/gems/gems/thin-1.2.5/ext/thin_parser/common.rl
@@ -0,0 +1,55 @@
+%%{
+  
+  machine http_parser_common;
+
+#### HTTP PROTOCOL GRAMMAR
+# line endings
+  CRLF = "\r\n";
+
+# character types
+  CTL = (cntrl | 127);
+  safe = ("$" | "-" | "_" | ".");
+  extra = ("!" | "*" | "'" | "(" | ")" | ",");
+  reserved = (";" | "/" | "?" | ":" | "@" | "&" | "=" | "+");
+  sorta_safe = ("\"" | "<" | ">");
+  unsafe = (CTL | " " | "#" | "%" | sorta_safe);
+  national = any -- (alpha | digit | reserved | extra | safe | unsafe);
+  unreserved = (alpha | digit | safe | extra | national);
+  escape = ("%" xdigit xdigit);
+  uchar = (unreserved | escape | sorta_safe);
+  pchar = (uchar | ":" | "@" | "&" | "=" | "+");
+  tspecials = ("(" | ")" | "<" | ">" | "@" | "," | ";" | ":" | "\\" | "\"" | "/" | "[" | "]" | "?" | "=" | "{" | "}" | " " | "\t");
+
+# elements
+  token = (ascii -- (CTL | tspecials));
+
+# URI schemes and absolute paths
+  scheme = ( alpha | digit | "+" | "-" | "." )* ;
+  absolute_uri = (scheme ":" (uchar | reserved )*);
+
+  path = ( pchar+ ( "/" pchar* )* ) ;
+  query = ( uchar | reserved )* %query_string ;
+  param = ( pchar | "/" )* ;
+  params = ( param ( ";" param )* ) ;
+  rel_path = ( path? %request_path (";" params)? ) ("?" %start_query query)?;
+  absolute_path = ( "/"+ rel_path );
+
+  Request_URI = ( "*" | absolute_uri | absolute_path ) >mark %request_uri;
+  Fragment = ( uchar | reserved )* >mark %fragment;
+  Method = ( upper | digit | safe ){1,20} >mark %request_method;
+
+  http_number = ( digit+ "." digit+ ) ;
+  HTTP_Version = ( "HTTP/" http_number ) >mark %http_version ;
+  Request_Line = ( Method " " Request_URI ("#" Fragment){0,1} " " HTTP_Version CRLF ) ;
+
+  field_name = ( token -- ":" )+ >start_field %write_field;
+
+  field_value = any* >start_value %write_value;
+
+  message_header = field_name ":" " "* field_value :> CRLF;
+
+  Request = Request_Line ( message_header )* ( CRLF @done );
+
+main := Request;
+
+}%%
diff --git a/vendor/gems/gems/thin-1.2.5/ext/thin_parser/ext_help.h b/vendor/gems/gems/thin-1.2.5/ext/thin_parser/ext_help.h
new file mode 100755
index 00000000..8b4d754c
--- /dev/null
+++ b/vendor/gems/gems/thin-1.2.5/ext/thin_parser/ext_help.h
@@ -0,0 +1,14 @@
+#ifndef ext_help_h
+#define ext_help_h
+
+#define RAISE_NOT_NULL(T) if(T == NULL) rb_raise(rb_eArgError, "NULL found for " # T " when shouldn't be.");
+#define DATA_GET(from,type,name) Data_Get_Struct(from,type,name); RAISE_NOT_NULL(name);
+#define REQUIRE_TYPE(V, T) if(TYPE(V) != T) rb_raise(rb_eTypeError, "Wrong argument type for " # V " required " # T);
+
+#ifdef DEBUG
+#define TRACE()  fprintf(stderr, "> %s:%d:%s\n", __FILE__, __LINE__, __FUNCTION__)
+#else
+#define TRACE() 
+#endif
+
+#endif
diff --git a/vendor/gems/gems/thin-1.2.5/ext/thin_parser/extconf.rb b/vendor/gems/gems/thin-1.2.5/ext/thin_parser/extconf.rb
new file mode 100755
index 00000000..f83a75ac
--- /dev/null
+++ b/vendor/gems/gems/thin-1.2.5/ext/thin_parser/extconf.rb
@@ -0,0 +1,6 @@
+require 'mkmf'
+
+dir_config("thin_parser")
+have_library("c", "main")
+
+create_makefile("thin_parser")
diff --git a/vendor/gems/gems/thin-1.2.5/ext/thin_parser/mkmf.log b/vendor/gems/gems/thin-1.2.5/ext/thin_parser/mkmf.log
new file mode 100755
index 00000000..fdfb205e
--- /dev/null
+++ b/vendor/gems/gems/thin-1.2.5/ext/thin_parser/mkmf.log
@@ -0,0 +1,12 @@
+have_library: checking for main() in -lc... -------------------- yes
+
+"gcc -o conftest -I. -I/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/universal-darwin10.0 -I.  -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE   -arch i386 -arch x86_64 -g -Os -pipe -fno-common -DENABLE_DTRACE  -fno-common  -pipe -fno-common   conftest.c  -L. -L/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib -L. -arch i386 -arch x86_64      -lruby -lc  -lpthread -ldl  "
+checked program was:
+/* begin */
+1: /*top*/
+2: int main() { return 0; }
+3: int t() { void ((*volatile p)()); p = (void ((*)()))main; return 0; }
+/* end */
+
+--------------------
+
diff --git a/vendor/gems/gems/thin-1.2.5/ext/thin_parser/parser.c b/vendor/gems/gems/thin-1.2.5/ext/thin_parser/parser.c
new file mode 100755
index 00000000..60f6720f
--- /dev/null
+++ b/vendor/gems/gems/thin-1.2.5/ext/thin_parser/parser.c
@@ -0,0 +1,452 @@
+#line 1 "parser.rl"
+/**
+ * Copyright (c) 2005 Zed A. Shaw
+ * You can redistribute it and/or modify it under the same terms as Ruby.
+ */
+#include "parser.h"
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#define LEN(AT, FPC) (FPC - buffer - parser->AT)
+#define MARK(M,FPC) (parser->M = (FPC) - buffer)
+#define PTR_TO(F) (buffer + parser->F)
+
+/** Machine **/
+
+#line 81 "parser.rl"
+
+
+/** Data **/
+
+#line 25 "parser.c"
+static const char _http_parser_actions[] = {
+	0, 1, 0, 1, 1, 1, 2, 1, 
+	3, 1, 4, 1, 5, 1, 6, 1, 
+	7, 1, 8, 1, 10, 1, 11, 1, 
+	12, 2, 0, 7, 2, 3, 4, 2, 
+	9, 6, 2, 11, 6, 3, 8, 9, 
+	6
+};
+
+static const short _http_parser_key_offsets[] = {
+	0, 0, 8, 17, 27, 29, 30, 31, 
+	32, 33, 34, 36, 39, 41, 44, 45, 
+	61, 62, 78, 80, 81, 87, 93, 99, 
+	105, 115, 121, 127, 133, 141, 147, 153, 
+	160, 166, 172, 178, 184, 190, 196, 205, 
+	214, 223, 232, 241, 250, 259, 268, 277, 
+	286, 295, 304, 313, 322, 331, 340, 349, 
+	358, 359
+};
+
+static const char _http_parser_trans_keys[] = {
+	36, 95, 45, 46, 48, 57, 65, 90, 
+	32, 36, 95, 45, 46, 48, 57, 65, 
+	90, 42, 43, 47, 58, 45, 57, 65, 
+	90, 97, 122, 32, 35, 72, 84, 84, 
+	80, 47, 48, 57, 46, 48, 57, 48, 
+	57, 13, 48, 57, 10, 13, 33, 124, 
+	126, 35, 39, 42, 43, 45, 46, 48, 
+	57, 65, 90, 94, 122, 10, 33, 58, 
+	124, 126, 35, 39, 42, 43, 45, 46, 
+	48, 57, 65, 90, 94, 122, 13, 32, 
+	13, 32, 35, 37, 127, 0, 31, 32, 
+	35, 37, 127, 0, 31, 48, 57, 65, 
+	70, 97, 102, 48, 57, 65, 70, 97, 
+	102, 43, 58, 45, 46, 48, 57, 65, 
+	90, 97, 122, 32, 35, 37, 127, 0, 
+	31, 48, 57, 65, 70, 97, 102, 48, 
+	57, 65, 70, 97, 102, 32, 35, 37, 
+	59, 63, 127, 0, 31, 48, 57, 65, 
+	70, 97, 102, 48, 57, 65, 70, 97, 
+	102, 32, 35, 37, 63, 127, 0, 31, 
+	48, 57, 65, 70, 97, 102, 48, 57, 
+	65, 70, 97, 102, 32, 35, 37, 127, 
+	0, 31, 32, 35, 37, 127, 0, 31, 
+	48, 57, 65, 70, 97, 102, 48, 57, 
+	65, 70, 97, 102, 32, 36, 95, 45, 
+	46, 48, 57, 65, 90, 32, 36, 95, 
+	45, 46, 48, 57, 65, 90, 32, 36, 
+	95, 45, 46, 48, 57, 65, 90, 32, 
+	36, 95, 45, 46, 48, 57, 65, 90, 
+	32, 36, 95, 45, 46, 48, 57, 65, 
+	90, 32, 36, 95, 45, 46, 48, 57, 
+	65, 90, 32, 36, 95, 45, 46, 48, 
+	57, 65, 90, 32, 36, 95, 45, 46, 
+	48, 57, 65, 90, 32, 36, 95, 45, 
+	46, 48, 57, 65, 90, 32, 36, 95, 
+	45, 46, 48, 57, 65, 90, 32, 36, 
+	95, 45, 46, 48, 57, 65, 90, 32, 
+	36, 95, 45, 46, 48, 57, 65, 90, 
+	32, 36, 95, 45, 46, 48, 57, 65, 
+	90, 32, 36, 95, 45, 46, 48, 57, 
+	65, 90, 32, 36, 95, 45, 46, 48, 
+	57, 65, 90, 32, 36, 95, 45, 46, 
+	48, 57, 65, 90, 32, 36, 95, 45, 
+	46, 48, 57, 65, 90, 32, 36, 95, 
+	45, 46, 48, 57, 65, 90, 32, 0
+};
+
+static const char _http_parser_single_lengths[] = {
+	0, 2, 3, 4, 2, 1, 1, 1, 
+	1, 1, 0, 1, 0, 1, 1, 4, 
+	1, 4, 2, 1, 4, 4, 0, 0, 
+	2, 4, 0, 0, 6, 0, 0, 5, 
+	0, 0, 4, 4, 0, 0, 3, 3, 
+	3, 3, 3, 3, 3, 3, 3, 3, 
+	3, 3, 3, 3, 3, 3, 3, 3, 
+	1, 0
+};
+
+static const char _http_parser_range_lengths[] = {
+	0, 3, 3, 3, 0, 0, 0, 0, 
+	0, 0, 1, 1, 1, 1, 0, 6, 
+	0, 6, 0, 0, 1, 1, 3, 3, 
+	4, 1, 3, 3, 1, 3, 3, 1, 
+	3, 3, 1, 1, 3, 3, 3, 3, 
+	3, 3, 3, 3, 3, 3, 3, 3, 
+	3, 3, 3, 3, 3, 3, 3, 3, 
+	0, 0
+};
+
+static const short _http_parser_index_offsets[] = {
+	0, 0, 6, 13, 21, 24, 26, 28, 
+	30, 32, 34, 36, 39, 41, 44, 46, 
+	57, 59, 70, 73, 75, 81, 87, 91, 
+	95, 102, 108, 112, 116, 124, 128, 132, 
+	139, 143, 147, 153, 159, 163, 167, 174, 
+	181, 188, 195, 202, 209, 216, 223, 230, 
+	237, 244, 251, 258, 265, 272, 279, 286, 
+	293, 295
+};
+
+static const char _http_parser_indicies[] = {
+	0, 0, 0, 0, 0, 1, 2, 3, 
+	3, 3, 3, 3, 1, 4, 5, 6, 
+	7, 5, 5, 5, 1, 8, 9, 1, 
+	10, 1, 11, 1, 12, 1, 13, 1, 
+	14, 1, 15, 1, 16, 15, 1, 17, 
+	1, 18, 17, 1, 19, 1, 20, 21, 
+	21, 21, 21, 21, 21, 21, 21, 21, 
+	1, 22, 1, 23, 24, 23, 23, 23, 
+	23, 23, 23, 23, 23, 1, 26, 27, 
+	25, 29, 28, 31, 1, 32, 1, 1, 
+	30, 34, 1, 35, 1, 1, 33, 36, 
+	36, 36, 1, 33, 33, 33, 1, 37, 
+	38, 37, 37, 37, 37, 1, 8, 9, 
+	39, 1, 1, 38, 40, 40, 40, 1, 
+	38, 38, 38, 1, 42, 43, 44, 45, 
+	46, 1, 1, 41, 47, 47, 47, 1, 
+	41, 41, 41, 1, 8, 9, 49, 50, 
+	1, 1, 48, 51, 51, 51, 1, 48, 
+	48, 48, 1, 53, 54, 55, 1, 1, 
+	52, 57, 58, 59, 1, 1, 56, 60, 
+	60, 60, 1, 56, 56, 56, 1, 2, 
+	61, 61, 61, 61, 61, 1, 2, 62, 
+	62, 62, 62, 62, 1, 2, 63, 63, 
+	63, 63, 63, 1, 2, 64, 64, 64, 
+	64, 64, 1, 2, 65, 65, 65, 65, 
+	65, 1, 2, 66, 66, 66, 66, 66, 
+	1, 2, 67, 67, 67, 67, 67, 1, 
+	2, 68, 68, 68, 68, 68, 1, 2, 
+	69, 69, 69, 69, 69, 1, 2, 70, 
+	70, 70, 70, 70, 1, 2, 71, 71, 
+	71, 71, 71, 1, 2, 72, 72, 72, 
+	72, 72, 1, 2, 73, 73, 73, 73, 
+	73, 1, 2, 74, 74, 74, 74, 74, 
+	1, 2, 75, 75, 75, 75, 75, 1, 
+	2, 76, 76, 76, 76, 76, 1, 2, 
+	77, 77, 77, 77, 77, 1, 2, 78, 
+	78, 78, 78, 78, 1, 2, 1, 1, 
+	0
+};
+
+static const char _http_parser_trans_targs[] = {
+	2, 0, 3, 38, 4, 24, 28, 25, 
+	5, 20, 6, 7, 8, 9, 10, 11, 
+	12, 13, 14, 15, 16, 17, 57, 17, 
+	18, 19, 14, 18, 19, 14, 21, 5, 
+	22, 21, 5, 22, 23, 24, 25, 26, 
+	27, 28, 5, 20, 29, 31, 34, 30, 
+	31, 32, 34, 33, 35, 5, 20, 36, 
+	35, 5, 20, 36, 37, 39, 40, 41, 
+	42, 43, 44, 45, 46, 47, 48, 49, 
+	50, 51, 52, 53, 54, 55, 56
+};
+
+static const char _http_parser_trans_actions[] = {
+	1, 0, 11, 0, 1, 1, 1, 1, 
+	13, 13, 1, 0, 0, 0, 0, 0, 
+	0, 0, 19, 0, 0, 3, 23, 0, 
+	5, 7, 28, 7, 0, 9, 1, 25, 
+	1, 0, 15, 0, 0, 0, 0, 0, 
+	0, 0, 34, 34, 0, 21, 21, 0, 
+	0, 0, 0, 0, 17, 37, 37, 17, 
+	0, 31, 31, 0, 0, 0, 0, 0, 
+	0, 0, 0, 0, 0, 0, 0, 0, 
+	0, 0, 0, 0, 0, 0, 0
+};
+
+static const int http_parser_start = 1;
+static const int http_parser_first_final = 57;
+static const int http_parser_error = 0;
+
+static const int http_parser_en_main = 1;
+
+#line 85 "parser.rl"
+
+int thin_http_parser_init(http_parser *parser)  {
+  int cs = 0;
+  
+#line 205 "parser.c"
+	{
+	cs = http_parser_start;
+	}
+#line 89 "parser.rl"
+  parser->cs = cs;
+  parser->body_start = 0;
+  parser->content_len = 0;
+  parser->mark = 0;
+  parser->nread = 0;
+  parser->field_len = 0;
+  parser->field_start = 0;    
+
+  return(1);
+}
+
+
+/** exec **/
+size_t thin_http_parser_execute(http_parser *parser, const char *buffer, size_t len, size_t off)  {
+  const char *p, *pe;
+  int cs = parser->cs;
+
+  assert(off <= len && "offset past end of buffer");
+
+  p = buffer+off;
+  pe = buffer+len;
+
+  assert(*pe == '\0' && "pointer does not end on NUL");
+  assert(pe - p == len - off && "pointers aren't same distance");
+
+
+  
+#line 237 "parser.c"
+	{
+	int _klen;
+	unsigned int _trans;
+	const char *_acts;
+	unsigned int _nacts;
+	const char *_keys;
+
+	if ( p == pe )
+		goto _test_eof;
+	if ( cs == 0 )
+		goto _out;
+_resume:
+	_keys = _http_parser_trans_keys + _http_parser_key_offsets[cs];
+	_trans = _http_parser_index_offsets[cs];
+
+	_klen = _http_parser_single_lengths[cs];
+	if ( _klen > 0 ) {
+		const char *_lower = _keys;
+		const char *_mid;
+		const char *_upper = _keys + _klen - 1;
+		while (1) {
+			if ( _upper < _lower )
+				break;
+
+			_mid = _lower + ((_upper-_lower) >> 1);
+			if ( (*p) < *_mid )
+				_upper = _mid - 1;
+			else if ( (*p) > *_mid )
+				_lower = _mid + 1;
+			else {
+				_trans += (_mid - _keys);
+				goto _match;
+			}
+		}
+		_keys += _klen;
+		_trans += _klen;
+	}
+
+	_klen = _http_parser_range_lengths[cs];
+	if ( _klen > 0 ) {
+		const char *_lower = _keys;
+		const char *_mid;
+		const char *_upper = _keys + (_klen<<1) - 2;
+		while (1) {
+			if ( _upper < _lower )
+				break;
+
+			_mid = _lower + (((_upper-_lower) >> 1) & ~1);
+			if ( (*p) < _mid[0] )
+				_upper = _mid - 2;
+			else if ( (*p) > _mid[1] )
+				_lower = _mid + 2;
+			else {
+				_trans += ((_mid - _keys)>>1);
+				goto _match;
+			}
+		}
+		_trans += _klen;
+	}
+
+_match:
+	_trans = _http_parser_indicies[_trans];
+	cs = _http_parser_trans_targs[_trans];
+
+	if ( _http_parser_trans_actions[_trans] == 0 )
+		goto _again;
+
+	_acts = _http_parser_actions + _http_parser_trans_actions[_trans];
+	_nacts = (unsigned int) *_acts++;
+	while ( _nacts-- > 0 )
+	{
+		switch ( *_acts++ )
+		{
+	case 0:
+#line 22 "parser.rl"
+	{MARK(mark, p); }
+	break;
+	case 1:
+#line 25 "parser.rl"
+	{ MARK(field_start, p); }
+	break;
+	case 2:
+#line 26 "parser.rl"
+	{ 
+    parser->field_len = LEN(field_start, p);
+  }
+	break;
+	case 3:
+#line 30 "parser.rl"
+	{ MARK(mark, p); }
+	break;
+	case 4:
+#line 31 "parser.rl"
+	{ 
+    if (parser->http_field != NULL) {
+      parser->http_field(parser->data, PTR_TO(field_start), parser->field_len, PTR_TO(mark), LEN(mark, p));
+    }
+  }
+	break;
+	case 5:
+#line 36 "parser.rl"
+	{ 
+    if (parser->request_method != NULL) {
+      parser->request_method(parser->data, PTR_TO(mark), LEN(mark, p));
+    }
+  }
+	break;
+	case 6:
+#line 41 "parser.rl"
+	{
+    if (parser->request_uri != NULL) {
+      parser->request_uri(parser->data, PTR_TO(mark), LEN(mark, p));
+    }
+  }
+	break;
+	case 7:
+#line 46 "parser.rl"
+	{ 
+    if (parser->fragment != NULL) {
+      parser->fragment(parser->data, PTR_TO(mark), LEN(mark, p));
+    }
+  }
+	break;
+	case 8:
+#line 52 "parser.rl"
+	{MARK(query_start, p); }
+	break;
+	case 9:
+#line 53 "parser.rl"
+	{ 
+    if (parser->query_string != NULL) {
+      parser->query_string(parser->data, PTR_TO(query_start), LEN(query_start, p));
+    }
+  }
+	break;
+	case 10:
+#line 59 "parser.rl"
+	{	
+    if (parser->http_version != NULL) {
+      parser->http_version(parser->data, PTR_TO(mark), LEN(mark, p));
+    }
+  }
+	break;
+	case 11:
+#line 65 "parser.rl"
+	{
+    if (parser->request_path != NULL) {
+      parser->request_path(parser->data, PTR_TO(mark), LEN(mark,p));
+    }
+  }
+	break;
+	case 12:
+#line 71 "parser.rl"
+	{ 
+    parser->body_start = p - buffer + 1; 
+    if (parser->header_done != NULL) {
+      parser->header_done(parser->data, p + 1, pe - p - 1);
+    }
+    {p++; goto _out; }
+  }
+	break;
+#line 399 "parser.c"
+		}
+	}
+
+_again:
+	if ( cs == 0 )
+		goto _out;
+	if ( ++p != pe )
+		goto _resume;
+	_test_eof: {}
+	_out: {}
+	}
+#line 116 "parser.rl"
+
+  parser->cs = cs;
+  parser->nread += p - (buffer + off);
+
+  assert(p <= pe && "buffer overflow after parsing execute");
+  assert(parser->nread <= len && "nread longer than length");
+  assert(parser->body_start <= len && "body starts after buffer end");
+  assert(parser->mark < len && "mark is after buffer end");
+  assert(parser->field_len <= len && "field has length longer than whole buffer");
+  assert(parser->field_start < len && "field starts after buffer end");
+
+  if(parser->body_start) {
+    /* final \r\n combo encountered so stop right here */
+    parser->nread++;
+  }
+
+  return(parser->nread);
+}
+
+int thin_http_parser_finish(http_parser *parser)
+{
+  int cs = parser->cs;
+
+
+  parser->cs = cs;
+
+  if (thin_http_parser_has_error(parser) ) {
+    return -1;
+  } else if (thin_http_parser_is_finished(parser) ) {
+    return 1;
+  } else {
+    return 0;
+  }
+}
+
+int thin_http_parser_has_error(http_parser *parser) {
+  return parser->cs == http_parser_error;
+}
+
+int thin_http_parser_is_finished(http_parser *parser) {
+  return parser->cs == http_parser_first_final;
+}
diff --git a/vendor/gems/gems/thin-1.2.5/ext/thin_parser/parser.h b/vendor/gems/gems/thin-1.2.5/ext/thin_parser/parser.h
new file mode 100755
index 00000000..8d074bab
--- /dev/null
+++ b/vendor/gems/gems/thin-1.2.5/ext/thin_parser/parser.h
@@ -0,0 +1,49 @@
+/**
+ * Copyright (c) 2005 Zed A. Shaw
+ * You can redistribute it and/or modify it under the same terms as Ruby.
+ */
+
+#ifndef http11_parser_h
+#define http11_parser_h
+
+#include 
+
+#if defined(_WIN32)
+#include 
+#endif
+
+typedef void (*element_cb)(void *data, const char *at, size_t length);
+typedef void (*field_cb)(void *data, const char *field, size_t flen, const char *value, size_t vlen);
+
+typedef struct http_parser { 
+  int cs;
+  size_t body_start;
+  int content_len;
+  size_t nread;
+  size_t mark;
+  size_t field_start;
+  size_t field_len;
+  size_t query_start;
+
+  void *data;
+
+  field_cb http_field;
+  element_cb request_method;
+  element_cb request_uri;
+  element_cb fragment;
+  element_cb request_path;
+  element_cb query_string;
+  element_cb http_version;
+  element_cb header_done;
+  
+} http_parser;
+
+int http_parser_init(http_parser *parser);
+int http_parser_finish(http_parser *parser);
+size_t http_parser_execute(http_parser *parser, const char *data, size_t len, size_t off);
+int http_parser_has_error(http_parser *parser);
+int http_parser_is_finished(http_parser *parser);
+
+#define http_parser_nread(parser) (parser)->nread 
+
+#endif
diff --git a/vendor/gems/gems/thin-1.2.5/ext/thin_parser/parser.o b/vendor/gems/gems/thin-1.2.5/ext/thin_parser/parser.o
new file mode 100755
index 00000000..17badb13
Binary files /dev/null and b/vendor/gems/gems/thin-1.2.5/ext/thin_parser/parser.o differ
diff --git a/vendor/gems/gems/thin-1.2.5/ext/thin_parser/parser.rl b/vendor/gems/gems/thin-1.2.5/ext/thin_parser/parser.rl
new file mode 100755
index 00000000..d32f81d9
--- /dev/null
+++ b/vendor/gems/gems/thin-1.2.5/ext/thin_parser/parser.rl
@@ -0,0 +1,157 @@
+/**
+ * Copyright (c) 2005 Zed A. Shaw
+ * You can redistribute it and/or modify it under the same terms as Ruby.
+ */
+#include "parser.h"
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#define LEN(AT, FPC) (FPC - buffer - parser->AT)
+#define MARK(M,FPC) (parser->M = (FPC) - buffer)
+#define PTR_TO(F) (buffer + parser->F)
+
+/** Machine **/
+
+%%{
+  
+  machine http_parser;
+
+  action mark {MARK(mark, fpc); }
+
+
+  action start_field { MARK(field_start, fpc); }
+  action write_field { 
+    parser->field_len = LEN(field_start, fpc);
+  }
+
+  action start_value { MARK(mark, fpc); }
+  action write_value { 
+    if (parser->http_field != NULL) {
+      parser->http_field(parser->data, PTR_TO(field_start), parser->field_len, PTR_TO(mark), LEN(mark, fpc));
+    }
+  }
+  action request_method { 
+    if (parser->request_method != NULL) {
+      parser->request_method(parser->data, PTR_TO(mark), LEN(mark, fpc));
+    }
+  }
+  action request_uri {
+    if (parser->request_uri != NULL) {
+      parser->request_uri(parser->data, PTR_TO(mark), LEN(mark, fpc));
+    }
+  }
+  action fragment { 
+    if (parser->fragment != NULL) {
+      parser->fragment(parser->data, PTR_TO(mark), LEN(mark, fpc));
+    }
+  }
+
+  action start_query {MARK(query_start, fpc); }
+  action query_string { 
+    if (parser->query_string != NULL) {
+      parser->query_string(parser->data, PTR_TO(query_start), LEN(query_start, fpc));
+    }
+  }
+
+  action http_version {	
+    if (parser->http_version != NULL) {
+      parser->http_version(parser->data, PTR_TO(mark), LEN(mark, fpc));
+    }
+  }
+
+  action request_path {
+    if (parser->request_path != NULL) {
+      parser->request_path(parser->data, PTR_TO(mark), LEN(mark,fpc));
+    }
+  }
+
+  action done { 
+    parser->body_start = fpc - buffer + 1; 
+    if (parser->header_done != NULL) {
+      parser->header_done(parser->data, fpc + 1, pe - fpc - 1);
+    }
+    fbreak;
+  }
+
+  include http_parser_common "common.rl";
+
+}%%
+
+/** Data **/
+%% write data;
+
+int thin_http_parser_init(http_parser *parser)  {
+  int cs = 0;
+  %% write init;
+  parser->cs = cs;
+  parser->body_start = 0;
+  parser->content_len = 0;
+  parser->mark = 0;
+  parser->nread = 0;
+  parser->field_len = 0;
+  parser->field_start = 0;    
+
+  return(1);
+}
+
+
+/** exec **/
+size_t thin_http_parser_execute(http_parser *parser, const char *buffer, size_t len, size_t off)  {
+  const char *p, *pe;
+  int cs = parser->cs;
+
+  assert(off <= len && "offset past end of buffer");
+
+  p = buffer+off;
+  pe = buffer+len;
+
+  assert(*pe == '\0' && "pointer does not end on NUL");
+  assert(pe - p == len - off && "pointers aren't same distance");
+
+
+  %% write exec;
+
+  parser->cs = cs;
+  parser->nread += p - (buffer + off);
+
+  assert(p <= pe && "buffer overflow after parsing execute");
+  assert(parser->nread <= len && "nread longer than length");
+  assert(parser->body_start <= len && "body starts after buffer end");
+  assert(parser->mark < len && "mark is after buffer end");
+  assert(parser->field_len <= len && "field has length longer than whole buffer");
+  assert(parser->field_start < len && "field starts after buffer end");
+
+  if(parser->body_start) {
+    /* final \r\n combo encountered so stop right here */
+    parser->nread++;
+  }
+
+  return(parser->nread);
+}
+
+int thin_http_parser_finish(http_parser *parser)
+{
+  int cs = parser->cs;
+
+
+  parser->cs = cs;
+
+  if (thin_http_parser_has_error(parser) ) {
+    return -1;
+  } else if (thin_http_parser_is_finished(parser) ) {
+    return 1;
+  } else {
+    return 0;
+  }
+}
+
+int thin_http_parser_has_error(http_parser *parser) {
+  return parser->cs == http_parser_error;
+}
+
+int thin_http_parser_is_finished(http_parser *parser) {
+  return parser->cs == http_parser_first_final;
+}
diff --git a/vendor/gems/gems/thin-1.2.5/ext/thin_parser/thin.c b/vendor/gems/gems/thin-1.2.5/ext/thin_parser/thin.c
new file mode 100755
index 00000000..04754bc9
--- /dev/null
+++ b/vendor/gems/gems/thin-1.2.5/ext/thin_parser/thin.c
@@ -0,0 +1,433 @@
+/**
+ * Mongrel Parser adpated to Thin and to play more nicely with Rack specs.
+ * 
+ * Orignal version Copyright (c) 2005 Zed A. Shaw
+ * You can redistribute it and/or modify it under the same terms as Ruby.
+ */
+#include "ruby.h"
+#include "ext_help.h"
+#include 
+#include 
+#include "parser.h"
+#include 
+
+static VALUE mThin;
+static VALUE cHttpParser;
+static VALUE eHttpParserError;
+
+static VALUE global_empty;
+static VALUE global_http_prefix;
+static VALUE global_request_method;
+static VALUE global_request_uri;
+static VALUE global_fragment;
+static VALUE global_query_string;
+static VALUE global_http_version;
+static VALUE global_content_length;
+static VALUE global_http_content_length;
+static VALUE global_request_path;
+static VALUE global_content_type;
+static VALUE global_http_content_type;
+static VALUE global_gateway_interface;
+static VALUE global_gateway_interface_value;
+static VALUE global_server_name;
+static VALUE global_server_port;
+static VALUE global_server_protocol;
+static VALUE global_server_protocol_value;
+static VALUE global_http_host;
+static VALUE global_port_80;
+static VALUE global_http_body;
+static VALUE global_url_scheme;
+static VALUE global_url_scheme_value;
+static VALUE global_script_name;
+static VALUE global_path_info;
+
+#define TRIE_INCREASE 30
+
+/** Defines common length and error messages for input length validation. */
+#define DEF_MAX_LENGTH(N,length) const size_t MAX_##N##_LENGTH = length; const char *MAX_##N##_LENGTH_ERR = "HTTP element " # N  " is longer than the " # length " allowed length."
+
+/** Validates the max length of given input and throws an HttpParserError exception if over. */
+#define VALIDATE_MAX_LENGTH(len, N) if(len > MAX_##N##_LENGTH) { rb_raise(eHttpParserError, MAX_##N##_LENGTH_ERR); }
+
+/** Defines global strings in the init method. */
+#define DEF_GLOBAL(N, val)   global_##N = rb_obj_freeze(rb_str_new2(val)); rb_global_variable(&global_##N)
+
+/* for compatibility with Ruby 1.8.5, which doesn't declare RSTRING_PTR */
+#ifndef RSTRING_PTR
+#define RSTRING_PTR(s) (RSTRING(s)->ptr)
+#endif
+
+/* for compatibility with Ruby 1.8.5, which doesn't declare RSTRING_LEN */
+#ifndef RSTRING_LEN
+#define RSTRING_LEN(s) (RSTRING(s)->len)
+#endif
+
+/* Defines the maximum allowed lengths for various input elements.*/
+DEF_MAX_LENGTH(FIELD_NAME, 256);
+DEF_MAX_LENGTH(FIELD_VALUE, 80 * 1024);
+DEF_MAX_LENGTH(REQUEST_URI, 1024 * 12);
+DEF_MAX_LENGTH(FRAGMENT, 1024); /* Don't know if this length is specified somewhere or not */
+DEF_MAX_LENGTH(REQUEST_PATH, 1024);
+DEF_MAX_LENGTH(QUERY_STRING, (1024 * 10));
+DEF_MAX_LENGTH(HEADER, (1024 * (80 + 32)));
+
+
+static void http_field(void *data, const char *field, size_t flen, const char *value, size_t vlen)
+{
+  char *ch, *end;
+  VALUE req = (VALUE)data;
+  VALUE v = Qnil;
+  VALUE f = Qnil;
+
+  VALIDATE_MAX_LENGTH(flen, FIELD_NAME);
+  VALIDATE_MAX_LENGTH(vlen, FIELD_VALUE);
+
+  v = rb_str_new(value, vlen);
+  f = rb_str_dup(global_http_prefix);
+  f = rb_str_buf_cat(f, field, flen); 
+
+  for(ch = RSTRING_PTR(f) + RSTRING_LEN(global_http_prefix), end = RSTRING_PTR(f) + RSTRING_LEN(f); ch < end; ch++) {
+    if(*ch == '-') {
+      *ch = '_';
+    } else {
+      *ch = toupper(*ch);
+    }
+  }
+
+  rb_hash_aset(req, f, v);
+}
+
+static void request_method(void *data, const char *at, size_t length)
+{
+  VALUE req = (VALUE)data;
+  VALUE val = Qnil;
+
+  val = rb_str_new(at, length);
+  rb_hash_aset(req, global_request_method, val);
+}
+
+static void request_uri(void *data, const char *at, size_t length)
+{
+  VALUE req = (VALUE)data;
+  VALUE val = Qnil;
+
+  VALIDATE_MAX_LENGTH(length, REQUEST_URI);
+
+  val = rb_str_new(at, length);
+  rb_hash_aset(req, global_request_uri, val);
+}
+
+static void fragment(void *data, const char *at, size_t length)
+{
+  VALUE req = (VALUE)data;
+  VALUE val = Qnil;
+
+  VALIDATE_MAX_LENGTH(length, FRAGMENT);
+
+  val = rb_str_new(at, length);
+  rb_hash_aset(req, global_fragment, val);
+}
+
+static void request_path(void *data, const char *at, size_t length)
+{
+  VALUE req = (VALUE)data;
+  VALUE val = Qnil;
+
+  VALIDATE_MAX_LENGTH(length, REQUEST_PATH);
+
+  val = rb_str_new(at, length);
+  rb_hash_aset(req, global_request_path, val);
+  rb_hash_aset(req, global_path_info, val);
+}
+
+static void query_string(void *data, const char *at, size_t length)
+{
+  VALUE req = (VALUE)data;
+  VALUE val = Qnil;
+
+  VALIDATE_MAX_LENGTH(length, QUERY_STRING);
+
+  val = rb_str_new(at, length);
+  rb_hash_aset(req, global_query_string, val);
+}
+
+static void http_version(void *data, const char *at, size_t length)
+{
+  VALUE req = (VALUE)data;
+  VALUE val = rb_str_new(at, length);
+  rb_hash_aset(req, global_http_version, val);
+}
+
+/** Finalizes the request header to have a bunch of stuff that's
+  needed. */
+
+static void header_done(void *data, const char *at, size_t length)
+{
+  VALUE req = (VALUE)data;
+  VALUE temp = Qnil;
+  VALUE ctype = Qnil;
+  VALUE clen = Qnil;
+  VALUE body = Qnil;
+  char *colon = NULL;
+
+  clen = rb_hash_aref(req, global_http_content_length);
+  if(clen != Qnil) {
+    rb_hash_aset(req, global_content_length, clen);
+    rb_hash_delete(req, global_http_content_length);
+  }
+
+  ctype = rb_hash_aref(req, global_http_content_type);
+  if(ctype != Qnil) {
+    rb_hash_aset(req, global_content_type, ctype);
+    rb_hash_delete(req, global_http_content_type);
+  }
+
+  rb_hash_aset(req, global_gateway_interface, global_gateway_interface_value);
+  if((temp = rb_hash_aref(req, global_http_host)) != Qnil) {
+    /* ruby better close strings off with a '\0' dammit */
+    colon = strchr(RSTRING_PTR(temp), ':');
+    if(colon != NULL) {
+      rb_hash_aset(req, global_server_name, rb_str_substr(temp, 0, colon - RSTRING_PTR(temp)));
+      rb_hash_aset(req, global_server_port, 
+          rb_str_substr(temp, colon - RSTRING_PTR(temp)+1, 
+            RSTRING_LEN(temp)));
+    } else {
+      rb_hash_aset(req, global_server_name, temp);
+      rb_hash_aset(req, global_server_port, global_port_80);
+    }
+  }
+
+  /* grab the initial body and stuff it into the hash */
+  if(length > 0) {
+    body = rb_hash_aref(req, global_http_body);
+    rb_io_write(body, rb_str_new(at, length));
+  }
+  
+  /* according to Rack specs, query string must be empty string if none */
+  if (rb_hash_aref(req, global_query_string) == Qnil) {
+    rb_hash_aset(req, global_query_string, global_empty);
+  }
+  
+  /* set some constants */
+  rb_hash_aset(req, global_server_protocol, global_server_protocol_value);
+  rb_hash_aset(req, global_url_scheme, global_url_scheme_value);
+  rb_hash_aset(req, global_script_name, global_empty);
+}
+
+
+void Thin_HttpParser_free(void *data) {
+  TRACE();
+
+  if(data) {
+    free(data);
+  }
+}
+
+
+VALUE Thin_HttpParser_alloc(VALUE klass)
+{
+  VALUE obj;
+  http_parser *hp = ALLOC_N(http_parser, 1);
+  TRACE();
+  hp->http_field = http_field;
+  hp->request_method = request_method;
+  hp->request_uri = request_uri;
+  hp->fragment = fragment;
+  hp->request_path = request_path;
+  hp->query_string = query_string;
+  hp->http_version = http_version;
+  hp->header_done = header_done;
+  thin_http_parser_init(hp);
+
+  obj = Data_Wrap_Struct(klass, NULL, Thin_HttpParser_free, hp);
+
+  return obj;
+}
+
+
+/**
+ * call-seq:
+ *    parser.new -> parser
+ *
+ * Creates a new parser.
+ */
+VALUE Thin_HttpParser_init(VALUE self)
+{
+  http_parser *http = NULL;
+  DATA_GET(self, http_parser, http);
+  thin_http_parser_init(http);
+
+  return self;
+}
+
+
+/**
+ * call-seq:
+ *    parser.reset -> nil
+ *
+ * Resets the parser to it's initial state so that you can reuse it
+ * rather than making new ones.
+ */
+VALUE Thin_HttpParser_reset(VALUE self)
+{
+  http_parser *http = NULL;
+  DATA_GET(self, http_parser, http);
+  thin_http_parser_init(http);
+
+  return Qnil;
+}
+
+
+/**
+ * call-seq:
+ *    parser.finish -> true/false
+ *
+ * Finishes a parser early which could put in a "good" or bad state.
+ * You should call reset after finish it or bad things will happen.
+ */
+VALUE Thin_HttpParser_finish(VALUE self)
+{
+  http_parser *http = NULL;
+  DATA_GET(self, http_parser, http);
+  thin_http_parser_finish(http);
+
+  return thin_http_parser_is_finished(http) ? Qtrue : Qfalse;
+}
+
+
+/**
+ * call-seq:
+ *    parser.execute(req_hash, data, start) -> Integer
+ *
+ * Takes a Hash and a String of data, parses the String of data filling in the Hash
+ * returning an Integer to indicate how much of the data has been read.  No matter
+ * what the return value, you should call HttpParser#finished? and HttpParser#error?
+ * to figure out if it's done parsing or there was an error.
+ * 
+ * This function now throws an exception when there is a parsing error.  This makes 
+ * the logic for working with the parser much easier.  You can still test for an 
+ * error, but now you need to wrap the parser with an exception handling block.
+ *
+ * The third argument allows for parsing a partial request and then continuing
+ * the parsing from that position.  It needs all of the original data as well 
+ * so you have to append to the data buffer as you read.
+ */
+VALUE Thin_HttpParser_execute(VALUE self, VALUE req_hash, VALUE data, VALUE start)
+{
+  http_parser *http = NULL;
+  int from = 0;
+  char *dptr = NULL;
+  long dlen = 0;
+
+  DATA_GET(self, http_parser, http);
+
+  from = FIX2INT(start);
+  dptr = RSTRING_PTR(data);
+  dlen = RSTRING_LEN(data);
+
+  if(from >= dlen) {
+    rb_raise(eHttpParserError, "Requested start is after data buffer end.");
+  } else {
+    http->data = (void *)req_hash;
+    thin_http_parser_execute(http, dptr, dlen, from);
+
+    VALIDATE_MAX_LENGTH(http_parser_nread(http), HEADER);
+
+    if(thin_http_parser_has_error(http)) {
+      rb_raise(eHttpParserError, "Invalid HTTP format, parsing fails.");
+    } else {
+      return INT2FIX(http_parser_nread(http));
+    }
+  }
+}
+
+
+
+/**
+ * call-seq:
+ *    parser.error? -> true/false
+ *
+ * Tells you whether the parser is in an error state.
+ */
+VALUE Thin_HttpParser_has_error(VALUE self)
+{
+  http_parser *http = NULL;
+  DATA_GET(self, http_parser, http);
+
+  return thin_http_parser_has_error(http) ? Qtrue : Qfalse;
+}
+
+
+/**
+ * call-seq:
+ *    parser.finished? -> true/false
+ *
+ * Tells you whether the parser is finished or not and in a good state.
+ */
+VALUE Thin_HttpParser_is_finished(VALUE self)
+{
+  http_parser *http = NULL;
+  DATA_GET(self, http_parser, http);
+
+  return thin_http_parser_is_finished(http) ? Qtrue : Qfalse;
+}
+
+
+/**
+ * call-seq:
+ *    parser.nread -> Integer
+ *
+ * Returns the amount of data processed so far during this processing cycle.  It is
+ * set to 0 on initialize or reset calls and is incremented each time execute is called.
+ */
+VALUE Thin_HttpParser_nread(VALUE self)
+{
+  http_parser *http = NULL;
+  DATA_GET(self, http_parser, http);
+
+  return INT2FIX(http->nread);
+}
+
+void Init_thin_parser()
+{
+
+  mThin = rb_define_module("Thin");
+
+  DEF_GLOBAL(empty, "");
+  DEF_GLOBAL(http_prefix, "HTTP_");
+  DEF_GLOBAL(request_method, "REQUEST_METHOD");
+  DEF_GLOBAL(request_uri, "REQUEST_URI");
+  DEF_GLOBAL(fragment, "FRAGMENT");
+  DEF_GLOBAL(query_string, "QUERY_STRING");
+  DEF_GLOBAL(http_version, "HTTP_VERSION");
+  DEF_GLOBAL(request_path, "REQUEST_PATH");
+  DEF_GLOBAL(content_length, "CONTENT_LENGTH");
+  DEF_GLOBAL(http_content_length, "HTTP_CONTENT_LENGTH");
+  DEF_GLOBAL(content_type, "CONTENT_TYPE");
+  DEF_GLOBAL(http_content_type, "HTTP_CONTENT_TYPE");
+  DEF_GLOBAL(gateway_interface, "GATEWAY_INTERFACE");
+  DEF_GLOBAL(gateway_interface_value, "CGI/1.2");
+  DEF_GLOBAL(server_name, "SERVER_NAME");
+  DEF_GLOBAL(server_port, "SERVER_PORT");
+  DEF_GLOBAL(server_protocol, "SERVER_PROTOCOL");
+  DEF_GLOBAL(server_protocol_value, "HTTP/1.1");
+  DEF_GLOBAL(http_host, "HTTP_HOST");
+  DEF_GLOBAL(port_80, "80");
+  DEF_GLOBAL(http_body, "rack.input");
+  DEF_GLOBAL(url_scheme, "rack.url_scheme");
+  DEF_GLOBAL(url_scheme_value, "http");
+  DEF_GLOBAL(script_name, "SCRIPT_NAME");
+  DEF_GLOBAL(path_info, "PATH_INFO");
+
+  eHttpParserError = rb_define_class_under(mThin, "InvalidRequest", rb_eIOError);
+
+  cHttpParser = rb_define_class_under(mThin, "HttpParser", rb_cObject);
+  rb_define_alloc_func(cHttpParser, Thin_HttpParser_alloc);
+  rb_define_method(cHttpParser, "initialize", Thin_HttpParser_init,0);
+  rb_define_method(cHttpParser, "reset", Thin_HttpParser_reset,0);
+  rb_define_method(cHttpParser, "finish", Thin_HttpParser_finish,0);
+  rb_define_method(cHttpParser, "execute", Thin_HttpParser_execute,3);
+  rb_define_method(cHttpParser, "error?", Thin_HttpParser_has_error,0);
+  rb_define_method(cHttpParser, "finished?", Thin_HttpParser_is_finished,0);
+  rb_define_method(cHttpParser, "nread", Thin_HttpParser_nread,0);
+}
diff --git a/vendor/gems/gems/thin-1.2.5/ext/thin_parser/thin.o b/vendor/gems/gems/thin-1.2.5/ext/thin_parser/thin.o
new file mode 100755
index 00000000..67542019
Binary files /dev/null and b/vendor/gems/gems/thin-1.2.5/ext/thin_parser/thin.o differ
diff --git a/vendor/gems/gems/thin-1.2.5/ext/thin_parser/thin_parser.bundle b/vendor/gems/gems/thin-1.2.5/ext/thin_parser/thin_parser.bundle
new file mode 100755
index 00000000..c9a122b9
Binary files /dev/null and b/vendor/gems/gems/thin-1.2.5/ext/thin_parser/thin_parser.bundle differ
diff --git a/vendor/gems/gems/thin-1.2.5/lib/rack/adapter/loader.rb b/vendor/gems/gems/thin-1.2.5/lib/rack/adapter/loader.rb
new file mode 100755
index 00000000..44b04a97
--- /dev/null
+++ b/vendor/gems/gems/thin-1.2.5/lib/rack/adapter/loader.rb
@@ -0,0 +1,79 @@
+module Rack
+  class AdapterNotFound < RuntimeError; end
+  
+  # Mapping used to guess which adapter to use in Adapter.for.
+  # Framework  =>  in order they will
+  # be tested.
+  # +nil+ for value to never guess.
+  # NOTE: If a framework has a file that is not unique, make sure to place
+  # it at the end.
+  ADAPTERS = [
+    [:rails,   'config/environment.rb'],
+    [:ramaze,  'start.rb'],
+    [:halcyon, 'runner.ru'],
+    [:merb,    'config/init.rb'],
+    [:mack,    'config/app_config/default.yml'],
+    [:mack,    'config/configatron/default.rb'],
+    [:file,    nil]
+  ]
+  
+  module Adapter
+    # Guess which adapter to use based on the directory structure
+    # or file content.
+    # Returns a symbol representing the name of the adapter to use
+    # to load the application under dir/.
+    def self.guess(dir)
+      ADAPTERS.each do |adapter, file|
+        return adapter if file && ::File.exist?(::File.join(dir, file))
+      end
+      raise AdapterNotFound, "No adapter found for #{dir}"
+    end
+    
+    # Loads an adapter identified by +name+ using +options+ hash.
+    def self.for(name, options={})
+      case name.to_sym
+      when :rails
+        return Rails.new(options.merge(:root => options[:chdir]))
+      
+      when :ramaze
+        require "#{options[:chdir]}/start"
+        
+        Ramaze.trait[:essentials].delete Ramaze::Adapter
+        Ramaze.start :force => true
+        
+        return Ramaze::Adapter::Base
+        
+      when :merb
+        require 'merb-core'
+        
+        Merb::Config.setup(:merb_root   => options[:chdir],
+                           :environment => options[:environment])
+        Merb.environment = Merb::Config[:environment]
+        Merb.root = Merb::Config[:merb_root]
+        Merb::BootLoader.run
+        
+        return Merb::Rack::Application.new
+        
+      when :halcyon
+        require 'halcyon'
+        
+        $:.unshift(Halcyon.root/'lib')
+        
+        return Halcyon::Runner.new
+        
+      when :mack
+        ENV["MACK_ENV"] = options[:environment]
+        load(::File.join(options[:chdir], "Rakefile"))
+        require 'mack'
+        return Mack::Utils::Server.build_app
+        
+      when :file
+        return Rack::File.new(options[:chdir])
+        
+      else
+        raise AdapterNotFound, "Adapter not found: #{name}"
+        
+      end
+    end
+  end
+end
\ No newline at end of file
diff --git a/vendor/gems/gems/thin-1.2.5/lib/rack/adapter/rails.rb b/vendor/gems/gems/thin-1.2.5/lib/rack/adapter/rails.rb
new file mode 100755
index 00000000..34196d84
--- /dev/null
+++ b/vendor/gems/gems/thin-1.2.5/lib/rack/adapter/rails.rb
@@ -0,0 +1,180 @@
+require 'cgi'
+
+# Adapter to run a Rails app with any supported Rack handler.
+# By default it will try to load the Rails application in the
+# current directory in the development environment.
+#
+# Options:
+#  root: Root directory of the Rails app
+#  environment: Rails environment to run in (development [default], production or test)
+#  prefix: Set the relative URL root.
+#
+# Based on http://fuzed.rubyforge.org/ Rails adapter
+module Rack
+  module Adapter 
+    class Rails
+      FILE_METHODS = %w(GET HEAD).freeze
+      
+      def initialize(options={})
+        @root   = options[:root]         || Dir.pwd
+        @env    = options[:environment]  || 'development'
+        @prefix = options[:prefix]
+        
+        load_application
+        
+        @rails_app = if rack_based?
+          ActionController::Dispatcher.new
+        else
+          CgiApp.new
+        end
+        
+        @file_app = Rack::File.new(::File.join(RAILS_ROOT, "public"))
+      end
+      
+      def rack_based?
+        rails_version = ::Rails::VERSION
+        rails_version::MAJOR >= 2 && rails_version::MINOR >= 2 && rails_version::TINY >= 3
+      end
+      
+      def load_application
+        ENV['RAILS_ENV'] = @env
+
+        require "#{@root}/config/environment"
+        require 'dispatcher'
+        
+        if @prefix
+          if ActionController::Base.respond_to?(:relative_url_root=)
+            ActionController::Base.relative_url_root = @prefix # Rails 2.1.1
+          else
+            ActionController::AbstractRequest.relative_url_root = @prefix
+          end
+        end
+      end
+      
+      def file_exist?(path)
+        full_path = ::File.join(@file_app.root, Utils.unescape(path))
+        ::File.file?(full_path) && ::File.readable_real?(full_path)
+      end
+      
+      def call(env)
+        path        = env['PATH_INFO'].chomp('/')
+        method      = env['REQUEST_METHOD']
+        cached_path = (path.empty? ? 'index' : path) + ActionController::Base.page_cache_extension
+        
+        if FILE_METHODS.include?(method)
+          if file_exist?(path)              # Serve the file if it's there
+            return @file_app.call(env)
+          elsif file_exist?(cached_path)    # Serve the page cache if it's there
+            env['PATH_INFO'] = cached_path
+            return @file_app.call(env)
+          end
+        end
+        
+        # No static file, let Rails handle it
+        @rails_app.call(env)
+      end
+    
+      protected
+        # For Rails pre Rack (2.3)
+        class CgiApp
+          def call(env)
+            request         = Request.new(env)
+            response        = Response.new
+            session_options = ActionController::CgiRequest::DEFAULT_SESSION_OPTIONS
+            cgi             = CGIWrapper.new(request, response)
+
+            Dispatcher.dispatch(cgi, session_options, response)
+
+            response.finish
+          end
+        end
+        
+        class CGIWrapper < ::CGI
+          def initialize(request, response, *args)
+            @request  = request
+            @response = response
+            @args     = *args
+            @input    = request.body
+
+            super *args
+          end
+        
+          def header(options = "text/html")
+            if options.is_a?(String)
+              @response['Content-Type']     = options unless @response['Content-Type']
+            else
+              @response['Content-Length']   = options.delete('Content-Length').to_s if options['Content-Length']
+            
+              @response['Content-Type']     = options.delete('type') || "text/html"
+              @response['Content-Type']    += "; charset=" + options.delete('charset') if options['charset']
+                        
+              @response['Content-Language'] = options.delete('language') if options['language']
+              @response['Expires']          = options.delete('expires') if options['expires']
+
+              @response.status              = options.delete('Status') if options['Status']
+              
+              # Convert 'cookie' header to 'Set-Cookie' headers.
+              # Because Set-Cookie header can appear more the once in the response body, 
+              # we store it in a line break seperated string that will be translated to
+              # multiple Set-Cookie header by the handler.
+              if cookie = options.delete('cookie')
+                cookies = []
+                
+                case cookie
+                  when Array then cookie.each { |c| cookies << c.to_s }
+                  when Hash  then cookie.each { |_, c| cookies << c.to_s }
+                  else            cookies << cookie.to_s
+                end
+                
+                @output_cookies.each { |c| cookies << c.to_s } if @output_cookies
+                
+                @response['Set-Cookie'] = [@response['Set-Cookie'], cookies].compact
+                # See http://groups.google.com/group/rack-devel/browse_thread/thread/e8759b91a82c5a10/a8dbd4574fe97d69?#a8dbd4574fe97d69
+                if Thin.ruby_18?
+                  @response['Set-Cookie'].flatten!
+                else
+                  @response['Set-Cookie'] = @response['Set-Cookie'].join("\n")
+                end
+              end
+              
+              options.each { |k,v| @response[k] = v }
+            end
+            
+            ""
+          end
+                        
+          def params
+            @params ||= @request.params
+          end
+        
+          def cookies
+            @request.cookies
+          end
+        
+          def query_string
+            @request.query_string
+          end
+          
+          # Used to wrap the normal args variable used inside CGI.
+          def args
+            @args
+          end
+    
+          # Used to wrap the normal env_table variable used inside CGI.
+          def env_table
+            @request.env
+          end
+    
+          # Used to wrap the normal stdinput variable used inside CGI.
+          def stdinput
+            @input
+          end
+        
+          def stdoutput
+            STDERR.puts "stdoutput should not be used."
+            @response.body
+          end
+      end
+    end
+  end
+end
diff --git a/vendor/gems/gems/thin-1.2.5/lib/thin.rb b/vendor/gems/gems/thin-1.2.5/lib/thin.rb
new file mode 100755
index 00000000..93c83e37
--- /dev/null
+++ b/vendor/gems/gems/thin-1.2.5/lib/thin.rb
@@ -0,0 +1,46 @@
+require 'fileutils'
+require 'timeout'
+require 'stringio'
+require 'time'
+require 'forwardable'
+
+require 'openssl'
+require 'eventmachine'
+
+require 'thin/version'
+require 'thin/statuses'
+
+module Thin
+  autoload :Command,            'thin/command'
+  autoload :Connection,         'thin/connection'
+  autoload :Daemonizable,       'thin/daemonizing'
+  autoload :Logging,            'thin/logging'
+  autoload :Headers,            'thin/headers'
+  autoload :Request,            'thin/request'
+  autoload :Response,           'thin/response'
+  autoload :Runner,             'thin/runner'
+  autoload :Server,             'thin/server'
+  autoload :Stats,              'thin/stats'
+  
+  module Backends
+    autoload :Base,             'thin/backends/base'
+    autoload :SwiftiplyClient,  'thin/backends/swiftiply_client'
+    autoload :TcpServer,        'thin/backends/tcp_server'
+    autoload :UnixServer,       'thin/backends/unix_server'
+  end
+  
+  module Controllers
+    autoload :Cluster,          'thin/controllers/cluster'
+    autoload :Controller,       'thin/controllers/controller'
+    autoload :Service,          'thin/controllers/service'
+  end
+end
+
+require 'rack'
+require 'rack/adapter/loader'
+
+module Rack
+  module Adapter
+    autoload :Rails, 'rack/adapter/rails'
+  end
+end
diff --git a/vendor/gems/gems/thin-1.2.5/lib/thin/backends/base.rb b/vendor/gems/gems/thin-1.2.5/lib/thin/backends/base.rb
new file mode 100755
index 00000000..ee7f3e46
--- /dev/null
+++ b/vendor/gems/gems/thin-1.2.5/lib/thin/backends/base.rb
@@ -0,0 +1,141 @@
+module Thin
+  module Backends
+    # A Backend connects the server to the client. It handles:
+    # * connection/disconnection to the server
+    # * initialization of the connections
+    # * manitoring of the active connections.
+    #
+    # == Implementing your own backend
+    # You can create your own minimal backend by inheriting this class and
+    # defining the +connect+ and +disconnect+ method.
+    # If your backend is not based on EventMachine you also need to redefine
+    # the +start+, +stop+, stop! and +config+ methods.
+    class Base
+      # Server serving the connections throught the backend
+      attr_accessor :server
+      
+      # Maximum time for incoming data to arrive
+      attr_accessor :timeout
+      
+      # Maximum number of file or socket descriptors that the server may open.
+      attr_accessor :maximum_connections
+      
+      # Maximum number of connections that can be persistent
+      attr_accessor :maximum_persistent_connections
+      
+      # Allow using threads in the backend.
+      attr_writer :threaded
+      def threaded?; @threaded end
+      
+      # Number of persistent connections currently opened
+      attr_accessor :persistent_connection_count
+      
+      # Disable the use of epoll under Linux
+      attr_accessor :no_epoll
+      
+      def initialize
+        @connections                    = []
+        @timeout                        = Server::DEFAULT_TIMEOUT
+        @persistent_connection_count    = 0
+        @maximum_connections            = Server::DEFAULT_MAXIMUM_CONNECTIONS
+        @maximum_persistent_connections = Server::DEFAULT_MAXIMUM_PERSISTENT_CONNECTIONS
+        @no_epoll                       = false
+      end
+      
+      # Start the backend and connect it.
+      def start
+        @stopping = false
+        starter   = proc do
+          connect
+          @running = true
+        end
+        
+        # Allow for early run up of eventmachine.
+        if EventMachine.reactor_running?
+          starter.call
+        else
+          EventMachine.run(&starter)
+        end
+      end
+      
+      # Stop of the backend from accepting new connections.
+      def stop
+        @running  = false
+        @stopping = true
+        
+        # Do not accept anymore connection
+        disconnect
+        stop! if @connections.empty?
+      end
+      
+      # Force stop of the backend NOW, too bad for the current connections.
+      def stop!
+        @running  = false
+        @stopping = false
+        
+        EventMachine.stop if EventMachine.reactor_running?
+        @connections.each { |connection| connection.close_connection }
+        close
+      end
+      
+      # Configure the backend. This method will be called before droping superuser privileges,
+      # so you can do crazy stuff that require godlike powers here.
+      def config
+        # See http://rubyeventmachine.com/pub/rdoc/files/EPOLL.html
+        EventMachine.epoll unless @no_epoll
+        
+        # Set the maximum number of socket descriptors that the server may open.
+        # The process needs to have required privilege to set it higher the 1024 on
+        # some systems.
+        @maximum_connections = EventMachine.set_descriptor_table_size(@maximum_connections) unless Thin.win?
+      end
+      
+      # Free up resources used by the backend.
+      def close
+      end
+      
+      # Returns +true+ if the backend is connected and running.
+      def running?
+        @running
+      end
+            
+      # Called by a connection when it's unbinded.
+      def connection_finished(connection)
+        @persistent_connection_count -= 1 if connection.can_persist?
+        @connections.delete(connection)
+        
+        # Finalize gracefull stop if there's no more active connection.
+        stop! if @stopping && @connections.empty?
+      end
+      
+      # Returns +true+ if no active connection.
+      def empty?
+        @connections.empty?
+      end
+      
+      # Number of active connections.
+      def size
+        @connections.size
+      end
+      
+      protected
+        # Initialize a new connection to a client.
+        def initialize_connection(connection)
+          connection.backend                 = self
+          connection.app                     = @server.app
+          connection.comm_inactivity_timeout = @timeout
+          connection.threaded                = @threaded
+
+          # We control the number of persistent connections by keeping
+          # a count of the total one allowed yet.
+          if @persistent_connection_count < @maximum_persistent_connections
+            connection.can_persist!
+            @persistent_connection_count += 1
+          end
+
+          @connections << connection
+        end
+      
+    end
+  end
+end
\ No newline at end of file
diff --git a/vendor/gems/gems/thin-1.2.5/lib/thin/backends/swiftiply_client.rb b/vendor/gems/gems/thin-1.2.5/lib/thin/backends/swiftiply_client.rb
new file mode 100755
index 00000000..506a84c3
--- /dev/null
+++ b/vendor/gems/gems/thin-1.2.5/lib/thin/backends/swiftiply_client.rb
@@ -0,0 +1,56 @@
+module Thin
+  module Backends
+    # Backend to act as a Swiftiply client (http://swiftiply.swiftcore.org).
+    class SwiftiplyClient < Base
+      attr_accessor :key
+      
+      attr_accessor :host, :port
+      
+      def initialize(host, port, options={})
+        @host = host
+        @port = port.to_i
+        @key  = options[:swiftiply].to_s
+        super()
+      end
+
+      # Connect the server
+      def connect
+        EventMachine.connect(@host, @port, SwiftiplyConnection, &method(:initialize_connection))
+      end
+
+      # Stops the server
+      def disconnect
+        EventMachine.stop
+      end
+
+      def to_s
+        "#{@host}:#{@port} swiftiply"
+      end
+    end    
+  end
+
+  class SwiftiplyConnection < Connection
+    def connection_completed
+      send_data swiftiply_handshake(@backend.key)
+    end
+    
+    def persistent?
+      true
+    end
+    
+    def unbind
+      super
+      EventMachine.add_timer(rand(2)) { reconnect(@backend.host, @backend.port) } if @backend.running?
+    end
+    
+    protected
+      def swiftiply_handshake(key)
+        'swiftclient' << host_ip.collect { |x| sprintf('%02x', x.to_i)}.join << sprintf('%04x', @backend.port) << sprintf('%02x', key.length) << key
+      end
+      
+      # For some reason Swiftiply request the current host
+      def host_ip
+        Socket.gethostbyname(@backend.host)[3].unpack('CCCC') rescue [0,0,0,0]
+      end
+  end
+end
\ No newline at end of file
diff --git a/vendor/gems/gems/thin-1.2.5/lib/thin/backends/tcp_server.rb b/vendor/gems/gems/thin-1.2.5/lib/thin/backends/tcp_server.rb
new file mode 100755
index 00000000..0f2b38ee
--- /dev/null
+++ b/vendor/gems/gems/thin-1.2.5/lib/thin/backends/tcp_server.rb
@@ -0,0 +1,29 @@
+module Thin
+  module Backends
+    # Backend to act as a TCP socket server.
+    class TcpServer < Base
+      # Address and port on which the server is listening for connections.
+      attr_accessor :host, :port
+      
+      def initialize(host, port)
+        @host = host
+        @port = port
+        super()
+      end
+      
+      # Connect the server
+      def connect
+        @signature = EventMachine.start_server(@host, @port, Connection, &method(:initialize_connection))
+      end
+      
+      # Stops the server
+      def disconnect
+        EventMachine.stop_server(@signature)
+      end
+            
+      def to_s
+        "#{@host}:#{@port}"
+      end
+    end
+  end
+end
\ No newline at end of file
diff --git a/vendor/gems/gems/thin-1.2.5/lib/thin/backends/unix_server.rb b/vendor/gems/gems/thin-1.2.5/lib/thin/backends/unix_server.rb
new file mode 100755
index 00000000..bf81b875
--- /dev/null
+++ b/vendor/gems/gems/thin-1.2.5/lib/thin/backends/unix_server.rb
@@ -0,0 +1,51 @@
+module Thin
+  module Backends
+    # Backend to act as a UNIX domain socket server.
+    class UnixServer < Base
+      # UNIX domain socket on which the server is listening for connections.
+      attr_accessor :socket
+      
+      def initialize(socket)
+        raise PlatformNotSupported, 'UNIX domain sockets not available on Windows' if Thin.win?
+        @socket = socket
+        super()
+      end
+      
+      # Connect the server
+      def connect
+        at_exit { remove_socket_file } # In case it crashes
+        EventMachine.start_unix_domain_server(@socket, UnixConnection, &method(:initialize_connection))
+        # HACK EventMachine.start_unix_domain_server doesn't return the connection signature
+        #      so we have to go in the internal stuff to find it.
+        @signature = EventMachine.instance_eval{@acceptors.keys.first}
+      end
+      
+      # Stops the server
+      def disconnect
+        EventMachine.stop_server(@signature)
+      end
+      
+      # Free up resources used by the backend.
+      def close
+        remove_socket_file
+      end
+      
+      def to_s
+        @socket
+      end
+      
+      protected
+        def remove_socket_file
+          File.delete(@socket) if @socket && File.exist?(@socket)
+        end
+    end    
+  end
+
+  # Connection through a UNIX domain socket.
+  class UnixConnection < Connection
+    protected
+      def socket_address        
+        '127.0.0.1' # Unix domain sockets can only be local
+      end
+  end
+end
\ No newline at end of file
diff --git a/vendor/gems/gems/thin-1.2.5/lib/thin/command.rb b/vendor/gems/gems/thin-1.2.5/lib/thin/command.rb
new file mode 100755
index 00000000..798b1fca
--- /dev/null
+++ b/vendor/gems/gems/thin-1.2.5/lib/thin/command.rb
@@ -0,0 +1,53 @@
+require 'open3'
+
+module Thin
+  # Run a command through the +thin+ command-line script.
+  class Command
+    include Logging
+    
+    class << self
+      # Path to the +thin+ script used to control the servers.
+      # Leave this to default to use the one in the path.
+      attr_accessor :script
+    end
+    
+    def initialize(name, options={})
+      @name    = name
+      @options = options
+    end
+    
+    def self.run(*args)
+      new(*args).run
+    end
+    
+    # Send the command to the +thin+ script
+    def run
+      shell_cmd = shellify
+      trace shell_cmd
+      trap('INT') {} # Ignore INT signal to pass CTRL+C to subprocess
+      Open3.popen3(shell_cmd) do |stdin, stdout, stderr|
+        log stdout.gets until stdout.eof?
+        log stderr.gets until stderr.eof?
+      end
+    end
+    
+    # Turn into a runnable shell command
+    def shellify
+      shellified_options = @options.inject([]) do |args, (name, value)|
+        option_name = name.to_s.tr("_", "-")
+        case value
+        when NilClass,
+             TrueClass then args << "--#{option_name}"
+        when FalseClass
+        when Array     then value.each { |v| args << "--#{option_name}=#{v.inspect}" }
+        else                args << "--#{option_name}=#{value.inspect}"
+        end
+        args
+      end
+      
+      raise ArgumentError, "Path to thin script can't be found, set Command.script" unless self.class.script
+      
+      "#{self.class.script} #{@name} #{shellified_options.compact.join(' ')}"
+    end
+  end
+end
diff --git a/vendor/gems/gems/thin-1.2.5/lib/thin/connection.rb b/vendor/gems/gems/thin-1.2.5/lib/thin/connection.rb
new file mode 100755
index 00000000..7ead989a
--- /dev/null
+++ b/vendor/gems/gems/thin-1.2.5/lib/thin/connection.rb
@@ -0,0 +1,222 @@
+require 'socket'
+
+module Thin
+  # Connection between the server and client.
+  # This class is instanciated by EventMachine on each new connection
+  # that is opened.
+  class Connection < EventMachine::Connection
+    CONTENT_LENGTH    = 'Content-Length'.freeze
+    TRANSFER_ENCODING = 'Transfer-Encoding'.freeze
+    CHUNKED_REGEXP    = /\bchunked\b/i.freeze
+
+    include Logging
+    
+    # This is a template async response. N.B. Can't use string for body on 1.9
+    AsyncResponse = [-1, {}, []].freeze
+    
+    # Rack application (adapter) served by this connection.
+    attr_accessor :app
+
+    # Backend to the server
+    attr_accessor :backend
+
+    # Current request served by the connection
+    attr_accessor :request
+
+    # Next response sent through the connection
+    attr_accessor :response
+
+    # Calling the application in a threaded allowing
+    # concurrent processing of requests.
+    attr_writer :threaded
+
+    # Get the connection ready to process a request.
+    def post_init
+      @request  = Request.new
+      @response = Response.new
+    end
+
+    # Called when data is received from the client.
+    def receive_data(data)
+      trace { data }
+      process if @request.parse(data)
+    rescue InvalidRequest => e
+      log "!! Invalid request"
+      log_error e
+      close_connection
+    end
+
+    # Called when all data was received and the request
+    # is ready to be processed.
+    def process
+      if threaded?
+        @request.threaded = true
+        EventMachine.defer(method(:pre_process), method(:post_process))
+      else
+        @request.threaded = false
+        post_process(pre_process)
+      end
+    end
+
+    def pre_process
+      # Add client info to the request env
+      @request.remote_address = remote_address
+
+      # Connection may be closed unless the App#call response was a [-1, ...]
+      # It should be noted that connection objects will linger until this 
+      # callback is no longer referenced, so be tidy!
+      @request.async_callback = method(:post_process)
+      
+      # When we're under a non-async framework like rails, we can still spawn
+      # off async responses using the callback info, so there's little point
+      # in removing this.
+      response = AsyncResponse
+      catch(:async) do
+        # Process the request calling the Rack adapter
+        response = @app.call(@request.env)
+      end
+      response
+    rescue Exception
+      handle_error
+      terminate_request
+      nil # Signal to post_process that the request could not be processed
+    end
+
+    def post_process(result)
+      return unless result
+      result = result.to_a
+      
+      # Status code -1 indicates that we're going to respond later (async).
+      return if result.first == AsyncResponse.first
+
+      # Set the Content-Length header if possible
+      set_content_length(result) if need_content_length?(result)
+      
+      @response.status, @response.headers, @response.body = *result
+
+      log "!! Rack application returned nil body. Probably you wanted it to be an empty string?" if @response.body.nil?
+
+      # Make the response persistent if requested by the client
+      @response.persistent! if @request.persistent?
+
+      # Send the response
+      @response.each do |chunk|
+        trace { chunk }
+        send_data chunk
+      end
+
+    rescue Exception
+      handle_error
+    ensure
+      # If the body is being deferred, then terminate afterward.
+      if @response.body.respond_to?(:callback) && @response.body.respond_to?(:errback)
+        @response.body.callback { terminate_request }
+        @response.body.errback  { terminate_request }
+      else
+        # Don't terminate the response if we're going async.
+        terminate_request unless result && result.first == AsyncResponse.first
+      end
+    end
+
+    # Logs catched exception and closes the connection.
+    def handle_error
+      log "!! Unexpected error while processing request: #{$!.message}"
+      log_error
+      close_connection rescue nil
+    end
+
+    def close_request_response
+      @request.async_close.succeed if @request.async_close
+      @request.close  rescue nil
+      @response.close rescue nil
+    end
+
+    # Does request and response cleanup (closes open IO streams and
+    # deletes created temporary files).
+    # Re-initializes response and request if client supports persistent
+    # connection.
+    def terminate_request
+      unless persistent?
+        close_connection_after_writing rescue nil
+        close_request_response
+      else
+        close_request_response
+        # Prepare the connection for another request if the client
+        # supports HTTP pipelining (persistent connection).
+        post_init
+      end
+    end
+
+    # Called when the connection is unbinded from the socket
+    # and can no longer be used to process requests.
+    def unbind
+      @request.async_close.succeed if @request.async_close
+      @response.body.fail if @response.body.respond_to?(:fail)
+      @backend.connection_finished(self)
+    end
+
+    # Allows this connection to be persistent.
+    def can_persist!
+      @can_persist = true
+    end
+
+    # Return +true+ if this connection is allowed to stay open and be persistent.
+    def can_persist?
+      @can_persist
+    end
+
+    # Return +true+ if the connection must be left open
+    # and ready to be reused for another request.
+    def persistent?
+      @can_persist && @response.persistent?
+    end
+
+    # +true+ if app.call will be called inside a thread.
+    # You can set all requests as threaded setting Connection#threaded=true
+    # or on a per-request case returning +true+ in app.deferred?.
+    def threaded?
+      @threaded || (@app.respond_to?(:deferred?) && @app.deferred?(@request.env))
+    end
+
+    # IP Address of the remote client.
+    def remote_address
+      socket_address
+    rescue Exception
+      log_error
+      nil
+    end
+
+    protected
+
+      # Returns IP address of peer as a string.
+      def socket_address
+        Socket.unpack_sockaddr_in(get_peername)[1]
+      end
+
+    private
+      def need_content_length?(result)
+        status, headers, body = result
+        return false if status == -1
+        return false if headers.has_key?(CONTENT_LENGTH)
+        return false if (100..199).include?(status) || status == 204 || status == 304
+        return false if headers.has_key?(TRANSFER_ENCODING) && headers[TRANSFER_ENCODING] =~ CHUNKED_REGEXP
+        return false unless body.kind_of?(String) || body.kind_of?(Array)
+        true
+      end
+
+      def set_content_length(result)
+        headers, body = result[1..2]
+        case body
+        when String
+          # See http://redmine.ruby-lang.org/issues/show/203
+          headers[CONTENT_LENGTH] = (body.respond_to?(:bytesize) ? body.bytesize : body.size).to_s
+        when Array
+           bytes = 0
+           body.each do |p|
+             bytes += p.respond_to?(:bytesize) ? p.bytesize : p.size
+           end
+           headers[CONTENT_LENGTH] = bytes.to_s
+        end
+      end
+  end
+end
diff --git a/vendor/gems/gems/thin-1.2.5/lib/thin/controllers/cluster.rb b/vendor/gems/gems/thin-1.2.5/lib/thin/controllers/cluster.rb
new file mode 100755
index 00000000..f8749f04
--- /dev/null
+++ b/vendor/gems/gems/thin-1.2.5/lib/thin/controllers/cluster.rb
@@ -0,0 +1,178 @@
+require 'socket'
+
+module Thin
+  # An exception class to handle the event that server didn't start on time
+  class RestartTimeout < RuntimeError; end
+  
+  module Controllers
+    # Control a set of servers.
+    # * Generate start and stop commands and run them.
+    # * Inject the port or socket number in the pid and log filenames.
+    # Servers are started throught the +thin+ command-line script.
+    class Cluster < Controller
+      # Cluster only options that should not be passed in the command sent
+      # to the indiviual servers.
+      CLUSTER_OPTIONS = [:servers, :only, :onebyone, :wait]
+      
+      # Maximum wait time for the server to be restarted
+      DEFAULT_WAIT_TIME = 30    # seconds
+      
+      # Create a new cluster of servers launched using +options+.
+      def initialize(options)
+        super
+        # Cluster can only contain daemonized servers
+        @options.merge!(:daemonize => true)
+      end
+      
+      def first_port; @options[:port]     end
+      def address;    @options[:address]  end
+      def socket;     @options[:socket]   end
+      def pid_file;   @options[:pid]      end
+      def log_file;   @options[:log]      end
+      def size;       @options[:servers]  end
+      def only;       @options[:only]     end
+      def onebyone;   @options[:onebyone] end
+      def wait;       @options[:wait]     end
+      
+      def swiftiply?
+        @options.has_key?(:swiftiply)
+      end
+    
+      # Start the servers
+      def start
+        with_each_server { |n| start_server n }
+      end
+    
+      # Start a single server
+      def start_server(number)
+        log "Starting server on #{server_id(number)} ... "
+      
+        run :start, number
+      end
+  
+      # Stop the servers
+      def stop
+        with_each_server { |n| stop_server n }
+      end
+    
+      # Stop a single server
+      def stop_server(number)
+        log "Stopping server on #{server_id(number)} ... "
+      
+        run :stop, number
+      end
+    
+      # Stop and start the servers.
+      def restart
+        unless onebyone
+          # Let's do a normal restart by defaults
+          stop
+          sleep 0.1 # Let's breath a bit shall we ?
+          start
+        else
+          with_each_server do |n| 
+            stop_server(n)
+            sleep 0.1 # Let's breath a bit shall we ?
+            start_server(n)
+            wait_until_server_started(n)
+          end
+        end
+      end
+      
+      def test_socket(number)
+        if socket
+          UNIXSocket.new(socket_for(number))
+        else
+          TCPSocket.new(address, number)
+        end
+      rescue
+        nil
+      end
+      
+      # Make sure the server is running before moving on to the next one.
+      def wait_until_server_started(number)
+        log "Waiting for server to start ..."
+        STDOUT.flush # Need this to make sure user got the message
+        
+        tries = 0
+        loop do
+          if test_socket = test_socket(number)
+            test_socket.close
+            break
+          elsif tries < wait
+            sleep 1
+            tries += 1
+          else
+            raise RestartTimeout, "The server didn't start in time. Please look at server's log file " +
+                                  "for more information, or set the value of 'wait' in your config " +
+                                  "file to be higher (defaults: 30)."
+          end
+        end
+      end
+    
+      def server_id(number)
+        if socket
+          socket_for(number)
+        elsif swiftiply?
+          [address, first_port, number].join(':')
+        else
+          [address, number].join(':')
+        end
+      end
+    
+      def log_file_for(number)
+        include_server_number log_file, number
+      end
+    
+      def pid_file_for(number)
+        include_server_number pid_file, number
+      end
+    
+      def socket_for(number)
+        include_server_number socket, number
+      end
+    
+      def pid_for(number)
+        File.read(pid_file_for(number)).chomp.to_i
+      end
+      
+      private
+        # Send the command to the +thin+ script
+        def run(cmd, number)
+          cmd_options = @options.reject { |option, value| CLUSTER_OPTIONS.include?(option) }
+          cmd_options.merge!(:pid => pid_file_for(number), :log => log_file_for(number))
+          if socket
+            cmd_options.merge!(:socket => socket_for(number))
+          elsif swiftiply?
+            cmd_options.merge!(:port => first_port)
+          else
+            cmd_options.merge!(:port => number)
+          end
+          Command.run(cmd, cmd_options)
+        end
+      
+        def with_each_server
+          if only
+            if first_port && only < 80
+              # interpret +only+ as a sequence number
+              yield first_port + only
+            else
+              # interpret +only+ as an absolute port number
+              yield only
+            end
+          elsif socket || swiftiply?
+            size.times { |n| yield n }
+          else
+            size.times { |n| yield first_port + n }
+          end
+        end
+      
+        # Add the server port or number in the filename
+        # so each instance get its own file
+        def include_server_number(path, number)
+          ext = File.extname(path)
+          path.gsub(/#{ext}$/, ".#{number}#{ext}")
+        end
+    end
+  end
+end
\ No newline at end of file
diff --git a/vendor/gems/gems/thin-1.2.5/lib/thin/controllers/controller.rb b/vendor/gems/gems/thin-1.2.5/lib/thin/controllers/controller.rb
new file mode 100755
index 00000000..6cece408
--- /dev/null
+++ b/vendor/gems/gems/thin-1.2.5/lib/thin/controllers/controller.rb
@@ -0,0 +1,183 @@
+require 'yaml'
+
+module Thin
+  # Error raised that will abort the process and print not backtrace.
+  class RunnerError < RuntimeError; end
+  
+  # Raised when a mandatory option is missing to run a command.
+  class OptionRequired < RunnerError
+    def initialize(option)
+      super("#{option} option required")
+    end
+  end
+  
+  # Raised when an option is not valid.
+  class InvalidOption < RunnerError; end
+  
+  # Build and control Thin servers.
+  # Hey Controller pattern is not only for web apps yo!
+  module Controllers  
+    # Controls one Thin server.
+    # Allow to start, stop, restart and configure a single thin server.
+    class Controller
+      include Logging
+    
+      # Command line options passed to the thin script
+      attr_accessor :options
+    
+      def initialize(options)
+        @options = options
+        
+        if @options[:socket]
+          @options.delete(:address)
+          @options.delete(:port)
+        end
+      end
+    
+      def start
+        # Constantize backend class
+        @options[:backend] = eval(@options[:backend], TOPLEVEL_BINDING) if @options[:backend]
+        
+        server = Server.new(@options[:socket] || @options[:address], # Server detects kind of socket
+                            @options[:port],                         # Port ignored on UNIX socket
+                            @options)
+        
+        # Set options
+        server.pid_file                       = @options[:pid]
+        server.log_file                       = @options[:log]
+        server.timeout                        = @options[:timeout]
+        server.maximum_connections            = @options[:max_conns]
+        server.maximum_persistent_connections = @options[:max_persistent_conns]
+        server.threaded                       = @options[:threaded]
+        server.no_epoll                       = @options[:no_epoll] if server.backend.respond_to?(:no_epoll=)
+
+        # Detach the process, after this line the current process returns
+        server.daemonize if @options[:daemonize]
+
+        # +config+ must be called before changing privileges since it might require superuser power.
+        server.config
+        
+        server.change_privilege @options[:user], @options[:group] if @options[:user] && @options[:group]
+
+        # If a Rack config file is specified we eval it inside a Rack::Builder block to create
+        # a Rack adapter from it. Or else we guess which adapter to use and load it.
+        if @options[:rackup]
+          server.app = load_rackup_config
+        else
+          server.app = load_adapter
+        end
+
+        # If a prefix is required, wrap in Rack URL mapper
+        server.app = Rack::URLMap.new(@options[:prefix] => server.app) if @options[:prefix]
+
+        # If a stats URL is specified, wrap in Stats adapter
+        server.app = Stats::Adapter.new(server.app, @options[:stats]) if @options[:stats]
+
+        # Register restart procedure which just start another process with same options,
+        # so that's why this is done here.
+        server.on_restart { Command.run(:start, @options) }
+
+        server.start
+      end
+    
+      def stop
+        raise OptionRequired, :pid unless @options[:pid]
+      
+        tail_log(@options[:log]) do
+          if Server.kill(@options[:pid], @options[:force] ? 0 : (@options[:timeout] || 60))
+            wait_for_file :deletion, @options[:pid]
+          end
+        end
+      end
+    
+      def restart
+        raise OptionRequired, :pid unless @options[:pid]
+        
+        tail_log(@options[:log]) do
+          if Server.restart(@options[:pid])
+            wait_for_file :creation, @options[:pid]
+          end
+        end
+      end
+    
+      def config
+        config_file = @options.delete(:config) || raise(OptionRequired, :config)
+
+        # Stringify keys
+        @options.keys.each { |o| @options[o.to_s] = @options.delete(o) }
+
+        File.open(config_file, 'w') { |f| f << @options.to_yaml }
+        log ">> Wrote configuration to #{config_file}"
+      end
+      
+      protected
+        # Wait for a pid file to either be created or deleted.
+        def wait_for_file(state, file)
+          Timeout.timeout(@options[:timeout] || 30) do
+            case state
+            when :creation then sleep 0.1 until File.exist?(file)
+            when :deletion then sleep 0.1 while File.exist?(file)
+            end
+          end
+        end
+        
+        # Tail the log file of server +number+ during the execution of the block.        
+        def tail_log(log_file)
+          if log_file
+            tail_thread = tail(log_file)
+            yield
+            tail_thread.kill
+          else
+            yield
+          end
+        end
+        
+        # Acts like GNU tail command. Taken from Rails.
+        def tail(file)
+          cursor = File.exist?(file) ? File.size(file) : 0
+          last_checked = Time.now
+          tail_thread = Thread.new do
+            Thread.pass until File.exist?(file)
+            File.open(file, 'r') do |f|
+              loop do
+                f.seek cursor
+                if f.mtime > last_checked
+                  last_checked = f.mtime
+                  contents = f.read
+                  cursor += contents.length
+                  print contents
+                  STDOUT.flush
+                end
+                sleep 0.1
+              end
+            end
+          end
+          sleep 1 if File.exist?(file) # HACK Give the thread a little time to open the file
+          tail_thread
+        end
+
+      private
+        def load_adapter
+          adapter = @options[:adapter] || Rack::Adapter.guess(@options[:chdir])
+          log ">> Using #{adapter} adapter"
+          Rack::Adapter.for(adapter, @options)
+        rescue Rack::AdapterNotFound => e
+          raise InvalidOption, e.message
+        end
+        
+        def load_rackup_config
+          ENV['RACK_ENV'] = @options[:environment]
+          case @options[:rackup]
+          when /\.rb$/
+            Kernel.load(@options[:rackup])
+            Object.const_get(File.basename(@options[:rackup], '.rb').capitalize.to_sym)
+          when /\.ru$/
+            rackup_code = File.read(@options[:rackup])
+            eval("Rack::Builder.new {( #{rackup_code}\n )}.to_app", TOPLEVEL_BINDING, @options[:rackup])
+          else
+            raise "Invalid rackup file.  please specify either a .ru or .rb file"
+          end
+        end
+    end
+  end
+end
\ No newline at end of file
diff --git a/vendor/gems/gems/thin-1.2.5/lib/thin/controllers/service.rb b/vendor/gems/gems/thin-1.2.5/lib/thin/controllers/service.rb
new file mode 100755
index 00000000..540e6595
--- /dev/null
+++ b/vendor/gems/gems/thin-1.2.5/lib/thin/controllers/service.rb
@@ -0,0 +1,75 @@
+require 'erb'
+
+module Thin
+  module Controllers
+    # System service controller to launch all servers which
+    # config files are in a directory.
+    class Service < Controller
+      INITD_PATH          = '/etc/init.d/thin'
+      DEFAULT_CONFIG_PATH = '/etc/thin'
+      TEMPLATE            = File.dirname(__FILE__) + '/service.sh.erb'
+    
+      def initialize(options)
+        super
+      
+        raise PlatformNotSupported, 'Running as a service only supported on Linux' unless Thin.linux?
+      end
+    
+      def config_path
+        @options[:all] || DEFAULT_CONFIG_PATH
+      end
+    
+      def start
+        run :start
+      end
+    
+      def stop
+        run :stop
+      end
+    
+      def restart
+        run :restart
+      end
+    
+      def install(config_files_path=DEFAULT_CONFIG_PATH)
+        if File.exist?(INITD_PATH)
+          log ">> Thin service already installed at #{INITD_PATH}"
+        else
+          log ">> Installing thin service at #{INITD_PATH} ..."
+          sh "mkdir -p #{File.dirname(INITD_PATH)}"
+          log "writing #{INITD_PATH}"        
+          File.open(INITD_PATH, 'w') do |f|
+            f << ERB.new(File.read(TEMPLATE)).result(binding)
+          end
+          sh "chmod +x #{INITD_PATH}" # Make executable
+        end
+      
+        sh "mkdir -p #{config_files_path}"
+
+        log ''
+        log "To configure thin to start at system boot:"
+        log "on RedHat like systems:"
+        log "  sudo /sbin/chkconfig --level 345 #{NAME} on"
+        log "on Debian-like systems (Ubuntu):"
+        log "  sudo /usr/sbin/update-rc.d -f #{NAME} defaults"
+        log "on Gentoo:"
+        log "  sudo rc-update add #{NAME} default"
+        log ''
+        log "Then put your config files in #{config_files_path}"
+      end
+    
+      private
+        def run(command)
+          Dir[config_path + '/*'].each do |config|
+            log "[#{command}] #{config} ..."
+            Command.run(command, :config => config, :daemonize => true)
+          end
+        end
+      
+        def sh(cmd)
+          log cmd
+          system(cmd)
+        end
+    end
+  end
+end
\ No newline at end of file
diff --git a/vendor/gems/gems/thin-1.2.5/lib/thin/controllers/service.sh.erb b/vendor/gems/gems/thin-1.2.5/lib/thin/controllers/service.sh.erb
new file mode 100755
index 00000000..5b96548c
--- /dev/null
+++ b/vendor/gems/gems/thin-1.2.5/lib/thin/controllers/service.sh.erb
@@ -0,0 +1,39 @@
+#!/bin/sh
+### BEGIN INIT INFO
+# Provides:          thin
+# Required-Start:    $local_fs $remote_fs
+# Required-Stop:     $local_fs $remote_fs
+# Default-Start:     2 3 4 5
+# Default-Stop:      S 0 1 6
+# Short-Description: thin initscript
+# Description:       thin
+### END INIT INFO
+
+# Original author: Forrest Robertson
+
+# Do NOT "set -e"
+
+DAEMON=<%= Command.script %>
+SCRIPT_NAME=<%= INITD_PATH %>
+CONFIG_PATH=<%= config_files_path %>
+
+# Exit if the package is not installed
+[ -x "$DAEMON" ] || exit 0
+
+case "$1" in
+  start)
+	$DAEMON start --all $CONFIG_PATH
+	;;
+  stop)
+	$DAEMON stop --all $CONFIG_PATH
+	;;
+  restart)
+	$DAEMON restart --all $CONFIG_PATH
+	;;
+  *)
+	echo "Usage: $SCRIPT_NAME {start|stop|restart}" >&2
+	exit 3
+	;;
+esac
+
+:
diff --git a/vendor/gems/gems/thin-1.2.5/lib/thin/daemonizing.rb b/vendor/gems/gems/thin-1.2.5/lib/thin/daemonizing.rb
new file mode 100755
index 00000000..2f127278
--- /dev/null
+++ b/vendor/gems/gems/thin-1.2.5/lib/thin/daemonizing.rb
@@ -0,0 +1,174 @@
+require 'etc'
+require 'daemons' unless Thin.win?
+
+module Process
+  # Returns +true+ the process identied by +pid+ is running.
+  def running?(pid)
+    Process.getpgid(pid) != -1
+  rescue Errno::ESRCH
+    false
+  end
+  module_function :running?
+end
+
+module Thin
+  # Raised when the pid file already exist starting as a daemon.
+  class PidFileExist < RuntimeError; end
+  
+  # Module included in classes that can be turned into a daemon.
+  # Handle stuff like:
+  # * storing the PID in a file
+  # * redirecting output to the log file
+  # * changing processs privileges
+  # * killing the process gracefully
+  module Daemonizable
+    attr_accessor :pid_file, :log_file
+    
+    def self.included(base)
+      base.extend ClassMethods
+    end
+    
+    def pid
+      File.exist?(pid_file) ? open(pid_file).read.to_i : nil
+    end
+    
+    # Turns the current script into a daemon process that detaches from the console.
+    def daemonize
+      raise PlatformNotSupported, 'Daemonizing is not supported on Windows'     if Thin.win?
+      raise ArgumentError,        'You must specify a pid_file to daemonize' unless @pid_file
+
+      remove_stale_pid_file
+      
+      pwd = Dir.pwd # Current directory is changed during daemonization, so store it
+      
+      Daemonize.daemonize(File.expand_path(@log_file), name)
+      
+      Dir.chdir(pwd)
+      
+      write_pid_file
+      
+      trap('HUP') { restart }
+      at_exit do
+        log ">> Exiting!"
+        remove_pid_file
+      end
+    end
+
+    # Change privileges of the process
+    # to the specified user and group.
+    def change_privilege(user, group=user)
+      log ">> Changing process privilege to #{user}:#{group}"
+      
+      uid, gid = Process.euid, Process.egid
+      target_uid = Etc.getpwnam(user).uid
+      target_gid = Etc.getgrnam(group).gid
+
+      if uid != target_uid || gid != target_gid
+        # Change process ownership
+        Process.initgroups(user, target_gid)
+        Process::GID.change_privilege(target_gid)
+        Process::UID.change_privilege(target_uid)
+      end
+    rescue Errno::EPERM => e
+      log "Couldn't change user and group to #{user}:#{group}: #{e}"
+    end
+    
+    # Register a proc to be called to restart the server.
+    def on_restart(&block)
+      @on_restart = block
+    end
+    
+    # Restart the server.
+    def restart
+      raise ArgumentError, "Can't restart, no 'on_restart' proc specified" unless @on_restart
+      log '>> Restarting ...'
+      stop
+      remove_pid_file
+      @on_restart.call
+      exit!
+    end
+    
+    module ClassMethods
+      # Send a QUIT or INT (if timeout is +0+) signal the process which
+      # PID is stored in +pid_file+.
+      # If the process is still running after +timeout+, KILL signal is
+      # sent.
+      def kill(pid_file, timeout=60)
+        if timeout == 0
+          send_signal('INT', pid_file, timeout)
+        else
+          send_signal('QUIT', pid_file, timeout)
+        end
+      end
+      
+      # Restart the server by sending HUP signal.
+      def restart(pid_file)
+        send_signal('HUP', pid_file)
+      end
+      
+      # Send a +signal+ to the process which PID is stored in +pid_file+.
+      def send_signal(signal, pid_file, timeout=60)
+        if pid = read_pid_file(pid_file)
+          Logging.log "Sending #{signal} signal to process #{pid} ... "
+          Process.kill(signal, pid)
+          Timeout.timeout(timeout) do
+            sleep 0.1 while Process.running?(pid)
+          end
+        else
+          Logging.log "Can't stop process, no PID found in #{pid_file}"
+        end
+      rescue Timeout::Error
+        Logging.log "Timeout!"
+        force_kill pid_file
+      rescue Interrupt
+        force_kill pid_file
+      rescue Errno::ESRCH # No such process
+        Logging.log "process not found!"
+        force_kill pid_file
+      end
+      
+      def force_kill(pid_file)
+        if pid = read_pid_file(pid_file)
+          Logging.log "Sending KILL signal to process #{pid} ... "
+          Process.kill("KILL", pid)
+          File.delete(pid_file) if File.exist?(pid_file)
+        else
+          Logging.log "Can't stop process, no PID found in #{pid_file}"
+        end
+      end
+      
+      def read_pid_file(file)
+        if File.file?(file) && pid = File.read(file)
+          pid.to_i
+        else
+          nil
+        end
+      end
+    end
+    
+    protected
+      def remove_pid_file
+        File.delete(@pid_file) if @pid_file && File.exists?(@pid_file)
+      end
+    
+      def write_pid_file
+        log ">> Writing PID to #{@pid_file}"
+        FileUtils.mkdir_p File.dirname(@pid_file)
+        open(@pid_file,"w") { |f| f.write(Process.pid) }
+        File.chmod(0644, @pid_file)
+      end
+      
+      # If PID file is stale, remove it.
+      def remove_stale_pid_file
+        if File.exist?(@pid_file)
+          if pid && Process.running?(pid)
+            raise PidFileExist, "#{@pid_file} already exists, seems like it's already running (process ID: #{pid}). " +
+                                "Stop the process or delete #{@pid_file}."
+          else
+            log ">> Deleting stale PID file #{@pid_file}"
+            remove_pid_file
+          end
+        end
+      end
+  end
+end
diff --git a/vendor/gems/gems/thin-1.2.5/lib/thin/headers.rb b/vendor/gems/gems/thin-1.2.5/lib/thin/headers.rb
new file mode 100755
index 00000000..3e1b9cc3
--- /dev/null
+++ b/vendor/gems/gems/thin-1.2.5/lib/thin/headers.rb
@@ -0,0 +1,39 @@
+module Thin
+  # Store HTTP header name-value pairs direcly to a string
+  # and allow duplicated entries on some names.
+  class Headers
+    HEADER_FORMAT      = "%s: %s\r\n".freeze
+    ALLOWED_DUPLICATES = %w(Set-Cookie Set-Cookie2 Warning WWW-Authenticate).freeze
+    
+    def initialize
+      @sent = {}
+      @out = []
+    end
+    
+    # Add key: value pair to the headers.
+    # Ignore if already sent and no duplicates are allowed
+    # for this +key+.
+    def []=(key, value)
+      if !@sent.has_key?(key) || ALLOWED_DUPLICATES.include?(key)
+        @sent[key] = true
+        value = case value
+                when Time
+                  value.httpdate
+                when NilClass
+                  return
+                else
+                  value.to_s
+                end
+        @out << HEADER_FORMAT % [key, value]
+      end
+    end
+    
+    def has_key?(key)
+      @sent[key]
+    end
+    
+    def to_s
+      @out.join
+    end
+  end
+end
\ No newline at end of file
diff --git a/vendor/gems/gems/thin-1.2.5/lib/thin/logging.rb b/vendor/gems/gems/thin-1.2.5/lib/thin/logging.rb
new file mode 100755
index 00000000..2a998274
--- /dev/null
+++ b/vendor/gems/gems/thin-1.2.5/lib/thin/logging.rb
@@ -0,0 +1,54 @@
+module Thin
+  # To be included in classes to allow some basic logging
+  # that can be silenced (Logging.silent=) or made
+  # more verbose.
+  # Logging.debug=: log all error backtrace and messages
+  #                          logged with +debug+.
+  # Logging.trace=: log all raw request and response and
+  #                          messages logged with +trace+.
+  module Logging
+    class << self
+      attr_writer :trace, :debug, :silent
+      
+      def trace?;  !@silent && @trace  end
+      def debug?;  !@silent && @debug  end
+      def silent?;  @silent            end
+    end
+    
+    # Global silencer methods
+    def silent
+      Logging.silent?
+    end
+    def silent=(value)
+      Logging.silent = value
+    end
+    
+    # Log a message to the console
+    def log(msg)
+      puts msg unless Logging.silent?
+    end
+    module_function :log
+    public :log
+    
+    # Log a message to the console if tracing is activated
+    def trace(msg=nil)
+      log msg || yield if Logging.trace?
+    end
+    module_function :trace
+    public :trace
+    
+    # Log a message to the console if debugging is activated
+    def debug(msg=nil)
+      log msg || yield if Logging.debug?
+    end
+    module_function :debug
+    public :debug
+    
+    # Log an error backtrace if debugging is activated
+    def log_error(e=$!)
+      debug "#{e}\n\t" + e.backtrace.join("\n\t")
+    end
+    module_function :log_error
+    public :log_error
+  end
+end
\ No newline at end of file
diff --git a/vendor/gems/gems/thin-1.2.5/lib/thin/request.rb b/vendor/gems/gems/thin-1.2.5/lib/thin/request.rb
new file mode 100755
index 00000000..7b982dae
--- /dev/null
+++ b/vendor/gems/gems/thin-1.2.5/lib/thin/request.rb
@@ -0,0 +1,157 @@
+require 'thin_parser'
+require 'tempfile'
+
+module Thin
+  # Raised when an incoming request is not valid
+  # and the server can not process it.
+  class InvalidRequest < IOError; end
+
+  # A request sent by the client to the server.
+  class Request
+    # Maximum request body size before it is moved out of memory
+    # and into a tempfile for reading.
+    MAX_BODY          = 1024 * (80 + 32)
+    BODY_TMPFILE      = 'thin-body'.freeze
+    MAX_HEADER        = 1024 * (80 + 32)
+    
+    INITIAL_BODY      = ''
+    # Force external_encoding of request's body to ASCII_8BIT
+    INITIAL_BODY.encode!(Encoding::ASCII_8BIT) if INITIAL_BODY.respond_to?(:encode)
+    
+    # Freeze some HTTP header names & values
+    SERVER_SOFTWARE   = 'SERVER_SOFTWARE'.freeze
+    SERVER_NAME       = 'SERVER_NAME'.freeze
+    LOCALHOST         = 'localhost'.freeze
+    HTTP_VERSION      = 'HTTP_VERSION'.freeze
+    HTTP_1_0          = 'HTTP/1.0'.freeze
+    REMOTE_ADDR       = 'REMOTE_ADDR'.freeze
+    CONTENT_LENGTH    = 'CONTENT_LENGTH'.freeze
+    CONNECTION        = 'HTTP_CONNECTION'.freeze
+    KEEP_ALIVE_REGEXP = /\bkeep-alive\b/i.freeze
+    CLOSE_REGEXP      = /\bclose\b/i.freeze
+    
+    # Freeze some Rack header names
+    RACK_INPUT        = 'rack.input'.freeze
+    RACK_VERSION      = 'rack.version'.freeze
+    RACK_ERRORS       = 'rack.errors'.freeze
+    RACK_MULTITHREAD  = 'rack.multithread'.freeze
+    RACK_MULTIPROCESS = 'rack.multiprocess'.freeze
+    RACK_RUN_ONCE     = 'rack.run_once'.freeze
+    ASYNC_CALLBACK    = 'async.callback'.freeze
+    ASYNC_CLOSE       = 'async.close'.freeze
+
+    # CGI-like request environment variables
+    attr_reader :env
+
+    # Unparsed data of the request
+    attr_reader :data
+
+    # Request body
+    attr_reader :body
+
+    def initialize
+      @parser   = Thin::HttpParser.new
+      @data     = ''
+      @nparsed  = 0
+      @body     = StringIO.new(INITIAL_BODY.dup)
+      @env      = {
+        SERVER_SOFTWARE   => SERVER,
+        SERVER_NAME       => LOCALHOST,
+
+        # Rack stuff
+        RACK_INPUT        => @body,
+
+        RACK_VERSION      => VERSION::RACK,
+        RACK_ERRORS       => STDERR,
+
+        RACK_MULTITHREAD  => false,
+        RACK_MULTIPROCESS => false,
+        RACK_RUN_ONCE     => false
+      }
+    end
+
+    # Parse a chunk of data into the request environment
+    # Raises a +InvalidRequest+ if invalid.
+    # Returns +true+ if the parsing is complete.
+    def parse(data)
+      if @parser.finished?  # Header finished, can only be some more body
+        body << data
+      else                  # Parse more header using the super parser
+        @data << data
+        raise InvalidRequest, 'Header longer than allowed' if @data.size > MAX_HEADER
+
+        @nparsed = @parser.execute(@env, @data, @nparsed)
+
+        # Transfert to a tempfile if body is very big
+        move_body_to_tempfile if @parser.finished? && content_length > MAX_BODY
+      end
+
+
+      if finished?   # Check if header and body are complete
+        @data = nil
+        @body.rewind
+        true         # Request is fully parsed
+      else
+        false        # Not finished, need more data
+      end
+    end
+
+    # +true+ if headers and body are finished parsing
+    def finished?
+      @parser.finished? && @body.size >= content_length
+    end
+
+    # Expected size of the body
+    def content_length
+      @env[CONTENT_LENGTH].to_i
+    end
+
+    # Returns +true+ if the client expect the connection to be persistent.
+    def persistent?
+      # Clients and servers SHOULD NOT assume that a persistent connection
+      # is maintained for HTTP versions less than 1.1 unless it is explicitly
+      # signaled. (http://www.w3.org/Protocols/rfc2616/rfc2616-sec8.html)
+      if @env[HTTP_VERSION] == HTTP_1_0
+        @env[CONNECTION] =~ KEEP_ALIVE_REGEXP
+
+      # HTTP/1.1 client intends to maintain a persistent connection unless
+      # a Connection header including the connection-token "close" was sent
+      # in the request
+      else
+        @env[CONNECTION].nil? || @env[CONNECTION] !~ CLOSE_REGEXP
+      end
+    end
+
+    def remote_address=(address)
+      @env[REMOTE_ADDR] = address
+    end
+
+    def threaded=(value)
+      @env[RACK_MULTITHREAD] = value
+    end
+    
+    def async_callback=(callback)
+      @env[ASYNC_CALLBACK] = callback
+      @env[ASYNC_CLOSE] = EventMachine::DefaultDeferrable.new
+    end
+    
+    def async_close
+      @async_close ||= @env[ASYNC_CLOSE]
+    end
+
+    # Close any resource used by the request
+    def close
+      @body.delete if @body.class == Tempfile
+    end
+
+    private
+      def move_body_to_tempfile
+        current_body = @body
+        current_body.rewind
+        @body = Tempfile.new(BODY_TMPFILE)
+        @body.binmode
+        @body << current_body.read
+        @env[RACK_INPUT] = @body
+      end
+  end
+end
diff --git a/vendor/gems/gems/thin-1.2.5/lib/thin/response.rb b/vendor/gems/gems/thin-1.2.5/lib/thin/response.rb
new file mode 100755
index 00000000..0ff95784
--- /dev/null
+++ b/vendor/gems/gems/thin-1.2.5/lib/thin/response.rb
@@ -0,0 +1,101 @@
+module Thin
+  # A response sent to the client.
+  class Response
+    CONNECTION     = 'Connection'.freeze
+    CLOSE          = 'close'.freeze
+    KEEP_ALIVE     = 'keep-alive'.freeze
+    SERVER         = 'Server'.freeze
+    CONTENT_LENGTH = 'Content-Length'.freeze
+
+    # Status code
+    attr_accessor :status
+
+    # Response body, must respond to +each+.
+    attr_accessor :body
+
+    # Headers key-value hash
+    attr_reader   :headers
+
+    def initialize
+      @headers    = Headers.new
+      @status     = 200
+      @persistent = false
+    end
+
+    # String representation of the headers
+    # to be sent in the response.
+    def headers_output
+      # Set default headers
+      @headers[CONNECTION] = persistent? ? KEEP_ALIVE : CLOSE
+      @headers[SERVER]     = Thin::SERVER
+
+      @headers.to_s
+    end
+
+    # Top header of the response,
+    # containing the status code and response headers.
+    def head
+      "HTTP/1.1 #{@status} #{HTTP_STATUS_CODES[@status.to_i]}\r\n#{headers_output}\r\n"
+    end
+
+    if Thin.ruby_18?
+
+      # Ruby 1.8 implementation.
+      # Respects Rack specs.
+      #
+      # See http://rack.rubyforge.org/doc/files/SPEC.html
+      def headers=(key_value_pairs)
+        key_value_pairs.each do |k, vs|
+          vs.each { |v| @headers[k] = v.chomp } if vs
+        end if key_value_pairs
+      end
+
+    else
+
+      # Ruby 1.9 doesn't have a String#each anymore.
+      # Rack spec doesn't take care of that yet, for now we just use
+      # +each+ but fallback to +each_line+ on strings.
+      # I wish we could remove that condition.
+      # To be reviewed when a new Rack spec comes out.
+      def headers=(key_value_pairs)
+        key_value_pairs.each do |k, vs|
+          next unless vs
+          if vs.is_a?(String)
+            vs.each_line { |v| @headers[k] = v.chomp }
+          else
+            vs.each { |v| @headers[k] = v.chomp }
+          end
+        end if key_value_pairs
+      end
+
+    end
+
+    # Close any resource used by the response
+    def close
+      @body.close if @body.respond_to?(:close)
+    end
+
+    # Yields each chunk of the response.
+    # To control the size of each chunk
+    # define your own +each+ method on +body+.
+    def each
+      yield head
+      if @body.is_a?(String)
+        yield @body
+      else
+        @body.each { |chunk| yield chunk }
+      end
+    end
+
+    # Tell the client the connection should stay open
+    def persistent!
+      @persistent = true
+    end
+
+    # Persistent connection must be requested as keep-alive
+    # from the server and have a Content-Length.
+    def persistent?
+      @persistent && @headers.has_key?(CONTENT_LENGTH)
+    end
+  end
+end
diff --git a/vendor/gems/gems/thin-1.2.5/lib/thin/runner.rb b/vendor/gems/gems/thin-1.2.5/lib/thin/runner.rb
new file mode 100755
index 00000000..c91994c5
--- /dev/null
+++ b/vendor/gems/gems/thin-1.2.5/lib/thin/runner.rb
@@ -0,0 +1,212 @@
+require 'optparse'
+require 'yaml'
+
+module Thin  
+  # CLI runner.
+  # Parse options and send command to the correct Controller.
+  class Runner
+    COMMANDS            = %w(start stop restart config)
+    LINUX_ONLY_COMMANDS = %w(install)
+    
+    # Commands that wont load options from the config file
+    CONFIGLESS_COMMANDS = %w(config install)
+    
+    # Parsed options
+    attr_accessor :options
+    
+    # Name of the command to be runned.
+    attr_accessor :command
+    
+    # Arguments to be passed to the command.
+    attr_accessor :arguments
+    
+    # Return all available commands
+    def self.commands
+      commands  = COMMANDS
+      commands += LINUX_ONLY_COMMANDS if Thin.linux?
+      commands
+    end
+    
+    def initialize(argv)
+      @argv = argv
+      
+      # Default options values
+      @options = {
+        :chdir                => Dir.pwd,
+        :environment          => 'development',
+        :address              => '0.0.0.0',
+        :port                 => Server::DEFAULT_PORT,
+        :timeout              => Server::DEFAULT_TIMEOUT,
+        :log                  => 'log/thin.log',
+        :pid                  => 'tmp/pids/thin.pid',
+        :max_conns            => Server::DEFAULT_MAXIMUM_CONNECTIONS,
+        :max_persistent_conns => Server::DEFAULT_MAXIMUM_PERSISTENT_CONNECTIONS,
+        :require              => [],
+        :wait                 => Controllers::Cluster::DEFAULT_WAIT_TIME
+      }
+      
+      parse!
+    end
+    
+    def parser
+      # NOTE: If you add an option here make sure the key in the +options+ hash is the
+      # same as the name of the command line option.
+      # +option+ keys are used to build the command line to launch other processes,
+      # see lib/thin/command.rb.
+      @parser ||= OptionParser.new do |opts|
+        opts.banner = "Usage: thin [options] #{self.class.commands.join('|')}"
+
+        opts.separator ""
+        opts.separator "Server options:"
+
+        opts.on("-a", "--address HOST", "bind to HOST address " +
+                                        "(default: #{@options[:address]})")             { |host| @options[:address] = host }
+        opts.on("-p", "--port PORT", "use PORT (default: #{@options[:port]})")          { |port| @options[:port] = port.to_i }
+        opts.on("-S", "--socket FILE", "bind to unix domain socket")                    { |file| @options[:socket] = file }
+        opts.on("-y", "--swiftiply [KEY]", "Run using swiftiply")                       { |key| @options[:swiftiply] = key }
+        opts.on("-A", "--adapter NAME", "Rack adapter to use (default: autodetect)",
+                                        "(#{Rack::ADAPTERS.map{|(a,b)|a}.join(', ')})") { |name| @options[:adapter] = name }
+        opts.on("-R", "--rackup FILE", "Load a Rack config file instead of " +
+                                       "Rack adapter")                                  { |file| @options[:rackup] = file }
+        opts.on("-c", "--chdir DIR", "Change to dir before starting")                   { |dir| @options[:chdir] = File.expand_path(dir) }
+        opts.on(      "--stats PATH", "Mount the Stats adapter under PATH")             { |path| @options[:stats] = path }
+        
+        opts.separator ""
+        opts.separator "Adapter options:"
+        opts.on("-e", "--environment ENV", "Framework environment " +                       
+                                           "(default: #{@options[:environment]})")      { |env| @options[:environment] = env }
+        opts.on(      "--prefix PATH", "Mount the app under PATH (start with /)")       { |path| @options[:prefix] = path }
+        
+        unless Thin.win? # Daemonizing not supported on Windows
+          opts.separator ""
+          opts.separator "Daemon options:"
+                                                                                      
+          opts.on("-d", "--daemonize", "Run daemonized in the background")              { @options[:daemonize] = true }
+          opts.on("-l", "--log FILE", "File to redirect output " +                      
+                                      "(default: #{@options[:log]})")                   { |file| @options[:log] = file }
+          opts.on("-P", "--pid FILE", "File to store PID " +                            
+                                      "(default: #{@options[:pid]})")                   { |file| @options[:pid] = file }
+          opts.on("-u", "--user NAME", "User to run daemon as (use with -g)")           { |user| @options[:user] = user }
+          opts.on("-g", "--group NAME", "Group to run daemon as (use with -u)")         { |group| @options[:group] = group }
+          opts.on(      "--tag NAME", "Additional text to display in process listing")  { |tag| @options[:tag] = tag }
+                                                                                      
+          opts.separator ""
+          opts.separator "Cluster options:"                                             
+                                                                                      
+          opts.on("-s", "--servers NUM", "Number of servers to start")                  { |num| @options[:servers] = num.to_i }
+          opts.on("-o", "--only NUM", "Send command to only one server of the cluster") { |only| @options[:only] = only.to_i }
+          opts.on("-C", "--config FILE", "Load options from config file")               { |file| @options[:config] = file }
+          opts.on(      "--all [DIR]", "Send command to each config files in DIR")      { |dir| @options[:all] = dir } if Thin.linux?
+          opts.on("-O", "--onebyone", "Restart the cluster one by one (only works with restart command)") { @options[:onebyone] = true }
+          opts.on("-w", "--wait NUM", "Maximum wait time for server to be started in seconds (use with -O)") { |time| @options[:wait] = time.to_i }
+        end
+        
+        opts.separator ""
+        opts.separator "Tuning options:"
+        
+        opts.on("-b", "--backend CLASS", "Backend to use, full classname")              { |name| @options[:backend] = name }
+        opts.on("-t", "--timeout SEC", "Request or command timeout in sec " +            
+                                       "(default: #{@options[:timeout]})")              { |sec| @options[:timeout] = sec.to_i }
+        opts.on("-f", "--force", "Force the execution of the command")                  { @options[:force] = true }
+        opts.on(      "--max-conns NUM", "Maximum number of open file descriptors " +
+                                         "(default: #{@options[:max_conns]})",
+                                         "Might require sudo to set higher then 1024")  { |num| @options[:max_conns] = num.to_i } unless Thin.win?
+        opts.on(      "--max-persistent-conns NUM",
+                                       "Maximum number of persistent connections",
+                                       "(default: #{@options[:max_persistent_conns]})") { |num| @options[:max_persistent_conns] = num.to_i }
+        opts.on(      "--threaded", "Call the Rack application in threads " +
+                                    "[experimental]")                                   { @options[:threaded] = true }
+        opts.on(      "--no-epoll", "Disable the use of epoll")                         { @options[:no_epoll] = true } if Thin.linux?
+        
+        opts.separator ""
+        opts.separator "Common options:"
+
+        opts.on_tail("-r", "--require FILE", "require the library")                     { |file| @options[:require] << file }
+        opts.on_tail("-D", "--debug", "Set debbuging on")                               { @options[:debug] = true }
+        opts.on_tail("-V", "--trace", "Set tracing on (log raw request/response)")      { @options[:trace] = true }
+        opts.on_tail("-h", "--help", "Show this message")                               { puts opts; exit }
+        opts.on_tail('-v', '--version', "Show version")                                 { puts Thin::SERVER; exit }
+      end
+    end
+    
+    # Parse the options.
+    def parse!
+      parser.parse! @argv
+      @command   = @argv.shift
+      @arguments = @argv
+    end
+        
+    # Parse the current shell arguments and run the command.
+    # Exits on error.
+    def run!
+      if self.class.commands.include?(@command)
+        run_command
+      elsif @command.nil?
+        puts "Command required"
+        puts @parser
+        exit 1  
+      else
+        abort "Unknown command: #{@command}. Use one of #{self.class.commands.join(', ')}"
+      end
+    end
+    
+    # Send the command to the controller: single instance or cluster.
+    def run_command
+      load_options_from_config_file! unless CONFIGLESS_COMMANDS.include?(@command)
+      
+      # PROGRAM_NAME is relative to the current directory, so make sure
+      # we store and expand it before changing directory.
+      Command.script = File.expand_path($PROGRAM_NAME)
+      
+      # Change the current directory ASAP so that all relative paths are
+      # relative to this one.
+      Dir.chdir(@options[:chdir]) unless CONFIGLESS_COMMANDS.include?(@command)
+      
+      @options[:require].each { |r| ruby_require r }
+      Logging.debug = @options[:debug]
+      Logging.trace = @options[:trace]
+      
+      controller = case
+      when cluster? then Controllers::Cluster.new(@options)
+      when service? then Controllers::Service.new(@options)
+      else               Controllers::Controller.new(@options)
+      end
+      
+      if controller.respond_to?(@command)
+        begin
+          controller.send(@command, *@arguments)
+        rescue RunnerError => e
+          abort e.message
+        end
+      else
+        abort "Invalid options for command: #{@command}"
+      end
+    end
+    
+    # +true+ if we're controlling a cluster.
+    def cluster?
+      @options[:only] || @options[:servers] || @options[:config]
+    end
+    
+    # +true+ if we're acting a as system service.
+    def service?
+      @options.has_key?(:all) || @command == 'install'
+    end
+    
+    private
+      def load_options_from_config_file!
+        if file = @options.delete(:config)
+          YAML.load_file(file).each { |key, value| @options[key.to_sym] = value }
+        end
+      end
+      
+      def ruby_require(file)
+        if File.extname(file) == '.ru'
+          warn 'WARNING: Use the -R option to load a Rack config file'
+          @options[:rackup] = file
+        else
+          require file
+        end
+      end
+  end
+end
diff --git a/vendor/gems/gems/thin-1.2.5/lib/thin/server.rb b/vendor/gems/gems/thin-1.2.5/lib/thin/server.rb
new file mode 100755
index 00000000..852ee02c
--- /dev/null
+++ b/vendor/gems/gems/thin-1.2.5/lib/thin/server.rb
@@ -0,0 +1,247 @@
+module Thin
+  # The uterly famous Thin HTTP server.
+  # It listen for incoming request through a given +backend+
+  # and forward all request to +app+.
+  #
+  # == TCP server
+  # Create a new TCP server on bound to host:port by specifiying +host+
+  # and +port+ as the first 2 arguments.
+  #
+  #   Thin::Server.start('0.0.0.0', 3000, app)
+  #
+  # == UNIX domain server
+  # Create a new UNIX domain socket bound to +socket+ file by specifiying a filename
+  # as the first argument. Eg.: /tmp/thin.sock. If the first argument contains a /
+  # it will be assumed to be a UNIX socket. 
+  #
+  #   Thin::Server.start('/tmp/thin.sock', app)
+  #
+  # == Using a custom backend
+  # You can implement your own way to connect the server to its client by creating your
+  # own Backend class and pass it as the :backend option.
+  #
+  #   Thin::Server.start('galaxy://faraway', 1345, app, :backend => Thin::Backends::MyFancyBackend)
+  #
+  # == Rack application (+app+)
+  # All requests will be processed through +app+ that must be a valid Rack adapter.
+  # A valid Rack adapter (application) must respond to call(env#Hash) and
+  # return an array of [status, headers, body].
+  #
+  # == Building an app in place
+  # If a block is passed, a Rack::Builder instance
+  # will be passed to build the +app+. So you can do cool stuff like this:
+  # 
+  #   Thin::Server.start('0.0.0.0', 3000) do
+  #     use Rack::CommonLogger
+  #     use Rack::ShowExceptions
+  #     map "/lobster" do
+  #       use Rack::Lint
+  #       run Rack::Lobster.new
+  #     end
+  #   end
+  #
+  # == Controlling with signals
+  # * QUIT: Gracefull shutdown (see Server#stop)
+  # * INT and TERM: Force shutdown (see Server#stop!)
+  # Disable signals by passing :signals => false
+  # 
+  class Server
+    include Logging
+    include Daemonizable
+    extend  Forwardable
+    
+    # Default values
+    DEFAULT_TIMEOUT                        = 30 #sec
+    DEFAULT_HOST                           = '0.0.0.0'
+    DEFAULT_PORT                           = 3000
+    DEFAULT_MAXIMUM_CONNECTIONS            = 1024
+    DEFAULT_MAXIMUM_PERSISTENT_CONNECTIONS = 512
+        
+    # Application (Rack adapter) called with the request that produces the response.
+    attr_accessor :app
+
+    # A tag that will show in the process listing
+    attr_accessor :tag
+
+    # Backend handling the connections to the clients.
+    attr_accessor :backend
+    
+    # Maximum number of seconds for incoming data to arrive before the connection
+    # is dropped.
+    def_delegators :backend, :timeout, :timeout=
+    
+    # Maximum number of file or socket descriptors that the server may open.
+    def_delegators :backend, :maximum_connections, :maximum_connections=
+    
+    # Maximum number of connection that can be persistent at the same time.
+    # Most browser never close the connection so most of the time they are closed
+    # when the timeout occur. If we don't control the number of persistent connection,
+    # if would be very easy to overflow the server for a DoS attack.
+    def_delegators :backend, :maximum_persistent_connections, :maximum_persistent_connections=
+    
+    # Allow using threads in the backend.
+    def_delegators :backend, :threaded?, :threaded=
+    
+    # Address and port on which the server is listening for connections.
+    def_delegators :backend, :host, :port
+    
+    # UNIX domain socket on which the server is listening for connections.
+    def_delegator :backend, :socket
+    
+    # Disable the use of epoll under Linux
+    def_delegators :backend, :no_epoll, :no_epoll=
+    
+    def initialize(*args, &block)
+      host, port, options = DEFAULT_HOST, DEFAULT_PORT, {}
+      
+      # Guess each parameter by its type so they can be
+      # received in any order.
+      args.each do |arg|
+        case arg
+        when Fixnum, /^\d+$/ then port    = arg.to_i
+        when String          then host    = arg
+        when Hash            then options = arg
+        else
+          @app = arg if arg.respond_to?(:call)
+        end
+      end
+      
+      # Set tag if needed
+      self.tag = options[:tag]
+
+      # Try to intelligently select which backend to use.
+      @backend = select_backend(host, port, options)
+      
+      load_cgi_multipart_eof_fix
+      
+      @backend.server = self
+      
+      # Set defaults
+      @backend.maximum_connections            = DEFAULT_MAXIMUM_CONNECTIONS
+      @backend.maximum_persistent_connections = DEFAULT_MAXIMUM_PERSISTENT_CONNECTIONS
+      @backend.timeout                        = DEFAULT_TIMEOUT
+      
+      # Allow using Rack builder as a block
+      @app = Rack::Builder.new(&block).to_app if block
+      
+      # If in debug mode, wrap in logger adapter
+      @app = Rack::CommonLogger.new(@app) if Logging.debug?
+      
+      setup_signals unless options[:signals].class == FalseClass
+    end
+    
+    # Lil' shortcut to turn this:
+    # 
+    #   Server.new(...).start
+    # 
+    # into this:
+    # 
+    #   Server.start(...)
+    # 
+    def self.start(*args, &block)
+      new(*args, &block).start!
+    end
+        
+    # Start the server and listen for connections.
+    def start
+      raise ArgumentError, 'app required' unless @app
+      
+      log   ">> Thin web server (v#{VERSION::STRING} codename #{VERSION::CODENAME})"
+      debug ">> Debugging ON"
+      trace ">> Tracing ON"
+      
+      log ">> Maximum connections set to #{@backend.maximum_connections}"
+      log ">> Listening on #{@backend}, CTRL+C to stop"
+      
+      @backend.start
+    end
+    alias :start! :start
+    
+    # == Gracefull shutdown
+    # Stops the server after processing all current connections.
+    # As soon as this method is called, the server stops accepting
+    # new requests and wait for all current connections to finish.
+    # Calling twice is the equivalent of calling stop!.
+    def stop
+      if running?
+        @backend.stop
+        unless @backend.empty?
+          log ">> Waiting for #{@backend.size} connection(s) to finish, " +
+                 "can take up to #{timeout} sec, CTRL+C to stop now"
+        end
+      else
+        stop!
+      end
+    end
+    
+    # == Force shutdown
+    # Stops the server closing all current connections right away.
+    # This doesn't wait for connection to finish their work and send data.
+    # All current requests will be dropped.
+    def stop!
+      log ">> Stopping ..."
+
+      @backend.stop!
+    end
+    
+    # == Configure the server
+    # The process might need to have superuser privilege to configure
+    # server with optimal options.
+    def config
+      @backend.config
+    end
+    
+    # Name of the server and type of backend used.
+    # This is also the name of the process in which Thin is running as a daemon.
+    def name
+      "thin server (#{@backend})" + (tag ? " [#{tag}]" : "")
+    end
+    alias :to_s :name
+    
+    # Return +true+ if the server is running and ready to receive requests.
+    # Note that the server might still be running and return +false+ when
+    # shuting down and waiting for active connections to complete.
+    def running?
+      @backend.running?
+    end
+    
+    protected
+      # Register signals:
+      # * INT calls +stop+ to shutdown gracefully.
+      # * TERM calls stop! to force shutdown.    
+      def setup_signals
+        trap('QUIT') { stop }  unless Thin.win?
+        trap('INT')  { stop! }
+        trap('TERM') { stop! }
+      end
+      
+      def select_backend(host, port, options)
+        case
+        when options.has_key?(:backend)
+          raise ArgumentError, ":backend must be a class" unless options[:backend].is_a?(Class)
+          options[:backend].new(host, port, options)
+        when options.has_key?(:swiftiply)
+          Backends::SwiftiplyClient.new(host, port, options)
+        when host.include?('/')
+          Backends::UnixServer.new(host)
+        else
+          Backends::TcpServer.new(host, port)
+        end
+      end
+      
+      # Taken from Mongrel cgi_multipart_eof_fix
+      # Ruby 1.8.5 has a security bug in cgi.rb, we need to patch it.
+      def load_cgi_multipart_eof_fix
+        version = RUBY_VERSION.split('.').map { |i| i.to_i }
+        
+        if version[0] <= 1 && version[1] <= 8 && version[2] <= 5 && RUBY_PLATFORM !~ /java/
+          begin
+            require 'cgi_multipart_eof_fix'
+          rescue LoadError
+            log "!! Ruby 1.8.5 is not secure please install cgi_multipart_eof_fix:"
+            log "   gem install cgi_multipart_eof_fix"
+          end
+        end
+      end
+  end
+end
\ No newline at end of file
diff --git a/vendor/gems/gems/thin-1.2.5/lib/thin/stats.html.erb b/vendor/gems/gems/thin-1.2.5/lib/thin/stats.html.erb
new file mode 100755
index 00000000..14338bf1
--- /dev/null
+++ b/vendor/gems/gems/thin-1.2.5/lib/thin/stats.html.erb
@@ -0,0 +1,216 @@
+<%#
+# Taken from Rack::ShowException
+# 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
+%>
+
+
+
+  
+  
+  Thin Stats
+  
+
+
+
+
+

Server stats

+

<%= Thin::SERVER %>

+ + + + + + + + + +
Uptime<%= Time.now - @start_time %> sec
PID<%=h Process.pid %>
+ + <% if @last_request %> +

Jump to:

+ + <% end %> +
+ +
+

Requests

+

Stats

+ + + + + + + + + + + + + + + + + +
Requests<%= @requests %>
Finished<%= @requests_finished %>
Errors<%= @requests - @requests_finished %>
Last request<%= @last_request_time %> sec
+
+ +<% if @last_request %> +
+

Last Request information

+ +

GET

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

No GET data.

+ <% end %> + +

POST

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

No POST data.

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

No cookie data.

+ <% end %> + +

Rack ENV

+ + + + + + + + + <% @last_request.env.sort_by { |k, v| k.to_s }.each { |key, val| %> + + + + + <% } %> + +
VariableValue
<%=h key %>
<%=h val %>
+ +
+<% end %> + +
+

+ You're seeing this page because you use Thin::Stats. +

+
+ + + \ No newline at end of file diff --git a/vendor/gems/gems/thin-1.2.5/lib/thin/stats.rb b/vendor/gems/gems/thin-1.2.5/lib/thin/stats.rb new file mode 100755 index 00000000..146baec5 --- /dev/null +++ b/vendor/gems/gems/thin-1.2.5/lib/thin/stats.rb @@ -0,0 +1,52 @@ +require 'erb' + +module Thin + module Stats + # Rack adapter to log stats about a Rack application. + class Adapter + include ERB::Util + + def initialize(app, path='/stats') + @app = app + @path = path + + @template = ERB.new(File.read(File.dirname(__FILE__) + '/stats.html.erb')) + + @requests = 0 + @requests_finished = 0 + @start_time = Time.now + end + + def call(env) + if env['PATH_INFO'].index(@path) == 0 + serve(env) + else + log(env) { @app.call(env) } + end + end + + def log(env) + @requests += 1 + @last_request = Rack::Request.new(env) + request_started_at = Time.now + + response = yield + + @requests_finished += 1 + @last_request_time = Time.now - request_started_at + + response + end + + def serve(env) + body = @template.result(binding) + + [ + 200, + { 'Content-Type' => 'text/html' }, + [body] + ] + end + end + end +end \ No newline at end of file diff --git a/vendor/gems/gems/thin-1.2.5/lib/thin/statuses.rb b/vendor/gems/gems/thin-1.2.5/lib/thin/statuses.rb new file mode 100755 index 00000000..8aa3614d --- /dev/null +++ b/vendor/gems/gems/thin-1.2.5/lib/thin/statuses.rb @@ -0,0 +1,43 @@ +module Thin + # Every standard HTTP code mapped to the appropriate message. + # Stolent from Mongrel. + HTTP_STATUS_CODES = { + 100 => 'Continue', + 101 => 'Switching Protocols', + 200 => 'OK', + 201 => 'Created', + 202 => 'Accepted', + 203 => 'Non-Authoritative Information', + 204 => 'No Content', + 205 => 'Reset Content', + 206 => 'Partial Content', + 300 => 'Multiple Choices', + 301 => 'Moved Permanently', + 302 => 'Moved Temporarily', + 303 => 'See Other', + 304 => 'Not Modified', + 305 => 'Use Proxy', + 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 Time-out', + 409 => 'Conflict', + 410 => 'Gone', + 411 => 'Length Required', + 412 => 'Precondition Failed', + 413 => 'Request Entity Too Large', + 414 => 'Request-URI Too Large', + 415 => 'Unsupported Media Type', + 500 => 'Internal Server Error', + 501 => 'Not Implemented', + 502 => 'Bad Gateway', + 503 => 'Service Unavailable', + 504 => 'Gateway Time-out', + 505 => 'HTTP Version not supported' + } +end \ No newline at end of file diff --git a/vendor/gems/gems/thin-1.2.5/lib/thin/version.rb b/vendor/gems/gems/thin-1.2.5/lib/thin/version.rb new file mode 100755 index 00000000..fbaf79e6 --- /dev/null +++ b/vendor/gems/gems/thin-1.2.5/lib/thin/version.rb @@ -0,0 +1,32 @@ +module Thin + # Raised when a feature is not supported on the + # current platform. + class PlatformNotSupported < RuntimeError; end + + module VERSION #:nodoc: + MAJOR = 1 + MINOR = 2 + TINY = 5 + + STRING = [MAJOR, MINOR, TINY].join('.') + + CODENAME = "This Is Not A Web Server".freeze + + RACK = [1, 0].freeze # Rack protocol version + end + + NAME = 'thin'.freeze + SERVER = "#{NAME} #{VERSION::STRING} codename #{VERSION::CODENAME}".freeze + + def self.win? + RUBY_PLATFORM =~ /mswin|mingw/ + end + + def self.linux? + RUBY_PLATFORM =~ /linux/ + end + + def self.ruby_18? + RUBY_VERSION =~ /^1\.8/ + end +end diff --git a/vendor/gems/gems/thin-1.2.5/lib/thin_parser.bundle b/vendor/gems/gems/thin-1.2.5/lib/thin_parser.bundle new file mode 100755 index 00000000..c9a122b9 Binary files /dev/null and b/vendor/gems/gems/thin-1.2.5/lib/thin_parser.bundle differ diff --git a/vendor/gems/gems/thin-1.2.5/spec/backends/swiftiply_client_spec.rb b/vendor/gems/gems/thin-1.2.5/spec/backends/swiftiply_client_spec.rb new file mode 100755 index 00000000..baebd6fe --- /dev/null +++ b/vendor/gems/gems/thin-1.2.5/spec/backends/swiftiply_client_spec.rb @@ -0,0 +1,66 @@ +require File.dirname(__FILE__) + '/../spec_helper' + +describe Backends::SwiftiplyClient do + before do + @backend = Backends::SwiftiplyClient.new('0.0.0.0', 3333) + @backend.server = mock('server', :null_object => true) + end + + it "should connect" do + EventMachine.run do + @backend.connect + EventMachine.stop + end + end + + it "should disconnect" do + EventMachine.run do + @backend.connect + @backend.disconnect + EventMachine.stop + end + end +end + +describe SwiftiplyConnection do + before do + @connection = SwiftiplyConnection.new(nil) + @connection.backend = Backends::SwiftiplyClient.new('0.0.0.0', 3333) + @connection.backend.server = mock('server', :null_object => true) + end + + it do + @connection.should be_persistent + end + + it "should send handshake on connection_completed" do + @connection.should_receive(:send_data).with('swiftclient000000000d0500') + @connection.connection_completed + end + + it "should reconnect on unbind" do + @connection.backend.stub!(:running?).and_return(true) + @connection.stub!(:rand).and_return(0) # Make sure we don't wait + + @connection.should_receive(:reconnect).with('0.0.0.0', 3333) + + EventMachine.run do + @connection.unbind + EventMachine.add_timer(0) { EventMachine.stop } + end + end + + it "should not reconnect when not running" do + @connection.backend.stub!(:running?).and_return(false) + EventMachine.should_not_receive(:add_timer) + @connection.unbind + end + + it "should have a host_ip" do + @connection.send(:host_ip).should == [0, 0, 0, 0] + end + + it "should generate swiftiply_handshake based on key" do + @connection.send(:swiftiply_handshake, 'key').should == 'swiftclient000000000d0503key' + end +end \ No newline at end of file diff --git a/vendor/gems/gems/thin-1.2.5/spec/backends/tcp_server_spec.rb b/vendor/gems/gems/thin-1.2.5/spec/backends/tcp_server_spec.rb new file mode 100755 index 00000000..f358e328 --- /dev/null +++ b/vendor/gems/gems/thin-1.2.5/spec/backends/tcp_server_spec.rb @@ -0,0 +1,33 @@ +require File.dirname(__FILE__) + '/../spec_helper' + +describe Backends::TcpServer do + before do + @backend = Backends::TcpServer.new('0.0.0.0', 3333) + end + + it "should not use epoll" do + @backend.no_epoll = true + EventMachine.should_not_receive(:epoll) + @backend.config + end + + it "should use epoll" do + EventMachine.should_receive(:epoll) + @backend.config + end + + it "should connect" do + EventMachine.run do + @backend.connect + EventMachine.stop + end + end + + it "should disconnect" do + EventMachine.run do + @backend.connect + @backend.disconnect + EventMachine.stop + end + end +end diff --git a/vendor/gems/gems/thin-1.2.5/spec/backends/unix_server_spec.rb b/vendor/gems/gems/thin-1.2.5/spec/backends/unix_server_spec.rb new file mode 100755 index 00000000..1abcdb69 --- /dev/null +++ b/vendor/gems/gems/thin-1.2.5/spec/backends/unix_server_spec.rb @@ -0,0 +1,37 @@ +require File.dirname(__FILE__) + '/../spec_helper' + +describe Backends::UnixServer do + before do + @backend = Backends::UnixServer.new('/tmp/thin-test.sock') + end + + it "should connect" do + EventMachine.run do + @backend.connect + EventMachine.stop + end + end + + it "should disconnect" do + EventMachine.run do + @backend.connect + @backend.disconnect + EventMachine.stop + end + end + + it "should remove socket file on close" do + @backend.close + File.exist?('/tmp/thin-test.sock').should be_false + end +end + +describe UnixConnection do + before do + @connection = UnixConnection.new(nil) + end + + it "should return 127.0.0.1 as remote_address" do + @connection.remote_address.should == '127.0.0.1' + end +end \ No newline at end of file diff --git a/vendor/gems/gems/thin-1.2.5/spec/command_spec.rb b/vendor/gems/gems/thin-1.2.5/spec/command_spec.rb new file mode 100755 index 00000000..751d11f7 --- /dev/null +++ b/vendor/gems/gems/thin-1.2.5/spec/command_spec.rb @@ -0,0 +1,25 @@ +require File.dirname(__FILE__) + '/spec_helper' + +describe Command do + before do + Command.script = 'thin' + @command = Command.new(:start, :port => 3000, :daemonize => true, :log => 'hi.log', + :require => %w(rubygems thin), :no_epoll => true) + end + + it 'should shellify command' do + out = @command.shellify + out.should include('--port=3000', '--daemonize', '--log="hi.log"', 'thin start --') + out.should_not include('--pid') + end + + it 'should shellify Array argument to multiple parameters' do + out = @command.shellify + out.should include('--require="rubygems"', '--require="thin"') + end + + it 'should convert _ to - in option name' do + out = @command.shellify + out.should include('--no-epoll') + end +end \ No newline at end of file diff --git a/vendor/gems/gems/thin-1.2.5/spec/configs/cluster.yml b/vendor/gems/gems/thin-1.2.5/spec/configs/cluster.yml new file mode 100755 index 00000000..5243635b --- /dev/null +++ b/vendor/gems/gems/thin-1.2.5/spec/configs/cluster.yml @@ -0,0 +1,9 @@ +--- +pid: tmp/pids/thin.pid +log: log/thin.log +timeout: 60 +port: 5000 +chdir: spec/rails_app +environment: production +servers: 3 +address: 127.0.0.1 diff --git a/vendor/gems/gems/thin-1.2.5/spec/configs/single.yml b/vendor/gems/gems/thin-1.2.5/spec/configs/single.yml new file mode 100755 index 00000000..29c3d611 --- /dev/null +++ b/vendor/gems/gems/thin-1.2.5/spec/configs/single.yml @@ -0,0 +1,9 @@ +--- +pid: tmp/pids/thin.pid +log: log/thin.log +timeout: 60 +port: 6000 +chdir: spec/rails_app +environment: production +daemonize: true +address: 127.0.0.1 diff --git a/vendor/gems/gems/thin-1.2.5/spec/connection_spec.rb b/vendor/gems/gems/thin-1.2.5/spec/connection_spec.rb new file mode 100755 index 00000000..11672117 --- /dev/null +++ b/vendor/gems/gems/thin-1.2.5/spec/connection_spec.rb @@ -0,0 +1,106 @@ +require File.dirname(__FILE__) + '/spec_helper' + +describe Connection do + before do + @connection = Connection.new(mock('EM', :null_object => true)) + @connection.post_init + @connection.app = proc do |env| + [200, {}, ['']] + end + end + + it "should parse on receive_data" do + @connection.request.should_receive(:parse).with('GET') + @connection.receive_data('GET') + end + + it "should close connection on InvalidRequest error in receive_data" do + @connection.request.stub!(:parse).and_raise(InvalidRequest) + @connection.should_receive(:close_connection) + @connection.receive_data('') + end + + it "should process when parsing complete" do + @connection.request.should_receive(:parse).and_return(true) + @connection.should_receive(:process) + @connection.receive_data('GET') + end + + it "should process" do + @connection.process + end + + it "should rescue error in process" do + @connection.app.should_receive(:call).and_raise(StandardError) + @connection.process + end + + it "should rescue Timeout error in process" do + @connection.app.should_receive(:call).and_raise(Timeout::Error.new("timeout error not rescued")) + @connection.process + end + + it "should not return HTTP_X_FORWARDED_FOR as remote_address" do + @connection.request.env['HTTP_X_FORWARDED_FOR'] = '1.2.3.4' + @connection.stub!(:socket_address).and_return("127.0.0.1") + @connection.remote_address.should == "127.0.0.1" + end + + it "should return nil on error retreiving remote_address" do + @connection.stub!(:get_peername).and_raise(RuntimeError) + @connection.remote_address.should be_nil + end + + it "should return nil on nil get_peername" do + @connection.stub!(:get_peername).and_return(nil) + @connection.remote_address.should be_nil + end + + it "should return nil on empty get_peername" do + @connection.stub!(:get_peername).and_return('') + @connection.remote_address.should be_nil + end + + it "should return remote_address" do + @connection.stub!(:get_peername).and_return(Socket.pack_sockaddr_in(3000, '127.0.0.1')) + @connection.remote_address.should == '127.0.0.1' + end + + it "should not be persistent" do + @connection.should_not be_persistent + end + + it "should be persistent when response is and allowed" do + @connection.response.stub!(:persistent?).and_return(true) + @connection.can_persist! + @connection.should be_persistent + end + + it "should not be persistent when response is but not allowed" do + @connection.response.persistent! + @connection.should_not be_persistent + end + + it "should set request env as rack.multithread" do + EventMachine.should_receive(:defer) + + @connection.threaded = true + @connection.process + + @connection.request.env["rack.multithread"].should == true + end + + it "should set as threaded when app.deferred? is true" do + @connection.app.should_receive(:deferred?).and_return(true) + @connection.should be_threaded + end + + it "should not set as threaded when app.deferred? is false" do + @connection.app.should_receive(:deferred?).and_return(false) + @connection.should_not be_threaded + end + + it "should not set as threaded when app do not respond to deferred?" do + @connection.should_not be_threaded + end +end \ No newline at end of file diff --git a/vendor/gems/gems/thin-1.2.5/spec/controllers/cluster_spec.rb b/vendor/gems/gems/thin-1.2.5/spec/controllers/cluster_spec.rb new file mode 100755 index 00000000..81246642 --- /dev/null +++ b/vendor/gems/gems/thin-1.2.5/spec/controllers/cluster_spec.rb @@ -0,0 +1,267 @@ +require File.dirname(__FILE__) + '/../spec_helper' +include Controllers + +describe Cluster, "with host and port" do + before do + @cluster = Cluster.new(:chdir => '/rails_app', + :address => '0.0.0.0', + :port => 3000, + :servers => 3, + :timeout => 10, + :log => 'thin.log', + :pid => 'thin.pid' + ) + end + + it 'should include port number in file names' do + @cluster.send(:include_server_number, 'thin.log', 3000).should == 'thin.3000.log' + @cluster.send(:include_server_number, 'thin.pid', 3000).should == 'thin.3000.pid' + end + + it 'should call each server' do + calls = [] + @cluster.send(:with_each_server) do |port| + calls << port + end + calls.should == [3000, 3001, 3002] + end + + it 'should start on each port' do + Command.should_receive(:run).with(:start, options_for_port(3000)) + Command.should_receive(:run).with(:start, options_for_port(3001)) + Command.should_receive(:run).with(:start, options_for_port(3002)) + + @cluster.start + end + + it 'should stop on each port' do + Command.should_receive(:run).with(:stop, options_for_port(3000)) + Command.should_receive(:run).with(:stop, options_for_port(3001)) + Command.should_receive(:run).with(:stop, options_for_port(3002)) + + @cluster.stop + end + + private + def options_for_port(port) + { :daemonize => true, :log => "thin.#{port}.log", :timeout => 10, :address => "0.0.0.0", :port => port, :pid => "thin.#{port}.pid", :chdir => "/rails_app" } + end +end + +describe Cluster, "with UNIX socket" do + before do + @cluster = Cluster.new(:chdir => '/rails_app', + :socket => '/tmp/thin.sock', + :address => '0.0.0.0', + :port => 3000, + :servers => 3, + :timeout => 10, + :log => 'thin.log', + :pid => 'thin.pid' + ) + end + + it 'should include socket number in file names' do + @cluster.send(:include_server_number, 'thin.sock', 0).should == 'thin.0.sock' + @cluster.send(:include_server_number, 'thin', 0).should == 'thin.0' + end + + it "should exclude :address and :port options" do + @cluster.options.should_not have_key(:address) + @cluster.options.should_not have_key(:port) + end + + it 'should call each server' do + calls = [] + @cluster.send(:with_each_server) do |n| + calls << n + end + calls.should == [0, 1, 2] + end + + it 'should start each server' do + Command.should_receive(:run).with(:start, options_for_socket(0)) + Command.should_receive(:run).with(:start, options_for_socket(1)) + Command.should_receive(:run).with(:start, options_for_socket(2)) + + @cluster.start + end + + it 'should stop each server' do + Command.should_receive(:run).with(:stop, options_for_socket(0)) + Command.should_receive(:run).with(:stop, options_for_socket(1)) + Command.should_receive(:run).with(:stop, options_for_socket(2)) + + @cluster.stop + end + + + private + def options_for_socket(number) + { :daemonize => true, :log => "thin.#{number}.log", :timeout => 10, :socket => "/tmp/thin.#{number}.sock", :pid => "thin.#{number}.pid", :chdir => "/rails_app" } + end +end + +describe Cluster, "controlling only one server" do + before do + @cluster = Cluster.new(:chdir => '/rails_app', + :address => '0.0.0.0', + :port => 3000, + :servers => 3, + :timeout => 10, + :log => 'thin.log', + :pid => 'thin.pid', + :only => 3001 + ) + end + + it 'should call only specified server' do + calls = [] + @cluster.send(:with_each_server) do |n| + calls << n + end + calls.should == [3001] + end + + it "should start only specified server" do + Command.should_receive(:run).with(:start, options_for_port(3001)) + + @cluster.start + end + + private + def options_for_port(port) + { :daemonize => true, :log => "thin.#{port}.log", :timeout => 10, :address => "0.0.0.0", :port => port, :pid => "thin.#{port}.pid", :chdir => "/rails_app" } + end +end + +describe Cluster, "controlling only one server with UNIX socket" do + before do + @cluster = Cluster.new(:chdir => '/rails_app', + :socket => '/tmp/thin.sock', + :address => '0.0.0.0', + :port => 3000, + :servers => 3, + :timeout => 10, + :log => 'thin.log', + :pid => 'thin.pid', + :only => 1 + ) + end + + it 'should call only specified server' do + calls = [] + @cluster.send(:with_each_server) do |n| + calls << n + end + calls.should == [1] + end +end + +describe Cluster, "controlling only one server, by sequence number" do + before do + @cluster = Cluster.new(:chdir => '/rails_app', + :address => '0.0.0.0', + :port => 3000, + :servers => 3, + :timeout => 10, + :log => 'thin.log', + :pid => 'thin.pid', + :only => 1 + ) + end + + it 'should call only specified server' do + calls = [] + @cluster.send(:with_each_server) do |n| + calls << n + end + calls.should == [3001] + end + + it "should start only specified server" do + Command.should_receive(:run).with(:start, options_for_port(3001)) + + @cluster.start + end + + private + def options_for_port(port) + { :daemonize => true, :log => "thin.#{port}.log", :timeout => 10, :address => "0.0.0.0", :port => port, :pid => "thin.#{port}.pid", :chdir => "/rails_app" } + end +end + +describe Cluster, "with Swiftiply" do + before do + @cluster = Cluster.new(:chdir => '/rails_app', + :address => '0.0.0.0', + :port => 3000, + :servers => 3, + :timeout => 10, + :log => 'thin.log', + :pid => 'thin.pid', + :swiftiply => true + ) + end + + it 'should call each server' do + calls = [] + @cluster.send(:with_each_server) do |n| + calls << n + end + calls.should == [0, 1, 2] + end + + it 'should start each server' do + Command.should_receive(:run).with(:start, options_for_swiftiply(0)) + Command.should_receive(:run).with(:start, options_for_swiftiply(1)) + Command.should_receive(:run).with(:start, options_for_swiftiply(2)) + + @cluster.start + end + + it 'should stop each server' do + Command.should_receive(:run).with(:stop, options_for_swiftiply(0)) + Command.should_receive(:run).with(:stop, options_for_swiftiply(1)) + Command.should_receive(:run).with(:stop, options_for_swiftiply(2)) + + @cluster.stop + end + + private + def options_for_swiftiply(number) + { :address => '0.0.0.0', :port => 3000, :daemonize => true, :log => "thin.#{number}.log", :timeout => 10, :pid => "thin.#{number}.pid", :chdir => "/rails_app", :swiftiply => true } + end +end + +describe Cluster, "rolling restart" do + before do + @cluster = Cluster.new(:chdir => '/rails_app', + :address => '0.0.0.0', + :port => 3000, + :servers => 2, + :timeout => 10, + :log => 'thin.log', + :pid => 'thin.pid', + :onebyone => true, + :wait => 30 + ) + end + + it "should restart servers one by one" do + Command.should_receive(:run).with(:stop, options_for_port(3000)) + Command.should_receive(:run).with(:start, options_for_port(3000)) + @cluster.should_receive(:wait_until_server_started).with(3000) + + Command.should_receive(:run).with(:stop, options_for_port(3001)) + Command.should_receive(:run).with(:start, options_for_port(3001)) + @cluster.should_receive(:wait_until_server_started).with(3001) + + @cluster.restart + end + + private + def options_for_port(port) + { :daemonize => true, :log => "thin.#{port}.log", :timeout => 10, :address => "0.0.0.0", :port => port, :pid => "thin.#{port}.pid", :chdir => "/rails_app" } + end +end \ No newline at end of file diff --git a/vendor/gems/gems/thin-1.2.5/spec/controllers/controller_spec.rb b/vendor/gems/gems/thin-1.2.5/spec/controllers/controller_spec.rb new file mode 100755 index 00000000..d98a011d --- /dev/null +++ b/vendor/gems/gems/thin-1.2.5/spec/controllers/controller_spec.rb @@ -0,0 +1,129 @@ +require File.dirname(__FILE__) + '/../spec_helper' +require 'ostruct' +include Controllers + +describe Controller, 'start' do + before do + @controller = Controller.new(:address => '0.0.0.0', + :port => 3000, + :pid => 'thin.pid', + :log => 'thin.log', + :timeout => 60, + :max_conns => 2000, + :max_persistent_conns => 1000, + :adapter => 'rails') + + @server = OpenStruct.new + @adapter = OpenStruct.new + + Server.should_receive(:new).with('0.0.0.0', 3000, @controller.options).and_return(@server) + @server.should_receive(:config) + Rack::Adapter::Rails.stub!(:new).and_return(@adapter) + end + + it "should configure server" do + @controller.start + + @server.app.should == @adapter + @server.pid_file.should == 'thin.pid' + @server.log_file.should == 'thin.log' + @server.maximum_connections.should == 2000 + @server.maximum_persistent_connections.should == 1000 + end + + it "should start as daemon" do + @controller.options[:daemonize] = true + @controller.options[:user] = true + @controller.options[:group] = true + + @server.should_receive(:daemonize) + @server.should_receive(:change_privilege) + + @controller.start + end + + it "should configure Rails adapter" do + Rack::Adapter::Rails.should_receive(:new).with(@controller.options.merge(:root => nil)) + + @controller.start + end + + it "should mount app under :prefix" do + @controller.options[:prefix] = '/app' + @controller.start + + @server.app.class.should == Rack::URLMap + end + + it "should mount Stats adapter under :stats" do + @controller.options[:stats] = '/stats' + @controller.start + + @server.app.class.should == Stats::Adapter + end + + it "should load app from Rack config" do + @controller.options[:rackup] = File.dirname(__FILE__) + '/../../example/config.ru' + @controller.start + + @server.app.class.should == Proc + end + + it "should load app from ruby file" do + @controller.options[:rackup] = File.dirname(__FILE__) + '/../../example/myapp.rb' + @controller.start + + @server.app.should == Myapp + end + + it "should throwup if rackup is not a .ru or .rb file" do + proc do + @controller.options[:rackup] = File.dirname(__FILE__) + '/../../example/myapp.foo' + @controller.start + end.should raise_error(RuntimeError, /please/) + end + + it "should set server as threaded" do + @controller.options[:threaded] = true + @controller.start + + @server.threaded.should be_true + end + + it "should set RACK_ENV" do + @controller.options[:rackup] = File.dirname(__FILE__) + '/../../example/config.ru' + @controller.options[:environment] = "lolcat" + @controller.start + + ENV['RACK_ENV'].should == "lolcat" + end + +end + +describe Controller do + before do + @controller = Controller.new(:pid => 'thin.pid', :timeout => 10) + @controller.stub!(:wait_for_file) + end + + it "should stop" do + Server.should_receive(:kill).with('thin.pid', 10) + @controller.stop + end + + it "should restart" do + Server.should_receive(:restart).with('thin.pid') + @controller.restart + end + + it "should write configuration file" do + silence_stream(STDOUT) do + Controller.new(:config => 'test.yml', :port => 5000, :address => '127.0.0.1').config + end + + File.read('test.yml').should include('port: 5000', 'address: 127.0.0.1') + File.read('test.yml').should_not include('config: ') + + File.delete('test.yml') + end +end \ No newline at end of file diff --git a/vendor/gems/gems/thin-1.2.5/spec/controllers/service_spec.rb b/vendor/gems/gems/thin-1.2.5/spec/controllers/service_spec.rb new file mode 100755 index 00000000..6c6cd3ba --- /dev/null +++ b/vendor/gems/gems/thin-1.2.5/spec/controllers/service_spec.rb @@ -0,0 +1,50 @@ +require File.dirname(__FILE__) + '/../spec_helper' +include Controllers + +describe Service do + before(:all) do + silence_stream(STDERR) do + Service::INITD_PATH = 'tmp/sandbox' + Service::INITD_PATH + Service::DEFAULT_CONFIG_PATH = 'tmp/sandbox' + Service::DEFAULT_CONFIG_PATH + end + end + + before do + Thin.stub!(:linux?).and_return(true) + FileUtils.mkdir_p 'tmp/sandbox' + + @service = Service.new(:all => 'spec/configs') + end + + it "should call command for each config file" do + Command.should_receive(:run).with(:start, :config => 'spec/configs/cluster.yml', :daemonize => true) + Command.should_receive(:run).with(:start, :config => 'spec/configs/single.yml', :daemonize => true) + + @service.start + end + + it "should create /etc/init.d/thin file when calling install" do + @service.install + + File.exist?(Service::INITD_PATH).should be_true + File.read(Service::INITD_PATH).should include('CONFIG_PATH=tmp/sandbox/etc/thin', + 'SCRIPT_NAME=tmp/sandbox/etc/init.d/thin', + 'DAEMON=' + Command.script) + end + + it "should create /etc/thin dir when calling install" do + @service.install + + File.directory?(Service::DEFAULT_CONFIG_PATH).should be_true + end + + it "should include specified path in /etc/init.d/thin script" do + @service.install('tmp/sandbox/usr/thin') + + File.read(Service::INITD_PATH).should include('CONFIG_PATH=tmp/sandbox/usr/thin') + end + + after do + FileUtils.rm_rf 'tmp/sandbox' + end +end \ No newline at end of file diff --git a/vendor/gems/gems/thin-1.2.5/spec/daemonizing_spec.rb b/vendor/gems/gems/thin-1.2.5/spec/daemonizing_spec.rb new file mode 100755 index 00000000..365d8df1 --- /dev/null +++ b/vendor/gems/gems/thin-1.2.5/spec/daemonizing_spec.rb @@ -0,0 +1,192 @@ +require File.dirname(__FILE__) + '/spec_helper' + +class TestServer + include Logging # Daemonizable should include this? + include Daemonizable + + def stop + end + + def name + 'Thin test server' + end +end + +describe 'Daemonizing' do + before :all do + @logfile = File.dirname(__FILE__) + '/../log/daemonizing_test.log' + @pidfile = 'test.pid' + File.delete(@logfile) if File.exist?(@logfile) + File.delete(@pidfile) if File.exist?(@pidfile) + end + + before :each do + @server = TestServer.new + @server.log_file = @logfile + @server.pid_file = @pidfile + @pid = nil + end + + it 'should have a pid file' do + @server.should respond_to(:pid_file) + @server.should respond_to(:pid_file=) + end + + it 'should create a pid file' do + @pid = fork do + @server.daemonize + sleep 1 + end + + sleep 1 + Process.wait(@pid) + File.exist?(@server.pid_file).should be_true + @pid = @server.pid + + proc { sleep 0.1 while File.exist?(@server.pid_file) }.should take_less_then(5) + end + + it 'should redirect stdio to a log file' do + @pid = fork do + @server.log_file = 'daemon_test.log' + @server.daemonize + + puts "simple puts" + STDERR.puts "STDERR.puts" + STDOUT.puts "STDOUT.puts" + end + Process.wait(@pid) + # Wait for the file to close and magical stuff to happen + proc { sleep 0.1 until File.exist?('daemon_test.log') }.should take_less_then(3) + sleep 0.5 + + @pid = @server.pid + + log = File.read('daemon_test.log') + log.should include('simple puts', 'STDERR.puts', 'STDOUT.puts') + + File.delete 'daemon_test.log' + end + + it 'should change privilege' do + @pid = fork do + @server.daemonize + @server.change_privilege('root', 'admin') + end + Process.wait(@pid) + $?.should be_a_success + end + + it 'should kill process in pid file' do + @pid = fork do + @server.daemonize + loop { sleep 3 } + end + + server_should_start_in_less_then 3 + + @pid = @server.pid + + silence_stream STDOUT do + TestServer.kill(@server.pid_file, 1) + end + + File.exist?(@server.pid_file).should be_false + end + + it 'should force kill process in pid file' do + @pid = fork do + @server.daemonize + loop { sleep 3 } + end + + server_should_start_in_less_then 3 + + @pid = @server.pid + + silence_stream STDOUT do + TestServer.kill(@server.pid_file, 0) + end + + File.exist?(@server.pid_file).should be_false + end + + it 'should send kill signal if timeout' do + @pid = fork do + @server.should_receive(:stop) # pretend we cannot handle the INT signal + @server.daemonize + sleep 5 + end + + server_should_start_in_less_then 10 + + @pid = @server.pid + + silence_stream STDOUT do + TestServer.kill(@server.pid_file, 1) + end + + sleep 1 + + File.exist?(@server.pid_file).should be_false + Process.running?(@pid).should be_false + end + + it "should restart" do + @pid = fork do + @server.on_restart {} + @server.daemonize + sleep 5 + end + + server_should_start_in_less_then 10 + + @pid = @server.pid + + silence_stream STDOUT do + TestServer.restart(@server.pid_file) + end + + proc { sleep 0.1 while File.exist?(@server.pid_file) }.should take_less_then(10) + end + + it "should not restart when not running" do + silence_stream STDOUT do + TestServer.restart(@server.pid_file) + end + end + + it "should exit and raise if pid file already exist" do + @pid = fork do + @server.daemonize + sleep 5 + end + server_should_start_in_less_then 10 + + @pid = @server.pid + + proc { @server.daemonize }.should raise_error(PidFileExist) + + File.exist?(@server.pid_file).should be_true + end + + it "should should delete pid file if stale" do + # Create a file w/ a PID that does not exist + File.open(@server.pid_file, 'w') { |f| f << 999999999 } + + @server.send(:remove_stale_pid_file) + + File.exist?(@server.pid_file).should be_false + end + + after do + Process.kill(9, @pid.to_i) if @pid && Process.running?(@pid.to_i) + Process.kill(9, @server.pid) if @server.pid && Process.running?(@server.pid) + File.delete(@server.pid_file) rescue nil + end + + private + def server_should_start_in_less_then(sec=10) + proc { sleep 0.1 until File.exist?(@server.pid_file) }.should take_less_then(10) + end +end \ No newline at end of file diff --git a/vendor/gems/gems/thin-1.2.5/spec/headers_spec.rb b/vendor/gems/gems/thin-1.2.5/spec/headers_spec.rb new file mode 100755 index 00000000..98ee4709 --- /dev/null +++ b/vendor/gems/gems/thin-1.2.5/spec/headers_spec.rb @@ -0,0 +1,40 @@ +require File.dirname(__FILE__) + '/spec_helper' + +describe Headers do + before do + @headers = Headers.new + end + + it 'should allow duplicate on some fields' do + @headers['Set-Cookie'] = 'twice' + @headers['Set-Cookie'] = 'is cooler the once' + + @headers.to_s.should == "Set-Cookie: twice\r\nSet-Cookie: is cooler the once\r\n" + end + + it 'should overwrite value on non duplicate fields' do + @headers['Host'] = 'this is unique' + @headers['Host'] = 'so is this' + + @headers.to_s.should == "Host: this is unique\r\n" + end + + it 'should output to string' do + @headers['Host'] = 'localhost:3000' + @headers['Set-Cookie'] = 'twice' + @headers['Set-Cookie'] = 'is cooler the once' + + @headers.to_s.should == "Host: localhost:3000\r\nSet-Cookie: twice\r\nSet-Cookie: is cooler the once\r\n" + end + + it 'should ignore nil values' do + @headers['Something'] = nil + @headers.to_s.should_not include('Something: ') + end + + it 'should format Time values correctly' do + time = Time.now + @headers['Modified-At'] = time + @headers.to_s.should include("Modified-At: #{time.httpdate}") + end +end \ No newline at end of file diff --git a/vendor/gems/gems/thin-1.2.5/spec/logging_spec.rb b/vendor/gems/gems/thin-1.2.5/spec/logging_spec.rb new file mode 100755 index 00000000..eeb160e6 --- /dev/null +++ b/vendor/gems/gems/thin-1.2.5/spec/logging_spec.rb @@ -0,0 +1,46 @@ +require File.dirname(__FILE__) + '/spec_helper' + +class TestLogging + include Logging +end + +describe Logging do + before do + Logging.silent = false + @object = TestLogging.new + end + + it "should output debug when set to true" do + Logging.debug = true + @object.should_receive(:puts) + @object.debug 'hi' + end + + it "should output trace when set to true" do + Logging.trace = true + @object.should_receive(:puts) + @object.trace 'hi' + end + + it "should not output when silenced" do + Logging.silent = true + @object.should_not_receive(:puts) + @object.log 'hi' + end + + it "should not output when silenced as instance method" do + @object.silent = true + + @object.should_not_receive(:puts) + @object.log 'hi' + end + + it "should be usable as module functions" do + Logging.silent = true + Logging.log "hi" + end + + after do + Logging.silent = true + end +end \ No newline at end of file diff --git a/vendor/gems/gems/thin-1.2.5/spec/perf/request_perf_spec.rb b/vendor/gems/gems/thin-1.2.5/spec/perf/request_perf_spec.rb new file mode 100755 index 00000000..bd1e6a4c --- /dev/null +++ b/vendor/gems/gems/thin-1.2.5/spec/perf/request_perf_spec.rb @@ -0,0 +1,50 @@ +require File.dirname(__FILE__) + '/../spec_helper' + +describe Request, 'performance' do + it "should be faster then #{max_parsing_time = 0.0002} RubySeconds" do + body = <<-EOS.chomp.gsub("\n", "\r\n") +POST /postit HTTP/1.1 +Host: localhost:3000 +User-Agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X; en-US; rv:1.8.1.9) Gecko/20071025 Firefox/2.0.0.9 +Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5 +Accept-Language: en-us,en;q=0.5 +Accept-Encoding: gzip,deflate +Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7 +Keep-Alive: 300 +Connection: keep-alive +Content-Type: text/html +Content-Length: 37 + +hi=there&name=marc&email=macournoyer@gmail.com +EOS + + proc { R(body) }.should be_faster_then(max_parsing_time) + end + + it 'should be comparable to Mongrel parser' do + require 'http11' + + body = <<-EOS.chomp.gsub("\n", "\r\n") +POST /postit HTTP/1.1 +Host: localhost:3000 +User-Agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X; en-US; rv:1.8.1.9) Gecko/20071025 Firefox/2.0.0.9 +Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5 +Accept-Language: en-us,en;q=0.5 +Accept-Encoding: gzip,deflate +Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7 +Keep-Alive: 300 +Connection: keep-alive +Content-Type: text/html +Content-Length: 37 + +hi=there&name=marc&email=macournoyer@gmail.com +EOS + + tests = 10_000 + puts + Benchmark.bmbm(10) do |results| + results.report("mongrel:") { tests.times { Mongrel::HttpParser.new.execute({}, body.dup, 0) } } + results.report("thin:") { tests.times { Thin::HttpParser.new.execute({'rack.input' => StringIO.new}, body.dup, 0) } } + end + end if ENV['BM'] +end \ No newline at end of file diff --git a/vendor/gems/gems/thin-1.2.5/spec/perf/response_perf_spec.rb b/vendor/gems/gems/thin-1.2.5/spec/perf/response_perf_spec.rb new file mode 100755 index 00000000..1456cae6 --- /dev/null +++ b/vendor/gems/gems/thin-1.2.5/spec/perf/response_perf_spec.rb @@ -0,0 +1,19 @@ +require File.dirname(__FILE__) + '/../spec_helper' + +describe Response, 'performance' do + before do + @response = Response.new + @response.body = '' + end + + it "should be fast" do + @response.body << <<-EOS +Dir listing +

Listing stuff

    +#{'
  • Hi!
  • ' * 100} +
+EOS + + proc { @response.each { |l| l } }.should be_faster_then(0.00011) + end +end \ No newline at end of file diff --git a/vendor/gems/gems/thin-1.2.5/spec/perf/server_perf_spec.rb b/vendor/gems/gems/thin-1.2.5/spec/perf/server_perf_spec.rb new file mode 100755 index 00000000..528ebc4f --- /dev/null +++ b/vendor/gems/gems/thin-1.2.5/spec/perf/server_perf_spec.rb @@ -0,0 +1,39 @@ +require File.dirname(__FILE__) + '/../spec_helper' + +describe Server, 'performance' do + before do + start_server do |env| + body = env.inspect + env['rack.input'].read + [200, { 'Content-Length' => body.size.to_s }, body] + end + end + + it "should handle GET in less then #{get_request_time = 0.0045} RubySecond" do + proc { get('/') }.should be_faster_then(get_request_time) + end + + it "should handle POST in less then #{post_request_time = 0.007} RubySecond" do + proc { post('/', :file => 'X' * 1000) }.should be_faster_then(post_request_time) + end + + after do + stop_server + end +end + +describe Server, 'UNIX socket performance' do + before do + start_server('/tmp/thin_test.sock') do |env| + body = env.inspect + env['rack.input'].read + [200, { 'Content-Length' => body.size.to_s }, body] + end + end + + it "should handle GET in less then #{get_request_time = 0.002} RubySecond" do + proc { get('/') }.should be_faster_then(get_request_time) + end + + after do + stop_server + end +end \ No newline at end of file diff --git a/vendor/gems/gems/thin-1.2.5/spec/rack/loader_spec.rb b/vendor/gems/gems/thin-1.2.5/spec/rack/loader_spec.rb new file mode 100755 index 00000000..0cfb19da --- /dev/null +++ b/vendor/gems/gems/thin-1.2.5/spec/rack/loader_spec.rb @@ -0,0 +1,29 @@ +require File.dirname(__FILE__) + '/../spec_helper' + +describe Rack::Adapter do + before do + @rails_path = File.dirname(__FILE__) + '/../rails_app' + end + + it "should guess rails app from dir" do + Rack::Adapter.guess(@rails_path).should == :rails + end + + it "should return nil when can't guess from dir" do + proc { Rack::Adapter.guess('.') }.should raise_error(Rack::AdapterNotFound) + end + + it "should load Rails adapter" do + Rack::Adapter::Rails.should_receive(:new) + Rack::Adapter.for(:rails, :chdir => @rails_path) + end + + it "should load File adapter" do + Rack::File.should_receive(:new) + Rack::Adapter.for(:file) + end + + it "should raise error when adapter can't be found" do + proc { Rack::Adapter.for(:fart, {}) }.should raise_error(Rack::AdapterNotFound) + end +end \ No newline at end of file diff --git a/vendor/gems/gems/thin-1.2.5/spec/rack/rails_adapter_spec.rb b/vendor/gems/gems/thin-1.2.5/spec/rack/rails_adapter_spec.rb new file mode 100755 index 00000000..279c26d4 --- /dev/null +++ b/vendor/gems/gems/thin-1.2.5/spec/rack/rails_adapter_spec.rb @@ -0,0 +1,106 @@ +require File.dirname(__FILE__) + '/../spec_helper' +require 'rack/mock' + +begin + gem 'rails', '= 2.0.2' # We could freeze Rails in the rails_app dir to remove this + + describe Rack::Adapter::Rails do + before do + @rails_app_path = File.dirname(__FILE__) + '/../rails_app' + @request = Rack::MockRequest.new(Rack::Adapter::Rails.new(:root => @rails_app_path)) + end + + it "should handle simple GET request" do + res = @request.get("/simple", :lint => true) + + res.should be_ok + res["Content-Type"].should include("text/html") + + res.body.should include('Simple#index') + end + + it "should handle POST parameters" do + data = "foo=bar" + res = @request.post("/simple/post_form", :input => data, 'CONTENT_LENGTH' => data.size.to_s, :lint => true) + + res.should be_ok + res["Content-Type"].should include("text/html") + res["Content-Length"].should_not be_nil + + res.body.should include('foo: bar') + end + + it "should serve static files" do + res = @request.get("/index.html", :lint => true) + + res.should be_ok + res["Content-Type"].should include("text/html") + end + + it "should serve root with index.html if present" do + res = @request.get("/", :lint => true) + + res.should be_ok + res["Content-Length"].to_i.should == File.size(@rails_app_path + '/public/index.html') + end + + it "should serve page cache if present" do + res = @request.get("/simple/cached?value=cached", :lint => true) + + res.should be_ok + res.body.should == 'cached' + + res = @request.get("/simple/cached?value=notcached") + + res.should be_ok + res.body.should == 'cached' + end + + it "should not serve page cache on POST request" do + res = @request.get("/simple/cached?value=cached", :lint => true) + + res.should be_ok + res.body.should == 'cached' + + res = @request.post("/simple/cached?value=notcached") + + res.should be_ok + res.body.should == 'notcached' + end + + it "handles multiple cookies" do + res = @request.get('/simple/set_cookie?name=a&value=1', :lint => true) + + res.should be_ok + res.original_headers['Set-Cookie'].size.should == 2 + res.original_headers['Set-Cookie'].first.should include('a=1; path=/') + res.original_headers['Set-Cookie'].last.should include('_rails_app_session') + end + + after do + FileUtils.rm_rf @rails_app_path + '/public/simple' + end + end + + describe Rack::Adapter::Rails, 'with prefix' do + before do + @rails_app_path = File.dirname(__FILE__) + '/../rails_app' + @prefix = '/nowhere' + @request = Rack::MockRequest.new( + Rack::URLMap.new( + @prefix => Rack::Adapter::Rails.new(:root => @rails_app_path, :prefix => @prefix))) + end + + it "should handle simple GET request" do + res = @request.get("#{@prefix}/simple", :lint => true) + + res.should be_ok + res["Content-Type"].should include("text/html") + + res.body.should include('Simple#index') + end + end + +rescue Gem::LoadError + warn 'Rails 2.0.2 is required to run the Rails adapter specs' +end diff --git a/vendor/gems/gems/thin-1.2.5/spec/rails_app/app/controllers/application.rb b/vendor/gems/gems/thin-1.2.5/spec/rails_app/app/controllers/application.rb new file mode 100755 index 00000000..cfdb724c --- /dev/null +++ b/vendor/gems/gems/thin-1.2.5/spec/rails_app/app/controllers/application.rb @@ -0,0 +1,10 @@ +# Filters added to this controller apply to all controllers in the application. +# Likewise, all the methods added will be available for all controllers. + +class ApplicationController < ActionController::Base + helper :all # include all helpers, all the time + + # See ActionController::RequestForgeryProtection for details + # Uncomment the :secret if you're not using the cookie session store + # protect_from_forgery # :secret => 'a8af303b8dabf2d2d8f1a7912ac04d7d' +end diff --git a/vendor/gems/gems/thin-1.2.5/spec/rails_app/app/controllers/simple_controller.rb b/vendor/gems/gems/thin-1.2.5/spec/rails_app/app/controllers/simple_controller.rb new file mode 100755 index 00000000..2c17427e --- /dev/null +++ b/vendor/gems/gems/thin-1.2.5/spec/rails_app/app/controllers/simple_controller.rb @@ -0,0 +1,19 @@ +class SimpleController < ApplicationController + caches_page :cached + + def index + end + + def post_form + render :text => params.to_yaml + end + + def set_cookie + cookies[params[:name]] = params[:value] if params[:name] + render :text => cookies.to_yaml + end + + def cached + render :text => params[:value] + end +end diff --git a/vendor/gems/gems/thin-1.2.5/spec/rails_app/app/helpers/application_helper.rb b/vendor/gems/gems/thin-1.2.5/spec/rails_app/app/helpers/application_helper.rb new file mode 100755 index 00000000..22a7940e --- /dev/null +++ b/vendor/gems/gems/thin-1.2.5/spec/rails_app/app/helpers/application_helper.rb @@ -0,0 +1,3 @@ +# Methods added to this helper will be available to all templates in the application. +module ApplicationHelper +end diff --git a/vendor/gems/gems/thin-1.2.5/spec/rails_app/app/views/simple/index.html.erb b/vendor/gems/gems/thin-1.2.5/spec/rails_app/app/views/simple/index.html.erb new file mode 100755 index 00000000..7717b8ec --- /dev/null +++ b/vendor/gems/gems/thin-1.2.5/spec/rails_app/app/views/simple/index.html.erb @@ -0,0 +1,15 @@ +

Simple#index

+ +

ENV

+<%= request.env.to_yaml %> + +

Cookies

+<%= request.cookies.to_yaml %> + +

Params

+<%= params.to_yaml %> + +<% form_tag '/simple' do %> + <%= text_field_tag :a %> + <%= submit_tag 'Submit' %> +<% end %> \ No newline at end of file diff --git a/vendor/gems/gems/thin-1.2.5/spec/rails_app/config/boot.rb b/vendor/gems/gems/thin-1.2.5/spec/rails_app/config/boot.rb new file mode 100755 index 00000000..5697cc1b --- /dev/null +++ b/vendor/gems/gems/thin-1.2.5/spec/rails_app/config/boot.rb @@ -0,0 +1,109 @@ +# Don't change this file! +# Configure your app in config/environment.rb and config/environments/*.rb + +RAILS_ROOT = "#{File.dirname(__FILE__)}/.." unless defined?(RAILS_ROOT) + +module Rails + class << self + def boot! + unless booted? + preinitialize + pick_boot.run + end + end + + def booted? + defined? Rails::Initializer + end + + def pick_boot + (vendor_rails? ? VendorBoot : GemBoot).new + end + + def vendor_rails? + File.exist?("#{RAILS_ROOT}/vendor/rails") + end + + # FIXME : Ruby 1.9 + def preinitialize + load(preinitializer_path) if File.exists?(preinitializer_path) + end + + def preinitializer_path + "#{RAILS_ROOT}/config/preinitializer.rb" + end + end + + class Boot + def run + load_initializer + Rails::Initializer.run(:set_load_path) + end + end + + class VendorBoot < Boot + def load_initializer + require "#{RAILS_ROOT}/vendor/rails/railties/lib/initializer" + end + end + + class GemBoot < Boot + def load_initializer + self.class.load_rubygems + load_rails_gem + require 'initializer' + end + + def load_rails_gem + if version = self.class.gem_version + 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 if defined? Gem::RubyGemsVersion + end + + def gem_version + if defined? RAILS_GEM_VERSION + RAILS_GEM_VERSION + elsif ENV.include?('RAILS_GEM_VERSION') + ENV['RAILS_GEM_VERSION'] + else + parse_gem_version(read_environment_rb) + end + end + + def load_rubygems + require 'rubygems' + + unless rubygems_version >= '0.9.4' + $stderr.puts %(Rails requires RubyGems >= 0.9.4 (you have #{rubygems_version}). Please `gem update --system` and try again.) + exit 1 + end + + rescue LoadError + $stderr.puts %(Rails requires RubyGems >= 0.9.4. Please install RubyGems and try again: http://rubygems.rubyforge.org) + exit 1 + end + + def parse_gem_version(text) + $1 if text =~ /^[^#]*RAILS_GEM_VERSION\s*=\s*["']([!~<>=]*\s*[\d.]+)["']/ + end + + private + def read_environment_rb + File.read("#{RAILS_ROOT}/config/environment.rb") + end + end + end +end + +# All that for this: +Rails.boot! diff --git a/vendor/gems/gems/thin-1.2.5/spec/rails_app/config/environment.rb b/vendor/gems/gems/thin-1.2.5/spec/rails_app/config/environment.rb new file mode 100755 index 00000000..2af27f14 --- /dev/null +++ b/vendor/gems/gems/thin-1.2.5/spec/rails_app/config/environment.rb @@ -0,0 +1,64 @@ +# Be sure to restart your server when you modify this file + +# Uncomment below to force Rails into production mode when +# you don't control web/app server and can't set it the proper way +# ENV['RAILS_ENV'] ||= 'production' + +# Specifies gem version of Rails to use when vendor/rails is not present +RAILS_GEM_VERSION = '2.0.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. + # See Rails::Configuration for more options. + + # Skip frameworks you're not going to use (only works if using vendor/rails). + # To use Rails without a database, you must remove the Active Record framework + config.frameworks -= [ :active_record, :active_resource, :action_mailer ] + + # Only load the plugins named here, in the order given. By default, all plugins + # in vendor/plugins are loaded in alphabetical order. + # :all can be used as a placeholder for all plugins not explicitly named + # config.plugins = [ :exception_notification, :ssl_requirement, :all ] + + # Add additional load paths for your own custom dirs + # config.load_paths += %W( #{RAILS_ROOT}/extras ) + + # No need for log files + config.logger = Logger.new(nil) + + # Force all environments to use the same logger level + # (by default production uses :info, the others :debug) + # config.log_level = :debug + + # 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. + config.action_controller.session = { + :session_key => '_rails_app_session', + :secret => 'cb7141365b4443eff37e7122473e704ceae95146a4028930b21300965fe6abec51e3e93b2670a914b3b65d06058b81aadfe6b240d63e7d7713db044b42a6e1c1' + } + + config.action_controller.allow_forgery_protection = false + + # 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') + # config.action_controller.session_store = :active_record_store + + # 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 + + # Activate observers that should always be running + # config.active_record.observers = :cacher, :garbage_collector + + # Make Active Record use UTC-base instead of local time + # config.active_record.default_timezone = :utc +end \ No newline at end of file diff --git a/vendor/gems/gems/thin-1.2.5/spec/rails_app/config/environments/development.rb b/vendor/gems/gems/thin-1.2.5/spec/rails_app/config/environments/development.rb new file mode 100755 index 00000000..191f39cb --- /dev/null +++ b/vendor/gems/gems/thin-1.2.5/spec/rails_app/config/environments/development.rb @@ -0,0 +1,18 @@ +# Settings specified here will take precedence over those in config/environment.rb + +# In the development environment your application's code is reloaded on +# every request. This slows down response time but is perfect for development +# since you don't have to restart the webserver when you make code changes. +config.cache_classes = false + +# Log error messages when you accidentally call methods on nil. +config.whiny_nils = true + +# Show full error reports and disable caching +config.action_controller.consider_all_requests_local = true +config.action_view.debug_rjs = true +config.action_controller.perform_caching = true +config.action_view.cache_template_extensions = false + +# Don't care if the mailer can't send +config.action_mailer.raise_delivery_errors = false \ No newline at end of file diff --git a/vendor/gems/gems/thin-1.2.5/spec/rails_app/config/environments/production.rb b/vendor/gems/gems/thin-1.2.5/spec/rails_app/config/environments/production.rb new file mode 100755 index 00000000..91f541c4 --- /dev/null +++ b/vendor/gems/gems/thin-1.2.5/spec/rails_app/config/environments/production.rb @@ -0,0 +1,19 @@ +# Settings specified here will take precedence over those in config/environment.rb + +# The production environment is meant for finished, "live" apps. +# Code is not reloaded between requests +config.cache_classes = true + +# Use a different logger for distributed setups +# config.logger = SyslogLogger.new + +# Full error reports are disabled and caching is turned on +config.action_controller.consider_all_requests_local = false +config.action_controller.perform_caching = true +config.action_view.cache_template_loading = true + +# Enable serving of images, stylesheets, and javascripts from an asset server +# config.action_controller.asset_host = "http://assets.example.com" + +# Disable delivery errors, bad email addresses will be ignored +# config.action_mailer.raise_delivery_errors = false diff --git a/vendor/gems/gems/thin-1.2.5/spec/rails_app/config/environments/test.rb b/vendor/gems/gems/thin-1.2.5/spec/rails_app/config/environments/test.rb new file mode 100755 index 00000000..58850a79 --- /dev/null +++ b/vendor/gems/gems/thin-1.2.5/spec/rails_app/config/environments/test.rb @@ -0,0 +1,22 @@ +# 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 + +# Disable request forgery protection in test environment +config.action_controller.allow_forgery_protection = false + +# Tell ActionMailer not to deliver emails to the real world. +# The :test delivery method accumulates sent emails in the +# ActionMailer::Base.deliveries array. +config.action_mailer.delivery_method = :test diff --git a/vendor/gems/gems/thin-1.2.5/spec/rails_app/config/initializers/inflections.rb b/vendor/gems/gems/thin-1.2.5/spec/rails_app/config/initializers/inflections.rb new file mode 100755 index 00000000..09158b86 --- /dev/null +++ b/vendor/gems/gems/thin-1.2.5/spec/rails_app/config/initializers/inflections.rb @@ -0,0 +1,10 @@ +# Be sure to restart your server when you modify this file. + +# Add new inflection rules using the following format +# (all these examples are active by default): +# Inflector.inflections do |inflect| +# inflect.plural /^(ox)$/i, '\1en' +# inflect.singular /^(ox)en/i, '\1' +# inflect.irregular 'person', 'people' +# inflect.uncountable %w( fish sheep ) +# end diff --git a/vendor/gems/gems/thin-1.2.5/spec/rails_app/config/initializers/mime_types.rb b/vendor/gems/gems/thin-1.2.5/spec/rails_app/config/initializers/mime_types.rb new file mode 100755 index 00000000..72aca7e4 --- /dev/null +++ b/vendor/gems/gems/thin-1.2.5/spec/rails_app/config/initializers/mime_types.rb @@ -0,0 +1,5 @@ +# Be sure to restart your server when you modify this file. + +# Add new mime types for use in respond_to blocks: +# Mime::Type.register "text/richtext", :rtf +# Mime::Type.register_alias "text/html", :iphone diff --git a/vendor/gems/gems/thin-1.2.5/spec/rails_app/config/routes.rb b/vendor/gems/gems/thin-1.2.5/spec/rails_app/config/routes.rb new file mode 100755 index 00000000..d94afa1b --- /dev/null +++ b/vendor/gems/gems/thin-1.2.5/spec/rails_app/config/routes.rb @@ -0,0 +1,35 @@ +ActionController::Routing::Routes.draw do |map| + # The priority is based upon order of creation: first created -> highest priority. + + # Sample of regular route: + # map.connect 'products/:id', :controller => 'catalog', :action => 'view' + # Keep in mind you can assign values other than :controller and :action + + # Sample of named route: + # map.purchase 'products/:id/purchase', :controller => 'catalog', :action => 'purchase' + # This route can be invoked with purchase_url(:id => product.id) + + # Sample resource route (maps HTTP verbs to controller actions automatically): + # map.resources :products + + # Sample resource route with options: + # map.resources :products, :member => { :short => :get, :toggle => :post }, :collection => { :sold => :get } + + # Sample resource route with sub-resources: + # map.resources :products, :has_many => [ :comments, :sales ], :has_one => :seller + + # Sample resource route within a namespace: + # map.namespace :admin do |admin| + # # Directs /admin/products/* to Admin::ProductsController (app/controllers/admin/products_controller.rb) + # admin.resources :products + # end + + # You can have the root of your site routed with map.root -- just remember to delete public/index.html. + # map.root :controller => "welcome" + + # See how all your routes lay out with "rake routes" + + # Install the default routes as the lowest priority. + map.connect ':controller/:action/:id' + map.connect ':controller/:action/:id.:format' +end diff --git a/vendor/gems/gems/thin-1.2.5/spec/rails_app/public/404.html b/vendor/gems/gems/thin-1.2.5/spec/rails_app/public/404.html new file mode 100755 index 00000000..eff660b9 --- /dev/null +++ b/vendor/gems/gems/thin-1.2.5/spec/rails_app/public/404.html @@ -0,0 +1,30 @@ + + + + + + + The page you were looking for doesn't exist (404) + + + + + +
+

The page you were looking for doesn't exist.

+

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

+
+ + \ No newline at end of file diff --git a/vendor/gems/gems/thin-1.2.5/spec/rails_app/public/422.html b/vendor/gems/gems/thin-1.2.5/spec/rails_app/public/422.html new file mode 100755 index 00000000..b54e4a3c --- /dev/null +++ b/vendor/gems/gems/thin-1.2.5/spec/rails_app/public/422.html @@ -0,0 +1,30 @@ + + + + + + + The change you wanted was rejected (422) + + + + + +
+

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/vendor/gems/gems/thin-1.2.5/spec/rails_app/public/500.html b/vendor/gems/gems/thin-1.2.5/spec/rails_app/public/500.html new file mode 100755 index 00000000..0e9c14f4 --- /dev/null +++ b/vendor/gems/gems/thin-1.2.5/spec/rails_app/public/500.html @@ -0,0 +1,30 @@ + + + + + + + We're sorry, but something went wrong (500) + + + + + +
+

We're sorry, but something went wrong.

+

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

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

Getting started

+

Here’s how to get rolling:

+ +
    +
  1. +

    Create your databases and edit config/database.yml

    +

    Rails needs to know your login and password.

    +
  2. + +
  3. +

    Use script/generate to create your models and controllers

    +

    To see all available options, run it without parameters.

    +
  4. + +
  5. +

    Set up a default route and remove or rename this file

    +

    Routes are set up in config/routes.rb.

    +
  6. +
+
+
+ + +
+ + \ No newline at end of file diff --git a/vendor/gems/gems/thin-1.2.5/spec/rails_app/public/javascripts/application.js b/vendor/gems/gems/thin-1.2.5/spec/rails_app/public/javascripts/application.js new file mode 100755 index 00000000..fe457769 --- /dev/null +++ b/vendor/gems/gems/thin-1.2.5/spec/rails_app/public/javascripts/application.js @@ -0,0 +1,2 @@ +// Place your application-specific JavaScript functions and classes here +// This file is automatically included by javascript_include_tag :defaults diff --git a/vendor/gems/gems/thin-1.2.5/spec/rails_app/public/javascripts/controls.js b/vendor/gems/gems/thin-1.2.5/spec/rails_app/public/javascripts/controls.js new file mode 100755 index 00000000..fbc4418b --- /dev/null +++ b/vendor/gems/gems/thin-1.2.5/spec/rails_app/public/javascripts/controls.js @@ -0,0 +1,963 @@ +// Copyright (c) 2005-2007 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us) +// (c) 2005-2007 Ivan Krstic (http://blogs.law.harvard.edu/ivan) +// (c) 2005-2007 Jon Tirsen (http://www.tirsen.com) +// Contributors: +// Richard Livsey +// Rahul Bhargava +// Rob Wills +// +// script.aculo.us is freely distributable under the terms of an MIT-style license. +// For details, see the script.aculo.us web site: http://script.aculo.us/ + +// Autocompleter.Base handles all the autocompletion functionality +// that's independent of the data source for autocompletion. This +// includes drawing the autocompletion menu, observing keyboard +// and mouse events, and similar. +// +// Specific autocompleters need to provide, at the very least, +// a getUpdatedChoices function that will be invoked every time +// the text inside the monitored textbox changes. This method +// should get the text for which to provide autocompletion by +// invoking this.getToken(), NOT by directly accessing +// this.element.value. This is to allow incremental tokenized +// autocompletion. Specific auto-completion logic (AJAX, etc) +// belongs in getUpdatedChoices. +// +// Tokenized incremental autocompletion is enabled automatically +// when an autocompleter is instantiated with the 'tokens' option +// in the options parameter, e.g.: +// new Ajax.Autocompleter('id','upd', '/url/', { tokens: ',' }); +// will incrementally autocomplete with a comma as the token. +// Additionally, ',' in the above example can be replaced with +// a token array, e.g. { tokens: [',', '\n'] } which +// enables autocompletion on multiple tokens. This is most +// useful when one of the tokens is \n (a newline), as it +// allows smart autocompletion after linebreaks. + +if(typeof Effect == 'undefined') + throw("controls.js requires including script.aculo.us' effects.js library"); + +var Autocompleter = { } +Autocompleter.Base = Class.create({ + baseInitialize: function(element, update, options) { + element = $(element) + this.element = element; + this.update = $(update); + this.hasFocus = false; + this.changed = false; + this.active = false; + this.index = 0; + this.entryCount = 0; + this.oldElementValue = this.element.value; + + if(this.setOptions) + this.setOptions(options); + else + this.options = options || { }; + + this.options.paramName = this.options.paramName || this.element.name; + this.options.tokens = this.options.tokens || []; + this.options.frequency = this.options.frequency || 0.4; + this.options.minChars = this.options.minChars || 1; + this.options.onShow = this.options.onShow || + function(element, update){ + if(!update.style.position || update.style.position=='absolute') { + update.style.position = 'absolute'; + Position.clone(element, update, { + setHeight: false, + offsetTop: element.offsetHeight + }); + } + Effect.Appear(update,{duration:0.15}); + }; + this.options.onHide = this.options.onHide || + function(element, update){ new Effect.Fade(update,{duration:0.15}) }; + + if(typeof(this.options.tokens) == 'string') + this.options.tokens = new Array(this.options.tokens); + // Force carriage returns as token delimiters anyway + if (!this.options.tokens.include('\n')) + this.options.tokens.push('\n'); + + this.observer = null; + + this.element.setAttribute('autocomplete','off'); + + Element.hide(this.update); + + Event.observe(this.element, 'blur', this.onBlur.bindAsEventListener(this)); + Event.observe(this.element, 'keydown', this.onKeyPress.bindAsEventListener(this)); + }, + + show: function() { + if(Element.getStyle(this.update, 'display')=='none') this.options.onShow(this.element, this.update); + if(!this.iefix && + (Prototype.Browser.IE) && + (Element.getStyle(this.update, 'position')=='absolute')) { + new Insertion.After(this.update, + ''); + this.iefix = $(this.update.id+'_iefix'); + } + if(this.iefix) setTimeout(this.fixIEOverlapping.bind(this), 50); + }, + + fixIEOverlapping: function() { + Position.clone(this.update, this.iefix, {setTop:(!this.update.style.height)}); + this.iefix.style.zIndex = 1; + this.update.style.zIndex = 2; + Element.show(this.iefix); + }, + + hide: function() { + this.stopIndicator(); + if(Element.getStyle(this.update, 'display')!='none') this.options.onHide(this.element, this.update); + if(this.iefix) Element.hide(this.iefix); + }, + + startIndicator: function() { + if(this.options.indicator) Element.show(this.options.indicator); + }, + + stopIndicator: function() { + if(this.options.indicator) Element.hide(this.options.indicator); + }, + + onKeyPress: function(event) { + if(this.active) + switch(event.keyCode) { + case Event.KEY_TAB: + case Event.KEY_RETURN: + this.selectEntry(); + Event.stop(event); + case Event.KEY_ESC: + this.hide(); + this.active = false; + Event.stop(event); + return; + case Event.KEY_LEFT: + case Event.KEY_RIGHT: + return; + case Event.KEY_UP: + this.markPrevious(); + this.render(); + Event.stop(event); + return; + case Event.KEY_DOWN: + this.markNext(); + this.render(); + Event.stop(event); + return; + } + else + if(event.keyCode==Event.KEY_TAB || event.keyCode==Event.KEY_RETURN || + (Prototype.Browser.WebKit > 0 && event.keyCode == 0)) return; + + this.changed = true; + this.hasFocus = true; + + if(this.observer) clearTimeout(this.observer); + this.observer = + setTimeout(this.onObserverEvent.bind(this), this.options.frequency*1000); + }, + + activate: function() { + this.changed = false; + this.hasFocus = true; + this.getUpdatedChoices(); + }, + + onHover: function(event) { + var element = Event.findElement(event, 'LI'); + if(this.index != element.autocompleteIndex) + { + this.index = element.autocompleteIndex; + this.render(); + } + Event.stop(event); + }, + + onClick: function(event) { + var element = Event.findElement(event, 'LI'); + this.index = element.autocompleteIndex; + this.selectEntry(); + this.hide(); + }, + + onBlur: function(event) { + // needed to make click events working + setTimeout(this.hide.bind(this), 250); + this.hasFocus = false; + this.active = false; + }, + + render: function() { + if(this.entryCount > 0) { + for (var i = 0; i < this.entryCount; i++) + this.index==i ? + Element.addClassName(this.getEntry(i),"selected") : + Element.removeClassName(this.getEntry(i),"selected"); + if(this.hasFocus) { + this.show(); + this.active = true; + } + } else { + this.active = false; + this.hide(); + } + }, + + markPrevious: function() { + if(this.index > 0) this.index-- + else this.index = this.entryCount-1; + this.getEntry(this.index).scrollIntoView(true); + }, + + markNext: function() { + if(this.index < this.entryCount-1) this.index++ + else this.index = 0; + this.getEntry(this.index).scrollIntoView(false); + }, + + getEntry: function(index) { + return this.update.firstChild.childNodes[index]; + }, + + getCurrentEntry: function() { + return this.getEntry(this.index); + }, + + selectEntry: function() { + this.active = false; + this.updateElement(this.getCurrentEntry()); + }, + + updateElement: function(selectedElement) { + if (this.options.updateElement) { + this.options.updateElement(selectedElement); + return; + } + var value = ''; + if (this.options.select) { + var nodes = $(selectedElement).select('.' + this.options.select) || []; + if(nodes.length>0) value = Element.collectTextNodes(nodes[0], this.options.select); + } else + value = Element.collectTextNodesIgnoreClass(selectedElement, 'informal'); + + var bounds = this.getTokenBounds(); + if (bounds[0] != -1) { + var newValue = this.element.value.substr(0, bounds[0]); + var whitespace = this.element.value.substr(bounds[0]).match(/^\s+/); + if (whitespace) + newValue += whitespace[0]; + this.element.value = newValue + value + this.element.value.substr(bounds[1]); + } else { + this.element.value = value; + } + this.oldElementValue = this.element.value; + this.element.focus(); + + if (this.options.afterUpdateElement) + this.options.afterUpdateElement(this.element, selectedElement); + }, + + updateChoices: function(choices) { + if(!this.changed && this.hasFocus) { + this.update.innerHTML = choices; + Element.cleanWhitespace(this.update); + Element.cleanWhitespace(this.update.down()); + + if(this.update.firstChild && this.update.down().childNodes) { + this.entryCount = + this.update.down().childNodes.length; + for (var i = 0; i < this.entryCount; i++) { + var entry = this.getEntry(i); + entry.autocompleteIndex = i; + this.addObservers(entry); + } + } else { + this.entryCount = 0; + } + + this.stopIndicator(); + this.index = 0; + + if(this.entryCount==1 && this.options.autoSelect) { + this.selectEntry(); + this.hide(); + } else { + this.render(); + } + } + }, + + addObservers: function(element) { + Event.observe(element, "mouseover", this.onHover.bindAsEventListener(this)); + Event.observe(element, "click", this.onClick.bindAsEventListener(this)); + }, + + onObserverEvent: function() { + this.changed = false; + this.tokenBounds = null; + if(this.getToken().length>=this.options.minChars) { + this.getUpdatedChoices(); + } else { + this.active = false; + this.hide(); + } + this.oldElementValue = this.element.value; + }, + + getToken: function() { + var bounds = this.getTokenBounds(); + return this.element.value.substring(bounds[0], bounds[1]).strip(); + }, + + getTokenBounds: function() { + if (null != this.tokenBounds) return this.tokenBounds; + var value = this.element.value; + if (value.strip().empty()) return [-1, 0]; + var diff = arguments.callee.getFirstDifferencePos(value, this.oldElementValue); + var offset = (diff == this.oldElementValue.length ? 1 : 0); + var prevTokenPos = -1, nextTokenPos = value.length; + var tp; + for (var index = 0, l = this.options.tokens.length; index < l; ++index) { + tp = value.lastIndexOf(this.options.tokens[index], diff + offset - 1); + if (tp > prevTokenPos) prevTokenPos = tp; + tp = value.indexOf(this.options.tokens[index], diff + offset); + if (-1 != tp && tp < nextTokenPos) nextTokenPos = tp; + } + return (this.tokenBounds = [prevTokenPos + 1, nextTokenPos]); + } +}); + +Autocompleter.Base.prototype.getTokenBounds.getFirstDifferencePos = function(newS, oldS) { + var boundary = Math.min(newS.length, oldS.length); + for (var index = 0; index < boundary; ++index) + if (newS[index] != oldS[index]) + return index; + return boundary; +}; + +Ajax.Autocompleter = Class.create(Autocompleter.Base, { + initialize: function(element, update, url, options) { + this.baseInitialize(element, update, options); + this.options.asynchronous = true; + this.options.onComplete = this.onComplete.bind(this); + this.options.defaultParams = this.options.parameters || null; + this.url = url; + }, + + getUpdatedChoices: function() { + this.startIndicator(); + + var entry = encodeURIComponent(this.options.paramName) + '=' + + encodeURIComponent(this.getToken()); + + this.options.parameters = this.options.callback ? + this.options.callback(this.element, entry) : entry; + + if(this.options.defaultParams) + this.options.parameters += '&' + this.options.defaultParams; + + new Ajax.Request(this.url, this.options); + }, + + onComplete: function(request) { + this.updateChoices(request.responseText); + } +}); + +// The local array autocompleter. Used when you'd prefer to +// inject an array of autocompletion options into the page, rather +// than sending out Ajax queries, which can be quite slow sometimes. +// +// The constructor takes four parameters. The first two are, as usual, +// the id of the monitored textbox, and id of the autocompletion menu. +// The third is the array you want to autocomplete from, and the fourth +// is the options block. +// +// Extra local autocompletion options: +// - choices - How many autocompletion choices to offer +// +// - partialSearch - If false, the autocompleter will match entered +// text only at the beginning of strings in the +// autocomplete array. Defaults to true, which will +// match text at the beginning of any *word* in the +// strings in the autocomplete array. If you want to +// search anywhere in the string, additionally set +// the option fullSearch to true (default: off). +// +// - fullSsearch - Search anywhere in autocomplete array strings. +// +// - partialChars - How many characters to enter before triggering +// a partial match (unlike minChars, which defines +// how many characters are required to do any match +// at all). Defaults to 2. +// +// - ignoreCase - Whether to ignore case when autocompleting. +// Defaults to true. +// +// It's possible to pass in a custom function as the 'selector' +// option, if you prefer to write your own autocompletion logic. +// In that case, the other options above will not apply unless +// you support them. + +Autocompleter.Local = Class.create(Autocompleter.Base, { + initialize: function(element, update, array, options) { + this.baseInitialize(element, update, options); + this.options.array = array; + }, + + getUpdatedChoices: function() { + this.updateChoices(this.options.selector(this)); + }, + + setOptions: function(options) { + this.options = Object.extend({ + choices: 10, + partialSearch: true, + partialChars: 2, + ignoreCase: true, + fullSearch: false, + selector: function(instance) { + var ret = []; // Beginning matches + var partial = []; // Inside matches + var entry = instance.getToken(); + var count = 0; + + for (var i = 0; i < instance.options.array.length && + ret.length < instance.options.choices ; i++) { + + var elem = instance.options.array[i]; + var foundPos = instance.options.ignoreCase ? + elem.toLowerCase().indexOf(entry.toLowerCase()) : + elem.indexOf(entry); + + while (foundPos != -1) { + if (foundPos == 0 && elem.length != entry.length) { + ret.push("
  • " + elem.substr(0, entry.length) + "" + + elem.substr(entry.length) + "
  • "); + break; + } else if (entry.length >= instance.options.partialChars && + instance.options.partialSearch && foundPos != -1) { + if (instance.options.fullSearch || /\s/.test(elem.substr(foundPos-1,1))) { + partial.push("
  • " + elem.substr(0, foundPos) + "" + + elem.substr(foundPos, entry.length) + "" + elem.substr( + foundPos + entry.length) + "
  • "); + break; + } + } + + foundPos = instance.options.ignoreCase ? + elem.toLowerCase().indexOf(entry.toLowerCase(), foundPos + 1) : + elem.indexOf(entry, foundPos + 1); + + } + } + if (partial.length) + ret = ret.concat(partial.slice(0, instance.options.choices - ret.length)) + return "
      " + ret.join('') + "
    "; + } + }, options || { }); + } +}); + +// AJAX in-place editor and collection editor +// Full rewrite by Christophe Porteneuve (April 2007). + +// Use this if you notice weird scrolling problems on some browsers, +// the DOM might be a bit confused when this gets called so do this +// waits 1 ms (with setTimeout) until it does the activation +Field.scrollFreeActivate = function(field) { + setTimeout(function() { + Field.activate(field); + }, 1); +} + +Ajax.InPlaceEditor = Class.create({ + initialize: function(element, url, options) { + this.url = url; + this.element = element = $(element); + this.prepareOptions(); + this._controls = { }; + arguments.callee.dealWithDeprecatedOptions(options); // DEPRECATION LAYER!!! + Object.extend(this.options, options || { }); + if (!this.options.formId && this.element.id) { + this.options.formId = this.element.id + '-inplaceeditor'; + if ($(this.options.formId)) + this.options.formId = ''; + } + if (this.options.externalControl) + this.options.externalControl = $(this.options.externalControl); + if (!this.options.externalControl) + this.options.externalControlOnly = false; + this._originalBackground = this.element.getStyle('background-color') || 'transparent'; + this.element.title = this.options.clickToEditText; + this._boundCancelHandler = this.handleFormCancellation.bind(this); + this._boundComplete = (this.options.onComplete || Prototype.emptyFunction).bind(this); + this._boundFailureHandler = this.handleAJAXFailure.bind(this); + this._boundSubmitHandler = this.handleFormSubmission.bind(this); + this._boundWrapperHandler = this.wrapUp.bind(this); + this.registerListeners(); + }, + checkForEscapeOrReturn: function(e) { + if (!this._editing || e.ctrlKey || e.altKey || e.shiftKey) return; + if (Event.KEY_ESC == e.keyCode) + this.handleFormCancellation(e); + else if (Event.KEY_RETURN == e.keyCode) + this.handleFormSubmission(e); + }, + createControl: function(mode, handler, extraClasses) { + var control = this.options[mode + 'Control']; + var text = this.options[mode + 'Text']; + if ('button' == control) { + var btn = document.createElement('input'); + btn.type = 'submit'; + btn.value = text; + btn.className = 'editor_' + mode + '_button'; + if ('cancel' == mode) + btn.onclick = this._boundCancelHandler; + this._form.appendChild(btn); + this._controls[mode] = btn; + } else if ('link' == control) { + var link = document.createElement('a'); + link.href = '#'; + link.appendChild(document.createTextNode(text)); + link.onclick = 'cancel' == mode ? this._boundCancelHandler : this._boundSubmitHandler; + link.className = 'editor_' + mode + '_link'; + if (extraClasses) + link.className += ' ' + extraClasses; + this._form.appendChild(link); + this._controls[mode] = link; + } + }, + createEditField: function() { + var text = (this.options.loadTextURL ? this.options.loadingText : this.getText()); + var fld; + if (1 >= this.options.rows && !/\r|\n/.test(this.getText())) { + fld = document.createElement('input'); + fld.type = 'text'; + var size = this.options.size || this.options.cols || 0; + if (0 < size) fld.size = size; + } else { + fld = document.createElement('textarea'); + fld.rows = (1 >= this.options.rows ? this.options.autoRows : this.options.rows); + fld.cols = this.options.cols || 40; + } + fld.name = this.options.paramName; + fld.value = text; // No HTML breaks conversion anymore + fld.className = 'editor_field'; + if (this.options.submitOnBlur) + fld.onblur = this._boundSubmitHandler; + this._controls.editor = fld; + if (this.options.loadTextURL) + this.loadExternalText(); + this._form.appendChild(this._controls.editor); + }, + createForm: function() { + var ipe = this; + function addText(mode, condition) { + var text = ipe.options['text' + mode + 'Controls']; + if (!text || condition === false) return; + ipe._form.appendChild(document.createTextNode(text)); + }; + this._form = $(document.createElement('form')); + this._form.id = this.options.formId; + this._form.addClassName(this.options.formClassName); + this._form.onsubmit = this._boundSubmitHandler; + this.createEditField(); + if ('textarea' == this._controls.editor.tagName.toLowerCase()) + this._form.appendChild(document.createElement('br')); + if (this.options.onFormCustomization) + this.options.onFormCustomization(this, this._form); + addText('Before', this.options.okControl || this.options.cancelControl); + this.createControl('ok', this._boundSubmitHandler); + addText('Between', this.options.okControl && this.options.cancelControl); + this.createControl('cancel', this._boundCancelHandler, 'editor_cancel'); + addText('After', this.options.okControl || this.options.cancelControl); + }, + destroy: function() { + if (this._oldInnerHTML) + this.element.innerHTML = this._oldInnerHTML; + this.leaveEditMode(); + this.unregisterListeners(); + }, + enterEditMode: function(e) { + if (this._saving || this._editing) return; + this._editing = true; + this.triggerCallback('onEnterEditMode'); + if (this.options.externalControl) + this.options.externalControl.hide(); + this.element.hide(); + this.createForm(); + this.element.parentNode.insertBefore(this._form, this.element); + if (!this.options.loadTextURL) + this.postProcessEditField(); + if (e) Event.stop(e); + }, + enterHover: function(e) { + if (this.options.hoverClassName) + this.element.addClassName(this.options.hoverClassName); + if (this._saving) return; + this.triggerCallback('onEnterHover'); + }, + getText: function() { + return this.element.innerHTML; + }, + handleAJAXFailure: function(transport) { + this.triggerCallback('onFailure', transport); + if (this._oldInnerHTML) { + this.element.innerHTML = this._oldInnerHTML; + this._oldInnerHTML = null; + } + }, + handleFormCancellation: function(e) { + this.wrapUp(); + if (e) Event.stop(e); + }, + handleFormSubmission: function(e) { + var form = this._form; + var value = $F(this._controls.editor); + this.prepareSubmission(); + var params = this.options.callback(form, value) || ''; + if (Object.isString(params)) + params = params.toQueryParams(); + params.editorId = this.element.id; + if (this.options.htmlResponse) { + var options = Object.extend({ evalScripts: true }, this.options.ajaxOptions); + Object.extend(options, { + parameters: params, + onComplete: this._boundWrapperHandler, + onFailure: this._boundFailureHandler + }); + new Ajax.Updater({ success: this.element }, this.url, options); + } else { + var options = Object.extend({ method: 'get' }, this.options.ajaxOptions); + Object.extend(options, { + parameters: params, + onComplete: this._boundWrapperHandler, + onFailure: this._boundFailureHandler + }); + new Ajax.Request(this.url, options); + } + if (e) Event.stop(e); + }, + leaveEditMode: function() { + this.element.removeClassName(this.options.savingClassName); + this.removeForm(); + this.leaveHover(); + this.element.style.backgroundColor = this._originalBackground; + this.element.show(); + if (this.options.externalControl) + this.options.externalControl.show(); + this._saving = false; + this._editing = false; + this._oldInnerHTML = null; + this.triggerCallback('onLeaveEditMode'); + }, + leaveHover: function(e) { + if (this.options.hoverClassName) + this.element.removeClassName(this.options.hoverClassName); + if (this._saving) return; + this.triggerCallback('onLeaveHover'); + }, + loadExternalText: function() { + this._form.addClassName(this.options.loadingClassName); + this._controls.editor.disabled = true; + var options = Object.extend({ method: 'get' }, this.options.ajaxOptions); + Object.extend(options, { + parameters: 'editorId=' + encodeURIComponent(this.element.id), + onComplete: Prototype.emptyFunction, + onSuccess: function(transport) { + this._form.removeClassName(this.options.loadingClassName); + var text = transport.responseText; + if (this.options.stripLoadedTextTags) + text = text.stripTags(); + this._controls.editor.value = text; + this._controls.editor.disabled = false; + this.postProcessEditField(); + }.bind(this), + onFailure: this._boundFailureHandler + }); + new Ajax.Request(this.options.loadTextURL, options); + }, + postProcessEditField: function() { + var fpc = this.options.fieldPostCreation; + if (fpc) + $(this._controls.editor)['focus' == fpc ? 'focus' : 'activate'](); + }, + prepareOptions: function() { + this.options = Object.clone(Ajax.InPlaceEditor.DefaultOptions); + Object.extend(this.options, Ajax.InPlaceEditor.DefaultCallbacks); + [this._extraDefaultOptions].flatten().compact().each(function(defs) { + Object.extend(this.options, defs); + }.bind(this)); + }, + prepareSubmission: function() { + this._saving = true; + this.removeForm(); + this.leaveHover(); + this.showSaving(); + }, + registerListeners: function() { + this._listeners = { }; + var listener; + $H(Ajax.InPlaceEditor.Listeners).each(function(pair) { + listener = this[pair.value].bind(this); + this._listeners[pair.key] = listener; + if (!this.options.externalControlOnly) + this.element.observe(pair.key, listener); + if (this.options.externalControl) + this.options.externalControl.observe(pair.key, listener); + }.bind(this)); + }, + removeForm: function() { + if (!this._form) return; + this._form.remove(); + this._form = null; + this._controls = { }; + }, + showSaving: function() { + this._oldInnerHTML = this.element.innerHTML; + this.element.innerHTML = this.options.savingText; + this.element.addClassName(this.options.savingClassName); + this.element.style.backgroundColor = this._originalBackground; + this.element.show(); + }, + triggerCallback: function(cbName, arg) { + if ('function' == typeof this.options[cbName]) { + this.options[cbName](this, arg); + } + }, + unregisterListeners: function() { + $H(this._listeners).each(function(pair) { + if (!this.options.externalControlOnly) + this.element.stopObserving(pair.key, pair.value); + if (this.options.externalControl) + this.options.externalControl.stopObserving(pair.key, pair.value); + }.bind(this)); + }, + wrapUp: function(transport) { + this.leaveEditMode(); + // Can't use triggerCallback due to backward compatibility: requires + // binding + direct element + this._boundComplete(transport, this.element); + } +}); + +Object.extend(Ajax.InPlaceEditor.prototype, { + dispose: Ajax.InPlaceEditor.prototype.destroy +}); + +Ajax.InPlaceCollectionEditor = Class.create(Ajax.InPlaceEditor, { + initialize: function($super, element, url, options) { + this._extraDefaultOptions = Ajax.InPlaceCollectionEditor.DefaultOptions; + $super(element, url, options); + }, + + createEditField: function() { + var list = document.createElement('select'); + list.name = this.options.paramName; + list.size = 1; + this._controls.editor = list; + this._collection = this.options.collection || []; + if (this.options.loadCollectionURL) + this.loadCollection(); + else + this.checkForExternalText(); + this._form.appendChild(this._controls.editor); + }, + + loadCollection: function() { + this._form.addClassName(this.options.loadingClassName); + this.showLoadingText(this.options.loadingCollectionText); + var options = Object.extend({ method: 'get' }, this.options.ajaxOptions); + Object.extend(options, { + parameters: 'editorId=' + encodeURIComponent(this.element.id), + onComplete: Prototype.emptyFunction, + onSuccess: function(transport) { + var js = transport.responseText.strip(); + if (!/^\[.*\]$/.test(js)) // TODO: improve sanity check + throw 'Server returned an invalid collection representation.'; + this._collection = eval(js); + this.checkForExternalText(); + }.bind(this), + onFailure: this.onFailure + }); + new Ajax.Request(this.options.loadCollectionURL, options); + }, + + showLoadingText: function(text) { + this._controls.editor.disabled = true; + var tempOption = this._controls.editor.firstChild; + if (!tempOption) { + tempOption = document.createElement('option'); + tempOption.value = ''; + this._controls.editor.appendChild(tempOption); + tempOption.selected = true; + } + tempOption.update((text || '').stripScripts().stripTags()); + }, + + checkForExternalText: function() { + this._text = this.getText(); + if (this.options.loadTextURL) + this.loadExternalText(); + else + this.buildOptionList(); + }, + + loadExternalText: function() { + this.showLoadingText(this.options.loadingText); + var options = Object.extend({ method: 'get' }, this.options.ajaxOptions); + Object.extend(options, { + parameters: 'editorId=' + encodeURIComponent(this.element.id), + onComplete: Prototype.emptyFunction, + onSuccess: function(transport) { + this._text = transport.responseText.strip(); + this.buildOptionList(); + }.bind(this), + onFailure: this.onFailure + }); + new Ajax.Request(this.options.loadTextURL, options); + }, + + buildOptionList: function() { + this._form.removeClassName(this.options.loadingClassName); + this._collection = this._collection.map(function(entry) { + return 2 === entry.length ? entry : [entry, entry].flatten(); + }); + var marker = ('value' in this.options) ? this.options.value : this._text; + var textFound = this._collection.any(function(entry) { + return entry[0] == marker; + }.bind(this)); + this._controls.editor.update(''); + var option; + this._collection.each(function(entry, index) { + option = document.createElement('option'); + option.value = entry[0]; + option.selected = textFound ? entry[0] == marker : 0 == index; + option.appendChild(document.createTextNode(entry[1])); + this._controls.editor.appendChild(option); + }.bind(this)); + this._controls.editor.disabled = false; + Field.scrollFreeActivate(this._controls.editor); + } +}); + +//**** DEPRECATION LAYER FOR InPlace[Collection]Editor! **** +//**** This only exists for a while, in order to let **** +//**** users adapt to the new API. Read up on the new **** +//**** API and convert your code to it ASAP! **** + +Ajax.InPlaceEditor.prototype.initialize.dealWithDeprecatedOptions = function(options) { + if (!options) return; + function fallback(name, expr) { + if (name in options || expr === undefined) return; + options[name] = expr; + }; + fallback('cancelControl', (options.cancelLink ? 'link' : (options.cancelButton ? 'button' : + options.cancelLink == options.cancelButton == false ? false : undefined))); + fallback('okControl', (options.okLink ? 'link' : (options.okButton ? 'button' : + options.okLink == options.okButton == false ? false : undefined))); + fallback('highlightColor', options.highlightcolor); + fallback('highlightEndColor', options.highlightendcolor); +}; + +Object.extend(Ajax.InPlaceEditor, { + DefaultOptions: { + ajaxOptions: { }, + autoRows: 3, // Use when multi-line w/ rows == 1 + cancelControl: 'link', // 'link'|'button'|false + cancelText: 'cancel', + clickToEditText: 'Click to edit', + externalControl: null, // id|elt + externalControlOnly: false, + fieldPostCreation: 'activate', // 'activate'|'focus'|false + formClassName: 'inplaceeditor-form', + formId: null, // id|elt + highlightColor: '#ffff99', + highlightEndColor: '#ffffff', + hoverClassName: '', + htmlResponse: true, + loadingClassName: 'inplaceeditor-loading', + loadingText: 'Loading...', + okControl: 'button', // 'link'|'button'|false + okText: 'ok', + paramName: 'value', + rows: 1, // If 1 and multi-line, uses autoRows + savingClassName: 'inplaceeditor-saving', + savingText: 'Saving...', + size: 0, + stripLoadedTextTags: false, + submitOnBlur: false, + textAfterControls: '', + textBeforeControls: '', + textBetweenControls: '' + }, + DefaultCallbacks: { + callback: function(form) { + return Form.serialize(form); + }, + onComplete: function(transport, element) { + // For backward compatibility, this one is bound to the IPE, and passes + // the element directly. It was too often customized, so we don't break it. + new Effect.Highlight(element, { + startcolor: this.options.highlightColor, keepBackgroundImage: true }); + }, + onEnterEditMode: null, + onEnterHover: function(ipe) { + ipe.element.style.backgroundColor = ipe.options.highlightColor; + if (ipe._effect) + ipe._effect.cancel(); + }, + onFailure: function(transport, ipe) { + alert('Error communication with the server: ' + transport.responseText.stripTags()); + }, + onFormCustomization: null, // Takes the IPE and its generated form, after editor, before controls. + onLeaveEditMode: null, + onLeaveHover: function(ipe) { + ipe._effect = new Effect.Highlight(ipe.element, { + startcolor: ipe.options.highlightColor, endcolor: ipe.options.highlightEndColor, + restorecolor: ipe._originalBackground, keepBackgroundImage: true + }); + } + }, + Listeners: { + click: 'enterEditMode', + keydown: 'checkForEscapeOrReturn', + mouseover: 'enterHover', + mouseout: 'leaveHover' + } +}); + +Ajax.InPlaceCollectionEditor.DefaultOptions = { + loadingCollectionText: 'Loading options...' +}; + +// Delayed observer, like Form.Element.Observer, +// but waits for delay after last key input +// Ideal for live-search fields + +Form.Element.DelayedObserver = Class.create({ + initialize: function(element, delay, callback) { + this.delay = delay || 0.5; + this.element = $(element); + this.callback = callback; + this.timer = null; + this.lastValue = $F(this.element); + Event.observe(this.element,'keyup',this.delayedListener.bindAsEventListener(this)); + }, + delayedListener: function(event) { + if(this.lastValue == $F(this.element)) return; + if(this.timer) clearTimeout(this.timer); + this.timer = setTimeout(this.onTimerEvent.bind(this), this.delay * 1000); + this.lastValue = $F(this.element); + }, + onTimerEvent: function() { + this.timer = null; + this.callback(this.element, $F(this.element)); + } +}); diff --git a/vendor/gems/gems/thin-1.2.5/spec/rails_app/public/javascripts/dragdrop.js b/vendor/gems/gems/thin-1.2.5/spec/rails_app/public/javascripts/dragdrop.js new file mode 100755 index 00000000..ccf4a1e4 --- /dev/null +++ b/vendor/gems/gems/thin-1.2.5/spec/rails_app/public/javascripts/dragdrop.js @@ -0,0 +1,972 @@ +// Copyright (c) 2005-2007 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us) +// (c) 2005-2007 Sammi Williams (http://www.oriontransfer.co.nz, sammi@oriontransfer.co.nz) +// +// script.aculo.us is freely distributable under the terms of an MIT-style license. +// For details, see the script.aculo.us web site: http://script.aculo.us/ + +if(Object.isUndefined(Effect)) + throw("dragdrop.js requires including script.aculo.us' effects.js library"); + +var Droppables = { + drops: [], + + remove: function(element) { + this.drops = this.drops.reject(function(d) { return d.element==$(element) }); + }, + + add: function(element) { + element = $(element); + var options = Object.extend({ + greedy: true, + hoverclass: null, + tree: false + }, arguments[1] || { }); + + // cache containers + if(options.containment) { + options._containers = []; + var containment = options.containment; + if(Object.isArray(containment)) { + containment.each( function(c) { options._containers.push($(c)) }); + } else { + options._containers.push($(containment)); + } + } + + if(options.accept) options.accept = [options.accept].flatten(); + + Element.makePositioned(element); // fix IE + options.element = element; + + this.drops.push(options); + }, + + findDeepestChild: function(drops) { + deepest = drops[0]; + + for (i = 1; i < drops.length; ++i) + if (Element.isParent(drops[i].element, deepest.element)) + deepest = drops[i]; + + return deepest; + }, + + isContained: function(element, drop) { + var containmentNode; + if(drop.tree) { + containmentNode = element.treeNode; + } else { + containmentNode = element.parentNode; + } + return drop._containers.detect(function(c) { return containmentNode == c }); + }, + + isAffected: function(point, element, drop) { + return ( + (drop.element!=element) && + ((!drop._containers) || + this.isContained(element, drop)) && + ((!drop.accept) || + (Element.classNames(element).detect( + function(v) { return drop.accept.include(v) } ) )) && + Position.within(drop.element, point[0], point[1]) ); + }, + + deactivate: function(drop) { + if(drop.hoverclass) + Element.removeClassName(drop.element, drop.hoverclass); + this.last_active = null; + }, + + activate: function(drop) { + if(drop.hoverclass) + Element.addClassName(drop.element, drop.hoverclass); + this.last_active = drop; + }, + + show: function(point, element) { + if(!this.drops.length) return; + var drop, affected = []; + + this.drops.each( function(drop) { + if(Droppables.isAffected(point, element, drop)) + affected.push(drop); + }); + + if(affected.length>0) + drop = Droppables.findDeepestChild(affected); + + if(this.last_active && this.last_active != drop) this.deactivate(this.last_active); + if (drop) { + Position.within(drop.element, point[0], point[1]); + if(drop.onHover) + drop.onHover(element, drop.element, Position.overlap(drop.overlap, drop.element)); + + if (drop != this.last_active) Droppables.activate(drop); + } + }, + + fire: function(event, element) { + if(!this.last_active) return; + Position.prepare(); + + if (this.isAffected([Event.pointerX(event), Event.pointerY(event)], element, this.last_active)) + if (this.last_active.onDrop) { + this.last_active.onDrop(element, this.last_active.element, event); + return true; + } + }, + + reset: function() { + if(this.last_active) + this.deactivate(this.last_active); + } +} + +var Draggables = { + drags: [], + observers: [], + + register: function(draggable) { + if(this.drags.length == 0) { + this.eventMouseUp = this.endDrag.bindAsEventListener(this); + this.eventMouseMove = this.updateDrag.bindAsEventListener(this); + this.eventKeypress = this.keyPress.bindAsEventListener(this); + + Event.observe(document, "mouseup", this.eventMouseUp); + Event.observe(document, "mousemove", this.eventMouseMove); + Event.observe(document, "keypress", this.eventKeypress); + } + this.drags.push(draggable); + }, + + unregister: function(draggable) { + this.drags = this.drags.reject(function(d) { return d==draggable }); + if(this.drags.length == 0) { + Event.stopObserving(document, "mouseup", this.eventMouseUp); + Event.stopObserving(document, "mousemove", this.eventMouseMove); + Event.stopObserving(document, "keypress", this.eventKeypress); + } + }, + + activate: function(draggable) { + if(draggable.options.delay) { + this._timeout = setTimeout(function() { + Draggables._timeout = null; + window.focus(); + Draggables.activeDraggable = draggable; + }.bind(this), draggable.options.delay); + } else { + window.focus(); // allows keypress events if window isn't currently focused, fails for Safari + this.activeDraggable = draggable; + } + }, + + deactivate: function() { + this.activeDraggable = null; + }, + + updateDrag: function(event) { + if(!this.activeDraggable) return; + var pointer = [Event.pointerX(event), Event.pointerY(event)]; + // Mozilla-based browsers fire successive mousemove events with + // the same coordinates, prevent needless redrawing (moz bug?) + if(this._lastPointer && (this._lastPointer.inspect() == pointer.inspect())) return; + this._lastPointer = pointer; + + this.activeDraggable.updateDrag(event, pointer); + }, + + endDrag: function(event) { + if(this._timeout) { + clearTimeout(this._timeout); + this._timeout = null; + } + if(!this.activeDraggable) return; + this._lastPointer = null; + this.activeDraggable.endDrag(event); + this.activeDraggable = null; + }, + + keyPress: function(event) { + if(this.activeDraggable) + this.activeDraggable.keyPress(event); + }, + + addObserver: function(observer) { + this.observers.push(observer); + this._cacheObserverCallbacks(); + }, + + removeObserver: function(element) { // element instead of observer fixes mem leaks + this.observers = this.observers.reject( function(o) { return o.element==element }); + this._cacheObserverCallbacks(); + }, + + notify: function(eventName, draggable, event) { // 'onStart', 'onEnd', 'onDrag' + if(this[eventName+'Count'] > 0) + this.observers.each( function(o) { + if(o[eventName]) o[eventName](eventName, draggable, event); + }); + if(draggable.options[eventName]) draggable.options[eventName](draggable, event); + }, + + _cacheObserverCallbacks: function() { + ['onStart','onEnd','onDrag'].each( function(eventName) { + Draggables[eventName+'Count'] = Draggables.observers.select( + function(o) { return o[eventName]; } + ).length; + }); + } +} + +/*--------------------------------------------------------------------------*/ + +var Draggable = Class.create({ + initialize: function(element) { + var defaults = { + handle: false, + reverteffect: function(element, top_offset, left_offset) { + var dur = Math.sqrt(Math.abs(top_offset^2)+Math.abs(left_offset^2))*0.02; + new Effect.Move(element, { x: -left_offset, y: -top_offset, duration: dur, + queue: {scope:'_draggable', position:'end'} + }); + }, + endeffect: function(element) { + var toOpacity = Object.isNumber(element._opacity) ? element._opacity : 1.0; + new Effect.Opacity(element, {duration:0.2, from:0.7, to:toOpacity, + queue: {scope:'_draggable', position:'end'}, + afterFinish: function(){ + Draggable._dragging[element] = false + } + }); + }, + zindex: 1000, + revert: false, + quiet: false, + scroll: false, + scrollSensitivity: 20, + scrollSpeed: 15, + snap: false, // false, or xy or [x,y] or function(x,y){ return [x,y] } + delay: 0 + }; + + if(!arguments[1] || Object.isUndefined(arguments[1].endeffect)) + Object.extend(defaults, { + starteffect: function(element) { + element._opacity = Element.getOpacity(element); + Draggable._dragging[element] = true; + new Effect.Opacity(element, {duration:0.2, from:element._opacity, to:0.7}); + } + }); + + var options = Object.extend(defaults, arguments[1] || { }); + + this.element = $(element); + + if(options.handle && Object.isString(options.handle)) + this.handle = this.element.down('.'+options.handle, 0); + + if(!this.handle) this.handle = $(options.handle); + if(!this.handle) this.handle = this.element; + + if(options.scroll && !options.scroll.scrollTo && !options.scroll.outerHTML) { + options.scroll = $(options.scroll); + this._isScrollChild = Element.childOf(this.element, options.scroll); + } + + Element.makePositioned(this.element); // fix IE + + this.options = options; + this.dragging = false; + + this.eventMouseDown = this.initDrag.bindAsEventListener(this); + Event.observe(this.handle, "mousedown", this.eventMouseDown); + + Draggables.register(this); + }, + + destroy: function() { + Event.stopObserving(this.handle, "mousedown", this.eventMouseDown); + Draggables.unregister(this); + }, + + currentDelta: function() { + return([ + parseInt(Element.getStyle(this.element,'left') || '0'), + parseInt(Element.getStyle(this.element,'top') || '0')]); + }, + + initDrag: function(event) { + if(!Object.isUndefined(Draggable._dragging[this.element]) && + Draggable._dragging[this.element]) return; + if(Event.isLeftClick(event)) { + // abort on form elements, fixes a Firefox issue + var src = Event.element(event); + if((tag_name = src.tagName.toUpperCase()) && ( + tag_name=='INPUT' || + tag_name=='SELECT' || + tag_name=='OPTION' || + tag_name=='BUTTON' || + tag_name=='TEXTAREA')) return; + + var pointer = [Event.pointerX(event), Event.pointerY(event)]; + var pos = Position.cumulativeOffset(this.element); + this.offset = [0,1].map( function(i) { return (pointer[i] - pos[i]) }); + + Draggables.activate(this); + Event.stop(event); + } + }, + + startDrag: function(event) { + this.dragging = true; + if(!this.delta) + this.delta = this.currentDelta(); + + if(this.options.zindex) { + this.originalZ = parseInt(Element.getStyle(this.element,'z-index') || 0); + this.element.style.zIndex = this.options.zindex; + } + + if(this.options.ghosting) { + this._clone = this.element.cloneNode(true); + this.element._originallyAbsolute = (this.element.getStyle('position') == 'absolute'); + if (!this.element._originallyAbsolute) + Position.absolutize(this.element); + this.element.parentNode.insertBefore(this._clone, this.element); + } + + if(this.options.scroll) { + if (this.options.scroll == window) { + var where = this._getWindowScroll(this.options.scroll); + this.originalScrollLeft = where.left; + this.originalScrollTop = where.top; + } else { + this.originalScrollLeft = this.options.scroll.scrollLeft; + this.originalScrollTop = this.options.scroll.scrollTop; + } + } + + Draggables.notify('onStart', this, event); + + if(this.options.starteffect) this.options.starteffect(this.element); + }, + + updateDrag: function(event, pointer) { + if(!this.dragging) this.startDrag(event); + + if(!this.options.quiet){ + Position.prepare(); + Droppables.show(pointer, this.element); + } + + Draggables.notify('onDrag', this, event); + + this.draw(pointer); + if(this.options.change) this.options.change(this); + + if(this.options.scroll) { + this.stopScrolling(); + + var p; + if (this.options.scroll == window) { + with(this._getWindowScroll(this.options.scroll)) { p = [ left, top, left+width, top+height ]; } + } else { + p = Position.page(this.options.scroll); + p[0] += this.options.scroll.scrollLeft + Position.deltaX; + p[1] += this.options.scroll.scrollTop + Position.deltaY; + p.push(p[0]+this.options.scroll.offsetWidth); + p.push(p[1]+this.options.scroll.offsetHeight); + } + var speed = [0,0]; + if(pointer[0] < (p[0]+this.options.scrollSensitivity)) speed[0] = pointer[0]-(p[0]+this.options.scrollSensitivity); + if(pointer[1] < (p[1]+this.options.scrollSensitivity)) speed[1] = pointer[1]-(p[1]+this.options.scrollSensitivity); + if(pointer[0] > (p[2]-this.options.scrollSensitivity)) speed[0] = pointer[0]-(p[2]-this.options.scrollSensitivity); + if(pointer[1] > (p[3]-this.options.scrollSensitivity)) speed[1] = pointer[1]-(p[3]-this.options.scrollSensitivity); + this.startScrolling(speed); + } + + // fix AppleWebKit rendering + if(Prototype.Browser.WebKit) window.scrollBy(0,0); + + Event.stop(event); + }, + + finishDrag: function(event, success) { + this.dragging = false; + + if(this.options.quiet){ + Position.prepare(); + var pointer = [Event.pointerX(event), Event.pointerY(event)]; + Droppables.show(pointer, this.element); + } + + if(this.options.ghosting) { + if (!this.element._originallyAbsolute) + Position.relativize(this.element); + delete this.element._originallyAbsolute; + Element.remove(this._clone); + this._clone = null; + } + + var dropped = false; + if(success) { + dropped = Droppables.fire(event, this.element); + if (!dropped) dropped = false; + } + if(dropped && this.options.onDropped) this.options.onDropped(this.element); + Draggables.notify('onEnd', this, event); + + var revert = this.options.revert; + if(revert && Object.isFunction(revert)) revert = revert(this.element); + + var d = this.currentDelta(); + if(revert && this.options.reverteffect) { + if (dropped == 0 || revert != 'failure') + this.options.reverteffect(this.element, + d[1]-this.delta[1], d[0]-this.delta[0]); + } else { + this.delta = d; + } + + if(this.options.zindex) + this.element.style.zIndex = this.originalZ; + + if(this.options.endeffect) + this.options.endeffect(this.element); + + Draggables.deactivate(this); + Droppables.reset(); + }, + + keyPress: function(event) { + if(event.keyCode!=Event.KEY_ESC) return; + this.finishDrag(event, false); + Event.stop(event); + }, + + endDrag: function(event) { + if(!this.dragging) return; + this.stopScrolling(); + this.finishDrag(event, true); + Event.stop(event); + }, + + draw: function(point) { + var pos = Position.cumulativeOffset(this.element); + if(this.options.ghosting) { + var r = Position.realOffset(this.element); + pos[0] += r[0] - Position.deltaX; pos[1] += r[1] - Position.deltaY; + } + + var d = this.currentDelta(); + pos[0] -= d[0]; pos[1] -= d[1]; + + if(this.options.scroll && (this.options.scroll != window && this._isScrollChild)) { + pos[0] -= this.options.scroll.scrollLeft-this.originalScrollLeft; + pos[1] -= this.options.scroll.scrollTop-this.originalScrollTop; + } + + var p = [0,1].map(function(i){ + return (point[i]-pos[i]-this.offset[i]) + }.bind(this)); + + if(this.options.snap) { + if(Object.isFunction(this.options.snap)) { + p = this.options.snap(p[0],p[1],this); + } else { + if(Object.isArray(this.options.snap)) { + p = p.map( function(v, i) { + return (v/this.options.snap[i]).round()*this.options.snap[i] }.bind(this)) + } else { + p = p.map( function(v) { + return (v/this.options.snap).round()*this.options.snap }.bind(this)) + } + }} + + var style = this.element.style; + if((!this.options.constraint) || (this.options.constraint=='horizontal')) + style.left = p[0] + "px"; + if((!this.options.constraint) || (this.options.constraint=='vertical')) + style.top = p[1] + "px"; + + if(style.visibility=="hidden") style.visibility = ""; // fix gecko rendering + }, + + stopScrolling: function() { + if(this.scrollInterval) { + clearInterval(this.scrollInterval); + this.scrollInterval = null; + Draggables._lastScrollPointer = null; + } + }, + + startScrolling: function(speed) { + if(!(speed[0] || speed[1])) return; + this.scrollSpeed = [speed[0]*this.options.scrollSpeed,speed[1]*this.options.scrollSpeed]; + this.lastScrolled = new Date(); + this.scrollInterval = setInterval(this.scroll.bind(this), 10); + }, + + scroll: function() { + var current = new Date(); + var delta = current - this.lastScrolled; + this.lastScrolled = current; + if(this.options.scroll == window) { + with (this._getWindowScroll(this.options.scroll)) { + if (this.scrollSpeed[0] || this.scrollSpeed[1]) { + var d = delta / 1000; + this.options.scroll.scrollTo( left + d*this.scrollSpeed[0], top + d*this.scrollSpeed[1] ); + } + } + } else { + this.options.scroll.scrollLeft += this.scrollSpeed[0] * delta / 1000; + this.options.scroll.scrollTop += this.scrollSpeed[1] * delta / 1000; + } + + Position.prepare(); + Droppables.show(Draggables._lastPointer, this.element); + Draggables.notify('onDrag', this); + if (this._isScrollChild) { + Draggables._lastScrollPointer = Draggables._lastScrollPointer || $A(Draggables._lastPointer); + Draggables._lastScrollPointer[0] += this.scrollSpeed[0] * delta / 1000; + Draggables._lastScrollPointer[1] += this.scrollSpeed[1] * delta / 1000; + if (Draggables._lastScrollPointer[0] < 0) + Draggables._lastScrollPointer[0] = 0; + if (Draggables._lastScrollPointer[1] < 0) + Draggables._lastScrollPointer[1] = 0; + this.draw(Draggables._lastScrollPointer); + } + + if(this.options.change) this.options.change(this); + }, + + _getWindowScroll: function(w) { + var T, L, W, H; + with (w.document) { + if (w.document.documentElement && documentElement.scrollTop) { + T = documentElement.scrollTop; + L = documentElement.scrollLeft; + } else if (w.document.body) { + T = body.scrollTop; + L = body.scrollLeft; + } + if (w.innerWidth) { + W = w.innerWidth; + H = w.innerHeight; + } else if (w.document.documentElement && documentElement.clientWidth) { + W = documentElement.clientWidth; + H = documentElement.clientHeight; + } else { + W = body.offsetWidth; + H = body.offsetHeight + } + } + return { top: T, left: L, width: W, height: H }; + } +}); + +Draggable._dragging = { }; + +/*--------------------------------------------------------------------------*/ + +var SortableObserver = Class.create({ + initialize: function(element, observer) { + this.element = $(element); + this.observer = observer; + this.lastValue = Sortable.serialize(this.element); + }, + + onStart: function() { + this.lastValue = Sortable.serialize(this.element); + }, + + onEnd: function() { + Sortable.unmark(); + if(this.lastValue != Sortable.serialize(this.element)) + this.observer(this.element) + } +}); + +var Sortable = { + SERIALIZE_RULE: /^[^_\-](?:[A-Za-z0-9\-\_]*)[_](.*)$/, + + sortables: { }, + + _findRootElement: function(element) { + while (element.tagName.toUpperCase() != "BODY") { + if(element.id && Sortable.sortables[element.id]) return element; + element = element.parentNode; + } + }, + + options: function(element) { + element = Sortable._findRootElement($(element)); + if(!element) return; + return Sortable.sortables[element.id]; + }, + + destroy: function(element){ + var s = Sortable.options(element); + + if(s) { + Draggables.removeObserver(s.element); + s.droppables.each(function(d){ Droppables.remove(d) }); + s.draggables.invoke('destroy'); + + delete Sortable.sortables[s.element.id]; + } + }, + + create: function(element) { + element = $(element); + var options = Object.extend({ + element: element, + tag: 'li', // assumes li children, override with tag: 'tagname' + dropOnEmpty: false, + tree: false, + treeTag: 'ul', + overlap: 'vertical', // one of 'vertical', 'horizontal' + constraint: 'vertical', // one of 'vertical', 'horizontal', false + containment: element, // also takes array of elements (or id's); or false + handle: false, // or a CSS class + only: false, + delay: 0, + hoverclass: null, + ghosting: false, + quiet: false, + scroll: false, + scrollSensitivity: 20, + scrollSpeed: 15, + format: this.SERIALIZE_RULE, + + // these take arrays of elements or ids and can be + // used for better initialization performance + elements: false, + handles: false, + + onChange: Prototype.emptyFunction, + onUpdate: Prototype.emptyFunction + }, arguments[1] || { }); + + // clear any old sortable with same element + this.destroy(element); + + // build options for the draggables + var options_for_draggable = { + revert: true, + quiet: options.quiet, + scroll: options.scroll, + scrollSpeed: options.scrollSpeed, + scrollSensitivity: options.scrollSensitivity, + delay: options.delay, + ghosting: options.ghosting, + constraint: options.constraint, + handle: options.handle }; + + if(options.starteffect) + options_for_draggable.starteffect = options.starteffect; + + if(options.reverteffect) + options_for_draggable.reverteffect = options.reverteffect; + else + if(options.ghosting) options_for_draggable.reverteffect = function(element) { + element.style.top = 0; + element.style.left = 0; + }; + + if(options.endeffect) + options_for_draggable.endeffect = options.endeffect; + + if(options.zindex) + options_for_draggable.zindex = options.zindex; + + // build options for the droppables + var options_for_droppable = { + overlap: options.overlap, + containment: options.containment, + tree: options.tree, + hoverclass: options.hoverclass, + onHover: Sortable.onHover + } + + var options_for_tree = { + onHover: Sortable.onEmptyHover, + overlap: options.overlap, + containment: options.containment, + hoverclass: options.hoverclass + } + + // fix for gecko engine + Element.cleanWhitespace(element); + + options.draggables = []; + options.droppables = []; + + // drop on empty handling + if(options.dropOnEmpty || options.tree) { + Droppables.add(element, options_for_tree); + options.droppables.push(element); + } + + (options.elements || this.findElements(element, options) || []).each( function(e,i) { + var handle = options.handles ? $(options.handles[i]) : + (options.handle ? $(e).select('.' + options.handle)[0] : e); + options.draggables.push( + new Draggable(e, Object.extend(options_for_draggable, { handle: handle }))); + Droppables.add(e, options_for_droppable); + if(options.tree) e.treeNode = element; + options.droppables.push(e); + }); + + if(options.tree) { + (Sortable.findTreeElements(element, options) || []).each( function(e) { + Droppables.add(e, options_for_tree); + e.treeNode = element; + options.droppables.push(e); + }); + } + + // keep reference + this.sortables[element.id] = options; + + // for onupdate + Draggables.addObserver(new SortableObserver(element, options.onUpdate)); + + }, + + // return all suitable-for-sortable elements in a guaranteed order + findElements: function(element, options) { + return Element.findChildren( + element, options.only, options.tree ? true : false, options.tag); + }, + + findTreeElements: function(element, options) { + return Element.findChildren( + element, options.only, options.tree ? true : false, options.treeTag); + }, + + onHover: function(element, dropon, overlap) { + if(Element.isParent(dropon, element)) return; + + if(overlap > .33 && overlap < .66 && Sortable.options(dropon).tree) { + return; + } else if(overlap>0.5) { + Sortable.mark(dropon, 'before'); + if(dropon.previousSibling != element) { + var oldParentNode = element.parentNode; + element.style.visibility = "hidden"; // fix gecko rendering + dropon.parentNode.insertBefore(element, dropon); + if(dropon.parentNode!=oldParentNode) + Sortable.options(oldParentNode).onChange(element); + Sortable.options(dropon.parentNode).onChange(element); + } + } else { + Sortable.mark(dropon, 'after'); + var nextElement = dropon.nextSibling || null; + if(nextElement != element) { + var oldParentNode = element.parentNode; + element.style.visibility = "hidden"; // fix gecko rendering + dropon.parentNode.insertBefore(element, nextElement); + if(dropon.parentNode!=oldParentNode) + Sortable.options(oldParentNode).onChange(element); + Sortable.options(dropon.parentNode).onChange(element); + } + } + }, + + onEmptyHover: function(element, dropon, overlap) { + var oldParentNode = element.parentNode; + var droponOptions = Sortable.options(dropon); + + if(!Element.isParent(dropon, element)) { + var index; + + var children = Sortable.findElements(dropon, {tag: droponOptions.tag, only: droponOptions.only}); + var child = null; + + if(children) { + var offset = Element.offsetSize(dropon, droponOptions.overlap) * (1.0 - overlap); + + for (index = 0; index < children.length; index += 1) { + if (offset - Element.offsetSize (children[index], droponOptions.overlap) >= 0) { + offset -= Element.offsetSize (children[index], droponOptions.overlap); + } else if (offset - (Element.offsetSize (children[index], droponOptions.overlap) / 2) >= 0) { + child = index + 1 < children.length ? children[index + 1] : null; + break; + } else { + child = children[index]; + break; + } + } + } + + dropon.insertBefore(element, child); + + Sortable.options(oldParentNode).onChange(element); + droponOptions.onChange(element); + } + }, + + unmark: function() { + if(Sortable._marker) Sortable._marker.hide(); + }, + + mark: function(dropon, position) { + // mark on ghosting only + var sortable = Sortable.options(dropon.parentNode); + if(sortable && !sortable.ghosting) return; + + if(!Sortable._marker) { + Sortable._marker = + ($('dropmarker') || Element.extend(document.createElement('DIV'))). + hide().addClassName('dropmarker').setStyle({position:'absolute'}); + document.getElementsByTagName("body").item(0).appendChild(Sortable._marker); + } + var offsets = Position.cumulativeOffset(dropon); + Sortable._marker.setStyle({left: offsets[0]+'px', top: offsets[1] + 'px'}); + + if(position=='after') + if(sortable.overlap == 'horizontal') + Sortable._marker.setStyle({left: (offsets[0]+dropon.clientWidth) + 'px'}); + else + Sortable._marker.setStyle({top: (offsets[1]+dropon.clientHeight) + 'px'}); + + Sortable._marker.show(); + }, + + _tree: function(element, options, parent) { + var children = Sortable.findElements(element, options) || []; + + for (var i = 0; i < children.length; ++i) { + var match = children[i].id.match(options.format); + + if (!match) continue; + + var child = { + id: encodeURIComponent(match ? match[1] : null), + element: element, + parent: parent, + children: [], + position: parent.children.length, + container: $(children[i]).down(options.treeTag) + } + + /* Get the element containing the children and recurse over it */ + if (child.container) + this._tree(child.container, options, child) + + parent.children.push (child); + } + + return parent; + }, + + tree: function(element) { + element = $(element); + var sortableOptions = this.options(element); + var options = Object.extend({ + tag: sortableOptions.tag, + treeTag: sortableOptions.treeTag, + only: sortableOptions.only, + name: element.id, + format: sortableOptions.format + }, arguments[1] || { }); + + var root = { + id: null, + parent: null, + children: [], + container: element, + position: 0 + } + + return Sortable._tree(element, options, root); + }, + + /* Construct a [i] index for a particular node */ + _constructIndex: function(node) { + var index = ''; + do { + if (node.id) index = '[' + node.position + ']' + index; + } while ((node = node.parent) != null); + return index; + }, + + sequence: function(element) { + element = $(element); + var options = Object.extend(this.options(element), arguments[1] || { }); + + return $(this.findElements(element, options) || []).map( function(item) { + return item.id.match(options.format) ? item.id.match(options.format)[1] : ''; + }); + }, + + setSequence: function(element, new_sequence) { + element = $(element); + var options = Object.extend(this.options(element), arguments[2] || { }); + + var nodeMap = { }; + this.findElements(element, options).each( function(n) { + if (n.id.match(options.format)) + nodeMap[n.id.match(options.format)[1]] = [n, n.parentNode]; + n.parentNode.removeChild(n); + }); + + new_sequence.each(function(ident) { + var n = nodeMap[ident]; + if (n) { + n[1].appendChild(n[0]); + delete nodeMap[ident]; + } + }); + }, + + serialize: function(element) { + element = $(element); + var options = Object.extend(Sortable.options(element), arguments[1] || { }); + var name = encodeURIComponent( + (arguments[1] && arguments[1].name) ? arguments[1].name : element.id); + + if (options.tree) { + return Sortable.tree(element, arguments[1]).children.map( function (item) { + return [name + Sortable._constructIndex(item) + "[id]=" + + encodeURIComponent(item.id)].concat(item.children.map(arguments.callee)); + }).flatten().join('&'); + } else { + return Sortable.sequence(element, arguments[1]).map( function(item) { + return name + "[]=" + encodeURIComponent(item); + }).join('&'); + } + } +} + +// Returns true if child is contained within element +Element.isParent = function(child, element) { + if (!child.parentNode || child == element) return false; + if (child.parentNode == element) return true; + return Element.isParent(child.parentNode, element); +} + +Element.findChildren = function(element, only, recursive, tagName) { + if(!element.hasChildNodes()) return null; + tagName = tagName.toUpperCase(); + if(only) only = [only].flatten(); + var elements = []; + $A(element.childNodes).each( function(e) { + if(e.tagName && e.tagName.toUpperCase()==tagName && + (!only || (Element.classNames(e).detect(function(v) { return only.include(v) })))) + elements.push(e); + if(recursive) { + var grandchildren = Element.findChildren(e, only, recursive, tagName); + if(grandchildren) elements.push(grandchildren); + } + }); + + return (elements.length>0 ? elements.flatten() : []); +} + +Element.offsetSize = function (element, type) { + return element['offset' + ((type=='vertical' || type=='height') ? 'Height' : 'Width')]; +} diff --git a/vendor/gems/gems/thin-1.2.5/spec/rails_app/public/javascripts/effects.js b/vendor/gems/gems/thin-1.2.5/spec/rails_app/public/javascripts/effects.js new file mode 100755 index 00000000..65aed239 --- /dev/null +++ b/vendor/gems/gems/thin-1.2.5/spec/rails_app/public/javascripts/effects.js @@ -0,0 +1,1120 @@ +// Copyright (c) 2005-2007 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us) +// Contributors: +// Justin Palmer (http://encytemedia.com/) +// Mark Pilgrim (http://diveintomark.org/) +// Martin Bialasinki +// +// script.aculo.us is freely distributable under the terms of an MIT-style license. +// For details, see the script.aculo.us web site: http://script.aculo.us/ + +// converts rgb() and #xxx to #xxxxxx format, +// returns self (or first argument) if not convertable +String.prototype.parseColor = function() { + var color = '#'; + if (this.slice(0,4) == 'rgb(') { + var cols = this.slice(4,this.length-1).split(','); + var i=0; do { color += parseInt(cols[i]).toColorPart() } while (++i<3); + } else { + if (this.slice(0,1) == '#') { + if (this.length==4) for(var i=1;i<4;i++) color += (this.charAt(i) + this.charAt(i)).toLowerCase(); + if (this.length==7) color = this.toLowerCase(); + } + } + return (color.length==7 ? color : (arguments[0] || this)); +}; + +/*--------------------------------------------------------------------------*/ + +Element.collectTextNodes = function(element) { + return $A($(element).childNodes).collect( function(node) { + return (node.nodeType==3 ? node.nodeValue : + (node.hasChildNodes() ? Element.collectTextNodes(node) : '')); + }).flatten().join(''); +}; + +Element.collectTextNodesIgnoreClass = function(element, className) { + return $A($(element).childNodes).collect( function(node) { + return (node.nodeType==3 ? node.nodeValue : + ((node.hasChildNodes() && !Element.hasClassName(node,className)) ? + Element.collectTextNodesIgnoreClass(node, className) : '')); + }).flatten().join(''); +}; + +Element.setContentZoom = function(element, percent) { + element = $(element); + element.setStyle({fontSize: (percent/100) + 'em'}); + if (Prototype.Browser.WebKit) window.scrollBy(0,0); + return element; +}; + +Element.getInlineOpacity = function(element){ + return $(element).style.opacity || ''; +}; + +Element.forceRerendering = function(element) { + try { + element = $(element); + var n = document.createTextNode(' '); + element.appendChild(n); + element.removeChild(n); + } catch(e) { } +}; + +/*--------------------------------------------------------------------------*/ + +var Effect = { + _elementDoesNotExistError: { + name: 'ElementDoesNotExistError', + message: 'The specified DOM element does not exist, but is required for this effect to operate' + }, + Transitions: { + linear: Prototype.K, + sinoidal: function(pos) { + return (-Math.cos(pos*Math.PI)/2) + 0.5; + }, + reverse: function(pos) { + return 1-pos; + }, + flicker: function(pos) { + var pos = ((-Math.cos(pos*Math.PI)/4) + 0.75) + Math.random()/4; + return pos > 1 ? 1 : pos; + }, + wobble: function(pos) { + return (-Math.cos(pos*Math.PI*(9*pos))/2) + 0.5; + }, + pulse: function(pos, pulses) { + pulses = pulses || 5; + return ( + ((pos % (1/pulses)) * pulses).round() == 0 ? + ((pos * pulses * 2) - (pos * pulses * 2).floor()) : + 1 - ((pos * pulses * 2) - (pos * pulses * 2).floor()) + ); + }, + spring: function(pos) { + return 1 - (Math.cos(pos * 4.5 * Math.PI) * Math.exp(-pos * 6)); + }, + none: function(pos) { + return 0; + }, + full: function(pos) { + return 1; + } + }, + DefaultOptions: { + duration: 1.0, // seconds + fps: 100, // 100= assume 66fps max. + sync: false, // true for combining + from: 0.0, + to: 1.0, + delay: 0.0, + queue: 'parallel' + }, + tagifyText: function(element) { + var tagifyStyle = 'position:relative'; + if (Prototype.Browser.IE) tagifyStyle += ';zoom:1'; + + element = $(element); + $A(element.childNodes).each( function(child) { + if (child.nodeType==3) { + child.nodeValue.toArray().each( function(character) { + element.insertBefore( + new Element('span', {style: tagifyStyle}).update( + character == ' ' ? String.fromCharCode(160) : character), + child); + }); + Element.remove(child); + } + }); + }, + multiple: function(element, effect) { + var elements; + if (((typeof element == 'object') || + Object.isFunction(element)) && + (element.length)) + elements = element; + else + elements = $(element).childNodes; + + var options = Object.extend({ + speed: 0.1, + delay: 0.0 + }, arguments[2] || { }); + var masterDelay = options.delay; + + $A(elements).each( function(element, index) { + new effect(element, Object.extend(options, { delay: index * options.speed + masterDelay })); + }); + }, + PAIRS: { + 'slide': ['SlideDown','SlideUp'], + 'blind': ['BlindDown','BlindUp'], + 'appear': ['Appear','Fade'] + }, + toggle: function(element, effect) { + element = $(element); + effect = (effect || 'appear').toLowerCase(); + var options = Object.extend({ + queue: { position:'end', scope:(element.id || 'global'), limit: 1 } + }, arguments[2] || { }); + Effect[element.visible() ? + Effect.PAIRS[effect][1] : Effect.PAIRS[effect][0]](element, options); + } +}; + +Effect.DefaultOptions.transition = Effect.Transitions.sinoidal; + +/* ------------- core effects ------------- */ + +Effect.ScopedQueue = Class.create(Enumerable, { + initialize: function() { + this.effects = []; + this.interval = null; + }, + _each: function(iterator) { + this.effects._each(iterator); + }, + add: function(effect) { + var timestamp = new Date().getTime(); + + var position = Object.isString(effect.options.queue) ? + effect.options.queue : effect.options.queue.position; + + switch(position) { + case 'front': + // move unstarted effects after this effect + this.effects.findAll(function(e){ return e.state=='idle' }).each( function(e) { + e.startOn += effect.finishOn; + e.finishOn += effect.finishOn; + }); + break; + case 'with-last': + timestamp = this.effects.pluck('startOn').max() || timestamp; + break; + case 'end': + // start effect after last queued effect has finished + timestamp = this.effects.pluck('finishOn').max() || timestamp; + break; + } + + effect.startOn += timestamp; + effect.finishOn += timestamp; + + if (!effect.options.queue.limit || (this.effects.length < effect.options.queue.limit)) + this.effects.push(effect); + + if (!this.interval) + this.interval = setInterval(this.loop.bind(this), 15); + }, + remove: function(effect) { + this.effects = this.effects.reject(function(e) { return e==effect }); + if (this.effects.length == 0) { + clearInterval(this.interval); + this.interval = null; + } + }, + loop: function() { + var timePos = new Date().getTime(); + for(var i=0, len=this.effects.length;i= this.startOn) { + if (timePos >= this.finishOn) { + this.render(1.0); + this.cancel(); + this.event('beforeFinish'); + if (this.finish) this.finish(); + this.event('afterFinish'); + return; + } + var pos = (timePos - this.startOn) / this.totalTime, + frame = (pos * this.totalFrames).round(); + if (frame > this.currentFrame) { + this.render(pos); + this.currentFrame = frame; + } + } + }, + cancel: function() { + if (!this.options.sync) + Effect.Queues.get(Object.isString(this.options.queue) ? + 'global' : this.options.queue.scope).remove(this); + this.state = 'finished'; + }, + event: function(eventName) { + if (this.options[eventName + 'Internal']) this.options[eventName + 'Internal'](this); + if (this.options[eventName]) this.options[eventName](this); + }, + inspect: function() { + var data = $H(); + for(property in this) + if (!Object.isFunction(this[property])) data.set(property, this[property]); + return '#'; + } +}); + +Effect.Parallel = Class.create(Effect.Base, { + initialize: function(effects) { + this.effects = effects || []; + this.start(arguments[1]); + }, + update: function(position) { + this.effects.invoke('render', position); + }, + finish: function(position) { + this.effects.each( function(effect) { + effect.render(1.0); + effect.cancel(); + effect.event('beforeFinish'); + if (effect.finish) effect.finish(position); + effect.event('afterFinish'); + }); + } +}); + +Effect.Tween = Class.create(Effect.Base, { + initialize: function(object, from, to) { + object = Object.isString(object) ? $(object) : object; + var args = $A(arguments), method = args.last(), + options = args.length == 5 ? args[3] : null; + this.method = Object.isFunction(method) ? method.bind(object) : + Object.isFunction(object[method]) ? object[method].bind(object) : + function(value) { object[method] = value }; + this.start(Object.extend({ from: from, to: to }, options || { })); + }, + update: function(position) { + this.method(position); + } +}); + +Effect.Event = Class.create(Effect.Base, { + initialize: function() { + this.start(Object.extend({ duration: 0 }, arguments[0] || { })); + }, + update: Prototype.emptyFunction +}); + +Effect.Opacity = Class.create(Effect.Base, { + initialize: function(element) { + this.element = $(element); + if (!this.element) throw(Effect._elementDoesNotExistError); + // make this work on IE on elements without 'layout' + if (Prototype.Browser.IE && (!this.element.currentStyle.hasLayout)) + this.element.setStyle({zoom: 1}); + var options = Object.extend({ + from: this.element.getOpacity() || 0.0, + to: 1.0 + }, arguments[1] || { }); + this.start(options); + }, + update: function(position) { + this.element.setOpacity(position); + } +}); + +Effect.Move = Class.create(Effect.Base, { + initialize: function(element) { + this.element = $(element); + if (!this.element) throw(Effect._elementDoesNotExistError); + var options = Object.extend({ + x: 0, + y: 0, + mode: 'relative' + }, arguments[1] || { }); + this.start(options); + }, + setup: function() { + this.element.makePositioned(); + this.originalLeft = parseFloat(this.element.getStyle('left') || '0'); + this.originalTop = parseFloat(this.element.getStyle('top') || '0'); + if (this.options.mode == 'absolute') { + this.options.x = this.options.x - this.originalLeft; + this.options.y = this.options.y - this.originalTop; + } + }, + update: function(position) { + this.element.setStyle({ + left: (this.options.x * position + this.originalLeft).round() + 'px', + top: (this.options.y * position + this.originalTop).round() + 'px' + }); + } +}); + +// for backwards compatibility +Effect.MoveBy = function(element, toTop, toLeft) { + return new Effect.Move(element, + Object.extend({ x: toLeft, y: toTop }, arguments[3] || { })); +}; + +Effect.Scale = Class.create(Effect.Base, { + initialize: function(element, percent) { + this.element = $(element); + if (!this.element) throw(Effect._elementDoesNotExistError); + var options = Object.extend({ + scaleX: true, + scaleY: true, + scaleContent: true, + scaleFromCenter: false, + scaleMode: 'box', // 'box' or 'contents' or { } with provided values + scaleFrom: 100.0, + scaleTo: percent + }, arguments[2] || { }); + this.start(options); + }, + setup: function() { + this.restoreAfterFinish = this.options.restoreAfterFinish || false; + this.elementPositioning = this.element.getStyle('position'); + + this.originalStyle = { }; + ['top','left','width','height','fontSize'].each( function(k) { + this.originalStyle[k] = this.element.style[k]; + }.bind(this)); + + this.originalTop = this.element.offsetTop; + this.originalLeft = this.element.offsetLeft; + + var fontSize = this.element.getStyle('font-size') || '100%'; + ['em','px','%','pt'].each( function(fontSizeType) { + if (fontSize.indexOf(fontSizeType)>0) { + this.fontSize = parseFloat(fontSize); + this.fontSizeType = fontSizeType; + } + }.bind(this)); + + this.factor = (this.options.scaleTo - this.options.scaleFrom)/100; + + this.dims = null; + if (this.options.scaleMode=='box') + this.dims = [this.element.offsetHeight, this.element.offsetWidth]; + if (/^content/.test(this.options.scaleMode)) + this.dims = [this.element.scrollHeight, this.element.scrollWidth]; + if (!this.dims) + this.dims = [this.options.scaleMode.originalHeight, + this.options.scaleMode.originalWidth]; + }, + update: function(position) { + var currentScale = (this.options.scaleFrom/100.0) + (this.factor * position); + if (this.options.scaleContent && this.fontSize) + this.element.setStyle({fontSize: this.fontSize * currentScale + this.fontSizeType }); + this.setDimensions(this.dims[0] * currentScale, this.dims[1] * currentScale); + }, + finish: function(position) { + if (this.restoreAfterFinish) this.element.setStyle(this.originalStyle); + }, + setDimensions: function(height, width) { + var d = { }; + if (this.options.scaleX) d.width = width.round() + 'px'; + if (this.options.scaleY) d.height = height.round() + 'px'; + if (this.options.scaleFromCenter) { + var topd = (height - this.dims[0])/2; + var leftd = (width - this.dims[1])/2; + if (this.elementPositioning == 'absolute') { + if (this.options.scaleY) d.top = this.originalTop-topd + 'px'; + if (this.options.scaleX) d.left = this.originalLeft-leftd + 'px'; + } else { + if (this.options.scaleY) d.top = -topd + 'px'; + if (this.options.scaleX) d.left = -leftd + 'px'; + } + } + this.element.setStyle(d); + } +}); + +Effect.Highlight = Class.create(Effect.Base, { + initialize: function(element) { + this.element = $(element); + if (!this.element) throw(Effect._elementDoesNotExistError); + var options = Object.extend({ startcolor: '#ffff99' }, arguments[1] || { }); + this.start(options); + }, + setup: function() { + // Prevent executing on elements not in the layout flow + if (this.element.getStyle('display')=='none') { this.cancel(); return; } + // Disable background image during the effect + this.oldStyle = { }; + if (!this.options.keepBackgroundImage) { + this.oldStyle.backgroundImage = this.element.getStyle('background-image'); + this.element.setStyle({backgroundImage: 'none'}); + } + if (!this.options.endcolor) + this.options.endcolor = this.element.getStyle('background-color').parseColor('#ffffff'); + if (!this.options.restorecolor) + this.options.restorecolor = this.element.getStyle('background-color'); + // init color calculations + this._base = $R(0,2).map(function(i){ return parseInt(this.options.startcolor.slice(i*2+1,i*2+3),16) }.bind(this)); + this._delta = $R(0,2).map(function(i){ return parseInt(this.options.endcolor.slice(i*2+1,i*2+3),16)-this._base[i] }.bind(this)); + }, + update: function(position) { + this.element.setStyle({backgroundColor: $R(0,2).inject('#',function(m,v,i){ + return m+((this._base[i]+(this._delta[i]*position)).round().toColorPart()); }.bind(this)) }); + }, + finish: function() { + this.element.setStyle(Object.extend(this.oldStyle, { + backgroundColor: this.options.restorecolor + })); + } +}); + +Effect.ScrollTo = function(element) { + var options = arguments[1] || { }, + scrollOffsets = document.viewport.getScrollOffsets(), + elementOffsets = $(element).cumulativeOffset(), + max = (window.height || document.body.scrollHeight) - document.viewport.getHeight(); + + if (options.offset) elementOffsets[1] += options.offset; + + return new Effect.Tween(null, + scrollOffsets.top, + elementOffsets[1] > max ? max : elementOffsets[1], + options, + function(p){ scrollTo(scrollOffsets.left, p.round()) } + ); +}; + +/* ------------- combination effects ------------- */ + +Effect.Fade = function(element) { + element = $(element); + var oldOpacity = element.getInlineOpacity(); + var options = Object.extend({ + from: element.getOpacity() || 1.0, + to: 0.0, + afterFinishInternal: function(effect) { + if (effect.options.to!=0) return; + effect.element.hide().setStyle({opacity: oldOpacity}); + } + }, arguments[1] || { }); + return new Effect.Opacity(element,options); +}; + +Effect.Appear = function(element) { + element = $(element); + var options = Object.extend({ + from: (element.getStyle('display') == 'none' ? 0.0 : element.getOpacity() || 0.0), + to: 1.0, + // force Safari to render floated elements properly + afterFinishInternal: function(effect) { + effect.element.forceRerendering(); + }, + beforeSetup: function(effect) { + effect.element.setOpacity(effect.options.from).show(); + }}, arguments[1] || { }); + return new Effect.Opacity(element,options); +}; + +Effect.Puff = function(element) { + element = $(element); + var oldStyle = { + opacity: element.getInlineOpacity(), + position: element.getStyle('position'), + top: element.style.top, + left: element.style.left, + width: element.style.width, + height: element.style.height + }; + return new Effect.Parallel( + [ new Effect.Scale(element, 200, + { sync: true, scaleFromCenter: true, scaleContent: true, restoreAfterFinish: true }), + new Effect.Opacity(element, { sync: true, to: 0.0 } ) ], + Object.extend({ duration: 1.0, + beforeSetupInternal: function(effect) { + Position.absolutize(effect.effects[0].element) + }, + afterFinishInternal: function(effect) { + effect.effects[0].element.hide().setStyle(oldStyle); } + }, arguments[1] || { }) + ); +}; + +Effect.BlindUp = function(element) { + element = $(element); + element.makeClipping(); + return new Effect.Scale(element, 0, + Object.extend({ scaleContent: false, + scaleX: false, + restoreAfterFinish: true, + afterFinishInternal: function(effect) { + effect.element.hide().undoClipping(); + } + }, arguments[1] || { }) + ); +}; + +Effect.BlindDown = function(element) { + element = $(element); + var elementDimensions = element.getDimensions(); + return new Effect.Scale(element, 100, Object.extend({ + scaleContent: false, + scaleX: false, + scaleFrom: 0, + scaleMode: {originalHeight: elementDimensions.height, originalWidth: elementDimensions.width}, + restoreAfterFinish: true, + afterSetup: function(effect) { + effect.element.makeClipping().setStyle({height: '0px'}).show(); + }, + afterFinishInternal: function(effect) { + effect.element.undoClipping(); + } + }, arguments[1] || { })); +}; + +Effect.SwitchOff = function(element) { + element = $(element); + var oldOpacity = element.getInlineOpacity(); + return new Effect.Appear(element, Object.extend({ + duration: 0.4, + from: 0, + transition: Effect.Transitions.flicker, + afterFinishInternal: function(effect) { + new Effect.Scale(effect.element, 1, { + duration: 0.3, scaleFromCenter: true, + scaleX: false, scaleContent: false, restoreAfterFinish: true, + beforeSetup: function(effect) { + effect.element.makePositioned().makeClipping(); + }, + afterFinishInternal: function(effect) { + effect.element.hide().undoClipping().undoPositioned().setStyle({opacity: oldOpacity}); + } + }) + } + }, arguments[1] || { })); +}; + +Effect.DropOut = function(element) { + element = $(element); + var oldStyle = { + top: element.getStyle('top'), + left: element.getStyle('left'), + opacity: element.getInlineOpacity() }; + return new Effect.Parallel( + [ new Effect.Move(element, {x: 0, y: 100, sync: true }), + new Effect.Opacity(element, { sync: true, to: 0.0 }) ], + Object.extend( + { duration: 0.5, + beforeSetup: function(effect) { + effect.effects[0].element.makePositioned(); + }, + afterFinishInternal: function(effect) { + effect.effects[0].element.hide().undoPositioned().setStyle(oldStyle); + } + }, arguments[1] || { })); +}; + +Effect.Shake = function(element) { + element = $(element); + var options = Object.extend({ + distance: 20, + duration: 0.5 + }, arguments[1] || {}); + var distance = parseFloat(options.distance); + var split = parseFloat(options.duration) / 10.0; + var oldStyle = { + top: element.getStyle('top'), + left: element.getStyle('left') }; + return new Effect.Move(element, + { x: distance, y: 0, duration: split, afterFinishInternal: function(effect) { + new Effect.Move(effect.element, + { x: -distance*2, y: 0, duration: split*2, afterFinishInternal: function(effect) { + new Effect.Move(effect.element, + { x: distance*2, y: 0, duration: split*2, afterFinishInternal: function(effect) { + new Effect.Move(effect.element, + { x: -distance*2, y: 0, duration: split*2, afterFinishInternal: function(effect) { + new Effect.Move(effect.element, + { x: distance*2, y: 0, duration: split*2, afterFinishInternal: function(effect) { + new Effect.Move(effect.element, + { x: -distance, y: 0, duration: split, afterFinishInternal: function(effect) { + effect.element.undoPositioned().setStyle(oldStyle); + }}) }}) }}) }}) }}) }}); +}; + +Effect.SlideDown = function(element) { + element = $(element).cleanWhitespace(); + // SlideDown need to have the content of the element wrapped in a container element with fixed height! + var oldInnerBottom = element.down().getStyle('bottom'); + var elementDimensions = element.getDimensions(); + return new Effect.Scale(element, 100, Object.extend({ + scaleContent: false, + scaleX: false, + scaleFrom: window.opera ? 0 : 1, + scaleMode: {originalHeight: elementDimensions.height, originalWidth: elementDimensions.width}, + restoreAfterFinish: true, + afterSetup: function(effect) { + effect.element.makePositioned(); + effect.element.down().makePositioned(); + if (window.opera) effect.element.setStyle({top: ''}); + effect.element.makeClipping().setStyle({height: '0px'}).show(); + }, + afterUpdateInternal: function(effect) { + effect.element.down().setStyle({bottom: + (effect.dims[0] - effect.element.clientHeight) + 'px' }); + }, + afterFinishInternal: function(effect) { + effect.element.undoClipping().undoPositioned(); + effect.element.down().undoPositioned().setStyle({bottom: oldInnerBottom}); } + }, arguments[1] || { }) + ); +}; + +Effect.SlideUp = function(element) { + element = $(element).cleanWhitespace(); + var oldInnerBottom = element.down().getStyle('bottom'); + var elementDimensions = element.getDimensions(); + return new Effect.Scale(element, window.opera ? 0 : 1, + Object.extend({ scaleContent: false, + scaleX: false, + scaleMode: 'box', + scaleFrom: 100, + scaleMode: {originalHeight: elementDimensions.height, originalWidth: elementDimensions.width}, + restoreAfterFinish: true, + afterSetup: function(effect) { + effect.element.makePositioned(); + effect.element.down().makePositioned(); + if (window.opera) effect.element.setStyle({top: ''}); + effect.element.makeClipping().show(); + }, + afterUpdateInternal: function(effect) { + effect.element.down().setStyle({bottom: + (effect.dims[0] - effect.element.clientHeight) + 'px' }); + }, + afterFinishInternal: function(effect) { + effect.element.hide().undoClipping().undoPositioned(); + effect.element.down().undoPositioned().setStyle({bottom: oldInnerBottom}); + } + }, arguments[1] || { }) + ); +}; + +// Bug in opera makes the TD containing this element expand for a instance after finish +Effect.Squish = function(element) { + return new Effect.Scale(element, window.opera ? 1 : 0, { + restoreAfterFinish: true, + beforeSetup: function(effect) { + effect.element.makeClipping(); + }, + afterFinishInternal: function(effect) { + effect.element.hide().undoClipping(); + } + }); +}; + +Effect.Grow = function(element) { + element = $(element); + var options = Object.extend({ + direction: 'center', + moveTransition: Effect.Transitions.sinoidal, + scaleTransition: Effect.Transitions.sinoidal, + opacityTransition: Effect.Transitions.full + }, arguments[1] || { }); + var oldStyle = { + top: element.style.top, + left: element.style.left, + height: element.style.height, + width: element.style.width, + opacity: element.getInlineOpacity() }; + + var dims = element.getDimensions(); + var initialMoveX, initialMoveY; + var moveX, moveY; + + switch (options.direction) { + case 'top-left': + initialMoveX = initialMoveY = moveX = moveY = 0; + break; + case 'top-right': + initialMoveX = dims.width; + initialMoveY = moveY = 0; + moveX = -dims.width; + break; + case 'bottom-left': + initialMoveX = moveX = 0; + initialMoveY = dims.height; + moveY = -dims.height; + break; + case 'bottom-right': + initialMoveX = dims.width; + initialMoveY = dims.height; + moveX = -dims.width; + moveY = -dims.height; + break; + case 'center': + initialMoveX = dims.width / 2; + initialMoveY = dims.height / 2; + moveX = -dims.width / 2; + moveY = -dims.height / 2; + break; + } + + return new Effect.Move(element, { + x: initialMoveX, + y: initialMoveY, + duration: 0.01, + beforeSetup: function(effect) { + effect.element.hide().makeClipping().makePositioned(); + }, + afterFinishInternal: function(effect) { + new Effect.Parallel( + [ new Effect.Opacity(effect.element, { sync: true, to: 1.0, from: 0.0, transition: options.opacityTransition }), + new Effect.Move(effect.element, { x: moveX, y: moveY, sync: true, transition: options.moveTransition }), + new Effect.Scale(effect.element, 100, { + scaleMode: { originalHeight: dims.height, originalWidth: dims.width }, + sync: true, scaleFrom: window.opera ? 1 : 0, transition: options.scaleTransition, restoreAfterFinish: true}) + ], Object.extend({ + beforeSetup: function(effect) { + effect.effects[0].element.setStyle({height: '0px'}).show(); + }, + afterFinishInternal: function(effect) { + effect.effects[0].element.undoClipping().undoPositioned().setStyle(oldStyle); + } + }, options) + ) + } + }); +}; + +Effect.Shrink = function(element) { + element = $(element); + var options = Object.extend({ + direction: 'center', + moveTransition: Effect.Transitions.sinoidal, + scaleTransition: Effect.Transitions.sinoidal, + opacityTransition: Effect.Transitions.none + }, arguments[1] || { }); + var oldStyle = { + top: element.style.top, + left: element.style.left, + height: element.style.height, + width: element.style.width, + opacity: element.getInlineOpacity() }; + + var dims = element.getDimensions(); + var moveX, moveY; + + switch (options.direction) { + case 'top-left': + moveX = moveY = 0; + break; + case 'top-right': + moveX = dims.width; + moveY = 0; + break; + case 'bottom-left': + moveX = 0; + moveY = dims.height; + break; + case 'bottom-right': + moveX = dims.width; + moveY = dims.height; + break; + case 'center': + moveX = dims.width / 2; + moveY = dims.height / 2; + break; + } + + return new Effect.Parallel( + [ new Effect.Opacity(element, { sync: true, to: 0.0, from: 1.0, transition: options.opacityTransition }), + new Effect.Scale(element, window.opera ? 1 : 0, { sync: true, transition: options.scaleTransition, restoreAfterFinish: true}), + new Effect.Move(element, { x: moveX, y: moveY, sync: true, transition: options.moveTransition }) + ], Object.extend({ + beforeStartInternal: function(effect) { + effect.effects[0].element.makePositioned().makeClipping(); + }, + afterFinishInternal: function(effect) { + effect.effects[0].element.hide().undoClipping().undoPositioned().setStyle(oldStyle); } + }, options) + ); +}; + +Effect.Pulsate = function(element) { + element = $(element); + var options = arguments[1] || { }; + var oldOpacity = element.getInlineOpacity(); + var transition = options.transition || Effect.Transitions.sinoidal; + var reverser = function(pos){ return transition(1-Effect.Transitions.pulse(pos, options.pulses)) }; + reverser.bind(transition); + return new Effect.Opacity(element, + Object.extend(Object.extend({ duration: 2.0, from: 0, + afterFinishInternal: function(effect) { effect.element.setStyle({opacity: oldOpacity}); } + }, options), {transition: reverser})); +}; + +Effect.Fold = function(element) { + element = $(element); + var oldStyle = { + top: element.style.top, + left: element.style.left, + width: element.style.width, + height: element.style.height }; + element.makeClipping(); + return new Effect.Scale(element, 5, Object.extend({ + scaleContent: false, + scaleX: false, + afterFinishInternal: function(effect) { + new Effect.Scale(element, 1, { + scaleContent: false, + scaleY: false, + afterFinishInternal: function(effect) { + effect.element.hide().undoClipping().setStyle(oldStyle); + } }); + }}, arguments[1] || { })); +}; + +Effect.Morph = Class.create(Effect.Base, { + initialize: function(element) { + this.element = $(element); + if (!this.element) throw(Effect._elementDoesNotExistError); + var options = Object.extend({ + style: { } + }, arguments[1] || { }); + + if (!Object.isString(options.style)) this.style = $H(options.style); + else { + if (options.style.include(':')) + this.style = options.style.parseStyle(); + else { + this.element.addClassName(options.style); + this.style = $H(this.element.getStyles()); + this.element.removeClassName(options.style); + var css = this.element.getStyles(); + this.style = this.style.reject(function(style) { + return style.value == css[style.key]; + }); + options.afterFinishInternal = function(effect) { + effect.element.addClassName(effect.options.style); + effect.transforms.each(function(transform) { + effect.element.style[transform.style] = ''; + }); + } + } + } + this.start(options); + }, + + setup: function(){ + function parseColor(color){ + if (!color || ['rgba(0, 0, 0, 0)','transparent'].include(color)) color = '#ffffff'; + color = color.parseColor(); + return $R(0,2).map(function(i){ + return parseInt( color.slice(i*2+1,i*2+3), 16 ) + }); + } + this.transforms = this.style.map(function(pair){ + var property = pair[0], value = pair[1], unit = null; + + if (value.parseColor('#zzzzzz') != '#zzzzzz') { + value = value.parseColor(); + unit = 'color'; + } else if (property == 'opacity') { + value = parseFloat(value); + if (Prototype.Browser.IE && (!this.element.currentStyle.hasLayout)) + this.element.setStyle({zoom: 1}); + } else if (Element.CSS_LENGTH.test(value)) { + var components = value.match(/^([\+\-]?[0-9\.]+)(.*)$/); + value = parseFloat(components[1]); + unit = (components.length == 3) ? components[2] : null; + } + + var originalValue = this.element.getStyle(property); + return { + style: property.camelize(), + originalValue: unit=='color' ? parseColor(originalValue) : parseFloat(originalValue || 0), + targetValue: unit=='color' ? parseColor(value) : value, + unit: unit + }; + }.bind(this)).reject(function(transform){ + return ( + (transform.originalValue == transform.targetValue) || + ( + transform.unit != 'color' && + (isNaN(transform.originalValue) || isNaN(transform.targetValue)) + ) + ) + }); + }, + update: function(position) { + var style = { }, transform, i = this.transforms.length; + while(i--) + style[(transform = this.transforms[i]).style] = + transform.unit=='color' ? '#'+ + (Math.round(transform.originalValue[0]+ + (transform.targetValue[0]-transform.originalValue[0])*position)).toColorPart() + + (Math.round(transform.originalValue[1]+ + (transform.targetValue[1]-transform.originalValue[1])*position)).toColorPart() + + (Math.round(transform.originalValue[2]+ + (transform.targetValue[2]-transform.originalValue[2])*position)).toColorPart() : + (transform.originalValue + + (transform.targetValue - transform.originalValue) * position).toFixed(3) + + (transform.unit === null ? '' : transform.unit); + this.element.setStyle(style, true); + } +}); + +Effect.Transform = Class.create({ + initialize: function(tracks){ + this.tracks = []; + this.options = arguments[1] || { }; + this.addTracks(tracks); + }, + addTracks: function(tracks){ + tracks.each(function(track){ + track = $H(track); + var data = track.values().first(); + this.tracks.push($H({ + ids: track.keys().first(), + effect: Effect.Morph, + options: { style: data } + })); + }.bind(this)); + return this; + }, + play: function(){ + return new Effect.Parallel( + this.tracks.map(function(track){ + var ids = track.get('ids'), effect = track.get('effect'), options = track.get('options'); + var elements = [$(ids) || $$(ids)].flatten(); + return elements.map(function(e){ return new effect(e, Object.extend({ sync:true }, options)) }); + }).flatten(), + this.options + ); + } +}); + +Element.CSS_PROPERTIES = $w( + 'backgroundColor backgroundPosition borderBottomColor borderBottomStyle ' + + 'borderBottomWidth borderLeftColor borderLeftStyle borderLeftWidth ' + + 'borderRightColor borderRightStyle borderRightWidth borderSpacing ' + + 'borderTopColor borderTopStyle borderTopWidth bottom clip color ' + + 'fontSize fontWeight height left letterSpacing lineHeight ' + + 'marginBottom marginLeft marginRight marginTop markerOffset maxHeight '+ + 'maxWidth minHeight minWidth opacity outlineColor outlineOffset ' + + 'outlineWidth paddingBottom paddingLeft paddingRight paddingTop ' + + 'right textIndent top width wordSpacing zIndex'); + +Element.CSS_LENGTH = /^(([\+\-]?[0-9\.]+)(em|ex|px|in|cm|mm|pt|pc|\%))|0$/; + +String.__parseStyleElement = document.createElement('div'); +String.prototype.parseStyle = function(){ + var style, styleRules = $H(); + if (Prototype.Browser.WebKit) + style = new Element('div',{style:this}).style; + else { + String.__parseStyleElement.innerHTML = '
    '; + style = String.__parseStyleElement.childNodes[0].style; + } + + Element.CSS_PROPERTIES.each(function(property){ + if (style[property]) styleRules.set(property, style[property]); + }); + + if (Prototype.Browser.IE && this.include('opacity')) + styleRules.set('opacity', this.match(/opacity:\s*((?:0|1)?(?:\.\d*)?)/)[1]); + + return styleRules; +}; + +if (document.defaultView && document.defaultView.getComputedStyle) { + Element.getStyles = function(element) { + var css = document.defaultView.getComputedStyle($(element), null); + return Element.CSS_PROPERTIES.inject({ }, function(styles, property) { + styles[property] = css[property]; + return styles; + }); + }; +} else { + Element.getStyles = function(element) { + element = $(element); + var css = element.currentStyle, styles; + styles = Element.CSS_PROPERTIES.inject({ }, function(hash, property) { + hash.set(property, css[property]); + return hash; + }); + if (!styles.opacity) styles.set('opacity', element.getOpacity()); + return styles; + }; +}; + +Effect.Methods = { + morph: function(element, style) { + element = $(element); + new Effect.Morph(element, Object.extend({ style: style }, arguments[2] || { })); + return element; + }, + visualEffect: function(element, effect, options) { + element = $(element) + var s = effect.dasherize().camelize(), klass = s.charAt(0).toUpperCase() + s.substring(1); + new Effect[klass](element, options); + return element; + }, + highlight: function(element, options) { + element = $(element); + new Effect.Highlight(element, options); + return element; + } +}; + +$w('fade appear grow shrink fold blindUp blindDown slideUp slideDown '+ + 'pulsate shake puff squish switchOff dropOut').each( + function(effect) { + Effect.Methods[effect] = function(element, options){ + element = $(element); + Effect[effect.charAt(0).toUpperCase() + effect.substring(1)](element, options); + return element; + } + } +); + +$w('getInlineOpacity forceRerendering setContentZoom collectTextNodes collectTextNodesIgnoreClass getStyles').each( + function(f) { Effect.Methods[f] = Element[f]; } +); + +Element.addMethods(Effect.Methods); diff --git a/vendor/gems/gems/thin-1.2.5/spec/rails_app/public/javascripts/prototype.js b/vendor/gems/gems/thin-1.2.5/spec/rails_app/public/javascripts/prototype.js new file mode 100755 index 00000000..546f9fe4 --- /dev/null +++ b/vendor/gems/gems/thin-1.2.5/spec/rails_app/public/javascripts/prototype.js @@ -0,0 +1,4225 @@ +/* Prototype JavaScript framework, version 1.6.0.1 + * (c) 2005-2007 Sam Stephenson + * + * Prototype is freely distributable under the terms of an MIT-style license. + * For details, see the Prototype web site: http://www.prototypejs.org/ + * + *--------------------------------------------------------------------------*/ + +var Prototype = { + Version: '1.6.0.1', + + Browser: { + IE: !!(window.attachEvent && !window.opera), + Opera: !!window.opera, + WebKit: navigator.userAgent.indexOf('AppleWebKit/') > -1, + Gecko: navigator.userAgent.indexOf('Gecko') > -1 && navigator.userAgent.indexOf('KHTML') == -1, + MobileSafari: !!navigator.userAgent.match(/Apple.*Mobile.*Safari/) + }, + + BrowserFeatures: { + XPath: !!document.evaluate, + ElementExtensions: !!window.HTMLElement, + SpecificElementExtensions: + document.createElement('div').__proto__ && + document.createElement('div').__proto__ !== + document.createElement('form').__proto__ + }, + + ScriptFragment: ']*>([\\S\\s]*?)<\/script>', + JSONFilter: /^\/\*-secure-([\s\S]*)\*\/\s*$/, + + emptyFunction: function() { }, + K: function(x) { return x } +}; + +if (Prototype.Browser.MobileSafari) + Prototype.BrowserFeatures.SpecificElementExtensions = false; + + +/* Based on Alex Arnell's inheritance implementation. */ +var Class = { + create: function() { + var parent = null, properties = $A(arguments); + if (Object.isFunction(properties[0])) + parent = properties.shift(); + + function klass() { + this.initialize.apply(this, arguments); + } + + Object.extend(klass, Class.Methods); + klass.superclass = parent; + klass.subclasses = []; + + if (parent) { + var subclass = function() { }; + subclass.prototype = parent.prototype; + klass.prototype = new subclass; + parent.subclasses.push(klass); + } + + for (var i = 0; i < properties.length; i++) + klass.addMethods(properties[i]); + + if (!klass.prototype.initialize) + klass.prototype.initialize = Prototype.emptyFunction; + + klass.prototype.constructor = klass; + + return klass; + } +}; + +Class.Methods = { + addMethods: function(source) { + var ancestor = this.superclass && this.superclass.prototype; + var properties = Object.keys(source); + + if (!Object.keys({ toString: true }).length) + properties.push("toString", "valueOf"); + + for (var i = 0, length = properties.length; i < length; i++) { + var property = properties[i], value = source[property]; + if (ancestor && Object.isFunction(value) && + value.argumentNames().first() == "$super") { + var method = value, value = Object.extend((function(m) { + return function() { return ancestor[m].apply(this, arguments) }; + })(property).wrap(method), { + valueOf: function() { return method }, + toString: function() { return method.toString() } + }); + } + this.prototype[property] = value; + } + + return this; + } +}; + +var Abstract = { }; + +Object.extend = function(destination, source) { + for (var property in source) + destination[property] = source[property]; + return destination; +}; + +Object.extend(Object, { + inspect: function(object) { + try { + if (Object.isUndefined(object)) return 'undefined'; + if (object === null) return 'null'; + return object.inspect ? object.inspect() : object.toString(); + } catch (e) { + if (e instanceof RangeError) return '...'; + throw e; + } + }, + + toJSON: function(object) { + var type = typeof object; + switch (type) { + case 'undefined': + case 'function': + case 'unknown': return; + case 'boolean': return object.toString(); + } + + if (object === null) return 'null'; + if (object.toJSON) return object.toJSON(); + if (Object.isElement(object)) return; + + var results = []; + for (var property in object) { + var value = Object.toJSON(object[property]); + if (!Object.isUndefined(value)) + results.push(property.toJSON() + ': ' + value); + } + + return '{' + results.join(', ') + '}'; + }, + + toQueryString: function(object) { + return $H(object).toQueryString(); + }, + + toHTML: function(object) { + return object && object.toHTML ? object.toHTML() : String.interpret(object); + }, + + keys: function(object) { + var keys = []; + for (var property in object) + keys.push(property); + return keys; + }, + + values: function(object) { + var values = []; + for (var property in object) + values.push(object[property]); + return values; + }, + + clone: function(object) { + return Object.extend({ }, object); + }, + + isElement: function(object) { + return object && object.nodeType == 1; + }, + + isArray: function(object) { + return object && object.constructor === Array; + }, + + isHash: function(object) { + return object instanceof Hash; + }, + + isFunction: function(object) { + return typeof object == "function"; + }, + + isString: function(object) { + return typeof object == "string"; + }, + + isNumber: function(object) { + return typeof object == "number"; + }, + + isUndefined: function(object) { + return typeof object == "undefined"; + } +}); + +Object.extend(Function.prototype, { + argumentNames: function() { + var names = this.toString().match(/^[\s\(]*function[^(]*\((.*?)\)/)[1].split(",").invoke("strip"); + return names.length == 1 && !names[0] ? [] : names; + }, + + bind: function() { + if (arguments.length < 2 && Object.isUndefined(arguments[0])) return this; + var __method = this, args = $A(arguments), object = args.shift(); + return function() { + return __method.apply(object, args.concat($A(arguments))); + } + }, + + bindAsEventListener: function() { + var __method = this, args = $A(arguments), object = args.shift(); + return function(event) { + return __method.apply(object, [event || window.event].concat(args)); + } + }, + + curry: function() { + if (!arguments.length) return this; + var __method = this, args = $A(arguments); + return function() { + return __method.apply(this, args.concat($A(arguments))); + } + }, + + delay: function() { + var __method = this, args = $A(arguments), timeout = args.shift() * 1000; + return window.setTimeout(function() { + return __method.apply(__method, args); + }, timeout); + }, + + wrap: function(wrapper) { + var __method = this; + return function() { + return wrapper.apply(this, [__method.bind(this)].concat($A(arguments))); + } + }, + + methodize: function() { + if (this._methodized) return this._methodized; + var __method = this; + return this._methodized = function() { + return __method.apply(null, [this].concat($A(arguments))); + }; + } +}); + +Function.prototype.defer = Function.prototype.delay.curry(0.01); + +Date.prototype.toJSON = function() { + return '"' + this.getUTCFullYear() + '-' + + (this.getUTCMonth() + 1).toPaddedString(2) + '-' + + this.getUTCDate().toPaddedString(2) + 'T' + + this.getUTCHours().toPaddedString(2) + ':' + + this.getUTCMinutes().toPaddedString(2) + ':' + + this.getUTCSeconds().toPaddedString(2) + 'Z"'; +}; + +var Try = { + these: function() { + var returnValue; + + for (var i = 0, length = arguments.length; i < length; i++) { + var lambda = arguments[i]; + try { + returnValue = lambda(); + break; + } catch (e) { } + } + + return returnValue; + } +}; + +RegExp.prototype.match = RegExp.prototype.test; + +RegExp.escape = function(str) { + return String(str).replace(/([.*+?^=!:${}()|[\]\/\\])/g, '\\$1'); +}; + +/*--------------------------------------------------------------------------*/ + +var PeriodicalExecuter = Class.create({ + initialize: function(callback, frequency) { + this.callback = callback; + this.frequency = frequency; + this.currentlyExecuting = false; + + this.registerCallback(); + }, + + registerCallback: function() { + this.timer = setInterval(this.onTimerEvent.bind(this), this.frequency * 1000); + }, + + execute: function() { + this.callback(this); + }, + + stop: function() { + if (!this.timer) return; + clearInterval(this.timer); + this.timer = null; + }, + + onTimerEvent: function() { + if (!this.currentlyExecuting) { + try { + this.currentlyExecuting = true; + this.execute(); + } finally { + this.currentlyExecuting = false; + } + } + } +}); +Object.extend(String, { + interpret: function(value) { + return value == null ? '' : String(value); + }, + specialChar: { + '\b': '\\b', + '\t': '\\t', + '\n': '\\n', + '\f': '\\f', + '\r': '\\r', + '\\': '\\\\' + } +}); + +Object.extend(String.prototype, { + gsub: function(pattern, replacement) { + var result = '', source = this, match; + replacement = arguments.callee.prepareReplacement(replacement); + + while (source.length > 0) { + if (match = source.match(pattern)) { + result += source.slice(0, match.index); + result += String.interpret(replacement(match)); + source = source.slice(match.index + match[0].length); + } else { + result += source, source = ''; + } + } + return result; + }, + + sub: function(pattern, replacement, count) { + replacement = this.gsub.prepareReplacement(replacement); + count = Object.isUndefined(count) ? 1 : count; + + return this.gsub(pattern, function(match) { + if (--count < 0) return match[0]; + return replacement(match); + }); + }, + + scan: function(pattern, iterator) { + this.gsub(pattern, iterator); + return String(this); + }, + + truncate: function(length, truncation) { + length = length || 30; + truncation = Object.isUndefined(truncation) ? '...' : truncation; + return this.length > length ? + this.slice(0, length - truncation.length) + truncation : String(this); + }, + + strip: function() { + return this.replace(/^\s+/, '').replace(/\s+$/, ''); + }, + + stripTags: function() { + return this.replace(/<\/?[^>]+>/gi, ''); + }, + + stripScripts: function() { + return this.replace(new RegExp(Prototype.ScriptFragment, 'img'), ''); + }, + + extractScripts: function() { + var matchAll = new RegExp(Prototype.ScriptFragment, 'img'); + var matchOne = new RegExp(Prototype.ScriptFragment, 'im'); + return (this.match(matchAll) || []).map(function(scriptTag) { + return (scriptTag.match(matchOne) || ['', ''])[1]; + }); + }, + + evalScripts: function() { + return this.extractScripts().map(function(script) { return eval(script) }); + }, + + escapeHTML: function() { + var self = arguments.callee; + self.text.data = this; + return self.div.innerHTML; + }, + + unescapeHTML: function() { + var div = new Element('div'); + div.innerHTML = this.stripTags(); + return div.childNodes[0] ? (div.childNodes.length > 1 ? + $A(div.childNodes).inject('', function(memo, node) { return memo+node.nodeValue }) : + div.childNodes[0].nodeValue) : ''; + }, + + toQueryParams: function(separator) { + var match = this.strip().match(/([^?#]*)(#.*)?$/); + if (!match) return { }; + + return match[1].split(separator || '&').inject({ }, function(hash, pair) { + if ((pair = pair.split('='))[0]) { + var key = decodeURIComponent(pair.shift()); + var value = pair.length > 1 ? pair.join('=') : pair[0]; + if (value != undefined) value = decodeURIComponent(value); + + if (key in hash) { + if (!Object.isArray(hash[key])) hash[key] = [hash[key]]; + hash[key].push(value); + } + else hash[key] = value; + } + return hash; + }); + }, + + toArray: function() { + return this.split(''); + }, + + succ: function() { + return this.slice(0, this.length - 1) + + String.fromCharCode(this.charCodeAt(this.length - 1) + 1); + }, + + times: function(count) { + return count < 1 ? '' : new Array(count + 1).join(this); + }, + + camelize: function() { + var parts = this.split('-'), len = parts.length; + if (len == 1) return parts[0]; + + var camelized = this.charAt(0) == '-' + ? parts[0].charAt(0).toUpperCase() + parts[0].substring(1) + : parts[0]; + + for (var i = 1; i < len; i++) + camelized += parts[i].charAt(0).toUpperCase() + parts[i].substring(1); + + return camelized; + }, + + capitalize: function() { + return this.charAt(0).toUpperCase() + this.substring(1).toLowerCase(); + }, + + underscore: function() { + return this.gsub(/::/, '/').gsub(/([A-Z]+)([A-Z][a-z])/,'#{1}_#{2}').gsub(/([a-z\d])([A-Z])/,'#{1}_#{2}').gsub(/-/,'_').toLowerCase(); + }, + + dasherize: function() { + return this.gsub(/_/,'-'); + }, + + inspect: function(useDoubleQuotes) { + var escapedString = this.gsub(/[\x00-\x1f\\]/, function(match) { + var character = String.specialChar[match[0]]; + return character ? character : '\\u00' + match[0].charCodeAt().toPaddedString(2, 16); + }); + if (useDoubleQuotes) return '"' + escapedString.replace(/"/g, '\\"') + '"'; + return "'" + escapedString.replace(/'/g, '\\\'') + "'"; + }, + + toJSON: function() { + return this.inspect(true); + }, + + unfilterJSON: function(filter) { + return this.sub(filter || Prototype.JSONFilter, '#{1}'); + }, + + isJSON: function() { + var str = this; + if (str.blank()) return false; + str = this.replace(/\\./g, '@').replace(/"[^"\\\n\r]*"/g, ''); + return (/^[,:{}\[\]0-9.\-+Eaeflnr-u \n\r\t]*$/).test(str); + }, + + evalJSON: function(sanitize) { + var json = this.unfilterJSON(); + try { + if (!sanitize || json.isJSON()) return eval('(' + json + ')'); + } catch (e) { } + throw new SyntaxError('Badly formed JSON string: ' + this.inspect()); + }, + + include: function(pattern) { + return this.indexOf(pattern) > -1; + }, + + startsWith: function(pattern) { + return this.indexOf(pattern) === 0; + }, + + endsWith: function(pattern) { + var d = this.length - pattern.length; + return d >= 0 && this.lastIndexOf(pattern) === d; + }, + + empty: function() { + return this == ''; + }, + + blank: function() { + return /^\s*$/.test(this); + }, + + interpolate: function(object, pattern) { + return new Template(this, pattern).evaluate(object); + } +}); + +if (Prototype.Browser.WebKit || Prototype.Browser.IE) Object.extend(String.prototype, { + escapeHTML: function() { + return this.replace(/&/g,'&').replace(//g,'>'); + }, + unescapeHTML: function() { + return this.replace(/&/g,'&').replace(/</g,'<').replace(/>/g,'>'); + } +}); + +String.prototype.gsub.prepareReplacement = function(replacement) { + if (Object.isFunction(replacement)) return replacement; + var template = new Template(replacement); + return function(match) { return template.evaluate(match) }; +}; + +String.prototype.parseQuery = String.prototype.toQueryParams; + +Object.extend(String.prototype.escapeHTML, { + div: document.createElement('div'), + text: document.createTextNode('') +}); + +with (String.prototype.escapeHTML) div.appendChild(text); + +var Template = Class.create({ + initialize: function(template, pattern) { + this.template = template.toString(); + this.pattern = pattern || Template.Pattern; + }, + + evaluate: function(object) { + if (Object.isFunction(object.toTemplateReplacements)) + object = object.toTemplateReplacements(); + + return this.template.gsub(this.pattern, function(match) { + if (object == null) return ''; + + var before = match[1] || ''; + if (before == '\\') return match[2]; + + var ctx = object, expr = match[3]; + var pattern = /^([^.[]+|\[((?:.*?[^\\])?)\])(\.|\[|$)/; + match = pattern.exec(expr); + if (match == null) return before; + + while (match != null) { + var comp = match[1].startsWith('[') ? match[2].gsub('\\\\]', ']') : match[1]; + ctx = ctx[comp]; + if (null == ctx || '' == match[3]) break; + expr = expr.substring('[' == match[3] ? match[1].length : match[0].length); + match = pattern.exec(expr); + } + + return before + String.interpret(ctx); + }.bind(this)); + } +}); +Template.Pattern = /(^|.|\r|\n)(#\{(.*?)\})/; + +var $break = { }; + +var Enumerable = { + each: function(iterator, context) { + var index = 0; + iterator = iterator.bind(context); + try { + this._each(function(value) { + iterator(value, index++); + }); + } catch (e) { + if (e != $break) throw e; + } + return this; + }, + + eachSlice: function(number, iterator, context) { + iterator = iterator ? iterator.bind(context) : Prototype.K; + var index = -number, slices = [], array = this.toArray(); + while ((index += number) < array.length) + slices.push(array.slice(index, index+number)); + return slices.collect(iterator, context); + }, + + all: function(iterator, context) { + iterator = iterator ? iterator.bind(context) : Prototype.K; + var result = true; + this.each(function(value, index) { + result = result && !!iterator(value, index); + if (!result) throw $break; + }); + return result; + }, + + any: function(iterator, context) { + iterator = iterator ? iterator.bind(context) : Prototype.K; + var result = false; + this.each(function(value, index) { + if (result = !!iterator(value, index)) + throw $break; + }); + return result; + }, + + collect: function(iterator, context) { + iterator = iterator ? iterator.bind(context) : Prototype.K; + var results = []; + this.each(function(value, index) { + results.push(iterator(value, index)); + }); + return results; + }, + + detect: function(iterator, context) { + iterator = iterator.bind(context); + var result; + this.each(function(value, index) { + if (iterator(value, index)) { + result = value; + throw $break; + } + }); + return result; + }, + + findAll: function(iterator, context) { + iterator = iterator.bind(context); + var results = []; + this.each(function(value, index) { + if (iterator(value, index)) + results.push(value); + }); + return results; + }, + + grep: function(filter, iterator, context) { + iterator = iterator ? iterator.bind(context) : Prototype.K; + var results = []; + + if (Object.isString(filter)) + filter = new RegExp(filter); + + this.each(function(value, index) { + if (filter.match(value)) + results.push(iterator(value, index)); + }); + return results; + }, + + include: function(object) { + if (Object.isFunction(this.indexOf)) + if (this.indexOf(object) != -1) return true; + + var found = false; + this.each(function(value) { + if (value == object) { + found = true; + throw $break; + } + }); + return found; + }, + + inGroupsOf: function(number, fillWith) { + fillWith = Object.isUndefined(fillWith) ? null : fillWith; + return this.eachSlice(number, function(slice) { + while(slice.length < number) slice.push(fillWith); + return slice; + }); + }, + + inject: function(memo, iterator, context) { + iterator = iterator.bind(context); + this.each(function(value, index) { + memo = iterator(memo, value, index); + }); + return memo; + }, + + invoke: function(method) { + var args = $A(arguments).slice(1); + return this.map(function(value) { + return value[method].apply(value, args); + }); + }, + + max: function(iterator, context) { + iterator = iterator ? iterator.bind(context) : Prototype.K; + var result; + this.each(function(value, index) { + value = iterator(value, index); + if (result == null || value >= result) + result = value; + }); + return result; + }, + + min: function(iterator, context) { + iterator = iterator ? iterator.bind(context) : Prototype.K; + var result; + this.each(function(value, index) { + value = iterator(value, index); + if (result == null || value < result) + result = value; + }); + return result; + }, + + partition: function(iterator, context) { + iterator = iterator ? iterator.bind(context) : Prototype.K; + var trues = [], falses = []; + this.each(function(value, index) { + (iterator(value, index) ? + trues : falses).push(value); + }); + return [trues, falses]; + }, + + pluck: function(property) { + var results = []; + this.each(function(value) { + results.push(value[property]); + }); + return results; + }, + + reject: function(iterator, context) { + iterator = iterator.bind(context); + var results = []; + this.each(function(value, index) { + if (!iterator(value, index)) + results.push(value); + }); + return results; + }, + + sortBy: function(iterator, context) { + iterator = iterator.bind(context); + return this.map(function(value, index) { + return {value: value, criteria: iterator(value, index)}; + }).sort(function(left, right) { + var a = left.criteria, b = right.criteria; + return a < b ? -1 : a > b ? 1 : 0; + }).pluck('value'); + }, + + toArray: function() { + return this.map(); + }, + + zip: function() { + var iterator = Prototype.K, args = $A(arguments); + if (Object.isFunction(args.last())) + iterator = args.pop(); + + var collections = [this].concat(args).map($A); + return this.map(function(value, index) { + return iterator(collections.pluck(index)); + }); + }, + + size: function() { + return this.toArray().length; + }, + + inspect: function() { + return '#'; + } +}; + +Object.extend(Enumerable, { + map: Enumerable.collect, + find: Enumerable.detect, + select: Enumerable.findAll, + filter: Enumerable.findAll, + member: Enumerable.include, + entries: Enumerable.toArray, + every: Enumerable.all, + some: Enumerable.any +}); +function $A(iterable) { + if (!iterable) return []; + if (iterable.toArray) return iterable.toArray(); + var length = iterable.length, results = new Array(length); + while (length--) results[length] = iterable[length]; + return results; +} + +if (Prototype.Browser.WebKit) { + function $A(iterable) { + if (!iterable) return []; + if (!(Object.isFunction(iterable) && iterable == '[object NodeList]') && + iterable.toArray) return iterable.toArray(); + var length = iterable.length, results = new Array(length); + while (length--) results[length] = iterable[length]; + return results; + } +} + +Array.from = $A; + +Object.extend(Array.prototype, Enumerable); + +if (!Array.prototype._reverse) Array.prototype._reverse = Array.prototype.reverse; + +Object.extend(Array.prototype, { + _each: function(iterator) { + for (var i = 0, length = this.length; i < length; i++) + iterator(this[i]); + }, + + clear: function() { + this.length = 0; + return this; + }, + + first: function() { + return this[0]; + }, + + last: function() { + return this[this.length - 1]; + }, + + compact: function() { + return this.select(function(value) { + return value != null; + }); + }, + + flatten: function() { + return this.inject([], function(array, value) { + return array.concat(Object.isArray(value) ? + value.flatten() : [value]); + }); + }, + + without: function() { + var values = $A(arguments); + return this.select(function(value) { + return !values.include(value); + }); + }, + + reverse: function(inline) { + return (inline !== false ? this : this.toArray())._reverse(); + }, + + reduce: function() { + return this.length > 1 ? this : this[0]; + }, + + uniq: function(sorted) { + return this.inject([], function(array, value, index) { + if (0 == index || (sorted ? array.last() != value : !array.include(value))) + array.push(value); + return array; + }); + }, + + intersect: function(array) { + return this.uniq().findAll(function(item) { + return array.detect(function(value) { return item === value }); + }); + }, + + clone: function() { + return [].concat(this); + }, + + size: function() { + return this.length; + }, + + inspect: function() { + return '[' + this.map(Object.inspect).join(', ') + ']'; + }, + + toJSON: function() { + var results = []; + this.each(function(object) { + var value = Object.toJSON(object); + if (!Object.isUndefined(value)) results.push(value); + }); + return '[' + results.join(', ') + ']'; + } +}); + +// use native browser JS 1.6 implementation if available +if (Object.isFunction(Array.prototype.forEach)) + Array.prototype._each = Array.prototype.forEach; + +if (!Array.prototype.indexOf) Array.prototype.indexOf = function(item, i) { + i || (i = 0); + var length = this.length; + if (i < 0) i = length + i; + for (; i < length; i++) + if (this[i] === item) return i; + return -1; +}; + +if (!Array.prototype.lastIndexOf) Array.prototype.lastIndexOf = function(item, i) { + i = isNaN(i) ? this.length : (i < 0 ? this.length + i : i) + 1; + var n = this.slice(0, i).reverse().indexOf(item); + return (n < 0) ? n : i - n - 1; +}; + +Array.prototype.toArray = Array.prototype.clone; + +function $w(string) { + if (!Object.isString(string)) return []; + string = string.strip(); + return string ? string.split(/\s+/) : []; +} + +if (Prototype.Browser.Opera){ + Array.prototype.concat = function() { + var array = []; + for (var i = 0, length = this.length; i < length; i++) array.push(this[i]); + for (var i = 0, length = arguments.length; i < length; i++) { + if (Object.isArray(arguments[i])) { + for (var j = 0, arrayLength = arguments[i].length; j < arrayLength; j++) + array.push(arguments[i][j]); + } else { + array.push(arguments[i]); + } + } + return array; + }; +} +Object.extend(Number.prototype, { + toColorPart: function() { + return this.toPaddedString(2, 16); + }, + + succ: function() { + return this + 1; + }, + + times: function(iterator) { + $R(0, this, true).each(iterator); + return this; + }, + + toPaddedString: function(length, radix) { + var string = this.toString(radix || 10); + return '0'.times(length - string.length) + string; + }, + + toJSON: function() { + return isFinite(this) ? this.toString() : 'null'; + } +}); + +$w('abs round ceil floor').each(function(method){ + Number.prototype[method] = Math[method].methodize(); +}); +function $H(object) { + return new Hash(object); +}; + +var Hash = Class.create(Enumerable, (function() { + + function toQueryPair(key, value) { + if (Object.isUndefined(value)) return key; + return key + '=' + encodeURIComponent(String.interpret(value)); + } + + return { + initialize: function(object) { + this._object = Object.isHash(object) ? object.toObject() : Object.clone(object); + }, + + _each: function(iterator) { + for (var key in this._object) { + var value = this._object[key], pair = [key, value]; + pair.key = key; + pair.value = value; + iterator(pair); + } + }, + + set: function(key, value) { + return this._object[key] = value; + }, + + get: function(key) { + return this._object[key]; + }, + + unset: function(key) { + var value = this._object[key]; + delete this._object[key]; + return value; + }, + + toObject: function() { + return Object.clone(this._object); + }, + + keys: function() { + return this.pluck('key'); + }, + + values: function() { + return this.pluck('value'); + }, + + index: function(value) { + var match = this.detect(function(pair) { + return pair.value === value; + }); + return match && match.key; + }, + + merge: function(object) { + return this.clone().update(object); + }, + + update: function(object) { + return new Hash(object).inject(this, function(result, pair) { + result.set(pair.key, pair.value); + return result; + }); + }, + + toQueryString: function() { + return this.map(function(pair) { + var key = encodeURIComponent(pair.key), values = pair.value; + + if (values && typeof values == 'object') { + if (Object.isArray(values)) + return values.map(toQueryPair.curry(key)).join('&'); + } + return toQueryPair(key, values); + }).join('&'); + }, + + inspect: function() { + return '#'; + }, + + toJSON: function() { + return Object.toJSON(this.toObject()); + }, + + clone: function() { + return new Hash(this); + } + } +})()); + +Hash.prototype.toTemplateReplacements = Hash.prototype.toObject; +Hash.from = $H; +var ObjectRange = Class.create(Enumerable, { + initialize: function(start, end, exclusive) { + this.start = start; + this.end = end; + this.exclusive = exclusive; + }, + + _each: function(iterator) { + var value = this.start; + while (this.include(value)) { + iterator(value); + value = value.succ(); + } + }, + + include: function(value) { + if (value < this.start) + return false; + if (this.exclusive) + return value < this.end; + return value <= this.end; + } +}); + +var $R = function(start, end, exclusive) { + return new ObjectRange(start, end, exclusive); +}; + +var Ajax = { + getTransport: function() { + return Try.these( + function() {return new XMLHttpRequest()}, + function() {return new ActiveXObject('Msxml2.XMLHTTP')}, + function() {return new ActiveXObject('Microsoft.XMLHTTP')} + ) || false; + }, + + activeRequestCount: 0 +}; + +Ajax.Responders = { + responders: [], + + _each: function(iterator) { + this.responders._each(iterator); + }, + + register: function(responder) { + if (!this.include(responder)) + this.responders.push(responder); + }, + + unregister: function(responder) { + this.responders = this.responders.without(responder); + }, + + dispatch: function(callback, request, transport, json) { + this.each(function(responder) { + if (Object.isFunction(responder[callback])) { + try { + responder[callback].apply(responder, [request, transport, json]); + } catch (e) { } + } + }); + } +}; + +Object.extend(Ajax.Responders, Enumerable); + +Ajax.Responders.register({ + onCreate: function() { Ajax.activeRequestCount++ }, + onComplete: function() { Ajax.activeRequestCount-- } +}); + +Ajax.Base = Class.create({ + initialize: function(options) { + this.options = { + method: 'post', + asynchronous: true, + contentType: 'application/x-www-form-urlencoded', + encoding: 'UTF-8', + parameters: '', + evalJSON: true, + evalJS: true + }; + Object.extend(this.options, options || { }); + + this.options.method = this.options.method.toLowerCase(); + + if (Object.isString(this.options.parameters)) + this.options.parameters = this.options.parameters.toQueryParams(); + else if (Object.isHash(this.options.parameters)) + this.options.parameters = this.options.parameters.toObject(); + } +}); + +Ajax.Request = Class.create(Ajax.Base, { + _complete: false, + + initialize: function($super, url, options) { + $super(options); + this.transport = Ajax.getTransport(); + this.request(url); + }, + + request: function(url) { + this.url = url; + this.method = this.options.method; + var params = Object.clone(this.options.parameters); + + if (!['get', 'post'].include(this.method)) { + // simulate other verbs over post + params['_method'] = this.method; + this.method = 'post'; + } + + this.parameters = params; + + if (params = Object.toQueryString(params)) { + // when GET, append parameters to URL + if (this.method == 'get') + this.url += (this.url.include('?') ? '&' : '?') + params; + else if (/Konqueror|Safari|KHTML/.test(navigator.userAgent)) + params += '&_='; + } + + try { + var response = new Ajax.Response(this); + if (this.options.onCreate) this.options.onCreate(response); + Ajax.Responders.dispatch('onCreate', this, response); + + this.transport.open(this.method.toUpperCase(), this.url, + this.options.asynchronous); + + if (this.options.asynchronous) this.respondToReadyState.bind(this).defer(1); + + this.transport.onreadystatechange = this.onStateChange.bind(this); + this.setRequestHeaders(); + + this.body = this.method == 'post' ? (this.options.postBody || params) : null; + this.transport.send(this.body); + + /* Force Firefox to handle ready state 4 for synchronous requests */ + if (!this.options.asynchronous && this.transport.overrideMimeType) + this.onStateChange(); + + } + catch (e) { + this.dispatchException(e); + } + }, + + onStateChange: function() { + var readyState = this.transport.readyState; + if (readyState > 1 && !((readyState == 4) && this._complete)) + this.respondToReadyState(this.transport.readyState); + }, + + setRequestHeaders: function() { + var headers = { + 'X-Requested-With': 'XMLHttpRequest', + 'X-Prototype-Version': Prototype.Version, + 'Accept': 'text/javascript, text/html, application/xml, text/xml, */*' + }; + + if (this.method == 'post') { + headers['Content-type'] = this.options.contentType + + (this.options.encoding ? '; charset=' + this.options.encoding : ''); + + /* Force "Connection: close" for older Mozilla browsers to work + * around a bug where XMLHttpRequest sends an incorrect + * Content-length header. See Mozilla Bugzilla #246651. + */ + if (this.transport.overrideMimeType && + (navigator.userAgent.match(/Gecko\/(\d{4})/) || [0,2005])[1] < 2005) + headers['Connection'] = 'close'; + } + + // user-defined headers + if (typeof this.options.requestHeaders == 'object') { + var extras = this.options.requestHeaders; + + if (Object.isFunction(extras.push)) + for (var i = 0, length = extras.length; i < length; i += 2) + headers[extras[i]] = extras[i+1]; + else + $H(extras).each(function(pair) { headers[pair.key] = pair.value }); + } + + for (var name in headers) + this.transport.setRequestHeader(name, headers[name]); + }, + + success: function() { + var status = this.getStatus(); + return !status || (status >= 200 && status < 300); + }, + + getStatus: function() { + try { + return this.transport.status || 0; + } catch (e) { return 0 } + }, + + respondToReadyState: function(readyState) { + var state = Ajax.Request.Events[readyState], response = new Ajax.Response(this); + + if (state == 'Complete') { + try { + this._complete = true; + (this.options['on' + response.status] + || this.options['on' + (this.success() ? 'Success' : 'Failure')] + || Prototype.emptyFunction)(response, response.headerJSON); + } catch (e) { + this.dispatchException(e); + } + + var contentType = response.getHeader('Content-type'); + if (this.options.evalJS == 'force' + || (this.options.evalJS && contentType + && contentType.match(/^\s*(text|application)\/(x-)?(java|ecma)script(;.*)?\s*$/i))) + this.evalResponse(); + } + + try { + (this.options['on' + state] || Prototype.emptyFunction)(response, response.headerJSON); + Ajax.Responders.dispatch('on' + state, this, response, response.headerJSON); + } catch (e) { + this.dispatchException(e); + } + + if (state == 'Complete') { + // avoid memory leak in MSIE: clean up + this.transport.onreadystatechange = Prototype.emptyFunction; + } + }, + + getHeader: function(name) { + try { + return this.transport.getResponseHeader(name); + } catch (e) { return null } + }, + + evalResponse: function() { + try { + return eval((this.transport.responseText || '').unfilterJSON()); + } catch (e) { + this.dispatchException(e); + } + }, + + dispatchException: function(exception) { + (this.options.onException || Prototype.emptyFunction)(this, exception); + Ajax.Responders.dispatch('onException', this, exception); + } +}); + +Ajax.Request.Events = + ['Uninitialized', 'Loading', 'Loaded', 'Interactive', 'Complete']; + +Ajax.Response = Class.create({ + initialize: function(request){ + this.request = request; + var transport = this.transport = request.transport, + readyState = this.readyState = transport.readyState; + + if((readyState > 2 && !Prototype.Browser.IE) || readyState == 4) { + this.status = this.getStatus(); + this.statusText = this.getStatusText(); + this.responseText = String.interpret(transport.responseText); + this.headerJSON = this._getHeaderJSON(); + } + + if(readyState == 4) { + var xml = transport.responseXML; + this.responseXML = Object.isUndefined(xml) ? null : xml; + this.responseJSON = this._getResponseJSON(); + } + }, + + status: 0, + statusText: '', + + getStatus: Ajax.Request.prototype.getStatus, + + getStatusText: function() { + try { + return this.transport.statusText || ''; + } catch (e) { return '' } + }, + + getHeader: Ajax.Request.prototype.getHeader, + + getAllHeaders: function() { + try { + return this.getAllResponseHeaders(); + } catch (e) { return null } + }, + + getResponseHeader: function(name) { + return this.transport.getResponseHeader(name); + }, + + getAllResponseHeaders: function() { + return this.transport.getAllResponseHeaders(); + }, + + _getHeaderJSON: function() { + var json = this.getHeader('X-JSON'); + if (!json) return null; + json = decodeURIComponent(escape(json)); + try { + return json.evalJSON(this.request.options.sanitizeJSON); + } catch (e) { + this.request.dispatchException(e); + } + }, + + _getResponseJSON: function() { + var options = this.request.options; + if (!options.evalJSON || (options.evalJSON != 'force' && + !(this.getHeader('Content-type') || '').include('application/json')) || + this.responseText.blank()) + return null; + try { + return this.responseText.evalJSON(options.sanitizeJSON); + } catch (e) { + this.request.dispatchException(e); + } + } +}); + +Ajax.Updater = Class.create(Ajax.Request, { + initialize: function($super, container, url, options) { + this.container = { + success: (container.success || container), + failure: (container.failure || (container.success ? null : container)) + }; + + options = Object.clone(options); + var onComplete = options.onComplete; + options.onComplete = (function(response, json) { + this.updateContent(response.responseText); + if (Object.isFunction(onComplete)) onComplete(response, json); + }).bind(this); + + $super(url, options); + }, + + updateContent: function(responseText) { + var receiver = this.container[this.success() ? 'success' : 'failure'], + options = this.options; + + if (!options.evalScripts) responseText = responseText.stripScripts(); + + if (receiver = $(receiver)) { + if (options.insertion) { + if (Object.isString(options.insertion)) { + var insertion = { }; insertion[options.insertion] = responseText; + receiver.insert(insertion); + } + else options.insertion(receiver, responseText); + } + else receiver.update(responseText); + } + } +}); + +Ajax.PeriodicalUpdater = Class.create(Ajax.Base, { + initialize: function($super, container, url, options) { + $super(options); + this.onComplete = this.options.onComplete; + + this.frequency = (this.options.frequency || 2); + this.decay = (this.options.decay || 1); + + this.updater = { }; + this.container = container; + this.url = url; + + this.start(); + }, + + start: function() { + this.options.onComplete = this.updateComplete.bind(this); + this.onTimerEvent(); + }, + + stop: function() { + this.updater.options.onComplete = undefined; + clearTimeout(this.timer); + (this.onComplete || Prototype.emptyFunction).apply(this, arguments); + }, + + updateComplete: function(response) { + if (this.options.decay) { + this.decay = (response.responseText == this.lastText ? + this.decay * this.options.decay : 1); + + this.lastText = response.responseText; + } + this.timer = this.onTimerEvent.bind(this).delay(this.decay * this.frequency); + }, + + onTimerEvent: function() { + this.updater = new Ajax.Updater(this.container, this.url, this.options); + } +}); +function $(element) { + if (arguments.length > 1) { + for (var i = 0, elements = [], length = arguments.length; i < length; i++) + elements.push($(arguments[i])); + return elements; + } + if (Object.isString(element)) + element = document.getElementById(element); + return Element.extend(element); +} + +if (Prototype.BrowserFeatures.XPath) { + document._getElementsByXPath = function(expression, parentElement) { + var results = []; + var query = document.evaluate(expression, $(parentElement) || document, + null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null); + for (var i = 0, length = query.snapshotLength; i < length; i++) + results.push(Element.extend(query.snapshotItem(i))); + return results; + }; +} + +/*--------------------------------------------------------------------------*/ + +if (!window.Node) var Node = { }; + +if (!Node.ELEMENT_NODE) { + // DOM level 2 ECMAScript Language Binding + Object.extend(Node, { + ELEMENT_NODE: 1, + ATTRIBUTE_NODE: 2, + TEXT_NODE: 3, + CDATA_SECTION_NODE: 4, + ENTITY_REFERENCE_NODE: 5, + ENTITY_NODE: 6, + PROCESSING_INSTRUCTION_NODE: 7, + COMMENT_NODE: 8, + DOCUMENT_NODE: 9, + DOCUMENT_TYPE_NODE: 10, + DOCUMENT_FRAGMENT_NODE: 11, + NOTATION_NODE: 12 + }); +} + +(function() { + var element = this.Element; + this.Element = function(tagName, attributes) { + attributes = attributes || { }; + tagName = tagName.toLowerCase(); + var cache = Element.cache; + if (Prototype.Browser.IE && attributes.name) { + tagName = '<' + tagName + ' name="' + attributes.name + '">'; + delete attributes.name; + return Element.writeAttribute(document.createElement(tagName), attributes); + } + if (!cache[tagName]) cache[tagName] = Element.extend(document.createElement(tagName)); + return Element.writeAttribute(cache[tagName].cloneNode(false), attributes); + }; + Object.extend(this.Element, element || { }); +}).call(window); + +Element.cache = { }; + +Element.Methods = { + visible: function(element) { + return $(element).style.display != 'none'; + }, + + toggle: function(element) { + element = $(element); + Element[Element.visible(element) ? 'hide' : 'show'](element); + return element; + }, + + hide: function(element) { + $(element).style.display = 'none'; + return element; + }, + + show: function(element) { + $(element).style.display = ''; + return element; + }, + + remove: function(element) { + element = $(element); + element.parentNode.removeChild(element); + return element; + }, + + update: function(element, content) { + element = $(element); + if (content && content.toElement) content = content.toElement(); + if (Object.isElement(content)) return element.update().insert(content); + content = Object.toHTML(content); + element.innerHTML = content.stripScripts(); + content.evalScripts.bind(content).defer(); + return element; + }, + + replace: function(element, content) { + element = $(element); + if (content && content.toElement) content = content.toElement(); + else if (!Object.isElement(content)) { + content = Object.toHTML(content); + var range = element.ownerDocument.createRange(); + range.selectNode(element); + content.evalScripts.bind(content).defer(); + content = range.createContextualFragment(content.stripScripts()); + } + element.parentNode.replaceChild(content, element); + return element; + }, + + insert: function(element, insertions) { + element = $(element); + + if (Object.isString(insertions) || Object.isNumber(insertions) || + Object.isElement(insertions) || (insertions && (insertions.toElement || insertions.toHTML))) + insertions = {bottom:insertions}; + + var content, t, range; + + for (position in insertions) { + content = insertions[position]; + position = position.toLowerCase(); + t = Element._insertionTranslations[position]; + + if (content && content.toElement) content = content.toElement(); + if (Object.isElement(content)) { + t.insert(element, content); + continue; + } + + content = Object.toHTML(content); + + range = element.ownerDocument.createRange(); + t.initializeRange(element, range); + t.insert(element, range.createContextualFragment(content.stripScripts())); + + content.evalScripts.bind(content).defer(); + } + + return element; + }, + + wrap: function(element, wrapper, attributes) { + element = $(element); + if (Object.isElement(wrapper)) + $(wrapper).writeAttribute(attributes || { }); + else if (Object.isString(wrapper)) wrapper = new Element(wrapper, attributes); + else wrapper = new Element('div', wrapper); + if (element.parentNode) + element.parentNode.replaceChild(wrapper, element); + wrapper.appendChild(element); + return wrapper; + }, + + inspect: function(element) { + element = $(element); + var result = '<' + element.tagName.toLowerCase(); + $H({'id': 'id', 'className': 'class'}).each(function(pair) { + var property = pair.first(), attribute = pair.last(); + var value = (element[property] || '').toString(); + if (value) result += ' ' + attribute + '=' + value.inspect(true); + }); + return result + '>'; + }, + + recursivelyCollect: function(element, property) { + element = $(element); + var elements = []; + while (element = element[property]) + if (element.nodeType == 1) + elements.push(Element.extend(element)); + return elements; + }, + + ancestors: function(element) { + return $(element).recursivelyCollect('parentNode'); + }, + + descendants: function(element) { + return $(element).getElementsBySelector("*"); + }, + + firstDescendant: function(element) { + element = $(element).firstChild; + while (element && element.nodeType != 1) element = element.nextSibling; + return $(element); + }, + + immediateDescendants: function(element) { + if (!(element = $(element).firstChild)) return []; + while (element && element.nodeType != 1) element = element.nextSibling; + if (element) return [element].concat($(element).nextSiblings()); + return []; + }, + + previousSiblings: function(element) { + return $(element).recursivelyCollect('previousSibling'); + }, + + nextSiblings: function(element) { + return $(element).recursivelyCollect('nextSibling'); + }, + + siblings: function(element) { + element = $(element); + return element.previousSiblings().reverse().concat(element.nextSiblings()); + }, + + match: function(element, selector) { + if (Object.isString(selector)) + selector = new Selector(selector); + return selector.match($(element)); + }, + + up: function(element, expression, index) { + element = $(element); + if (arguments.length == 1) return $(element.parentNode); + var ancestors = element.ancestors(); + return expression ? Selector.findElement(ancestors, expression, index) : + ancestors[index || 0]; + }, + + down: function(element, expression, index) { + element = $(element); + if (arguments.length == 1) return element.firstDescendant(); + var descendants = element.descendants(); + return expression ? Selector.findElement(descendants, expression, index) : + descendants[index || 0]; + }, + + previous: function(element, expression, index) { + element = $(element); + if (arguments.length == 1) return $(Selector.handlers.previousElementSibling(element)); + var previousSiblings = element.previousSiblings(); + return expression ? Selector.findElement(previousSiblings, expression, index) : + previousSiblings[index || 0]; + }, + + next: function(element, expression, index) { + element = $(element); + if (arguments.length == 1) return $(Selector.handlers.nextElementSibling(element)); + var nextSiblings = element.nextSiblings(); + return expression ? Selector.findElement(nextSiblings, expression, index) : + nextSiblings[index || 0]; + }, + + select: function() { + var args = $A(arguments), element = $(args.shift()); + return Selector.findChildElements(element, args); + }, + + adjacent: function() { + var args = $A(arguments), element = $(args.shift()); + return Selector.findChildElements(element.parentNode, args).without(element); + }, + + identify: function(element) { + element = $(element); + var id = element.readAttribute('id'), self = arguments.callee; + if (id) return id; + do { id = 'anonymous_element_' + self.counter++ } while ($(id)); + element.writeAttribute('id', id); + return id; + }, + + readAttribute: function(element, name) { + element = $(element); + if (Prototype.Browser.IE) { + var t = Element._attributeTranslations.read; + if (t.values[name]) return t.values[name](element, name); + if (t.names[name]) name = t.names[name]; + if (name.include(':')) { + return (!element.attributes || !element.attributes[name]) ? null : + element.attributes[name].value; + } + } + return element.getAttribute(name); + }, + + writeAttribute: function(element, name, value) { + element = $(element); + var attributes = { }, t = Element._attributeTranslations.write; + + if (typeof name == 'object') attributes = name; + else attributes[name] = Object.isUndefined(value) ? true : value; + + for (var attr in attributes) { + name = t.names[attr] || attr; + value = attributes[attr]; + if (t.values[attr]) name = t.values[attr](element, value); + if (value === false || value === null) + element.removeAttribute(name); + else if (value === true) + element.setAttribute(name, name); + else element.setAttribute(name, value); + } + return element; + }, + + getHeight: function(element) { + return $(element).getDimensions().height; + }, + + getWidth: function(element) { + return $(element).getDimensions().width; + }, + + classNames: function(element) { + return new Element.ClassNames(element); + }, + + hasClassName: function(element, className) { + if (!(element = $(element))) return; + var elementClassName = element.className; + return (elementClassName.length > 0 && (elementClassName == className || + new RegExp("(^|\\s)" + className + "(\\s|$)").test(elementClassName))); + }, + + addClassName: function(element, className) { + if (!(element = $(element))) return; + if (!element.hasClassName(className)) + element.className += (element.className ? ' ' : '') + className; + return element; + }, + + removeClassName: function(element, className) { + if (!(element = $(element))) return; + element.className = element.className.replace( + new RegExp("(^|\\s+)" + className + "(\\s+|$)"), ' ').strip(); + return element; + }, + + toggleClassName: function(element, className) { + if (!(element = $(element))) return; + return element[element.hasClassName(className) ? + 'removeClassName' : 'addClassName'](className); + }, + + // removes whitespace-only text node children + cleanWhitespace: function(element) { + element = $(element); + var node = element.firstChild; + while (node) { + var nextNode = node.nextSibling; + if (node.nodeType == 3 && !/\S/.test(node.nodeValue)) + element.removeChild(node); + node = nextNode; + } + return element; + }, + + empty: function(element) { + return $(element).innerHTML.blank(); + }, + + descendantOf: function(element, ancestor) { + element = $(element), ancestor = $(ancestor); + var originalAncestor = ancestor; + + if (element.compareDocumentPosition) + return (element.compareDocumentPosition(ancestor) & 8) === 8; + + if (element.sourceIndex && !Prototype.Browser.Opera) { + var e = element.sourceIndex, a = ancestor.sourceIndex, + nextAncestor = ancestor.nextSibling; + if (!nextAncestor) { + do { ancestor = ancestor.parentNode; } + while (!(nextAncestor = ancestor.nextSibling) && ancestor.parentNode); + } + if (nextAncestor) return (e > a && e < nextAncestor.sourceIndex); + } + + while (element = element.parentNode) + if (element == originalAncestor) return true; + return false; + }, + + scrollTo: function(element) { + element = $(element); + var pos = element.cumulativeOffset(); + window.scrollTo(pos[0], pos[1]); + return element; + }, + + getStyle: function(element, style) { + element = $(element); + style = style == 'float' ? 'cssFloat' : style.camelize(); + var value = element.style[style]; + if (!value) { + var css = document.defaultView.getComputedStyle(element, null); + value = css ? css[style] : null; + } + if (style == 'opacity') return value ? parseFloat(value) : 1.0; + return value == 'auto' ? null : value; + }, + + getOpacity: function(element) { + return $(element).getStyle('opacity'); + }, + + setStyle: function(element, styles) { + element = $(element); + var elementStyle = element.style, match; + if (Object.isString(styles)) { + element.style.cssText += ';' + styles; + return styles.include('opacity') ? + element.setOpacity(styles.match(/opacity:\s*(\d?\.?\d*)/)[1]) : element; + } + for (var property in styles) + if (property == 'opacity') element.setOpacity(styles[property]); + else + elementStyle[(property == 'float' || property == 'cssFloat') ? + (Object.isUndefined(elementStyle.styleFloat) ? 'cssFloat' : 'styleFloat') : + property] = styles[property]; + + return element; + }, + + setOpacity: function(element, value) { + element = $(element); + element.style.opacity = (value == 1 || value === '') ? '' : + (value < 0.00001) ? 0 : value; + return element; + }, + + getDimensions: function(element) { + element = $(element); + var display = $(element).getStyle('display'); + if (display != 'none' && display != null) // Safari bug + return {width: element.offsetWidth, height: element.offsetHeight}; + + // All *Width and *Height properties give 0 on elements with display none, + // so enable the element temporarily + var els = element.style; + var originalVisibility = els.visibility; + var originalPosition = els.position; + var originalDisplay = els.display; + els.visibility = 'hidden'; + els.position = 'absolute'; + els.display = 'block'; + var originalWidth = element.clientWidth; + var originalHeight = element.clientHeight; + els.display = originalDisplay; + els.position = originalPosition; + els.visibility = originalVisibility; + return {width: originalWidth, height: originalHeight}; + }, + + makePositioned: function(element) { + element = $(element); + var pos = Element.getStyle(element, 'position'); + if (pos == 'static' || !pos) { + element._madePositioned = true; + element.style.position = 'relative'; + // Opera returns the offset relative to the positioning context, when an + // element is position relative but top and left have not been defined + if (window.opera) { + element.style.top = 0; + element.style.left = 0; + } + } + return element; + }, + + undoPositioned: function(element) { + element = $(element); + if (element._madePositioned) { + element._madePositioned = undefined; + element.style.position = + element.style.top = + element.style.left = + element.style.bottom = + element.style.right = ''; + } + return element; + }, + + makeClipping: function(element) { + element = $(element); + if (element._overflow) return element; + element._overflow = Element.getStyle(element, 'overflow') || 'auto'; + if (element._overflow !== 'hidden') + element.style.overflow = 'hidden'; + return element; + }, + + undoClipping: function(element) { + element = $(element); + if (!element._overflow) return element; + element.style.overflow = element._overflow == 'auto' ? '' : element._overflow; + element._overflow = null; + return element; + }, + + cumulativeOffset: function(element) { + var valueT = 0, valueL = 0; + do { + valueT += element.offsetTop || 0; + valueL += element.offsetLeft || 0; + element = element.offsetParent; + } while (element); + return Element._returnOffset(valueL, valueT); + }, + + positionedOffset: function(element) { + var valueT = 0, valueL = 0; + do { + valueT += element.offsetTop || 0; + valueL += element.offsetLeft || 0; + element = element.offsetParent; + if (element) { + if (element.tagName == 'BODY') break; + var p = Element.getStyle(element, 'position'); + if (p == 'relative' || p == 'absolute') break; + } + } while (element); + return Element._returnOffset(valueL, valueT); + }, + + absolutize: function(element) { + element = $(element); + if (element.getStyle('position') == 'absolute') return; + // Position.prepare(); // To be done manually by Scripty when it needs it. + + var offsets = element.positionedOffset(); + var top = offsets[1]; + var left = offsets[0]; + var width = element.clientWidth; + var height = element.clientHeight; + + element._originalLeft = left - parseFloat(element.style.left || 0); + element._originalTop = top - parseFloat(element.style.top || 0); + element._originalWidth = element.style.width; + element._originalHeight = element.style.height; + + element.style.position = 'absolute'; + element.style.top = top + 'px'; + element.style.left = left + 'px'; + element.style.width = width + 'px'; + element.style.height = height + 'px'; + return element; + }, + + relativize: function(element) { + element = $(element); + if (element.getStyle('position') == 'relative') return; + // Position.prepare(); // To be done manually by Scripty when it needs it. + + element.style.position = 'relative'; + var top = parseFloat(element.style.top || 0) - (element._originalTop || 0); + var left = parseFloat(element.style.left || 0) - (element._originalLeft || 0); + + element.style.top = top + 'px'; + element.style.left = left + 'px'; + element.style.height = element._originalHeight; + element.style.width = element._originalWidth; + return element; + }, + + cumulativeScrollOffset: function(element) { + var valueT = 0, valueL = 0; + do { + valueT += element.scrollTop || 0; + valueL += element.scrollLeft || 0; + element = element.parentNode; + } while (element); + return Element._returnOffset(valueL, valueT); + }, + + getOffsetParent: function(element) { + if (element.offsetParent) return $(element.offsetParent); + if (element == document.body) return $(element); + + while ((element = element.parentNode) && element != document.body) + if (Element.getStyle(element, 'position') != 'static') + return $(element); + + return $(document.body); + }, + + viewportOffset: function(forElement) { + var valueT = 0, valueL = 0; + + var element = forElement; + do { + valueT += element.offsetTop || 0; + valueL += element.offsetLeft || 0; + + // Safari fix + if (element.offsetParent == document.body && + Element.getStyle(element, 'position') == 'absolute') break; + + } while (element = element.offsetParent); + + element = forElement; + do { + if (!Prototype.Browser.Opera || element.tagName == 'BODY') { + valueT -= element.scrollTop || 0; + valueL -= element.scrollLeft || 0; + } + } while (element = element.parentNode); + + return Element._returnOffset(valueL, valueT); + }, + + clonePosition: function(element, source) { + var options = Object.extend({ + setLeft: true, + setTop: true, + setWidth: true, + setHeight: true, + offsetTop: 0, + offsetLeft: 0 + }, arguments[2] || { }); + + // find page position of source + source = $(source); + var p = source.viewportOffset(); + + // find coordinate system to use + element = $(element); + var delta = [0, 0]; + var parent = null; + // delta [0,0] will do fine with position: fixed elements, + // position:absolute needs offsetParent deltas + if (Element.getStyle(element, 'position') == 'absolute') { + parent = element.getOffsetParent(); + delta = parent.viewportOffset(); + } + + // correct by body offsets (fixes Safari) + if (parent == document.body) { + delta[0] -= document.body.offsetLeft; + delta[1] -= document.body.offsetTop; + } + + // set position + if (options.setLeft) element.style.left = (p[0] - delta[0] + options.offsetLeft) + 'px'; + if (options.setTop) element.style.top = (p[1] - delta[1] + options.offsetTop) + 'px'; + if (options.setWidth) element.style.width = source.offsetWidth + 'px'; + if (options.setHeight) element.style.height = source.offsetHeight + 'px'; + return element; + } +}; + +Element.Methods.identify.counter = 1; + +Object.extend(Element.Methods, { + getElementsBySelector: Element.Methods.select, + childElements: Element.Methods.immediateDescendants +}); + +Element._attributeTranslations = { + write: { + names: { + className: 'class', + htmlFor: 'for' + }, + values: { } + } +}; + + +if (!document.createRange || Prototype.Browser.Opera) { + Element.Methods.insert = function(element, insertions) { + element = $(element); + + if (Object.isString(insertions) || Object.isNumber(insertions) || + Object.isElement(insertions) || (insertions && (insertions.toElement || insertions.toHTML))) + insertions = { bottom: insertions }; + + var t = Element._insertionTranslations, content, position, pos, tagName; + + for (position in insertions) { + content = insertions[position]; + position = position.toLowerCase(); + pos = t[position]; + + if (content && content.toElement) content = content.toElement(); + if (Object.isElement(content)) { + pos.insert(element, content); + continue; + } + + content = Object.toHTML(content); + tagName = ((position == 'before' || position == 'after') + ? element.parentNode : element).tagName.toUpperCase(); + + if (t.tags[tagName]) { + var fragments = Element._getContentFromAnonymousElement(tagName, content.stripScripts()); + if (position == 'top' || position == 'after') fragments.reverse(); + fragments.each(pos.insert.curry(element)); + } + else element.insertAdjacentHTML(pos.adjacency, content.stripScripts()); + + content.evalScripts.bind(content).defer(); + } + + return element; + }; +} + +if (Prototype.Browser.Opera) { + Element.Methods.getStyle = Element.Methods.getStyle.wrap( + function(proceed, element, style) { + switch (style) { + case 'left': case 'top': case 'right': case 'bottom': + if (proceed(element, 'position') === 'static') return null; + case 'height': case 'width': + // returns '0px' for hidden elements; we want it to return null + if (!Element.visible(element)) return null; + + // returns the border-box dimensions rather than the content-box + // dimensions, so we subtract padding and borders from the value + var dim = parseInt(proceed(element, style), 10); + + if (dim !== element['offset' + style.capitalize()]) + return dim + 'px'; + + var properties; + if (style === 'height') { + properties = ['border-top-width', 'padding-top', + 'padding-bottom', 'border-bottom-width']; + } + else { + properties = ['border-left-width', 'padding-left', + 'padding-right', 'border-right-width']; + } + return properties.inject(dim, function(memo, property) { + var val = proceed(element, property); + return val === null ? memo : memo - parseInt(val, 10); + }) + 'px'; + default: return proceed(element, style); + } + } + ); + + Element.Methods.readAttribute = Element.Methods.readAttribute.wrap( + function(proceed, element, attribute) { + if (attribute === 'title') return element.title; + return proceed(element, attribute); + } + ); +} + +else if (Prototype.Browser.IE) { + $w('positionedOffset getOffsetParent viewportOffset').each(function(method) { + Element.Methods[method] = Element.Methods[method].wrap( + function(proceed, element) { + element = $(element); + var position = element.getStyle('position'); + if (position != 'static') return proceed(element); + element.setStyle({ position: 'relative' }); + var value = proceed(element); + element.setStyle({ position: position }); + return value; + } + ); + }); + + Element.Methods.getStyle = function(element, style) { + element = $(element); + style = (style == 'float' || style == 'cssFloat') ? 'styleFloat' : style.camelize(); + var value = element.style[style]; + if (!value && element.currentStyle) value = element.currentStyle[style]; + + if (style == 'opacity') { + if (value = (element.getStyle('filter') || '').match(/alpha\(opacity=(.*)\)/)) + if (value[1]) return parseFloat(value[1]) / 100; + return 1.0; + } + + if (value == 'auto') { + if ((style == 'width' || style == 'height') && (element.getStyle('display') != 'none')) + return element['offset' + style.capitalize()] + 'px'; + return null; + } + return value; + }; + + Element.Methods.setOpacity = function(element, value) { + function stripAlpha(filter){ + return filter.replace(/alpha\([^\)]*\)/gi,''); + } + element = $(element); + var currentStyle = element.currentStyle; + if ((currentStyle && !currentStyle.hasLayout) || + (!currentStyle && element.style.zoom == 'normal')) + element.style.zoom = 1; + + var filter = element.getStyle('filter'), style = element.style; + if (value == 1 || value === '') { + (filter = stripAlpha(filter)) ? + style.filter = filter : style.removeAttribute('filter'); + return element; + } else if (value < 0.00001) value = 0; + style.filter = stripAlpha(filter) + + 'alpha(opacity=' + (value * 100) + ')'; + return element; + }; + + Element._attributeTranslations = { + read: { + names: { + 'class': 'className', + 'for': 'htmlFor' + }, + values: { + _getAttr: function(element, attribute) { + return element.getAttribute(attribute, 2); + }, + _getAttrNode: function(element, attribute) { + var node = element.getAttributeNode(attribute); + return node ? node.value : ""; + }, + _getEv: function(element, attribute) { + attribute = element.getAttribute(attribute); + return attribute ? attribute.toString().slice(23, -2) : null; + }, + _flag: function(element, attribute) { + return $(element).hasAttribute(attribute) ? attribute : null; + }, + style: function(element) { + return element.style.cssText.toLowerCase(); + }, + title: function(element) { + return element.title; + } + } + } + }; + + Element._attributeTranslations.write = { + names: Object.clone(Element._attributeTranslations.read.names), + values: { + checked: function(element, value) { + element.checked = !!value; + }, + + style: function(element, value) { + element.style.cssText = value ? value : ''; + } + } + }; + + Element._attributeTranslations.has = {}; + + $w('colSpan rowSpan vAlign dateTime accessKey tabIndex ' + + 'encType maxLength readOnly longDesc').each(function(attr) { + Element._attributeTranslations.write.names[attr.toLowerCase()] = attr; + Element._attributeTranslations.has[attr.toLowerCase()] = attr; + }); + + (function(v) { + Object.extend(v, { + href: v._getAttr, + src: v._getAttr, + type: v._getAttr, + action: v._getAttrNode, + disabled: v._flag, + checked: v._flag, + readonly: v._flag, + multiple: v._flag, + onload: v._getEv, + onunload: v._getEv, + onclick: v._getEv, + ondblclick: v._getEv, + onmousedown: v._getEv, + onmouseup: v._getEv, + onmouseover: v._getEv, + onmousemove: v._getEv, + onmouseout: v._getEv, + onfocus: v._getEv, + onblur: v._getEv, + onkeypress: v._getEv, + onkeydown: v._getEv, + onkeyup: v._getEv, + onsubmit: v._getEv, + onreset: v._getEv, + onselect: v._getEv, + onchange: v._getEv + }); + })(Element._attributeTranslations.read.values); +} + +else if (Prototype.Browser.Gecko && /rv:1\.8\.0/.test(navigator.userAgent)) { + Element.Methods.setOpacity = function(element, value) { + element = $(element); + element.style.opacity = (value == 1) ? 0.999999 : + (value === '') ? '' : (value < 0.00001) ? 0 : value; + return element; + }; +} + +else if (Prototype.Browser.WebKit) { + Element.Methods.setOpacity = function(element, value) { + element = $(element); + element.style.opacity = (value == 1 || value === '') ? '' : + (value < 0.00001) ? 0 : value; + + if (value == 1) + if(element.tagName == 'IMG' && element.width) { + element.width++; element.width--; + } else try { + var n = document.createTextNode(' '); + element.appendChild(n); + element.removeChild(n); + } catch (e) { } + + return element; + }; + + // Safari returns margins on body which is incorrect if the child is absolutely + // positioned. For performance reasons, redefine Element#cumulativeOffset for + // KHTML/WebKit only. + Element.Methods.cumulativeOffset = function(element) { + var valueT = 0, valueL = 0; + do { + valueT += element.offsetTop || 0; + valueL += element.offsetLeft || 0; + if (element.offsetParent == document.body) + if (Element.getStyle(element, 'position') == 'absolute') break; + + element = element.offsetParent; + } while (element); + + return Element._returnOffset(valueL, valueT); + }; +} + +if (Prototype.Browser.IE || Prototype.Browser.Opera) { + // IE and Opera are missing .innerHTML support for TABLE-related and SELECT elements + Element.Methods.update = function(element, content) { + element = $(element); + + if (content && content.toElement) content = content.toElement(); + if (Object.isElement(content)) return element.update().insert(content); + + content = Object.toHTML(content); + var tagName = element.tagName.toUpperCase(); + + if (tagName in Element._insertionTranslations.tags) { + $A(element.childNodes).each(function(node) { element.removeChild(node) }); + Element._getContentFromAnonymousElement(tagName, content.stripScripts()) + .each(function(node) { element.appendChild(node) }); + } + else element.innerHTML = content.stripScripts(); + + content.evalScripts.bind(content).defer(); + return element; + }; +} + +if (document.createElement('div').outerHTML) { + Element.Methods.replace = function(element, content) { + element = $(element); + + if (content && content.toElement) content = content.toElement(); + if (Object.isElement(content)) { + element.parentNode.replaceChild(content, element); + return element; + } + + content = Object.toHTML(content); + var parent = element.parentNode, tagName = parent.tagName.toUpperCase(); + + if (Element._insertionTranslations.tags[tagName]) { + var nextSibling = element.next(); + var fragments = Element._getContentFromAnonymousElement(tagName, content.stripScripts()); + parent.removeChild(element); + if (nextSibling) + fragments.each(function(node) { parent.insertBefore(node, nextSibling) }); + else + fragments.each(function(node) { parent.appendChild(node) }); + } + else element.outerHTML = content.stripScripts(); + + content.evalScripts.bind(content).defer(); + return element; + }; +} + +Element._returnOffset = function(l, t) { + var result = [l, t]; + result.left = l; + result.top = t; + return result; +}; + +Element._getContentFromAnonymousElement = function(tagName, html) { + var div = new Element('div'), t = Element._insertionTranslations.tags[tagName]; + div.innerHTML = t[0] + html + t[1]; + t[2].times(function() { div = div.firstChild }); + return $A(div.childNodes); +}; + +Element._insertionTranslations = { + before: { + adjacency: 'beforeBegin', + insert: function(element, node) { + element.parentNode.insertBefore(node, element); + }, + initializeRange: function(element, range) { + range.setStartBefore(element); + } + }, + top: { + adjacency: 'afterBegin', + insert: function(element, node) { + element.insertBefore(node, element.firstChild); + }, + initializeRange: function(element, range) { + range.selectNodeContents(element); + range.collapse(true); + } + }, + bottom: { + adjacency: 'beforeEnd', + insert: function(element, node) { + element.appendChild(node); + } + }, + after: { + adjacency: 'afterEnd', + insert: function(element, node) { + element.parentNode.insertBefore(node, element.nextSibling); + }, + initializeRange: function(element, range) { + range.setStartAfter(element); + } + }, + tags: { + TABLE: ['', '
    ', 1], + TBODY: ['', '
    ', 2], + TR: ['', '
    ', 3], + TD: ['
    ', '
    ', 4], + SELECT: ['', 1] + } +}; + +(function() { + this.bottom.initializeRange = this.top.initializeRange; + Object.extend(this.tags, { + THEAD: this.tags.TBODY, + TFOOT: this.tags.TBODY, + TH: this.tags.TD + }); +}).call(Element._insertionTranslations); + +Element.Methods.Simulated = { + hasAttribute: function(element, attribute) { + attribute = Element._attributeTranslations.has[attribute] || attribute; + var node = $(element).getAttributeNode(attribute); + return node && node.specified; + } +}; + +Element.Methods.ByTag = { }; + +Object.extend(Element, Element.Methods); + +if (!Prototype.BrowserFeatures.ElementExtensions && + document.createElement('div').__proto__) { + window.HTMLElement = { }; + window.HTMLElement.prototype = document.createElement('div').__proto__; + Prototype.BrowserFeatures.ElementExtensions = true; +} + +Element.extend = (function() { + if (Prototype.BrowserFeatures.SpecificElementExtensions) + return Prototype.K; + + var Methods = { }, ByTag = Element.Methods.ByTag; + + var extend = Object.extend(function(element) { + if (!element || element._extendedByPrototype || + element.nodeType != 1 || element == window) return element; + + var methods = Object.clone(Methods), + tagName = element.tagName, property, value; + + // extend methods for specific tags + if (ByTag[tagName]) Object.extend(methods, ByTag[tagName]); + + for (property in methods) { + value = methods[property]; + if (Object.isFunction(value) && !(property in element)) + element[property] = value.methodize(); + } + + element._extendedByPrototype = Prototype.emptyFunction; + return element; + + }, { + refresh: function() { + // extend methods for all tags (Safari doesn't need this) + if (!Prototype.BrowserFeatures.ElementExtensions) { + Object.extend(Methods, Element.Methods); + Object.extend(Methods, Element.Methods.Simulated); + } + } + }); + + extend.refresh(); + return extend; +})(); + +Element.hasAttribute = function(element, attribute) { + if (element.hasAttribute) return element.hasAttribute(attribute); + return Element.Methods.Simulated.hasAttribute(element, attribute); +}; + +Element.addMethods = function(methods) { + var F = Prototype.BrowserFeatures, T = Element.Methods.ByTag; + + if (!methods) { + Object.extend(Form, Form.Methods); + Object.extend(Form.Element, Form.Element.Methods); + Object.extend(Element.Methods.ByTag, { + "FORM": Object.clone(Form.Methods), + "INPUT": Object.clone(Form.Element.Methods), + "SELECT": Object.clone(Form.Element.Methods), + "TEXTAREA": Object.clone(Form.Element.Methods) + }); + } + + if (arguments.length == 2) { + var tagName = methods; + methods = arguments[1]; + } + + if (!tagName) Object.extend(Element.Methods, methods || { }); + else { + if (Object.isArray(tagName)) tagName.each(extend); + else extend(tagName); + } + + function extend(tagName) { + tagName = tagName.toUpperCase(); + if (!Element.Methods.ByTag[tagName]) + Element.Methods.ByTag[tagName] = { }; + Object.extend(Element.Methods.ByTag[tagName], methods); + } + + function copy(methods, destination, onlyIfAbsent) { + onlyIfAbsent = onlyIfAbsent || false; + for (var property in methods) { + var value = methods[property]; + if (!Object.isFunction(value)) continue; + if (!onlyIfAbsent || !(property in destination)) + destination[property] = value.methodize(); + } + } + + function findDOMClass(tagName) { + var klass; + var trans = { + "OPTGROUP": "OptGroup", "TEXTAREA": "TextArea", "P": "Paragraph", + "FIELDSET": "FieldSet", "UL": "UList", "OL": "OList", "DL": "DList", + "DIR": "Directory", "H1": "Heading", "H2": "Heading", "H3": "Heading", + "H4": "Heading", "H5": "Heading", "H6": "Heading", "Q": "Quote", + "INS": "Mod", "DEL": "Mod", "A": "Anchor", "IMG": "Image", "CAPTION": + "TableCaption", "COL": "TableCol", "COLGROUP": "TableCol", "THEAD": + "TableSection", "TFOOT": "TableSection", "TBODY": "TableSection", "TR": + "TableRow", "TH": "TableCell", "TD": "TableCell", "FRAMESET": + "FrameSet", "IFRAME": "IFrame" + }; + if (trans[tagName]) klass = 'HTML' + trans[tagName] + 'Element'; + if (window[klass]) return window[klass]; + klass = 'HTML' + tagName + 'Element'; + if (window[klass]) return window[klass]; + klass = 'HTML' + tagName.capitalize() + 'Element'; + if (window[klass]) return window[klass]; + + window[klass] = { }; + window[klass].prototype = document.createElement(tagName).__proto__; + return window[klass]; + } + + if (F.ElementExtensions) { + copy(Element.Methods, HTMLElement.prototype); + copy(Element.Methods.Simulated, HTMLElement.prototype, true); + } + + if (F.SpecificElementExtensions) { + for (var tag in Element.Methods.ByTag) { + var klass = findDOMClass(tag); + if (Object.isUndefined(klass)) continue; + copy(T[tag], klass.prototype); + } + } + + Object.extend(Element, Element.Methods); + delete Element.ByTag; + + if (Element.extend.refresh) Element.extend.refresh(); + Element.cache = { }; +}; + +document.viewport = { + getDimensions: function() { + var dimensions = { }; + var B = Prototype.Browser; + $w('width height').each(function(d) { + var D = d.capitalize(); + dimensions[d] = (B.WebKit && !document.evaluate) ? self['inner' + D] : + (B.Opera) ? document.body['client' + D] : document.documentElement['client' + D]; + }); + return dimensions; + }, + + getWidth: function() { + return this.getDimensions().width; + }, + + getHeight: function() { + return this.getDimensions().height; + }, + + getScrollOffsets: function() { + return Element._returnOffset( + window.pageXOffset || document.documentElement.scrollLeft || document.body.scrollLeft, + window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop); + } +}; +/* Portions of the Selector class are derived from Jack Slocum’s DomQuery, + * part of YUI-Ext version 0.40, distributed under the terms of an MIT-style + * license. Please see http://www.yui-ext.com/ for more information. */ + +var Selector = Class.create({ + initialize: function(expression) { + this.expression = expression.strip(); + this.compileMatcher(); + }, + + shouldUseXPath: function() { + if (!Prototype.BrowserFeatures.XPath) return false; + + var e = this.expression; + + // Safari 3 chokes on :*-of-type and :empty + if (Prototype.Browser.WebKit && + (e.include("-of-type") || e.include(":empty"))) + return false; + + // XPath can't do namespaced attributes, nor can it read + // the "checked" property from DOM nodes + if ((/(\[[\w-]*?:|:checked)/).test(this.expression)) + return false; + + return true; + }, + + compileMatcher: function() { + if (this.shouldUseXPath()) + return this.compileXPathMatcher(); + + var e = this.expression, ps = Selector.patterns, h = Selector.handlers, + c = Selector.criteria, le, p, m; + + if (Selector._cache[e]) { + this.matcher = Selector._cache[e]; + return; + } + + this.matcher = ["this.matcher = function(root) {", + "var r = root, h = Selector.handlers, c = false, n;"]; + + while (e && le != e && (/\S/).test(e)) { + le = e; + for (var i in ps) { + p = ps[i]; + if (m = e.match(p)) { + this.matcher.push(Object.isFunction(c[i]) ? c[i](m) : + new Template(c[i]).evaluate(m)); + e = e.replace(m[0], ''); + break; + } + } + } + + this.matcher.push("return h.unique(n);\n}"); + eval(this.matcher.join('\n')); + Selector._cache[this.expression] = this.matcher; + }, + + compileXPathMatcher: function() { + var e = this.expression, ps = Selector.patterns, + x = Selector.xpath, le, m; + + if (Selector._cache[e]) { + this.xpath = Selector._cache[e]; return; + } + + this.matcher = ['.//*']; + while (e && le != e && (/\S/).test(e)) { + le = e; + for (var i in ps) { + if (m = e.match(ps[i])) { + this.matcher.push(Object.isFunction(x[i]) ? x[i](m) : + new Template(x[i]).evaluate(m)); + e = e.replace(m[0], ''); + break; + } + } + } + + this.xpath = this.matcher.join(''); + Selector._cache[this.expression] = this.xpath; + }, + + findElements: function(root) { + root = root || document; + if (this.xpath) return document._getElementsByXPath(this.xpath, root); + return this.matcher(root); + }, + + match: function(element) { + this.tokens = []; + + var e = this.expression, ps = Selector.patterns, as = Selector.assertions; + var le, p, m; + + while (e && le !== e && (/\S/).test(e)) { + le = e; + for (var i in ps) { + p = ps[i]; + if (m = e.match(p)) { + // use the Selector.assertions methods unless the selector + // is too complex. + if (as[i]) { + this.tokens.push([i, Object.clone(m)]); + e = e.replace(m[0], ''); + } else { + // reluctantly do a document-wide search + // and look for a match in the array + return this.findElements(document).include(element); + } + } + } + } + + var match = true, name, matches; + for (var i = 0, token; token = this.tokens[i]; i++) { + name = token[0], matches = token[1]; + if (!Selector.assertions[name](element, matches)) { + match = false; break; + } + } + + return match; + }, + + toString: function() { + return this.expression; + }, + + inspect: function() { + return "#"; + } +}); + +Object.extend(Selector, { + _cache: { }, + + xpath: { + descendant: "//*", + child: "/*", + adjacent: "/following-sibling::*[1]", + laterSibling: '/following-sibling::*', + tagName: function(m) { + if (m[1] == '*') return ''; + return "[local-name()='" + m[1].toLowerCase() + + "' or local-name()='" + m[1].toUpperCase() + "']"; + }, + className: "[contains(concat(' ', @class, ' '), ' #{1} ')]", + id: "[@id='#{1}']", + attrPresence: function(m) { + m[1] = m[1].toLowerCase(); + return new Template("[@#{1}]").evaluate(m); + }, + attr: function(m) { + m[1] = m[1].toLowerCase(); + m[3] = m[5] || m[6]; + return new Template(Selector.xpath.operators[m[2]]).evaluate(m); + }, + pseudo: function(m) { + var h = Selector.xpath.pseudos[m[1]]; + if (!h) return ''; + if (Object.isFunction(h)) return h(m); + return new Template(Selector.xpath.pseudos[m[1]]).evaluate(m); + }, + operators: { + '=': "[@#{1}='#{3}']", + '!=': "[@#{1}!='#{3}']", + '^=': "[starts-with(@#{1}, '#{3}')]", + '$=': "[substring(@#{1}, (string-length(@#{1}) - string-length('#{3}') + 1))='#{3}']", + '*=': "[contains(@#{1}, '#{3}')]", + '~=': "[contains(concat(' ', @#{1}, ' '), ' #{3} ')]", + '|=': "[contains(concat('-', @#{1}, '-'), '-#{3}-')]" + }, + pseudos: { + 'first-child': '[not(preceding-sibling::*)]', + 'last-child': '[not(following-sibling::*)]', + 'only-child': '[not(preceding-sibling::* or following-sibling::*)]', + 'empty': "[count(*) = 0 and (count(text()) = 0 or translate(text(), ' \t\r\n', '') = '')]", + 'checked': "[@checked]", + 'disabled': "[@disabled]", + 'enabled': "[not(@disabled)]", + 'not': function(m) { + var e = m[6], p = Selector.patterns, + x = Selector.xpath, le, v; + + var exclusion = []; + while (e && le != e && (/\S/).test(e)) { + le = e; + for (var i in p) { + if (m = e.match(p[i])) { + v = Object.isFunction(x[i]) ? x[i](m) : new Template(x[i]).evaluate(m); + exclusion.push("(" + v.substring(1, v.length - 1) + ")"); + e = e.replace(m[0], ''); + break; + } + } + } + return "[not(" + exclusion.join(" and ") + ")]"; + }, + 'nth-child': function(m) { + return Selector.xpath.pseudos.nth("(count(./preceding-sibling::*) + 1) ", m); + }, + 'nth-last-child': function(m) { + return Selector.xpath.pseudos.nth("(count(./following-sibling::*) + 1) ", m); + }, + 'nth-of-type': function(m) { + return Selector.xpath.pseudos.nth("position() ", m); + }, + 'nth-last-of-type': function(m) { + return Selector.xpath.pseudos.nth("(last() + 1 - position()) ", m); + }, + 'first-of-type': function(m) { + m[6] = "1"; return Selector.xpath.pseudos['nth-of-type'](m); + }, + 'last-of-type': function(m) { + m[6] = "1"; return Selector.xpath.pseudos['nth-last-of-type'](m); + }, + 'only-of-type': function(m) { + var p = Selector.xpath.pseudos; return p['first-of-type'](m) + p['last-of-type'](m); + }, + nth: function(fragment, m) { + var mm, formula = m[6], predicate; + if (formula == 'even') formula = '2n+0'; + if (formula == 'odd') formula = '2n+1'; + if (mm = formula.match(/^(\d+)$/)) // digit only + return '[' + fragment + "= " + mm[1] + ']'; + if (mm = formula.match(/^(-?\d*)?n(([+-])(\d+))?/)) { // an+b + if (mm[1] == "-") mm[1] = -1; + var a = mm[1] ? Number(mm[1]) : 1; + var b = mm[2] ? Number(mm[2]) : 0; + predicate = "[((#{fragment} - #{b}) mod #{a} = 0) and " + + "((#{fragment} - #{b}) div #{a} >= 0)]"; + return new Template(predicate).evaluate({ + fragment: fragment, a: a, b: b }); + } + } + } + }, + + criteria: { + tagName: 'n = h.tagName(n, r, "#{1}", c); c = false;', + className: 'n = h.className(n, r, "#{1}", c); c = false;', + id: 'n = h.id(n, r, "#{1}", c); c = false;', + attrPresence: 'n = h.attrPresence(n, r, "#{1}"); c = false;', + attr: function(m) { + m[3] = (m[5] || m[6]); + return new Template('n = h.attr(n, r, "#{1}", "#{3}", "#{2}"); c = false;').evaluate(m); + }, + pseudo: function(m) { + if (m[6]) m[6] = m[6].replace(/"/g, '\\"'); + return new Template('n = h.pseudo(n, "#{1}", "#{6}", r, c); c = false;').evaluate(m); + }, + descendant: 'c = "descendant";', + child: 'c = "child";', + adjacent: 'c = "adjacent";', + laterSibling: 'c = "laterSibling";' + }, + + patterns: { + // combinators must be listed first + // (and descendant needs to be last combinator) + laterSibling: /^\s*~\s*/, + child: /^\s*>\s*/, + adjacent: /^\s*\+\s*/, + descendant: /^\s/, + + // selectors follow + tagName: /^\s*(\*|[\w\-]+)(\b|$)?/, + id: /^#([\w\-\*]+)(\b|$)/, + className: /^\.([\w\-\*]+)(\b|$)/, + pseudo: /^:((first|last|nth|nth-last|only)(-child|-of-type)|empty|checked|(en|dis)abled|not)(\((.*?)\))?(\b|$|(?=\s)|(?=:))/, + attrPresence: /^\[([\w]+)\]/, + attr: /\[((?:[\w-]*:)?[\w-]+)\s*(?:([!^$*~|]?=)\s*((['"])([^\4]*?)\4|([^'"][^\]]*?)))?\]/ + }, + + // for Selector.match and Element#match + assertions: { + tagName: function(element, matches) { + return matches[1].toUpperCase() == element.tagName.toUpperCase(); + }, + + className: function(element, matches) { + return Element.hasClassName(element, matches[1]); + }, + + id: function(element, matches) { + return element.id === matches[1]; + }, + + attrPresence: function(element, matches) { + return Element.hasAttribute(element, matches[1]); + }, + + attr: function(element, matches) { + var nodeValue = Element.readAttribute(element, matches[1]); + return Selector.operators[matches[2]](nodeValue, matches[3]); + } + }, + + handlers: { + // UTILITY FUNCTIONS + // joins two collections + concat: function(a, b) { + for (var i = 0, node; node = b[i]; i++) + a.push(node); + return a; + }, + + // marks an array of nodes for counting + mark: function(nodes) { + for (var i = 0, node; node = nodes[i]; i++) + node._counted = true; + return nodes; + }, + + unmark: function(nodes) { + for (var i = 0, node; node = nodes[i]; i++) + node._counted = undefined; + return nodes; + }, + + // mark each child node with its position (for nth calls) + // "ofType" flag indicates whether we're indexing for nth-of-type + // rather than nth-child + index: function(parentNode, reverse, ofType) { + parentNode._counted = true; + if (reverse) { + for (var nodes = parentNode.childNodes, i = nodes.length - 1, j = 1; i >= 0; i--) { + var node = nodes[i]; + if (node.nodeType == 1 && (!ofType || node._counted)) node.nodeIndex = j++; + } + } else { + for (var i = 0, j = 1, nodes = parentNode.childNodes; node = nodes[i]; i++) + if (node.nodeType == 1 && (!ofType || node._counted)) node.nodeIndex = j++; + } + }, + + // filters out duplicates and extends all nodes + unique: function(nodes) { + if (nodes.length == 0) return nodes; + var results = [], n; + for (var i = 0, l = nodes.length; i < l; i++) + if (!(n = nodes[i])._counted) { + n._counted = true; + results.push(Element.extend(n)); + } + return Selector.handlers.unmark(results); + }, + + // COMBINATOR FUNCTIONS + descendant: function(nodes) { + var h = Selector.handlers; + for (var i = 0, results = [], node; node = nodes[i]; i++) + h.concat(results, node.getElementsByTagName('*')); + return results; + }, + + child: function(nodes) { + var h = Selector.handlers; + for (var i = 0, results = [], node; node = nodes[i]; i++) { + for (var j = 0, child; child = node.childNodes[j]; j++) + if (child.nodeType == 1 && child.tagName != '!') results.push(child); + } + return results; + }, + + adjacent: function(nodes) { + for (var i = 0, results = [], node; node = nodes[i]; i++) { + var next = this.nextElementSibling(node); + if (next) results.push(next); + } + return results; + }, + + laterSibling: function(nodes) { + var h = Selector.handlers; + for (var i = 0, results = [], node; node = nodes[i]; i++) + h.concat(results, Element.nextSiblings(node)); + return results; + }, + + nextElementSibling: function(node) { + while (node = node.nextSibling) + if (node.nodeType == 1) return node; + return null; + }, + + previousElementSibling: function(node) { + while (node = node.previousSibling) + if (node.nodeType == 1) return node; + return null; + }, + + // TOKEN FUNCTIONS + tagName: function(nodes, root, tagName, combinator) { + tagName = tagName.toUpperCase(); + var results = [], h = Selector.handlers; + if (nodes) { + if (combinator) { + // fastlane for ordinary descendant combinators + if (combinator == "descendant") { + for (var i = 0, node; node = nodes[i]; i++) + h.concat(results, node.getElementsByTagName(tagName)); + return results; + } else nodes = this[combinator](nodes); + if (tagName == "*") return nodes; + } + for (var i = 0, node; node = nodes[i]; i++) + if (node.tagName.toUpperCase() == tagName) results.push(node); + return results; + } else return root.getElementsByTagName(tagName); + }, + + id: function(nodes, root, id, combinator) { + var targetNode = $(id), h = Selector.handlers; + if (!targetNode) return []; + if (!nodes && root == document) return [targetNode]; + if (nodes) { + if (combinator) { + if (combinator == 'child') { + for (var i = 0, node; node = nodes[i]; i++) + if (targetNode.parentNode == node) return [targetNode]; + } else if (combinator == 'descendant') { + for (var i = 0, node; node = nodes[i]; i++) + if (Element.descendantOf(targetNode, node)) return [targetNode]; + } else if (combinator == 'adjacent') { + for (var i = 0, node; node = nodes[i]; i++) + if (Selector.handlers.previousElementSibling(targetNode) == node) + return [targetNode]; + } else nodes = h[combinator](nodes); + } + for (var i = 0, node; node = nodes[i]; i++) + if (node == targetNode) return [targetNode]; + return []; + } + return (targetNode && Element.descendantOf(targetNode, root)) ? [targetNode] : []; + }, + + className: function(nodes, root, className, combinator) { + if (nodes && combinator) nodes = this[combinator](nodes); + return Selector.handlers.byClassName(nodes, root, className); + }, + + byClassName: function(nodes, root, className) { + if (!nodes) nodes = Selector.handlers.descendant([root]); + var needle = ' ' + className + ' '; + for (var i = 0, results = [], node, nodeClassName; node = nodes[i]; i++) { + nodeClassName = node.className; + if (nodeClassName.length == 0) continue; + if (nodeClassName == className || (' ' + nodeClassName + ' ').include(needle)) + results.push(node); + } + return results; + }, + + attrPresence: function(nodes, root, attr) { + if (!nodes) nodes = root.getElementsByTagName("*"); + var results = []; + for (var i = 0, node; node = nodes[i]; i++) + if (Element.hasAttribute(node, attr)) results.push(node); + return results; + }, + + attr: function(nodes, root, attr, value, operator) { + if (!nodes) nodes = root.getElementsByTagName("*"); + var handler = Selector.operators[operator], results = []; + for (var i = 0, node; node = nodes[i]; i++) { + var nodeValue = Element.readAttribute(node, attr); + if (nodeValue === null) continue; + if (handler(nodeValue, value)) results.push(node); + } + return results; + }, + + pseudo: function(nodes, name, value, root, combinator) { + if (nodes && combinator) nodes = this[combinator](nodes); + if (!nodes) nodes = root.getElementsByTagName("*"); + return Selector.pseudos[name](nodes, value, root); + } + }, + + pseudos: { + 'first-child': function(nodes, value, root) { + for (var i = 0, results = [], node; node = nodes[i]; i++) { + if (Selector.handlers.previousElementSibling(node)) continue; + results.push(node); + } + return results; + }, + 'last-child': function(nodes, value, root) { + for (var i = 0, results = [], node; node = nodes[i]; i++) { + if (Selector.handlers.nextElementSibling(node)) continue; + results.push(node); + } + return results; + }, + 'only-child': function(nodes, value, root) { + var h = Selector.handlers; + for (var i = 0, results = [], node; node = nodes[i]; i++) + if (!h.previousElementSibling(node) && !h.nextElementSibling(node)) + results.push(node); + return results; + }, + 'nth-child': function(nodes, formula, root) { + return Selector.pseudos.nth(nodes, formula, root); + }, + 'nth-last-child': function(nodes, formula, root) { + return Selector.pseudos.nth(nodes, formula, root, true); + }, + 'nth-of-type': function(nodes, formula, root) { + return Selector.pseudos.nth(nodes, formula, root, false, true); + }, + 'nth-last-of-type': function(nodes, formula, root) { + return Selector.pseudos.nth(nodes, formula, root, true, true); + }, + 'first-of-type': function(nodes, formula, root) { + return Selector.pseudos.nth(nodes, "1", root, false, true); + }, + 'last-of-type': function(nodes, formula, root) { + return Selector.pseudos.nth(nodes, "1", root, true, true); + }, + 'only-of-type': function(nodes, formula, root) { + var p = Selector.pseudos; + return p['last-of-type'](p['first-of-type'](nodes, formula, root), formula, root); + }, + + // handles the an+b logic + getIndices: function(a, b, total) { + if (a == 0) return b > 0 ? [b] : []; + return $R(1, total).inject([], function(memo, i) { + if (0 == (i - b) % a && (i - b) / a >= 0) memo.push(i); + return memo; + }); + }, + + // handles nth(-last)-child, nth(-last)-of-type, and (first|last)-of-type + nth: function(nodes, formula, root, reverse, ofType) { + if (nodes.length == 0) return []; + if (formula == 'even') formula = '2n+0'; + if (formula == 'odd') formula = '2n+1'; + var h = Selector.handlers, results = [], indexed = [], m; + h.mark(nodes); + for (var i = 0, node; node = nodes[i]; i++) { + if (!node.parentNode._counted) { + h.index(node.parentNode, reverse, ofType); + indexed.push(node.parentNode); + } + } + if (formula.match(/^\d+$/)) { // just a number + formula = Number(formula); + for (var i = 0, node; node = nodes[i]; i++) + if (node.nodeIndex == formula) results.push(node); + } else if (m = formula.match(/^(-?\d*)?n(([+-])(\d+))?/)) { // an+b + if (m[1] == "-") m[1] = -1; + var a = m[1] ? Number(m[1]) : 1; + var b = m[2] ? Number(m[2]) : 0; + var indices = Selector.pseudos.getIndices(a, b, nodes.length); + for (var i = 0, node, l = indices.length; node = nodes[i]; i++) { + for (var j = 0; j < l; j++) + if (node.nodeIndex == indices[j]) results.push(node); + } + } + h.unmark(nodes); + h.unmark(indexed); + return results; + }, + + 'empty': function(nodes, value, root) { + for (var i = 0, results = [], node; node = nodes[i]; i++) { + // IE treats comments as element nodes + if (node.tagName == '!' || (node.firstChild && !node.innerHTML.match(/^\s*$/))) continue; + results.push(node); + } + return results; + }, + + 'not': function(nodes, selector, root) { + var h = Selector.handlers, selectorType, m; + var exclusions = new Selector(selector).findElements(root); + h.mark(exclusions); + for (var i = 0, results = [], node; node = nodes[i]; i++) + if (!node._counted) results.push(node); + h.unmark(exclusions); + return results; + }, + + 'enabled': function(nodes, value, root) { + for (var i = 0, results = [], node; node = nodes[i]; i++) + if (!node.disabled) results.push(node); + return results; + }, + + 'disabled': function(nodes, value, root) { + for (var i = 0, results = [], node; node = nodes[i]; i++) + if (node.disabled) results.push(node); + return results; + }, + + 'checked': function(nodes, value, root) { + for (var i = 0, results = [], node; node = nodes[i]; i++) + if (node.checked) results.push(node); + return results; + } + }, + + operators: { + '=': function(nv, v) { return nv == v; }, + '!=': function(nv, v) { return nv != v; }, + '^=': function(nv, v) { return nv.startsWith(v); }, + '$=': function(nv, v) { return nv.endsWith(v); }, + '*=': function(nv, v) { return nv.include(v); }, + '~=': function(nv, v) { return (' ' + nv + ' ').include(' ' + v + ' '); }, + '|=': function(nv, v) { return ('-' + nv.toUpperCase() + '-').include('-' + v.toUpperCase() + '-'); } + }, + + matchElements: function(elements, expression) { + var matches = new Selector(expression).findElements(), h = Selector.handlers; + h.mark(matches); + for (var i = 0, results = [], element; element = elements[i]; i++) + if (element._counted) results.push(element); + h.unmark(matches); + return results; + }, + + findElement: function(elements, expression, index) { + if (Object.isNumber(expression)) { + index = expression; expression = false; + } + return Selector.matchElements(elements, expression || '*')[index || 0]; + }, + + findChildElements: function(element, expressions) { + var exprs = expressions.join(','); + expressions = []; + exprs.scan(/(([\w#:.~>+()\s-]+|\*|\[.*?\])+)\s*(,|$)/, function(m) { + expressions.push(m[1].strip()); + }); + var results = [], h = Selector.handlers; + for (var i = 0, l = expressions.length, selector; i < l; i++) { + selector = new Selector(expressions[i].strip()); + h.concat(results, selector.findElements(element)); + } + return (l > 1) ? h.unique(results) : results; + } +}); + +if (Prototype.Browser.IE) { + // IE returns comment nodes on getElementsByTagName("*"). + // Filter them out. + Selector.handlers.concat = function(a, b) { + for (var i = 0, node; node = b[i]; i++) + if (node.tagName !== "!") a.push(node); + return a; + }; +} + +function $$() { + return Selector.findChildElements(document, $A(arguments)); +} +var Form = { + reset: function(form) { + $(form).reset(); + return form; + }, + + serializeElements: function(elements, options) { + if (typeof options != 'object') options = { hash: !!options }; + else if (Object.isUndefined(options.hash)) options.hash = true; + var key, value, submitted = false, submit = options.submit; + + var data = elements.inject({ }, function(result, element) { + if (!element.disabled && element.name) { + key = element.name; value = $(element).getValue(); + if (value != null && (element.type != 'submit' || (!submitted && + submit !== false && (!submit || key == submit) && (submitted = true)))) { + if (key in result) { + // a key is already present; construct an array of values + if (!Object.isArray(result[key])) result[key] = [result[key]]; + result[key].push(value); + } + else result[key] = value; + } + } + return result; + }); + + return options.hash ? data : Object.toQueryString(data); + } +}; + +Form.Methods = { + serialize: function(form, options) { + return Form.serializeElements(Form.getElements(form), options); + }, + + getElements: function(form) { + return $A($(form).getElementsByTagName('*')).inject([], + function(elements, child) { + if (Form.Element.Serializers[child.tagName.toLowerCase()]) + elements.push(Element.extend(child)); + return elements; + } + ); + }, + + getInputs: function(form, typeName, name) { + form = $(form); + var inputs = form.getElementsByTagName('input'); + + if (!typeName && !name) return $A(inputs).map(Element.extend); + + for (var i = 0, matchingInputs = [], length = inputs.length; i < length; i++) { + var input = inputs[i]; + if ((typeName && input.type != typeName) || (name && input.name != name)) + continue; + matchingInputs.push(Element.extend(input)); + } + + return matchingInputs; + }, + + disable: function(form) { + form = $(form); + Form.getElements(form).invoke('disable'); + return form; + }, + + enable: function(form) { + form = $(form); + Form.getElements(form).invoke('enable'); + return form; + }, + + findFirstElement: function(form) { + var elements = $(form).getElements().findAll(function(element) { + return 'hidden' != element.type && !element.disabled; + }); + var firstByIndex = elements.findAll(function(element) { + return element.hasAttribute('tabIndex') && element.tabIndex >= 0; + }).sortBy(function(element) { return element.tabIndex }).first(); + + return firstByIndex ? firstByIndex : elements.find(function(element) { + return ['input', 'select', 'textarea'].include(element.tagName.toLowerCase()); + }); + }, + + focusFirstElement: function(form) { + form = $(form); + form.findFirstElement().activate(); + return form; + }, + + request: function(form, options) { + form = $(form), options = Object.clone(options || { }); + + var params = options.parameters, action = form.readAttribute('action') || ''; + if (action.blank()) action = window.location.href; + options.parameters = form.serialize(true); + + if (params) { + if (Object.isString(params)) params = params.toQueryParams(); + Object.extend(options.parameters, params); + } + + if (form.hasAttribute('method') && !options.method) + options.method = form.method; + + return new Ajax.Request(action, options); + } +}; + +/*--------------------------------------------------------------------------*/ + +Form.Element = { + focus: function(element) { + $(element).focus(); + return element; + }, + + select: function(element) { + $(element).select(); + return element; + } +}; + +Form.Element.Methods = { + serialize: function(element) { + element = $(element); + if (!element.disabled && element.name) { + var value = element.getValue(); + if (value != undefined) { + var pair = { }; + pair[element.name] = value; + return Object.toQueryString(pair); + } + } + return ''; + }, + + getValue: function(element) { + element = $(element); + var method = element.tagName.toLowerCase(); + return Form.Element.Serializers[method](element); + }, + + setValue: function(element, value) { + element = $(element); + var method = element.tagName.toLowerCase(); + Form.Element.Serializers[method](element, value); + return element; + }, + + clear: function(element) { + $(element).value = ''; + return element; + }, + + present: function(element) { + return $(element).value != ''; + }, + + activate: function(element) { + element = $(element); + try { + element.focus(); + if (element.select && (element.tagName.toLowerCase() != 'input' || + !['button', 'reset', 'submit'].include(element.type))) + element.select(); + } catch (e) { } + return element; + }, + + disable: function(element) { + element = $(element); + element.blur(); + element.disabled = true; + return element; + }, + + enable: function(element) { + element = $(element); + element.disabled = false; + return element; + } +}; + +/*--------------------------------------------------------------------------*/ + +var Field = Form.Element; +var $F = Form.Element.Methods.getValue; + +/*--------------------------------------------------------------------------*/ + +Form.Element.Serializers = { + input: function(element, value) { + switch (element.type.toLowerCase()) { + case 'checkbox': + case 'radio': + return Form.Element.Serializers.inputSelector(element, value); + default: + return Form.Element.Serializers.textarea(element, value); + } + }, + + inputSelector: function(element, value) { + if (Object.isUndefined(value)) return element.checked ? element.value : null; + else element.checked = !!value; + }, + + textarea: function(element, value) { + if (Object.isUndefined(value)) return element.value; + else element.value = value; + }, + + select: function(element, index) { + if (Object.isUndefined(index)) + return this[element.type == 'select-one' ? + 'selectOne' : 'selectMany'](element); + else { + var opt, value, single = !Object.isArray(index); + for (var i = 0, length = element.length; i < length; i++) { + opt = element.options[i]; + value = this.optionValue(opt); + if (single) { + if (value == index) { + opt.selected = true; + return; + } + } + else opt.selected = index.include(value); + } + } + }, + + selectOne: function(element) { + var index = element.selectedIndex; + return index >= 0 ? this.optionValue(element.options[index]) : null; + }, + + selectMany: function(element) { + var values, length = element.length; + if (!length) return null; + + for (var i = 0, values = []; i < length; i++) { + var opt = element.options[i]; + if (opt.selected) values.push(this.optionValue(opt)); + } + return values; + }, + + optionValue: function(opt) { + // extend element because hasAttribute may not be native + return Element.extend(opt).hasAttribute('value') ? opt.value : opt.text; + } +}; + +/*--------------------------------------------------------------------------*/ + +Abstract.TimedObserver = Class.create(PeriodicalExecuter, { + initialize: function($super, element, frequency, callback) { + $super(callback, frequency); + this.element = $(element); + this.lastValue = this.getValue(); + }, + + execute: function() { + var value = this.getValue(); + if (Object.isString(this.lastValue) && Object.isString(value) ? + this.lastValue != value : String(this.lastValue) != String(value)) { + this.callback(this.element, value); + this.lastValue = value; + } + } +}); + +Form.Element.Observer = Class.create(Abstract.TimedObserver, { + getValue: function() { + return Form.Element.getValue(this.element); + } +}); + +Form.Observer = Class.create(Abstract.TimedObserver, { + getValue: function() { + return Form.serialize(this.element); + } +}); + +/*--------------------------------------------------------------------------*/ + +Abstract.EventObserver = Class.create({ + initialize: function(element, callback) { + this.element = $(element); + this.callback = callback; + + this.lastValue = this.getValue(); + if (this.element.tagName.toLowerCase() == 'form') + this.registerFormCallbacks(); + else + this.registerCallback(this.element); + }, + + onElementEvent: function() { + var value = this.getValue(); + if (this.lastValue != value) { + this.callback(this.element, value); + this.lastValue = value; + } + }, + + registerFormCallbacks: function() { + Form.getElements(this.element).each(this.registerCallback, this); + }, + + registerCallback: function(element) { + if (element.type) { + switch (element.type.toLowerCase()) { + case 'checkbox': + case 'radio': + Event.observe(element, 'click', this.onElementEvent.bind(this)); + break; + default: + Event.observe(element, 'change', this.onElementEvent.bind(this)); + break; + } + } + } +}); + +Form.Element.EventObserver = Class.create(Abstract.EventObserver, { + getValue: function() { + return Form.Element.getValue(this.element); + } +}); + +Form.EventObserver = Class.create(Abstract.EventObserver, { + getValue: function() { + return Form.serialize(this.element); + } +}); +if (!window.Event) var Event = { }; + +Object.extend(Event, { + KEY_BACKSPACE: 8, + KEY_TAB: 9, + KEY_RETURN: 13, + KEY_ESC: 27, + KEY_LEFT: 37, + KEY_UP: 38, + KEY_RIGHT: 39, + KEY_DOWN: 40, + KEY_DELETE: 46, + KEY_HOME: 36, + KEY_END: 35, + KEY_PAGEUP: 33, + KEY_PAGEDOWN: 34, + KEY_INSERT: 45, + + cache: { }, + + relatedTarget: function(event) { + var element; + switch(event.type) { + case 'mouseover': element = event.fromElement; break; + case 'mouseout': element = event.toElement; break; + default: return null; + } + return Element.extend(element); + } +}); + +Event.Methods = (function() { + var isButton; + + if (Prototype.Browser.IE) { + var buttonMap = { 0: 1, 1: 4, 2: 2 }; + isButton = function(event, code) { + return event.button == buttonMap[code]; + }; + + } else if (Prototype.Browser.WebKit) { + isButton = function(event, code) { + switch (code) { + case 0: return event.which == 1 && !event.metaKey; + case 1: return event.which == 1 && event.metaKey; + default: return false; + } + }; + + } else { + isButton = function(event, code) { + return event.which ? (event.which === code + 1) : (event.button === code); + }; + } + + return { + isLeftClick: function(event) { return isButton(event, 0) }, + isMiddleClick: function(event) { return isButton(event, 1) }, + isRightClick: function(event) { return isButton(event, 2) }, + + element: function(event) { + var node = Event.extend(event).target; + return Element.extend(node.nodeType == Node.TEXT_NODE ? node.parentNode : node); + }, + + findElement: function(event, expression) { + var element = Event.element(event); + if (!expression) return element; + var elements = [element].concat(element.ancestors()); + return Selector.findElement(elements, expression, 0); + }, + + pointer: function(event) { + return { + x: event.pageX || (event.clientX + + (document.documentElement.scrollLeft || document.body.scrollLeft)), + y: event.pageY || (event.clientY + + (document.documentElement.scrollTop || document.body.scrollTop)) + }; + }, + + pointerX: function(event) { return Event.pointer(event).x }, + pointerY: function(event) { return Event.pointer(event).y }, + + stop: function(event) { + Event.extend(event); + event.preventDefault(); + event.stopPropagation(); + event.stopped = true; + } + }; +})(); + +Event.extend = (function() { + var methods = Object.keys(Event.Methods).inject({ }, function(m, name) { + m[name] = Event.Methods[name].methodize(); + return m; + }); + + if (Prototype.Browser.IE) { + Object.extend(methods, { + stopPropagation: function() { this.cancelBubble = true }, + preventDefault: function() { this.returnValue = false }, + inspect: function() { return "[object Event]" } + }); + + return function(event) { + if (!event) return false; + if (event._extendedByPrototype) return event; + + event._extendedByPrototype = Prototype.emptyFunction; + var pointer = Event.pointer(event); + Object.extend(event, { + target: event.srcElement, + relatedTarget: Event.relatedTarget(event), + pageX: pointer.x, + pageY: pointer.y + }); + return Object.extend(event, methods); + }; + + } else { + Event.prototype = Event.prototype || document.createEvent("HTMLEvents").__proto__; + Object.extend(Event.prototype, methods); + return Prototype.K; + } +})(); + +Object.extend(Event, (function() { + var cache = Event.cache; + + function getEventID(element) { + if (element._eventID) return element._eventID; + arguments.callee.id = arguments.callee.id || 1; + return element._eventID = ++arguments.callee.id; + } + + function getDOMEventName(eventName) { + if (eventName && eventName.include(':')) return "dataavailable"; + return eventName; + } + + function getCacheForID(id) { + return cache[id] = cache[id] || { }; + } + + function getWrappersForEventName(id, eventName) { + var c = getCacheForID(id); + return c[eventName] = c[eventName] || []; + } + + function createWrapper(element, eventName, handler) { + var id = getEventID(element); + var c = getWrappersForEventName(id, eventName); + if (c.pluck("handler").include(handler)) return false; + + var wrapper = function(event) { + if (!Event || !Event.extend || + (event.eventName && event.eventName != eventName)) + return false; + + Event.extend(event); + handler.call(element, event) + }; + + wrapper.handler = handler; + c.push(wrapper); + return wrapper; + } + + function findWrapper(id, eventName, handler) { + var c = getWrappersForEventName(id, eventName); + return c.find(function(wrapper) { return wrapper.handler == handler }); + } + + function destroyWrapper(id, eventName, handler) { + var c = getCacheForID(id); + if (!c[eventName]) return false; + c[eventName] = c[eventName].without(findWrapper(id, eventName, handler)); + } + + function destroyCache() { + for (var id in cache) + for (var eventName in cache[id]) + cache[id][eventName] = null; + } + + if (window.attachEvent) { + window.attachEvent("onunload", destroyCache); + } + + return { + observe: function(element, eventName, handler) { + element = $(element); + var name = getDOMEventName(eventName); + + var wrapper = createWrapper(element, eventName, handler); + if (!wrapper) return element; + + if (element.addEventListener) { + element.addEventListener(name, wrapper, false); + } else { + element.attachEvent("on" + name, wrapper); + } + + return element; + }, + + stopObserving: function(element, eventName, handler) { + element = $(element); + var id = getEventID(element), name = getDOMEventName(eventName); + + if (!handler && eventName) { + getWrappersForEventName(id, eventName).each(function(wrapper) { + element.stopObserving(eventName, wrapper.handler); + }); + return element; + + } else if (!eventName) { + Object.keys(getCacheForID(id)).each(function(eventName) { + element.stopObserving(eventName); + }); + return element; + } + + var wrapper = findWrapper(id, eventName, handler); + if (!wrapper) return element; + + if (element.removeEventListener) { + element.removeEventListener(name, wrapper, false); + } else { + element.detachEvent("on" + name, wrapper); + } + + destroyWrapper(id, eventName, handler); + + return element; + }, + + fire: function(element, eventName, memo) { + element = $(element); + if (element == document && document.createEvent && !element.dispatchEvent) + element = document.documentElement; + + if (document.createEvent) { + var event = document.createEvent("HTMLEvents"); + event.initEvent("dataavailable", true, true); + } else { + var event = document.createEventObject(); + event.eventType = "ondataavailable"; + } + + event.eventName = eventName; + event.memo = memo || { }; + + if (document.createEvent) { + element.dispatchEvent(event); + } else { + element.fireEvent(event.eventType, event); + } + + return Event.extend(event); + } + }; +})()); + +Object.extend(Event, Event.Methods); + +Element.addMethods({ + fire: Event.fire, + observe: Event.observe, + stopObserving: Event.stopObserving +}); + +Object.extend(document, { + fire: Element.Methods.fire.methodize(), + observe: Element.Methods.observe.methodize(), + stopObserving: Element.Methods.stopObserving.methodize() +}); + +(function() { + /* Support for the DOMContentLoaded event is based on work by Dan Webb, + Matthias Miller, Dean Edwards and John Resig. */ + + var timer, fired = false; + + function fireContentLoadedEvent() { + if (fired) return; + if (timer) window.clearInterval(timer); + document.fire("dom:loaded"); + fired = true; + } + + if (document.addEventListener) { + if (Prototype.Browser.WebKit) { + timer = window.setInterval(function() { + if (/loaded|complete/.test(document.readyState)) + fireContentLoadedEvent(); + }, 0); + + Event.observe(window, "load", fireContentLoadedEvent); + + } else { + document.addEventListener("DOMContentLoaded", + fireContentLoadedEvent, false); + } + + } else { + document.write(" + + ) + end + + body do + div :id => 'top' do + div :id => 'main_navigation' do + main_navigation + end + end + div :id => 'middle' do + div :id => 'content' do + content + end + end + div :id => 'bottom' do + + end + end + end + end + + def main_navigation + ul do + li { link_to "Documentation", SyntacticRecognition, Documentation } + li { link_to "Contribute", Contribute } + li { link_to "Home", Index } + end + end + + def content + end +end + +class Index < Layout + def content + bluecloth "index.markdown" + end +end + +class Documentation < Layout + abstract + + def content + div :id => 'secondary_navigation' do + ul do + li { link_to 'Syntax', SyntacticRecognition } + li { link_to 'Semantics', SemanticInterpretation } + li { link_to 'Using In Ruby', UsingInRuby } + li { link_to 'Advanced Techniques', PitfallsAndAdvancedTechniques } + end + end + + div :id => 'documentation_content' do + documentation_content + end + end +end + +class SyntacticRecognition < Documentation + def documentation_content + bluecloth "syntactic_recognition.markdown" + end +end + +class SemanticInterpretation < Documentation + def documentation_content + bluecloth "semantic_interpretation.markdown" + end +end + +class UsingInRuby < Documentation + def documentation_content + bluecloth "using_in_ruby.markdown" + end +end + +class PitfallsAndAdvancedTechniques < Documentation + def documentation_content + bluecloth "pitfalls_and_advanced_techniques.markdown" + end +end + + +class Contribute < Layout + def content + bluecloth "contributing_and_planned_features.markdown" + end +end + + +Layout.generate_site \ No newline at end of file diff --git a/vendor/gems/gems/treetop-1.4.2/doc/sitegen.rb b/vendor/gems/gems/treetop-1.4.2/doc/sitegen.rb new file mode 100755 index 00000000..09d8d441 --- /dev/null +++ b/vendor/gems/gems/treetop-1.4.2/doc/sitegen.rb @@ -0,0 +1,65 @@ +class Layout < Erector::Widget + + class << self + def inherited(page_class) + puts page_class + (@@page_classes ||= []) << page_class + end + + def generate_site + FileUtils.mkdir_p(site_dir) + @@page_classes.each do |page_class| + page_class.generate_html unless page_class.abstract? + puts page_class + end + end + + def generate_html + File.open(absolute_path, 'w') do |file| + file.write(new.render) + end + end + + def absolute_path + absolutize(relative_path) + end + + def relative_path + "#{name.gsub('::', '_').underscore}.html" + end + + def absolutize(relative_path) + File.join(site_dir, relative_path) + end + + def abstract + @abstract = true + end + + def abstract? + @abstract + end + + def site_dir + File.join(File.dirname(__FILE__), "site") + end + end + + def bluecloth(relative_path) + File.open(File.join(File.dirname(__FILE__), relative_path)) do |file| + rawtext BlueCloth.new(file.read).to_html + end + end + + def absolutize(relative_path) + self.class.absolutize(relative_path) + end + + def link_to(link_text, page_class, section_class=nil) + if instance_of?(page_class) || section_class && is_a?(section_class) + text link_text + else + a link_text, :href => page_class.relative_path + end + end +end diff --git a/vendor/gems/gems/treetop-1.4.2/doc/syntactic_recognition.markdown b/vendor/gems/gems/treetop-1.4.2/doc/syntactic_recognition.markdown new file mode 100755 index 00000000..6c718103 --- /dev/null +++ b/vendor/gems/gems/treetop-1.4.2/doc/syntactic_recognition.markdown @@ -0,0 +1,100 @@ +#Syntactic Recognition +Treetop grammars are written in a custom language based on parsing expression grammars. Literature on the subject of parsing expression grammars is useful in writing Treetop grammars. + +#Grammar Structure +Treetop grammars look like this: + + grammar GrammarName + rule rule_name + ... + end + + rule rule_name + ... + end + + ... + end + +The main keywords are: + +* `grammar` : This introduces a new grammar. It is followed by a constant name to which the grammar will be bound when it is loaded. + +* `rule` : This defines a parsing rule within the grammar. It is followed by a name by which this rule can be referenced within other rules. It is then followed by a parsing expression defining the rule. + +#Parsing Expressions +Each rule associates a name with a _parsing expression_. Parsing expressions are a generalization of vanilla regular expressions. Their key feature is the ability to reference other expressions in the grammar by name. + +##Terminal Symbols +###Strings +Strings are surrounded in double or single quotes and must be matched exactly. + +* `"foo"` +* `'foo'` + +###Character Classes +Character classes are surrounded by brackets. Their semantics are identical to those used in Ruby's regular expressions. + +* `[a-zA-Z]` +* `[0-9]` + +###The Anything Symbol +The anything symbol is represented by a dot (`.`) and matches any single character. + +##Nonterminal Symbols +Nonterminal symbols are unquoted references to other named rules. They are equivalent to an inline substitution of the named expression. + + rule foo + "the dog " bar + end + + rule bar + "jumped" + end + +The above grammar is equivalent to: + + rule foo + "the dog jumped" + end + +##Ordered Choice +Parsers attempt to match ordered choices in left-to-right order, and stop after the first successful match. + + "foobar" / "foo" / "bar" + +Note that if `"foo"` in the above expression came first, `"foobar"` would never be matched. + +##Sequences + +Sequences are a space-separated list of parsing expressions. They have higher precedence than choices, so choices must be parenthesized to be used as the elements of a sequence. + + "foo" "bar" ("baz" / "bop") + +##Zero or More +Parsers will greedily match an expression zero or more times if it is followed by the star (`*`) symbol. + +* `'foo'*` matches the empty string, `"foo"`, `"foofoo"`, etc. + +##One or More +Parsers will greedily match an expression one or more times if it is followed by the star (`+`) symbol. + +* `'foo'+` does not match the empty string, but matches `"foo"`, `"foofoo"`, etc. + +##Optional Expressions +An expression can be declared optional by following it with a question mark (`?`). + +* `'foo'?` matches `"foo"` or the empty string. + +##Lookahead Assertions +Lookahead assertions can be used to give parsing expressions a limited degree of context-sensitivity. The parser will look ahead into the buffer and attempt to match an expression without consuming input. + +###Positive Lookahead Assertion +Preceding an expression with an ampersand `(&)` indicates that it must match, but no input will be consumed in the process of determining whether this is true. + +* `"foo" &"bar"` matches `"foobar"` but only consumes up to the end `"foo"`. It will not match `"foobaz"`. + +###Negative Lookahead Assertion +Preceding an expression with a bang `(!)` indicates that the expression must not match, but no input will be consumed in the process of determining whether this is true. + +* `"foo" !"bar"` matches `"foobaz"` but only consumes up to the end `"foo"`. It will not match `"foobar"`. diff --git a/vendor/gems/gems/treetop-1.4.2/doc/using_in_ruby.markdown b/vendor/gems/gems/treetop-1.4.2/doc/using_in_ruby.markdown new file mode 100755 index 00000000..57382af5 --- /dev/null +++ b/vendor/gems/gems/treetop-1.4.2/doc/using_in_ruby.markdown @@ -0,0 +1,21 @@ +#Using Treetop Grammars in Ruby +##Using the Command Line Compiler +You can `.treetop` files into Ruby source code with the `tt` command line script. `tt` takes an list of files with a `.treetop` extension and compiles them into `.rb` files of the same name. You can then `require` these files like any other Ruby script. Alternately, you can supply just one `.treetop` file and a `-o` flag to name specify the name of the output file. Improvements to this compilation script are welcome. + + tt foo.treetop bar.treetop + tt foo.treetop -o foogrammar.rb + +##Loading A Grammar Directly +The Polyglot gem makes it possible to load `.treetop` or `.tt` files directly with `require`. This will invoke `Treetop.load`, which automatically compiles the grammar to Ruby and then evaluates the Ruby source. If you are getting errors in methods you define on the syntax tree, try using the command line compiler for better stack trace feedback. A better solution to this issue is in the works. + +##Instantiating and Using Parsers +If a grammar by the name of `Foo` is defined, the compiled Ruby source will define a `FooParser` class. To parse input, create an instance and call its `parse` method with a string. The parser will return the syntax tree of the match or `nil` if there is a failure. + + Treetop.load "arithmetic" + + parser = ArithmeticParser.new + if parser.parse('1+1') + puts 'success' + else + puts 'failure' + end diff --git a/vendor/gems/gems/treetop-1.4.2/examples/lambda_calculus/arithmetic.rb b/vendor/gems/gems/treetop-1.4.2/examples/lambda_calculus/arithmetic.rb new file mode 100755 index 00000000..8f741296 --- /dev/null +++ b/vendor/gems/gems/treetop-1.4.2/examples/lambda_calculus/arithmetic.rb @@ -0,0 +1,551 @@ +module Arithmetic + include Treetop::Runtime + + def root + @root || :expression + end + + def _nt_expression + start_index = index + cached = node_cache[:expression][index] + if cached + @index = cached.interval.end + return cached + end + + i0 = index + r1 = _nt_comparative + if r1.success? + r0 = r1 + else + r2 = _nt_additive + if r2.success? + r0 = r2 + else + self.index = i0 + r0 = ParseFailure.new(input, i0) + end + end + + node_cache[:expression][start_index] = r0 + + return r0 + end + + module Comparative0 + def operand_1 + elements[0] + end + + def space + elements[1] + end + + def operator + elements[2] + end + + def space + elements[3] + end + + def operand_2 + elements[4] + end + end + + def _nt_comparative + start_index = index + cached = node_cache[:comparative][index] + if cached + @index = cached.interval.end + return cached + end + + i0, s0 = index, [] + r1 = _nt_additive + s0 << r1 + if r1.success? + r2 = _nt_space + s0 << r2 + if r2.success? + r3 = _nt_equality_op + s0 << r3 + if r3.success? + r4 = _nt_space + s0 << r4 + if r4.success? + r5 = _nt_additive + s0 << r5 + end + end + end + end + if s0.last.success? + r0 = (BinaryOperation).new(input, i0...index, s0) + r0.extend(Comparative0) + else + self.index = i0 + r0 = ParseFailure.new(input, i0) + end + + node_cache[:comparative][start_index] = r0 + + return r0 + end + + module EqualityOp0 + def apply(a, b) + a == b + end + end + + def _nt_equality_op + start_index = index + cached = node_cache[:equality_op][index] + if cached + @index = cached.interval.end + return cached + end + + r0 = parse_terminal('==', SyntaxNode, EqualityOp0) + + node_cache[:equality_op][start_index] = r0 + + return r0 + end + + module Additive0 + def operand_1 + elements[0] + end + + def space + elements[1] + end + + def operator + elements[2] + end + + def space + elements[3] + end + + def operand_2 + elements[4] + end + end + + def _nt_additive + start_index = index + cached = node_cache[:additive][index] + if cached + @index = cached.interval.end + return cached + end + + i0 = index + i1, s1 = index, [] + r2 = _nt_multitive + s1 << r2 + if r2.success? + r3 = _nt_space + s1 << r3 + if r3.success? + r4 = _nt_additive_op + s1 << r4 + if r4.success? + r5 = _nt_space + s1 << r5 + if r5.success? + r6 = _nt_additive + s1 << r6 + end + end + end + end + if s1.last.success? + r1 = (BinaryOperation).new(input, i1...index, s1) + r1.extend(Additive0) + else + self.index = i1 + r1 = ParseFailure.new(input, i1) + end + if r1.success? + r0 = r1 + else + r7 = _nt_multitive + if r7.success? + r0 = r7 + else + self.index = i0 + r0 = ParseFailure.new(input, i0) + end + end + + node_cache[:additive][start_index] = r0 + + return r0 + end + + module AdditiveOp0 + def apply(a, b) + a + b + end + end + + module AdditiveOp1 + def apply(a, b) + a - b + end + end + + def _nt_additive_op + start_index = index + cached = node_cache[:additive_op][index] + if cached + @index = cached.interval.end + return cached + end + + i0 = index + r1 = parse_terminal('+', SyntaxNode, AdditiveOp0) + if r1.success? + r0 = r1 + else + r2 = parse_terminal('-', SyntaxNode, AdditiveOp1) + if r2.success? + r0 = r2 + else + self.index = i0 + r0 = ParseFailure.new(input, i0) + end + end + + node_cache[:additive_op][start_index] = r0 + + return r0 + end + + module Multitive0 + def operand_1 + elements[0] + end + + def space + elements[1] + end + + def operator + elements[2] + end + + def space + elements[3] + end + + def operand_2 + elements[4] + end + end + + def _nt_multitive + start_index = index + cached = node_cache[:multitive][index] + if cached + @index = cached.interval.end + return cached + end + + i0 = index + i1, s1 = index, [] + r2 = _nt_primary + s1 << r2 + if r2.success? + r3 = _nt_space + s1 << r3 + if r3.success? + r4 = _nt_multitive_op + s1 << r4 + if r4.success? + r5 = _nt_space + s1 << r5 + if r5.success? + r6 = _nt_multitive + s1 << r6 + end + end + end + end + if s1.last.success? + r1 = (BinaryOperation).new(input, i1...index, s1) + r1.extend(Multitive0) + else + self.index = i1 + r1 = ParseFailure.new(input, i1) + end + if r1.success? + r0 = r1 + else + r7 = _nt_primary + if r7.success? + r0 = r7 + else + self.index = i0 + r0 = ParseFailure.new(input, i0) + end + end + + node_cache[:multitive][start_index] = r0 + + return r0 + end + + module MultitiveOp0 + def apply(a, b) + a * b + end + end + + module MultitiveOp1 + def apply(a, b) + a / b + end + end + + def _nt_multitive_op + start_index = index + cached = node_cache[:multitive_op][index] + if cached + @index = cached.interval.end + return cached + end + + i0 = index + r1 = parse_terminal('*', SyntaxNode, MultitiveOp0) + if r1.success? + r0 = r1 + else + r2 = parse_terminal('/', SyntaxNode, MultitiveOp1) + if r2.success? + r0 = r2 + else + self.index = i0 + r0 = ParseFailure.new(input, i0) + end + end + + node_cache[:multitive_op][start_index] = r0 + + return r0 + end + + module Primary0 + def space + elements[1] + end + + def expression + elements[2] + end + + def space + elements[3] + end + + end + + module Primary1 + def eval(env={}) + expression.eval(env) + end + end + + def _nt_primary + start_index = index + cached = node_cache[:primary][index] + if cached + @index = cached.interval.end + return cached + end + + i0 = index + r1 = _nt_variable + if r1.success? + r0 = r1 + else + r2 = _nt_number + if r2.success? + r0 = r2 + else + i3, s3 = index, [] + r4 = parse_terminal('(', SyntaxNode) + s3 << r4 + if r4.success? + r5 = _nt_space + s3 << r5 + if r5.success? + r6 = _nt_expression + s3 << r6 + if r6.success? + r7 = _nt_space + s3 << r7 + if r7.success? + r8 = parse_terminal(')', SyntaxNode) + s3 << r8 + end + end + end + end + if s3.last.success? + r3 = (SyntaxNode).new(input, i3...index, s3) + r3.extend(Primary0) + r3.extend(Primary1) + else + self.index = i3 + r3 = ParseFailure.new(input, i3) + end + if r3.success? + r0 = r3 + else + self.index = i0 + r0 = ParseFailure.new(input, i0) + end + end + end + + node_cache[:primary][start_index] = r0 + + return r0 + end + + module Variable0 + def eval(env={}) + env[name] + end + + def name + text_value + end + end + + def _nt_variable + start_index = index + cached = node_cache[:variable][index] + if cached + @index = cached.interval.end + return cached + end + + s0, i0 = [], index + loop do + r1 = parse_char_class(/[a-z]/, 'a-z', SyntaxNode) + if r1.success? + s0 << r1 + else + break + end + end + if s0.empty? + self.index = i0 + r0 = ParseFailure.new(input, i0) + else + r0 = SyntaxNode.new(input, i0...index, s0) + r0.extend(Variable0) + end + + node_cache[:variable][start_index] = r0 + + return r0 + end + + module Number0 + end + + module Number1 + def eval(env={}) + text_value.to_i + end + end + + def _nt_number + start_index = index + cached = node_cache[:number][index] + if cached + @index = cached.interval.end + return cached + end + + i0 = index + i1, s1 = index, [] + r2 = parse_char_class(/[1-9]/, '1-9', SyntaxNode) + s1 << r2 + if r2.success? + s3, i3 = [], index + loop do + r4 = parse_char_class(/[0-9]/, '0-9', SyntaxNode) + if r4.success? + s3 << r4 + else + break + end + end + r3 = SyntaxNode.new(input, i3...index, s3) + s1 << r3 + end + if s1.last.success? + r1 = (SyntaxNode).new(input, i1...index, s1) + r1.extend(Number0) + else + self.index = i1 + r1 = ParseFailure.new(input, i1) + end + if r1.success? + r0 = r1 + r0.extend(Number1) + else + r5 = parse_terminal('0', SyntaxNode) + if r5.success? + r0 = r5 + r0.extend(Number1) + else + self.index = i0 + r0 = ParseFailure.new(input, i0) + end + end + + node_cache[:number][start_index] = r0 + + return r0 + end + + def _nt_space + start_index = index + cached = node_cache[:space][index] + if cached + @index = cached.interval.end + return cached + end + + s0, i0 = [], index + loop do + r1 = parse_terminal(' ', SyntaxNode) + if r1.success? + s0 << r1 + else + break + end + end + r0 = SyntaxNode.new(input, i0...index, s0) + + node_cache[:space][start_index] = r0 + + return r0 + end + +end + +class ArithmeticParser < Treetop::Runtime::CompiledParser + include Arithmetic +end diff --git a/vendor/gems/gems/treetop-1.4.2/examples/lambda_calculus/arithmetic.treetop b/vendor/gems/gems/treetop-1.4.2/examples/lambda_calculus/arithmetic.treetop new file mode 100755 index 00000000..a54f6e24 --- /dev/null +++ b/vendor/gems/gems/treetop-1.4.2/examples/lambda_calculus/arithmetic.treetop @@ -0,0 +1,97 @@ +grammar Arithmetic + rule expression + comparative / additive + end + + rule comparative + operand_1:additive space operator:equality_op space operand_2:additive + end + + rule equality_op + '==' { + def apply(a, b) + a == b + end + } + end + + rule additive + operand_1:multitive + space operator:additive_op space + operand_2:additive + / + multitive + end + + rule additive_op + '+' { + def apply(a, b) + a + b + end + } + / + '-' { + def apply(a, b) + a - b + end + } + end + + rule multitive + operand_1:primary + space operator:multitive_op space + operand_2:multitive + / + primary + end + + rule multitive_op + '*' { + def apply(a, b) + a * b + end + } + / + '/' { + def apply(a, b) + a / b + end + } + end + + rule primary + variable + / + number + / + '(' space expression space ')' { + def eval(env={}) + expression.eval(env) + end + } + end + + rule variable + [a-z]+ { + def eval(env={}) + env[name] + end + + def name + text_value + end + } + end + + rule number + ([1-9] [0-9]* / '0') { + def eval(env={}) + text_value.to_i + end + } + end + + rule space + ' '* + end +end \ No newline at end of file diff --git a/vendor/gems/gems/treetop-1.4.2/examples/lambda_calculus/arithmetic_node_classes.rb b/vendor/gems/gems/treetop-1.4.2/examples/lambda_calculus/arithmetic_node_classes.rb new file mode 100755 index 00000000..63a60121 --- /dev/null +++ b/vendor/gems/gems/treetop-1.4.2/examples/lambda_calculus/arithmetic_node_classes.rb @@ -0,0 +1,7 @@ +module Arithmetic + class BinaryOperation < Treetop::Runtime::SyntaxNode + def eval(env={}) + operator.apply(operand_1.eval(env), operand_2.eval(env)) + end + end +end \ No newline at end of file diff --git a/vendor/gems/gems/treetop-1.4.2/examples/lambda_calculus/arithmetic_test.rb b/vendor/gems/gems/treetop-1.4.2/examples/lambda_calculus/arithmetic_test.rb new file mode 100755 index 00000000..753209cc --- /dev/null +++ b/vendor/gems/gems/treetop-1.4.2/examples/lambda_calculus/arithmetic_test.rb @@ -0,0 +1,54 @@ +dir = File.dirname(__FILE__) +require File.expand_path("#{dir}/test_helper") + +require File.expand_path("#{dir}/arithmetic_node_classes") +Treetop.load File.expand_path("#{dir}/arithmetic") + +class ArithmeticParserTest < Test::Unit::TestCase + include ParserTestHelper + + def setup + @parser = ArithmeticParser.new + end + + def test_number + assert_equal 0, parse('0').eval + assert_equal 1, parse('1').eval + assert_equal 123, parse('123').eval + end + + def test_variable + assert_equal 0, parse('x').eval('x' => 0) + assert_equal 3, parse('x').eval('x' => 3) + assert_equal 10, parse('y').eval('y' => 10) + end + + def test_addition + assert_equal 10, parse('x + 5').eval('x' => 5) + end + + def test_subtraction + assert_equal 0, parse('x - 5').eval('x' => 5) + end + + def test_multiplication + assert_equal 6, parse('x * 2').eval('x' => 3) + end + + def test_division + assert_equal 3, parse('x / 2').eval('x' => 6) + end + + def test_order_of_operations + assert_equal 11, parse('1 + 2 * 3 + 4').eval + end + + def test_parentheses + assert_equal 25, parse('(5 + x) * (10 - y)').eval('x' => 0, 'y' => 5) + end + + def test_equality + assert parse('4 == 4').eval + assert !parse('4 == 3').eval + end +end diff --git a/vendor/gems/gems/treetop-1.4.2/examples/lambda_calculus/lambda_calculus b/vendor/gems/gems/treetop-1.4.2/examples/lambda_calculus/lambda_calculus new file mode 100755 index 00000000..e69de29b diff --git a/vendor/gems/gems/treetop-1.4.2/examples/lambda_calculus/lambda_calculus.rb b/vendor/gems/gems/treetop-1.4.2/examples/lambda_calculus/lambda_calculus.rb new file mode 100755 index 00000000..8b5ae09f --- /dev/null +++ b/vendor/gems/gems/treetop-1.4.2/examples/lambda_calculus/lambda_calculus.rb @@ -0,0 +1,718 @@ +module LambdaCalculus + include Treetop::Runtime + + def root + @root || :program + end + + include Arithmetic + + module Program0 + def space + elements[1] + end + + def expression + elements[2] + end + end + + module Program1 + def expression + elements[0] + end + + def more_expressions + elements[1] + end + end + + module Program2 + def eval(env={}) + env = env.clone + last_eval = nil + expressions.each do |exp| + last_eval = exp.eval(env) + end + last_eval + end + + def expressions + [expression] + more_expressions.elements.map {|elt| elt.expression} + end + end + + def _nt_program + start_index = index + cached = node_cache[:program][index] + if cached + @index = cached.interval.end + return cached + end + + i0, s0 = index, [] + r1 = _nt_expression + s0 << r1 + if r1.success? + s2, i2 = [], index + loop do + i3, s3 = index, [] + r4 = parse_terminal(';', SyntaxNode) + s3 << r4 + if r4.success? + r5 = _nt_space + s3 << r5 + if r5.success? + r6 = _nt_expression + s3 << r6 + end + end + if s3.last.success? + r3 = (SyntaxNode).new(input, i3...index, s3) + r3.extend(Program0) + else + self.index = i3 + r3 = ParseFailure.new(input, i3) + end + if r3.success? + s2 << r3 + else + break + end + end + r2 = SyntaxNode.new(input, i2...index, s2) + s0 << r2 + end + if s0.last.success? + r0 = (SyntaxNode).new(input, i0...index, s0) + r0.extend(Program1) + r0.extend(Program2) + else + self.index = i0 + r0 = ParseFailure.new(input, i0) + end + + node_cache[:program][start_index] = r0 + + return r0 + end + + def _nt_expression + start_index = index + cached = node_cache[:expression][index] + if cached + @index = cached.interval.end + return cached + end + + i0 = index + r1 = _nt_definition + if r1.success? + r0 = r1 + else + r2 = _nt_conditional + if r2.success? + r0 = r2 + else + r3 = _nt_application + if r3.success? + r0 = r3 + else + r4 = _nt_function + if r4.success? + r0 = r4 + else + r5 = super + if r5.success? + r0 = r5 + else + self.index = i0 + r0 = ParseFailure.new(input, i0) + end + end + end + end + end + + node_cache[:expression][start_index] = r0 + + return r0 + end + + module Definition0 + def space + elements[1] + end + + def variable + elements[2] + end + + def space + elements[3] + end + + def expression + elements[4] + end + end + + module Definition1 + def eval(env) + env[variable.name] = expression.eval(env) + end + end + + def _nt_definition + start_index = index + cached = node_cache[:definition][index] + if cached + @index = cached.interval.end + return cached + end + + i0, s0 = index, [] + r1 = parse_terminal('def', SyntaxNode) + s0 << r1 + if r1.success? + r2 = _nt_space + s0 << r2 + if r2.success? + r3 = _nt_variable + s0 << r3 + if r3.success? + r4 = _nt_space + s0 << r4 + if r4.success? + r5 = _nt_expression + s0 << r5 + end + end + end + end + if s0.last.success? + r0 = (SyntaxNode).new(input, i0...index, s0) + r0.extend(Definition0) + r0.extend(Definition1) + else + self.index = i0 + r0 = ParseFailure.new(input, i0) + end + + node_cache[:definition][start_index] = r0 + + return r0 + end + + module Conditional0 + def space + elements[1] + end + + def space + elements[3] + end + + def condition + elements[4] + end + + def space + elements[5] + end + + def space + elements[7] + end + + def true_case + elements[8] + end + + def space + elements[9] + end + + def space + elements[11] + end + + def false_case + elements[12] + end + end + + module Conditional1 + def eval(env) + if condition.eval(env) + true_case.eval(env) + else + false_case.eval(env) + end + end + end + + def _nt_conditional + start_index = index + cached = node_cache[:conditional][index] + if cached + @index = cached.interval.end + return cached + end + + i0, s0 = index, [] + r1 = parse_terminal('if', SyntaxNode) + s0 << r1 + if r1.success? + r2 = _nt_space + s0 << r2 + if r2.success? + r3 = parse_terminal('(', SyntaxNode) + s0 << r3 + if r3.success? + r4 = _nt_space + s0 << r4 + if r4.success? + r5 = _nt_expression + s0 << r5 + if r5.success? + r6 = _nt_space + s0 << r6 + if r6.success? + r7 = parse_terminal(')', SyntaxNode) + s0 << r7 + if r7.success? + r8 = _nt_space + s0 << r8 + if r8.success? + r9 = _nt_expression + s0 << r9 + if r9.success? + r10 = _nt_space + s0 << r10 + if r10.success? + r11 = parse_terminal('else', SyntaxNode) + s0 << r11 + if r11.success? + r12 = _nt_space + s0 << r12 + if r12.success? + r13 = _nt_expression + s0 << r13 + end + end + end + end + end + end + end + end + end + end + end + end + if s0.last.success? + r0 = (SyntaxNode).new(input, i0...index, s0) + r0.extend(Conditional0) + r0.extend(Conditional1) + else + self.index = i0 + r0 = ParseFailure.new(input, i0) + end + + node_cache[:conditional][start_index] = r0 + + return r0 + end + + def _nt_primary + start_index = index + cached = node_cache[:primary][index] + if cached + @index = cached.interval.end + return cached + end + + i0 = index + r1 = _nt_application + if r1.success? + r0 = r1 + else + r2 = super + if r2.success? + r0 = r2 + else + self.index = i0 + r0 = ParseFailure.new(input, i0) + end + end + + node_cache[:primary][start_index] = r0 + + return r0 + end + + module Application0 + def operator + elements[0] + end + + def space + elements[1] + end + + def expression + elements[2] + end + end + + module Application1 + def eval(env={}) + left_associative_apply(operator.eval(env), env) + end + + def left_associative_apply(operator, env) + if expression.instance_of?(Application) + expression.left_associative_apply(operator.apply(expression.operator.eval(env)), env) + else + operator.apply(expression.eval(env)) + end + end + + def to_s(env={}) + operator.to_s(env) + ' ' + expression.to_s(env) + end + end + + def _nt_application + start_index = index + cached = node_cache[:application][index] + if cached + @index = cached.interval.end + return cached + end + + i0, s0 = index, [] + r1 = _nt_operator + s0 << r1 + if r1.success? + r2 = _nt_space + s0 << r2 + if r2.success? + r3 = _nt_expression + s0 << r3 + end + end + if s0.last.success? + r0 = (Application).new(input, i0...index, s0) + r0.extend(Application0) + r0.extend(Application1) + else + self.index = i0 + r0 = ParseFailure.new(input, i0) + end + + node_cache[:application][start_index] = r0 + + return r0 + end + + def _nt_operator + start_index = index + cached = node_cache[:operator][index] + if cached + @index = cached.interval.end + return cached + end + + i0 = index + r1 = _nt_function + if r1.success? + r0 = r1 + else + r2 = _nt_variable + if r2.success? + r0 = r2 + else + self.index = i0 + r0 = ParseFailure.new(input, i0) + end + end + + node_cache[:operator][start_index] = r0 + + return r0 + end + + def _nt_non_application + start_index = index + cached = node_cache[:non_application][index] + if cached + @index = cached.interval.end + return cached + end + + i0 = index + r1 = _nt_function + if r1.success? + r0 = r1 + else + r2 = _nt_variable + if r2.success? + r0 = r2 + else + self.index = i0 + r0 = ParseFailure.new(input, i0) + end + end + + node_cache[:non_application][start_index] = r0 + + return r0 + end + + module Function0 + def param + elements[1] + end + + def body + elements[3] + end + + end + + module Function1 + class Closure + attr_reader :env, :function + + def initialize(function, env) + @function = function + @env = env + end + + def apply(arg) + function.body.eval(function.param.bind(arg, env)) + end + + def to_s(other_env={}) + "\\#{function.param.to_s}(#{function.body.to_s(other_env.merge(env))})" + end + end + + def eval(env={}) + Closure.new(self, env) + end + + def to_s(env={}) + eval(env).to_s + end + end + + def _nt_function + start_index = index + cached = node_cache[:function][index] + if cached + @index = cached.interval.end + return cached + end + + i0, s0 = index, [] + r1 = parse_terminal('\\', SyntaxNode) + s0 << r1 + if r1.success? + r2 = _nt_variable + s0 << r2 + if r2.success? + r3 = parse_terminal('(', SyntaxNode) + s0 << r3 + if r3.success? + r4 = _nt_expression + s0 << r4 + if r4.success? + r5 = parse_terminal(')', SyntaxNode) + s0 << r5 + end + end + end + end + if s0.last.success? + r0 = (SyntaxNode).new(input, i0...index, s0) + r0.extend(Function0) + r0.extend(Function1) + else + self.index = i0 + r0 = ParseFailure.new(input, i0) + end + + node_cache[:function][start_index] = r0 + + return r0 + end + + module Variable0 + def bind(value, env) + env.merge(name => value) + end + + def to_s(env={}) + env.has_key?(name) ? env[name].to_s : name + end + end + + module Variable1 + end + + def _nt_variable + start_index = index + cached = node_cache[:variable][index] + if cached + @index = cached.interval.end + return cached + end + + i0, s0 = index, [] + i1 = index + r2 = _nt_keyword + if r2.success? + r1 = ParseFailure.new(input, i1) + else + self.index = i1 + r1 = SyntaxNode.new(input, index...index) + end + s0 << r1 + if r1.success? + r3 = super + r3.extend(Variable0) + s0 << r3 + end + if s0.last.success? + r0 = (SyntaxNode).new(input, i0...index, s0) + r0.extend(Variable1) + else + self.index = i0 + r0 = ParseFailure.new(input, i0) + end + + node_cache[:variable][start_index] = r0 + + return r0 + end + + module Keyword0 + end + + def _nt_keyword + start_index = index + cached = node_cache[:keyword][index] + if cached + @index = cached.interval.end + return cached + end + + i0, s0 = index, [] + i1 = index + r2 = parse_terminal('if', SyntaxNode) + if r2.success? + r1 = r2 + else + r3 = parse_terminal('else', SyntaxNode) + if r3.success? + r1 = r3 + else + self.index = i1 + r1 = ParseFailure.new(input, i1) + end + end + s0 << r1 + if r1.success? + i4 = index + r5 = _nt_non_space_char + if r5.success? + r4 = ParseFailure.new(input, i4) + else + self.index = i4 + r4 = SyntaxNode.new(input, index...index) + end + s0 << r4 + end + if s0.last.success? + r0 = (SyntaxNode).new(input, i0...index, s0) + r0.extend(Keyword0) + else + self.index = i0 + r0 = ParseFailure.new(input, i0) + end + + node_cache[:keyword][start_index] = r0 + + return r0 + end + + module NonSpaceChar0 + end + + def _nt_non_space_char + start_index = index + cached = node_cache[:non_space_char][index] + if cached + @index = cached.interval.end + return cached + end + + i0, s0 = index, [] + i1 = index + r2 = parse_char_class(/[ \n]/, ' \n', SyntaxNode) + if r2.success? + r1 = ParseFailure.new(input, i1) + else + self.index = i1 + r1 = SyntaxNode.new(input, index...index) + end + s0 << r1 + if r1.success? + r3 = parse_anything(SyntaxNode) + s0 << r3 + end + if s0.last.success? + r0 = (SyntaxNode).new(input, i0...index, s0) + r0.extend(NonSpaceChar0) + else + self.index = i0 + r0 = ParseFailure.new(input, i0) + end + + node_cache[:non_space_char][start_index] = r0 + + return r0 + end + + def _nt_space + start_index = index + cached = node_cache[:space][index] + if cached + @index = cached.interval.end + return cached + end + + s0, i0 = [], index + loop do + r1 = parse_char_class(/[ \n]/, ' \n', SyntaxNode) + if r1.success? + s0 << r1 + else + break + end + end + r0 = SyntaxNode.new(input, i0...index, s0) + + node_cache[:space][start_index] = r0 + + return r0 + end + +end + +class LambdaCalculusParser < Treetop::Runtime::CompiledParser + include LambdaCalculus +end diff --git a/vendor/gems/gems/treetop-1.4.2/examples/lambda_calculus/lambda_calculus.treetop b/vendor/gems/gems/treetop-1.4.2/examples/lambda_calculus/lambda_calculus.treetop new file mode 100755 index 00000000..7e72c932 --- /dev/null +++ b/vendor/gems/gems/treetop-1.4.2/examples/lambda_calculus/lambda_calculus.treetop @@ -0,0 +1,132 @@ +grammar LambdaCalculus + include Arithmetic + + rule program + expression more_expressions:(';' space expression)* { + def eval(env={}) + env = env.clone + last_eval = nil + expressions.each do |exp| + last_eval = exp.eval(env) + end + last_eval + end + + def expressions + [expression] + more_expressions.elements.map {|elt| elt.expression} + end + } + end + + rule expression + definition / conditional / application / function / super + end + + rule definition + 'def' space variable space expression { + def eval(env) + env[variable.name] = expression.eval(env) + end + } + end + + rule conditional + 'if' space '(' space condition:expression space ')' space + true_case:expression space 'else' space false_case:expression { + def eval(env) + if condition.eval(env) + true_case.eval(env) + else + false_case.eval(env) + end + end + } + end + + rule primary + application / super + end + + rule application + operator space expression { + def eval(env={}) + left_associative_apply(operator.eval(env), env) + end + + def left_associative_apply(operator, env) + if expression.instance_of?(Application) + expression.left_associative_apply(operator.apply(expression.operator.eval(env)), env) + else + operator.apply(expression.eval(env)) + end + end + + def to_s(env={}) + operator.to_s(env) + ' ' + expression.to_s(env) + end + } + end + + rule operator + function / variable + end + + rule non_application + function / variable + end + + rule function + '\\' param:variable '(' body:expression ')' { + class Closure + attr_reader :env, :function + + def initialize(function, env) + @function = function + @env = env + end + + def apply(arg) + function.body.eval(function.param.bind(arg, env)) + end + + def to_s(other_env={}) + "\\#{function.param.to_s}(#{function.body.to_s(other_env.merge(env))})" + end + end + + def eval(env={}) + Closure.new(self, env) + end + + def to_s(env={}) + eval(env).to_s + end + } + end + + rule variable + !keyword ( + super { + def bind(value, env) + env.merge(name => value) + end + + def to_s(env={}) + env.has_key?(name) ? env[name].to_s : name + end + } + ) + end + + rule keyword + ('if' / 'else') !non_space_char + end + + rule non_space_char + ![ \n] . + end + + rule space + [ \n]* + end +end \ No newline at end of file diff --git a/vendor/gems/gems/treetop-1.4.2/examples/lambda_calculus/lambda_calculus_node_classes.rb b/vendor/gems/gems/treetop-1.4.2/examples/lambda_calculus/lambda_calculus_node_classes.rb new file mode 100755 index 00000000..9a220ec8 --- /dev/null +++ b/vendor/gems/gems/treetop-1.4.2/examples/lambda_calculus/lambda_calculus_node_classes.rb @@ -0,0 +1,5 @@ +module LambdaCalculus + class Application < Treetop::Runtime::SyntaxNode + + end +end \ No newline at end of file diff --git a/vendor/gems/gems/treetop-1.4.2/examples/lambda_calculus/lambda_calculus_test.rb b/vendor/gems/gems/treetop-1.4.2/examples/lambda_calculus/lambda_calculus_test.rb new file mode 100755 index 00000000..0844ef03 --- /dev/null +++ b/vendor/gems/gems/treetop-1.4.2/examples/lambda_calculus/lambda_calculus_test.rb @@ -0,0 +1,89 @@ +dir = File.dirname(__FILE__) +require File.expand_path("#{dir}/test_helper") +require File.expand_path("#{dir}/arithmetic_node_classes") +require File.expand_path("#{dir}/lambda_calculus_node_classes") +Treetop.load File.expand_path("#{dir}/arithmetic") +Treetop.load File.expand_path("#{dir}/lambda_calculus") + +class Treetop::Runtime::SyntaxNode + def method_missing(method, *args) + raise "Node representing #{text_value} does not respond to #{method}" + end +end + +class LambdaCalculusParserTest < Test::Unit::TestCase + include ParserTestHelper + + def setup + @parser = LambdaCalculusParser.new + end + + def test_free_variable + assert_equal 'x', parse('x').eval.to_s + end + + def test_variable_binding + variable = parse('x').eval + env = variable.bind(1, {}) + assert_equal 1, env['x'] + end + + def test_bound_variable_evaluation + assert_equal 1, parse('x').eval({'x' => 1}) + end + + def test_identity_function + assert_equal '\x(x)', parse('\x(x)').eval.to_s + end + + def test_function_returning_constant_function + assert_equal '\x(\y(x))', parse('\x(\y(x))').eval.to_s + end + + def test_identity_function_application + assert_equal 1, parse('\x(x) 1').eval + assert_equal '\y(y)', parse('\x(x) \y(y)').eval.to_s + end + + def test_constant_function_construction + assert_equal '\y(1)', parse('\x(\y(x)) 1').eval.to_s + end + + def test_multiple_argument_application_is_left_associative + assert_equal '\b(b)', parse('\x(\y(x y)) \a(a) \b(b)').eval.to_s + end + + def test_parentheses_override_application_order + assert_equal '\y(\b(b) y)', parse('\x(\y(x y)) (\a(a) \b(b))').eval.to_s + end + + def test_arithmetic_in_function_body + assert_equal 10, parse('\x(x + 5) 5').eval + end + + def test_addition_of_function_results + assert_equal 20, parse('\x(x + 5) 5 + \x(15 - x) 5').eval + end + + def test_conditional + result = parse('if (x) 1 else 2') + assert_equal 1, result.eval({'x' => true}) + assert_equal 2, result.eval({'x' => false}) + end + + def test_keyword + assert @parser.parse('if').failure? + assert @parser.parse('else').failure? + assert parse('elsee').success? + assert parse('iff').success? + end + + def test_program + result = parse('def fact \x(if (x == 0) + 1 + else + x * fact (x - 1)); + fact(5)').eval + assert_equal 5 * 4 * 3 * 2, result + end +end diff --git a/vendor/gems/gems/treetop-1.4.2/examples/lambda_calculus/test_helper.rb b/vendor/gems/gems/treetop-1.4.2/examples/lambda_calculus/test_helper.rb new file mode 100755 index 00000000..bfdb7adc --- /dev/null +++ b/vendor/gems/gems/treetop-1.4.2/examples/lambda_calculus/test_helper.rb @@ -0,0 +1,18 @@ +require 'test/unit' +require 'rubygems' +require 'treetop' + +module ParserTestHelper + def assert_evals_to_self(input) + assert_evals_to(input, input) + end + + def parse(input) + result = @parser.parse(input) + unless result + puts @parser.terminal_failures.join("\n") + end + assert !result.nil? + result + end +end \ No newline at end of file diff --git a/vendor/gems/gems/treetop-1.4.2/lib/treetop.rb b/vendor/gems/gems/treetop-1.4.2/lib/treetop.rb new file mode 100755 index 00000000..07315333 --- /dev/null +++ b/vendor/gems/gems/treetop-1.4.2/lib/treetop.rb @@ -0,0 +1,16 @@ +require 'rubygems' + +module Treetop + VALID_GRAMMAR_EXT = ['treetop', 'tt'] + VALID_GRAMMAR_EXT_REGEXP = /\.(#{VALID_GRAMMAR_EXT.join('|')})\Z/o +end + +dir = File.dirname(__FILE__) + +TREETOP_ROOT = File.join(dir, 'treetop') +require File.join(TREETOP_ROOT, "ruby_extensions") +require File.join(TREETOP_ROOT, "runtime") +require File.join(TREETOP_ROOT, "compiler") + +require 'polyglot' +Polyglot.register(Treetop::VALID_GRAMMAR_EXT, Treetop) diff --git a/vendor/gems/gems/treetop-1.4.2/lib/treetop/bootstrap_gen_1_metagrammar.rb b/vendor/gems/gems/treetop-1.4.2/lib/treetop/bootstrap_gen_1_metagrammar.rb new file mode 100755 index 00000000..f587bfa8 --- /dev/null +++ b/vendor/gems/gems/treetop-1.4.2/lib/treetop/bootstrap_gen_1_metagrammar.rb @@ -0,0 +1,45 @@ +# This file's job is to load a Treetop::Compiler::Metagrammar and Treetop::Compiler::MetagrammarParser +# into the environment by compiling the current metagrammar.treetop using a trusted version of Treetop. + +require 'rubygems' +dir = File.dirname(__FILE__) + +TREETOP_VERSION_REQUIRED_TO_BOOTSTRAP = '>= 1.1.5' + +# Loading trusted version of Treetop to compile the compiler +gem_spec = Gem.source_index.find_name('treetop', TREETOP_VERSION_REQUIRED_TO_BOOTSTRAP).last +raise "Install a Treetop Gem version #{TREETOP_VERSION_REQUIRED_TO_BOOTSTRAP} to bootstrap." unless gem_spec +trusted_treetop_path = gem_spec.full_gem_path +require File.join(trusted_treetop_path, 'lib', 'treetop') + +# Relocating trusted version of Treetop to Trusted::Treetop +Trusted = Module.new +Trusted::Treetop = Treetop +Object.send(:remove_const, :Treetop) +Object.send(:remove_const, :TREETOP_ROOT) + +# Requiring version of Treetop that is under test +$exclude_metagrammar = true +require File.expand_path(File.join(dir, '..', 'treetop')) + +# Compile and evaluate freshly generated metagrammar source +METAGRAMMAR_PATH = File.join(TREETOP_ROOT, 'compiler', 'metagrammar.treetop') +compiled_metagrammar_source = Trusted::Treetop::Compiler::GrammarCompiler.new.ruby_source(METAGRAMMAR_PATH) +Object.class_eval(compiled_metagrammar_source) + +# The compiler under test was compiled with the trusted grammar and therefore depends on its runtime +# But the runtime in the global namespace is the new runtime. We therefore inject the trusted runtime +# into the compiler so its parser functions correctly. It will still not work for custom classes that +# explicitly subclass the wrong runtime. For now I am working around this by keeping 1 generation of +# backward compatibility in these cases. +# Treetop::Compiler::Metagrammar.module_eval do +# include Trusted::Treetop::Runtime +# end +# +# Treetop::Compiler.send(:remove_const, :MetagrammarParser) +# class Treetop::Compiler::MetagrammarParser < Trusted::Treetop::Runtime::CompiledParser +# include Treetop::Compiler::Metagrammar +# include Trusted::Treetop::Runtime +# end + +$bootstrapped_gen_1_metagrammar = true \ No newline at end of file diff --git a/vendor/gems/gems/treetop-1.4.2/lib/treetop/compiler.rb b/vendor/gems/gems/treetop-1.4.2/lib/treetop/compiler.rb new file mode 100755 index 00000000..75b4893f --- /dev/null +++ b/vendor/gems/gems/treetop-1.4.2/lib/treetop/compiler.rb @@ -0,0 +1,6 @@ +dir = File.dirname(__FILE__) +require File.join(dir, *%w[compiler lexical_address_space]) +require File.join(dir, *%w[compiler ruby_builder]) +require File.join(dir, *%w[compiler node_classes]) +require File.join(dir, *%w[compiler metagrammar]) unless defined?($exclude_metagrammar) +require File.join(dir, *%w[compiler grammar_compiler]) diff --git a/vendor/gems/gems/treetop-1.4.2/lib/treetop/compiler/grammar_compiler.rb b/vendor/gems/gems/treetop-1.4.2/lib/treetop/compiler/grammar_compiler.rb new file mode 100755 index 00000000..24e9cf16 --- /dev/null +++ b/vendor/gems/gems/treetop-1.4.2/lib/treetop/compiler/grammar_compiler.rb @@ -0,0 +1,44 @@ +module Treetop + module Compiler + AUTOGENERATED = "# Autogenerated from a Treetop grammar. Edits may be lost.\n" + class GrammarCompiler + def compile(source_path, target_path = source_path.gsub(/\.(treetop|tt)\Z/, '.rb')) + File.open(target_path, 'w') do |target_file| + target_file.write(AUTOGENERATED+"\n\n") + target_file.write(ruby_source(source_path)) + end + end + + # compile a treetop file into ruby + def ruby_source(source_path) + ruby_source_from_string(File.read(source_path)) + end + + # compile a string containing treetop source into ruby + def ruby_source_from_string(s) + parser = MetagrammarParser.new + result = parser.parse(s) + unless result + raise RuntimeError.new(parser.failure_reason) + end + result.compile + end + end + end + + # compile a treetop source file and load it + def self.load(path) + adjusted_path = path =~ /\.(treetop|tt)\Z/ ? path : path + '.treetop' + File.open(adjusted_path) do |source_file| + source = source_file.read + source.gsub!(/\b__FILE__\b/, %Q{"#{adjusted_path}"}) + load_from_string(source) + end + end + + # compile a treetop source string and load it + def self.load_from_string(s) + compiler = Treetop::Compiler::GrammarCompiler.new + Object.class_eval(compiler.ruby_source_from_string(s)) + end +end diff --git a/vendor/gems/gems/treetop-1.4.2/lib/treetop/compiler/lexical_address_space.rb b/vendor/gems/gems/treetop-1.4.2/lib/treetop/compiler/lexical_address_space.rb new file mode 100755 index 00000000..a09478c1 --- /dev/null +++ b/vendor/gems/gems/treetop-1.4.2/lib/treetop/compiler/lexical_address_space.rb @@ -0,0 +1,17 @@ +module Treetop + module Compiler + class LexicalAddressSpace + def initialize + reset_addresses + end + + def next_address + @next_address += 1 + end + + def reset_addresses + @next_address = -1 + end + end + end +end \ No newline at end of file diff --git a/vendor/gems/gems/treetop-1.4.2/lib/treetop/compiler/metagrammar.rb b/vendor/gems/gems/treetop-1.4.2/lib/treetop/compiler/metagrammar.rb new file mode 100755 index 00000000..3d4c19c4 --- /dev/null +++ b/vendor/gems/gems/treetop-1.4.2/lib/treetop/compiler/metagrammar.rb @@ -0,0 +1,3258 @@ +# Autogenerated from a Treetop grammar. Edits may be lost. + + +module Treetop + module Compiler + module Metagrammar + include Treetop::Runtime + + def root + @root || :treetop_file + end + + module TreetopFile0 + def require_statement + elements[1] + end + end + + module TreetopFile1 + def requires + elements[0] + end + + def prefix + elements[1] + end + + def module_or_grammar + elements[2] + end + + def suffix + elements[3] + end + end + + module TreetopFile2 + def compile + requires.text_value + prefix.text_value + module_or_grammar.compile + suffix.text_value + end + end + + def _nt_treetop_file + start_index = index + if node_cache[:treetop_file].has_key?(index) + cached = node_cache[:treetop_file][index] + @index = cached.interval.end if cached + return cached + end + + i0, s0 = index, [] + s1, i1 = [], index + loop do + i2, s2 = index, [] + r4 = _nt_space + if r4 + r3 = r4 + else + r3 = instantiate_node(SyntaxNode,input, index...index) + end + s2 << r3 + if r3 + r5 = _nt_require_statement + s2 << r5 + end + if s2.last + r2 = instantiate_node(SyntaxNode,input, i2...index, s2) + r2.extend(TreetopFile0) + else + @index = i2 + r2 = nil + end + if r2 + s1 << r2 + else + break + end + end + r1 = instantiate_node(SyntaxNode,input, i1...index, s1) + s0 << r1 + if r1 + r7 = _nt_space + if r7 + r6 = r7 + else + r6 = instantiate_node(SyntaxNode,input, index...index) + end + s0 << r6 + if r6 + i8 = index + r9 = _nt_module_declaration + if r9 + r8 = r9 + else + r10 = _nt_grammar + if r10 + r8 = r10 + else + @index = i8 + r8 = nil + end + end + s0 << r8 + if r8 + r12 = _nt_space + if r12 + r11 = r12 + else + r11 = instantiate_node(SyntaxNode,input, index...index) + end + s0 << r11 + end + end + end + if s0.last + r0 = instantiate_node(SyntaxNode,input, i0...index, s0) + r0.extend(TreetopFile1) + r0.extend(TreetopFile2) + else + @index = i0 + r0 = nil + end + + node_cache[:treetop_file][start_index] = r0 + + r0 + end + + module RequireStatement0 + def prefix + elements[0] + end + + end + + def _nt_require_statement + start_index = index + if node_cache[:require_statement].has_key?(index) + cached = node_cache[:require_statement][index] + @index = cached.interval.end if cached + return cached + end + + i0, s0 = index, [] + r2 = _nt_space + if r2 + r1 = r2 + else + r1 = instantiate_node(SyntaxNode,input, index...index) + end + s0 << r1 + if r1 + if has_terminal?("require", false, index) + r3 = instantiate_node(SyntaxNode,input, index...(index + 7)) + @index += 7 + else + terminal_parse_failure("require") + r3 = nil + end + s0 << r3 + if r3 + s4, i4 = [], index + loop do + if has_terminal?('\G[ \\t]', true, index) + next_character = index + input[index..-1].match(/\A(.)/um).end(1) + r5 = true + @index = next_character + else + r5 = nil + end + if r5 + s4 << r5 + else + break + end + end + if s4.empty? + @index = i4 + r4 = nil + else + r4 = instantiate_node(SyntaxNode,input, i4...index, s4) + end + s0 << r4 + if r4 + s6, i6 = [], index + loop do + if has_terminal?('\G[^\\n\\r]', true, index) + next_character = index + input[index..-1].match(/\A(.)/um).end(1) + r7 = true + @index = next_character + else + r7 = nil + end + if r7 + s6 << r7 + else + break + end + end + if s6.empty? + @index = i6 + r6 = nil + else + r6 = instantiate_node(SyntaxNode,input, i6...index, s6) + end + s0 << r6 + if r6 + if has_terminal?('\G[\\n\\r]', true, index) + next_character = index + input[index..-1].match(/\A(.)/um).end(1) + r8 = true + @index = next_character + else + r8 = nil + end + s0 << r8 + end + end + end + end + if s0.last + r0 = instantiate_node(SyntaxNode,input, i0...index, s0) + r0.extend(RequireStatement0) + else + @index = i0 + r0 = nil + end + + node_cache[:require_statement][start_index] = r0 + + r0 + end + + module ModuleDeclaration0 + def space1 + elements[1] + end + + def space2 + elements[4] + end + end + + module ModuleDeclaration1 + def space + elements[0] + end + + end + + module ModuleDeclaration2 + def prefix + elements[0] + end + + def module_contents + elements[1] + end + + def suffix + elements[2] + end + end + + module ModuleDeclaration3 + def compile + prefix.text_value + module_contents.compile + suffix.text_value + end + end + + def _nt_module_declaration + start_index = index + if node_cache[:module_declaration].has_key?(index) + cached = node_cache[:module_declaration][index] + @index = cached.interval.end if cached + return cached + end + + i0, s0 = index, [] + i1, s1 = index, [] + if has_terminal?('module', false, index) + r2 = instantiate_node(SyntaxNode,input, index...(index + 6)) + @index += 6 + else + terminal_parse_failure('module') + r2 = nil + end + s1 << r2 + if r2 + r3 = _nt_space + s1 << r3 + if r3 + if has_terminal?('\G[A-Z]', true, index) + next_character = index + input[index..-1].match(/\A(.)/um).end(1) + r4 = true + @index = next_character + else + r4 = nil + end + s1 << r4 + if r4 + s5, i5 = [], index + loop do + r6 = _nt_alphanumeric_char + if r6 + s5 << r6 + else + break + end + end + r5 = instantiate_node(SyntaxNode,input, i5...index, s5) + s1 << r5 + if r5 + r7 = _nt_space + s1 << r7 + end + end + end + end + if s1.last + r1 = instantiate_node(SyntaxNode,input, i1...index, s1) + r1.extend(ModuleDeclaration0) + else + @index = i1 + r1 = nil + end + s0 << r1 + if r1 + i8 = index + r9 = _nt_module_declaration + if r9 + r8 = r9 + else + r10 = _nt_grammar + if r10 + r8 = r10 + else + @index = i8 + r8 = nil + end + end + s0 << r8 + if r8 + i11, s11 = index, [] + r12 = _nt_space + s11 << r12 + if r12 + if has_terminal?('end', false, index) + r13 = instantiate_node(SyntaxNode,input, index...(index + 3)) + @index += 3 + else + terminal_parse_failure('end') + r13 = nil + end + s11 << r13 + end + if s11.last + r11 = instantiate_node(SyntaxNode,input, i11...index, s11) + r11.extend(ModuleDeclaration1) + else + @index = i11 + r11 = nil + end + s0 << r11 + end + end + if s0.last + r0 = instantiate_node(SyntaxNode,input, i0...index, s0) + r0.extend(ModuleDeclaration2) + r0.extend(ModuleDeclaration3) + else + @index = i0 + r0 = nil + end + + node_cache[:module_declaration][start_index] = r0 + + r0 + end + + module Grammar0 + def space + elements[1] + end + end + + module Grammar1 + def space1 + elements[1] + end + + def grammar_name + elements[2] + end + + def space2 + elements[3] + end + + def declaration_sequence + elements[5] + end + + end + + def _nt_grammar + start_index = index + if node_cache[:grammar].has_key?(index) + cached = node_cache[:grammar][index] + @index = cached.interval.end if cached + return cached + end + + i0, s0 = index, [] + if has_terminal?('grammar', false, index) + r1 = instantiate_node(SyntaxNode,input, index...(index + 7)) + @index += 7 + else + terminal_parse_failure('grammar') + r1 = nil + end + s0 << r1 + if r1 + r2 = _nt_space + s0 << r2 + if r2 + r3 = _nt_grammar_name + s0 << r3 + if r3 + r4 = _nt_space + s0 << r4 + if r4 + i6, s6 = index, [] + if has_terminal?('do', false, index) + r7 = instantiate_node(SyntaxNode,input, index...(index + 2)) + @index += 2 + else + terminal_parse_failure('do') + r7 = nil + end + s6 << r7 + if r7 + r8 = _nt_space + s6 << r8 + end + if s6.last + r6 = instantiate_node(SyntaxNode,input, i6...index, s6) + r6.extend(Grammar0) + else + @index = i6 + r6 = nil + end + if r6 + r5 = r6 + else + r5 = instantiate_node(SyntaxNode,input, index...index) + end + s0 << r5 + if r5 + r9 = _nt_declaration_sequence + s0 << r9 + if r9 + r11 = _nt_space + if r11 + r10 = r11 + else + r10 = instantiate_node(SyntaxNode,input, index...index) + end + s0 << r10 + if r10 + if has_terminal?('end', false, index) + r12 = instantiate_node(SyntaxNode,input, index...(index + 3)) + @index += 3 + else + terminal_parse_failure('end') + r12 = nil + end + s0 << r12 + end + end + end + end + end + end + end + if s0.last + r0 = instantiate_node(Grammar,input, i0...index, s0) + r0.extend(Grammar1) + else + @index = i0 + r0 = nil + end + + node_cache[:grammar][start_index] = r0 + + r0 + end + + module GrammarName0 + end + + def _nt_grammar_name + start_index = index + if node_cache[:grammar_name].has_key?(index) + cached = node_cache[:grammar_name][index] + @index = cached.interval.end if cached + return cached + end + + i0, s0 = index, [] + if has_terminal?('\G[A-Z]', true, index) + next_character = index + input[index..-1].match(/\A(.)/um).end(1) + r1 = true + @index = next_character + else + r1 = nil + end + s0 << r1 + if r1 + s2, i2 = [], index + loop do + r3 = _nt_alphanumeric_char + if r3 + s2 << r3 + else + break + end + end + r2 = instantiate_node(SyntaxNode,input, i2...index, s2) + s0 << r2 + end + if s0.last + r0 = instantiate_node(SyntaxNode,input, i0...index, s0) + r0.extend(GrammarName0) + else + @index = i0 + r0 = nil + end + + node_cache[:grammar_name][start_index] = r0 + + r0 + end + + module DeclarationSequence0 + def space + elements[0] + end + + def declaration + elements[1] + end + end + + module DeclarationSequence1 + def head + elements[0] + end + + def tail + elements[1] + end + end + + module DeclarationSequence2 + def declarations + [head] + tail + end + + def tail + super.elements.map { |elt| elt.declaration } + end + end + + module DeclarationSequence3 + def compile(builder) + end + end + + def _nt_declaration_sequence + start_index = index + if node_cache[:declaration_sequence].has_key?(index) + cached = node_cache[:declaration_sequence][index] + @index = cached.interval.end if cached + return cached + end + + i0 = index + i1, s1 = index, [] + r2 = _nt_declaration + s1 << r2 + if r2 + s3, i3 = [], index + loop do + i4, s4 = index, [] + r5 = _nt_space + s4 << r5 + if r5 + r6 = _nt_declaration + s4 << r6 + end + if s4.last + r4 = instantiate_node(SyntaxNode,input, i4...index, s4) + r4.extend(DeclarationSequence0) + else + @index = i4 + r4 = nil + end + if r4 + s3 << r4 + else + break + end + end + r3 = instantiate_node(SyntaxNode,input, i3...index, s3) + s1 << r3 + end + if s1.last + r1 = instantiate_node(DeclarationSequence,input, i1...index, s1) + r1.extend(DeclarationSequence1) + r1.extend(DeclarationSequence2) + else + @index = i1 + r1 = nil + end + if r1 + r0 = r1 + else + if has_terminal?('', false, index) + r7 = instantiate_node(SyntaxNode,input, index...(index + 0)) + r7.extend(DeclarationSequence3) + @index += 0 + else + terminal_parse_failure('') + r7 = nil + end + if r7 + r0 = r7 + else + @index = i0 + r0 = nil + end + end + + node_cache[:declaration_sequence][start_index] = r0 + + r0 + end + + def _nt_declaration + start_index = index + if node_cache[:declaration].has_key?(index) + cached = node_cache[:declaration][index] + @index = cached.interval.end if cached + return cached + end + + i0 = index + r1 = _nt_parsing_rule + if r1 + r0 = r1 + else + r2 = _nt_include_declaration + if r2 + r0 = r2 + else + @index = i0 + r0 = nil + end + end + + node_cache[:declaration][start_index] = r0 + + r0 + end + + module IncludeDeclaration0 + def space + elements[1] + end + + end + + module IncludeDeclaration1 + def compile(builder) + builder << text_value + end + end + + def _nt_include_declaration + start_index = index + if node_cache[:include_declaration].has_key?(index) + cached = node_cache[:include_declaration][index] + @index = cached.interval.end if cached + return cached + end + + i0, s0 = index, [] + if has_terminal?('include', false, index) + r1 = instantiate_node(SyntaxNode,input, index...(index + 7)) + @index += 7 + else + terminal_parse_failure('include') + r1 = nil + end + s0 << r1 + if r1 + r2 = _nt_space + s0 << r2 + if r2 + if has_terminal?('\G[A-Z]', true, index) + next_character = index + input[index..-1].match(/\A(.)/um).end(1) + r3 = true + @index = next_character + else + r3 = nil + end + s0 << r3 + if r3 + s4, i4 = [], index + loop do + i5 = index + r6 = _nt_alphanumeric_char + if r6 + r5 = r6 + else + if has_terminal?('::', false, index) + r7 = instantiate_node(SyntaxNode,input, index...(index + 2)) + @index += 2 + else + terminal_parse_failure('::') + r7 = nil + end + if r7 + r5 = r7 + else + @index = i5 + r5 = nil + end + end + if r5 + s4 << r5 + else + break + end + end + r4 = instantiate_node(SyntaxNode,input, i4...index, s4) + s0 << r4 + end + end + end + if s0.last + r0 = instantiate_node(SyntaxNode,input, i0...index, s0) + r0.extend(IncludeDeclaration0) + r0.extend(IncludeDeclaration1) + else + @index = i0 + r0 = nil + end + + node_cache[:include_declaration][start_index] = r0 + + r0 + end + + module ParsingRule0 + def space + elements[1] + end + end + + module ParsingRule1 + def space1 + elements[1] + end + + def nonterminal + elements[2] + end + + def space2 + elements[3] + end + + def parsing_expression + elements[5] + end + + def space3 + elements[6] + end + + end + + def _nt_parsing_rule + start_index = index + if node_cache[:parsing_rule].has_key?(index) + cached = node_cache[:parsing_rule][index] + @index = cached.interval.end if cached + return cached + end + + i0, s0 = index, [] + if has_terminal?('rule', false, index) + r1 = instantiate_node(SyntaxNode,input, index...(index + 4)) + @index += 4 + else + terminal_parse_failure('rule') + r1 = nil + end + s0 << r1 + if r1 + r2 = _nt_space + s0 << r2 + if r2 + r3 = _nt_nonterminal + s0 << r3 + if r3 + r4 = _nt_space + s0 << r4 + if r4 + i6, s6 = index, [] + if has_terminal?('do', false, index) + r7 = instantiate_node(SyntaxNode,input, index...(index + 2)) + @index += 2 + else + terminal_parse_failure('do') + r7 = nil + end + s6 << r7 + if r7 + r8 = _nt_space + s6 << r8 + end + if s6.last + r6 = instantiate_node(SyntaxNode,input, i6...index, s6) + r6.extend(ParsingRule0) + else + @index = i6 + r6 = nil + end + if r6 + r5 = r6 + else + r5 = instantiate_node(SyntaxNode,input, index...index) + end + s0 << r5 + if r5 + r9 = _nt_parsing_expression + s0 << r9 + if r9 + r10 = _nt_space + s0 << r10 + if r10 + if has_terminal?('end', false, index) + r11 = instantiate_node(SyntaxNode,input, index...(index + 3)) + @index += 3 + else + terminal_parse_failure('end') + r11 = nil + end + s0 << r11 + end + end + end + end + end + end + end + if s0.last + r0 = instantiate_node(ParsingRule,input, i0...index, s0) + r0.extend(ParsingRule1) + else + @index = i0 + r0 = nil + end + + node_cache[:parsing_rule][start_index] = r0 + + r0 + end + + def _nt_parsing_expression + start_index = index + if node_cache[:parsing_expression].has_key?(index) + cached = node_cache[:parsing_expression][index] + @index = cached.interval.end if cached + return cached + end + + i0 = index + r1 = _nt_choice + if r1 + r0 = r1 + else + r2 = _nt_sequence + if r2 + r0 = r2 + else + r3 = _nt_primary + if r3 + r0 = r3 + else + @index = i0 + r0 = nil + end + end + end + + node_cache[:parsing_expression][start_index] = r0 + + r0 + end + + module Choice0 + def alternative + elements[3] + end + end + + module Choice1 + def head + elements[0] + end + + def tail + elements[1] + end + end + + module Choice2 + def alternatives + [head] + tail + end + + def tail + super.elements.map {|elt| elt.alternative} + end + + def inline_modules + (alternatives.map {|alt| alt.inline_modules }).flatten + end + end + + def _nt_choice + start_index = index + if node_cache[:choice].has_key?(index) + cached = node_cache[:choice][index] + @index = cached.interval.end if cached + return cached + end + + i0, s0 = index, [] + r1 = _nt_alternative + s0 << r1 + if r1 + s2, i2 = [], index + loop do + i3, s3 = index, [] + r5 = _nt_space + if r5 + r4 = r5 + else + r4 = instantiate_node(SyntaxNode,input, index...index) + end + s3 << r4 + if r4 + if has_terminal?('/', false, index) + r6 = instantiate_node(SyntaxNode,input, index...(index + 1)) + @index += 1 + else + terminal_parse_failure('/') + r6 = nil + end + s3 << r6 + if r6 + r8 = _nt_space + if r8 + r7 = r8 + else + r7 = instantiate_node(SyntaxNode,input, index...index) + end + s3 << r7 + if r7 + r9 = _nt_alternative + s3 << r9 + end + end + end + if s3.last + r3 = instantiate_node(SyntaxNode,input, i3...index, s3) + r3.extend(Choice0) + else + @index = i3 + r3 = nil + end + if r3 + s2 << r3 + else + break + end + end + if s2.empty? + @index = i2 + r2 = nil + else + r2 = instantiate_node(SyntaxNode,input, i2...index, s2) + end + s0 << r2 + end + if s0.last + r0 = instantiate_node(Choice,input, i0...index, s0) + r0.extend(Choice1) + r0.extend(Choice2) + else + @index = i0 + r0 = nil + end + + node_cache[:choice][start_index] = r0 + + r0 + end + + module Sequence0 + def space + elements[0] + end + + def labeled_sequence_primary + elements[1] + end + end + + module Sequence1 + def head + elements[0] + end + + def tail + elements[1] + end + + def node_class_declarations + elements[2] + end + end + + module Sequence2 + def sequence_elements + [head] + tail + end + + def tail + super.elements.map {|elt| elt.labeled_sequence_primary } + end + + def inline_modules + (sequence_elements.map {|elt| elt.inline_modules}).flatten + + [sequence_element_accessor_module] + + node_class_declarations.inline_modules + end + + def inline_module_name + node_class_declarations.inline_module_name + end + end + + def _nt_sequence + start_index = index + if node_cache[:sequence].has_key?(index) + cached = node_cache[:sequence][index] + @index = cached.interval.end if cached + return cached + end + + i0, s0 = index, [] + r1 = _nt_labeled_sequence_primary + s0 << r1 + if r1 + s2, i2 = [], index + loop do + i3, s3 = index, [] + r4 = _nt_space + s3 << r4 + if r4 + r5 = _nt_labeled_sequence_primary + s3 << r5 + end + if s3.last + r3 = instantiate_node(SyntaxNode,input, i3...index, s3) + r3.extend(Sequence0) + else + @index = i3 + r3 = nil + end + if r3 + s2 << r3 + else + break + end + end + if s2.empty? + @index = i2 + r2 = nil + else + r2 = instantiate_node(SyntaxNode,input, i2...index, s2) + end + s0 << r2 + if r2 + r6 = _nt_node_class_declarations + s0 << r6 + end + end + if s0.last + r0 = instantiate_node(Sequence,input, i0...index, s0) + r0.extend(Sequence1) + r0.extend(Sequence2) + else + @index = i0 + r0 = nil + end + + node_cache[:sequence][start_index] = r0 + + r0 + end + + def _nt_alternative + start_index = index + if node_cache[:alternative].has_key?(index) + cached = node_cache[:alternative][index] + @index = cached.interval.end if cached + return cached + end + + i0 = index + r1 = _nt_sequence + if r1 + r0 = r1 + else + r2 = _nt_primary + if r2 + r0 = r2 + else + @index = i0 + r0 = nil + end + end + + node_cache[:alternative][start_index] = r0 + + r0 + end + + module Primary0 + def prefix + elements[0] + end + + def atomic + elements[1] + end + end + + module Primary1 + def compile(address, builder, parent_expression=nil) + prefix.compile(address, builder, self) + end + + def prefixed_expression + atomic + end + + def inline_modules + atomic.inline_modules + end + + def inline_module_name + nil + end + end + + module Primary2 + def prefix + elements[0] + end + + def predicate_block + elements[2] + end + end + + module Primary3 + def compile(address, builder, parent_expression=nil) + prefix.compile(address, builder, self) + end + def prefixed_expression + predicate_block + end + def inline_modules + [] + end + end + + module Primary4 + def atomic + elements[0] + end + + def suffix + elements[1] + end + + def node_class_declarations + elements[2] + end + end + + module Primary5 + def compile(address, builder, parent_expression=nil) + suffix.compile(address, builder, self) + end + + def optional_expression + atomic + end + + def node_class_name + node_class_declarations.node_class_name + end + + def inline_modules + atomic.inline_modules + node_class_declarations.inline_modules + end + + def inline_module_name + node_class_declarations.inline_module_name + end + end + + module Primary6 + def atomic + elements[0] + end + + def node_class_declarations + elements[1] + end + end + + module Primary7 + def compile(address, builder, parent_expression=nil) + atomic.compile(address, builder, self) + end + + def node_class_name + node_class_declarations.node_class_name + end + + def inline_modules + atomic.inline_modules + node_class_declarations.inline_modules + end + + def inline_module_name + node_class_declarations.inline_module_name + end + end + + def _nt_primary + start_index = index + if node_cache[:primary].has_key?(index) + cached = node_cache[:primary][index] + @index = cached.interval.end if cached + return cached + end + + i0 = index + i1, s1 = index, [] + r2 = _nt_prefix + s1 << r2 + if r2 + r3 = _nt_atomic + s1 << r3 + end + if s1.last + r1 = instantiate_node(SyntaxNode,input, i1...index, s1) + r1.extend(Primary0) + r1.extend(Primary1) + else + @index = i1 + r1 = nil + end + if r1 + r0 = r1 + else + i4, s4 = index, [] + r5 = _nt_prefix + s4 << r5 + if r5 + r7 = _nt_space + if r7 + r6 = r7 + else + r6 = instantiate_node(SyntaxNode,input, index...index) + end + s4 << r6 + if r6 + r8 = _nt_predicate_block + s4 << r8 + end + end + if s4.last + r4 = instantiate_node(SyntaxNode,input, i4...index, s4) + r4.extend(Primary2) + r4.extend(Primary3) + else + @index = i4 + r4 = nil + end + if r4 + r0 = r4 + else + i9, s9 = index, [] + r10 = _nt_atomic + s9 << r10 + if r10 + r11 = _nt_suffix + s9 << r11 + if r11 + r12 = _nt_node_class_declarations + s9 << r12 + end + end + if s9.last + r9 = instantiate_node(SyntaxNode,input, i9...index, s9) + r9.extend(Primary4) + r9.extend(Primary5) + else + @index = i9 + r9 = nil + end + if r9 + r0 = r9 + else + i13, s13 = index, [] + r14 = _nt_atomic + s13 << r14 + if r14 + r15 = _nt_node_class_declarations + s13 << r15 + end + if s13.last + r13 = instantiate_node(SyntaxNode,input, i13...index, s13) + r13.extend(Primary6) + r13.extend(Primary7) + else + @index = i13 + r13 = nil + end + if r13 + r0 = r13 + else + @index = i0 + r0 = nil + end + end + end + end + + node_cache[:primary][start_index] = r0 + + r0 + end + + module LabeledSequencePrimary0 + def label + elements[0] + end + + def sequence_primary + elements[1] + end + end + + module LabeledSequencePrimary1 + def compile(lexical_address, builder) + sequence_primary.compile(lexical_address, builder) + end + + def inline_modules + sequence_primary.inline_modules + end + + def label_name + if label.name + label.name + elsif sequence_primary.instance_of?(Nonterminal) + sequence_primary.text_value + else + nil + end + end + end + + def _nt_labeled_sequence_primary + start_index = index + if node_cache[:labeled_sequence_primary].has_key?(index) + cached = node_cache[:labeled_sequence_primary][index] + @index = cached.interval.end if cached + return cached + end + + i0, s0 = index, [] + r1 = _nt_label + s0 << r1 + if r1 + r2 = _nt_sequence_primary + s0 << r2 + end + if s0.last + r0 = instantiate_node(SyntaxNode,input, i0...index, s0) + r0.extend(LabeledSequencePrimary0) + r0.extend(LabeledSequencePrimary1) + else + @index = i0 + r0 = nil + end + + node_cache[:labeled_sequence_primary][start_index] = r0 + + r0 + end + + module Label0 + def alpha_char + elements[0] + end + + end + + module Label1 + end + + module Label2 + def name + elements[0].text_value + end + end + + module Label3 + def name + nil + end + end + + def _nt_label + start_index = index + if node_cache[:label].has_key?(index) + cached = node_cache[:label][index] + @index = cached.interval.end if cached + return cached + end + + i0 = index + i1, s1 = index, [] + i2, s2 = index, [] + r3 = _nt_alpha_char + s2 << r3 + if r3 + s4, i4 = [], index + loop do + r5 = _nt_alphanumeric_char + if r5 + s4 << r5 + else + break + end + end + r4 = instantiate_node(SyntaxNode,input, i4...index, s4) + s2 << r4 + end + if s2.last + r2 = instantiate_node(SyntaxNode,input, i2...index, s2) + r2.extend(Label0) + else + @index = i2 + r2 = nil + end + s1 << r2 + if r2 + if has_terminal?(':', false, index) + r6 = instantiate_node(SyntaxNode,input, index...(index + 1)) + @index += 1 + else + terminal_parse_failure(':') + r6 = nil + end + s1 << r6 + end + if s1.last + r1 = instantiate_node(SyntaxNode,input, i1...index, s1) + r1.extend(Label1) + r1.extend(Label2) + else + @index = i1 + r1 = nil + end + if r1 + r0 = r1 + else + if has_terminal?('', false, index) + r7 = instantiate_node(SyntaxNode,input, index...(index + 0)) + r7.extend(Label3) + @index += 0 + else + terminal_parse_failure('') + r7 = nil + end + if r7 + r0 = r7 + else + @index = i0 + r0 = nil + end + end + + node_cache[:label][start_index] = r0 + + r0 + end + + module SequencePrimary0 + def prefix + elements[0] + end + + def atomic + elements[1] + end + end + + module SequencePrimary1 + def compile(lexical_address, builder) + prefix.compile(lexical_address, builder, self) + end + + def prefixed_expression + elements[1] + end + + def inline_modules + atomic.inline_modules + end + + def inline_module_name + nil + end + end + + module SequencePrimary2 + def prefix + elements[0] + end + + def predicate_block + elements[2] + end + end + + module SequencePrimary3 + def compile(address, builder, parent_expression=nil) + prefix.compile(address, builder, self) + end + def prefixed_expression + predicate_block + end + def inline_modules + [] + end + end + + module SequencePrimary4 + def atomic + elements[0] + end + + def suffix + elements[1] + end + end + + module SequencePrimary5 + def compile(lexical_address, builder) + suffix.compile(lexical_address, builder, self) + end + + def node_class_name + nil + end + + def inline_modules + atomic.inline_modules + end + + def inline_module_name + nil + end + end + + def _nt_sequence_primary + start_index = index + if node_cache[:sequence_primary].has_key?(index) + cached = node_cache[:sequence_primary][index] + @index = cached.interval.end if cached + return cached + end + + i0 = index + i1, s1 = index, [] + r2 = _nt_prefix + s1 << r2 + if r2 + r3 = _nt_atomic + s1 << r3 + end + if s1.last + r1 = instantiate_node(SyntaxNode,input, i1...index, s1) + r1.extend(SequencePrimary0) + r1.extend(SequencePrimary1) + else + @index = i1 + r1 = nil + end + if r1 + r0 = r1 + else + i4, s4 = index, [] + r5 = _nt_prefix + s4 << r5 + if r5 + r7 = _nt_space + if r7 + r6 = r7 + else + r6 = instantiate_node(SyntaxNode,input, index...index) + end + s4 << r6 + if r6 + r8 = _nt_predicate_block + s4 << r8 + end + end + if s4.last + r4 = instantiate_node(SyntaxNode,input, i4...index, s4) + r4.extend(SequencePrimary2) + r4.extend(SequencePrimary3) + else + @index = i4 + r4 = nil + end + if r4 + r0 = r4 + else + i9, s9 = index, [] + r10 = _nt_atomic + s9 << r10 + if r10 + r11 = _nt_suffix + s9 << r11 + end + if s9.last + r9 = instantiate_node(SyntaxNode,input, i9...index, s9) + r9.extend(SequencePrimary4) + r9.extend(SequencePrimary5) + else + @index = i9 + r9 = nil + end + if r9 + r0 = r9 + else + r12 = _nt_atomic + if r12 + r0 = r12 + else + @index = i0 + r0 = nil + end + end + end + end + + node_cache[:sequence_primary][start_index] = r0 + + r0 + end + + def _nt_suffix + start_index = index + if node_cache[:suffix].has_key?(index) + cached = node_cache[:suffix][index] + @index = cached.interval.end if cached + return cached + end + + i0 = index + r1 = _nt_repetition_suffix + if r1 + r0 = r1 + else + r2 = _nt_optional_suffix + if r2 + r0 = r2 + else + @index = i0 + r0 = nil + end + end + + node_cache[:suffix][start_index] = r0 + + r0 + end + + def _nt_optional_suffix + start_index = index + if node_cache[:optional_suffix].has_key?(index) + cached = node_cache[:optional_suffix][index] + @index = cached.interval.end if cached + return cached + end + + if has_terminal?('?', false, index) + r0 = instantiate_node(Optional,input, index...(index + 1)) + @index += 1 + else + terminal_parse_failure('?') + r0 = nil + end + + node_cache[:optional_suffix][start_index] = r0 + + r0 + end + + module NodeClassDeclarations0 + def node_class_expression + elements[0] + end + + def trailing_inline_module + elements[1] + end + end + + module NodeClassDeclarations1 + def node_class_name + node_class_expression.node_class_name + end + + def inline_modules + trailing_inline_module.inline_modules + end + + def inline_module + trailing_inline_module.inline_module + end + + def inline_module_name + inline_module.module_name if inline_module + end + end + + def _nt_node_class_declarations + start_index = index + if node_cache[:node_class_declarations].has_key?(index) + cached = node_cache[:node_class_declarations][index] + @index = cached.interval.end if cached + return cached + end + + i0, s0 = index, [] + r1 = _nt_node_class_expression + s0 << r1 + if r1 + r2 = _nt_trailing_inline_module + s0 << r2 + end + if s0.last + r0 = instantiate_node(SyntaxNode,input, i0...index, s0) + r0.extend(NodeClassDeclarations0) + r0.extend(NodeClassDeclarations1) + else + @index = i0 + r0 = nil + end + + node_cache[:node_class_declarations][start_index] = r0 + + r0 + end + + def _nt_repetition_suffix + start_index = index + if node_cache[:repetition_suffix].has_key?(index) + cached = node_cache[:repetition_suffix][index] + @index = cached.interval.end if cached + return cached + end + + i0 = index + if has_terminal?('+', false, index) + r1 = instantiate_node(OneOrMore,input, index...(index + 1)) + @index += 1 + else + terminal_parse_failure('+') + r1 = nil + end + if r1 + r0 = r1 + else + if has_terminal?('*', false, index) + r2 = instantiate_node(ZeroOrMore,input, index...(index + 1)) + @index += 1 + else + terminal_parse_failure('*') + r2 = nil + end + if r2 + r0 = r2 + else + @index = i0 + r0 = nil + end + end + + node_cache[:repetition_suffix][start_index] = r0 + + r0 + end + + def _nt_prefix + start_index = index + if node_cache[:prefix].has_key?(index) + cached = node_cache[:prefix][index] + @index = cached.interval.end if cached + return cached + end + + i0 = index + if has_terminal?('&', false, index) + r1 = instantiate_node(AndPredicate,input, index...(index + 1)) + @index += 1 + else + terminal_parse_failure('&') + r1 = nil + end + if r1 + r0 = r1 + else + if has_terminal?('!', false, index) + r2 = instantiate_node(NotPredicate,input, index...(index + 1)) + @index += 1 + else + terminal_parse_failure('!') + r2 = nil + end + if r2 + r0 = r2 + else + if has_terminal?('~', false, index) + r3 = instantiate_node(TransientPrefix,input, index...(index + 1)) + @index += 1 + else + terminal_parse_failure('~') + r3 = nil + end + if r3 + r0 = r3 + else + @index = i0 + r0 = nil + end + end + end + + node_cache[:prefix][start_index] = r0 + + r0 + end + + def _nt_atomic + start_index = index + if node_cache[:atomic].has_key?(index) + cached = node_cache[:atomic][index] + @index = cached.interval.end if cached + return cached + end + + i0 = index + r1 = _nt_terminal + if r1 + r0 = r1 + else + r2 = _nt_nonterminal + if r2 + r0 = r2 + else + r3 = _nt_parenthesized_expression + if r3 + r0 = r3 + else + @index = i0 + r0 = nil + end + end + end + + node_cache[:atomic][start_index] = r0 + + r0 + end + + module ParenthesizedExpression0 + def parsing_expression + elements[2] + end + + end + + module ParenthesizedExpression1 + def inline_modules + parsing_expression.inline_modules + end + end + + def _nt_parenthesized_expression + start_index = index + if node_cache[:parenthesized_expression].has_key?(index) + cached = node_cache[:parenthesized_expression][index] + @index = cached.interval.end if cached + return cached + end + + i0, s0 = index, [] + if has_terminal?('(', false, index) + r1 = instantiate_node(SyntaxNode,input, index...(index + 1)) + @index += 1 + else + terminal_parse_failure('(') + r1 = nil + end + s0 << r1 + if r1 + r3 = _nt_space + if r3 + r2 = r3 + else + r2 = instantiate_node(SyntaxNode,input, index...index) + end + s0 << r2 + if r2 + r4 = _nt_parsing_expression + s0 << r4 + if r4 + r6 = _nt_space + if r6 + r5 = r6 + else + r5 = instantiate_node(SyntaxNode,input, index...index) + end + s0 << r5 + if r5 + if has_terminal?(')', false, index) + r7 = instantiate_node(SyntaxNode,input, index...(index + 1)) + @index += 1 + else + terminal_parse_failure(')') + r7 = nil + end + s0 << r7 + end + end + end + end + if s0.last + r0 = instantiate_node(ParenthesizedExpression,input, i0...index, s0) + r0.extend(ParenthesizedExpression0) + r0.extend(ParenthesizedExpression1) + else + @index = i0 + r0 = nil + end + + node_cache[:parenthesized_expression][start_index] = r0 + + r0 + end + + module Nonterminal0 + def alpha_char + elements[0] + end + + end + + module Nonterminal1 + end + + def _nt_nonterminal + start_index = index + if node_cache[:nonterminal].has_key?(index) + cached = node_cache[:nonterminal][index] + @index = cached.interval.end if cached + return cached + end + + i0, s0 = index, [] + i1 = index + r2 = _nt_keyword_inside_grammar + if r2 + r1 = nil + else + @index = i1 + r1 = instantiate_node(SyntaxNode,input, index...index) + end + s0 << r1 + if r1 + i3, s3 = index, [] + r4 = _nt_alpha_char + s3 << r4 + if r4 + s5, i5 = [], index + loop do + r6 = _nt_alphanumeric_char + if r6 + s5 << r6 + else + break + end + end + r5 = instantiate_node(SyntaxNode,input, i5...index, s5) + s3 << r5 + end + if s3.last + r3 = instantiate_node(SyntaxNode,input, i3...index, s3) + r3.extend(Nonterminal0) + else + @index = i3 + r3 = nil + end + s0 << r3 + end + if s0.last + r0 = instantiate_node(Nonterminal,input, i0...index, s0) + r0.extend(Nonterminal1) + else + @index = i0 + r0 = nil + end + + node_cache[:nonterminal][start_index] = r0 + + r0 + end + + def _nt_terminal + start_index = index + if node_cache[:terminal].has_key?(index) + cached = node_cache[:terminal][index] + @index = cached.interval.end if cached + return cached + end + + i0 = index + r1 = _nt_quoted_string + if r1 + r0 = r1 + else + r2 = _nt_character_class + if r2 + r0 = r2 + else + r3 = _nt_anything_symbol + if r3 + r0 = r3 + else + @index = i0 + r0 = nil + end + end + end + + node_cache[:terminal][start_index] = r0 + + r0 + end + + module QuotedString0 + def string + super.text_value + end + end + + def _nt_quoted_string + start_index = index + if node_cache[:quoted_string].has_key?(index) + cached = node_cache[:quoted_string][index] + @index = cached.interval.end if cached + return cached + end + + i0 = index + r1 = _nt_single_quoted_string + if r1 + r0 = r1 + r0.extend(QuotedString0) + else + r2 = _nt_double_quoted_string + if r2 + r0 = r2 + r0.extend(QuotedString0) + else + @index = i0 + r0 = nil + end + end + + node_cache[:quoted_string][start_index] = r0 + + r0 + end + + module DoubleQuotedString0 + end + + module DoubleQuotedString1 + def string + elements[1] + end + + end + + def _nt_double_quoted_string + start_index = index + if node_cache[:double_quoted_string].has_key?(index) + cached = node_cache[:double_quoted_string][index] + @index = cached.interval.end if cached + return cached + end + + i0, s0 = index, [] + if has_terminal?('"', false, index) + r1 = instantiate_node(SyntaxNode,input, index...(index + 1)) + @index += 1 + else + terminal_parse_failure('"') + r1 = nil + end + s0 << r1 + if r1 + s2, i2 = [], index + loop do + i3, s3 = index, [] + i4 = index + if has_terminal?('"', false, index) + r5 = instantiate_node(SyntaxNode,input, index...(index + 1)) + @index += 1 + else + terminal_parse_failure('"') + r5 = nil + end + if r5 + r4 = nil + else + @index = i4 + r4 = instantiate_node(SyntaxNode,input, index...index) + end + s3 << r4 + if r4 + i6 = index + if has_terminal?("\\\\", false, index) + r7 = instantiate_node(SyntaxNode,input, index...(index + 2)) + @index += 2 + else + terminal_parse_failure("\\\\") + r7 = nil + end + if r7 + r6 = r7 + else + if has_terminal?('\"', false, index) + r8 = instantiate_node(SyntaxNode,input, index...(index + 2)) + @index += 2 + else + terminal_parse_failure('\"') + r8 = nil + end + if r8 + r6 = r8 + else + if index < input_length + next_character = index + input[index..-1].match(/\A(.)/um).end(1) + r9 = instantiate_node(SyntaxNode,input, index...next_character) + @index = next_character + else + terminal_parse_failure("any character") + r9 = nil + end + if r9 + r6 = r9 + else + @index = i6 + r6 = nil + end + end + end + s3 << r6 + end + if s3.last + r3 = instantiate_node(SyntaxNode,input, i3...index, s3) + r3.extend(DoubleQuotedString0) + else + @index = i3 + r3 = nil + end + if r3 + s2 << r3 + else + break + end + end + r2 = instantiate_node(SyntaxNode,input, i2...index, s2) + s0 << r2 + if r2 + if has_terminal?('"', false, index) + r10 = instantiate_node(SyntaxNode,input, index...(index + 1)) + @index += 1 + else + terminal_parse_failure('"') + r10 = nil + end + s0 << r10 + end + end + if s0.last + r0 = instantiate_node(Terminal,input, i0...index, s0) + r0.extend(DoubleQuotedString1) + else + @index = i0 + r0 = nil + end + + node_cache[:double_quoted_string][start_index] = r0 + + r0 + end + + module SingleQuotedString0 + end + + module SingleQuotedString1 + def string + elements[1] + end + + end + + def _nt_single_quoted_string + start_index = index + if node_cache[:single_quoted_string].has_key?(index) + cached = node_cache[:single_quoted_string][index] + @index = cached.interval.end if cached + return cached + end + + i0, s0 = index, [] + if has_terminal?("'", false, index) + r1 = instantiate_node(SyntaxNode,input, index...(index + 1)) + @index += 1 + else + terminal_parse_failure("'") + r1 = nil + end + s0 << r1 + if r1 + s2, i2 = [], index + loop do + i3, s3 = index, [] + i4 = index + if has_terminal?("'", false, index) + r5 = instantiate_node(SyntaxNode,input, index...(index + 1)) + @index += 1 + else + terminal_parse_failure("'") + r5 = nil + end + if r5 + r4 = nil + else + @index = i4 + r4 = instantiate_node(SyntaxNode,input, index...index) + end + s3 << r4 + if r4 + i6 = index + if has_terminal?("\\\\", false, index) + r7 = instantiate_node(SyntaxNode,input, index...(index + 2)) + @index += 2 + else + terminal_parse_failure("\\\\") + r7 = nil + end + if r7 + r6 = r7 + else + if has_terminal?("\\'", false, index) + r8 = instantiate_node(SyntaxNode,input, index...(index + 2)) + @index += 2 + else + terminal_parse_failure("\\'") + r8 = nil + end + if r8 + r6 = r8 + else + if index < input_length + next_character = index + input[index..-1].match(/\A(.)/um).end(1) + r9 = instantiate_node(SyntaxNode,input, index...next_character) + @index = next_character + else + terminal_parse_failure("any character") + r9 = nil + end + if r9 + r6 = r9 + else + @index = i6 + r6 = nil + end + end + end + s3 << r6 + end + if s3.last + r3 = instantiate_node(SyntaxNode,input, i3...index, s3) + r3.extend(SingleQuotedString0) + else + @index = i3 + r3 = nil + end + if r3 + s2 << r3 + else + break + end + end + r2 = instantiate_node(SyntaxNode,input, i2...index, s2) + s0 << r2 + if r2 + if has_terminal?("'", false, index) + r10 = instantiate_node(SyntaxNode,input, index...(index + 1)) + @index += 1 + else + terminal_parse_failure("'") + r10 = nil + end + s0 << r10 + end + end + if s0.last + r0 = instantiate_node(Terminal,input, i0...index, s0) + r0.extend(SingleQuotedString1) + else + @index = i0 + r0 = nil + end + + node_cache[:single_quoted_string][start_index] = r0 + + r0 + end + + module CharacterClass0 + end + + module CharacterClass1 + end + + module CharacterClass2 + end + + module CharacterClass3 + def characters + elements[1] + end + + end + + module CharacterClass4 + def characters + super.text_value + end + end + + def _nt_character_class + start_index = index + if node_cache[:character_class].has_key?(index) + cached = node_cache[:character_class][index] + @index = cached.interval.end if cached + return cached + end + + i0, s0 = index, [] + if has_terminal?('[', false, index) + r1 = instantiate_node(SyntaxNode,input, index...(index + 1)) + @index += 1 + else + terminal_parse_failure('[') + r1 = nil + end + s0 << r1 + if r1 + s2, i2 = [], index + loop do + i3, s3 = index, [] + i4 = index + if has_terminal?(']', false, index) + r5 = instantiate_node(SyntaxNode,input, index...(index + 1)) + @index += 1 + else + terminal_parse_failure(']') + r5 = nil + end + if r5 + r4 = nil + else + @index = i4 + r4 = instantiate_node(SyntaxNode,input, index...index) + end + s3 << r4 + if r4 + i6 = index + i7, s7 = index, [] + if has_terminal?('\\', false, index) + r8 = instantiate_node(SyntaxNode,input, index...(index + 1)) + @index += 1 + else + terminal_parse_failure('\\') + r8 = nil + end + s7 << r8 + if r8 + if index < input_length + next_character = index + input[index..-1].match(/\A(.)/um).end(1) + r9 = instantiate_node(SyntaxNode,input, index...next_character) + @index = next_character + else + terminal_parse_failure("any character") + r9 = nil + end + s7 << r9 + end + if s7.last + r7 = instantiate_node(SyntaxNode,input, i7...index, s7) + r7.extend(CharacterClass0) + else + @index = i7 + r7 = nil + end + if r7 + r6 = r7 + else + i10, s10 = index, [] + i11 = index + if has_terminal?('\\', false, index) + r12 = instantiate_node(SyntaxNode,input, index...(index + 1)) + @index += 1 + else + terminal_parse_failure('\\') + r12 = nil + end + if r12 + r11 = nil + else + @index = i11 + r11 = instantiate_node(SyntaxNode,input, index...index) + end + s10 << r11 + if r11 + if index < input_length + next_character = index + input[index..-1].match(/\A(.)/um).end(1) + r13 = instantiate_node(SyntaxNode,input, index...next_character) + @index = next_character + else + terminal_parse_failure("any character") + r13 = nil + end + s10 << r13 + end + if s10.last + r10 = instantiate_node(SyntaxNode,input, i10...index, s10) + r10.extend(CharacterClass1) + else + @index = i10 + r10 = nil + end + if r10 + r6 = r10 + else + @index = i6 + r6 = nil + end + end + s3 << r6 + end + if s3.last + r3 = instantiate_node(SyntaxNode,input, i3...index, s3) + r3.extend(CharacterClass2) + else + @index = i3 + r3 = nil + end + if r3 + s2 << r3 + else + break + end + end + if s2.empty? + @index = i2 + r2 = nil + else + r2 = instantiate_node(SyntaxNode,input, i2...index, s2) + end + s0 << r2 + if r2 + if has_terminal?(']', false, index) + r14 = instantiate_node(SyntaxNode,input, index...(index + 1)) + @index += 1 + else + terminal_parse_failure(']') + r14 = nil + end + s0 << r14 + end + end + if s0.last + r0 = instantiate_node(CharacterClass,input, i0...index, s0) + r0.extend(CharacterClass3) + r0.extend(CharacterClass4) + else + @index = i0 + r0 = nil + end + + node_cache[:character_class][start_index] = r0 + + r0 + end + + def _nt_anything_symbol + start_index = index + if node_cache[:anything_symbol].has_key?(index) + cached = node_cache[:anything_symbol][index] + @index = cached.interval.end if cached + return cached + end + + if has_terminal?('.', false, index) + r0 = instantiate_node(AnythingSymbol,input, index...(index + 1)) + @index += 1 + else + terminal_parse_failure('.') + r0 = nil + end + + node_cache[:anything_symbol][start_index] = r0 + + r0 + end + + module NodeClassExpression0 + end + + module NodeClassExpression1 + def space + elements[0] + end + + end + + module NodeClassExpression2 + def node_class_name + elements[2].text_value + end + end + + module NodeClassExpression3 + def node_class_name + nil + end + end + + def _nt_node_class_expression + start_index = index + if node_cache[:node_class_expression].has_key?(index) + cached = node_cache[:node_class_expression][index] + @index = cached.interval.end if cached + return cached + end + + i0 = index + i1, s1 = index, [] + r2 = _nt_space + s1 << r2 + if r2 + if has_terminal?('<', false, index) + r3 = instantiate_node(SyntaxNode,input, index...(index + 1)) + @index += 1 + else + terminal_parse_failure('<') + r3 = nil + end + s1 << r3 + if r3 + s4, i4 = [], index + loop do + i5, s5 = index, [] + i6 = index + if has_terminal?('>', false, index) + r7 = instantiate_node(SyntaxNode,input, index...(index + 1)) + @index += 1 + else + terminal_parse_failure('>') + r7 = nil + end + if r7 + r6 = nil + else + @index = i6 + r6 = instantiate_node(SyntaxNode,input, index...index) + end + s5 << r6 + if r6 + if index < input_length + next_character = index + input[index..-1].match(/\A(.)/um).end(1) + r8 = instantiate_node(SyntaxNode,input, index...next_character) + @index = next_character + else + terminal_parse_failure("any character") + r8 = nil + end + s5 << r8 + end + if s5.last + r5 = instantiate_node(SyntaxNode,input, i5...index, s5) + r5.extend(NodeClassExpression0) + else + @index = i5 + r5 = nil + end + if r5 + s4 << r5 + else + break + end + end + if s4.empty? + @index = i4 + r4 = nil + else + r4 = instantiate_node(SyntaxNode,input, i4...index, s4) + end + s1 << r4 + if r4 + if has_terminal?('>', false, index) + r9 = instantiate_node(SyntaxNode,input, index...(index + 1)) + @index += 1 + else + terminal_parse_failure('>') + r9 = nil + end + s1 << r9 + end + end + end + if s1.last + r1 = instantiate_node(SyntaxNode,input, i1...index, s1) + r1.extend(NodeClassExpression1) + r1.extend(NodeClassExpression2) + else + @index = i1 + r1 = nil + end + if r1 + r0 = r1 + else + if has_terminal?('', false, index) + r10 = instantiate_node(SyntaxNode,input, index...(index + 0)) + r10.extend(NodeClassExpression3) + @index += 0 + else + terminal_parse_failure('') + r10 = nil + end + if r10 + r0 = r10 + else + @index = i0 + r0 = nil + end + end + + node_cache[:node_class_expression][start_index] = r0 + + r0 + end + + module TrailingInlineModule0 + def space + elements[0] + end + + def inline_module + elements[1] + end + end + + module TrailingInlineModule1 + def inline_modules + [inline_module] + end + + def inline_module_name + inline_module.module_name + end + end + + module TrailingInlineModule2 + def inline_modules + [] + end + + def inline_module + nil + end + + def inline_module_name + nil + end + end + + def _nt_trailing_inline_module + start_index = index + if node_cache[:trailing_inline_module].has_key?(index) + cached = node_cache[:trailing_inline_module][index] + @index = cached.interval.end if cached + return cached + end + + i0 = index + i1, s1 = index, [] + r2 = _nt_space + s1 << r2 + if r2 + r3 = _nt_inline_module + s1 << r3 + end + if s1.last + r1 = instantiate_node(SyntaxNode,input, i1...index, s1) + r1.extend(TrailingInlineModule0) + r1.extend(TrailingInlineModule1) + else + @index = i1 + r1 = nil + end + if r1 + r0 = r1 + else + if has_terminal?('', false, index) + r4 = instantiate_node(SyntaxNode,input, index...(index + 0)) + r4.extend(TrailingInlineModule2) + @index += 0 + else + terminal_parse_failure('') + r4 = nil + end + if r4 + r0 = r4 + else + @index = i0 + r0 = nil + end + end + + node_cache[:trailing_inline_module][start_index] = r0 + + r0 + end + + module PredicateBlock0 + def inline_module + elements[1] + end + end + + def _nt_predicate_block + start_index = index + if node_cache[:predicate_block].has_key?(index) + cached = node_cache[:predicate_block][index] + @index = cached.interval.end if cached + return cached + end + + i0, s0 = index, [] + if has_terminal?('', false, index) + r1 = instantiate_node(SyntaxNode,input, index...(index + 0)) + @index += 0 + else + terminal_parse_failure('') + r1 = nil + end + s0 << r1 + if r1 + r2 = _nt_inline_module + s0 << r2 + end + if s0.last + r0 = instantiate_node(PredicateBlock,input, i0...index, s0) + r0.extend(PredicateBlock0) + else + @index = i0 + r0 = nil + end + + node_cache[:predicate_block][start_index] = r0 + + r0 + end + + module InlineModule0 + end + + module InlineModule1 + end + + def _nt_inline_module + start_index = index + if node_cache[:inline_module].has_key?(index) + cached = node_cache[:inline_module][index] + @index = cached.interval.end if cached + return cached + end + + i0, s0 = index, [] + if has_terminal?('{', false, index) + r1 = instantiate_node(SyntaxNode,input, index...(index + 1)) + @index += 1 + else + terminal_parse_failure('{') + r1 = nil + end + s0 << r1 + if r1 + s2, i2 = [], index + loop do + i3 = index + r4 = _nt_inline_module + if r4 + r3 = r4 + else + i5, s5 = index, [] + i6 = index + if has_terminal?('\G[{}]', true, index) + next_character = index + input[index..-1].match(/\A(.)/um).end(1) + r7 = true + @index = next_character + else + r7 = nil + end + if r7 + r6 = nil + else + @index = i6 + r6 = instantiate_node(SyntaxNode,input, index...index) + end + s5 << r6 + if r6 + if index < input_length + next_character = index + input[index..-1].match(/\A(.)/um).end(1) + r8 = instantiate_node(SyntaxNode,input, index...next_character) + @index = next_character + else + terminal_parse_failure("any character") + r8 = nil + end + s5 << r8 + end + if s5.last + r5 = instantiate_node(SyntaxNode,input, i5...index, s5) + r5.extend(InlineModule0) + else + @index = i5 + r5 = nil + end + if r5 + r3 = r5 + else + @index = i3 + r3 = nil + end + end + if r3 + s2 << r3 + else + break + end + end + r2 = instantiate_node(SyntaxNode,input, i2...index, s2) + s0 << r2 + if r2 + if has_terminal?('}', false, index) + r9 = instantiate_node(SyntaxNode,input, index...(index + 1)) + @index += 1 + else + terminal_parse_failure('}') + r9 = nil + end + s0 << r9 + end + end + if s0.last + r0 = instantiate_node(InlineModule,input, i0...index, s0) + r0.extend(InlineModule1) + else + @index = i0 + r0 = nil + end + + node_cache[:inline_module][start_index] = r0 + + r0 + end + + module KeywordInsideGrammar0 + end + + def _nt_keyword_inside_grammar + start_index = index + if node_cache[:keyword_inside_grammar].has_key?(index) + cached = node_cache[:keyword_inside_grammar][index] + @index = cached.interval.end if cached + return cached + end + + i0, s0 = index, [] + i1 = index + if has_terminal?('rule', false, index) + r2 = instantiate_node(SyntaxNode,input, index...(index + 4)) + @index += 4 + else + terminal_parse_failure('rule') + r2 = nil + end + if r2 + r1 = r2 + else + if has_terminal?('end', false, index) + r3 = instantiate_node(SyntaxNode,input, index...(index + 3)) + @index += 3 + else + terminal_parse_failure('end') + r3 = nil + end + if r3 + r1 = r3 + else + @index = i1 + r1 = nil + end + end + s0 << r1 + if r1 + i4 = index + r5 = _nt_non_space_char + if r5 + r4 = nil + else + @index = i4 + r4 = instantiate_node(SyntaxNode,input, index...index) + end + s0 << r4 + end + if s0.last + r0 = instantiate_node(SyntaxNode,input, i0...index, s0) + r0.extend(KeywordInsideGrammar0) + else + @index = i0 + r0 = nil + end + + node_cache[:keyword_inside_grammar][start_index] = r0 + + r0 + end + + module NonSpaceChar0 + end + + def _nt_non_space_char + start_index = index + if node_cache[:non_space_char].has_key?(index) + cached = node_cache[:non_space_char][index] + @index = cached.interval.end if cached + return cached + end + + i0, s0 = index, [] + i1 = index + r2 = _nt_space + if r2 + r1 = nil + else + @index = i1 + r1 = instantiate_node(SyntaxNode,input, index...index) + end + s0 << r1 + if r1 + if index < input_length + next_character = index + input[index..-1].match(/\A(.)/um).end(1) + r3 = instantiate_node(SyntaxNode,input, index...next_character) + @index = next_character + else + terminal_parse_failure("any character") + r3 = nil + end + s0 << r3 + end + if s0.last + r0 = instantiate_node(SyntaxNode,input, i0...index, s0) + r0.extend(NonSpaceChar0) + else + @index = i0 + r0 = nil + end + + node_cache[:non_space_char][start_index] = r0 + + r0 + end + + def _nt_alpha_char + start_index = index + if node_cache[:alpha_char].has_key?(index) + cached = node_cache[:alpha_char][index] + @index = cached.interval.end if cached + return cached + end + + if has_terminal?('\G[A-Za-z_]', true, index) + next_character = index + input[index..-1].match(/\A(.)/um).end(1) + r0 = instantiate_node(SyntaxNode, input, index...next_character) + @index = next_character + else + r0 = nil + end + + node_cache[:alpha_char][start_index] = r0 + + r0 + end + + def _nt_alphanumeric_char + start_index = index + if node_cache[:alphanumeric_char].has_key?(index) + cached = node_cache[:alphanumeric_char][index] + @index = cached.interval.end if cached + return cached + end + + i0 = index + r1 = _nt_alpha_char + if r1 + r0 = r1 + else + if has_terminal?('\G[0-9]', true, index) + next_character = index + input[index..-1].match(/\A(.)/um).end(1) + r2 = true + @index = next_character + else + r2 = nil + end + if r2 + r0 = r2 + else + @index = i0 + r0 = nil + end + end + + node_cache[:alphanumeric_char][start_index] = r0 + + r0 + end + + def _nt_space + start_index = index + if node_cache[:space].has_key?(index) + cached = node_cache[:space][index] + @index = cached.interval.end if cached + return cached + end + + s0, i0 = [], index + loop do + i1 = index + r2 = _nt_white + if r2 + r1 = r2 + else + r3 = _nt_comment_to_eol + if r3 + r1 = r3 + else + @index = i1 + r1 = nil + end + end + if r1 + s0 << r1 + else + break + end + end + if s0.empty? + @index = i0 + r0 = nil + else + r0 = instantiate_node(SyntaxNode,input, i0...index, s0) + end + + node_cache[:space][start_index] = r0 + + r0 + end + + module CommentToEol0 + end + + module CommentToEol1 + end + + def _nt_comment_to_eol + start_index = index + if node_cache[:comment_to_eol].has_key?(index) + cached = node_cache[:comment_to_eol][index] + @index = cached.interval.end if cached + return cached + end + + i0, s0 = index, [] + if has_terminal?('#', false, index) + r1 = instantiate_node(SyntaxNode,input, index...(index + 1)) + @index += 1 + else + terminal_parse_failure('#') + r1 = nil + end + s0 << r1 + if r1 + s2, i2 = [], index + loop do + i3, s3 = index, [] + i4 = index + if has_terminal?("\n", false, index) + r5 = instantiate_node(SyntaxNode,input, index...(index + 1)) + @index += 1 + else + terminal_parse_failure("\n") + r5 = nil + end + if r5 + r4 = nil + else + @index = i4 + r4 = instantiate_node(SyntaxNode,input, index...index) + end + s3 << r4 + if r4 + if index < input_length + next_character = index + input[index..-1].match(/\A(.)/um).end(1) + r6 = instantiate_node(SyntaxNode,input, index...next_character) + @index = next_character + else + terminal_parse_failure("any character") + r6 = nil + end + s3 << r6 + end + if s3.last + r3 = instantiate_node(SyntaxNode,input, i3...index, s3) + r3.extend(CommentToEol0) + else + @index = i3 + r3 = nil + end + if r3 + s2 << r3 + else + break + end + end + r2 = instantiate_node(SyntaxNode,input, i2...index, s2) + s0 << r2 + end + if s0.last + r0 = instantiate_node(SyntaxNode,input, i0...index, s0) + r0.extend(CommentToEol1) + else + @index = i0 + r0 = nil + end + + node_cache[:comment_to_eol][start_index] = r0 + + r0 + end + + def _nt_white + start_index = index + if node_cache[:white].has_key?(index) + cached = node_cache[:white][index] + @index = cached.interval.end if cached + return cached + end + + if has_terminal?('\G[ \\t\\n\\r]', true, index) + next_character = index + input[index..-1].match(/\A(.)/um).end(1) + r0 = instantiate_node(SyntaxNode, input, index...next_character) + @index = next_character + else + r0 = nil + end + + node_cache[:white][start_index] = r0 + + r0 + end + + end + + class MetagrammarParser < Treetop::Runtime::CompiledParser + include Metagrammar + end + + end +end diff --git a/vendor/gems/gems/treetop-1.4.2/lib/treetop/compiler/metagrammar.treetop b/vendor/gems/gems/treetop-1.4.2/lib/treetop/compiler/metagrammar.treetop new file mode 100755 index 00000000..b55e0f11 --- /dev/null +++ b/vendor/gems/gems/treetop-1.4.2/lib/treetop/compiler/metagrammar.treetop @@ -0,0 +1,436 @@ +module Treetop + module Compiler + grammar Metagrammar + rule treetop_file + requires:(space? require_statement)* prefix:space? module_or_grammar:(module_declaration / grammar) suffix:space? { + def compile + requires.text_value + prefix.text_value + module_or_grammar.compile + suffix.text_value + end + } + end + + rule require_statement + prefix:space? "require" [ \t]+ [^\n\r]+ [\n\r] + end + + rule module_declaration + prefix:('module' space [A-Z] alphanumeric_char* space) module_contents:(module_declaration / grammar) suffix:(space 'end') { + def compile + prefix.text_value + module_contents.compile + suffix.text_value + end + } + end + + rule grammar + 'grammar' space grammar_name space ('do' space)? declaration_sequence space? 'end' + end + + rule grammar_name + ([A-Z] alphanumeric_char*) + end + + rule declaration_sequence + head:declaration tail:(space declaration)* { + def declarations + [head] + tail + end + + def tail + super.elements.map { |elt| elt.declaration } + end + } + / + '' { + def compile(builder) + end + } + end + + rule declaration + parsing_rule / include_declaration + end + + rule include_declaration + 'include' space [A-Z] (alphanumeric_char / '::')* { + def compile(builder) + builder << text_value + end + } + end + + rule parsing_rule + 'rule' space nonterminal space ('do' space)? parsing_expression space 'end' + end + + rule parsing_expression + choice / sequence / primary + end + + rule choice + head:alternative tail:(space? '/' space? alternative)+ { + def alternatives + [head] + tail + end + + def tail + super.elements.map {|elt| elt.alternative} + end + + def inline_modules + (alternatives.map {|alt| alt.inline_modules }).flatten + end + } + end + + rule sequence + head:labeled_sequence_primary tail:(space labeled_sequence_primary)+ node_class_declarations { + def sequence_elements + [head] + tail + end + + def tail + super.elements.map {|elt| elt.labeled_sequence_primary } + end + + def inline_modules + (sequence_elements.map {|elt| elt.inline_modules}).flatten + + [sequence_element_accessor_module] + + node_class_declarations.inline_modules + end + + def inline_module_name + node_class_declarations.inline_module_name + end + } + end + + rule alternative + sequence / primary + end + + rule primary + prefix atomic { + def compile(address, builder, parent_expression=nil) + prefix.compile(address, builder, self) + end + + def prefixed_expression + atomic + end + + def inline_modules + atomic.inline_modules + end + + def inline_module_name + nil + end + } + / + prefix space? predicate_block { + def compile(address, builder, parent_expression=nil) + prefix.compile(address, builder, self) + end + def prefixed_expression + predicate_block + end + def inline_modules + [] + end + } + / + atomic suffix node_class_declarations { + def compile(address, builder, parent_expression=nil) + suffix.compile(address, builder, self) + end + + def optional_expression + atomic + end + + def node_class_name + node_class_declarations.node_class_name + end + + def inline_modules + atomic.inline_modules + node_class_declarations.inline_modules + end + + def inline_module_name + node_class_declarations.inline_module_name + end + } + / + atomic node_class_declarations { + def compile(address, builder, parent_expression=nil) + atomic.compile(address, builder, self) + end + + def node_class_name + node_class_declarations.node_class_name + end + + def inline_modules + atomic.inline_modules + node_class_declarations.inline_modules + end + + def inline_module_name + node_class_declarations.inline_module_name + end + } + end + + rule labeled_sequence_primary + label sequence_primary { + def compile(lexical_address, builder) + sequence_primary.compile(lexical_address, builder) + end + + def inline_modules + sequence_primary.inline_modules + end + + def label_name + if label.name + label.name + elsif sequence_primary.instance_of?(Nonterminal) + sequence_primary.text_value + else + nil + end + end + } + end + + rule label + (alpha_char alphanumeric_char*) ':' { + def name + elements[0].text_value + end + } + / + '' { + def name + nil + end + } + end + + rule sequence_primary + prefix atomic { + def compile(lexical_address, builder) + prefix.compile(lexical_address, builder, self) + end + + def prefixed_expression + elements[1] + end + + def inline_modules + atomic.inline_modules + end + + def inline_module_name + nil + end + } + / + prefix space? predicate_block { + def compile(address, builder, parent_expression=nil) + prefix.compile(address, builder, self) + end + def prefixed_expression + predicate_block + end + def inline_modules + [] + end + } + / + atomic suffix { + def compile(lexical_address, builder) + suffix.compile(lexical_address, builder, self) + end + + def node_class_name + nil + end + + def inline_modules + atomic.inline_modules + end + + def inline_module_name + nil + end + } + / + atomic + end + + rule suffix + repetition_suffix / optional_suffix + end + + rule optional_suffix + '?' + end + + rule node_class_declarations + node_class_expression trailing_inline_module { + def node_class_name + node_class_expression.node_class_name + end + + def inline_modules + trailing_inline_module.inline_modules + end + + def inline_module + trailing_inline_module.inline_module + end + + def inline_module_name + inline_module.module_name if inline_module + end + } + end + + rule repetition_suffix + '+' / '*' + end + + rule prefix + '&' / '!' / '~' + end + + rule atomic + terminal + / + nonterminal + / + parenthesized_expression + end + + rule parenthesized_expression + '(' space? parsing_expression space? ')' { + def inline_modules + parsing_expression.inline_modules + end + } + end + + rule nonterminal + !keyword_inside_grammar (alpha_char alphanumeric_char*) + end + + rule terminal + quoted_string / character_class / anything_symbol + end + + rule quoted_string + (single_quoted_string / double_quoted_string) { + def string + super.text_value + end + } + end + + rule double_quoted_string + '"' string:(!'"' ("\\\\" / '\"' / .))* '"' + end + + rule single_quoted_string + "'" string:(!"'" ("\\\\" / "\\'" / .))* "'" + end + + rule character_class + '[' characters:(!']' ('\\' . /!'\\' .))+ ']' { + def characters + super.text_value + end + } + end + + rule anything_symbol + '.' + end + + rule node_class_expression + space '<' (!'>' .)+ '>' { + def node_class_name + elements[2].text_value + end + } + / + '' { + def node_class_name + nil + end + } + end + + rule trailing_inline_module + space inline_module { + def inline_modules + [inline_module] + end + + def inline_module_name + inline_module.module_name + end + } + / + '' { + def inline_modules + [] + end + + def inline_module + nil + end + + def inline_module_name + nil + end + } + end + + rule predicate_block + '' inline_module + end + + rule inline_module + '{' (inline_module / ![{}] .)* '}' + end + + rule keyword_inside_grammar + ('rule' / 'end') !non_space_char + end + + rule non_space_char + !space . + end + + rule alpha_char + [A-Za-z_] + end + + rule alphanumeric_char + alpha_char / [0-9] + end + + rule space + (white / comment_to_eol)+ + end + + rule comment_to_eol + '#' (!"\n" .)* + end + + rule white + [ \t\n\r] + end + end + end +end diff --git a/vendor/gems/gems/treetop-1.4.2/lib/treetop/compiler/node_classes.rb b/vendor/gems/gems/treetop-1.4.2/lib/treetop/compiler/node_classes.rb new file mode 100755 index 00000000..942b1bd4 --- /dev/null +++ b/vendor/gems/gems/treetop-1.4.2/lib/treetop/compiler/node_classes.rb @@ -0,0 +1,20 @@ +dir = File.dirname(__FILE__) +require File.join(dir, *%w[node_classes parsing_expression]) +require File.join(dir, *%w[node_classes atomic_expression]) +require File.join(dir, *%w[node_classes inline_module]) +require File.join(dir, *%w[node_classes predicate_block]) +require File.join(dir, *%w[node_classes treetop_file]) +require File.join(dir, *%w[node_classes grammar]) +require File.join(dir, *%w[node_classes declaration_sequence]) +require File.join(dir, *%w[node_classes parsing_rule]) +require File.join(dir, *%w[node_classes parenthesized_expression]) +require File.join(dir, *%w[node_classes nonterminal]) +require File.join(dir, *%w[node_classes terminal]) +require File.join(dir, *%w[node_classes anything_symbol]) +require File.join(dir, *%w[node_classes character_class]) +require File.join(dir, *%w[node_classes sequence]) +require File.join(dir, *%w[node_classes choice]) +require File.join(dir, *%w[node_classes repetition]) +require File.join(dir, *%w[node_classes optional]) +require File.join(dir, *%w[node_classes predicate]) +require File.join(dir, *%w[node_classes transient_prefix]) diff --git a/vendor/gems/gems/treetop-1.4.2/lib/treetop/compiler/node_classes/anything_symbol.rb b/vendor/gems/gems/treetop-1.4.2/lib/treetop/compiler/node_classes/anything_symbol.rb new file mode 100755 index 00000000..4f2c26c1 --- /dev/null +++ b/vendor/gems/gems/treetop-1.4.2/lib/treetop/compiler/node_classes/anything_symbol.rb @@ -0,0 +1,18 @@ +module Treetop + module Compiler + class AnythingSymbol < AtomicExpression + def compile(address, builder, parent_expression = nil) + super + builder.if__ "index < input_length" do + assign_result "instantiate_node(#{node_class_name},input, index...(index + 1))" + extend_result_with_inline_module + builder << "@index += 1" + end + builder.else_ do + builder << 'terminal_parse_failure("any character")' + assign_result 'nil' + end + end + end + end +end \ No newline at end of file diff --git a/vendor/gems/gems/treetop-1.4.2/lib/treetop/compiler/node_classes/atomic_expression.rb b/vendor/gems/gems/treetop-1.4.2/lib/treetop/compiler/node_classes/atomic_expression.rb new file mode 100755 index 00000000..7da74ddc --- /dev/null +++ b/vendor/gems/gems/treetop-1.4.2/lib/treetop/compiler/node_classes/atomic_expression.rb @@ -0,0 +1,14 @@ +module Treetop + module Compiler + class AtomicExpression < ParsingExpression + def inline_modules + [] + end + + def single_quote(string) + # Double any backslashes, then backslash any single-quotes: + "'#{string.gsub(/\\/) { '\\\\' }.gsub(/'/) { "\\'"}}'" + end + end + end +end diff --git a/vendor/gems/gems/treetop-1.4.2/lib/treetop/compiler/node_classes/character_class.rb b/vendor/gems/gems/treetop-1.4.2/lib/treetop/compiler/node_classes/character_class.rb new file mode 100755 index 00000000..c7d0dd65 --- /dev/null +++ b/vendor/gems/gems/treetop-1.4.2/lib/treetop/compiler/node_classes/character_class.rb @@ -0,0 +1,28 @@ +module Treetop + module Compiler + class CharacterClass < AtomicExpression + def compile(address, builder, parent_expression = nil) + super + + builder.if__ "has_terminal?(#{grounded_regexp(text_value)}, true, index)" do + if address == 0 || decorated? + assign_result "instantiate_node(#{node_class_name},input, index...(index + 1))" + extend_result_with_inline_module + else + assign_lazily_instantiated_node + end + builder << "@index += 1" + end + builder.else_ do + # "terminal_parse_failure(#{single_quote(characters)})" + assign_result 'nil' + end + end + + def grounded_regexp(string) + # Double any backslashes, then backslash any single-quotes: + "'\\G#{string.gsub(/\\/) { '\\\\' }.gsub(/'/) { "\\'"}}'" + end + end + end +end diff --git a/vendor/gems/gems/treetop-1.4.2/lib/treetop/compiler/node_classes/choice.rb b/vendor/gems/gems/treetop-1.4.2/lib/treetop/compiler/node_classes/choice.rb new file mode 100755 index 00000000..bd269a2d --- /dev/null +++ b/vendor/gems/gems/treetop-1.4.2/lib/treetop/compiler/node_classes/choice.rb @@ -0,0 +1,31 @@ +module Treetop + module Compiler + class Choice < ParsingExpression + def compile(address, builder, parent_expression = nil) + super + begin_comment(self) + use_vars :result, :start_index + compile_alternatives(alternatives) + end_comment(self) + end + + def compile_alternatives(alternatives) + obtain_new_subexpression_address + alternatives.first.compile(subexpression_address, builder) + builder.if__ subexpression_success? do + assign_result subexpression_result_var + extend_result_with_declared_module + extend_result_with_inline_module + end + builder.else_ do + if alternatives.size == 1 + reset_index + assign_failure start_index_var + else + compile_alternatives(alternatives[1..-1]) + end + end + end + end + end +end \ No newline at end of file diff --git a/vendor/gems/gems/treetop-1.4.2/lib/treetop/compiler/node_classes/declaration_sequence.rb b/vendor/gems/gems/treetop-1.4.2/lib/treetop/compiler/node_classes/declaration_sequence.rb new file mode 100755 index 00000000..a561d72a --- /dev/null +++ b/vendor/gems/gems/treetop-1.4.2/lib/treetop/compiler/node_classes/declaration_sequence.rb @@ -0,0 +1,24 @@ +module Treetop + module Compiler + class DeclarationSequence < Runtime::SyntaxNode + + def compile(builder) + unless rules.empty? + builder.method_declaration("root") do + builder << "@root || :#{rules.first.name}" + end + builder.newline + end + + declarations.each do |declaration| + declaration.compile(builder) + builder.newline + end + end + + def rules + declarations.select { |declaration| declaration.instance_of?(ParsingRule) } + end + end + end +end \ No newline at end of file diff --git a/vendor/gems/gems/treetop-1.4.2/lib/treetop/compiler/node_classes/grammar.rb b/vendor/gems/gems/treetop-1.4.2/lib/treetop/compiler/node_classes/grammar.rb new file mode 100755 index 00000000..41a205b7 --- /dev/null +++ b/vendor/gems/gems/treetop-1.4.2/lib/treetop/compiler/node_classes/grammar.rb @@ -0,0 +1,28 @@ +module Treetop + module Compiler + class Grammar < Runtime::SyntaxNode + def compile + builder = RubyBuilder.new + + builder.module_declaration "#{grammar_name.text_value}" do + builder.in(indent_level) # account for initial indentation of grammar declaration + builder << "include Treetop::Runtime" + builder.newline + declaration_sequence.compile(builder) + end + builder.newline + builder.class_declaration "#{parser_name} < Treetop::Runtime::CompiledParser" do + builder << "include #{grammar_name.text_value}" + end + end + + def indent_level + input.column_of(interval.begin) - 1 + end + + def parser_name + grammar_name.text_value + 'Parser' + end + end + end +end \ No newline at end of file diff --git a/vendor/gems/gems/treetop-1.4.2/lib/treetop/compiler/node_classes/inline_module.rb b/vendor/gems/gems/treetop-1.4.2/lib/treetop/compiler/node_classes/inline_module.rb new file mode 100755 index 00000000..3cb1ef0c --- /dev/null +++ b/vendor/gems/gems/treetop-1.4.2/lib/treetop/compiler/node_classes/inline_module.rb @@ -0,0 +1,27 @@ +module Treetop + module Compiler + module InlineModuleMixin + attr_reader :module_name + + def compile(index, builder, rule) + @module_name = "#{rule.name.treetop_camelize}#{index}" + end + end + + class InlineModule < Runtime::SyntaxNode + + include InlineModuleMixin + + def compile(index, builder, rule) + super + builder.module_declaration(module_name) do + builder << ruby_code.gsub(/\A\n/, '').rstrip + end + end + + def ruby_code + elements[1].text_value + end + end + end +end diff --git a/vendor/gems/gems/treetop-1.4.2/lib/treetop/compiler/node_classes/nonterminal.rb b/vendor/gems/gems/treetop-1.4.2/lib/treetop/compiler/node_classes/nonterminal.rb new file mode 100755 index 00000000..7421dbea --- /dev/null +++ b/vendor/gems/gems/treetop-1.4.2/lib/treetop/compiler/node_classes/nonterminal.rb @@ -0,0 +1,13 @@ +module Treetop + module Compiler + class Nonterminal < AtomicExpression + def compile(address, builder, parent_expression = nil) + super + use_vars :result + assign_result text_value == 'super' ? 'super' : "_nt_#{text_value}" + extend_result_with_declared_module + extend_result_with_inline_module + end + end + end +end \ No newline at end of file diff --git a/vendor/gems/gems/treetop-1.4.2/lib/treetop/compiler/node_classes/optional.rb b/vendor/gems/gems/treetop-1.4.2/lib/treetop/compiler/node_classes/optional.rb new file mode 100755 index 00000000..72d2bb9f --- /dev/null +++ b/vendor/gems/gems/treetop-1.4.2/lib/treetop/compiler/node_classes/optional.rb @@ -0,0 +1,19 @@ +module Treetop + module Compiler + class Optional < ParsingExpression + def compile(address, builder, parent_expression) + super + use_vars :result + obtain_new_subexpression_address + parent_expression.atomic.compile(subexpression_address, builder) + + builder.if__ subexpression_success? do + assign_result subexpression_result_var + end + builder.else_ do + assign_result epsilon_node + end + end + end + end +end \ No newline at end of file diff --git a/vendor/gems/gems/treetop-1.4.2/lib/treetop/compiler/node_classes/parenthesized_expression.rb b/vendor/gems/gems/treetop-1.4.2/lib/treetop/compiler/node_classes/parenthesized_expression.rb new file mode 100755 index 00000000..e58f8f92 --- /dev/null +++ b/vendor/gems/gems/treetop-1.4.2/lib/treetop/compiler/node_classes/parenthesized_expression.rb @@ -0,0 +1,9 @@ +module Treetop + module Compiler + class ParenthesizedExpression < ParsingExpression + def compile(address, builder, parent_expression = nil) + elements[2].compile(address, builder, parent_expression) + end + end + end +end \ No newline at end of file diff --git a/vendor/gems/gems/treetop-1.4.2/lib/treetop/compiler/node_classes/parsing_expression.rb b/vendor/gems/gems/treetop-1.4.2/lib/treetop/compiler/node_classes/parsing_expression.rb new file mode 100755 index 00000000..e67b84fc --- /dev/null +++ b/vendor/gems/gems/treetop-1.4.2/lib/treetop/compiler/node_classes/parsing_expression.rb @@ -0,0 +1,146 @@ +module Treetop + module Compiler + class ParsingExpression < Runtime::SyntaxNode + attr_reader :address, :builder, :subexpression_address, :var_symbols, :parent_expression + + def compile(address, builder, parent_expression) + @address = address + @builder = builder + @parent_expression = parent_expression + end + + def node_class_name + parent_expression && parent_expression.node_class_name || 'SyntaxNode' + end + + def declared_module_name + parent_expression && parent_expression.node_class_name + end + + def inline_module_name + parent_expression && parent_expression.inline_module_name + end + + def decorated? + parent_expression && (parent_expression.node_class_name || parent_expression.node_class_name || parent_expression.inline_module_name) + end + + def optional_arg(arg) + if arg + ", #{arg}" + else + '' + end + end + + def use_vars(*var_symbols) + @var_symbols = var_symbols + builder << var_initialization + end + + def result_var + var(:result) + end + + def accumulator_var + var(:accumulator) + end + + def start_index_var + var(:start_index) + end + + def subexpression_result_var + "r#{subexpression_address}" + end + + def subexpression_success? + subexpression_result_var + end + + def obtain_new_subexpression_address + @subexpression_address = builder.next_address + end + + def accumulate_subexpression_result + builder.accumulate accumulator_var, subexpression_result_var + end + + def assign_result(value_ruby) + builder.assign result_var, value_ruby + end + + def extend_result(module_name) + builder.extend result_var, module_name + end + + def extend_result_with_declared_module + extend_result declared_module_name if declared_module_name + end + + def extend_result_with_inline_module + extend_result inline_module_name if inline_module_name + end + + def reset_index + builder.assign '@index', start_index_var + end + + def epsilon_node + "instantiate_node(SyntaxNode,input, index...index)" + end + + def assign_failure(start_index_var) + assign_result("nil") + end + + def assign_lazily_instantiated_node + assign_result("true") + end + + def var_initialization + left, right = [], [] + var_symbols.each do |symbol| + if init_value(symbol) + left << var(symbol) + right << init_value(symbol) + end + end + if left.empty? + "" + else + left.join(', ') + ' = ' + right.join(', ') + end + end + + def var(var_symbol) + case var_symbol + when :result then "r#{address}" + when :accumulator then "s#{address}" + when :start_index then "i#{address}" + else raise "Unknown var symbol #{var_symbol}." + end + end + + def init_value(var_symbol) + case var_symbol + when :accumulator then '[]' + when :start_index then 'index' + else nil + end + end + + def begin_comment(expression) + #builder << "# begin #{on_one_line(expression)}" + end + + def end_comment(expression) + #builder << "# end #{on_one_line(expression)}" + end + + def on_one_line(expression) + expression.text_value.tr("\n", ' ') + end + end + end +end diff --git a/vendor/gems/gems/treetop-1.4.2/lib/treetop/compiler/node_classes/parsing_rule.rb b/vendor/gems/gems/treetop-1.4.2/lib/treetop/compiler/node_classes/parsing_rule.rb new file mode 100755 index 00000000..34bd8735 --- /dev/null +++ b/vendor/gems/gems/treetop-1.4.2/lib/treetop/compiler/node_classes/parsing_rule.rb @@ -0,0 +1,55 @@ +module Treetop + module Compiler + class ParsingRule < Runtime::SyntaxNode + + def compile(builder) + compile_inline_module_declarations(builder) + generate_method_definition(builder) + end + + def compile_inline_module_declarations(builder) + parsing_expression.inline_modules.each_with_index do |inline_module, i| + inline_module.compile(i, builder, self) + builder.newline + end + end + + def generate_method_definition(builder) + builder.reset_addresses + expression_address = builder.next_address + result_var = "r#{expression_address}" + + builder.method_declaration(method_name) do + builder.assign 'start_index', 'index' + generate_cache_lookup(builder) + builder.newline + parsing_expression.compile(expression_address, builder) + builder.newline + generate_cache_storage(builder, result_var) + builder.newline + builder << result_var + end + end + + def generate_cache_lookup(builder) + builder.if_ "node_cache[:#{name}].has_key?(index)" do + builder.assign 'cached', "node_cache[:#{name}][index]" + builder << '@index = cached.interval.end if cached' + builder << 'return cached' + end + end + + def generate_cache_storage(builder, result_var) + builder.assign "node_cache[:#{name}][start_index]", result_var + end + + def method_name + "_nt_#{name}" + end + + def name + nonterminal.text_value + end + end + end +end diff --git a/vendor/gems/gems/treetop-1.4.2/lib/treetop/compiler/node_classes/predicate.rb b/vendor/gems/gems/treetop-1.4.2/lib/treetop/compiler/node_classes/predicate.rb new file mode 100755 index 00000000..f80d06ed --- /dev/null +++ b/vendor/gems/gems/treetop-1.4.2/lib/treetop/compiler/node_classes/predicate.rb @@ -0,0 +1,45 @@ +module Treetop + module Compiler + class Predicate < ParsingExpression + def compile(address, builder, parent_expression) + super + begin_comment(parent_expression) + use_vars :result, :start_index + obtain_new_subexpression_address + parent_expression.prefixed_expression.compile(subexpression_address, builder) + builder.if__(subexpression_success?) { when_success } + builder.else_ { when_failure } + end_comment(parent_expression) + end + + def assign_failure + super(start_index_var) + end + + def assign_success + reset_index + assign_result epsilon_node + end + end + + class AndPredicate < Predicate + def when_success + assign_success + end + + def when_failure + assign_failure + end + end + + class NotPredicate < Predicate + def when_success + assign_failure + end + + def when_failure + assign_success + end + end + end +end \ No newline at end of file diff --git a/vendor/gems/gems/treetop-1.4.2/lib/treetop/compiler/node_classes/predicate_block.rb b/vendor/gems/gems/treetop-1.4.2/lib/treetop/compiler/node_classes/predicate_block.rb new file mode 100755 index 00000000..21cf6d1b --- /dev/null +++ b/vendor/gems/gems/treetop-1.4.2/lib/treetop/compiler/node_classes/predicate_block.rb @@ -0,0 +1,16 @@ +module Treetop + module Compiler + class PredicateBlock < ParsingExpression + def compile(index, builder, parent_expression = nil) + super + # REVISIT: This is distinctly dodgey, but since we can only be called from + # two contexts, and it works in both those, I'm going with it for now, as + # opposed to doing the major refactor of providing a proper way of accessing + # the parent's accumulator variable. + p = parent + p = p.parent while p && !p.respond_to?(:accumulator_var) + assign_result "lambda #{text_value}.call(#{p ? p.accumulator_var : ""})" + end + end + end +end diff --git a/vendor/gems/gems/treetop-1.4.2/lib/treetop/compiler/node_classes/repetition.rb b/vendor/gems/gems/treetop-1.4.2/lib/treetop/compiler/node_classes/repetition.rb new file mode 100755 index 00000000..2d7adc24 --- /dev/null +++ b/vendor/gems/gems/treetop-1.4.2/lib/treetop/compiler/node_classes/repetition.rb @@ -0,0 +1,55 @@ +module Treetop + module Compiler + class Repetition < ParsingExpression + def compile(address, builder, parent_expression) + super + repeated_expression = parent_expression.atomic + begin_comment(parent_expression) + use_vars :result, :accumulator, :start_index + + builder.loop do + obtain_new_subexpression_address + repeated_expression.compile(subexpression_address, builder) + builder.if__ subexpression_success? do + accumulate_subexpression_result + end + builder.else_ do + builder.break + end + end + end + + def inline_module_name + parent_expression.inline_module_name + end + + def assign_and_extend_result + assign_result "instantiate_node(#{node_class_name},input, #{start_index_var}...index, #{accumulator_var})" + extend_result_with_inline_module + end + end + + + class ZeroOrMore < Repetition + def compile(address, builder, parent_expression) + super + assign_and_extend_result + end_comment(parent_expression) + end + end + + class OneOrMore < Repetition + def compile(address, builder, parent_expression) + super + builder.if__ "#{accumulator_var}.empty?" do + reset_index + assign_failure start_index_var + end + builder.else_ do + assign_and_extend_result + end + end_comment(parent_expression) + end + end + end +end \ No newline at end of file diff --git a/vendor/gems/gems/treetop-1.4.2/lib/treetop/compiler/node_classes/sequence.rb b/vendor/gems/gems/treetop-1.4.2/lib/treetop/compiler/node_classes/sequence.rb new file mode 100755 index 00000000..1e5d7205 --- /dev/null +++ b/vendor/gems/gems/treetop-1.4.2/lib/treetop/compiler/node_classes/sequence.rb @@ -0,0 +1,71 @@ +module Treetop + module Compiler + class Sequence < ParsingExpression + def compile(address, builder, parent_expression = nil) + super + begin_comment(self) + use_vars :result, :start_index, :accumulator + compile_sequence_elements(sequence_elements) + builder.if__ "#{accumulator_var}.last" do + assign_result "instantiate_node(#{node_class_name},input, #{start_index_var}...index, #{accumulator_var})" + extend_result sequence_element_accessor_module_name if sequence_element_accessor_module_name + extend_result_with_inline_module + end + builder.else_ do + reset_index + assign_failure start_index_var + end + end_comment(self) + end + + def node_class_name + node_class_declarations.node_class_name || 'SyntaxNode' + end + + def compile_sequence_elements(elements) + obtain_new_subexpression_address + elements.first.compile(subexpression_address, builder) + accumulate_subexpression_result + if elements.size > 1 + builder.if_ subexpression_success? do + compile_sequence_elements(elements[1..-1]) + end + end + end + + def sequence_element_accessor_module + @sequence_element_accessor_module ||= SequenceElementAccessorModule.new(sequence_elements) + end + + def sequence_element_accessor_module_name + sequence_element_accessor_module.module_name + end + end + + class SequenceElementAccessorModule + include InlineModuleMixin + attr_reader :sequence_elements + + def initialize(sequence_elements) + @sequence_elements = sequence_elements + end + + def compile(index, builder, rule) + super + builder.module_declaration(module_name) do + elements_by_name = sequence_elements.inject({}){|h,e| (h[e.label_name.to_s] ||= []) << e; h} + sequence_elements.each_with_index do |element, index| + if element.label_name + repetitions = elements_by_name[element.label_name.to_s] + label_name = element.label_name + (repetitions.size > 1 ? (repetitions.index(element)+1).to_s : "") + builder.method_declaration(label_name) do + builder << "elements[#{index}]" + end + builder.newline unless index == sequence_elements.size - 1 + end + end + end + end + end + end +end diff --git a/vendor/gems/gems/treetop-1.4.2/lib/treetop/compiler/node_classes/terminal.rb b/vendor/gems/gems/treetop-1.4.2/lib/treetop/compiler/node_classes/terminal.rb new file mode 100755 index 00000000..e624115d --- /dev/null +++ b/vendor/gems/gems/treetop-1.4.2/lib/treetop/compiler/node_classes/terminal.rb @@ -0,0 +1,20 @@ +module Treetop + module Compiler + class Terminal < AtomicExpression + def compile(address, builder, parent_expression = nil) + super + string_length = eval(text_value).length + + builder.if__ "has_terminal?(#{text_value}, false, index)" do + assign_result "instantiate_node(#{node_class_name},input, index...(index + #{string_length}))" + extend_result_with_inline_module + builder << "@index += #{string_length}" + end + builder.else_ do + builder << "terminal_parse_failure(#{text_value})" + assign_result 'nil' + end + end + end + end +end \ No newline at end of file diff --git a/vendor/gems/gems/treetop-1.4.2/lib/treetop/compiler/node_classes/transient_prefix.rb b/vendor/gems/gems/treetop-1.4.2/lib/treetop/compiler/node_classes/transient_prefix.rb new file mode 100755 index 00000000..4bd24981 --- /dev/null +++ b/vendor/gems/gems/treetop-1.4.2/lib/treetop/compiler/node_classes/transient_prefix.rb @@ -0,0 +1,9 @@ +module Treetop + module Compiler + class TransientPrefix < ParsingExpression + def compile(address, builder, parent_expression) + parent_expression.prefixed_expression.compile(address, builder) + end + end + end +end \ No newline at end of file diff --git a/vendor/gems/gems/treetop-1.4.2/lib/treetop/compiler/node_classes/treetop_file.rb b/vendor/gems/gems/treetop-1.4.2/lib/treetop/compiler/node_classes/treetop_file.rb new file mode 100755 index 00000000..ada97507 --- /dev/null +++ b/vendor/gems/gems/treetop-1.4.2/lib/treetop/compiler/node_classes/treetop_file.rb @@ -0,0 +1,9 @@ +module Treetop + module Compiler + class TreetopFile < Runtime::SyntaxNode + def compile + (elements.map {|elt| elt.compile}).join + end + end + end +end \ No newline at end of file diff --git a/vendor/gems/gems/treetop-1.4.2/lib/treetop/compiler/ruby_builder.rb b/vendor/gems/gems/treetop-1.4.2/lib/treetop/compiler/ruby_builder.rb new file mode 100755 index 00000000..df37f069 --- /dev/null +++ b/vendor/gems/gems/treetop-1.4.2/lib/treetop/compiler/ruby_builder.rb @@ -0,0 +1,113 @@ +module Treetop + module Compiler + class RubyBuilder + + attr_reader :level, :address_space, :ruby + + def initialize + @level = 0 + @address_space = LexicalAddressSpace.new + @ruby = "" + end + + def <<(ruby_line) + return if ruby_line.blank? + ruby << ruby_line.tabto(level) << "\n" + end + + def newline + ruby << "\n" + end + + def indented(depth = 2) + self.in(depth) + yield + self.out(depth) + end + + def class_declaration(name, &block) + self << "class #{name}" + indented(&block) + self << "end" + end + + def module_declaration(name, &block) + self << "module #{name}" + indented(&block) + self << "end" + end + + def method_declaration(name, &block) + self << "def #{name}" + indented(&block) + self << "end" + end + + def assign(left, right) + if left.instance_of? Array + self << "#{left.join(', ')} = #{right.join(', ')}" + else + self << "#{left} = #{right}" + end + end + + def extend(var, module_name) + self << "#{var}.extend(#{module_name})" + end + + def accumulate(left, right) + self << "#{left} << #{right}" + end + + def if__(condition, &block) + self << "if #{condition}" + indented(&block) + end + + def if_(condition, &block) + if__(condition, &block) + self << 'end' + end + + def else_(&block) + self << 'else' + indented(&block) + self << 'end' + end + + def loop(&block) + self << 'loop do' + indented(&block) + self << 'end' + end + + def break + self << 'break' + end + + def in(depth = 2) + @level += depth + self + end + + def out(depth = 2) + @level -= depth + self + end + + def next_address + address_space.next_address + end + + def reset_addresses + address_space.reset_addresses + end + + private + + def indent + " " * level + end + end + end +end diff --git a/vendor/gems/gems/treetop-1.4.2/lib/treetop/ruby_extensions.rb b/vendor/gems/gems/treetop-1.4.2/lib/treetop/ruby_extensions.rb new file mode 100755 index 00000000..c271c7f9 --- /dev/null +++ b/vendor/gems/gems/treetop-1.4.2/lib/treetop/ruby_extensions.rb @@ -0,0 +1,2 @@ +dir = File.dirname(__FILE__) +require "#{dir}/ruby_extensions/string" \ No newline at end of file diff --git a/vendor/gems/gems/treetop-1.4.2/lib/treetop/ruby_extensions/string.rb b/vendor/gems/gems/treetop-1.4.2/lib/treetop/ruby_extensions/string.rb new file mode 100755 index 00000000..da342120 --- /dev/null +++ b/vendor/gems/gems/treetop-1.4.2/lib/treetop/ruby_extensions/string.rb @@ -0,0 +1,42 @@ +class String + def column_of(index) + return 1 if index == 0 + newline_index = rindex("\n", index - 1) + if newline_index + index - newline_index + else + index + 1 + end + end + + def line_of(index) + self[0...index].count("\n") + 1 + end + + unless method_defined?(:blank?) + def blank? + self == "" + end + end + + # The following methods are lifted from Facets 2.0.2 + def tabto(n) + if self =~ /^( *)\S/ + indent(n - $1.length) + else + self + end + end + + def indent(n) + if n >= 0 + gsub(/^/, ' ' * n) + else + gsub(/^ {0,#{-n}}/, "") + end + end + + def treetop_camelize + to_s.gsub(/\/(.?)/){ "::" + $1.upcase }.gsub(/(^|_)(.)/){ $2.upcase } + end +end \ No newline at end of file diff --git a/vendor/gems/gems/treetop-1.4.2/lib/treetop/runtime.rb b/vendor/gems/gems/treetop-1.4.2/lib/treetop/runtime.rb new file mode 100755 index 00000000..38a84f4b --- /dev/null +++ b/vendor/gems/gems/treetop-1.4.2/lib/treetop/runtime.rb @@ -0,0 +1,5 @@ +dir = File.dirname(__FILE__) +require "#{dir}/runtime/compiled_parser" +require "#{dir}/runtime/syntax_node" +require "#{dir}/runtime/terminal_parse_failure" +require "#{dir}/runtime/interval_skip_list" diff --git a/vendor/gems/gems/treetop-1.4.2/lib/treetop/runtime/compiled_parser.rb b/vendor/gems/gems/treetop-1.4.2/lib/treetop/runtime/compiled_parser.rb new file mode 100755 index 00000000..9cfde4f4 --- /dev/null +++ b/vendor/gems/gems/treetop-1.4.2/lib/treetop/runtime/compiled_parser.rb @@ -0,0 +1,109 @@ +module Treetop + module Runtime + class CompiledParser + include Treetop::Runtime + + attr_reader :input, :index, :max_terminal_failure_index + attr_writer :root + attr_accessor :consume_all_input + alias :consume_all_input? :consume_all_input + + def initialize + self.consume_all_input = true + end + + def parse(input, options = {}) + prepare_to_parse(input) + @index = options[:index] if options[:index] + result = send("_nt_#{root}") + return nil if (consume_all_input? && index != input.size) + return result + end + + def failure_index + max_terminal_failure_index + end + + def failure_line + @terminal_failures && input.line_of(failure_index) + end + + def failure_column + @terminal_failures && input.column_of(failure_index) + end + + def failure_reason + return nil unless (tf = terminal_failures) && tf.size > 0 + "Expected " + + (tf.size == 1 ? + tf[0].expected_string : + "one of #{tf.map{|f| f.expected_string}.uniq*', '}" + ) + + " at line #{failure_line}, column #{failure_column} (byte #{failure_index+1})" + + " after #{input[index...failure_index]}" + end + + def terminal_failures + @terminal_failures.map! {|tf_ary| TerminalParseFailure.new(*tf_ary) } + end + + + protected + + attr_reader :node_cache, :input_length + attr_writer :index + + def prepare_to_parse(input) + @input = input + @input_length = input.length + reset_index + @node_cache = Hash.new {|hash, key| hash[key] = Hash.new} + @regexps = {} + @terminal_failures = [] + @max_terminal_failure_index = 0 + end + + def reset_index + @index = 0 + end + + def parse_anything(node_class = SyntaxNode, inline_module = nil) + if index < input.length + result = instantiate_node(node_class,input, index...(index + 1)) + result.extend(inline_module) if inline_module + @index += 1 + result + else + terminal_parse_failure("any character") + end + end + + def instantiate_node(node_type,*args) + if node_type.respond_to? :new + node_type.new(*args) + else + SyntaxNode.new(*args).extend(node_type) + end + end + + def has_terminal?(terminal, regex, index) + if regex + rx = @regexps[terminal] ||= Regexp.new(terminal) + input.index(rx, index) == index + else + input[index, terminal.size] == terminal + end + end + + def terminal_parse_failure(expected_string) + return nil if index < max_terminal_failure_index + if index > max_terminal_failure_index + @max_terminal_failure_index = index + @terminal_failures = [] + end + @terminal_failures << [index, expected_string] + return nil + end + end + end +end diff --git a/vendor/gems/gems/treetop-1.4.2/lib/treetop/runtime/interval_skip_list.rb b/vendor/gems/gems/treetop-1.4.2/lib/treetop/runtime/interval_skip_list.rb new file mode 100755 index 00000000..8f34379d --- /dev/null +++ b/vendor/gems/gems/treetop-1.4.2/lib/treetop/runtime/interval_skip_list.rb @@ -0,0 +1,4 @@ +dir = File.dirname(__FILE__) +require "#{dir}/interval_skip_list/interval_skip_list.rb" +require "#{dir}/interval_skip_list/head_node.rb" +require "#{dir}/interval_skip_list/node.rb" \ No newline at end of file diff --git a/vendor/gems/gems/treetop-1.4.2/lib/treetop/runtime/interval_skip_list/head_node.rb b/vendor/gems/gems/treetop-1.4.2/lib/treetop/runtime/interval_skip_list/head_node.rb new file mode 100755 index 00000000..7cb0bab8 --- /dev/null +++ b/vendor/gems/gems/treetop-1.4.2/lib/treetop/runtime/interval_skip_list/head_node.rb @@ -0,0 +1,15 @@ +class IntervalSkipList + class HeadNode + attr_reader :height, :forward, :forward_markers + + def initialize(height) + @height = height + @forward = Array.new(height, nil) + @forward_markers = Array.new(height) {|i| []} + end + + def top_level + height - 1 + end + end +end \ No newline at end of file diff --git a/vendor/gems/gems/treetop-1.4.2/lib/treetop/runtime/interval_skip_list/interval_skip_list.rb b/vendor/gems/gems/treetop-1.4.2/lib/treetop/runtime/interval_skip_list/interval_skip_list.rb new file mode 100755 index 00000000..27b53e00 --- /dev/null +++ b/vendor/gems/gems/treetop-1.4.2/lib/treetop/runtime/interval_skip_list/interval_skip_list.rb @@ -0,0 +1,200 @@ +class IntervalSkipList + attr_reader :probability + + def initialize + @head = HeadNode.new(max_height) + @ranges = {} + @probability = 0.5 + end + + def max_height + 3 + end + + def empty? + head.forward[0].nil? + end + + def expire(range, length_change) + expired_markers, first_node_after_range = overlapping(range) + expired_markers.each { |marker| delete(marker) } + first_node_after_range.propagate_length_change(length_change) + end + + def overlapping(range) + markers, first_node = containing_with_node(range.first) + + cur_node = first_node + begin + markers.concat(cur_node.forward_markers.flatten) + cur_node = cur_node.forward[0] + end while cur_node.key < range.last + + return markers.uniq, cur_node + end + + def containing(n) + containing_with_node(n).first + end + + def insert(range, marker) + ranges[marker] = range + first_node = insert_node(range.first) + first_node.endpoint_of.push(marker) + last_node = insert_node(range.last) + last_node.endpoint_of.push(marker) + + cur_node = first_node + cur_level = first_node.top_level + while next_node_at_level_inside_range?(cur_node, cur_level, range) + while can_ascend_from?(cur_node, cur_level) && next_node_at_level_inside_range?(cur_node, cur_level + 1, range) + cur_level += 1 + end + cur_node = mark_forward_path_at_level(cur_node, cur_level, marker) + end + + while node_inside_range?(cur_node, range) + while can_descend_from?(cur_level) && next_node_at_level_outside_range?(cur_node, cur_level, range) + cur_level -= 1 + end + cur_node = mark_forward_path_at_level(cur_node, cur_level, marker) + end + end + + def delete(marker) + range = ranges[marker] + path_to_first_node = make_path + first_node = find(range.first, path_to_first_node) + + cur_node = first_node + cur_level = first_node.top_level + while next_node_at_level_inside_range?(cur_node, cur_level, range) + while can_ascend_from?(cur_node, cur_level) && next_node_at_level_inside_range?(cur_node, cur_level + 1, range) + cur_level += 1 + end + cur_node = unmark_forward_path_at_level(cur_node, cur_level, marker) + end + + while node_inside_range?(cur_node, range) + while can_descend_from?(cur_level) && next_node_at_level_outside_range?(cur_node, cur_level, range) + cur_level -= 1 + end + cur_node = unmark_forward_path_at_level(cur_node, cur_level, marker) + end + last_node = cur_node + + first_node.endpoint_of.delete(marker) + if first_node.endpoint_of.empty? + first_node.delete(path_to_first_node) + end + + last_node.endpoint_of.delete(marker) + if last_node.endpoint_of.empty? + path_to_last_node = make_path + find(range.last, path_to_last_node) + last_node.delete(path_to_last_node) + end + end + + protected + attr_reader :head, :ranges + + def insert_node(key) + path = make_path + found_node = find(key, path) + if found_node && found_node.key == key + return found_node + else + return Node.new(key, next_node_height, path) + end + end + + def containing_with_node(n) + containing = [] + cur_node = head + (max_height - 1).downto(0) do |cur_level| + while (next_node = cur_node.forward[cur_level]) && next_node.key <= n + cur_node = next_node + if cur_node.key == n + return containing + (cur_node.markers - cur_node.endpoint_of), cur_node + end + end + containing.concat(cur_node.forward_markers[cur_level]) + end + + return containing, cur_node + end + + def delete_node(key) + path = make_path + found_node = find(key, path) + found_node.delete(path) if found_node.key == key + end + + def find(key, path) + cur_node = head + (max_height - 1).downto(0) do |cur_level| + while (next_node = cur_node.forward[cur_level]) && next_node.key < key + cur_node = next_node + end + path[cur_level] = cur_node + end + cur_node.forward[0] + end + + def make_path + Array.new(max_height, nil) + end + + def next_node_height + height = 1 + while rand < probability && height < max_height + height += 1 + end + height + end + + def can_ascend_from?(node, level) + level < node.top_level + end + + def can_descend_from?(level) + level > 0 + end + + def node_inside_range?(node, range) + node.key < range.last + end + + def next_node_at_level_inside_range?(node, level, range) + node.forward[level] && node.forward[level].key <= range.last + end + + def next_node_at_level_outside_range?(node, level, range) + (node.forward[level].nil? || node.forward[level].key > range.last) + end + + def mark_forward_path_at_level(node, level, marker) + node.forward_markers[level].push(marker) + next_node = node.forward[level] + next_node.markers.push(marker) + node = next_node + end + + def unmark_forward_path_at_level(node, level, marker) + node.forward_markers[level].delete(marker) + next_node = node.forward[level] + next_node.markers.delete(marker) + node = next_node + end + + def nodes + nodes = [] + cur_node = head.forward[0] + until cur_node.nil? + nodes << cur_node + cur_node = cur_node.forward[0] + end + nodes + end +end \ No newline at end of file diff --git a/vendor/gems/gems/treetop-1.4.2/lib/treetop/runtime/interval_skip_list/node.rb b/vendor/gems/gems/treetop-1.4.2/lib/treetop/runtime/interval_skip_list/node.rb new file mode 100755 index 00000000..a53edb26 --- /dev/null +++ b/vendor/gems/gems/treetop-1.4.2/lib/treetop/runtime/interval_skip_list/node.rb @@ -0,0 +1,164 @@ +class IntervalSkipList + class Node < HeadNode + attr_accessor :key + attr_reader :markers, :endpoint_of + + def initialize(key, height, path) + super(height) + @key = key + @markers = [] + @endpoint_of = [] + update_forward_pointers(path) + promote_markers(path) + end + + def all_forward_markers + markers.flatten + end + + def delete(path) + 0.upto(top_level) do |i| + path[i].forward[i] = forward[i] + end + demote_markers(path) + end + + def propagate_length_change(length_change) + cur_node = self + while cur_node do + cur_node.key += length_change + cur_node = cur_node.forward[0] + end + end + + protected + + def update_forward_pointers(path) + 0.upto(top_level) do |i| + forward[i] = path[i].forward[i] + path[i].forward[i] = self + end + end + + def promote_markers(path) + promoted = [] + new_promoted = [] + 0.upto(top_level) do |i| + incoming_markers = path[i].forward_markers[i] + markers.concat(incoming_markers) + + incoming_markers.each do |marker| + if can_be_promoted_higher?(marker, i) + new_promoted.push(marker) + forward[i].delete_marker_from_path(marker, i, forward[i+1]) + else + forward_markers[i].push(marker) + end + end + + promoted.each do |marker| + if can_be_promoted_higher?(marker, i) + new_promoted.push(marker) + forward[i].delete_marker_from_path(marker, i, forward[i+1]) + else + forward_markers[i].push(marker) + end + end + + promoted = new_promoted + new_promoted = [] + end + end + + + def can_be_promoted_higher?(marker, level) + level < top_level && forward[level + 1] && forward[level + 1].markers.include?(marker) + end + + def delete_marker_from_path(marker, level, terminus) + cur_node = self + until cur_node == terminus + cur_node.forward_markers[level].delete(marker) + cur_node.markers.delete(marker) + cur_node = cur_node.forward[level] + end + end + + def demote_markers(path) + demote_inbound_markers(path) + demote_outbound_markers(path) + end + + def demote_inbound_markers(path) + demoted = [] + new_demoted = [] + + top_level.downto(0) do |i| + incoming_markers = path[i].forward_markers[i].dup + incoming_markers.each do |marker| + unless forward_node_with_marker_at_or_above_level?(marker, i) + path[i].forward_markers[i].delete(marker) + new_demoted.push(marker) + end + end + + demoted.each do |marker| + path[i + 1].place_marker_on_inbound_path(marker, i, path[i]) + + if forward[i].markers.include?(marker) + path[i].forward_markers[i].push(marker) + else + new_demoted.push(marker) + end + end + + demoted = new_demoted + new_demoted = [] + end + end + + def demote_outbound_markers(path) + demoted = [] + new_demoted = [] + + top_level.downto(0) do |i| + forward_markers[i].each do |marker| + new_demoted.push(marker) unless path[i].forward_markers[i].include?(marker) + end + + demoted.each do |marker| + forward[i].place_marker_on_outbound_path(marker, i, forward[i + 1]) + new_demoted.push(marker) unless path[i].forward_markers[i].include?(marker) + end + + demoted = new_demoted + new_demoted = [] + end + end + + def forward_node_with_marker_at_or_above_level?(marker, level) + level.upto(top_level) do |i| + return true if forward[i].markers.include?(marker) + end + false + end + + def place_marker_on_outbound_path(marker, level, terminus) + cur_node = self + until cur_node == terminus + cur_node.forward_markers[level].push(marker) + cur_node.markers.push(marker) + cur_node = cur_node.forward[level] + end + end + + def place_marker_on_inbound_path(marker, level, terminus) + cur_node = self + until cur_node == terminus + cur_node.forward_markers[level].push(marker) + cur_node = cur_node.forward[level] + cur_node.markers.push(marker) + end + end + end +end \ No newline at end of file diff --git a/vendor/gems/gems/treetop-1.4.2/lib/treetop/runtime/syntax_node.rb b/vendor/gems/gems/treetop-1.4.2/lib/treetop/runtime/syntax_node.rb new file mode 100755 index 00000000..9df471cc --- /dev/null +++ b/vendor/gems/gems/treetop-1.4.2/lib/treetop/runtime/syntax_node.rb @@ -0,0 +1,114 @@ +module Treetop + module Runtime + class SyntaxNode + attr_reader :input, :interval + attr_accessor :parent + attr_reader :dot_id + + @@dot_id_counter = 0 + + def initialize(input, interval, elements = nil) + @input = input + @interval = interval + @elements = elements + end + + def elements + return @elements if terminal? + # replace the character class placeholders in the sequence (lazy instantiation) + last_element = nil + @comprehensive_elements ||= @elements.map do |element| + if element == true + index = last_element ? last_element.interval.last : interval.first + element = SyntaxNode.new(input, index...(index + 1)) + end + element.parent = self + last_element = element + end + + @dot_id = @@dot_id_counter + @@dot_id_counter += 1 + + @comprehensive_elements + end + + def terminal? + @elements.nil? + end + + def nonterminal? + !terminal? + end + + def text_value + input[interval] + end + + def empty? + interval.first == interval.last && interval.exclude_end? + end + + def <=>(other) + self.interval.first <=> other.interval.first + end + + def extension_modules + local_extensions = + class < 0 + local_extensions + else + [] # There weren't any; must be a literal node + end + end + + def inspect(indent="") + em = extension_modules + interesting_methods = methods-[em.last ? em.last.methods : nil]-self.class.instance_methods + im = interesting_methods.size > 0 ? " (#{interesting_methods.join(",")})" : "" + tv = text_value + tv = "...#{tv[-20..-1]}" if tv.size > 20 + + indent + + self.class.to_s.sub(/.*:/,'') + + em.map{|m| "+"+m.to_s.sub(/.*:/,'')}*"" + + " offset=#{interval.first}" + + ", #{tv.inspect}" + + im + + (elements && elements.size > 0 ? + ":" + + (elements||[]).map{|e| + begin + "\n"+e.inspect(indent+" ") + rescue # Defend against inspect not taking a parameter + "\n"+indent+" "+e.inspect + end + }.join("") : + "" + ) + end + + def write_dot(io) + io.puts "node#{dot_id} [label=\"#{text_value}\"];" + if nonterminal? then + elements.each do + |x| + io.puts "node#{dot_id} -> node#{x.dot_id};" + x.write_dot(io) + end + end + end + + def write_dot_file(fname) + File.open(fname + ".dot","w") do + |file| + file.puts "digraph G {" + write_dot(file) + file.puts "}" + end + end + end + end +end diff --git a/vendor/gems/gems/treetop-1.4.2/lib/treetop/runtime/terminal_parse_failure.rb b/vendor/gems/gems/treetop-1.4.2/lib/treetop/runtime/terminal_parse_failure.rb new file mode 100755 index 00000000..b87bdbb1 --- /dev/null +++ b/vendor/gems/gems/treetop-1.4.2/lib/treetop/runtime/terminal_parse_failure.rb @@ -0,0 +1,16 @@ +module Treetop + module Runtime + class TerminalParseFailure + attr_reader :index, :expected_string + + def initialize(index, expected_string) + @index = index + @expected_string = expected_string + end + + def to_s + "String matching #{expected_string} expected." + end + end + end +end diff --git a/vendor/gems/gems/treetop-1.4.2/lib/treetop/runtime/terminal_parse_failure_debug.rb b/vendor/gems/gems/treetop-1.4.2/lib/treetop/runtime/terminal_parse_failure_debug.rb new file mode 100755 index 00000000..3b52ccaa --- /dev/null +++ b/vendor/gems/gems/treetop-1.4.2/lib/treetop/runtime/terminal_parse_failure_debug.rb @@ -0,0 +1,21 @@ +module Treetop + module Runtime + class TerminalParseFailure + attr_reader :index + + def initialize(index, expected_string) + @index = index + @caller = caller + @expected_string = expected_string + end + + def expected_string + "#{@expected_string} from #{@caller.map{|s| s.sub(/\A.*:([0-9]+):in `([^']*)'.*/,'\2:\1')}*" from "}\n\t" + end + + def to_s + "String matching #{expected_string} expected." + end + end + end +end diff --git a/vendor/gems/gems/treetop-1.4.2/lib/treetop/runtime/terminal_syntax_node.rb b/vendor/gems/gems/treetop-1.4.2/lib/treetop/runtime/terminal_syntax_node.rb new file mode 100755 index 00000000..06c68161 --- /dev/null +++ b/vendor/gems/gems/treetop-1.4.2/lib/treetop/runtime/terminal_syntax_node.rb @@ -0,0 +1,17 @@ +module Treetop + module Runtime + class TerminalSyntaxNode < SyntaxNode + + def initialize(input, interval) + super(input, interval, []) + end + + def inspect(indent="") + indent+ + self.class.to_s.sub(/.*:/,'') + + " offset=#{interval.first}" + + " #{text_value.inspect}" + end + end + end +end diff --git a/vendor/gems/gems/treetop-1.4.2/lib/treetop/version.rb b/vendor/gems/gems/treetop-1.4.2/lib/treetop/version.rb new file mode 100755 index 00000000..d033fff3 --- /dev/null +++ b/vendor/gems/gems/treetop-1.4.2/lib/treetop/version.rb @@ -0,0 +1,9 @@ +module Treetop #:nodoc: + module VERSION #:nodoc: + MAJOR = 1 + MINOR = 4 + TINY = 2 + + STRING = [MAJOR, MINOR, TINY].join('.') + end +end diff --git a/vendor/gems/gems/yui-compressor-0.9.1/Rakefile b/vendor/gems/gems/yui-compressor-0.9.1/Rakefile new file mode 100755 index 00000000..8a351b69 --- /dev/null +++ b/vendor/gems/gems/yui-compressor-0.9.1/Rakefile @@ -0,0 +1,21 @@ +require "rubygems" +require "rake/gempackagetask" +require "rake/rdoctask" +require "rake/testtask" + +task :default => :test + +Rake::TestTask.new do |t| + t.libs += ["lib", "test"] + t.test_files = FileList["test/*_test.rb"] + t.verbose = true +end + +Rake::RDocTask.new do |t| + t.rdoc_files.include("README.rdoc", "lib/**/*.rb") +end + +Rake::GemPackageTask.new(eval(IO.read(File.join(File.dirname(__FILE__), "yui-compressor.gemspec")))) do |pkg| + pkg.need_zip = true + pkg.need_tar = true +end diff --git a/vendor/gems/gems/yui-compressor-0.9.1/lib/yui/compressor.rb b/vendor/gems/gems/yui-compressor-0.9.1/lib/yui/compressor.rb new file mode 100755 index 00000000..da4d0c7a --- /dev/null +++ b/vendor/gems/gems/yui-compressor-0.9.1/lib/yui/compressor.rb @@ -0,0 +1,200 @@ +require "open3" +require "stringio" + +module YUI #:nodoc: + class Compressor + class Error < StandardError; end + class OptionError < Error; end + class RuntimeError < Error; end + + attr_reader :options, :command + + def self.default_options #:nodoc: + { :charset => "utf-8", :line_break => nil } + end + + def self.compressor_type #:nodoc: + raise Error, "create a CssCompressor or JavaScriptCompressor instead" + end + + def initialize(options = {}) #:nodoc: + @options = self.class.default_options.merge(options) + @command = [path_to_java, "-jar", path_to_jar_file, *(command_option_for_type + command_options)] + end + + # Compress a stream or string of code with YUI Compressor. (A stream is + # any object that responds to +read+ and +close+ like an IO.) If a block + # is given, you can read the compressed code from the block's argument. + # Otherwise, +compress+ returns a string of compressed code. + # + # ==== Example: Compress CSS + # compressor = YUI::CssCompressor.new + # compressor.compress(<<-END_CSS) + # div.error { + # color: red; + # } + # div.warning { + # display: none; + # } + # END_CSS + # # => "div.error{color:red;}div.warning{display:none;}" + # + # ==== Example: Compress JavaScript + # compressor = YUI::JavaScriptCompressor.new + # compressor.compress('(function () { var foo = {}; foo["bar"] = "baz"; })()') + # # => "(function(){var foo={};foo.bar=\"baz\"})();" + # + # ==== Example: Compress and gzip a file on disk + # File.open("my.js", "r") do |source| + # Zlib::GzipWriter.open("my.js.gz", "w") do |gzip| + # compressor.compress(source) do |compressed| + # while buffer = compressed.read(4096) + # gzip.write(buffer) + # end + # end + # end + # end + # + def compress(stream_or_string) + streamify(stream_or_string) do |stream| + Open3.popen3(*command) do |stdin, stdout, stderr| + begin + transfer(stream, stdin) + + if block_given? + yield stdout + else + stdout.read + end + + rescue Exception => e + raise RuntimeError, "compression failed" + end + end + end + end + + private + def command_options + options.inject([]) do |command_options, (name, argument)| + method = begin + method(:"command_option_for_#{name}") + rescue NameError + raise OptionError, "undefined option #{name.inspect}" + end + + command_options.concat(method.call(argument)) + end + end + + def path_to_java + options.delete(:java) || "java" + end + + def path_to_jar_file + options.delete(:jar_file) || File.join(File.dirname(__FILE__), *%w".. .. vendor yuicompressor-2.4.2.jar") + end + + def streamify(stream_or_string) + if stream_or_string.respond_to?(:read) + yield stream_or_string + else + yield StringIO.new(stream_or_string.to_s) + end + end + + def transfer(from_stream, to_stream) + while buffer = from_stream.read(4096) + to_stream.write(buffer) + end + to_stream.close + end + + def command_option_for_type + ["--type", self.class.compressor_type.to_s] + end + + def command_option_for_charset(charset) + ["--charset", charset.to_s] + end + + def command_option_for_line_break(line_break) + line_break ? ["--line-break", line_break.to_s] : [] + end + end + + class CssCompressor < Compressor + def self.compressor_type #:nodoc: + "css" + end + + # Creates a new YUI::CssCompressor for minifying CSS code. + # + # Options are: + # + # :charset:: Specifies the character encoding to use. Defaults to + # "utf-8". + # :line_break:: By default, CSS will be compressed onto a single + # line. Use this option to specify the maximum + # number of characters in each line before a newline + # is added. If :line_break is 0, a newline + # is added after each CSS rule. + # + def initialize(options = {}) + super + end + end + + class JavaScriptCompressor < Compressor + def self.compressor_type #:nodoc: + "js" + end + + def self.default_options #:nodoc: + super.merge( + :munge => false, + :optimize => true, + :preserve_semicolons => false + ) + end + + # Creates a new YUI::JavaScriptCompressor for minifying JavaScript code. + # + # Options are: + # + # :charset:: Specifies the character encoding to use. Defaults to + # "utf-8". + # :line_break:: By default, JavaScript will be compressed onto a + # single line. Use this option to specify the + # maximum number of characters in each line before a + # newline is added. If :line_break is 0, a + # newline is added after each JavaScript statement. + # :munge:: Specifies whether YUI Compressor should shorten local + # variable names when possible. Defaults to +false+. + # :optimize:: Specifies whether YUI Compressor should optimize + # JavaScript object property access and object literal + # declarations to use as few characters as possible. + # Defaults to +true+. + # :preserve_semicolons:: Defaults to +false+. If +true+, YUI + # Compressor will ensure semicolons exist + # after each statement to appease tools like + # JSLint. + # + def initialize(options = {}) + super + end + + private + def command_option_for_munge(munge) + munge ? [] : ["--nomunge"] + end + + def command_option_for_optimize(optimize) + optimize ? [] : ["--disable-optimizations"] + end + + def command_option_for_preserve_semicolons(preserve_semicolons) + preserve_semicolons ? ["--preserve-semi"] : [] + end + end +end diff --git a/vendor/gems/gems/yui-compressor-0.9.1/test/compressor_test.rb b/vendor/gems/gems/yui-compressor-0.9.1/test/compressor_test.rb new file mode 100755 index 00000000..f5bba625 --- /dev/null +++ b/vendor/gems/gems/yui-compressor-0.9.1/test/compressor_test.rb @@ -0,0 +1,94 @@ +require "test/unit" +require "yui/compressor" + +module YUI + class CompressorTest < Test::Unit::TestCase + FIXTURE_CSS = <<-END_CSS + div.warning { + display: none; + } + + div.error { + background: red; + color: white; + } + END_CSS + + FIXTURE_JS = <<-END_JS + // here's a comment + var Foo = { "a": 1 }; + Foo["bar"] = (function(baz) { + /* here's a + multiline comment */ + if (false) { + doSomething(); + } else { + for (var index = 0; index < baz.length; index++) { + doSomething(baz[index]); + } + } + })("hello"); + END_JS + + def test_compressor_should_raise_when_instantiated + assert_raises YUI::Compressor::Error do + YUI::Compressor.new + end + end + + def test_css_should_be_compressed + @compressor = YUI::CssCompressor.new + assert_equal "div.warning{display:none;}div.error{background:red;color:white;}", @compressor.compress(FIXTURE_CSS) + end + + def test_js_should_be_compressed + @compressor = YUI::JavaScriptCompressor.new + assert_equal "var Foo={a:1};Foo.bar=(function(baz){if(false){doSomething()}else{for(var index=0;index "bar") + @compressor.compress(FIXTURE_JS) + end + end + + def test_compress_should_accept_an_io_argument + @compressor = YUI::CssCompressor.new + assert_equal "div.warning{display:none;}div.error{background:red;color:white;}", @compressor.compress(StringIO.new(FIXTURE_CSS)) + end + + def test_compress_should_accept_a_block_and_yield_an_io + @compressor = YUI::CssCompressor.new + @compressor.compress(FIXTURE_CSS) do |stream| + assert_kind_of IO, stream + assert_equal "div.warning{display:none;}div.error{background:red;color:white;}", stream.read + end + end + + def test_line_break_option_should_insert_line_breaks_in_css + @compressor = YUI::CssCompressor.new(:line_break => 0) + assert_equal "div.warning{display:none;}\ndiv.error{background:red;color:white;}", @compressor.compress(FIXTURE_CSS) + end + + def test_line_break_option_should_insert_line_breaks_in_js + @compressor = YUI::JavaScriptCompressor.new(:line_break => 0) + assert_equal "var Foo={a:1};\nFoo.bar=(function(baz){if(false){doSomething()\n}else{for(var index=0;\nindex true) + assert_equal "var Foo={a:1};Foo.bar=(function(b){if(false){doSomething()}else{for(var a=0;a false) + assert_equal "var Foo={\"a\":1};Foo[\"bar\"]=(function(baz){if(false){doSomething()}else{for(var index=0;index true) + assert_equal "var Foo={a:1};Foo.bar=(function(baz){if(false){doSomething();}else{for(var index=0;index 0.0.0") + s.rubygems_version = %q{1.3.5} + s.summary = %q{Builders for MarkUp.} + s.test_files = ["test/test_xchar.rb", "test/testblankslate.rb", "test/testeventbuilder.rb", "test/testmarkupbuilder.rb"] + + if s.respond_to? :specification_version then + current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION + s.specification_version = 1 + + if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then + else + end + else + end +end diff --git a/vendor/gems/specifications/compass-0.8.17.gemspec b/vendor/gems/specifications/compass-0.8.17.gemspec new file mode 100755 index 00000000..09b7fd42 --- /dev/null +++ b/vendor/gems/specifications/compass-0.8.17.gemspec @@ -0,0 +1,36 @@ +# -*- encoding: utf-8 -*- + +Gem::Specification.new do |s| + s.name = %q{compass} + s.version = "0.8.17" + + s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version= + s.authors = ["Chris Eppstein"] + s.date = %q{2009-09-24} + s.default_executable = %q{compass} + s.description = %q{Compass is a Sass-based Stylesheet Framework that streamlines the creation and maintainance of CSS.} + s.email = %q{chris@eppsteins.net} + s.executables = ["compass"] + s.extra_rdoc_files = ["LICENSE.markdown", "README.markdown"] + s.files = ["CHANGELOG.markdown", "LICENSE.markdown", "README.markdown", "REVISION", "Rakefile", "VERSION.yml", "bin/compass", "deps.rip", "examples/README.markdown", "examples/blueprint_default/config.rb", "examples/blueprint_default/images/grid.png", "examples/blueprint_default/index.html.haml", "examples/blueprint_default/parts/elements.html.haml", "examples/blueprint_default/parts/forms.html.haml", "examples/blueprint_default/parts/grid.html.haml", "examples/blueprint_default/parts/test-small.jpg", "examples/blueprint_default/parts/test.jpg", "examples/blueprint_default/parts/valid.png", "examples/blueprint_default/src/ie.sass", "examples/blueprint_default/src/images/grid.png", "examples/blueprint_default/src/print.sass", "examples/blueprint_default/src/screen.sass", "examples/blueprint_plugins/config.rb", "examples/blueprint_plugins/images/buttons/cross.png", "examples/blueprint_plugins/images/buttons/key.png", "examples/blueprint_plugins/images/buttons/tick.png", "examples/blueprint_plugins/images/grid.png", "examples/blueprint_plugins/images/link_icons/doc.png", "examples/blueprint_plugins/images/link_icons/email.png", "examples/blueprint_plugins/images/link_icons/external.png", "examples/blueprint_plugins/images/link_icons/feed.png", "examples/blueprint_plugins/images/link_icons/im.png", "examples/blueprint_plugins/images/link_icons/pdf.png", "examples/blueprint_plugins/images/link_icons/visited.png", "examples/blueprint_plugins/images/link_icons/xls.png", "examples/blueprint_plugins/images/test-small.jpg", "examples/blueprint_plugins/images/test.jpg", "examples/blueprint_plugins/images/valid.png", "examples/blueprint_plugins/index.html.haml", "examples/blueprint_plugins/plugins/buttons.html.haml", "examples/blueprint_plugins/plugins/fancy_type.html.haml", "examples/blueprint_plugins/plugins/link_icons.html.haml", "examples/blueprint_plugins/plugins/rtl.html.haml", "examples/blueprint_plugins/src/buttons.sass", "examples/blueprint_plugins/src/ie.sass", "examples/blueprint_plugins/src/images/grid.png", "examples/blueprint_plugins/src/link_icons.sass", "examples/blueprint_plugins/src/print.sass", "examples/blueprint_plugins/src/rtl_screen.sass", "examples/blueprint_plugins/src/screen.sass", "examples/blueprint_scoped/images/grid.png", "examples/blueprint_scoped/src/ie.sass", "examples/blueprint_scoped/src/print.sass", "examples/blueprint_scoped/src/screen.sass", "examples/blueprint_scoped_form/images/grid.png", "examples/blueprint_scoped_form/src/ie.sass", "examples/blueprint_scoped_form/src/print.sass", "examples/blueprint_scoped_form/src/screen.sass", "examples/blueprint_semantic/config.rb", "examples/blueprint_semantic/images/grid.png", "examples/blueprint_semantic/index.html.haml", "examples/blueprint_semantic/parts/fancy_type.html.haml", "examples/blueprint_semantic/parts/liquid.html.haml", "examples/blueprint_semantic/parts/test-small.jpg", "examples/blueprint_semantic/parts/test.jpg", "examples/blueprint_semantic/parts/valid.png", "examples/blueprint_semantic/src/ie.sass", "examples/blueprint_semantic/src/images/grid.png", "examples/blueprint_semantic/src/liquid.sass", "examples/blueprint_semantic/src/print.sass", "examples/blueprint_semantic/src/screen.sass", "examples/compass/compass.html.haml", "examples/compass/config.rb", "examples/compass/images/blue_arrow.gif", "examples/compass/src/compass.sass", "examples/compass/src/images/blue_arrow.gif", "examples/compass/src/sticky_footer.sass", "examples/compass/src/utilities.sass", "examples/compass/sticky_footer.html.haml", "examples/compass/utilities.html.haml", "examples/logo/logo.html.haml", "examples/logo/src/ie.sass", "examples/logo/src/print.sass", "examples/logo/src/screen.sass", "examples/yui/divisions.html.haml", "examples/yui/index.html.haml", "examples/yui/src/screen.sass", "examples/yui/sub_divisions.html.haml", "examples/yui/templates.html.haml", "examples/yui/test.jpg", "examples/yui/typography.html.haml", "frameworks/blueprint.rb", "frameworks/blueprint/stylesheets/_blueprint.sass", "frameworks/blueprint/stylesheets/blueprint/_ie.sass", "frameworks/blueprint/stylesheets/blueprint/_print.sass", "frameworks/blueprint/stylesheets/blueprint/_reset.sass", "frameworks/blueprint/stylesheets/blueprint/_screen.sass", "frameworks/blueprint/stylesheets/blueprint/modules/_buttons.sass", "frameworks/blueprint/stylesheets/blueprint/modules/_colors.sass", "frameworks/blueprint/stylesheets/blueprint/modules/_debug.sass", "frameworks/blueprint/stylesheets/blueprint/modules/_fancy_type.sass", "frameworks/blueprint/stylesheets/blueprint/modules/_form.sass", "frameworks/blueprint/stylesheets/blueprint/modules/_grid.sass", "frameworks/blueprint/stylesheets/blueprint/modules/_interaction.sass", "frameworks/blueprint/stylesheets/blueprint/modules/_link_icons.sass", "frameworks/blueprint/stylesheets/blueprint/modules/_liquid.sass", "frameworks/blueprint/stylesheets/blueprint/modules/_reset.sass", "frameworks/blueprint/stylesheets/blueprint/modules/_rtl.sass", "frameworks/blueprint/stylesheets/blueprint/modules/_scaffolding.sass", "frameworks/blueprint/stylesheets/blueprint/modules/_typography.sass", "frameworks/blueprint/stylesheets/blueprint/modules/_utilities.sass", "frameworks/blueprint/templates/buttons/buttons.sass", "frameworks/blueprint/templates/buttons/buttons/cross.png", "frameworks/blueprint/templates/buttons/buttons/key.png", "frameworks/blueprint/templates/buttons/buttons/tick.png", "frameworks/blueprint/templates/buttons/manifest.rb", "frameworks/blueprint/templates/link_icons/link_icons.sass", "frameworks/blueprint/templates/link_icons/link_icons/doc.png", "frameworks/blueprint/templates/link_icons/link_icons/email.png", "frameworks/blueprint/templates/link_icons/link_icons/external.png", "frameworks/blueprint/templates/link_icons/link_icons/feed.png", "frameworks/blueprint/templates/link_icons/link_icons/im.png", "frameworks/blueprint/templates/link_icons/link_icons/pdf.png", "frameworks/blueprint/templates/link_icons/link_icons/visited.png", "frameworks/blueprint/templates/link_icons/link_icons/xls.png", "frameworks/blueprint/templates/link_icons/manifest.rb", "frameworks/blueprint/templates/project/grid.png", "frameworks/blueprint/templates/project/ie.sass", "frameworks/blueprint/templates/project/manifest.rb", "frameworks/blueprint/templates/project/partials/_base.sass", "frameworks/blueprint/templates/project/print.sass", "frameworks/blueprint/templates/project/screen.sass", "frameworks/compass.rb", "frameworks/compass/stylesheets/_compass.sass", "frameworks/compass/stylesheets/compass/_layout.sass", "frameworks/compass/stylesheets/compass/_misc.sass", "frameworks/compass/stylesheets/compass/_reset.sass", "frameworks/compass/stylesheets/compass/_utilities.sass", "frameworks/compass/stylesheets/compass/layout/_sticky_footer.sass", "frameworks/compass/stylesheets/compass/utilities/_general.sass", "frameworks/compass/stylesheets/compass/utilities/_links.sass", "frameworks/compass/stylesheets/compass/utilities/_lists.sass", "frameworks/compass/stylesheets/compass/utilities/_print.sass", "frameworks/compass/stylesheets/compass/utilities/_sprites.sass", "frameworks/compass/stylesheets/compass/utilities/_tables.sass", "frameworks/compass/stylesheets/compass/utilities/_text.sass", "frameworks/compass/stylesheets/compass/utilities/general/_clearfix.sass", "frameworks/compass/stylesheets/compass/utilities/general/_float.sass", "frameworks/compass/stylesheets/compass/utilities/general/_hacks.sass", "frameworks/compass/stylesheets/compass/utilities/general/_inline_block.sass", "frameworks/compass/stylesheets/compass/utilities/general/_reset.sass", "frameworks/compass/stylesheets/compass/utilities/general/_tabs.sass", "frameworks/compass/stylesheets/compass/utilities/general/_tag_cloud.sass", "frameworks/compass/stylesheets/compass/utilities/links/_hover_link.sass", "frameworks/compass/stylesheets/compass/utilities/links/_link_colors.sass", "frameworks/compass/stylesheets/compass/utilities/links/_unstyled_link.sass", "frameworks/compass/stylesheets/compass/utilities/lists/_bullets.sass", "frameworks/compass/stylesheets/compass/utilities/lists/_horizontal_list.sass", "frameworks/compass/stylesheets/compass/utilities/lists/_inline_list.sass", "frameworks/compass/stylesheets/compass/utilities/sprites/_sprite_img.sass", "frameworks/compass/stylesheets/compass/utilities/tables/_alternating_rows_and_columns.sass", "frameworks/compass/stylesheets/compass/utilities/tables/_borders.sass", "frameworks/compass/stylesheets/compass/utilities/tables/_scaffolding.sass", "frameworks/compass/stylesheets/compass/utilities/text/_ellipsis.sass", "frameworks/compass/stylesheets/compass/utilities/text/_nowrap.sass", "frameworks/compass/stylesheets/compass/utilities/text/_replacement.sass", "frameworks/compass/templates/ellipsis/ellipsis.sass", "frameworks/compass/templates/ellipsis/manifest.rb", "frameworks/compass/templates/ellipsis/xml/ellipsis.xml", "frameworks/compass/templates/project/ie.sass", "frameworks/compass/templates/project/manifest.rb", "frameworks/compass/templates/project/print.sass", "frameworks/compass/templates/project/screen.sass", "frameworks/yui.rb", "frameworks/yui/stylesheets/_yui.sass", "frameworks/yui/stylesheets/yui/modules/_base.sass", "frameworks/yui/stylesheets/yui/modules/_fonts.sass", "frameworks/yui/stylesheets/yui/modules/_grids.sass", "frameworks/yui/stylesheets/yui/modules/_reset.sass", "frameworks/yui/templates/project/manifest.rb", "frameworks/yui/templates/project/screen.sass", "lib/compass.rb", "lib/compass/actions.rb", "lib/compass/app_integration.rb", "lib/compass/app_integration/merb.rb", "lib/compass/app_integration/rails.rb", "lib/compass/app_integration/rails/action_controller.rb", "lib/compass/app_integration/rails/sass_plugin.rb", "lib/compass/app_integration/rails/templates/compass-install-rails.rb", "lib/compass/app_integration/rails/urls.rb", "lib/compass/commands/base.rb", "lib/compass/commands/create_project.rb", "lib/compass/commands/generate_grid_background.rb", "lib/compass/commands/installer_command.rb", "lib/compass/commands/list_frameworks.rb", "lib/compass/commands/print_version.rb", "lib/compass/commands/project_base.rb", "lib/compass/commands/stamp_pattern.rb", "lib/compass/commands/update_project.rb", "lib/compass/commands/validate_project.rb", "lib/compass/commands/watch_project.rb", "lib/compass/commands/write_configuration.rb", "lib/compass/compiler.rb", "lib/compass/configuration.rb", "lib/compass/core_ext.rb", "lib/compass/dependencies.rb", "lib/compass/errors.rb", "lib/compass/exec.rb", "lib/compass/frameworks.rb", "lib/compass/grid_builder.rb", "lib/compass/installers.rb", "lib/compass/installers/base.rb", "lib/compass/installers/manifest.rb", "lib/compass/installers/rails.rb", "lib/compass/installers/stand_alone.rb", "lib/compass/logger.rb", "lib/compass/sass_extensions.rb", "lib/compass/sass_extensions/functions.rb", "lib/compass/sass_extensions/functions/display.rb", "lib/compass/sass_extensions/functions/enumerate.rb", "lib/compass/sass_extensions/functions/inline_image.rb", "lib/compass/sass_extensions/functions/selectors.rb", "lib/compass/sass_extensions/functions/urls.rb", "lib/compass/sass_extensions/monkey_patches.rb", "lib/compass/sass_extensions/monkey_patches/stylesheet_updating.rb", "lib/compass/test_case.rb", "lib/compass/validator.rb", "lib/compass/version.rb", "lib/vendor/fssm.rb", "lib/vendor/fssm/backends/fsevents.rb", "lib/vendor/fssm/backends/polling.rb", "lib/vendor/fssm/cache.rb", "lib/vendor/fssm/ext.rb", "lib/vendor/fssm/fsevents.rb", "lib/vendor/fssm/monitor.rb", "lib/vendor/fssm/path.rb", "lib/vendor/fssm/state.rb", "lib/vendor/fssm/support.rb", "lib/vendor/fssm/tree.rb", "test/command_line_helper.rb", "test/command_line_test.rb", "test/compass_test.rb", "test/configuration_test.rb", "test/fixtures/stylesheets/blueprint/config.rb", "test/fixtures/stylesheets/blueprint/css/typography.css", "test/fixtures/stylesheets/blueprint/images/grid.png", "test/fixtures/stylesheets/blueprint/sass/ie.sass", "test/fixtures/stylesheets/blueprint/sass/print.sass", "test/fixtures/stylesheets/blueprint/sass/screen.sass", "test/fixtures/stylesheets/blueprint/sass/typography.sass", "test/fixtures/stylesheets/compass/config.rb", "test/fixtures/stylesheets/compass/css/layout.css", "test/fixtures/stylesheets/compass/css/print.css", "test/fixtures/stylesheets/compass/css/reset.css", "test/fixtures/stylesheets/compass/css/utilities.css", "test/fixtures/stylesheets/compass/sass/layout.sass", "test/fixtures/stylesheets/compass/sass/print.sass", "test/fixtures/stylesheets/compass/sass/reset.sass", "test/fixtures/stylesheets/compass/sass/utilities.sass", "test/fixtures/stylesheets/image_urls/config.rb", "test/fixtures/stylesheets/image_urls/css/screen.css", "test/fixtures/stylesheets/image_urls/images/grid.png", "test/fixtures/stylesheets/image_urls/sass/screen.sass", "test/fixtures/stylesheets/yui/config.rb", "test/fixtures/stylesheets/yui/css/mixins.css", "test/fixtures/stylesheets/yui/sass/base.sass", "test/fixtures/stylesheets/yui/sass/fonts.sass", "test/fixtures/stylesheets/yui/sass/grids.sass", "test/fixtures/stylesheets/yui/sass/mixins.sass", "test/rails_integration_test.rb", "test/sass_extensions_test.rb", "test/test_case_helper.rb", "test/test_helper.rb", "test/test_rails_helper.rb"] + s.homepage = %q{http://compass-style.org} + s.rdoc_options = ["--charset=UTF-8"] + s.require_paths = ["lib"] + s.rubyforge_project = %q{compass} + s.rubygems_version = %q{1.3.5} + s.summary = %q{A Real Stylesheet Framework} + s.test_files = ["test/command_line_helper.rb", "test/command_line_test.rb", "test/compass_test.rb", "test/configuration_test.rb", "test/fixtures/stylesheets/blueprint/config.rb", "test/fixtures/stylesheets/blueprint/css/typography.css", "test/fixtures/stylesheets/blueprint/images/grid.png", "test/fixtures/stylesheets/blueprint/sass/ie.sass", "test/fixtures/stylesheets/blueprint/sass/print.sass", "test/fixtures/stylesheets/blueprint/sass/screen.sass", "test/fixtures/stylesheets/blueprint/sass/typography.sass", "test/fixtures/stylesheets/compass/config.rb", "test/fixtures/stylesheets/compass/css/layout.css", "test/fixtures/stylesheets/compass/css/print.css", "test/fixtures/stylesheets/compass/css/reset.css", "test/fixtures/stylesheets/compass/css/utilities.css", "test/fixtures/stylesheets/compass/sass/layout.sass", "test/fixtures/stylesheets/compass/sass/print.sass", "test/fixtures/stylesheets/compass/sass/reset.sass", "test/fixtures/stylesheets/compass/sass/utilities.sass", "test/fixtures/stylesheets/image_urls/config.rb", "test/fixtures/stylesheets/image_urls/css/screen.css", "test/fixtures/stylesheets/image_urls/images/grid.png", "test/fixtures/stylesheets/image_urls/sass/screen.sass", "test/fixtures/stylesheets/yui/config.rb", "test/fixtures/stylesheets/yui/css/mixins.css", "test/fixtures/stylesheets/yui/sass/base.sass", "test/fixtures/stylesheets/yui/sass/fonts.sass", "test/fixtures/stylesheets/yui/sass/grids.sass", "test/fixtures/stylesheets/yui/sass/mixins.sass", "test/rails_integration_test.rb", "test/sass_extensions_test.rb", "test/test_case_helper.rb", "test/test_helper.rb", "test/test_rails_helper.rb"] + + if s.respond_to? :specification_version then + current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION + s.specification_version = 3 + + if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then + s.add_runtime_dependency(%q, [">= 2.2.0"]) + else + s.add_dependency(%q, [">= 2.2.0"]) + end + else + s.add_dependency(%q, [">= 2.2.0"]) + end +end diff --git a/vendor/gems/specifications/configuration-1.1.0.gemspec b/vendor/gems/specifications/configuration-1.1.0.gemspec new file mode 100755 index 00000000..cc56d537 --- /dev/null +++ b/vendor/gems/specifications/configuration-1.1.0.gemspec @@ -0,0 +1,27 @@ +# -*- encoding: utf-8 -*- + +Gem::Specification.new do |s| + s.name = %q{configuration} + s.version = "1.1.0" + + s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version= + s.authors = ["Ara T. Howard"] + s.date = %q{2009-09-22} + s.email = %q{ara.t.howard@gmail.com} + s.files = ["config", "config/a.rb", "config/b.rb", "config/c.rb", "config/d.rb", "config/e.rb", "configuration.gemspec", "lib", "lib/configuration.rb", "Rakefile", "README", "README.erb", "samples", "samples/a.rb", "samples/b.rb", "samples/c.rb", "samples/d.rb", "samples/e.rb"] + s.homepage = %q{http://github.com/ahoward/configuration/tree/master} + s.require_paths = ["lib"] + s.rubyforge_project = %q{codeforpeople} + s.rubygems_version = %q{1.3.5} + s.summary = %q{configuration} + + if s.respond_to? :specification_version then + current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION + s.specification_version = 2 + + if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then + else + end + else + end +end diff --git a/vendor/gems/specifications/cucumber-0.4.4.gemspec b/vendor/gems/specifications/cucumber-0.4.4.gemspec new file mode 100755 index 00000000..fc8749d2 --- /dev/null +++ b/vendor/gems/specifications/cucumber-0.4.4.gemspec @@ -0,0 +1,72 @@ +# -*- encoding: utf-8 -*- + +Gem::Specification.new do |s| + s.name = %q{cucumber} + s.version = "0.4.4" + + s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version= + s.authors = ["Aslak Helles\303\270y"] + s.date = %q{2009-11-12} + s.default_executable = %q{cucumber} + s.description = %q{A BDD tool written in Ruby} + s.email = %q{cukes@googlegroups.com} + s.executables = ["cucumber"] + s.extra_rdoc_files = ["LICENSE", "README.rdoc"] + s.files = [".gitattributes", ".gitignore", "History.txt", "LICENSE", "Manifest.txt", "README.rdoc", "Rakefile", "VERSION.yml", "bin/cucumber", "cucumber.gemspec", "cucumber.yml", "examples/dos_line_endings/Rakefile", "examples/dos_line_endings/features/dos_line_endings.feature", "examples/i18n/README.textile", "examples/i18n/Rakefile", "examples/i18n/ar/Rakefile", "examples/i18n/ar/features/addition.feature", "examples/i18n/ar/features/step_definitons/calculator_steps.rb", "examples/i18n/ar/lib/calculator.rb", "examples/i18n/bg/Rakefile", "examples/i18n/bg/features/addition.feature", "examples/i18n/bg/features/consecutive_calculations.feature", "examples/i18n/bg/features/division.feature", "examples/i18n/bg/features/step_definitons/calculator_steps.rb", "examples/i18n/bg/features/support/env.rb", "examples/i18n/bg/features/support/world.rb", "examples/i18n/bg/lib/calculator.rb", "examples/i18n/cat/Rakefile", "examples/i18n/cat/features/step_definitons/calculator_steps.rb", "examples/i18n/cat/features/suma.feature", "examples/i18n/cat/lib/calculadora.rb", "examples/i18n/da/Rakefile", "examples/i18n/da/features/sammenlaegning.feature", "examples/i18n/da/features/step_definitons/lommeregner_steps.rb", "examples/i18n/da/lib/lommeregner.rb", "examples/i18n/de/.gitignore", "examples/i18n/de/Rakefile", "examples/i18n/de/features/addition.feature", "examples/i18n/de/features/division.feature", "examples/i18n/de/features/step_definitons/calculator_steps.rb", "examples/i18n/de/lib/calculator.rb", "examples/i18n/en-lol/Rakefile", "examples/i18n/en-lol/features/step_definitions/cucumbrz_steps.rb", "examples/i18n/en-lol/features/stuffing.feature", "examples/i18n/en-lol/features/support/env.rb", "examples/i18n/en-lol/lib/basket.rb", "examples/i18n/en-lol/lib/belly.rb", "examples/i18n/en/.gitignore", "examples/i18n/en/Rakefile", "examples/i18n/en/features/addition.feature", "examples/i18n/en/features/division.feature", "examples/i18n/en/features/step_definitons/calculator_steps.rb", "examples/i18n/en/lib/calculator.rb", "examples/i18n/es/Rakefile", "examples/i18n/es/features/adicion.feature", "examples/i18n/es/features/step_definitons/calculador_steps.rb", "examples/i18n/es/lib/calculador.rb", "examples/i18n/et/Rakefile", "examples/i18n/et/features/jagamine.feature", "examples/i18n/et/features/liitmine.feature", "examples/i18n/et/features/step_definitions/kalkulaator_steps.rb", "examples/i18n/et/lib/kalkulaator.rb", "examples/i18n/fi/.gitignore", "examples/i18n/fi/Rakefile", "examples/i18n/fi/features/jakolasku.feature", "examples/i18n/fi/features/step_definitons/laskin_steps.rb", "examples/i18n/fi/features/yhteenlasku.feature", "examples/i18n/fi/lib/laskin.rb", "examples/i18n/fr/Rakefile", "examples/i18n/fr/features/addition.feature", "examples/i18n/fr/features/step_definitions/calculatrice_steps.rb", "examples/i18n/fr/lib/calculatrice.rb", "examples/i18n/he/Rakefile", "examples/i18n/he/features/addition.feature", "examples/i18n/he/features/division.feature", "examples/i18n/he/features/step_definitons/calculator_steps.rb", "examples/i18n/he/lib/calculator.rb", "examples/i18n/hu/.gitignore", "examples/i18n/hu/Rakefile", "examples/i18n/hu/features/addition.feature", "examples/i18n/hu/features/division.feature", "examples/i18n/hu/features/step_definitons/calculator_steps.rb", "examples/i18n/hu/lib/calculator.rb", "examples/i18n/id/.gitignore", "examples/i18n/id/Rakefile", "examples/i18n/id/features/addition.feature", "examples/i18n/id/features/division.feature", "examples/i18n/id/features/step_definitons/calculator_steps.rb", "examples/i18n/id/lib/calculator.rb", "examples/i18n/it/Rakefile", "examples/i18n/it/features/somma.feature", "examples/i18n/it/features/step_definitons/calcolatrice_steps.rb", "examples/i18n/it/lib/calcolatrice.rb", "examples/i18n/ja/.gitignore", "examples/i18n/ja/Rakefile", "examples/i18n/ja/features/addition.feature", "examples/i18n/ja/features/division.feature", "examples/i18n/ja/features/step_definitons/calculator_steps.rb", "examples/i18n/ja/lib/calculator.rb", "examples/i18n/ko/.gitignore", "examples/i18n/ko/Rakefile", "examples/i18n/ko/features/addition.feature", "examples/i18n/ko/features/division.feature", "examples/i18n/ko/features/step_definitons/calculator_steps.rb", "examples/i18n/ko/lib/calculator.rb", "examples/i18n/lt/.gitignore", "examples/i18n/lt/Rakefile", "examples/i18n/lt/features/addition.feature", "examples/i18n/lt/features/division.feature", "examples/i18n/lt/features/step_definitons/calculator_steps.rb", "examples/i18n/lt/lib/calculator.rb", "examples/i18n/lv/Rakefile", "examples/i18n/lv/features/addition.feature", "examples/i18n/lv/features/division.feature", "examples/i18n/lv/features/step_definitons/calculator_steps.rb", "examples/i18n/lv/lib/calculator.rb", "examples/i18n/no/Rakefile", "examples/i18n/no/features/step_definitons/kalkulator_steps.rb", "examples/i18n/no/features/summering.feature", "examples/i18n/no/features/support/env.rb", "examples/i18n/no/lib/kalkulator.rb", "examples/i18n/pl/.gitignore", "examples/i18n/pl/Rakefile", "examples/i18n/pl/features/addition.feature", "examples/i18n/pl/features/division.feature", "examples/i18n/pl/features/step_definitons/calculator_steps.rb", "examples/i18n/pl/features/support/env.rb", "examples/i18n/pl/lib/calculator.rb", "examples/i18n/pt/Rakefile", "examples/i18n/pt/features/adicao.feature", "examples/i18n/pt/features/step_definitions/calculadora_steps.rb", "examples/i18n/pt/features/support/env.rb", "examples/i18n/pt/lib/calculadora.rb", "examples/i18n/ro/Rakefile", "examples/i18n/ro/features/step_definitons/calculator_steps.rb", "examples/i18n/ro/features/suma.feature", "examples/i18n/ro/lib/calculator.rb", "examples/i18n/ru/Rakefile", "examples/i18n/ru/features/addition.feature", "examples/i18n/ru/features/consecutive_calculations.feature", "examples/i18n/ru/features/division.feature", "examples/i18n/ru/features/step_definitons/calculator_steps.rb", "examples/i18n/ru/features/support/env.rb", "examples/i18n/ru/features/support/world.rb", "examples/i18n/ru/lib/calculator.rb", "examples/i18n/se/Rakefile", "examples/i18n/se/features/step_definitons/kalkulator_steps.rb", "examples/i18n/se/features/summering.feature", "examples/i18n/se/lib/kalkulator.rb", "examples/i18n/sk/.gitignore", "examples/i18n/sk/Rakefile", "examples/i18n/sk/features/addition.feature", "examples/i18n/sk/features/division.feature", "examples/i18n/sk/features/step_definitons/calculator_steps.rb", "examples/i18n/sk/lib/calculator.rb", "examples/i18n/sr-latn/Rakefile", "examples/i18n/sr-latn/features/sabiranje.feature", "examples/i18n/sr-latn/features/step_definitons/calculator_steps.rb", "examples/i18n/sr-latn/lib/calculator.rb", "examples/i18n/sr/Rakefile", "examples/i18n/sr/features/sabiranje.feature", "examples/i18n/sr/features/step_definitons/calculator_steps.rb", "examples/i18n/sr/lib/calculator.rb", "examples/i18n/tr/.gitignore", "examples/i18n/tr/Rakefile", "examples/i18n/tr/features/bolme.feature", "examples/i18n/tr/features/step_definitons/hesap_makinesi_adimlari.rb", "examples/i18n/tr/features/toplama.feature", "examples/i18n/tr/lib/hesap_makinesi.rb", "examples/i18n/uz/Rakefile", "examples/i18n/uz/features/addition.feature", "examples/i18n/uz/features/consecutive_calculations.feature", "examples/i18n/uz/features/division.feature", "examples/i18n/uz/features/step_definitons/calculator_steps.rb", "examples/i18n/uz/features/support/env.rb", "examples/i18n/uz/features/support/world.rb", "examples/i18n/uz/lib/calculator.rb", "examples/i18n/zh-CN/Rakefile", "examples/i18n/zh-CN/features/addition.feature", "examples/i18n/zh-CN/features/step_definitons/calculator_steps.rb", "examples/i18n/zh-CN/lib/calculator.rb", "examples/i18n/zh-TW/.gitignore", "examples/i18n/zh-TW/Rakefile", "examples/i18n/zh-TW/features/addition.feature", "examples/i18n/zh-TW/features/division.feature", "examples/i18n/zh-TW/features/step_definitons/calculator_steps.rb", "examples/i18n/zh-TW/lib/calculator.rb", "examples/junit/features/one_passing_one_failing.feature", "examples/junit/features/pending.feature", "examples/junit/features/step_definitions/steps.rb", "examples/python/features/fibonacci.feature", "examples/python/features/step_definitions/fib_steps.py", "examples/python/lib/.gitignore", "examples/python/lib/fib.py", "examples/ramaze/README.textile", "examples/ramaze/Rakefile", "examples/ramaze/app.rb", "examples/ramaze/features/add.feature", "examples/ramaze/features/step_definitions/add_steps.rb", "examples/ramaze/features/support/env.rb", "examples/ramaze/layout/default.html.erb", "examples/ramaze/view/index.html.erb", "examples/ruby2python/features/fibonacci.feature", "examples/ruby2python/features/step_definitions/fib_steps.rb", "examples/ruby2python/features/support/env.rb", "examples/ruby2python/lib/.gitignore", "examples/ruby2python/lib/fib.py", "examples/selenium/Rakefile", "examples/selenium/features/search.feature", "examples/selenium/features/step_definitons/search_steps.rb", "examples/selenium/features/support/env.rb", "examples/selenium_webrat/Rakefile", "examples/selenium_webrat/config.ru", "examples/selenium_webrat/features/search.feature", "examples/selenium_webrat/features/step_definitons/search_steps.rb", "examples/selenium_webrat/features/support/env.rb", "examples/self_test/.gitignore", "examples/self_test/README.textile", "examples/self_test/Rakefile", "examples/self_test/features/background/background_tagged_before_on_outline.feature", "examples/self_test/features/background/background_with_name.feature", "examples/self_test/features/background/failing_background.feature", "examples/self_test/features/background/failing_background_after_success.feature", "examples/self_test/features/background/multiline_args_background.feature", "examples/self_test/features/background/passing_background.feature", "examples/self_test/features/background/pending_background.feature", "examples/self_test/features/background/scenario_outline_failing_background.feature", "examples/self_test/features/background/scenario_outline_passing_background.feature", "examples/self_test/features/call_undefined_step_from_step_def.feature", "examples/self_test/features/failing_expectation.feature", "examples/self_test/features/lots_of_undefined.feature", "examples/self_test/features/multiline_name.feature", "examples/self_test/features/outline_sample.feature", "examples/self_test/features/sample.feature", "examples/self_test/features/search_sample.feature", "examples/self_test/features/step_definitions/sample_steps.rb", "examples/self_test/features/support/env.rb", "examples/self_test/features/tags_sample.feature", "examples/self_test/features/tons_of_cukes.feature", "examples/self_test/features/undefined_multiline_args.feature", "examples/self_test/list-of-features.txt", "examples/sinatra/README.textile", "examples/sinatra/Rakefile", "examples/sinatra/app.rb", "examples/sinatra/features/add.feature", "examples/sinatra/features/step_definitions/add_steps.rb", "examples/sinatra/features/support/env.rb", "examples/sinatra/views/add.erb", "examples/sinatra/views/layout.erb", "examples/steps_library/features/step_definitions/steps_lib1.rb", "examples/steps_library/features/step_definitions/steps_lib2.rb", "examples/test_unit/Rakefile", "examples/test_unit/features/step_definitions/test_unit_steps.rb", "examples/test_unit/features/test_unit.feature", "examples/tickets/Rakefile", "examples/tickets/features.html", "examples/tickets/features/172.feature", "examples/tickets/features/177/1.feature", "examples/tickets/features/177/2.feature", "examples/tickets/features/177/3.feature", "examples/tickets/features/180.feature", "examples/tickets/features/229/tagged_hooks.feature", "examples/tickets/features/229/tagged_hooks.rb", "examples/tickets/features/236.feature", "examples/tickets/features/241.feature", "examples/tickets/features/246.feature", "examples/tickets/features/248.feature", "examples/tickets/features/270/back.feature", "examples/tickets/features/270/back.steps.rb", "examples/tickets/features/272/hooks.feature", "examples/tickets/features/272/hooks_steps.rb", "examples/tickets/features/279/py_string_indent.feature", "examples/tickets/features/279/py_string_indent.steps.rb", "examples/tickets/features/279/wrong.feature_", "examples/tickets/features/301/filter_background_tagged_hooks.feature", "examples/tickets/features/301/filter_background_tagged_hooks_steps.rb", "examples/tickets/features/306/only_background.feature", "examples/tickets/features/lib/eatting_machine.rb", "examples/tickets/features/lib/pantry.rb", "examples/tickets/features/scenario_outline.feature", "examples/tickets/features/step_definitons/246_steps.rb", "examples/tickets/features/step_definitons/248_steps.rb", "examples/tickets/features/step_definitons/scenario_outline_steps.rb", "examples/tickets/features/step_definitons/tickets_steps.rb", "examples/tickets/features/table_diffing.feature", "examples/tickets/features/tickets.feature", "examples/watir/README.textile", "examples/watir/Rakefile", "examples/watir/features/search.feature", "examples/watir/features/step_definitions/search_steps.rb", "examples/watir/features/support/env.rb", "examples/watir/features/support/screenshots.rb", "examples/webrat/features/search.feature", "examples/webrat/features/step_definitions/kvasir_steps.rb", "examples/webrat/features/support/env.rb", "features/announce.feature", "features/background.feature", "features/bug_371.feature", "features/bug_464.feature", "features/bug_475.feature", "features/call_many_steps.feature", "features/cucumber_cli.feature", "features/cucumber_cli_diff_disabled.feature", "features/cucumber_cli_outlines.feature", "features/custom_formatter.feature", "features/default_snippets.feature", "features/drb_server_integration.feature", "features/exception_in_after_block.feature", "features/exception_in_after_step_block.feature", "features/exception_in_before_block.feature", "features/exclude_files.feature", "features/expand.feature", "features/html_formatter.feature", "features/html_formatter/a.html", "features/junit_formatter.feature", "features/language_from_header.feature", "features/language_help.feature", "features/listener_debugger_formatter.feature", "features/multiline_names.feature", "features/negative_tagged_hooks.feature", "features/post_configuration_hook.feature", "features/profiles.feature", "features/rake_task.feature", "features/report_called_undefined_steps.feature", "features/simplest.feature", "features/snippet.feature", "features/step_definitions/cucumber_steps.rb", "features/step_definitions/extra_steps.rb", "features/step_definitions/simplest_steps.rb", "features/step_definitions/wire_steps.rb", "features/support/env.rb", "features/support/env.rb.simplest", "features/support/fake_wire_server.rb", "features/table_diffing.feature", "features/table_mapping.feature", "features/tag_logic.feature", "features/transform.feature", "features/unicode_table.feature", "features/usage_and_stepdefs_formatter.feature", "features/wire_protocol.feature", "features/work_in_progress.feature", "gem_tasks/contributors.rake", "gem_tasks/environment.rake", "gem_tasks/features.rake", "gem_tasks/fix_cr_lf.rake", "gem_tasks/flog.rake", "gem_tasks/rspec.rake", "gem_tasks/sass.rake", "gem_tasks/sdoc.rake", "lib/README.rdoc", "lib/autotest/cucumber.rb", "lib/autotest/cucumber_mixin.rb", "lib/autotest/cucumber_rails.rb", "lib/autotest/cucumber_rails_rspec.rb", "lib/autotest/cucumber_rspec.rb", "lib/autotest/discover.rb", "lib/cucumber.rb", "lib/cucumber/ast.rb", "lib/cucumber/ast/background.rb", "lib/cucumber/ast/comment.rb", "lib/cucumber/ast/examples.rb", "lib/cucumber/ast/feature.rb", "lib/cucumber/ast/feature_element.rb", "lib/cucumber/ast/features.rb", "lib/cucumber/ast/outline_table.rb", "lib/cucumber/ast/py_string.rb", "lib/cucumber/ast/scenario.rb", "lib/cucumber/ast/scenario_outline.rb", "lib/cucumber/ast/step.rb", "lib/cucumber/ast/step_collection.rb", "lib/cucumber/ast/step_invocation.rb", "lib/cucumber/ast/table.rb", "lib/cucumber/ast/tags.rb", "lib/cucumber/ast/tree_walker.rb", "lib/cucumber/ast/visitor.rb", "lib/cucumber/broadcaster.rb", "lib/cucumber/cli/configuration.rb", "lib/cucumber/cli/drb_client.rb", "lib/cucumber/cli/language_help_formatter.rb", "lib/cucumber/cli/main.rb", "lib/cucumber/cli/options.rb", "lib/cucumber/cli/profile_loader.rb", "lib/cucumber/constantize.rb", "lib/cucumber/core_ext/instance_exec.rb", "lib/cucumber/core_ext/proc.rb", "lib/cucumber/core_ext/string.rb", "lib/cucumber/feature_file.rb", "lib/cucumber/filter.rb", "lib/cucumber/formatter/ansicolor.rb", "lib/cucumber/formatter/color_io.rb", "lib/cucumber/formatter/console.rb", "lib/cucumber/formatter/cucumber.css", "lib/cucumber/formatter/cucumber.sass", "lib/cucumber/formatter/debug.rb", "lib/cucumber/formatter/duration.rb", "lib/cucumber/formatter/html.rb", "lib/cucumber/formatter/junit.rb", "lib/cucumber/formatter/ordered_xml_markup.rb", "lib/cucumber/formatter/pdf.rb", "lib/cucumber/formatter/pretty.rb", "lib/cucumber/formatter/progress.rb", "lib/cucumber/formatter/rerun.rb", "lib/cucumber/formatter/stepdefs.rb", "lib/cucumber/formatter/steps.rb", "lib/cucumber/formatter/summary.rb", "lib/cucumber/formatter/tag_cloud.rb", "lib/cucumber/formatter/unicode.rb", "lib/cucumber/formatter/usage.rb", "lib/cucumber/language_support.rb", "lib/cucumber/language_support/language_methods.rb", "lib/cucumber/languages.yml", "lib/cucumber/parser.rb", "lib/cucumber/parser/common.rb", "lib/cucumber/parser/common.tt", "lib/cucumber/parser/feature.rb", "lib/cucumber/parser/feature.tt", "lib/cucumber/parser/i18n.tt", "lib/cucumber/parser/natural_language.rb", "lib/cucumber/parser/py_string.rb", "lib/cucumber/parser/py_string.tt", "lib/cucumber/parser/table.rb", "lib/cucumber/parser/table.tt", "lib/cucumber/parser/treetop_ext.rb", "lib/cucumber/platform.rb", "lib/cucumber/py_support/py_dsl.py", "lib/cucumber/py_support/py_language.py", "lib/cucumber/py_support/py_language.rb", "lib/cucumber/rails/action_controller.rb", "lib/cucumber/rails/active_record.rb", "lib/cucumber/rails/rspec.rb", "lib/cucumber/rails/test_unit.rb", "lib/cucumber/rails/world.rb", "lib/cucumber/rake/task.rb", "lib/cucumber/rb_support/rb_dsl.rb", "lib/cucumber/rb_support/rb_hook.rb", "lib/cucumber/rb_support/rb_language.rb", "lib/cucumber/rb_support/rb_step_definition.rb", "lib/cucumber/rb_support/rb_transform.rb", "lib/cucumber/rb_support/rb_world.rb", "lib/cucumber/rb_support/regexp_argument_matcher.rb", "lib/cucumber/rspec_neuter.rb", "lib/cucumber/step_argument.rb", "lib/cucumber/step_definition_light.rb", "lib/cucumber/step_match.rb", "lib/cucumber/step_mother.rb", "lib/cucumber/webrat/element_locator.rb", "lib/cucumber/webrat/table_locator.rb", "lib/cucumber/wire_support/connection.rb", "lib/cucumber/wire_support/request_handler.rb", "lib/cucumber/wire_support/wire_exception.rb", "lib/cucumber/wire_support/wire_language.rb", "lib/cucumber/wire_support/wire_packet.rb", "lib/cucumber/wire_support/wire_protocol.rb", "lib/cucumber/wire_support/wire_step_definition.rb", "rails_generators/cucumber/USAGE", "rails_generators/cucumber/cucumber_generator.rb", "rails_generators/cucumber/templates/cucumber", "rails_generators/cucumber/templates/cucumber.rake", "rails_generators/cucumber/templates/cucumber_environment.rb", "rails_generators/cucumber/templates/env.rb", "rails_generators/cucumber/templates/paths.rb", "rails_generators/cucumber/templates/spork_env.rb", "rails_generators/cucumber/templates/version_check.rb", "rails_generators/cucumber/templates/webrat_steps.rb", "rails_generators/feature/USAGE", "rails_generators/feature/feature_generator.rb", "rails_generators/feature/templates/feature.erb", "rails_generators/feature/templates/steps.erb", "spec/cucumber/ast/background_spec.rb", "spec/cucumber/ast/feature_element_spec.rb", "spec/cucumber/ast/feature_factory.rb", "spec/cucumber/ast/feature_spec.rb", "spec/cucumber/ast/outline_table_spec.rb", "spec/cucumber/ast/py_string_spec.rb", "spec/cucumber/ast/scenario_outline_spec.rb", "spec/cucumber/ast/scenario_spec.rb", "spec/cucumber/ast/step_collection_spec.rb", "spec/cucumber/ast/step_spec.rb", "spec/cucumber/ast/table_spec.rb", "spec/cucumber/ast/tags_spec.rb", "spec/cucumber/ast/tree_walker_spec.rb", "spec/cucumber/broadcaster_spec.rb", "spec/cucumber/cli/configuration_spec.rb", "spec/cucumber/cli/drb_client_spec.rb", "spec/cucumber/cli/main_spec.rb", "spec/cucumber/cli/options_spec.rb", "spec/cucumber/cli/profile_loader_spec.rb", "spec/cucumber/core_ext/proc_spec.rb", "spec/cucumber/formatter/ansicolor_spec.rb", "spec/cucumber/formatter/color_io_spec.rb", "spec/cucumber/formatter/console_spec.rb", "spec/cucumber/formatter/duration_spec.rb", "spec/cucumber/formatter/html_spec.rb", "spec/cucumber/formatter/junit_spec.rb", "spec/cucumber/formatter/progress_spec.rb", "spec/cucumber/formatter/spec_helper.rb", "spec/cucumber/parser/feature_parser_spec.rb", "spec/cucumber/parser/table_parser_spec.rb", "spec/cucumber/rb_support/rb_step_definition_spec.rb", "spec/cucumber/rb_support/regexp_argument_matcher_spec.rb", "spec/cucumber/sell_cucumbers.feature", "spec/cucumber/step_match_spec.rb", "spec/cucumber/step_mother_spec.rb", "spec/cucumber/treetop_parser/empty_feature.feature", "spec/cucumber/treetop_parser/empty_scenario.feature", "spec/cucumber/treetop_parser/empty_scenario_outline.feature", "spec/cucumber/treetop_parser/fit_scenario.feature", "spec/cucumber/treetop_parser/given_scenario.feature", "spec/cucumber/treetop_parser/invalid_scenario_outlines.feature", "spec/cucumber/treetop_parser/multiline_steps.feature", "spec/cucumber/treetop_parser/multiple_tables.feature", "spec/cucumber/treetop_parser/scenario_outline.feature", "spec/cucumber/treetop_parser/spaces.feature", "spec/cucumber/treetop_parser/test_dos.feature", "spec/cucumber/treetop_parser/with_comments.feature", "spec/cucumber/treetop_parser/with_tags.feature", "spec/cucumber/wire_support/wire_language_spec.rb", "spec/cucumber/wire_support/wire_packet_spec.rb", "spec/cucumber/world/pending_spec.rb", "spec/spec.opts", "spec/spec_helper.rb", "examples/self_test/tmp/features/step_definitions/steps.rb"] + s.homepage = %q{http://cukes.info} + s.post_install_message = %q{ +(::) (::) (::) (::) (::) (::) (::) (::) (::) (::) (::) (::) (::) (::) (::) + + (::) U P G R A D I N G (::) + +Thank you for installing cucumber-0.4.4. +Please be sure to read http://wiki.github.com/aslakhellesoy/cucumber/upgrading +for important information about this release. Happy cuking! + +(::) (::) (::) (::) (::) (::) (::) (::) (::) (::) (::) (::) (::) (::) (::) + +} + s.rdoc_options = ["--charset=UTF-8"] + s.require_paths = ["lib"] + s.rubyforge_project = %q{rspec} + s.rubygems_version = %q{1.3.5} + s.summary = %q{Behaviour Driven Development with elegance and joy} + s.test_files = ["spec/cucumber/ast/background_spec.rb", "spec/cucumber/ast/feature_element_spec.rb", "spec/cucumber/ast/feature_factory.rb", "spec/cucumber/ast/feature_spec.rb", "spec/cucumber/ast/outline_table_spec.rb", "spec/cucumber/ast/py_string_spec.rb", "spec/cucumber/ast/scenario_outline_spec.rb", "spec/cucumber/ast/scenario_spec.rb", "spec/cucumber/ast/step_collection_spec.rb", "spec/cucumber/ast/step_spec.rb", "spec/cucumber/ast/table_spec.rb", "spec/cucumber/ast/tags_spec.rb", "spec/cucumber/ast/tree_walker_spec.rb", "spec/cucumber/broadcaster_spec.rb", "spec/cucumber/cli/configuration_spec.rb", "spec/cucumber/cli/drb_client_spec.rb", "spec/cucumber/cli/main_spec.rb", "spec/cucumber/cli/options_spec.rb", "spec/cucumber/cli/profile_loader_spec.rb", "spec/cucumber/core_ext/proc_spec.rb", "spec/cucumber/formatter/ansicolor_spec.rb", "spec/cucumber/formatter/color_io_spec.rb", "spec/cucumber/formatter/console_spec.rb", "spec/cucumber/formatter/duration_spec.rb", "spec/cucumber/formatter/html_spec.rb", "spec/cucumber/formatter/junit_spec.rb", "spec/cucumber/formatter/progress_spec.rb", "spec/cucumber/formatter/spec_helper.rb", "spec/cucumber/parser/feature_parser_spec.rb", "spec/cucumber/parser/table_parser_spec.rb", "spec/cucumber/rb_support/rb_step_definition_spec.rb", "spec/cucumber/rb_support/regexp_argument_matcher_spec.rb", "spec/cucumber/step_match_spec.rb", "spec/cucumber/step_mother_spec.rb", "spec/cucumber/wire_support/wire_language_spec.rb", "spec/cucumber/wire_support/wire_packet_spec.rb", "spec/cucumber/world/pending_spec.rb", "spec/spec_helper.rb", "examples/i18n/ar/features/step_definitons/calculator_steps.rb", "examples/i18n/ar/lib/calculator.rb", "examples/i18n/bg/features/step_definitons/calculator_steps.rb", "examples/i18n/bg/features/support/env.rb", "examples/i18n/bg/features/support/world.rb", "examples/i18n/bg/lib/calculator.rb", "examples/i18n/cat/features/step_definitons/calculator_steps.rb", "examples/i18n/cat/lib/calculadora.rb", "examples/i18n/da/features/step_definitons/lommeregner_steps.rb", "examples/i18n/da/lib/lommeregner.rb", "examples/i18n/de/features/step_definitons/calculator_steps.rb", "examples/i18n/de/lib/calculator.rb", "examples/i18n/en/features/step_definitons/calculator_steps.rb", "examples/i18n/en/lib/calculator.rb", "examples/i18n/en-lol/features/step_definitions/cucumbrz_steps.rb", "examples/i18n/en-lol/features/support/env.rb", "examples/i18n/en-lol/lib/basket.rb", "examples/i18n/en-lol/lib/belly.rb", "examples/i18n/es/features/step_definitons/calculador_steps.rb", "examples/i18n/es/lib/calculador.rb", "examples/i18n/et/features/step_definitions/kalkulaator_steps.rb", "examples/i18n/et/lib/kalkulaator.rb", "examples/i18n/fi/features/step_definitons/laskin_steps.rb", "examples/i18n/fi/lib/laskin.rb", "examples/i18n/fr/features/step_definitions/calculatrice_steps.rb", "examples/i18n/fr/lib/calculatrice.rb", "examples/i18n/he/features/step_definitons/calculator_steps.rb", "examples/i18n/he/lib/calculator.rb", "examples/i18n/hu/features/step_definitons/calculator_steps.rb", "examples/i18n/hu/lib/calculator.rb", "examples/i18n/id/features/step_definitons/calculator_steps.rb", "examples/i18n/id/lib/calculator.rb", "examples/i18n/it/features/step_definitons/calcolatrice_steps.rb", "examples/i18n/it/lib/calcolatrice.rb", "examples/i18n/ja/features/step_definitons/calculator_steps.rb", "examples/i18n/ja/lib/calculator.rb", "examples/i18n/ko/features/step_definitons/calculator_steps.rb", "examples/i18n/ko/lib/calculator.rb", "examples/i18n/lt/features/step_definitons/calculator_steps.rb", "examples/i18n/lt/lib/calculator.rb", "examples/i18n/lv/features/step_definitons/calculator_steps.rb", "examples/i18n/lv/lib/calculator.rb", "examples/i18n/no/features/step_definitons/kalkulator_steps.rb", "examples/i18n/no/features/support/env.rb", "examples/i18n/no/lib/kalkulator.rb", "examples/i18n/pl/features/step_definitons/calculator_steps.rb", "examples/i18n/pl/features/support/env.rb", "examples/i18n/pl/lib/calculator.rb", "examples/i18n/pt/features/step_definitions/calculadora_steps.rb", "examples/i18n/pt/features/support/env.rb", "examples/i18n/pt/lib/calculadora.rb", "examples/i18n/ro/features/step_definitons/calculator_steps.rb", "examples/i18n/ro/lib/calculator.rb", "examples/i18n/ru/features/step_definitons/calculator_steps.rb", "examples/i18n/ru/features/support/env.rb", "examples/i18n/ru/features/support/world.rb", "examples/i18n/ru/lib/calculator.rb", "examples/i18n/se/features/step_definitons/kalkulator_steps.rb", "examples/i18n/se/lib/kalkulator.rb", "examples/i18n/sk/features/step_definitons/calculator_steps.rb", "examples/i18n/sk/lib/calculator.rb", "examples/i18n/sr/features/step_definitons/calculator_steps.rb", "examples/i18n/sr/lib/calculator.rb", "examples/i18n/sr-latn/features/step_definitons/calculator_steps.rb", "examples/i18n/sr-latn/lib/calculator.rb", "examples/i18n/tr/features/step_definitons/hesap_makinesi_adimlari.rb", "examples/i18n/tr/lib/hesap_makinesi.rb", "examples/i18n/uz/features/step_definitons/calculator_steps.rb", "examples/i18n/uz/features/support/env.rb", "examples/i18n/uz/features/support/world.rb", "examples/i18n/uz/lib/calculator.rb", "examples/i18n/zh-CN/features/step_definitons/calculator_steps.rb", "examples/i18n/zh-CN/lib/calculator.rb", "examples/i18n/zh-TW/features/step_definitons/calculator_steps.rb", "examples/i18n/zh-TW/lib/calculator.rb", "examples/junit/features/step_definitions/steps.rb", "examples/ramaze/app.rb", "examples/ramaze/features/step_definitions/add_steps.rb", "examples/ramaze/features/support/env.rb", "examples/ruby2python/features/step_definitions/fib_steps.rb", "examples/ruby2python/features/support/env.rb", "examples/selenium/features/step_definitons/search_steps.rb", "examples/selenium/features/support/env.rb", "examples/selenium_webrat/features/step_definitons/search_steps.rb", "examples/selenium_webrat/features/support/env.rb", "examples/self_test/features/step_definitions/sample_steps.rb", "examples/self_test/features/support/env.rb", "examples/self_test/tmp/features/step_definitions/steps.rb", "examples/sinatra/app.rb", "examples/sinatra/features/step_definitions/add_steps.rb", "examples/sinatra/features/support/env.rb", "examples/steps_library/features/step_definitions/steps_lib1.rb", "examples/steps_library/features/step_definitions/steps_lib2.rb", "examples/test_unit/features/step_definitions/test_unit_steps.rb", "examples/tickets/features/229/tagged_hooks.rb", "examples/tickets/features/270/back.steps.rb", "examples/tickets/features/272/hooks_steps.rb", "examples/tickets/features/279/py_string_indent.steps.rb", "examples/tickets/features/301/filter_background_tagged_hooks_steps.rb", "examples/tickets/features/lib/eatting_machine.rb", "examples/tickets/features/lib/pantry.rb", "examples/tickets/features/step_definitons/246_steps.rb", "examples/tickets/features/step_definitons/248_steps.rb", "examples/tickets/features/step_definitons/scenario_outline_steps.rb", "examples/tickets/features/step_definitons/tickets_steps.rb", "examples/watir/features/step_definitions/search_steps.rb", "examples/watir/features/support/env.rb", "examples/watir/features/support/screenshots.rb", "examples/webrat/features/step_definitions/kvasir_steps.rb", "examples/webrat/features/support/env.rb"] + + if s.respond_to? :specification_version then + current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION + s.specification_version = 3 + + if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then + s.add_runtime_dependency(%q, ["= 1.0.4"]) + s.add_runtime_dependency(%q, ["= 1.4.2"]) + s.add_runtime_dependency(%q, ["= 0.2.9"]) + s.add_runtime_dependency(%q, ["= 2.1.2"]) + s.add_runtime_dependency(%q, ["= 1.1.2"]) + s.add_development_dependency(%q, ["= 1.3.3"]) + s.add_development_dependency(%q, ["= 0.5.1"]) + s.add_development_dependency(%q, ["= 1.2.9"]) + s.add_development_dependency(%q, ["= 0.7.3"]) + else + s.add_dependency(%q, ["= 1.0.4"]) + s.add_dependency(%q, ["= 1.4.2"]) + s.add_dependency(%q, ["= 0.2.9"]) + s.add_dependency(%q, ["= 2.1.2"]) + s.add_dependency(%q, ["= 1.1.2"]) + s.add_dependency(%q, ["= 1.3.3"]) + s.add_dependency(%q, ["= 0.5.1"]) + s.add_dependency(%q, ["= 1.2.9"]) + s.add_dependency(%q, ["= 0.7.3"]) + end + else + s.add_dependency(%q, ["= 1.0.4"]) + s.add_dependency(%q, ["= 1.4.2"]) + s.add_dependency(%q, ["= 0.2.9"]) + s.add_dependency(%q, ["= 2.1.2"]) + s.add_dependency(%q, ["= 1.1.2"]) + s.add_dependency(%q, ["= 1.3.3"]) + s.add_dependency(%q, ["= 0.5.1"]) + s.add_dependency(%q, ["= 1.2.9"]) + s.add_dependency(%q, ["= 0.7.3"]) + end +end diff --git a/vendor/gems/specifications/daemons-1.0.10.gemspec b/vendor/gems/specifications/daemons-1.0.10.gemspec new file mode 100755 index 00000000..fb8b91e7 --- /dev/null +++ b/vendor/gems/specifications/daemons-1.0.10.gemspec @@ -0,0 +1,30 @@ +# -*- encoding: utf-8 -*- + +Gem::Specification.new do |s| + s.name = %q{daemons} + s.version = "1.0.10" + + s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version= + s.authors = ["Thomas Uehlinger"] + s.autorequire = %q{daemons} + s.date = %q{2008-03-20} + s.description = %q{Daemons provides an easy way to wrap existing ruby scripts (for example a self-written server) to be run as a daemon and to be controlled by simple start/stop/restart commands. You can also call blocks as daemons and control them from the parent or just daemonize the current process. Besides this basic functionality, daemons offers many advanced features like exception backtracing and logging (in case your ruby script crashes) and monitoring and automatic restarting of your processes if they crash.} + s.email = %q{th.uehlinger@gmx.ch} + s.extra_rdoc_files = ["README", "Releases", "TODO"] + s.files = ["Rakefile", "Releases", "TODO", "README", "LICENSE", "setup.rb", "lib/daemons/application.rb", "lib/daemons/application_group.rb", "lib/daemons/cmdline.rb", "lib/daemons/controller.rb", "lib/daemons/daemonize.rb", "lib/daemons/exceptions.rb", "lib/daemons/monitor.rb", "lib/daemons/pid.rb", "lib/daemons/pidfile.rb", "lib/daemons/pidmem.rb", "lib/daemons.rb", "examples/call", "examples/call/call.rb", "examples/call/call_monitor.rb", "examples/daemonize", "examples/daemonize/daemonize.rb", "examples/run", "examples/run/ctrl_crash.rb", "examples/run/ctrl_exec.rb", "examples/run/ctrl_exit.rb", "examples/run/ctrl_keep_pid_files.rb", "examples/run/ctrl_monitor.rb", "examples/run/ctrl_multiple.rb", "examples/run/ctrl_normal.rb", "examples/run/ctrl_ontop.rb", "examples/run/ctrl_optionparser.rb", "examples/run/ctrl_proc.rb", "examples/run/ctrl_proc.rb.output", "examples/run/ctrl_proc_multiple.rb", "examples/run/ctrl_proc_multiple.rb.output", "examples/run/ctrl_proc_simple.rb", "examples/run/myserver.rb", "examples/run/myserver_crashing.rb", "examples/run/myserver_crashing.rb.output", "examples/run/myserver_exiting.rb"] + s.homepage = %q{http://daemons.rubyforge.org} + s.require_paths = ["lib"] + s.rubyforge_project = %q{daemons} + s.rubygems_version = %q{1.3.5} + s.summary = %q{A toolkit to create and control daemons in different ways} + + if s.respond_to? :specification_version then + current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION + s.specification_version = 2 + + if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then + else + end + else + end +end diff --git a/vendor/gems/specifications/diff-lcs-1.1.2.gemspec b/vendor/gems/specifications/diff-lcs-1.1.2.gemspec new file mode 100755 index 00000000..c43289e0 --- /dev/null +++ b/vendor/gems/specifications/diff-lcs-1.1.2.gemspec @@ -0,0 +1,34 @@ +# -*- encoding: utf-8 -*- + +Gem::Specification.new do |s| + s.name = %q{diff-lcs} + s.version = "1.1.2" + + s.required_rubygems_version = nil if s.respond_to? :required_rubygems_version= + s.autorequire = %q{diff/lcs} + s.cert_chain = nil + s.date = %q{2004-10-20} + s.description = %q{Diff::LCS is a port of Algorithm::Diff that uses the McIlroy-Hunt longest common subsequence (LCS) algorithm to compute intelligent differences between two sequenced enumerable containers. The implementation is based on Mario I. Wolczko's Smalltalk version (1.2, 1993) and Ned Konz's Perl version (Algorithm::Diff).} + s.email = %q{diff-lcs@halostatue.ca} + s.executables = ["ldiff", "htmldiff"] + s.extra_rdoc_files = ["README", "ChangeLog", "Install"] + s.files = ["bin", "ChangeLog", "Install", "lib", "Rakefile", "README", "tests", "bin/htmldiff", "bin/ldiff", "lib/diff", "lib/diff/lcs", "lib/diff/lcs.rb", "lib/diff/lcs/array.rb", "lib/diff/lcs/block.rb", "lib/diff/lcs/callbacks.rb", "lib/diff/lcs/change.rb", "lib/diff/lcs/hunk.rb", "lib/diff/lcs/ldiff.rb", "lib/diff/lcs/string.rb", "tests/00test.rb"] + s.homepage = %q{http://rubyforge.org/projects/ruwiki/} + s.rdoc_options = ["--title", "Diff::LCS -- A Diff Algorithm", "--main", "README", "--line-numbers"] + s.require_paths = ["lib"] + s.required_ruby_version = Gem::Requirement.new(">= 1.8.1") + s.rubyforge_project = %q{ruwiki} + s.rubygems_version = %q{1.3.5} + s.summary = %q{Provides a list of changes that represent the difference between two sequenced collections.} + s.test_files = ["tests/00test.rb"] + + if s.respond_to? :specification_version then + current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION + s.specification_version = 1 + + if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then + else + end + else + end +end diff --git a/vendor/gems/specifications/eventmachine-0.12.10.gemspec b/vendor/gems/specifications/eventmachine-0.12.10.gemspec new file mode 100755 index 00000000..e03b00da --- /dev/null +++ b/vendor/gems/specifications/eventmachine-0.12.10.gemspec @@ -0,0 +1,40 @@ +# -*- encoding: utf-8 -*- + +Gem::Specification.new do |s| + s.name = %q{eventmachine} + s.version = "0.12.10" + + s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version= + s.authors = ["Francis Cianfrocca"] + s.date = %q{2009-10-25} + s.description = %q{EventMachine implements a fast, single-threaded engine for arbitrary network +communications. It's extremely easy to use in Ruby. EventMachine wraps all +interactions with IP sockets, allowing programs to concentrate on the +implementation of network protocols. It can be used to create both network +servers and clients. To create a server or client, a Ruby program only needs +to specify the IP address and port, and provide a Module that implements the +communications protocol. Implementations of several standard network protocols +are provided with the package, primarily to serve as examples. The real goal +of EventMachine is to enable programs to easily interface with other programs +using TCP/IP, especially if custom protocols are required. +} + s.email = %q{garbagecat10@gmail.com} + s.extensions = ["ext/extconf.rb", "ext/fastfilereader/extconf.rb"] + s.files = [".gitignore", "README", "Rakefile", "docs/COPYING", "docs/ChangeLog", "docs/DEFERRABLES", "docs/EPOLL", "docs/GNU", "docs/INSTALL", "docs/KEYBOARD", "docs/LEGAL", "docs/LIGHTWEIGHT_CONCURRENCY", "docs/PURE_RUBY", "docs/RELEASE_NOTES", "docs/SMTP", "docs/SPAWNED_PROCESSES", "docs/TODO", "eventmachine.gemspec", "examples/ex_channel.rb", "examples/ex_queue.rb", "examples/helper.rb", "ext/binder.cpp", "ext/binder.h", "ext/cmain.cpp", "ext/cplusplus.cpp", "ext/ed.cpp", "ext/ed.h", "ext/em.cpp", "ext/em.h", "ext/emwin.cpp", "ext/emwin.h", "ext/epoll.cpp", "ext/epoll.h", "ext/eventmachine.h", "ext/eventmachine_cpp.h", "ext/extconf.rb", "ext/fastfilereader/extconf.rb", "ext/fastfilereader/mapper.cpp", "ext/fastfilereader/mapper.h", "ext/fastfilereader/rubymain.cpp", "ext/files.cpp", "ext/files.h", "ext/kb.cpp", "ext/page.cpp", "ext/page.h", "ext/pipe.cpp", "ext/project.h", "ext/rubymain.cpp", "ext/sigs.cpp", "ext/sigs.h", "ext/ssl.cpp", "ext/ssl.h", "java/.classpath", "java/.project", "java/src/com/rubyeventmachine/EmReactor.java", "java/src/com/rubyeventmachine/EmReactorException.java", "java/src/com/rubyeventmachine/EventableChannel.java", "java/src/com/rubyeventmachine/EventableDatagramChannel.java", "java/src/com/rubyeventmachine/EventableSocketChannel.java", "java/src/com/rubyeventmachine/application/Application.java", "java/src/com/rubyeventmachine/application/Connection.java", "java/src/com/rubyeventmachine/application/ConnectionFactory.java", "java/src/com/rubyeventmachine/application/DefaultConnectionFactory.java", "java/src/com/rubyeventmachine/application/PeriodicTimer.java", "java/src/com/rubyeventmachine/application/Timer.java", "java/src/com/rubyeventmachine/tests/ApplicationTest.java", "java/src/com/rubyeventmachine/tests/ConnectTest.java", "java/src/com/rubyeventmachine/tests/EMTest.java", "java/src/com/rubyeventmachine/tests/TestDatagrams.java", "java/src/com/rubyeventmachine/tests/TestServers.java", "java/src/com/rubyeventmachine/tests/TestTimers.java", "lib/em/buftok.rb", "lib/em/callback.rb", "lib/em/channel.rb", "lib/em/connection.rb", "lib/em/deferrable.rb", "lib/em/file_watch.rb", "lib/em/future.rb", "lib/em/messages.rb", "lib/em/process_watch.rb", "lib/em/processes.rb", "lib/em/protocols.rb", "lib/em/protocols/header_and_content.rb", "lib/em/protocols/httpclient.rb", "lib/em/protocols/httpclient2.rb", "lib/em/protocols/line_and_text.rb", "lib/em/protocols/linetext2.rb", "lib/em/protocols/memcache.rb", "lib/em/protocols/object_protocol.rb", "lib/em/protocols/postgres3.rb", "lib/em/protocols/saslauth.rb", "lib/em/protocols/smtpclient.rb", "lib/em/protocols/smtpserver.rb", "lib/em/protocols/socks4.rb", "lib/em/protocols/stomp.rb", "lib/em/protocols/tcptest.rb", "lib/em/queue.rb", "lib/em/spawnable.rb", "lib/em/streamer.rb", "lib/em/timers.rb", "lib/em/version.rb", "lib/eventmachine.rb", "lib/evma.rb", "lib/evma/callback.rb", "lib/evma/container.rb", "lib/evma/factory.rb", "lib/evma/protocol.rb", "lib/evma/reactor.rb", "lib/jeventmachine.rb", "lib/pr_eventmachine.rb", "setup.rb", "tasks/cpp.rake_example", "tests/client.crt", "tests/client.key", "tests/test_attach.rb", "tests/test_basic.rb", "tests/test_channel.rb", "tests/test_connection_count.rb", "tests/test_defer.rb", "tests/test_epoll.rb", "tests/test_error_handler.rb", "tests/test_errors.rb", "tests/test_exc.rb", "tests/test_file_watch.rb", "tests/test_futures.rb", "tests/test_get_sock_opt.rb", "tests/test_handler_check.rb", "tests/test_hc.rb", "tests/test_httpclient.rb", "tests/test_httpclient2.rb", "tests/test_inactivity_timeout.rb", "tests/test_kb.rb", "tests/test_ltp.rb", "tests/test_ltp2.rb", "tests/test_next_tick.rb", "tests/test_object_protocol.rb", "tests/test_pause.rb", "tests/test_pending_connect_timeout.rb", "tests/test_process_watch.rb", "tests/test_processes.rb", "tests/test_proxy_connection.rb", "tests/test_pure.rb", "tests/test_queue.rb", "tests/test_running.rb", "tests/test_sasl.rb", "tests/test_send_file.rb", "tests/test_servers.rb", "tests/test_smtpclient.rb", "tests/test_smtpserver.rb", "tests/test_spawn.rb", "tests/test_ssl_args.rb", "tests/test_ssl_methods.rb", "tests/test_ssl_verify.rb", "tests/test_timers.rb", "tests/test_ud.rb", "tests/testem.rb", "web/whatis"] + s.homepage = %q{http://rubyeventmachine.com} + s.rdoc_options = ["--title", "EventMachine", "--main", "README", "--line-numbers", "-x", "lib/em/version", "-x", "lib/emva", "-x", "lib/evma/", "-x", "lib/pr_eventmachine", "-x", "lib/jeventmachine"] + s.require_paths = ["lib"] + s.rubyforge_project = %q{eventmachine} + s.rubygems_version = %q{1.3.5} + s.summary = %q{Ruby/EventMachine library} + + if s.respond_to? :specification_version then + current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION + s.specification_version = 3 + + if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then + else + end + else + end +end diff --git a/vendor/gems/specifications/extlib-0.9.13.gemspec b/vendor/gems/specifications/extlib-0.9.13.gemspec new file mode 100755 index 00000000..f070f543 --- /dev/null +++ b/vendor/gems/specifications/extlib-0.9.13.gemspec @@ -0,0 +1,28 @@ +# -*- encoding: utf-8 -*- + +Gem::Specification.new do |s| + s.name = %q{extlib} + s.version = "0.9.13" + + s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version= + s.authors = ["Dan Kubb"] + s.date = %q{2009-09-15} + s.description = %q{Support library for DataMapper and Merb.} + s.email = %q{dan.kubb@gmail.com} + s.extra_rdoc_files = ["LICENSE", "README", "History.txt"] + s.files = ["LICENSE", "README", "Rakefile", "History.txt", "lib/extlib/array.rb", "lib/extlib/assertions.rb", "lib/extlib/blank.rb", "lib/extlib/boolean.rb", "lib/extlib/byte_array.rb", "lib/extlib/class.rb", "lib/extlib/datetime.rb", "lib/extlib/dictionary.rb", "lib/extlib/hash.rb", "lib/extlib/hook.rb", "lib/extlib/inflection.rb", "lib/extlib/lazy_array.rb", "lib/extlib/lazy_module.rb", "lib/extlib/logger.rb", "lib/extlib/mash.rb", "lib/extlib/module.rb", "lib/extlib/nil.rb", "lib/extlib/numeric.rb", "lib/extlib/object.rb", "lib/extlib/object_space.rb", "lib/extlib/pathname.rb", "lib/extlib/pooling.rb", "lib/extlib/rubygems.rb", "lib/extlib/simple_set.rb", "lib/extlib/string.rb", "lib/extlib/struct.rb", "lib/extlib/symbol.rb", "lib/extlib/tasks/release.rb", "lib/extlib/time.rb", "lib/extlib/version.rb", "lib/extlib/virtual_file.rb", "lib/extlib.rb", "spec/array_spec.rb", "spec/blank_spec.rb", "spec/byte_array_spec.rb", "spec/class_spec.rb", "spec/datetime_spec.rb", "spec/hash_spec.rb", "spec/hook_spec.rb", "spec/inflection/plural_spec.rb", "spec/inflection/singular_spec.rb", "spec/inflection_extras_spec.rb", "spec/lazy_array_spec.rb", "spec/lazy_module_spec.rb", "spec/mash_spec.rb", "spec/module_spec.rb", "spec/object_space_spec.rb", "spec/object_spec.rb", "spec/pooling_spec.rb", "spec/simple_set_spec.rb", "spec/spec.opts", "spec/spec_helper.rb", "spec/string_spec.rb", "spec/struct_spec.rb", "spec/symbol_spec.rb", "spec/time_spec.rb", "spec/try_call_spec.rb", "spec/try_dup_spec.rb", "spec/virtual_file_spec.rb"] + s.homepage = %q{http://extlib.rubyforge.org} + s.require_paths = ["lib"] + s.rubygems_version = %q{1.3.5} + s.summary = %q{Support library for DataMapper and Merb.} + + if s.respond_to? :specification_version then + current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION + s.specification_version = 3 + + if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then + else + end + else + end +end diff --git a/vendor/gems/specifications/haml-2.2.13.gemspec b/vendor/gems/specifications/haml-2.2.13.gemspec new file mode 100755 index 00000000..a47ae274 --- /dev/null +++ b/vendor/gems/specifications/haml-2.2.13.gemspec @@ -0,0 +1,45 @@ +# -*- encoding: utf-8 -*- + +Gem::Specification.new do |s| + s.name = %q{haml} + s.version = "2.2.13" + + s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version= + s.authors = ["Nathan Weizenbaum", "Hampton Catlin"] + s.date = %q{2009-11-09} + s.description = %q{ Haml (HTML Abstraction Markup Language) is a layer on top of XHTML or XML + that's designed to express the structure of XHTML or XML documents + in a non-repetitive, elegant, easy way, + using indentation rather than closing tags + and allowing Ruby to be embedded with ease. + It was originally envisioned as a plugin for Ruby on Rails, + but it can function as a stand-alone templating engine. +} + s.email = %q{haml@googlegroups.com} + s.executables = ["haml", "html2haml", "sass", "css2sass"] + s.extra_rdoc_files = ["VERSION_NAME", "CONTRIBUTING", "README.md", "MIT-LICENSE", "VERSION", "REVISION"] + s.files = ["rails/init.rb", "lib/sass.rb", "lib/sass/css.rb", "lib/sass/script/node.rb", "lib/sass/script/number.rb", "lib/sass/script/operation.rb", "lib/sass/script/literal.rb", "lib/sass/script/functions.rb", "lib/sass/script/bool.rb", "lib/sass/script/color.rb", "lib/sass/script/lexer.rb", "lib/sass/script/parser.rb", "lib/sass/script/variable.rb", "lib/sass/script/string.rb", "lib/sass/script/funcall.rb", "lib/sass/script/unary_operation.rb", "lib/sass/script.rb", "lib/sass/error.rb", "lib/sass/repl.rb", "lib/sass/tree/comment_node.rb", "lib/sass/tree/node.rb", "lib/sass/tree/for_node.rb", "lib/sass/tree/debug_node.rb", "lib/sass/tree/import_node.rb", "lib/sass/tree/while_node.rb", "lib/sass/tree/mixin_def_node.rb", "lib/sass/tree/if_node.rb", "lib/sass/tree/mixin_node.rb", "lib/sass/tree/directive_node.rb", "lib/sass/tree/rule_node.rb", "lib/sass/tree/prop_node.rb", "lib/sass/tree/variable_node.rb", "lib/sass/plugin/rails.rb", "lib/sass/plugin/merb.rb", "lib/sass/environment.rb", "lib/sass/files.rb", "lib/sass/engine.rb", "lib/sass/plugin.rb", "lib/haml/filters.rb", "lib/haml/exec.rb", "lib/haml/error.rb", "lib/haml/template.rb", "lib/haml/shared.rb", "lib/haml/engine.rb", "lib/haml/version.rb", "lib/haml/template/patch.rb", "lib/haml/template/plugin.rb", "lib/haml/helpers.rb", "lib/haml/buffer.rb", "lib/haml/html.rb", "lib/haml/precompiler.rb", "lib/haml/util.rb", "lib/haml/helpers/action_view_mods.rb", "lib/haml/helpers/xss_mods.rb", "lib/haml/helpers/action_view_extensions.rb", "lib/haml.rb", "bin/sass", "bin/css2sass", "bin/html2haml", "bin/haml", "test/linked_rails.rb", "test/benchmark.rb", "test/sass/script_test.rb", "test/sass/css2sass_test.rb", "test/sass/results/units.css", "test/sass/results/parent_ref.css", "test/sass/results/compressed.css", "test/sass/results/complex.css", "test/sass/results/compact.css", "test/sass/results/mixins.css", "test/sass/results/line_numbers.css", "test/sass/results/alt.css", "test/sass/results/subdir/subdir.css", "test/sass/results/subdir/nested_subdir/nested_subdir.css", "test/sass/results/nested.css", "test/sass/results/import.css", "test/sass/results/multiline.css", "test/sass/results/script.css", "test/sass/results/basic.css", "test/sass/results/expanded.css", "test/sass/more_results/more_import.css", "test/sass/more_results/more1_with_line_comments.css", "test/sass/more_results/more1.css", "test/sass/templates/basic.sass", "test/sass/templates/bork.sass", "test/sass/templates/compressed.sass", "test/sass/templates/import.sass", "test/sass/templates/script.sass", "test/sass/templates/expanded.sass", "test/sass/templates/nested.sass", "test/sass/templates/_partial.sass", "test/sass/templates/line_numbers.sass", "test/sass/templates/compact.sass", "test/sass/templates/subdir/subdir.sass", "test/sass/templates/subdir/nested_subdir/nested_subdir.sass", "test/sass/templates/subdir/nested_subdir/_nested_partial.sass", "test/sass/templates/parent_ref.sass", "test/sass/templates/alt.sass", "test/sass/templates/importee.sass", "test/sass/templates/mixins.sass", "test/sass/templates/multiline.sass", "test/sass/templates/units.sass", "test/sass/templates/complex.sass", "test/sass/templates/bork2.sass", "test/sass/more_templates/_more_partial.sass", "test/sass/more_templates/more1.sass", "test/sass/more_templates/more_import.sass", "test/sass/functions_test.rb", "test/sass/engine_test.rb", "test/sass/plugin_test.rb", "test/haml/mocks/article.rb", "test/haml/rhtml/_av_partial_2.rhtml", "test/haml/rhtml/standard.rhtml", "test/haml/rhtml/_av_partial_1.rhtml", "test/haml/rhtml/action_view.rhtml", "test/haml/util_test.rb", "test/haml/spec/ruby_haml_test.rb", "test/haml/spec/README.md", "test/haml/spec/lua_haml_spec.lua", "test/haml/spec/tests.json", "test/haml/html2haml_test.rb", "test/haml/template_test.rb", "test/haml/helper_test.rb", "test/haml/results/tag_parsing.xhtml", "test/haml/results/content_for_layout.xhtml", "test/haml/results/helpers.xhtml", "test/haml/results/original_engine.xhtml", "test/haml/results/very_basic.xhtml", "test/haml/results/helpful.xhtml", "test/haml/results/list.xhtml", "test/haml/results/partials.xhtml", "test/haml/results/eval_suppressed.xhtml", "test/haml/results/nuke_inner_whitespace.xhtml", "test/haml/results/whitespace_handling.xhtml", "test/haml/results/render_layout.xhtml", "test/haml/results/silent_script.xhtml", "test/haml/results/standard.xhtml", "test/haml/results/just_stuff.xhtml", "test/haml/results/partial_layout.xhtml", "test/haml/results/filters.xhtml", "test/haml/results/nuke_outer_whitespace.xhtml", "test/haml/markaby/standard.mab", "test/haml/templates/tag_parsing.haml", "test/haml/templates/nuke_inner_whitespace.haml", "test/haml/templates/partial_layout.haml", "test/haml/templates/_av_partial_2_ugly.haml", "test/haml/templates/partials.haml", "test/haml/templates/_layout_for_partial.haml", "test/haml/templates/original_engine.haml", "test/haml/templates/helpers.haml", "test/haml/templates/_layout.erb", "test/haml/templates/action_view_ugly.haml", "test/haml/templates/content_for_layout.haml", "test/haml/templates/silent_script.haml", "test/haml/templates/very_basic.haml", "test/haml/templates/render_layout.haml", "test/haml/templates/filters.haml", "test/haml/templates/_av_partial_1.haml", "test/haml/templates/standard_ugly.haml", "test/haml/templates/_partial.haml", "test/haml/templates/nuke_outer_whitespace.haml", "test/haml/templates/breakage.haml", "test/haml/templates/list.haml", "test/haml/templates/standard.haml", "test/haml/templates/whitespace_handling.haml", "test/haml/templates/eval_suppressed.haml", "test/haml/templates/action_view.haml", "test/haml/templates/_av_partial_2.haml", "test/haml/templates/partialize.haml", "test/haml/templates/just_stuff.haml", "test/haml/templates/helpful.haml", "test/haml/templates/_av_partial_1_ugly.haml", "test/haml/templates/_text_area.haml", "test/haml/engine_test.rb", "test/test_helper.rb", "extra/haml-mode.el", "extra/sass-mode.el", "extra/update_watch.rb", "Rakefile", "init.rb", ".yardopts", "VERSION_NAME", "CONTRIBUTING", "README.md", "MIT-LICENSE", "VERSION", "REVISION"] + s.homepage = %q{http://haml.hamptoncatlin.com/} + s.rdoc_options = ["--title", "Haml", "--main", "README.rdoc", "--exclude", "lib/haml/buffer.rb", "--line-numbers", "--inline-source"] + s.require_paths = ["lib"] + s.rubyforge_project = %q{haml} + s.rubygems_version = %q{1.3.5} + s.summary = %q{An elegant, structured XHTML/XML templating engine. Comes with Sass, a similar CSS templating engine.} + s.test_files = ["test/sass/script_test.rb", "test/sass/css2sass_test.rb", "test/sass/functions_test.rb", "test/sass/engine_test.rb", "test/sass/plugin_test.rb", "test/haml/util_test.rb", "test/haml/spec/ruby_haml_test.rb", "test/haml/html2haml_test.rb", "test/haml/template_test.rb", "test/haml/helper_test.rb", "test/haml/engine_test.rb"] + + if s.respond_to? :specification_version then + current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION + s.specification_version = 3 + + if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then + s.add_development_dependency(%q, [">= 0.2.3"]) + s.add_development_dependency(%q, [">= 0.5.9"]) + else + s.add_dependency(%q, [">= 0.2.3"]) + s.add_dependency(%q, [">= 0.5.9"]) + end + else + s.add_dependency(%q, [">= 0.2.3"]) + s.add_dependency(%q, [">= 0.5.9"]) + end +end diff --git a/vendor/gems/specifications/highline-1.5.1.gemspec b/vendor/gems/specifications/highline-1.5.1.gemspec new file mode 100755 index 00000000..20417855 --- /dev/null +++ b/vendor/gems/specifications/highline-1.5.1.gemspec @@ -0,0 +1,31 @@ +# -*- encoding: utf-8 -*- + +Gem::Specification.new do |s| + s.name = %q{highline} + s.version = "1.5.1" + + s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version= + s.authors = ["James Edward Gray II"] + s.date = %q{2009-05-06} + s.description = %q{A high-level IO library that provides validation, type conversion, and more for command-line interfaces. HighLine also includes a complete menu system that can crank out anything from simple list selection to complete shells with just minutes of work.} + s.email = %q{james@grayproductions.net} + s.extra_rdoc_files = ["README", "INSTALL", "TODO", "CHANGELOG", "LICENSE"] + s.files = ["examples/ansi_colors.rb", "examples/asking_for_arrays.rb", "examples/basic_usage.rb", "examples/color_scheme.rb", "examples/limit.rb", "examples/menus.rb", "examples/overwrite.rb", "examples/page_and_wrap.rb", "examples/password.rb", "examples/trapping_eof.rb", "examples/using_readline.rb", "lib/highline/color_scheme.rb", "lib/highline/compatibility.rb", "lib/highline/import.rb", "lib/highline/menu.rb", "lib/highline/question.rb", "lib/highline/system_extensions.rb", "lib/highline.rb", "test/tc_color_scheme.rb", "test/tc_highline.rb", "test/tc_import.rb", "test/tc_menu.rb", "test/ts_all.rb", "Rakefile", "setup.rb", "README", "INSTALL", "TODO", "CHANGELOG", "LICENSE"] + s.homepage = %q{http://highline.rubyforge.org} + s.rdoc_options = ["--title", "HighLine Documentation", "--main", "README"] + s.require_paths = ["lib"] + s.rubyforge_project = %q{highline} + s.rubygems_version = %q{1.3.5} + s.summary = %q{HighLine is a high-level command-line IO library.} + s.test_files = ["test/ts_all.rb"] + + if s.respond_to? :specification_version then + current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION + s.specification_version = 2 + + if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then + else + end + else + end +end diff --git a/vendor/gems/specifications/json-1.2.0.gemspec b/vendor/gems/specifications/json-1.2.0.gemspec new file mode 100755 index 00000000..c898ca01 --- /dev/null +++ b/vendor/gems/specifications/json-1.2.0.gemspec @@ -0,0 +1,34 @@ +# -*- encoding: utf-8 -*- + +Gem::Specification.new do |s| + s.name = %q{json} + s.version = "1.2.0" + + s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version= + s.authors = ["Florian Frank"] + s.date = %q{2009-11-07} + s.default_executable = %q{edit_json.rb} + s.description = %q{This is a JSON implementation as a Ruby extension in C.} + s.email = %q{flori@ping.de} + s.executables = ["edit_json.rb", "prettify_json.rb"] + s.extensions = ["ext/json/ext/generator/extconf.rb", "ext/json/ext/parser/extconf.rb"] + s.extra_rdoc_files = ["README"] + s.files = ["CHANGES", "bin/edit_json.rb", "bin/prettify_json.rb", "VERSION", "GPL", "TODO", "README", "benchmarks/parser_benchmark.rb", "benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkPure.log", "benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkComparison.log", "benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkYAML#parser.dat", "benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkExt#generator_safe.dat", "benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkExt#parser.dat", "benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkExt#generator_fast.dat", "benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkExt#generator_fast-autocorrelation.dat", "benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkPure.log", "benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkExt#parser-autocorrelation.dat", "benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkRails#generator-autocorrelation.dat", "benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkExt.log", "benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkPure#generator_fast-autocorrelation.dat", "benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkPure#generator_fast.dat", "benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkRails#parser.dat", "benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkPure#generator_pretty-autocorrelation.dat", "benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkPure#parser-autocorrelation.dat", "benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkExt#generator_pretty.dat", "benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkRails.log", "benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkExt.log", "benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkRails.log", "benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkComparison.log", "benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkPure#generator_safe.dat", "benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkRails#generator.dat", "benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkExt#generator_safe-autocorrelation.dat", "benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkPure#generator_pretty.dat", "benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkYAML.log", "benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkYAML#parser-autocorrelation.dat", "benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkExt#generator_pretty-autocorrelation.dat", "benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkRails#parser-autocorrelation.dat", "benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkPure#parser.dat", "benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkPure#generator_safe-autocorrelation.dat", "benchmarks/generator_benchmark.rb", "ext/json/ext/generator/extconf.rb", "ext/json/ext/generator/unicode.c", "ext/json/ext/generator/generator.c", "ext/json/ext/generator/unicode.h", "ext/json/ext/parser/extconf.rb", "ext/json/ext/parser/parser.rl", "ext/json/ext/parser/unicode.c", "ext/json/ext/parser/parser.c", "ext/json/ext/parser/unicode.h", "Rakefile", "tools/fuzz.rb", "tools/server.rb", "lib/json.rb", "lib/json/json.xpm", "lib/json/Key.xpm", "lib/json/String.xpm", "lib/json/Numeric.xpm", "lib/json/Hash.xpm", "lib/json/add/rails.rb", "lib/json/add/core.rb", "lib/json/common.rb", "lib/json/Array.xpm", "lib/json/FalseClass.xpm", "lib/json/pure/generator.rb", "lib/json/pure/parser.rb", "lib/json/TrueClass.xpm", "lib/json/pure.rb", "lib/json/version.rb", "lib/json/ext.rb", "lib/json/editor.rb", "lib/json/NilClass.xpm", "data/example.json", "data/index.html", "data/prototype.js", "tests/test_json_encoding.rb", "tests/test_json_addition.rb", "tests/fixtures/pass16.json", "tests/fixtures/fail4.json", "tests/fixtures/fail1.json", "tests/fixtures/fail28.json", "tests/fixtures/fail8.json", "tests/fixtures/fail19.json", "tests/fixtures/pass2.json", "tests/fixtures/pass26.json", "tests/fixtures/pass1.json", "tests/fixtures/fail3.json", "tests/fixtures/fail20.json", "tests/fixtures/pass3.json", "tests/fixtures/pass15.json", "tests/fixtures/fail12.json", "tests/fixtures/fail13.json", "tests/fixtures/fail22.json", "tests/fixtures/fail24.json", "tests/fixtures/fail9.json", "tests/fixtures/fail2.json", "tests/fixtures/fail14.json", "tests/fixtures/fail6.json", "tests/fixtures/fail21.json", "tests/fixtures/fail7.json", "tests/fixtures/pass17.json", "tests/fixtures/fail11.json", "tests/fixtures/fail25.json", "tests/fixtures/fail5.json", "tests/fixtures/fail18.json", "tests/fixtures/fail27.json", "tests/fixtures/fail10.json", "tests/fixtures/fail23.json", "tests/test_json_rails.rb", "tests/test_json.rb", "tests/test_json_generate.rb", "tests/test_json_unicode.rb", "tests/test_json_fixtures.rb", "COPYING", "install.rb"] + s.homepage = %q{http://json.rubyforge.org} + s.rdoc_options = ["--title", "JSON -- A JSON implemention", "--main", "README"] + s.require_paths = ["ext/json/ext", "ext", "lib"] + s.rubyforge_project = %q{json} + s.rubygems_version = %q{1.3.5} + s.summary = %q{A JSON implementation as a Ruby extension} + s.test_files = ["tests/test_json_encoding.rb", "tests/test_json_addition.rb", "tests/test_json_rails.rb", "tests/test_json.rb", "tests/test_json_generate.rb", "tests/test_json_unicode.rb", "tests/test_json_fixtures.rb"] + + if s.respond_to? :specification_version then + current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION + s.specification_version = 3 + + if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then + else + end + else + end +end diff --git a/vendor/gems/specifications/launchy-0.3.3.gemspec b/vendor/gems/specifications/launchy-0.3.3.gemspec new file mode 100755 index 00000000..13be819f --- /dev/null +++ b/vendor/gems/specifications/launchy-0.3.3.gemspec @@ -0,0 +1,38 @@ +# -*- encoding: utf-8 -*- + +Gem::Specification.new do |s| + s.name = %q{launchy} + s.version = "0.3.3" + + s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version= + s.authors = ["Jeremy Hinegardner"] + s.date = %q{2009-02-18} + s.default_executable = %q{launchy} + s.description = %q{Launchy is helper class for launching cross-platform applications in a fire and forget manner. There are application concepts (browser, email client, etc) that are common across all platforms, and they may be launched differently on each platform. Launchy is here to make a common approach to launching external application from within ruby programs.} + s.email = %q{jeremy@copiousfreetime.org} + s.executables = ["launchy"] + s.extra_rdoc_files = ["README", "HISTORY", "LICENSE", "lib/launchy/application.rb", "lib/launchy/browser.rb", "lib/launchy/command_line.rb", "lib/launchy/paths.rb", "lib/launchy/version.rb", "lib/launchy.rb"] + s.files = ["bin/launchy", "lib/launchy/application.rb", "lib/launchy/browser.rb", "lib/launchy/command_line.rb", "lib/launchy/paths.rb", "lib/launchy/version.rb", "lib/launchy.rb", "spec/application_spec.rb", "spec/browser_spec.rb", "spec/launchy_spec.rb", "spec/paths_spec.rb", "spec/spec_helper.rb", "spec/version_spec.rb", "README", "HISTORY", "LICENSE", "tasks/announce.rake", "tasks/distribution.rake", "tasks/documentation.rake", "tasks/rspec.rake", "tasks/rubyforge.rake", "tasks/config.rb", "tasks/utils.rb", "Rakefile", "gemspec.rb"] + s.homepage = %q{http://copiousfreetime.rubyforge.org/launchy/} + s.rdoc_options = ["--line-numbers", "--inline-source", "--main", "README"] + s.require_paths = ["lib"] + s.rubyforge_project = %q{copiousfreetime} + s.rubygems_version = %q{1.3.5} + s.summary = %q{Launchy is helper class for launching cross-platform applications in a fire and forget manner} + + if s.respond_to? :specification_version then + current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION + s.specification_version = 2 + + if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then + s.add_runtime_dependency(%q, [">= 0.8.1"]) + s.add_runtime_dependency(%q, [">= 0.0.5"]) + else + s.add_dependency(%q, [">= 0.8.1"]) + s.add_dependency(%q, [">= 0.0.5"]) + end + else + s.add_dependency(%q, [">= 0.8.1"]) + s.add_dependency(%q, [">= 0.0.5"]) + end +end diff --git a/vendor/gems/specifications/polyglot-0.2.9.gemspec b/vendor/gems/specifications/polyglot-0.2.9.gemspec new file mode 100755 index 00000000..8ca1f453 --- /dev/null +++ b/vendor/gems/specifications/polyglot-0.2.9.gemspec @@ -0,0 +1,34 @@ +# -*- encoding: utf-8 -*- + +Gem::Specification.new do |s| + s.name = %q{polyglot} + s.version = "0.2.9" + + s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version= + s.authors = ["Clifford Heath"] + s.date = %q{2009-09-12} + s.description = %q{Allows custom language loaders for specified file extensions to be hooked into require} + s.email = %q{cjheath@rubyforge.org} + s.extra_rdoc_files = ["History.txt", "License.txt", "Manifest.txt", "README.txt"] + s.files = ["History.txt", "License.txt", "Manifest.txt", "README.txt", "Rakefile", "lib/polyglot.rb", "lib/polyglot/version.rb", "test/test_helper.rb", "test/test_polyglot.rb"] + s.homepage = %q{http://polyglot.rubyforge.org} + s.rdoc_options = ["--main", "README.txt"] + s.require_paths = ["lib"] + s.rubyforge_project = %q{polyglot} + s.rubygems_version = %q{1.3.5} + s.summary = %q{Allows custom language loaders for specified file extensions to be hooked into require} + s.test_files = ["test/test_helper.rb", "test/test_polyglot.rb"] + + if s.respond_to? :specification_version then + current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION + s.specification_version = 3 + + if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then + s.add_development_dependency(%q, [">= 2.3.2"]) + else + s.add_dependency(%q, [">= 2.3.2"]) + end + else + s.add_dependency(%q, [">= 2.3.2"]) + end +end diff --git a/vendor/gems/specifications/rack-1.0.1.gemspec b/vendor/gems/specifications/rack-1.0.1.gemspec new file mode 100755 index 00000000..3059c61c --- /dev/null +++ b/vendor/gems/specifications/rack-1.0.1.gemspec @@ -0,0 +1,53 @@ +# -*- encoding: utf-8 -*- + +Gem::Specification.new do |s| + s.name = %q{rack} + s.version = "1.0.1" + + s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version= + s.authors = ["Christian Neukirchen"] + s.date = %q{2009-10-17} + s.default_executable = %q{rackup} + s.description = %q{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.} + s.email = %q{chneukirchen@gmail.com} + s.executables = ["rackup"] + s.extra_rdoc_files = ["README", "SPEC", "RDOX", "KNOWN-ISSUES"] + s.files = ["COPYING", "KNOWN-ISSUES", "README", "Rakefile", "bin/rackup", "contrib/rack_logo.svg", "example/lobster.ru", "example/protectedlobster.rb", "example/protectedlobster.ru", "lib/rack.rb", "lib/rack/adapter/camping.rb", "lib/rack/auth/abstract/handler.rb", "lib/rack/auth/abstract/request.rb", "lib/rack/auth/basic.rb", "lib/rack/auth/digest/md5.rb", "lib/rack/auth/digest/nonce.rb", "lib/rack/auth/digest/params.rb", "lib/rack/auth/digest/request.rb", "lib/rack/auth/openid.rb", "lib/rack/builder.rb", "lib/rack/cascade.rb", "lib/rack/chunked.rb", "lib/rack/commonlogger.rb", "lib/rack/conditionalget.rb", "lib/rack/content_length.rb", "lib/rack/content_type.rb", "lib/rack/deflater.rb", "lib/rack/directory.rb", "lib/rack/file.rb", "lib/rack/handler.rb", "lib/rack/handler/cgi.rb", "lib/rack/handler/evented_mongrel.rb", "lib/rack/handler/fastcgi.rb", "lib/rack/handler/lsws.rb", "lib/rack/handler/mongrel.rb", "lib/rack/handler/scgi.rb", "lib/rack/handler/swiftiplied_mongrel.rb", "lib/rack/handler/thin.rb", "lib/rack/handler/webrick.rb", "lib/rack/head.rb", "lib/rack/lint.rb", "lib/rack/lobster.rb", "lib/rack/lock.rb", "lib/rack/methodoverride.rb", "lib/rack/mime.rb", "lib/rack/mock.rb", "lib/rack/recursive.rb", "lib/rack/reloader.rb", "lib/rack/request.rb", "lib/rack/response.rb", "lib/rack/rewindable_input.rb", "lib/rack/session/abstract/id.rb", "lib/rack/session/cookie.rb", "lib/rack/session/memcache.rb", "lib/rack/session/pool.rb", "lib/rack/showexceptions.rb", "lib/rack/showstatus.rb", "lib/rack/static.rb", "lib/rack/urlmap.rb", "lib/rack/utils.rb", "test/cgi/lighttpd.conf", "test/cgi/test", "test/cgi/test.fcgi", "test/cgi/test.ru", "test/multipart/binary", "test/multipart/empty", "test/multipart/ie", "test/multipart/nested", "test/multipart/none", "test/multipart/semicolon", "test/multipart/text", "test/spec_rack_auth_basic.rb", "test/spec_rack_auth_digest.rb", "test/spec_rack_auth_openid.rb", "test/spec_rack_builder.rb", "test/spec_rack_camping.rb", "test/spec_rack_cascade.rb", "test/spec_rack_cgi.rb", "test/spec_rack_chunked.rb", "test/spec_rack_commonlogger.rb", "test/spec_rack_conditionalget.rb", "test/spec_rack_content_length.rb", "test/spec_rack_content_type.rb", "test/spec_rack_deflater.rb", "test/spec_rack_directory.rb", "test/spec_rack_fastcgi.rb", "test/spec_rack_file.rb", "test/spec_rack_handler.rb", "test/spec_rack_head.rb", "test/spec_rack_lint.rb", "test/spec_rack_lobster.rb", "test/spec_rack_lock.rb", "test/spec_rack_methodoverride.rb", "test/spec_rack_mock.rb", "test/spec_rack_mongrel.rb", "test/spec_rack_recursive.rb", "test/spec_rack_request.rb", "test/spec_rack_response.rb", "test/spec_rack_rewindable_input.rb", "test/spec_rack_session_cookie.rb", "test/spec_rack_session_memcache.rb", "test/spec_rack_session_pool.rb", "test/spec_rack_showexceptions.rb", "test/spec_rack_showstatus.rb", "test/spec_rack_static.rb", "test/spec_rack_thin.rb", "test/spec_rack_urlmap.rb", "test/spec_rack_utils.rb", "test/spec_rack_webrick.rb", "test/testrequest.rb", "test/unregistered_handler/rack/handler/unregistered.rb", "test/unregistered_handler/rack/handler/unregistered_long_one.rb", "SPEC", "RDOX", "rack.gemspec"] + s.homepage = %q{http://rack.rubyforge.org} + s.require_paths = ["lib"] + s.rubyforge_project = %q{rack} + s.rubygems_version = %q{1.3.5} + s.summary = %q{a modular Ruby webserver interface} + s.test_files = ["test/spec_rack_auth_basic.rb", "test/spec_rack_auth_digest.rb", "test/spec_rack_auth_openid.rb", "test/spec_rack_builder.rb", "test/spec_rack_camping.rb", "test/spec_rack_cascade.rb", "test/spec_rack_cgi.rb", "test/spec_rack_chunked.rb", "test/spec_rack_commonlogger.rb", "test/spec_rack_conditionalget.rb", "test/spec_rack_content_length.rb", "test/spec_rack_content_type.rb", "test/spec_rack_deflater.rb", "test/spec_rack_directory.rb", "test/spec_rack_fastcgi.rb", "test/spec_rack_file.rb", "test/spec_rack_handler.rb", "test/spec_rack_head.rb", "test/spec_rack_lint.rb", "test/spec_rack_lobster.rb", "test/spec_rack_lock.rb", "test/spec_rack_methodoverride.rb", "test/spec_rack_mock.rb", "test/spec_rack_mongrel.rb", "test/spec_rack_recursive.rb", "test/spec_rack_request.rb", "test/spec_rack_response.rb", "test/spec_rack_rewindable_input.rb", "test/spec_rack_session_cookie.rb", "test/spec_rack_session_memcache.rb", "test/spec_rack_session_pool.rb", "test/spec_rack_showexceptions.rb", "test/spec_rack_showstatus.rb", "test/spec_rack_static.rb", "test/spec_rack_thin.rb", "test/spec_rack_urlmap.rb", "test/spec_rack_utils.rb", "test/spec_rack_webrick.rb"] + + if s.respond_to? :specification_version then + current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION + s.specification_version = 2 + + if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then + s.add_development_dependency(%q, [">= 0"]) + s.add_development_dependency(%q, [">= 0"]) + s.add_development_dependency(%q, [">= 0"]) + s.add_development_dependency(%q, [">= 0"]) + s.add_development_dependency(%q, [">= 0"]) + s.add_development_dependency(%q, ["~> 2.0.0"]) + s.add_development_dependency(%q, [">= 0"]) + else + s.add_dependency(%q, [">= 0"]) + s.add_dependency(%q, [">= 0"]) + s.add_dependency(%q, [">= 0"]) + s.add_dependency(%q, [">= 0"]) + s.add_dependency(%q, [">= 0"]) + s.add_dependency(%q, ["~> 2.0.0"]) + s.add_dependency(%q, [">= 0"]) + end + else + s.add_dependency(%q, [">= 0"]) + s.add_dependency(%q, [">= 0"]) + s.add_dependency(%q, [">= 0"]) + s.add_dependency(%q, [">= 0"]) + s.add_dependency(%q, [">= 0"]) + s.add_dependency(%q, ["~> 2.0.0"]) + s.add_dependency(%q, [">= 0"]) + end +end diff --git a/vendor/gems/specifications/rack-test-0.5.1.gemspec b/vendor/gems/specifications/rack-test-0.5.1.gemspec new file mode 100755 index 00000000..c71da071 --- /dev/null +++ b/vendor/gems/specifications/rack-test-0.5.1.gemspec @@ -0,0 +1,36 @@ +# -*- encoding: utf-8 -*- + +Gem::Specification.new do |s| + s.name = %q{rack-test} + s.version = "0.5.1" + + s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version= + s.authors = ["Bryan Helmkamp"] + s.date = %q{2009-10-26} + s.description = %q{Rack::Test is a small, simple testing API for Rack apps. It can be used on its +own or as a reusable starting point for Web frameworks and testing libraries +to build on. Most of its initial functionality is an extraction of Merb 1.0's +request helpers feature.} + s.email = %q{bryan@brynary.com} + s.extra_rdoc_files = ["README.rdoc", "MIT-LICENSE.txt"] + s.files = [".document", ".gitignore", "History.txt", "MIT-LICENSE.txt", "README.rdoc", "Rakefile", "Thorfile", "lib/rack/mock_session.rb", "lib/rack/test.rb", "lib/rack/test/cookie_jar.rb", "lib/rack/test/methods.rb", "lib/rack/test/mock_digest_request.rb", "lib/rack/test/uploaded_file.rb", "lib/rack/test/utils.rb", "rack-test.gemspec", "spec/fixtures/config.ru", "spec/fixtures/fake_app.rb", "spec/fixtures/foo.txt", "spec/rack/test/cookie_spec.rb", "spec/rack/test/digest_auth_spec.rb", "spec/rack/test/multipart_spec.rb", "spec/rack/test/utils_spec.rb", "spec/rack/test_spec.rb", "spec/spec.opts", "spec/spec_helper.rb"] + s.homepage = %q{http://github.com/brynary/rack-test} + s.require_paths = ["lib"] + s.rubyforge_project = %q{rack-test} + s.rubygems_version = %q{1.3.5} + s.summary = %q{Simple testing API built on Rack} + s.test_files = ["spec/fixtures/fake_app.rb", "spec/rack/test/cookie_spec.rb", "spec/rack/test/digest_auth_spec.rb", "spec/rack/test/multipart_spec.rb", "spec/rack/test/utils_spec.rb", "spec/rack/test_spec.rb", "spec/spec_helper.rb"] + + if s.respond_to? :specification_version then + current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION + s.specification_version = 3 + + if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then + s.add_runtime_dependency(%q, [">= 1.0"]) + else + s.add_dependency(%q, [">= 1.0"]) + end + else + s.add_dependency(%q, [">= 1.0"]) + end +end diff --git a/vendor/gems/specifications/rake-0.8.7.gemspec b/vendor/gems/specifications/rake-0.8.7.gemspec new file mode 100755 index 00000000..cfcf7017 --- /dev/null +++ b/vendor/gems/specifications/rake-0.8.7.gemspec @@ -0,0 +1,32 @@ +# -*- encoding: utf-8 -*- + +Gem::Specification.new do |s| + s.name = %q{rake} + s.version = "0.8.7" + + s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version= + s.authors = ["Jim Weirich"] + s.date = %q{2009-05-14} + s.default_executable = %q{rake} + s.description = %q{Rake is a Make-like program implemented in Ruby. Tasks and dependencies are specified in standard Ruby syntax.} + s.email = %q{jim@weirichhouse.org} + s.executables = ["rake"] + s.extra_rdoc_files = ["README", "MIT-LICENSE", "TODO", "CHANGES", "doc/command_line_usage.rdoc", "doc/glossary.rdoc", "doc/proto_rake.rdoc", "doc/rakefile.rdoc", "doc/rational.rdoc", "doc/release_notes/rake-0.4.14.rdoc", "doc/release_notes/rake-0.4.15.rdoc", "doc/release_notes/rake-0.5.0.rdoc", "doc/release_notes/rake-0.5.3.rdoc", "doc/release_notes/rake-0.5.4.rdoc", "doc/release_notes/rake-0.6.0.rdoc", "doc/release_notes/rake-0.7.0.rdoc", "doc/release_notes/rake-0.7.1.rdoc", "doc/release_notes/rake-0.7.2.rdoc", "doc/release_notes/rake-0.7.3.rdoc", "doc/release_notes/rake-0.8.0.rdoc", "doc/release_notes/rake-0.8.2.rdoc", "doc/release_notes/rake-0.8.3.rdoc", "doc/release_notes/rake-0.8.4.rdoc", "doc/release_notes/rake-0.8.5.rdoc", "doc/release_notes/rake-0.8.6.rdoc", "doc/release_notes/rake-0.8.7.rdoc"] + s.files = ["install.rb", "CHANGES", "MIT-LICENSE", "Rakefile", "README", "TODO", "bin/rake", "lib/rake/alt_system.rb", "lib/rake/classic_namespace.rb", "lib/rake/clean.rb", "lib/rake/contrib/compositepublisher.rb", "lib/rake/contrib/ftptools.rb", "lib/rake/contrib/publisher.rb", "lib/rake/contrib/rubyforgepublisher.rb", "lib/rake/contrib/sshpublisher.rb", "lib/rake/contrib/sys.rb", "lib/rake/gempackagetask.rb", "lib/rake/loaders/makefile.rb", "lib/rake/packagetask.rb", "lib/rake/rake_test_loader.rb", "lib/rake/rdoctask.rb", "lib/rake/ruby182_test_unit_fix.rb", "lib/rake/runtest.rb", "lib/rake/tasklib.rb", "lib/rake/testtask.rb", "lib/rake/win32.rb", "lib/rake.rb", "test/capture_stdout.rb", "test/check_expansion.rb", "test/check_no_expansion.rb", "test/contrib/test_sys.rb", "test/data/rakelib/test1.rb", "test/data/rbext/rakefile.rb", "test/filecreation.rb", "test/functional.rb", "test/in_environment.rb", "test/rake_test_setup.rb", "test/reqfile.rb", "test/reqfile2.rb", "test/session_functional.rb", "test/shellcommand.rb", "test/test_application.rb", "test/test_clean.rb", "test/test_definitions.rb", "test/test_earlytime.rb", "test/test_extension.rb", "test/test_file_creation_task.rb", "test/test_file_task.rb", "test/test_filelist.rb", "test/test_fileutils.rb", "test/test_ftp.rb", "test/test_invocation_chain.rb", "test/test_makefile_loader.rb", "test/test_multitask.rb", "test/test_namespace.rb", "test/test_package_task.rb", "test/test_pathmap.rb", "test/test_pseudo_status.rb", "test/test_rake.rb", "test/test_rdoc_task.rb", "test/test_require.rb", "test/test_rules.rb", "test/test_task_arguments.rb", "test/test_task_manager.rb", "test/test_tasklib.rb", "test/test_tasks.rb", "test/test_test_task.rb", "test/test_top_level_functions.rb", "test/test_win32.rb", "test/data/imports/deps.mf", "test/data/sample.mf", "test/data/chains/Rakefile", "test/data/default/Rakefile", "test/data/dryrun/Rakefile", "test/data/file_creation_task/Rakefile", "test/data/imports/Rakefile", "test/data/multidesc/Rakefile", "test/data/namespace/Rakefile", "test/data/statusreturn/Rakefile", "test/data/unittest/Rakefile", "test/data/unittest/subdir", "doc/command_line_usage.rdoc", "doc/example", "doc/example/a.c", "doc/example/b.c", "doc/example/main.c", "doc/example/Rakefile1", "doc/example/Rakefile2", "doc/glossary.rdoc", "doc/jamis.rb", "doc/proto_rake.rdoc", "doc/rake.1.gz", "doc/rakefile.rdoc", "doc/rational.rdoc", "doc/release_notes", "doc/release_notes/rake-0.4.14.rdoc", "doc/release_notes/rake-0.4.15.rdoc", "doc/release_notes/rake-0.5.0.rdoc", "doc/release_notes/rake-0.5.3.rdoc", "doc/release_notes/rake-0.5.4.rdoc", "doc/release_notes/rake-0.6.0.rdoc", "doc/release_notes/rake-0.7.0.rdoc", "doc/release_notes/rake-0.7.1.rdoc", "doc/release_notes/rake-0.7.2.rdoc", "doc/release_notes/rake-0.7.3.rdoc", "doc/release_notes/rake-0.8.0.rdoc", "doc/release_notes/rake-0.8.2.rdoc", "doc/release_notes/rake-0.8.3.rdoc", "doc/release_notes/rake-0.8.4.rdoc", "doc/release_notes/rake-0.8.5.rdoc", "doc/release_notes/rake-0.8.6.rdoc", "doc/release_notes/rake-0.8.7.rdoc"] + s.homepage = %q{http://rake.rubyforge.org} + s.rdoc_options = ["--line-numbers", "--main", "README", "--title", "Rake -- Ruby Make"] + s.require_paths = ["lib"] + s.rubyforge_project = %q{rake} + s.rubygems_version = %q{1.3.5} + s.summary = %q{Ruby based make-like utility.} + + if s.respond_to? :specification_version then + current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION + s.specification_version = 2 + + if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then + else + end + else + end +end diff --git a/vendor/gems/specifications/rdoc-2.4.3.gemspec b/vendor/gems/specifications/rdoc-2.4.3.gemspec new file mode 100755 index 00000000..76c7c4ba --- /dev/null +++ b/vendor/gems/specifications/rdoc-2.4.3.gemspec @@ -0,0 +1,47 @@ +# -*- encoding: utf-8 -*- + +Gem::Specification.new do |s| + s.name = %q{rdoc} + s.version = "2.4.3" + + s.required_rubygems_version = Gem::Requirement.new(">= 1.3") if s.respond_to? :required_rubygems_version= + s.authors = ["Eric Hodel", "Dave Thomas", "Phil Hagelberg", "Tony Strauss"] + s.cert_chain = ["-----BEGIN CERTIFICATE-----\nMIIDNjCCAh6gAwIBAgIBADANBgkqhkiG9w0BAQUFADBBMRAwDgYDVQQDDAdkcmJy\nYWluMRgwFgYKCZImiZPyLGQBGRYIc2VnbWVudDcxEzARBgoJkiaJk/IsZAEZFgNu\nZXQwHhcNMDcxMjIxMDIwNDE0WhcNMDgxMjIwMDIwNDE0WjBBMRAwDgYDVQQDDAdk\ncmJyYWluMRgwFgYKCZImiZPyLGQBGRYIc2VnbWVudDcxEzARBgoJkiaJk/IsZAEZ\nFgNuZXQwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCbbgLrGLGIDE76\nLV/cvxdEzCuYuS3oG9PrSZnuDweySUfdp/so0cDq+j8bqy6OzZSw07gdjwFMSd6J\nU5ddZCVywn5nnAQ+Ui7jMW54CYt5/H6f2US6U0hQOjJR6cpfiymgxGdfyTiVcvTm\nGj/okWrQl0NjYOYBpDi+9PPmaH2RmLJu0dB/NylsDnW5j6yN1BEI8MfJRR+HRKZY\nmUtgzBwF1V4KIZQ8EuL6I/nHVu07i6IkrpAgxpXUfdJQJi0oZAqXurAV3yTxkFwd\ng62YrrW26mDe+pZBzR6bpLE+PmXCzz7UxUq3AE0gPHbiMXie3EFE0oxnsU3lIduh\nsCANiQ8BAgMBAAGjOTA3MAkGA1UdEwQCMAAwCwYDVR0PBAQDAgSwMB0GA1UdDgQW\nBBS5k4Z75VSpdM0AclG2UvzFA/VW5DANBgkqhkiG9w0BAQUFAAOCAQEAHagT4lfX\nkP/hDaiwGct7XPuVGbrOsKRVD59FF5kETBxEc9UQ1clKWngf8JoVuEoKD774dW19\nbU0GOVWO+J6FMmT/Cp7nuFJ79egMf/gy4gfUfQMuvfcr6DvZUPIs9P/TlK59iMYF\nDIOQ3DxdF3rMzztNUCizN4taVscEsjCcgW6WkUJnGdqlu3OHWpQxZBJkBTjPCoc6\nUW6on70SFPmAy/5Cq0OJNGEWBfgD9q7rrs/X8GGwUWqXb85RXnUVi/P8Up75E0ag\n14jEc90kN+C7oI/AGCBN0j6JnEtYIEJZibjjDJTSMWlUKKkj30kq7hlUC2CepJ4v\nx52qPcexcYZR7w==\n-----END CERTIFICATE-----\n"] + s.date = %q{2009-04-01} + s.description = %q{RDoc is an application that produces documentation for one or more Ruby source +files. RDoc includes the +rdoc+ and +ri+ tools for generating and displaying +online documentation. + +At this point in time, RDoc 2.x is a work in progress and may incur further +API changes beyond what has been made to RDoc 1.0.1. Command-line tools are +largely unaffected, but internal APIs may shift rapidly. + +See RDoc for a description of RDoc's markup and basic use.} + s.email = ["drbrain@segment7.net", "", "technomancy@gmail.com", "tony.strauss@designingpatterns.com"] + s.executables = ["rdoc", "ri"] + s.extra_rdoc_files = ["History.txt", "Manifest.txt", "README.txt", "RI.txt"] + s.files = [".autotest", ".document", "History.txt", "Manifest.txt", "README.txt", "RI.txt", "Rakefile", "bin/rdoc", "bin/ri", "lib/rdoc.rb", "lib/rdoc/alias.rb", "lib/rdoc/anon_class.rb", "lib/rdoc/any_method.rb", "lib/rdoc/attr.rb", "lib/rdoc/cache.rb", "lib/rdoc/class_module.rb", "lib/rdoc/code_object.rb", "lib/rdoc/code_objects.rb", "lib/rdoc/constant.rb", "lib/rdoc/context.rb", "lib/rdoc/diagram.rb", "lib/rdoc/dot.rb", "lib/rdoc/generator.rb", "lib/rdoc/generator/darkfish.rb", "lib/rdoc/generator/markup.rb", "lib/rdoc/generator/ri.rb", "lib/rdoc/generator/template/darkfish/.document", "lib/rdoc/generator/template/darkfish/classpage.rhtml", "lib/rdoc/generator/template/darkfish/filepage.rhtml", "lib/rdoc/generator/template/darkfish/images/brick.png", "lib/rdoc/generator/template/darkfish/images/brick_link.png", "lib/rdoc/generator/template/darkfish/images/bug.png", "lib/rdoc/generator/template/darkfish/images/bullet_black.png", "lib/rdoc/generator/template/darkfish/images/bullet_toggle_minus.png", "lib/rdoc/generator/template/darkfish/images/bullet_toggle_plus.png", "lib/rdoc/generator/template/darkfish/images/date.png", "lib/rdoc/generator/template/darkfish/images/find.png", "lib/rdoc/generator/template/darkfish/images/loadingAnimation.gif", "lib/rdoc/generator/template/darkfish/images/macFFBgHack.png", "lib/rdoc/generator/template/darkfish/images/package.png", "lib/rdoc/generator/template/darkfish/images/page_green.png", "lib/rdoc/generator/template/darkfish/images/page_white_text.png", "lib/rdoc/generator/template/darkfish/images/page_white_width.png", "lib/rdoc/generator/template/darkfish/images/plugin.png", "lib/rdoc/generator/template/darkfish/images/ruby.png", "lib/rdoc/generator/template/darkfish/images/tag_green.png", "lib/rdoc/generator/template/darkfish/images/wrench.png", "lib/rdoc/generator/template/darkfish/images/wrench_orange.png", "lib/rdoc/generator/template/darkfish/images/zoom.png", "lib/rdoc/generator/template/darkfish/index.rhtml", "lib/rdoc/generator/template/darkfish/js/darkfish.js", "lib/rdoc/generator/template/darkfish/js/jquery.js", "lib/rdoc/generator/template/darkfish/js/quicksearch.js", "lib/rdoc/generator/template/darkfish/js/thickbox-compressed.js", "lib/rdoc/generator/template/darkfish/rdoc.css", "lib/rdoc/ghost_method.rb", "lib/rdoc/include.rb", "lib/rdoc/known_classes.rb", "lib/rdoc/markup.rb", "lib/rdoc/markup/attribute_manager.rb", "lib/rdoc/markup/formatter.rb", "lib/rdoc/markup/fragments.rb", "lib/rdoc/markup/inline.rb", "lib/rdoc/markup/lines.rb", "lib/rdoc/markup/preprocess.rb", "lib/rdoc/markup/to_flow.rb", "lib/rdoc/markup/to_html.rb", "lib/rdoc/markup/to_html_crossref.rb", "lib/rdoc/markup/to_latex.rb", "lib/rdoc/markup/to_test.rb", "lib/rdoc/markup/to_texinfo.rb", "lib/rdoc/meta_method.rb", "lib/rdoc/normal_class.rb", "lib/rdoc/normal_module.rb", "lib/rdoc/options.rb", "lib/rdoc/parser.rb", "lib/rdoc/parser/c.rb", "lib/rdoc/parser/perl.rb", "lib/rdoc/parser/ruby.rb", "lib/rdoc/parser/simple.rb", "lib/rdoc/rdoc.rb", "lib/rdoc/require.rb", "lib/rdoc/ri.rb", "lib/rdoc/ri/cache.rb", "lib/rdoc/ri/descriptions.rb", "lib/rdoc/ri/display.rb", "lib/rdoc/ri/driver.rb", "lib/rdoc/ri/formatter.rb", "lib/rdoc/ri/paths.rb", "lib/rdoc/ri/reader.rb", "lib/rdoc/ri/util.rb", "lib/rdoc/ri/writer.rb", "lib/rdoc/single_class.rb", "lib/rdoc/stats.rb", "lib/rdoc/task.rb", "lib/rdoc/tokenstream.rb", "lib/rdoc/top_level.rb", "test/binary.dat", "test/test.ja.rdoc", "test/test.ja.txt", "test/test_attribute_manager.rb", "test/test_rdoc_any_method.rb", "test/test_rdoc_code_object.rb", "test/test_rdoc_constant.rb", "test/test_rdoc_context.rb", "test/test_rdoc_include.rb", "test/test_rdoc_markup.rb", "test/test_rdoc_markup_attribute_manager.rb", "test/test_rdoc_markup_to_html.rb", "test/test_rdoc_markup_to_html_crossref.rb", "test/test_rdoc_normal_module.rb", "test/test_rdoc_parser.rb", "test/test_rdoc_parser_c.rb", "test/test_rdoc_parser_perl.rb", "test/test_rdoc_parser_ruby.rb", "test/test_rdoc_require.rb", "test/test_rdoc_ri_attribute_formatter.rb", "test/test_rdoc_ri_default_display.rb", "test/test_rdoc_ri_driver.rb", "test/test_rdoc_ri_formatter.rb", "test/test_rdoc_ri_html_formatter.rb", "test/test_rdoc_ri_overstrike_formatter.rb", "test/test_rdoc_task.rb", "test/test_rdoc_top_level.rb", "test/xref_data.rb", "test/xref_test_case.rb"] + s.homepage = %q{http://rdoc.rubyforge.org} + s.rdoc_options = ["--main", "README.txt"] + s.require_paths = ["lib"] + s.rubyforge_project = %q{rdoc} + s.rubygems_version = %q{1.3.5} + s.summary = %q{RDoc is an application that produces documentation for one or more Ruby source files} + s.test_files = ["test/test_attribute_manager.rb", "test/test_rdoc_any_method.rb", "test/test_rdoc_code_object.rb", "test/test_rdoc_constant.rb", "test/test_rdoc_context.rb", "test/test_rdoc_include.rb", "test/test_rdoc_markup.rb", "test/test_rdoc_markup_attribute_manager.rb", "test/test_rdoc_markup_to_html.rb", "test/test_rdoc_markup_to_html_crossref.rb", "test/test_rdoc_normal_module.rb", "test/test_rdoc_parser.rb", "test/test_rdoc_parser_c.rb", "test/test_rdoc_parser_perl.rb", "test/test_rdoc_parser_ruby.rb", "test/test_rdoc_require.rb", "test/test_rdoc_ri_attribute_formatter.rb", "test/test_rdoc_ri_default_display.rb", "test/test_rdoc_ri_driver.rb", "test/test_rdoc_ri_formatter.rb", "test/test_rdoc_ri_html_formatter.rb", "test/test_rdoc_ri_overstrike_formatter.rb", "test/test_rdoc_task.rb", "test/test_rdoc_top_level.rb"] + + if s.respond_to? :specification_version then + current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION + s.specification_version = 3 + + if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then + s.add_development_dependency(%q, ["~> 1.3"]) + s.add_development_dependency(%q, [">= 1.12.1"]) + else + s.add_dependency(%q, ["~> 1.3"]) + s.add_dependency(%q, [">= 1.12.1"]) + end + else + s.add_dependency(%q, ["~> 1.3"]) + s.add_dependency(%q, [">= 1.12.1"]) + end +end diff --git a/vendor/gems/specifications/rspec-1.2.9.gemspec b/vendor/gems/specifications/rspec-1.2.9.gemspec new file mode 100755 index 00000000..13d5aa26 --- /dev/null +++ b/vendor/gems/specifications/rspec-1.2.9.gemspec @@ -0,0 +1,58 @@ +# -*- encoding: utf-8 -*- + +Gem::Specification.new do |s| + s.name = %q{rspec} + s.version = "1.2.9" + + s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version= + s.authors = ["RSpec Development Team"] + s.date = %q{2009-10-04} + s.description = %q{Behaviour Driven Development for Ruby.} + s.email = ["rspec-devel@rubyforge.org"] + s.executables = ["autospec", "spec"] + s.extra_rdoc_files = ["License.txt", "Manifest.txt", "TODO.txt", "examples/failing/README.txt"] + s.files = [".document", "History.rdoc", "License.txt", "Manifest.txt", "README.rdoc", "Rakefile", "Ruby1.9.rdoc", "TODO.txt", "Upgrade.rdoc", "bin/autospec", "bin/spec", "cucumber.yml", "examples/failing/README.txt", "examples/failing/diffing_spec.rb", "examples/failing/failing_implicit_docstrings_example.rb", "examples/failing/failure_in_after.rb", "examples/failing/failure_in_before.rb", "examples/failing/mocking_example.rb", "examples/failing/mocking_with_flexmock.rb", "examples/failing/mocking_with_mocha.rb", "examples/failing/mocking_with_rr.rb", "examples/failing/partial_mock_example.rb", "examples/failing/pending_example.rb", "examples/failing/predicate_example.rb", "examples/failing/raising_example.rb", "examples/failing/syntax_error_example.rb", "examples/failing/team_spec.rb", "examples/failing/timeout_behaviour.rb", "examples/passing/custom_formatter.rb", "examples/passing/custom_matchers.rb", "examples/passing/dynamic_spec.rb", "examples/passing/file_accessor.rb", "examples/passing/file_accessor_spec.rb", "examples/passing/filtered_formatter.rb", "examples/passing/filtered_formatter_example.rb", "examples/passing/greeter_spec.rb", "examples/passing/helper_method_example.rb", "examples/passing/implicit_docstrings_example.rb", "examples/passing/io_processor.rb", "examples/passing/io_processor_spec.rb", "examples/passing/mocking_example.rb", "examples/passing/multi_threaded_example_group_runner.rb", "examples/passing/nested_classes_example.rb", "examples/passing/options_example.rb", "examples/passing/options_formatter.rb", "examples/passing/partial_mock_example.rb", "examples/passing/pending_example.rb", "examples/passing/predicate_example.rb", "examples/passing/shared_example_group_example.rb", "examples/passing/shared_stack_examples.rb", "examples/passing/simple_matcher_example.rb", "examples/passing/stack.rb", "examples/passing/stack_spec.rb", "examples/passing/stack_spec_with_nested_example_groups.rb", "examples/passing/stubbing_example.rb", "examples/passing/yielding_example.rb", "examples/ruby1.9.compatibility/access_to_constants_spec.rb", "features/before_and_after_blocks/before_and_after_blocks.feature", "features/command_line/line_number_option.feature", "features/command_line/line_number_option_with_example_with_no_name.feature", "features/example_groups/define_example_attribute.feature", "features/example_groups/example_group_with_should_methods.feature", "features/example_groups/implicit_docstrings.feature", "features/example_groups/nested_groups.feature", "features/expectations/customized_message.feature", "features/expectations/expect_change.feature", "features/expectations/expect_error.feature", "features/extensions/custom_example_group.feature", "features/formatters/custom_formatter.feature", "features/interop/examples_and_tests_together.feature", "features/interop/rspec_output.feature", "features/interop/test_but_not_test_unit.feature", "features/interop/test_case_with_should_methods.feature", "features/load_paths/add_lib_to_load_path.feature", "features/load_paths/add_spec_to_load_path.feature", "features/matchers/define_diffable_matcher.feature", "features/matchers/define_matcher.feature", "features/matchers/define_matcher_outside_rspec.feature", "features/matchers/define_matcher_with_fluent_interface.feature", "features/matchers/define_wrapped_matcher.feature", "features/mock_framework_integration/use_flexmock.feature", "features/mock_framework_integration/use_mocha.feature", "features/mock_framework_integration/use_rr.feature", "features/mocks/mix_stubs_and_mocks.feature", "features/mocks/stub_implementation.feature", "features/pending/pending_examples.feature", "features/runner/specify_line_number.feature", "features/spec_helper/spec_helper.feature", "features/step_definitions/running_rspec_steps.rb", "features/subject/explicit_subject.feature", "features/subject/implicit_subject.feature", "features/support/env.rb", "features/support/matchers/smart_match.rb", "init.rb", "lib/autotest/discover.rb", "lib/autotest/rspec.rb", "lib/spec.rb", "lib/spec/adapters/mock_frameworks/flexmock.rb", "lib/spec/adapters/mock_frameworks/mocha.rb", "lib/spec/adapters/mock_frameworks/rr.rb", "lib/spec/adapters/mock_frameworks/rspec.rb", "lib/spec/autorun.rb", "lib/spec/deprecation.rb", "lib/spec/dsl.rb", "lib/spec/dsl/main.rb", "lib/spec/example.rb", "lib/spec/example/args_and_options.rb", "lib/spec/example/before_and_after_hooks.rb", "lib/spec/example/errors.rb", "lib/spec/example/example_group.rb", "lib/spec/example/example_group_factory.rb", "lib/spec/example/example_group_hierarchy.rb", "lib/spec/example/example_group_methods.rb", "lib/spec/example/example_group_proxy.rb", "lib/spec/example/example_matcher.rb", "lib/spec/example/example_methods.rb", "lib/spec/example/example_proxy.rb", "lib/spec/example/module_reopening_fix.rb", "lib/spec/example/pending.rb", "lib/spec/example/predicate_matchers.rb", "lib/spec/example/shared_example_group.rb", "lib/spec/example/subject.rb", "lib/spec/expectations.rb", "lib/spec/expectations/errors.rb", "lib/spec/expectations/extensions.rb", "lib/spec/expectations/extensions/kernel.rb", "lib/spec/expectations/fail_with.rb", "lib/spec/expectations/handler.rb", "lib/spec/interop/test.rb", "lib/spec/interop/test/unit/autorunner.rb", "lib/spec/interop/test/unit/testcase.rb", "lib/spec/interop/test/unit/testresult.rb", "lib/spec/interop/test/unit/testsuite_adapter.rb", "lib/spec/interop/test/unit/ui/console/testrunner.rb", "lib/spec/matchers.rb", "lib/spec/matchers/be.rb", "lib/spec/matchers/be_close.rb", "lib/spec/matchers/be_instance_of.rb", "lib/spec/matchers/be_kind_of.rb", "lib/spec/matchers/change.rb", "lib/spec/matchers/compatibility.rb", "lib/spec/matchers/dsl.rb", "lib/spec/matchers/eql.rb", "lib/spec/matchers/equal.rb", "lib/spec/matchers/errors.rb", "lib/spec/matchers/exist.rb", "lib/spec/matchers/extensions/instance_exec.rb", "lib/spec/matchers/generated_descriptions.rb", "lib/spec/matchers/has.rb", "lib/spec/matchers/have.rb", "lib/spec/matchers/include.rb", "lib/spec/matchers/match.rb", "lib/spec/matchers/match_array.rb", "lib/spec/matchers/matcher.rb", "lib/spec/matchers/method_missing.rb", "lib/spec/matchers/operator_matcher.rb", "lib/spec/matchers/pretty.rb", "lib/spec/matchers/raise_error.rb", "lib/spec/matchers/respond_to.rb", "lib/spec/matchers/satisfy.rb", "lib/spec/matchers/simple_matcher.rb", "lib/spec/matchers/throw_symbol.rb", "lib/spec/matchers/wrap_expectation.rb", "lib/spec/mocks.rb", "lib/spec/mocks/argument_expectation.rb", "lib/spec/mocks/argument_matchers.rb", "lib/spec/mocks/error_generator.rb", "lib/spec/mocks/errors.rb", "lib/spec/mocks/example_methods.rb", "lib/spec/mocks/extensions.rb", "lib/spec/mocks/extensions/object.rb", "lib/spec/mocks/framework.rb", "lib/spec/mocks/message_expectation.rb", "lib/spec/mocks/methods.rb", "lib/spec/mocks/mock.rb", "lib/spec/mocks/order_group.rb", "lib/spec/mocks/proxy.rb", "lib/spec/mocks/space.rb", "lib/spec/rake/spectask.rb", "lib/spec/rake/verify_rcov.rb", "lib/spec/ruby.rb", "lib/spec/runner.rb", "lib/spec/runner/backtrace_tweaker.rb", "lib/spec/runner/class_and_arguments_parser.rb", "lib/spec/runner/command_line.rb", "lib/spec/runner/configuration.rb", "lib/spec/runner/differs/default.rb", "lib/spec/runner/differs/load-diff-lcs.rb", "lib/spec/runner/drb_command_line.rb", "lib/spec/runner/example_group_runner.rb", "lib/spec/runner/extensions/kernel.rb", "lib/spec/runner/formatter/base_formatter.rb", "lib/spec/runner/formatter/base_text_formatter.rb", "lib/spec/runner/formatter/failing_example_groups_formatter.rb", "lib/spec/runner/formatter/failing_examples_formatter.rb", "lib/spec/runner/formatter/html_formatter.rb", "lib/spec/runner/formatter/nested_text_formatter.rb", "lib/spec/runner/formatter/no_op_method_missing.rb", "lib/spec/runner/formatter/profile_formatter.rb", "lib/spec/runner/formatter/progress_bar_formatter.rb", "lib/spec/runner/formatter/silent_formatter.rb", "lib/spec/runner/formatter/snippet_extractor.rb", "lib/spec/runner/formatter/specdoc_formatter.rb", "lib/spec/runner/formatter/text_mate_formatter.rb", "lib/spec/runner/heckle_runner.rb", "lib/spec/runner/heckle_runner_unsupported.rb", "lib/spec/runner/line_number_query.rb", "lib/spec/runner/option_parser.rb", "lib/spec/runner/options.rb", "lib/spec/runner/reporter.rb", "lib/spec/stubs/cucumber.rb", "lib/spec/test/unit.rb", "lib/spec/version.rb", "resources/helpers/cmdline.rb", "resources/rake/examples.rake", "resources/rake/examples_with_rcov.rake", "resources/rake/failing_examples_with_html.rake", "resources/rake/verify_rcov.rake", "spec/README.jruby", "spec/autotest/autotest_helper.rb", "spec/autotest/autotest_matchers.rb", "spec/autotest/discover_spec.rb", "spec/autotest/failed_results_re_spec.rb", "spec/autotest/rspec_spec.rb", "spec/ruby_forker.rb", "spec/spec.opts", "spec/spec/dsl/main_spec.rb", "spec/spec/example/example_group_class_definition_spec.rb", "spec/spec/example/example_group_factory_spec.rb", "spec/spec/example/example_group_methods_spec.rb", "spec/spec/example/example_group_proxy_spec.rb", "spec/spec/example/example_group_spec.rb", "spec/spec/example/example_matcher_spec.rb", "spec/spec/example/example_methods_spec.rb", "spec/spec/example/example_proxy_spec.rb", "spec/spec/example/helper_method_spec.rb", "spec/spec/example/nested_example_group_spec.rb", "spec/spec/example/pending_module_spec.rb", "spec/spec/example/predicate_matcher_spec.rb", "spec/spec/example/shared_example_group_spec.rb", "spec/spec/example/subclassing_example_group_spec.rb", "spec/spec/example/subject_spec.rb", "spec/spec/expectations/differs/default_spec.rb", "spec/spec/expectations/extensions/kernel_spec.rb", "spec/spec/expectations/fail_with_spec.rb", "spec/spec/expectations/handler_spec.rb", "spec/spec/expectations/wrap_expectation_spec.rb", "spec/spec/interop/test/unit/resources/spec_that_fails.rb", "spec/spec/interop/test/unit/resources/spec_that_passes.rb", "spec/spec/interop/test/unit/resources/spec_with_errors.rb", "spec/spec/interop/test/unit/resources/spec_with_options_hash.rb", "spec/spec/interop/test/unit/resources/test_case_that_fails.rb", "spec/spec/interop/test/unit/resources/test_case_that_passes.rb", "spec/spec/interop/test/unit/resources/test_case_with_errors.rb", "spec/spec/interop/test/unit/resources/test_case_with_various_names.rb", "spec/spec/interop/test/unit/resources/testsuite_adapter_spec_with_test_unit.rb", "spec/spec/interop/test/unit/spec_spec.rb", "spec/spec/interop/test/unit/test_unit_spec_helper.rb", "spec/spec/interop/test/unit/testcase_spec.rb", "spec/spec/interop/test/unit/testsuite_adapter_spec.rb", "spec/spec/matchers/be_close_spec.rb", "spec/spec/matchers/be_instance_of_spec.rb", "spec/spec/matchers/be_kind_of_spec.rb", "spec/spec/matchers/be_spec.rb", "spec/spec/matchers/change_spec.rb", "spec/spec/matchers/compatibility_spec.rb", "spec/spec/matchers/description_generation_spec.rb", "spec/spec/matchers/dsl_spec.rb", "spec/spec/matchers/eql_spec.rb", "spec/spec/matchers/equal_spec.rb", "spec/spec/matchers/exist_spec.rb", "spec/spec/matchers/has_spec.rb", "spec/spec/matchers/have_spec.rb", "spec/spec/matchers/include_spec.rb", "spec/spec/matchers/match_array_spec.rb", "spec/spec/matchers/match_spec.rb", "spec/spec/matchers/matcher_methods_spec.rb", "spec/spec/matchers/matcher_spec.rb", "spec/spec/matchers/matchers_spec.rb", "spec/spec/matchers/operator_matcher_spec.rb", "spec/spec/matchers/raise_error_spec.rb", "spec/spec/matchers/respond_to_spec.rb", "spec/spec/matchers/satisfy_spec.rb", "spec/spec/matchers/simple_matcher_spec.rb", "spec/spec/matchers/throw_symbol_spec.rb", "spec/spec/mocks/any_number_of_times_spec.rb", "spec/spec/mocks/argument_expectation_spec.rb", "spec/spec/mocks/argument_matchers_spec.rb", "spec/spec/mocks/at_least_spec.rb", "spec/spec/mocks/at_most_spec.rb", "spec/spec/mocks/bug_report_10260_spec.rb", "spec/spec/mocks/bug_report_10263_spec.rb", "spec/spec/mocks/bug_report_11545_spec.rb", "spec/spec/mocks/bug_report_15719_spec.rb", "spec/spec/mocks/bug_report_496_spec.rb", "spec/spec/mocks/bug_report_600_spec.rb", "spec/spec/mocks/bug_report_7611_spec.rb", "spec/spec/mocks/bug_report_7805_spec.rb", "spec/spec/mocks/bug_report_8165_spec.rb", "spec/spec/mocks/bug_report_8302_spec.rb", "spec/spec/mocks/bug_report_830_spec.rb", "spec/spec/mocks/double_spec.rb", "spec/spec/mocks/failing_argument_matchers_spec.rb", "spec/spec/mocks/hash_including_matcher_spec.rb", "spec/spec/mocks/hash_not_including_matcher_spec.rb", "spec/spec/mocks/mock_ordering_spec.rb", "spec/spec/mocks/mock_space_spec.rb", "spec/spec/mocks/mock_spec.rb", "spec/spec/mocks/multiple_return_value_spec.rb", "spec/spec/mocks/nil_expectation_warning_spec.rb", "spec/spec/mocks/null_object_mock_spec.rb", "spec/spec/mocks/once_counts_spec.rb", "spec/spec/mocks/options_hash_spec.rb", "spec/spec/mocks/partial_mock_spec.rb", "spec/spec/mocks/partial_mock_using_mocks_directly_spec.rb", "spec/spec/mocks/passing_argument_matchers_spec.rb", "spec/spec/mocks/precise_counts_spec.rb", "spec/spec/mocks/record_messages_spec.rb", "spec/spec/mocks/stub_chain_spec.rb", "spec/spec/mocks/stub_implementation_spec.rb", "spec/spec/mocks/stub_spec.rb", "spec/spec/mocks/stubbed_message_expectations_spec.rb", "spec/spec/mocks/twice_counts_spec.rb", "spec/spec/mocks/unstub_spec.rb", "spec/spec/package/bin_spec_spec.rb", "spec/spec/rake/spectask_spec.rb", "spec/spec/runner/class_and_argument_parser_spec.rb", "spec/spec/runner/command_line_spec.rb", "spec/spec/runner/configuration_spec.rb", "spec/spec/runner/drb_command_line_spec.rb", "spec/spec/runner/empty_file.txt", "spec/spec/runner/example_group_runner_spec.rb", "spec/spec/runner/examples.txt", "spec/spec/runner/failed.txt", "spec/spec/runner/formatter/base_formatter_spec.rb", "spec/spec/runner/formatter/base_text_formatter_spec.rb", "spec/spec/runner/formatter/failing_example_groups_formatter_spec.rb", "spec/spec/runner/formatter/failing_examples_formatter_spec.rb", "spec/spec/runner/formatter/html_formatted-1.8.6-jruby.html", "spec/spec/runner/formatter/html_formatted-1.8.6.html", "spec/spec/runner/formatter/html_formatted-1.8.7.html", "spec/spec/runner/formatter/html_formatted-1.9.1.html", "spec/spec/runner/formatter/html_formatter_spec.rb", "spec/spec/runner/formatter/nested_text_formatter_spec.rb", "spec/spec/runner/formatter/profile_formatter_spec.rb", "spec/spec/runner/formatter/progress_bar_formatter_spec.rb", "spec/spec/runner/formatter/snippet_extractor_spec.rb", "spec/spec/runner/formatter/specdoc_formatter_spec.rb", "spec/spec/runner/formatter/text_mate_formatted-1.8.6-jruby.html", "spec/spec/runner/formatter/text_mate_formatted-1.8.6.html", "spec/spec/runner/formatter/text_mate_formatted-1.8.7.html", "spec/spec/runner/formatter/text_mate_formatted-1.9.1.html", "spec/spec/runner/formatter/text_mate_formatter_spec.rb", "spec/spec/runner/heckle_runner_spec.rb", "spec/spec/runner/heckler_spec.rb", "spec/spec/runner/line_number_query/line_number_query_fixture.rb", "spec/spec/runner/line_number_query_spec.rb", "spec/spec/runner/noisy_backtrace_tweaker_spec.rb", "spec/spec/runner/option_parser_spec.rb", "spec/spec/runner/options_spec.rb", "spec/spec/runner/output_one_time_fixture.rb", "spec/spec/runner/output_one_time_fixture_runner.rb", "spec/spec/runner/output_one_time_spec.rb", "spec/spec/runner/quiet_backtrace_tweaker_spec.rb", "spec/spec/runner/reporter_spec.rb", "spec/spec/runner/resources/a_bar.rb", "spec/spec/runner/resources/a_foo.rb", "spec/spec/runner/resources/a_spec.rb", "spec/spec/runner/resources/custom_example_group_runner.rb", "spec/spec/runner/resources/utf8_encoded.rb", "spec/spec/runner/spec.opts", "spec/spec/runner/spec_drb.opts", "spec/spec/runner/spec_spaced.opts", "spec/spec/runner_spec.rb", "spec/spec_helper.rb", "spec/support/macros.rb", "spec/support/spec_classes.rb"] + s.homepage = %q{http://rspec.info} + s.post_install_message = %q{************************************************** + + Thank you for installing rspec-1.2.9 + + Please be sure to read History.rdoc and Upgrade.rdoc + for useful information about this release. + +************************************************** +} + s.rdoc_options = ["--main", "README.rdoc"] + s.require_paths = ["lib"] + s.rubyforge_project = %q{rspec} + s.rubygems_version = %q{1.3.5} + s.summary = %q{rspec 1.2.9} + + if s.respond_to? :specification_version then + current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION + s.specification_version = 3 + + if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then + s.add_development_dependency(%q, [">= 0.3"]) + s.add_development_dependency(%q, [">= 0.1.1"]) + s.add_development_dependency(%q, [">= 1.0"]) + s.add_development_dependency(%q, [">= 1.1.2"]) + s.add_development_dependency(%q, [">= 1.4.3"]) + s.add_development_dependency(%q, [">= 2.3.3"]) + else + s.add_dependency(%q, [">= 0.3"]) + s.add_dependency(%q, [">= 0.1.1"]) + s.add_dependency(%q, [">= 1.0"]) + s.add_dependency(%q, [">= 1.1.2"]) + s.add_dependency(%q, [">= 1.4.3"]) + s.add_dependency(%q, [">= 2.3.3"]) + end + else + s.add_dependency(%q, [">= 0.3"]) + s.add_dependency(%q, [">= 0.1.1"]) + s.add_dependency(%q, [">= 1.0"]) + s.add_dependency(%q, [">= 1.1.2"]) + s.add_dependency(%q, [">= 1.4.3"]) + s.add_dependency(%q, [">= 2.3.3"]) + end +end diff --git a/vendor/gems/specifications/sdoc-0.2.14.1.gemspec b/vendor/gems/specifications/sdoc-0.2.14.1.gemspec new file mode 100755 index 00000000..535e3523 --- /dev/null +++ b/vendor/gems/specifications/sdoc-0.2.14.1.gemspec @@ -0,0 +1,35 @@ +# -*- encoding: utf-8 -*- + +Gem::Specification.new do |s| + s.name = %q{sdoc} + s.version = "0.2.14.1" + + s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version= + s.authors = ["Volodya Kolesnikov"] + s.date = %q{2009-08-13} + s.email = %q{voloko@gmail.com} + s.executables = ["sdoc", "sdoc-merge"] + s.extra_rdoc_files = ["LICENSE", "README.rdoc"] + s.files = [".gitignore", "LICENSE", "README.rdoc", "Rakefile", "VERSION.yml", "bin/sdoc", "bin/sdoc-merge", "lib/rdoc/discover.rb", "lib/sdoc.rb", "lib/sdoc/c_parser_fix.rb", "lib/sdoc/generator/shtml.rb", "lib/sdoc/generator/template/direct/_context.rhtml", "lib/sdoc/generator/template/direct/class.rhtml", "lib/sdoc/generator/template/direct/file.rhtml", "lib/sdoc/generator/template/direct/index.rhtml", "lib/sdoc/generator/template/direct/resources/apple-touch-icon.png", "lib/sdoc/generator/template/direct/resources/css/main.css", "lib/sdoc/generator/template/direct/resources/css/panel.css", "lib/sdoc/generator/template/direct/resources/css/reset.css", "lib/sdoc/generator/template/direct/resources/favicon.ico", "lib/sdoc/generator/template/direct/resources/i/arrows.png", "lib/sdoc/generator/template/direct/resources/i/results_bg.png", "lib/sdoc/generator/template/direct/resources/i/tree_bg.png", "lib/sdoc/generator/template/direct/resources/js/jquery-1.3.2.min.js", "lib/sdoc/generator/template/direct/resources/js/jquery-effect.js", "lib/sdoc/generator/template/direct/resources/js/main.js", "lib/sdoc/generator/template/direct/resources/js/searchdoc.js", "lib/sdoc/generator/template/direct/resources/panel/index.html", "lib/sdoc/generator/template/merge/index.rhtml", "lib/sdoc/generator/template/shtml/_context.rhtml", "lib/sdoc/generator/template/shtml/class.rhtml", "lib/sdoc/generator/template/shtml/file.rhtml", "lib/sdoc/generator/template/shtml/index.rhtml", "lib/sdoc/generator/template/shtml/resources/apple-touch-icon.png", "lib/sdoc/generator/template/shtml/resources/css/main.css", "lib/sdoc/generator/template/shtml/resources/css/panel.css", "lib/sdoc/generator/template/shtml/resources/css/reset.css", "lib/sdoc/generator/template/shtml/resources/favicon.ico", "lib/sdoc/generator/template/shtml/resources/i/arrows.png", "lib/sdoc/generator/template/shtml/resources/i/results_bg.png", "lib/sdoc/generator/template/shtml/resources/i/tree_bg.png", "lib/sdoc/generator/template/shtml/resources/js/jquery-1.3.2.min.js", "lib/sdoc/generator/template/shtml/resources/js/main.js", "lib/sdoc/generator/template/shtml/resources/js/searchdoc.js", "lib/sdoc/generator/template/shtml/resources/panel/index.html", "lib/sdoc/github.rb", "lib/sdoc/helpers.rb", "lib/sdoc/merge.rb", "lib/sdoc/templatable.rb", "sdoc.gemspec"] + s.homepage = %q{http://github.com/voloko/sdoc} + s.rdoc_options = ["--charset=UTF-8"] + s.require_paths = ["lib"] + s.rubygems_version = %q{1.3.5} + s.summary = %q{rdoc html with javascript search index.} + + if s.respond_to? :specification_version then + current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION + s.specification_version = 3 + + if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then + s.add_runtime_dependency(%q, [">= 1.1.3"]) + s.add_runtime_dependency(%q, [">= 2.4.2"]) + else + s.add_dependency(%q, [">= 1.1.3"]) + s.add_dependency(%q, [">= 2.4.2"]) + end + else + s.add_dependency(%q, [">= 1.1.3"]) + s.add_dependency(%q, [">= 2.4.2"]) + end +end diff --git a/vendor/gems/specifications/shotgun-0.4.gemspec b/vendor/gems/specifications/shotgun-0.4.gemspec new file mode 100755 index 00000000..85abd25d --- /dev/null +++ b/vendor/gems/specifications/shotgun-0.4.gemspec @@ -0,0 +1,37 @@ +# -*- encoding: utf-8 -*- + +Gem::Specification.new do |s| + s.name = %q{shotgun} + s.version = "0.4" + + s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version= + s.authors = ["Ryan Tomayko"] + s.date = %q{2009-03-22} + s.default_executable = %q{shotgun} + s.description = %q{Because reloading sucks.} + s.email = %q{r@tomayko.com} + s.executables = ["shotgun"] + s.extra_rdoc_files = ["README"] + s.files = ["README", "COPYING", "Rakefile", "shotgun.gemspec", "lib/shotgun.rb", "bin/shotgun"] + s.homepage = %q{http://github.com/rtomayko/shotgun/} + s.require_paths = ["lib"] + s.rubyforge_project = %q{wink} + s.rubygems_version = %q{1.3.5} + s.summary = %q{Because reloading sucks.} + + if s.respond_to? :specification_version then + current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION + s.specification_version = 2 + + if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then + s.add_runtime_dependency(%q, [">= 0.9.1"]) + s.add_runtime_dependency(%q, [">= 0.3.3", "< 1.0"]) + else + s.add_dependency(%q, [">= 0.9.1"]) + s.add_dependency(%q, [">= 0.3.3", "< 1.0"]) + end + else + s.add_dependency(%q, [">= 0.9.1"]) + s.add_dependency(%q, [">= 0.3.3", "< 1.0"]) + end +end diff --git a/vendor/gems/specifications/sinatra-0.9.4.gemspec b/vendor/gems/specifications/sinatra-0.9.4.gemspec new file mode 100755 index 00000000..d4f7584a --- /dev/null +++ b/vendor/gems/specifications/sinatra-0.9.4.gemspec @@ -0,0 +1,40 @@ +# -*- encoding: utf-8 -*- + +Gem::Specification.new do |s| + s.name = %q{sinatra} + s.version = "0.9.4" + + s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version= + s.authors = ["Blake Mizerany"] + s.date = %q{2009-07-26} + s.description = %q{Classy web-development dressed in a DSL} + s.email = %q{sinatrarb@googlegroups.com} + s.extra_rdoc_files = ["README.rdoc", "LICENSE"] + s.files = ["AUTHORS", "CHANGES", "LICENSE", "README.rdoc", "Rakefile", "compat/app_test.rb", "compat/application_test.rb", "compat/builder_test.rb", "compat/compat_test.rb", "compat/custom_error_test.rb", "compat/erb_test.rb", "compat/events_test.rb", "compat/filter_test.rb", "compat/haml_test.rb", "compat/helper.rb", "compat/mapped_error_test.rb", "compat/pipeline_test.rb", "compat/public/foo.xml", "compat/sass_test.rb", "compat/sessions_test.rb", "compat/streaming_test.rb", "compat/sym_params_test.rb", "compat/template_test.rb", "compat/use_in_file_templates_test.rb", "compat/views/foo.builder", "compat/views/foo.erb", "compat/views/foo.haml", "compat/views/foo.sass", "compat/views/foo_layout.erb", "compat/views/foo_layout.haml", "compat/views/layout_test/foo.builder", "compat/views/layout_test/foo.erb", "compat/views/layout_test/foo.haml", "compat/views/layout_test/foo.sass", "compat/views/layout_test/layout.builder", "compat/views/layout_test/layout.erb", "compat/views/layout_test/layout.haml", "compat/views/layout_test/layout.sass", "compat/views/no_layout/no_layout.builder", "compat/views/no_layout/no_layout.haml", "lib/sinatra.rb", "lib/sinatra/base.rb", "lib/sinatra/compat.rb", "lib/sinatra/images/404.png", "lib/sinatra/images/500.png", "lib/sinatra/main.rb", "lib/sinatra/showexceptions.rb", "lib/sinatra/test.rb", "lib/sinatra/test/bacon.rb", "lib/sinatra/test/rspec.rb", "lib/sinatra/test/spec.rb", "lib/sinatra/test/unit.rb", "sinatra.gemspec", "test/base_test.rb", "test/builder_test.rb", "test/contest.rb", "test/data/reload_app_file.rb", "test/erb_test.rb", "test/extensions_test.rb", "test/filter_test.rb", "test/haml_test.rb", "test/helper.rb", "test/helpers_test.rb", "test/mapped_error_test.rb", "test/middleware_test.rb", "test/options_test.rb", "test/render_backtrace_test.rb", "test/request_test.rb", "test/response_test.rb", "test/result_test.rb", "test/route_added_hook_test.rb", "test/routing_test.rb", "test/sass_test.rb", "test/server_test.rb", "test/sinatra_test.rb", "test/static_test.rb", "test/templates_test.rb", "test/test_test.rb", "test/views/error.builder", "test/views/error.erb", "test/views/error.haml", "test/views/error.sass", "test/views/foo/hello.test", "test/views/hello.builder", "test/views/hello.erb", "test/views/hello.haml", "test/views/hello.sass", "test/views/hello.test", "test/views/layout2.builder", "test/views/layout2.erb", "test/views/layout2.haml", "test/views/layout2.test"] + s.homepage = %q{http://sinatra.rubyforge.org} + s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Sinatra", "--main", "README.rdoc"] + s.require_paths = ["lib"] + s.rubyforge_project = %q{sinatra} + s.rubygems_version = %q{1.3.5} + s.summary = %q{Classy web-development dressed in a DSL} + s.test_files = ["test/base_test.rb", "test/builder_test.rb", "test/erb_test.rb", "test/extensions_test.rb", "test/filter_test.rb", "test/haml_test.rb", "test/helpers_test.rb", "test/mapped_error_test.rb", "test/middleware_test.rb", "test/options_test.rb", "test/render_backtrace_test.rb", "test/request_test.rb", "test/response_test.rb", "test/result_test.rb", "test/route_added_hook_test.rb", "test/routing_test.rb", "test/sass_test.rb", "test/server_test.rb", "test/sinatra_test.rb", "test/static_test.rb", "test/templates_test.rb", "test/test_test.rb"] + + if s.respond_to? :specification_version then + current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION + s.specification_version = 2 + + if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then + s.add_runtime_dependency(%q, [">= 0.9.1"]) + s.add_development_dependency(%q, [">= 0.2", "< 1.0"]) + s.add_development_dependency(%q, [">= 0.3.0"]) + else + s.add_dependency(%q, [">= 0.9.1"]) + s.add_dependency(%q, [">= 0.2", "< 1.0"]) + s.add_dependency(%q, [">= 0.3.0"]) + end + else + s.add_dependency(%q, [">= 0.9.1"]) + s.add_dependency(%q, [">= 0.2", "< 1.0"]) + s.add_dependency(%q, [">= 0.3.0"]) + end +end diff --git a/vendor/gems/specifications/sinatra-content-for-0.2.gemspec b/vendor/gems/specifications/sinatra-content-for-0.2.gemspec new file mode 100755 index 00000000..342d29e8 --- /dev/null +++ b/vendor/gems/specifications/sinatra-content-for-0.2.gemspec @@ -0,0 +1,40 @@ +# -*- encoding: utf-8 -*- + +Gem::Specification.new do |s| + s.name = %q{sinatra-content-for} + s.version = "0.2" + + s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version= + s.authors = ["Nicol\303\241s Sanguinetti"] + s.date = %q{2009-05-08} + s.description = %q{Small Sinatra extension to add a content_for helper similar to Rails'} + s.email = %q{contacto@nicolassanguinetti.info} + s.files = [".gitignore", "LICENSE", "README.rdoc", "sinatra-content-for.gemspec", "lib/sinatra/content_for.rb", "test/content_for_test.rb"] + s.homepage = %q{http://sinatrarb.com} + s.require_paths = ["lib"] + s.rubyforge_project = %q{sinatra-ditties} + s.rubygems_version = %q{1.3.5} + s.summary = %q{Small Sinatra extension to add a content_for helper similar to Rails'} + + if s.respond_to? :specification_version then + current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION + s.specification_version = 3 + + if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then + s.add_runtime_dependency(%q, [">= 0"]) + s.add_development_dependency(%q, [">= 0"]) + s.add_development_dependency(%q, [">= 0"]) + s.add_development_dependency(%q, [">= 0"]) + else + s.add_dependency(%q, [">= 0"]) + s.add_dependency(%q, [">= 0"]) + s.add_dependency(%q, [">= 0"]) + s.add_dependency(%q, [">= 0"]) + end + else + s.add_dependency(%q, [">= 0"]) + s.add_dependency(%q, [">= 0"]) + s.add_dependency(%q, [">= 0"]) + s.add_dependency(%q, [">= 0"]) + end +end diff --git a/vendor/gems/specifications/sprockets-1.0.2.gemspec b/vendor/gems/specifications/sprockets-1.0.2.gemspec new file mode 100755 index 00000000..ab0c5425 --- /dev/null +++ b/vendor/gems/specifications/sprockets-1.0.2.gemspec @@ -0,0 +1,31 @@ +# -*- encoding: utf-8 -*- + +Gem::Specification.new do |s| + s.name = %q{sprockets} + s.version = "1.0.2" + + s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version= + s.authors = ["Sam Stephenson"] + s.date = %q{2009-02-23} + s.default_executable = %q{sprocketize} + s.description = %q{Sprockets is a Ruby library that preprocesses and concatenates JavaScript source files.} + s.email = %q{sstephenson@gmail.com} + s.executables = ["sprocketize"] + s.files = ["Rakefile", "bin/sprocketize", "lib/sprockets", "lib/sprockets/concatenation.rb", "lib/sprockets/environment.rb", "lib/sprockets/error.rb", "lib/sprockets/pathname.rb", "lib/sprockets/preprocessor.rb", "lib/sprockets/secretary.rb", "lib/sprockets/source_file.rb", "lib/sprockets/source_line.rb", "lib/sprockets/version.rb", "lib/sprockets.rb", "test/fixtures", "test/fixtures/assets", "test/fixtures/assets/images", "test/fixtures/assets/images/script_with_assets", "test/fixtures/assets/images/script_with_assets/one.png", "test/fixtures/assets/images/script_with_assets/two.png", "test/fixtures/assets/stylesheets", "test/fixtures/assets/stylesheets/script_with_assets.css", "test/fixtures/constants.yml", "test/fixtures/double_slash_comments_that_are_not_requires_should_be_ignored_when_strip_comments_is_false.js", "test/fixtures/double_slash_comments_that_are_not_requires_should_be_removed_by_default.js", "test/fixtures/multiline_comments_should_be_removed_by_default.js", "test/fixtures/requiring_a_file_after_it_has_already_been_required_should_do_nothing.js", "test/fixtures/requiring_a_file_that_does_not_exist_should_raise_an_error.js", "test/fixtures/requiring_a_single_file_should_replace_the_require_comment_with_the_file_contents.js", "test/fixtures/requiring_the_current_file_should_do_nothing.js", "test/fixtures/src", "test/fixtures/src/constants.yml", "test/fixtures/src/foo", "test/fixtures/src/foo/bar.js", "test/fixtures/src/foo/foo.js", "test/fixtures/src/foo.js", "test/fixtures/src/script_with_assets.js", "test/test_concatenation.rb", "test/test_environment.rb", "test/test_helper.rb", "test/test_pathname.rb", "test/test_preprocessor.rb", "test/test_secretary.rb", "test/test_source_file.rb", "test/test_source_line.rb", "ext/nph-sprockets.cgi"] + s.homepage = %q{http://getsprockets.org/} + s.require_paths = ["lib"] + s.rubyforge_project = %q{sprockets} + s.rubygems_version = %q{1.3.5} + s.summary = %q{JavaScript dependency management and concatenation} + s.test_files = ["test/test_concatenation.rb", "test/test_environment.rb", "test/test_helper.rb", "test/test_pathname.rb", "test/test_preprocessor.rb", "test/test_secretary.rb", "test/test_source_file.rb", "test/test_source_line.rb"] + + if s.respond_to? :specification_version then + current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION + s.specification_version = 2 + + if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then + else + end + else + end +end diff --git a/vendor/gems/specifications/templater-1.0.0.gemspec b/vendor/gems/specifications/templater-1.0.0.gemspec new file mode 100755 index 00000000..8c2bad94 --- /dev/null +++ b/vendor/gems/specifications/templater-1.0.0.gemspec @@ -0,0 +1,54 @@ +# -*- encoding: utf-8 -*- + +Gem::Specification.new do |s| + s.name = %q{templater} + s.version = "1.0.0" + + s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version= + s.authors = ["Jonas Nicklas"] + s.date = %q{2009-08-27} + s.description = %q{Templater has the ability to both copy files from A to B and also to render templates using ERB. Templater consists of four parts: + +- Actions (File copying routines, templates generation and directories creation routines). +- Generators (set of rules). +- Manifolds (generator suites). +- The command line interface. + +Hierarchy is pretty simple: manifold has one or many public and private generators. Public ones are supposed to be called +by end user. Generators have one or more action that specify what they do, where they take files, how they name resulting +files and so forth.} + s.email = ["jonas.nicklas@gmail.com"] + s.extra_rdoc_files = ["History.txt", "Manifest.txt"] + s.files = ["History.txt", "Manifest.txt", "README.rdoc", "Rakefile", "lib/templater.rb", "lib/templater/actions/action.rb", "lib/templater/actions/directory.rb", "lib/templater/actions/empty_directory.rb", "lib/templater/actions/file.rb", "lib/templater/actions/template.rb", "lib/templater/capture_helpers.rb", "lib/templater/cli/generator.rb", "lib/templater/cli/manifold.rb", "lib/templater/cli/parser.rb", "lib/templater/core_ext/kernel.rb", "lib/templater/core_ext/string.rb", "lib/templater/description.rb", "lib/templater/discovery.rb", "lib/templater/generator.rb", "lib/templater/manifold.rb", "lib/templater/spec/helpers.rb", "script/console", "script/destroy", "script/generate", "spec/actions/directory_spec.rb", "spec/actions/empty_directory_spec.rb", "spec/actions/file_spec.rb", "spec/actions/template_spec.rb", "spec/core_ext/string_spec.rb", "spec/generator/actions_spec.rb", "spec/generator/arguments_spec.rb", "spec/generator/desc_spec.rb", "spec/generator/destination_root_spec.rb", "spec/generator/empty_directories_spec.rb", "spec/generator/files_spec.rb", "spec/generator/generators_spec.rb", "spec/generator/glob_spec.rb", "spec/generator/invocations_spec.rb", "spec/generator/invoke_spec.rb", "spec/generator/options_spec.rb", "spec/generator/render_spec.rb", "spec/generator/source_root_spec.rb", "spec/generator/templates_spec.rb", "spec/manifold_spec.rb", "spec/options_parser_spec.rb", "spec/results/erb.rbs", "spec/results/file.rbs", "spec/results/random.rbs", "spec/results/simple_erb.rbs", "spec/spec_helper.rb", "spec/spec_helpers_spec.rb", "spec/templater_spec.rb", "spec/templates/erb.rbt", "spec/templates/glob/README", "spec/templates/glob/arg.js", "spec/templates/glob/hellothar.%feh%", "spec/templates/glob/hellothar.html.%feh%", "spec/templates/glob/subfolder/jessica_alba.jpg", "spec/templates/glob/subfolder/monkey.rb", "spec/templates/glob/test.rb", "spec/templates/literals_erb.rbt", "spec/templates/simple.rbt", "spec/templates/simple_erb.rbt", "templater.gemspec"] + s.homepage = %q{http://github.com/jnicklas/templater} + s.rdoc_options = ["--main", "README.rdoc"] + s.require_paths = ["lib"] + s.rubyforge_project = %q{templater} + s.rubygems_version = %q{1.3.5} + s.summary = %q{Templater has the ability to both copy files from A to B and also to render templates using ERB} + + if s.respond_to? :specification_version then + current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION + s.specification_version = 3 + + if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then + s.add_runtime_dependency(%q, [">= 1.4.0"]) + s.add_runtime_dependency(%q, [">= 1.1.2"]) + s.add_runtime_dependency(%q, [">= 0.9.5"]) + s.add_development_dependency(%q, [">= 1.2.8"]) + s.add_development_dependency(%q, [">= 2.3.3"]) + else + s.add_dependency(%q, [">= 1.4.0"]) + s.add_dependency(%q, [">= 1.1.2"]) + s.add_dependency(%q, [">= 0.9.5"]) + s.add_dependency(%q, [">= 1.2.8"]) + s.add_dependency(%q, [">= 2.3.3"]) + end + else + s.add_dependency(%q, [">= 1.4.0"]) + s.add_dependency(%q, [">= 1.1.2"]) + s.add_dependency(%q, [">= 0.9.5"]) + s.add_dependency(%q, [">= 1.2.8"]) + s.add_dependency(%q, [">= 2.3.3"]) + end +end diff --git a/vendor/gems/specifications/term-ansicolor-1.0.4.gemspec b/vendor/gems/specifications/term-ansicolor-1.0.4.gemspec new file mode 100755 index 00000000..765669fe --- /dev/null +++ b/vendor/gems/specifications/term-ansicolor-1.0.4.gemspec @@ -0,0 +1,30 @@ +# -*- encoding: utf-8 -*- + +Gem::Specification.new do |s| + s.name = %q{term-ansicolor} + s.version = "1.0.4" + + s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version= + s.authors = ["Florian Frank"] + s.date = %q{2009-07-22} + s.description = %q{} + s.email = %q{flori@ping.de} + s.extra_rdoc_files = ["doc-main.txt"] + s.files = ["CHANGES", "COPYING", "README", "Rakefile", "VERSION", "examples/cdiff.rb", "examples/example.rb", "install.rb", "lib/term/ansicolor.rb", "lib/term/ansicolor/version.rb", "term-ansicolor.gemspec", "doc-main.txt"] + s.homepage = %q{http://term-ansicolor.rubyforge.org} + s.rdoc_options = ["--main", "doc-main.txt"] + s.require_paths = ["lib"] + s.rubyforge_project = %q{term-ansicolor} + s.rubygems_version = %q{1.3.5} + s.summary = %q{Ruby library that colors strings using ANSI escape sequences} + + if s.respond_to? :specification_version then + current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION + s.specification_version = 3 + + if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then + else + end + else + end +end diff --git a/vendor/gems/specifications/thin-1.2.5.gemspec b/vendor/gems/specifications/thin-1.2.5.gemspec new file mode 100755 index 00000000..7fe3fed5 --- /dev/null +++ b/vendor/gems/specifications/thin-1.2.5.gemspec @@ -0,0 +1,41 @@ +# -*- encoding: utf-8 -*- + +Gem::Specification.new do |s| + s.name = %q{thin} + s.version = "1.2.5" + + s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version= + s.authors = ["Marc-Andre Cournoyer"] + s.date = %q{2009-11-03} + s.default_executable = %q{thin} + s.description = %q{A thin and fast web server} + s.email = %q{macournoyer@gmail.com} + s.executables = ["thin"] + s.extensions = ["ext/thin_parser/extconf.rb"] + s.files = ["COPYING", "CHANGELOG", "README", "Rakefile", "benchmark/abc", "benchmark/benchmarker.rb", "benchmark/runner", "bin/thin", "example/adapter.rb", "example/async_app.ru", "example/async_chat.ru", "example/async_tailer.ru", "example/config.ru", "example/monit_sockets", "example/monit_unixsock", "example/myapp.rb", "example/ramaze.ru", "example/thin.god", "example/thin_solaris_smf.erb", "example/thin_solaris_smf.readme.txt", "example/vlad.rake", "lib/rack/adapter/loader.rb", "lib/rack/adapter/rails.rb", "lib/thin/backends/base.rb", "lib/thin/backends/swiftiply_client.rb", "lib/thin/backends/tcp_server.rb", "lib/thin/backends/unix_server.rb", "lib/thin/command.rb", "lib/thin/connection.rb", "lib/thin/controllers/cluster.rb", "lib/thin/controllers/controller.rb", "lib/thin/controllers/service.rb", "lib/thin/controllers/service.sh.erb", "lib/thin/daemonizing.rb", "lib/thin/headers.rb", "lib/thin/logging.rb", "lib/thin/request.rb", "lib/thin/response.rb", "lib/thin/runner.rb", "lib/thin/server.rb", "lib/thin/stats.html.erb", "lib/thin/stats.rb", "lib/thin/statuses.rb", "lib/thin/version.rb", "lib/thin.rb", "lib/thin_parser.bundle", "spec/backends/swiftiply_client_spec.rb", "spec/backends/tcp_server_spec.rb", "spec/backends/unix_server_spec.rb", "spec/command_spec.rb", "spec/configs/cluster.yml", "spec/configs/single.yml", "spec/connection_spec.rb", "spec/controllers/cluster_spec.rb", "spec/controllers/controller_spec.rb", "spec/controllers/service_spec.rb", "spec/daemonizing_spec.rb", "spec/headers_spec.rb", "spec/logging_spec.rb", "spec/perf/request_perf_spec.rb", "spec/perf/response_perf_spec.rb", "spec/perf/server_perf_spec.rb", "spec/rack/loader_spec.rb", "spec/rack/rails_adapter_spec.rb", "spec/rails_app/app/controllers/application.rb", "spec/rails_app/app/controllers/simple_controller.rb", "spec/rails_app/app/helpers/application_helper.rb", "spec/rails_app/app/views/simple/index.html.erb", "spec/rails_app/config/boot.rb", "spec/rails_app/config/environment.rb", "spec/rails_app/config/environments/development.rb", "spec/rails_app/config/environments/production.rb", "spec/rails_app/config/environments/test.rb", "spec/rails_app/config/initializers/inflections.rb", "spec/rails_app/config/initializers/mime_types.rb", "spec/rails_app/config/routes.rb", "spec/rails_app/public/404.html", "spec/rails_app/public/422.html", "spec/rails_app/public/500.html", "spec/rails_app/public/dispatch.cgi", "spec/rails_app/public/dispatch.fcgi", "spec/rails_app/public/dispatch.rb", "spec/rails_app/public/favicon.ico", "spec/rails_app/public/images/rails.png", "spec/rails_app/public/index.html", "spec/rails_app/public/javascripts/application.js", "spec/rails_app/public/javascripts/controls.js", "spec/rails_app/public/javascripts/dragdrop.js", "spec/rails_app/public/javascripts/effects.js", "spec/rails_app/public/javascripts/prototype.js", "spec/rails_app/public/robots.txt", "spec/rails_app/script/about", "spec/rails_app/script/console", "spec/rails_app/script/destroy", "spec/rails_app/script/generate", "spec/rails_app/script/performance/benchmarker", "spec/rails_app/script/performance/profiler", "spec/rails_app/script/performance/request", "spec/rails_app/script/plugin", "spec/rails_app/script/process/inspector", "spec/rails_app/script/process/reaper", "spec/rails_app/script/process/spawner", "spec/rails_app/script/runner", "spec/rails_app/script/server", "spec/request/mongrel_spec.rb", "spec/request/parser_spec.rb", "spec/request/persistent_spec.rb", "spec/request/processing_spec.rb", "spec/response_spec.rb", "spec/runner_spec.rb", "spec/server/builder_spec.rb", "spec/server/pipelining_spec.rb", "spec/server/robustness_spec.rb", "spec/server/stopping_spec.rb", "spec/server/swiftiply.yml", "spec/server/swiftiply_spec.rb", "spec/server/tcp_spec.rb", "spec/server/threaded_spec.rb", "spec/server/unix_socket_spec.rb", "spec/server_spec.rb", "spec/spec_helper.rb", "tasks/announce.rake", "tasks/deploy.rake", "tasks/email.erb", "tasks/gem.rake", "tasks/rdoc.rake", "tasks/site.rake", "tasks/spec.rake", "tasks/stats.rake", "ext/thin_parser/ext_help.h", "ext/thin_parser/parser.h", "ext/thin_parser/parser.c", "ext/thin_parser/thin.c", "ext/thin_parser/extconf.rb", "ext/thin_parser/common.rl", "ext/thin_parser/parser.rl"] + s.homepage = %q{http://code.macournoyer.com/thin/} + s.require_paths = ["lib"] + s.required_ruby_version = Gem::Requirement.new(">= 1.8.5") + s.rubyforge_project = %q{thin} + s.rubygems_version = %q{1.3.5} + s.summary = %q{A thin and fast web server} + + if s.respond_to? :specification_version then + current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION + s.specification_version = 3 + + if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then + s.add_runtime_dependency(%q, [">= 1.0.0"]) + s.add_runtime_dependency(%q, [">= 0.12.6"]) + s.add_runtime_dependency(%q, [">= 1.0.9"]) + else + s.add_dependency(%q, [">= 1.0.0"]) + s.add_dependency(%q, [">= 0.12.6"]) + s.add_dependency(%q, [">= 1.0.9"]) + end + else + s.add_dependency(%q, [">= 1.0.0"]) + s.add_dependency(%q, [">= 0.12.6"]) + s.add_dependency(%q, [">= 1.0.9"]) + end +end diff --git a/vendor/gems/specifications/treetop-1.4.2.gemspec b/vendor/gems/specifications/treetop-1.4.2.gemspec new file mode 100755 index 00000000..c333514b --- /dev/null +++ b/vendor/gems/specifications/treetop-1.4.2.gemspec @@ -0,0 +1,32 @@ +# -*- encoding: utf-8 -*- + +Gem::Specification.new do |s| + s.name = %q{treetop} + s.version = "1.4.2" + + s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version= + s.authors = ["Nathan Sobo"] + s.autorequire = %q{treetop} + s.date = %q{2009-09-10} + s.default_executable = %q{tt} + s.email = %q{nathansobo@gmail.com} + s.executables = ["tt"] + s.files = ["LICENSE", "README.md", "Rakefile", "lib/treetop/bootstrap_gen_1_metagrammar.rb", "lib/treetop/compiler/grammar_compiler.rb", "lib/treetop/compiler/lexical_address_space.rb", "lib/treetop/compiler/metagrammar.rb", "lib/treetop/compiler/metagrammar.treetop", "lib/treetop/compiler/node_classes/anything_symbol.rb", "lib/treetop/compiler/node_classes/atomic_expression.rb", "lib/treetop/compiler/node_classes/character_class.rb", "lib/treetop/compiler/node_classes/choice.rb", "lib/treetop/compiler/node_classes/declaration_sequence.rb", "lib/treetop/compiler/node_classes/grammar.rb", "lib/treetop/compiler/node_classes/inline_module.rb", "lib/treetop/compiler/node_classes/nonterminal.rb", "lib/treetop/compiler/node_classes/optional.rb", "lib/treetop/compiler/node_classes/parenthesized_expression.rb", "lib/treetop/compiler/node_classes/parsing_expression.rb", "lib/treetop/compiler/node_classes/parsing_rule.rb", "lib/treetop/compiler/node_classes/predicate.rb", "lib/treetop/compiler/node_classes/predicate_block.rb", "lib/treetop/compiler/node_classes/repetition.rb", "lib/treetop/compiler/node_classes/sequence.rb", "lib/treetop/compiler/node_classes/terminal.rb", "lib/treetop/compiler/node_classes/transient_prefix.rb", "lib/treetop/compiler/node_classes/treetop_file.rb", "lib/treetop/compiler/node_classes.rb", "lib/treetop/compiler/ruby_builder.rb", "lib/treetop/compiler.rb", "lib/treetop/ruby_extensions/string.rb", "lib/treetop/ruby_extensions.rb", "lib/treetop/runtime/compiled_parser.rb", "lib/treetop/runtime/interval_skip_list/head_node.rb", "lib/treetop/runtime/interval_skip_list/interval_skip_list.rb", "lib/treetop/runtime/interval_skip_list/node.rb", "lib/treetop/runtime/interval_skip_list.rb", "lib/treetop/runtime/syntax_node.rb", "lib/treetop/runtime/terminal_parse_failure.rb", "lib/treetop/runtime/terminal_parse_failure_debug.rb", "lib/treetop/runtime/terminal_syntax_node.rb", "lib/treetop/runtime.rb", "lib/treetop/version.rb", "lib/treetop.rb", "bin/tt", "doc/contributing_and_planned_features.markdown", "doc/grammar_composition.markdown", "doc/index.markdown", "doc/pitfalls_and_advanced_techniques.markdown", "doc/semantic_interpretation.markdown", "doc/site.rb", "doc/sitegen.rb", "doc/syntactic_recognition.markdown", "doc/using_in_ruby.markdown", "examples/lambda_calculus/arithmetic.rb", "examples/lambda_calculus/arithmetic.treetop", "examples/lambda_calculus/arithmetic_node_classes.rb", "examples/lambda_calculus/arithmetic_test.rb", "examples/lambda_calculus/lambda_calculus", "examples/lambda_calculus/lambda_calculus.rb", "examples/lambda_calculus/lambda_calculus.treetop", "examples/lambda_calculus/lambda_calculus_node_classes.rb", "examples/lambda_calculus/lambda_calculus_test.rb", "examples/lambda_calculus/test_helper.rb"] + s.homepage = %q{http://functionalform.blogspot.com} + s.require_paths = ["lib"] + s.rubygems_version = %q{1.3.5} + s.summary = %q{A Ruby-based text parsing and interpretation DSL} + + if s.respond_to? :specification_version then + current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION + s.specification_version = 3 + + if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then + s.add_runtime_dependency(%q, [">= 0.2.5"]) + else + s.add_dependency(%q, [">= 0.2.5"]) + end + else + s.add_dependency(%q, [">= 0.2.5"]) + end +end diff --git a/vendor/gems/specifications/yui-compressor-0.9.1.gemspec b/vendor/gems/specifications/yui-compressor-0.9.1.gemspec new file mode 100755 index 00000000..8b84ba0d --- /dev/null +++ b/vendor/gems/specifications/yui-compressor-0.9.1.gemspec @@ -0,0 +1,29 @@ +# -*- encoding: utf-8 -*- + +Gem::Specification.new do |s| + s.name = %q{yui-compressor} + s.version = "0.9.1" + + s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version= + s.authors = ["Sam Stephenson"] + s.date = %q{2009-07-19} + s.description = %q{A Ruby interface to YUI Compressor for minifying JavaScript and CSS assets.} + s.email = %q{sstephenson@gmail.com} + s.files = ["Rakefile", "lib/yui/compressor.rb", "test/compressor_test.rb", "vendor/yuicompressor-2.4.2.jar"] + s.homepage = %q{http://github.com/sstephenson/ruby-yui-compressor/} + s.require_paths = ["lib"] + s.rubyforge_project = %q{yui} + s.rubygems_version = %q{1.3.5} + s.summary = %q{JavaScript and CSS minification library} + s.test_files = ["test/compressor_test.rb"] + + if s.respond_to? :specification_version then + current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION + s.specification_version = 3 + + if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then + else + end + else + end +end