autoforme 1.2.0 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG +12 -0
- data/MIT-LICENSE +1 -1
- data/README.rdoc +11 -0
- data/autoforme.js +6 -2
- data/lib/autoforme.rb +2 -0
- data/lib/autoforme/action.rb +39 -14
- data/lib/autoforme/framework.rb +11 -1
- data/lib/autoforme/frameworks/rails.rb +2 -0
- data/lib/autoforme/frameworks/roda.rb +2 -0
- data/lib/autoforme/frameworks/sinatra.rb +3 -1
- data/lib/autoforme/model.rb +11 -1
- data/lib/autoforme/models/sequel.rb +2 -0
- data/lib/autoforme/opts_attributes.rb +2 -0
- data/lib/autoforme/request.rb +2 -0
- data/lib/autoforme/table.rb +10 -4
- data/lib/autoforme/version.rb +3 -1
- data/lib/roda/plugins/autoforme.rb +2 -0
- data/spec/basic_spec.rb +68 -1
- data/spec/roda_spec_helper.rb +1 -0
- metadata +75 -6
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA1:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: d5d8f0b4739dec3afd2a850017943c1e63e611ef
         | 
| 4 | 
            +
              data.tar.gz: be9289f7da3c2769d9326df35f8e88c266795bf3
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: e9de31745c4580fd52d51f5222d314e566995d270e5ba9d68a3f32016a9e61571b89f9ceca871abb45fc4f9c8555f30149dacab5076ed60e82afb98457318c8f
         | 
| 7 | 
            +
              data.tar.gz: 5426d2b558346e01c15dc85a480f7811369bc3fbf555ad76d3a1045810fdd2b38c1fee8e3ac65cff84afa4b9bd4b46934abaaede05989655a119c29b9d7cf7a4
         | 
    
        data/CHANGELOG
    CHANGED
    
    | @@ -1,3 +1,15 @@ | |
| 1 | 
            +
            === 1.3.0 (2016-02-02)
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            * Add support for running with --enable-frozen-string-literal on ruby 2.3 (jeremyevans)
         | 
| 4 | 
            +
             | 
| 5 | 
            +
            * Make autoforme.js compatible with turbolinks (mrbrdo) (#3)
         | 
| 6 | 
            +
             | 
| 7 | 
            +
            * Force explicit labeler on show page, so that two columns are used (jeremyevans) (#2)
         | 
| 8 | 
            +
             | 
| 9 | 
            +
            * Add edit_html and show_html for overriding the html used for a field (jeremyevans) (#1)
         | 
| 10 | 
            +
             | 
| 11 | 
            +
            * Give the browse/search tables an id (jeremyevans)
         | 
| 12 | 
            +
             | 
| 1 13 | 
             
            === 1.2.0 (2015-05-21)
         | 
| 2 14 |  | 
| 3 15 | 
             
            * Add support for returning browse and search results in CSV format (jeremyevans)
         | 
    
        data/MIT-LICENSE
    CHANGED
    
    
    
        data/README.rdoc
    CHANGED
    
    | @@ -167,8 +167,12 @@ display_name :: The string to use when referring to a model instance.  Can eithe | |
| 167 167 | 
             
                            the model object and type symbol, or the model object, type symbol, and request,
         | 
| 168 168 | 
             
                            depending on the arity of the Proc.
         | 
| 169 169 | 
             
            link_name :: The string to use in links for the class
         | 
| 170 | 
            +
            edit_html :: The html to use for a particular object edit field.  Should be a proc that takes the
         | 
| 171 | 
            +
                         model object, column symbol, type symbol, and request and returns the html to use.
         | 
| 170 172 | 
             
            page_footer :: Override the default footer used for pages
         | 
| 171 173 | 
             
            page_header :: Override the default header used for pages
         | 
| 174 | 
            +
            show_html :: The html to use for displaying the value for an object field.  Should be a proc that takes the
         | 
| 175 | 
            +
                         model object, column symbol, type symbol, and request and returns the html to use.
         | 
| 172 176 | 
             
            table_class :: The html class string to use for the browse and search tables
         | 
| 173 177 |  | 
| 174 178 | 
             
            These hook options should be callable objects that are called with the model object and the request.
         | 
| @@ -227,6 +231,13 @@ class.  Example: | |
| 227 231 | 
             
                end
         | 
| 228 232 | 
             
              end
         | 
| 229 233 |  | 
| 234 | 
            +
            = Rails
         | 
| 235 | 
            +
             | 
| 236 | 
            +
            Because Rails separates routing from request handling, it can be little awkward to
         | 
| 237 | 
            +
            use AutoForme in Rails development mode.  The best way to handle it is to call
         | 
| 238 | 
            +
            +AutoForme.for+ in the related controller file, and have an initializer reference
         | 
| 239 | 
            +
            the controller class, causing the controller file to be loaded.
         | 
| 240 | 
            +
             | 
| 230 241 | 
             
            = TODO
         | 
| 231 242 |  | 
| 232 243 | 
             
            * capybara-webkit tests for ajax behavior
         | 
    
        data/autoforme.js
    CHANGED
    
    | @@ -1,4 +1,4 @@ | |
| 1 | 
            -
             | 
| 1 | 
            +
            var ready = function() {
         | 
| 2 2 | 
             
              var autoforme = $('#autoforme_content');
         | 
| 3 3 | 
             
              var base_url = autoforme.data('url');
         | 
| 4 4 |  | 
| @@ -74,4 +74,8 @@ $(function() { | |
| 74 74 | 
             
                });
         | 
| 75 75 | 
             
                e.preventDefault();
         | 
| 76 76 | 
             
              });
         | 
| 77 | 
            -
            } | 
| 77 | 
            +
            };
         | 
| 78 | 
            +
             | 
| 79 | 
            +
             | 
| 80 | 
            +
            $(document).ready(ready);
         | 
| 81 | 
            +
            $(document).on('page:load', ready);
         | 
    
        data/lib/autoforme.rb
    CHANGED
    
    
    
        data/lib/autoforme/action.rb
    CHANGED
    
    | @@ -1,3 +1,5 @@ | |
| 1 | 
            +
            # frozen-string-literal: true
         | 
| 2 | 
            +
             | 
| 1 3 | 
             
            require 'enum_csv'
         | 
| 2 4 |  | 
| 3 5 | 
             
            module AutoForme
         | 
| @@ -195,7 +197,8 @@ module AutoForme | |
| 195 197 |  | 
| 196 198 | 
             
                # HTML fragment for the default page header, which uses tabs for each supported action.
         | 
| 197 199 | 
             
                def tabs
         | 
| 198 | 
            -
                  content =  | 
| 200 | 
            +
                  content = String.new
         | 
| 201 | 
            +
                  content << '<ul class="nav nav-tabs">'
         | 
| 199 202 | 
             
                  Model::DEFAULT_SUPPORTED_ACTIONS.each do |action_type|
         | 
| 200 203 | 
             
                    if model.supported_action?(action_type, request)
         | 
| 201 204 | 
             
                      content << "<li class=\"#{'active' if type == action_type}\"><a href=\"#{url_for(action_type)}\">#{tab_name(action_type)}</a></li>"
         | 
| @@ -218,7 +221,7 @@ module AutoForme | |
| 218 221 |  | 
| 219 222 | 
             
                # Yields and wraps the returned data in a header and footer for the page.
         | 
| 220 223 | 
             
                def page
         | 
| 221 | 
            -
                  html =  | 
| 224 | 
            +
                  html = String.new
         | 
| 222 225 | 
             
                  html << (model.page_header_for(type, request) || tabs)
         | 
| 223 226 | 
             
                  html << "<div id='autoforme_content' data-url='#{url_for('')}'>"
         | 
| 224 227 | 
             
                  html << yield.to_s
         | 
| @@ -248,7 +251,11 @@ module AutoForme | |
| 248 251 | 
             
                  page do
         | 
| 249 252 | 
             
                    Forme.form(obj, form_attributes(:action=>url_for("create")), form_opts) do |f|
         | 
| 250 253 | 
             
                      model.columns_for(:new, request).each do |column|
         | 
| 251 | 
            -
                         | 
| 254 | 
            +
                        col_opts = column_options_for(:new, request, obj, column)
         | 
| 255 | 
            +
                        if html = model.edit_html_for(obj, column, :new, request)
         | 
| 256 | 
            +
                          col_opts = col_opts.merge(:html=>html)
         | 
| 257 | 
            +
                        end
         | 
| 258 | 
            +
                        f.input(column, col_opts)
         | 
| 252 259 | 
             
                      end
         | 
| 253 260 | 
             
                      f.button(:value=>'Create', :class=>'btn btn-primary')
         | 
| 254 261 | 
             
                    end
         | 
| @@ -300,11 +307,15 @@ module AutoForme | |
| 300 307 | 
             
                # The page to use when displaying an object, always used as a confirmation screen when deleting an object.
         | 
| 301 308 | 
             
                def show_page(obj)
         | 
| 302 309 | 
             
                  page do
         | 
| 303 | 
            -
                    t =  | 
| 304 | 
            -
                    f = Forme::Form.new(obj, :formatter=>:readonly, :wrapper=>:trtd)
         | 
| 310 | 
            +
                    t = String.new
         | 
| 311 | 
            +
                    f = Forme::Form.new(obj, :formatter=>:readonly, :wrapper=>:trtd, :labeler=>:explicit)
         | 
| 305 312 | 
             
                    t << "<table class=\"#{model.table_class_for(:show, request)}\">"
         | 
| 306 313 | 
             
                    model.columns_for(type, request).each do |column|
         | 
| 307 | 
            -
                       | 
| 314 | 
            +
                      col_opts = column_options_for(type, request, obj, column)
         | 
| 315 | 
            +
                      if html = model.show_html_for(obj, column, type, request)
         | 
| 316 | 
            +
                        col_opts = col_opts.merge(:html=>html)
         | 
| 317 | 
            +
                      end
         | 
| 318 | 
            +
                      t << f.input(column, col_opts).to_s
         | 
| 308 319 | 
             
                    end
         | 
| 309 320 | 
             
                    t << '</table>'
         | 
| 310 321 | 
             
                    if type == :show && model.supported_action?(:edit, request)
         | 
| @@ -335,9 +346,14 @@ module AutoForme | |
| 335 346 | 
             
                # The page to use when editing the object.
         | 
| 336 347 | 
             
                def edit_page(obj)
         | 
| 337 348 | 
             
                  page do
         | 
| 338 | 
            -
                    t =  | 
| 349 | 
            +
                    t = String.new
         | 
| 350 | 
            +
                    t << Forme.form(obj, form_attributes(:action=>url_for("update/#{model.primary_key_value(obj)}")), form_opts) do |f|
         | 
| 339 351 | 
             
                      model.columns_for(:edit, request).each do |column|
         | 
| 340 | 
            -
                         | 
| 352 | 
            +
                        col_opts = column_options_for(:edit, request, obj, column)
         | 
| 353 | 
            +
                        if html = model.edit_html_for(obj, column, :edit, request)
         | 
| 354 | 
            +
                          col_opts = col_opts.merge(:html=>html)
         | 
| 355 | 
            +
                        end
         | 
| 356 | 
            +
                        f.input(column, col_opts)
         | 
| 341 357 | 
             
                      end
         | 
| 342 358 | 
             
                      f.button(:value=>'Update', :class=>'btn btn-primary')
         | 
| 343 359 | 
             
                    end.to_s
         | 
| @@ -397,7 +413,8 @@ module AutoForme | |
| 397 413 |  | 
| 398 414 | 
             
                # HTML fragment for the table pager, showing links to next page or previous page for browse/search forms.
         | 
| 399 415 | 
             
                def table_pager(type, next_page)
         | 
| 400 | 
            -
                  html =  | 
| 416 | 
            +
                  html = String.new
         | 
| 417 | 
            +
                  html << '<ul class="pager">'
         | 
| 401 418 | 
             
                  page = request.id.to_i
         | 
| 402 419 | 
             
                  if page > 1
         | 
| 403 420 | 
             
                    html << "<li><a href=\"#{url_for("#{type}/#{page-1}?#{h request.query_string}")}\">Previous</a></li>"
         | 
| @@ -441,7 +458,11 @@ module AutoForme | |
| 441 458 | 
             
                    page do
         | 
| 442 459 | 
             
                      Forme.form(model.new(nil, request), form_attributes(:action=>url_for("search/1"), :method=>:get), form_opts) do |f|
         | 
| 443 460 | 
             
                        model.columns_for(:search_form, request).each do |column|
         | 
| 444 | 
            -
                           | 
| 461 | 
            +
                          col_opts = column_options_for(:search_form, request, f.obj, column).merge(:name=>column, :id=>column)
         | 
| 462 | 
            +
                          if html = model.edit_html_for(f.obj, column, :search_form, request)
         | 
| 463 | 
            +
                            col_opts[:html] = html
         | 
| 464 | 
            +
                          end
         | 
| 465 | 
            +
                          f.input(column, col_opts)
         | 
| 445 466 | 
             
                        end
         | 
| 446 467 | 
             
                        f.button(:value=>'Search', :class=>'btn btn-primary')
         | 
| 447 468 | 
             
                      end
         | 
| @@ -462,7 +483,8 @@ module AutoForme | |
| 462 483 | 
             
                    end
         | 
| 463 484 | 
             
                    if assoc
         | 
| 464 485 | 
             
                      page do
         | 
| 465 | 
            -
                        t =  | 
| 486 | 
            +
                        t = String.new
         | 
| 487 | 
            +
                        t << "<h2>Edit #{humanize(assoc)} for #{h model.object_display_name(type, request, obj)}</h2>"
         | 
| 466 488 | 
             
                        t << Forme.form(obj, form_attributes(:action=>url_for("mtm_update/#{model.primary_key_value(obj)}?association=#{assoc}")), form_opts) do |f|
         | 
| 467 489 | 
             
                          opts = model.column_options_for(:mtm_edit, request, assoc)
         | 
| 468 490 | 
             
                          add_opts = opts[:add] ? opts.merge(opts.delete(:add)) : opts
         | 
| @@ -542,7 +564,8 @@ module AutoForme | |
| 542 564 | 
             
                  assocs = model.association_links_for(type, request) 
         | 
| 543 565 | 
             
                  return if assocs.empty?
         | 
| 544 566 | 
             
                  read_only = type == :show
         | 
| 545 | 
            -
                  t =  | 
| 567 | 
            +
                  t = String.new
         | 
| 568 | 
            +
                  t << '<h3 class="associated_records_header">Associated Records</h3>'
         | 
| 546 569 | 
             
                  t << "<ul class='association_links'>\n"
         | 
| 547 570 | 
             
                  assocs.each do |assoc|
         | 
| 548 571 | 
             
                    mc = model.associated_model_class(assoc)
         | 
| @@ -620,7 +643,8 @@ module AutoForme | |
| 620 643 | 
             
                  assocs = model.inline_mtm_assocs(request)
         | 
| 621 644 | 
             
                  return if assocs.empty?
         | 
| 622 645 |  | 
| 623 | 
            -
                  t =  | 
| 646 | 
            +
                  t = String.new
         | 
| 647 | 
            +
                  t << "<div class='inline_mtm_add_associations'>"
         | 
| 624 648 | 
             
                  assocs.each do |assoc|
         | 
| 625 649 | 
             
                    form_attr = form_attributes(:action=>url_for("mtm_update/#{model.primary_key_value(obj)}?association=#{assoc}&redir=edit"), :class => 'mtm_add_associations', 'data-remove' => "##{assoc}_remove_list")
         | 
| 626 650 | 
             
                    t << Forme.form(obj, form_attr, form_opts) do |f|
         | 
| @@ -652,7 +676,8 @@ module AutoForme | |
| 652 676 |  | 
| 653 677 | 
             
                # Line item containing form to remove the currently associated object.
         | 
| 654 678 | 
             
                def mtm_edit_remove(assoc, mc, obj, assoc_obj)
         | 
| 655 | 
            -
                  t =  | 
| 679 | 
            +
                  t = String.new
         | 
| 680 | 
            +
                  t << "<li>"
         | 
| 656 681 | 
             
                  t << association_link(mc, assoc_obj)
         | 
| 657 682 | 
             
                  form_attr = form_attributes(:action=>url_for("mtm_update/#{model.primary_key_value(obj)}?association=#{assoc}&remove%5b%5d=#{model.primary_key_value(assoc_obj)}&redir=edit"), :method=>'post', :class => 'mtm_remove_associations', 'data-add'=>"#add_#{assoc}")
         | 
| 658 683 | 
             
                  t << Forme.form(form_attr, form_opts) do |f|
         | 
    
        data/lib/autoforme/framework.rb
    CHANGED
    
    | @@ -1,3 +1,5 @@ | |
| 1 | 
            +
            # frozen-string-literal: true
         | 
| 2 | 
            +
             | 
| 1 3 | 
             
            module AutoForme
         | 
| 2 4 | 
             
              # The Framework class contains forms for a set of models, tied to web
         | 
| 3 5 | 
             
              # framework controller.
         | 
| @@ -38,7 +40,7 @@ module AutoForme | |
| 38 40 | 
             
                  :columns, :display_name, :filter, :form_attributes, :form_options,
         | 
| 39 41 | 
             
                  :inline_mtm_associations, :lazy_load_association_links,
         | 
| 40 42 | 
             
                  :model_type, :mtm_associations, :order, :page_footer, :page_header, :per_page,
         | 
| 41 | 
            -
                  :redirect, :supported_actions, :table_class
         | 
| 43 | 
            +
                  :redirect, :supported_actions, :table_class, :show_html, :edit_html
         | 
| 42 44 |  | 
| 43 45 | 
             
                def initialize(controller, opts={})
         | 
| 44 46 | 
             
                  @controller = controller
         | 
| @@ -116,6 +118,14 @@ module AutoForme | |
| 116 118 | 
             
                  handle_proc(association_links, model, type, request)
         | 
| 117 119 | 
             
                end
         | 
| 118 120 |  | 
| 121 | 
            +
                def show_html_for(obj, column, type, request)
         | 
| 122 | 
            +
                  handle_proc(show_html, obj, column, type, request)
         | 
| 123 | 
            +
                end
         | 
| 124 | 
            +
             | 
| 125 | 
            +
                def edit_html_for(obj, column, type, request)
         | 
| 126 | 
            +
                  handle_proc(edit_html, obj, column, type, request)
         | 
| 127 | 
            +
                end
         | 
| 128 | 
            +
             | 
| 119 129 | 
             
                # Set whether to register classes by name instead of by reference
         | 
| 120 130 | 
             
                def register_by_name(register=true)
         | 
| 121 131 | 
             
                  opts[:register_by_name] = register
         | 
| @@ -1,3 +1,5 @@ | |
| 1 | 
            +
            # frozen-string-literal: true
         | 
| 2 | 
            +
             | 
| 1 3 | 
             
            module AutoForme
         | 
| 2 4 | 
             
              module Frameworks
         | 
| 3 5 | 
             
                class Sinatra < AutoForme::Framework
         | 
| @@ -48,7 +50,7 @@ module AutoForme | |
| 48 50 | 
             
                        elsif @autoforme_action.request.xhr?
         | 
| 49 51 | 
             
                          @autoforme_text
         | 
| 50 52 | 
             
                        else
         | 
| 51 | 
            -
                          erb "<%= @autoforme_text %>"
         | 
| 53 | 
            +
                          erb "<%= @autoforme_text %>".dup
         | 
| 52 54 | 
             
                        end
         | 
| 53 55 | 
             
                      else
         | 
| 54 56 | 
             
                        pass
         | 
    
        data/lib/autoforme/model.rb
    CHANGED
    
    | @@ -1,3 +1,5 @@ | |
| 1 | 
            +
            # frozen-string-literal: true
         | 
| 2 | 
            +
             | 
| 1 3 | 
             
            module AutoForme
         | 
| 2 4 | 
             
              # Wraps a specific model class
         | 
| 3 5 | 
             
              class Model
         | 
| @@ -39,7 +41,7 @@ module AutoForme | |
| 39 41 | 
             
                  :filter, :form_attributes, :form_options,
         | 
| 40 42 | 
             
                  :inline_mtm_associations, :lazy_load_association_links, :link_name, :mtm_associations,
         | 
| 41 43 | 
             
                  :order, :page_footer, :page_header, :per_page,
         | 
| 42 | 
            -
                  :redirect, :supported_actions, :table_class
         | 
| 44 | 
            +
                  :redirect, :supported_actions, :table_class, :show_html, :edit_html
         | 
| 43 45 |  | 
| 44 46 | 
             
                def initialize(model, framework)
         | 
| 45 47 | 
             
                  @model = model
         | 
| @@ -143,6 +145,14 @@ module AutoForme | |
| 143 145 | 
             
                  opts
         | 
| 144 146 | 
             
                end
         | 
| 145 147 |  | 
| 148 | 
            +
                def show_html_for(obj, column, type, request)
         | 
| 149 | 
            +
                  handle_proc(show_html || framework.show_html_for(obj, column, type, request), obj, column, type, request)
         | 
| 150 | 
            +
                end
         | 
| 151 | 
            +
             | 
| 152 | 
            +
                def edit_html_for(obj, column, type, request)
         | 
| 153 | 
            +
                  handle_proc(edit_html || framework.edit_html_for(obj, column, type, request), obj, column, type, request)
         | 
| 154 | 
            +
                end
         | 
| 155 | 
            +
             | 
| 146 156 | 
             
                def order_for(type, request)
         | 
| 147 157 | 
             
                  handle_proc(order || framework.order_for(model, type, request), type, request)
         | 
| 148 158 | 
             
                end
         | 
    
        data/lib/autoforme/request.rb
    CHANGED
    
    
    
        data/lib/autoforme/table.rb
    CHANGED
    
    | @@ -1,3 +1,5 @@ | |
| 1 | 
            +
            # frozen-string-literal: true
         | 
| 2 | 
            +
             | 
| 1 3 | 
             
            module AutoForme
         | 
| 2 4 | 
             
              # Helper class for formating HTML tables used for the browse/search results pages.
         | 
| 3 5 | 
             
              class Table
         | 
| @@ -38,7 +40,8 @@ module AutoForme | |
| 38 40 |  | 
| 39 41 | 
             
                # Return an HTML string for the table.
         | 
| 40 42 | 
             
                def to_s
         | 
| 41 | 
            -
                  html =  | 
| 43 | 
            +
                  html = String.new
         | 
| 44 | 
            +
                  html << "<table id=\"autoforme_table\" class=\"#{model.table_class_for(type, request)}\">"
         | 
| 42 45 | 
             
                  if caption = opts[:caption]
         | 
| 43 46 | 
             
                    html << "<caption>#{h caption}</caption>"
         | 
| 44 47 | 
             
                  end
         | 
| @@ -56,9 +59,12 @@ module AutoForme | |
| 56 59 | 
             
                  objs.each do |obj|
         | 
| 57 60 | 
             
                    html << "<tr>"
         | 
| 58 61 | 
             
                    columns.each do |column|
         | 
| 59 | 
            -
                      val = model. | 
| 60 | 
            -
             | 
| 61 | 
            -
             | 
| 62 | 
            +
                      unless val = model.show_html_for(obj, column, type, request)
         | 
| 63 | 
            +
                        val = model.column_value(type, request, obj, column)
         | 
| 64 | 
            +
                        val = val.to_s('F') if defined?(BigDecimal) && val.is_a?(BigDecimal)
         | 
| 65 | 
            +
                        val = h(val)
         | 
| 66 | 
            +
                      end
         | 
| 67 | 
            +
                      html << "<td>#{val}</td>"
         | 
| 62 68 | 
             
                    end
         | 
| 63 69 | 
             
                    html << "<td><a href=\"#{action.url_for("show/#{model.primary_key_value(obj)}")}\" class=\"btn btn-mini btn-info\">Show</a></td>" if show
         | 
| 64 70 | 
             
                    html << "<td><a href=\"#{action.url_for("edit/#{model.primary_key_value(obj)}")}\" class=\"btn btn-mini btn-primary\">Edit</a></td>" if edit
         | 
    
        data/lib/autoforme/version.rb
    CHANGED
    
    
    
        data/spec/basic_spec.rb
    CHANGED
    
    | @@ -38,6 +38,7 @@ describe AutoForme do | |
| 38 38 | 
             
                page.title.must_equal 'Artist - Search'
         | 
| 39 39 | 
             
                fill_in 'Name', :with=>'Upd'
         | 
| 40 40 | 
             
                click_button 'Search'
         | 
| 41 | 
            +
                page.all('table').first['id'].must_equal 'autoforme_table'
         | 
| 41 42 | 
             
                page.all('th').map{|s| s.text}.must_equal ['Name', 'Show', 'Edit', 'Delete']
         | 
| 42 43 | 
             
                page.all('td').map{|s| s.text}.must_equal ["TestArtistUpdate", "Show", "Edit", "Delete"]
         | 
| 43 44 | 
             
                click_link 'CSV Format'
         | 
| @@ -245,7 +246,7 @@ describe AutoForme do | |
| 245 246 | 
             
                  before_create{|obj, req| a << -1}
         | 
| 246 247 | 
             
                  before_update{|obj, req| a << -2}
         | 
| 247 248 | 
             
                  before_destroy{|obj, req| a << -3}
         | 
| 248 | 
            -
                  before_new{|obj, req| obj.name = 'weNtsitrAtseT'}
         | 
| 249 | 
            +
                  before_new{|obj, req| obj.name = 'weNtsitrAtseT'.dup}
         | 
| 249 250 | 
             
                  before_edit{|obj, req| obj.name << '2'}
         | 
| 250 251 | 
             
                  after_create{|obj, req| a << 1 }
         | 
| 251 252 | 
             
                  after_update{|obj, req| a << 2 }
         | 
| @@ -411,6 +412,72 @@ describe AutoForme do | |
| 411 412 | 
             
                click_button 'Delete'
         | 
| 412 413 | 
             
                Artist.count.must_equal 0
         | 
| 413 414 | 
             
              end
         | 
| 415 | 
            +
             | 
| 416 | 
            +
              it "should support show_html and edit_html" do
         | 
| 417 | 
            +
                app_setup(Artist) do
         | 
| 418 | 
            +
                  show_html do |obj, c, t, req|
         | 
| 419 | 
            +
                    "#{c}#{t}-#{obj.send(c).to_s*2}"
         | 
| 420 | 
            +
                  end
         | 
| 421 | 
            +
                  edit_html do |obj, c, t, req|
         | 
| 422 | 
            +
                    "<label for='artist_#{c}'>#{c}#{t}</label><input type='text' id='artist_#{c}' name='#{t == :search_form ? c : "artist[#{c}]"}' value='#{obj.send(c).to_s*2}'/>"
         | 
| 423 | 
            +
                  end
         | 
| 424 | 
            +
                end
         | 
| 425 | 
            +
                visit("/Artist/new")
         | 
| 426 | 
            +
                page.title.must_equal 'Artist - New'
         | 
| 427 | 
            +
                fill_in 'namenew', :with=>'TAN'
         | 
| 428 | 
            +
                click_button 'Create'
         | 
| 429 | 
            +
                page.html.must_match /Created Artist/
         | 
| 430 | 
            +
                page.current_path.must_equal '/Artist/new'
         | 
| 431 | 
            +
             | 
| 432 | 
            +
                click_link 'Show'
         | 
| 433 | 
            +
                page.title.must_equal 'Artist - Show'
         | 
| 434 | 
            +
                select 'TAN'
         | 
| 435 | 
            +
                click_button 'Show'
         | 
| 436 | 
            +
                page.html.must_match /nameshow-TANTAN/
         | 
| 437 | 
            +
             | 
| 438 | 
            +
                click_link 'Edit'
         | 
| 439 | 
            +
                page.title.must_equal 'Artist - Edit'
         | 
| 440 | 
            +
                select 'TAN'
         | 
| 441 | 
            +
                click_button 'Edit'
         | 
| 442 | 
            +
                fill_in 'nameedit', :with=>'TAU'
         | 
| 443 | 
            +
                click_button 'Update'
         | 
| 444 | 
            +
                page.html.must_match /Updated Artist/
         | 
| 445 | 
            +
                page.html.must_match /nameedit.+TAUTAU/m
         | 
| 446 | 
            +
                page.current_path.must_match %r{/Artist/edit/\d+}
         | 
| 447 | 
            +
             | 
| 448 | 
            +
                click_link 'Search'
         | 
| 449 | 
            +
                page.title.must_equal 'Artist - Search'
         | 
| 450 | 
            +
                fill_in 'namesearch_form', :with=>'AU'
         | 
| 451 | 
            +
                click_button 'Search'
         | 
| 452 | 
            +
                page.all('table').first['id'].must_equal 'autoforme_table'
         | 
| 453 | 
            +
                page.all('th').map{|s| s.text}.must_equal ['Name', 'Show', 'Edit', 'Delete']
         | 
| 454 | 
            +
                page.all('td').map{|s| s.text}.must_equal ["namesearch-TAUTAU", "Show", "Edit", "Delete"]
         | 
| 455 | 
            +
                click_link 'CSV Format'
         | 
| 456 | 
            +
                page.body.must_equal "Name\nTAU\n"
         | 
| 457 | 
            +
             | 
| 458 | 
            +
                visit("/Artist/browse")
         | 
| 459 | 
            +
                click_link 'Search'
         | 
| 460 | 
            +
                fill_in 'namesearch_form', :with=>'TAUTAU'
         | 
| 461 | 
            +
                click_button 'Search'
         | 
| 462 | 
            +
                page.all('td').map{|s| s.text}.must_equal []
         | 
| 463 | 
            +
             | 
| 464 | 
            +
                click_link 'Artist'
         | 
| 465 | 
            +
                page.title.must_equal 'Artist - Browse'
         | 
| 466 | 
            +
                page.all('td').map{|s| s.text}.must_equal ["namebrowse-TAUTAU", "Show", "Edit", "Delete"]
         | 
| 467 | 
            +
                click_link 'CSV Format'
         | 
| 468 | 
            +
                page.body.must_equal "Name\nTAU\n"
         | 
| 469 | 
            +
             | 
| 470 | 
            +
                visit("/Artist/browse")
         | 
| 471 | 
            +
                page.all('td').last.find('a').click
         | 
| 472 | 
            +
                page.html.must_match /namedelete-TAUTAU/
         | 
| 473 | 
            +
                click_button 'Delete'
         | 
| 474 | 
            +
                page.title.must_equal 'Artist - Delete'
         | 
| 475 | 
            +
                page.html.must_match /Deleted Artist/
         | 
| 476 | 
            +
                page.current_path.must_equal '/Artist/delete'
         | 
| 477 | 
            +
             | 
| 478 | 
            +
                click_link 'Artist'
         | 
| 479 | 
            +
                page.all('td').map{|s| s.text}.must_equal []
         | 
| 480 | 
            +
              end
         | 
| 414 481 | 
             
            end
         | 
| 415 482 |  | 
| 416 483 | 
             
            describe AutoForme do
         | 
    
        data/spec/roda_spec_helper.rb
    CHANGED
    
    
    
        metadata
    CHANGED
    
    | @@ -1,14 +1,14 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: autoforme
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 1. | 
| 4 | 
            +
              version: 1.3.0
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - Jeremy Evans
         | 
| 8 8 | 
             
            autorequire: 
         | 
| 9 9 | 
             
            bindir: bin
         | 
| 10 10 | 
             
            cert_chain: []
         | 
| 11 | 
            -
            date:  | 
| 11 | 
            +
            date: 2016-02-02 00:00:00.000000000 Z
         | 
| 12 12 | 
             
            dependencies:
         | 
| 13 13 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 14 14 | 
             
              name: forme
         | 
| @@ -16,14 +16,14 @@ dependencies: | |
| 16 16 | 
             
                requirements:
         | 
| 17 17 | 
             
                - - ">="
         | 
| 18 18 | 
             
                  - !ruby/object:Gem::Version
         | 
| 19 | 
            -
                    version:  | 
| 19 | 
            +
                    version: 1.4.0
         | 
| 20 20 | 
             
              type: :runtime
         | 
| 21 21 | 
             
              prerelease: false
         | 
| 22 22 | 
             
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 23 23 | 
             
                requirements:
         | 
| 24 24 | 
             
                - - ">="
         | 
| 25 25 | 
             
                  - !ruby/object:Gem::Version
         | 
| 26 | 
            -
                    version:  | 
| 26 | 
            +
                    version: 1.4.0
         | 
| 27 27 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 28 28 | 
             
              name: rack
         | 
| 29 29 | 
             
              requirement: !ruby/object:Gem::Requirement
         | 
| @@ -108,6 +108,76 @@ dependencies: | |
| 108 108 | 
             
                - - ">="
         | 
| 109 109 | 
             
                  - !ruby/object:Gem::Version
         | 
| 110 110 | 
             
                    version: 2.1.0
         | 
| 111 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 112 | 
            +
              name: roda
         | 
| 113 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 114 | 
            +
                requirements:
         | 
| 115 | 
            +
                - - ">="
         | 
| 116 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 117 | 
            +
                    version: '0'
         | 
| 118 | 
            +
              type: :development
         | 
| 119 | 
            +
              prerelease: false
         | 
| 120 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 121 | 
            +
                requirements:
         | 
| 122 | 
            +
                - - ">="
         | 
| 123 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 124 | 
            +
                    version: '0'
         | 
| 125 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 126 | 
            +
              name: rack_csrf
         | 
| 127 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 128 | 
            +
                requirements:
         | 
| 129 | 
            +
                - - ">="
         | 
| 130 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 131 | 
            +
                    version: '0'
         | 
| 132 | 
            +
              type: :development
         | 
| 133 | 
            +
              prerelease: false
         | 
| 134 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 135 | 
            +
                requirements:
         | 
| 136 | 
            +
                - - ">="
         | 
| 137 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 138 | 
            +
                    version: '0'
         | 
| 139 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 140 | 
            +
              name: sinatra
         | 
| 141 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 142 | 
            +
                requirements:
         | 
| 143 | 
            +
                - - ">="
         | 
| 144 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 145 | 
            +
                    version: '0'
         | 
| 146 | 
            +
              type: :development
         | 
| 147 | 
            +
              prerelease: false
         | 
| 148 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 149 | 
            +
                requirements:
         | 
| 150 | 
            +
                - - ">="
         | 
| 151 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 152 | 
            +
                    version: '0'
         | 
| 153 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 154 | 
            +
              name: sinatra-flash
         | 
| 155 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 156 | 
            +
                requirements:
         | 
| 157 | 
            +
                - - ">="
         | 
| 158 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 159 | 
            +
                    version: '0'
         | 
| 160 | 
            +
              type: :development
         | 
| 161 | 
            +
              prerelease: false
         | 
| 162 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 163 | 
            +
                requirements:
         | 
| 164 | 
            +
                - - ">="
         | 
| 165 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 166 | 
            +
                    version: '0'
         | 
| 167 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 168 | 
            +
              name: rails
         | 
| 169 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 170 | 
            +
                requirements:
         | 
| 171 | 
            +
                - - ">="
         | 
| 172 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 173 | 
            +
                    version: '0'
         | 
| 174 | 
            +
              type: :development
         | 
| 175 | 
            +
              prerelease: false
         | 
| 176 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 177 | 
            +
                requirements:
         | 
| 178 | 
            +
                - - ">="
         | 
| 179 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 180 | 
            +
                    version: '0'
         | 
| 111 181 | 
             
            description: |
         | 
| 112 182 | 
             
              AutoForme is an web administrative console for Sequel::Model that
         | 
| 113 183 | 
             
              supports Sinatra and Rails.  It offers the following features:
         | 
| @@ -181,9 +251,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement | |
| 181 251 | 
             
                  version: '0'
         | 
| 182 252 | 
             
            requirements: []
         | 
| 183 253 | 
             
            rubyforge_project: 
         | 
| 184 | 
            -
            rubygems_version: 2. | 
| 254 | 
            +
            rubygems_version: 2.5.1
         | 
| 185 255 | 
             
            signing_key: 
         | 
| 186 256 | 
             
            specification_version: 4
         | 
| 187 257 | 
             
            summary: Web Administrative Console for Sinatra/Rails and Sequel
         | 
| 188 258 | 
             
            test_files: []
         | 
| 189 | 
            -
            has_rdoc: true
         |