tuning 0.0.9 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.rdoc +6 -8
- data/lib/tuning/action_controller/base.rb +0 -22
- data/lib/tuning/action_view/base.rb +2 -2
- data/lib/tuning/version.rb +1 -1
- data/test/dummy/log/test.log +42 -0
- data/test/view_test.rb +2 -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: e26655041f082469be05f8a721a507d9e67be6e4
|
4
|
+
data.tar.gz: eae31ff42e6e539df0d88fc90d0ef19f67236e91
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 07f9823d485a2e21e1566c47115372ef8772b8e396d694a51ea52bad56b557f266032b026bc2aebeb30cca05481f3573a80d9722326b77877127450689157b90
|
7
|
+
data.tar.gz: 0951e9316e1b6536b39b0b09e14638017c9153a8cc3aac8fd80bc6454a6bf098dba06f10d76a44e0d8641041acbc3ae05cc01f9ef0b71b0f0df699180a80f261
|
data/README.rdoc
CHANGED
@@ -1,3 +1,7 @@
|
|
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
|
+
|
1
5
|
{<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]
|
2
6
|
|
3
7
|
= Tuning
|
@@ -22,16 +26,10 @@ Use not_found method to show 404.html in your controller:
|
|
22
26
|
Use forbidden method to show 422.html in your controller:
|
23
27
|
forbidden
|
24
28
|
|
25
|
-
Use redirect_with_flash to directly redirect with flash inside your controller:
|
26
|
-
redirect_with_flash home_path, :success, 'success message'
|
27
|
-
|
28
|
-
Use flash_errors method to directly flash models errors inside your controller:
|
29
|
-
flash_errors model
|
30
|
-
|
31
29
|
= Views
|
32
30
|
|
33
|
-
Use
|
34
|
-
<%=
|
31
|
+
Use content_tag_if if you want wrap content into some tag if certain condition it's true in your views:
|
32
|
+
<%= content_tag_if request.path == home_path, :h1 do %>
|
35
33
|
<%= link_to 'Home', home_path, id: 'logo' %>
|
36
34
|
<% end %>
|
37
35
|
|
@@ -23,28 +23,6 @@ module Tuning
|
|
23
23
|
render file: Rails.root.join('public', '422.html'), status: 422, layout: false
|
24
24
|
end
|
25
25
|
|
26
|
-
def redirect_with_flash(options, type, flash)
|
27
|
-
args = [options]
|
28
|
-
if flash.is_a? String
|
29
|
-
flash = [flash]
|
30
|
-
elsif flash.respond_to? :errors
|
31
|
-
flash = flash.errors.full_messages
|
32
|
-
end
|
33
|
-
flash = { flash: { type => flash } }
|
34
|
-
redirect_to *(args[0].is_a?(Hash) ? args[0].merge(flash) : args.push(flash))
|
35
|
-
end
|
36
|
-
|
37
|
-
def flash_errors(source)
|
38
|
-
flash.now[:error] = [] unless flash.now[:error].is_a? Array
|
39
|
-
if source.is_a? String
|
40
|
-
flash.now[:error] << source
|
41
|
-
elsif source.is_a? Array
|
42
|
-
source.each { |error| flash.now[:error] << error }
|
43
|
-
elsif source.respond_to? :errors
|
44
|
-
source.errors.full_messages.each { |error| flash.now[:error] << error }
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
26
|
end
|
49
27
|
end
|
50
28
|
end
|
@@ -7,8 +7,8 @@ module Tuning
|
|
7
7
|
alias_method_chain :submit_tag, :button
|
8
8
|
end
|
9
9
|
|
10
|
-
def
|
11
|
-
condition ? content_tag(
|
10
|
+
def content_tag_if(condition, name, options=nil, &block)
|
11
|
+
condition ? content_tag(name, options, &block) : capture(&block)
|
12
12
|
end
|
13
13
|
|
14
14
|
def active_menu?(path)
|
data/lib/tuning/version.rb
CHANGED
data/test/dummy/log/test.log
CHANGED
@@ -78,5 +78,47 @@ ViewTest: test_should_have_active_menu?_method
|
|
78
78
|
[1m[36m (0.1ms)[0m [1mbegin transaction[0m
|
79
79
|
-------------------------------------------------
|
80
80
|
ViewTest: test_should_have_conditional_tag_method
|
81
|
+
-------------------------------------------------
|
82
|
+
[1m[35m (0.0ms)[0m rollback transaction
|
83
|
+
[1m[36m (0.3ms)[0m [1mCREATE TABLE "schema_migrations" ("version" varchar(255) NOT NULL) [0m
|
84
|
+
[1m[35m (0.2ms)[0m CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
|
85
|
+
[1m[36m (0.1ms)[0m [1mSELECT version FROM "schema_migrations"[0m
|
86
|
+
[1m[35m (0.1ms)[0m INSERT INTO "schema_migrations" (version) VALUES ('0')
|
87
|
+
[1m[36m (0.1ms)[0m [1mbegin transaction[0m
|
88
|
+
----------------------------------------------
|
89
|
+
ViewTest: test_should_have_active_menu?_method
|
90
|
+
----------------------------------------------
|
91
|
+
[1m[35m (0.1ms)[0m rollback transaction
|
92
|
+
[1m[36m (0.1ms)[0m [1mbegin transaction[0m
|
93
|
+
-------------------------------------------------
|
94
|
+
ViewTest: test_should_have_conditional_tag_method
|
95
|
+
-------------------------------------------------
|
96
|
+
[1m[35m (0.0ms)[0m rollback transaction
|
97
|
+
[1m[36m (0.2ms)[0m [1mCREATE TABLE "schema_migrations" ("version" varchar(255) NOT NULL) [0m
|
98
|
+
[1m[35m (0.1ms)[0m CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
|
99
|
+
[1m[36m (0.1ms)[0m [1mSELECT version FROM "schema_migrations"[0m
|
100
|
+
[1m[35m (0.1ms)[0m INSERT INTO "schema_migrations" (version) VALUES ('0')
|
101
|
+
[1m[36m (0.1ms)[0m [1mbegin transaction[0m
|
102
|
+
----------------------------------------------
|
103
|
+
ViewTest: test_should_have_active_menu?_method
|
104
|
+
----------------------------------------------
|
105
|
+
[1m[35m (0.1ms)[0m rollback transaction
|
106
|
+
[1m[36m (0.1ms)[0m [1mbegin transaction[0m
|
107
|
+
-------------------------------------------------
|
108
|
+
ViewTest: test_should_have_contenta_tag_if_method
|
109
|
+
-------------------------------------------------
|
110
|
+
[1m[35m (0.0ms)[0m rollback transaction
|
111
|
+
[1m[36m (0.2ms)[0m [1mCREATE TABLE "schema_migrations" ("version" varchar(255) NOT NULL) [0m
|
112
|
+
[1m[35m (0.1ms)[0m CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
|
113
|
+
[1m[36m (0.1ms)[0m [1mSELECT version FROM "schema_migrations"[0m
|
114
|
+
[1m[35m (0.1ms)[0m INSERT INTO "schema_migrations" (version) VALUES ('0')
|
115
|
+
[1m[36m (0.1ms)[0m [1mbegin transaction[0m
|
116
|
+
----------------------------------------------
|
117
|
+
ViewTest: test_should_have_active_menu?_method
|
118
|
+
----------------------------------------------
|
119
|
+
[1m[35m (0.1ms)[0m rollback transaction
|
120
|
+
[1m[36m (0.1ms)[0m [1mbegin transaction[0m
|
121
|
+
-------------------------------------------------
|
122
|
+
ViewTest: test_should_have_contenta_tag_if_method
|
81
123
|
-------------------------------------------------
|
82
124
|
[1m[35m (0.0ms)[0m rollback transaction
|
data/test/view_test.rb
CHANGED
@@ -6,8 +6,8 @@ class ViewTest < ActiveSupport::TestCase
|
|
6
6
|
@instance = ActionView::Base.new
|
7
7
|
end
|
8
8
|
|
9
|
-
test "should have
|
10
|
-
assert @instance.respond_to?(:
|
9
|
+
test "should have contenta_tag_if method" do
|
10
|
+
assert @instance.respond_to?(:content_tag_if)
|
11
11
|
end
|
12
12
|
|
13
13
|
test "should have active_menu? method" do
|
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.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mattways
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-10-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|