lazy_methods 1.0.4 → 1.0.5
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.
- data/Rakefile +8 -9
- data/VERSION +1 -1
- data/lazy_methods.gemspec +20 -22
- data/spec/lazy_method_spec.rb +15 -15
- metadata +11 -12
- data/.gitignore +0 -1
data/Rakefile
CHANGED
|
@@ -6,14 +6,13 @@ desc 'Default: run unit tests.'
|
|
|
6
6
|
task :default => :test
|
|
7
7
|
|
|
8
8
|
begin
|
|
9
|
-
require '
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
end
|
|
9
|
+
require 'rspec'
|
|
10
|
+
require 'rspec/core/rake_task'
|
|
11
|
+
desc 'Run the unit tests'
|
|
12
|
+
RSpec::Core::RakeTask.new(:test)
|
|
14
13
|
rescue LoadError
|
|
15
|
-
|
|
16
|
-
STDERR.puts "You must have rspec
|
|
14
|
+
task :test do
|
|
15
|
+
STDERR.puts "You must have rspec 2.0 installed to run the tests"
|
|
17
16
|
end
|
|
18
17
|
end
|
|
19
18
|
|
|
@@ -32,11 +31,11 @@ begin
|
|
|
32
31
|
gem.summary = %Q{Gem that adds lazy method wrapping to every object. Preceding any method with lazy_ will defer the invocation until the result is actually needed.}
|
|
33
32
|
gem.description = %Q(Gem that adds lazy method wrapping to every object. Preceding any method with lazy_ will defer the invocation until the result is actually needed. This pattern is useful when used with caching systems.)
|
|
34
33
|
gem.email = "brian@embellishedvisions.com"
|
|
35
|
-
gem.homepage = "http://github.com/bdurand/
|
|
34
|
+
gem.homepage = "http://github.com/bdurand/lazy_methods"
|
|
36
35
|
gem.authors = ["Brian Durand"]
|
|
37
36
|
gem.rdoc_options = ["--charset=UTF-8", "--main", "README.rdoc"]
|
|
38
37
|
|
|
39
|
-
gem.add_development_dependency('rspec', '>=
|
|
38
|
+
gem.add_development_dependency('rspec', '>= 2.0.0')
|
|
40
39
|
gem.add_development_dependency('jeweler')
|
|
41
40
|
end
|
|
42
41
|
|
data/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
1.0.
|
|
1
|
+
1.0.5
|
data/lazy_methods.gemspec
CHANGED
|
@@ -1,57 +1,55 @@
|
|
|
1
1
|
# Generated by jeweler
|
|
2
2
|
# DO NOT EDIT THIS FILE DIRECTLY
|
|
3
|
-
# Instead, edit Jeweler::Tasks in Rakefile, and run
|
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
|
4
4
|
# -*- encoding: utf-8 -*-
|
|
5
5
|
|
|
6
6
|
Gem::Specification.new do |s|
|
|
7
7
|
s.name = %q{lazy_methods}
|
|
8
|
-
s.version = "1.0.
|
|
8
|
+
s.version = "1.0.5"
|
|
9
9
|
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
|
11
11
|
s.authors = ["Brian Durand"]
|
|
12
|
-
s.date = %q{
|
|
12
|
+
s.date = %q{2011-01-19}
|
|
13
13
|
s.description = %q{Gem that adds lazy method wrapping to every object. Preceding any method with lazy_ will defer the invocation until the result is actually needed. This pattern is useful when used with caching systems.}
|
|
14
14
|
s.email = %q{brian@embellishedvisions.com}
|
|
15
15
|
s.extra_rdoc_files = [
|
|
16
16
|
"README.rdoc"
|
|
17
17
|
]
|
|
18
18
|
s.files = [
|
|
19
|
-
"
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
"spec/spec_helper.rb"
|
|
19
|
+
"MIT-LICENSE",
|
|
20
|
+
"README.rdoc",
|
|
21
|
+
"Rakefile",
|
|
22
|
+
"VERSION",
|
|
23
|
+
"lazy_methods.gemspec",
|
|
24
|
+
"lib/lazy_methods.rb",
|
|
25
|
+
"lib/lazy_methods/lazy_methods.rb",
|
|
26
|
+
"spec/lazy_method_spec.rb",
|
|
27
|
+
"spec/method_tester.rb",
|
|
28
|
+
"spec/spec_helper.rb"
|
|
30
29
|
]
|
|
31
|
-
s.homepage = %q{http://github.com/bdurand/
|
|
30
|
+
s.homepage = %q{http://github.com/bdurand/lazy_methods}
|
|
32
31
|
s.rdoc_options = ["--charset=UTF-8", "--main", "README.rdoc"]
|
|
33
32
|
s.require_paths = ["lib"]
|
|
34
|
-
s.rubygems_version = %q{1.
|
|
33
|
+
s.rubygems_version = %q{1.4.1}
|
|
35
34
|
s.summary = %q{Gem that adds lazy method wrapping to every object. Preceding any method with lazy_ will defer the invocation until the result is actually needed.}
|
|
36
35
|
s.test_files = [
|
|
37
36
|
"spec/lazy_method_spec.rb",
|
|
38
|
-
|
|
39
|
-
|
|
37
|
+
"spec/method_tester.rb",
|
|
38
|
+
"spec/spec_helper.rb"
|
|
40
39
|
]
|
|
41
40
|
|
|
42
41
|
if s.respond_to? :specification_version then
|
|
43
|
-
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
|
44
42
|
s.specification_version = 3
|
|
45
43
|
|
|
46
44
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
|
47
|
-
s.add_development_dependency(%q<rspec>, [">=
|
|
45
|
+
s.add_development_dependency(%q<rspec>, [">= 2.0.0"])
|
|
48
46
|
s.add_development_dependency(%q<jeweler>, [">= 0"])
|
|
49
47
|
else
|
|
50
|
-
s.add_dependency(%q<rspec>, [">=
|
|
48
|
+
s.add_dependency(%q<rspec>, [">= 2.0.0"])
|
|
51
49
|
s.add_dependency(%q<jeweler>, [">= 0"])
|
|
52
50
|
end
|
|
53
51
|
else
|
|
54
|
-
s.add_dependency(%q<rspec>, [">=
|
|
52
|
+
s.add_dependency(%q<rspec>, [">= 2.0.0"])
|
|
55
53
|
s.add_dependency(%q<jeweler>, [">= 0"])
|
|
56
54
|
end
|
|
57
55
|
end
|
data/spec/lazy_method_spec.rb
CHANGED
|
@@ -2,52 +2,52 @@ require File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib', 'lazy_me
|
|
|
2
2
|
Object.send(:include, LazyMethods::InstanceMethods) unless Object.include?(LazyMethods::InstanceMethods)
|
|
3
3
|
require File.expand_path(File.dirname(__FILE__) + '/method_tester')
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
describe LazyMethods::InstanceMethods do
|
|
6
6
|
|
|
7
7
|
let(:object) { MethodTester.new }
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
it "should inject lazy method handling" do
|
|
10
10
|
proxy = object.lazy_test("arg")
|
|
11
11
|
proxy.to_s.should == "ARG"
|
|
12
12
|
proxy.__proxy_loaded__.should == true
|
|
13
13
|
end
|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
it "should return a proxy object that has not been invoked yet" do
|
|
16
16
|
proxy = object.lazy_test("arg")
|
|
17
17
|
proxy.__proxy_loaded__.should == false
|
|
18
18
|
end
|
|
19
19
|
|
|
20
20
|
end
|
|
21
21
|
|
|
22
|
-
|
|
22
|
+
describe LazyMethods::Proxy do
|
|
23
23
|
|
|
24
24
|
let(:object) { MethodTester.new }
|
|
25
25
|
|
|
26
|
-
|
|
26
|
+
it "should be able to wrap a method without executing it" do
|
|
27
27
|
proxy = object.lazy_test("arg")
|
|
28
28
|
object.test_called.should == 0
|
|
29
29
|
end
|
|
30
30
|
|
|
31
|
-
|
|
31
|
+
it "should execute the wrapped method when it needs to" do
|
|
32
32
|
proxy = object.lazy_test("arg")
|
|
33
33
|
proxy.to_s
|
|
34
34
|
object.test_called.should == 1
|
|
35
35
|
end
|
|
36
36
|
|
|
37
|
-
|
|
37
|
+
it "should only execute the wrapped method once" do
|
|
38
38
|
proxy = object.lazy_test("arg")
|
|
39
39
|
proxy.to_s
|
|
40
40
|
proxy.to_s
|
|
41
41
|
object.test_called.should == 1
|
|
42
42
|
end
|
|
43
43
|
|
|
44
|
-
|
|
44
|
+
it "should allow nil as a valid proxied value" do
|
|
45
45
|
proxy = object.lazy_test(nil)
|
|
46
46
|
proxy.should_not
|
|
47
47
|
object.test_called.should == 1
|
|
48
48
|
end
|
|
49
49
|
|
|
50
|
-
|
|
50
|
+
it "should allow blocks in the lazy method" do
|
|
51
51
|
n = 1
|
|
52
52
|
proxy = object.lazy_test("arg") do
|
|
53
53
|
n = 2
|
|
@@ -57,23 +57,23 @@ context "LazyMethods Proxy" do
|
|
|
57
57
|
n.should == 2
|
|
58
58
|
end
|
|
59
59
|
|
|
60
|
-
|
|
60
|
+
it "should be indistinguishable from the real object" do
|
|
61
61
|
proxy = object.lazy_test("arg")
|
|
62
62
|
proxy.class.should == String
|
|
63
63
|
proxy.kind_of?(String).should == true
|
|
64
64
|
end
|
|
65
65
|
|
|
66
|
-
|
|
66
|
+
it "should proxy core methods on Object" do
|
|
67
67
|
proxy = "xxx".lazy_to_s
|
|
68
68
|
proxy.should == "xxx"
|
|
69
69
|
end
|
|
70
70
|
|
|
71
|
-
|
|
71
|
+
it "should proxy missing methods" do
|
|
72
72
|
proxy = object.lazy_find_test
|
|
73
73
|
proxy.to_s.should == "FINDER"
|
|
74
74
|
end
|
|
75
75
|
|
|
76
|
-
|
|
76
|
+
it "should allow blocks in the lazy missing methods" do
|
|
77
77
|
n = 1
|
|
78
78
|
proxy = object.lazy_find_test do
|
|
79
79
|
n = 2
|
|
@@ -83,12 +83,12 @@ context "LazyMethods Proxy" do
|
|
|
83
83
|
n.should == 2
|
|
84
84
|
end
|
|
85
85
|
|
|
86
|
-
|
|
86
|
+
it "should not interfere with the proxied object's method_missing" do
|
|
87
87
|
real = object.find_test
|
|
88
88
|
real.to_s.should == "FINDER"
|
|
89
89
|
end
|
|
90
90
|
|
|
91
|
-
|
|
91
|
+
it "should not interfere with real methods that begin with lazy_" do
|
|
92
92
|
object.lazy_real_method_called.should == false
|
|
93
93
|
object.lazy_real_method
|
|
94
94
|
object.lazy_real_method_called.should == true
|
metadata
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: lazy_methods
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
hash:
|
|
5
|
-
prerelease:
|
|
4
|
+
hash: 29
|
|
5
|
+
prerelease:
|
|
6
6
|
segments:
|
|
7
7
|
- 1
|
|
8
8
|
- 0
|
|
9
|
-
-
|
|
10
|
-
version: 1.0.
|
|
9
|
+
- 5
|
|
10
|
+
version: 1.0.5
|
|
11
11
|
platform: ruby
|
|
12
12
|
authors:
|
|
13
13
|
- Brian Durand
|
|
@@ -15,7 +15,7 @@ autorequire:
|
|
|
15
15
|
bindir: bin
|
|
16
16
|
cert_chain: []
|
|
17
17
|
|
|
18
|
-
date:
|
|
18
|
+
date: 2011-01-19 00:00:00 -06:00
|
|
19
19
|
default_executable:
|
|
20
20
|
dependencies:
|
|
21
21
|
- !ruby/object:Gem::Dependency
|
|
@@ -26,12 +26,12 @@ dependencies:
|
|
|
26
26
|
requirements:
|
|
27
27
|
- - ">="
|
|
28
28
|
- !ruby/object:Gem::Version
|
|
29
|
-
hash:
|
|
29
|
+
hash: 15
|
|
30
30
|
segments:
|
|
31
|
-
-
|
|
32
|
-
-
|
|
31
|
+
- 2
|
|
32
|
+
- 0
|
|
33
33
|
- 0
|
|
34
|
-
version:
|
|
34
|
+
version: 2.0.0
|
|
35
35
|
type: :development
|
|
36
36
|
version_requirements: *id001
|
|
37
37
|
- !ruby/object:Gem::Dependency
|
|
@@ -57,7 +57,6 @@ extensions: []
|
|
|
57
57
|
extra_rdoc_files:
|
|
58
58
|
- README.rdoc
|
|
59
59
|
files:
|
|
60
|
-
- .gitignore
|
|
61
60
|
- MIT-LICENSE
|
|
62
61
|
- README.rdoc
|
|
63
62
|
- Rakefile
|
|
@@ -69,7 +68,7 @@ files:
|
|
|
69
68
|
- spec/method_tester.rb
|
|
70
69
|
- spec/spec_helper.rb
|
|
71
70
|
has_rdoc: true
|
|
72
|
-
homepage: http://github.com/bdurand/
|
|
71
|
+
homepage: http://github.com/bdurand/lazy_methods
|
|
73
72
|
licenses: []
|
|
74
73
|
|
|
75
74
|
post_install_message:
|
|
@@ -100,7 +99,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
100
99
|
requirements: []
|
|
101
100
|
|
|
102
101
|
rubyforge_project:
|
|
103
|
-
rubygems_version: 1.
|
|
102
|
+
rubygems_version: 1.4.1
|
|
104
103
|
signing_key:
|
|
105
104
|
specification_version: 3
|
|
106
105
|
summary: Gem that adds lazy method wrapping to every object. Preceding any method with lazy_ will defer the invocation until the result is actually needed.
|
data/.gitignore
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
pkg
|