procto 0.0.2 → 0.0.3
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/.travis.yml +3 -2
- data/Gemfile +4 -3
- data/config/flay.yml +2 -2
- data/config/flog.yml +1 -1
- data/config/reek.yml +1 -1
- data/config/rubocop.yml +6 -6
- data/lib/procto.rb +32 -0
- data/lib/procto/version.rb +1 -1
- data/procto.gemspec +1 -1
- data/spec/shared/procto_behavior.rb +10 -0
- data/spec/{procto_spec.rb → unit/procto/call_spec.rb} +1 -10
- data/spec/unit/procto/to_proc_spec.rb +29 -0
- metadata +18 -22
- data/.ruby-version +0 -1
- data/Gemfile.devtools +0 -67
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: f5773a83ff9ba5df3c3c9c8bcc34300ed2421e79
|
4
|
+
data.tar.gz: ff5be4828220d15e4018f165079bbb7e3740b567
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: d7267fcabfd12b7631fd8b2fc9337cd2aced70ce958b62f6c3da87510d6cc5f547328f3a4bfecf257c199fddd6429583b1c599035b22ad52d9405cce76c68c88
|
7
|
+
data.tar.gz: cac224bef82278288a507f358b89fa3a2718428a50035d60923e563184c6ffcdb6420ed7dc806a4b923822693472c1b8214e59e9c4178fad4ef00b320b0754dc
|
data/.travis.yml
CHANGED
@@ -3,8 +3,7 @@ before_install: gem install bundler
|
|
3
3
|
bundler_args: --without yard guard benchmarks
|
4
4
|
script: "bundle exec rake ci"
|
5
5
|
rvm:
|
6
|
-
-
|
7
|
-
- 2.0.0
|
6
|
+
- 2.3.0
|
8
7
|
- ruby-head
|
9
8
|
- rbx-19mode
|
10
9
|
matrix:
|
@@ -15,3 +14,5 @@ matrix:
|
|
15
14
|
env: JRUBY_OPTS="$JRUBY_OPTS --debug"
|
16
15
|
allow_failures:
|
17
16
|
- rvm: rbx-19mode
|
17
|
+
- rvm: jruby-19mode
|
18
|
+
- rvm: jruby-head
|
data/Gemfile
CHANGED
@@ -5,8 +5,9 @@ source 'https://rubygems.org'
|
|
5
5
|
gemspec
|
6
6
|
|
7
7
|
group :development do
|
8
|
-
gem 'devtools', git: 'https://github.com/
|
8
|
+
gem 'devtools', git: 'https://github.com/mbj/devtools.git'
|
9
9
|
end
|
10
10
|
|
11
|
-
|
12
|
-
|
11
|
+
group :test do
|
12
|
+
gem 'coveralls', '~> 0.8.9'
|
13
|
+
end
|
data/config/flay.yml
CHANGED
@@ -1,3 +1,3 @@
|
|
1
1
|
---
|
2
|
-
threshold:
|
3
|
-
total_score:
|
2
|
+
threshold: 2
|
3
|
+
total_score: 2
|
data/config/flog.yml
CHANGED
@@ -1,2 +1,2 @@
|
|
1
1
|
---
|
2
|
-
threshold:
|
2
|
+
threshold: 5.5
|
data/config/reek.yml
CHANGED
data/config/rubocop.yml
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
AllCops:
|
2
|
-
|
2
|
+
Include:
|
3
3
|
- '**/*.rake'
|
4
4
|
- 'Gemfile'
|
5
5
|
- 'Gemfile.devtools'
|
6
|
-
|
6
|
+
Exclude:
|
7
7
|
- '**/vendor/**'
|
8
8
|
- '**/benchmarks/**'
|
9
9
|
|
@@ -57,10 +57,6 @@ ConstantName:
|
|
57
57
|
TrivialAccessors:
|
58
58
|
Enabled: false
|
59
59
|
|
60
|
-
# Do not prefer do/end over {} for multiline blocks
|
61
|
-
Blocks:
|
62
|
-
Enabled: false
|
63
|
-
|
64
60
|
# Do not favor aligned parameters in method calls
|
65
61
|
AlignParameters:
|
66
62
|
Enabled: false
|
@@ -76,3 +72,7 @@ Lambda:
|
|
76
72
|
|
77
73
|
AndOr:
|
78
74
|
Enabled: false # we agree to use and/or for control flow
|
75
|
+
|
76
|
+
# Allow code to be aligned more nicely
|
77
|
+
SpaceBeforeFirstArg:
|
78
|
+
Enabled: false
|
data/lib/procto.rb
CHANGED
@@ -76,5 +76,37 @@ class Procto < Module
|
|
76
76
|
host.instance_exec(@block) do |block|
|
77
77
|
define_singleton_method(:call, &block)
|
78
78
|
end
|
79
|
+
|
80
|
+
host.extend(ClassMethods)
|
81
|
+
end
|
82
|
+
|
83
|
+
# Procto module for adding .to_proc to host class
|
84
|
+
module ClassMethods
|
85
|
+
# Return the `call` singleton method as a lambda
|
86
|
+
#
|
87
|
+
# @example using a class as a proc
|
88
|
+
#
|
89
|
+
# class Shouter
|
90
|
+
# include Procto.call
|
91
|
+
#
|
92
|
+
# def initialize(text)
|
93
|
+
# @text = text
|
94
|
+
# end
|
95
|
+
#
|
96
|
+
# def call
|
97
|
+
# "#{@text.upcase}!"
|
98
|
+
# end
|
99
|
+
# end
|
100
|
+
#
|
101
|
+
# Shouter.to_proc.call('hello') # => "HELLO!"
|
102
|
+
# %w[foo bar].map(&Shouter) # => ["FOO!", "BAR!"]
|
103
|
+
#
|
104
|
+
# @return [Proc]
|
105
|
+
#
|
106
|
+
# @api public
|
107
|
+
def to_proc
|
108
|
+
public_method(:call).to_proc
|
109
|
+
end
|
79
110
|
end
|
111
|
+
private_constant(:ClassMethods)
|
80
112
|
end # Procto
|
data/lib/procto/version.rb
CHANGED
data/procto.gemspec
CHANGED
@@ -2,18 +2,9 @@
|
|
2
2
|
|
3
3
|
require 'spec_helper'
|
4
4
|
|
5
|
-
|
5
|
+
describe Procto, '.call' do
|
6
6
|
subject { klass.call(text) }
|
7
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
8
|
context 'with no name' do
|
18
9
|
include_context 'procto'
|
19
10
|
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe Procto, '.to_proc' do
|
6
|
+
include_context 'procto'
|
7
|
+
|
8
|
+
subject { proc.call(text) }
|
9
|
+
|
10
|
+
let(:proc) { klass.to_proc }
|
11
|
+
|
12
|
+
let(:klass) do
|
13
|
+
Class.new do
|
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
|
+
end
|
25
|
+
|
26
|
+
it 'exposes a lambda proc' do
|
27
|
+
expect(proc).to be_a_lambda
|
28
|
+
end
|
29
|
+
end
|
metadata
CHANGED
@@ -1,32 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: procto
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
5
|
-
prerelease:
|
4
|
+
version: 0.0.3
|
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:
|
11
|
+
date: 2016-02-29 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: bundler
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
16
|
requirements:
|
19
|
-
- - ~>
|
17
|
+
- - "~>"
|
20
18
|
- !ruby/object:Gem::Version
|
21
|
-
version: 1
|
19
|
+
version: '1'
|
22
20
|
type: :development
|
23
21
|
prerelease: false
|
24
22
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
23
|
requirements:
|
27
|
-
- - ~>
|
24
|
+
- - "~>"
|
28
25
|
- !ruby/object:Gem::Version
|
29
|
-
version: 1
|
26
|
+
version: '1'
|
30
27
|
description: Turns your object into a method object
|
31
28
|
email:
|
32
29
|
- gamsnjaga@gmail.com
|
@@ -37,14 +34,12 @@ extra_rdoc_files:
|
|
37
34
|
- README.md
|
38
35
|
- CONTRIBUTING.md
|
39
36
|
files:
|
40
|
-
- .gitignore
|
41
|
-
- .rspec
|
42
|
-
- .ruby-gemset
|
43
|
-
- .
|
44
|
-
- .travis.yml
|
37
|
+
- ".gitignore"
|
38
|
+
- ".rspec"
|
39
|
+
- ".ruby-gemset"
|
40
|
+
- ".travis.yml"
|
45
41
|
- CONTRIBUTING.md
|
46
42
|
- Gemfile
|
47
|
-
- Gemfile.devtools
|
48
43
|
- LICENSE
|
49
44
|
- README.md
|
50
45
|
- Rakefile
|
@@ -58,32 +53,33 @@ files:
|
|
58
53
|
- lib/procto.rb
|
59
54
|
- lib/procto/version.rb
|
60
55
|
- procto.gemspec
|
61
|
-
- spec/
|
56
|
+
- spec/shared/procto_behavior.rb
|
62
57
|
- spec/spec_helper.rb
|
58
|
+
- spec/unit/procto/call_spec.rb
|
59
|
+
- spec/unit/procto/to_proc_spec.rb
|
63
60
|
homepage: https://github.com/snusnu/procto
|
64
61
|
licenses:
|
65
62
|
- MIT
|
63
|
+
metadata: {}
|
66
64
|
post_install_message:
|
67
65
|
rdoc_options: []
|
68
66
|
require_paths:
|
69
67
|
- lib
|
70
68
|
required_ruby_version: !ruby/object:Gem::Requirement
|
71
|
-
none: false
|
72
69
|
requirements:
|
73
|
-
- -
|
70
|
+
- - ">="
|
74
71
|
- !ruby/object:Gem::Version
|
75
72
|
version: '0'
|
76
73
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
77
|
-
none: false
|
78
74
|
requirements:
|
79
|
-
- -
|
75
|
+
- - ">="
|
80
76
|
- !ruby/object:Gem::Version
|
81
77
|
version: '0'
|
82
78
|
requirements: []
|
83
79
|
rubyforge_project:
|
84
|
-
rubygems_version:
|
80
|
+
rubygems_version: 2.2.2
|
85
81
|
signing_key:
|
86
|
-
specification_version:
|
82
|
+
specification_version: 4
|
87
83
|
summary: Defines Foo.call(*args) which invokes Foo.new(*args).bar
|
88
84
|
test_files: []
|
89
85
|
has_rdoc:
|
data/.ruby-version
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
1.9.3
|
data/Gemfile.devtools
DELETED
@@ -1,67 +0,0 @@
|
|
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
|