cherry_pick 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.
- checksums.yaml +7 -0
- data/.gitignore +19 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +35 -0
- data/README.md +4 -0
- data/cherry_pick.gemspec +25 -0
- data/lib/cherry_pick/version.rb +3 -0
- data/lib/cherry_pick.rb +26 -0
- data/spec/lib/cherry_pick_spec.rb +63 -0
- metadata +110 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: e9e9ed178a56da3cfcb433f295635ea678d07782
|
4
|
+
data.tar.gz: 24d505495a299cb6b5e55884a8dcedc4d4c0d924
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 364e11eb1d973ae0f4db0d662e80a6ef63d2c7dc0df9bf5329d17c5301b6830ed19df4109f769ab9bbbf375774c2b93e11a2682f2d7d02ce7503970de91d1cc4
|
7
|
+
data.tar.gz: 2e2c80b517cc2d45805829a50a86e1ef1e17be370049304cf45ef09af337cb819b9c0ff7c090773253aeae0895a0d57c27732068a8e42b280481236ca38192bc
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
overload (0.0.1)
|
5
|
+
|
6
|
+
GEM
|
7
|
+
remote: https://rubygems.org/
|
8
|
+
specs:
|
9
|
+
coderay (1.1.0)
|
10
|
+
diff-lcs (1.2.5)
|
11
|
+
method_source (0.8.2)
|
12
|
+
pry (0.9.12.4)
|
13
|
+
coderay (~> 1.0)
|
14
|
+
method_source (~> 0.8)
|
15
|
+
slop (~> 3.4)
|
16
|
+
rake (10.1.1)
|
17
|
+
rspec (2.14.1)
|
18
|
+
rspec-core (~> 2.14.0)
|
19
|
+
rspec-expectations (~> 2.14.0)
|
20
|
+
rspec-mocks (~> 2.14.0)
|
21
|
+
rspec-core (2.14.7)
|
22
|
+
rspec-expectations (2.14.4)
|
23
|
+
diff-lcs (>= 1.1.3, < 2.0)
|
24
|
+
rspec-mocks (2.14.4)
|
25
|
+
slop (3.4.7)
|
26
|
+
|
27
|
+
PLATFORMS
|
28
|
+
ruby
|
29
|
+
|
30
|
+
DEPENDENCIES
|
31
|
+
bundler (~> 1.3)
|
32
|
+
overload!
|
33
|
+
pry
|
34
|
+
rake
|
35
|
+
rspec
|
data/README.md
ADDED
data/cherry_pick.gemspec
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'cherry_pick/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "cherry_pick"
|
8
|
+
spec.version = CherryPick::VERSION
|
9
|
+
spec.authors = ["Alex Sunderland"]
|
10
|
+
spec.email = ["alex.sunderland@gmail.com"]
|
11
|
+
spec.description = "Cherry pick the methods you want."
|
12
|
+
spec.summary = "A gem that allows cherry picking a single method from a required class or module."
|
13
|
+
spec.homepage = "https://github.com/AgentAntelope/cherry_pick"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files`.split($/)
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
22
|
+
spec.add_development_dependency "rake"
|
23
|
+
spec.add_development_dependency "rspec"
|
24
|
+
spec.add_development_dependency "pry"
|
25
|
+
end
|
data/lib/cherry_pick.rb
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
module CherryPick
|
2
|
+
|
3
|
+
def cherry_pick(*method_symbols, klass)
|
4
|
+
klass = klass.dup
|
5
|
+
|
6
|
+
klass.instance_methods.each do |method|
|
7
|
+
unless method_symbols.include?(method)
|
8
|
+
klass.send(:remove_method, method)
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
include klass
|
13
|
+
end
|
14
|
+
|
15
|
+
def class_cherry_pick(*method_symbols, klass)
|
16
|
+
method_symbols.each do |method_symbol|
|
17
|
+
meta_class.send(:define_method, method_symbol) { klass.method(method_symbol).call }
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
private
|
22
|
+
|
23
|
+
def meta_class
|
24
|
+
class << self; self; end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,63 @@
|
|
1
|
+
require 'cherry_pick'
|
2
|
+
module Mark
|
3
|
+
def valueable_method
|
4
|
+
"I am so worth having!"
|
5
|
+
end
|
6
|
+
|
7
|
+
def other_valueable_method
|
8
|
+
"I am even better!"
|
9
|
+
end
|
10
|
+
|
11
|
+
def rubbish_method
|
12
|
+
"I am not useful at all!"
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.valueable_class_method
|
16
|
+
"I am so worth having, at a class level!!"
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.other_valueable_class_method
|
20
|
+
"I am even better, at a class level!!"
|
21
|
+
end
|
22
|
+
|
23
|
+
def self.rubbish_class_method
|
24
|
+
"I am not useful at all, at a class level!!"
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
class TestClass
|
29
|
+
extend CherryPick
|
30
|
+
|
31
|
+
cherry_pick(:valueable_method, :other_valueable_method, Mark)
|
32
|
+
class_cherry_pick(:valueable_class_method, :other_valueable_class_method, Mark)
|
33
|
+
end
|
34
|
+
|
35
|
+
describe TestClass do
|
36
|
+
context "instance methods" do
|
37
|
+
it "has valueable_method available" do
|
38
|
+
expect(subject.valueable_method).to eq("I am so worth having!")
|
39
|
+
end
|
40
|
+
|
41
|
+
it "has other_valueable_method" do
|
42
|
+
expect(subject.other_valueable_method).to eq("I am even better!")
|
43
|
+
end
|
44
|
+
|
45
|
+
it "does not have rubbish_method available" do
|
46
|
+
expect { subject.rubbish_method }.to raise_error(NoMethodError)
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
context "class methods" do
|
51
|
+
it "has valueable_class_method available" do
|
52
|
+
expect(described_class.valueable_class_method).to eq("I am so worth having, at a class level!!")
|
53
|
+
end
|
54
|
+
|
55
|
+
it "has other_valueable_class_method" do
|
56
|
+
expect(described_class.other_valueable_class_method).to eq("I am even better, at a class level!!")
|
57
|
+
end
|
58
|
+
|
59
|
+
it "does not have rubbish_class_method available" do
|
60
|
+
expect { described_class.rubbish_class_method }.to raise_error(NoMethodError)
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
metadata
ADDED
@@ -0,0 +1,110 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: cherry_pick
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Alex Sunderland
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-02-19 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.3'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.3'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '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: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '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
|
+
description: Cherry pick the methods you want.
|
70
|
+
email:
|
71
|
+
- alex.sunderland@gmail.com
|
72
|
+
executables: []
|
73
|
+
extensions: []
|
74
|
+
extra_rdoc_files: []
|
75
|
+
files:
|
76
|
+
- .gitignore
|
77
|
+
- Gemfile
|
78
|
+
- Gemfile.lock
|
79
|
+
- README.md
|
80
|
+
- cherry_pick.gemspec
|
81
|
+
- lib/cherry_pick.rb
|
82
|
+
- lib/cherry_pick/version.rb
|
83
|
+
- spec/lib/cherry_pick_spec.rb
|
84
|
+
homepage: https://github.com/AgentAntelope/cherry_pick
|
85
|
+
licenses:
|
86
|
+
- MIT
|
87
|
+
metadata: {}
|
88
|
+
post_install_message:
|
89
|
+
rdoc_options: []
|
90
|
+
require_paths:
|
91
|
+
- lib
|
92
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - '>='
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
98
|
+
requirements:
|
99
|
+
- - '>='
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: '0'
|
102
|
+
requirements: []
|
103
|
+
rubyforge_project:
|
104
|
+
rubygems_version: 2.0.6
|
105
|
+
signing_key:
|
106
|
+
specification_version: 4
|
107
|
+
summary: A gem that allows cherry picking a single method from a required class or
|
108
|
+
module.
|
109
|
+
test_files:
|
110
|
+
- spec/lib/cherry_pick_spec.rb
|