motivation 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.md +10 -0
- data/README.md +25 -2
- data/lib/motivation/version.rb +1 -1
- data/lib/motivation.rb +8 -3
- data/spec/motivation_spec.rb +13 -2
- metadata +4 -3
data/CHANGELOG.md
ADDED
data/README.md
CHANGED
@@ -88,10 +88,33 @@ Note it currently does not include i18n, you can pass the generated keys straigh
|
|
88
88
|
your helper (such as `t` in Rails views).
|
89
89
|
|
90
90
|
```
|
91
|
-
motivation.next_check.translation_key #=> "motivations.profile.setup_twitter.
|
91
|
+
motivation.next_check.translation_key #=> "motivations.profile.setup_twitter.default"
|
92
92
|
```
|
93
93
|
|
94
|
-
The key format is `motivations.motivation_subject.step_name.[
|
94
|
+
The key format is `motivations.motivation_subject.step_name.[default|complete]`. Note you can
|
95
|
+
call `default_translation_key` as a shortcut to always grab the default translation key. This is
|
96
|
+
useful if you want to always have the same messaging regardless of completion status. If you
|
97
|
+
wish to provide alternate messaging based on completion, fill our your local data with both `default`
|
98
|
+
and `complete` keys.
|
99
|
+
|
100
|
+
Here's an example locale that would match the motivation key structure:
|
101
|
+
|
102
|
+
```yaml
|
103
|
+
en:
|
104
|
+
motivations:
|
105
|
+
project:
|
106
|
+
name:
|
107
|
+
default: "Add a project name"
|
108
|
+
complete: "Your project is named!"
|
109
|
+
support_email:
|
110
|
+
default: "Setup a support email address"
|
111
|
+
complete: "Your support email is ready to go"
|
112
|
+
users_added:
|
113
|
+
default: "Now go sign up some users"
|
114
|
+
complete: "Awesome, you've got users!"
|
115
|
+
```
|
116
|
+
|
117
|
+
|
95
118
|
|
96
119
|
## Contributing
|
97
120
|
|
data/lib/motivation/version.rb
CHANGED
data/lib/motivation.rb
CHANGED
@@ -156,18 +156,23 @@ module Motivation
|
|
156
156
|
# or for a completed step
|
157
157
|
# 'motivations.project.complete.signed_up'
|
158
158
|
#
|
159
|
-
def translation_key
|
159
|
+
def translation_key(end_key = status_key)
|
160
160
|
[
|
161
161
|
"motivations",
|
162
162
|
@motivation.translation_key,
|
163
163
|
@check.name,
|
164
|
-
|
164
|
+
end_key
|
165
165
|
].join('.')
|
166
166
|
end
|
167
|
+
|
168
|
+
def default_translation_key
|
169
|
+
translation_key(:default)
|
170
|
+
end
|
171
|
+
|
167
172
|
private
|
168
173
|
|
169
174
|
def status_key
|
170
|
-
completed? ? "complete" : "
|
175
|
+
completed? ? "complete" : "default"
|
171
176
|
end
|
172
177
|
end
|
173
178
|
|
data/spec/motivation_spec.rb
CHANGED
@@ -171,9 +171,9 @@ describe Motivation::WrappedCheck, "#translation_key" do
|
|
171
171
|
end
|
172
172
|
|
173
173
|
context "for a incomplete step" do
|
174
|
-
it "generates a key like motivations.project.step_name.
|
174
|
+
it "generates a key like motivations.project.step_name.default" do
|
175
175
|
check.flag = false
|
176
|
-
expect(wrapped_check.translation_key).to eq "motivations.project.foo_bar.
|
176
|
+
expect(wrapped_check.translation_key).to eq "motivations.project.foo_bar.default"
|
177
177
|
end
|
178
178
|
end
|
179
179
|
|
@@ -183,4 +183,15 @@ describe Motivation::WrappedCheck, "#translation_key" do
|
|
183
183
|
expect(wrapped_check.translation_key).to eq "motivations.project.foo_bar.complete"
|
184
184
|
end
|
185
185
|
end
|
186
|
+
|
187
|
+
context "when an end_key is passed" do
|
188
|
+
it "uses the end_key as the terminal position" do
|
189
|
+
expect(wrapped_check.translation_key(:foobar)).to eq "motivations.project.foo_bar.foobar"
|
190
|
+
end
|
191
|
+
end
|
192
|
+
|
193
|
+
it "provides #default_translation_key as a convienience" do
|
194
|
+
expect(wrapped_check.default_translation_key).to eq "motivations.project.foo_bar.default"
|
195
|
+
end
|
196
|
+
|
186
197
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: motivation
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -13,7 +13,7 @@ date: 2013-03-14 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|
16
|
-
requirement: &
|
16
|
+
requirement: &2160517080 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
@@ -21,7 +21,7 @@ dependencies:
|
|
21
21
|
version: 2.13.0
|
22
22
|
type: :development
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *2160517080
|
25
25
|
description: Simple DSL for use in classes to motivate a user towards a goal
|
26
26
|
email:
|
27
27
|
- xternal1+github@gmail.com
|
@@ -30,6 +30,7 @@ extensions: []
|
|
30
30
|
extra_rdoc_files: []
|
31
31
|
files:
|
32
32
|
- .gitignore
|
33
|
+
- CHANGELOG.md
|
33
34
|
- Gemfile
|
34
35
|
- LICENSE
|
35
36
|
- README.md
|