motivation 0.0.3 → 0.0.4

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.md CHANGED
@@ -1,4 +1,4 @@
1
- # Motivation
1
+ # Motivation [![Code Climate](https://codeclimate.com/github/bemurphy/motivation.png)](https://codeclimate.com/github/bemurphy/motivation)
2
2
 
3
3
  Simple DSL for use in classes to motivate a user towards a goal. An example
4
4
  goal might be "Complete Profile", or "Setup Project".
@@ -39,6 +39,13 @@ class ProfileMotivation
39
39
  # Aliases profile to subject for clarity in steps
40
40
  subject :profile
41
41
 
42
+ # Provides an #applies? check. use this block to
43
+ # house logic if you want to selectively apply the
44
+ # motivation. Note this doesn't impact checks at
45
+ # all, it's so you have a central place for checking
46
+ # if you wish. true by default
47
+ applies { profile.age <= 14 }
48
+
42
49
  # Create a simple check. This defines the predicate `#setup_twitter?`
43
50
  check(:setup_twitter) { profile.twitter_name.to_s.length > 0 }
44
51
 
data/lib/motivation.rb CHANGED
@@ -32,6 +32,14 @@ module Motivation
32
32
  checks.detect { |c| ! c.completed? }
33
33
  end
34
34
 
35
+ def complete?
36
+ ! next_check
37
+ end
38
+
39
+ def [](check_name)
40
+ checks.detect { |c| c.name == check_name }
41
+ end
42
+
35
43
  def completions
36
44
  self.class.completions
37
45
  end
@@ -1,3 +1,3 @@
1
1
  module Motivation
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
@@ -151,6 +151,28 @@ describe Motivation do
151
151
  end
152
152
  end
153
153
 
154
+ describe "checking if all checks are complete" do
155
+ it "returns false if there's an incomplete check" do
156
+ motivation.method_check = false
157
+ expect(motivation).to_not be_complete
158
+ end
159
+
160
+ it "returns true if all checks are complete" do
161
+ motivation.method_check = true
162
+ expect(motivation).to be_complete
163
+ end
164
+ end
165
+
166
+ describe "retrieving a check with #[]" do
167
+ it "returns a check by name" do
168
+ check = motivation[:name_setup]
169
+ expect(check.name).to eq :name_setup
170
+
171
+ check = motivation[:users_signed_up]
172
+ expect(check.name).to eq :users_signed_up
173
+ end
174
+ end
175
+
154
176
  end
155
177
 
156
178
  describe Motivation::WrappedCheck, "#translation_key" do
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.3
4
+ version: 0.0.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-03-14 00:00:00.000000000 Z
12
+ date: 2014-07-08 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec
16
- requirement: &2160517080 !ruby/object:Gem::Requirement
16
+ requirement: !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,7 +21,12 @@ dependencies:
21
21
  version: 2.13.0
22
22
  type: :development
23
23
  prerelease: false
24
- version_requirements: *2160517080
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: 2.13.0
25
30
  description: Simple DSL for use in classes to motivate a user towards a goal
26
31
  email:
27
32
  - xternal1+github@gmail.com
@@ -59,7 +64,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
59
64
  version: '0'
60
65
  requirements: []
61
66
  rubyforge_project:
62
- rubygems_version: 1.8.15
67
+ rubygems_version: 1.8.23
63
68
  signing_key:
64
69
  specification_version: 3
65
70
  summary: Simple DSL for use in classes to motivate a user towards a goal