human_attribute 0.1.0 → 0.2.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.
data/{README.rdoc → README.md}
RENAMED
@@ -1,10 +1,11 @@
|
|
1
|
-
|
1
|
+
# Human Attribute
|
2
2
|
|
3
|
-
1
|
4
|
-
|
3
|
+
1. Defines method "human_name" for attribute name translation;
|
4
|
+
1. Defines method "human_value" for attribute value translation.
|
5
5
|
|
6
|
-
|
6
|
+
## Usage example
|
7
7
|
|
8
|
+
```yaml
|
8
9
|
en.yml:
|
9
10
|
en
|
10
11
|
activerecord
|
@@ -16,18 +17,25 @@ en.yml:
|
|
16
17
|
state:
|
17
18
|
new: Just registered
|
18
19
|
ok: Active
|
20
|
+
```
|
19
21
|
|
20
22
|
Then:
|
23
|
+
|
24
|
+
```ruby
|
21
25
|
user = User.first
|
22
26
|
user.state # => "new"
|
23
27
|
user.human_name(:state) # => "Status"
|
24
28
|
user.human_value(:state) # => "Just registered"
|
29
|
+
```
|
25
30
|
|
26
|
-
|
31
|
+
## Installation
|
27
32
|
|
28
33
|
In Gemfile:
|
34
|
+
|
35
|
+
```ruby
|
29
36
|
gem 'human_attribute'
|
37
|
+
```
|
30
38
|
|
31
|
-
|
39
|
+
## Copyright
|
32
40
|
|
33
|
-
Copyright (c)
|
41
|
+
Copyright (c) 2012 divineforest, [Evrone.com](http://evrone.com)
|
@@ -12,7 +12,7 @@ module ActiveRecord
|
|
12
12
|
def human_value(attribute_name)
|
13
13
|
value = send(attribute_name)
|
14
14
|
if value.present?
|
15
|
-
I18n.t(value, :scope => "activerecord.attribute_values.#{self.class.name.
|
15
|
+
I18n.t(value, :scope => "activerecord.attribute_values.#{self.class.name.underscore}.#{attribute_name}")
|
16
16
|
else
|
17
17
|
value
|
18
18
|
end
|
metadata
CHANGED
@@ -1,12 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: human_attribute
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
4
|
+
hash: 23
|
5
|
+
prerelease:
|
5
6
|
segments:
|
6
7
|
- 0
|
7
|
-
-
|
8
|
+
- 2
|
8
9
|
- 0
|
9
|
-
version: 0.
|
10
|
+
version: 0.2.0
|
10
11
|
platform: ruby
|
11
12
|
authors:
|
12
13
|
- Alexander Balashov
|
@@ -14,8 +15,7 @@ autorequire:
|
|
14
15
|
bindir: bin
|
15
16
|
cert_chain: []
|
16
17
|
|
17
|
-
date:
|
18
|
-
default_executable:
|
18
|
+
date: 2012-05-15 00:00:00 Z
|
19
19
|
dependencies: []
|
20
20
|
|
21
21
|
description:
|
@@ -29,13 +29,12 @@ extra_rdoc_files: []
|
|
29
29
|
files:
|
30
30
|
- .gitignore
|
31
31
|
- Gemfile
|
32
|
-
- README.
|
32
|
+
- README.md
|
33
33
|
- Rakefile
|
34
34
|
- human_attribute.gemspec
|
35
35
|
- lib/human_attribute.rb
|
36
36
|
- lib/human_attribute/active_record/base.rb
|
37
37
|
- lib/human_attribute/version.rb
|
38
|
-
has_rdoc: true
|
39
38
|
homepage: http://github.com/divineforest/human_attribute
|
40
39
|
licenses: []
|
41
40
|
|
@@ -45,25 +44,30 @@ rdoc_options: []
|
|
45
44
|
require_paths:
|
46
45
|
- lib
|
47
46
|
required_ruby_version: !ruby/object:Gem::Requirement
|
47
|
+
none: false
|
48
48
|
requirements:
|
49
49
|
- - ">="
|
50
50
|
- !ruby/object:Gem::Version
|
51
|
+
hash: 3
|
51
52
|
segments:
|
52
53
|
- 0
|
53
54
|
version: "0"
|
54
55
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
56
|
+
none: false
|
55
57
|
requirements:
|
56
58
|
- - ">="
|
57
59
|
- !ruby/object:Gem::Version
|
60
|
+
hash: 3
|
58
61
|
segments:
|
59
62
|
- 0
|
60
63
|
version: "0"
|
61
64
|
requirements: []
|
62
65
|
|
63
66
|
rubyforge_project: human_attribute
|
64
|
-
rubygems_version: 1.
|
67
|
+
rubygems_version: 1.8.24
|
65
68
|
signing_key:
|
66
69
|
specification_version: 3
|
67
70
|
summary: Translate model attribute values from locales
|
68
71
|
test_files: []
|
69
72
|
|
73
|
+
has_rdoc:
|