human_attribute 0.0.2 → 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.
- data/README.rdoc +7 -2
 - data/lib/human_attribute/active_record/base.rb +8 -0
 - data/lib/human_attribute/version.rb +1 -1
 - metadata +5 -10
 
    
        data/README.rdoc
    CHANGED
    
    | 
         @@ -1,12 +1,16 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            = Human Attribute
         
     | 
| 
       2 
2 
     | 
    
         | 
| 
       3 
     | 
    
         
            -
            Defines method " 
     | 
| 
      
 3 
     | 
    
         
            +
            1) Defines method "human_name" for attribute name translation;
         
     | 
| 
      
 4 
     | 
    
         
            +
            2) Defines method "human_value" for attribute value translation.
         
     | 
| 
       4 
5 
     | 
    
         | 
| 
       5 
6 
     | 
    
         
             
            = Usage example
         
     | 
| 
       6 
7 
     | 
    
         | 
| 
       7 
8 
     | 
    
         
             
            en.yml:
         
     | 
| 
       8 
9 
     | 
    
         
             
              en
         
     | 
| 
       9 
10 
     | 
    
         
             
                activerecord
         
     | 
| 
      
 11 
     | 
    
         
            +
                  attributes:
         
     | 
| 
      
 12 
     | 
    
         
            +
                    user:
         
     | 
| 
      
 13 
     | 
    
         
            +
                      state: Status
         
     | 
| 
       10 
14 
     | 
    
         
             
                  attribute_values:
         
     | 
| 
       11 
15 
     | 
    
         
             
                    user:
         
     | 
| 
       12 
16 
     | 
    
         
             
                      state:
         
     | 
| 
         @@ -16,6 +20,7 @@ en.yml: 
     | 
|
| 
       16 
20 
     | 
    
         
             
            Then:
         
     | 
| 
       17 
21 
     | 
    
         
             
              user = User.first
         
     | 
| 
       18 
22 
     | 
    
         
             
              user.state # => "new"
         
     | 
| 
      
 23 
     | 
    
         
            +
              user.human_name(:state) # => "Status"
         
     | 
| 
       19 
24 
     | 
    
         
             
              user.human_value(:state) # => "Just registered"
         
     | 
| 
       20 
25 
     | 
    
         | 
| 
       21 
26 
     | 
    
         
             
            = Installation
         
     | 
| 
         @@ -25,4 +30,4 @@ In Gemfile: 
     | 
|
| 
       25 
30 
     | 
    
         | 
| 
       26 
31 
     | 
    
         
             
            == Copyright
         
     | 
| 
       27 
32 
     | 
    
         | 
| 
       28 
     | 
    
         
            -
            Copyright (c) 2011 divineforest, Evrone.com. 
     | 
| 
      
 33 
     | 
    
         
            +
            Copyright (c) 2011 divineforest, {Evrone.com}[http://evrone.com]
         
     | 
| 
         @@ -1,6 +1,14 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            module ActiveRecord
         
     | 
| 
       2 
2 
     | 
    
         
             
              class Base
         
     | 
| 
       3 
3 
     | 
    
         | 
| 
      
 4 
     | 
    
         
            +
                # Looks in en.activerecord.attributes.class.attribute_name
         
     | 
| 
      
 5 
     | 
    
         
            +
                # Example I18n lookup: en.activerecord.attributes.user.state
         
     | 
| 
      
 6 
     | 
    
         
            +
                def human_name(attribute_name)
         
     | 
| 
      
 7 
     | 
    
         
            +
                  self.class.human_attribute_name(attribute_name)
         
     | 
| 
      
 8 
     | 
    
         
            +
                end
         
     | 
| 
      
 9 
     | 
    
         
            +
             
     | 
| 
      
 10 
     | 
    
         
            +
                # en.activerecord.attribute_values.class_name.attribute_name
         
     | 
| 
      
 11 
     | 
    
         
            +
                # Example I18n lookup: en.activerecord.attribute_values.user.state
         
     | 
| 
       4 
12 
     | 
    
         
             
                def human_value(attribute_name)
         
     | 
| 
       5 
13 
     | 
    
         
             
                  value = send(attribute_name)
         
     | 
| 
       6 
14 
     | 
    
         
             
                  if value.present?
         
     | 
    
        metadata
    CHANGED
    
    | 
         @@ -1,13 +1,12 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification 
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: human_attribute
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version 
         
     | 
| 
       4 
     | 
    
         
            -
               
     | 
| 
       5 
     | 
    
         
            -
              prerelease: 
         
     | 
| 
      
 4 
     | 
    
         
            +
              prerelease: false
         
     | 
| 
       6 
5 
     | 
    
         
             
              segments: 
         
     | 
| 
       7 
6 
     | 
    
         
             
              - 0
         
     | 
| 
      
 7 
     | 
    
         
            +
              - 1
         
     | 
| 
       8 
8 
     | 
    
         
             
              - 0
         
     | 
| 
       9 
     | 
    
         
            -
               
     | 
| 
       10 
     | 
    
         
            -
              version: 0.0.2
         
     | 
| 
      
 9 
     | 
    
         
            +
              version: 0.1.0
         
     | 
| 
       11 
10 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       12 
11 
     | 
    
         
             
            authors: 
         
     | 
| 
       13 
12 
     | 
    
         
             
            - Alexander Balashov
         
     | 
| 
         @@ -15,7 +14,7 @@ autorequire: 
     | 
|
| 
       15 
14 
     | 
    
         
             
            bindir: bin
         
     | 
| 
       16 
15 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       17 
16 
     | 
    
         | 
| 
       18 
     | 
    
         
            -
            date: 2011-11- 
     | 
| 
      
 17 
     | 
    
         
            +
            date: 2011-11-17 00:00:00 +04:00
         
     | 
| 
       19 
18 
     | 
    
         
             
            default_executable: 
         
     | 
| 
       20 
19 
     | 
    
         
             
            dependencies: []
         
     | 
| 
       21 
20 
     | 
    
         | 
| 
         @@ -46,27 +45,23 @@ rdoc_options: [] 
     | 
|
| 
       46 
45 
     | 
    
         
             
            require_paths: 
         
     | 
| 
       47 
46 
     | 
    
         
             
            - lib
         
     | 
| 
       48 
47 
     | 
    
         
             
            required_ruby_version: !ruby/object:Gem::Requirement 
         
     | 
| 
       49 
     | 
    
         
            -
              none: false
         
     | 
| 
       50 
48 
     | 
    
         
             
              requirements: 
         
     | 
| 
       51 
49 
     | 
    
         
             
              - - ">="
         
     | 
| 
       52 
50 
     | 
    
         
             
                - !ruby/object:Gem::Version 
         
     | 
| 
       53 
     | 
    
         
            -
                  hash: 3
         
     | 
| 
       54 
51 
     | 
    
         
             
                  segments: 
         
     | 
| 
       55 
52 
     | 
    
         
             
                  - 0
         
     | 
| 
       56 
53 
     | 
    
         
             
                  version: "0"
         
     | 
| 
       57 
54 
     | 
    
         
             
            required_rubygems_version: !ruby/object:Gem::Requirement 
         
     | 
| 
       58 
     | 
    
         
            -
              none: false
         
     | 
| 
       59 
55 
     | 
    
         
             
              requirements: 
         
     | 
| 
       60 
56 
     | 
    
         
             
              - - ">="
         
     | 
| 
       61 
57 
     | 
    
         
             
                - !ruby/object:Gem::Version 
         
     | 
| 
       62 
     | 
    
         
            -
                  hash: 3
         
     | 
| 
       63 
58 
     | 
    
         
             
                  segments: 
         
     | 
| 
       64 
59 
     | 
    
         
             
                  - 0
         
     | 
| 
       65 
60 
     | 
    
         
             
                  version: "0"
         
     | 
| 
       66 
61 
     | 
    
         
             
            requirements: []
         
     | 
| 
       67 
62 
     | 
    
         | 
| 
       68 
63 
     | 
    
         
             
            rubyforge_project: human_attribute
         
     | 
| 
       69 
     | 
    
         
            -
            rubygems_version: 1.6 
     | 
| 
      
 64 
     | 
    
         
            +
            rubygems_version: 1.3.6
         
     | 
| 
       70 
65 
     | 
    
         
             
            signing_key: 
         
     | 
| 
       71 
66 
     | 
    
         
             
            specification_version: 3
         
     | 
| 
       72 
67 
     | 
    
         
             
            summary: Translate model attribute values from locales
         
     |