rails_utils 3.2.2 → 3.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7166c5b4a4b5666c7f5437f05141d887be49262d
4
- data.tar.gz: 02cef886ad60d0c220f6c1d58fc6590136f53bde
3
+ metadata.gz: 1b74801dca81a0f37b7c7c1d437d11d968c48fb4
4
+ data.tar.gz: 97ff2354d937ae47037a098f4ca27ac634fa4beb
5
5
  SHA512:
6
- metadata.gz: 2e18e7c2f93768d6657bf9a07370c4260ec9768398ef2de01a4fa7e2f30ab5a2ed60927bd1d1e87fdd3c16195c63e043d6c7124662dfdee02e904078945d7844
7
- data.tar.gz: 5f306f45b70d3f8b1d1314f72f76efac1e82c7c4061d0b82b7d98f1e86c6f7ddf21dd5d46dcfccba5c267c32ce296fc1ac39eb40697ab666ea40bda83c2c48a9
6
+ metadata.gz: 4d41c4c24a71d0c465fc8b59fe4e81d9b28cbbc898f92a63e28e910695763a98e9c8dfeeec3fb97638f9624b9eed7fefae5590f3f09bee9f4e4bd6a9ef97bb93
7
+ data.tar.gz: 70a60df61784f419f58574a851a589bad462fb5c2ec558c232f01efe5e5426b1f56062f03f78c817e78655a8f01051ae097a369df0d1a9265321feda8db3424a
data/README.md CHANGED
@@ -15,21 +15,21 @@ Rails helpers based on opinionated project practices. Currently useful for struc
15
15
  This helper method returns controller name and action name as a single string value,
16
16
  which can be used to target CSS styles specifically for this controller or action.
17
17
 
18
- For example, when controller and action is `anime#show`,
18
+ For example, when controller and action is `animes#show`,
19
19
  you can use `page_class` to include the controller name and action name as CSS classes on the page.
20
20
 
21
21
  %body{ class: page_class }
22
22
 
23
23
  becomes
24
24
 
25
- <body class='anime show'>
25
+ <body class='animes show'>
26
26
 
27
27
  Then in your CSS, you can either target your styles specific to controller and/or action.
28
28
 
29
- body.anime
29
+ body.animes
30
30
  background: black
31
31
 
32
- body.anime.show
32
+ body.animes.show
33
33
  font-size: 24px
34
34
 
35
35
  Usually, when the `create` or `update` actions render, the `new` or `edit` views will be rendered due to a form error.
@@ -44,14 +44,14 @@ The two methods are `page_controller_class` and `page_action_class`.
44
44
 
45
45
  This helper method returns page title based on controller name and action name.
46
46
 
47
- When controller and action is `anime#show`
47
+ When controller and action is `animes#show`
48
48
  you can easily use `page_title` like
49
49
 
50
50
  .page-title= page_title
51
51
 
52
52
  becomes
53
53
 
54
- <div class='page-title'>Anime Show</div>
54
+ <div class='page-title'>Animes Show</div>
55
55
 
56
56
  Besides, it supports I18n and interpolation:
57
57
 
@@ -76,14 +76,14 @@ Add `javascript_initialization` to the bottom of your layout.
76
76
 
77
77
  = javascript_initialization
78
78
 
79
- When application is MyApp, and controller/action is `anime#show`, `javascript_initialization` compiles to:
79
+ When application is MyApp, and controller/action is `animes#show`, `javascript_initialization` compiles to:
80
80
 
81
81
  <script type="text/javascript">
82
82
  //<![CDATA[
83
83
  MyApp.init();
84
- if(MyApp.anime) {
85
- if(MyApp.anime.init) { MyApp.anime.init(); }
86
- if(MyApp.anime.init_show) { MyApp.anime.init_show(); }
84
+ if(MyApp.animes) {
85
+ if(MyApp.animes.init) { MyApp.animes.init(); }
86
+ if(MyApp.animes.init_show) { MyApp.animes.init_show(); }
87
87
  }
88
88
  //]]>
89
89
  </script>
@@ -112,6 +112,10 @@ Suppose there's a `flash[:success]`, you should see:
112
112
  <p>flash is success</p>
113
113
  </div>
114
114
 
115
+ You can also:
116
+
117
+ - Add additional CSS classes to the alert with the `class` option.
118
+ - Customize the close button with `button_html` and `button_class` options.
115
119
 
116
120
  ## Contributing
117
121
 
@@ -121,6 +125,12 @@ Minitest-ed. To run all tests, just run `rake` or `rake test`.
121
125
 
122
126
  ## Changelog
123
127
 
128
+ _Version 3.3.0_
129
+
130
+ - [Pull Request 8](https://github.com/winston/rails_utils/pull/8) - Add `button_html` and `button_class` options for `flash_messages` - by @choonkeat.
131
+ - [Pull Request 9](https://github.com/winston/rails_utils/pull/9) - Remove `timedout` from `flash` that's specific to `Devise`.
132
+
133
+
124
134
  _Version 3.2.2_
125
135
 
126
136
  - [Pull Request 5](https://github.com/winston/rails_utils/pull/5) - Minor updates - by @JuanitoFatas.
@@ -1,3 +1,3 @@
1
1
  module RailsUtils
2
- VERSION = "3.2.2"
2
+ VERSION = "3.3.0"
3
3
  end
data/lib/rails_utils.rb CHANGED
@@ -36,8 +36,9 @@ module RailsUtils
36
36
  def flash_messages(options = {})
37
37
  flash.collect do |key, message|
38
38
  next if message.blank?
39
+ next if key.to_s == 'timedout'
39
40
 
40
- content_tag(:div, content_tag(:button, "x", type: "button", class: "close", "data-dismiss" => "alert") + message, class: "#{flash_class(key)} fade in #{options[:class]}")
41
+ content_tag(:div, content_tag(:button, options[:button_html] || "x", type: "button", class: options[:button_class] || "close", "data-dismiss" => "alert") + message, class: "#{flash_class(key)} fade in #{options[:class]}")
41
42
  end.join("\n").html_safe
42
43
  end
43
44
 
@@ -191,5 +191,25 @@ describe "RailsUtils::ActionViewExtensions" do
191
191
  view.flash_messages.must_match /data-dismiss=.*alert/
192
192
  end
193
193
  end
194
+
195
+ describe "options" do
196
+ it "can allow override of button content (default 'x')" do
197
+ set_flash :alert, "not important"
198
+ view.flash_messages.must_match %r{>x</button>}
199
+ view.flash_messages(button_html: '').must_match %r{button class="close"}
200
+ end
201
+
202
+ it "can allow override of button css class (default 'close')" do
203
+ set_flash :alert, "not important"
204
+ view.flash_messages.must_match %r{>x</button>}
205
+ view.flash_messages(button_class: 'abc def').must_match %r{button class="abc def"}
206
+ end
207
+ end
208
+
209
+ it "should skip flash[:timedout]" do
210
+ set_flash :timedout, "not important"
211
+ view.flash_messages.must_equal ""
212
+ end
213
+
194
214
  end
195
215
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails_utils
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.2.2
4
+ version: 3.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Winston Teo
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-10-04 00:00:00.000000000 Z
11
+ date: 2014-11-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -129,7 +129,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
129
129
  version: '0'
130
130
  requirements: []
131
131
  rubyforge_project:
132
- rubygems_version: 2.2.2
132
+ rubygems_version: 2.4.2
133
133
  signing_key:
134
134
  specification_version: 4
135
135
  summary: Rails helpers based on opinionated project practices.