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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: dfe0f4e62357202f010df5e00f9974e474c08fd8
4
- data.tar.gz: a149686ba2ab4269a79607678ee1cba6c41270ad
3
+ metadata.gz: 835360bfe1b297294600dfa7990d0cdae5608e41
4
+ data.tar.gz: 94e6987ac6f3fa962c5b0b2857761e90b50f3336
5
5
  SHA512:
6
- metadata.gz: d4ac4f96f8f774599fabc84851342e113abe38d9ae4d6ad8c81d7aa5399bab6436aac2c6d61eb676d4d633d48e3057858ed1ef6100507fa34279cc59049b7da9
7
- data.tar.gz: ad6b5c9b50f99cde5e04a26fbd366436acdf5e5696d4f9a5f840e1e01963028c76da3be4e714f35c414d63d2692196cef7186de3c9a62e2a78c7d9fabe9048c6
6
+ metadata.gz: 65b76c46d3d2d343e0de497c0ba60ce95ce9e2c9867cb21a2615cdd4129a7fc29245c4382a2ddb8d67852471dd3f893d45b17d9c64d556186f66ec7ff078e4c8
7
+ data.tar.gz: 2f07dd54907c0bb8ff5ca7afd29b54a33268b923425bf082d63e22daf5340fb84c41e5512c44152b2658a435c14ecbb74f5ce8067ee195772ebf522d3ff28f3e
data/MIT-LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright 2014 Museways
1
+ Copyright 2015 Museways
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
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
@@ -4,7 +4,6 @@ module Tuning
4
4
  initializer 'tuning' do
5
5
  ::ActionController::Base.send :include, Tuning::ActionController::Base
6
6
  ::ActionView::Base.send :include, Tuning::ActionView::Base
7
- ::ActionView::Template.send :include, Tuning::ActionView::Template
8
7
  end
9
8
 
10
9
  end
@@ -1,5 +1,5 @@
1
1
  module Tuning
2
2
 
3
- VERSION = '0.2.3'
3
+ VERSION = '0.2.4'
4
4
 
5
5
  end
data/lib/tuning.rb CHANGED
@@ -1,6 +1,5 @@
1
1
  require 'tuning/action_controller/base'
2
2
  require 'tuning/action_view/base'
3
- require 'tuning/action_view/template'
4
3
  require 'tuning/railtie'
5
4
 
6
5
  module Tuning
@@ -2,13 +2,13 @@ require 'test_helper'
2
2
 
3
3
  class ActiveTrailTest < ActionView::TestCase
4
4
 
5
- test "return true if path is in active trail" do
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 "return true if path is the same as active trail" do
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 "return false if path is not in active trail" do
19
+ test 'active trail not in path' do
20
20
  set_path '/'
21
21
  assert !active_trail?('/some-path')
22
22
 
@@ -2,15 +2,15 @@ require 'test_helper'
2
2
 
3
3
  class ContentTagIfTest < ActionView::TestCase
4
4
 
5
- test "show tag if condition is true" do
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 "not show tag if condition if false" do
9
+ test 'false condition' do
10
10
  assert_equal 'content', content_tag_if(1 == 2, 'a') { 'content' }
11
11
  end
12
12
 
13
- test "accept options as attributes" do
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
- config.serve_static_assets = false
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
- config.serve_static_assets = true
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