tuning 0.0.9 → 0.1.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b4a3d88946f6d2bdb54798fbdfac4faa31bb5185
4
- data.tar.gz: cf751bb1e3fa5bbf5e0f26202a2247279754761a
3
+ metadata.gz: e26655041f082469be05f8a721a507d9e67be6e4
4
+ data.tar.gz: eae31ff42e6e539df0d88fc90d0ef19f67236e91
5
5
  SHA512:
6
- metadata.gz: 84729ae7daae797691f0af5a823ed204740554c567afd39fc347bf9ec4cd648e6604509864295c60fc83d5f605a004453efbcd22dfc55dddc8bab24f6e111f71
7
- data.tar.gz: 1de89d0c27a815b14eb0476aa290e75f98f2afb00dc3f2ce6d4b0a0718e208b377cfb716b76c25365f9fb223cc640819a0b1e328e50daa6584b3164f05ff27b9
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 conditional_tag if you want wrap content into some tag if certain condition it's true in your views:
34
- <%= conditional_tag :h1, request.path == home_path do %>
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 conditional_tag(tag, condition, options=nil, &block)
11
- condition ? content_tag(tag, options, &block) : capture(&block)
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)
@@ -1,5 +1,5 @@
1
1
  module Tuning
2
2
 
3
- VERSION = '0.0.9'
3
+ VERSION = '0.1.0'
4
4
 
5
5
  end
@@ -78,5 +78,47 @@ ViewTest: test_should_have_active_menu?_method
78
78
   (0.1ms) begin transaction
79
79
  -------------------------------------------------
80
80
  ViewTest: test_should_have_conditional_tag_method
81
+ -------------------------------------------------
82
+  (0.0ms) rollback transaction
83
+  (0.3ms) CREATE TABLE "schema_migrations" ("version" varchar(255) NOT NULL) 
84
+  (0.2ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
85
+  (0.1ms) SELECT version FROM "schema_migrations"
86
+  (0.1ms) INSERT INTO "schema_migrations" (version) VALUES ('0')
87
+  (0.1ms) begin transaction
88
+ ----------------------------------------------
89
+ ViewTest: test_should_have_active_menu?_method
90
+ ----------------------------------------------
91
+  (0.1ms) rollback transaction
92
+  (0.1ms) begin transaction
93
+ -------------------------------------------------
94
+ ViewTest: test_should_have_conditional_tag_method
95
+ -------------------------------------------------
96
+  (0.0ms) rollback transaction
97
+  (0.2ms) CREATE TABLE "schema_migrations" ("version" varchar(255) NOT NULL) 
98
+  (0.1ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
99
+  (0.1ms) SELECT version FROM "schema_migrations"
100
+  (0.1ms) INSERT INTO "schema_migrations" (version) VALUES ('0')
101
+  (0.1ms) begin transaction
102
+ ----------------------------------------------
103
+ ViewTest: test_should_have_active_menu?_method
104
+ ----------------------------------------------
105
+  (0.1ms) rollback transaction
106
+  (0.1ms) begin transaction
107
+ -------------------------------------------------
108
+ ViewTest: test_should_have_contenta_tag_if_method
109
+ -------------------------------------------------
110
+  (0.0ms) rollback transaction
111
+  (0.2ms) CREATE TABLE "schema_migrations" ("version" varchar(255) NOT NULL) 
112
+  (0.1ms) CREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")
113
+  (0.1ms) SELECT version FROM "schema_migrations"
114
+  (0.1ms) INSERT INTO "schema_migrations" (version) VALUES ('0')
115
+  (0.1ms) begin transaction
116
+ ----------------------------------------------
117
+ ViewTest: test_should_have_active_menu?_method
118
+ ----------------------------------------------
119
+  (0.1ms) rollback transaction
120
+  (0.1ms) begin transaction
121
+ -------------------------------------------------
122
+ ViewTest: test_should_have_contenta_tag_if_method
81
123
  -------------------------------------------------
82
124
   (0.0ms) 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 conditional_tag method" do
10
- assert @instance.respond_to?(:conditional_tag)
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.9
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-08-19 00:00:00.000000000 Z
11
+ date: 2013-10-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails