media-path 0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +3 -0
- data/LICENSE +20 -0
- data/README.textile +40 -0
- data/Rakefile +79 -0
- data/TODO.txt +6 -0
- data/deps.rip +5 -0
- data/lib/media-path.rb +269 -0
- data/media-path.gemspec +38 -0
- data/script/spec +14 -0
- data/spec/media-path_spec.rb +158 -0
- data/spec/spec.opts +5 -0
- data/spec/stubs/blog/public/js/moo.js +0 -0
- data/url.rb +20 -0
- data/url_spec.rb +35 -0
- data/vendor/rspec/History.rdoc +1512 -0
- data/vendor/rspec/License.txt +22 -0
- data/vendor/rspec/Manifest.txt +383 -0
- data/vendor/rspec/README.rdoc +55 -0
- data/vendor/rspec/Rakefile +145 -0
- data/vendor/rspec/Ruby1.9.rdoc +31 -0
- data/vendor/rspec/TODO.txt +17 -0
- data/vendor/rspec/Upgrade.rdoc +199 -0
- data/vendor/rspec/bin/autospec +4 -0
- data/vendor/rspec/bin/spec +5 -0
- data/vendor/rspec/cucumber.yml +5 -0
- data/vendor/rspec/examples/failing/README.txt +11 -0
- data/vendor/rspec/examples/failing/diffing_spec.rb +36 -0
- data/vendor/rspec/examples/failing/failing_implicit_docstrings_example.rb +17 -0
- data/vendor/rspec/examples/failing/failure_in_after.rb +10 -0
- data/vendor/rspec/examples/failing/failure_in_before.rb +10 -0
- data/vendor/rspec/examples/failing/mocking_example.rb +38 -0
- data/vendor/rspec/examples/failing/mocking_with_flexmock.rb +26 -0
- data/vendor/rspec/examples/failing/mocking_with_mocha.rb +25 -0
- data/vendor/rspec/examples/failing/mocking_with_rr.rb +27 -0
- data/vendor/rspec/examples/failing/partial_mock_example.rb +18 -0
- data/vendor/rspec/examples/failing/pending_example.rb +7 -0
- data/vendor/rspec/examples/failing/predicate_example.rb +32 -0
- data/vendor/rspec/examples/failing/raising_example.rb +47 -0
- data/vendor/rspec/examples/failing/syntax_error_example.rb +7 -0
- data/vendor/rspec/examples/failing/team_spec.rb +41 -0
- data/vendor/rspec/examples/failing/timeout_behaviour.rb +5 -0
- data/vendor/rspec/examples/passing/custom_formatter.rb +11 -0
- data/vendor/rspec/examples/passing/custom_matchers.rb +54 -0
- data/vendor/rspec/examples/passing/dynamic_spec.rb +7 -0
- data/vendor/rspec/examples/passing/file_accessor.rb +18 -0
- data/vendor/rspec/examples/passing/file_accessor_spec.rb +37 -0
- data/vendor/rspec/examples/passing/filtered_formatter.rb +17 -0
- data/vendor/rspec/examples/passing/filtered_formatter_example.rb +31 -0
- data/vendor/rspec/examples/passing/greeter_spec.rb +30 -0
- data/vendor/rspec/examples/passing/helper_method_example.rb +12 -0
- data/vendor/rspec/examples/passing/implicit_docstrings_example.rb +16 -0
- data/vendor/rspec/examples/passing/io_processor.rb +8 -0
- data/vendor/rspec/examples/passing/io_processor_spec.rb +20 -0
- data/vendor/rspec/examples/passing/mocking_example.rb +25 -0
- data/vendor/rspec/examples/passing/multi_threaded_example_group_runner.rb +26 -0
- data/vendor/rspec/examples/passing/nested_classes_example.rb +35 -0
- data/vendor/rspec/examples/passing/options_example.rb +29 -0
- data/vendor/rspec/examples/passing/options_formatter.rb +20 -0
- data/vendor/rspec/examples/passing/partial_mock_example.rb +27 -0
- data/vendor/rspec/examples/passing/pending_example.rb +18 -0
- data/vendor/rspec/examples/passing/predicate_example.rb +25 -0
- data/vendor/rspec/examples/passing/shared_example_group_example.rb +79 -0
- data/vendor/rspec/examples/passing/shared_stack_examples.rb +36 -0
- data/vendor/rspec/examples/passing/simple_matcher_example.rb +29 -0
- data/vendor/rspec/examples/passing/stack.rb +36 -0
- data/vendor/rspec/examples/passing/stack_spec.rb +63 -0
- data/vendor/rspec/examples/passing/stack_spec_with_nested_example_groups.rb +66 -0
- data/vendor/rspec/examples/passing/stubbing_example.rb +67 -0
- data/vendor/rspec/examples/passing/yielding_example.rb +31 -0
- data/vendor/rspec/examples/ruby1.9.compatibility/access_to_constants_spec.rb +85 -0
- data/vendor/rspec/features-pending/cli/conditional_exclusion.feature +39 -0
- data/vendor/rspec/features-pending/heckle/heckle.feature +56 -0
- data/vendor/rspec/features/before_and_after_blocks/before_and_after_blocks.feature +167 -0
- data/vendor/rspec/features/command_line/line_number_option.feature +56 -0
- data/vendor/rspec/features/command_line/line_number_option_with_example_with_no_name.feature +22 -0
- data/vendor/rspec/features/example_groups/define_example_attribute.feature +41 -0
- data/vendor/rspec/features/example_groups/example_group_with_should_methods.feature +29 -0
- data/vendor/rspec/features/example_groups/implicit_docstrings.feature +59 -0
- data/vendor/rspec/features/example_groups/nested_groups.feature +32 -0
- data/vendor/rspec/features/expectations/customized_message.feature +54 -0
- data/vendor/rspec/features/expectations/expect_change.feature +65 -0
- data/vendor/rspec/features/expectations/expect_error.feature +44 -0
- data/vendor/rspec/features/extensions/custom_example_group.feature +19 -0
- data/vendor/rspec/features/formatters/custom_formatter.feature +30 -0
- data/vendor/rspec/features/interop/examples_and_tests_together.feature +84 -0
- data/vendor/rspec/features/interop/rspec_output.feature +25 -0
- data/vendor/rspec/features/interop/test_but_not_test_unit.feature +26 -0
- data/vendor/rspec/features/interop/test_case_with_should_methods.feature +46 -0
- data/vendor/rspec/features/load_paths/add_lib_to_load_path.feature +20 -0
- data/vendor/rspec/features/load_paths/add_spec_to_load_path.feature +20 -0
- data/vendor/rspec/features/matchers/define_diffable_matcher.feature +26 -0
- data/vendor/rspec/features/matchers/define_matcher.feature +179 -0
- data/vendor/rspec/features/matchers/define_matcher_outside_rspec.feature +38 -0
- data/vendor/rspec/features/matchers/define_matcher_with_fluent_interface.feature +27 -0
- data/vendor/rspec/features/matchers/define_wrapped_matcher.feature +29 -0
- data/vendor/rspec/features/matchers/match_unless_raises.feature +60 -0
- data/vendor/rspec/features/matchers/match_unless_raises_unexpected_error.feature +39 -0
- data/vendor/rspec/features/mock_framework_integration/use_flexmock.feature +27 -0
- data/vendor/rspec/features/mock_framework_integration/use_mocha.feature +27 -0
- data/vendor/rspec/features/mock_framework_integration/use_rr.feature +27 -0
- data/vendor/rspec/features/mocks/block_local_expectations.feature +62 -0
- data/vendor/rspec/features/mocks/mix_stubs_and_mocks.feature +22 -0
- data/vendor/rspec/features/mocks/stub_implementation.feature +26 -0
- data/vendor/rspec/features/pending/pending_examples.feature +81 -0
- data/vendor/rspec/features/runner/specify_line_number.feature +32 -0
- data/vendor/rspec/features/spec_helper/spec_helper.feature +25 -0
- data/vendor/rspec/features/step_definitions/running_rspec_steps.rb +43 -0
- data/vendor/rspec/features/subject/explicit_subject.feature +31 -0
- data/vendor/rspec/features/subject/implicit_subject.feature +43 -0
- data/vendor/rspec/features/support/env.rb +82 -0
- data/vendor/rspec/features/support/matchers/smart_match.rb +12 -0
- data/vendor/rspec/geminstaller.yml +28 -0
- data/vendor/rspec/init.rb +9 -0
- data/vendor/rspec/lib/autotest/discover.rb +3 -0
- data/vendor/rspec/lib/autotest/rspec.rb +54 -0
- data/vendor/rspec/lib/spec.rb +8 -0
- data/vendor/rspec/lib/spec/adapters/mock_frameworks/flexmock.rb +24 -0
- data/vendor/rspec/lib/spec/adapters/mock_frameworks/mocha.rb +25 -0
- data/vendor/rspec/lib/spec/adapters/mock_frameworks/rr.rb +22 -0
- data/vendor/rspec/lib/spec/adapters/mock_frameworks/rspec.rb +21 -0
- data/vendor/rspec/lib/spec/autorun.rb +3 -0
- data/vendor/rspec/lib/spec/deprecation.rb +40 -0
- data/vendor/rspec/lib/spec/dsl.rb +1 -0
- data/vendor/rspec/lib/spec/dsl/main.rb +92 -0
- data/vendor/rspec/lib/spec/example.rb +164 -0
- data/vendor/rspec/lib/spec/example/args_and_options.rb +27 -0
- data/vendor/rspec/lib/spec/example/before_and_after_hooks.rb +93 -0
- data/vendor/rspec/lib/spec/example/errors.rb +25 -0
- data/vendor/rspec/lib/spec/example/example_group.rb +10 -0
- data/vendor/rspec/lib/spec/example/example_group_factory.rb +82 -0
- data/vendor/rspec/lib/spec/example/example_group_hierarchy.rb +53 -0
- data/vendor/rspec/lib/spec/example/example_group_methods.rb +282 -0
- data/vendor/rspec/lib/spec/example/example_group_proxy.rb +61 -0
- data/vendor/rspec/lib/spec/example/example_matcher.rb +43 -0
- data/vendor/rspec/lib/spec/example/example_methods.rb +152 -0
- data/vendor/rspec/lib/spec/example/example_proxy.rb +41 -0
- data/vendor/rspec/lib/spec/example/module_reopening_fix.rb +43 -0
- data/vendor/rspec/lib/spec/example/pending.rb +18 -0
- data/vendor/rspec/lib/spec/example/predicate_matchers.rb +46 -0
- data/vendor/rspec/lib/spec/example/shared_example_group.rb +59 -0
- data/vendor/rspec/lib/spec/example/subject.rb +108 -0
- data/vendor/rspec/lib/spec/expectations.rb +35 -0
- data/vendor/rspec/lib/spec/expectations/errors.rb +12 -0
- data/vendor/rspec/lib/spec/expectations/extensions.rb +1 -0
- data/vendor/rspec/lib/spec/expectations/extensions/kernel.rb +52 -0
- data/vendor/rspec/lib/spec/expectations/fail_with.rb +45 -0
- data/vendor/rspec/lib/spec/expectations/handler.rb +50 -0
- data/vendor/rspec/lib/spec/extensions/instance_exec.rb +31 -0
- data/vendor/rspec/lib/spec/interop/test.rb +44 -0
- data/vendor/rspec/lib/spec/interop/test/unit/autorunner.rb +6 -0
- data/vendor/rspec/lib/spec/interop/test/unit/testcase.rb +56 -0
- data/vendor/rspec/lib/spec/interop/test/unit/testresult.rb +6 -0
- data/vendor/rspec/lib/spec/interop/test/unit/testsuite_adapter.rb +34 -0
- data/vendor/rspec/lib/spec/interop/test/unit/ui/console/testrunner.rb +61 -0
- data/vendor/rspec/lib/spec/matchers.rb +195 -0
- data/vendor/rspec/lib/spec/matchers/be.rb +211 -0
- data/vendor/rspec/lib/spec/matchers/be_close.rb +32 -0
- data/vendor/rspec/lib/spec/matchers/be_instance_of.rb +26 -0
- data/vendor/rspec/lib/spec/matchers/be_kind_of.rb +26 -0
- data/vendor/rspec/lib/spec/matchers/change.rb +151 -0
- data/vendor/rspec/lib/spec/matchers/compatibility.rb +14 -0
- data/vendor/rspec/lib/spec/matchers/dsl.rb +20 -0
- data/vendor/rspec/lib/spec/matchers/eql.rb +42 -0
- data/vendor/rspec/lib/spec/matchers/equal.rb +53 -0
- data/vendor/rspec/lib/spec/matchers/errors.rb +5 -0
- data/vendor/rspec/lib/spec/matchers/exist.rb +16 -0
- data/vendor/rspec/lib/spec/matchers/generated_descriptions.rb +36 -0
- data/vendor/rspec/lib/spec/matchers/has.rb +35 -0
- data/vendor/rspec/lib/spec/matchers/have.rb +152 -0
- data/vendor/rspec/lib/spec/matchers/include.rb +44 -0
- data/vendor/rspec/lib/spec/matchers/match.rb +21 -0
- data/vendor/rspec/lib/spec/matchers/match_array.rb +71 -0
- data/vendor/rspec/lib/spec/matchers/matcher.rb +102 -0
- data/vendor/rspec/lib/spec/matchers/method_missing.rb +9 -0
- data/vendor/rspec/lib/spec/matchers/operator_matcher.rb +78 -0
- data/vendor/rspec/lib/spec/matchers/pretty.rb +37 -0
- data/vendor/rspec/lib/spec/matchers/raise_error.rb +129 -0
- data/vendor/rspec/lib/spec/matchers/respond_to.rb +71 -0
- data/vendor/rspec/lib/spec/matchers/satisfy.rb +47 -0
- data/vendor/rspec/lib/spec/matchers/simple_matcher.rb +133 -0
- data/vendor/rspec/lib/spec/matchers/throw_symbol.rb +104 -0
- data/vendor/rspec/lib/spec/matchers/wrap_expectation.rb +55 -0
- data/vendor/rspec/lib/spec/mocks.rb +200 -0
- data/vendor/rspec/lib/spec/mocks/argument_expectation.rb +51 -0
- data/vendor/rspec/lib/spec/mocks/argument_matchers.rb +237 -0
- data/vendor/rspec/lib/spec/mocks/error_generator.rb +92 -0
- data/vendor/rspec/lib/spec/mocks/errors.rb +10 -0
- data/vendor/rspec/lib/spec/mocks/example_methods.rb +69 -0
- data/vendor/rspec/lib/spec/mocks/extensions.rb +1 -0
- data/vendor/rspec/lib/spec/mocks/extensions/object.rb +3 -0
- data/vendor/rspec/lib/spec/mocks/framework.rb +15 -0
- data/vendor/rspec/lib/spec/mocks/message_expectation.rb +343 -0
- data/vendor/rspec/lib/spec/mocks/methods.rb +89 -0
- data/vendor/rspec/lib/spec/mocks/mock.rb +71 -0
- data/vendor/rspec/lib/spec/mocks/order_group.rb +29 -0
- data/vendor/rspec/lib/spec/mocks/proxy.rb +245 -0
- data/vendor/rspec/lib/spec/mocks/space.rb +28 -0
- data/vendor/rspec/lib/spec/rake/spectask.rb +230 -0
- data/vendor/rspec/lib/spec/rake/verify_rcov.rb +52 -0
- data/vendor/rspec/lib/spec/ruby.rb +9 -0
- data/vendor/rspec/lib/spec/runner.rb +66 -0
- data/vendor/rspec/lib/spec/runner/backtrace_tweaker.rb +77 -0
- data/vendor/rspec/lib/spec/runner/class_and_arguments_parser.rb +14 -0
- data/vendor/rspec/lib/spec/runner/command_line.rb +15 -0
- data/vendor/rspec/lib/spec/runner/configuration.rb +194 -0
- data/vendor/rspec/lib/spec/runner/differs/default.rb +93 -0
- data/vendor/rspec/lib/spec/runner/differs/load-diff-lcs.rb +12 -0
- data/vendor/rspec/lib/spec/runner/drb_command_line.rb +32 -0
- data/vendor/rspec/lib/spec/runner/example_group_runner.rb +58 -0
- data/vendor/rspec/lib/spec/runner/extensions/kernel.rb +9 -0
- data/vendor/rspec/lib/spec/runner/formatter/base_formatter.rb +139 -0
- data/vendor/rspec/lib/spec/runner/formatter/base_text_formatter.rb +142 -0
- data/vendor/rspec/lib/spec/runner/formatter/failing_example_groups_formatter.rb +25 -0
- data/vendor/rspec/lib/spec/runner/formatter/failing_examples_formatter.rb +20 -0
- data/vendor/rspec/lib/spec/runner/formatter/html_formatter.rb +338 -0
- data/vendor/rspec/lib/spec/runner/formatter/nested_text_formatter.rb +47 -0
- data/vendor/rspec/lib/spec/runner/formatter/no_op_method_missing.rb +21 -0
- data/vendor/rspec/lib/spec/runner/formatter/profile_formatter.rb +47 -0
- data/vendor/rspec/lib/spec/runner/formatter/progress_bar_formatter.rb +33 -0
- data/vendor/rspec/lib/spec/runner/formatter/silent_formatter.rb +10 -0
- data/vendor/rspec/lib/spec/runner/formatter/snippet_extractor.rb +52 -0
- data/vendor/rspec/lib/spec/runner/formatter/specdoc_formatter.rb +33 -0
- data/vendor/rspec/lib/spec/runner/formatter/text_mate_formatter.rb +16 -0
- data/vendor/rspec/lib/spec/runner/heckle_runner.rb +72 -0
- data/vendor/rspec/lib/spec/runner/heckle_runner_unsupported.rb +10 -0
- data/vendor/rspec/lib/spec/runner/line_number_query.rb +78 -0
- data/vendor/rspec/lib/spec/runner/option_parser.rb +225 -0
- data/vendor/rspec/lib/spec/runner/options.rb +405 -0
- data/vendor/rspec/lib/spec/runner/reporter.rb +171 -0
- data/vendor/rspec/lib/spec/stubs/cucumber.rb +5 -0
- data/vendor/rspec/lib/spec/test/unit.rb +10 -0
- data/vendor/rspec/lib/spec/version.rb +14 -0
- data/vendor/rspec/resources/helpers/cmdline.rb +8 -0
- data/vendor/rspec/resources/rake/examples.rake +7 -0
- data/vendor/rspec/resources/rake/examples_with_rcov.rake +9 -0
- data/vendor/rspec/resources/rake/failing_examples_with_html.rake +9 -0
- data/vendor/rspec/resources/rake/verify_rcov.rake +7 -0
- data/vendor/rspec/spec/README.jruby +15 -0
- data/vendor/rspec/spec/autotest/autotest_helper.rb +8 -0
- data/vendor/rspec/spec/autotest/autotest_matchers.rb +38 -0
- data/vendor/rspec/spec/autotest/discover_spec.rb +8 -0
- data/vendor/rspec/spec/autotest/failed_results_re_spec.rb +31 -0
- data/vendor/rspec/spec/autotest/rspec_spec.rb +126 -0
- data/vendor/rspec/spec/ruby_forker.rb +13 -0
- data/vendor/rspec/spec/spec.opts +6 -0
- data/vendor/rspec/spec/spec/dsl/main_spec.rb +95 -0
- data/vendor/rspec/spec/spec/example/example_group_class_definition_spec.rb +51 -0
- data/vendor/rspec/spec/spec/example/example_group_factory_spec.rb +180 -0
- data/vendor/rspec/spec/spec/example/example_group_methods_spec.rb +759 -0
- data/vendor/rspec/spec/spec/example/example_group_proxy_spec.rb +107 -0
- data/vendor/rspec/spec/spec/example/example_group_spec.rb +643 -0
- data/vendor/rspec/spec/spec/example/example_matcher_spec.rb +86 -0
- data/vendor/rspec/spec/spec/example/example_methods_spec.rb +162 -0
- data/vendor/rspec/spec/spec/example/example_proxy_spec.rb +57 -0
- data/vendor/rspec/spec/spec/example/helper_method_spec.rb +24 -0
- data/vendor/rspec/spec/spec/example/nested_example_group_spec.rb +71 -0
- data/vendor/rspec/spec/spec/example/pending_module_spec.rb +58 -0
- data/vendor/rspec/spec/spec/example/predicate_matcher_spec.rb +41 -0
- data/vendor/rspec/spec/spec/example/shared_example_group_spec.rb +257 -0
- data/vendor/rspec/spec/spec/example/subclassing_example_group_spec.rb +25 -0
- data/vendor/rspec/spec/spec/example/subject_spec.rb +103 -0
- data/vendor/rspec/spec/spec/expectations/differs/default_spec.rb +194 -0
- data/vendor/rspec/spec/spec/expectations/extensions/kernel_spec.rb +45 -0
- data/vendor/rspec/spec/spec/expectations/fail_with_spec.rb +96 -0
- data/vendor/rspec/spec/spec/expectations/handler_spec.rb +206 -0
- data/vendor/rspec/spec/spec/expectations/wrap_expectation_spec.rb +30 -0
- data/vendor/rspec/spec/spec/interop/test/unit/resources/spec_that_fails.rb +10 -0
- data/vendor/rspec/spec/spec/interop/test/unit/resources/spec_that_passes.rb +10 -0
- data/vendor/rspec/spec/spec/interop/test/unit/resources/spec_with_errors.rb +10 -0
- data/vendor/rspec/spec/spec/interop/test/unit/resources/spec_with_options_hash.rb +13 -0
- data/vendor/rspec/spec/spec/interop/test/unit/resources/test_case_that_fails.rb +10 -0
- data/vendor/rspec/spec/spec/interop/test/unit/resources/test_case_that_passes.rb +10 -0
- data/vendor/rspec/spec/spec/interop/test/unit/resources/test_case_with_errors.rb +10 -0
- data/vendor/rspec/spec/spec/interop/test/unit/resources/test_case_with_various_names.rb +22 -0
- data/vendor/rspec/spec/spec/interop/test/unit/resources/testsuite_adapter_spec_with_test_unit.rb +38 -0
- data/vendor/rspec/spec/spec/interop/test/unit/spec_spec.rb +48 -0
- data/vendor/rspec/spec/spec/interop/test/unit/test_unit_spec_helper.rb +18 -0
- data/vendor/rspec/spec/spec/interop/test/unit/testcase_spec.rb +50 -0
- data/vendor/rspec/spec/spec/interop/test/unit/testsuite_adapter_spec.rb +9 -0
- data/vendor/rspec/spec/spec/matchers/be_close_spec.rb +50 -0
- data/vendor/rspec/spec/spec/matchers/be_instance_of_spec.rb +36 -0
- data/vendor/rspec/spec/spec/matchers/be_kind_of_spec.rb +33 -0
- data/vendor/rspec/spec/spec/matchers/be_spec.rb +419 -0
- data/vendor/rspec/spec/spec/matchers/change_spec.rb +349 -0
- data/vendor/rspec/spec/spec/matchers/compatibility_spec.rb +28 -0
- data/vendor/rspec/spec/spec/matchers/description_generation_spec.rb +160 -0
- data/vendor/rspec/spec/spec/matchers/dsl_spec.rb +34 -0
- data/vendor/rspec/spec/spec/matchers/eql_spec.rb +33 -0
- data/vendor/rspec/spec/spec/matchers/equal_spec.rb +57 -0
- data/vendor/rspec/spec/spec/matchers/exist_spec.rb +65 -0
- data/vendor/rspec/spec/spec/matchers/has_spec.rb +190 -0
- data/vendor/rspec/spec/spec/matchers/have_spec.rb +396 -0
- data/vendor/rspec/spec/spec/matchers/include_spec.rb +88 -0
- data/vendor/rspec/spec/spec/matchers/match_array_spec.rb +108 -0
- data/vendor/rspec/spec/spec/matchers/match_spec.rb +57 -0
- data/vendor/rspec/spec/spec/matchers/matcher_methods_spec.rb +63 -0
- data/vendor/rspec/spec/spec/matchers/matcher_spec.rb +273 -0
- data/vendor/rspec/spec/spec/matchers/matchers_spec.rb +2 -0
- data/vendor/rspec/spec/spec/matchers/operator_matcher_spec.rb +191 -0
- data/vendor/rspec/spec/spec/matchers/raise_error_spec.rb +333 -0
- data/vendor/rspec/spec/spec/matchers/respond_to_spec.rb +116 -0
- data/vendor/rspec/spec/spec/matchers/satisfy_spec.rb +36 -0
- data/vendor/rspec/spec/spec/matchers/simple_matcher_spec.rb +93 -0
- data/vendor/rspec/spec/spec/matchers/throw_symbol_spec.rb +96 -0
- data/vendor/rspec/spec/spec/mocks/and_yield_spec.rb +117 -0
- data/vendor/rspec/spec/spec/mocks/any_number_of_times_spec.rb +36 -0
- data/vendor/rspec/spec/spec/mocks/argument_expectation_spec.rb +23 -0
- data/vendor/rspec/spec/spec/mocks/argument_matchers_spec.rb +19 -0
- data/vendor/rspec/spec/spec/mocks/at_least_spec.rb +97 -0
- data/vendor/rspec/spec/spec/mocks/at_most_spec.rb +93 -0
- data/vendor/rspec/spec/spec/mocks/bug_report_10260_spec.rb +8 -0
- data/vendor/rspec/spec/spec/mocks/bug_report_10263_spec.rb +27 -0
- data/vendor/rspec/spec/spec/mocks/bug_report_11545_spec.rb +32 -0
- data/vendor/rspec/spec/spec/mocks/bug_report_15719_spec.rb +30 -0
- data/vendor/rspec/spec/spec/mocks/bug_report_496_spec.rb +19 -0
- data/vendor/rspec/spec/spec/mocks/bug_report_600_spec.rb +22 -0
- data/vendor/rspec/spec/spec/mocks/bug_report_7611_spec.rb +19 -0
- data/vendor/rspec/spec/spec/mocks/bug_report_7805_spec.rb +22 -0
- data/vendor/rspec/spec/spec/mocks/bug_report_8165_spec.rb +31 -0
- data/vendor/rspec/spec/spec/mocks/bug_report_8302_spec.rb +26 -0
- data/vendor/rspec/spec/spec/mocks/bug_report_830_spec.rb +21 -0
- data/vendor/rspec/spec/spec/mocks/double_spec.rb +12 -0
- data/vendor/rspec/spec/spec/mocks/failing_argument_matchers_spec.rb +95 -0
- data/vendor/rspec/spec/spec/mocks/hash_including_matcher_spec.rb +90 -0
- data/vendor/rspec/spec/spec/mocks/hash_not_including_matcher_spec.rb +67 -0
- data/vendor/rspec/spec/spec/mocks/mock_ordering_spec.rb +94 -0
- data/vendor/rspec/spec/spec/mocks/mock_space_spec.rb +54 -0
- data/vendor/rspec/spec/spec/mocks/mock_spec.rb +594 -0
- data/vendor/rspec/spec/spec/mocks/multiple_return_value_spec.rb +113 -0
- data/vendor/rspec/spec/spec/mocks/nil_expectation_warning_spec.rb +53 -0
- data/vendor/rspec/spec/spec/mocks/null_object_mock_spec.rb +54 -0
- data/vendor/rspec/spec/spec/mocks/once_counts_spec.rb +53 -0
- data/vendor/rspec/spec/spec/mocks/options_hash_spec.rb +35 -0
- data/vendor/rspec/spec/spec/mocks/partial_mock_spec.rb +164 -0
- data/vendor/rspec/spec/spec/mocks/partial_mock_using_mocks_directly_spec.rb +66 -0
- data/vendor/rspec/spec/spec/mocks/passing_argument_matchers_spec.rb +145 -0
- data/vendor/rspec/spec/spec/mocks/precise_counts_spec.rb +52 -0
- data/vendor/rspec/spec/spec/mocks/record_messages_spec.rb +26 -0
- data/vendor/rspec/spec/spec/mocks/stub_chain_spec.rb +42 -0
- data/vendor/rspec/spec/spec/mocks/stub_implementation_spec.rb +31 -0
- data/vendor/rspec/spec/spec/mocks/stub_spec.rb +203 -0
- data/vendor/rspec/spec/spec/mocks/stubbed_message_expectations_spec.rb +26 -0
- data/vendor/rspec/spec/spec/mocks/twice_counts_spec.rb +67 -0
- data/vendor/rspec/spec/spec/mocks/unstub_spec.rb +127 -0
- data/vendor/rspec/spec/spec/package/bin_spec_spec.rb +16 -0
- data/vendor/rspec/spec/spec/rake/spectask_spec.rb +150 -0
- data/vendor/rspec/spec/spec/runner/class_and_argument_parser_spec.rb +23 -0
- data/vendor/rspec/spec/spec/runner/command_line_spec.rb +162 -0
- data/vendor/rspec/spec/spec/runner/configuration_spec.rb +320 -0
- data/vendor/rspec/spec/spec/runner/drb_command_line_spec.rb +146 -0
- data/vendor/rspec/spec/spec/runner/empty_file.txt +0 -0
- data/vendor/rspec/spec/spec/runner/example_group_runner_spec.rb +26 -0
- data/vendor/rspec/spec/spec/runner/examples.txt +2 -0
- data/vendor/rspec/spec/spec/runner/failed.txt +3 -0
- data/vendor/rspec/spec/spec/runner/formatter/base_formatter_spec.rb +30 -0
- data/vendor/rspec/spec/spec/runner/formatter/base_text_formatter_spec.rb +113 -0
- data/vendor/rspec/spec/spec/runner/formatter/failing_example_groups_formatter_spec.rb +45 -0
- data/vendor/rspec/spec/spec/runner/formatter/failing_examples_formatter_spec.rb +33 -0
- data/vendor/rspec/spec/spec/runner/formatter/html_formatted-1.8.6-jruby.html +377 -0
- data/vendor/rspec/spec/spec/runner/formatter/html_formatted-1.8.6.html +377 -0
- data/vendor/rspec/spec/spec/runner/formatter/html_formatted-1.8.7.html +377 -0
- data/vendor/rspec/spec/spec/runner/formatter/html_formatted-1.9.1.html +377 -0
- data/vendor/rspec/spec/spec/runner/formatter/html_formatter_spec.rb +118 -0
- data/vendor/rspec/spec/spec/runner/formatter/nested_text_formatter_spec.rb +305 -0
- data/vendor/rspec/spec/spec/runner/formatter/profile_formatter_spec.rb +70 -0
- data/vendor/rspec/spec/spec/runner/formatter/progress_bar_formatter_spec.rb +149 -0
- data/vendor/rspec/spec/spec/runner/formatter/snippet_extractor_spec.rb +18 -0
- data/vendor/rspec/spec/spec/runner/formatter/specdoc_formatter_spec.rb +159 -0
- data/vendor/rspec/spec/spec/runner/formatter/text_mate_formatted-1.8.6-jruby.html +371 -0
- data/vendor/rspec/spec/spec/runner/formatter/text_mate_formatted-1.8.6.html +371 -0
- data/vendor/rspec/spec/spec/runner/formatter/text_mate_formatted-1.8.7.html +371 -0
- data/vendor/rspec/spec/spec/runner/formatter/text_mate_formatted-1.9.1.html +371 -0
- data/vendor/rspec/spec/spec/runner/formatter/text_mate_formatter_spec.rb +106 -0
- data/vendor/rspec/spec/spec/runner/heckle_runner_spec.rb +78 -0
- data/vendor/rspec/spec/spec/runner/heckler_spec.rb +20 -0
- data/vendor/rspec/spec/spec/runner/line_number_query/line_number_query_fixture.rb +70 -0
- data/vendor/rspec/spec/spec/runner/line_number_query_spec.rb +129 -0
- data/vendor/rspec/spec/spec/runner/noisy_backtrace_tweaker_spec.rb +51 -0
- data/vendor/rspec/spec/spec/runner/option_parser_spec.rb +554 -0
- data/vendor/rspec/spec/spec/runner/options_spec.rb +554 -0
- data/vendor/rspec/spec/spec/runner/output_one_time_fixture.rb +7 -0
- data/vendor/rspec/spec/spec/runner/output_one_time_fixture_runner.rb +7 -0
- data/vendor/rspec/spec/spec/runner/output_one_time_spec.rb +15 -0
- data/vendor/rspec/spec/spec/runner/quiet_backtrace_tweaker_spec.rb +123 -0
- data/vendor/rspec/spec/spec/runner/reporter_spec.rb +244 -0
- data/vendor/rspec/spec/spec/runner/resources/a_bar.rb +0 -0
- data/vendor/rspec/spec/spec/runner/resources/a_foo.rb +0 -0
- data/vendor/rspec/spec/spec/runner/resources/a_spec.rb +1 -0
- data/vendor/rspec/spec/spec/runner/resources/custom_example_group_runner.rb +14 -0
- data/vendor/rspec/spec/spec/runner/resources/utf8_encoded.rb +8 -0
- data/vendor/rspec/spec/spec/runner/spec.opts +2 -0
- data/vendor/rspec/spec/spec/runner/spec_drb.opts +2 -0
- data/vendor/rspec/spec/spec/runner/spec_spaced.opts +2 -0
- data/vendor/rspec/spec/spec/runner_spec.rb +13 -0
- data/vendor/rspec/spec/spec_helper.rb +112 -0
- data/vendor/rspec/spec/support/macros.rb +29 -0
- data/vendor/rspec/spec/support/spec_classes.rb +133 -0
- data/vendor/rubyexts/CHANGELOG +2 -0
- data/vendor/rubyexts/LICENSE +20 -0
- data/vendor/rubyexts/README.textile +0 -0
- data/vendor/rubyexts/Rakefile +79 -0
- data/vendor/rubyexts/TODO.txt +6 -0
- data/vendor/rubyexts/lib/rubyexts.rb +102 -0
- data/vendor/rubyexts/lib/rubyexts/array.rb +20 -0
- data/vendor/rubyexts/lib/rubyexts/attribute.rb +151 -0
- data/vendor/rubyexts/lib/rubyexts/capture_io.rb +32 -0
- data/vendor/rubyexts/lib/rubyexts/class.rb +177 -0
- data/vendor/rubyexts/lib/rubyexts/colored_string.rb +103 -0
- data/vendor/rubyexts/lib/rubyexts/enumerable.rb +30 -0
- data/vendor/rubyexts/lib/rubyexts/file.rb +84 -0
- data/vendor/rubyexts/lib/rubyexts/hash.rb +180 -0
- data/vendor/rubyexts/lib/rubyexts/kernel.rb +91 -0
- data/vendor/rubyexts/lib/rubyexts/module.rb +53 -0
- data/vendor/rubyexts/lib/rubyexts/object.rb +56 -0
- data/vendor/rubyexts/lib/rubyexts/object_space.rb +16 -0
- data/vendor/rubyexts/lib/rubyexts/os.rb +89 -0
- data/vendor/rubyexts/lib/rubyexts/platform.rb +27 -0
- data/vendor/rubyexts/lib/rubyexts/random.rb +25 -0
- data/vendor/rubyexts/lib/rubyexts/string.rb +92 -0
- data/vendor/rubyexts/lib/rubyexts/time.rb +15 -0
- data/vendor/rubyexts/lib/rubyexts/time_dsl.rb +62 -0
- data/vendor/rubyexts/lib/rubyexts/try_dup.rb +43 -0
- data/vendor/rubyexts/lib/rubyexts/unique_array.rb +16 -0
- data/vendor/rubyexts/rubyexts.gemspec +36 -0
- data/vendor/rubyexts/script/spec +12 -0
- data/vendor/rubyexts/spec/rubyexts/array_spec.rb +19 -0
- data/vendor/rubyexts/spec/rubyexts/attribute_spec.rb +37 -0
- data/vendor/rubyexts/spec/rubyexts/class_spec.rb +1 -0
- data/vendor/rubyexts/spec/rubyexts/cli_spec.rb +0 -0
- data/vendor/rubyexts/spec/rubyexts/colored_string_spec.rb +9 -0
- data/vendor/rubyexts/spec/rubyexts/enumerable_spec.rb +52 -0
- data/vendor/rubyexts/spec/rubyexts/file_spec.rb +78 -0
- data/vendor/rubyexts/spec/rubyexts/hash_spec.rb +91 -0
- data/vendor/rubyexts/spec/rubyexts/kernel_spec.rb +9 -0
- data/vendor/rubyexts/spec/rubyexts/module_spec.rb +0 -0
- data/vendor/rubyexts/spec/rubyexts/object_space_spec.rb +17 -0
- data/vendor/rubyexts/spec/rubyexts/object_spec.rb +57 -0
- data/vendor/rubyexts/spec/rubyexts/os_spec.rb +121 -0
- data/vendor/rubyexts/spec/rubyexts/platform_spec.rb +0 -0
- data/vendor/rubyexts/spec/rubyexts/random_spec.rb +31 -0
- data/vendor/rubyexts/spec/rubyexts/string_spec.rb +23 -0
- data/vendor/rubyexts/spec/rubyexts/time_dsl_spec.rb +88 -0
- data/vendor/rubyexts/spec/rubyexts/time_spec.rb +11 -0
- data/vendor/rubyexts/spec/rubyexts/unique_array_spec.rb +0 -0
- data/vendor/rubyexts/spec/rubyexts_spec.rb +182 -0
- data/vendor/rubyexts/spec/spec.opts +5 -0
- data/vendor/rubyexts/spec/spec_helper.rb +16 -0
- metadata +510 -0
@@ -0,0 +1,30 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
module Enumerable
|
4
|
+
# Enumerable#none? is the logical opposite of the builtin method Enumerable#any?. It
|
5
|
+
# returns +true+ if and only if _none_ of the elements in the collection satisfy the
|
6
|
+
# predicate.
|
7
|
+
#
|
8
|
+
# If no predicate is provided, Enumerable#none? returns +true+ if and only if _none_ of the
|
9
|
+
# elements have a true value (i.e. not +nil+ or +false+).
|
10
|
+
#
|
11
|
+
# @author Botanicus
|
12
|
+
# @from Extensions
|
13
|
+
# @since 0.0.3
|
14
|
+
# @yield [block] Block which will be evaluated in Project.setttings object.
|
15
|
+
# @yieldparam [item] Each item of array-like collection
|
16
|
+
# @yieldparam [key, value] Each item of hash-like collection
|
17
|
+
# @option params [String, Array<String>] :exclude File or list of files or globs relative to base directory
|
18
|
+
# @raise [LoadError] If base directory doesn't exist
|
19
|
+
# @raise [ArgumentError] If first argument isn't a glob
|
20
|
+
# @return [Array<String>] List of successfully loaded files
|
21
|
+
# @example
|
22
|
+
# [].none? # => true
|
23
|
+
# [nil].none? # => true
|
24
|
+
# [5,8,9].none? # => false
|
25
|
+
# (1...10).none? { |n| n < 0 } # => true
|
26
|
+
# (1...10).none? { |n| n > 0 } # => false
|
27
|
+
def none?(&block)
|
28
|
+
not self.any?(&block)
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,84 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
class File
|
4
|
+
# Append given chunks to the existing file or create new one.
|
5
|
+
# It use <tt>IO#puts</tt> for write to given file.
|
6
|
+
#
|
7
|
+
# @author Botanicus
|
8
|
+
# @since 0.0.3
|
9
|
+
# @param [String] file Path to file. You can use <tt>~</tt>, <tt>~user</tt> or similar expressions.
|
10
|
+
# @param [String, Object] *chunks Chunks which will be written to the file
|
11
|
+
# @raise [Errno::ENOENT] If parent directory of given file doesn't exist
|
12
|
+
# @raise [Errno::EACCES] If you don't have permissions to write to given file
|
13
|
+
# @return [String] Expanded path to given file
|
14
|
+
# @example
|
15
|
+
# File.append "~/.bashrc", source # => "/Users/botanicus/.bashrc"
|
16
|
+
def self.append(file, *chunks)
|
17
|
+
self.write(:puts, "a", file, *chunks)
|
18
|
+
end
|
19
|
+
|
20
|
+
# Append given chunks to the existing file or create new one.
|
21
|
+
# It use <tt>IO#print</tt> for write to given file.
|
22
|
+
#
|
23
|
+
# @author Botanicus
|
24
|
+
# @since 0.0.3
|
25
|
+
# @param [String] file Path to file. You can use <tt>~</tt>, <tt>~user</tt> or similar expressions.
|
26
|
+
# @param [String, Object] *chunks Chunks which will be written to the file
|
27
|
+
# @raise [Errno::ENOENT] If parent directory of given file doesn't exist
|
28
|
+
# @raise [Errno::EACCES] If you don't have permissions to write to given file
|
29
|
+
# @return [String] Expanded path to given file
|
30
|
+
# @example
|
31
|
+
# File.append "~/.bashrc", source # => "/Users/botanicus/.bashrc"
|
32
|
+
def self.add(file, *chunks)
|
33
|
+
self.write(:print, "a", file, *chunks)
|
34
|
+
end
|
35
|
+
|
36
|
+
# Create new file and write there given chunks.
|
37
|
+
# It use <tt>IO#puts</tt> for write to given file.
|
38
|
+
#
|
39
|
+
# @author Botanicus
|
40
|
+
# @since 0.0.3
|
41
|
+
# @param [String] file Path to file. You can use <tt>~</tt>, <tt>~user</tt> or similar expressions.
|
42
|
+
# @param [String, Object] *chunks Chunks which will be written to the file
|
43
|
+
# @raise [Errno::ENOENT] If parent directory of given file doesn't exist
|
44
|
+
# @raise [Errno::EACCES] If you don't have permissions to write to given file
|
45
|
+
# @return [String] Expanded path to given file
|
46
|
+
# @example
|
47
|
+
# File.puts "~/.bashrc", source # => "/Users/botanicus/.bashrc"
|
48
|
+
def self.puts(file, *chunks)
|
49
|
+
self.write(:puts, "w", file, *chunks)
|
50
|
+
end
|
51
|
+
|
52
|
+
# Create new file and write there given chunks.
|
53
|
+
# It use <tt>IO#print</tt> for write to given file.
|
54
|
+
#
|
55
|
+
# @author Botanicus
|
56
|
+
# @since 0.0.3
|
57
|
+
# @param [String] file Path to file. You can use <tt>~</tt>, <tt>~user</tt> or similar expressions.
|
58
|
+
# @param [String, Object] *chunks Chunks which will be written to the file
|
59
|
+
# @raise [Errno::ENOENT] If parent directory of given file doesn't exist
|
60
|
+
# @raise [Errno::EACCES] If you don't have permissions to write to given file
|
61
|
+
# @return [String] Expanded path to given file
|
62
|
+
# @example
|
63
|
+
# File.print "~/.bashrc", source # => "/Users/botanicus/.bashrc"
|
64
|
+
def self.print(file, *chunks)
|
65
|
+
self.write(:print, "w", file, *chunks)
|
66
|
+
end
|
67
|
+
|
68
|
+
# Write data to file with given method.
|
69
|
+
#
|
70
|
+
# @author Botanicus
|
71
|
+
# @since 0.0.3
|
72
|
+
# @param [String] file Path to file. You can use <tt>~</tt>, <tt>~user</tt> or similar expressions.
|
73
|
+
# @param [String, Object] *chunks Chunks which will be written to the file
|
74
|
+
# @raise [Errno::ENOENT] If parent directory of given file doesn't exist
|
75
|
+
# @raise [Errno::EACCES] If you don't have permissions to write to given file
|
76
|
+
# @return [String] Expanded path to given file
|
77
|
+
# @example
|
78
|
+
# File.write :printf, "w", "~/.bashrc", "%d %04x", 123, 123 # => "/Users/botanicus/.bashrc"
|
79
|
+
def self.write(method, mode, file, *args)
|
80
|
+
self.expand_path(file).tap do |path|
|
81
|
+
self.open(path, mode) { |file| file.send(method, *args) }
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
@@ -0,0 +1,180 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
class Hash
|
4
|
+
# Return duplication of self with all keys non-recursively converted to symbols
|
5
|
+
#
|
6
|
+
# @author Botanicus
|
7
|
+
# @since 0.0.2
|
8
|
+
# @return [Hash] A hash with all keys transformed into symbols
|
9
|
+
def symbolize_keys
|
10
|
+
self.inject(Hash.new) do |result, array|
|
11
|
+
result[array.first.to_sym] = array.last
|
12
|
+
result
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
# Replace keys in self by coresponding symbols
|
17
|
+
#
|
18
|
+
# @author Botanicus
|
19
|
+
# @since 0.0.2
|
20
|
+
# @return [Hash] A hash with all keys transformed into symbols
|
21
|
+
def symbolize_keys!
|
22
|
+
self.replace(self.symbolize_keys)
|
23
|
+
end
|
24
|
+
|
25
|
+
# Return duplication of self with all keys recursively converted to symbols
|
26
|
+
#
|
27
|
+
# @author Botanicus
|
28
|
+
# @since 0.0.2
|
29
|
+
# @return [Hash] A hash with all keys transformed into symbols even in inner hashes
|
30
|
+
def deep_symbolize_keys
|
31
|
+
self.inject(Hash.new) do |result, array|
|
32
|
+
key, value = array.first, array.last
|
33
|
+
if value.respond_to?(:symbolize_keys)
|
34
|
+
result[key.to_sym] = value.symbolize_keys
|
35
|
+
else
|
36
|
+
result[key.to_sym] = value
|
37
|
+
end
|
38
|
+
result
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
# Recursively replace keys in self by coresponding symbols
|
43
|
+
#
|
44
|
+
# @author Botanicus
|
45
|
+
# @since 0.0.2
|
46
|
+
# @return [Hash] A hash with all keys transformed into symbols even in inner hashes
|
47
|
+
def deep_symbolize_keys!
|
48
|
+
self.replace(self.deep_symbolize_keys)
|
49
|
+
end
|
50
|
+
|
51
|
+
# Returns the value of self for each argument and deletes those entries.
|
52
|
+
#
|
53
|
+
# @author Botanicus
|
54
|
+
# @since 0.0.2
|
55
|
+
# @param [*args] the keys whose values should be extracted and deleted.
|
56
|
+
# @return [Array<Object>] The values of the provided arguments in corresponding order.
|
57
|
+
# @api public
|
58
|
+
# @example
|
59
|
+
# hash = {one: 1, two: 2, three: 3}
|
60
|
+
# hash.extract!(:one, :two) # => [1, 2]
|
61
|
+
# hash # => {:three => 3}
|
62
|
+
def extract!(*args)
|
63
|
+
args.map do |arg|
|
64
|
+
self.delete(arg)
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
# @author Botanicus
|
69
|
+
# @since 0.0.2
|
70
|
+
# @return [String] A string formatted for HTML attributes
|
71
|
+
# @example
|
72
|
+
# {class: "inner", id: "post-#{@post.id}"}.to_html_attrs # => "class='inner' id='post-1'"
|
73
|
+
def to_html_attrs
|
74
|
+
self.map { |key, value| "#{key}='#{value}'" }.join(" ")
|
75
|
+
end
|
76
|
+
|
77
|
+
# @author Botanicus
|
78
|
+
# @since 0.0.2
|
79
|
+
# @return [String] A string formatted for URL
|
80
|
+
# @example
|
81
|
+
# {action: "rate", rating: 2}.to_url_attrs # => "action=rate&rating=2"
|
82
|
+
def to_url_attrs
|
83
|
+
self.map { |key, value| "#{key}=#{value}" }.join("&")
|
84
|
+
end
|
85
|
+
|
86
|
+
# @author Botanicus
|
87
|
+
# @since 0.0.2
|
88
|
+
# @return [String] Merge self into hash given as argument
|
89
|
+
def reverse_merge(another)
|
90
|
+
another.merge(self)
|
91
|
+
end
|
92
|
+
|
93
|
+
# @author Botanicus
|
94
|
+
# @since 0.0.2
|
95
|
+
# @return [String] Replace self by result of merge self into hash given as argument
|
96
|
+
def reverse_merge!(another)
|
97
|
+
self.replace(self.reverse_merge(another))
|
98
|
+
end
|
99
|
+
|
100
|
+
# @author Botanicus
|
101
|
+
# @since 0.0.2
|
102
|
+
# @deprecated
|
103
|
+
def to_native
|
104
|
+
self.each do |key, value|
|
105
|
+
value = case value
|
106
|
+
when "true" then true
|
107
|
+
when "false" then false
|
108
|
+
when "nil" then nil
|
109
|
+
when /^\d+$/ then value.to_i
|
110
|
+
when /^\d+\.\d+$/ then value.to_f
|
111
|
+
else value end
|
112
|
+
self[key.to_sym] = value
|
113
|
+
end
|
114
|
+
return self
|
115
|
+
end
|
116
|
+
|
117
|
+
# Simplier syntax for code such as params[:post] && params[:post][:title]
|
118
|
+
#
|
119
|
+
# @author Jakub Stastny aka Botanicus
|
120
|
+
# @since 0.0.3
|
121
|
+
# @param [Object] First argument is the key of the hash, the second one the key of the inner hash selected by the first key etc.
|
122
|
+
# @return [Object, nil] The value of the most inner hash if found or nil.
|
123
|
+
# @raise [ArgumentError] If you don't specify keys.
|
124
|
+
# @raise [IndexError] If you work with final result as with hash, so basically you are trying to call fetch method on string or whatever.
|
125
|
+
#
|
126
|
+
# @example
|
127
|
+
# {a: {b: 1}}.get(:a, :b) # => 1
|
128
|
+
# {a: {b: 1}}.get(:a, :b, :c) # => IndexError
|
129
|
+
# {a: {b: 1}}.get(:a, :c) # => nil
|
130
|
+
def get(*keys)
|
131
|
+
raise ArgumentError, "You must specify at least one key" if keys.empty?
|
132
|
+
keys.inject(self) do |object, key|
|
133
|
+
# Hash#fetch works similar as Hash#[], but [] method is
|
134
|
+
# defined for too many objects, also strings and even numbers
|
135
|
+
if object.respond_to?(:fetch)
|
136
|
+
begin
|
137
|
+
object.fetch(key)
|
138
|
+
# Hash#fetch raise IndexError if key doesn't exist
|
139
|
+
rescue IndexError
|
140
|
+
return nil
|
141
|
+
end
|
142
|
+
else
|
143
|
+
raise IndexError, "Object #{object.inspect} isn't hash-like collection"
|
144
|
+
end
|
145
|
+
end
|
146
|
+
end
|
147
|
+
|
148
|
+
##
|
149
|
+
# Create a hash with *only* key/value pairs in receiver and +allowed+
|
150
|
+
#
|
151
|
+
# { :one => 1, :two => 2, :three => 3 }.only(:one) #=> { :one => 1 }
|
152
|
+
#
|
153
|
+
# @param [Array[String, Symbol]] *allowed The hash keys to include.
|
154
|
+
#
|
155
|
+
# @return [Hash] A new hash with only the selected keys.
|
156
|
+
#
|
157
|
+
# @api public
|
158
|
+
def only(*allowed)
|
159
|
+
hash = {}
|
160
|
+
allowed.each {|k| hash[k] = self[k] if self.has_key?(k) }
|
161
|
+
hash
|
162
|
+
end
|
163
|
+
|
164
|
+
##
|
165
|
+
# Create a hash with all key/value pairs in receiver *except* +rejected+
|
166
|
+
#
|
167
|
+
# { :one => 1, :two => 2, :three => 3 }.except(:one)
|
168
|
+
# #=> { :two => 2, :three => 3 }
|
169
|
+
#
|
170
|
+
# @param [Array[String, Symbol]] *rejected The hash keys to exclude.
|
171
|
+
#
|
172
|
+
# @return [Hash] A new hash without the selected keys.
|
173
|
+
#
|
174
|
+
# @api public
|
175
|
+
def except(*rejected)
|
176
|
+
hash = self.dup
|
177
|
+
rejected.each {|k| hash.delete(k) }
|
178
|
+
hash
|
179
|
+
end
|
180
|
+
end
|
@@ -0,0 +1,91 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
module Kernel
|
4
|
+
# @since 0.0.2
|
5
|
+
def metaclass
|
6
|
+
class << self
|
7
|
+
self
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
# os.home
|
12
|
+
def os
|
13
|
+
@os ||= OS.parse
|
14
|
+
end
|
15
|
+
|
16
|
+
# @since 0.0.1
|
17
|
+
# @example
|
18
|
+
# try_require_gem "term/ansicolor", "term-ansicolor"
|
19
|
+
# @param [String] library Library to require.
|
20
|
+
# @param [String, @optional] gemname Name of gem which contains required library. Will be used for displaying message.
|
21
|
+
# @return [Boolean] True if require was successful, false otherwise.
|
22
|
+
def try_require_gem(library, gemname = library, options = Hash.new)
|
23
|
+
gemname, options = library, gemname if gemname.is_a?(Hash) && options.empty?
|
24
|
+
try_require_gem!(library, gemname, options)
|
25
|
+
rescue LoadError
|
26
|
+
return false
|
27
|
+
end
|
28
|
+
|
29
|
+
# @since 0.0.3
|
30
|
+
def try_require_gem!(library, gemname = library, options = Hash.new)
|
31
|
+
gemname, options = library, gemname if gemname.is_a?(Hash) && options.empty?
|
32
|
+
require library
|
33
|
+
rescue LoadError => exception
|
34
|
+
message = "Gem #{gemname} isn't installed. Run sudo gem install #{gemname}. (#{exception.inspect})"
|
35
|
+
logger = Rango.logger.method(options[:level] || :error)
|
36
|
+
callable = defined?(Rango.logger) ? logger : method(:puts)
|
37
|
+
callable.call(message)
|
38
|
+
raise exception
|
39
|
+
end
|
40
|
+
|
41
|
+
# @since 0.0.3
|
42
|
+
def require_gem_or_exit(library, gemname = library, options = Hash.new)
|
43
|
+
gemname, options = library, gemname if gemname.is_a?(Hash) && options.empty?
|
44
|
+
try_require_gem!(library, gemname, options)
|
45
|
+
rescue LoadError
|
46
|
+
exit 1
|
47
|
+
end
|
48
|
+
|
49
|
+
# @since 0.0.3
|
50
|
+
def try_require(library)
|
51
|
+
require library
|
52
|
+
rescue LoadError
|
53
|
+
return false
|
54
|
+
end
|
55
|
+
|
56
|
+
def command(command)
|
57
|
+
puts command
|
58
|
+
puts %x[#{command}]
|
59
|
+
end
|
60
|
+
alias_method :sh, :command
|
61
|
+
alias_method :run, :command
|
62
|
+
|
63
|
+
def quiet(&block)
|
64
|
+
old_stdout = STDOUT.dup
|
65
|
+
STDOUT.reopen("/dev/null")
|
66
|
+
returned = block.call
|
67
|
+
STDOUT.reopen(old_stdout)
|
68
|
+
return returned
|
69
|
+
end
|
70
|
+
|
71
|
+
def quiet!(&block)
|
72
|
+
old_stderr = STDERR.dup
|
73
|
+
STDERR.reopen("/dev/null", "a")
|
74
|
+
returned = quiet(&block)
|
75
|
+
STDERR.reopen(old_stderr)
|
76
|
+
return returned
|
77
|
+
end
|
78
|
+
|
79
|
+
# for quick inspection
|
80
|
+
# @since 0.0.2
|
81
|
+
def puts_and_return(*args)
|
82
|
+
puts(*args)
|
83
|
+
return *args
|
84
|
+
end
|
85
|
+
|
86
|
+
# @since 0.0.2
|
87
|
+
def p_and_return(*args)
|
88
|
+
p(*args)
|
89
|
+
return *args
|
90
|
+
end
|
91
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
# Extends the module object with module and instance accessors for class attributes,
|
4
|
+
# just like the native attr* accessors for instance attributes.
|
5
|
+
#
|
6
|
+
# module AppConfiguration
|
7
|
+
# mattr_accessor :google_api_key
|
8
|
+
# self.google_api_key = "123456789"
|
9
|
+
#
|
10
|
+
# mattr_accessor :paypal_url
|
11
|
+
# self.paypal_url = "www.sandbox.paypal.com"
|
12
|
+
# end
|
13
|
+
#
|
14
|
+
# AppConfiguration.google_api_key = "overriding the api key!"
|
15
|
+
class Module
|
16
|
+
def mattr_reader(*syms)
|
17
|
+
syms.each do |sym|
|
18
|
+
next if sym.is_a?(Hash)
|
19
|
+
class_eval(<<-EOS, __FILE__, __LINE__)
|
20
|
+
unless defined? @@#{sym}
|
21
|
+
@@#{sym} = nil
|
22
|
+
end
|
23
|
+
|
24
|
+
def self.#{sym}
|
25
|
+
@@#{sym}
|
26
|
+
end
|
27
|
+
|
28
|
+
def #{sym}
|
29
|
+
@@#{sym}
|
30
|
+
end
|
31
|
+
EOS
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def mattr_writer(*syms)
|
36
|
+
syms.each do |sym|
|
37
|
+
class_eval(<<-EOS, __FILE__, __LINE__)
|
38
|
+
unless defined? @@#{sym}
|
39
|
+
@@#{sym} = nil
|
40
|
+
end
|
41
|
+
|
42
|
+
def self.#{sym}=(obj)
|
43
|
+
@@#{sym} = obj
|
44
|
+
end
|
45
|
+
EOS
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
def mattr_accessor(*syms)
|
50
|
+
mattr_reader(*syms)
|
51
|
+
mattr_writer(*syms)
|
52
|
+
end
|
53
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
class Object
|
4
|
+
# *Unlike* that method however, a +NoMethodError+ exception will *not* be raised
|
5
|
+
# and +nil+ will be returned instead, if the receiving object is a +nil+ object or NilClass.
|
6
|
+
#
|
7
|
+
# Invokes the method identified by the symbol +method+, passing it any arguments
|
8
|
+
# and/or the block specified, just like the regular Ruby <tt>Object#send</tt> does.
|
9
|
+
#
|
10
|
+
# @author Botanicus
|
11
|
+
# @since 0.0.3
|
12
|
+
# @return [Object, nil] Return value of object.send(method) if object respond to method or nil
|
13
|
+
# @param [Symbol] Method which will be called on object if object respond to this method
|
14
|
+
# @param [Object, optional] Arguments for +method+ argument
|
15
|
+
# @yield [block, optional] Block for +method+ argument
|
16
|
+
# @example
|
17
|
+
# @post.try(:name) # instead @post && @post.name
|
18
|
+
# eBook.try(:find, 1)
|
19
|
+
# @post.try(:collect) { |p| p.name }
|
20
|
+
def try(method, *args, &block)
|
21
|
+
self.send(method, *args, &block) if self.respond_to?(method)
|
22
|
+
end
|
23
|
+
|
24
|
+
# The opposite of <tt>#nil?</tt>.
|
25
|
+
#
|
26
|
+
# @author Botanicus
|
27
|
+
# @since 0.0.3
|
28
|
+
# @return [true, false] True if self is nil, false otherwise
|
29
|
+
def not_nil?
|
30
|
+
not self.nil?
|
31
|
+
end
|
32
|
+
|
33
|
+
# Defines a instance method on class of the object.
|
34
|
+
#
|
35
|
+
# @author Botanicus
|
36
|
+
# @since 0.0.3
|
37
|
+
# @param [Symbol] Method name
|
38
|
+
# @param [Method, Proc, optional] +Method+ or +Proc+ which will be used as body of the method
|
39
|
+
# @yield [block] Block which will be used as body of the method
|
40
|
+
# @return [Object] First (and only) item of the array
|
41
|
+
# @see <tt>Module#define_singleton_method</tt> for define method on singleton class
|
42
|
+
# @example
|
43
|
+
# class Experiment
|
44
|
+
# def method_generator
|
45
|
+
# define_instance_method(:new_method) do |arg|
|
46
|
+
# puts "Method :new_method called with #{arg}"
|
47
|
+
# end
|
48
|
+
# end
|
49
|
+
# end
|
50
|
+
# Experiment.new.methods.include?(:new_method) # => false
|
51
|
+
# Experiment.new.method_generator
|
52
|
+
# Experiment.new.methods.include?(:new_method) # => true
|
53
|
+
def define_instance_method(*args, &block)
|
54
|
+
self.class.send(:define_method, *args, &block)
|
55
|
+
end
|
56
|
+
end
|