ruhl 0.16.0 → 0.17.0

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/VERSION CHANGED
@@ -1 +1 @@
1
- 0.16.0
1
+ 0.17.0
data/lib/ruhl/engine.rb CHANGED
@@ -156,16 +156,22 @@ module Ruhl
156
156
  throw :done
157
157
  else
158
158
  if continue_processing?
159
+ # yield if block given. otherwise do nothing and have ruhl
160
+ # continue processing
159
161
  yield if block_given?
160
162
  else
161
- process_results
163
+ if block_given?
164
+ yield
165
+ else
166
+ process_results
167
+ end
162
168
  end
163
169
  end
164
170
  end
165
171
 
166
172
  def ruhl_unless
167
173
  if call_result
168
- unless call_result_empty?
174
+ unless call_result_empty_array?
169
175
  current_tag.remove
170
176
  throw :done
171
177
  end
@@ -225,15 +231,19 @@ module Ruhl
225
231
  def stop_processing?
226
232
  call_result.nil? ||
227
233
  call_result == false ||
228
- call_result_empty?
234
+ call_result_empty_array?
229
235
  end
230
236
 
231
237
  def continue_processing?
232
- call_result == true || !call_result_empty?
238
+ call_result == true || call_result_populated_array?
233
239
  end
234
240
 
235
- def call_result_empty?
236
- call_result.kind_of?(Enumerable) && call_result.empty?
241
+ def call_result_populated_array?
242
+ call_result.kind_of?(Array) && !call_result.empty?
243
+
244
+ end
245
+ def call_result_empty_array?
246
+ call_result.kind_of?(Array) && call_result.empty?
237
247
  end
238
248
 
239
249
  def log_context(code)
data/ruhl.gemspec ADDED
@@ -0,0 +1,84 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{ruhl}
8
+ s.version = "0.17.0"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Andrew Stone"]
12
+ s.date = %q{2009-11-21}
13
+ s.description = %q{Make your HTML dynamic with the addition of a data-ruhl attribute.}
14
+ s.email = %q{andy@stonean.com}
15
+ s.extra_rdoc_files = [
16
+ "README"
17
+ ]
18
+ s.files = [
19
+ ".gitignore",
20
+ "README",
21
+ "Rakefile",
22
+ "VERSION",
23
+ "lib/ruhl.rb",
24
+ "lib/ruhl/engine.rb",
25
+ "lib/ruhl/errors.rb",
26
+ "lib/ruhl/rails.rb",
27
+ "lib/ruhl/rails/active_record.rb",
28
+ "lib/ruhl/rails/helper.rb",
29
+ "lib/ruhl/rails/ruhl_presenter.rb",
30
+ "lib/ruhl/sinatra.rb",
31
+ "ruhl.gemspec",
32
+ "spec/html/basic.html",
33
+ "spec/html/collection_of_hashes.html",
34
+ "spec/html/collection_of_strings.html",
35
+ "spec/html/form.html",
36
+ "spec/html/fragment.html",
37
+ "spec/html/hash.html",
38
+ "spec/html/if.html",
39
+ "spec/html/if_on_collection.html",
40
+ "spec/html/if_with_hash.html",
41
+ "spec/html/layout.html",
42
+ "spec/html/loop.html",
43
+ "spec/html/main_with_form.html",
44
+ "spec/html/main_with_sidebar.html",
45
+ "spec/html/medium.html",
46
+ "spec/html/parameters.html",
47
+ "spec/html/seo.html",
48
+ "spec/html/sidebar.html",
49
+ "spec/html/special.html",
50
+ "spec/html/swap.html",
51
+ "spec/html/use.html",
52
+ "spec/html/use_if.html",
53
+ "spec/rcov.opts",
54
+ "spec/ruhl_spec.rb",
55
+ "spec/spec.opts",
56
+ "spec/spec_helper.rb"
57
+ ]
58
+ s.homepage = %q{http://github.com/stonean/ruhl}
59
+ s.rdoc_options = ["--charset=UTF-8"]
60
+ s.require_paths = ["lib"]
61
+ s.rubygems_version = %q{1.3.5}
62
+ s.summary = %q{Ruby Hypertext Language}
63
+ s.test_files = [
64
+ "spec/ruhl_spec.rb",
65
+ "spec/spec_helper.rb"
66
+ ]
67
+
68
+ if s.respond_to? :specification_version then
69
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
70
+ s.specification_version = 3
71
+
72
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
73
+ s.add_runtime_dependency(%q<nokogiri>, ["= 1.4.0"])
74
+ s.add_development_dependency(%q<rspec>, [">= 0"])
75
+ else
76
+ s.add_dependency(%q<nokogiri>, ["= 1.4.0"])
77
+ s.add_dependency(%q<rspec>, [">= 0"])
78
+ end
79
+ else
80
+ s.add_dependency(%q<nokogiri>, ["= 1.4.0"])
81
+ s.add_dependency(%q<rspec>, [">= 0"])
82
+ end
83
+ end
84
+
@@ -0,0 +1,9 @@
1
+ <html>
2
+ <head>
3
+ <title>This is a title template</title>
4
+ </head>
5
+ <body>
6
+ <h1>This is the header template</h1>
7
+ <p data-ruhl="_if: hash_value"/>
8
+ </body>
9
+ </html>
data/spec/ruhl_spec.rb CHANGED
@@ -95,7 +95,7 @@ describe Ruhl do
95
95
  it_should_behave_like "having sidebar"
96
96
 
97
97
  it "should update the h1" do
98
- puts @doc.xpath("//div[@id='main']").first.children[1].
98
+ @doc.xpath("//div[@id='main']").first.children[1].
99
99
  inner_html.should == "Welcome to the Home page"
100
100
  end
101
101
  end
@@ -154,6 +154,27 @@ describe Ruhl do
154
154
 
155
155
  it_should_behave_like "if with users"
156
156
  end
157
+
158
+ describe "hash returned" do
159
+ before do
160
+ class ContextObject
161
+ def users?
162
+ true
163
+ end
164
+ end
165
+
166
+ @html = File.read html(:if_with_hash)
167
+ @doc = create_doc
168
+ end
169
+
170
+ it "should use hash appropriately" do
171
+ ptag = @doc.xpath("/html/body/p").first
172
+ ptag["class"].should == "pretty"
173
+ ptag["id"].should == "8675309"
174
+ ptag.inner_html.should=="jenny"
175
+ end
176
+ end
177
+
157
178
  end
158
179
 
159
180
  describe "if_on_collection.html" do
data/spec/spec_helper.rb CHANGED
@@ -206,6 +206,9 @@ class ContextObject
206
206
  {:value => 'WY', :inner_html => 'Wyoming'}]
207
207
  end
208
208
 
209
+ def hash_value
210
+ {:class => "pretty", :id => "8675309", :inner_html => "jenny"}
211
+ end
209
212
 
210
213
  end
211
214
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruhl
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.16.0
4
+ version: 0.17.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Stone
@@ -53,6 +53,7 @@ files:
53
53
  - lib/ruhl/rails/helper.rb
54
54
  - lib/ruhl/rails/ruhl_presenter.rb
55
55
  - lib/ruhl/sinatra.rb
56
+ - ruhl.gemspec
56
57
  - spec/html/basic.html
57
58
  - spec/html/collection_of_hashes.html
58
59
  - spec/html/collection_of_strings.html
@@ -61,6 +62,7 @@ files:
61
62
  - spec/html/hash.html
62
63
  - spec/html/if.html
63
64
  - spec/html/if_on_collection.html
65
+ - spec/html/if_with_hash.html
64
66
  - spec/html/layout.html
65
67
  - spec/html/loop.html
66
68
  - spec/html/main_with_form.html