human_attribute 0.2.0 → 1.0.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 +7 -0
- data/README.md +6 -2
- data/human_attribute.gemspec +1 -1
- data/lib/human_attribute/active_record/base.rb +11 -6
- data/lib/human_attribute/version.rb +1 -1
- metadata +34 -43
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 90255dfb5a1fdae5322422fd5050f5eb2b3162ff
|
4
|
+
data.tar.gz: 04762ede9bb785df1d8b76965e09602b488eb12f
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 3998fbed937d0016654478362c403286c9747b7501ddc1b84e65816c3207fc39d9885f210610b82675448e658669ff13e7bb6ff50b2f057b8eead67233bff1a9
|
7
|
+
data.tar.gz: 6c04dbf298eff388e9e14c372863f58f06fbb569773ec0f0274b515a7be9f99ad8c62e0fe742a910bdefbe46b0554fbdce80c16d4a70a08de3962ab3930e5cf6
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# Human Attribute
|
2
2
|
|
3
|
-
1. Defines method "human_name" for attribute name translation;
|
3
|
+
1. Defines method "human_name" for attribute name translation (shortcut for class level method human_attribute_name);
|
4
4
|
1. Defines method "human_value" for attribute value translation.
|
5
5
|
|
6
6
|
## Usage example
|
@@ -38,4 +38,8 @@ In Gemfile:
|
|
38
38
|
|
39
39
|
## Copyright
|
40
40
|
|
41
|
-
Copyright (c)
|
41
|
+
Copyright (c) 2013 divineforest, [Evrone.com](http://evrone.com)
|
42
|
+
|
43
|
+
## License
|
44
|
+
|
45
|
+
human_attribute is released under the [MIT License](http://www.opensource.org/licenses/MIT).
|
data/human_attribute.gemspec
CHANGED
@@ -1,6 +1,16 @@
|
|
1
1
|
module ActiveRecord
|
2
2
|
class Base
|
3
3
|
|
4
|
+
# en.activerecord.attribute_values.class_name.attribute_name
|
5
|
+
# Example I18n lookup: en.activerecord.attribute_values.user.state
|
6
|
+
def self.human_attribute_value(attribute_name, value)
|
7
|
+
if value.present?
|
8
|
+
I18n.t(value, :scope => "activerecord.attribute_values.#{self.name.underscore}.#{attribute_name}")
|
9
|
+
else
|
10
|
+
value
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
4
14
|
# Looks in en.activerecord.attributes.class.attribute_name
|
5
15
|
# Example I18n lookup: en.activerecord.attributes.user.state
|
6
16
|
def human_name(attribute_name)
|
@@ -11,12 +21,7 @@ module ActiveRecord
|
|
11
21
|
# Example I18n lookup: en.activerecord.attribute_values.user.state
|
12
22
|
def human_value(attribute_name)
|
13
23
|
value = send(attribute_name)
|
14
|
-
|
15
|
-
I18n.t(value, :scope => "activerecord.attribute_values.#{self.class.name.underscore}.#{attribute_name}")
|
16
|
-
else
|
17
|
-
value
|
18
|
-
end
|
24
|
+
self.class.human_attribute_value attribute_name, value
|
19
25
|
end
|
20
|
-
|
21
26
|
end
|
22
27
|
end
|
metadata
CHANGED
@@ -1,33 +1,36 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: human_attribute
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
prerelease:
|
6
|
-
segments:
|
7
|
-
- 0
|
8
|
-
- 2
|
9
|
-
- 0
|
10
|
-
version: 0.2.0
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
11
5
|
platform: ruby
|
12
|
-
authors:
|
6
|
+
authors:
|
13
7
|
- Alexander Balashov
|
14
8
|
autorequire:
|
15
9
|
bindir: bin
|
16
10
|
cert_chain: []
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
11
|
+
date: 2016-07-28 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rake
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
21
27
|
description:
|
22
28
|
email:
|
23
29
|
executables: []
|
24
|
-
|
25
30
|
extensions: []
|
26
|
-
|
27
31
|
extra_rdoc_files: []
|
28
|
-
|
29
|
-
|
30
|
-
- .gitignore
|
32
|
+
files:
|
33
|
+
- ".gitignore"
|
31
34
|
- Gemfile
|
32
35
|
- README.md
|
33
36
|
- Rakefile
|
@@ -37,37 +40,25 @@ files:
|
|
37
40
|
- lib/human_attribute/version.rb
|
38
41
|
homepage: http://github.com/divineforest/human_attribute
|
39
42
|
licenses: []
|
40
|
-
|
43
|
+
metadata: {}
|
41
44
|
post_install_message:
|
42
45
|
rdoc_options: []
|
43
|
-
|
44
|
-
require_paths:
|
46
|
+
require_paths:
|
45
47
|
- lib
|
46
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
47
|
-
|
48
|
-
requirements:
|
48
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
49
|
+
requirements:
|
49
50
|
- - ">="
|
50
|
-
- !ruby/object:Gem::Version
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
version: "0"
|
55
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
56
|
-
none: false
|
57
|
-
requirements:
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
version: '0'
|
53
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
54
|
+
requirements:
|
58
55
|
- - ">="
|
59
|
-
- !ruby/object:Gem::Version
|
60
|
-
|
61
|
-
segments:
|
62
|
-
- 0
|
63
|
-
version: "0"
|
56
|
+
- !ruby/object:Gem::Version
|
57
|
+
version: '0'
|
64
58
|
requirements: []
|
65
|
-
|
66
59
|
rubyforge_project: human_attribute
|
67
|
-
rubygems_version:
|
60
|
+
rubygems_version: 2.4.5.1
|
68
61
|
signing_key:
|
69
|
-
specification_version:
|
62
|
+
specification_version: 4
|
70
63
|
summary: Translate model attribute values from locales
|
71
64
|
test_files: []
|
72
|
-
|
73
|
-
has_rdoc:
|