method_repository 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +6 -6
- data/lib/method_repository.rb +2 -3
- data/lib/method_repository/version.rb +1 -1
- data/method_repository.gemspec +2 -2
- data/spec/lib/method_repository_spec.rb +1 -1
- data/spec/spec_helper.rb +1 -2
- metadata +4 -4
data/README.md
CHANGED
@@ -1,20 +1,20 @@
|
|
1
1
|
# MethodRepository [![BuildStatus](https://secure.travis-ci.org/kentaro/method_repository.png)](http://travis-ci.org/kentaro/method_repository)
|
2
2
|
|
3
|
-
Extracting
|
3
|
+
Extracting redundant code and commonalizing it in a different way.
|
4
4
|
|
5
5
|
## Problem
|
6
6
|
|
7
|
-
To extract
|
7
|
+
To extract redundant codes into a method to commonalize them is a usual strategy for OOP. It allows us to streamline our codes and modify at one stop even though the method is used at anywhere, anytimes.
|
8
8
|
|
9
|
-
I don't like when highly commonalized OOP structure disturbes me from quick tracing where such methods are defined. It's OOP's natural defect, I think. Once
|
9
|
+
I don't like when highly commonalized OOP structure disturbes me from quick tracing where such methods are defined. It's OOP's natural defect, I think. Once classes/modules are defined, it's inevitable that the classes/modules are inherited/included at anywhere we don't know.
|
10
10
|
|
11
|
-
In that way, inheritance/inclusion-based OOP resembles `goto` programming; There's no clear reason why some classes/modules are inherited/included by another classes/modules. Even though there's some structural thought in your classes/modules design, such an excessively free inheritance/inclusion prevent
|
11
|
+
In that way, inheritance/inclusion-based OOP resembles `goto` programming; There's no clear reason why some classes/modules are inherited/included by another classes/modules. Even though there's some structural thought in your classes/modules design, such an excessively free inheritance/inclusion prevent us from grasping the whole code quickily.
|
12
12
|
|
13
13
|
## Solution
|
14
14
|
|
15
|
-
This library provides a "method repository" in which you can add your methods to commonalize
|
15
|
+
This library provides a "method repository" in which you can add your methods to commonalize redundant codes here and there in your whole codes, which is just same as usual module usage. However, the methods you define in the "repository" will never be included automatically into other classes/modules unless not permitted explicitely.
|
16
16
|
|
17
|
-
This is the point; There's no chance the methods in the "repository" appear at somewhere the "repository" don't know. To commonalize
|
17
|
+
This is the point; There's no chance the methods in the "repository" appear at somewhere the "repository" don't know. To commonalize redundancy is our intension, but we don't want the methods to be used where we don't know. The way this library provides solves the problem.
|
18
18
|
|
19
19
|
## Usage
|
20
20
|
|
data/lib/method_repository.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
|
1
|
+
require_relative "method_repository/version"
|
2
2
|
|
3
3
|
module MethodRepository
|
4
4
|
def self.included(base)
|
@@ -11,8 +11,7 @@ module MethodRepository
|
|
11
11
|
klass_name = base.class.to_s == 'Class' ? base.to_s : base.class.to_s
|
12
12
|
|
13
13
|
if (methods = @targets[klass_name])
|
14
|
-
singleton_class
|
15
|
-
singleton_class.class_eval do
|
14
|
+
base.singleton_class.class_eval do
|
16
15
|
methods.each do |method|
|
17
16
|
define_method method[:name], method[:block]
|
18
17
|
end
|
data/method_repository.gemspec
CHANGED
@@ -8,8 +8,8 @@ Gem::Specification.new do |gem|
|
|
8
8
|
gem.version = MethodRepository::VERSION
|
9
9
|
gem.authors = ["Kentaro Kuribayashi"]
|
10
10
|
gem.email = ["kentarok@gmail.com"]
|
11
|
-
gem.description = %q{Extracting
|
12
|
-
gem.summary = %q{Extracting
|
11
|
+
gem.description = %q{Extracting redundant code and commonalizing it in a different way.}
|
12
|
+
gem.summary = %q{Extracting redundant code and commonalizing it in a different way}
|
13
13
|
gem.homepage = "https://github.com/kentaro/method_repository"
|
14
14
|
|
15
15
|
gem.required_ruby_version = '>= 1.9.2'
|
data/spec/spec_helper.rb
CHANGED
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.4
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-02-
|
12
|
+
date: 2013-02-03 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rspec
|
@@ -43,7 +43,7 @@ dependencies:
|
|
43
43
|
- - ! '>='
|
44
44
|
- !ruby/object:Gem::Version
|
45
45
|
version: '0'
|
46
|
-
description: Extracting
|
46
|
+
description: Extracting redundant code and commonalizing it in a different way.
|
47
47
|
email:
|
48
48
|
- kentarok@gmail.com
|
49
49
|
executables: []
|
@@ -84,7 +84,7 @@ rubyforge_project:
|
|
84
84
|
rubygems_version: 1.8.23
|
85
85
|
signing_key:
|
86
86
|
specification_version: 3
|
87
|
-
summary: Extracting
|
87
|
+
summary: Extracting redundant code and commonalizing it in a different way
|
88
88
|
test_files:
|
89
89
|
- spec/lib/method_repository_spec.rb
|
90
90
|
- spec/spec_helper.rb
|