substation 0.0.10 → 0.0.11

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 460edad266e28bfdc471140411262db60a2db61a
4
+ data.tar.gz: 6a6da7ff265afc01e5ba055ab3624394c21cb5c9
5
+ SHA512:
6
+ metadata.gz: a0993d61b35f793ba71eac5da235f2349545e58c854767ec9393afa640c0c99ea4d2c38f4883013dbcbdc33617d15021b406e83626c0aa1b459e14236d2b9bd8
7
+ data.tar.gz: 4d8ac928cf4b493573fefc95685bf85edc3ecdc09c3642ccdae589ac22505d87a33d1e5fd973d6eed287a1c488b4544dc0de7cdefab84d4daf1fbe4a3394dfc8
@@ -0,0 +1,6 @@
1
+ AllCops:
2
+ Include:
3
+ - 'Gemfile'
4
+ Exclude:
5
+ - 'vendor/**/*'
6
+ - 'benchmarks/**/*'
@@ -1 +1 @@
1
- 1.9.3
1
+ 2.1.5
@@ -1,18 +1,18 @@
1
1
  language: ruby
2
- before_install: gem install bundler
3
- bundler_args: --without yard guard benchmarks
4
- script: "bundle exec rake ci"
2
+ sudo: false
3
+ cache: bundler
4
+ script: "bundle exec rake spec"
5
5
  rvm:
6
- - 1.9.3
7
- - 2.0.0
6
+ - 1.9
7
+ - 2.0
8
+ - 2.1
9
+ - 2.2
8
10
  - ruby-head
9
- - rbx
11
+ - rbx-2
12
+ - jruby
13
+ - jruby-head
10
14
  matrix:
11
- include:
12
- - rvm: jruby-19mode
13
- env: JRUBY_OPTS="$JRUBY_OPTS --debug"
14
- - rvm: jruby-head
15
- env: JRUBY_OPTS="$JRUBY_OPTS --debug"
16
15
  allow_failures:
16
+ - rvm: 2.2
17
17
  - rvm: ruby-head
18
18
  - rvm: jruby-head
@@ -1,3 +1,10 @@
1
+ # v0.0.11 2015-01-20
2
+
3
+ * Added missing specs to reach 100% mutation coverage
4
+ * Refactored a few internals without changing any API
5
+
6
+ [Compare v0.0.10..v0.0.11](https://github.com/snusnu/substation/compare/v0.0.10...v0.0.11)
7
+
1
8
  # v0.0.10 2014-08-11
2
9
 
3
10
  * This release is full of breaking changes and new features. The README is still out of
data/Gemfile CHANGED
@@ -4,12 +4,11 @@ gemspec
4
4
 
5
5
  group :test do
6
6
  gem 'multi_json', '~> 1.8.0'
7
- gem 'ducktrap', '~> 0.0.2', :git => 'https://github.com/mbj/ducktrap', :branch => 'master'
8
- gem 'vanguard', '~> 0.0.4', :git => 'https://github.com/mbj/vanguard', :branch => 'master'
7
+ gem 'ducktrap', '~> 0.0.2', git: 'https://github.com/mbj/ducktrap', branch: 'master'
8
+ gem 'vanguard', '~> 0.0.4', git: 'https://github.com/mbj/vanguard', branch: 'master'
9
9
  gem 'anima', '~> 0.2.0'
10
10
  end
11
11
 
12
12
  group :development do
13
- gem 'devtools', :git => 'https://github.com/rom-rb/devtools.git', :branch => 'master'
14
- eval File.read('Gemfile.devtools')
13
+ gem 'devtools', git: 'https://github.com/mbj/devtools.git', branch: 'master'
15
14
  end
data/Rakefile CHANGED
@@ -1,6 +1,4 @@
1
1
  # encoding: utf-8
2
2
 
3
- require 'rake'
4
3
  require 'devtools'
5
-
6
4
  Devtools.init_rake_tasks
@@ -1,2 +1,2 @@
1
1
  ---
2
- unit_test_timeout: 0.3
2
+ unit_test_timeout: 2
@@ -1,3 +1,3 @@
1
1
  ---
2
- threshold: 12 # TODO bring it back to 11 by collapsing the dsl registries
3
- total_score: 207
2
+ threshold: 10
3
+ total_score: 176
@@ -1,2 +1,2 @@
1
1
  ---
2
- threshold: 16.7
2
+ threshold: 15.2
@@ -1,3 +1,4 @@
1
1
  ---
2
2
  name: substation
3
3
  namespace: Substation
4
+ expect_coverage: 100
@@ -36,6 +36,7 @@ FeatureEnvy:
36
36
  - Substation::Processor::Evaluator#on_success # method object
37
37
  - Substation::Processor#success? # in a module to be included in a method object
38
38
  - Substation::Chain::DSL#__call__ # relies heavily on #new(other)
39
+ - Substation::DSL::Registry#initialize # some weirdness i don't understand
39
40
  IrresponsibleModule:
40
41
  enabled: true
41
42
  exclude: []
@@ -138,4 +139,5 @@ UtilityFunction:
138
139
  - Substation::Processor#success? # in a module to be included in a method object
139
140
  - Substation::Environment#action # DSL method
140
141
  - Substation::Environment#dispatcher # DSL method
142
+ - Substation::DSL::Registry#initialize # some weirdness i don't understand
141
143
  max_helper_calls: 0
@@ -1,8 +1,4 @@
1
- AllCops:
2
- Includes:
3
- - '../**/*.rake'
4
- Excludes:
5
- - '../spec/spec_helper.rb'
1
+ inherit_from: ../.rubocop.yml
6
2
 
7
3
  # Avoid parameter lists longer than five parameters.
8
4
  ParameterLists:
@@ -13,32 +9,113 @@ ParameterLists:
13
9
  BlockNesting:
14
10
  Max: 3
15
11
 
16
- HashSyntax:
12
+ # Align with the style guide.
13
+ CollectionMethods:
14
+ PreferredMethods:
15
+ collect: 'map'
16
+ inject: 'reduce'
17
+ find: 'detect'
18
+ find_all: 'select'
19
+
20
+ # Do not force public/protected/private keyword to be indented at the same
21
+ # level as the def keyword. My personal preference is to outdent these keywords
22
+ # because I think when scanning code it makes it easier to identify the
23
+ # sections of code and visually separate them. When the keyword is at the same
24
+ # level I think it sort of blends in with the def keywords and makes it harder
25
+ # to scan the code and see where the sections are.
26
+ AccessModifierIndentation:
17
27
  Enabled: false
18
28
 
19
- Blocks:
29
+ # Limit line length
30
+ LineLength:
31
+ Max: 106
32
+
33
+ # Disable documentation checking until a class needs to be documented once
34
+ Documentation:
20
35
  Enabled: false
21
36
 
22
- SpaceInsideBrackets:
37
+ # Do not always use &&/|| instead of and/or.
38
+ AndOr:
23
39
  Enabled: false
24
40
 
25
- Documentation:
26
- Enabled: false # reek already checks this and rubocop requires duplicate docs
41
+ # Do not favor modifier if/unless usage when you have a single-line body
42
+ IfUnlessModifier:
43
+ Enabled: false
27
44
 
28
- SingleLineMethods:
45
+ # Allow case equality operator (in limited use within the specs)
46
+ CaseEquality:
29
47
  Enabled: false
30
48
 
31
- LineLength:
32
- Max: 114 # the offending lines are in specs, sadly this means global disabling for now
49
+ # Constants do not always have to use SCREAMING_SNAKE_CASE
50
+ ConstantName:
51
+ Enabled: false
52
+
53
+ # Not all trivial readers/writers can be defined with attr_* methods
54
+ TrivialAccessors:
55
+ Enabled: false
56
+
57
+ # Allow empty lines around class body
58
+ EmptyLinesAroundClassBody:
59
+ Enabled: false
60
+
61
+ # Allow empty lines around module body
62
+ EmptyLinesAroundModuleBody:
63
+ Enabled: false
33
64
 
34
- MethodLength:
35
- Max: 12 # reek performs these checks anyway
65
+ # Allow empty lines around block body
66
+ EmptyLinesAroundBlockBody:
67
+ Enabled: false
36
68
 
37
- CaseIndentation:
69
+ # Allow multiple line operations to not require indentation
70
+ MultilineOperationIndentation:
38
71
  Enabled: false
39
72
 
73
+ # Prefer String#% over Kernel#sprintf
74
+ FormatString:
75
+ Enabled: false
76
+
77
+ # Use square brackets for literal Array objects
78
+ PercentLiteralDelimiters:
79
+ PreferredDelimiters:
80
+ '%': '{}'
81
+ '%i': '[]'
82
+ '%q': ()
83
+ '%Q': ()
84
+ '%r': '{}'
85
+ '%s': ()
86
+ '%w': '[]'
87
+ '%W': '[]'
88
+ '%x': ()
89
+
90
+ # Align if/else blocks with the variable assignment
91
+ EndAlignment:
92
+ AlignWith: variable
93
+
94
+ # Do not always align parameters when it is easier to read
95
+ AlignParameters:
96
+ Exclude:
97
+ - spec/**/*_spec.rb
98
+
99
+ # Prefer #kind_of? over #is_a?
100
+ ClassCheck:
101
+ EnforcedStyle: kind_of?
102
+
103
+ # Do not prefer double quotes to be used when %q or %Q is more appropriate
104
+ UnneededPercentQ:
105
+ Enabled: false
106
+
107
+ # Do not prefer lambda.call(...) over lambda.(...)
108
+ LambdaCall:
109
+ Enabled: false
110
+
111
+ # Allow using braces for value-returning blocks
112
+ Blocks:
113
+ Enabled: false
114
+
115
+ # I like it that way
40
116
  Lambda:
41
- Enabled: false # i personally like the look of multiline ->(arg) {} lambdas
117
+ Enabled: false
42
118
 
43
- IfUnlessModifier:
44
- Enabled: false # i have no strong opinion but i won't let it force me to go over the col limit
119
+ # Sometimes I like to align things differently
120
+ SingleSpaceBeforeFirstArg:
121
+ Enabled: false
@@ -7,6 +7,7 @@ require 'adamantium'
7
7
  require 'equalizer'
8
8
  require 'abstract_type'
9
9
  require 'concord'
10
+ require 'lupo'
10
11
 
11
12
  # Substation can be thought of as a domain level request router. It assumes
12
13
  # that every usecase in your application has a name and is implemented in a
@@ -43,21 +44,42 @@ module Substation
43
44
  # An empty frozen hash useful for (default) parameters
44
45
  EMPTY_HASH = {}.freeze
45
46
 
47
+ # Base class for substation errors
48
+ class Error < StandardError
49
+ def self.msg(object)
50
+ self::MSG % object.inspect
51
+ end
52
+
53
+ def initialize(object)
54
+ super(self.class.msg(object))
55
+ end
56
+ end # Error
57
+
46
58
  # Error raised when trying to access an unknown processor
47
- UnknownProcessor = Class.new(StandardError)
59
+ class UnknownProcessor < Error
60
+ MSG = 'No processor named %s is registered'.freeze
61
+ end # UnknownProcessor
48
62
 
49
63
  # Raised when trying to dispatch to an unregistered action
50
- UnknownActionError = Class.new(StandardError)
64
+ class UnknownActionError < Error
65
+ MSG = 'No action named %s is registered'.freeze
66
+ end # UnknownActionError
51
67
 
52
68
  # Raised when an object is already registered under the a given name
53
- AlreadyRegisteredError = Class.new(StandardError)
69
+ class AlreadyRegisteredError < Error
70
+ MSG = '%s is already registered'.freeze
71
+ end # AlreadyRegisteredError
54
72
 
55
73
  # Raised when a reserved method is being given
56
- ReservedNameError = Class.new(StandardError)
74
+ class ReservedNameError < Error
75
+ MSG = '%s is a reserved name'.freeze
76
+ end # ReservedNameError
57
77
 
58
78
  # Raised when a duplicate {Processor} should be registered within a {Chain}
59
- DuplicateProcessorError = Class.new(StandardError)
60
- end
79
+ class DuplicateProcessorError < Error
80
+ MSG = 'The following processors already exist within this chain: %s'.freeze
81
+ end # DuplicateProcessorError
82
+ end # Substation
61
83
 
62
84
  require 'substation/request'
63
85
  require 'substation/response'
@@ -66,8 +66,8 @@ module Substation
66
66
  #
67
67
  class Chain
68
68
 
69
- include Enumerable
70
69
  include Concord.new(:processors, :exception_chain)
70
+ include Lupo.enumerable(:processors)
71
71
  include Adamantium::Flat
72
72
 
73
73
  # Empty chain
@@ -146,25 +146,6 @@ module Substation
146
146
  }
147
147
  end
148
148
 
149
- # Iterate over all processors
150
- #
151
- # @param [Proc] block
152
- # a block passed to {#handlers} each method
153
- #
154
- # @yield [processor]
155
- #
156
- # @yieldparam [#call] processor
157
- # each processor in the chain
158
- #
159
- # @return [self]
160
- #
161
- # @api private
162
- def each(&block)
163
- return to_enum unless block
164
- processors.each(&block)
165
- self
166
- end
167
-
168
149
  private
169
150
 
170
151
  # Call the failure chain in case of an uncaught exception
@@ -8,13 +8,7 @@ module Substation
8
8
  class Definition
9
9
 
10
10
  include Equalizer.new(:name, :processors)
11
- include Enumerable
12
-
13
- # The message for {UnknownProcessor} exceptions
14
- UNKNOWN_PROCESSOR_MSG = 'No processor named %s is registered'.freeze
15
-
16
- # The message for {DuplicateProcessorError} exceptions
17
- DUPLICATE_PROCESSOR_MSG = 'The following processors already exist within this chain: %s'
11
+ include Lupo.enumerable(:processors)
18
12
 
19
13
  # The name of the chain
20
14
  #
@@ -80,25 +74,6 @@ module Substation
80
74
  self
81
75
  end
82
76
 
83
- # Iterate over all processors
84
- #
85
- # @param [Proc] block
86
- # a block passed to #{processors} each method
87
- #
88
- # @yield [processor]
89
- #
90
- # @yieldparam [#call] processor
91
- # each processor in this instance
92
- #
93
- # @return [self]
94
- #
95
- # @api private
96
- def each(&block)
97
- return to_enum unless block
98
- processors.each(&block)
99
- self
100
- end
101
-
102
77
  # Returns a new instance with +other+'s processors prepended
103
78
  #
104
79
  # @param [Definition] other
@@ -126,8 +101,8 @@ module Substation
126
101
  #
127
102
  # @api private
128
103
  def fetch(processor_name)
129
- processors.index {|processor| processor.name == processor_name} ||
130
- raise(UnknownProcessor, UNKNOWN_PROCESSOR_MSG % processor_name.inspect)
104
+ idx = processors.index {|processor| processor.name.equal?(processor_name)}
105
+ idx or raise(UnknownProcessor.new(processor_name))
131
106
  end
132
107
 
133
108
  # Raise {DuplicateProcessorError} with a message tailored for +dupes+
@@ -139,7 +114,7 @@ module Substation
139
114
  #
140
115
  # @api private
141
116
  def raise_duplicate_processor_error(dupes)
142
- raise DuplicateProcessorError, DUPLICATE_PROCESSOR_MSG % dupes.inspect
117
+ raise DuplicateProcessorError.new(dupes)
143
118
  end
144
119
 
145
120
  end # class Definition
@@ -94,7 +94,7 @@ module Substation
94
94
  #
95
95
  # @api private
96
96
  def fetch(name)
97
- actions.fetch(name) { raise(UnknownActionError) }
97
+ actions.fetch(name) { raise(UnknownActionError.new(name)) }
98
98
  end
99
99
 
100
100
  end # class Dispatcher
@@ -6,23 +6,9 @@ module Substation
6
6
  # A guard used for rejecting invalid names in {DSL}
7
7
  class Guard
8
8
 
9
- include Equalizer.new(:reserved_names)
9
+ include Concord.new(:reserved_names)
10
10
  include Adamantium::Flat
11
11
 
12
- # Message for ReservedNameError
13
- RESERVED_NAME_MSG = '%s is a reserved name'.freeze
14
-
15
- # Message for AlreadyRegisteredError
16
- ALREADY_REGISTERED_MSG = '%s is already registered'.freeze
17
-
18
- # The list of reserved names
19
- #
20
- # @return [Enumerable<Symbol>]
21
- #
22
- # @api private
23
- attr_reader :reserved_names
24
- private :reserved_names
25
-
26
12
  # Initialize a new instance
27
13
  #
28
14
  # @param [Enumerable<Symbol>] reserved_names
@@ -31,8 +17,8 @@ module Substation
31
17
  # @return [undefined]
32
18
  #
33
19
  # @api private
34
- def initialize(reserved_names = EMPTY_ARRAY)
35
- @reserved_names = reserved_names
20
+ def initialize(_reserved_names = EMPTY_ARRAY)
21
+ super
36
22
  end
37
23
 
38
24
  # Raise if {#name} is either reserved or already registered
@@ -71,7 +57,7 @@ module Substation
71
57
  # @api private
72
58
  def raise_if_already_registered(name, registry)
73
59
  if registry.include?(name)
74
- raise AlreadyRegisteredError, ALREADY_REGISTERED_MSG % name.inspect
60
+ raise AlreadyRegisteredError.new(name)
75
61
  end
76
62
  end
77
63
 
@@ -87,7 +73,7 @@ module Substation
87
73
  # @api private
88
74
  def raise_if_reserved(name)
89
75
  if reserved_names.include?(name)
90
- raise ReservedNameError, RESERVED_NAME_MSG % name.inspect
76
+ raise ReservedNameError.new(name)
91
77
  end
92
78
  end
93
79
 
@@ -6,8 +6,8 @@ module Substation
6
6
  # A mutable registry for objects collected with DSL classes
7
7
  class Registry
8
8
 
9
- include Equalizer.new(:guard, :entries)
10
- include Enumerable
9
+ include Concord.new(:guard, :items)
10
+ include Lupo.enumerable(:items)
11
11
 
12
12
  # Coerce +name+ into a Symbol
13
13
  #
@@ -21,57 +21,19 @@ module Substation
21
21
  name.to_sym
22
22
  end
23
23
 
24
- # The guard responsible for rejecting invalid entries
25
- #
26
- # @return [Guard]
27
- #
28
- # @api private
29
- attr_reader :guard
30
- protected :guard
31
-
32
- # The entries this registry stores
33
- #
34
- # @return [Hash<Symbol, Object>]
35
- #
36
- # @api private
37
- attr_reader :entries
38
- protected :entries
39
-
40
24
  # Initialize a new instance
41
25
  #
42
26
  # @param [Guard] guard
43
27
  # the guard to use for rejecting invalid entries
44
28
  #
45
- # @param [Hash<Symbol, Object>] entires
46
- # the entries this registry stores
29
+ # @param [Hash<Symbol, Object>] items
30
+ # the items this registry stores
47
31
  #
48
32
  # @return [undefined]
49
33
  #
50
34
  # @api private
51
- def initialize(guard, entries = EMPTY_HASH)
52
- @guard, @entries = guard, entries.dup
53
- end
54
-
55
- # Iterate over all entries
56
- #
57
- # @param [Proc] block
58
- # the block passed to #{entries}.each
59
- #
60
- # @yield [name, object]
61
- #
62
- # @yieldparam [Symbol] name
63
- # the name of the current entry
64
- #
65
- # @yieldparam [Object] object
66
- # the object registered by name
67
- #
68
- # @return [self]
69
- #
70
- # @api private
71
- def each(&block)
72
- return to_enum unless block
73
- entries.each(&block)
74
- self
35
+ def initialize(guard, items = EMPTY_HASH)
36
+ super(guard, items.dup)
75
37
  end
76
38
 
77
39
  # Return a new instance with +other+ merged in
@@ -113,8 +75,8 @@ module Substation
113
75
  # @api private
114
76
  def []=(name, object)
115
77
  coerced_name = coerce_name(name)
116
- guard.call(coerced_name, entries)
117
- entries[coerced_name] = object
78
+ guard.call(coerced_name, items)
79
+ items[coerced_name] = object
118
80
  end
119
81
 
120
82
  # Test wether an object is registered by +name+
@@ -127,7 +89,7 @@ module Substation
127
89
  #
128
90
  # @api private
129
91
  def include?(name)
130
- entries.include?(coerce_name(name))
92
+ items.include?(coerce_name(name))
131
93
  end
132
94
 
133
95
  # Return the object registered by +name+ or the value returned from +block+
@@ -142,7 +104,7 @@ module Substation
142
104
  #
143
105
  # @api private
144
106
  def fetch(name, &block)
145
- entries.fetch(coerce_name(name), &block)
107
+ items.fetch(coerce_name(name), &block)
146
108
  end
147
109
 
148
110
  # Return all names by which objects are registered
@@ -151,7 +113,7 @@ module Substation
151
113
  #
152
114
  # @api private
153
115
  def keys
154
- entries.keys
116
+ items.keys
155
117
  end
156
118
 
157
119
  private
@@ -174,7 +136,7 @@ module Substation
174
136
  #
175
137
  # @api private
176
138
  def new
177
- self.class.new(guard, entries)
139
+ self.class.new(guard, items)
178
140
  end
179
141
  end # class Registry
180
142
  end # module DSL
@@ -5,7 +5,7 @@ module Substation
5
5
  # Namespace for chain processors
6
6
  module Processor
7
7
 
8
- include Equalizer.new(:name, :handler, :config)
8
+ include Concord.new(:name, :handler, :config)
9
9
 
10
10
  # FIXME: include this once the bug with deep freezing
11
11
  # is resolved (currently this deep freezes and thus
@@ -24,13 +24,11 @@ module Substation
24
24
  # @return [undefined]
25
25
  #
26
26
  # @api private
27
- def initialize(name, handler, config)
28
- @name = name
29
- @handler = handler
30
- @config = config
31
- @executor = @config.executor
32
- @observers = @config.observers
33
- @failure_chain = @config.failure_chain
27
+ def initialize(_name, _handler, _config)
28
+ super
29
+ @executor = config.executor
30
+ @observers = config.observers
31
+ @failure_chain = config.failure_chain
34
32
  end
35
33
 
36
34
  # This processor's name
@@ -38,23 +36,7 @@ module Substation
38
36
  # @return [Symbol]
39
37
  #
40
38
  # @api private
41
- attr_reader :name
42
-
43
- # This processor's config
44
- #
45
- # @return [Builder::Config]
46
- #
47
- # @api private
48
- attr_reader :config
49
- protected :config
50
-
51
- # Return handler
52
- #
53
- # @return [#call]
54
- #
55
- # @api private
56
- attr_reader :handler
57
- protected :handler
39
+ public :name
58
40
 
59
41
  # Return failure chain
60
42
  #
@@ -40,20 +40,10 @@ module Substation
40
40
  class Response
41
41
 
42
42
  include AbstractType
43
- include Equalizer.new(:request, :output)
43
+ include Concord::Public.new(:request, :output)
44
44
  include Adamantium::Flat
45
45
 
46
- # The request that lead to this response
47
- #
48
- # @example
49
- #
50
- # response = dispatcher.call(:successful_action, :some_input)
51
- # response.request # => request passed to action named :successful_action
52
- #
53
- # @return [Request]
54
- #
55
- # @api public
56
- attr_reader :request
46
+ alias_method :data, :output
57
47
 
58
48
  # The application environment used within an action
59
49
  #
@@ -81,20 +71,6 @@ module Substation
81
71
  # @api public
82
72
  attr_reader :input
83
73
 
84
- # The data wrapped inside an action {Response}
85
- #
86
- # @example
87
- #
88
- # response = dispatcher.call(:successful_action, :some_input)
89
- # response.output # => data passed to request.success(data)
90
- #
91
- # @return [Object]
92
- #
93
- # @api public
94
- attr_reader :output
95
-
96
- alias_method :data, :output
97
-
98
74
  # Initialize a new instance
99
75
  #
100
76
  # @param [Request] request
@@ -106,11 +82,10 @@ module Substation
106
82
  # @return [undefined]
107
83
  #
108
84
  # @api private
109
- def initialize(request, output)
110
- @request = request
111
- @env = @request.env
112
- @input = @request.input
113
- @output = output
85
+ def initialize(_request, _output)
86
+ super
87
+ @env = request.env
88
+ @input = request.input
114
89
  end
115
90
 
116
91
  # Indicates wether this is a successful response or not
@@ -51,7 +51,7 @@ module Substation
51
51
  #
52
52
  # @api private
53
53
  def cmp?(comparator, other)
54
- super && exception.class.send(comparator, other.exception.class)
54
+ super && exception.class.public_send(comparator, other.exception.class)
55
55
  end
56
56
  end # class Output
57
57
  end # class Exception
@@ -2,5 +2,5 @@
2
2
 
3
3
  module Substation
4
4
  # Gem version
5
- VERSION = '0.0.10'.freeze
5
+ VERSION = '0.0.11'.freeze
6
6
  end
@@ -4,18 +4,14 @@ require 'rspec/its'
4
4
 
5
5
  if ENV['COVERAGE'] == 'true'
6
6
  require 'simplecov'
7
- require 'coveralls'
8
7
 
9
- SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[
10
- SimpleCov::Formatter::HTMLFormatter,
11
- Coveralls::SimpleCov::Formatter
12
- ]
8
+ SimpleCov.formatter = SimpleCov::Formatter::HTMLFormatter
13
9
 
14
10
  SimpleCov.start do
15
11
  command_name 'spec:unit'
16
- add_filter 'config'
17
- add_filter 'spec'
18
- minimum_coverage 99.6
12
+ add_filter '/spec/'
13
+ add_filter '/vendor/'
14
+ minimum_coverage 100
19
15
  end
20
16
  end
21
17
 
@@ -57,7 +57,7 @@ describe Chain::Definition do
57
57
 
58
58
  context 'when the given processor is already present in object' do
59
59
  let(:processors) { [processor] }
60
- let(:msg) { Chain::Definition::DUPLICATE_PROCESSOR_MSG % [processor].inspect }
60
+ let(:msg) { DuplicateProcessorError.msg([processor]) }
61
61
 
62
62
  it 'raises DuplicateProcessorError' do
63
63
  expect { subject }.to raise_error(DuplicateProcessorError, msg)
@@ -84,7 +84,7 @@ describe Chain::Definition do
84
84
 
85
85
  context 'and the processors contain duplicates' do
86
86
  let(:processor_2) { processor_1 }
87
- let(:msg) { Chain::Definition::DUPLICATE_PROCESSOR_MSG % [processor_2].inspect }
87
+ let(:msg) { DuplicateProcessorError.msg([processor_2]) }
88
88
 
89
89
  it 'raises DuplicateProcessorError' do
90
90
  expect { subject }.to raise_error(DuplicateProcessorError, msg)
@@ -132,9 +132,10 @@ describe Chain::Definition do
132
132
 
133
133
  context 'when no processor is registered under the given name' do
134
134
  let(:processors) { [] }
135
+ let(:msg) { UnknownProcessor.msg(name) }
135
136
 
136
137
  it 'raises an UnknownProcessorError' do
137
- expect { subject }.to raise_error(UnknownProcessor, "No processor named #{name.inspect} is registered")
138
+ expect { subject }.to raise_error(UnknownProcessor, msg)
138
139
  end
139
140
  end
140
141
  end
@@ -26,7 +26,7 @@ describe Chain::DSL do
26
26
 
27
27
  shared_examples_for 'duplicate processors' do
28
28
  let(:new_processor) { processor }
29
- let(:msg) { Chain::Definition::DUPLICATE_PROCESSOR_MSG % [processor].inspect }
29
+ let(:msg) { DuplicateProcessorError::MSG % [processor].inspect }
30
30
 
31
31
  it 'should raise DuplicateProcessorError' do
32
32
  expect { subject }.to raise_error(DuplicateProcessorError, msg)
@@ -25,9 +25,10 @@ describe Dispatcher do
25
25
 
26
26
  context 'when the action is not registered' do
27
27
  let(:name) { :unknown }
28
+ let(:msg) { UnknownActionError.msg(name) }
28
29
 
29
30
  specify do
30
- expect { subject }.to raise_error(described_class::UnknownActionError)
31
+ expect { subject }.to raise_error(UnknownActionError, msg)
31
32
  end
32
33
  end
33
34
  end
@@ -26,7 +26,7 @@ describe DSL::Guard do
26
26
 
27
27
  context 'when the given name is already registered' do
28
28
  let(:name) { :test }
29
- let(:msg) { described_class::ALREADY_REGISTERED_MSG % name.inspect }
29
+ let(:msg) { AlreadyRegisteredError.msg(name) }
30
30
 
31
31
  before do
32
32
  expect(registry).to receive(:include?).with(name).and_return(true)
@@ -57,7 +57,7 @@ describe DSL::Guard do
57
57
  end
58
58
 
59
59
  context 'when the given name is reserved' do
60
- let(:msg) { described_class::RESERVED_NAME_MSG % name.inspect }
60
+ let(:msg) { ReservedNameError.msg(name) }
61
61
 
62
62
  before do
63
63
  expect(reserved_names).to receive(:include?).with(name).and_return(true)
@@ -44,7 +44,7 @@ describe DSL::Registry do
44
44
  end
45
45
 
46
46
  context 'when name is already registered' do
47
- let(:msg) { DSL::Guard::ALREADY_REGISTERED_MSG % coerced_name.inspect }
47
+ let(:msg) { AlreadyRegisteredError.msg(coerced_name) }
48
48
 
49
49
  before { object[name] = expected }
50
50
 
@@ -52,7 +52,7 @@ describe DSL::Registry do
52
52
  end
53
53
 
54
54
  context 'when name is reserved' do
55
- let(:msg) { DSL::Guard::RESERVED_NAME_MSG % coerced_name.inspect }
55
+ let(:msg) { ReservedNameError.msg(coerced_name) }
56
56
  let(:reserved_names) { [coerced_name] }
57
57
 
58
58
  specify { expect { subject }.to raise_error(ReservedNameError, msg) }
@@ -108,7 +108,7 @@ describe Substation::Environment::DSL do
108
108
 
109
109
  context 'when the given name is reserved' do
110
110
  let(:name) { Chain::DSL::BASE_METHODS.first }
111
- let(:msg) { DSL::Guard::RESERVED_NAME_MSG % name.inspect }
111
+ let(:msg) { ReservedNameError.msg(name) }
112
112
 
113
113
  it 'raises ReservedNameError' do
114
114
  expect { subject }.to raise_error(ReservedNameError, msg)
@@ -117,7 +117,7 @@ describe Substation::Environment::DSL do
117
117
 
118
118
  context 'when the given name is already registered' do
119
119
  let(:name) { :test }
120
- let(:msg) { DSL::Guard::ALREADY_REGISTERED_MSG % name.inspect }
120
+ let(:msg) { AlreadyRegisteredError.msg(name) }
121
121
 
122
122
  before do
123
123
  object.register(name, processor)
@@ -21,6 +21,7 @@ Gem::Specification.new do |gem|
21
21
  gem.add_dependency 'equalizer', '~> 0.0', '>= 0.0.9'
22
22
  gem.add_dependency 'abstract_type', '~> 0.0', '>= 0.0.7'
23
23
  gem.add_dependency 'concord', '~> 0.1', '>= 0.1.5'
24
+ gem.add_dependency 'lupo', '~> 0.0', '>= 0.0.1'
24
25
 
25
- gem.add_development_dependency 'bundler', '~> 1.6', '>= 1.6.5'
26
+ gem.add_development_dependency 'bundler', '~> 1.7'
26
27
  end
metadata CHANGED
@@ -1,126 +1,129 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: substation
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.10
5
- prerelease:
4
+ version: 0.0.11
6
5
  platform: ruby
7
6
  authors:
8
7
  - Martin Gamsjaeger (snusnu)
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2014-08-11 00:00:00.000000000 Z
11
+ date: 2015-01-20 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: adamantium
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ~>
17
+ - - "~>"
20
18
  - !ruby/object:Gem::Version
21
19
  version: '0.2'
22
- - - ! '>='
20
+ - - ">="
23
21
  - !ruby/object:Gem::Version
24
22
  version: 0.2.0
25
23
  type: :runtime
26
24
  prerelease: false
27
25
  version_requirements: !ruby/object:Gem::Requirement
28
- none: false
29
26
  requirements:
30
- - - ~>
27
+ - - "~>"
31
28
  - !ruby/object:Gem::Version
32
29
  version: '0.2'
33
- - - ! '>='
30
+ - - ">="
34
31
  - !ruby/object:Gem::Version
35
32
  version: 0.2.0
36
33
  - !ruby/object:Gem::Dependency
37
34
  name: equalizer
38
35
  requirement: !ruby/object:Gem::Requirement
39
- none: false
40
36
  requirements:
41
- - - ~>
37
+ - - "~>"
42
38
  - !ruby/object:Gem::Version
43
39
  version: '0.0'
44
- - - ! '>='
40
+ - - ">="
45
41
  - !ruby/object:Gem::Version
46
42
  version: 0.0.9
47
43
  type: :runtime
48
44
  prerelease: false
49
45
  version_requirements: !ruby/object:Gem::Requirement
50
- none: false
51
46
  requirements:
52
- - - ~>
47
+ - - "~>"
53
48
  - !ruby/object:Gem::Version
54
49
  version: '0.0'
55
- - - ! '>='
50
+ - - ">="
56
51
  - !ruby/object:Gem::Version
57
52
  version: 0.0.9
58
53
  - !ruby/object:Gem::Dependency
59
54
  name: abstract_type
60
55
  requirement: !ruby/object:Gem::Requirement
61
- none: false
62
56
  requirements:
63
- - - ~>
57
+ - - "~>"
64
58
  - !ruby/object:Gem::Version
65
59
  version: '0.0'
66
- - - ! '>='
60
+ - - ">="
67
61
  - !ruby/object:Gem::Version
68
62
  version: 0.0.7
69
63
  type: :runtime
70
64
  prerelease: false
71
65
  version_requirements: !ruby/object:Gem::Requirement
72
- none: false
73
66
  requirements:
74
- - - ~>
67
+ - - "~>"
75
68
  - !ruby/object:Gem::Version
76
69
  version: '0.0'
77
- - - ! '>='
70
+ - - ">="
78
71
  - !ruby/object:Gem::Version
79
72
  version: 0.0.7
80
73
  - !ruby/object:Gem::Dependency
81
74
  name: concord
82
75
  requirement: !ruby/object:Gem::Requirement
83
- none: false
84
76
  requirements:
85
- - - ~>
77
+ - - "~>"
86
78
  - !ruby/object:Gem::Version
87
79
  version: '0.1'
88
- - - ! '>='
80
+ - - ">="
89
81
  - !ruby/object:Gem::Version
90
82
  version: 0.1.5
91
83
  type: :runtime
92
84
  prerelease: false
93
85
  version_requirements: !ruby/object:Gem::Requirement
94
- none: false
95
86
  requirements:
96
- - - ~>
87
+ - - "~>"
97
88
  - !ruby/object:Gem::Version
98
89
  version: '0.1'
99
- - - ! '>='
90
+ - - ">="
100
91
  - !ruby/object:Gem::Version
101
92
  version: 0.1.5
102
93
  - !ruby/object:Gem::Dependency
103
- name: bundler
94
+ name: lupo
104
95
  requirement: !ruby/object:Gem::Requirement
105
- none: false
106
96
  requirements:
107
- - - ~>
97
+ - - "~>"
108
98
  - !ruby/object:Gem::Version
109
- version: '1.6'
110
- - - ! '>='
99
+ version: '0.0'
100
+ - - ">="
111
101
  - !ruby/object:Gem::Version
112
- version: 1.6.5
113
- type: :development
102
+ version: 0.0.1
103
+ type: :runtime
114
104
  prerelease: false
115
105
  version_requirements: !ruby/object:Gem::Requirement
116
- none: false
117
106
  requirements:
118
- - - ~>
107
+ - - "~>"
119
108
  - !ruby/object:Gem::Version
120
- version: '1.6'
121
- - - ! '>='
109
+ version: '0.0'
110
+ - - ">="
111
+ - !ruby/object:Gem::Version
112
+ version: 0.0.1
113
+ - !ruby/object:Gem::Dependency
114
+ name: bundler
115
+ requirement: !ruby/object:Gem::Requirement
116
+ requirements:
117
+ - - "~>"
118
+ - !ruby/object:Gem::Version
119
+ version: '1.7'
120
+ type: :development
121
+ prerelease: false
122
+ version_requirements: !ruby/object:Gem::Requirement
123
+ requirements:
124
+ - - "~>"
122
125
  - !ruby/object:Gem::Version
123
- version: 1.6.5
126
+ version: '1.7'
124
127
  description: Implement application boundary interfaces with dedicated classes
125
128
  email:
126
129
  - gamsnjaga@gmail.com
@@ -131,15 +134,15 @@ extra_rdoc_files:
131
134
  - README.md
132
135
  - TODO.md
133
136
  files:
134
- - .gitignore
135
- - .rspec
136
- - .ruby-gemset
137
- - .ruby-version
138
- - .travis.yml
137
+ - ".gitignore"
138
+ - ".rspec"
139
+ - ".rubocop.yml"
140
+ - ".ruby-gemset"
141
+ - ".ruby-version"
142
+ - ".travis.yml"
139
143
  - CONTRIBUTING.md
140
144
  - Changelog.md
141
145
  - Gemfile
142
- - Gemfile.devtools
143
146
  - Guardfile
144
147
  - LICENSE
145
148
  - README.md
@@ -261,27 +264,26 @@ files:
261
264
  homepage: https://github.com/snusnu/substation
262
265
  licenses:
263
266
  - MIT
267
+ metadata: {}
264
268
  post_install_message:
265
269
  rdoc_options: []
266
270
  require_paths:
267
271
  - lib
268
272
  required_ruby_version: !ruby/object:Gem::Requirement
269
- none: false
270
273
  requirements:
271
- - - ! '>='
274
+ - - ">="
272
275
  - !ruby/object:Gem::Version
273
276
  version: '0'
274
277
  required_rubygems_version: !ruby/object:Gem::Requirement
275
- none: false
276
278
  requirements:
277
- - - ! '>='
279
+ - - ">="
278
280
  - !ruby/object:Gem::Version
279
281
  version: '0'
280
282
  requirements: []
281
283
  rubyforge_project:
282
- rubygems_version: 1.8.23
284
+ rubygems_version: 2.2.2
283
285
  signing_key:
284
- specification_version: 3
286
+ specification_version: 4
285
287
  summary: Think of it as a domain level request router. It assumes that every usecase
286
288
  in your application has a name and is implemented in a dedicated action handler
287
289
  (class).
@@ -1,71 +0,0 @@
1
- # encoding: utf-8
2
-
3
- group :development do
4
- gem 'rake', '~> 10.3.2'
5
- gem 'rspec', '~> 3.0.0'
6
- gem 'rspec-its', '~> 1.0.1'
7
- gem 'yard', '~> 0.8.7.4'
8
-
9
- platform :rbx do
10
- gem 'rubysl-singleton', '~> 2.0.0'
11
- end
12
- end
13
-
14
- group :yard do
15
- gem 'kramdown', '~> 1.3.3'
16
- end
17
-
18
- group :guard do
19
- gem 'guard', '~> 2.6.1'
20
- gem 'guard-bundler', '~> 2.0.0'
21
- gem 'guard-rspec', '~> 4.2.9'
22
- gem 'guard-rubocop', '~> 1.1.0'
23
-
24
- # file system change event handling
25
- gem 'listen', '~> 2.7.7'
26
- gem 'rb-fchange', '~> 0.0.6', require: false
27
- gem 'rb-fsevent', '~> 0.9.4', require: false
28
- gem 'rb-inotify', '~> 0.9.5', require: false
29
-
30
- # notification handling
31
- gem 'libnotify', '~> 0.8.3', require: false
32
- gem 'rb-notifu', '~> 0.0.4', require: false
33
- gem 'terminal-notifier-guard', '~> 1.5.3', require: false
34
- end
35
-
36
- group :metrics do
37
- gem 'coveralls', '~> 0.7.0'
38
- gem 'flay', '~> 2.5.0'
39
- gem 'flog', '~> 4.2.1'
40
- gem 'reek', '~> 1.3.7'
41
- gem 'rubocop', '~> 0.23.0'
42
- gem 'simplecov', '~> 0.7.1'
43
- gem 'yardstick', '~> 0.9.9'
44
-
45
- platforms :mri do
46
- gem 'mutant', '~> 0.5.23'
47
- gem 'mutant-rspec', '~> 0.5.21'
48
- end
49
-
50
- platforms :ruby_19, :ruby_20 do
51
- gem 'yard-spellcheck', '~> 0.1.5'
52
- end
53
-
54
- platform :rbx do
55
- gem 'json', '~> 1.8.1'
56
- gem 'racc', '~> 1.4.11'
57
- gem 'rubysl-logger', '~> 2.0.0'
58
- gem 'rubysl-open-uri', '~> 2.0.0'
59
- gem 'rubysl-prettyprint', '~> 2.0.3'
60
- end
61
- end
62
-
63
- group :benchmarks do
64
- gem 'rbench', '~> 0.2.3'
65
- end
66
-
67
- platform :jruby do
68
- group :jruby do
69
- gem 'jruby-openssl', '~> 0.9.4'
70
- end
71
- end