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
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 835360bfe1b297294600dfa7990d0cdae5608e41
|
4
|
+
data.tar.gz: 94e6987ac6f3fa962c5b0b2857761e90b50f3336
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 65b76c46d3d2d343e0de497c0ba60ce95ce9e2c9867cb21a2615cdd4129a7fc29245c4382a2ddb8d67852471dd3f893d45b17d9c64d556186f66ec7ff078e4c8
|
7
|
+
data.tar.gz: 2f07dd54907c0bb8ff5ca7afd29b54a33268b923425bf082d63e22daf5340fb84c41e5512c44152b2658a435c14ecbb74f5ce8067ee195772ebf522d3ff28f3e
|
data/MIT-LICENSE
CHANGED
data/README.md
ADDED
@@ -0,0 +1,68 @@
|
|
1
|
+
[![Gem Version](https://badge.fury.io/rb/tuning.svg)](http://badge.fury.io/rb/tuning) [![Code Climate](https://codeclimate.com/github/museways/tuning/badges/gpa.svg)](https://codeclimate.com/github/museways/tuning) [![Build Status](https://travis-ci.org/museways/tuning.svg?branch=0.2.3)](https://travis-ci.org/museways/tuning) [![Dependency Status](https://gemnasium.com/museways/tuning.svg)](https://gemnasium.com/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
|
+
```ruby
|
11
|
+
gem 'tuning'
|
12
|
+
```
|
13
|
+
|
14
|
+
Then bundle:
|
15
|
+
```
|
16
|
+
$ bundle
|
17
|
+
```
|
18
|
+
|
19
|
+
## Controllers
|
20
|
+
|
21
|
+
Use error method to respond with status 500 and show 500.html (if format it's html):
|
22
|
+
```ruby
|
23
|
+
error
|
24
|
+
```
|
25
|
+
|
26
|
+
Use not_found to respond with status 404 and show 404.html (if format it's html):
|
27
|
+
```ruby
|
28
|
+
not_found
|
29
|
+
```
|
30
|
+
|
31
|
+
Use unauthorized to respond with status 401 and show 422.html (if format it's html):
|
32
|
+
```ruby
|
33
|
+
unauthorized
|
34
|
+
```
|
35
|
+
|
36
|
+
Use forbidden to respond with status 403 and show 422.html (if format it's html):
|
37
|
+
```ruby
|
38
|
+
forbidden
|
39
|
+
```
|
40
|
+
|
41
|
+
Use unprocessable_entity to respond with status 422 and show 422.html (if format it's html):
|
42
|
+
```ruby
|
43
|
+
unprocessable_entity
|
44
|
+
```
|
45
|
+
|
46
|
+
NOTE: If any exception is raised, error will be called to force debug information in development.
|
47
|
+
|
48
|
+
## Views
|
49
|
+
|
50
|
+
Use content_tag_if if you want wrap content into some tag if certain condition it's true:
|
51
|
+
```erb
|
52
|
+
<%= content_tag_if request.path == home_path, :h1 do %>
|
53
|
+
<%= link_to 'Home', home_path, id: 'logo' %>
|
54
|
+
<% end %>
|
55
|
+
```
|
56
|
+
|
57
|
+
Use active_trail? if you want to check if some path is on active trail:
|
58
|
+
```erb
|
59
|
+
<li class="<%= 'active' if active_trail? some_path %>"></li>
|
60
|
+
```
|
61
|
+
|
62
|
+
## Credits
|
63
|
+
|
64
|
+
This gem is maintained and funded by [museways](http://museways.com).
|
65
|
+
|
66
|
+
## License
|
67
|
+
|
68
|
+
It is free software, and may be redistributed under the terms specified in the MIT-LICENSE file.
|
@@ -15,6 +15,7 @@ module Tuning
|
|
15
15
|
exception.backtrace.each { |line| logger.error line }
|
16
16
|
end
|
17
17
|
respond_to do |format|
|
18
|
+
format.xml { head 500 }
|
18
19
|
format.json { head 500 }
|
19
20
|
format.any { render file: Rails.root.join('public', '500.html'), status: 500, layout: false }
|
20
21
|
end
|
@@ -22,13 +23,15 @@ module Tuning
|
|
22
23
|
|
23
24
|
def not_found
|
24
25
|
respond_to do |format|
|
26
|
+
format.xml { head 404 }
|
25
27
|
format.json { head 404 }
|
26
28
|
format.any { render file: Rails.root.join('public', '404.html'), status: 404, layout: false }
|
27
29
|
end
|
28
|
-
end
|
30
|
+
end
|
29
31
|
|
30
32
|
def unauthorized
|
31
33
|
respond_to do |format|
|
34
|
+
format.xml { head 401 }
|
32
35
|
format.json { head 401 }
|
33
36
|
format.any { render file: Rails.root.join('public', '422.html'), status: 401, layout: false }
|
34
37
|
end
|
@@ -36,6 +39,7 @@ module Tuning
|
|
36
39
|
|
37
40
|
def forbidden
|
38
41
|
respond_to do |format|
|
42
|
+
format.xml { head 403 }
|
39
43
|
format.json { head 403 }
|
40
44
|
format.any { render file: Rails.root.join('public', '422.html'), status: 403, layout: false }
|
41
45
|
end
|
@@ -43,6 +47,7 @@ module Tuning
|
|
43
47
|
|
44
48
|
def unprocessable_entity
|
45
49
|
respond_to do |format|
|
50
|
+
format.xml { head 422 }
|
46
51
|
format.json { head 422 }
|
47
52
|
format.any { render file: Rails.root.join('public', '422.html'), status: 422, layout: false }
|
48
53
|
end
|
@@ -3,14 +3,6 @@ module Tuning
|
|
3
3
|
module Base
|
4
4
|
extend ActiveSupport::Concern
|
5
5
|
|
6
|
-
included do
|
7
|
-
alias_method_chain :submit_tag, :button
|
8
|
-
end
|
9
|
-
|
10
|
-
def seo_options(options)
|
11
|
-
@seo_options = options
|
12
|
-
end
|
13
|
-
|
14
6
|
def active_trail?(path)
|
15
7
|
(path == '/' && request.path == path) or request.path.start_with?(path)
|
16
8
|
end
|
@@ -19,10 +11,6 @@ module Tuning
|
|
19
11
|
condition ? content_tag(name, options, &block) : capture(&block)
|
20
12
|
end
|
21
13
|
|
22
|
-
def submit_tag_with_button(value='Send', options={})
|
23
|
-
button_tag({ type: 'submit', name: 'commit' }.update(options)) { content_tag(:span, value) }
|
24
|
-
end
|
25
|
-
|
26
14
|
end
|
27
15
|
end
|
28
16
|
end
|
data/lib/tuning/railtie.rb
CHANGED
data/lib/tuning/version.rb
CHANGED
data/lib/tuning.rb
CHANGED
data/test/active_trail_test.rb
CHANGED
@@ -2,13 +2,13 @@ require 'test_helper'
|
|
2
2
|
|
3
3
|
class ActiveTrailTest < ActionView::TestCase
|
4
4
|
|
5
|
-
test
|
5
|
+
test 'active trail in path' do
|
6
6
|
set_path '/some-path/other-path'
|
7
7
|
assert active_trail?('/')
|
8
8
|
assert active_trail?('/some-path')
|
9
9
|
end
|
10
10
|
|
11
|
-
test
|
11
|
+
test 'active trail same as path' do
|
12
12
|
set_path '/'
|
13
13
|
assert active_trail?('/')
|
14
14
|
|
@@ -16,7 +16,7 @@ class ActiveTrailTest < ActionView::TestCase
|
|
16
16
|
assert active_trail?('/some-path')
|
17
17
|
end
|
18
18
|
|
19
|
-
test
|
19
|
+
test 'active trail not in path' do
|
20
20
|
set_path '/'
|
21
21
|
assert !active_trail?('/some-path')
|
22
22
|
|
data/test/content_tag_if_test.rb
CHANGED
@@ -2,15 +2,15 @@ require 'test_helper'
|
|
2
2
|
|
3
3
|
class ContentTagIfTest < ActionView::TestCase
|
4
4
|
|
5
|
-
test
|
5
|
+
test 'true condition' do
|
6
6
|
assert_equal '<a>content</a>', content_tag_if(1 == 1, 'a') { 'content' }
|
7
7
|
end
|
8
8
|
|
9
|
-
test
|
9
|
+
test 'false condition' do
|
10
10
|
assert_equal 'content', content_tag_if(1 == 2, 'a') { 'content' }
|
11
11
|
end
|
12
12
|
|
13
|
-
test
|
13
|
+
test 'attributes options' do
|
14
14
|
assert_equal '<a href="#">content</a>', content_tag_if(1 == 1, 'a', href: '#') { 'content' }
|
15
15
|
end
|
16
16
|
|
@@ -20,7 +20,11 @@ Dummy::Application.configure do
|
|
20
20
|
# config.action_dispatch.rack_cache = true
|
21
21
|
|
22
22
|
# Disable Rails's static asset server (Apache or nginx will already do this).
|
23
|
-
|
23
|
+
if Rails::VERSION::MAJOR == 4 && Rails::VERSION::MINOR >= 2
|
24
|
+
config.serve_static_files = false
|
25
|
+
else
|
26
|
+
config.serve_static_assets = false
|
27
|
+
end
|
24
28
|
|
25
29
|
# Compress JavaScripts and CSS.
|
26
30
|
config.assets.js_compressor = :uglifier
|
@@ -13,7 +13,11 @@ Dummy::Application.configure do
|
|
13
13
|
config.eager_load = false
|
14
14
|
|
15
15
|
# Configure static asset server for tests with Cache-Control for performance.
|
16
|
-
|
16
|
+
if Rails::VERSION::MAJOR == 4 && Rails::VERSION::MINOR >= 2
|
17
|
+
config.serve_static_files = false
|
18
|
+
else
|
19
|
+
config.serve_static_assets = false
|
20
|
+
end
|
17
21
|
config.static_cache_control = "public, max-age=3600"
|
18
22
|
|
19
23
|
# Show full error reports and disable caching.
|
@@ -33,4 +37,8 @@ Dummy::Application.configure do
|
|
33
37
|
|
34
38
|
# Print deprecation notices to the stderr.
|
35
39
|
config.active_support.deprecation = :stderr
|
40
|
+
|
41
|
+
if Rails::VERSION::MAJOR == 4 && Rails::VERSION::MINOR >= 2
|
42
|
+
config.active_support.test_order = :random
|
43
|
+
end
|
36
44
|
end
|