pay_dirt 0.0.0 → 0.0.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 02ffbebfd616ea3615894973a41e9c54844fc270
4
- data.tar.gz: 13ae80297a56e44103e3f95633b67445dd08543c
3
+ metadata.gz: 225b334258cfa4c5dc7836bcc7bd8b58a19c6119
4
+ data.tar.gz: ec7e1f4d3e4aa5e210d33a239eb95279e9fe7f9d
5
5
  SHA512:
6
- metadata.gz: b5fcfcbd57874ab7e28232ff5fa2b913981fd187e1dfaffd22563717c3e98690a08491e86dbc9d22958092c5d8d67a528edff8017e48a840e05d66398996de64
7
- data.tar.gz: 6144b015159bccc341ddf46d86341d540945cc23bf68afddcf5504a6281ec5bd2f7d5817debbeae3993cd324665ab7047c7d2983ba7201f11b2fa6bc2f03faca
6
+ metadata.gz: f78dbd7abbe33e65260f9b823dcb9f0c0cfbacad5ad36517cf30bc9064e2785c7ab99a0f419989390c198fa44c36b6840d2c21d98142aef3f8114c148b46bb7e
7
+ data.tar.gz: c5aa125838ca42dda0c14a1857eafba7ed60322c9d8fb10120b0fcb9b2f1e30a8fc675fc0f100afa6604e68660fa6b5eb1111814d88558e2d8be33bbc9b6dddf
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT license:
2
+
3
+ Copyright (c) 2013 Tad Hosford
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE
data/README.md CHANGED
@@ -2,3 +2,61 @@
2
2
  #### A Ruby gem based on the "use case" pattern set forth in [opencurriculum-flashcards](https://github.com/isotope11/opencurriculum-flashcards)
3
3
 
4
4
  Provides the basic building blocks of a pattern capable of reducing a towering codebase to modular rubble (or more Ruby gems)
5
+
6
+ The [pay_dirt/base_test](https://github.com/rthbound/pay_dirt/blob/master/test/unit/pay_dirt/base_test.rb) provides a complete working example. It's all plain old Ruby, but you can require any dependency you like to be injected as an option via [load_options](https://github.com/rthbound/pay_dirt/blob/master/test/unit/pay_dirt/base_test.rb#L8)
7
+
8
+ describe PayDirt::Base do
9
+ before do
10
+
11
+ # A sample use case
12
+ module UseCase
13
+ class UltimateQuestion < PayDirt::Base
14
+ def initialize(options)
15
+ load_options(:the_secret_to_life_the_universe_and_everything, options)
16
+ end
17
+
18
+ def execute!
19
+ if @the_secret_to_life_the_universe_and_everything == 42
20
+ return PayDirt::Result.new(data: @the_secret_to_life_the_universe_and_everything, success: true)
21
+ else
22
+ return PayDirt::Result.new(data: @the_secret_to_life_the_universe_and_everything, success: false)
23
+ end
24
+ end
25
+ end
26
+ end
27
+
28
+ @use_case = UseCase::UltimateQuestion
29
+ end
30
+
31
+ it "must inherit from PayDirt::Base" do
32
+ assert_operator @use_case, :<, PayDirt::Base
33
+ end
34
+
35
+ it "must error when initialized without required options" do
36
+ begin
37
+ @use_case.new
38
+ rescue => e
39
+ e.must_be_kind_of ArgumentError
40
+ end
41
+ end
42
+
43
+ it "can execute successfully" do
44
+ dependencies = {
45
+ the_secret_to_life_the_universe_and_everything: 42
46
+ }
47
+
48
+ result = @use_case.new(dependencies).execute!
49
+
50
+ result.successful?.must_equal true
51
+ end
52
+
53
+ it "can execute successfully" do
54
+ dependencies = {
55
+ the_secret_to_life_the_universe_and_everything: :i_dunno
56
+ }
57
+
58
+ result = @use_case.new(dependencies).execute!
59
+
60
+ result.successful?.must_equal false
61
+ end
62
+ end
@@ -1,3 +1,3 @@
1
1
  module PayDirt
2
- VERSION = "0.0.0"
2
+ VERSION = "0.0.1"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pay_dirt
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.0
4
+ version: 0.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tad Hosford
@@ -65,6 +65,7 @@ files:
65
65
  - .ruby-gemset
66
66
  - .ruby-version
67
67
  - Gemfile
68
+ - LICENSE
68
69
  - README.md
69
70
  - Rakefile
70
71
  - lib/pay_dirt.rb
@@ -76,7 +77,6 @@ files:
76
77
  - test/unit/.gitkeep
77
78
  - test/unit/pay_dirt/base_test.rb
78
79
  - test/unit/pay_dirt/result_test.rb
79
- - test/unit/pay_dirt/use_case.rb
80
80
  homepage: http://github.com/rthbound/pay_dirt
81
81
  licenses: []
82
82
  metadata: {}
@@ -1,55 +0,0 @@
1
- require 'test_helper'
2
-
3
- describe PayDirt::Base do
4
- before do
5
- module UseCase
6
- class UltimateQuestion < PayDirt::Base
7
- def initialize(options)
8
- load_options(:the_secret_to_life_the_universe_and_everything, options)
9
- end
10
-
11
- def execute!
12
- if @the_secret_to_life_the_universe_and_everything == 42
13
- return PayDirt::Result.new(data: @the_secret_to_life_the_universe_and_everything, success: true)
14
- else
15
- return PayDirt::Result.new(data: @the_secret_to_life_the_universe_and_everything, success: false)
16
- end
17
- end
18
- end
19
- end
20
-
21
- @use_case = UseCase::UltimateQuestion
22
- end
23
-
24
- it "must inherit from PayDirt::Base" do
25
- assert_operator @use_case, :<, PayDirt::Base
26
- end
27
-
28
- it "must error when initialized without required options" do
29
- begin
30
- @use_case.new
31
- rescue => e
32
- e.must_be_kind_of ArgumentError
33
- end
34
- end
35
-
36
- it "can execute successfully" do
37
- dependencies = {
38
- the_secret_to_life_the_universe_and_everything: 42
39
- }
40
-
41
- result = @use_case.new(dependencies).execute!
42
-
43
- result.successful?.must_equal true
44
- end
45
-
46
- it "can execute successfully" do
47
- dependencies = {
48
- the_secret_to_life_the_universe_and_everything: :i_dunno
49
- }
50
-
51
- result = @use_case.new(dependencies).execute!
52
-
53
- result.successful?.must_equal false
54
- end
55
- end