methodobject 0.1.0
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 +7 -0
- data/.gitignore +9 -0
- data/.rspec +2 -0
- data/.travis.yml +10 -0
- data/CODE_OF_CONDUCT.md +49 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +129 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/method_object/parameter.rb +54 -0
- data/lib/method_object/version.rb +5 -0
- data/lib/method_object.rb +193 -0
- data/lib/methodobject.rb +1 -0
- data/methodobject.gemspec +33 -0
- metadata +132 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 8f916404cf4e974217978e9ae9059d1096fab845
|
4
|
+
data.tar.gz: 770f10363861e160a56f3762fe65478b3be6d114
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 4c32191104f627bfef8a295790497146ec76788fac297ae4ed02a1f87e8dfab25cfe79d15758466690ca2bca710d841edb2cc954410f6e9b699d016528c076bd
|
7
|
+
data.tar.gz: 95ada31f90716259011285e221d67e7441bf8b8e316a1e83466158632c4cc374d4c5ab4422856a3d4da7ef7bcc0bee6f73ecd3e6c113bb4fe27834e1cea9242b
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
# Contributor Code of Conduct
|
2
|
+
|
3
|
+
As contributors and maintainers of this project, and in the interest of
|
4
|
+
fostering an open and welcoming community, we pledge to respect all people who
|
5
|
+
contribute through reporting issues, posting feature requests, updating
|
6
|
+
documentation, submitting pull requests or patches, and other activities.
|
7
|
+
|
8
|
+
We are committed to making participation in this project a harassment-free
|
9
|
+
experience for everyone, regardless of level of experience, gender, gender
|
10
|
+
identity and expression, sexual orientation, disability, personal appearance,
|
11
|
+
body size, race, ethnicity, age, religion, or nationality.
|
12
|
+
|
13
|
+
Examples of unacceptable behavior by participants include:
|
14
|
+
|
15
|
+
* The use of sexualized language or imagery
|
16
|
+
* Personal attacks
|
17
|
+
* Trolling or insulting/derogatory comments
|
18
|
+
* Public or private harassment
|
19
|
+
* Publishing other's private information, such as physical or electronic
|
20
|
+
addresses, without explicit permission
|
21
|
+
* Other unethical or unprofessional conduct
|
22
|
+
|
23
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
24
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
25
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
26
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
27
|
+
threatening, offensive, or harmful.
|
28
|
+
|
29
|
+
By adopting this Code of Conduct, project maintainers commit themselves to
|
30
|
+
fairly and consistently applying these principles to every aspect of managing
|
31
|
+
this project. Project maintainers who do not follow or enforce the Code of
|
32
|
+
Conduct may be permanently removed from the project team.
|
33
|
+
|
34
|
+
This code of conduct applies both within project spaces and in public spaces
|
35
|
+
when an individual is representing the project or its community.
|
36
|
+
|
37
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
38
|
+
reported by contacting a project maintainer at michele.piccirillo@gmail.com. All
|
39
|
+
complaints will be reviewed and investigated and will result in a response that
|
40
|
+
is deemed necessary and appropriate to the circumstances. Maintainers are
|
41
|
+
obligated to maintain confidentiality with regard to the reporter of an
|
42
|
+
incident.
|
43
|
+
|
44
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
|
45
|
+
version 1.3.0, available at
|
46
|
+
[http://contributor-covenant.org/version/1/3/0/][version]
|
47
|
+
|
48
|
+
[homepage]: http://contributor-covenant.org
|
49
|
+
[version]: http://contributor-covenant.org/version/1/3/0/
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2017 Michele Piccirillo
|
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
ADDED
@@ -0,0 +1,129 @@
|
|
1
|
+
# Method Object
|
2
|
+
[](https://rubygems.org/gems/methodobject)
|
3
|
+
[](https://travis-ci.org/LIQIDTechnology/methodobject)
|
4
|
+
[](https://coveralls.io/github/LIQIDTechnology/methodobject?branch=master)
|
5
|
+
[](http://www.rubydoc.info/gems/methodobject/)
|
6
|
+
[](https://inch-ci.org/github/LIQIDTechnology/methodobject)
|
7
|
+
|
8
|
+
|
9
|
+
Provides a lightweight and dependency-free solution for the creation of [method objects](https://sourcemaking.com/refactoring/replace-method-with-method-object),
|
10
|
+
a common pattern used to ease the extraction of complex methods from other classes and for the implementation of service objects.
|
11
|
+
|
12
|
+
The __method object pattern__ is advisable when a method is too long and difficult to separate due to tangled masses of local variables that are hard to isolate from each other: the solution is to extract the entire method into a separate class and turn its local variables into fields of the class; this allows isolating the problem at the class level and it paves the way for splitting a large and unwieldy method into smaller ones that would not fit with the purpose of the original class anyway.
|
13
|
+
|
14
|
+
This gem also provides a uniform interface to write __service objects__, that is a common way to extract common operations from models and controllers in Rails application. Borrowing the design from [an article](http://brewhouse.io/blog/2014/04/30/gourmet-service-objects.html) on what the author defines as _"Gourmet Service Object"_, it provides some plumbing to implement such a pattern, with objects that expose a operation as their entry-point.
|
15
|
+
|
16
|
+
The interface exposed by a MethodObject is similar to the one of a _proc_/_lambda_, exposing a `call` method both at class and instance level and a convenience `to_proc` method to convert it to a Proc. Other neat features include optional type checking for the arguments and inheritance between MO's.
|
17
|
+
|
18
|
+
## Installation
|
19
|
+
|
20
|
+
Add this line to your application's Gemfile:
|
21
|
+
|
22
|
+
```ruby
|
23
|
+
gem 'methodobject'
|
24
|
+
```
|
25
|
+
|
26
|
+
And then execute:
|
27
|
+
|
28
|
+
$ bundle
|
29
|
+
|
30
|
+
Or install it yourself as:
|
31
|
+
|
32
|
+
$ gem install methodobject
|
33
|
+
|
34
|
+
## Usage
|
35
|
+
|
36
|
+
### Defining and invoking a method object
|
37
|
+
|
38
|
+
```ruby
|
39
|
+
class ComplexCalculation < MethodObject
|
40
|
+
# Type checking is optional. If omitted, anything is accepted.
|
41
|
+
# Type checking can also done with a proc or anything that responds to #===
|
42
|
+
# e.g. parameter :start_number, ->(p) { p.respond_to?(:to_i) }
|
43
|
+
parameter :start_number, Integer
|
44
|
+
|
45
|
+
# Parameters that define a default are optional.
|
46
|
+
# `default` supports also a proc, that gets evaluated at
|
47
|
+
# object instantiation.
|
48
|
+
# e.g. default: -> { Time.now }
|
49
|
+
parameter :end_number, Integer, default: 2
|
50
|
+
|
51
|
+
# Defines the `call` method body.
|
52
|
+
# Inheritance works also as expected. Calling `super()` invokes
|
53
|
+
# superclass' implementation.
|
54
|
+
called do
|
55
|
+
@magic_number = 42
|
56
|
+
perform_complex_calculation
|
57
|
+
end
|
58
|
+
|
59
|
+
private
|
60
|
+
|
61
|
+
def perform_complex_calculation
|
62
|
+
# The arguments are available as accessors
|
63
|
+
start_number + second_number + @magic_number
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
# The class-method version of `call` accepts the arguments as named parameters
|
68
|
+
ComplexCalculation.call(start_number: 1, end_number: 3) #=> 46
|
69
|
+
ComplexCalculation.call(start_number: 1) #=> 45
|
70
|
+
ComplexCalculation.call(end_number: 3) #=> raise ArgumentError
|
71
|
+
|
72
|
+
# `call` can also be omitted, as per usual Ruby semantics
|
73
|
+
ComplexCalculation.(start_number: 1)
|
74
|
+
|
75
|
+
# The class-method version of `to_proc` returns a proc that takes the same arguments
|
76
|
+
ComplexCalculation.to_proc.call(start_number: 1)
|
77
|
+
|
78
|
+
# The method object can also be instantiated, passing the arguments to the constructor
|
79
|
+
# or to the accessors
|
80
|
+
calculation = ComplexCalculation.new(end_number: 3)
|
81
|
+
calculation.start_number = 1
|
82
|
+
calculation.call # => 46
|
83
|
+
|
84
|
+
calculation.end_number = 2
|
85
|
+
calculation.call # => 45
|
86
|
+
|
87
|
+
# The instance-method version of `to_proc` returns a lambda that calls the method object
|
88
|
+
# with the parameters currently set
|
89
|
+
calculation.to_proc.call # => 45
|
90
|
+
```
|
91
|
+
|
92
|
+
### Using the method object as a block
|
93
|
+
|
94
|
+
```ruby
|
95
|
+
class NameSayer < MethodObject
|
96
|
+
parameter :name
|
97
|
+
|
98
|
+
called { "You're #{name}" }
|
99
|
+
end
|
100
|
+
|
101
|
+
def say_my_name
|
102
|
+
puts "- Say my name."
|
103
|
+
puts "- " + yield(name: "Heisenberg")
|
104
|
+
puts "- You're goddamn right!"
|
105
|
+
end
|
106
|
+
|
107
|
+
say_my_name(&NameSayer)
|
108
|
+
# Output:
|
109
|
+
#
|
110
|
+
# - Say my name.
|
111
|
+
# - You're Heisenberg
|
112
|
+
# - You're goddamn right!
|
113
|
+
```
|
114
|
+
|
115
|
+
## Development
|
116
|
+
|
117
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
118
|
+
|
119
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
120
|
+
|
121
|
+
## Contributing
|
122
|
+
|
123
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/LIQIDTechnology/methodobject. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
124
|
+
|
125
|
+
|
126
|
+
## License
|
127
|
+
|
128
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
129
|
+
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "methodobject"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start
|
data/bin/setup
ADDED
@@ -0,0 +1,54 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class MethodObject
|
4
|
+
# @!visibility private
|
5
|
+
class Parameter
|
6
|
+
def initialize(name, type, options = {})
|
7
|
+
invalid_options = options.keys - [:default]
|
8
|
+
raise ArgumentError, "Invalid keys: #{invalid_options.inspect}. Valid keys are: :default" \
|
9
|
+
unless invalid_options.empty?
|
10
|
+
|
11
|
+
@name = name
|
12
|
+
@type = type
|
13
|
+
@options = options
|
14
|
+
|
15
|
+
freeze
|
16
|
+
end
|
17
|
+
|
18
|
+
attr_reader :name, :type
|
19
|
+
|
20
|
+
def default?
|
21
|
+
@options.key?(:default)
|
22
|
+
end
|
23
|
+
|
24
|
+
def default
|
25
|
+
@options[:default]
|
26
|
+
end
|
27
|
+
|
28
|
+
def default_in(context)
|
29
|
+
if @options[:default].respond_to?(:call)
|
30
|
+
context.instance_exec(&@options[:default])
|
31
|
+
else
|
32
|
+
@options[:default]
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def hash
|
37
|
+
name.to_s.hash
|
38
|
+
end
|
39
|
+
|
40
|
+
def acceptable?(value)
|
41
|
+
(value.nil? && nullable?) || type === value # rubocop:disable Style/CaseEquality
|
42
|
+
end
|
43
|
+
|
44
|
+
def nullable?
|
45
|
+
default? && default.nil?
|
46
|
+
end
|
47
|
+
|
48
|
+
def ==(other)
|
49
|
+
instance_of?(other.class) && name == other.name
|
50
|
+
end
|
51
|
+
|
52
|
+
alias eql? ==
|
53
|
+
end
|
54
|
+
end
|
@@ -0,0 +1,193 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'method_object/parameter'
|
4
|
+
|
5
|
+
# Allows for the creation of {https://sourcemaking.com/refactoring/replace-method-with-method-object method objects},
|
6
|
+
# to ease the extraction of complex methods from other classes and the implementation of service objects.
|
7
|
+
#
|
8
|
+
# A method object works similarly to a proc/lambda, exposing a {.call} method and convenience
|
9
|
+
# {.to_proc} method to convert it to a Proc.
|
10
|
+
#
|
11
|
+
# Major differences in behaviour compared to a `lambda`:
|
12
|
+
# * It accepts only named parameters
|
13
|
+
# * It performs type checking on the parameters
|
14
|
+
#
|
15
|
+
# @example Defining and invoking a method object
|
16
|
+
# class ComplexCalculation < MethodObject
|
17
|
+
# parameter :start_number, Integer
|
18
|
+
# parameter :end_number, Integer, default: 2
|
19
|
+
#
|
20
|
+
# called do
|
21
|
+
# @magic_number = 42
|
22
|
+
# perform_complex_calculation
|
23
|
+
# end
|
24
|
+
#
|
25
|
+
# private
|
26
|
+
#
|
27
|
+
# def perform_complex_calculation
|
28
|
+
# start_number + second_number + @magic_number
|
29
|
+
# end
|
30
|
+
# end
|
31
|
+
#
|
32
|
+
# ComplexCalculation.call(start_number: 1, end_number: 3) #=> 46
|
33
|
+
# ComplexCalculation.call(start_number: 1) #=> 45
|
34
|
+
# ComplexCalculation.call(end_number: 3) #=> raise ArgumentError
|
35
|
+
#
|
36
|
+
# calculation = ComplexCalculation.new(end_number: 3)
|
37
|
+
# calculation.start_number = 1
|
38
|
+
# calculation.call # => 46
|
39
|
+
#
|
40
|
+
# calculation.end_number = 2
|
41
|
+
# calculation.call # => 45
|
42
|
+
#
|
43
|
+
# @example Using the method object as a block
|
44
|
+
# class NameSayer < MethodObject
|
45
|
+
# parameter :name, String
|
46
|
+
#
|
47
|
+
# called { "You're #{name}" }
|
48
|
+
# end
|
49
|
+
#
|
50
|
+
# def say_my_name
|
51
|
+
# puts "- Say my name."
|
52
|
+
# puts "- " + yield(name: "Heisenberg")
|
53
|
+
# puts "- You're goddamn right!"
|
54
|
+
# end
|
55
|
+
#
|
56
|
+
# say_my_name(&NameSayer)
|
57
|
+
# # Output:
|
58
|
+
# #
|
59
|
+
# # - Say my name.
|
60
|
+
# # - You're Heisenberg
|
61
|
+
# # - You're goddamn right!
|
62
|
+
class MethodObject
|
63
|
+
class << self
|
64
|
+
# Calls the MethodObject with the given arguments.
|
65
|
+
#
|
66
|
+
# @param **args [Hash{Symbol => Object}] arguments to pass to the method
|
67
|
+
# @return [Object] return value of the method object
|
68
|
+
def call(**args)
|
69
|
+
new(**args).call
|
70
|
+
end
|
71
|
+
|
72
|
+
# Returns a proc that calls the MO with the given arguments.
|
73
|
+
# @return [Proc]
|
74
|
+
def to_proc
|
75
|
+
proc { |**args| call(**args) }
|
76
|
+
end
|
77
|
+
|
78
|
+
protected
|
79
|
+
|
80
|
+
# Defines a parameter for the method object.
|
81
|
+
#
|
82
|
+
# Parameters are also inherited from superclasses and can be redefined (overwritten) in subclasses.
|
83
|
+
#
|
84
|
+
# @param name [Symbol] name of the parameter
|
85
|
+
# @param type [Class, #===] type of the parameter. Can be a Class, a Proc or anything that defines a meaningful
|
86
|
+
# `===` method
|
87
|
+
# @param **options [Hash] extra options for the parameter
|
88
|
+
# @option **options [Object, #call] :default default value if the parameter is not passed. If the default implements
|
89
|
+
# `#call`, it gets called once in the context of the method object instance when it is instanciated
|
90
|
+
#
|
91
|
+
# @return [void]
|
92
|
+
def parameter(name, type = BasicObject, **options)
|
93
|
+
arg = MethodObject::Parameter.new(name, type, options)
|
94
|
+
parameters.delete(arg)
|
95
|
+
parameters << arg
|
96
|
+
|
97
|
+
define_method("#{name}=") do |value|
|
98
|
+
raise ArgumentError, "Expected a #{type} for #{name}, #{value.class} received" unless arg.acceptable?(value)
|
99
|
+
@monitor.synchronize { instance_variable_set("@#{name}", value) }
|
100
|
+
end
|
101
|
+
|
102
|
+
define_method("#{name}?") do
|
103
|
+
!public_send(name).nil?
|
104
|
+
end
|
105
|
+
|
106
|
+
attr_reader name
|
107
|
+
end
|
108
|
+
|
109
|
+
# Defines the method body.
|
110
|
+
# The body can be overwritten in subclasses and the superclass implementation can be invoked with `super()`,
|
111
|
+
# as with a regular method definition.
|
112
|
+
#
|
113
|
+
# @yield Block to be used as method body definition for the method object
|
114
|
+
# @return [void]
|
115
|
+
def called(&block)
|
116
|
+
define_method(:do_call, &block)
|
117
|
+
protected :do_call
|
118
|
+
end
|
119
|
+
|
120
|
+
private
|
121
|
+
|
122
|
+
# @return [Set]
|
123
|
+
def superclass_parameters
|
124
|
+
if superclass < MethodObject
|
125
|
+
superclass.send(:parameters)
|
126
|
+
else
|
127
|
+
Set.new
|
128
|
+
end
|
129
|
+
end
|
130
|
+
|
131
|
+
# @return [Set]
|
132
|
+
def parameters
|
133
|
+
@parameters ||= Set.new(superclass_parameters)
|
134
|
+
end
|
135
|
+
end
|
136
|
+
|
137
|
+
# @param **args [Hash{Symbol => Object}] arguments to set on the method object
|
138
|
+
def initialize(**args)
|
139
|
+
self.class.send(:parameters).freeze
|
140
|
+
|
141
|
+
@monitor = Monitor.new
|
142
|
+
|
143
|
+
args.each { |k, v| public_send("#{k}=", v) }
|
144
|
+
self.class.send(:parameters)
|
145
|
+
.reject { |p| args.keys.map(&:to_sym).include?(p.name) }
|
146
|
+
.select(&:default?)
|
147
|
+
.each { |p| public_send("#{p.name}=", p.default_in(self)) }
|
148
|
+
end
|
149
|
+
|
150
|
+
# Returns a hash with the parameters currently set.
|
151
|
+
# @return [Hash{Symbol => Object}]
|
152
|
+
def parameters
|
153
|
+
Hash[
|
154
|
+
self.class.send(:parameters).map(&:name)
|
155
|
+
.select { |p| instance_variable_defined?("@#{p}") }
|
156
|
+
.map { |p| [p, public_send(p)] }
|
157
|
+
]
|
158
|
+
end
|
159
|
+
|
160
|
+
# Calls the method object with the parameters currently set.
|
161
|
+
# @raise [ArgumentError] if any required parameter is missing
|
162
|
+
# @return [Object] the return value result of the method invokation
|
163
|
+
def call
|
164
|
+
unless respond_to?(:do_call, true)
|
165
|
+
raise NotImplementedError,
|
166
|
+
'Implementation missing. Please use `called { ... }` to define method body'
|
167
|
+
end
|
168
|
+
|
169
|
+
@monitor.synchronize do
|
170
|
+
assert_required_arguments!
|
171
|
+
do_call
|
172
|
+
end
|
173
|
+
end
|
174
|
+
|
175
|
+
# Returns a lambda that calls the method object with the parameters currently set.
|
176
|
+
# @return [Proc]
|
177
|
+
def to_proc
|
178
|
+
-> { call }
|
179
|
+
end
|
180
|
+
|
181
|
+
private
|
182
|
+
|
183
|
+
# @raise [ArgumentError]
|
184
|
+
def assert_required_arguments!
|
185
|
+
missing_params =
|
186
|
+
self.class.send(:parameters)
|
187
|
+
.select { |p| !p.default? && !public_send("#{p.name}?") }
|
188
|
+
.map(&:name)
|
189
|
+
|
190
|
+
raise ArgumentError, "Missing required arguments: #{missing_params.join(', ')}" \
|
191
|
+
unless missing_params.empty?
|
192
|
+
end
|
193
|
+
end
|
data/lib/methodobject.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "method_object"
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'method_object/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "methodobject"
|
8
|
+
spec.version = MethodObject::VERSION
|
9
|
+
spec.authors = ["Michele Piccirillo"]
|
10
|
+
spec.email = ["michele@liqid.de"]
|
11
|
+
|
12
|
+
spec.summary = 'Method Object pattern in Ruby for your service objects'
|
13
|
+
spec.description = <<-EOF
|
14
|
+
Lightweight and dependency-free solution for the creation of method objects,
|
15
|
+
a common pattern used to ease the extraction of complex methods from other classes
|
16
|
+
and for the implementation of service objects.
|
17
|
+
EOF
|
18
|
+
|
19
|
+
spec.homepage = "https://github.com/LIQIDTechnology/methodobject"
|
20
|
+
spec.license = "MIT"
|
21
|
+
|
22
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
23
|
+
spec.bindir = "exe"
|
24
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
25
|
+
spec.require_paths = ["lib"]
|
26
|
+
spec.required_ruby_version = "~> 2.0"
|
27
|
+
|
28
|
+
spec.add_development_dependency "bundler", "~> 1.12"
|
29
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
30
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
31
|
+
spec.add_development_dependency "pry"
|
32
|
+
spec.add_development_dependency "simplecov"
|
33
|
+
end
|
metadata
ADDED
@@ -0,0 +1,132 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: methodobject
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Michele Piccirillo
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2017-04-27 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.12'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.12'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '3.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: pry
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: simplecov
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
description: |2
|
84
|
+
Lightweight and dependency-free solution for the creation of method objects,
|
85
|
+
a common pattern used to ease the extraction of complex methods from other classes
|
86
|
+
and for the implementation of service objects.
|
87
|
+
email:
|
88
|
+
- michele@liqid.de
|
89
|
+
executables: []
|
90
|
+
extensions: []
|
91
|
+
extra_rdoc_files: []
|
92
|
+
files:
|
93
|
+
- ".gitignore"
|
94
|
+
- ".rspec"
|
95
|
+
- ".travis.yml"
|
96
|
+
- CODE_OF_CONDUCT.md
|
97
|
+
- Gemfile
|
98
|
+
- LICENSE.txt
|
99
|
+
- README.md
|
100
|
+
- Rakefile
|
101
|
+
- bin/console
|
102
|
+
- bin/setup
|
103
|
+
- lib/method_object.rb
|
104
|
+
- lib/method_object/parameter.rb
|
105
|
+
- lib/method_object/version.rb
|
106
|
+
- lib/methodobject.rb
|
107
|
+
- methodobject.gemspec
|
108
|
+
homepage: https://github.com/LIQIDTechnology/methodobject
|
109
|
+
licenses:
|
110
|
+
- MIT
|
111
|
+
metadata: {}
|
112
|
+
post_install_message:
|
113
|
+
rdoc_options: []
|
114
|
+
require_paths:
|
115
|
+
- lib
|
116
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
117
|
+
requirements:
|
118
|
+
- - "~>"
|
119
|
+
- !ruby/object:Gem::Version
|
120
|
+
version: '2.0'
|
121
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
122
|
+
requirements:
|
123
|
+
- - ">="
|
124
|
+
- !ruby/object:Gem::Version
|
125
|
+
version: '0'
|
126
|
+
requirements: []
|
127
|
+
rubyforge_project:
|
128
|
+
rubygems_version: 2.5.1
|
129
|
+
signing_key:
|
130
|
+
specification_version: 4
|
131
|
+
summary: Method Object pattern in Ruby for your service objects
|
132
|
+
test_files: []
|