tuning 0.1.1 → 0.1.2
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/README.rdoc +14 -9
- data/lib/tuning/action_view/base.rb +10 -7
- data/lib/tuning/version.rb +1 -1
- data/test/view_test.rb +6 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2905dec322526dd21c3aeb41a722d1590fb9c4ba
|
4
|
+
data.tar.gz: 04a821c58f34e36bb6dc3180c12310dff1b56c21
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f5b555d8d40cf9b7e4806a6edf7e7d6e843d6d3e9cee8ee77c5e7b77db9a1e2b85ba377e3204bcffc79daf32631dcf11355f1435f3614d195e2a34440ff594d1
|
7
|
+
data.tar.gz: 39c78175744b75a3fb1700a5afb6ee63b6cedc0db9d4c1db13ada1cce970d71462a4d07f6d55265f719e149ce5a670c5a55b0c5288c6cc44c59fe2930f96c4a0
|
data/README.rdoc
CHANGED
@@ -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
|
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
|
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
|
-
|
37
|
-
<li class="<%=
|
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
|
15
|
-
|
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
|
data/lib/tuning/version.rb
CHANGED
data/test/view_test.rb
CHANGED
@@ -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
|
14
|
-
assert @instance.respond_to?(:
|
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.
|
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:
|
11
|
+
date: 2014-01-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|