acts_as_railable 0.3.0 → 0.4.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/lib/acts_as_railable/railtie.rb +5 -0
 - data/lib/acts_as_railable/version.rb +1 -1
 - data/lib/acts_as_railable/view_helpers.rb +132 -0
 - data/lib/acts_as_railable.rb +1 -1
 - metadata +3 -2
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA256:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: fdd0050a08bd25499046cc5913df3966af963cb4020f196772b4c67659a85a80
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: 3aac2d44904b4b9bbe1abc1fd98695c5686b0b0f85b82714af6e957c454af18c
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: 7c79fc4c2c54a8038d2a1cc900d10f021f1e09c92b573031ec30217d27242554fb42c82e447536d5a8d04113e858c392e01d4bc7af10014284fd3e0870b3d072
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: 529a059eed3e9b18d85a64bbf81b7d6e996398e4aec9001f1b56c536bf355d833a85cccfeae749af72b49262d8d95a4f190e9741ade795ac5d04f7893c7bef33
         
     | 
| 
         @@ -0,0 +1,132 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            module ActsAsRailable
         
     | 
| 
      
 2 
     | 
    
         
            +
              module ViewHelpers
         
     | 
| 
      
 3 
     | 
    
         
            +
                def void_link_to name, html_options=nil
         
     | 
| 
      
 4 
     | 
    
         
            +
                  link_to name, "javascript:void(0);", html_options
         
     | 
| 
      
 5 
     | 
    
         
            +
                end
         
     | 
| 
      
 6 
     | 
    
         
            +
             
     | 
| 
      
 7 
     | 
    
         
            +
                def back_link_to name, html_options
         
     | 
| 
      
 8 
     | 
    
         
            +
                  link_to name, :back, html_options
         
     | 
| 
      
 9 
     | 
    
         
            +
                end
         
     | 
| 
      
 10 
     | 
    
         
            +
             
     | 
| 
      
 11 
     | 
    
         
            +
                def native_flash_messages!
         
     | 
| 
      
 12 
     | 
    
         
            +
                  html = ""
         
     | 
| 
      
 13 
     | 
    
         
            +
                  flash.each do |name, msg|
         
     | 
| 
      
 14 
     | 
    
         
            +
                    if msg.is_a? String
         
     | 
| 
      
 15 
     | 
    
         
            +
                      color_code = name == 'notice' ? 'green' : 'red'
         
     | 
| 
      
 16 
     | 
    
         
            +
                      flash_style = "color: #{color_code}"
         
     | 
| 
      
 17 
     | 
    
         
            +
                      html += <<-HTML
         
     | 
| 
      
 18 
     | 
    
         
            +
                      <p style="#{flash_style}">
         
     | 
| 
      
 19 
     | 
    
         
            +
                        #{msg}
         
     | 
| 
      
 20 
     | 
    
         
            +
                      </p>
         
     | 
| 
      
 21 
     | 
    
         
            +
                      HTML
         
     | 
| 
      
 22 
     | 
    
         
            +
                    end
         
     | 
| 
      
 23 
     | 
    
         
            +
                  end
         
     | 
| 
      
 24 
     | 
    
         
            +
                  html.html_safe
         
     | 
| 
      
 25 
     | 
    
         
            +
                end
         
     | 
| 
      
 26 
     | 
    
         
            +
             
     | 
| 
      
 27 
     | 
    
         
            +
                def bootstrap_flash_messages!
         
     | 
| 
      
 28 
     | 
    
         
            +
                  html = ""
         
     | 
| 
      
 29 
     | 
    
         
            +
                  flash.each do |name, msg|
         
     | 
| 
      
 30 
     | 
    
         
            +
                    if msg.is_a? String
         
     | 
| 
      
 31 
     | 
    
         
            +
                      color_code = name == 'notice' ? 'success' : 'danger'
         
     | 
| 
      
 32 
     | 
    
         
            +
                      flash_class = "alert alert-#{color_code} alert-dismissible fade show"
         
     | 
| 
      
 33 
     | 
    
         
            +
                      html += <<-HTML
         
     | 
| 
      
 34 
     | 
    
         
            +
                      <div class="#{flash_class}" role="alert">
         
     | 
| 
      
 35 
     | 
    
         
            +
                        <div>#{msg}</div>
         
     | 
| 
      
 36 
     | 
    
         
            +
                        <button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
         
     | 
| 
      
 37 
     | 
    
         
            +
                      </div>
         
     | 
| 
      
 38 
     | 
    
         
            +
                      HTML
         
     | 
| 
      
 39 
     | 
    
         
            +
                    end
         
     | 
| 
      
 40 
     | 
    
         
            +
                  end
         
     | 
| 
      
 41 
     | 
    
         
            +
                  html.html_safe
         
     | 
| 
      
 42 
     | 
    
         
            +
                end
         
     | 
| 
      
 43 
     | 
    
         
            +
             
     | 
| 
      
 44 
     | 
    
         
            +
                def native_form_error_messages!(object)
         
     | 
| 
      
 45 
     | 
    
         
            +
                  if object.errors.any?
         
     | 
| 
      
 46 
     | 
    
         
            +
                    messages = object.errors.full_messages.map { |msg| content_tag(:li, msg) }.join
         
     | 
| 
      
 47 
     | 
    
         
            +
                    sentence = I18n.t("errors.template.header",
         
     | 
| 
      
 48 
     | 
    
         
            +
                                      count: object.errors.count,
         
     | 
| 
      
 49 
     | 
    
         
            +
                                      model: object.class.model_name.human.downcase)
         
     | 
| 
      
 50 
     | 
    
         
            +
                    bodyhead = I18n.t("errors.template.body")
         
     | 
| 
      
 51 
     | 
    
         
            +
             
     | 
| 
      
 52 
     | 
    
         
            +
                    html = <<-HTML
         
     | 
| 
      
 53 
     | 
    
         
            +
                      <div id="#{object.form_error_placeholder_id}" style="color: red">
         
     | 
| 
      
 54 
     | 
    
         
            +
                        <h2>#{sentence}</h2>
         
     | 
| 
      
 55 
     | 
    
         
            +
                        <ul>#{messages}</ul>
         
     | 
| 
      
 56 
     | 
    
         
            +
                      </div>
         
     | 
| 
      
 57 
     | 
    
         
            +
                    HTML
         
     | 
| 
      
 58 
     | 
    
         
            +
                  else
         
     | 
| 
      
 59 
     | 
    
         
            +
                    html = <<-HTML
         
     | 
| 
      
 60 
     | 
    
         
            +
                      <div id="#{object.form_error_placeholder_id}">
         
     | 
| 
      
 61 
     | 
    
         
            +
                      </div>
         
     | 
| 
      
 62 
     | 
    
         
            +
                    HTML
         
     | 
| 
      
 63 
     | 
    
         
            +
                  end
         
     | 
| 
      
 64 
     | 
    
         
            +
             
     | 
| 
      
 65 
     | 
    
         
            +
                  html.html_safe
         
     | 
| 
      
 66 
     | 
    
         
            +
                end
         
     | 
| 
      
 67 
     | 
    
         
            +
             
     | 
| 
      
 68 
     | 
    
         
            +
                def bootstrap_form_error_messages!(object)
         
     | 
| 
      
 69 
     | 
    
         
            +
                  if object.errors.any?
         
     | 
| 
      
 70 
     | 
    
         
            +
                    messages = object.errors.full_messages.map { |msg| content_tag(:li, msg) }.join
         
     | 
| 
      
 71 
     | 
    
         
            +
                    sentence = I18n.t("errors.template.header",
         
     | 
| 
      
 72 
     | 
    
         
            +
                                      count: object.errors.count,
         
     | 
| 
      
 73 
     | 
    
         
            +
                                      model: object.class.model_name.human.downcase)
         
     | 
| 
      
 74 
     | 
    
         
            +
                    bodyhead = I18n.t("errors.template.body")
         
     | 
| 
      
 75 
     | 
    
         
            +
             
     | 
| 
      
 76 
     | 
    
         
            +
                    html = <<-HTML
         
     | 
| 
      
 77 
     | 
    
         
            +
                      <div id="#{object.form_error_placeholder_id}">
         
     | 
| 
      
 78 
     | 
    
         
            +
                        <div class="alert alert-danger" role="alert">
         
     | 
| 
      
 79 
     | 
    
         
            +
                          <h6 class="alert-heading">#{sentence}</h6>
         
     | 
| 
      
 80 
     | 
    
         
            +
                          <ul class="mb-0">#{messages}</ul>
         
     | 
| 
      
 81 
     | 
    
         
            +
                        </div>
         
     | 
| 
      
 82 
     | 
    
         
            +
                      </div>
         
     | 
| 
      
 83 
     | 
    
         
            +
                    HTML
         
     | 
| 
      
 84 
     | 
    
         
            +
                  else
         
     | 
| 
      
 85 
     | 
    
         
            +
                    html = <<-HTML
         
     | 
| 
      
 86 
     | 
    
         
            +
                      <div id="#{object.form_error_placeholder_id}">
         
     | 
| 
      
 87 
     | 
    
         
            +
                      </div>
         
     | 
| 
      
 88 
     | 
    
         
            +
                    HTML
         
     | 
| 
      
 89 
     | 
    
         
            +
                  end
         
     | 
| 
      
 90 
     | 
    
         
            +
             
     | 
| 
      
 91 
     | 
    
         
            +
                  html.html_safe
         
     | 
| 
      
 92 
     | 
    
         
            +
                end
         
     | 
| 
      
 93 
     | 
    
         
            +
             
     | 
| 
      
 94 
     | 
    
         
            +
                def native_devise_error_messages!(resource)
         
     | 
| 
      
 95 
     | 
    
         
            +
                  return "" if resource.errors.empty?
         
     | 
| 
      
 96 
     | 
    
         
            +
             
     | 
| 
      
 97 
     | 
    
         
            +
                  messages = resource.errors.full_messages.map { |msg| content_tag(:li, msg) }.join
         
     | 
| 
      
 98 
     | 
    
         
            +
                  sentence = I18n.t("errors.messages.not_saved",
         
     | 
| 
      
 99 
     | 
    
         
            +
                                    count: resource.errors.count,
         
     | 
| 
      
 100 
     | 
    
         
            +
                                    resource: resource.class.model_name.human.downcase)
         
     | 
| 
      
 101 
     | 
    
         
            +
                  bodyhead = I18n.t("errors.template.body")
         
     | 
| 
      
 102 
     | 
    
         
            +
             
     | 
| 
      
 103 
     | 
    
         
            +
                  html = <<-HTML
         
     | 
| 
      
 104 
     | 
    
         
            +
                    <div id="error_explanation">
         
     | 
| 
      
 105 
     | 
    
         
            +
                      <h2>#{sentence}</h2>
         
     | 
| 
      
 106 
     | 
    
         
            +
                      <ul>#{messages}</ul>
         
     | 
| 
      
 107 
     | 
    
         
            +
                    </div>
         
     | 
| 
      
 108 
     | 
    
         
            +
                  HTML
         
     | 
| 
      
 109 
     | 
    
         
            +
             
     | 
| 
      
 110 
     | 
    
         
            +
                  html.html_safe
         
     | 
| 
      
 111 
     | 
    
         
            +
                end
         
     | 
| 
      
 112 
     | 
    
         
            +
             
     | 
| 
      
 113 
     | 
    
         
            +
                def bootstrap_devise_error_messages!(resource)
         
     | 
| 
      
 114 
     | 
    
         
            +
                  return "" if resource.errors.empty?
         
     | 
| 
      
 115 
     | 
    
         
            +
             
     | 
| 
      
 116 
     | 
    
         
            +
                  messages = resource.errors.full_messages.map { |msg| content_tag(:li, msg) }.join
         
     | 
| 
      
 117 
     | 
    
         
            +
                  sentence = I18n.t("errors.messages.not_saved",
         
     | 
| 
      
 118 
     | 
    
         
            +
                                    count: resource.errors.count,
         
     | 
| 
      
 119 
     | 
    
         
            +
                                    resource: resource.class.model_name.human.downcase)
         
     | 
| 
      
 120 
     | 
    
         
            +
                  bodyhead = I18n.t("errors.template.body")
         
     | 
| 
      
 121 
     | 
    
         
            +
             
     | 
| 
      
 122 
     | 
    
         
            +
                  html = <<-HTML
         
     | 
| 
      
 123 
     | 
    
         
            +
                  <div class="alert alert-danger" role="alert">
         
     | 
| 
      
 124 
     | 
    
         
            +
                    <h6>#{sentence}</h6>
         
     | 
| 
      
 125 
     | 
    
         
            +
                    <ul class="my-0">#{messages}</ul>
         
     | 
| 
      
 126 
     | 
    
         
            +
                  </div>
         
     | 
| 
      
 127 
     | 
    
         
            +
                  HTML
         
     | 
| 
      
 128 
     | 
    
         
            +
             
     | 
| 
      
 129 
     | 
    
         
            +
                  html.html_safe
         
     | 
| 
      
 130 
     | 
    
         
            +
                end
         
     | 
| 
      
 131 
     | 
    
         
            +
              end
         
     | 
| 
      
 132 
     | 
    
         
            +
            end
         
     | 
    
        data/lib/acts_as_railable.rb
    CHANGED
    
    
    
        metadata
    CHANGED
    
    | 
         @@ -1,14 +1,14 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: acts_as_railable
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version
         
     | 
| 
       4 
     | 
    
         
            -
              version: 0. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 0.4.0
         
     | 
| 
       5 
5 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       6 
6 
     | 
    
         
             
            authors:
         
     | 
| 
       7 
7 
     | 
    
         
             
            - Li Qi
         
     | 
| 
       8 
8 
     | 
    
         
             
            autorequire:
         
     | 
| 
       9 
9 
     | 
    
         
             
            bindir: bin
         
     | 
| 
       10 
10 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       11 
     | 
    
         
            -
            date: 2022-04- 
     | 
| 
      
 11 
     | 
    
         
            +
            date: 2022-04-22 00:00:00.000000000 Z
         
     | 
| 
       12 
12 
     | 
    
         
             
            dependencies:
         
     | 
| 
       13 
13 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       14 
14 
     | 
    
         
             
              name: rails
         
     | 
| 
         @@ -40,6 +40,7 @@ files: 
     | 
|
| 
       40 
40 
     | 
    
         
             
            - lib/acts_as_railable/interval.rb
         
     | 
| 
       41 
41 
     | 
    
         
             
            - lib/acts_as_railable/railtie.rb
         
     | 
| 
       42 
42 
     | 
    
         
             
            - lib/acts_as_railable/version.rb
         
     | 
| 
      
 43 
     | 
    
         
            +
            - lib/acts_as_railable/view_helpers.rb
         
     | 
| 
       43 
44 
     | 
    
         
             
            - lib/tasks/acts_as_railable_tasks.rake
         
     | 
| 
       44 
45 
     | 
    
         
             
            homepage: http://github.com/cloudbsd/acts_as_moonable
         
     | 
| 
       45 
46 
     | 
    
         
             
            licenses:
         
     |