simple-service 0.1.3 → 0.1.4

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.
Files changed (43) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +2 -2
  3. data/Makefile +4 -11
  4. data/README.md +67 -2
  5. data/VERSION +1 -1
  6. data/doc/Simple.html +117 -0
  7. data/doc/Simple/Service.html +863 -0
  8. data/doc/Simple/Service/Action.html +1014 -0
  9. data/doc/Simple/Service/Action/Comment.html +451 -0
  10. data/doc/Simple/Service/Action/Comment/Extractor.html +347 -0
  11. data/doc/Simple/Service/Action/IndieHash.html +506 -0
  12. data/doc/Simple/Service/Action/MethodReflection.html +285 -0
  13. data/doc/Simple/Service/Action/Parameter.html +816 -0
  14. data/doc/Simple/Service/ArgumentError.html +128 -0
  15. data/doc/Simple/Service/ClassMethods.html +187 -0
  16. data/doc/Simple/Service/Context.html +379 -0
  17. data/doc/Simple/Service/ContextMissingError.html +124 -0
  18. data/doc/Simple/Service/ContextReadOnlyError.html +206 -0
  19. data/doc/Simple/Service/ExtraArguments.html +428 -0
  20. data/doc/Simple/Service/GemHelper.html +190 -0
  21. data/doc/Simple/Service/MissingArguments.html +426 -0
  22. data/doc/Simple/Service/NoSuchAction.html +433 -0
  23. data/doc/_index.html +286 -0
  24. data/doc/class_list.html +51 -0
  25. data/doc/css/common.css +1 -0
  26. data/doc/css/full_list.css +58 -0
  27. data/doc/css/style.css +496 -0
  28. data/doc/file.README.html +146 -0
  29. data/doc/file_list.html +56 -0
  30. data/doc/frames.html +17 -0
  31. data/doc/index.html +146 -0
  32. data/doc/js/app.js +303 -0
  33. data/doc/js/full_list.js +216 -0
  34. data/doc/js/jquery.js +4 -0
  35. data/doc/method_list.html +539 -0
  36. data/doc/top-level-namespace.html +110 -0
  37. data/lib/simple/service.rb +56 -16
  38. data/lib/simple/service/action.rb +6 -6
  39. data/lib/simple/service/action/comment.rb +1 -1
  40. data/lib/simple/service/action/method_reflection.rb +1 -1
  41. data/lib/simple/service/context.rb +5 -5
  42. data/lib/simple/service/version.rb +2 -2
  43. metadata +33 -2
@@ -0,0 +1,110 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>
7
+ Top Level Namespace
8
+
9
+ &mdash; Documentation by YARD 0.9.20
10
+
11
+ </title>
12
+
13
+ <link rel="stylesheet" href="css/style.css" type="text/css" charset="utf-8" />
14
+
15
+ <link rel="stylesheet" href="css/common.css" type="text/css" charset="utf-8" />
16
+
17
+ <script type="text/javascript" charset="utf-8">
18
+ pathId = "";
19
+ relpath = '';
20
+ </script>
21
+
22
+
23
+ <script type="text/javascript" charset="utf-8" src="js/jquery.js"></script>
24
+
25
+ <script type="text/javascript" charset="utf-8" src="js/app.js"></script>
26
+
27
+
28
+ </head>
29
+ <body>
30
+ <div class="nav_wrap">
31
+ <iframe id="nav" src="class_list.html?1"></iframe>
32
+ <div id="resizer"></div>
33
+ </div>
34
+
35
+ <div id="main" tabindex="-1">
36
+ <div id="header">
37
+ <div id="menu">
38
+
39
+ <a href="_index.html">Index</a> &raquo;
40
+
41
+
42
+ <span class="title">Top Level Namespace</span>
43
+
44
+ </div>
45
+
46
+ <div id="search">
47
+
48
+ <a class="full_list_link" id="class_list_link"
49
+ href="class_list.html">
50
+
51
+ <svg width="24" height="24">
52
+ <rect x="0" y="4" width="24" height="4" rx="1" ry="1"></rect>
53
+ <rect x="0" y="12" width="24" height="4" rx="1" ry="1"></rect>
54
+ <rect x="0" y="20" width="24" height="4" rx="1" ry="1"></rect>
55
+ </svg>
56
+ </a>
57
+
58
+ </div>
59
+ <div class="clear"></div>
60
+ </div>
61
+
62
+ <div id="content"><h1>Top Level Namespace
63
+
64
+
65
+
66
+ </h1>
67
+ <div class="box_info">
68
+
69
+
70
+
71
+
72
+
73
+
74
+
75
+
76
+
77
+
78
+
79
+ </div>
80
+
81
+ <h2>Defined Under Namespace</h2>
82
+ <p class="children">
83
+
84
+
85
+ <strong class="modules">Modules:</strong> <span class='object_link'><a href="Simple.html" title="Simple (module)">Simple</a></span>
86
+
87
+
88
+
89
+
90
+ </p>
91
+
92
+
93
+
94
+
95
+
96
+
97
+
98
+
99
+
100
+ </div>
101
+
102
+ <div id="footer">
103
+ Generated on Tue Dec 3 13:46:26 2019 by
104
+ <a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
105
+ 0.9.20 (ruby-2.5.1).
106
+ </div>
107
+
108
+ </div>
109
+ </body>
110
+ </html>
@@ -1,4 +1,4 @@
1
- module Simple # :nodoc:
1
+ module Simple # @private
2
2
  end
3
3
 
4
4
  require "expectation"
@@ -8,26 +8,60 @@ require_relative "service/action"
8
8
  require_relative "service/context"
9
9
  require_relative "service/version"
10
10
 
11
- # The Simple::Service module.
11
+ # <b>The Simple::Service interface</b>
12
12
  #
13
- # To mark a target module as a service module one must include the
14
- # Simple::Service module into the target module.
13
+ # This module implements the main API of the Simple::Service ruby gem.
14
+ #
15
+ # 1. <em>Marking a service module:</em> To turn a target module as a service module one must include <tt>Simple::Service</tt>
16
+ # into the target. This serves as a marker that this module is actually intended
17
+ # to provide one or more services. Example:
18
+ #
19
+ # module GodMode
20
+ # include Simple::Service
21
+ #
22
+ # # Build a universe.
23
+ # #
24
+ # # This comment will become part of the full description of the
25
+ # # "build_universe" service
26
+ # def build_universe(name, c: , pi: 3.14, e: 2.781)
27
+ # # at this point I realize that *I* am not God.
28
+ #
29
+ # 42 # Best try approach
30
+ # end
31
+ # end
32
+ #
33
+ # 2. <em>Discover services:</em> To discover services in a service module use the #actions method. This returns a Hash
34
+ # of actions. [TODO] why a Hash?
35
+ #
36
+ # Simple::Service.actions(GodMode)
37
+ # => {:build_universe=>#<Simple::Service::Action...>, ...}
38
+ #
39
+ # 3. <em>Invoke a service:</em> run <tt>Simple::Service.invoke</tt> or <tt>Simple::Service.invoke2</tt>. You must set a context first.
40
+ #
41
+ # Simple::Service.with_context do
42
+ # Simple::Service.invoke(GodMode, :build_universe, "TestWorld", c: 1e9)
43
+ # end
44
+ # => 42
15
45
  #
16
- # This serves as a marker that this module is actually intended
17
- # to be used as a service.
18
46
  module Simple::Service
19
- def self.included(klass) # :nodoc:
47
+ def self.included(klass) # @private
20
48
  klass.extend ClassMethods
21
49
  end
22
50
 
23
51
  # returns true if the passed in object is a service module.
52
+ #
53
+ # A service must be a module, and it must include the Simple::Service module.
24
54
  def self.service?(service)
25
- service.is_a?(Module) && service.include?(self)
55
+ verify_service! service
56
+ true
57
+ rescue ::ArgumentError
58
+ false
26
59
  end
27
60
 
28
- def self.verify_service!(service) # :nodoc:
61
+ # Raises an error if the passed in object is not a service
62
+ def self.verify_service!(service) # @private
29
63
  raise ::ArgumentError, "#{service.inspect} must be a Simple::Service, but is not even a Module" unless service.is_a?(Module)
30
- raise ::ArgumentError, "#{service.inspect} must be a Simple::Service, did you 'include Simple::Service'" unless service?(service)
64
+ raise ::ArgumentError, "#{service.inspect} must be a Simple::Service, did you 'include Simple::Service'" unless service.include?(self)
31
65
  end
32
66
 
33
67
  # returns a Hash with all actions in the +service+ module
@@ -47,11 +81,15 @@ module Simple::Service
47
81
 
48
82
  # invokes an action with a given +name+ in a service with +arguments+ and +params+.
49
83
  #
50
- # You cannot call this method if the context is not set.
84
+ # When calling +invoke+ using positional arguments (i.e. non-keyword arguments)
85
+ # they will be matched against positional arguments of the invoked method -
86
+ # but they will not be matched against named arguments.
51
87
  #
52
- # When calling #invoke using positional arguments they will be matched against
53
- # positional arguments of the invoked method - but they will not be matched
54
- # against named arguments.
88
+ # In other words: if the service implements an action "def foo(bar, baz:)", one can
89
+ # run it via
90
+ #
91
+ # - +Service.invoke("bar-value", baz: "baz-value")+, or via
92
+ # - +Service.invoke(bar: "bar-value", baz: "baz-value")+
55
93
  #
56
94
  # When there are not enough positional arguments to match the number of required
57
95
  # positional arguments of the method we raise an ArgumentError.
@@ -59,7 +97,9 @@ module Simple::Service
59
97
  # When there are more positional arguments provided than the number accepted
60
98
  # by the method we raise an ArgumentError.
61
99
  #
62
- # Entries in the named_args Hash that are not defined in the action itself are ignored.
100
+ # Entries in the +named_args+ Hash that are not defined in the action itself are ignored.
101
+ #
102
+ # *Note:* You cannot call this method if the context is not set.
63
103
  def self.invoke(service, name, *args, **named_args)
64
104
  raise ContextMissingError, "Need to set context before calling ::Simple::Service.invoke" unless context
65
105
 
@@ -75,7 +115,7 @@ module Simple::Service
75
115
  action(service, name).invoke2(args: args, flags: flags)
76
116
  end
77
117
 
78
- module ClassMethods # :nodoc:
118
+ module ClassMethods # @private
79
119
  # returns a Hash of actions provided by the service module.
80
120
  def __simple_service_actions__
81
121
  @__simple_service_actions__ ||= Action.enumerate(service: self)
@@ -15,11 +15,11 @@ module Simple::Service
15
15
  # rubocop:disable Metrics/ClassLength
16
16
 
17
17
  class Action
18
- IDENTIFIER_PATTERN = "[a-z][a-z0-9_]*" # :nodoc:
19
- IDENTIFIER_REGEXP = Regexp.compile("\\A#{IDENTIFIER_PATTERN}\\z") # :nodoc:
18
+ IDENTIFIER_PATTERN = "[a-z][a-z0-9_]*" # @private
19
+ IDENTIFIER_REGEXP = Regexp.compile("\\A#{IDENTIFIER_PATTERN}\\z") # @private
20
20
 
21
21
  # determines all services provided by the +service+ service module.
22
- def self.enumerate(service:) # :nodoc:
22
+ def self.enumerate(service:) # @private
23
23
  service.public_instance_methods(false)
24
24
  .grep(IDENTIFIER_REGEXP)
25
25
  .each_with_object({}) { |name, hsh| hsh[name] = Action.new(service, name) }
@@ -32,7 +32,7 @@ module Simple::Service
32
32
  "#{service.name}##{name}"
33
33
  end
34
34
 
35
- def to_s # :nodoc:
35
+ def to_s # @private
36
36
  full_name
37
37
  end
38
38
 
@@ -41,7 +41,7 @@ module Simple::Service
41
41
  @parameters ||= Parameter.reflect_on_method(service: service, name: name)
42
42
  end
43
43
 
44
- def initialize(service, name) # :nodoc:
44
+ def initialize(service, name) # @private
45
45
  @service = service
46
46
  @name = name
47
47
 
@@ -116,7 +116,7 @@ module Simple::Service
116
116
  private
117
117
 
118
118
  # returns an error if the keywords hash does not define all required keyword arguments.
119
- def verify_required_args!(args, flags) # :nodoc:
119
+ def verify_required_args!(args, flags) # @private
120
120
  @required_names ||= parameters.select(&:required?).map(&:name).map(&:to_s)
121
121
 
122
122
  missing_parameters = @required_names - args.keys - flags.keys
@@ -1,5 +1,5 @@
1
1
  # returns the comment for an action
2
- class ::Simple::Service::Action::Comment # :nodoc:
2
+ class ::Simple::Service::Action::Comment # @private
3
3
  attr_reader :short
4
4
  attr_reader :full
5
5
 
@@ -1,6 +1,6 @@
1
1
  # rubocop:disable Metrics/AbcSize
2
2
 
3
- module ::Simple::Service::Action::MethodReflection # :nodoc:
3
+ module ::Simple::Service::Action::MethodReflection # @private
4
4
  extend self
5
5
 
6
6
  #
@@ -32,8 +32,8 @@ module Simple::Service
32
32
  # Also, once a value is set in the context it is not possible to change or
33
33
  # unset it.
34
34
  class Context
35
- def initialize(hsh = {}) # :nodoc:
36
- @hsh = hsh
35
+ def initialize(hsh = nil) # @private
36
+ @hsh = hsh || {}
37
37
  end
38
38
 
39
39
  # returns a new Context object, which merges the values in the +overlay+
@@ -52,9 +52,9 @@ module Simple::Service
52
52
 
53
53
  private
54
54
 
55
- IDENTIFIER_PATTERN = "[a-z][a-z0-9_]*" # :nodoc:
56
- IDENTIFIER_REGEXP = Regexp.compile("\\A#{IDENTIFIER_PATTERN}\\z") # :nodoc:
57
- ASSIGNMENT_REGEXP = Regexp.compile("\\A(#{IDENTIFIER_PATTERN})=\\z") # :nodoc:
55
+ IDENTIFIER_PATTERN = "[a-z][a-z0-9_]*" # @private
56
+ IDENTIFIER_REGEXP = Regexp.compile("\\A#{IDENTIFIER_PATTERN}\\z") # @private
57
+ ASSIGNMENT_REGEXP = Regexp.compile("\\A(#{IDENTIFIER_PATTERN})=\\z") # @private
58
58
 
59
59
  def method_missing(sym, *args, &block)
60
60
  raise ArgumentError, "Block given" if block
@@ -1,8 +1,8 @@
1
- module Simple # :nodoc:
1
+ module Simple # @private
2
2
  end
3
3
 
4
4
  module Simple::Service
5
- module GemHelper # :nodoc:
5
+ module GemHelper # @private
6
6
  extend self
7
7
 
8
8
  def version(name)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: simple-service
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - radiospiel
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-11-29 00:00:00.000000000 Z
11
+ date: 2019-12-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: expectation
@@ -42,6 +42,37 @@ files:
42
42
  - bin/console
43
43
  - bin/rake
44
44
  - bin/rspec
45
+ - doc/Simple.html
46
+ - doc/Simple/Service.html
47
+ - doc/Simple/Service/Action.html
48
+ - doc/Simple/Service/Action/Comment.html
49
+ - doc/Simple/Service/Action/Comment/Extractor.html
50
+ - doc/Simple/Service/Action/IndieHash.html
51
+ - doc/Simple/Service/Action/MethodReflection.html
52
+ - doc/Simple/Service/Action/Parameter.html
53
+ - doc/Simple/Service/ArgumentError.html
54
+ - doc/Simple/Service/ClassMethods.html
55
+ - doc/Simple/Service/Context.html
56
+ - doc/Simple/Service/ContextMissingError.html
57
+ - doc/Simple/Service/ContextReadOnlyError.html
58
+ - doc/Simple/Service/ExtraArguments.html
59
+ - doc/Simple/Service/GemHelper.html
60
+ - doc/Simple/Service/MissingArguments.html
61
+ - doc/Simple/Service/NoSuchAction.html
62
+ - doc/_index.html
63
+ - doc/class_list.html
64
+ - doc/css/common.css
65
+ - doc/css/full_list.css
66
+ - doc/css/style.css
67
+ - doc/file.README.html
68
+ - doc/file_list.html
69
+ - doc/frames.html
70
+ - doc/index.html
71
+ - doc/js/app.js
72
+ - doc/js/full_list.js
73
+ - doc/js/jquery.js
74
+ - doc/method_list.html
75
+ - doc/top-level-namespace.html
45
76
  - lib/simple-service.rb
46
77
  - lib/simple/service.rb
47
78
  - lib/simple/service/action.rb