mack 0.8.1 → 0.8.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGELOG +22 -1
- data/bin/mack +3 -0
- data/bin/mackery-console +4 -0
- data/bin/mackery-server +21 -4
- data/lib/gems.rb +15 -0
- data/lib/gems/abstract-1.0.0/lib/abstract.rb +75 -0
- data/lib/gems/builder-2.1.2/lib/blankslate.rb +113 -0
- data/lib/gems/builder-2.1.2/lib/builder.rb +13 -0
- data/lib/gems/builder-2.1.2/lib/builder/blankslate.rb +20 -0
- data/lib/gems/builder-2.1.2/lib/builder/css.rb +250 -0
- data/lib/gems/builder-2.1.2/lib/builder/xchar.rb +115 -0
- data/lib/gems/builder-2.1.2/lib/builder/xmlbase.rb +139 -0
- data/lib/gems/builder-2.1.2/lib/builder/xmlevents.rb +63 -0
- data/lib/gems/builder-2.1.2/lib/builder/xmlmarkup.rb +328 -0
- data/lib/gems/configatron-2.1.5/lib/configatron.rb +6 -0
- data/lib/gems/configatron-2.1.5/lib/configatron/configatron.rb +52 -0
- data/lib/gems/configatron-2.1.5/lib/configatron/errors.rb +7 -0
- data/lib/gems/configatron-2.1.5/lib/configatron/kernel.rb +8 -0
- data/lib/gems/configatron-2.1.5/lib/configatron/store.rb +224 -0
- data/lib/gems/daemons-1.0.10/lib/daemons.rb +283 -0
- data/lib/gems/daemons-1.0.10/lib/daemons/application.rb +372 -0
- data/lib/gems/daemons-1.0.10/lib/daemons/application_group.rb +152 -0
- data/lib/gems/daemons-1.0.10/lib/daemons/cmdline.rb +117 -0
- data/lib/gems/daemons-1.0.10/lib/daemons/controller.rb +134 -0
- data/lib/gems/daemons-1.0.10/lib/daemons/daemonize.rb +263 -0
- data/lib/gems/daemons-1.0.10/lib/daemons/exceptions.rb +28 -0
- data/lib/gems/daemons-1.0.10/lib/daemons/monitor.rb +127 -0
- data/lib/gems/daemons-1.0.10/lib/daemons/pid.rb +101 -0
- data/lib/gems/daemons-1.0.10/lib/daemons/pidfile.rb +111 -0
- data/lib/gems/daemons-1.0.10/lib/daemons/pidmem.rb +10 -0
- data/lib/gems/flexmock-0.8.3/lib/flexmock.rb +13 -0
- data/lib/gems/flexmock-0.8.3/lib/flexmock/argument_matchers.rb +57 -0
- data/lib/gems/flexmock-0.8.3/lib/flexmock/argument_types.rb +42 -0
- data/lib/gems/flexmock-0.8.3/lib/flexmock/base.rb +24 -0
- data/lib/gems/flexmock-0.8.3/lib/flexmock/composite.rb +10 -0
- data/lib/gems/flexmock-0.8.3/lib/flexmock/core.rb +218 -0
- data/lib/gems/flexmock-0.8.3/lib/flexmock/core_class_methods.rb +83 -0
- data/lib/gems/flexmock-0.8.3/lib/flexmock/default_framework_adapter.rb +31 -0
- data/lib/gems/flexmock-0.8.3/lib/flexmock/deprecated_methods.rb +62 -0
- data/lib/gems/flexmock-0.8.3/lib/flexmock/errors.rb +23 -0
- data/lib/gems/flexmock-0.8.3/lib/flexmock/expectation.rb +476 -0
- data/lib/gems/flexmock-0.8.3/lib/flexmock/expectation_director.rb +87 -0
- data/lib/gems/flexmock-0.8.3/lib/flexmock/mock_container.rb +321 -0
- data/lib/gems/flexmock-0.8.3/lib/flexmock/noop.rb +13 -0
- data/lib/gems/flexmock-0.8.3/lib/flexmock/ordering.rb +51 -0
- data/lib/gems/flexmock-0.8.3/lib/flexmock/partial_mock.rb +291 -0
- data/lib/gems/flexmock-0.8.3/lib/flexmock/rails.rb +15 -0
- data/lib/gems/flexmock-0.8.3/lib/flexmock/rails/view_mocking.rb +102 -0
- data/lib/gems/flexmock-0.8.3/lib/flexmock/recorder.rb +71 -0
- data/lib/gems/flexmock-0.8.3/lib/flexmock/rspec.rb +34 -0
- data/lib/gems/flexmock-0.8.3/lib/flexmock/test_unit.rb +32 -0
- data/lib/gems/flexmock-0.8.3/lib/flexmock/test_unit_integration.rb +53 -0
- data/lib/gems/flexmock-0.8.3/lib/flexmock/undefined.rb +50 -0
- data/lib/gems/flexmock-0.8.3/lib/flexmock/validators.rb +77 -0
- data/lib/gems/genosaurus-1.2.4/lib/genosaurus.rb +233 -0
- data/lib/gems/lockfile-1.4.3/bin/rlock +360 -0
- data/lib/gems/lockfile-1.4.3/bin/rlock-1.4.3 +360 -0
- data/lib/gems/lockfile-1.4.3/lib/lockfile-1.4.3.rb +564 -0
- data/lib/gems/lockfile-1.4.3/lib/lockfile.rb +564 -0
- data/lib/gems/logging-0.9.4/data/bad_logging_1.rb +13 -0
- data/lib/gems/logging-0.9.4/data/bad_logging_2.rb +21 -0
- data/lib/gems/logging-0.9.4/data/logging.rb +42 -0
- data/lib/gems/logging-0.9.4/data/logging.yaml +63 -0
- data/lib/gems/logging-0.9.4/data/simple_logging.rb +13 -0
- data/lib/gems/logging-0.9.4/lib/logging.rb +404 -0
- data/lib/gems/logging-0.9.4/lib/logging/appender.rb +300 -0
- data/lib/gems/logging-0.9.4/lib/logging/appenders/console.rb +62 -0
- data/lib/gems/logging-0.9.4/lib/logging/appenders/email.rb +130 -0
- data/lib/gems/logging-0.9.4/lib/logging/appenders/file.rb +54 -0
- data/lib/gems/logging-0.9.4/lib/logging/appenders/growl.rb +197 -0
- data/lib/gems/logging-0.9.4/lib/logging/appenders/io.rb +80 -0
- data/lib/gems/logging-0.9.4/lib/logging/appenders/rolling_file.rb +291 -0
- data/lib/gems/logging-0.9.4/lib/logging/appenders/syslog.rb +201 -0
- data/lib/gems/logging-0.9.4/lib/logging/config/configurator.rb +190 -0
- data/lib/gems/logging-0.9.4/lib/logging/config/yaml_configurator.rb +195 -0
- data/lib/gems/logging-0.9.4/lib/logging/layout.rb +110 -0
- data/lib/gems/logging-0.9.4/lib/logging/layouts/basic.rb +34 -0
- data/lib/gems/logging-0.9.4/lib/logging/layouts/pattern.rb +291 -0
- data/lib/gems/logging-0.9.4/lib/logging/log_event.rb +49 -0
- data/lib/gems/logging-0.9.4/lib/logging/logger.rb +490 -0
- data/lib/gems/logging-0.9.4/lib/logging/repository.rb +172 -0
- data/lib/gems/logging-0.9.4/lib/logging/root_logger.rb +61 -0
- data/lib/gems/logging-0.9.4/lib/logging/stats.rb +278 -0
- data/lib/gems/logging-0.9.4/lib/logging/utils.rb +130 -0
- data/lib/gems/rack-0.4.0/bin/rackup +172 -0
- data/lib/gems/rack-0.4.0/lib/rack.rb +81 -0
- data/lib/gems/rack-0.4.0/lib/rack/adapter/camping.rb +22 -0
- data/lib/gems/rack-0.4.0/lib/rack/auth/abstract/handler.rb +28 -0
- data/lib/gems/rack-0.4.0/lib/rack/auth/abstract/request.rb +37 -0
- data/lib/gems/rack-0.4.0/lib/rack/auth/basic.rb +58 -0
- data/lib/gems/rack-0.4.0/lib/rack/auth/digest/md5.rb +124 -0
- data/lib/gems/rack-0.4.0/lib/rack/auth/digest/nonce.rb +51 -0
- data/lib/gems/rack-0.4.0/lib/rack/auth/digest/params.rb +55 -0
- data/lib/gems/rack-0.4.0/lib/rack/auth/digest/request.rb +40 -0
- data/lib/gems/rack-0.4.0/lib/rack/auth/openid.rb +437 -0
- data/lib/gems/rack-0.4.0/lib/rack/builder.rb +56 -0
- data/lib/gems/rack-0.4.0/lib/rack/cascade.rb +36 -0
- data/lib/gems/rack-0.4.0/lib/rack/commonlogger.rb +61 -0
- data/lib/gems/rack-0.4.0/lib/rack/deflater.rb +63 -0
- data/lib/gems/rack-0.4.0/lib/rack/directory.rb +158 -0
- data/lib/gems/rack-0.4.0/lib/rack/file.rb +116 -0
- data/lib/gems/rack-0.4.0/lib/rack/handler.rb +44 -0
- data/lib/gems/rack-0.4.0/lib/rack/handler/cgi.rb +57 -0
- data/lib/gems/rack-0.4.0/lib/rack/handler/evented_mongrel.rb +8 -0
- data/lib/gems/rack-0.4.0/lib/rack/handler/fastcgi.rb +84 -0
- data/lib/gems/rack-0.4.0/lib/rack/handler/lsws.rb +52 -0
- data/lib/gems/rack-0.4.0/lib/rack/handler/mongrel.rb +78 -0
- data/lib/gems/rack-0.4.0/lib/rack/handler/scgi.rb +57 -0
- data/lib/gems/rack-0.4.0/lib/rack/handler/webrick.rb +57 -0
- data/lib/gems/rack-0.4.0/lib/rack/lint.rb +401 -0
- data/lib/gems/rack-0.4.0/lib/rack/lobster.rb +65 -0
- data/lib/gems/rack-0.4.0/lib/rack/mock.rb +160 -0
- data/lib/gems/rack-0.4.0/lib/rack/recursive.rb +57 -0
- data/lib/gems/rack-0.4.0/lib/rack/reloader.rb +64 -0
- data/lib/gems/rack-0.4.0/lib/rack/request.rb +209 -0
- data/lib/gems/rack-0.4.0/lib/rack/response.rb +166 -0
- data/lib/gems/rack-0.4.0/lib/rack/session/abstract/id.rb +140 -0
- data/lib/gems/rack-0.4.0/lib/rack/session/cookie.rb +71 -0
- data/lib/gems/rack-0.4.0/lib/rack/session/memcache.rb +97 -0
- data/lib/gems/rack-0.4.0/lib/rack/session/pool.rb +73 -0
- data/lib/gems/rack-0.4.0/lib/rack/showexceptions.rb +344 -0
- data/lib/gems/rack-0.4.0/lib/rack/showstatus.rb +105 -0
- data/lib/gems/rack-0.4.0/lib/rack/static.rb +38 -0
- data/lib/gems/rack-0.4.0/lib/rack/urlmap.rb +48 -0
- data/lib/gems/rack-0.4.0/lib/rack/utils.rb +318 -0
- data/lib/gems/rcov-0.8.1.2.0/bin/rcov +1327 -0
- data/lib/gems/rcov-0.8.1.2.0/ext/rcovrt/callsite.c +242 -0
- data/lib/gems/rcov-0.8.1.2.0/ext/rcovrt/extconf.rb +11 -0
- data/lib/gems/rcov-0.8.1.2.0/ext/rcovrt/rcovrt.c +329 -0
- data/lib/gems/rcov-0.8.1.2.0/lib/rcov.rb +988 -0
- data/lib/gems/rcov-0.8.1.2.0/lib/rcov/lowlevel.rb +147 -0
- data/lib/gems/rcov-0.8.1.2.0/lib/rcov/rant.rb +87 -0
- data/lib/gems/rcov-0.8.1.2.0/lib/rcov/rcovtask.rb +156 -0
- data/lib/gems/rcov-0.8.1.2.0/lib/rcov/report.rb +1236 -0
- data/lib/gems/rcov-0.8.1.2.0/lib/rcov/version.rb +13 -0
- data/lib/gems/rspec-1.1.11/bin/autospec +4 -0
- data/lib/gems/rspec-1.1.11/bin/spec +4 -0
- data/lib/gems/rspec-1.1.11/lib/autotest/discover.rb +3 -0
- data/lib/gems/rspec-1.1.11/lib/autotest/rspec.rb +46 -0
- data/lib/gems/rspec-1.1.11/lib/spec.rb +32 -0
- data/lib/gems/rspec-1.1.11/lib/spec/adapters.rb +1 -0
- data/lib/gems/rspec-1.1.11/lib/spec/adapters/ruby_engine.rb +26 -0
- data/lib/gems/rspec-1.1.11/lib/spec/adapters/ruby_engine/mri.rb +8 -0
- data/lib/gems/rspec-1.1.11/lib/spec/adapters/ruby_engine/rubinius.rb +8 -0
- data/lib/gems/rspec-1.1.11/lib/spec/example.rb +12 -0
- data/lib/gems/rspec-1.1.11/lib/spec/example/before_and_after_hooks.rb +93 -0
- data/lib/gems/rspec-1.1.11/lib/spec/example/configuration.rb +167 -0
- data/lib/gems/rspec-1.1.11/lib/spec/example/errors.rb +30 -0
- data/lib/gems/rspec-1.1.11/lib/spec/example/example_group.rb +25 -0
- data/lib/gems/rspec-1.1.11/lib/spec/example/example_group_factory.rb +81 -0
- data/lib/gems/rspec-1.1.11/lib/spec/example/example_group_methods.rb +368 -0
- data/lib/gems/rspec-1.1.11/lib/spec/example/example_matcher.rb +44 -0
- data/lib/gems/rspec-1.1.11/lib/spec/example/example_methods.rb +105 -0
- data/lib/gems/rspec-1.1.11/lib/spec/example/module_reopening_fix.rb +21 -0
- data/lib/gems/rspec-1.1.11/lib/spec/example/pending.rb +18 -0
- data/lib/gems/rspec-1.1.11/lib/spec/example/shared_example_group.rb +52 -0
- data/lib/gems/rspec-1.1.11/lib/spec/expectations.rb +56 -0
- data/lib/gems/rspec-1.1.11/lib/spec/expectations/differs/default.rb +66 -0
- data/lib/gems/rspec-1.1.11/lib/spec/expectations/errors.rb +12 -0
- data/lib/gems/rspec-1.1.11/lib/spec/expectations/extensions.rb +2 -0
- data/lib/gems/rspec-1.1.11/lib/spec/expectations/extensions/object.rb +63 -0
- data/lib/gems/rspec-1.1.11/lib/spec/expectations/extensions/string_and_symbol.rb +17 -0
- data/lib/gems/rspec-1.1.11/lib/spec/expectations/handler.rb +52 -0
- data/lib/gems/rspec-1.1.11/lib/spec/extensions.rb +4 -0
- data/lib/gems/rspec-1.1.11/lib/spec/extensions/class.rb +24 -0
- data/lib/gems/rspec-1.1.11/lib/spec/extensions/main.rb +87 -0
- data/lib/gems/rspec-1.1.11/lib/spec/extensions/metaclass.rb +7 -0
- data/lib/gems/rspec-1.1.11/lib/spec/extensions/object.rb +6 -0
- data/lib/gems/rspec-1.1.11/lib/spec/interop/test.rb +12 -0
- data/lib/gems/rspec-1.1.11/lib/spec/interop/test/unit/autorunner.rb +6 -0
- data/lib/gems/rspec-1.1.11/lib/spec/interop/test/unit/testcase.rb +71 -0
- data/lib/gems/rspec-1.1.11/lib/spec/interop/test/unit/testresult.rb +6 -0
- data/lib/gems/rspec-1.1.11/lib/spec/interop/test/unit/testsuite_adapter.rb +34 -0
- data/lib/gems/rspec-1.1.11/lib/spec/interop/test/unit/ui/console/testrunner.rb +61 -0
- data/lib/gems/rspec-1.1.11/lib/spec/matchers.rb +162 -0
- data/lib/gems/rspec-1.1.11/lib/spec/matchers/be.rb +221 -0
- data/lib/gems/rspec-1.1.11/lib/spec/matchers/be_close.rb +37 -0
- data/lib/gems/rspec-1.1.11/lib/spec/matchers/change.rb +148 -0
- data/lib/gems/rspec-1.1.11/lib/spec/matchers/eql.rb +43 -0
- data/lib/gems/rspec-1.1.11/lib/spec/matchers/equal.rb +43 -0
- data/lib/gems/rspec-1.1.11/lib/spec/matchers/exist.rb +22 -0
- data/lib/gems/rspec-1.1.11/lib/spec/matchers/has.rb +34 -0
- data/lib/gems/rspec-1.1.11/lib/spec/matchers/have.rb +150 -0
- data/lib/gems/rspec-1.1.11/lib/spec/matchers/include.rb +77 -0
- data/lib/gems/rspec-1.1.11/lib/spec/matchers/match.rb +41 -0
- data/lib/gems/rspec-1.1.11/lib/spec/matchers/operator_matcher.rb +79 -0
- data/lib/gems/rspec-1.1.11/lib/spec/matchers/raise_error.rb +132 -0
- data/lib/gems/rspec-1.1.11/lib/spec/matchers/respond_to.rb +46 -0
- data/lib/gems/rspec-1.1.11/lib/spec/matchers/satisfy.rb +47 -0
- data/lib/gems/rspec-1.1.11/lib/spec/matchers/simple_matcher.rb +132 -0
- data/lib/gems/rspec-1.1.11/lib/spec/matchers/throw_symbol.rb +74 -0
- data/lib/gems/rspec-1.1.11/lib/spec/mocks.rb +200 -0
- data/lib/gems/rspec-1.1.11/lib/spec/mocks/argument_constraints.rb +165 -0
- data/lib/gems/rspec-1.1.11/lib/spec/mocks/argument_expectation.rb +49 -0
- data/lib/gems/rspec-1.1.11/lib/spec/mocks/error_generator.rb +84 -0
- data/lib/gems/rspec-1.1.11/lib/spec/mocks/errors.rb +10 -0
- data/lib/gems/rspec-1.1.11/lib/spec/mocks/extensions.rb +1 -0
- data/lib/gems/rspec-1.1.11/lib/spec/mocks/extensions/object.rb +3 -0
- data/lib/gems/rspec-1.1.11/lib/spec/mocks/framework.rb +15 -0
- data/lib/gems/rspec-1.1.11/lib/spec/mocks/message_expectation.rb +331 -0
- data/lib/gems/rspec-1.1.11/lib/spec/mocks/methods.rb +51 -0
- data/lib/gems/rspec-1.1.11/lib/spec/mocks/mock.rb +56 -0
- data/lib/gems/rspec-1.1.11/lib/spec/mocks/order_group.rb +29 -0
- data/lib/gems/rspec-1.1.11/lib/spec/mocks/proxy.rb +224 -0
- data/lib/gems/rspec-1.1.11/lib/spec/mocks/space.rb +28 -0
- data/lib/gems/rspec-1.1.11/lib/spec/mocks/spec_methods.rb +46 -0
- data/lib/gems/rspec-1.1.11/lib/spec/rake/spectask.rb +227 -0
- data/lib/gems/rspec-1.1.11/lib/spec/rake/verify_rcov.rb +52 -0
- data/lib/gems/rspec-1.1.11/lib/spec/runner.rb +213 -0
- data/lib/gems/rspec-1.1.11/lib/spec/runner/backtrace_tweaker.rb +56 -0
- data/lib/gems/rspec-1.1.11/lib/spec/runner/class_and_arguments_parser.rb +16 -0
- data/lib/gems/rspec-1.1.11/lib/spec/runner/command_line.rb +17 -0
- data/lib/gems/rspec-1.1.11/lib/spec/runner/drb_command_line.rb +20 -0
- data/lib/gems/rspec-1.1.11/lib/spec/runner/example_group_runner.rb +59 -0
- data/lib/gems/rspec-1.1.11/lib/spec/runner/formatter/base_formatter.rb +79 -0
- data/lib/gems/rspec-1.1.11/lib/spec/runner/formatter/base_text_formatter.rb +126 -0
- data/lib/gems/rspec-1.1.11/lib/spec/runner/formatter/failing_example_groups_formatter.rb +27 -0
- data/lib/gems/rspec-1.1.11/lib/spec/runner/formatter/failing_examples_formatter.rb +20 -0
- data/lib/gems/rspec-1.1.11/lib/spec/runner/formatter/html_formatter.rb +337 -0
- data/lib/gems/rspec-1.1.11/lib/spec/runner/formatter/nested_text_formatter.rb +65 -0
- data/lib/gems/rspec-1.1.11/lib/spec/runner/formatter/profile_formatter.rb +51 -0
- data/lib/gems/rspec-1.1.11/lib/spec/runner/formatter/progress_bar_formatter.rb +34 -0
- data/lib/gems/rspec-1.1.11/lib/spec/runner/formatter/snippet_extractor.rb +52 -0
- data/lib/gems/rspec-1.1.11/lib/spec/runner/formatter/specdoc_formatter.rb +39 -0
- data/lib/gems/rspec-1.1.11/lib/spec/runner/formatter/story/html_formatter.rb +174 -0
- data/lib/gems/rspec-1.1.11/lib/spec/runner/formatter/story/plain_text_formatter.rb +194 -0
- data/lib/gems/rspec-1.1.11/lib/spec/runner/formatter/story/progress_bar_formatter.rb +42 -0
- data/lib/gems/rspec-1.1.11/lib/spec/runner/formatter/text_mate_formatter.rb +16 -0
- data/lib/gems/rspec-1.1.11/lib/spec/runner/heckle_runner.rb +72 -0
- data/lib/gems/rspec-1.1.11/lib/spec/runner/heckle_runner_unsupported.rb +10 -0
- data/lib/gems/rspec-1.1.11/lib/spec/runner/option_parser.rb +205 -0
- data/lib/gems/rspec-1.1.11/lib/spec/runner/options.rb +320 -0
- data/lib/gems/rspec-1.1.11/lib/spec/runner/reporter.rb +167 -0
- data/lib/gems/rspec-1.1.11/lib/spec/runner/spec_parser.rb +71 -0
- data/lib/gems/rspec-1.1.11/lib/spec/story.rb +10 -0
- data/lib/gems/rspec-1.1.11/lib/spec/story/extensions.rb +3 -0
- data/lib/gems/rspec-1.1.11/lib/spec/story/extensions/main.rb +86 -0
- data/lib/gems/rspec-1.1.11/lib/spec/story/extensions/regexp.rb +9 -0
- data/lib/gems/rspec-1.1.11/lib/spec/story/extensions/string.rb +9 -0
- data/lib/gems/rspec-1.1.11/lib/spec/story/given_scenario.rb +14 -0
- data/lib/gems/rspec-1.1.11/lib/spec/story/runner.rb +59 -0
- data/lib/gems/rspec-1.1.11/lib/spec/story/runner/plain_text_story_runner.rb +48 -0
- data/lib/gems/rspec-1.1.11/lib/spec/story/runner/scenario_collector.rb +18 -0
- data/lib/gems/rspec-1.1.11/lib/spec/story/runner/scenario_runner.rb +54 -0
- data/lib/gems/rspec-1.1.11/lib/spec/story/runner/story_mediator.rb +137 -0
- data/lib/gems/rspec-1.1.11/lib/spec/story/runner/story_parser.rb +247 -0
- data/lib/gems/rspec-1.1.11/lib/spec/story/runner/story_runner.rb +70 -0
- data/lib/gems/rspec-1.1.11/lib/spec/story/scenario.rb +14 -0
- data/lib/gems/rspec-1.1.11/lib/spec/story/step.rb +70 -0
- data/lib/gems/rspec-1.1.11/lib/spec/story/step_group.rb +89 -0
- data/lib/gems/rspec-1.1.11/lib/spec/story/step_mother.rb +38 -0
- data/lib/gems/rspec-1.1.11/lib/spec/story/story.rb +39 -0
- data/lib/gems/rspec-1.1.11/lib/spec/story/world.rb +128 -0
- data/lib/gems/rspec-1.1.11/lib/spec/version.rb +13 -0
- data/lib/gems/rspec-1.1.11/plugins/mock_frameworks/flexmock.rb +23 -0
- data/lib/gems/rspec-1.1.11/plugins/mock_frameworks/mocha.rb +19 -0
- data/lib/gems/rspec-1.1.11/plugins/mock_frameworks/rr.rb +21 -0
- data/lib/gems/rspec-1.1.11/plugins/mock_frameworks/rspec.rb +20 -0
- data/lib/gems/rspec-1.1.11/rake_tasks/examples.rake +7 -0
- data/lib/gems/rspec-1.1.11/rake_tasks/examples_with_rcov.rake +9 -0
- data/lib/gems/rspec-1.1.11/rake_tasks/failing_examples_with_html.rake +9 -0
- data/lib/gems/rspec-1.1.11/rake_tasks/verify_rcov.rake +7 -0
- data/lib/gems/rspec-1.1.11/spec/README.jruby +15 -0
- data/lib/gems/rspec-1.1.11/spec/autotest/autotest_helper.rb +6 -0
- data/lib/gems/rspec-1.1.11/spec/autotest/autotest_matchers.rb +47 -0
- data/lib/gems/rspec-1.1.11/spec/autotest/discover_spec.rb +19 -0
- data/lib/gems/rspec-1.1.11/spec/autotest/rspec_spec.rb +150 -0
- data/lib/gems/rspec-1.1.11/spec/rspec_suite.rb +6 -0
- data/lib/gems/rspec-1.1.11/spec/ruby_forker.rb +13 -0
- data/lib/gems/rspec-1.1.11/spec/spec.opts +6 -0
- data/lib/gems/rspec-1.1.11/spec/spec/adapters/ruby_engine_spec.rb +16 -0
- data/lib/gems/rspec-1.1.11/spec/spec/example/configuration_spec.rb +296 -0
- data/lib/gems/rspec-1.1.11/spec/spec/example/example_group_class_definition_spec.rb +48 -0
- data/lib/gems/rspec-1.1.11/spec/spec/example/example_group_factory_spec.rb +165 -0
- data/lib/gems/rspec-1.1.11/spec/spec/example/example_group_methods_spec.rb +584 -0
- data/lib/gems/rspec-1.1.11/spec/spec/example/example_group_spec.rb +683 -0
- data/lib/gems/rspec-1.1.11/spec/spec/example/example_matcher_spec.rb +96 -0
- data/lib/gems/rspec-1.1.11/spec/spec/example/example_methods_spec.rb +169 -0
- data/lib/gems/rspec-1.1.11/spec/spec/example/example_runner_spec.rb +194 -0
- data/lib/gems/rspec-1.1.11/spec/spec/example/nested_example_group_spec.rb +71 -0
- data/lib/gems/rspec-1.1.11/spec/spec/example/pending_module_spec.rb +145 -0
- data/lib/gems/rspec-1.1.11/spec/spec/example/predicate_matcher_spec.rb +21 -0
- data/lib/gems/rspec-1.1.11/spec/spec/example/shared_example_group_spec.rb +281 -0
- data/lib/gems/rspec-1.1.11/spec/spec/example/subclassing_example_group_spec.rb +25 -0
- data/lib/gems/rspec-1.1.11/spec/spec/expectations/differs/default_spec.rb +127 -0
- data/lib/gems/rspec-1.1.11/spec/spec/expectations/extensions/object_spec.rb +95 -0
- data/lib/gems/rspec-1.1.11/spec/spec/expectations/fail_with_spec.rb +71 -0
- data/lib/gems/rspec-1.1.11/spec/spec/extensions/main_spec.rb +71 -0
- data/lib/gems/rspec-1.1.11/spec/spec/interop/test/unit/resources/spec_that_fails.rb +10 -0
- data/lib/gems/rspec-1.1.11/spec/spec/interop/test/unit/resources/spec_that_passes.rb +10 -0
- data/lib/gems/rspec-1.1.11/spec/spec/interop/test/unit/resources/spec_with_errors.rb +10 -0
- data/lib/gems/rspec-1.1.11/spec/spec/interop/test/unit/resources/spec_with_options_hash.rb +13 -0
- data/lib/gems/rspec-1.1.11/spec/spec/interop/test/unit/resources/test_case_that_fails.rb +10 -0
- data/lib/gems/rspec-1.1.11/spec/spec/interop/test/unit/resources/test_case_that_passes.rb +10 -0
- data/lib/gems/rspec-1.1.11/spec/spec/interop/test/unit/resources/test_case_with_errors.rb +10 -0
- data/lib/gems/rspec-1.1.11/spec/spec/interop/test/unit/resources/testsuite_adapter_spec_with_test_unit.rb +38 -0
- data/lib/gems/rspec-1.1.11/spec/spec/interop/test/unit/spec_spec.rb +52 -0
- data/lib/gems/rspec-1.1.11/spec/spec/interop/test/unit/test_unit_spec_helper.rb +14 -0
- data/lib/gems/rspec-1.1.11/spec/spec/interop/test/unit/testcase_spec.rb +49 -0
- data/lib/gems/rspec-1.1.11/spec/spec/interop/test/unit/testsuite_adapter_spec.rb +9 -0
- data/lib/gems/rspec-1.1.11/spec/spec/matchers/be_close_spec.rb +39 -0
- data/lib/gems/rspec-1.1.11/spec/spec/matchers/be_spec.rb +248 -0
- data/lib/gems/rspec-1.1.11/spec/spec/matchers/change_spec.rb +329 -0
- data/lib/gems/rspec-1.1.11/spec/spec/matchers/description_generation_spec.rb +153 -0
- data/lib/gems/rspec-1.1.11/spec/spec/matchers/eql_spec.rb +28 -0
- data/lib/gems/rspec-1.1.11/spec/spec/matchers/equal_spec.rb +28 -0
- data/lib/gems/rspec-1.1.11/spec/spec/matchers/exist_spec.rb +57 -0
- data/lib/gems/rspec-1.1.11/spec/spec/matchers/handler_spec.rb +150 -0
- data/lib/gems/rspec-1.1.11/spec/spec/matchers/has_spec.rb +63 -0
- data/lib/gems/rspec-1.1.11/spec/spec/matchers/have_spec.rb +394 -0
- data/lib/gems/rspec-1.1.11/spec/spec/matchers/include_spec.rb +64 -0
- data/lib/gems/rspec-1.1.11/spec/spec/matchers/match_spec.rb +37 -0
- data/lib/gems/rspec-1.1.11/spec/spec/matchers/matcher_methods_spec.rb +78 -0
- data/lib/gems/rspec-1.1.11/spec/spec/matchers/mock_constraint_matchers_spec.rb +24 -0
- data/lib/gems/rspec-1.1.11/spec/spec/matchers/operator_matcher_spec.rb +191 -0
- data/lib/gems/rspec-1.1.11/spec/spec/matchers/raise_error_spec.rb +315 -0
- data/lib/gems/rspec-1.1.11/spec/spec/matchers/respond_to_spec.rb +54 -0
- data/lib/gems/rspec-1.1.11/spec/spec/matchers/satisfy_spec.rb +36 -0
- data/lib/gems/rspec-1.1.11/spec/spec/matchers/simple_matcher_spec.rb +93 -0
- data/lib/gems/rspec-1.1.11/spec/spec/matchers/throw_symbol_spec.rb +54 -0
- data/lib/gems/rspec-1.1.11/spec/spec/mocks/any_number_of_times_spec.rb +36 -0
- data/lib/gems/rspec-1.1.11/spec/spec/mocks/argument_expectation_spec.rb +23 -0
- data/lib/gems/rspec-1.1.11/spec/spec/mocks/at_least_spec.rb +97 -0
- data/lib/gems/rspec-1.1.11/spec/spec/mocks/at_most_spec.rb +93 -0
- data/lib/gems/rspec-1.1.11/spec/spec/mocks/bug_report_10260_spec.rb +8 -0
- data/lib/gems/rspec-1.1.11/spec/spec/mocks/bug_report_10263_spec.rb +24 -0
- data/lib/gems/rspec-1.1.11/spec/spec/mocks/bug_report_11545_spec.rb +33 -0
- data/lib/gems/rspec-1.1.11/spec/spec/mocks/bug_report_15719_spec.rb +30 -0
- data/lib/gems/rspec-1.1.11/spec/spec/mocks/bug_report_496.rb +17 -0
- data/lib/gems/rspec-1.1.11/spec/spec/mocks/bug_report_7611_spec.rb +19 -0
- data/lib/gems/rspec-1.1.11/spec/spec/mocks/bug_report_7805_spec.rb +22 -0
- data/lib/gems/rspec-1.1.11/spec/spec/mocks/bug_report_8165_spec.rb +31 -0
- data/lib/gems/rspec-1.1.11/spec/spec/mocks/bug_report_8302_spec.rb +26 -0
- data/lib/gems/rspec-1.1.11/spec/spec/mocks/failing_mock_argument_constraints_spec.rb +95 -0
- data/lib/gems/rspec-1.1.11/spec/spec/mocks/hash_including_matcher_spec.rb +53 -0
- data/lib/gems/rspec-1.1.11/spec/spec/mocks/mock_ordering_spec.rb +84 -0
- data/lib/gems/rspec-1.1.11/spec/spec/mocks/mock_space_spec.rb +54 -0
- data/lib/gems/rspec-1.1.11/spec/spec/mocks/mock_spec.rb +555 -0
- data/lib/gems/rspec-1.1.11/spec/spec/mocks/multiple_return_value_spec.rb +113 -0
- data/lib/gems/rspec-1.1.11/spec/spec/mocks/nil_expectation_warning_spec.rb +53 -0
- data/lib/gems/rspec-1.1.11/spec/spec/mocks/null_object_mock_spec.rb +54 -0
- data/lib/gems/rspec-1.1.11/spec/spec/mocks/once_counts_spec.rb +53 -0
- data/lib/gems/rspec-1.1.11/spec/spec/mocks/options_hash_spec.rb +35 -0
- data/lib/gems/rspec-1.1.11/spec/spec/mocks/partial_mock_spec.rb +149 -0
- data/lib/gems/rspec-1.1.11/spec/spec/mocks/partial_mock_using_mocks_directly_spec.rb +66 -0
- data/lib/gems/rspec-1.1.11/spec/spec/mocks/passing_mock_argument_constraints_spec.rb +130 -0
- data/lib/gems/rspec-1.1.11/spec/spec/mocks/precise_counts_spec.rb +52 -0
- data/lib/gems/rspec-1.1.11/spec/spec/mocks/record_messages_spec.rb +26 -0
- data/lib/gems/rspec-1.1.11/spec/spec/mocks/stub_spec.rb +188 -0
- data/lib/gems/rspec-1.1.11/spec/spec/mocks/twice_counts_spec.rb +67 -0
- data/lib/gems/rspec-1.1.11/spec/spec/package/bin_spec_spec.rb +22 -0
- data/lib/gems/rspec-1.1.11/spec/spec/runner/class_and_argument_parser_spec.rb +23 -0
- data/lib/gems/rspec-1.1.11/spec/spec/runner/command_line_spec.rb +141 -0
- data/lib/gems/rspec-1.1.11/spec/spec/runner/drb_command_line_spec.rb +97 -0
- data/lib/gems/rspec-1.1.11/spec/spec/runner/empty_file.txt +0 -0
- data/lib/gems/rspec-1.1.11/spec/spec/runner/examples.txt +2 -0
- data/lib/gems/rspec-1.1.11/spec/spec/runner/failed.txt +3 -0
- data/lib/gems/rspec-1.1.11/spec/spec/runner/formatter/base_formatter_spec.rb +112 -0
- data/lib/gems/rspec-1.1.11/spec/spec/runner/formatter/failing_example_groups_formatter_spec.rb +45 -0
- data/lib/gems/rspec-1.1.11/spec/spec/runner/formatter/failing_examples_formatter_spec.rb +33 -0
- data/lib/gems/rspec-1.1.11/spec/spec/runner/formatter/html_formatted-1.8.4.html +365 -0
- data/lib/gems/rspec-1.1.11/spec/spec/runner/formatter/html_formatted-1.8.5-jruby.html +387 -0
- data/lib/gems/rspec-1.1.11/spec/spec/runner/formatter/html_formatted-1.8.5.html +371 -0
- data/lib/gems/rspec-1.1.11/spec/spec/runner/formatter/html_formatted-1.8.6-jruby.html +381 -0
- data/lib/gems/rspec-1.1.11/spec/spec/runner/formatter/html_formatted-1.8.6.html +370 -0
- data/lib/gems/rspec-1.1.11/spec/spec/runner/formatter/html_formatter_spec.rb +61 -0
- data/lib/gems/rspec-1.1.11/spec/spec/runner/formatter/nested_text_formatter_spec.rb +318 -0
- data/lib/gems/rspec-1.1.11/spec/spec/runner/formatter/profile_formatter_spec.rb +65 -0
- data/lib/gems/rspec-1.1.11/spec/spec/runner/formatter/progress_bar_formatter_spec.rb +155 -0
- data/lib/gems/rspec-1.1.11/spec/spec/runner/formatter/snippet_extractor_spec.rb +18 -0
- data/lib/gems/rspec-1.1.11/spec/spec/runner/formatter/spec_mate_formatter_spec.rb +103 -0
- data/lib/gems/rspec-1.1.11/spec/spec/runner/formatter/specdoc_formatter_spec.rb +159 -0
- data/lib/gems/rspec-1.1.11/spec/spec/runner/formatter/story/html_formatter_spec.rb +135 -0
- data/lib/gems/rspec-1.1.11/spec/spec/runner/formatter/story/plain_text_formatter_spec.rb +600 -0
- data/lib/gems/rspec-1.1.11/spec/spec/runner/formatter/story/progress_bar_formatter_spec.rb +82 -0
- data/lib/gems/rspec-1.1.11/spec/spec/runner/formatter/text_mate_formatted-1.8.4.html +365 -0
- data/lib/gems/rspec-1.1.11/spec/spec/runner/formatter/text_mate_formatted-1.8.6.html +370 -0
- data/lib/gems/rspec-1.1.11/spec/spec/runner/heckle_runner_spec.rb +78 -0
- data/lib/gems/rspec-1.1.11/spec/spec/runner/heckler_spec.rb +13 -0
- data/lib/gems/rspec-1.1.11/spec/spec/runner/noisy_backtrace_tweaker_spec.rb +45 -0
- data/lib/gems/rspec-1.1.11/spec/spec/runner/option_parser_spec.rb +421 -0
- data/lib/gems/rspec-1.1.11/spec/spec/runner/options_spec.rb +450 -0
- data/lib/gems/rspec-1.1.11/spec/spec/runner/output_one_time_fixture.rb +7 -0
- data/lib/gems/rspec-1.1.11/spec/spec/runner/output_one_time_fixture_runner.rb +8 -0
- data/lib/gems/rspec-1.1.11/spec/spec/runner/output_one_time_spec.rb +16 -0
- data/lib/gems/rspec-1.1.11/spec/spec/runner/quiet_backtrace_tweaker_spec.rb +62 -0
- data/lib/gems/rspec-1.1.11/spec/spec/runner/reporter_spec.rb +238 -0
- data/lib/gems/rspec-1.1.11/spec/spec/runner/resources/a_bar.rb +0 -0
- data/lib/gems/rspec-1.1.11/spec/spec/runner/resources/a_foo.rb +0 -0
- data/lib/gems/rspec-1.1.11/spec/spec/runner/resources/a_spec.rb +1 -0
- data/lib/gems/rspec-1.1.11/spec/spec/runner/spec.opts +2 -0
- data/lib/gems/rspec-1.1.11/spec/spec/runner/spec_drb.opts +1 -0
- data/lib/gems/rspec-1.1.11/spec/spec/runner/spec_parser/spec_parser_fixture.rb +70 -0
- data/lib/gems/rspec-1.1.11/spec/spec/runner/spec_parser_spec.rb +85 -0
- data/lib/gems/rspec-1.1.11/spec/spec/runner/spec_spaced.opts +2 -0
- data/lib/gems/rspec-1.1.11/spec/spec/runner_spec.rb +11 -0
- data/lib/gems/rspec-1.1.11/spec/spec/spec_classes.rb +133 -0
- data/lib/gems/rspec-1.1.11/spec/spec/story/builders.rb +46 -0
- data/lib/gems/rspec-1.1.11/spec/spec/story/extensions/main_spec.rb +161 -0
- data/lib/gems/rspec-1.1.11/spec/spec/story/extensions_spec.rb +14 -0
- data/lib/gems/rspec-1.1.11/spec/spec/story/given_scenario_spec.rb +27 -0
- data/lib/gems/rspec-1.1.11/spec/spec/story/runner/plain_text_story_runner_spec.rb +90 -0
- data/lib/gems/rspec-1.1.11/spec/spec/story/runner/scenario_collector_spec.rb +27 -0
- data/lib/gems/rspec-1.1.11/spec/spec/story/runner/scenario_runner_spec.rb +214 -0
- data/lib/gems/rspec-1.1.11/spec/spec/story/runner/story_mediator_spec.rb +143 -0
- data/lib/gems/rspec-1.1.11/spec/spec/story/runner/story_parser_spec.rb +401 -0
- data/lib/gems/rspec-1.1.11/spec/spec/story/runner/story_runner_spec.rb +294 -0
- data/lib/gems/rspec-1.1.11/spec/spec/story/runner_spec.rb +93 -0
- data/lib/gems/rspec-1.1.11/spec/spec/story/scenario_spec.rb +18 -0
- data/lib/gems/rspec-1.1.11/spec/spec/story/step_group_spec.rb +157 -0
- data/lib/gems/rspec-1.1.11/spec/spec/story/step_mother_spec.rb +84 -0
- data/lib/gems/rspec-1.1.11/spec/spec/story/step_spec.rb +272 -0
- data/lib/gems/rspec-1.1.11/spec/spec/story/story_helper.rb +2 -0
- data/lib/gems/rspec-1.1.11/spec/spec/story/story_spec.rb +84 -0
- data/lib/gems/rspec-1.1.11/spec/spec/story/world_spec.rb +423 -0
- data/lib/gems/rspec-1.1.11/spec/spec_helper.rb +77 -0
- data/lib/gems/rspec-1.1.11/stories/all.rb +5 -0
- data/lib/gems/rspec-1.1.11/stories/configuration/before_blocks.story +21 -0
- data/lib/gems/rspec-1.1.11/stories/configuration/stories.rb +7 -0
- data/lib/gems/rspec-1.1.11/stories/example_groups/autogenerated_docstrings +45 -0
- data/lib/gems/rspec-1.1.11/stories/example_groups/example_group_with_should_methods +17 -0
- data/lib/gems/rspec-1.1.11/stories/example_groups/nested_groups +17 -0
- data/lib/gems/rspec-1.1.11/stories/example_groups/output +25 -0
- data/lib/gems/rspec-1.1.11/stories/example_groups/stories.rb +7 -0
- data/lib/gems/rspec-1.1.11/stories/helper.rb +6 -0
- data/lib/gems/rspec-1.1.11/stories/interop/examples_and_tests_together +30 -0
- data/lib/gems/rspec-1.1.11/stories/interop/stories.rb +7 -0
- data/lib/gems/rspec-1.1.11/stories/interop/test_case_with_should_methods +17 -0
- data/lib/gems/rspec-1.1.11/stories/mock_framework_integration/stories.rb +7 -0
- data/lib/gems/rspec-1.1.11/stories/mock_framework_integration/use_flexmock.story +9 -0
- data/lib/gems/rspec-1.1.11/stories/pending_stories/README +3 -0
- data/lib/gems/rspec-1.1.11/stories/resources/helpers/cmdline.rb +9 -0
- data/lib/gems/rspec-1.1.11/stories/resources/helpers/story_helper.rb +16 -0
- data/lib/gems/rspec-1.1.11/stories/resources/matchers/smart_match.rb +37 -0
- data/lib/gems/rspec-1.1.11/stories/resources/spec/before_blocks_example.rb +32 -0
- data/lib/gems/rspec-1.1.11/stories/resources/spec/example_group_with_should_methods.rb +12 -0
- data/lib/gems/rspec-1.1.11/stories/resources/spec/simple_spec.rb +8 -0
- data/lib/gems/rspec-1.1.11/stories/resources/spec/spec_with_flexmock.rb +18 -0
- data/lib/gems/rspec-1.1.11/stories/resources/steps/running_rspec.rb +50 -0
- data/lib/gems/rspec-1.1.11/stories/resources/stories/failing_story.rb +15 -0
- data/lib/gems/rspec-1.1.11/stories/resources/test/spec_and_test_together.rb +57 -0
- data/lib/gems/rspec-1.1.11/stories/resources/test/test_case_with_should_methods.rb +30 -0
- data/lib/gems/rspec-1.1.11/stories/stories/multiline_steps.story +23 -0
- data/lib/gems/rspec-1.1.11/stories/stories/steps/multiline_steps.rb +13 -0
- data/lib/gems/rspec-1.1.11/stories/stories/stories.rb +6 -0
- data/lib/gems/rspec-1.1.11/story_server/prototype/javascripts/builder.js +136 -0
- data/lib/gems/rspec-1.1.11/story_server/prototype/javascripts/controls.js +972 -0
- data/lib/gems/rspec-1.1.11/story_server/prototype/javascripts/dragdrop.js +976 -0
- data/lib/gems/rspec-1.1.11/story_server/prototype/javascripts/effects.js +1117 -0
- data/lib/gems/rspec-1.1.11/story_server/prototype/javascripts/prototype.js +4140 -0
- data/lib/gems/rspec-1.1.11/story_server/prototype/javascripts/rspec.js +149 -0
- data/lib/gems/rspec-1.1.11/story_server/prototype/javascripts/scriptaculous.js +58 -0
- data/lib/gems/rspec-1.1.11/story_server/prototype/javascripts/slider.js +276 -0
- data/lib/gems/rspec-1.1.11/story_server/prototype/javascripts/sound.js +55 -0
- data/lib/gems/rspec-1.1.11/story_server/prototype/javascripts/unittest.js +568 -0
- data/lib/gems/rspec-1.1.11/story_server/prototype/lib/server.rb +24 -0
- data/lib/gems/rspec-1.1.11/story_server/prototype/stories.html +176 -0
- data/lib/gems/rspec-1.1.11/story_server/prototype/stylesheets/rspec.css +136 -0
- data/lib/gems/rspec-1.1.11/story_server/prototype/stylesheets/test.css +90 -0
- data/lib/mack/boot/configuration.rb +2 -0
- data/lib/mack/boot/console.rb +2 -0
- data/lib/mack/boot/gems.rb +6 -1
- data/lib/mack/boot/logging.rb +1 -1
- data/lib/mack/controller/request.rb +2 -55
- data/lib/mack/controller/request/date_time_parameter.rb +37 -0
- data/lib/mack/controller/request/parameters.rb +31 -0
- data/lib/mack/core_extensions/gem_kernel.rb +30 -0
- data/lib/mack/core_extensions/kernel.rb +31 -14
- data/lib/mack/routing/route_map.rb +19 -18
- data/lib/mack/routing/route_object.rb +14 -3
- data/lib/mack/routing/routes.rb +4 -0
- data/lib/mack/runner.rb +11 -0
- data/lib/mack/version.rb +1 -1
- data/lib/mack_app.rb +1 -26
- data/lib/mack_core.rb +2 -50
- data/lib/mack_tasks.rb +1 -32
- metadata +669 -90
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
module Rack
|
|
2
|
+
|
|
3
|
+
# The Rack::Static middleware intercepts requests for static files
|
|
4
|
+
# (javascript files, images, stylesheets, etc) based on the url prefixes
|
|
5
|
+
# passed in the options, and serves them using a Rack::File object. This
|
|
6
|
+
# allows a Rack stack to serve both static and dynamic content.
|
|
7
|
+
#
|
|
8
|
+
# Examples:
|
|
9
|
+
# use Rack::Static, :urls => ["/media"]
|
|
10
|
+
# will serve all requests beginning with /media from the "media" folder
|
|
11
|
+
# located in the current directory (ie media/*).
|
|
12
|
+
#
|
|
13
|
+
# use Rack::Static, :urls => ["/css", "/images"], :root => "public"
|
|
14
|
+
# will serve all requests beginning with /css or /images from the folder
|
|
15
|
+
# "public" in the current directory (ie public/css/* and public/images/*)
|
|
16
|
+
|
|
17
|
+
class Static
|
|
18
|
+
|
|
19
|
+
def initialize(app, options={})
|
|
20
|
+
@app = app
|
|
21
|
+
@urls = options[:urls] || ["/favicon.ico"]
|
|
22
|
+
root = options[:root] || Dir.pwd
|
|
23
|
+
@file_server = Rack::File.new(root)
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def call(env)
|
|
27
|
+
path = env["PATH_INFO"]
|
|
28
|
+
can_serve = @urls.any? { |url| path.index(url) == 0 }
|
|
29
|
+
|
|
30
|
+
if can_serve
|
|
31
|
+
@file_server.call(env)
|
|
32
|
+
else
|
|
33
|
+
@app.call(env)
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
end
|
|
38
|
+
end
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
module Rack
|
|
2
|
+
# Rack::URLMap takes a hash mapping urls or paths to apps, and
|
|
3
|
+
# dispatches accordingly. Support for HTTP/1.1 host names exists if
|
|
4
|
+
# the URLs start with <tt>http://</tt> or <tt>https://</tt>.
|
|
5
|
+
#
|
|
6
|
+
# URLMap modifies the SCRIPT_NAME and PATH_INFO such that the part
|
|
7
|
+
# relevant for dispatch is in the SCRIPT_NAME, and the rest in the
|
|
8
|
+
# PATH_INFO. This should be taken care of when you need to
|
|
9
|
+
# reconstruct the URL in order to create links.
|
|
10
|
+
#
|
|
11
|
+
# URLMap dispatches in such a way that the longest paths are tried
|
|
12
|
+
# first, since they are most specific.
|
|
13
|
+
|
|
14
|
+
class URLMap
|
|
15
|
+
def initialize(map)
|
|
16
|
+
@mapping = map.map { |location, app|
|
|
17
|
+
if location =~ %r{\Ahttps?://(.*?)(/.*)}
|
|
18
|
+
host, location = $1, $2
|
|
19
|
+
else
|
|
20
|
+
host = nil
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
unless location[0] == ?/
|
|
24
|
+
raise ArgumentError, "paths need to start with /"
|
|
25
|
+
end
|
|
26
|
+
location = location.chomp('/')
|
|
27
|
+
|
|
28
|
+
[host, location, app]
|
|
29
|
+
}.sort_by { |(h, l, a)| -l.size } # Longest path first
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def call(env)
|
|
33
|
+
path = env["PATH_INFO"].to_s.squeeze("/")
|
|
34
|
+
hHost, sName, sPort = env.values_at('HTTP_HOST','SERVER_NAME','SERVER_PORT')
|
|
35
|
+
@mapping.each { |host, location, app|
|
|
36
|
+
next unless (hHost == host || sName == host \
|
|
37
|
+
|| (host.nil? && (hHost == sName || hHost == sName+':'+sPort)))
|
|
38
|
+
next unless location == path[0, location.size]
|
|
39
|
+
next unless path[location.size] == nil || path[location.size] == ?/
|
|
40
|
+
env["SCRIPT_NAME"] += location
|
|
41
|
+
env["PATH_INFO"] = path[location.size..-1]
|
|
42
|
+
return app.call(env)
|
|
43
|
+
}
|
|
44
|
+
[404, {"Content-Type" => "text/plain"}, ["Not Found: #{path}"]]
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
|
|
@@ -0,0 +1,318 @@
|
|
|
1
|
+
require 'tempfile'
|
|
2
|
+
|
|
3
|
+
module Rack
|
|
4
|
+
# Rack::Utils contains a grab-bag of useful methods for writing web
|
|
5
|
+
# applications adopted from all kinds of Ruby libraries.
|
|
6
|
+
|
|
7
|
+
module Utils
|
|
8
|
+
# Performs URI escaping so that you can construct proper
|
|
9
|
+
# query strings faster. Use this rather than the cgi.rb
|
|
10
|
+
# version since it's faster. (Stolen from Camping).
|
|
11
|
+
def escape(s)
|
|
12
|
+
s.to_s.gsub(/([^ a-zA-Z0-9_.-]+)/n) {
|
|
13
|
+
'%'+$1.unpack('H2'*$1.size).join('%').upcase
|
|
14
|
+
}.tr(' ', '+')
|
|
15
|
+
end
|
|
16
|
+
module_function :escape
|
|
17
|
+
|
|
18
|
+
# Unescapes a URI escaped string. (Stolen from Camping).
|
|
19
|
+
def unescape(s)
|
|
20
|
+
s.tr('+', ' ').gsub(/((?:%[0-9a-fA-F]{2})+)/n){
|
|
21
|
+
[$1.delete('%')].pack('H*')
|
|
22
|
+
}
|
|
23
|
+
end
|
|
24
|
+
module_function :unescape
|
|
25
|
+
|
|
26
|
+
# Stolen from Mongrel, with some small modifications:
|
|
27
|
+
# Parses a query string by breaking it up at the '&'
|
|
28
|
+
# and ';' characters. You can also use this to parse
|
|
29
|
+
# cookies by changing the characters used in the second
|
|
30
|
+
# parameter (which defaults to '&;').
|
|
31
|
+
|
|
32
|
+
def parse_query(qs, d = '&;')
|
|
33
|
+
params = {}
|
|
34
|
+
|
|
35
|
+
(qs || '').split(/[#{d}] */n).each do |p|
|
|
36
|
+
k, v = unescape(p).split('=', 2)
|
|
37
|
+
|
|
38
|
+
if cur = params[k]
|
|
39
|
+
if cur.class == Array
|
|
40
|
+
params[k] << v
|
|
41
|
+
else
|
|
42
|
+
params[k] = [cur, v]
|
|
43
|
+
end
|
|
44
|
+
else
|
|
45
|
+
params[k] = v
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
return params
|
|
50
|
+
end
|
|
51
|
+
module_function :parse_query
|
|
52
|
+
|
|
53
|
+
def build_query(params)
|
|
54
|
+
params.map { |k, v|
|
|
55
|
+
if v.class == Array
|
|
56
|
+
build_query(v.map { |x| [k, x] })
|
|
57
|
+
else
|
|
58
|
+
escape(k) + "=" + escape(v)
|
|
59
|
+
end
|
|
60
|
+
}.join("&")
|
|
61
|
+
end
|
|
62
|
+
module_function :build_query
|
|
63
|
+
|
|
64
|
+
# Escape ampersands, brackets and quotes to their HTML/XML entities.
|
|
65
|
+
def escape_html(string)
|
|
66
|
+
string.to_s.gsub("&", "&").
|
|
67
|
+
gsub("<", "<").
|
|
68
|
+
gsub(">", ">").
|
|
69
|
+
gsub("'", "'").
|
|
70
|
+
gsub('"', """)
|
|
71
|
+
end
|
|
72
|
+
module_function :escape_html
|
|
73
|
+
|
|
74
|
+
def select_best_encoding(available_encodings, accept_encoding)
|
|
75
|
+
# http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html
|
|
76
|
+
|
|
77
|
+
expanded_accept_encoding =
|
|
78
|
+
accept_encoding.map { |m, q|
|
|
79
|
+
if m == "*"
|
|
80
|
+
(available_encodings - accept_encoding.map { |m2, _| m2 }).map { |m2| [m2, q] }
|
|
81
|
+
else
|
|
82
|
+
[[m, q]]
|
|
83
|
+
end
|
|
84
|
+
}.inject([]) { |mem, list|
|
|
85
|
+
mem + list
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
encoding_candidates = expanded_accept_encoding.sort_by { |_, q| -q }.map { |m, _| m }
|
|
89
|
+
|
|
90
|
+
unless encoding_candidates.include?("identity")
|
|
91
|
+
encoding_candidates.push("identity")
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
expanded_accept_encoding.find_all { |m, q|
|
|
95
|
+
q == 0.0
|
|
96
|
+
}.each { |m, _|
|
|
97
|
+
encoding_candidates.delete(m)
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
return (encoding_candidates & available_encodings)[0]
|
|
101
|
+
end
|
|
102
|
+
module_function :select_best_encoding
|
|
103
|
+
|
|
104
|
+
# The recommended manner in which to implement a contexting application
|
|
105
|
+
# is to define a method #context in which a new Context is instantiated.
|
|
106
|
+
#
|
|
107
|
+
# As a Context is a glorified block, it is highly recommended that you
|
|
108
|
+
# define the contextual block within the application's operational scope.
|
|
109
|
+
# This would typically the application as you're place into Rack's stack.
|
|
110
|
+
#
|
|
111
|
+
# class MyObject
|
|
112
|
+
# ...
|
|
113
|
+
# def context app
|
|
114
|
+
# Rack::Utils::Context.new app do |env|
|
|
115
|
+
# do_stuff
|
|
116
|
+
# response = app.call(env)
|
|
117
|
+
# do_more_stuff
|
|
118
|
+
# end
|
|
119
|
+
# end
|
|
120
|
+
# ...
|
|
121
|
+
# end
|
|
122
|
+
#
|
|
123
|
+
# mobj = MyObject.new
|
|
124
|
+
# app = mobj.context other_app
|
|
125
|
+
# Rack::Handler::Mongrel.new app
|
|
126
|
+
class Context < Proc
|
|
127
|
+
alias_method :old_inspect, :inspect
|
|
128
|
+
attr_reader :for, :app
|
|
129
|
+
def initialize app_f, app_r
|
|
130
|
+
raise 'running context not provided' unless app_f
|
|
131
|
+
raise 'running context does not respond to #context' unless app_f.respond_to? :context
|
|
132
|
+
raise 'application context not provided' unless app_r
|
|
133
|
+
raise 'application context does not respond to #call' unless app_r.respond_to? :call
|
|
134
|
+
@for = app_f
|
|
135
|
+
@app = app_r
|
|
136
|
+
end
|
|
137
|
+
def inspect
|
|
138
|
+
"#{old_inspect} ==> #{@for.inspect} ==> #{@app.inspect}"
|
|
139
|
+
end
|
|
140
|
+
def context app_r
|
|
141
|
+
raise 'new application context not provided' unless app_r
|
|
142
|
+
raise 'new application context does not respond to #call' unless app_r.respond_to? :call
|
|
143
|
+
@for.context app_r
|
|
144
|
+
end
|
|
145
|
+
def pretty_print pp
|
|
146
|
+
pp.text old_inspect
|
|
147
|
+
pp.nest 1 do
|
|
148
|
+
pp.breakable
|
|
149
|
+
pp.text '=for> '
|
|
150
|
+
pp.pp @for
|
|
151
|
+
pp.breakable
|
|
152
|
+
pp.text '=app> '
|
|
153
|
+
pp.pp @app
|
|
154
|
+
end
|
|
155
|
+
end
|
|
156
|
+
end
|
|
157
|
+
|
|
158
|
+
# A case-normalizing Hash, adjusting on [] and []=.
|
|
159
|
+
class HeaderHash < Hash
|
|
160
|
+
def initialize(hash={})
|
|
161
|
+
hash.each { |k, v| self[k] = v }
|
|
162
|
+
end
|
|
163
|
+
|
|
164
|
+
def to_hash
|
|
165
|
+
{}.replace(self)
|
|
166
|
+
end
|
|
167
|
+
|
|
168
|
+
def [](k)
|
|
169
|
+
super capitalize(k)
|
|
170
|
+
end
|
|
171
|
+
|
|
172
|
+
def []=(k, v)
|
|
173
|
+
super capitalize(k), v
|
|
174
|
+
end
|
|
175
|
+
|
|
176
|
+
def capitalize(k)
|
|
177
|
+
k.to_s.downcase.gsub(/^.|[-_\s]./) { |x| x.upcase }
|
|
178
|
+
end
|
|
179
|
+
end
|
|
180
|
+
|
|
181
|
+
# Every standard HTTP code mapped to the appropriate message.
|
|
182
|
+
# Stolen from Mongrel.
|
|
183
|
+
HTTP_STATUS_CODES = {
|
|
184
|
+
100 => 'Continue',
|
|
185
|
+
101 => 'Switching Protocols',
|
|
186
|
+
200 => 'OK',
|
|
187
|
+
201 => 'Created',
|
|
188
|
+
202 => 'Accepted',
|
|
189
|
+
203 => 'Non-Authoritative Information',
|
|
190
|
+
204 => 'No Content',
|
|
191
|
+
205 => 'Reset Content',
|
|
192
|
+
206 => 'Partial Content',
|
|
193
|
+
300 => 'Multiple Choices',
|
|
194
|
+
301 => 'Moved Permanently',
|
|
195
|
+
302 => 'Moved Temporarily',
|
|
196
|
+
303 => 'See Other',
|
|
197
|
+
304 => 'Not Modified',
|
|
198
|
+
305 => 'Use Proxy',
|
|
199
|
+
400 => 'Bad Request',
|
|
200
|
+
401 => 'Unauthorized',
|
|
201
|
+
402 => 'Payment Required',
|
|
202
|
+
403 => 'Forbidden',
|
|
203
|
+
404 => 'Not Found',
|
|
204
|
+
405 => 'Method Not Allowed',
|
|
205
|
+
406 => 'Not Acceptable',
|
|
206
|
+
407 => 'Proxy Authentication Required',
|
|
207
|
+
408 => 'Request Time-out',
|
|
208
|
+
409 => 'Conflict',
|
|
209
|
+
410 => 'Gone',
|
|
210
|
+
411 => 'Length Required',
|
|
211
|
+
412 => 'Precondition Failed',
|
|
212
|
+
413 => 'Request Entity Too Large',
|
|
213
|
+
414 => 'Request-URI Too Large',
|
|
214
|
+
415 => 'Unsupported Media Type',
|
|
215
|
+
500 => 'Internal Server Error',
|
|
216
|
+
501 => 'Not Implemented',
|
|
217
|
+
502 => 'Bad Gateway',
|
|
218
|
+
503 => 'Service Unavailable',
|
|
219
|
+
504 => 'Gateway Time-out',
|
|
220
|
+
505 => 'HTTP Version not supported'
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
# A multipart form data parser, adapted from IOWA.
|
|
224
|
+
#
|
|
225
|
+
# Usually, Rack::Request#POST takes care of calling this.
|
|
226
|
+
|
|
227
|
+
module Multipart
|
|
228
|
+
EOL = "\r\n"
|
|
229
|
+
|
|
230
|
+
def self.parse_multipart(env)
|
|
231
|
+
unless env['CONTENT_TYPE'] =~
|
|
232
|
+
%r|\Amultipart/form-data.*boundary=\"?([^\";,]+)\"?|n
|
|
233
|
+
nil
|
|
234
|
+
else
|
|
235
|
+
boundary = "--#{$1}"
|
|
236
|
+
|
|
237
|
+
params = {}
|
|
238
|
+
buf = ""
|
|
239
|
+
content_length = env['CONTENT_LENGTH'].to_i
|
|
240
|
+
input = env['rack.input']
|
|
241
|
+
|
|
242
|
+
boundary_size = boundary.size + EOL.size
|
|
243
|
+
bufsize = 16384
|
|
244
|
+
|
|
245
|
+
content_length -= boundary_size
|
|
246
|
+
|
|
247
|
+
status = input.read(boundary_size)
|
|
248
|
+
raise EOFError, "bad content body" unless status == boundary + EOL
|
|
249
|
+
|
|
250
|
+
rx = /(?:#{EOL})?#{Regexp.quote boundary}(#{EOL}|--)/
|
|
251
|
+
|
|
252
|
+
loop {
|
|
253
|
+
head = nil
|
|
254
|
+
body = ''
|
|
255
|
+
filename = content_type = name = nil
|
|
256
|
+
|
|
257
|
+
until head && buf =~ rx
|
|
258
|
+
if !head && i = buf.index("\r\n\r\n")
|
|
259
|
+
head = buf.slice!(0, i+2) # First \r\n
|
|
260
|
+
buf.slice!(0, 2) # Second \r\n
|
|
261
|
+
|
|
262
|
+
filename = head[/Content-Disposition:.* filename="?([^\";]*)"?/ni, 1]
|
|
263
|
+
content_type = head[/Content-Type: (.*)\r\n/ni, 1]
|
|
264
|
+
name = head[/Content-Disposition:.* name="?([^\";]*)"?/ni, 1]
|
|
265
|
+
|
|
266
|
+
if filename
|
|
267
|
+
body = Tempfile.new("RackMultipart")
|
|
268
|
+
body.binmode if body.respond_to?(:binmode)
|
|
269
|
+
end
|
|
270
|
+
|
|
271
|
+
next
|
|
272
|
+
end
|
|
273
|
+
|
|
274
|
+
# Save the read body part.
|
|
275
|
+
if head && (boundary_size+4 < buf.size)
|
|
276
|
+
body << buf.slice!(0, buf.size - (boundary_size+4))
|
|
277
|
+
end
|
|
278
|
+
|
|
279
|
+
c = input.read(bufsize < content_length ? bufsize : content_length)
|
|
280
|
+
raise EOFError, "bad content body" if c.nil? || c.empty?
|
|
281
|
+
buf << c
|
|
282
|
+
content_length -= c.size
|
|
283
|
+
end
|
|
284
|
+
|
|
285
|
+
# Save the rest.
|
|
286
|
+
if i = buf.index(rx)
|
|
287
|
+
body << buf.slice!(0, i)
|
|
288
|
+
buf.slice!(0, boundary_size+2)
|
|
289
|
+
|
|
290
|
+
content_length = -1 if $1 == "--"
|
|
291
|
+
end
|
|
292
|
+
|
|
293
|
+
if filename
|
|
294
|
+
body.rewind
|
|
295
|
+
data = {:filename => filename, :type => content_type,
|
|
296
|
+
:name => name, :tempfile => body, :head => head}
|
|
297
|
+
else
|
|
298
|
+
data = body
|
|
299
|
+
end
|
|
300
|
+
|
|
301
|
+
if name
|
|
302
|
+
if name =~ /\[\]\z/
|
|
303
|
+
params[name] ||= []
|
|
304
|
+
params[name] << data
|
|
305
|
+
else
|
|
306
|
+
params[name] = data
|
|
307
|
+
end
|
|
308
|
+
end
|
|
309
|
+
|
|
310
|
+
break if buf.empty? || content_length == -1
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
params
|
|
314
|
+
end
|
|
315
|
+
end
|
|
316
|
+
end
|
|
317
|
+
end
|
|
318
|
+
end
|
|
@@ -0,0 +1,1327 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
# rcov Copyright (c) 2004-2006 Mauricio Fernandez <mfp@acm.org>
|
|
3
|
+
#
|
|
4
|
+
# rcov originally based on
|
|
5
|
+
# module COVERAGE__ originally (c) NAKAMURA Hiroshi
|
|
6
|
+
# module PrettyCoverage originally (c) Simon Strandgaard
|
|
7
|
+
#
|
|
8
|
+
# rewritten & extended by Mauricio Fern�ndez <mfp@acm.org>
|
|
9
|
+
#
|
|
10
|
+
# See LEGAL and LICENSE for additional licensing information.
|
|
11
|
+
#
|
|
12
|
+
|
|
13
|
+
require 'cgi'
|
|
14
|
+
require 'rbconfig'
|
|
15
|
+
require 'optparse'
|
|
16
|
+
require 'ostruct'
|
|
17
|
+
# load xx-0.1.0-1
|
|
18
|
+
eval File.read(File.expand_path(__FILE__)).gsub(/.*^__END__$/m,"")
|
|
19
|
+
|
|
20
|
+
# extend XX
|
|
21
|
+
module XX
|
|
22
|
+
module XMLish
|
|
23
|
+
include Markup
|
|
24
|
+
|
|
25
|
+
def xmlish_ *a, &b
|
|
26
|
+
xx_which(XMLish){ xx_with_doc_in_effect(*a, &b)}
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
SCRIPT_LINES__ = {} unless defined? SCRIPT_LINES__
|
|
32
|
+
require 'rcov/version'
|
|
33
|
+
require 'rcov/report'
|
|
34
|
+
|
|
35
|
+
#{{{ "main" code
|
|
36
|
+
options = OpenStruct.new
|
|
37
|
+
options.color = true
|
|
38
|
+
options.range = 30.0
|
|
39
|
+
options.profiling = false
|
|
40
|
+
options.destdir = nil
|
|
41
|
+
options.loadpaths = []
|
|
42
|
+
options.textmode = false
|
|
43
|
+
options.skip = Rcov::Formatter::DEFAULT_OPTS[:ignore]
|
|
44
|
+
options.include = []
|
|
45
|
+
options.html = true
|
|
46
|
+
options.comments_run_by_default = false
|
|
47
|
+
options.test_unit_only = false
|
|
48
|
+
options.spec_only = false
|
|
49
|
+
options.sort = :name
|
|
50
|
+
options.sort_reverse = false
|
|
51
|
+
options.output_threshold = 101
|
|
52
|
+
options.replace_prog_name = false
|
|
53
|
+
options.callsites = false
|
|
54
|
+
options.crossrefs = false
|
|
55
|
+
options.coverage_diff_file = "coverage.info"
|
|
56
|
+
options.coverage_diff_mode = :compare
|
|
57
|
+
options.coverage_diff_save = false
|
|
58
|
+
options.diff_cmd = "diff"
|
|
59
|
+
options.report_cov_bug_for = nil
|
|
60
|
+
options.aggregate_file = nil
|
|
61
|
+
options.gcc_output = false
|
|
62
|
+
options.show_validator_links = true
|
|
63
|
+
options.charset = nil
|
|
64
|
+
|
|
65
|
+
EXTRA_HELP = <<-EOF
|
|
66
|
+
|
|
67
|
+
You can run several programs at once:
|
|
68
|
+
rcov something.rb somethingelse.rb
|
|
69
|
+
|
|
70
|
+
The parameters to be passed to the program under inspection can be specified
|
|
71
|
+
after --:
|
|
72
|
+
|
|
73
|
+
rcov -Ilib -t something.rb -- --theseopts --are --given --to --something.rb
|
|
74
|
+
|
|
75
|
+
ARGV will be set to the specified parameters after --.
|
|
76
|
+
Keep in mind that all the programs are run under the same process
|
|
77
|
+
(i.e. they just get Kernel#load()'ed in sequence).
|
|
78
|
+
|
|
79
|
+
$PROGRAM_NAME (aka. $0) will be set before each file is load()ed if
|
|
80
|
+
--replace-progname is used.
|
|
81
|
+
EOF
|
|
82
|
+
|
|
83
|
+
#{{{ OptionParser
|
|
84
|
+
opts = OptionParser.new do |opts|
|
|
85
|
+
opts.banner = <<-EOF
|
|
86
|
+
rcov #{Rcov::VERSION} #{Rcov::RELEASE_DATE}
|
|
87
|
+
Usage: rcov [options] <script1.rb> [script2.rb] [-- --extra-options]
|
|
88
|
+
EOF
|
|
89
|
+
opts.separator ""
|
|
90
|
+
opts.separator "Options:"
|
|
91
|
+
opts.on("-o", "--output PATH", "Destination directory.") do |dir|
|
|
92
|
+
options.destdir = dir
|
|
93
|
+
end
|
|
94
|
+
opts.on("-I", "--include PATHS",
|
|
95
|
+
"Prepend PATHS to $: (colon separated list)") do |paths|
|
|
96
|
+
options.loadpaths = paths.split(/:/)
|
|
97
|
+
end
|
|
98
|
+
opts.on("--[no-]comments",
|
|
99
|
+
"Mark all comments by default.",
|
|
100
|
+
"(default: --no-comments)") do |comments_run_p|
|
|
101
|
+
options.comments_run_by_default = comments_run_p
|
|
102
|
+
end
|
|
103
|
+
opts.on("--test-unit-only",
|
|
104
|
+
"Only trace code executed inside TestCases.") do
|
|
105
|
+
options.test_unit_only = true
|
|
106
|
+
end
|
|
107
|
+
opts.on("--spec-only",
|
|
108
|
+
"Only trace code executed inside RSpec specs.") do
|
|
109
|
+
options.spec_only = true
|
|
110
|
+
end
|
|
111
|
+
opts.on("-n", "--no-color", "Create colorblind-safe output.") do
|
|
112
|
+
options.color = false
|
|
113
|
+
end
|
|
114
|
+
opts.on("-i", "--include-file PATTERNS",
|
|
115
|
+
"Generate info for files matching a",
|
|
116
|
+
"pattern (comma-separated regexp list)") do |list|
|
|
117
|
+
begin
|
|
118
|
+
regexps = list.split(/,/).map{|x| Regexp.new(x) }
|
|
119
|
+
options.include += regexps
|
|
120
|
+
rescue RegexpError => e
|
|
121
|
+
raise OptionParser::InvalidArgument, e.message
|
|
122
|
+
end
|
|
123
|
+
end
|
|
124
|
+
opts.on("-x", "--exclude PATTERNS",
|
|
125
|
+
"Don't generate info for files matching a",
|
|
126
|
+
"pattern (comma-separated regexp list)") do |list|
|
|
127
|
+
begin
|
|
128
|
+
regexps = list.split(/,/).map{|x| Regexp.new x}
|
|
129
|
+
options.skip += regexps
|
|
130
|
+
rescue RegexpError => e
|
|
131
|
+
raise OptionParser::InvalidArgument, e.message
|
|
132
|
+
end
|
|
133
|
+
end
|
|
134
|
+
opts.on("--exclude-only PATTERNS",
|
|
135
|
+
"Skip info only for files matching the",
|
|
136
|
+
"given patterns.") do |list|
|
|
137
|
+
begin
|
|
138
|
+
options.skip = list.split(/,/).map{|x| Regexp.new(x) }
|
|
139
|
+
rescue RegexpError => e
|
|
140
|
+
raise OptionParser::InvalidArgument, e.message
|
|
141
|
+
end
|
|
142
|
+
end
|
|
143
|
+
opts.on("--rails", "Skip config/, environment/ and vendor/.") do
|
|
144
|
+
options.skip.concat [%r{\bvendor/},%r{\bconfig/},%r{\benvironment/}]
|
|
145
|
+
end
|
|
146
|
+
opts.on("--[no-]callsites", "Show callsites in generated XHTML report.",
|
|
147
|
+
"(somewhat slower; disabled by default)") do |val|
|
|
148
|
+
options.callsites = val
|
|
149
|
+
end
|
|
150
|
+
opts.on("--[no-]xrefs", "Generate fully cross-referenced report.",
|
|
151
|
+
"(includes --callsites)") do |val|
|
|
152
|
+
options.crossrefs = val
|
|
153
|
+
options.callsites ||= val
|
|
154
|
+
end
|
|
155
|
+
opts.on("-p", "--profile", "Generate bogo-profiling info.") do
|
|
156
|
+
options.profiling = true
|
|
157
|
+
options.destdir ||= "profiling"
|
|
158
|
+
end
|
|
159
|
+
opts.on("-r", "--range RANGE", Float,
|
|
160
|
+
"Color scale range for profiling info (dB).") do |val|
|
|
161
|
+
options.range = val
|
|
162
|
+
end
|
|
163
|
+
opts.on("-a", "--annotate",
|
|
164
|
+
"Generate annotated source code.") do
|
|
165
|
+
options.html = false
|
|
166
|
+
options.textmode = :annotate
|
|
167
|
+
options.crossrefs = true
|
|
168
|
+
options.callsites = true
|
|
169
|
+
options.skip = [ %r!/test/unit/! ]
|
|
170
|
+
end
|
|
171
|
+
|
|
172
|
+
opts.on("-T", "--text-report", "Dump detailed plain-text report to stdout.",
|
|
173
|
+
"(filename, LoC, total lines, coverage)") do
|
|
174
|
+
options.textmode = :report
|
|
175
|
+
end
|
|
176
|
+
opts.on("-t", "--text-summary", "Dump plain-text summary to stdout.") do
|
|
177
|
+
options.textmode = :summary
|
|
178
|
+
end
|
|
179
|
+
opts.on("--text-counts", "Dump execution counts in plaintext.") do
|
|
180
|
+
options.textmode = :counts
|
|
181
|
+
end
|
|
182
|
+
opts.on("--text-coverage", "Dump coverage info to stdout, using",
|
|
183
|
+
"ANSI color sequences unless -n.") do
|
|
184
|
+
options.textmode = :coverage
|
|
185
|
+
end
|
|
186
|
+
opts.on("--gcc", "Dump uncovered line in GCC error format.") do
|
|
187
|
+
options.gcc_output = true
|
|
188
|
+
end
|
|
189
|
+
opts.on("--aggregate FILE", "Aggregate data from previous runs",
|
|
190
|
+
"in FILE. Overwrites FILE with the",
|
|
191
|
+
"merged data. FILE is created if",
|
|
192
|
+
"necessary.") do |file|
|
|
193
|
+
options.aggregate_file = file
|
|
194
|
+
end
|
|
195
|
+
opts.on("-D [FILE]", "--text-coverage-diff [FILE]",
|
|
196
|
+
"Compare code coverage with saved state",
|
|
197
|
+
"in FILE, defaults to coverage.info.",
|
|
198
|
+
"Implies --comments.") do |file|
|
|
199
|
+
options.textmode = :coverage_diff
|
|
200
|
+
options.comments_run_by_default = true
|
|
201
|
+
if options.coverage_diff_save
|
|
202
|
+
raise "You shouldn't use --save and --text-coverage-diff at a time."
|
|
203
|
+
end
|
|
204
|
+
options.coverage_diff_mode = :compare
|
|
205
|
+
options.coverage_diff_file = file if file && !file.empty?
|
|
206
|
+
end
|
|
207
|
+
opts.on("--save [FILE]", "Save coverage data to FILE,",
|
|
208
|
+
"for later use with rcov -D.",
|
|
209
|
+
"(default: coverage.info)") do |file|
|
|
210
|
+
options.coverage_diff_save = true
|
|
211
|
+
options.coverage_diff_mode = :record
|
|
212
|
+
if options.textmode == :coverage_diff
|
|
213
|
+
raise "You shouldn't use --save and --text-coverage-diff at a time."
|
|
214
|
+
end
|
|
215
|
+
options.coverage_diff_file = file if file && !file.empty?
|
|
216
|
+
end
|
|
217
|
+
opts.on("--[no-]html", "Generate HTML output.",
|
|
218
|
+
"(default: --html)") do |val|
|
|
219
|
+
options.html = val
|
|
220
|
+
end
|
|
221
|
+
opts.on("--sort CRITERION", [:name, :loc, :coverage],
|
|
222
|
+
"Sort files in the output by the specified",
|
|
223
|
+
"field (name, loc, coverage)") do |criterion|
|
|
224
|
+
options.sort = criterion
|
|
225
|
+
end
|
|
226
|
+
opts.on("--sort-reverse", "Reverse files in the output.") do
|
|
227
|
+
options.sort_reverse = true
|
|
228
|
+
end
|
|
229
|
+
opts.on("--threshold INT", "Only list files with coverage < INT %.",
|
|
230
|
+
"(default: 101)") do |threshold|
|
|
231
|
+
begin
|
|
232
|
+
threshold = Integer(threshold)
|
|
233
|
+
raise if threshold <= 0 || threshold > 101
|
|
234
|
+
rescue Exception
|
|
235
|
+
raise OptionParser::InvalidArgument, threshold
|
|
236
|
+
end
|
|
237
|
+
options.output_threshold = threshold
|
|
238
|
+
end
|
|
239
|
+
opts.on("--charset CHARSET",
|
|
240
|
+
"Charset used in Content-Type declaration of HTML reports.") do |c|
|
|
241
|
+
options.charset = c
|
|
242
|
+
end
|
|
243
|
+
opts.on("--[no-]validator-links", "Add link to W3C's validation services.",
|
|
244
|
+
"(default: true)") do |show_validator_links|
|
|
245
|
+
options.show_validator_links = show_validator_links
|
|
246
|
+
end
|
|
247
|
+
opts.on("--only-uncovered", "Same as --threshold 100") do
|
|
248
|
+
options.output_threshold = 100
|
|
249
|
+
end
|
|
250
|
+
opts.on("--replace-progname", "Replace $0 when loading the .rb files.") do
|
|
251
|
+
options.replace_prog_name = true
|
|
252
|
+
end
|
|
253
|
+
opts.on("-w", "Turn warnings on (like ruby).") do
|
|
254
|
+
$VERBOSE = true
|
|
255
|
+
end
|
|
256
|
+
opts.on("--no-rcovrt", "Do not use the optimized C runtime.",
|
|
257
|
+
"(will run 30-300 times slower)") do
|
|
258
|
+
$rcov_do_not_use_rcovrt = true
|
|
259
|
+
end
|
|
260
|
+
opts.on("--diff-cmd PROGNAME", "Use PROGNAME for --text-coverage-diff.",
|
|
261
|
+
"(default: diff)") do |cmd|
|
|
262
|
+
options.diff_cmd = cmd
|
|
263
|
+
end
|
|
264
|
+
opts.separator ""
|
|
265
|
+
opts.on_tail("-h", "--help", "Show extended help message") do
|
|
266
|
+
require 'pp'
|
|
267
|
+
puts opts
|
|
268
|
+
puts <<EOF
|
|
269
|
+
|
|
270
|
+
Files matching any of the following regexps will be omitted in the report(s):
|
|
271
|
+
#{PP.pp(options.skip, "").chomp}
|
|
272
|
+
EOF
|
|
273
|
+
puts EXTRA_HELP
|
|
274
|
+
exit
|
|
275
|
+
end
|
|
276
|
+
opts.on_tail("--report-cov-bug SELECTOR",
|
|
277
|
+
"Report coverage analysis bug for the",
|
|
278
|
+
"method specified by SELECTOR",
|
|
279
|
+
"(format: Foo::Bar#method, A::B.method)") do |selector|
|
|
280
|
+
case selector
|
|
281
|
+
when /([^.]+)(#|\.)(.*)/: options.report_cov_bug_for = selector
|
|
282
|
+
else
|
|
283
|
+
raise OptionParser::InvalidArgument, selector
|
|
284
|
+
end
|
|
285
|
+
options.textmode = nil
|
|
286
|
+
options.html = false
|
|
287
|
+
options.callsites = true
|
|
288
|
+
end
|
|
289
|
+
opts.on_tail("--version", "Show version") do
|
|
290
|
+
puts "rcov " + Rcov::VERSION + " " + Rcov::RELEASE_DATE
|
|
291
|
+
exit
|
|
292
|
+
end
|
|
293
|
+
end
|
|
294
|
+
|
|
295
|
+
$ORIGINAL_ARGV = ARGV.clone
|
|
296
|
+
if (idx = ARGV.index("--"))
|
|
297
|
+
extra_args = ARGV[idx+1..-1]
|
|
298
|
+
ARGV.replace(ARGV[0,idx])
|
|
299
|
+
else
|
|
300
|
+
extra_args = []
|
|
301
|
+
end
|
|
302
|
+
|
|
303
|
+
begin
|
|
304
|
+
opts.parse! ARGV
|
|
305
|
+
rescue OptionParser::InvalidOption, OptionParser::InvalidArgument,
|
|
306
|
+
OptionParser::MissingArgument => e
|
|
307
|
+
puts opts
|
|
308
|
+
puts
|
|
309
|
+
puts e.message
|
|
310
|
+
exit(-1)
|
|
311
|
+
end
|
|
312
|
+
options.destdir ||= "coverage"
|
|
313
|
+
unless ARGV[0] or options.aggregate_file && File.file?(options.aggregate_file)
|
|
314
|
+
puts opts
|
|
315
|
+
exit
|
|
316
|
+
end
|
|
317
|
+
|
|
318
|
+
# {{{ set loadpath
|
|
319
|
+
options.loadpaths.reverse_each{|x| $:.unshift x}
|
|
320
|
+
|
|
321
|
+
#{{{ require 'rcov': do it only now in order to be able to run rcov on itself
|
|
322
|
+
# since we need to set $: before.
|
|
323
|
+
|
|
324
|
+
require 'rcov'
|
|
325
|
+
|
|
326
|
+
options.callsites = true if options.report_cov_bug_for
|
|
327
|
+
options.textmode = :gcc if !options.textmode and options.gcc_output
|
|
328
|
+
|
|
329
|
+
def rcov_load_aggregate_data(file)
|
|
330
|
+
require 'zlib'
|
|
331
|
+
begin
|
|
332
|
+
old_data = nil
|
|
333
|
+
Zlib::GzipReader.open(file){|gz| old_data = Marshal.load(gz) }
|
|
334
|
+
rescue
|
|
335
|
+
old_data = {}
|
|
336
|
+
end
|
|
337
|
+
old_data || {}
|
|
338
|
+
end
|
|
339
|
+
|
|
340
|
+
def rcov_save_aggregate_data(file)
|
|
341
|
+
require 'zlib'
|
|
342
|
+
Zlib::GzipWriter.open(file) do |f|
|
|
343
|
+
Marshal.dump({:callsites => $rcov_callsite_analyzer,
|
|
344
|
+
:coverage => $rcov_code_coverage_analyzer}, f)
|
|
345
|
+
end
|
|
346
|
+
end
|
|
347
|
+
|
|
348
|
+
if options.callsites
|
|
349
|
+
if options.aggregate_file
|
|
350
|
+
saved_aggregate_data = rcov_load_aggregate_data(options.aggregate_file)
|
|
351
|
+
if saved_aggregate_data[:callsites]
|
|
352
|
+
$rcov_callsite_analyzer = saved_aggregate_data[:callsites]
|
|
353
|
+
end
|
|
354
|
+
end
|
|
355
|
+
$rcov_callsite_analyzer ||= Rcov::CallSiteAnalyzer.new
|
|
356
|
+
$rcov_callsite_analyzer.install_hook
|
|
357
|
+
else
|
|
358
|
+
$rcov_callsite_analyzer = nil
|
|
359
|
+
end
|
|
360
|
+
|
|
361
|
+
# {{{ create formatters
|
|
362
|
+
formatters = []
|
|
363
|
+
make_formatter = lambda do |klass|
|
|
364
|
+
klass.new(:destdir => options.destdir, :color => options.color,
|
|
365
|
+
:fsr => options.range, :textmode => options.textmode,
|
|
366
|
+
:ignore => options.skip, :dont_ignore => options.include,
|
|
367
|
+
:sort => options.sort,
|
|
368
|
+
:sort_reverse => options.sort_reverse,
|
|
369
|
+
:output_threshold => options.output_threshold,
|
|
370
|
+
:callsite_analyzer => $rcov_callsite_analyzer,
|
|
371
|
+
:coverage_diff_mode => options.coverage_diff_mode,
|
|
372
|
+
:coverage_diff_file => options.coverage_diff_file,
|
|
373
|
+
:callsites => options.callsites,
|
|
374
|
+
:cross_references => options.crossrefs,
|
|
375
|
+
:diff_cmd => options.diff_cmd,
|
|
376
|
+
:comments_run_by_default => options.comments_run_by_default,
|
|
377
|
+
:gcc_output => options.gcc_output,
|
|
378
|
+
:validator_links => options.show_validator_links,
|
|
379
|
+
:charset => options.charset
|
|
380
|
+
)
|
|
381
|
+
end
|
|
382
|
+
|
|
383
|
+
if options.html
|
|
384
|
+
if options.profiling
|
|
385
|
+
formatters << make_formatter[Rcov::HTMLProfiling]
|
|
386
|
+
else
|
|
387
|
+
formatters << make_formatter[Rcov::HTMLCoverage]
|
|
388
|
+
end
|
|
389
|
+
end
|
|
390
|
+
textual_formatters = {:counts => Rcov::FullTextReport,
|
|
391
|
+
:coverage => Rcov::FullTextReport,
|
|
392
|
+
:gcc => Rcov::FullTextReport,
|
|
393
|
+
:annotate => Rcov::RubyAnnotation,
|
|
394
|
+
:summary => Rcov::TextSummary, :report => Rcov::TextReport,
|
|
395
|
+
:coverage_diff => Rcov::TextCoverageDiff}
|
|
396
|
+
|
|
397
|
+
if textual_formatters[options.textmode]
|
|
398
|
+
formatters << make_formatter[textual_formatters[options.textmode]]
|
|
399
|
+
end
|
|
400
|
+
|
|
401
|
+
formatters << make_formatter[Rcov::TextCoverageDiff] if options.coverage_diff_save
|
|
402
|
+
|
|
403
|
+
if options.aggregate_file
|
|
404
|
+
saved_aggregate_data ||= rcov_load_aggregate_data(options.aggregate_file)
|
|
405
|
+
if saved_aggregate_data[:coverage]
|
|
406
|
+
$rcov_code_coverage_analyzer = saved_aggregate_data[:coverage]
|
|
407
|
+
end
|
|
408
|
+
end
|
|
409
|
+
$rcov_code_coverage_analyzer ||= Rcov::CodeCoverageAnalyzer.new
|
|
410
|
+
|
|
411
|
+
# must be registered before test/unit puts its own
|
|
412
|
+
|
|
413
|
+
|
|
414
|
+
# The exception to rethrow after reporting has been handled.
|
|
415
|
+
$__rcov_exit_exception = nil
|
|
416
|
+
|
|
417
|
+
END {
|
|
418
|
+
$rcov_code_coverage_analyzer.remove_hook
|
|
419
|
+
$rcov_callsite_analyzer.remove_hook if $rcov_callsite_analyzer
|
|
420
|
+
rcov_save_aggregate_data(options.aggregate_file) if options.aggregate_file
|
|
421
|
+
$rcov_code_coverage_analyzer.dump_coverage_info(formatters)
|
|
422
|
+
if options.report_cov_bug_for
|
|
423
|
+
defsite = $rcov_callsite_analyzer.defsite(options.report_cov_bug_for)
|
|
424
|
+
if !defsite
|
|
425
|
+
$stderr.puts <<-EOF
|
|
426
|
+
Couldn't find definition site of #{options.report_cov_bug_for}.
|
|
427
|
+
Was it executed at all?
|
|
428
|
+
EOF
|
|
429
|
+
exit(-1)
|
|
430
|
+
end
|
|
431
|
+
lines, mark_info, count_info = $rcov_code_coverage_analyzer.data(defsite.file)
|
|
432
|
+
puts <<EOF
|
|
433
|
+
|
|
434
|
+
Please fill in the blanks in the following report.
|
|
435
|
+
|
|
436
|
+
You can report the bug via the Ruby-Talk ML, send it directly to
|
|
437
|
+
<mfp at acm dot org> (include "rcov" in the subject to get past the spam filters),
|
|
438
|
+
or post it to
|
|
439
|
+
http://eigenclass.org/hiki.rb?rcov+#{VERSION}
|
|
440
|
+
|
|
441
|
+
Thank you!
|
|
442
|
+
|
|
443
|
+
=============================================================================
|
|
444
|
+
Bug report generated on #{Time.new}
|
|
445
|
+
|
|
446
|
+
Ruby version: #{RUBY_VERSION} (#{RUBY_RELEASE_DATE})
|
|
447
|
+
Platform: #{RUBY_PLATFORM}
|
|
448
|
+
rcov version: #{Rcov::VERSION}
|
|
449
|
+
rcovrt loaded? #{$".any?{|x| /\brcovrt\b/ =~ x} }
|
|
450
|
+
using RubyGems? #{$".any?{|x| /\brubygems\b/ =~ x} }
|
|
451
|
+
Command-line arguments: #{$ORIGINAL_ARGV.inspect}
|
|
452
|
+
Coverage analysis bug in: #{options.report_cov_bug_for}
|
|
453
|
+
|
|
454
|
+
Line(s) ____________ should be ______ (red/green).
|
|
455
|
+
|
|
456
|
+
Raw coverage information (feel free to remove useless data, but please leave
|
|
457
|
+
some context around the faulty lines):
|
|
458
|
+
|
|
459
|
+
EOF
|
|
460
|
+
defsite.line.upto(SCRIPT_LINES__[defsite.file].size) do |i|
|
|
461
|
+
puts "%7d:%5d:%s" % [count_info[i-1], i, lines[i-1]]
|
|
462
|
+
end
|
|
463
|
+
exit
|
|
464
|
+
end
|
|
465
|
+
if formatters.all?{|formatter| formatter.sorted_file_pairs.empty? }
|
|
466
|
+
require 'pp'
|
|
467
|
+
$stderr.puts <<-EOF
|
|
468
|
+
|
|
469
|
+
No file to analyze was found. All the files loaded by rcov matched one of the
|
|
470
|
+
following expressions, and were thus ignored:
|
|
471
|
+
#{PP.pp(options.skip, "").chomp}
|
|
472
|
+
|
|
473
|
+
You can solve this by doing one or more of the following:
|
|
474
|
+
* rename the files not to be ignored so they don't match the above regexps
|
|
475
|
+
* use --include-file to give a list of patterns for files not to be ignored
|
|
476
|
+
* use --exclude-only to give the new list of regexps to match against
|
|
477
|
+
* structure your code as follows:
|
|
478
|
+
test/test_*.rb for the test cases
|
|
479
|
+
lib/**/*.rb for the target source code whose coverage you want
|
|
480
|
+
making sure that the test/test_*.rb files are loading from lib/, e.g. by
|
|
481
|
+
using the -Ilib command-line argument, adding
|
|
482
|
+
$:.unshift File.join(File.dirname(__FILE__), "..", "lib")
|
|
483
|
+
to test/test_*.rb, or running rcov via a Rakefile (read the RDoc
|
|
484
|
+
documentation or README.rake in the source distribution).
|
|
485
|
+
EOF
|
|
486
|
+
end
|
|
487
|
+
|
|
488
|
+
raise $__rcov_exit_exception if $__rcov_exit_exception
|
|
489
|
+
}
|
|
490
|
+
|
|
491
|
+
if options.test_unit_only
|
|
492
|
+
require 'test/unit'
|
|
493
|
+
module Test::Unit
|
|
494
|
+
class TestCase
|
|
495
|
+
remove_method(:run) if instance_methods.include? "run"
|
|
496
|
+
def run(result)
|
|
497
|
+
yield(STARTED, name)
|
|
498
|
+
@_result = result
|
|
499
|
+
begin
|
|
500
|
+
$rcov_code_coverage_analyzer.run_hooked do
|
|
501
|
+
setup
|
|
502
|
+
__send__(@method_name)
|
|
503
|
+
end
|
|
504
|
+
rescue AssertionFailedError => e
|
|
505
|
+
add_failure(e.message, e.backtrace)
|
|
506
|
+
rescue StandardError, ScriptError
|
|
507
|
+
add_error($!)
|
|
508
|
+
ensure
|
|
509
|
+
begin
|
|
510
|
+
$rcov_code_coverage_analyzer.run_hooked { teardown }
|
|
511
|
+
rescue AssertionFailedError => e
|
|
512
|
+
add_failure(e.message, e.backtrace)
|
|
513
|
+
rescue StandardError, ScriptError
|
|
514
|
+
add_error($!)
|
|
515
|
+
end
|
|
516
|
+
end
|
|
517
|
+
result.add_run
|
|
518
|
+
yield(FINISHED, name)
|
|
519
|
+
end
|
|
520
|
+
end
|
|
521
|
+
end
|
|
522
|
+
elsif options.spec_only
|
|
523
|
+
require 'spec'
|
|
524
|
+
override_run = lambda do
|
|
525
|
+
oldrun = instance_method(:run)
|
|
526
|
+
define_method(:run) do |*args|
|
|
527
|
+
$rcov_code_coverage_analyzer.run_hooked { oldrun.bind(self).call(*args) }
|
|
528
|
+
end
|
|
529
|
+
end
|
|
530
|
+
if defined? Spec::DSL::Example
|
|
531
|
+
Spec::DSL::Example.instance_eval(&override_run)
|
|
532
|
+
elsif defined? Spec::Example::ExampleGroup
|
|
533
|
+
Spec::Example::ExampleGroup.instance_eval(&override_run)
|
|
534
|
+
else
|
|
535
|
+
$stderr.puts <<-EOF
|
|
536
|
+
Your RSpec version isn't supported. If it's a old one, consider upgrading;
|
|
537
|
+
otherwise, please report the problem.
|
|
538
|
+
EOF
|
|
539
|
+
exit(-1)
|
|
540
|
+
end
|
|
541
|
+
else
|
|
542
|
+
$rcov_code_coverage_analyzer.install_hook
|
|
543
|
+
end
|
|
544
|
+
|
|
545
|
+
#{{{ Load scripts
|
|
546
|
+
begin
|
|
547
|
+
pending_scripts = ARGV.clone
|
|
548
|
+
ARGV.replace extra_args
|
|
549
|
+
until pending_scripts.empty?
|
|
550
|
+
prog = pending_scripts.shift
|
|
551
|
+
if options.replace_prog_name
|
|
552
|
+
$0 = File.basename(File.expand_path(prog))
|
|
553
|
+
end
|
|
554
|
+
load prog
|
|
555
|
+
end
|
|
556
|
+
rescue Object => err
|
|
557
|
+
$__rcov_exit_exception = err
|
|
558
|
+
end
|
|
559
|
+
|
|
560
|
+
# xx-0.1.0-1 follows
|
|
561
|
+
__END__
|
|
562
|
+
# xx can be redistributed and used under the following conditions
|
|
563
|
+
# (just keep the following copyright notice, list of conditions and disclaimer
|
|
564
|
+
# in order to satisfy rcov's "Ruby license" and xx's license simultaneously).
|
|
565
|
+
#
|
|
566
|
+
#ePark Labs Public License version 1
|
|
567
|
+
#Copyright (c) 2005, ePark Labs, Inc. and contributors
|
|
568
|
+
#All rights reserved.
|
|
569
|
+
#
|
|
570
|
+
#Redistribution and use in source and binary forms, with or without modification,
|
|
571
|
+
#are permitted provided that the following conditions are met:
|
|
572
|
+
#
|
|
573
|
+
# 1. Redistributions of source code must retain the above copyright notice, this
|
|
574
|
+
# list of conditions and the following disclaimer.
|
|
575
|
+
# 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
576
|
+
# this list of conditions and the following disclaimer in the documentation
|
|
577
|
+
# and/or other materials provided with the distribution.
|
|
578
|
+
# 3. Neither the name of ePark Labs nor the names of its contributors may be
|
|
579
|
+
# used to endorse or promote products derived from this software without
|
|
580
|
+
# specific prior written permission.
|
|
581
|
+
#
|
|
582
|
+
#THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
583
|
+
#ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
584
|
+
#WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
585
|
+
#DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
|
586
|
+
#ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
587
|
+
#(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
588
|
+
#LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
|
589
|
+
#ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
590
|
+
#(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
591
|
+
#SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
592
|
+
|
|
593
|
+
unless defined? $__xx_rb__
|
|
594
|
+
|
|
595
|
+
require "rexml/document"
|
|
596
|
+
|
|
597
|
+
|
|
598
|
+
module XX
|
|
599
|
+
#--{{{
|
|
600
|
+
VERSION = "0.1.0"
|
|
601
|
+
|
|
602
|
+
%w(
|
|
603
|
+
CRAZY_LIKE_A_HELL
|
|
604
|
+
PERMISSIVE
|
|
605
|
+
STRICT
|
|
606
|
+
ANY
|
|
607
|
+
).each{|c| const_set c, c}
|
|
608
|
+
|
|
609
|
+
class Document
|
|
610
|
+
#--{{{
|
|
611
|
+
attr "doc"
|
|
612
|
+
attr "stack"
|
|
613
|
+
attr "size"
|
|
614
|
+
|
|
615
|
+
def initialize *a, &b
|
|
616
|
+
#--{{{
|
|
617
|
+
@doc = ::REXML::Document::new(*a, &b)
|
|
618
|
+
@stack = [@doc]
|
|
619
|
+
@size = 0
|
|
620
|
+
#--}}}
|
|
621
|
+
end
|
|
622
|
+
def top
|
|
623
|
+
#--{{{
|
|
624
|
+
@stack.last
|
|
625
|
+
#--}}}
|
|
626
|
+
end
|
|
627
|
+
def push element
|
|
628
|
+
#--{{{
|
|
629
|
+
@stack.push element
|
|
630
|
+
#--}}}
|
|
631
|
+
end
|
|
632
|
+
def pop
|
|
633
|
+
#--{{{
|
|
634
|
+
@stack.pop unless @stack.size == 1
|
|
635
|
+
#--}}}
|
|
636
|
+
end
|
|
637
|
+
def tracking_additions
|
|
638
|
+
#--{{{
|
|
639
|
+
n = @size
|
|
640
|
+
yield
|
|
641
|
+
return @size - n
|
|
642
|
+
#--}}}
|
|
643
|
+
end
|
|
644
|
+
def to_str port = ""
|
|
645
|
+
#--{{{
|
|
646
|
+
@doc.write port, indent=-1, transitive=false, ie_hack=true
|
|
647
|
+
port
|
|
648
|
+
#--}}}
|
|
649
|
+
end
|
|
650
|
+
alias_method "to_s", "to_str"
|
|
651
|
+
def pretty port = ''
|
|
652
|
+
#--{{{
|
|
653
|
+
@doc.write port, indent=2, transitive=false, ie_hack=true
|
|
654
|
+
port
|
|
655
|
+
#--}}}
|
|
656
|
+
end
|
|
657
|
+
def create element
|
|
658
|
+
#--{{{
|
|
659
|
+
push element
|
|
660
|
+
begin
|
|
661
|
+
object = nil
|
|
662
|
+
additions =
|
|
663
|
+
tracking_additions do
|
|
664
|
+
object = yield element if block_given?
|
|
665
|
+
end
|
|
666
|
+
if object and additions.zero?
|
|
667
|
+
self << object
|
|
668
|
+
end
|
|
669
|
+
ensure
|
|
670
|
+
pop
|
|
671
|
+
end
|
|
672
|
+
self << element
|
|
673
|
+
element
|
|
674
|
+
#--}}}
|
|
675
|
+
end
|
|
676
|
+
def << object
|
|
677
|
+
#--{{{
|
|
678
|
+
t, x = top, object
|
|
679
|
+
|
|
680
|
+
if x
|
|
681
|
+
case t
|
|
682
|
+
when ::REXML::Document
|
|
683
|
+
|
|
684
|
+
begin
|
|
685
|
+
t <<
|
|
686
|
+
case x
|
|
687
|
+
when ::REXML::Document
|
|
688
|
+
x.root || ::REXML::Text::new(x.to_s)
|
|
689
|
+
when ::REXML::Element
|
|
690
|
+
x
|
|
691
|
+
when ::REXML::CData
|
|
692
|
+
x
|
|
693
|
+
when ::REXML::Text
|
|
694
|
+
x
|
|
695
|
+
else # string
|
|
696
|
+
::REXML::Text::new(x.to_s)
|
|
697
|
+
end
|
|
698
|
+
rescue
|
|
699
|
+
if t.respond_to? "root"
|
|
700
|
+
t = t.root
|
|
701
|
+
retry
|
|
702
|
+
else
|
|
703
|
+
raise
|
|
704
|
+
end
|
|
705
|
+
end
|
|
706
|
+
|
|
707
|
+
when ::REXML::Element
|
|
708
|
+
t <<
|
|
709
|
+
case x
|
|
710
|
+
when ::REXML::Document
|
|
711
|
+
x.root || ::REXML::Text::new(x.to_s)
|
|
712
|
+
when ::REXML::Element
|
|
713
|
+
x
|
|
714
|
+
when ::REXML::CData
|
|
715
|
+
#::REXML::Text::new(x.write(""))
|
|
716
|
+
x
|
|
717
|
+
when ::REXML::Text
|
|
718
|
+
x
|
|
719
|
+
else # string
|
|
720
|
+
::REXML::Text::new(x.to_s)
|
|
721
|
+
end
|
|
722
|
+
|
|
723
|
+
when ::REXML::Text
|
|
724
|
+
t <<
|
|
725
|
+
case x
|
|
726
|
+
when ::REXML::Document
|
|
727
|
+
x.write ""
|
|
728
|
+
when ::REXML::Element
|
|
729
|
+
x.write ""
|
|
730
|
+
when ::REXML::CData
|
|
731
|
+
x.write ""
|
|
732
|
+
when ::REXML::Text
|
|
733
|
+
x.write ""
|
|
734
|
+
else # string
|
|
735
|
+
x.to_s
|
|
736
|
+
end
|
|
737
|
+
|
|
738
|
+
else # other - try anyhow
|
|
739
|
+
t <<
|
|
740
|
+
case x
|
|
741
|
+
when ::REXML::Document
|
|
742
|
+
x.write ""
|
|
743
|
+
when ::REXML::Element
|
|
744
|
+
x.write ""
|
|
745
|
+
when ::REXML::CData
|
|
746
|
+
x.write ""
|
|
747
|
+
when ::REXML::Text
|
|
748
|
+
x.write ""
|
|
749
|
+
else # string
|
|
750
|
+
x.to_s
|
|
751
|
+
end
|
|
752
|
+
end
|
|
753
|
+
end
|
|
754
|
+
|
|
755
|
+
@size += 1
|
|
756
|
+
self
|
|
757
|
+
#--}}}
|
|
758
|
+
end
|
|
759
|
+
#--}}}
|
|
760
|
+
end
|
|
761
|
+
|
|
762
|
+
module Markup
|
|
763
|
+
#--{{{
|
|
764
|
+
class Error < ::StandardError; end
|
|
765
|
+
|
|
766
|
+
module InstanceMethods
|
|
767
|
+
#--{{{
|
|
768
|
+
def method_missing m, *a, &b
|
|
769
|
+
#--{{{
|
|
770
|
+
m = m.to_s
|
|
771
|
+
|
|
772
|
+
tag_method, tag_name = xx_class::xx_tag_method_name m
|
|
773
|
+
|
|
774
|
+
c_method_missing = xx_class::xx_config_for "method_missing", xx_which
|
|
775
|
+
c_tags = xx_class::xx_config_for "tags", xx_which
|
|
776
|
+
|
|
777
|
+
pat =
|
|
778
|
+
case c_method_missing
|
|
779
|
+
when ::XX::CRAZY_LIKE_A_HELL
|
|
780
|
+
%r/.*/
|
|
781
|
+
when ::XX::PERMISSIVE
|
|
782
|
+
%r/_$/o
|
|
783
|
+
when ::XX::STRICT
|
|
784
|
+
%r/_$/o
|
|
785
|
+
else
|
|
786
|
+
super(m.to_sym, *a, &b)
|
|
787
|
+
end
|
|
788
|
+
|
|
789
|
+
super(m.to_sym, *a, &b) unless m =~ pat
|
|
790
|
+
|
|
791
|
+
if c_method_missing == ::XX::STRICT
|
|
792
|
+
super(m.to_sym, *a, &b) unless c_tags.include? tag_name
|
|
793
|
+
end
|
|
794
|
+
|
|
795
|
+
ret, defined = nil
|
|
796
|
+
|
|
797
|
+
begin
|
|
798
|
+
xx_class::xx_define_tmp_method tag_method
|
|
799
|
+
xx_class::xx_define_tag_method tag_method, tag_name
|
|
800
|
+
ret = send tag_method, *a, &b
|
|
801
|
+
defined = true
|
|
802
|
+
ensure
|
|
803
|
+
xx_class::xx_remove_tag_method tag_method unless defined
|
|
804
|
+
end
|
|
805
|
+
|
|
806
|
+
ret
|
|
807
|
+
#--}}}
|
|
808
|
+
end
|
|
809
|
+
def xx_tag_ tag_name, *a, &b
|
|
810
|
+
#--{{{
|
|
811
|
+
tag_method, tag_name = xx_class::xx_tag_method_name tag_name
|
|
812
|
+
|
|
813
|
+
ret, defined = nil
|
|
814
|
+
|
|
815
|
+
begin
|
|
816
|
+
xx_class::xx_define_tmp_method tag_method
|
|
817
|
+
xx_class::xx_define_tag_method tag_method, tag_name
|
|
818
|
+
ret = send tag_method, *a, &b
|
|
819
|
+
defined = true
|
|
820
|
+
ensure
|
|
821
|
+
xx_class::xx_remove_tag_method tag_method unless defined
|
|
822
|
+
end
|
|
823
|
+
|
|
824
|
+
ret
|
|
825
|
+
#--}}}
|
|
826
|
+
end
|
|
827
|
+
alias_method "g_", "xx_tag_"
|
|
828
|
+
def xx_which *argv
|
|
829
|
+
#--{{{
|
|
830
|
+
@xx_which = nil unless defined? @xx_which
|
|
831
|
+
if argv.empty?
|
|
832
|
+
@xx_which
|
|
833
|
+
else
|
|
834
|
+
xx_which = @xx_which
|
|
835
|
+
begin
|
|
836
|
+
@xx_which = argv.shift
|
|
837
|
+
return yield
|
|
838
|
+
ensure
|
|
839
|
+
@xx_which = xx_which
|
|
840
|
+
end
|
|
841
|
+
end
|
|
842
|
+
#--}}}
|
|
843
|
+
end
|
|
844
|
+
def xx_with_doc_in_effect *a, &b
|
|
845
|
+
#--{{{
|
|
846
|
+
@xx_docs ||= []
|
|
847
|
+
doc = ::XX::Document::new(*a)
|
|
848
|
+
ddoc = doc.doc
|
|
849
|
+
begin
|
|
850
|
+
@xx_docs.push doc
|
|
851
|
+
b.call doc if b
|
|
852
|
+
|
|
853
|
+
doctype = xx_config_for "doctype", xx_which
|
|
854
|
+
if doctype
|
|
855
|
+
unless ddoc.doctype
|
|
856
|
+
doctype = ::REXML::DocType::new doctype unless
|
|
857
|
+
::REXML::DocType === doctype
|
|
858
|
+
ddoc << doctype
|
|
859
|
+
end
|
|
860
|
+
end
|
|
861
|
+
|
|
862
|
+
xmldecl = xx_config_for "xmldecl", xx_which
|
|
863
|
+
if xmldecl
|
|
864
|
+
if ddoc.xml_decl == ::REXML::XMLDecl::default
|
|
865
|
+
xmldecl = ::REXML::XMLDecl::new xmldecl unless
|
|
866
|
+
::REXML::XMLDecl === xmldecl
|
|
867
|
+
ddoc << xmldecl
|
|
868
|
+
end
|
|
869
|
+
end
|
|
870
|
+
|
|
871
|
+
return doc
|
|
872
|
+
ensure
|
|
873
|
+
@xx_docs.pop
|
|
874
|
+
end
|
|
875
|
+
#--}}}
|
|
876
|
+
end
|
|
877
|
+
def xx_doc
|
|
878
|
+
#--{{{
|
|
879
|
+
@xx_docs.last rescue raise "no xx_doc in effect!"
|
|
880
|
+
#--}}}
|
|
881
|
+
end
|
|
882
|
+
def xx_text_ *objects, &b
|
|
883
|
+
#--{{{
|
|
884
|
+
doc = xx_doc
|
|
885
|
+
|
|
886
|
+
text =
|
|
887
|
+
::REXML::Text::new("",
|
|
888
|
+
respect_whitespace=true, parent=nil
|
|
889
|
+
)
|
|
890
|
+
|
|
891
|
+
objects.each do |object|
|
|
892
|
+
text << object.to_s if object
|
|
893
|
+
end
|
|
894
|
+
|
|
895
|
+
doc.create text, &b
|
|
896
|
+
#--}}}
|
|
897
|
+
end
|
|
898
|
+
alias_method "text_", "xx_text_"
|
|
899
|
+
alias_method "t_", "xx_text_"
|
|
900
|
+
def xx_markup_ *objects, &b
|
|
901
|
+
#--{{{
|
|
902
|
+
doc = xx_doc
|
|
903
|
+
|
|
904
|
+
doc2 = ::REXML::Document::new ""
|
|
905
|
+
|
|
906
|
+
objects.each do |object|
|
|
907
|
+
(doc2.root ? doc2.root : doc2) << ::REXML::Document::new(object.to_s)
|
|
908
|
+
end
|
|
909
|
+
|
|
910
|
+
|
|
911
|
+
ret = doc.create doc2, &b
|
|
912
|
+
puts doc2.to_s
|
|
913
|
+
STDIN.gets
|
|
914
|
+
ret
|
|
915
|
+
#--}}}
|
|
916
|
+
end
|
|
917
|
+
alias_method "x_", "xx_markup_"
|
|
918
|
+
def xx_any_ *objects, &b
|
|
919
|
+
#--{{{
|
|
920
|
+
doc = xx_doc
|
|
921
|
+
nothing = %r/.^/m
|
|
922
|
+
|
|
923
|
+
text =
|
|
924
|
+
::REXML::Text::new("",
|
|
925
|
+
respect_whitespace=true, parent=nil, raw=true, entity_filter=nil, illegal=nothing
|
|
926
|
+
)
|
|
927
|
+
|
|
928
|
+
objects.each do |object|
|
|
929
|
+
text << object.to_s if object
|
|
930
|
+
end
|
|
931
|
+
|
|
932
|
+
doc.create text, &b
|
|
933
|
+
#--}}}
|
|
934
|
+
end
|
|
935
|
+
alias_method "h_", "xx_any_"
|
|
936
|
+
remove_method "x_" if instance_methods.include? "x_"
|
|
937
|
+
alias_method "x_", "xx_any_" # supplant for now
|
|
938
|
+
def xx_cdata_ *objects, &b
|
|
939
|
+
#--{{{
|
|
940
|
+
doc = xx_doc
|
|
941
|
+
|
|
942
|
+
cdata = ::REXML::CData::new ""
|
|
943
|
+
|
|
944
|
+
objects.each do |object|
|
|
945
|
+
cdata << object.to_s if object
|
|
946
|
+
end
|
|
947
|
+
|
|
948
|
+
doc.create cdata, &b
|
|
949
|
+
#--}}}
|
|
950
|
+
end
|
|
951
|
+
alias_method "c_", "xx_cdata_"
|
|
952
|
+
def xx_parse_attributes string
|
|
953
|
+
#--{{{
|
|
954
|
+
string = string.to_s
|
|
955
|
+
tokens = string.split %r/,/o
|
|
956
|
+
tokens.map{|t| t.sub!(%r/[^=]+=/){|key_eq| key_eq.chop << " : "}}
|
|
957
|
+
xx_parse_yaml_attributes(tokens.join(','))
|
|
958
|
+
#--}}}
|
|
959
|
+
end
|
|
960
|
+
alias_method "att_", "xx_parse_attributes"
|
|
961
|
+
def xx_parse_yaml_attributes string
|
|
962
|
+
#--{{{
|
|
963
|
+
require "yaml"
|
|
964
|
+
string = string.to_s
|
|
965
|
+
string = "{" << string unless string =~ %r/^\s*[{]/o
|
|
966
|
+
string = string << "}" unless string =~ %r/[}]\s*$/o
|
|
967
|
+
obj = ::YAML::load string
|
|
968
|
+
raise ArgumentError, "<#{ obj.class }> not Hash!" unless Hash === obj
|
|
969
|
+
obj
|
|
970
|
+
#--}}}
|
|
971
|
+
end
|
|
972
|
+
alias_method "at_", "xx_parse_yaml_attributes"
|
|
973
|
+
alias_method "yat_", "xx_parse_yaml_attributes"
|
|
974
|
+
def xx_class
|
|
975
|
+
#--{{{
|
|
976
|
+
@xx_class ||= self.class
|
|
977
|
+
#--}}}
|
|
978
|
+
end
|
|
979
|
+
def xx_tag_method_name *a, &b
|
|
980
|
+
#--{{{
|
|
981
|
+
xx_class.xx_tag_method_name(*a, &b)
|
|
982
|
+
#--}}}
|
|
983
|
+
end
|
|
984
|
+
def xx_define_tmp_method *a, &b
|
|
985
|
+
#--{{{
|
|
986
|
+
xx_class.xx_define_tmp_methodr(*a, &b)
|
|
987
|
+
#--}}}
|
|
988
|
+
end
|
|
989
|
+
def xx_define_tag_method *a, &b
|
|
990
|
+
#--{{{
|
|
991
|
+
xx_class.xx_define_tag_method(*a, &b)
|
|
992
|
+
#--}}}
|
|
993
|
+
end
|
|
994
|
+
def xx_remove_tag_method *a, &b
|
|
995
|
+
#--{{{
|
|
996
|
+
xx_class.xx_tag_remove_method(*a, &b)
|
|
997
|
+
#--}}}
|
|
998
|
+
end
|
|
999
|
+
def xx_ancestors
|
|
1000
|
+
#--{{{
|
|
1001
|
+
raise Error, "no xx_which in effect" unless xx_which
|
|
1002
|
+
xx_class.xx_ancestors xx_which
|
|
1003
|
+
#--}}}
|
|
1004
|
+
end
|
|
1005
|
+
def xx_config
|
|
1006
|
+
#--{{{
|
|
1007
|
+
xx_class.xx_config
|
|
1008
|
+
#--}}}
|
|
1009
|
+
end
|
|
1010
|
+
def xx_config_for *a, &b
|
|
1011
|
+
#--{{{
|
|
1012
|
+
xx_class.xx_config_for(*a, &b)
|
|
1013
|
+
#--}}}
|
|
1014
|
+
end
|
|
1015
|
+
def xx_configure *a, &b
|
|
1016
|
+
#--{{{
|
|
1017
|
+
xx_class.xx_configure(*a, &b)
|
|
1018
|
+
#--}}}
|
|
1019
|
+
end
|
|
1020
|
+
#--}}}
|
|
1021
|
+
end
|
|
1022
|
+
|
|
1023
|
+
module ClassMethods
|
|
1024
|
+
#--{{{
|
|
1025
|
+
def xx_tag_method_name m
|
|
1026
|
+
#--{{{
|
|
1027
|
+
m = m.to_s
|
|
1028
|
+
tag_method, tag_name = m, m.gsub(%r/_+$/, "")
|
|
1029
|
+
[ tag_method, tag_name ]
|
|
1030
|
+
#--}}}
|
|
1031
|
+
end
|
|
1032
|
+
def xx_define_tmp_method m
|
|
1033
|
+
#--{{{
|
|
1034
|
+
define_method(m){ raise NotImplementedError, m.to_s }
|
|
1035
|
+
#--}}}
|
|
1036
|
+
end
|
|
1037
|
+
def xx_define_tag_method tag_method, tag_name = nil
|
|
1038
|
+
#--{{{
|
|
1039
|
+
tag_method = tag_method.to_s
|
|
1040
|
+
tag_name ||= tag_method.gsub %r/_+$/, ""
|
|
1041
|
+
|
|
1042
|
+
remove_method tag_method if instance_methods.include? tag_method
|
|
1043
|
+
module_eval <<-code, __FILE__, __LINE__+1
|
|
1044
|
+
def #{ tag_method } *a, &b
|
|
1045
|
+
hashes, nothashes = a.partition{|x| Hash === x}
|
|
1046
|
+
|
|
1047
|
+
doc = xx_doc
|
|
1048
|
+
element = ::REXML::Element::new '#{ tag_name }'
|
|
1049
|
+
|
|
1050
|
+
hashes.each{|h| h.each{|k,v| element.add_attribute k.to_s, v}}
|
|
1051
|
+
nothashes.each{|nh| element << ::REXML::Text::new(nh.to_s)}
|
|
1052
|
+
|
|
1053
|
+
doc.create element, &b
|
|
1054
|
+
end
|
|
1055
|
+
code
|
|
1056
|
+
tag_method
|
|
1057
|
+
#--}}}
|
|
1058
|
+
end
|
|
1059
|
+
def xx_remove_tag_method tag_method
|
|
1060
|
+
#--{{{
|
|
1061
|
+
remove_method tag_method rescue nil
|
|
1062
|
+
#--}}}
|
|
1063
|
+
end
|
|
1064
|
+
def xx_ancestors xx_which = self
|
|
1065
|
+
#--{{{
|
|
1066
|
+
list = []
|
|
1067
|
+
ancestors.each do |a|
|
|
1068
|
+
list << a if a < xx_which
|
|
1069
|
+
end
|
|
1070
|
+
xx_which.ancestors.each do |a|
|
|
1071
|
+
list << a if a <= Markup
|
|
1072
|
+
end
|
|
1073
|
+
list
|
|
1074
|
+
#--}}}
|
|
1075
|
+
end
|
|
1076
|
+
def xx_config
|
|
1077
|
+
#--{{{
|
|
1078
|
+
@@xx_config ||= Hash::new{|h,k| h[k] = {}}
|
|
1079
|
+
#--}}}
|
|
1080
|
+
end
|
|
1081
|
+
def xx_config_for key, xx_which = nil
|
|
1082
|
+
#--{{{
|
|
1083
|
+
key = key.to_s
|
|
1084
|
+
xx_which ||= self
|
|
1085
|
+
xx_ancestors(xx_which).each do |a|
|
|
1086
|
+
if xx_config[a].has_key? key
|
|
1087
|
+
return xx_config[a][key]
|
|
1088
|
+
end
|
|
1089
|
+
end
|
|
1090
|
+
nil
|
|
1091
|
+
#--}}}
|
|
1092
|
+
end
|
|
1093
|
+
def xx_configure key, value, xx_which = nil
|
|
1094
|
+
#--{{{
|
|
1095
|
+
key = key.to_s
|
|
1096
|
+
xx_which ||= self
|
|
1097
|
+
xx_config[xx_which][key] = value
|
|
1098
|
+
#--}}}
|
|
1099
|
+
end
|
|
1100
|
+
#--}}}
|
|
1101
|
+
end
|
|
1102
|
+
|
|
1103
|
+
extend ClassMethods
|
|
1104
|
+
include InstanceMethods
|
|
1105
|
+
|
|
1106
|
+
def self::included other, *a, &b
|
|
1107
|
+
#--{{{
|
|
1108
|
+
ret = super
|
|
1109
|
+
other.module_eval do
|
|
1110
|
+
include Markup::InstanceMethods
|
|
1111
|
+
extend Markup::ClassMethods
|
|
1112
|
+
class << self
|
|
1113
|
+
define_method("included", Markup::XX_MARKUP_RECURSIVE_INCLUSION_PROC)
|
|
1114
|
+
end
|
|
1115
|
+
end
|
|
1116
|
+
ret
|
|
1117
|
+
#--}}}
|
|
1118
|
+
end
|
|
1119
|
+
XX_MARKUP_RECURSIVE_INCLUSION_PROC = method("included").to_proc
|
|
1120
|
+
|
|
1121
|
+
xx_configure "method_missing", XX::PERMISSIVE
|
|
1122
|
+
xx_configure "tags", []
|
|
1123
|
+
xx_configure "doctype", nil
|
|
1124
|
+
xx_configure "xmldecl", nil
|
|
1125
|
+
#--}}}
|
|
1126
|
+
end
|
|
1127
|
+
|
|
1128
|
+
module XHTML
|
|
1129
|
+
#--{{{
|
|
1130
|
+
include Markup
|
|
1131
|
+
xx_configure "doctype", %(html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd")
|
|
1132
|
+
|
|
1133
|
+
def xhtml_ which = XHTML, *a, &b
|
|
1134
|
+
#--{{{
|
|
1135
|
+
xx_which(which) do
|
|
1136
|
+
doc = xx_with_doc_in_effect(*a, &b)
|
|
1137
|
+
ddoc = doc.doc
|
|
1138
|
+
root = ddoc.root
|
|
1139
|
+
if root and root.name and root.name =~ %r/^html$/i
|
|
1140
|
+
if root.attribute("lang",nil).nil? or root.attribute("lang",nil).to_s.empty?
|
|
1141
|
+
root.add_attribute "lang", "en"
|
|
1142
|
+
end
|
|
1143
|
+
if root.attribute("xml:lang").nil? or root.attribute("xml:lang").to_s.empty?
|
|
1144
|
+
root.add_attribute "xml:lang", "en"
|
|
1145
|
+
end
|
|
1146
|
+
if root.namespace.nil? or root.namespace.to_s.empty?
|
|
1147
|
+
root.add_namespace "http://www.w3.org/1999/xhtml"
|
|
1148
|
+
end
|
|
1149
|
+
end
|
|
1150
|
+
doc
|
|
1151
|
+
end
|
|
1152
|
+
#--}}}
|
|
1153
|
+
end
|
|
1154
|
+
|
|
1155
|
+
module Strict
|
|
1156
|
+
#--{{{
|
|
1157
|
+
include XHTML
|
|
1158
|
+
xx_configure "doctype", %(html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd")
|
|
1159
|
+
xx_configure "tags", %w(
|
|
1160
|
+
html head body div span DOCTYPE title link meta style p
|
|
1161
|
+
h1 h2 h3 h4 h5 h6 strong em abbr acronym address bdo blockquote cite q code
|
|
1162
|
+
ins del dfn kbd pre samp var br a base img
|
|
1163
|
+
area map object param ul ol li dl dt dd table
|
|
1164
|
+
tr td th tbody thead tfoot col colgroup caption form input
|
|
1165
|
+
textarea select option optgroup button label fieldset legend script noscript b
|
|
1166
|
+
i tt sub sup big small hr
|
|
1167
|
+
)
|
|
1168
|
+
xx_configure "method_missing", ::XX::STRICT
|
|
1169
|
+
|
|
1170
|
+
def xhtml_ which = XHTML::Strict, *a, &b
|
|
1171
|
+
#--{{{
|
|
1172
|
+
super(which, *a, &b)
|
|
1173
|
+
#--}}}
|
|
1174
|
+
end
|
|
1175
|
+
#--}}}
|
|
1176
|
+
end
|
|
1177
|
+
|
|
1178
|
+
module Transitional
|
|
1179
|
+
#--{{{
|
|
1180
|
+
include XHTML
|
|
1181
|
+
xx_configure "doctype", %(html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd")
|
|
1182
|
+
def xhtml_ which = XHTML::Transitional, *a, &b
|
|
1183
|
+
#--{{{
|
|
1184
|
+
super(which, *a, &b)
|
|
1185
|
+
#--}}}
|
|
1186
|
+
end
|
|
1187
|
+
#--}}}
|
|
1188
|
+
end
|
|
1189
|
+
#--}}}
|
|
1190
|
+
end
|
|
1191
|
+
|
|
1192
|
+
module HTML4
|
|
1193
|
+
#--{{{
|
|
1194
|
+
include Markup
|
|
1195
|
+
xx_configure "doctype", %(html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN")
|
|
1196
|
+
|
|
1197
|
+
def html4_ which = HTML4, *a, &b
|
|
1198
|
+
#--{{{
|
|
1199
|
+
xx_which(which){ xx_with_doc_in_effect(*a, &b) }
|
|
1200
|
+
#--}}}
|
|
1201
|
+
end
|
|
1202
|
+
|
|
1203
|
+
module Strict
|
|
1204
|
+
#--{{{
|
|
1205
|
+
include HTML4
|
|
1206
|
+
xx_configure "doctype", %(html PUBLIC "-//W3C//DTD HTML 4.01 Strict//EN")
|
|
1207
|
+
xx_configure "tags", %w(
|
|
1208
|
+
html head body div span DOCTYPE title link meta style p
|
|
1209
|
+
h1 h2 h3 h4 h5 h6 strong em abbr acronym address bdo blockquote cite q code
|
|
1210
|
+
ins del dfn kbd pre samp var br a base img
|
|
1211
|
+
area map object param ul ol li dl dt dd table
|
|
1212
|
+
tr td th tbody thead tfoot col colgroup caption form input
|
|
1213
|
+
textarea select option optgroup button label fieldset legend script noscript b
|
|
1214
|
+
i tt sub sup big small hr
|
|
1215
|
+
)
|
|
1216
|
+
xx_configure "method_missing", ::XX::STRICT
|
|
1217
|
+
def html4_ which = HTML4::Strict, *a, &b
|
|
1218
|
+
#--{{{
|
|
1219
|
+
super(which, *a, &b)
|
|
1220
|
+
#--}}}
|
|
1221
|
+
end
|
|
1222
|
+
#--}}}
|
|
1223
|
+
end
|
|
1224
|
+
|
|
1225
|
+
module Transitional
|
|
1226
|
+
#--{{{
|
|
1227
|
+
include HTML4
|
|
1228
|
+
xx_configure "doctype", %(html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN")
|
|
1229
|
+
def html4_ which = HTML4::Transitional, *a, &b
|
|
1230
|
+
#--{{{
|
|
1231
|
+
super(which, *a, &b)
|
|
1232
|
+
#--}}}
|
|
1233
|
+
end
|
|
1234
|
+
#--}}}
|
|
1235
|
+
end
|
|
1236
|
+
#--}}}
|
|
1237
|
+
end
|
|
1238
|
+
HTML = HTML4
|
|
1239
|
+
|
|
1240
|
+
module XML
|
|
1241
|
+
#--{{{
|
|
1242
|
+
include Markup
|
|
1243
|
+
xx_configure "xmldecl", ::REXML::XMLDecl::new
|
|
1244
|
+
|
|
1245
|
+
def xml_ *a, &b
|
|
1246
|
+
#--{{{
|
|
1247
|
+
xx_which(XML){ xx_with_doc_in_effect(*a, &b)}
|
|
1248
|
+
#--}}}
|
|
1249
|
+
end
|
|
1250
|
+
#--}}}
|
|
1251
|
+
end
|
|
1252
|
+
#--}}}
|
|
1253
|
+
end
|
|
1254
|
+
|
|
1255
|
+
$__xx_rb__ = __FILE__
|
|
1256
|
+
end
|
|
1257
|
+
|
|
1258
|
+
|
|
1259
|
+
|
|
1260
|
+
|
|
1261
|
+
|
|
1262
|
+
|
|
1263
|
+
|
|
1264
|
+
|
|
1265
|
+
|
|
1266
|
+
|
|
1267
|
+
#
|
|
1268
|
+
# simple examples - see samples/ dir for more complete examples
|
|
1269
|
+
#
|
|
1270
|
+
|
|
1271
|
+
if __FILE__ == $0
|
|
1272
|
+
|
|
1273
|
+
class Table < ::Array
|
|
1274
|
+
include XX::XHTML::Strict
|
|
1275
|
+
include XX::HTML4::Strict
|
|
1276
|
+
include XX::XML
|
|
1277
|
+
|
|
1278
|
+
def doc
|
|
1279
|
+
html_{
|
|
1280
|
+
head_{ title_{ "xhtml/html4/xml demo" } }
|
|
1281
|
+
|
|
1282
|
+
div_{
|
|
1283
|
+
h_{ "< malformed html & un-escaped symbols" }
|
|
1284
|
+
}
|
|
1285
|
+
|
|
1286
|
+
t_{ "escaped & text > <" }
|
|
1287
|
+
|
|
1288
|
+
x_{ "<any_valid> xml </any_valid>" }
|
|
1289
|
+
|
|
1290
|
+
div_(:style => :sweet){
|
|
1291
|
+
em_ "this is a table"
|
|
1292
|
+
|
|
1293
|
+
table_(:width => 42, :height => 42){
|
|
1294
|
+
each{|row| tr_{ row.each{|cell| td_ cell } } }
|
|
1295
|
+
}
|
|
1296
|
+
}
|
|
1297
|
+
|
|
1298
|
+
script_(:type => :dangerous){ cdata_{ "javascript" } }
|
|
1299
|
+
}
|
|
1300
|
+
end
|
|
1301
|
+
def to_xhtml
|
|
1302
|
+
xhtml_{ doc }
|
|
1303
|
+
end
|
|
1304
|
+
def to_html4
|
|
1305
|
+
html4_{ doc }
|
|
1306
|
+
end
|
|
1307
|
+
def to_xml
|
|
1308
|
+
xml_{ doc }
|
|
1309
|
+
end
|
|
1310
|
+
end
|
|
1311
|
+
|
|
1312
|
+
table = Table[ %w( 0 1 2 ), %w( a b c ) ]
|
|
1313
|
+
|
|
1314
|
+
methods = %w( to_xhtml to_html4 to_xml )
|
|
1315
|
+
|
|
1316
|
+
methods.each do |method|
|
|
1317
|
+
2.times{ puts "-" * 42 }
|
|
1318
|
+
puts(table.send(method).pretty)
|
|
1319
|
+
puts
|
|
1320
|
+
end
|
|
1321
|
+
|
|
1322
|
+
end
|
|
1323
|
+
# vi: set sw=4:
|
|
1324
|
+
# Here is Emacs setting. DO NOT REMOVE!
|
|
1325
|
+
# Local Variables:
|
|
1326
|
+
# ruby-indent-level: 4
|
|
1327
|
+
# End:
|