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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: deb62d56966b35151bb79ca90be9ef8782668bb7
4
- data.tar.gz: daec7ce9dc30b8c260de4e0eabac949c92e24401
3
+ metadata.gz: b57e758bcc9b93c274185526b7aab9e36088447d
4
+ data.tar.gz: 06b703b2c97f3d2d9073e2b72a15e1b5f3400b74
5
5
  SHA512:
6
- metadata.gz: 55677cf4e2a832677f672c8b9e332a2f40ca3df46c1c517bbc0cef4365f5c90b4726da53b4cd4f48a556f3e83596860d98c08f9db4ca377ffbef765c8292f43a
7
- data.tar.gz: b422b2fbf53018bd23d471cfebb351645d845459fe1298d225ea4ee643ed6f184c1c7e71dfbfbc92b5e1cd4dae57bc8bf058a3ab0cf90c7400e80e848147803c
6
+ metadata.gz: d4fc4a28cd10416757ef6a6eae0da1c47c655493f445ef1f51146f080fee3ae331d8f18bef6d8fafe5f2960cbc1b515aa78289c9c4c54d2720ac0745d0b28be2
7
+ data.tar.gz: bb56fe12bc73ea1cbdb5bf18cc25343d00bcd6acdd7630e75d666e45ddf3fee3fd2eebef71c0909eb85e60f0d468693f2d743c2f30afa7708ffa01d0c899b8b1
data/.gitignore CHANGED
@@ -9,7 +9,8 @@
9
9
  .ruby-gemset
10
10
  /.bundle
11
11
 
12
- lib/service_objects
12
+ lib/quick
13
+ test/unit/quick
13
14
 
14
15
  *.sw?
15
16
  .sw?
data/.travis.yml CHANGED
@@ -2,13 +2,17 @@ language: ruby
2
2
 
3
3
  matrix:
4
4
  allow_failures:
5
- - rvm: ruby-head
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
@@ -1,4 +1,5 @@
1
1
  module PayDirt
2
+ # Provides developers with a [re]usable result object for their service objects to return.
2
3
  class Result
3
4
  # The response from a use case execution
4
5
  #
@@ -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
- def self.included(base)
4
- # Load instance variables from the provided hash of dependencies.
5
- #
6
- # Raises if any required dependencies are missing from +options+ hash.
7
- #
8
- # @param [List<String,Symbol>]
9
- # option_names list of keys representing required dependencies
10
- #
11
- # @param [Hash]
12
- # options A hash of dependencies
13
- #
14
- # @public
15
- def load_options(*option_names, options)
16
- # Load required options
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
- # Load remaining options
20
- options.each_key { |o| options = load_option(o, options) }
21
- end
20
+ # Load remaining options
21
+ options.each_key { |k| options = load_option(k, options) }
22
+ end
22
23
 
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
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
- private
37
- # @private
38
- def load_option(option, options)
39
- instance_variable_set("@#{option}", fetch(option, options))
40
- options.delete(option)
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
- return options
43
- end
44
+ return options
45
+ end
44
46
 
45
- # @private
46
- def fetch(opt, opts)
47
- opts.fetch(opt.to_sym) { raise "Missing required option: #{opt}" }
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
@@ -1,3 +1,3 @@
1
1
  module PayDirt
2
- VERSION = "1.0.8"
2
+ VERSION = "1.0.9"
3
3
  end
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
- append(0, "require 'minitest_helper'\n\n")
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
- append(0, "require 'test_helper'\n\n")
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
@@ -7,3 +7,5 @@ require "minitest/autorun"
7
7
  $: << File.dirname(__FILE__) + "/../lib"
8
8
  $: << File.dirname(__FILE__)
9
9
 
10
+ `thor pay_dirt:service_object:new quick/digit_check -d fingers toes nose -D fingers:10 toes:10`
11
+
@@ -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 UltimateQuestion < PayDirt::Base
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::UltimateQuestion
23
+ @use_case = UseCase::UltimateQuestionBase
24
24
  end
25
25
 
26
26
  it "must inherit from PayDirt::Base" do
27
- lineage = UseCase::UltimateQuestion.ancestors.map(&:to_s)
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 UltimateQuestion
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::UltimateQuestion
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.8
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: 2013-10-13 00:00:00.000000000 Z
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.0.3
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