lilu 0.1.0 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/lib/lilu.rb +7 -3
  2. data/spec/lilu_spec.rb +15 -0
  3. metadata +3 -3
@@ -44,7 +44,7 @@ class Hpricot::Elem
44
44
  end
45
45
  module Lilu
46
46
 
47
- module Version ; MAJOR, MINOR, TINY = 0, 1, 0 ; end
47
+ module Version ; MAJOR, MINOR, TINY = 0, 1, 2 ; end
48
48
 
49
49
  class Action
50
50
  attr_accessor :element
@@ -57,6 +57,10 @@ module Lilu
57
57
 
58
58
 
59
59
  class Populate < Action
60
+ def method_missing(sym,*args)
61
+ send :for, sym, *args
62
+ end
63
+
60
64
  def for(method,data,&block)
61
65
  return element.collect {|e| self.element = e ; renderer.instance_eval { action.for(method,data,&block) } } if element.is_a?(Hpricot::Elements)
62
66
 
@@ -68,7 +72,7 @@ module Lilu
68
72
  update_action.element = element
69
73
  update_action.with(block.call(*objects))
70
74
 
71
- parent.insert_after(Hpricot.make(element.to_html),element)
75
+ parent.insert_before(Hpricot.make(element.to_html),element)
72
76
  element = Hpricot.make(element_html)
73
77
  end
74
78
  renderer.action = self
@@ -116,7 +120,7 @@ module Lilu
116
120
  case path
117
121
  when String
118
122
  elem = element.at(path)
119
- raise ElementNotFound.new("Element #{elem} not found") unless elem
123
+ raise ElementNotFound.new(elem) unless elem
120
124
 
121
125
  saved_element = element
122
126
  self.element = elem
@@ -78,6 +78,8 @@ describe Lilu::Renderer do
78
78
  result = Hpricot(@renderer.apply)
79
79
  result.at("#some-lilu-data").inner_html.should == "Lola <a href=\"/\">is here</a>"
80
80
  end
81
+
82
+
81
83
 
82
84
  it "should populate element details on populate(path).for(:each,@blogs) { block } construct" do
83
85
  @blogs = [OpenStruct.new(:url => "http://railsware.com", :blog_id => 1, :name => "Railsware"),OpenStruct.new(:url => "http://railsware.com/", :blog_id => 2, :name => "Railsware!")]
@@ -88,6 +90,9 @@ describe Lilu::Renderer do
88
90
  result.at("#blogs/#2/a")[:href].should == "http://railsware.com/"
89
91
  result.at("#blogs/#1/a").inner_html.should == "Railsware"
90
92
  result.at("#blogs/#blog-example").should be_nil
93
+ li_items = result.search("li")
94
+ li_items.first[:id].should == "1"
95
+ li_items.last[:id].should == "2"
91
96
  end
92
97
 
93
98
  it "should populate element details on populate(:all,path).for(:each,@blogs) { block } construct" do
@@ -221,3 +226,13 @@ describe Lilu::Renderer do
221
226
  end
222
227
 
223
228
  end
229
+
230
+ describe Lilu::Populate do
231
+ it "should send for(missed_name,*args) on a missed_name(*args)" do
232
+ populate = Lilu::Populate.new(nil,Lilu::Renderer.new(nil,""))
233
+ [:each,:any].each do |sym|
234
+ populate.should_receive(:for).with(sym,anything(),anything(),anything())
235
+ populate.send sym, 1,2,3
236
+ end
237
+ end
238
+ end
metadata CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.9.2
3
3
  specification_version: 1
4
4
  name: lilu
5
5
  version: !ruby/object:Gem::Version
6
- version: 0.1.0
7
- date: 2007-05-16 00:00:00 +03:00
6
+ version: 0.1.2
7
+ date: 2007-06-30 00:00:00 +02:00
8
8
  summary: View subsystem that allows to keep pure HTML for views
9
9
  require_paths:
10
10
  - lib
@@ -50,6 +50,6 @@ executables: []
50
50
  extensions: []
51
51
 
52
52
  requirements:
53
- - hprico
53
+ - hpricot
54
54
  dependencies: []
55
55