simple_helpers 0.0.3 → 0.0.4
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.
- data/CHANGELOG.md +4 -0
- data/README.md +7 -7
- data/lib/simple_helpers/config.rb +12 -12
- data/lib/simple_helpers/support.rb +1 -0
- data/lib/simple_helpers/version.rb +1 -1
- data/lib/simple_helpers.rb +4 -4
- data/templates/initializer.rb +3 -3
- metadata +4 -4
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
[](https://codeclimate.com/github/vitormil/simple_helpers)
|
3
3
|
[](http://travis-ci.org/vitormil/simple_helpers)
|
4
4
|
|
5
|
-
Easily create
|
5
|
+
Easily create helper methods with I18n and interpolation support to your controllers and views.
|
6
6
|
|
7
7
|
You can configure it to automaticly create some methods (like page_title, page_subtitle) or call the method **simple_helper** manually according to your needs.
|
8
8
|
|
@@ -20,9 +20,9 @@ You can configure an automatic behavior to your controllers setting an initializ
|
|
20
20
|
require "simple_helpers"
|
21
21
|
|
22
22
|
SimpleHelpers.configure do |config|
|
23
|
-
config.helpers
|
24
|
-
config.
|
25
|
-
config.
|
23
|
+
config.helpers = [:page_title]
|
24
|
+
config.except = [SessionsController]
|
25
|
+
config.only = []
|
26
26
|
end
|
27
27
|
```
|
28
28
|
|
@@ -63,7 +63,7 @@ en:
|
|
63
63
|
|
64
64
|
### Interpolation
|
65
65
|
|
66
|
-
In many cases you want to abstract your translations so that variables can be interpolated into the translation, just like Rails
|
66
|
+
In many cases you want to abstract your translations so that variables can be interpolated into the translation, just like Rails does.
|
67
67
|
|
68
68
|
```ruby
|
69
69
|
page_title :name => @user.name
|
@@ -83,7 +83,7 @@ There are some action aliases:
|
|
83
83
|
"remove" => "destroy"
|
84
84
|
```
|
85
85
|
|
86
|
-
I18n
|
86
|
+
I18n backend chain:
|
87
87
|
|
88
88
|
```ruby
|
89
89
|
en:
|
@@ -116,7 +116,7 @@ end
|
|
116
116
|
|
117
117
|
This means that the I18n scope for the action "the_custom_action" will be the same as "index".
|
118
118
|
|
119
|
-
You can also specify a custom location at the "scope" key at the options hash, like
|
119
|
+
You can also specify a custom location at the "scope" key at the options hash, exactly like Rails does.
|
120
120
|
|
121
121
|
```ruby
|
122
122
|
simple_helper :page_title, :scope => "my.awesome.chain", :name => "John"
|
@@ -1,22 +1,22 @@
|
|
1
1
|
module SimpleHelpers
|
2
2
|
class Config
|
3
3
|
|
4
|
-
VALID_OPTIONS = [:log]
|
4
|
+
VALID_OPTIONS = [:log, :pluralize]
|
5
5
|
|
6
|
-
def self.
|
7
|
-
@
|
6
|
+
def self.only
|
7
|
+
@only ||= []
|
8
8
|
end
|
9
9
|
|
10
|
-
def self.
|
11
|
-
@
|
10
|
+
def self.only=(*allowed)
|
11
|
+
@only = SimpleHelpers::Support.certified_array!(allowed)
|
12
12
|
end
|
13
13
|
|
14
|
-
def self.
|
15
|
-
@
|
14
|
+
def self.except
|
15
|
+
@except ||= []
|
16
16
|
end
|
17
17
|
|
18
|
-
def self.
|
19
|
-
@
|
18
|
+
def self.except=(*not_allowed)
|
19
|
+
@except = SimpleHelpers::Support.certified_array!(not_allowed)
|
20
20
|
end
|
21
21
|
|
22
22
|
def self.helpers
|
@@ -28,9 +28,9 @@ module SimpleHelpers
|
|
28
28
|
end
|
29
29
|
|
30
30
|
def self.allowed_controller?(controller)
|
31
|
-
( @
|
32
|
-
( not @
|
33
|
-
( not @
|
31
|
+
( @only.empty? and @except.empty? ) or
|
32
|
+
( not @only.empty? and @only.include?(controller) ) or
|
33
|
+
( not @except.empty? and not @except.include?(controller) )
|
34
34
|
end
|
35
35
|
|
36
36
|
def self.options
|
@@ -24,6 +24,7 @@ module SimpleHelpers
|
|
24
24
|
simple_helper_aliases = controller.class.const_get :SIMPLE_HELPER_ALIASES
|
25
25
|
action_name = simple_helper_aliases.fetch(action_name, action_name) if simple_helper_aliases.is_a? Hash
|
26
26
|
end
|
27
|
+
group = method_name
|
27
28
|
group = group.pluralize if options.has_key? :pluralize
|
28
29
|
|
29
30
|
{
|
data/lib/simple_helpers.rb
CHANGED
@@ -11,8 +11,8 @@ module SimpleHelpers
|
|
11
11
|
end
|
12
12
|
|
13
13
|
SimpleHelpers.configure do |config|
|
14
|
-
config.helpers
|
15
|
-
config.
|
16
|
-
config.
|
17
|
-
config.options
|
14
|
+
config.helpers = []
|
15
|
+
config.except = []
|
16
|
+
config.only = []
|
17
|
+
config.options = [:log]
|
18
18
|
end
|
data/templates/initializer.rb
CHANGED
@@ -9,12 +9,12 @@ SimpleHelpers.configure do |config|
|
|
9
9
|
# config.helpers will NOT be created automatically in these controllers
|
10
10
|
# *** keep it empty if you would allow all controlers
|
11
11
|
# example: [SessionsController]
|
12
|
-
# config.
|
12
|
+
# config.except = []
|
13
13
|
|
14
14
|
# config.helpers will be created automatically in these controllers
|
15
15
|
# *** keep it empty if you would allow all controlers
|
16
|
-
# example: [
|
17
|
-
# config.
|
16
|
+
# example: [PostsController]
|
17
|
+
# config.only = []
|
18
18
|
|
19
19
|
# Options:
|
20
20
|
# :pluralize => I18n pluralized helper names
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: simple_helpers
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-07-
|
12
|
+
date: 2012-07-21 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
@@ -124,7 +124,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
124
124
|
version: '0'
|
125
125
|
segments:
|
126
126
|
- 0
|
127
|
-
hash:
|
127
|
+
hash: 632949602249206258
|
128
128
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
129
129
|
none: false
|
130
130
|
requirements:
|
@@ -133,7 +133,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
133
133
|
version: '0'
|
134
134
|
segments:
|
135
135
|
- 0
|
136
|
-
hash:
|
136
|
+
hash: 632949602249206258
|
137
137
|
requirements: []
|
138
138
|
rubyforge_project:
|
139
139
|
rubygems_version: 1.8.23
|