rango 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +8 -0
- data/LICENSE +20 -0
- data/README.textile +18 -0
- data/bin/rango +30 -0
- data/doc/head/Array.html +114 -0
- data/doc/head/AttributeMixin.html +613 -0
- data/doc/head/Class.html +102 -0
- data/doc/head/ColoredString.html +476 -0
- data/doc/head/Hash.html +643 -0
- data/doc/head/Kernel.html +641 -0
- data/doc/head/Object.html +140 -0
- data/doc/head/ObjectSpace.html +103 -0
- data/doc/head/Path.html +2499 -0
- data/doc/head/Range.html +109 -0
- data/doc/head/Rango.html +397 -0
- data/doc/head/Rango/ApplicationMixin.html +396 -0
- data/doc/head/Rango/Bundling.html +23 -0
- data/doc/head/Rango/Bundling/RequireStrategy.html +283 -0
- data/doc/head/Rango/Bundling/Strategy.html +703 -0
- data/doc/head/Rango/CallableStrategy.html +300 -0
- data/doc/head/Rango/Chainable.html +181 -0
- data/doc/head/Rango/Configurable.html +199 -0
- data/doc/head/Rango/Controller.html +962 -0
- data/doc/head/Rango/ControllerMixin.html +860 -0
- data/doc/head/Rango/ControllerStrategy.html +264 -0
- data/doc/head/Rango/DependencyStrategy.html +116 -0
- data/doc/head/Rango/Dispatcher.html +305 -0
- data/doc/head/Rango/Form.html +162 -0
- data/doc/head/Rango/GemDependencyStrategy.html +210 -0
- data/doc/head/Rango/Generator.html +93 -0
- data/doc/head/Rango/GenericViews.html +128 -0
- data/doc/head/Rango/GitDependencyStrategy.html +224 -0
- data/doc/head/Rango/GithubDependencyStrategy.html +118 -0
- data/doc/head/Rango/Handler.html +474 -0
- data/doc/head/Rango/Helpers.html +1271 -0
- data/doc/head/Rango/Hookable.html +202 -0
- data/doc/head/Rango/ImportMixin.html +755 -0
- data/doc/head/Rango/Logger.html +920 -0
- data/doc/head/Rango/ModelForm.html +42 -0
- data/doc/head/Rango/Project.html +516 -0
- data/doc/head/Rango/RenderMixin.html +23 -0
- data/doc/head/Rango/Request.html +1177 -0
- data/doc/head/Rango/Route.html +751 -0
- data/doc/head/Rango/Router.html +42 -0
- data/doc/head/Rango/Router/Dispatcher.html +311 -0
- data/doc/head/Rango/RouterStrategy.html +258 -0
- data/doc/head/Rango/Session.html +23 -0
- data/doc/head/Rango/Settings.html +23 -0
- data/doc/head/Rango/Settings/Erubis.html +23 -0
- data/doc/head/Rango/Settings/Framework.html +198 -0
- data/doc/head/Rango/Settings/Haml.html +23 -0
- data/doc/head/Rango/SimpleTemplate.html +187 -0
- data/doc/head/Rango/StrategyMixin.html +261 -0
- data/doc/head/Rango/Tasks.html +251 -0
- data/doc/head/Rango/Template.html +95 -0
- data/doc/head/Rango/Template/Adapter.html +90 -0
- data/doc/head/Rango/Templates.html +116 -0
- data/doc/head/Rango/Templates/Adapter.html +128 -0
- data/doc/head/Rango/Templates/Template.html +636 -0
- data/doc/head/Rango/Templates/TemplateHelpers.html +328 -0
- data/doc/head/RangoThor.html +205 -0
- data/doc/head/String.html +163 -0
- data/doc/head/TimeDSL.html +612 -0
- data/doc/head/all-methods.html +2012 -0
- data/doc/head/all-namespaces.html +114 -0
- data/doc/head/app.js +18 -0
- data/doc/head/index.html +18 -0
- data/doc/head/jquery.js +11 -0
- data/doc/head/readme.html +34 -0
- data/doc/head/style.css +68 -0
- data/doc/head/syntax_highlight.css +21 -0
- data/doc/versions/0.0.1/Rango.html +1025 -0
- data/doc/versions/0.0.1/Rango/CallableStrategy.html +166 -0
- data/doc/versions/0.0.1/Rango/ControllerStrategy.html +180 -0
- data/doc/versions/0.0.1/Rango/Route.html +340 -0
- data/doc/versions/0.0.1/Rango/Router.html +502 -0
- data/doc/versions/0.0.1/Rango/RouterStrategy.html +94 -0
- data/doc/versions/0.0.1/Rango/Template.html +28 -0
- data/doc/versions/0.0.1/Rango/Template/Adapter.html +90 -0
- data/doc/versions/0.0.1/all-methods.html +228 -0
- data/doc/versions/0.0.1/all-namespaces.html +36 -0
- data/doc/versions/0.0.1/app.js +18 -0
- data/doc/versions/0.0.1/index.html +18 -0
- data/doc/versions/0.0.1/jquery.js +11 -0
- data/doc/versions/0.0.1/readme.html +137 -0
- data/doc/versions/0.0.1/style.css +68 -0
- data/doc/versions/0.0.1/syntax_highlight.css +21 -0
- data/lib/rango.rb +25 -0
- data/lib/rango/boot.rb +54 -0
- data/lib/rango/bundling/dependency.rb +65 -0
- data/lib/rango/bundling/strategies/copy.rb +36 -0
- data/lib/rango/bundling/strategies/gem.rb +55 -0
- data/lib/rango/bundling/strategies/git.rb +71 -0
- data/lib/rango/bundling/strategies/hg.rb +9 -0
- data/lib/rango/bundling/strategy.rb +85 -0
- data/lib/rango/cli/generator.rb +15 -0
- data/lib/rango/cli/project.rb +87 -0
- data/lib/rango/cli/simple_template.rb +47 -0
- data/lib/rango/contrib/pagination.rb +15 -0
- data/lib/rango/contrib/pagination/README.textile +21 -0
- data/lib/rango/contrib/pagination/TODO +3 -0
- data/lib/rango/contrib/pagination/_pagination.html.haml +39 -0
- data/lib/rango/contrib/pagination/adapters/datamapper.rb +22 -0
- data/lib/rango/contrib/pagination/helpers.rb +12 -0
- data/lib/rango/contrib/pagination/page.rb +107 -0
- data/lib/rango/contrib/pagination/strategies.rb +49 -0
- data/lib/rango/contrib/syndication.rb +1 -0
- data/lib/rango/exceptions.rb +269 -0
- data/lib/rango/ext.rb +14 -0
- data/lib/rango/ext/attribute.rb +140 -0
- data/lib/rango/ext/class.rb +99 -0
- data/lib/rango/ext/colored_string.rb +105 -0
- data/lib/rango/ext/core_ext.rb +52 -0
- data/lib/rango/ext/hash.rb +21 -0
- data/lib/rango/ext/kernel.rb +74 -0
- data/lib/rango/ext/object_space.rb +11 -0
- data/lib/rango/ext/path.rb +222 -0
- data/lib/rango/ext/random.rb +22 -0
- data/lib/rango/ext/string.rb +16 -0
- data/lib/rango/ext/thor.rb +32 -0
- data/lib/rango/ext/time_dsl.rb +63 -0
- data/lib/rango/ext/try.rb +30 -0
- data/lib/rango/forms/form.rb +29 -0
- data/lib/rango/generic_views/static.rb +7 -0
- data/lib/rango/helpers.rb +24 -0
- data/lib/rango/helpers/README +179 -0
- data/lib/rango/helpers/assets.rb +29 -0
- data/lib/rango/helpers/general.rb +41 -0
- data/lib/rango/helpers/merb-helpers.rb +40 -0
- data/lib/rango/helpers/merb-helpers/core_ext.rb +58 -0
- data/lib/rango/helpers/merb-helpers/core_ext/numeric.rb +388 -0
- data/lib/rango/helpers/merb-helpers/date_time_formatting.rb +158 -0
- data/lib/rango/helpers/merb-helpers/date_time_helpers.rb +191 -0
- data/lib/rango/helpers/merb-helpers/form/builder.rb +447 -0
- data/lib/rango/helpers/merb-helpers/form/helpers.rb +451 -0
- data/lib/rango/helpers/merb-helpers/form_helpers.rb +19 -0
- data/lib/rango/helpers/merb-helpers/tag_helpers.rb +63 -0
- data/lib/rango/helpers/merb-helpers/text_helpers.rb +63 -0
- data/lib/rango/helpers/merb-helpers/time_dsl.rb +61 -0
- data/lib/rango/helpers/spec/core_ext_spec.rb +21 -0
- data/lib/rango/helpers/spec/fixture/app/controllers/application.rb +4 -0
- data/lib/rango/helpers/spec/fixture/app/controllers/bound_check_box.rb +2 -0
- data/lib/rango/helpers/spec/fixture/app/controllers/bound_file_field.rb +2 -0
- data/lib/rango/helpers/spec/fixture/app/controllers/bound_hidden_field.rb +2 -0
- data/lib/rango/helpers/spec/fixture/app/controllers/bound_option_tag.rb +2 -0
- data/lib/rango/helpers/spec/fixture/app/controllers/bound_password_field.rb +2 -0
- data/lib/rango/helpers/spec/fixture/app/controllers/bound_radio_button.rb +2 -0
- data/lib/rango/helpers/spec/fixture/app/controllers/bound_radio_group.rb +2 -0
- data/lib/rango/helpers/spec/fixture/app/controllers/bound_select.rb +2 -0
- data/lib/rango/helpers/spec/fixture/app/controllers/bound_text_area.rb +2 -0
- data/lib/rango/helpers/spec/fixture/app/controllers/bound_text_field.rb +2 -0
- data/lib/rango/helpers/spec/fixture/app/controllers/button.rb +2 -0
- data/lib/rango/helpers/spec/fixture/app/controllers/check_box.rb +2 -0
- data/lib/rango/helpers/spec/fixture/app/controllers/custom_builder.rb +2 -0
- data/lib/rango/helpers/spec/fixture/app/controllers/delete_button.rb +2 -0
- data/lib/rango/helpers/spec/fixture/app/controllers/exceptions.rb +25 -0
- data/lib/rango/helpers/spec/fixture/app/controllers/field_set.rb +2 -0
- data/lib/rango/helpers/spec/fixture/app/controllers/fields_for.rb +3 -0
- data/lib/rango/helpers/spec/fixture/app/controllers/file_field.rb +2 -0
- data/lib/rango/helpers/spec/fixture/app/controllers/foo.rb +23 -0
- data/lib/rango/helpers/spec/fixture/app/controllers/form.rb +2 -0
- data/lib/rango/helpers/spec/fixture/app/controllers/form_for.rb +2 -0
- data/lib/rango/helpers/spec/fixture/app/controllers/hacker.rb +2 -0
- data/lib/rango/helpers/spec/fixture/app/controllers/hidden_field.rb +2 -0
- data/lib/rango/helpers/spec/fixture/app/controllers/label.rb +3 -0
- data/lib/rango/helpers/spec/fixture/app/controllers/numeric_ext.rb +3 -0
- data/lib/rango/helpers/spec/fixture/app/controllers/option_tag.rb +2 -0
- data/lib/rango/helpers/spec/fixture/app/controllers/password_field.rb +2 -0
- data/lib/rango/helpers/spec/fixture/app/controllers/radio_button.rb +2 -0
- data/lib/rango/helpers/spec/fixture/app/controllers/radio_group.rb +2 -0
- data/lib/rango/helpers/spec/fixture/app/controllers/relative_date.rb +2 -0
- data/lib/rango/helpers/spec/fixture/app/controllers/relative_date_span.rb +2 -0
- data/lib/rango/helpers/spec/fixture/app/controllers/select.rb +2 -0
- data/lib/rango/helpers/spec/fixture/app/controllers/specs_controller.rb +11 -0
- data/lib/rango/helpers/spec/fixture/app/controllers/submit.rb +2 -0
- data/lib/rango/helpers/spec/fixture/app/controllers/tag_helper.rb +21 -0
- data/lib/rango/helpers/spec/fixture/app/controllers/text_area.rb +2 -0
- data/lib/rango/helpers/spec/fixture/app/controllers/text_field.rb +3 -0
- data/lib/rango/helpers/spec/fixture/app/helpers/global_helpers.rb +8 -0
- data/lib/rango/helpers/spec/fixture/app/models/fake_dm_model.rb +25 -0
- data/lib/rango/helpers/spec/fixture/app/models/first_generic_fake_model.rb +57 -0
- data/lib/rango/helpers/spec/fixture/app/models/hacker_generic_model.rb +5 -0
- data/lib/rango/helpers/spec/fixture/app/models/second_generic_fake_model.rb +18 -0
- data/lib/rango/helpers/spec/fixture/app/models/third_generic_fake_model.rb +3 -0
- data/lib/rango/helpers/spec/fixture/app/views/bound_check_box_specs/basic.html.erb +4 -0
- data/lib/rango/helpers/spec/fixture/app/views/bound_check_box_specs/basic_unchecked.html.erb +3 -0
- data/lib/rango/helpers/spec/fixture/app/views/bound_check_box_specs/checked.html.erb +4 -0
- data/lib/rango/helpers/spec/fixture/app/views/bound_check_box_specs/errors.html.erb +4 -0
- data/lib/rango/helpers/spec/fixture/app/views/bound_check_box_specs/label.html.erb +3 -0
- data/lib/rango/helpers/spec/fixture/app/views/bound_check_box_specs/on_and_off.html.erb +3 -0
- data/lib/rango/helpers/spec/fixture/app/views/bound_check_box_specs/raise_value_error.html.erb +3 -0
- data/lib/rango/helpers/spec/fixture/app/views/bound_file_field_specs/additional_attributes.html.erb +3 -0
- data/lib/rango/helpers/spec/fixture/app/views/bound_file_field_specs/takes_string.html.erb +3 -0
- data/lib/rango/helpers/spec/fixture/app/views/bound_file_field_specs/with_label.html.erb +3 -0
- data/lib/rango/helpers/spec/fixture/app/views/bound_hidden_field_specs/basic.html.erb +3 -0
- data/lib/rango/helpers/spec/fixture/app/views/bound_hidden_field_specs/errors.html.erb +3 -0
- data/lib/rango/helpers/spec/fixture/app/views/bound_hidden_field_specs/hidden_error.html.erb +3 -0
- data/lib/rango/helpers/spec/fixture/app/views/bound_hidden_field_specs/label.html.erb +3 -0
- data/lib/rango/helpers/spec/fixture/app/views/bound_option_tag_specs/grouped.html.erb +3 -0
- data/lib/rango/helpers/spec/fixture/app/views/bound_option_tag_specs/nested.html.erb +3 -0
- data/lib/rango/helpers/spec/fixture/app/views/bound_option_tag_specs/text_and_value.html.erb +4 -0
- data/lib/rango/helpers/spec/fixture/app/views/bound_password_field_specs/attributes.html.erb +3 -0
- data/lib/rango/helpers/spec/fixture/app/views/bound_password_field_specs/basic.html.erb +3 -0
- data/lib/rango/helpers/spec/fixture/app/views/bound_password_field_specs/label.html.erb +3 -0
- data/lib/rango/helpers/spec/fixture/app/views/bound_radio_button_specs/basic.html.erb +3 -0
- data/lib/rango/helpers/spec/fixture/app/views/bound_radio_group_specs/basic.html.erb +3 -0
- data/lib/rango/helpers/spec/fixture/app/views/bound_radio_group_specs/hashes.html.erb +3 -0
- data/lib/rango/helpers/spec/fixture/app/views/bound_radio_group_specs/mixed.html.erb +4 -0
- data/lib/rango/helpers/spec/fixture/app/views/bound_radio_group_specs/override_id.html.erb +3 -0
- data/lib/rango/helpers/spec/fixture/app/views/bound_select_specs/basic.html.erb +3 -0
- data/lib/rango/helpers/spec/fixture/app/views/bound_select_specs/blank.html.erb +3 -0
- data/lib/rango/helpers/spec/fixture/app/views/bound_select_specs/label.html.erb +3 -0
- data/lib/rango/helpers/spec/fixture/app/views/bound_select_specs/multiple.html.erb +3 -0
- data/lib/rango/helpers/spec/fixture/app/views/bound_select_specs/prompt.html.erb +3 -0
- data/lib/rango/helpers/spec/fixture/app/views/bound_select_specs/with_options.html.erb +3 -0
- data/lib/rango/helpers/spec/fixture/app/views/bound_select_specs/with_options_with_blank.html.erb +3 -0
- data/lib/rango/helpers/spec/fixture/app/views/bound_text_area_specs/basic.html.erb +3 -0
- data/lib/rango/helpers/spec/fixture/app/views/bound_text_area_specs/label.html.erb +3 -0
- data/lib/rango/helpers/spec/fixture/app/views/bound_text_field_specs/basic.html.erb +3 -0
- data/lib/rango/helpers/spec/fixture/app/views/button_specs/button_with_label.html.erb +1 -0
- data/lib/rango/helpers/spec/fixture/app/views/button_specs/button_with_values.html.erb +1 -0
- data/lib/rango/helpers/spec/fixture/app/views/button_specs/disabled_button.html.erb +1 -0
- data/lib/rango/helpers/spec/fixture/app/views/check_box_specs/basic.html.erb +1 -0
- data/lib/rango/helpers/spec/fixture/app/views/check_box_specs/boolean.html.erb +1 -0
- data/lib/rango/helpers/spec/fixture/app/views/check_box_specs/disabled.html.erb +1 -0
- data/lib/rango/helpers/spec/fixture/app/views/check_box_specs/label.html.erb +1 -0
- data/lib/rango/helpers/spec/fixture/app/views/check_box_specs/on_off_is_boolean.html.erb +1 -0
- data/lib/rango/helpers/spec/fixture/app/views/check_box_specs/raise_unless_both_on_and_off.html.erb +2 -0
- data/lib/rango/helpers/spec/fixture/app/views/check_box_specs/raises_error_if_not_boolean.html.erb +1 -0
- data/lib/rango/helpers/spec/fixture/app/views/check_box_specs/raises_error_if_on_off_and_boolean_false.html.erb +1 -0
- data/lib/rango/helpers/spec/fixture/app/views/check_box_specs/simple.html.erb +1 -0
- data/lib/rango/helpers/spec/fixture/app/views/check_box_specs/to_string.html.erb +8 -0
- data/lib/rango/helpers/spec/fixture/app/views/check_box_specs/unchecked.html.erb +2 -0
- data/lib/rango/helpers/spec/fixture/app/views/custom_builder_specs/everything.html.erb +10 -0
- data/lib/rango/helpers/spec/fixture/app/views/delete_button_specs/delete_with_explicit_url.html.erb +1 -0
- data/lib/rango/helpers/spec/fixture/app/views/delete_button_specs/delete_with_extra_params.html.erb +1 -0
- data/lib/rango/helpers/spec/fixture/app/views/delete_button_specs/delete_with_label.html.erb +1 -0
- data/lib/rango/helpers/spec/fixture/app/views/delete_button_specs/simple_delete.html.erb +1 -0
- data/lib/rango/helpers/spec/fixture/app/views/exeptions/client_error.html.erb +37 -0
- data/lib/rango/helpers/spec/fixture/app/views/exeptions/internal_server_error.html.erb +216 -0
- data/lib/rango/helpers/spec/fixture/app/views/exeptions/not_acceptable.html.erb +38 -0
- data/lib/rango/helpers/spec/fixture/app/views/exeptions/not_found.html.erb +40 -0
- data/lib/rango/helpers/spec/fixture/app/views/fields_for_specs/basic.html.erb +3 -0
- data/lib/rango/helpers/spec/fixture/app/views/fields_for_specs/midstream.html.erb +7 -0
- data/lib/rango/helpers/spec/fixture/app/views/fields_for_specs/nil.html.erb +3 -0
- data/lib/rango/helpers/spec/fixture/app/views/fieldset_specs/legend.html.erb +3 -0
- data/lib/rango/helpers/spec/fixture/app/views/file_field_specs/disabled.html.erb +1 -0
- data/lib/rango/helpers/spec/fixture/app/views/file_field_specs/makes_multipart.html.erb +3 -0
- data/lib/rango/helpers/spec/fixture/app/views/file_field_specs/with_label.html.erb +1 -0
- data/lib/rango/helpers/spec/fixture/app/views/file_field_specs/with_values.html.erb +1 -0
- data/lib/rango/helpers/spec/fixture/app/views/foo/bar.html.erb +0 -0
- data/lib/rango/helpers/spec/fixture/app/views/form_for_specs/basic.html.erb +3 -0
- data/lib/rango/helpers/spec/fixture/app/views/form_specs/create_a_form.html.erb +3 -0
- data/lib/rango/helpers/spec/fixture/app/views/form_specs/create_a_multipart_form.html.erb +3 -0
- data/lib/rango/helpers/spec/fixture/app/views/form_specs/fake_delete_if_set.html.erb +3 -0
- data/lib/rango/helpers/spec/fixture/app/views/form_specs/fake_put_if_set.html.erb +3 -0
- data/lib/rango/helpers/spec/fixture/app/views/form_specs/get_if_set.html.erb +3 -0
- data/lib/rango/helpers/spec/fixture/app/views/form_specs/post_by_default.html.erb +3 -0
- data/lib/rango/helpers/spec/fixture/app/views/form_specs/resourceful_form.html.erb +3 -0
- data/lib/rango/helpers/spec/fixture/app/views/hacker/file_field.html.erb +3 -0
- data/lib/rango/helpers/spec/fixture/app/views/hacker/hidden_field.html.erb +3 -0
- data/lib/rango/helpers/spec/fixture/app/views/hacker/option_tag.html.erb +4 -0
- data/lib/rango/helpers/spec/fixture/app/views/hacker/password_field.html.erb +3 -0
- data/lib/rango/helpers/spec/fixture/app/views/hacker/radio_button.html.erb +3 -0
- data/lib/rango/helpers/spec/fixture/app/views/hacker/radio_group.html.erb +3 -0
- data/lib/rango/helpers/spec/fixture/app/views/hacker/text_area.html.erb +3 -0
- data/lib/rango/helpers/spec/fixture/app/views/hacker/text_field.html.erb +3 -0
- data/lib/rango/helpers/spec/fixture/app/views/hidden_field_specs/basic.html.erb +1 -0
- data/lib/rango/helpers/spec/fixture/app/views/hidden_field_specs/disabled.html.erb +1 -0
- data/lib/rango/helpers/spec/fixture/app/views/hidden_field_specs/label.html.erb +1 -0
- data/lib/rango/helpers/spec/fixture/app/views/label_specs/basic.html.erb +1 -0
- data/lib/rango/helpers/spec/fixture/app/views/label_specs/basic_with_attributes.html.erb +1 -0
- data/lib/rango/helpers/spec/fixture/app/views/label_specs/basic_with_class.html.erb +1 -0
- data/lib/rango/helpers/spec/fixture/app/views/layout/application.html.erb +11 -0
- data/lib/rango/helpers/spec/fixture/app/views/numeric_ext_specs/minutes_to_hours.html.erb +1 -0
- data/lib/rango/helpers/spec/fixture/app/views/numeric_ext_specs/to_concurrency_default.html.erb +1 -0
- data/lib/rango/helpers/spec/fixture/app/views/numeric_ext_specs/two_digits.html.erb +1 -0
- data/lib/rango/helpers/spec/fixture/app/views/option_tag_specs/array.html.erb +1 -0
- data/lib/rango/helpers/spec/fixture/app/views/option_tag_specs/clean.html.erb +1 -0
- data/lib/rango/helpers/spec/fixture/app/views/option_tag_specs/collection.html.erb +1 -0
- data/lib/rango/helpers/spec/fixture/app/views/option_tag_specs/multiple_selects.html.erb +1 -0
- data/lib/rango/helpers/spec/fixture/app/views/option_tag_specs/no_extra_attributes.html.erb +1 -0
- data/lib/rango/helpers/spec/fixture/app/views/option_tag_specs/optgroups.html.erb +1 -0
- data/lib/rango/helpers/spec/fixture/app/views/option_tag_specs/selected.html.erb +1 -0
- data/lib/rango/helpers/spec/fixture/app/views/option_tag_specs/with_blank.html.erb +1 -0
- data/lib/rango/helpers/spec/fixture/app/views/option_tag_specs/with_prompt.html.erb +1 -0
- data/lib/rango/helpers/spec/fixture/app/views/password_field_specs/basic.html.erb +1 -0
- data/lib/rango/helpers/spec/fixture/app/views/password_field_specs/disabled.html.erb +1 -0
- data/lib/rango/helpers/spec/fixture/app/views/radio_button_specs/basic.html.erb +1 -0
- data/lib/rango/helpers/spec/fixture/app/views/radio_button_specs/checked.html.erb +1 -0
- data/lib/rango/helpers/spec/fixture/app/views/radio_button_specs/disabled.html.erb +1 -0
- data/lib/rango/helpers/spec/fixture/app/views/radio_button_specs/label.html.erb +1 -0
- data/lib/rango/helpers/spec/fixture/app/views/radio_button_specs/unchecked.html.erb +1 -0
- data/lib/rango/helpers/spec/fixture/app/views/radio_group_specs/attributes.html.erb +1 -0
- data/lib/rango/helpers/spec/fixture/app/views/radio_group_specs/basic.html.erb +1 -0
- data/lib/rango/helpers/spec/fixture/app/views/radio_group_specs/checked.html.erb +1 -0
- data/lib/rango/helpers/spec/fixture/app/views/radio_group_specs/hash.html.erb +1 -0
- data/lib/rango/helpers/spec/fixture/app/views/radio_group_specs/specific_attributes.html.erb +1 -0
- data/lib/rango/helpers/spec/fixture/app/views/relative_date_span_specs/date_span_on_same_day.html.erb +1 -0
- data/lib/rango/helpers/spec/fixture/app/views/relative_date_span_specs/date_span_on_same_day_on_different_year.html.erb +1 -0
- data/lib/rango/helpers/spec/fixture/app/views/relative_date_specs/relative_date_with_year.html.erb +1 -0
- data/lib/rango/helpers/spec/fixture/app/views/relative_date_specs/relative_date_without_year.html.erb +1 -0
- data/lib/rango/helpers/spec/fixture/app/views/relative_date_specs/relative_today.html.erb +1 -0
- data/lib/rango/helpers/spec/fixture/app/views/relative_date_specs/relative_tomorrow.html.erb +1 -0
- data/lib/rango/helpers/spec/fixture/app/views/relative_date_specs/relative_yesterday.html.erb +1 -0
- data/lib/rango/helpers/spec/fixture/app/views/select_specs/basic.html.erb +1 -0
- data/lib/rango/helpers/spec/fixture/app/views/select_specs/blank.html.erb +1 -0
- data/lib/rango/helpers/spec/fixture/app/views/select_specs/multiple.html.erb +1 -0
- data/lib/rango/helpers/spec/fixture/app/views/select_specs/selected.html.erb +1 -0
- data/lib/rango/helpers/spec/fixture/app/views/submit_specs/disabled_submit.html.erb +1 -0
- data/lib/rango/helpers/spec/fixture/app/views/submit_specs/submit_with_label.html.erb +1 -0
- data/lib/rango/helpers/spec/fixture/app/views/submit_specs/submit_with_values.html.erb +1 -0
- data/lib/rango/helpers/spec/fixture/app/views/tag_helper/nested_tags.html.erb +5 -0
- data/lib/rango/helpers/spec/fixture/app/views/tag_helper/tag_with_attributes.html.erb +1 -0
- data/lib/rango/helpers/spec/fixture/app/views/tag_helper/tag_with_content.html.erb +1 -0
- data/lib/rango/helpers/spec/fixture/app/views/tag_helper/tag_with_content_in_the_block.html.erb +3 -0
- data/lib/rango/helpers/spec/fixture/app/views/text_area_specs/basic.html.erb +1 -0
- data/lib/rango/helpers/spec/fixture/app/views/text_area_specs/disabled.html.erb +1 -0
- data/lib/rango/helpers/spec/fixture/app/views/text_area_specs/label.html.erb +1 -0
- data/lib/rango/helpers/spec/fixture/app/views/text_area_specs/nil.html.erb +1 -0
- data/lib/rango/helpers/spec/fixture/app/views/text_field_specs/basic.html.erb +1 -0
- data/lib/rango/helpers/spec/fixture/app/views/text_field_specs/class.html.erb +1 -0
- data/lib/rango/helpers/spec/fixture/app/views/text_field_specs/disabled.html.erb +1 -0
- data/lib/rango/helpers/spec/fixture/app/views/text_field_specs/label.html.erb +1 -0
- data/lib/rango/helpers/spec/fixture/app/views/text_field_specs/symbolized_name.html.erb +1 -0
- data/lib/rango/helpers/spec/fixture/config/environments/development.rb +6 -0
- data/lib/rango/helpers/spec/fixture/config/environments/production.rb +5 -0
- data/lib/rango/helpers/spec/fixture/config/environments/test.rb +6 -0
- data/lib/rango/helpers/spec/fixture/config/init.rb +46 -0
- data/lib/rango/helpers/spec/fixture/config/rack.rb +11 -0
- data/lib/rango/helpers/spec/fixture/config/router.rb +38 -0
- data/lib/rango/helpers/spec/fixture/public/images/merb.jpg +0 -0
- data/lib/rango/helpers/spec/fixture/public/merb.fcgi +4 -0
- data/lib/rango/helpers/spec/fixture/public/stylesheets/master.css +119 -0
- data/lib/rango/helpers/spec/merb_helpers_config_spec.rb +84 -0
- data/lib/rango/helpers/spec/merb_helpers_date_time_spec.rb +270 -0
- data/lib/rango/helpers/spec/merb_helpers_form_spec.rb +1371 -0
- data/lib/rango/helpers/spec/merb_helpers_tag_helper_spec.rb +42 -0
- data/lib/rango/helpers/spec/merb_helpers_text_spec.rb +69 -0
- data/lib/rango/helpers/spec/numeric_extlib_spec.rb +137 -0
- data/lib/rango/helpers/spec/ordinalize_spec.rb +53 -0
- data/lib/rango/helpers/spec/spec_helper.rb +160 -0
- data/lib/rango/helpers/spec/time_dsl_spec.rb +45 -0
- data/lib/rango/helpers/syntax.rb +28 -0
- data/lib/rango/loggers/fireruby.rb +1 -0
- data/lib/rango/loggers/logger.rb +100 -0
- data/lib/rango/mixins/application.rb +25 -0
- data/lib/rango/mixins/configurable.rb +20 -0
- data/lib/rango/mixins/controller.rb +113 -0
- data/lib/rango/mixins/import.rb +89 -0
- data/lib/rango/mixins/strategy.rb +28 -0
- data/lib/rango/mvc/controller.rb +139 -0
- data/lib/rango/mvc/strategies.rb +6 -0
- data/lib/rango/orm/adapters/datamapper/fields.rb +3 -0
- data/lib/rango/orm/adapters/datamapper/setup.rb +16 -0
- data/lib/rango/orm/adapters/datamapper/support.rb +15 -0
- data/lib/rango/orm/adapters/datamapper/tasks.thor +41 -0
- data/lib/rango/orm/adapters/datamapper/types/unicode_string.rb +15 -0
- data/lib/rango/project.rb +28 -0
- data/lib/rango/rack/dispatcher.rb +61 -0
- data/lib/rango/rack/middlewares/emails.rb +7 -0
- data/lib/rango/rack/middlewares/encoding.rb +25 -0
- data/lib/rango/rack/middlewares/static.rb +49 -0
- data/lib/rango/rack/request.rb +166 -0
- data/lib/rango/rango.rb +75 -0
- data/lib/rango/router/adapters/basic.rb +21 -0
- data/lib/rango/router/adapters/rack-router.rb +18 -0
- data/lib/rango/router/dispatcher.rb +29 -0
- data/lib/rango/router/specification.txt +16 -0
- data/lib/rango/settings.rb +87 -0
- data/lib/rango/settings/erubis.rb +13 -0
- data/lib/rango/settings/framework.rb +85 -0
- data/lib/rango/settings/haml.rb +35 -0
- data/lib/rango/support/cucumber/steps/given_steps.rb +5 -0
- data/lib/rango/support/cucumber/steps/then_steps.rb +41 -0
- data/lib/rango/support/cucumber/steps/when_steps.rb +54 -0
- data/lib/rango/tasks/bundle.thor +28 -0
- data/lib/rango/tasks/stats.thor +0 -0
- data/lib/rango/templates/adapter.rb +19 -0
- data/lib/rango/templates/adapters/erb.rb +45 -0
- data/lib/rango/templates/adapters/erubis.rb +60 -0
- data/lib/rango/templates/adapters/haml.rb +17 -0
- data/lib/rango/templates/template.rb +123 -0
- data/rango.gemspec +35 -0
- data/spec/factories.rb +21 -0
- data/spec/rango/auth/core/authenticated_helper_spec.rb +0 -0
- data/spec/rango/auth/core/authentication_spec.rb +0 -0
- data/spec/rango/auth/core/callbacks_spec.rb +0 -0
- data/spec/rango/auth/core/errors_spec.rb +0 -0
- data/spec/rango/auth/core/responses_spec.rb +0 -0
- data/spec/rango/auth/core/session_mixin_spec.rb +0 -0
- data/spec/rango/auth/core/spec/helpers/authentication_helper_spec_spec.rb +0 -0
- data/spec/rango/auth/core/spec/merb-auth-core/activation_fixture_spec.rb +0 -0
- data/spec/rango/auth/core/spec/merb-auth-core/authentication_spec_spec.rb +0 -0
- data/spec/rango/auth/core/spec/merb-auth-core/callbacks_spec_spec.rb +0 -0
- data/spec/rango/auth/core/spec/merb-auth-core/customizations_spec_spec.rb +0 -0
- data/spec/rango/auth/core/spec/merb-auth-core/errors_spec_spec.rb +0 -0
- data/spec/rango/auth/core/spec/merb-auth-core/failed_login_spec_spec.rb +0 -0
- data/spec/rango/auth/core/spec/merb-auth-core/merb-auth-core_spec_spec.rb +0 -0
- data/spec/rango/auth/core/spec/merb-auth-core/router_helper_spec_spec.rb +0 -0
- data/spec/rango/auth/core/spec/merb-auth-core/strategy_spec_spec.rb +0 -0
- data/spec/rango/auth/core/spec/spec_helper_spec.rb +0 -0
- data/spec/rango/auth/core/strategy_spec.rb +0 -0
- data/spec/rango/auth/core_spec.rb +0 -0
- data/spec/rango/auth/more/mixins/redirect_back_spec.rb +0 -0
- data/spec/rango/auth/more/mixins/salted_user/ar_salted_user_spec.rb +0 -0
- data/spec/rango/auth/more/mixins/salted_user/dm_salted_user_spec.rb +0 -0
- data/spec/rango/auth/more/mixins/salted_user/relaxdb_salted_user_spec.rb +0 -0
- data/spec/rango/auth/more/mixins/salted_user/sq_salted_user_spec.rb +0 -0
- data/spec/rango/auth/more/mixins/salted_user_spec.rb +0 -0
- data/spec/rango/auth/more/spec/merb-auth-more_spec_spec.rb +0 -0
- data/spec/rango/auth/more/spec/mixins/redirect_back_spec_spec.rb +0 -0
- data/spec/rango/auth/more/spec/mixins/salted_user_spec_spec.rb +0 -0
- data/spec/rango/auth/more/spec/spec_helper_spec.rb +0 -0
- data/spec/rango/auth/more/strategies/abstract_password_spec.rb +0 -0
- data/spec/rango/auth/more/strategies/basic/basic_auth_spec.rb +0 -0
- data/spec/rango/auth/more/strategies/basic/openid_spec.rb +0 -0
- data/spec/rango/auth/more/strategies/basic/password_form_spec.rb +0 -0
- data/spec/rango/auth/more_spec.rb +0 -0
- data/spec/rango/auth/slice/exceptions_spec.rb +0 -0
- data/spec/rango/auth/slice/merb-auth-slice-password_spec.rb +0 -0
- data/spec/rango/auth/slice/sessions_spec.rb +0 -0
- data/spec/rango/auth/slice/spec_helper_spec.rb +0 -0
- data/spec/rango/auth/slice/xsessions_spec.rb +0 -0
- data/spec/rango/boot_spec.rb +19 -0
- data/spec/rango/bundling/dependency_spec.rb +0 -0
- data/spec/rango/bundling/strategies_spec.rb +0 -0
- data/spec/rango/cli/project_spec.rb +0 -0
- data/spec/rango/contrib/pagination/adapters/dm_spec.rb +0 -0
- data/spec/rango/contrib/pagination/helpers_spec.rb +0 -0
- data/spec/rango/contrib/pagination/page_spec.rb +94 -0
- data/spec/rango/contrib/pagination/strategies_spec.rb +0 -0
- data/spec/rango/contrib/pagination_spec.rb +0 -0
- data/spec/rango/contrib/syndication_spec.rb +0 -0
- data/spec/rango/exceptions_spec.rb +0 -0
- data/spec/rango/ext/attribute_spec.rb +0 -0
- data/spec/rango/ext/colored_string_spec.rb +0 -0
- data/spec/rango/ext/core_ext_spec.rb +0 -0
- data/spec/rango/ext/kernel_spec.rb +0 -0
- data/spec/rango/ext/path_spec.rb +0 -0
- data/spec/rango/ext/string_spec.rb +0 -0
- data/spec/rango/ext/thor_spec.rb +0 -0
- data/spec/rango/ext/time_dsl_spec.rb +0 -0
- data/spec/rango/ext_spec.rb +0 -0
- data/spec/rango/forms/form_spec.rb +0 -0
- data/spec/rango/generators_spec.rb +0 -0
- data/spec/rango/generic_views/static_spec.rb +0 -0
- data/spec/rango/helpers/assets_spec.rb +0 -0
- data/spec/rango/helpers/general_spec.rb +0 -0
- data/spec/rango/helpers/merb-helpers/core_ext/numeric_spec.rb +0 -0
- data/spec/rango/helpers/merb-helpers/core_ext_spec.rb +0 -0
- 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/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/tag_helpers_spec.rb +0 -0
- data/spec/rango/helpers/merb-helpers/text_helpers_spec.rb +0 -0
- data/spec/rango/helpers/merb-helpers/time_dsl_spec.rb +0 -0
- data/spec/rango/helpers/merb-helpers_spec.rb +0 -0
- data/spec/rango/helpers/spec/core_ext_spec_spec.rb +0 -0
- data/spec/rango/helpers/spec/fixture/app/controllers/application_spec.rb +0 -0
- data/spec/rango/helpers/spec/fixture/app/controllers/bound_check_box_spec.rb +0 -0
- data/spec/rango/helpers/spec/fixture/app/controllers/bound_file_field_spec.rb +0 -0
- data/spec/rango/helpers/spec/fixture/app/controllers/bound_hidden_field_spec.rb +0 -0
- data/spec/rango/helpers/spec/fixture/app/controllers/bound_option_tag_spec.rb +0 -0
- data/spec/rango/helpers/spec/fixture/app/controllers/bound_password_field_spec.rb +0 -0
- data/spec/rango/helpers/spec/fixture/app/controllers/bound_radio_button_spec.rb +0 -0
- data/spec/rango/helpers/spec/fixture/app/controllers/bound_radio_group_spec.rb +0 -0
- data/spec/rango/helpers/spec/fixture/app/controllers/bound_select_spec.rb +0 -0
- data/spec/rango/helpers/spec/fixture/app/controllers/bound_text_area_spec.rb +0 -0
- data/spec/rango/helpers/spec/fixture/app/controllers/bound_text_field_spec.rb +0 -0
- data/spec/rango/helpers/spec/fixture/app/controllers/button_spec.rb +0 -0
- data/spec/rango/helpers/spec/fixture/app/controllers/check_box_spec.rb +0 -0
- data/spec/rango/helpers/spec/fixture/app/controllers/custom_builder_spec.rb +0 -0
- data/spec/rango/helpers/spec/fixture/app/controllers/delete_button_spec.rb +0 -0
- data/spec/rango/helpers/spec/fixture/app/controllers/exceptions_spec.rb +0 -0
- data/spec/rango/helpers/spec/fixture/app/controllers/field_set_spec.rb +0 -0
- data/spec/rango/helpers/spec/fixture/app/controllers/fields_for_spec.rb +0 -0
- data/spec/rango/helpers/spec/fixture/app/controllers/file_field_spec.rb +0 -0
- data/spec/rango/helpers/spec/fixture/app/controllers/foo_spec.rb +0 -0
- data/spec/rango/helpers/spec/fixture/app/controllers/form_for_spec.rb +0 -0
- data/spec/rango/helpers/spec/fixture/app/controllers/form_spec.rb +0 -0
- data/spec/rango/helpers/spec/fixture/app/controllers/hacker_spec.rb +0 -0
- data/spec/rango/helpers/spec/fixture/app/controllers/hidden_field_spec.rb +0 -0
- data/spec/rango/helpers/spec/fixture/app/controllers/label_spec.rb +0 -0
- data/spec/rango/helpers/spec/fixture/app/controllers/numeric_ext_spec.rb +0 -0
- data/spec/rango/helpers/spec/fixture/app/controllers/option_tag_spec.rb +0 -0
- data/spec/rango/helpers/spec/fixture/app/controllers/password_field_spec.rb +0 -0
- data/spec/rango/helpers/spec/fixture/app/controllers/radio_button_spec.rb +0 -0
- data/spec/rango/helpers/spec/fixture/app/controllers/radio_group_spec.rb +0 -0
- data/spec/rango/helpers/spec/fixture/app/controllers/relative_date_span_spec.rb +0 -0
- data/spec/rango/helpers/spec/fixture/app/controllers/relative_date_spec.rb +0 -0
- data/spec/rango/helpers/spec/fixture/app/controllers/select_spec.rb +0 -0
- data/spec/rango/helpers/spec/fixture/app/controllers/specs_controller_spec.rb +0 -0
- data/spec/rango/helpers/spec/fixture/app/controllers/submit_spec.rb +0 -0
- data/spec/rango/helpers/spec/fixture/app/controllers/tag_helper_spec.rb +0 -0
- data/spec/rango/helpers/spec/fixture/app/controllers/text_area_spec.rb +0 -0
- data/spec/rango/helpers/spec/fixture/app/controllers/text_field_spec.rb +0 -0
- data/spec/rango/helpers/spec/fixture/app/helpers/global_helpers_spec.rb +0 -0
- data/spec/rango/helpers/spec/fixture/app/models/fake_dm_model_spec.rb +0 -0
- data/spec/rango/helpers/spec/fixture/app/models/first_generic_fake_model_spec.rb +0 -0
- data/spec/rango/helpers/spec/fixture/app/models/hacker_generic_model_spec.rb +0 -0
- data/spec/rango/helpers/spec/fixture/app/models/second_generic_fake_model_spec.rb +0 -0
- data/spec/rango/helpers/spec/fixture/app/models/third_generic_fake_model_spec.rb +0 -0
- data/spec/rango/helpers/spec/fixture/config/environments/development_spec.rb +0 -0
- data/spec/rango/helpers/spec/fixture/config/environments/production_spec.rb +0 -0
- data/spec/rango/helpers/spec/fixture/config/environments/test_spec.rb +0 -0
- data/spec/rango/helpers/spec/fixture/config/init_spec.rb +0 -0
- data/spec/rango/helpers/spec/fixture/config/rack_spec.rb +0 -0
- data/spec/rango/helpers/spec/fixture/config/router_spec.rb +0 -0
- data/spec/rango/helpers/spec/merb_helpers_config_spec_spec.rb +0 -0
- data/spec/rango/helpers/spec/merb_helpers_date_time_spec_spec.rb +0 -0
- data/spec/rango/helpers/spec/merb_helpers_form_spec_spec.rb +0 -0
- data/spec/rango/helpers/spec/merb_helpers_tag_helper_spec_spec.rb +0 -0
- data/spec/rango/helpers/spec/merb_helpers_text_spec_spec.rb +0 -0
- data/spec/rango/helpers/spec/numeric_extlib_spec_spec.rb +0 -0
- data/spec/rango/helpers/spec/ordinalize_spec_spec.rb +0 -0
- data/spec/rango/helpers/spec/spec_helper_spec.rb +0 -0
- data/spec/rango/helpers/spec/time_dsl_spec_spec.rb +0 -0
- data/spec/rango/helpers/syntax_spec.rb +0 -0
- data/spec/rango/helpers_spec.rb +0 -0
- data/spec/rango/loggers/fireruby_spec.rb +0 -0
- data/spec/rango/loggers/logger_spec.rb +0 -0
- data/spec/rango/mixins/application_spec.rb +0 -0
- data/spec/rango/mixins/controller_spec.rb +0 -0
- data/spec/rango/mixins/import_spec.rb +0 -0
- data/spec/rango/mvc/controller_spec.rb +24 -0
- data/spec/rango/mvc/strategies_spec.rb +0 -0
- data/spec/rango/orm/adapters/dm/fields_spec.rb +0 -0
- data/spec/rango/orm/adapters/dm/setup_spec.rb +0 -0
- data/spec/rango/project_spec.rb +46 -0
- data/spec/rango/rack/dispatcher_spec.rb +0 -0
- data/spec/rango/rack/middlewares/emails_spec.rb +0 -0
- data/spec/rango/rack/middlewares/static_spec.rb +0 -0
- data/spec/rango/rack/request_spec.rb +18 -0
- data/spec/rango/rango_spec.rb +0 -0
- data/spec/rango/router/route_spec.rb +0 -0
- data/spec/rango/router/router_spec.rb +0 -0
- data/spec/rango/router/strategies_spec.rb +0 -0
- data/spec/rango/settings_spec.rb +26 -0
- data/spec/rango/spec/cucumber_spec.rb +0 -0
- data/spec/rango/spec/rspec_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 -0
- data/spec/rango/templates/adapters/haml_spec.rb +0 -0
- data/spec/rango/templates/template_spec.rb +0 -0
- data/spec/rango_spec.rb +37 -0
- data/spec/spec.opts +5 -0
- data/spec/spec_helper.rb +7 -0
- data/spec/stubs/flat.rb +0 -0
- data/stubs/app/content/init.rb.rbt +6 -0
- data/stubs/app/content/models.rb.rbt +9 -0
- data/stubs/app/content/views.rb.rbt +10 -0
- data/stubs/app/preprocess.rb +13 -0
- data/stubs/bigapp/content/init.rb +0 -0
- data/stubs/bigapp/content/views/application.rb +0 -0
- data/stubs/bigapp/preprocess.rb +5 -0
- data/stubs/features/content/env.rb +36 -0
- data/stubs/flat/content/flat.ru.rbt +19 -0
- data/stubs/flat/preprocess.rb +5 -0
- data/stubs/project/content/TODO +0 -0
- data/stubs/project/content/Thorfile +12 -0
- data/stubs/project/content/config.ru +34 -0
- data/stubs/project/content/init.rb +14 -0
- data/stubs/project/content/settings.rb.rbt +10 -0
- data/stubs/project/content/settings_local.rb.rbt +6 -0
- data/stubs/project/content/templates/base.html.haml.rbt +29 -0
- data/stubs/project/preprocess.rb +5 -0
- data/stubs/pupu/preprocess.rb +5 -0
- data/stubs/stub/content/metadata.yml +2 -0
- data/stubs/stub/content/postprocess.rb +7 -0
- data/stubs/stub/content/preprocess.rb +5 -0
- data/stubs/stub/preprocess.rb +5 -0
- data/support/Rango.tmbundle/Commands/Documentation for current word.tmCommand +22 -0
- data/support/Rango.tmbundle/Commands/Got to import.tmCommand +23 -0
- data/support/Rango.tmbundle/Commands/Rango console.tmCommand +22 -0
- data/support/Rango.tmbundle/Commands/Rango server.tmCommand +22 -0
- data/support/Rango.tmbundle/Commands/Read documentation.tmCommand +22 -0
- data/support/Rango.tmbundle/Snippets/Method with yardoc.tmSnippet +20 -0
- data/support/Rango.tmbundle/Snippets/Project_configure.tmSnippet +18 -0
- data/support/Rango.tmbundle/Snippets/Project_import.tmSnippet +16 -0
- data/support/Rango.tmbundle/Snippets/Project_logger_debug.tmSnippet +16 -0
- data/support/Rango.tmbundle/Snippets/Project_logger_error.tmSnippet +16 -0
- data/support/Rango.tmbundle/Snippets/Project_logger_fatal.tmSnippet +16 -0
- data/support/Rango.tmbundle/Snippets/Project_logger_inspect.tmSnippet +16 -0
- data/support/Rango.tmbundle/Snippets/Project_logger_warn.tmSnippet +16 -0
- data/support/Rango.tmbundle/Snippets/Rango_dependency.tmSnippet +16 -0
- data/support/Rango.tmbundle/Snippets/Rango_import.tmSnippet +16 -0
- data/support/Rango.tmbundle/Snippets/Rango_logger_debug.tmSnippet +16 -0
- data/support/Rango.tmbundle/Snippets/Rango_logger_error.tmSnippet +16 -0
- data/support/Rango.tmbundle/Snippets/Rango_logger_fatal.tmSnippet +16 -0
- data/support/Rango.tmbundle/Snippets/Rango_logger_inspect.tmSnippet +16 -0
- data/support/Rango.tmbundle/Snippets/Rango_logger_warn.tmSnippet +16 -0
- data/support/Rango.tmbundle/Snippets/controller.tmSnippet +28 -0
- data/support/Rango.tmbundle/Snippets/doc.tmSnippet +20 -0
- data/support/Rango.tmbundle/Snippets/match.tmSnippet +16 -0
- data/support/Rango.tmbundle/Snippets/thor task.tmSnippet +19 -0
- data/support/Rango.tmbundle/info.plist +37 -0
- data/support/hooks/commit-msg +13 -0
- data/support/hooks/post-commit +4 -0
- data/support/hooks/pre-commit +4 -0
- data/support/hooks/pre-rebase +169 -0
- data/support/hooks/prepare-commit-msg +36 -0
- data/tasks/hooks.thor +26 -0
- data/tasks/package.thor +49 -0
- data/tasks/release.thor +72 -0
- data/tasks/repair.thor +75 -0
- data/tasks/spec.thor +39 -0
- data/tasks/stats.thor +66 -0
- data/tasks/yardoc.thor +16 -0
- data/templates/errors/404.html.erb +52 -0
- data/templates/errors/406.html.erb +1 -0
- data/templates/errors/500.html.erb +48 -0
- metadata +866 -0
@@ -0,0 +1,158 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
|
3
|
+
module DateAndTimeFormatting
|
4
|
+
|
5
|
+
def self.included(base)
|
6
|
+
base.class_eval do
|
7
|
+
include DateAndTimeFormatting::InstanceMethods
|
8
|
+
include OrdinalizedFormatting
|
9
|
+
extend DateAndTimeFormatting::ClassMethods
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
module InstanceMethods
|
14
|
+
|
15
|
+
|
16
|
+
# Formats a date/time instance using a defined format
|
17
|
+
#
|
18
|
+
# ==== Parameters
|
19
|
+
# format<Symbol>:: of the format key from Date.date_formats
|
20
|
+
#
|
21
|
+
# ==== Returns
|
22
|
+
# String:: formatted string
|
23
|
+
#
|
24
|
+
# ==== Example
|
25
|
+
# Time.now.formatted(:rfc822) # => "Sun, 16 Nov 2007 00:21:16 -0800"
|
26
|
+
# Time.now.formatted(:db) # => "2008-11-16 00:22:09"
|
27
|
+
#
|
28
|
+
# You can also add your own formats using +Date.add_format+ when your app loads.
|
29
|
+
#
|
30
|
+
# # Add the following to your init.rb
|
31
|
+
# Rango::BootLoader.before_app_loads do
|
32
|
+
# Date.add_format(:matt, "%H:%M:%S %Y-%m-%d")
|
33
|
+
# end
|
34
|
+
#
|
35
|
+
# # Format a Time instance with the format you just specified
|
36
|
+
# Time.now.formatted(:matt) # => "00:00:00 2007-11-02"
|
37
|
+
#
|
38
|
+
#--
|
39
|
+
# @public
|
40
|
+
def formatted(format = :default)
|
41
|
+
self.strftime(Date.formats[format])
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|
45
|
+
|
46
|
+
module ClassMethods
|
47
|
+
|
48
|
+
@@formats = {
|
49
|
+
:db => "%Y-%m-%d %H:%M:%S",
|
50
|
+
:time => "%H:%M", # 21:12
|
51
|
+
:date => "%Y-%m-%d", # 2008-12-04
|
52
|
+
:short => "%d %b %H:%M", # 01 Sep 21:12
|
53
|
+
:long => "%B %d, %Y %H:%M",
|
54
|
+
:rfc822 => "%a, %d %b %Y %H:%M:%S %z"
|
55
|
+
}
|
56
|
+
|
57
|
+
# Lists the date and time formats
|
58
|
+
#
|
59
|
+
# ==== Returns
|
60
|
+
# Hash:: a hash with all formats available
|
61
|
+
# --
|
62
|
+
# @public
|
63
|
+
def formats
|
64
|
+
@@formats
|
65
|
+
end
|
66
|
+
|
67
|
+
# Adds a date and time format
|
68
|
+
#
|
69
|
+
# Because this operation is not thread safe, you should define
|
70
|
+
# custom formats when you load you application. The recommended way
|
71
|
+
# to do that, is to use the before_app_loads bootloader.
|
72
|
+
#
|
73
|
+
# If you want to add a format at runtime, you will need to use a mutex
|
74
|
+
# and synchronize it yourself.
|
75
|
+
#
|
76
|
+
# ==== Parameters
|
77
|
+
# key<Symbol>:: name of the format
|
78
|
+
# format<Hash>:: time format to use
|
79
|
+
#
|
80
|
+
# ==== Returns
|
81
|
+
# Hash:: a hash with all formats available
|
82
|
+
#
|
83
|
+
# ==== Example
|
84
|
+
#
|
85
|
+
# Rango::BootLoader.before_app_loads do
|
86
|
+
# Date.add_format(:matt, "%H:%M:%S %Y-%m-%d")
|
87
|
+
# end
|
88
|
+
#
|
89
|
+
#
|
90
|
+
# --
|
91
|
+
# @public
|
92
|
+
def add_format(key, format)
|
93
|
+
formats.merge!({key => format})
|
94
|
+
end
|
95
|
+
|
96
|
+
|
97
|
+
# Resets the date and time formats
|
98
|
+
# --
|
99
|
+
# @private
|
100
|
+
def reset_formats
|
101
|
+
original_formats = [:db, :time, :short, :date, :long, :long_ordinal, :rfc822]
|
102
|
+
formats = @@formats.delete_if{|format, v| !original_formats.include?(format)}
|
103
|
+
end
|
104
|
+
|
105
|
+
end
|
106
|
+
|
107
|
+
end
|
108
|
+
|
109
|
+
module Ordinalize
|
110
|
+
# Ordinalize turns a number into an ordinal string used to denote the
|
111
|
+
# position in an ordered sequence such as 1st, 2nd, 3rd, 4th.
|
112
|
+
#
|
113
|
+
# ==== Examples
|
114
|
+
# 1.ordinalize # => "1st"
|
115
|
+
# 2.ordinalize # => "2nd"
|
116
|
+
# 1002.ordinalize # => "1002nd"
|
117
|
+
# 1003.ordinalize # => "1003rd"
|
118
|
+
def ordinalize
|
119
|
+
if (11..13).include?(self % 100)
|
120
|
+
"#{self}th"
|
121
|
+
else
|
122
|
+
case self % 10
|
123
|
+
when 1; "#{self}st"
|
124
|
+
when 2; "#{self}nd"
|
125
|
+
when 3; "#{self}rd"
|
126
|
+
else "#{self}th"
|
127
|
+
end
|
128
|
+
end
|
129
|
+
end
|
130
|
+
end
|
131
|
+
|
132
|
+
Integer.send :include, Ordinalize
|
133
|
+
|
134
|
+
# Time.now.to_ordinalized_s :long
|
135
|
+
# => "February 28th, 2006 21:10"
|
136
|
+
module OrdinalizedFormatting
|
137
|
+
|
138
|
+
def to_ordinalized_s(format = :default)
|
139
|
+
format = Date.formats[format]
|
140
|
+
return self.to_s if format.nil?
|
141
|
+
strftime_ordinalized(format)
|
142
|
+
end
|
143
|
+
|
144
|
+
# Gives you a relative date in an attractive format
|
145
|
+
#
|
146
|
+
# ==== Parameters
|
147
|
+
# format<String>:: strftime string used to format a time/date object
|
148
|
+
# locale<String, Symbol>:: An optional value which can be used by localization plugins
|
149
|
+
#
|
150
|
+
# ==== Returns
|
151
|
+
# String:: Ordinalized time/date object
|
152
|
+
#
|
153
|
+
# ==== Examples
|
154
|
+
# 5.days.ago.strftime_ordinalized('%b %d, %Y') # =>
|
155
|
+
def strftime_ordinalized(fmt, format=nil)
|
156
|
+
strftime(fmt.gsub(/(^|[^-])%d/, '\1_%d_')).gsub(/_(\d+)_/) { |s| s.to_i.ordinalize }
|
157
|
+
end
|
158
|
+
end
|
@@ -0,0 +1,191 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
|
3
|
+
class Rango
|
4
|
+
module Helpers
|
5
|
+
# Provides a number of methods for displaying and dealing with dates and times
|
6
|
+
#
|
7
|
+
# Parts were strongly based on http://ar-code.svn.engineyard.com/plugins/relative_time_helpers/, and
|
8
|
+
# active_support
|
9
|
+
#
|
10
|
+
# The key methods are `relative_date`, `relative_date_span`, and `relative_time_span`. This also gives
|
11
|
+
# you the Rails style Time DSL for working with numbers eg. 3.months.ago or 5.days.until(1.year.from_now)
|
12
|
+
module DateAndTime
|
13
|
+
@@time_class = Time
|
14
|
+
@@time_output = {
|
15
|
+
:today => 'today',
|
16
|
+
:yesterday => 'yesterday',
|
17
|
+
:tomorrow => 'tomorrow',
|
18
|
+
:initial_format => '%b %d',
|
19
|
+
:year_format => ', %Y'
|
20
|
+
}
|
21
|
+
|
22
|
+
def self.time_class
|
23
|
+
@@time_class
|
24
|
+
end
|
25
|
+
|
26
|
+
# ==== Parameters
|
27
|
+
# format<Symbol>:: time format to use
|
28
|
+
# locale<String, Symbol>:: An optional value which can be used by localization plugins
|
29
|
+
#
|
30
|
+
# ==== Returns
|
31
|
+
# String:: a string used to format time using #strftime
|
32
|
+
def self.time_output(format, locale=nil)
|
33
|
+
@@time_output[format]
|
34
|
+
end
|
35
|
+
|
36
|
+
# Gives you a relative date in an attractive format
|
37
|
+
#
|
38
|
+
# ==== Parameters
|
39
|
+
# time<~to_date>:: The Date or Time to test
|
40
|
+
# locale<String, Symbol>:: An optional value which can be used by localization plugins
|
41
|
+
#
|
42
|
+
# ==== Returns
|
43
|
+
# String:: Relative date
|
44
|
+
#
|
45
|
+
# ==== Examples
|
46
|
+
# relative_date(Time.now.utc) => "today"
|
47
|
+
# relative_date(5.days.ago) => "March 5th"
|
48
|
+
# relative_date(1.year.ago) => "March 10th, 2007"
|
49
|
+
def relative_date(time, locale=nil)
|
50
|
+
date = time.to_date
|
51
|
+
today = DateAndTime.time_class.now.to_date
|
52
|
+
if date == today
|
53
|
+
DateAndTime.time_output(:today, locale)
|
54
|
+
elsif date == (today - 1)
|
55
|
+
DateAndTime.time_output(:yesterday, locale)
|
56
|
+
elsif date == (today + 1)
|
57
|
+
DateAndTime.time_output(:tomorrow, locale)
|
58
|
+
else
|
59
|
+
fmt = DateAndTime.time_output(:initial_format, locale).dup
|
60
|
+
fmt << DateAndTime.time_output(:year_format, locale) unless date.year == today.year
|
61
|
+
time.strftime_ordinalized(fmt, locale)
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
# Gives you a relative date span in an attractive format
|
66
|
+
#
|
67
|
+
# ==== Parameters
|
68
|
+
# times<~first,~last>:: The Dates or Times to test
|
69
|
+
#
|
70
|
+
# ==== Returns
|
71
|
+
# String:: The sexy relative date span
|
72
|
+
#
|
73
|
+
# ==== Examples
|
74
|
+
# relative_date([1.second.ago, 10.seconds.ago]) => "March 10th"
|
75
|
+
# relative_date([1.year.ago, 1.year.ago) => "March 10th, 2007"
|
76
|
+
# relative_date([Time.now, 1.day.from_now]) => "March 10th - 11th"
|
77
|
+
# relative_date([Time.now, 1.year.ago]) => "March 10th, 2007 - March 10th, 2008"
|
78
|
+
def relative_date_span(times)
|
79
|
+
times = [times.first, times.last].collect! { |t| t.to_date }
|
80
|
+
times.sort!
|
81
|
+
if times.first == times.last
|
82
|
+
relative_date(times.first)
|
83
|
+
else
|
84
|
+
first = times.first; last = times.last; now = DateAndTime.time_class.now
|
85
|
+
arr = [first.strftime_ordinalized('%b %d')]
|
86
|
+
arr << ", #{first.year}" unless first.year == last.year
|
87
|
+
arr << ' - '
|
88
|
+
arr << last.strftime('%b') << ' ' unless first.year == last.year && first.month == last.month
|
89
|
+
arr << last.day.ordinalize
|
90
|
+
arr << ", #{last.year}" unless first.year == last.year && last.year == now.year
|
91
|
+
arr.to_s
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
# Gives you a relative date span in an attractive format
|
96
|
+
#
|
97
|
+
# ==== Parameters
|
98
|
+
# times<~first,~last>:: The Dates or Times to test
|
99
|
+
#
|
100
|
+
# ==== Returns
|
101
|
+
# String:: The sexy relative time span
|
102
|
+
#
|
103
|
+
# ==== Examples
|
104
|
+
# relative_time_span([1.second.ago, 10.seconds.ago]) => "12:00 - 12:09 AM March 10th"
|
105
|
+
# relative_time_span([1.year.ago, 1.year.ago) => "12:09 AM March 10th, 2007"
|
106
|
+
# relative_time_span([Time.now, 13.hours.from_now]) => "12:09 AM - 1:09 PM March 10th"
|
107
|
+
# relative_time_span([Time.now, 1.year.ago]) => "12:09 AM March 10th, 2007 - 12:09 AM March 10th, 2008"
|
108
|
+
def relative_time_span(times)
|
109
|
+
times = [times.first, times.last].collect! { |t| t.to_time }
|
110
|
+
times.sort!
|
111
|
+
if times.first == times.last
|
112
|
+
"#{prettier_time(times.first)} #{relative_date(times.first)}"
|
113
|
+
elsif times.first.to_date == times.last.to_date
|
114
|
+
same_half = (times.first.hour/12 == times.last.hour/12)
|
115
|
+
"#{prettier_time(times.first, !same_half)} - #{prettier_time(times.last)} #{relative_date(times.first)}"
|
116
|
+
|
117
|
+
else
|
118
|
+
first = times.first; last = times.last; now = DateAndTime.time_class.now
|
119
|
+
arr = [prettier_time(first)]
|
120
|
+
arr << ' '
|
121
|
+
arr << first.strftime_ordinalized('%b %d')
|
122
|
+
arr << ", #{first.year}" unless first.year == last.year
|
123
|
+
arr << ' - '
|
124
|
+
arr << prettier_time(last)
|
125
|
+
arr << ' '
|
126
|
+
arr << last.strftime('%b') << ' ' unless first.year == last.year && first.month == last.month
|
127
|
+
arr << last.day.ordinalize
|
128
|
+
arr << ", #{last.year}" unless first.year == last.year && last.year == now.year
|
129
|
+
arr.to_s
|
130
|
+
end
|
131
|
+
end
|
132
|
+
|
133
|
+
# Condenses time... very similar to time_ago_in_words in ActionPack
|
134
|
+
#
|
135
|
+
# ==== Parameters
|
136
|
+
# from_time<~to_time>:: The Date or Time to start from
|
137
|
+
# to_time<~to_time>:: The Date or Time to go to, Defaults to Time.now.utc
|
138
|
+
# include_seconds<Boolean>:: Count the seconds initially, Defaults to false
|
139
|
+
# locale<String, Symbol>:: An optional value which can be used by localization plugins
|
140
|
+
#
|
141
|
+
# ==== Returns
|
142
|
+
# String:: The time distance
|
143
|
+
#
|
144
|
+
# ==== Examples
|
145
|
+
# time_lost_in_words(3.minutes.from_now) # => 3 minutes
|
146
|
+
# time_lost_in_words(Time.now - 15.hours) # => 15 hours
|
147
|
+
# time_lost_in_words(Time.now, 3.minutes.from_now) # => 3 minutes
|
148
|
+
# time_lost_in_words(Time.now) # => less than a minute
|
149
|
+
# time_lost_in_words(Time.now, Time.now, true) # => less than 5 seconds
|
150
|
+
#
|
151
|
+
def time_lost_in_words(from_time, to_time = Time.now.utc, include_seconds = false, locale=nil)
|
152
|
+
from_time = from_time.to_time if from_time.respond_to?(:to_time)
|
153
|
+
to_time = to_time.to_time if to_time.respond_to?(:to_time)
|
154
|
+
distance_in_minutes = (((to_time - from_time).abs)/60).round
|
155
|
+
distance_in_seconds = ((to_time - from_time).abs).round
|
156
|
+
|
157
|
+
case distance_in_minutes
|
158
|
+
when 0..1
|
159
|
+
return (distance_in_minutes == 0) ? 'less than a minute' : '1 minute' unless include_seconds
|
160
|
+
case distance_in_seconds
|
161
|
+
when 0..4 then 'less than 5 seconds'
|
162
|
+
when 5..9 then 'less than 10 seconds'
|
163
|
+
when 10..19 then 'less than 20 seconds'
|
164
|
+
when 20..39 then 'half a minute'
|
165
|
+
when 40..59 then 'less than a minute'
|
166
|
+
else '1 minute'
|
167
|
+
end
|
168
|
+
|
169
|
+
when 2..44 then "#{distance_in_minutes} minutes"
|
170
|
+
when 45..89 then 'about 1 hour'
|
171
|
+
when 90..1439 then "about #{(distance_in_minutes.to_f / 60.0).round} hours"
|
172
|
+
when 1440..2879 then '1 day'
|
173
|
+
when 2880..43199 then "#{(distance_in_minutes / 1440).round} days"
|
174
|
+
when 43200..86399 then 'about 1 month'
|
175
|
+
when 86400..525599 then "#{(distance_in_minutes / 43200).round} months"
|
176
|
+
when 525600..1051199 then 'about 1 year'
|
177
|
+
else "over #{(distance_in_minutes / 525600).round} years"
|
178
|
+
end
|
179
|
+
end
|
180
|
+
alias :time_ago_in_words :time_lost_in_words
|
181
|
+
|
182
|
+
def prettier_time(time, ampm=true, locale=nil)
|
183
|
+
time.strftime("%I:%M#{" %p" if ampm}").sub(/^0/, '')
|
184
|
+
end
|
185
|
+
end
|
186
|
+
end
|
187
|
+
end
|
188
|
+
|
189
|
+
class Rango::Controller
|
190
|
+
include Rango::Helpers::DateAndTime
|
191
|
+
end
|
@@ -0,0 +1,447 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
|
3
|
+
load File.dirname(__FILE__) / ".." / "tag_helpers.rb"
|
4
|
+
Rango.import("templates/template")
|
5
|
+
|
6
|
+
module Rango::Helpers::Form::Builder
|
7
|
+
|
8
|
+
class Base
|
9
|
+
include Rango::Helpers::Tag
|
10
|
+
include Rango::Templates::TemplateHelpers
|
11
|
+
|
12
|
+
def initialize(obj, name, origin)
|
13
|
+
@obj, @origin = obj, origin
|
14
|
+
@name = name || @obj.class.name.snake_case.split("/").last
|
15
|
+
end
|
16
|
+
|
17
|
+
def form(attrs = {}, &block)
|
18
|
+
captured = @origin.capture(&block)
|
19
|
+
fake_method_tag = process_form_attrs(attrs)
|
20
|
+
tag(:form, fake_method_tag + captured, attrs)
|
21
|
+
end
|
22
|
+
|
23
|
+
def fieldset(attrs, &block)
|
24
|
+
legend = (l_attr = attrs.delete(:legend)) ? tag(:legend, l_attr) : ""
|
25
|
+
tag(:fieldset, legend + @origin.capture(&block), attrs)
|
26
|
+
# @origin.concat(contents, block.binding)
|
27
|
+
end
|
28
|
+
|
29
|
+
%w(text password hidden file).each do |kind|
|
30
|
+
self.class_eval <<-RUBY, __FILE__, __LINE__ + 1
|
31
|
+
def bound_#{kind}_field(method, attrs = {})
|
32
|
+
name = control_name(method)
|
33
|
+
update_bound_controls(method, attrs, "#{kind}")
|
34
|
+
unbound_#{kind}_field({
|
35
|
+
:name => name,
|
36
|
+
:value => control_value(method)
|
37
|
+
}.merge(attrs))
|
38
|
+
end
|
39
|
+
|
40
|
+
def unbound_#{kind}_field(attrs)
|
41
|
+
update_unbound_controls(attrs, "#{kind}")
|
42
|
+
self_closing_tag(:input, {:type => "#{kind}"}.merge(attrs))
|
43
|
+
end
|
44
|
+
RUBY
|
45
|
+
end
|
46
|
+
|
47
|
+
def bound_check_box(method, attrs = {})
|
48
|
+
name = control_name(method)
|
49
|
+
update_bound_controls(method, attrs, "checkbox")
|
50
|
+
unbound_check_box({:name => name}.merge(attrs))
|
51
|
+
end
|
52
|
+
|
53
|
+
def unbound_check_box(attrs)
|
54
|
+
update_unbound_controls(attrs, "checkbox")
|
55
|
+
if attrs.delete(:boolean)
|
56
|
+
on, off = attrs.delete(:on), attrs.delete(:off)
|
57
|
+
unbound_hidden_field(:name => attrs[:name], :value => off) <<
|
58
|
+
self_closing_tag(:input, {:type => "checkbox", :value => on}.merge(attrs))
|
59
|
+
else
|
60
|
+
self_closing_tag(:input, {:type => "checkbox"}.merge(attrs))
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
def bound_radio_button(method, attrs = {})
|
65
|
+
name = control_name(method)
|
66
|
+
update_bound_controls(method, attrs, "radio")
|
67
|
+
unbound_radio_button({:name => name, :value => control_value(method)}.merge(attrs))
|
68
|
+
end
|
69
|
+
|
70
|
+
def unbound_radio_button(attrs)
|
71
|
+
update_unbound_controls(attrs, "radio")
|
72
|
+
self_closing_tag(:input, {:type => "radio"}.merge(attrs))
|
73
|
+
end
|
74
|
+
|
75
|
+
def bound_radio_group(method, arr)
|
76
|
+
val = control_value(method)
|
77
|
+
arr.map do |attrs|
|
78
|
+
attrs = {:value => attrs} unless attrs.is_a?(Hash)
|
79
|
+
attrs[:checked] = true if (val == attrs[:value])
|
80
|
+
radio_group_item(method, attrs)
|
81
|
+
end.join
|
82
|
+
end
|
83
|
+
|
84
|
+
def unbound_radio_group(arr, attrs = {})
|
85
|
+
arr.map do |ind_attrs|
|
86
|
+
ind_attrs = {:value => ind_attrs} unless ind_attrs.is_a?(Hash)
|
87
|
+
joined = attrs.merge(ind_attrs)
|
88
|
+
joined.merge!(:label => joined[:label] || joined[:value])
|
89
|
+
unbound_radio_button(joined)
|
90
|
+
end.join
|
91
|
+
end
|
92
|
+
|
93
|
+
def bound_select(method, attrs = {})
|
94
|
+
name = control_name(method)
|
95
|
+
update_bound_controls(method, attrs, "select")
|
96
|
+
unbound_select({:name => name}.merge(attrs))
|
97
|
+
end
|
98
|
+
|
99
|
+
def unbound_select(attrs = {})
|
100
|
+
update_unbound_controls(attrs, "select")
|
101
|
+
attrs[:name] << "[]" if attrs[:multiple] && !(attrs[:name] =~ /\[\]$/)
|
102
|
+
tag(:select, options_for(attrs), attrs)
|
103
|
+
end
|
104
|
+
|
105
|
+
def bound_text_area(method, attrs = {})
|
106
|
+
name = "#{@name}[#{method}]"
|
107
|
+
update_bound_controls(method, attrs, "text_area")
|
108
|
+
unbound_text_area(control_value(method), {:name => name}.merge(attrs))
|
109
|
+
end
|
110
|
+
|
111
|
+
def unbound_text_area(contents, attrs)
|
112
|
+
update_unbound_controls(attrs, "text_area")
|
113
|
+
tag(:textarea, contents, attrs)
|
114
|
+
end
|
115
|
+
|
116
|
+
def button(contents, attrs)
|
117
|
+
update_unbound_controls(attrs, "button")
|
118
|
+
tag(:button, contents, attrs)
|
119
|
+
end
|
120
|
+
|
121
|
+
def submit(value, attrs)
|
122
|
+
attrs[:type] ||= "submit"
|
123
|
+
attrs[:value] ||= value
|
124
|
+
update_unbound_controls(attrs, "submit")
|
125
|
+
self_closing_tag(:input, attrs)
|
126
|
+
end
|
127
|
+
|
128
|
+
private
|
129
|
+
|
130
|
+
def process_form_attrs(attrs)
|
131
|
+
method = attrs[:method]
|
132
|
+
|
133
|
+
# Unless the method is :get, fake out the method using :post
|
134
|
+
attrs[:method] = :post unless attrs[:method] == :get
|
135
|
+
# Use a fake PUT if the object is not new, otherwise use the method
|
136
|
+
# passed in. Defaults to :post if no method is set.
|
137
|
+
method ||= (@obj.respond_to?(:new_record?) && !@obj.new_record?) || (@obj.respond_to?(:new?) && !@obj.new?) ? :put : :post
|
138
|
+
|
139
|
+
attrs[:enctype] = "multipart/form-data" if attrs.delete(:multipart) || @multipart
|
140
|
+
|
141
|
+
method == :post || method == :get ? "" : fake_out_method(attrs, method)
|
142
|
+
end
|
143
|
+
|
144
|
+
# This can be overridden to use another method to fake out methods
|
145
|
+
def fake_out_method(attrs, method)
|
146
|
+
self_closing_tag(:input, :type => "hidden", :name => "_method", :value => method)
|
147
|
+
end
|
148
|
+
|
149
|
+
def update_bound_controls(method, attrs, type)
|
150
|
+
case type
|
151
|
+
when "checkbox"
|
152
|
+
update_bound_check_box(method, attrs)
|
153
|
+
when "select"
|
154
|
+
update_bound_select(method, attrs)
|
155
|
+
end
|
156
|
+
end
|
157
|
+
|
158
|
+
def update_bound_check_box(method, attrs)
|
159
|
+
raise ArgumentError, ":value can't be used with a bound_check_box" if attrs.has_key?(:value)
|
160
|
+
|
161
|
+
attrs[:boolean] = attrs.fetch(:boolean, true)
|
162
|
+
|
163
|
+
val = control_value(method)
|
164
|
+
attrs[:checked] = attrs.key?(:on) ? val == attrs[:on] : considered_true?(val)
|
165
|
+
end
|
166
|
+
|
167
|
+
def update_bound_select(method, attrs)
|
168
|
+
attrs[:value_method] ||= method
|
169
|
+
attrs[:text_method] ||= attrs[:value_method] || :to_s
|
170
|
+
attrs[:selected] ||= control_value(attrs[:value_method])
|
171
|
+
end
|
172
|
+
|
173
|
+
def update_unbound_controls(attrs, type)
|
174
|
+
case type
|
175
|
+
when "checkbox"
|
176
|
+
update_unbound_check_box(attrs)
|
177
|
+
when "radio"
|
178
|
+
update_unbound_radio_button(attrs)
|
179
|
+
when "file"
|
180
|
+
@multipart = true
|
181
|
+
end
|
182
|
+
|
183
|
+
attrs[:disabled] ? attrs[:disabled] = "disabled" : attrs.delete(:disabled)
|
184
|
+
end
|
185
|
+
|
186
|
+
def update_unbound_check_box(attrs)
|
187
|
+
boolean = attrs[:boolean] || (attrs[:on] && attrs[:off]) ? true : false
|
188
|
+
|
189
|
+
case
|
190
|
+
when attrs.key?(:on) ^ attrs.key?(:off)
|
191
|
+
raise ArgumentError, ":on and :off must be specified together"
|
192
|
+
when (attrs[:boolean] == false) && (attrs.key?(:on))
|
193
|
+
raise ArgumentError, ":boolean => false cannot be used with :on and :off"
|
194
|
+
when boolean && attrs.key?(:value)
|
195
|
+
raise ArgumentError, ":value can't be used with a boolean checkbox"
|
196
|
+
end
|
197
|
+
|
198
|
+
if attrs[:boolean] = boolean
|
199
|
+
attrs[:on] ||= "1"; attrs[:off] ||= "0"
|
200
|
+
end
|
201
|
+
|
202
|
+
attrs[:checked] = "checked" if attrs.delete(:checked)
|
203
|
+
end
|
204
|
+
|
205
|
+
def update_unbound_radio_button(attrs)
|
206
|
+
attrs[:checked] = "checked" if attrs.delete(:checked)
|
207
|
+
end
|
208
|
+
|
209
|
+
# Accepts a collection (hash, array, enumerable, your type) and returns a string of option tags.
|
210
|
+
# Given a collection where the elements respond to first and last (such as a two-element array),
|
211
|
+
# the "lasts" serve as option values and the "firsts" as option text. Hashes are turned into
|
212
|
+
# this form automatically, so the keys become "firsts" and values become lasts. If selected is
|
213
|
+
# specified, the matching "last" or element will get the selected option-tag. Selected may also
|
214
|
+
# be an array of values to be selected when using a multiple select.
|
215
|
+
#
|
216
|
+
# ==== Parameters
|
217
|
+
# attrs<Hash>:: HTML attributes and options
|
218
|
+
#
|
219
|
+
# ==== Options
|
220
|
+
# +selected+:: The value of a selected object, which may be either a string or an array.
|
221
|
+
# +prompt+:: Adds an addtional option tag with the provided string with no value.
|
222
|
+
# +include_blank+:: Adds an additional blank option tag with no value.
|
223
|
+
#
|
224
|
+
# ==== Returns
|
225
|
+
# String:: HTML
|
226
|
+
#
|
227
|
+
# ==== Examples
|
228
|
+
# <%= options_for [["apple", "Apple Pie"], ["orange", "Orange Juice"]], :selected => "orange"
|
229
|
+
# => <option value="apple">Apple Pie</option><option value="orange" selected="selected">Orange Juice</option>
|
230
|
+
#
|
231
|
+
# <%= options_for [["apple", "Apple Pie"], ["orange", "Orange Juice"]], :selected => ["orange", "apple"], :prompt => "Select One"
|
232
|
+
# => <option value="">Select One</option><option value="apple" selected="selected">Apple Pie</option><option value="orange" selected="selected">Orange Juice</option>
|
233
|
+
def options_for(attrs)
|
234
|
+
blank, prompt = attrs.delete(:include_blank), attrs.delete(:prompt)
|
235
|
+
b = blank || prompt ? tag(:option, prompt || "", :value => "") : ""
|
236
|
+
|
237
|
+
# yank out the options attrs
|
238
|
+
collection, selected, text_method, value_method =
|
239
|
+
attrs.extract!(:collection, :selected, :text_method, :value_method)
|
240
|
+
|
241
|
+
# if the collection is a Hash, optgroups are a-coming
|
242
|
+
if collection.is_a?(Hash)
|
243
|
+
([b] + collection.map do |g,col|
|
244
|
+
tag(:optgroup, options(col, text_method, value_method, selected), :label => g)
|
245
|
+
end).join
|
246
|
+
else
|
247
|
+
options(collection || [], text_method, value_method, selected, b)
|
248
|
+
end
|
249
|
+
end
|
250
|
+
|
251
|
+
def options(col, text_meth, value_meth, sel, b = nil)
|
252
|
+
([b] + col.map do |item|
|
253
|
+
text_meth = text_meth && item.respond_to?(text_meth) ? text_meth : :last
|
254
|
+
value_meth = value_meth && item.respond_to?(value_meth) ? value_meth : :first
|
255
|
+
|
256
|
+
text = item.is_a?(String) ? item : item.send(text_meth)
|
257
|
+
value = item.is_a?(String) ? item : item.send(value_meth)
|
258
|
+
|
259
|
+
# unless Rango.disabled?(:merb_helper_escaping)
|
260
|
+
# text = Rango::Parse.escape_xml(text)
|
261
|
+
# value = Rango::Parse.escape_xml(value)
|
262
|
+
# end
|
263
|
+
|
264
|
+
option_attrs = {:value => value}
|
265
|
+
if sel.is_a?(Array)
|
266
|
+
option_attrs.merge!(:selected => "selected") if value.in? sel
|
267
|
+
else
|
268
|
+
option_attrs.merge!(:selected => "selected") if value == sel
|
269
|
+
end
|
270
|
+
tag(:option, text, option_attrs)
|
271
|
+
end).join
|
272
|
+
end
|
273
|
+
|
274
|
+
def radio_group_item(method, attrs)
|
275
|
+
attrs.merge!(:checked => "checked") if attrs[:checked]
|
276
|
+
bound_radio_button(method, attrs)
|
277
|
+
end
|
278
|
+
|
279
|
+
def considered_true?(value)
|
280
|
+
value && value != "false" && value != "0" && value != 0
|
281
|
+
end
|
282
|
+
|
283
|
+
def control_name(method)
|
284
|
+
@obj ? "#{@name}[#{method}]" : method
|
285
|
+
end
|
286
|
+
|
287
|
+
def control_value(method)
|
288
|
+
value = @obj ? @obj.send(method) : @origin.params[method]
|
289
|
+
# if Rango.disabled?(:merb_helper_escaping)
|
290
|
+
value.to_s
|
291
|
+
# else
|
292
|
+
# Rango::Parse.escape_xml(value.to_s)
|
293
|
+
# end
|
294
|
+
end
|
295
|
+
|
296
|
+
def add_css_class(attrs, new_class)
|
297
|
+
attrs[:class] = attrs[:class] ? "#{attrs[:class]} #{new_class}" : new_class
|
298
|
+
end
|
299
|
+
end
|
300
|
+
|
301
|
+
class Form < Base
|
302
|
+
def label(contents, attrs = {})
|
303
|
+
if contents
|
304
|
+
if contents.is_a?(Hash)
|
305
|
+
label_attrs = contents
|
306
|
+
contents = label_attrs.delete(:title)
|
307
|
+
else
|
308
|
+
label_attrs = attrs
|
309
|
+
end
|
310
|
+
tag(:label, contents, label_attrs)
|
311
|
+
else
|
312
|
+
""
|
313
|
+
end
|
314
|
+
end
|
315
|
+
|
316
|
+
%w(text password file).each do |kind|
|
317
|
+
self.class_eval <<-RUBY, __FILE__, __LINE__ + 1
|
318
|
+
def unbound_#{kind}_field(attrs = {})
|
319
|
+
unbound_label(attrs) + super
|
320
|
+
end
|
321
|
+
RUBY
|
322
|
+
end
|
323
|
+
|
324
|
+
def unbound_label(attrs = {})
|
325
|
+
if attrs[:id]
|
326
|
+
label_attrs = {:for => attrs[:id]}
|
327
|
+
elsif attrs[:name]
|
328
|
+
label_attrs = {:for => attrs[:name]}
|
329
|
+
else
|
330
|
+
label_attrs = {}
|
331
|
+
end
|
332
|
+
|
333
|
+
label_option = attrs.delete(:label)
|
334
|
+
if label_option.is_a? Hash
|
335
|
+
label(label_attrs.merge(label_option))
|
336
|
+
else
|
337
|
+
label(label_option, label_attrs)
|
338
|
+
end
|
339
|
+
end
|
340
|
+
|
341
|
+
def unbound_check_box(attrs = {})
|
342
|
+
label_text = unbound_label(attrs)
|
343
|
+
super + label_text
|
344
|
+
end
|
345
|
+
|
346
|
+
def unbound_hidden_field(attrs = {})
|
347
|
+
attrs.delete(:label)
|
348
|
+
super
|
349
|
+
end
|
350
|
+
|
351
|
+
def unbound_radio_button(attrs = {})
|
352
|
+
label_text = unbound_label(attrs)
|
353
|
+
super + label_text
|
354
|
+
end
|
355
|
+
|
356
|
+
def unbound_select(attrs = {})
|
357
|
+
unbound_label(attrs) + super
|
358
|
+
end
|
359
|
+
|
360
|
+
def unbound_text_area(contents, attrs = {})
|
361
|
+
unbound_label(attrs) + super
|
362
|
+
end
|
363
|
+
|
364
|
+
def button(contents, attrs = {})
|
365
|
+
unbound_label(attrs) + super
|
366
|
+
end
|
367
|
+
|
368
|
+
def submit(value, attrs = {})
|
369
|
+
unbound_label(attrs) + super
|
370
|
+
end
|
371
|
+
|
372
|
+
private
|
373
|
+
|
374
|
+
def update_bound_controls(method, attrs, type)
|
375
|
+
attrs.merge!(:id => "#{@name}_#{method}") unless attrs[:id]
|
376
|
+
super
|
377
|
+
end
|
378
|
+
|
379
|
+
def update_unbound_controls(attrs, type)
|
380
|
+
attrs.merge!(:id => attrs[:name]) if attrs[:name] && !attrs[:id]
|
381
|
+
|
382
|
+
case type
|
383
|
+
when "text", "radio", "password", "hidden", "checkbox", "file"
|
384
|
+
add_css_class(attrs, type)
|
385
|
+
end
|
386
|
+
super
|
387
|
+
end
|
388
|
+
|
389
|
+
def radio_group_item(method, attrs)
|
390
|
+
unless attrs[:id]
|
391
|
+
attrs.merge!(:id => "#{@name}_#{method}_#{attrs[:value]}")
|
392
|
+
end
|
393
|
+
|
394
|
+
attrs.merge!(:label => attrs[:label] || attrs[:value])
|
395
|
+
super
|
396
|
+
end
|
397
|
+
end
|
398
|
+
|
399
|
+
module Errorifier
|
400
|
+
def error_messages_for(obj, error_class, build_li, header, before)
|
401
|
+
obj ||= @obj
|
402
|
+
return "" unless obj.respond_to?(:errors)
|
403
|
+
|
404
|
+
sequel = !obj.errors.respond_to?(:each)
|
405
|
+
errors = sequel ? obj.errors.full_messages : obj.errors
|
406
|
+
|
407
|
+
return "" if errors.empty?
|
408
|
+
|
409
|
+
header_message = header % [errors.size, errors.size == 1 ? "" : "s"]
|
410
|
+
markup = %Q{<div class='#{error_class}'>#{header_message}<ul>}
|
411
|
+
errors.each {|err| markup << (build_li % (sequel ? err : err.join(" ")))}
|
412
|
+
markup << %Q{</ul></div>}
|
413
|
+
end
|
414
|
+
|
415
|
+
private
|
416
|
+
|
417
|
+
def update_bound_controls(method, attrs, type)
|
418
|
+
if @obj && !@obj.errors.on(method.to_sym).blank?
|
419
|
+
add_css_class(attrs, "error")
|
420
|
+
end
|
421
|
+
super
|
422
|
+
end
|
423
|
+
end
|
424
|
+
|
425
|
+
class FormWithErrors < Form
|
426
|
+
include Errorifier
|
427
|
+
end
|
428
|
+
|
429
|
+
module Resourceful
|
430
|
+
private
|
431
|
+
|
432
|
+
def process_form_attrs(attrs)
|
433
|
+
attrs[:action] ||= @origin.url(@name, @obj) if @origin
|
434
|
+
super
|
435
|
+
end
|
436
|
+
end
|
437
|
+
|
438
|
+
class ResourcefulForm < Form
|
439
|
+
include Resourceful
|
440
|
+
end
|
441
|
+
|
442
|
+
class ResourcefulFormWithErrors < FormWithErrors
|
443
|
+
include Errorifier
|
444
|
+
include Resourceful
|
445
|
+
end
|
446
|
+
|
447
|
+
end
|