rango 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +6 -0
- data/CONTRIBUTORS +1 -0
- data/README.textile +4 -1
- data/bin/rango +1 -1
- data/lib/rango.rb +78 -12
- data/lib/rango/contrib/pagination.rb +2 -0
- data/lib/rango/controller.rb +58 -12
- data/lib/rango/environments.rb +26 -0
- data/lib/rango/exceptions.rb +2 -14
- data/lib/rango/gv.rb +7 -90
- data/lib/rango/gv/static.rb +22 -0
- data/lib/rango/helpers.rb +0 -1
- data/lib/rango/helpers/assets.rb +2 -0
- data/lib/rango/helpers/general.rb +1 -0
- data/lib/rango/helpers/syntax.rb +2 -0
- data/lib/rango/mini.rb +30 -0
- data/lib/rango/mixins/application.rb +5 -3
- data/lib/rango/mixins/configurable.rb +1 -0
- data/lib/rango/mixins/render.rb +13 -84
- data/lib/rango/orm/tasks/datamapper.rake +2 -2
- data/lib/rango/project.rb +2 -2
- data/lib/rango/rack/middlewares/basic.rb +15 -11
- data/lib/rango/rack/request.rb +5 -3
- data/lib/rango/router.rb +20 -2
- data/lib/rango/router/adapters/rack_mount.rb +0 -1
- data/lib/rango/router/adapters/rack_router.rb +0 -1
- data/lib/rango/router/adapters/urlmap.rb +0 -1
- data/lib/rango/router/adapters/usher.rb +0 -1
- data/lib/rango/settings/framework.rb +2 -43
- data/lib/rango/templates/{erubis.rb → exts/erubis.rb} +0 -19
- data/lib/rango/templates/exts/tilt.rb +16 -0
- data/lib/rango/templates/helpers.rb +107 -0
- data/lib/rango/templates/template.rb +44 -115
- data/lib/rango/utils.rb +9 -4
- data/spec/rango/controller_spec.rb +3 -1
- data/spec/rango/environments_spec.rb +68 -0
- data/spec/rango/gv_spec.rb +10 -0
- data/spec/rango/mini_spec.rb +58 -0
- data/spec/rango/project_spec.rb +1 -1
- data/spec/rango/templates/template_spec.rb +81 -0
- data/spec/rango/utils_spec.rb +33 -0
- data/spec/rango_spec.rb +3 -17
- data/spec/spec_helper.rb +5 -3
- data/spec/stubs/config.ru +5 -0
- data/spec/stubs/templates/capture.html.erb +1 -1
- data/spec/stubs/templates/erubis.html.erubis +2 -0
- data/spec/stubs/templates/inheritance/basic/base.html.haml +2 -0
- data/spec/stubs/templates/inheritance/basic/index.html.haml +2 -0
- data/spec/stubs/templates/inheritance/capture/erb/base.html.erb +3 -0
- data/spec/stubs/templates/inheritance/capture/erb/index.html.erb +4 -0
- data/spec/stubs/templates/inheritance/capture/erubis/base.html.erubis +3 -0
- data/spec/stubs/templates/inheritance/capture/erubis/index.html.erubis +4 -0
- data/spec/stubs/templates/inheritance/capture/haml/base.html.haml +2 -0
- data/spec/stubs/templates/inheritance/capture/haml/index.html.haml +3 -0
- data/spec/stubs/templates/test.html.haml +1 -0
- data/spec/stubs/templates/variables.html.haml +1 -0
- data/stubs/app/content/init.rb.rbt +2 -1
- data/stubs/app/content/views.rb.rbt +2 -0
- data/stubs/bigapp/content/views/%controller%.rb.rbt +2 -0
- data/stubs/project/content/config.ru.rbt +3 -0
- data/stubs/project/content/init.rb.rbt +11 -5
- data/stubs/project/content/settings.rb +0 -2
- data/stubs/project/content/settings_local.rb.rbt +1 -1
- data/stubs/project/content/templates/base.html.haml.rbt +1 -0
- metadata +42 -329
- data/examples/README.textile +0 -12
- data/examples/blog/Gemfile +0 -80
- data/examples/blog/Rakefile +0 -12
- data/examples/blog/TODO.txt +0 -0
- data/examples/blog/bin/autospec +0 -3
- data/examples/blog/bin/css2sass +0 -3
- data/examples/blog/bin/cucumber +0 -3
- data/examples/blog/bin/haml +0 -3
- data/examples/blog/bin/html2haml +0 -3
- data/examples/blog/bin/htmldiff +0 -3
- data/examples/blog/bin/launchy +0 -3
- data/examples/blog/bin/ldiff +0 -3
- data/examples/blog/bin/nokogiri +0 -3
- data/examples/blog/bin/racksh +0 -3
- data/examples/blog/bin/rackup +0 -3
- data/examples/blog/bin/rake +0 -3
- data/examples/blog/bin/rango +0 -3
- data/examples/blog/bin/sass +0 -3
- data/examples/blog/bin/shotgun +0 -3
- data/examples/blog/bin/simple-templater +0 -3
- data/examples/blog/bin/spec +0 -3
- data/examples/blog/bin/tt +0 -3
- data/examples/blog/blog/init.rb +0 -9
- data/examples/blog/blog/models.rb +0 -21
- data/examples/blog/blog/views.rb +0 -16
- data/examples/blog/config.ru +0 -19
- data/examples/blog/gems/cache/addressable-2.1.1.gem +0 -0
- data/examples/blog/gems/cache/builder-2.1.2.gem +0 -0
- data/examples/blog/gems/cache/bundler-0.7.0.gem +0 -0
- data/examples/blog/gems/cache/cli-0.0.1.gem +0 -0
- data/examples/blog/gems/cache/configuration-1.1.0.gem +0 -0
- data/examples/blog/gems/cache/cucumber-0.4.4.gem +0 -0
- data/examples/blog/gems/cache/data_objects-0.10.0.gem +0 -0
- data/examples/blog/gems/cache/diff-lcs-1.1.2.gem +0 -0
- data/examples/blog/gems/cache/dm-core-0.10.1.gem +0 -0
- data/examples/blog/gems/cache/dm-timestamps-0.10.1.gem +0 -0
- data/examples/blog/gems/cache/do_mysql-0.10.0.gem +0 -0
- data/examples/blog/gems/cache/do_sqlite3-0.10.0.gem +0 -0
- data/examples/blog/gems/cache/extlib-0.9.13.gem +0 -0
- data/examples/blog/gems/cache/fuzzyhash-0.0.9.gem +0 -0
- data/examples/blog/gems/cache/haml-2.2.14.gem +0 -0
- data/examples/blog/gems/cache/launchy-0.3.3.gem +0 -0
- data/examples/blog/gems/cache/media-path-0.1.gem +0 -0
- data/examples/blog/gems/cache/nokogiri-1.4.0.gem +0 -0
- data/examples/blog/gems/cache/polyglot-0.2.9.gem +0 -0
- data/examples/blog/gems/cache/rack-1.0.1.gem +0 -0
- data/examples/blog/gems/cache/rack-test-0.5.2.gem +0 -0
- data/examples/blog/gems/cache/racksh-0.9.4.2.gem +0 -0
- data/examples/blog/gems/cache/rake-0.8.7.gem +0 -0
- data/examples/blog/gems/cache/rango-0.1.0.gem +0 -0
- data/examples/blog/gems/cache/rspec-1.2.9.gem +0 -0
- data/examples/blog/gems/cache/rubyexts-0.0.1.gem +0 -0
- data/examples/blog/gems/cache/shotgun-0.4.gem +0 -0
- data/examples/blog/gems/cache/simple-templater-0.0.1.gem +0 -0
- data/examples/blog/gems/cache/term-ansicolor-1.0.4.gem +0 -0
- data/examples/blog/gems/cache/treetop-1.4.2.gem +0 -0
- data/examples/blog/gems/cache/usher-0.5.11.gem +0 -0
- data/examples/blog/gems/cache/webrat-0.5.3.gem +0 -0
- data/examples/blog/init.rb +0 -49
- data/examples/blog/settings.rb +0 -15
- data/examples/blog/settings_local.rb +0 -6
- data/examples/blog/spec/blog/init_spec.rb +0 -7
- data/examples/blog/spec/blog/models_spec.rb +0 -28
- data/examples/blog/spec/blog/views_spec.rb +0 -22
- data/examples/blog/spec/spec.opts +0 -5
- data/examples/blog/spec/spec_helper.rb +0 -27
- data/examples/blog/templates/base.html.haml +0 -16
- data/examples/blog/templates/index.html.haml +0 -12
- data/lib/rango/boot.rb +0 -55
- data/lib/rango/helpers/README +0 -179
- data/lib/rango/helpers/merb-helpers.rb +0 -3
- data/lib/rango/helpers/merb-helpers/core_ext.rb +0 -58
- data/lib/rango/helpers/merb-helpers/core_ext/numeric.rb +0 -389
- data/lib/rango/helpers/merb-helpers/date_time_formatting.rb +0 -146
- data/lib/rango/helpers/merb-helpers/date_time_helpers.rb +0 -191
- data/lib/rango/helpers/merb-helpers/form/builder.rb +0 -450
- data/lib/rango/helpers/merb-helpers/form/helpers.rb +0 -453
- data/lib/rango/helpers/merb-helpers/form_helpers.rb +0 -21
- data/lib/rango/helpers/merb-helpers/tag_helpers.rb +0 -63
- data/lib/rango/helpers/merb-helpers/text_helpers.rb +0 -73
- data/lib/rango/loggers/logger.rb +0 -100
- data/lib/rango/mixins/chainable.rb +0 -68
- data/lib/rango/mixins/hookable.rb +0 -32
- data/lib/rango/mixins/import.rb +0 -89
- data/lib/rango/mixins/mini.rb +0 -29
- data/lib/rango/mixins/strategy.rb +0 -28
- data/lib/rango/rango.rb +0 -93
- data/lib/rango/router/specification.txt +0 -11
- data/lib/rango/templates/adapter.rb +0 -19
- data/lib/rango/templates/adapters/erb.rb +0 -63
- data/lib/rango/templates/adapters/erubis.rb +0 -65
- data/lib/rango/templates/adapters/haml.rb +0 -26
- data/lib/rango/templates/templates.txt +0 -39
- data/spec/factories.rb +0 -22
- data/spec/rango/boot_spec.rb +0 -15
- data/spec/rango/helpers/merb-helpers/core_ext/numeric_spec.rb +0 -0
- data/spec/rango/helpers/merb-helpers/core_ext_spec.rb +0 -21
- data/spec/rango/helpers/merb-helpers/date_time_formatting_spec.rb +0 -0
- data/spec/rango/helpers/merb-helpers/date_time_helpers_spec.rb +0 -0
- data/spec/rango/helpers/merb-helpers/fixture/app/controllers/application.rb +0 -4
- data/spec/rango/helpers/merb-helpers/fixture/app/controllers/bound_check_box.rb +0 -4
- data/spec/rango/helpers/merb-helpers/fixture/app/controllers/bound_file_field.rb +0 -4
- data/spec/rango/helpers/merb-helpers/fixture/app/controllers/bound_hidden_field.rb +0 -4
- data/spec/rango/helpers/merb-helpers/fixture/app/controllers/bound_option_tag.rb +0 -4
- data/spec/rango/helpers/merb-helpers/fixture/app/controllers/bound_password_field.rb +0 -4
- data/spec/rango/helpers/merb-helpers/fixture/app/controllers/bound_radio_button.rb +0 -4
- data/spec/rango/helpers/merb-helpers/fixture/app/controllers/bound_radio_group.rb +0 -4
- data/spec/rango/helpers/merb-helpers/fixture/app/controllers/bound_select.rb +0 -4
- data/spec/rango/helpers/merb-helpers/fixture/app/controllers/bound_text_area.rb +0 -4
- data/spec/rango/helpers/merb-helpers/fixture/app/controllers/bound_text_field.rb +0 -4
- data/spec/rango/helpers/merb-helpers/fixture/app/controllers/button.rb +0 -4
- data/spec/rango/helpers/merb-helpers/fixture/app/controllers/check_box.rb +0 -4
- data/spec/rango/helpers/merb-helpers/fixture/app/controllers/custom_builder.rb +0 -4
- data/spec/rango/helpers/merb-helpers/fixture/app/controllers/delete_button.rb +0 -4
- data/spec/rango/helpers/merb-helpers/fixture/app/controllers/exceptions.rb +0 -25
- data/spec/rango/helpers/merb-helpers/fixture/app/controllers/field_set.rb +0 -4
- data/spec/rango/helpers/merb-helpers/fixture/app/controllers/fields_for.rb +0 -3
- data/spec/rango/helpers/merb-helpers/fixture/app/controllers/file_field.rb +0 -4
- data/spec/rango/helpers/merb-helpers/fixture/app/controllers/foo.rb +0 -23
- data/spec/rango/helpers/merb-helpers/fixture/app/controllers/form.rb +0 -4
- data/spec/rango/helpers/merb-helpers/fixture/app/controllers/form_for.rb +0 -4
- data/spec/rango/helpers/merb-helpers/fixture/app/controllers/hacker.rb +0 -4
- data/spec/rango/helpers/merb-helpers/fixture/app/controllers/hidden_field.rb +0 -4
- data/spec/rango/helpers/merb-helpers/fixture/app/controllers/label.rb +0 -4
- data/spec/rango/helpers/merb-helpers/fixture/app/controllers/numeric_ext.rb +0 -4
- data/spec/rango/helpers/merb-helpers/fixture/app/controllers/option_tag.rb +0 -4
- data/spec/rango/helpers/merb-helpers/fixture/app/controllers/password_field.rb +0 -4
- data/spec/rango/helpers/merb-helpers/fixture/app/controllers/radio_button.rb +0 -4
- data/spec/rango/helpers/merb-helpers/fixture/app/controllers/radio_group.rb +0 -4
- data/spec/rango/helpers/merb-helpers/fixture/app/controllers/relative_date.rb +0 -4
- data/spec/rango/helpers/merb-helpers/fixture/app/controllers/relative_date_span.rb +0 -4
- data/spec/rango/helpers/merb-helpers/fixture/app/controllers/select.rb +0 -4
- data/spec/rango/helpers/merb-helpers/fixture/app/controllers/specs_controller.rb +0 -13
- data/spec/rango/helpers/merb-helpers/fixture/app/controllers/submit.rb +0 -4
- data/spec/rango/helpers/merb-helpers/fixture/app/controllers/tag_helper.rb +0 -23
- data/spec/rango/helpers/merb-helpers/fixture/app/controllers/text_area.rb +0 -4
- data/spec/rango/helpers/merb-helpers/fixture/app/controllers/text_field.rb +0 -4
- data/spec/rango/helpers/merb-helpers/fixture/app/helpers/global_helpers.rb +0 -7
- data/spec/rango/helpers/merb-helpers/fixture/app/models/fake_dm_model.rb +0 -27
- data/spec/rango/helpers/merb-helpers/fixture/app/models/first_generic_fake_model.rb +0 -59
- data/spec/rango/helpers/merb-helpers/fixture/app/models/hacker_generic_model.rb +0 -7
- data/spec/rango/helpers/merb-helpers/fixture/app/models/second_generic_fake_model.rb +0 -20
- data/spec/rango/helpers/merb-helpers/fixture/app/models/third_generic_fake_model.rb +0 -5
- data/spec/rango/helpers/merb-helpers/fixture/app/views/bound_check_box_specs/basic.html.erb +0 -4
- data/spec/rango/helpers/merb-helpers/fixture/app/views/bound_check_box_specs/basic_unchecked.html.erb +0 -3
- data/spec/rango/helpers/merb-helpers/fixture/app/views/bound_check_box_specs/checked.html.erb +0 -4
- data/spec/rango/helpers/merb-helpers/fixture/app/views/bound_check_box_specs/errors.html.erb +0 -4
- data/spec/rango/helpers/merb-helpers/fixture/app/views/bound_check_box_specs/label.html.erb +0 -3
- data/spec/rango/helpers/merb-helpers/fixture/app/views/bound_check_box_specs/on_and_off.html.erb +0 -3
- data/spec/rango/helpers/merb-helpers/fixture/app/views/bound_check_box_specs/raise_value_error.html.erb +0 -3
- data/spec/rango/helpers/merb-helpers/fixture/app/views/bound_file_field_specs/additional_attributes.html.erb +0 -3
- data/spec/rango/helpers/merb-helpers/fixture/app/views/bound_file_field_specs/takes_string.html.erb +0 -3
- data/spec/rango/helpers/merb-helpers/fixture/app/views/bound_file_field_specs/with_label.html.erb +0 -3
- data/spec/rango/helpers/merb-helpers/fixture/app/views/bound_hidden_field_specs/basic.html.erb +0 -3
- data/spec/rango/helpers/merb-helpers/fixture/app/views/bound_hidden_field_specs/errors.html.erb +0 -3
- data/spec/rango/helpers/merb-helpers/fixture/app/views/bound_hidden_field_specs/hidden_error.html.erb +0 -3
- data/spec/rango/helpers/merb-helpers/fixture/app/views/bound_hidden_field_specs/label.html.erb +0 -3
- data/spec/rango/helpers/merb-helpers/fixture/app/views/bound_option_tag_specs/grouped.html.erb +0 -3
- data/spec/rango/helpers/merb-helpers/fixture/app/views/bound_option_tag_specs/nested.html.erb +0 -3
- data/spec/rango/helpers/merb-helpers/fixture/app/views/bound_option_tag_specs/text_and_value.html.erb +0 -4
- data/spec/rango/helpers/merb-helpers/fixture/app/views/bound_password_field_specs/attributes.html.erb +0 -3
- data/spec/rango/helpers/merb-helpers/fixture/app/views/bound_password_field_specs/basic.html.erb +0 -3
- data/spec/rango/helpers/merb-helpers/fixture/app/views/bound_password_field_specs/label.html.erb +0 -3
- data/spec/rango/helpers/merb-helpers/fixture/app/views/bound_radio_button_specs/basic.html.erb +0 -3
- data/spec/rango/helpers/merb-helpers/fixture/app/views/bound_radio_group_specs/basic.html.erb +0 -3
- data/spec/rango/helpers/merb-helpers/fixture/app/views/bound_radio_group_specs/hashes.html.erb +0 -3
- data/spec/rango/helpers/merb-helpers/fixture/app/views/bound_radio_group_specs/mixed.html.erb +0 -4
- data/spec/rango/helpers/merb-helpers/fixture/app/views/bound_radio_group_specs/override_id.html.erb +0 -3
- data/spec/rango/helpers/merb-helpers/fixture/app/views/bound_select_specs/basic.html.erb +0 -3
- data/spec/rango/helpers/merb-helpers/fixture/app/views/bound_select_specs/blank.html.erb +0 -3
- data/spec/rango/helpers/merb-helpers/fixture/app/views/bound_select_specs/label.html.erb +0 -3
- data/spec/rango/helpers/merb-helpers/fixture/app/views/bound_select_specs/multiple.html.erb +0 -3
- data/spec/rango/helpers/merb-helpers/fixture/app/views/bound_select_specs/prompt.html.erb +0 -3
- data/spec/rango/helpers/merb-helpers/fixture/app/views/bound_select_specs/with_options.html.erb +0 -3
- data/spec/rango/helpers/merb-helpers/fixture/app/views/bound_select_specs/with_options_with_blank.html.erb +0 -3
- data/spec/rango/helpers/merb-helpers/fixture/app/views/bound_text_area_specs/basic.html.erb +0 -3
- data/spec/rango/helpers/merb-helpers/fixture/app/views/bound_text_area_specs/label.html.erb +0 -3
- data/spec/rango/helpers/merb-helpers/fixture/app/views/bound_text_field_specs/basic.html.erb +0 -3
- data/spec/rango/helpers/merb-helpers/fixture/app/views/button_specs/button_with_label.html.erb +0 -1
- data/spec/rango/helpers/merb-helpers/fixture/app/views/button_specs/button_with_values.html.erb +0 -1
- data/spec/rango/helpers/merb-helpers/fixture/app/views/button_specs/disabled_button.html.erb +0 -1
- data/spec/rango/helpers/merb-helpers/fixture/app/views/check_box_specs/basic.html.erb +0 -1
- data/spec/rango/helpers/merb-helpers/fixture/app/views/check_box_specs/boolean.html.erb +0 -1
- data/spec/rango/helpers/merb-helpers/fixture/app/views/check_box_specs/disabled.html.erb +0 -1
- data/spec/rango/helpers/merb-helpers/fixture/app/views/check_box_specs/label.html.erb +0 -1
- data/spec/rango/helpers/merb-helpers/fixture/app/views/check_box_specs/on_off_is_boolean.html.erb +0 -1
- data/spec/rango/helpers/merb-helpers/fixture/app/views/check_box_specs/raise_unless_both_on_and_off.html.erb +0 -2
- data/spec/rango/helpers/merb-helpers/fixture/app/views/check_box_specs/raises_error_if_not_boolean.html.erb +0 -1
- data/spec/rango/helpers/merb-helpers/fixture/app/views/check_box_specs/raises_error_if_on_off_and_boolean_false.html.erb +0 -1
- data/spec/rango/helpers/merb-helpers/fixture/app/views/check_box_specs/simple.html.erb +0 -1
- data/spec/rango/helpers/merb-helpers/fixture/app/views/check_box_specs/to_string.html.erb +0 -8
- data/spec/rango/helpers/merb-helpers/fixture/app/views/check_box_specs/unchecked.html.erb +0 -2
- data/spec/rango/helpers/merb-helpers/fixture/app/views/custom_builder_specs/everything.html.erb +0 -10
- data/spec/rango/helpers/merb-helpers/fixture/app/views/delete_button_specs/delete_with_explicit_url.html.erb +0 -1
- data/spec/rango/helpers/merb-helpers/fixture/app/views/delete_button_specs/delete_with_extra_params.html.erb +0 -1
- data/spec/rango/helpers/merb-helpers/fixture/app/views/delete_button_specs/delete_with_label.html.erb +0 -1
- data/spec/rango/helpers/merb-helpers/fixture/app/views/delete_button_specs/simple_delete.html.erb +0 -1
- data/spec/rango/helpers/merb-helpers/fixture/app/views/exeptions/client_error.html.erb +0 -37
- data/spec/rango/helpers/merb-helpers/fixture/app/views/exeptions/internal_server_error.html.erb +0 -216
- data/spec/rango/helpers/merb-helpers/fixture/app/views/exeptions/not_acceptable.html.erb +0 -38
- data/spec/rango/helpers/merb-helpers/fixture/app/views/exeptions/not_found.html.erb +0 -40
- data/spec/rango/helpers/merb-helpers/fixture/app/views/fields_for_specs/basic.html.erb +0 -3
- data/spec/rango/helpers/merb-helpers/fixture/app/views/fields_for_specs/midstream.html.erb +0 -7
- data/spec/rango/helpers/merb-helpers/fixture/app/views/fields_for_specs/nil.html.erb +0 -3
- data/spec/rango/helpers/merb-helpers/fixture/app/views/fieldset_specs/legend.html.erb +0 -3
- data/spec/rango/helpers/merb-helpers/fixture/app/views/file_field_specs/disabled.html.erb +0 -1
- data/spec/rango/helpers/merb-helpers/fixture/app/views/file_field_specs/makes_multipart.html.erb +0 -3
- data/spec/rango/helpers/merb-helpers/fixture/app/views/file_field_specs/with_label.html.erb +0 -1
- data/spec/rango/helpers/merb-helpers/fixture/app/views/file_field_specs/with_values.html.erb +0 -1
- data/spec/rango/helpers/merb-helpers/fixture/app/views/foo/bar.html.erb +0 -0
- data/spec/rango/helpers/merb-helpers/fixture/app/views/form_for_specs/basic.html.erb +0 -3
- data/spec/rango/helpers/merb-helpers/fixture/app/views/form_specs/create_a_form.html.erb +0 -3
- data/spec/rango/helpers/merb-helpers/fixture/app/views/form_specs/create_a_multipart_form.html.erb +0 -3
- data/spec/rango/helpers/merb-helpers/fixture/app/views/form_specs/fake_delete_if_set.html.erb +0 -3
- data/spec/rango/helpers/merb-helpers/fixture/app/views/form_specs/fake_put_if_set.html.erb +0 -3
- data/spec/rango/helpers/merb-helpers/fixture/app/views/form_specs/get_if_set.html.erb +0 -3
- data/spec/rango/helpers/merb-helpers/fixture/app/views/form_specs/post_by_default.html.erb +0 -3
- data/spec/rango/helpers/merb-helpers/fixture/app/views/form_specs/resourceful_form.html.erb +0 -3
- data/spec/rango/helpers/merb-helpers/fixture/app/views/hacker/file_field.html.erb +0 -3
- data/spec/rango/helpers/merb-helpers/fixture/app/views/hacker/hidden_field.html.erb +0 -3
- data/spec/rango/helpers/merb-helpers/fixture/app/views/hacker/option_tag.html.erb +0 -4
- data/spec/rango/helpers/merb-helpers/fixture/app/views/hacker/password_field.html.erb +0 -3
- data/spec/rango/helpers/merb-helpers/fixture/app/views/hacker/radio_button.html.erb +0 -3
- data/spec/rango/helpers/merb-helpers/fixture/app/views/hacker/radio_group.html.erb +0 -3
- data/spec/rango/helpers/merb-helpers/fixture/app/views/hacker/text_area.html.erb +0 -3
- data/spec/rango/helpers/merb-helpers/fixture/app/views/hacker/text_field.html.erb +0 -3
- data/spec/rango/helpers/merb-helpers/fixture/app/views/hidden_field_specs/basic.html.erb +0 -1
- data/spec/rango/helpers/merb-helpers/fixture/app/views/hidden_field_specs/disabled.html.erb +0 -1
- data/spec/rango/helpers/merb-helpers/fixture/app/views/hidden_field_specs/label.html.erb +0 -1
- data/spec/rango/helpers/merb-helpers/fixture/app/views/label_specs/basic.html.erb +0 -1
- data/spec/rango/helpers/merb-helpers/fixture/app/views/label_specs/basic_with_attributes.html.erb +0 -1
- data/spec/rango/helpers/merb-helpers/fixture/app/views/label_specs/basic_with_class.html.erb +0 -1
- data/spec/rango/helpers/merb-helpers/fixture/app/views/layout/application.html.erb +0 -11
- data/spec/rango/helpers/merb-helpers/fixture/app/views/numeric_ext_specs/minutes_to_hours.html.erb +0 -1
- data/spec/rango/helpers/merb-helpers/fixture/app/views/numeric_ext_specs/to_concurrency_default.html.erb +0 -1
- data/spec/rango/helpers/merb-helpers/fixture/app/views/numeric_ext_specs/two_digits.html.erb +0 -1
- data/spec/rango/helpers/merb-helpers/fixture/app/views/option_tag_specs/array.html.erb +0 -1
- data/spec/rango/helpers/merb-helpers/fixture/app/views/option_tag_specs/clean.html.erb +0 -1
- data/spec/rango/helpers/merb-helpers/fixture/app/views/option_tag_specs/collection.html.erb +0 -1
- data/spec/rango/helpers/merb-helpers/fixture/app/views/option_tag_specs/multiple_selects.html.erb +0 -1
- data/spec/rango/helpers/merb-helpers/fixture/app/views/option_tag_specs/no_extra_attributes.html.erb +0 -1
- data/spec/rango/helpers/merb-helpers/fixture/app/views/option_tag_specs/optgroups.html.erb +0 -1
- data/spec/rango/helpers/merb-helpers/fixture/app/views/option_tag_specs/selected.html.erb +0 -1
- data/spec/rango/helpers/merb-helpers/fixture/app/views/option_tag_specs/with_blank.html.erb +0 -1
- data/spec/rango/helpers/merb-helpers/fixture/app/views/option_tag_specs/with_prompt.html.erb +0 -1
- data/spec/rango/helpers/merb-helpers/fixture/app/views/password_field_specs/basic.html.erb +0 -1
- data/spec/rango/helpers/merb-helpers/fixture/app/views/password_field_specs/disabled.html.erb +0 -1
- data/spec/rango/helpers/merb-helpers/fixture/app/views/radio_button_specs/basic.html.erb +0 -1
- data/spec/rango/helpers/merb-helpers/fixture/app/views/radio_button_specs/checked.html.erb +0 -1
- data/spec/rango/helpers/merb-helpers/fixture/app/views/radio_button_specs/disabled.html.erb +0 -1
- data/spec/rango/helpers/merb-helpers/fixture/app/views/radio_button_specs/label.html.erb +0 -1
- data/spec/rango/helpers/merb-helpers/fixture/app/views/radio_button_specs/unchecked.html.erb +0 -1
- data/spec/rango/helpers/merb-helpers/fixture/app/views/radio_group_specs/attributes.html.erb +0 -1
- data/spec/rango/helpers/merb-helpers/fixture/app/views/radio_group_specs/basic.html.erb +0 -1
- data/spec/rango/helpers/merb-helpers/fixture/app/views/radio_group_specs/checked.html.erb +0 -1
- data/spec/rango/helpers/merb-helpers/fixture/app/views/radio_group_specs/hash.html.erb +0 -1
- data/spec/rango/helpers/merb-helpers/fixture/app/views/radio_group_specs/specific_attributes.html.erb +0 -1
- data/spec/rango/helpers/merb-helpers/fixture/app/views/relative_date_span_specs/date_span_on_same_day.html.erb +0 -1
- data/spec/rango/helpers/merb-helpers/fixture/app/views/relative_date_span_specs/date_span_on_same_day_on_different_year.html.erb +0 -1
- data/spec/rango/helpers/merb-helpers/fixture/app/views/relative_date_specs/relative_date_with_year.html.erb +0 -1
- data/spec/rango/helpers/merb-helpers/fixture/app/views/relative_date_specs/relative_date_without_year.html.erb +0 -1
- data/spec/rango/helpers/merb-helpers/fixture/app/views/relative_date_specs/relative_today.html.erb +0 -1
- data/spec/rango/helpers/merb-helpers/fixture/app/views/relative_date_specs/relative_tomorrow.html.erb +0 -1
- data/spec/rango/helpers/merb-helpers/fixture/app/views/relative_date_specs/relative_yesterday.html.erb +0 -1
- data/spec/rango/helpers/merb-helpers/fixture/app/views/select_specs/basic.html.erb +0 -1
- data/spec/rango/helpers/merb-helpers/fixture/app/views/select_specs/blank.html.erb +0 -1
- data/spec/rango/helpers/merb-helpers/fixture/app/views/select_specs/multiple.html.erb +0 -1
- data/spec/rango/helpers/merb-helpers/fixture/app/views/select_specs/selected.html.erb +0 -1
- data/spec/rango/helpers/merb-helpers/fixture/app/views/submit_specs/disabled_submit.html.erb +0 -1
- data/spec/rango/helpers/merb-helpers/fixture/app/views/submit_specs/submit_with_label.html.erb +0 -1
- data/spec/rango/helpers/merb-helpers/fixture/app/views/submit_specs/submit_with_values.html.erb +0 -1
- data/spec/rango/helpers/merb-helpers/fixture/app/views/tag_helper/nested_tags.html.erb +0 -5
- data/spec/rango/helpers/merb-helpers/fixture/app/views/tag_helper/tag_with_attributes.html.erb +0 -1
- data/spec/rango/helpers/merb-helpers/fixture/app/views/tag_helper/tag_with_content.html.erb +0 -1
- data/spec/rango/helpers/merb-helpers/fixture/app/views/tag_helper/tag_with_content_in_the_block.html.erb +0 -3
- data/spec/rango/helpers/merb-helpers/fixture/app/views/text_area_specs/basic.html.erb +0 -1
- data/spec/rango/helpers/merb-helpers/fixture/app/views/text_area_specs/disabled.html.erb +0 -1
- data/spec/rango/helpers/merb-helpers/fixture/app/views/text_area_specs/label.html.erb +0 -1
- data/spec/rango/helpers/merb-helpers/fixture/app/views/text_area_specs/nil.html.erb +0 -1
- data/spec/rango/helpers/merb-helpers/fixture/app/views/text_field_specs/basic.html.erb +0 -1
- data/spec/rango/helpers/merb-helpers/fixture/app/views/text_field_specs/class.html.erb +0 -1
- data/spec/rango/helpers/merb-helpers/fixture/app/views/text_field_specs/disabled.html.erb +0 -1
- data/spec/rango/helpers/merb-helpers/fixture/app/views/text_field_specs/label.html.erb +0 -1
- data/spec/rango/helpers/merb-helpers/fixture/app/views/text_field_specs/symbolized_name.html.erb +0 -1
- data/spec/rango/helpers/merb-helpers/fixture/config/environments/development.rb +0 -8
- data/spec/rango/helpers/merb-helpers/fixture/config/environments/production.rb +0 -7
- data/spec/rango/helpers/merb-helpers/fixture/config/environments/test.rb +0 -8
- data/spec/rango/helpers/merb-helpers/fixture/config/init.rb +0 -48
- data/spec/rango/helpers/merb-helpers/fixture/config/rack.rb +0 -13
- data/spec/rango/helpers/merb-helpers/fixture/config/router.rb +0 -40
- data/spec/rango/helpers/merb-helpers/fixture/public/images/merb.jpg +0 -0
- data/spec/rango/helpers/merb-helpers/fixture/public/merb.fcgi +0 -4
- data/spec/rango/helpers/merb-helpers/fixture/public/stylesheets/master.css +0 -119
- data/spec/rango/helpers/merb-helpers/form/builder_spec.rb +0 -0
- data/spec/rango/helpers/merb-helpers/form/helpers_spec.rb +0 -0
- data/spec/rango/helpers/merb-helpers/form_helpers_spec.rb +0 -0
- data/spec/rango/helpers/merb-helpers/merb_helpers_config_spec.rb +0 -85
- data/spec/rango/helpers/merb-helpers/merb_helpers_date_time_spec.rb +0 -270
- data/spec/rango/helpers/merb-helpers/merb_helpers_form_spec.rb +0 -1372
- data/spec/rango/helpers/merb-helpers/merb_helpers_tag_helper_spec.rb +0 -46
- data/spec/rango/helpers/merb-helpers/merb_helpers_text_spec.rb +0 -71
- data/spec/rango/helpers/merb-helpers/numeric_extlib_spec.rb +0 -138
- data/spec/rango/helpers/merb-helpers/ordinalize_spec.rb +0 -55
- data/spec/rango/helpers/merb-helpers/tag_helpers_spec.rb +0 -0
- data/spec/rango/helpers/merb-helpers/text_helpers_spec.rb +0 -0
- data/spec/rango/helpers/merb-helpers_spec.rb +0 -0
- data/spec/rango/mixins/chainable_spec.rb +0 -0
- data/spec/rango/mixins/hookable_spec.rb +0 -0
- data/spec/rango/mixins/import_spec.rb +0 -0
- data/spec/rango/mixins/mini_spec.rb +0 -0
- data/spec/rango/mixins/strategy_spec.rb +0 -0
- data/spec/rango/rango_spec.rb +0 -0
- data/spec/rango/templates/adapter_spec.rb +0 -0
- data/spec/rango/templates/adapters/erb_spec.rb +0 -0
- data/spec/rango/templates/adapters/erubis_spec.rb +0 -117
- data/spec/rango/templates/adapters/haml_spec.rb +0 -0
- data/spec/rango/templates/adapters/template_helpers.rb +0 -38
@@ -1,21 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
require_relative "form/helpers"
|
4
|
-
require_relative "form/builder"
|
5
|
-
|
6
|
-
module Rango
|
7
|
-
module Helpers
|
8
|
-
include Rango::Helpers::Form
|
9
|
-
end
|
10
|
-
end
|
11
|
-
|
12
|
-
class Rango::Controller
|
13
|
-
class_inheritable_accessor :_default_builder
|
14
|
-
end
|
15
|
-
|
16
|
-
# Rango::BootLoader.after_app_loads do
|
17
|
-
# module Rango::Controller
|
18
|
-
# self._default_builder =
|
19
|
-
# Object.full_const_get(Rango::Plugins.config[:helpers][:default_builder]) rescue Rango::Helpers::Form::Builder::ResourcefulFormWithErrors
|
20
|
-
# end
|
21
|
-
# end
|
@@ -1,63 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
module Rango
|
4
|
-
module Helpers
|
5
|
-
module Tag
|
6
|
-
# Creates a generic HTML tag. You can invoke it a variety of ways.
|
7
|
-
#
|
8
|
-
# tag :div
|
9
|
-
# # <div></div>
|
10
|
-
#
|
11
|
-
# tag :div, 'content'
|
12
|
-
# # <div>content</div>
|
13
|
-
#
|
14
|
-
# tag :div, :class => 'class'
|
15
|
-
# # <div class="class"></div>
|
16
|
-
#
|
17
|
-
# tag :div, 'content', :class => 'class'
|
18
|
-
# # <div class="class">content</div>
|
19
|
-
#
|
20
|
-
# tag :div do
|
21
|
-
# 'content'
|
22
|
-
# end
|
23
|
-
# # <div>content</div>
|
24
|
-
#
|
25
|
-
# tag :div, :class => 'class' do
|
26
|
-
# 'content'
|
27
|
-
# end
|
28
|
-
# # <div class="class">content</div>
|
29
|
-
#
|
30
|
-
def tag(name, contents = nil, attrs = {}, &block)
|
31
|
-
attrs, contents = contents, nil if contents.is_a?(Hash)
|
32
|
-
contents = capture(&block) if block_given?
|
33
|
-
open_tag(name, attrs) + contents.to_s + close_tag(name)
|
34
|
-
end
|
35
|
-
|
36
|
-
# Creates the opening tag with attributes for the provided +name+
|
37
|
-
# attrs is a hash where all members will be mapped to key="value"
|
38
|
-
#
|
39
|
-
# Note: This tag will need to be closed
|
40
|
-
def open_tag(name, attrs = nil)
|
41
|
-
"<#{name}#{' ' + attrs.to_html_attributes unless attrs.blank?}>"
|
42
|
-
end
|
43
|
-
|
44
|
-
# Creates a closing tag
|
45
|
-
def close_tag(name)
|
46
|
-
"</#{name}>"
|
47
|
-
end
|
48
|
-
|
49
|
-
# Creates a self closing tag. Like <br/> or <img src="..."/>
|
50
|
-
#
|
51
|
-
# +name+ : the name of the tag to create
|
52
|
-
# +attrs+ : a hash where all members will be mapped to key="value"
|
53
|
-
def self_closing_tag(name, attrs = nil)
|
54
|
-
"<#{name}#{' ' + attrs.to_html_attributes if attrs && !attrs.empty?}/>"
|
55
|
-
end
|
56
|
-
|
57
|
-
end
|
58
|
-
end
|
59
|
-
end
|
60
|
-
|
61
|
-
module Rango::Helpers
|
62
|
-
include Rango::Helpers::Tag
|
63
|
-
end
|
@@ -1,73 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
module Rango
|
4
|
-
module Helpers
|
5
|
-
module Text
|
6
|
-
# from merb-core / Kernel
|
7
|
-
def extract_options_from_args!(args)
|
8
|
-
args.pop if (args.last.instance_of?(Hash) || args.last.instance_of?(Mash))
|
9
|
-
end
|
10
|
-
|
11
|
-
|
12
|
-
# Allows you to cycle through elements in an array
|
13
|
-
#
|
14
|
-
# ==== Parameters
|
15
|
-
# values<Array>:: Array of objects to cycle through
|
16
|
-
# values<Hash>:: Last element of array can be a hash with the key of
|
17
|
-
# :name to specify the name of the cycle
|
18
|
-
#
|
19
|
-
# ==== Returns
|
20
|
-
# String
|
21
|
-
#
|
22
|
-
# ==== Notes
|
23
|
-
# * Default name is :default
|
24
|
-
#
|
25
|
-
# ==== Example
|
26
|
-
# <%= 5.times { cycle("odd! ","even! "} %>
|
27
|
-
#
|
28
|
-
# Generates:
|
29
|
-
#
|
30
|
-
# odd! even! odd! even! odd!
|
31
|
-
def cycle(*values)
|
32
|
-
options = extract_options_from_args!(values) || {}
|
33
|
-
key = (options[:name] || :default).to_sym
|
34
|
-
(@cycle_positions ||= {})[key] ||= {:position => -1, :values => values}
|
35
|
-
unless values == @cycle_positions[key][:values]
|
36
|
-
@cycle_positions[key] = {:position => -1, :values => values}
|
37
|
-
end
|
38
|
-
current = @cycle_positions[key][:position]
|
39
|
-
@cycle_positions[key][:position] = current + 1
|
40
|
-
values.at( (current + 1) % values.length).to_s
|
41
|
-
end
|
42
|
-
|
43
|
-
# Allows you to reset a cycle
|
44
|
-
#
|
45
|
-
# ==== Parameters
|
46
|
-
# name<Symbol|String>:: Name of the cycle
|
47
|
-
#
|
48
|
-
# ==== Returns
|
49
|
-
# True if successful, otherwise nil
|
50
|
-
#
|
51
|
-
# ==== Notes
|
52
|
-
# * Default name is :default
|
53
|
-
#
|
54
|
-
# ==== Example
|
55
|
-
# <%= cycle("odd! ","even! ","what comes after even?") %>
|
56
|
-
# <%= cycle("odd! ","even! ","what comes after even?") %>
|
57
|
-
# <% reset_cycle %>
|
58
|
-
# <%= cycle("odd! ","even! ","what comes after even?") %>
|
59
|
-
#
|
60
|
-
# Generates:
|
61
|
-
#
|
62
|
-
# odd! even! odd!
|
63
|
-
def reset_cycle(name = :default)
|
64
|
-
(@cycle_positions[name.to_sym] = nil) &&
|
65
|
-
true if @cycle_positions && @cycle_positions[name.to_sym]
|
66
|
-
end
|
67
|
-
end
|
68
|
-
end
|
69
|
-
end
|
70
|
-
|
71
|
-
module Rango::Helpers
|
72
|
-
include Rango::Helpers::Text
|
73
|
-
end
|
data/lib/rango/loggers/logger.rb
DELETED
@@ -1,100 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
# TODO: documentation
|
4
|
-
# TODO: specs
|
5
|
-
require "logger"
|
6
|
-
|
7
|
-
module Rango
|
8
|
-
class Logger < ::Logger
|
9
|
-
# @since 0.0.1
|
10
|
-
def initialize(output = STDERR)
|
11
|
-
super(output)
|
12
|
-
self.setup
|
13
|
-
end
|
14
|
-
|
15
|
-
# @since 0.0.1
|
16
|
-
def setup
|
17
|
-
self.level = ::Logger::DEBUG
|
18
|
-
self.datetime_format = "%H:%M:%S"
|
19
|
-
self.setup_format
|
20
|
-
end
|
21
|
-
|
22
|
-
# @since 0.0.1
|
23
|
-
def exception(exception)
|
24
|
-
self.error("#{exception.message} (#{exception.class})")
|
25
|
-
exception.backtrace.each do |line|
|
26
|
-
unless line.match(/thin|eventmachine/)
|
27
|
-
STDERR.puts("- #{line.colorize.cyan}")
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
# Logger methods can takes more arguments and they returns array with arguments
|
33
|
-
# NOTE: why we dup args each time? Because we colorize messages, but if logger method
|
34
|
-
# is used for handling requests, we just need to send noncolored messages as response.
|
35
|
-
# @since 0.0.1
|
36
|
-
def debug(*args)
|
37
|
-
original = args.dup
|
38
|
-
args.map { |arg| super(arg) }
|
39
|
-
return original
|
40
|
-
end
|
41
|
-
|
42
|
-
# @since 0.0.1
|
43
|
-
def info(*args)
|
44
|
-
original = args.dup
|
45
|
-
args.map { |arg| super(arg) }
|
46
|
-
return original
|
47
|
-
end
|
48
|
-
|
49
|
-
# @since 0.0.1
|
50
|
-
def warn(*args)
|
51
|
-
original = args.dup
|
52
|
-
args.map { |arg| super(arg) }
|
53
|
-
return original
|
54
|
-
end
|
55
|
-
|
56
|
-
# @since 0.0.1
|
57
|
-
def error(*args)
|
58
|
-
original = args.dup
|
59
|
-
args.map { |arg| super(arg) }
|
60
|
-
return original
|
61
|
-
end
|
62
|
-
|
63
|
-
# @since 0.0.1
|
64
|
-
def fatal(*args)
|
65
|
-
original = args.dup
|
66
|
-
args.map { |arg| super(arg) }
|
67
|
-
return original
|
68
|
-
end
|
69
|
-
|
70
|
-
# Project.logger.inspect(@posts, item)
|
71
|
-
# Project.logger.inspect("@post" => @post)
|
72
|
-
# @since 0.0.1
|
73
|
-
def inspect(*args)
|
74
|
-
if args.first.is_a?(Hash) && args.length.eql?(1)
|
75
|
-
args.first.each do |name, value|
|
76
|
-
self.debug("#{name}: #{value.inspect}")
|
77
|
-
end
|
78
|
-
else
|
79
|
-
args = args.map { |arg| arg.inspect }
|
80
|
-
self.debug(*args)
|
81
|
-
end
|
82
|
-
end
|
83
|
-
|
84
|
-
# @since 0.0.1
|
85
|
-
def setup_format
|
86
|
-
self.formatter = lambda do |severity, datetime, progname, msg|
|
87
|
-
# logger.debug(object_to_inspect)
|
88
|
-
msg = msg.inspect unless msg.is_a?(String)
|
89
|
-
datetime = datetime.strftime("[%H:%M:%S]")
|
90
|
-
case severity
|
91
|
-
when "DEBUG" then "#{datetime} #{msg.colorize.yellow}\n"
|
92
|
-
when "INFO" then "#{datetime} #{msg.colorize.green}\n"
|
93
|
-
when "WARN" then "#{datetime} #{msg.colorize.yellow}\n"
|
94
|
-
when "ERROR" then "#{datetime} #{msg.colorize.red}\n"
|
95
|
-
when "FATAL" then "#{datetime} #{msg.colorize.red.bold}\n"
|
96
|
-
end
|
97
|
-
end
|
98
|
-
end
|
99
|
-
end
|
100
|
-
end
|
@@ -1,68 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
# from merb-core
|
4
|
-
module Rango
|
5
|
-
module Chainable
|
6
|
-
# Allows the definition of methods on a class that will be available via
|
7
|
-
# super.
|
8
|
-
#
|
9
|
-
# ==== Examples
|
10
|
-
# class Foo
|
11
|
-
# extend Rango::Chainable
|
12
|
-
# chainable do
|
13
|
-
# def hello
|
14
|
-
# "hello"
|
15
|
-
# end
|
16
|
-
# end
|
17
|
-
# end
|
18
|
-
#
|
19
|
-
# class Foo
|
20
|
-
# def hello
|
21
|
-
# super + " Merb!"
|
22
|
-
# end
|
23
|
-
# end
|
24
|
-
#
|
25
|
-
# # Example with mixin:
|
26
|
-
# module TestMixin
|
27
|
-
# extend Rango::Chainable
|
28
|
-
# chainable do
|
29
|
-
# def test
|
30
|
-
# "from mixin!"
|
31
|
-
# end
|
32
|
-
# end
|
33
|
-
# end
|
34
|
-
#
|
35
|
-
# class Test
|
36
|
-
# include TestMixin
|
37
|
-
# def test
|
38
|
-
# "hello " + super
|
39
|
-
# end
|
40
|
-
# end
|
41
|
-
#
|
42
|
-
# puts Test.new.test
|
43
|
-
#
|
44
|
-
#
|
45
|
-
# Foo.new.hello #=> "hello Merb!"
|
46
|
-
#
|
47
|
-
# ==== Parameters
|
48
|
-
# &block::
|
49
|
-
# a block containing method definitions that should be
|
50
|
-
# marked as chainable
|
51
|
-
#
|
52
|
-
# ==== Returns
|
53
|
-
# Module:: The anonymous module that was created
|
54
|
-
def chainable(method = nil, &block)
|
55
|
-
if method.nil? && block_given?
|
56
|
-
mixin = Module.new(&block)
|
57
|
-
include mixin
|
58
|
-
return mixin
|
59
|
-
elsif method && ! block_given?
|
60
|
-
# TODO
|
61
|
-
# def test
|
62
|
-
# # ...
|
63
|
-
# end
|
64
|
-
# chainable :test
|
65
|
-
end
|
66
|
-
end
|
67
|
-
end
|
68
|
-
end
|
@@ -1,32 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
# class Test
|
4
|
-
# extend Rango::Hookable
|
5
|
-
# install_hook do |instance|
|
6
|
-
# p instance
|
7
|
-
# end
|
8
|
-
#
|
9
|
-
# def initialize
|
10
|
-
# p self
|
11
|
-
# end
|
12
|
-
# end
|
13
|
-
#
|
14
|
-
# Test.new
|
15
|
-
|
16
|
-
module Rango
|
17
|
-
module Hookable
|
18
|
-
def new(*args)
|
19
|
-
instance = super(*args)
|
20
|
-
self.hooks.each { |hook| hook.call(instance) }
|
21
|
-
return instance
|
22
|
-
end
|
23
|
-
|
24
|
-
def hooks
|
25
|
-
@hooks ||= Array.new
|
26
|
-
end
|
27
|
-
|
28
|
-
def install_hook(&block)
|
29
|
-
self.hooks.push(block)
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
data/lib/rango/mixins/import.rb
DELETED
@@ -1,89 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
# boot: after rango.rb
|
4
|
-
|
5
|
-
module Rango
|
6
|
-
# This mixin will be included also to project or your custom app main namespace
|
7
|
-
module ImportMixin
|
8
|
-
# class Project
|
9
|
-
# extend Rango::ImportMixin
|
10
|
-
# end
|
11
|
-
def self.extended(base)
|
12
|
-
unless base.respond_to?(:root)
|
13
|
-
class << base
|
14
|
-
def root
|
15
|
-
File.dirname(caller[1].split(":").first)
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
# class Project
|
22
|
-
# class << self
|
23
|
-
# extend Rango::ImportMixin
|
24
|
-
# end
|
25
|
-
# end
|
26
|
-
def self.included(base)
|
27
|
-
unless base.respond_to?(:root)
|
28
|
-
base.class_eval do
|
29
|
-
def root
|
30
|
-
File.dirname(caller.last.split(":").first)
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
# @since 0.0.1
|
37
|
-
# @example
|
38
|
-
# Project.import("blog/views")
|
39
|
-
# Project.import("blog/views", soft: true)
|
40
|
-
# @param [String] path Path to file which will be loaded using +Kernel#load+ if +Project.settings.debug+ is true or +Kernel#require+ if not.
|
41
|
-
# @param [Hash[soft: Boolean(default true)], @optional] options
|
42
|
-
# @raise [LoadError] Unless <tt>soft: true</tt> option is used, it will raise +LoadError+ if the file wasn't found.
|
43
|
-
# @return [Boolean] If loading suceed.
|
44
|
-
def import(path, options = Hash.new)
|
45
|
-
# it is better than rescue LoadError, because
|
46
|
-
# LoadError can be raise inside the required file
|
47
|
-
fullpath = self.find_absolute(path)
|
48
|
-
if fullpath.nil? && options[:soft] # any file found and soft importing enabled
|
49
|
-
# do nothing
|
50
|
-
elsif fullpath.nil? && !options[:soft] # any file found and soft importing disabled
|
51
|
-
raise LoadError, "File #{path.inspect} (treated as #{fullpath.inspect}) doesn't exist"
|
52
|
-
elsif !fullpath.nil? # the file was found
|
53
|
-
Kernel.load(fullpath)
|
54
|
-
elsif !fullpath.nil? # the file was found
|
55
|
-
Kernel.require(fullpath)
|
56
|
-
end
|
57
|
-
end
|
58
|
-
|
59
|
-
# @since 0.0.2
|
60
|
-
def import_first(paths, options = Hash.new)
|
61
|
-
paths.each do |path|
|
62
|
-
fullpath = self.find_absolute(path)
|
63
|
-
next if fullpath.nil?
|
64
|
-
return self.import(fullpath, options)
|
65
|
-
end
|
66
|
-
raise LoadError unless options[:soft]
|
67
|
-
end
|
68
|
-
|
69
|
-
# @since 0.0.1
|
70
|
-
# @param [String] path Path to loaded file.
|
71
|
-
# @return [Boolean] If the loading was successful.
|
72
|
-
def import!(path)
|
73
|
-
path = File.join(self.root, path)
|
74
|
-
file = self.find_absolute(path)
|
75
|
-
Kernel.load(file)
|
76
|
-
end
|
77
|
-
|
78
|
-
def find(file)
|
79
|
-
["#{file}.rb", file].find do |file|
|
80
|
-
File.exist?(file)
|
81
|
-
end
|
82
|
-
end
|
83
|
-
|
84
|
-
def find_absolute(file)
|
85
|
-
file = File.join(self.root, file) unless file.match(%r[^/])
|
86
|
-
self.find(file)
|
87
|
-
end
|
88
|
-
end
|
89
|
-
end
|