lists_constant 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -27,7 +27,8 @@ Or install it yourself as:
27
27
  Example:
28
28
 
29
29
  In `my_state_machine.rb`:
30
- ```
30
+
31
+ ``` ruby
31
32
  class MyStateMachine
32
33
  include ListsConstant
33
34
  lists_constant :first, :second, :third, as: :steps
@@ -40,6 +41,7 @@ end
40
41
  ```
41
42
 
42
43
  In `locales/en.yml`:
44
+
43
45
  ```
44
46
  en:
45
47
  my_state_machine:
@@ -50,6 +52,7 @@ en:
50
52
  ```
51
53
 
52
54
  In `locales/es.yml`:
55
+
53
56
  ```
54
57
  es:
55
58
  my_state_machine:
@@ -60,13 +63,15 @@ es:
60
63
  ```
61
64
 
62
65
  Using the generated constant:
63
- ```
66
+
67
+ ``` ruby
64
68
  MyStateMachine::STEPS
65
69
  # => [:first, :second, :third]
66
70
  ```
67
71
 
68
72
  Using class-level localization:
69
- ```
73
+
74
+ ``` ruby
70
75
  I18n.locale = :en
71
76
  MyStateMachine.steps[:first]
72
77
  # => 'Initialize'
@@ -84,7 +89,8 @@ MyStateMachine.steps[:first]
84
89
  ```
85
90
 
86
91
  Instance query methods:
87
- ```
92
+
93
+ ``` ruby
88
94
  msm = MyStateMachine.new(:second)
89
95
 
90
96
  msm.step_second?
@@ -95,7 +101,8 @@ msm.step_third?
95
101
  ```
96
102
 
97
103
  Using instance-level localization:
98
- ```
104
+
105
+ ``` ruby
99
106
  I18n.locale = :en
100
107
  msm.localized_step
101
108
  # => 'Validate'
@@ -105,6 +112,22 @@ msm.localized_step
105
112
  # => 'Valide'
106
113
  ```
107
114
 
115
+ Localization lookups may be scoped by assigning a namespace to
116
+ the `ListsConstant` module:
117
+
118
+ ```
119
+ en:
120
+ activerecord:
121
+ attributes:
122
+ my_state_machine:
123
+ steps:
124
+ ...
125
+ ```
126
+
127
+ ``` ruby
128
+ ListsConstant.namespace = 'activerecord.attributes'
129
+ ```
130
+
108
131
  ## Contributing
109
132
 
110
133
  1. Fork it
@@ -1,3 +1,3 @@
1
1
  module ListsConstant
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
@@ -4,13 +4,18 @@ require File.expand_path('../lib/lists_constant/version', __FILE__)
4
4
  Gem::Specification.new do |gem|
5
5
  gem.authors = ["Andrew Horner"]
6
6
  gem.email = ["andrew@tablexi.com"]
7
+
8
+ gem.homepage = "https://github.com/ahorner/lists-constant"
7
9
  gem.description = %q{Easily create localization-friendly constant lists}
8
10
  gem.summary = %q{
9
- ListsConstant supplies a module which allows easy definition of lists of
10
- constant values for a Ruby class. I18n is used to translate the listed
11
+ ListsConstant is a module which allows you to easily define
12
+ lists of constant values. I18n is used to translate the listed
11
13
  constants into readable values.
14
+
15
+ This library is intended to make it simple to keep view-specific
16
+ information (like the text representations of your listed values)
17
+ out of your model classes.
12
18
  }
13
- gem.homepage = ""
14
19
 
15
20
  gem.files = `git ls-files`.split($\)
16
21
  gem.test_files = gem.files.grep(%r{^test/})
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lists_constant
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -61,7 +61,7 @@ files:
61
61
  - test/lib/lists_constant/lists_constant_test.rb
62
62
  - test/lib/lists_constant/version_test.rb
63
63
  - test/test_helper.rb
64
- homepage: ''
64
+ homepage: https://github.com/ahorner/lists-constant
65
65
  licenses: []
66
66
  post_install_message:
67
67
  rdoc_options: []
@@ -84,9 +84,10 @@ rubyforge_project:
84
84
  rubygems_version: 1.8.24
85
85
  signing_key:
86
86
  specification_version: 3
87
- summary: ListsConstant supplies a module which allows easy definition of lists of
88
- constant values for a Ruby class. I18n is used to translate the listed constants
89
- into readable values.
87
+ summary: ListsConstant is a module which allows you to easily define lists of constant
88
+ values. I18n is used to translate the listed constants into readable values. This
89
+ library is intended to make it simple to keep view-specific information (like the
90
+ text representations of your listed values) out of your model classes.
90
91
  test_files:
91
92
  - test/lib/lists_constant/lists_constant_test.rb
92
93
  - test/lib/lists_constant/version_test.rb