fsck 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +1 -0
- data/CHANGELOG.md +5 -1
- data/Gemfile.lock +9 -9
- data/Rakefile +6 -0
- data/fsck.gemspec +2 -2
- data/lib/fsck/version.rb +1 -1
- data/lib/fsck.rb +27 -17
- data/spec/fsck/fsck_spec.rb +45 -40
- metadata +33 -50
data/.gitignore
CHANGED
data/CHANGELOG.md
CHANGED
data/Gemfile.lock
CHANGED
@@ -6,15 +6,15 @@ PATH
|
|
6
6
|
GEM
|
7
7
|
remote: http://rubygems.org/
|
8
8
|
specs:
|
9
|
-
diff-lcs (1.1.
|
10
|
-
rspec (2.
|
11
|
-
rspec-core (~> 2.
|
12
|
-
rspec-expectations (~> 2.
|
13
|
-
rspec-mocks (~> 2.
|
14
|
-
rspec-core (2.
|
15
|
-
rspec-expectations (2.
|
16
|
-
diff-lcs (~> 1.1.
|
17
|
-
rspec-mocks (2.
|
9
|
+
diff-lcs (1.1.3)
|
10
|
+
rspec (2.12.0)
|
11
|
+
rspec-core (~> 2.12.0)
|
12
|
+
rspec-expectations (~> 2.12.0)
|
13
|
+
rspec-mocks (~> 2.12.0)
|
14
|
+
rspec-core (2.12.1)
|
15
|
+
rspec-expectations (2.12.0)
|
16
|
+
diff-lcs (~> 1.1.3)
|
17
|
+
rspec-mocks (2.12.0)
|
18
18
|
|
19
19
|
PLATFORMS
|
20
20
|
ruby
|
data/Rakefile
CHANGED
data/fsck.gemspec
CHANGED
data/lib/fsck/version.rb
CHANGED
data/lib/fsck.rb
CHANGED
@@ -1,28 +1,38 @@
|
|
1
1
|
module Fsck
|
2
|
-
def method_missing(
|
3
|
-
fscked_method =
|
4
|
-
|
5
|
-
if punctuation = fscked_method[/[!?=]$/]
|
6
|
-
fscked_method.chop!
|
7
|
-
end
|
8
|
-
|
9
|
-
matches = methods.select do |m|
|
10
|
-
fscked_method =~ /^#{__fsck_method_regex_str__(m)}#{punctuation}$/
|
11
|
-
end
|
2
|
+
def method_missing(method_name, *args, &block)
|
3
|
+
fscked_method = __fsck_method__(method_name)
|
12
4
|
|
13
|
-
if
|
14
|
-
|
5
|
+
if fscked_method
|
6
|
+
target = singleton_methods.include?(fscked_method) ? singleton_class : self.class
|
7
|
+
target.class_exec { alias_method(method_name, fscked_method) }
|
8
|
+
send(method_name, *args, &block)
|
15
9
|
else
|
16
|
-
|
17
|
-
target = singleton_methods.include?(method) ? singleton_class : self.class
|
18
|
-
target.class_exec { alias_method(sym, method) }
|
19
|
-
send(sym, *args, &block)
|
10
|
+
super
|
20
11
|
end
|
21
12
|
end
|
22
|
-
|
13
|
+
|
14
|
+
def respond_to_missing?(method_name, include_private = false)
|
15
|
+
!!__fsck_method__(method_name)
|
16
|
+
end
|
17
|
+
|
23
18
|
private
|
19
|
+
|
24
20
|
def __fsck_method_regex_str__(method)
|
25
21
|
words = method.to_s.delete("!?=").split("_").map { |w| Regexp.escape(w) }
|
26
22
|
"(\\w*_)?#{words.join('\w*_\w*')}(_\\w*)?"
|
27
23
|
end
|
24
|
+
|
25
|
+
def __fsck_method__(method_name)
|
26
|
+
fscked_method = method_name.to_s
|
27
|
+
|
28
|
+
if punctuation = fscked_method[/[!?=]$/]
|
29
|
+
fscked_method.chop!
|
30
|
+
end
|
31
|
+
|
32
|
+
matches = methods.select do |method|
|
33
|
+
fscked_method =~ /^#{__fsck_method_regex_str__(method)}#{punctuation}$/
|
34
|
+
end
|
35
|
+
|
36
|
+
matches.max_by(&:length)
|
37
|
+
end
|
28
38
|
end
|
data/spec/fsck/fsck_spec.rb
CHANGED
@@ -1,75 +1,80 @@
|
|
1
1
|
require "spec_helper"
|
2
2
|
|
3
3
|
describe Fsck do
|
4
|
-
|
5
|
-
|
6
|
-
end
|
7
|
-
|
4
|
+
subject { Class.new { include Fsck }.new }
|
5
|
+
|
8
6
|
describe "method is called" do
|
9
7
|
it "should match method with fluff at the beginning" do
|
10
|
-
|
11
|
-
|
8
|
+
subject.should_receive(:the_method)
|
9
|
+
subject.call_the_method
|
12
10
|
end
|
13
|
-
|
11
|
+
|
14
12
|
it "should match method with fluff at the end" do
|
15
|
-
|
16
|
-
|
13
|
+
subject.should_receive(:the_method)
|
14
|
+
subject.the_method_is_called
|
17
15
|
end
|
18
|
-
|
16
|
+
|
19
17
|
it "should match method with fluff in the middle" do
|
20
|
-
|
21
|
-
|
18
|
+
subject.should_receive(:the_method)
|
19
|
+
subject.the_awesome_method
|
22
20
|
end
|
23
21
|
end
|
24
|
-
|
22
|
+
|
25
23
|
describe "return value" do
|
26
24
|
it "should return the value from the method" do
|
27
|
-
|
28
|
-
|
25
|
+
subject.should_receive(:the_method).and_return(42)
|
26
|
+
subject.the_method_will_obey.should eql(42)
|
29
27
|
end
|
30
28
|
end
|
31
|
-
|
29
|
+
|
32
30
|
describe "method parameters" do
|
33
31
|
it "should pass along all parameters" do
|
34
|
-
|
35
|
-
|
32
|
+
subject.should_receive(:the_method).with(42, [1,2,3], "yo dawg")
|
33
|
+
subject.the_awesome_method(42, [1,2,3], "yo dawg")
|
36
34
|
end
|
37
35
|
end
|
38
|
-
|
36
|
+
|
39
37
|
describe "whacky method names" do
|
40
38
|
it "should pass the regex when containing regex special characters" do
|
41
|
-
|
42
|
-
|
39
|
+
subject.should_receive(:[])
|
40
|
+
subject.send "square_[]_brackets"
|
43
41
|
end
|
44
|
-
|
42
|
+
|
45
43
|
it "should not match within words" do
|
46
|
-
|
47
|
-
|
44
|
+
subject.should_not_receive(:the_method)
|
45
|
+
subject.the_methods
|
48
46
|
end
|
49
|
-
|
47
|
+
|
50
48
|
it "should allow fluff at the end of punctuated methods" do
|
51
|
-
|
52
|
-
|
49
|
+
subject.should_receive(:the_method?)
|
50
|
+
subject.the_method_will_be_called?
|
53
51
|
end
|
54
52
|
end
|
55
|
-
|
53
|
+
|
56
54
|
describe "aliasing" do
|
57
55
|
it "should alias method on the first call" do
|
58
|
-
|
59
|
-
|
60
|
-
|
56
|
+
subject.stub(:the_method)
|
57
|
+
subject.calling_the_method
|
58
|
+
subject.methods.should include(:calling_the_method)
|
61
59
|
end
|
62
|
-
|
60
|
+
|
63
61
|
it "should alias method defined in the class in the scope of the class" do
|
64
|
-
|
65
|
-
|
66
|
-
|
62
|
+
subject.class.send(:define_method, :the_method) {}
|
63
|
+
subject.calling_the_method
|
64
|
+
subject.class.instance_methods(false).should include(:calling_the_method)
|
67
65
|
end
|
68
|
-
|
66
|
+
|
69
67
|
it "should alias singleton method in the scope of the singleton" do
|
70
|
-
|
71
|
-
|
72
|
-
|
68
|
+
subject.define_singleton_method(:sing_method) {}
|
69
|
+
subject.calling_sing_method
|
70
|
+
subject.sinlgeton_methods(false).should include(:calling_sing_method)
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
describe "respond to" do
|
75
|
+
it "should respond to fsked method" do
|
76
|
+
subject.stub(:the_method?)
|
77
|
+
subject.should respond_to :the_awesome_method?
|
73
78
|
end
|
74
79
|
end
|
75
|
-
end
|
80
|
+
end
|
metadata
CHANGED
@@ -1,46 +1,39 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: fsck
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
|
6
|
-
- 0
|
7
|
-
- 0
|
8
|
-
- 4
|
9
|
-
version: 0.0.4
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.5
|
5
|
+
prerelease:
|
10
6
|
platform: ruby
|
11
|
-
authors:
|
7
|
+
authors:
|
12
8
|
- Chris Thorn
|
13
9
|
autorequire:
|
14
10
|
bindir: bin
|
15
11
|
cert_chain: []
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
dependencies:
|
20
|
-
- !ruby/object:Gem::Dependency
|
12
|
+
date: 2012-12-13 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
21
15
|
name: rspec
|
22
|
-
|
23
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
24
17
|
none: false
|
25
|
-
requirements:
|
18
|
+
requirements:
|
26
19
|
- - ~>
|
27
|
-
- !ruby/object:Gem::Version
|
28
|
-
|
29
|
-
- 2
|
30
|
-
- 3
|
31
|
-
version: "2.3"
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '2.3'
|
32
22
|
type: :development
|
33
|
-
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ~>
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '2.3'
|
34
30
|
description: A gem that allows you to be yourself while writing code.
|
35
|
-
email:
|
31
|
+
email:
|
36
32
|
- thorncp@gmail.com
|
37
33
|
executables: []
|
38
|
-
|
39
34
|
extensions: []
|
40
|
-
|
41
35
|
extra_rdoc_files: []
|
42
|
-
|
43
|
-
files:
|
36
|
+
files:
|
44
37
|
- .gitignore
|
45
38
|
- CHANGELOG.md
|
46
39
|
- Gemfile
|
@@ -55,40 +48,30 @@ files:
|
|
55
48
|
- license.txt
|
56
49
|
- spec/fsck/fsck_spec.rb
|
57
50
|
- spec/spec_helper.rb
|
58
|
-
|
59
|
-
homepage: ""
|
51
|
+
homepage: ''
|
60
52
|
licenses: []
|
61
|
-
|
62
53
|
post_install_message:
|
63
54
|
rdoc_options: []
|
64
|
-
|
65
|
-
require_paths:
|
55
|
+
require_paths:
|
66
56
|
- lib
|
67
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
57
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
68
58
|
none: false
|
69
|
-
requirements:
|
59
|
+
requirements:
|
70
60
|
- - ~>
|
71
|
-
- !ruby/object:Gem::Version
|
72
|
-
segments:
|
73
|
-
- 1
|
74
|
-
- 9
|
75
|
-
- 2
|
61
|
+
- !ruby/object:Gem::Version
|
76
62
|
version: 1.9.2
|
77
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
63
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
78
64
|
none: false
|
79
|
-
requirements:
|
80
|
-
- -
|
81
|
-
- !ruby/object:Gem::Version
|
82
|
-
|
83
|
-
- 0
|
84
|
-
version: "0"
|
65
|
+
requirements:
|
66
|
+
- - ! '>='
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
85
69
|
requirements: []
|
86
|
-
|
87
70
|
rubyforge_project: fsck
|
88
|
-
rubygems_version: 1.
|
71
|
+
rubygems_version: 1.8.24
|
89
72
|
signing_key:
|
90
73
|
specification_version: 3
|
91
74
|
summary: A gem that allows you to be yourself while writing code.
|
92
|
-
test_files:
|
75
|
+
test_files:
|
93
76
|
- spec/fsck/fsck_spec.rb
|
94
77
|
- spec/spec_helper.rb
|