procto 0.0.1
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.
- data/.gitignore +37 -0
- data/.rspec +4 -0
- data/.ruby-gemset +1 -0
- data/.ruby-version +1 -0
- data/.travis.yml +17 -0
- data/CONTRIBUTING.md +11 -0
- data/Gemfile +12 -0
- data/Gemfile.devtools +67 -0
- data/LICENSE +20 -0
- data/README.md +60 -0
- data/Rakefile +6 -0
- data/config/devtools.yml +2 -0
- data/config/flay.yml +3 -0
- data/config/flog.yml +2 -0
- data/config/mutant.yml +3 -0
- data/config/reek.yml +103 -0
- data/config/rubocop.yml +78 -0
- data/config/yardstick.yml +2 -0
- data/lib/procto.rb +82 -0
- data/lib/procto/version.rb +6 -0
- data/procto.gemspec +21 -0
- data/spec/procto_spec.rb +52 -0
- data/spec/spec_helper.rb +30 -0
- metadata +89 -0
data/.gitignore
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
## MAC OS
|
2
|
+
.DS_Store
|
3
|
+
|
4
|
+
## TEXTMATE
|
5
|
+
*.tmproj
|
6
|
+
tmtags
|
7
|
+
|
8
|
+
## EMACS
|
9
|
+
*~
|
10
|
+
\#*
|
11
|
+
.\#*
|
12
|
+
|
13
|
+
## VIM
|
14
|
+
*.swp
|
15
|
+
|
16
|
+
## Rubinius
|
17
|
+
*.rbc
|
18
|
+
.rbx
|
19
|
+
|
20
|
+
## PROJECT::GENERAL
|
21
|
+
*.gem
|
22
|
+
coverage
|
23
|
+
profiling
|
24
|
+
turbulence
|
25
|
+
rdoc
|
26
|
+
pkg
|
27
|
+
tmp
|
28
|
+
doc
|
29
|
+
log
|
30
|
+
.yardoc
|
31
|
+
measurements
|
32
|
+
|
33
|
+
## BUNDLER
|
34
|
+
.bundle
|
35
|
+
Gemfile.lock
|
36
|
+
|
37
|
+
## PROJECT::SPECIFIC
|
data/.rspec
ADDED
data/.ruby-gemset
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
procto
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
1.9.3
|
data/.travis.yml
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
language: ruby
|
2
|
+
before_install: gem install bundler
|
3
|
+
bundler_args: --without yard guard benchmarks
|
4
|
+
script: "bundle exec rake ci"
|
5
|
+
rvm:
|
6
|
+
- 1.9.3
|
7
|
+
- 2.0.0
|
8
|
+
- ruby-head
|
9
|
+
- rbx-19mode
|
10
|
+
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
|
+
allow_failures:
|
17
|
+
- rvm: ruby-head
|
data/CONTRIBUTING.md
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
Contributing
|
2
|
+
------------
|
3
|
+
|
4
|
+
* If you want your code merged into the mainline, please discuss the proposed changes with me before doing any work on it.
|
5
|
+
* Fork the project.
|
6
|
+
* Make your feature addition or bug fix.
|
7
|
+
* Follow this [style guide](https://github.com/dkubb/styleguide).
|
8
|
+
* Add specs for it. This is important so I don't break it in a future version unintentionally. Tests must cover all branches within the code, and code must be fully covered.
|
9
|
+
* Commit, do not mess with Rakefile, version, or history. (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
|
10
|
+
* Run "rake ci". This must pass and not show any regressions in the metrics for the code to be merged.
|
11
|
+
* Send me a pull request. Bonus points for topic branches.
|
data/Gemfile
ADDED
data/Gemfile.devtools
ADDED
@@ -0,0 +1,67 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
group :development do
|
4
|
+
gem 'rake', '~> 10.1.0'
|
5
|
+
gem 'rspec', '~> 2.14.1'
|
6
|
+
gem 'yard', '~> 0.8.7'
|
7
|
+
|
8
|
+
platform :rbx do
|
9
|
+
gem 'rubysl-singleton', '~> 2.0.0'
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
group :yard do
|
14
|
+
gem 'kramdown', '~> 1.3.0'
|
15
|
+
end
|
16
|
+
|
17
|
+
group :guard do
|
18
|
+
gem 'guard', '~> 2.2.4'
|
19
|
+
gem 'guard-bundler', '~> 2.0.0'
|
20
|
+
gem 'guard-rspec', '~> 4.2.0'
|
21
|
+
gem 'guard-rubocop', '~> 1.0.0'
|
22
|
+
|
23
|
+
# file system change event handling
|
24
|
+
gem 'listen', '~> 2.4.0'
|
25
|
+
gem 'rb-fchange', '~> 0.0.6', require: false
|
26
|
+
gem 'rb-fsevent', '~> 0.9.3', require: false
|
27
|
+
gem 'rb-inotify', '~> 0.9.0', require: false
|
28
|
+
|
29
|
+
# notification handling
|
30
|
+
gem 'libnotify', '~> 0.8.0', require: false
|
31
|
+
gem 'rb-notifu', '~> 0.0.4', require: false
|
32
|
+
gem 'terminal-notifier-guard', '~> 1.5.3', require: false
|
33
|
+
end
|
34
|
+
|
35
|
+
group :metrics do
|
36
|
+
gem 'coveralls', '~> 0.7.0'
|
37
|
+
gem 'flay', '~> 2.4.0'
|
38
|
+
gem 'flog', '~> 4.2.0'
|
39
|
+
gem 'reek', '~> 1.3.2'
|
40
|
+
gem 'rubocop', '~> 0.15.0'
|
41
|
+
gem 'simplecov', '~> 0.8.2'
|
42
|
+
gem 'yardstick', '~> 0.9.7', git: 'https://github.com/dkubb/yardstick.git'
|
43
|
+
|
44
|
+
platforms :ruby_19, :ruby_20 do
|
45
|
+
gem 'mutant', '~> 0.3.0', git: 'https://github.com/mbj/mutant.git'
|
46
|
+
gem 'unparser', '~> 0.1.5', git: 'https://github.com/mbj/unparser.git'
|
47
|
+
gem 'yard-spellcheck', '~> 0.1.5'
|
48
|
+
end
|
49
|
+
|
50
|
+
platform :rbx do
|
51
|
+
gem 'json', '~> 1.8.1'
|
52
|
+
gem 'racc', '~> 1.4.10'
|
53
|
+
gem 'rubysl-logger', '~> 2.0.0'
|
54
|
+
gem 'rubysl-open-uri', '~> 2.0.0'
|
55
|
+
gem 'rubysl-prettyprint', '~> 2.0.2'
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
group :benchmarks do
|
60
|
+
gem 'rbench', '~> 0.2.3'
|
61
|
+
end
|
62
|
+
|
63
|
+
platform :jruby do
|
64
|
+
group :jruby do
|
65
|
+
gem 'jruby-openssl', '~> 0.8.5'
|
66
|
+
end
|
67
|
+
end
|
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2013 Martin Gamsjaeger (snusnu)
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,60 @@
|
|
1
|
+
# procto
|
2
|
+
|
3
|
+
[][gem]
|
4
|
+
[][travis]
|
5
|
+
[][gemnasium]
|
6
|
+
[][codeclimate]
|
7
|
+
[][coveralls]
|
8
|
+
|
9
|
+
[gem]: https://rubygems.org/gems/procto
|
10
|
+
[travis]: https://travis-ci.org/snusnu/procto
|
11
|
+
[gemnasium]: https://gemnasium.com/snusnu/procto
|
12
|
+
[codeclimate]: https://codeclimate.com/github/snusnu/procto
|
13
|
+
[coveralls]: https://coveralls.io/r/snusnu/procto
|
14
|
+
|
15
|
+
## Usage
|
16
|
+
|
17
|
+
```ruby
|
18
|
+
require 'procto'
|
19
|
+
|
20
|
+
class Greeter
|
21
|
+
include Procto.call
|
22
|
+
|
23
|
+
def initialize(text)
|
24
|
+
@text = text
|
25
|
+
end
|
26
|
+
|
27
|
+
def call
|
28
|
+
"Hello #{text}"
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
Greeter.call('world') # => "Hello world"
|
33
|
+
|
34
|
+
class Printer
|
35
|
+
include Procto.call(:print)
|
36
|
+
|
37
|
+
def initialize(text)
|
38
|
+
@text = text
|
39
|
+
end
|
40
|
+
|
41
|
+
def print
|
42
|
+
"Hello #{text}"
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
Printer.call('world') # => "Hello world"
|
47
|
+
```
|
48
|
+
|
49
|
+
## Credits
|
50
|
+
|
51
|
+
* [snusnu](https://github.com/snusnu)
|
52
|
+
* [mbj](https://github.com/mbj)
|
53
|
+
|
54
|
+
## Contributing
|
55
|
+
|
56
|
+
See [CONTRIBUTING.md](CONTRIBUTING.md) for details.
|
57
|
+
|
58
|
+
## Copyright
|
59
|
+
|
60
|
+
Copyright © 2013 Martin Gamsjaeger (snusnu). See [LICENSE](LICENSE) for details.
|
data/Rakefile
ADDED
data/config/devtools.yml
ADDED
data/config/flay.yml
ADDED
data/config/flog.yml
ADDED
data/config/mutant.yml
ADDED
data/config/reek.yml
ADDED
@@ -0,0 +1,103 @@
|
|
1
|
+
---
|
2
|
+
Attribute:
|
3
|
+
enabled: true
|
4
|
+
exclude: []
|
5
|
+
BooleanParameter:
|
6
|
+
enabled: true
|
7
|
+
exclude: []
|
8
|
+
ClassVariable:
|
9
|
+
enabled: true
|
10
|
+
exclude: []
|
11
|
+
ControlParameter:
|
12
|
+
enabled: true
|
13
|
+
exclude: []
|
14
|
+
DataClump:
|
15
|
+
enabled: true
|
16
|
+
exclude: []
|
17
|
+
max_copies: 2
|
18
|
+
min_clump_size: 2
|
19
|
+
DuplicateMethodCall:
|
20
|
+
enabled: true
|
21
|
+
exclude: []
|
22
|
+
max_calls: 1
|
23
|
+
allow_calls: []
|
24
|
+
FeatureEnvy:
|
25
|
+
enabled: true
|
26
|
+
exclude: []
|
27
|
+
IrresponsibleModule:
|
28
|
+
enabled: true
|
29
|
+
exclude: []
|
30
|
+
LongParameterList:
|
31
|
+
enabled: true
|
32
|
+
exclude: []
|
33
|
+
max_params: 1
|
34
|
+
overrides:
|
35
|
+
initialize:
|
36
|
+
max_params: 2
|
37
|
+
LongYieldList:
|
38
|
+
enabled: true
|
39
|
+
exclude: []
|
40
|
+
max_params: 1
|
41
|
+
NestedIterators:
|
42
|
+
enabled: true
|
43
|
+
exclude:
|
44
|
+
- Lupo#included # 2
|
45
|
+
max_allowed_nesting: 1
|
46
|
+
ignore_iterators: []
|
47
|
+
NilCheck:
|
48
|
+
enabled: true
|
49
|
+
exclude: []
|
50
|
+
RepeatedConditional:
|
51
|
+
enabled: true
|
52
|
+
exclude: []
|
53
|
+
max_ifs: 1
|
54
|
+
TooManyInstanceVariables:
|
55
|
+
enabled: true
|
56
|
+
exclude: []
|
57
|
+
max_instance_variables: 1
|
58
|
+
TooManyMethods:
|
59
|
+
enabled: true
|
60
|
+
exclude: []
|
61
|
+
max_methods: 3
|
62
|
+
TooManyStatements:
|
63
|
+
enabled: true
|
64
|
+
exclude: []
|
65
|
+
max_statements: 4
|
66
|
+
UncommunicativeMethodName:
|
67
|
+
enabled: true
|
68
|
+
exclude: []
|
69
|
+
reject:
|
70
|
+
- !ruby/regexp /^[a-z]$/
|
71
|
+
- !ruby/regexp /[0-9]$/
|
72
|
+
- !ruby/regexp /[A-Z]/
|
73
|
+
accept: []
|
74
|
+
UncommunicativeModuleName:
|
75
|
+
enabled: true
|
76
|
+
exclude: []
|
77
|
+
reject:
|
78
|
+
- !ruby/regexp /^.$/
|
79
|
+
- !ruby/regexp /[0-9]$/
|
80
|
+
accept: []
|
81
|
+
UncommunicativeParameterName:
|
82
|
+
enabled: true
|
83
|
+
exclude: []
|
84
|
+
reject:
|
85
|
+
- !ruby/regexp /^.$/
|
86
|
+
- !ruby/regexp /[0-9]$/
|
87
|
+
- !ruby/regexp /[A-Z]/
|
88
|
+
accept: []
|
89
|
+
UncommunicativeVariableName:
|
90
|
+
enabled: true
|
91
|
+
exclude: []
|
92
|
+
reject:
|
93
|
+
- !ruby/regexp /^.$/
|
94
|
+
- !ruby/regexp /[0-9]$/
|
95
|
+
- !ruby/regexp /[A-Z]/
|
96
|
+
accept: []
|
97
|
+
UnusedParameters:
|
98
|
+
enabled: true
|
99
|
+
exclude: []
|
100
|
+
UtilityFunction:
|
101
|
+
enabled: true
|
102
|
+
exclude: []
|
103
|
+
max_helper_calls: 0
|
data/config/rubocop.yml
ADDED
@@ -0,0 +1,78 @@
|
|
1
|
+
AllCops:
|
2
|
+
Includes:
|
3
|
+
- '**/*.rake'
|
4
|
+
- 'Gemfile'
|
5
|
+
- 'Gemfile.devtools'
|
6
|
+
Excludes:
|
7
|
+
- '**/vendor/**'
|
8
|
+
- '**/benchmarks/**'
|
9
|
+
|
10
|
+
# Avoid parameter lists longer than five parameters.
|
11
|
+
ParameterLists:
|
12
|
+
Max: 1
|
13
|
+
CountKeywordArgs: true
|
14
|
+
|
15
|
+
# Avoid more than `Max` levels of nesting.
|
16
|
+
BlockNesting:
|
17
|
+
Max: 1
|
18
|
+
|
19
|
+
# Align with the style guide.
|
20
|
+
CollectionMethods:
|
21
|
+
PreferredMethods:
|
22
|
+
collect: 'map'
|
23
|
+
inject: 'reduce'
|
24
|
+
find: 'detect'
|
25
|
+
find_all: 'select'
|
26
|
+
|
27
|
+
# Do not force public/protected/private keyword to be indented at the same
|
28
|
+
# level as the def keyword. My personal preference is to outdent these keywords
|
29
|
+
# because I think when scanning code it makes it easier to identify the
|
30
|
+
# sections of code and visually separate them. When the keyword is at the same
|
31
|
+
# level I think it sort of blends in with the def keywords and makes it harder
|
32
|
+
# to scan the code and see where the sections are.
|
33
|
+
AccessModifierIndentation:
|
34
|
+
Enabled: false
|
35
|
+
|
36
|
+
# Limit line length
|
37
|
+
LineLength:
|
38
|
+
Max: 80
|
39
|
+
|
40
|
+
# Disable documentation checking until a class needs to be documented once
|
41
|
+
Documentation:
|
42
|
+
Enabled: false
|
43
|
+
|
44
|
+
# Do not favor modifier if/unless usage when you have a single-line body
|
45
|
+
IfUnlessModifier:
|
46
|
+
Enabled: false
|
47
|
+
|
48
|
+
# Allow case equality operator (in limited use within the specs)
|
49
|
+
CaseEquality:
|
50
|
+
Enabled: false
|
51
|
+
|
52
|
+
# Constants do not always have to use SCREAMING_SNAKE_CASE
|
53
|
+
ConstantName:
|
54
|
+
Enabled: false
|
55
|
+
|
56
|
+
# Not all trivial readers/writers can be defined with attr_* methods
|
57
|
+
TrivialAccessors:
|
58
|
+
Enabled: false
|
59
|
+
|
60
|
+
# Do not prefer do/end over {} for multiline blocks
|
61
|
+
Blocks:
|
62
|
+
Enabled: false
|
63
|
+
|
64
|
+
# Do not favor aligned parameters in method calls
|
65
|
+
AlignParameters:
|
66
|
+
Enabled: false
|
67
|
+
|
68
|
+
HashSyntax:
|
69
|
+
Enabled: false
|
70
|
+
|
71
|
+
SpaceInsideBrackets:
|
72
|
+
Enabled: false
|
73
|
+
|
74
|
+
Lambda:
|
75
|
+
Enabled: false # i personally like the look of multiline ->(arg) {} lambdas
|
76
|
+
|
77
|
+
AndOr:
|
78
|
+
Enabled: false # we agree to use and/or for control flow
|
data/lib/procto.rb
ADDED
@@ -0,0 +1,82 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
class Procto < Module
|
4
|
+
# The default name of the instance method to be called
|
5
|
+
DEFAULT_NAME = :call
|
6
|
+
|
7
|
+
private_class_method :new
|
8
|
+
|
9
|
+
# Return a custom module that calls a method named +name+
|
10
|
+
#
|
11
|
+
# @example without a name
|
12
|
+
#
|
13
|
+
# class Greeter
|
14
|
+
# include Procto.call
|
15
|
+
#
|
16
|
+
# def initialize(text)
|
17
|
+
# @text = text
|
18
|
+
# end
|
19
|
+
#
|
20
|
+
# def call
|
21
|
+
# "Hello #{text}"
|
22
|
+
# end
|
23
|
+
# end
|
24
|
+
#
|
25
|
+
# Greeter.call('world') # => "Hello world"
|
26
|
+
#
|
27
|
+
# @example with a name
|
28
|
+
#
|
29
|
+
# class Printer
|
30
|
+
# include Procto.call(:print)
|
31
|
+
#
|
32
|
+
# def initialize(text)
|
33
|
+
# @text = text
|
34
|
+
# end
|
35
|
+
#
|
36
|
+
# def print
|
37
|
+
# "Hello #{text}"
|
38
|
+
# end
|
39
|
+
# end
|
40
|
+
#
|
41
|
+
# Printer.call('world') # => "Hello world"
|
42
|
+
#
|
43
|
+
# @param [Symbol, String] name
|
44
|
+
# the name of the instance method to call
|
45
|
+
#
|
46
|
+
# @return [Procto]
|
47
|
+
#
|
48
|
+
# @api public
|
49
|
+
def self.call(name = DEFAULT_NAME)
|
50
|
+
new(name)
|
51
|
+
end
|
52
|
+
|
53
|
+
# Initialize a new instance
|
54
|
+
#
|
55
|
+
# @param [Symbol, String] name
|
56
|
+
# the name of the instance method to call
|
57
|
+
#
|
58
|
+
# @return [undefined]
|
59
|
+
#
|
60
|
+
# @api private
|
61
|
+
def initialize(name)
|
62
|
+
@block = ->(*args) {
|
63
|
+
new(*args).public_send(name)
|
64
|
+
}
|
65
|
+
end
|
66
|
+
|
67
|
+
private
|
68
|
+
|
69
|
+
# Define the .call method on +host+
|
70
|
+
#
|
71
|
+
# @param [Object] host
|
72
|
+
# the hosting object
|
73
|
+
#
|
74
|
+
# @return [undefined]
|
75
|
+
#
|
76
|
+
# @api private
|
77
|
+
def included(host)
|
78
|
+
host.instance_exec(@block) do |block|
|
79
|
+
define_singleton_method(:call, &block)
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end # Procto
|
data/procto.gemspec
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require File.expand_path('../lib/procto/version', __FILE__)
|
4
|
+
|
5
|
+
Gem::Specification.new do |gem|
|
6
|
+
gem.name = "procto"
|
7
|
+
gem.version = Procto::VERSION.dup
|
8
|
+
gem.authors = [ 'Martin Gamsjaeger (snusnu)' ]
|
9
|
+
gem.email = [ 'gamsnjaga@gmail.com' ]
|
10
|
+
gem.description = 'Turns your object into a method object'
|
11
|
+
gem.summary = 'Defines Foo.call(*args) which invokes Foo.new(*args).bar '
|
12
|
+
gem.homepage = 'https://github.com/snusnu/procto'
|
13
|
+
|
14
|
+
gem.require_paths = [ 'lib' ]
|
15
|
+
gem.files = `git ls-files`.split("\n")
|
16
|
+
gem.test_files = `git ls-files -- {spec}/*`.split("\n")
|
17
|
+
gem.extra_rdoc_files = %w[LICENSE README.md CONTRIBUTING.md]
|
18
|
+
gem.license = 'MIT'
|
19
|
+
|
20
|
+
gem.add_development_dependency 'bundler', '~> 1.3.5'
|
21
|
+
end
|
data/spec/procto_spec.rb
ADDED
@@ -0,0 +1,52 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
shared_context 'procto' do
|
6
|
+
subject { klass.call(text) }
|
7
|
+
|
8
|
+
let(:text) { 'world' }
|
9
|
+
let(:expected) { "Hello #{text}" }
|
10
|
+
|
11
|
+
it 'returns the correct value' do
|
12
|
+
expect(subject).to eql(expected)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
describe Procto, '.call' do
|
17
|
+
context 'with no name' do
|
18
|
+
include_context 'procto'
|
19
|
+
|
20
|
+
let(:klass) do
|
21
|
+
Class.new do
|
22
|
+
include Procto.call
|
23
|
+
|
24
|
+
def initialize(text)
|
25
|
+
@text = text
|
26
|
+
end
|
27
|
+
|
28
|
+
def call
|
29
|
+
"Hello #{@text}"
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
context 'with a name' do
|
36
|
+
include_context 'procto'
|
37
|
+
|
38
|
+
let(:klass) do
|
39
|
+
Class.new do
|
40
|
+
include Procto.call(:print)
|
41
|
+
|
42
|
+
def initialize(text)
|
43
|
+
@text = text
|
44
|
+
end
|
45
|
+
|
46
|
+
def print
|
47
|
+
"Hello #{@text}"
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
if ENV['COVERAGE'] == 'true'
|
4
|
+
require 'simplecov'
|
5
|
+
require 'coveralls'
|
6
|
+
|
7
|
+
SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[
|
8
|
+
SimpleCov::Formatter::HTMLFormatter,
|
9
|
+
Coveralls::SimpleCov::Formatter
|
10
|
+
]
|
11
|
+
|
12
|
+
SimpleCov.start do
|
13
|
+
command_name 'spec:unit'
|
14
|
+
add_filter 'config'
|
15
|
+
add_filter 'spec'
|
16
|
+
minimum_coverage 100
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
require 'procto'
|
21
|
+
require 'devtools/spec_helper'
|
22
|
+
|
23
|
+
RSpec.configure do |config|
|
24
|
+
config.expect_with :rspec do |c|
|
25
|
+
c.syntax = :expect
|
26
|
+
end
|
27
|
+
config.mock_with :rspec do |c|
|
28
|
+
c.syntax = :expect
|
29
|
+
end
|
30
|
+
end
|
metadata
ADDED
@@ -0,0 +1,89 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: procto
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Martin Gamsjaeger (snusnu)
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2013-12-20 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: bundler
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ~>
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 1.3.5
|
22
|
+
type: :development
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ~>
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: 1.3.5
|
30
|
+
description: Turns your object into a method object
|
31
|
+
email:
|
32
|
+
- gamsnjaga@gmail.com
|
33
|
+
executables: []
|
34
|
+
extensions: []
|
35
|
+
extra_rdoc_files:
|
36
|
+
- LICENSE
|
37
|
+
- README.md
|
38
|
+
- CONTRIBUTING.md
|
39
|
+
files:
|
40
|
+
- .gitignore
|
41
|
+
- .rspec
|
42
|
+
- .ruby-gemset
|
43
|
+
- .ruby-version
|
44
|
+
- .travis.yml
|
45
|
+
- CONTRIBUTING.md
|
46
|
+
- Gemfile
|
47
|
+
- Gemfile.devtools
|
48
|
+
- LICENSE
|
49
|
+
- README.md
|
50
|
+
- Rakefile
|
51
|
+
- config/devtools.yml
|
52
|
+
- config/flay.yml
|
53
|
+
- config/flog.yml
|
54
|
+
- config/mutant.yml
|
55
|
+
- config/reek.yml
|
56
|
+
- config/rubocop.yml
|
57
|
+
- config/yardstick.yml
|
58
|
+
- lib/procto.rb
|
59
|
+
- lib/procto/version.rb
|
60
|
+
- procto.gemspec
|
61
|
+
- spec/procto_spec.rb
|
62
|
+
- spec/spec_helper.rb
|
63
|
+
homepage: https://github.com/snusnu/procto
|
64
|
+
licenses:
|
65
|
+
- MIT
|
66
|
+
post_install_message:
|
67
|
+
rdoc_options: []
|
68
|
+
require_paths:
|
69
|
+
- lib
|
70
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
71
|
+
none: false
|
72
|
+
requirements:
|
73
|
+
- - ! '>='
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
77
|
+
none: false
|
78
|
+
requirements:
|
79
|
+
- - ! '>='
|
80
|
+
- !ruby/object:Gem::Version
|
81
|
+
version: '0'
|
82
|
+
requirements: []
|
83
|
+
rubyforge_project:
|
84
|
+
rubygems_version: 1.8.23
|
85
|
+
signing_key:
|
86
|
+
specification_version: 3
|
87
|
+
summary: Defines Foo.call(*args) which invokes Foo.new(*args).bar
|
88
|
+
test_files: []
|
89
|
+
has_rdoc:
|