method_repository 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/.travis.yml +9 -0
- data/README.md +30 -30
- data/Rakefile +8 -0
- data/lib/method_repository.rb +2 -2
- data/lib/method_repository/version.rb +1 -1
- data/method_repository.gemspec +3 -0
- data/spec/lib/method_repository_spec.rb +3 -3
- metadata +19 -2
data/.travis.yml
ADDED
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# MethodRepository
|
1
|
+
# MethodRepository [![BuildStatus](https://secure.travis-ci.org/kentaro/method_repository.png)](http://travis-ci.org/kentaro/method_repository)
|
2
2
|
|
3
3
|
Extracting redandunt code and commonalizing it in a different way.
|
4
4
|
|
@@ -61,29 +61,29 @@ qux = Qux.new; qux.extend(Repository)
|
|
61
61
|
Only explicitely permitted methods are defined as singleton methods of each classes/objects. That results in:
|
62
62
|
|
63
63
|
```ruby
|
64
|
-
Foo.respond_to?(:method1)
|
65
|
-
Bar.respond_to?(:method1)
|
66
|
-
Baz.respond_to?(:method1)
|
67
|
-
Qux.respond_to?(:method1)
|
68
|
-
|
69
|
-
Foo.respond_to?(:method2)
|
70
|
-
Bar.respond_to?(:method2)
|
71
|
-
Baz.respond_to?(:method2)
|
72
|
-
Qux.respond_to?(:
|
64
|
+
Foo.respond_to?(:method1) #=> true
|
65
|
+
Bar.respond_to?(:method1) #=> true
|
66
|
+
Baz.respond_to?(:method1) #=> false
|
67
|
+
Qux.respond_to?(:method1) #=> false
|
68
|
+
|
69
|
+
Foo.respond_to?(:method2) #=> false
|
70
|
+
Bar.respond_to?(:method2) #=> false
|
71
|
+
Baz.respond_to?(:method2) #=> true
|
72
|
+
Qux.respond_to?(:method2) #=> false
|
73
73
|
```
|
74
74
|
|
75
75
|
or
|
76
76
|
|
77
77
|
```ruby
|
78
|
-
foo.respond_to?(:method1)
|
79
|
-
bar.respond_to?(:method1)
|
80
|
-
baz.respond_to?(:method1)
|
81
|
-
qux.respond_to?(:method1)
|
82
|
-
|
83
|
-
foo.respond_to?(:method2)
|
84
|
-
bar.respond_to?(:method2)
|
85
|
-
baz.respond_to?(:method2)
|
86
|
-
qux.respond_to?(:
|
78
|
+
foo.respond_to?(:method1) #=> true
|
79
|
+
bar.respond_to?(:method1) #=> true
|
80
|
+
baz.respond_to?(:method1) #=> false
|
81
|
+
qux.respond_to?(:method1) #=> false
|
82
|
+
|
83
|
+
foo.respond_to?(:method2) #=> false
|
84
|
+
bar.respond_to?(:method2) #=> false
|
85
|
+
baz.respond_to?(:method2) #=> true
|
86
|
+
qux.respond_to?(:method2) #=> false
|
87
87
|
```
|
88
88
|
|
89
89
|
### Including
|
@@ -100,15 +100,15 @@ Qux.send(:include, Repository)
|
|
100
100
|
Results in:
|
101
101
|
|
102
102
|
```ruby
|
103
|
-
Foo.new.respond_to?(:method1)
|
104
|
-
Bar.new.respond_to?(:method1)
|
105
|
-
Baz.new.respond_to?(:method1)
|
106
|
-
Qux.new.respond_to?(:method1)
|
107
|
-
|
108
|
-
Foo.new.respond_to?(:method2)
|
109
|
-
Bar.new.respond_to?(:method2)
|
110
|
-
Baz.new.respond_to?(:method2)
|
111
|
-
Qux.new.respond_to?(:
|
103
|
+
Foo.new.respond_to?(:method1) #=> true
|
104
|
+
Bar.new.respond_to?(:method1) #=> true
|
105
|
+
Baz.new.respond_to?(:method1) #=> false
|
106
|
+
Qux.new.respond_to?(:method1) #=> false
|
107
|
+
|
108
|
+
Foo.new.respond_to?(:method2) #=> false
|
109
|
+
Bar.new.respond_to?(:method2) #=> false
|
110
|
+
Baz.new.respond_to?(:method2) #=> true
|
111
|
+
Qux.new.respond_to?(:method2) #=> false
|
112
112
|
```
|
113
113
|
|
114
114
|
In this case, the methods in `Repository` are, of course, defined as instance methods of each classes, not singleton methods of each objects.
|
@@ -117,7 +117,7 @@ In this case, the methods in `Repository` are, of course, defined as instance me
|
|
117
117
|
|
118
118
|
Add this line to your application's Gemfile:
|
119
119
|
|
120
|
-
gem '
|
120
|
+
gem 'method_repository'
|
121
121
|
|
122
122
|
And then execute:
|
123
123
|
|
@@ -125,7 +125,7 @@ And then execute:
|
|
125
125
|
|
126
126
|
Or install it yourself as:
|
127
127
|
|
128
|
-
$ gem install
|
128
|
+
$ gem install method_repository
|
129
129
|
|
130
130
|
## Contributing
|
131
131
|
|
data/Rakefile
CHANGED
data/lib/method_repository.rb
CHANGED
data/method_repository.gemspec
CHANGED
@@ -12,10 +12,13 @@ Gem::Specification.new do |gem|
|
|
12
12
|
gem.summary = %q{Extracting redandunt code and commonalizing it in a different way}
|
13
13
|
gem.homepage = "https://github.com/kentaro/method_repository"
|
14
14
|
|
15
|
+
gem.required_ruby_version = '>= 1.9.2'
|
16
|
+
|
15
17
|
gem.files = `git ls-files`.split($/)
|
16
18
|
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
17
19
|
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
18
20
|
gem.require_paths = ["lib"]
|
19
21
|
|
20
22
|
gem.add_development_dependency "rspec", "~> 2.12"
|
23
|
+
gem.add_development_dependency "rake"
|
21
24
|
end
|
@@ -44,7 +44,7 @@ describe MethodRepository do
|
|
44
44
|
expect(Foo.respond_to?(:method2)).to be false
|
45
45
|
expect(Bar.respond_to?(:method2)).to be false
|
46
46
|
expect(Baz.respond_to?(:method2)).to be true
|
47
|
-
expect(Qux.respond_to?(:
|
47
|
+
expect(Qux.respond_to?(:method2)).to be false
|
48
48
|
}
|
49
49
|
end
|
50
50
|
|
@@ -70,7 +70,7 @@ describe MethodRepository do
|
|
70
70
|
expect(foo.respond_to?(:method2)).to be false
|
71
71
|
expect(bar.respond_to?(:method2)).to be false
|
72
72
|
expect(baz.respond_to?(:method2)).to be true
|
73
|
-
expect(qux.respond_to?(:
|
73
|
+
expect(qux.respond_to?(:method2)).to be false
|
74
74
|
}
|
75
75
|
end
|
76
76
|
end
|
@@ -92,7 +92,7 @@ describe MethodRepository do
|
|
92
92
|
expect(Foo.new.respond_to?(:method2)).to be false
|
93
93
|
expect(Bar.new.respond_to?(:method2)).to be false
|
94
94
|
expect(Baz.new.respond_to?(:method2)).to be true
|
95
|
-
expect(Qux.new.respond_to?(:
|
95
|
+
expect(Qux.new.respond_to?(:method2)).to be false
|
96
96
|
}
|
97
97
|
end
|
98
98
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: method_repository
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -27,6 +27,22 @@ dependencies:
|
|
27
27
|
- - ~>
|
28
28
|
- !ruby/object:Gem::Version
|
29
29
|
version: '2.12'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: rake
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
type: :development
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
30
46
|
description: Extracting redandunt code and commonalizing it in a different way.
|
31
47
|
email:
|
32
48
|
- kentarok@gmail.com
|
@@ -35,6 +51,7 @@ extensions: []
|
|
35
51
|
extra_rdoc_files: []
|
36
52
|
files:
|
37
53
|
- .gitignore
|
54
|
+
- .travis.yml
|
38
55
|
- Gemfile
|
39
56
|
- LICENSE.txt
|
40
57
|
- README.md
|
@@ -55,7 +72,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
55
72
|
requirements:
|
56
73
|
- - ! '>='
|
57
74
|
- !ruby/object:Gem::Version
|
58
|
-
version:
|
75
|
+
version: 1.9.2
|
59
76
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
60
77
|
none: false
|
61
78
|
requirements:
|