pay_dirt 1.0.8 → 1.0.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +2 -1
- data/.travis.yml +6 -2
- data/lib/pay_dirt/base.rb +4 -1
- data/lib/pay_dirt/result.rb +1 -0
- data/lib/pay_dirt/use_case.rb +42 -41
- data/lib/pay_dirt/version.rb +1 -1
- data/pay_dirt.thor +16 -8
- data/test/test_helper.rb +2 -0
- data/test/unit/pay_dirt/base_test.rb +3 -3
- data/test/unit/pay_dirt/use_case_test.rb +2 -2
- metadata +15 -15
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b57e758bcc9b93c274185526b7aab9e36088447d
|
4
|
+
data.tar.gz: 06b703b2c97f3d2d9073e2b72a15e1b5f3400b74
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d4fc4a28cd10416757ef6a6eae0da1c47c655493f445ef1f51146f080fee3ae331d8f18bef6d8fafe5f2960cbc1b515aa78289c9c4c54d2720ac0745d0b28be2
|
7
|
+
data.tar.gz: bb56fe12bc73ea1cbdb5bf18cc25343d00bcd6acdd7630e75d666e45ddf3fee3fd2eebef71c0909eb85e60f0d468693f2d743c2f30afa7708ffa01d0c899b8b1
|
data/.gitignore
CHANGED
data/.travis.yml
CHANGED
@@ -2,13 +2,17 @@ language: ruby
|
|
2
2
|
|
3
3
|
matrix:
|
4
4
|
allow_failures:
|
5
|
-
- rvm:
|
5
|
+
- rvm: ree
|
6
|
+
|
6
7
|
|
7
8
|
rvm:
|
9
|
+
- 2.2.1
|
10
|
+
- 2.1.4
|
8
11
|
- 2.0.0
|
9
12
|
- 1.9.3
|
10
13
|
- 1.9.2
|
11
14
|
- jruby
|
12
15
|
- ruby-head
|
16
|
+
- rbx
|
13
17
|
|
14
|
-
script: bundle exec rake test
|
18
|
+
script: bundle exec rake test; bundle exec rake test # run twice to test generated classest & tests
|
data/lib/pay_dirt/base.rb
CHANGED
@@ -1,7 +1,10 @@
|
|
1
1
|
require_relative 'use_case'
|
2
2
|
|
3
|
-
# Here's something to inherit from
|
4
3
|
module PayDirt
|
4
|
+
# A developer can optionally inherit from this base class, rather than include the PayDirt::UseCase module --
|
5
|
+
# this is obviously not possible if your service object's class is already inheriting from another class.
|
6
|
+
#
|
7
|
+
# @since 0.0.0
|
5
8
|
class Base
|
6
9
|
include PayDirt::UseCase
|
7
10
|
end
|
data/lib/pay_dirt/result.rb
CHANGED
data/lib/pay_dirt/use_case.rb
CHANGED
@@ -1,51 +1,52 @@
|
|
1
1
|
module PayDirt
|
2
|
+
# Provides the basic functionality every PayDirt service object should have.
|
3
|
+
# @since 0.0.2
|
2
4
|
module UseCase
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
option_names.each { |o| options = load_option(o, options) }
|
5
|
+
# Load instance variables from the provided hash of dependencies.
|
6
|
+
#
|
7
|
+
# Raises if any required dependencies (+required_options+) are missing from +options+ hash.
|
8
|
+
#
|
9
|
+
# @param [List<String,Symbol>]
|
10
|
+
# option_names list of keys representing required dependencies
|
11
|
+
#
|
12
|
+
# @param [Hash]
|
13
|
+
# options A hash of dependencies
|
14
|
+
#
|
15
|
+
# @public
|
16
|
+
def load_options(*required_options, options)
|
17
|
+
# Load required options
|
18
|
+
required_options.each { |o| options = load_option(o, options) }
|
18
19
|
|
19
|
-
|
20
|
-
|
21
|
-
|
20
|
+
# Load remaining options
|
21
|
+
options.each_key { |k| options = load_option(k, options) }
|
22
|
+
end
|
22
23
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
24
|
+
# Returns a result object conveying success or failure (+success+)
|
25
|
+
# and any +data+. See PayDirt::Result.
|
26
|
+
#
|
27
|
+
# @param [Boolean]
|
28
|
+
# success should the result be +#successful?+?
|
29
|
+
#
|
30
|
+
# @param [Object]
|
31
|
+
# data (nil) optional, an object containing information
|
32
|
+
#
|
33
|
+
# @public
|
34
|
+
def result(success, data = nil)
|
35
|
+
PayDirt::Result.new(success: success, data: data)
|
36
|
+
end
|
35
37
|
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
38
|
+
private
|
39
|
+
# @private
|
40
|
+
def load_option(option, options)
|
41
|
+
instance_variable_set("@#{option}", fetch(option, options))
|
42
|
+
options.delete(option)
|
41
43
|
|
42
|
-
|
43
|
-
|
44
|
+
return options
|
45
|
+
end
|
44
46
|
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
end
|
47
|
+
# @private
|
48
|
+
def fetch(opt, opts)
|
49
|
+
opts.fetch(opt.to_sym) { raise "Missing required option: #{opt}" }
|
49
50
|
end
|
50
51
|
end
|
51
52
|
end
|
data/lib/pay_dirt/version.rb
CHANGED
data/pay_dirt.thor
CHANGED
@@ -89,19 +89,27 @@ module PayDirt
|
|
89
89
|
end
|
90
90
|
|
91
91
|
# TESTS!
|
92
|
+
def boiler_plate_test_classes(helper_name, file)
|
93
|
+
append(0, "require '#{helper_name}'\n\n")
|
94
|
+
|
95
|
+
File.file? "test/#{helper_name}.rb" or create_file "test/#{helper_name}.rb"
|
96
|
+
|
97
|
+
prepend_to_file "test/#{helper_name}.rb" do
|
98
|
+
"require \"minitest/autorun\"\n"
|
99
|
+
end
|
100
|
+
append_to_file "test/#{helper_name}.rb" do
|
101
|
+
"require \"#{file}\"\n"
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
92
105
|
def open_test_class(class_names, file)
|
93
106
|
case options[:test_framework]
|
94
107
|
when "minitest", "mini_test"
|
95
|
-
|
96
|
-
append_to_file "test/minitest_helper.rb" do
|
97
|
-
"require \"#{file}\"\n"
|
98
|
-
end
|
108
|
+
boiler_plate_test_classes("minitest_helper", file)
|
99
109
|
else
|
100
|
-
|
101
|
-
append_to_file "test/test_helper.rb" do
|
102
|
-
"require \"#{file}\"\n"
|
103
|
-
end
|
110
|
+
boiler_plate_test_classes("test_helper", file)
|
104
111
|
end
|
112
|
+
|
105
113
|
append(0, "describe #{ class_string(class_names) } do\n")
|
106
114
|
end
|
107
115
|
|
data/test/test_helper.rb
CHANGED
@@ -4,7 +4,7 @@ require_relative "../../../lib/pay_dirt/base"
|
|
4
4
|
describe PayDirt::Base do
|
5
5
|
before do
|
6
6
|
module UseCase
|
7
|
-
class
|
7
|
+
class UltimateQuestionBase < PayDirt::Base
|
8
8
|
def initialize(options)
|
9
9
|
options = {
|
10
10
|
the_question: "What is the secret to life, the universe, and everything?"
|
@@ -20,11 +20,11 @@ describe PayDirt::Base do
|
|
20
20
|
end
|
21
21
|
end
|
22
22
|
|
23
|
-
@use_case = UseCase::
|
23
|
+
@use_case = UseCase::UltimateQuestionBase
|
24
24
|
end
|
25
25
|
|
26
26
|
it "must inherit from PayDirt::Base" do
|
27
|
-
lineage = UseCase::
|
27
|
+
lineage = UseCase::UltimateQuestionBase.ancestors.map(&:to_s)
|
28
28
|
assert lineage.include?("PayDirt::Base")
|
29
29
|
end
|
30
30
|
|
@@ -5,7 +5,7 @@ describe PayDirt::UseCase do
|
|
5
5
|
before do
|
6
6
|
|
7
7
|
module UseCase
|
8
|
-
class
|
8
|
+
class UltimateQuestionInclude
|
9
9
|
include PayDirt::UseCase
|
10
10
|
|
11
11
|
def initialize(options)
|
@@ -35,7 +35,7 @@ describe PayDirt::UseCase do
|
|
35
35
|
end
|
36
36
|
end
|
37
37
|
|
38
|
-
@use_case = UseCase::
|
38
|
+
@use_case = UseCase::UltimateQuestionInclude
|
39
39
|
end
|
40
40
|
|
41
41
|
it "need not inherit from PayDirt::Base" do
|
metadata
CHANGED
@@ -1,69 +1,69 @@
|
|
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.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tad Hosford
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-07-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: minitest
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '0'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: thor
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '0'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- -
|
38
|
+
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: coveralls
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- -
|
45
|
+
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: '0'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- -
|
52
|
+
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: rake
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- -
|
59
|
+
- - ">="
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: '0'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- -
|
66
|
+
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
69
|
description: |2
|
@@ -77,8 +77,8 @@ executables: []
|
|
77
77
|
extensions: []
|
78
78
|
extra_rdoc_files: []
|
79
79
|
files:
|
80
|
-
- .gitignore
|
81
|
-
- .travis.yml
|
80
|
+
- ".gitignore"
|
81
|
+
- ".travis.yml"
|
82
82
|
- Gemfile
|
83
83
|
- LICENSE
|
84
84
|
- README.md
|
@@ -104,17 +104,17 @@ require_paths:
|
|
104
104
|
- lib
|
105
105
|
required_ruby_version: !ruby/object:Gem::Requirement
|
106
106
|
requirements:
|
107
|
-
- -
|
107
|
+
- - ">="
|
108
108
|
- !ruby/object:Gem::Version
|
109
109
|
version: '0'
|
110
110
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
111
111
|
requirements:
|
112
|
-
- -
|
112
|
+
- - ">="
|
113
113
|
- !ruby/object:Gem::Version
|
114
114
|
version: '0'
|
115
115
|
requirements: []
|
116
116
|
rubyforge_project:
|
117
|
-
rubygems_version: 2.
|
117
|
+
rubygems_version: 2.4.5
|
118
118
|
signing_key:
|
119
119
|
specification_version: 4
|
120
120
|
summary: Reduce a towering codebase to modular rubble (or more rubygems) with pay_dirt
|