tuning 0.1.1 → 0.1.2

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: d5789c96633959f77bfaa6da1dc4fb9f17d3a12f
4
- data.tar.gz: 3975a6588670a9a5e64ebace6b696ec21956027f
3
+ metadata.gz: 2905dec322526dd21c3aeb41a722d1590fb9c4ba
4
+ data.tar.gz: 04a821c58f34e36bb6dc3180c12310dff1b56c21
5
5
  SHA512:
6
- metadata.gz: 7d20e603a0d6fa880551fe99d5115735686c1d52e77f36a13c10c6645d3766ef3853dda25f02cf58483de0379c02e8b8202e2afbf68414454cfc09f84039ff90
7
- data.tar.gz: ecad167e71dc891f4cf8ff05ab8c64b46ddc0fec79c993fefbb5e82fe55c6e000909a5f0ce5fe7c0676d68271bf98443b527047c1dbdf81ae486d6b3d0ac47c3
6
+ metadata.gz: f5b555d8d40cf9b7e4806a6edf7e7d6e843d6d3e9cee8ee77c5e7b77db9a1e2b85ba377e3204bcffc79daf32631dcf11355f1435f3614d195e2a34440ff594d1
7
+ data.tar.gz: 39c78175744b75a3fb1700a5afb6ee63b6cedc0db9d4c1db13ada1cce970d71462a4d07f6d55265f719e149ce5a670c5a55b0c5288c6cc44c59fe2930f96c4a0
@@ -1,7 +1,3 @@
1
- === NOTE: The helper conditional_tag has been renamed to content_tag_if and flash_errors and redirect_with_flash has been removed
2
-
3
- ---
4
-
5
1
  {<img src="https://codeclimate.com/github/mattways/tuning.png" />}[https://codeclimate.com/github/mattways/tuning] {<img src="https://travis-ci.org/mattways/tuning.png?branch=master" alt="Build Status" />}[https://travis-ci.org/mattways/tuning] {<img src="https://gemnasium.com/mattways/tuning.png" alt="Dependency Status" />}[https://gemnasium.com/mattways/tuning]
6
2
 
7
3
  = Tuning
@@ -20,21 +16,30 @@ Then bundle:
20
16
 
21
17
  (This plugin will create an error method to force debug information on exceptions in development env)
22
18
 
23
- Use not_found method to show 404.html in your controller:
19
+ Use not_found method to respond with status 404 and show 404.html (if format it's html) in your controller:
24
20
  not_found
25
21
 
26
- Use forbidden method to show 422.html in your controller:
22
+ Use unauthorized method to respond with status 401 and show 422.html (if format it's html) in your controller:
23
+ unauthorized
24
+
25
+ Use forbidden method to respond with status 403 and show 422.html (if format it's html) in your controller:
27
26
  forbidden
28
27
 
28
+ Use unprocessable_entity method to respond with status 422 and show 422.html (if format it's html) in your controller:
29
+ unprocessable_entity
30
+
29
31
  = Views
30
32
 
31
- Use content_tag_if if you want wrap content into some tag if certain condition it's true in your views:
33
+ Use content_tag_if if you want wrap content into some tag if certain condition it's true:
32
34
  <%= content_tag_if request.path == home_path, :h1 do %>
33
35
  <%= link_to 'Home', home_path, id: 'logo' %>
34
36
  <% end %>
35
37
 
36
- User active_menu? if you want to add an active class to some tag in your views:
37
- <li class="<%= active_menu? some_path %>"></li>
38
+ Use active_trail? if you want to check if some path is on active trail:
39
+ <li class="<%= 'active' if active_trail? some_path %>"></li>
40
+
41
+ Use set_meta if you want to load the metadata from your locale yaml:
42
+ set_meta # .meta.title -> @meta_title, .meta.description -> @meta_description, .meta.keywords -> @meta_keywords
38
43
 
39
44
  The method submit_tag outputs a button with span inside:
40
45
  <button name="commit" value="submit">
@@ -7,22 +7,25 @@ module Tuning
7
7
  alias_method_chain :submit_tag, :button
8
8
  end
9
9
 
10
+ def set_meta(*args)
11
+ options = args.extract_options!
12
+ @meta_title = t('.meta.title', options)
13
+ @meta_keywords = t('.meta.keywords', options)
14
+ @meta_description = t('.meta.description', options)
15
+ end
16
+
10
17
  def content_tag_if(condition, name, options=nil, &block)
11
18
  condition ? content_tag(name, options, &block) : capture(&block)
12
19
  end
13
20
 
14
- def active_menu?(path)
15
- if path == '/'
16
- request.path == path ? 'active' : ''
17
- else
18
- request.path.start_with?(path) ? 'active' : ''
19
- end
21
+ def active_trail?(path)
22
+ (path == '/' && request.path == path) or request.path.start_with?(path)
20
23
  end
21
24
 
22
25
  def submit_tag_with_button(value='Send', options={})
23
26
  button_tag({ type: 'submit', name: 'commit' }.update(options)) { content_tag(:span, value) }
24
27
  end
25
-
28
+
26
29
  end
27
30
  end
28
31
  end
@@ -1,5 +1,5 @@
1
1
  module Tuning
2
2
 
3
- VERSION = '0.1.1'
3
+ VERSION = '0.1.2'
4
4
 
5
5
  end
@@ -10,8 +10,12 @@ class ViewTest < ActiveSupport::TestCase
10
10
  assert @instance.respond_to?(:content_tag_if)
11
11
  end
12
12
 
13
- test "should have active_menu? method" do
14
- assert @instance.respond_to?(:active_menu?)
13
+ test "should have active_trail? method" do
14
+ assert @instance.respond_to?(:active_trail?)
15
+ end
16
+
17
+ test "should have set_meta method" do
18
+ assert @instance.respond_to?(:set_meta)
15
19
  end
16
20
 
17
21
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tuning
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mattways
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-12-29 00:00:00.000000000 Z
11
+ date: 2014-01-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails