pay_dirt 1.0.6 → 1.0.7
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 +4 -4
- data/README.md +1 -1
- data/lib/pay_dirt/use_case.rb +13 -0
- data/lib/pay_dirt/version.rb +1 -1
- data/pay_dirt.thor +1 -1
- data/test/unit/pay_dirt/base_test.rb +8 -11
- data/test/unit/pay_dirt/result_test.rb +28 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 80daedc2e23621dd1692c5092c9cce375baf07a3
|
4
|
+
data.tar.gz: 6db425bb6a5785adb71396cfa42ef26fdc29ecf0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6d5956acf790c96f0086e66b0312cbfe4037e421ff3f902a23386f937fe265f458738c299c8d0fd183efd942e860a2cc305cbf25bbf0f8d749806f95c05b6277
|
7
|
+
data.tar.gz: 6cb08a75659b00259a7b273d6c0107c9f30a669817710fb97c2814984788cacb9065e4c4b000fa70622039eea600d7d6aaf20334197254123b687d7e8bda1183
|
data/README.md
CHANGED
data/lib/pay_dirt/use_case.rb
CHANGED
@@ -20,6 +20,19 @@ module PayDirt
|
|
20
20
|
options.each_key { |o| options = load_option(o, options) }
|
21
21
|
end
|
22
22
|
|
23
|
+
# Returns a result object representing success.
|
24
|
+
#
|
25
|
+
# @param [List<String,Symbol>]
|
26
|
+
# success should the result be +#successful?+
|
27
|
+
#
|
28
|
+
# @param [Object]
|
29
|
+
# data (nil) optional, an object containing information
|
30
|
+
#
|
31
|
+
# @public
|
32
|
+
def result(success, data = nil)
|
33
|
+
PayDirt::Result.new(success: success, data: data)
|
34
|
+
end
|
35
|
+
|
23
36
|
private
|
24
37
|
# @private
|
25
38
|
def load_option(option, options)
|
data/lib/pay_dirt/version.rb
CHANGED
data/pay_dirt.thor
CHANGED
@@ -68,7 +68,7 @@ module PayDirt
|
|
68
68
|
def write_execute_method
|
69
69
|
# The execute! method
|
70
70
|
@append.call(@inner_depth, "def execute!\n")
|
71
|
-
@append.call(@inner_depth.next, "return
|
71
|
+
@append.call(@inner_depth.next, "return result(true)\n")
|
72
72
|
@append.call(@inner_depth, "end\n")
|
73
73
|
end
|
74
74
|
|
@@ -10,15 +10,12 @@ describe PayDirt::Base do
|
|
10
10
|
the_question: "What is the secret to life, the universe, and everything?"
|
11
11
|
}.merge(options)
|
12
12
|
|
13
|
-
load_options(:the_question, :
|
13
|
+
load_options(:the_question, :the_secret, options)
|
14
14
|
end
|
15
15
|
|
16
16
|
def execute!
|
17
|
-
|
18
|
-
|
19
|
-
else
|
20
|
-
return PayDirt::Result.new(data: @the_secret_to_life_the_universe_and_everything, success: false)
|
21
|
-
end
|
17
|
+
@the_secret == 42 and return result(true, @the_secret )
|
18
|
+
return result(false)
|
22
19
|
end
|
23
20
|
end
|
24
21
|
end
|
@@ -31,17 +28,17 @@ describe PayDirt::Base do
|
|
31
28
|
assert lineage.include?("PayDirt::Base")
|
32
29
|
end
|
33
30
|
|
34
|
-
it "
|
31
|
+
it "will error when initialized without required options" do
|
35
32
|
proc { @use_case.new }.must_raise ArgumentError
|
36
33
|
end
|
37
34
|
|
38
|
-
it "
|
39
|
-
@use_case.new(
|
35
|
+
it "won't error if defaults were supplied for an omitted option" do
|
36
|
+
@use_case.new(the_secret: :not_telling).must_respond_to :execute!
|
40
37
|
end
|
41
38
|
|
42
39
|
it "can execute successfully" do
|
43
40
|
dependencies = {
|
44
|
-
|
41
|
+
the_secret: 42
|
45
42
|
}
|
46
43
|
|
47
44
|
result = @use_case.new(dependencies).execute!
|
@@ -52,7 +49,7 @@ describe PayDirt::Base do
|
|
52
49
|
|
53
50
|
it "can execute unsuccessfully" do
|
54
51
|
dependencies = {
|
55
|
-
|
52
|
+
the_secret: :i_dunno
|
56
53
|
}
|
57
54
|
|
58
55
|
result = @use_case.new(dependencies).execute!
|
@@ -11,4 +11,32 @@ describe PayDirt::Result do
|
|
11
11
|
pay_dirt = PayDirt::Result.new(data: 'foo')
|
12
12
|
pay_dirt.data.must_equal 'foo'
|
13
13
|
end
|
14
|
+
|
15
|
+
describe "has a little helper method" do
|
16
|
+
before do
|
17
|
+
class Subject < PayDirt::Base
|
18
|
+
def initialize(options)
|
19
|
+
load_options(:success, :data, options)
|
20
|
+
end
|
21
|
+
|
22
|
+
def execute!
|
23
|
+
result(@success, @data)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
@pay_dirt = Subject
|
28
|
+
end
|
29
|
+
|
30
|
+
it "can succeed" do
|
31
|
+
@pay_dirt.new(success: true, data: "yum").execute!.successful?.must_equal true
|
32
|
+
end
|
33
|
+
|
34
|
+
it "can be unsuccessful" do
|
35
|
+
@pay_dirt.new(success: false, data: "gross").execute!.successful?.must_equal false
|
36
|
+
end
|
37
|
+
|
38
|
+
it "provides access to data" do
|
39
|
+
@pay_dirt.new(success: true, data: "yum").execute!.data.must_equal "yum"
|
40
|
+
end
|
41
|
+
end
|
14
42
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pay_dirt
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tad Hosford
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-06-
|
11
|
+
date: 2013-06-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: minitest
|