tuning 0.2.3 → 0.2.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/MIT-LICENSE +1 -1
- data/README.md +68 -0
- data/lib/tuning/action_controller/base.rb +6 -1
- data/lib/tuning/action_view/base.rb +0 -12
- data/lib/tuning/railtie.rb +0 -1
- data/lib/tuning/version.rb +1 -1
- data/lib/tuning.rb +0 -1
- data/test/active_trail_test.rb +3 -3
- data/test/content_tag_if_test.rb +3 -3
- data/test/dummy/config/environments/production.rb +5 -1
- data/test/dummy/config/environments/test.rb +9 -1
- data/test/dummy/log/test.log +960 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/13fe41fee1fe35b49d145bcc06610705 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/2f5173deea6c795b8fdde723bb4b63af +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/357970feca3ac29060c1e3861e2c0953 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/cffd775d018f68ce5dba1ee0d951a994 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/d771ace226fc8215a3572e0aa35bb0d6 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/f7cbd26ba1d28d48de824f0e94586655 +0 -0
- data/test/status_test.rb +15 -15
- metadata +8 -13
- data/README.rdoc +0 -60
- data/lib/tuning/action_view/template.rb +0 -39
- data/test/button_test.rb +0 -26
- data/test/seo_test.rb +0 -26
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
data/test/status_test.rb
CHANGED
@@ -2,52 +2,52 @@ require 'test_helper'
|
|
2
2
|
|
3
3
|
class StatusTest < ActionDispatch::IntegrationTest
|
4
4
|
|
5
|
-
test
|
6
|
-
get 'error.json'
|
5
|
+
test 'error' do
|
6
|
+
get '/error.json'
|
7
7
|
assert_response 500
|
8
8
|
assert_equal ' ', response.body
|
9
9
|
|
10
|
-
get 'error'
|
10
|
+
get '/error'
|
11
11
|
assert_response 500
|
12
12
|
assert_equal File.read(Rails.root.join('public', '500.html')), response.body
|
13
13
|
end
|
14
14
|
|
15
|
-
test
|
16
|
-
get 'not_found.json'
|
15
|
+
test 'not found' do
|
16
|
+
get '/not_found.json'
|
17
17
|
assert_response 404
|
18
18
|
assert_equal ' ', response.body
|
19
19
|
|
20
|
-
get 'not_found'
|
20
|
+
get '/not_found'
|
21
21
|
assert_response 404
|
22
22
|
assert_equal File.read(Rails.root.join('public', '404.html')), response.body
|
23
23
|
end
|
24
24
|
|
25
|
-
test
|
26
|
-
get 'unauthorized.json'
|
25
|
+
test 'unauthorized' do
|
26
|
+
get '/unauthorized.json'
|
27
27
|
assert_response 401
|
28
28
|
assert_equal ' ', response.body
|
29
29
|
|
30
|
-
get 'unauthorized'
|
30
|
+
get '/unauthorized'
|
31
31
|
assert_response 401
|
32
32
|
assert_equal File.read(Rails.root.join('public', '422.html')), response.body
|
33
33
|
end
|
34
34
|
|
35
|
-
test
|
36
|
-
get 'forbidden.json'
|
35
|
+
test 'forbidden' do
|
36
|
+
get '/forbidden.json'
|
37
37
|
assert_response 403
|
38
38
|
assert_equal ' ', response.body
|
39
39
|
|
40
|
-
get 'forbidden'
|
40
|
+
get '/forbidden'
|
41
41
|
assert_response 403
|
42
42
|
assert_equal File.read(Rails.root.join('public', '422.html')), response.body
|
43
43
|
end
|
44
44
|
|
45
|
-
test
|
46
|
-
get 'unprocessable_entity.json'
|
45
|
+
test 'unprocessable entity' do
|
46
|
+
get '/unprocessable_entity.json'
|
47
47
|
assert_response 422
|
48
48
|
assert_equal ' ', response.body
|
49
49
|
|
50
|
-
get 'unprocessable_entity'
|
50
|
+
get '/unprocessable_entity'
|
51
51
|
assert_response 422
|
52
52
|
assert_equal File.read(Rails.root.join('public', '422.html')), response.body
|
53
53
|
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.2.
|
4
|
+
version: 0.2.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Museways
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-02-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -16,8 +16,8 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
20
|
-
- - "
|
19
|
+
version: 4.0.0
|
20
|
+
- - "<="
|
21
21
|
- !ruby/object:Gem::Version
|
22
22
|
version: 4.2.0
|
23
23
|
type: :runtime
|
@@ -26,8 +26,8 @@ dependencies:
|
|
26
26
|
requirements:
|
27
27
|
- - ">="
|
28
28
|
- !ruby/object:Gem::Version
|
29
|
-
version:
|
30
|
-
- - "
|
29
|
+
version: 4.0.0
|
30
|
+
- - "<="
|
31
31
|
- !ruby/object:Gem::Version
|
32
32
|
version: 4.2.0
|
33
33
|
- !ruby/object:Gem::Dependency
|
@@ -52,16 +52,14 @@ extensions: []
|
|
52
52
|
extra_rdoc_files: []
|
53
53
|
files:
|
54
54
|
- MIT-LICENSE
|
55
|
-
- README.
|
55
|
+
- README.md
|
56
56
|
- Rakefile
|
57
57
|
- lib/tuning.rb
|
58
58
|
- lib/tuning/action_controller/base.rb
|
59
59
|
- lib/tuning/action_view/base.rb
|
60
|
-
- lib/tuning/action_view/template.rb
|
61
60
|
- lib/tuning/railtie.rb
|
62
61
|
- lib/tuning/version.rb
|
63
62
|
- test/active_trail_test.rb
|
64
|
-
- test/button_test.rb
|
65
63
|
- test/content_tag_if_test.rb
|
66
64
|
- test/dummy/README.rdoc
|
67
65
|
- test/dummy/Rakefile
|
@@ -116,7 +114,6 @@ files:
|
|
116
114
|
- test/dummy/tmp/cache/assets/test/sprockets/cffd775d018f68ce5dba1ee0d951a994
|
117
115
|
- test/dummy/tmp/cache/assets/test/sprockets/d771ace226fc8215a3572e0aa35bb0d6
|
118
116
|
- test/dummy/tmp/cache/assets/test/sprockets/f7cbd26ba1d28d48de824f0e94586655
|
119
|
-
- test/seo_test.rb
|
120
117
|
- test/status_test.rb
|
121
118
|
- test/test_helper.rb
|
122
119
|
homepage: https://github.com/museways/tuning
|
@@ -139,13 +136,12 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
139
136
|
version: '0'
|
140
137
|
requirements: []
|
141
138
|
rubyforge_project:
|
142
|
-
rubygems_version: 2.
|
139
|
+
rubygems_version: 2.4.5
|
143
140
|
signing_key:
|
144
141
|
specification_version: 4
|
145
142
|
summary: Tuning for rails.
|
146
143
|
test_files:
|
147
144
|
- test/active_trail_test.rb
|
148
|
-
- test/button_test.rb
|
149
145
|
- test/content_tag_if_test.rb
|
150
146
|
- test/dummy/app/assets/javascripts/application.js
|
151
147
|
- test/dummy/app/assets/stylesheets/application.css
|
@@ -200,6 +196,5 @@ test_files:
|
|
200
196
|
- test/dummy/tmp/cache/assets/test/sprockets/cffd775d018f68ce5dba1ee0d951a994
|
201
197
|
- test/dummy/tmp/cache/assets/test/sprockets/d771ace226fc8215a3572e0aa35bb0d6
|
202
198
|
- test/dummy/tmp/cache/assets/test/sprockets/f7cbd26ba1d28d48de824f0e94586655
|
203
|
-
- test/seo_test.rb
|
204
199
|
- test/status_test.rb
|
205
200
|
- test/test_helper.rb
|
data/README.rdoc
DELETED
@@ -1,60 +0,0 @@
|
|
1
|
-
{<img src="https://badge.fury.io/rb/tuning.png" alt="Gem Version" />}[http://badge.fury.io/rb/tuning] {<img src="https://codeclimate.com/github/museways/tuning.png" />}[https://codeclimate.com/github/museways/tuning] {<img src="https://travis-ci.org/museways/tuning.png?branch=master" alt="Build Status" />}[https://travis-ci.org/museways/tuning]
|
2
|
-
|
3
|
-
= Tuning
|
4
|
-
|
5
|
-
Common tools used in rails extracted into a gem.
|
6
|
-
|
7
|
-
= Install
|
8
|
-
|
9
|
-
Put this line in your Gemfile:
|
10
|
-
gem 'tuning'
|
11
|
-
|
12
|
-
Then bundle:
|
13
|
-
$ bundle
|
14
|
-
|
15
|
-
= Controllers
|
16
|
-
|
17
|
-
Use error method to respond with status 500 and show 500.html (if format it's html) in your controller:
|
18
|
-
error
|
19
|
-
|
20
|
-
Use not_found to respond with status 404 and show 404.html (if format it's html) in your controller:
|
21
|
-
not_found
|
22
|
-
|
23
|
-
Use unauthorized to respond with status 401 and show 422.html (if format it's html) in your controller:
|
24
|
-
unauthorized
|
25
|
-
|
26
|
-
Use forbidden to respond with status 403 and show 422.html (if format it's html) in your controller:
|
27
|
-
forbidden
|
28
|
-
|
29
|
-
Use unprocessable_entity to respond with status 422 and show 422.html (if format it's html) in your controller:
|
30
|
-
unprocessable_entity
|
31
|
-
|
32
|
-
NOTE: If any exception is raised, error will be called to force debug information in development environment.
|
33
|
-
|
34
|
-
= Views
|
35
|
-
|
36
|
-
Use seo_options to customize the options of the title, description and keywords:
|
37
|
-
<% seo_options name: @record.name %>
|
38
|
-
|
39
|
-
Use content_tag_if if you want wrap content into some tag if certain condition it's true:
|
40
|
-
<%= content_tag_if request.path == home_path, :h1 do %>
|
41
|
-
<%= link_to 'Home', home_path, id: 'logo' %>
|
42
|
-
<% end %>
|
43
|
-
|
44
|
-
Use active_trail? if you want to check if some path is on active trail:
|
45
|
-
<li class="<%= 'active' if active_trail? some_path %>"></li>
|
46
|
-
|
47
|
-
The method submit_tag outputs a button with span inside:
|
48
|
-
<button name="commit" value="submit">
|
49
|
-
<span>Send</span>
|
50
|
-
</button>
|
51
|
-
|
52
|
-
NOTE: For each template @title, @description and @keywords will be set using lazy translation loaders.
|
53
|
-
|
54
|
-
= Credits
|
55
|
-
|
56
|
-
This gem is maintained and funded by museways[http://museways.com].
|
57
|
-
|
58
|
-
= License
|
59
|
-
|
60
|
-
It is free software, and may be redistributed under the terms specified in the MIT-LICENSE file.
|
@@ -1,39 +0,0 @@
|
|
1
|
-
module Tuning
|
2
|
-
module ActionView
|
3
|
-
module Template
|
4
|
-
extend ActiveSupport::Concern
|
5
|
-
|
6
|
-
included do
|
7
|
-
alias_method_chain :render, :seo
|
8
|
-
end
|
9
|
-
|
10
|
-
def render_with_seo(view, locals, buffer=nil, &block)
|
11
|
-
output = render_without_seo(view, locals, buffer, &block)
|
12
|
-
if Rails::VERSION::MAJOR > 3
|
13
|
-
format = type.symbol
|
14
|
-
else
|
15
|
-
format = mime_type.symbol
|
16
|
-
end
|
17
|
-
if format == :html and virtual_path and virtual_path.split('/').last.first != '_'
|
18
|
-
if virtual_path.split('/').first == 'layouts'
|
19
|
-
%w(title description keywords seo_options).each do |tag|
|
20
|
-
if view.instance_variable_defined? :"@#{tag}"
|
21
|
-
view.send :remove_instance_variable, :"@#{tag}"
|
22
|
-
end
|
23
|
-
end
|
24
|
-
else
|
25
|
-
%w(title description keywords).each do |tag|
|
26
|
-
unless view.instance_variable_defined? :"@#{tag}"
|
27
|
-
options = (view.instance_variable_get(:@seo_options) || {}).merge(default: '')
|
28
|
-
content = I18n.t("#{virtual_path.gsub('/', '.')}.#{tag}", options)
|
29
|
-
view.instance_variable_set :"@#{tag}", content
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
34
|
-
output
|
35
|
-
end
|
36
|
-
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|
data/test/button_test.rb
DELETED
@@ -1,26 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
|
3
|
-
class ButtonTest < ActionView::TestCase
|
4
|
-
|
5
|
-
test "use button with span inside instead of input" do
|
6
|
-
assert_equal(
|
7
|
-
'<button name="commit" type="submit"><span>Send</span></button>',
|
8
|
-
submit_tag
|
9
|
-
)
|
10
|
-
end
|
11
|
-
|
12
|
-
test "use the value as label" do
|
13
|
-
assert_equal(
|
14
|
-
'<button name="commit" type="submit"><span>Other</span></button>',
|
15
|
-
submit_tag('Other')
|
16
|
-
)
|
17
|
-
end
|
18
|
-
|
19
|
-
test "accept options as attributes" do
|
20
|
-
assert_equal(
|
21
|
-
'<button attribute="value" name="commit" type="submit"><span>Send</span></button>',
|
22
|
-
submit_tag('Send', attribute: 'value')
|
23
|
-
)
|
24
|
-
end
|
25
|
-
|
26
|
-
end
|
data/test/seo_test.rb
DELETED
@@ -1,26 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
|
3
|
-
class SeoTest < ActionView::TestCase
|
4
|
-
|
5
|
-
test "populate meta using the path of the template as key" do
|
6
|
-
render template: 'pages/index', layout: 'layouts/application'
|
7
|
-
assert_select 'title', I18n.t('pages.index.title')
|
8
|
-
assert_select %Q{meta[content="#{I18n.t('pages.index.description')}"]}
|
9
|
-
assert_select %Q{meta[content="#{I18n.t('pages.index.keywords')}"]}
|
10
|
-
|
11
|
-
render template: 'pages/variable', layout: 'layouts/application'
|
12
|
-
assert_select 'title', I18n.t('pages.variable.title', name: 'other')
|
13
|
-
assert_select %Q{meta[content="#{I18n.t('pages.variable.description', name: 'other')}"]}
|
14
|
-
assert_select %Q{meta[content="#{I18n.t('pages.variable.keywords', name: 'other')}"]}
|
15
|
-
|
16
|
-
render template: 'pages/empty', layout: 'layouts/application'
|
17
|
-
assert_select 'title', ''
|
18
|
-
assert_select %Q{meta[content=""]}, 2
|
19
|
-
|
20
|
-
render template: 'pages/defined', layout: 'layouts/application'
|
21
|
-
assert_select 'title', 'title'
|
22
|
-
assert_select %Q{meta[content="description"]}
|
23
|
-
assert_select %Q{meta[content="keywords"]}
|
24
|
-
end
|
25
|
-
|
26
|
-
end
|