renshi 0.1.7 → 0.1.8

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/README CHANGED
@@ -142,6 +142,10 @@ Other Rules
142
142
  ===========
143
143
  To print a $ use $$, e.g. $$10.95 comes out as $10.95
144
144
 
145
+ Because the $foo evaluation can take all sorts of symbols to interpret a ruby statement, if you are using a special symbol *immediately* before it, you'll have to use #{foo} instead.
146
+
147
+ For example, because $"hello".upcase works, if you want to do "$"hello".upcase" to produce "HELLO" you'll need to use "${"hello".upcase}" instead.
148
+
145
149
  Installation
146
150
  ============
147
151
  Renshi is hosted on Rubyforge so 'sudo gem install renshi'. Alternatively, use github to do what you want with it.
@@ -3,7 +3,8 @@ module Renshi
3
3
  class Each
4
4
  def evaluate(expression, node)
5
5
  bits = expression.split(",")
6
- node.open_clause("#{bits[0]}.each do #{bits[1]}")
6
+
7
+ node.open_clause("#{bits[0]}.each do #{bits[1..-1].join(',')}")
7
8
  node.close_clause("end")
8
9
  end
9
10
  end
data/lib/renshi.rb CHANGED
@@ -9,7 +9,7 @@ require 'renshi/attribute_expressions'
9
9
  require 'renshi/frameworks'
10
10
 
11
11
  module Renshi
12
- VERSION="0.1.7"
12
+ VERSION="0.1.8"
13
13
 
14
14
  class SyntaxError < StandardError; end
15
15
  end
data/spec/each_spec.rb CHANGED
@@ -12,4 +12,23 @@ describe Renshi::Parser do
12
12
  (doc/"span[@id='red1']").text.strip.should eql "hello1"
13
13
  (doc/"span[@id='red2']").text.strip.should eql "hello2"
14
14
  end
15
+
16
+
17
+ class Foo
18
+ attr_accessor :results
19
+ def initialize
20
+ @results = {"earth" => {"hello" => "world"}}
21
+ end
22
+ end
23
+ # <li r:each="@sphinx_results.results[:words], |k,v|">
24
+ # $k - Hits $v[:hits] in $v[:docs] documents
25
+ # </li>
26
+ it "should evaluate complex r:each" do
27
+ str = %Q!<div id="test"><li r:each="@foo.results['earth'], |k,v|">$k $v</li></div>!
28
+ @foo = Foo.new
29
+ compiled = Renshi::Parser.parse(str)
30
+ doc = eval(compiled, binding)
31
+ doc = N(doc)
32
+ (doc/"div[@id='test']").text.strip.should =~ /hello world/
33
+ end
15
34
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: renshi
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.7
4
+ version: 0.1.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nicholas Faiz
@@ -9,7 +9,7 @@ autorequire: renshi
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-08-25 00:00:00 +10:00
12
+ date: 2009-08-26 00:00:00 +10:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency