poser 1.0.3 → 1.0.4
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/lib/poser/presenter.rb +2 -8
- data/lib/poser/util.rb +5 -1
- data/lib/poser/version.rb +1 -1
- data/spec/poser/enumerable_presenter_spec.rb +29 -0
- data/spec/poser/presenter_spec.rb +0 -7
- metadata +3 -1
data/lib/poser/presenter.rb
CHANGED
@@ -22,18 +22,12 @@ module Poser
|
|
22
22
|
|
23
23
|
attr_reader :context
|
24
24
|
|
25
|
-
alias_method :__class__, :class
|
26
|
-
|
27
25
|
def id
|
28
26
|
__getobj__.id
|
29
27
|
end
|
30
28
|
|
31
|
-
def class
|
32
|
-
__getobj__.class
|
33
|
-
end
|
34
|
-
|
35
29
|
def present(object)
|
36
|
-
|
30
|
+
self.class.present object, context
|
37
31
|
end
|
38
32
|
|
39
33
|
def presented?
|
@@ -41,7 +35,7 @@ module Poser
|
|
41
35
|
end
|
42
36
|
|
43
37
|
def ==(other)
|
44
|
-
other.is_a?(
|
38
|
+
other.is_a?(self.class) && context == other.context && __getobj__ == other.__getobj__
|
45
39
|
end
|
46
40
|
|
47
41
|
end
|
data/lib/poser/util.rb
CHANGED
@@ -21,7 +21,11 @@ module Poser
|
|
21
21
|
names.shift if names.empty? || names.first.empty?
|
22
22
|
|
23
23
|
names.inject(Object) do |constant, name|
|
24
|
-
|
24
|
+
if RUBY_VERSION =~ /^1\.8/
|
25
|
+
constant.const_get name
|
26
|
+
else
|
27
|
+
constant.const_get name, false
|
28
|
+
end
|
25
29
|
end
|
26
30
|
end
|
27
31
|
end
|
data/lib/poser/version.rb
CHANGED
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Poser::EnumerablePresenter do
|
4
|
+
subject { described_class.new @presentee, @context }
|
5
|
+
|
6
|
+
before do
|
7
|
+
@presentee = mock Object
|
8
|
+
@context = mock Object
|
9
|
+
end
|
10
|
+
|
11
|
+
it { should be_a(Poser::Presenter) }
|
12
|
+
|
13
|
+
describe "each" do
|
14
|
+
it "yields each object presented" do
|
15
|
+
@presentee = [Object.new, Object.new]
|
16
|
+
|
17
|
+
yielded_objects = []
|
18
|
+
subject.each do |obj|
|
19
|
+
yielded_objects << obj
|
20
|
+
end
|
21
|
+
|
22
|
+
yielded_objects.should == [
|
23
|
+
subject.present(@presentee[0]),
|
24
|
+
subject.present(@presentee[1])
|
25
|
+
]
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: poser
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.4
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -48,6 +48,7 @@ files:
|
|
48
48
|
- lib/poser/version.rb
|
49
49
|
- poser.gemspec
|
50
50
|
- spec/poser/context_spec.rb
|
51
|
+
- spec/poser/enumerable_presenter_spec.rb
|
51
52
|
- spec/poser/presentable_spec.rb
|
52
53
|
- spec/poser/presenter_spec.rb
|
53
54
|
- spec/poser_spec.rb
|
@@ -78,6 +79,7 @@ specification_version: 3
|
|
78
79
|
summary: A minimal implementation of the presenter pattern.
|
79
80
|
test_files:
|
80
81
|
- spec/poser/context_spec.rb
|
82
|
+
- spec/poser/enumerable_presenter_spec.rb
|
81
83
|
- spec/poser/presentable_spec.rb
|
82
84
|
- spec/poser/presenter_spec.rb
|
83
85
|
- spec/poser_spec.rb
|