erector-rails4 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: cf70db8bc4222c447f5b7d613fd029da5936df19
4
- data.tar.gz: b584d63e1e6a78cb7ea1da565859e210a42735c3
3
+ metadata.gz: e211a8ac04b10af2252d4713e0ce8ec22424a8ba
4
+ data.tar.gz: c301fdd53d28c30c6d68da8d9c9ca8b5eef52f5e
5
5
  SHA512:
6
- metadata.gz: 09e3d1a72dda9f47c330b52b929c3ba51b95b011929cd72a1b5e6eb2f84d36028842c77da94e48040346e8204e73752f9f273cca7ce137b1d3bd1ce58efb6722
7
- data.tar.gz: 611d90b3a8949e4fca8ea50d887de30aae31bcb54d505aaab870e6a22b159624c31292854249ebb554cbe2349406c10b8881063ce2ff2f64f1e17cf9ef2992b3
6
+ metadata.gz: 0a559f5f718628a692414c3a6c5f36144975db97828841ca0f9bb3ec6756e72ea739df674c91dc21c30f30cf7566785a8f7390a0d4ec698dc2e72cf5f1a1a270
7
+ data.tar.gz: d03c8b61cf5365588e4fc18fdb4afe72c70ffc853580690beb10a8c2366a3673d98d9f1b3b9d3f08bd008a78847e44ac157883e0c978117297ba6ad3528b9ecf
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- erector-rails4 (0.0.2)
4
+ erector-rails4 (0.0.4)
5
5
  rails (>= 4.0)
6
6
  treetop (>= 1.2.3)
7
7
 
@@ -2,7 +2,7 @@ module Erector
2
2
  def self.inline(*args, &block)
3
3
  InlineWidget.new(*args, &block)
4
4
  end
5
-
5
+
6
6
  module Inline
7
7
  # Executes the widget's block (the one that was passed in the
8
8
  # constructor). Since "self" is pointing to the new widget, the block does
@@ -17,6 +17,17 @@ module Erector
17
17
  # note that instance_eval seems to pass in self as a parameter to the block
18
18
  instance_eval(&block) if block
19
19
  end
20
+
21
+ private
22
+ # This is part of the sub-widget/parent feature (see #widget method).
23
+ def method_missing(name, *args, &block)
24
+ if parent && parent.respond_to?(name)
25
+ block ||= lambda {} # captures self HERE
26
+ parent.send(name, *args, &block)
27
+ else
28
+ super
29
+ end
30
+ end
20
31
  end
21
32
 
22
33
  class InlineWidget < Widget
data/lib/erector/rails.rb CHANGED
@@ -43,6 +43,16 @@ module Erector
43
43
  end
44
44
  end
45
45
 
46
+ # Wrappers for rails helpers that produce markup. Erector needs to
47
+ # manually emit their result.
48
+ def def_simple_rails_helper(method_name)
49
+ module_eval <<-METHOD_DEF, __FILE__, __LINE__+1
50
+ def #{method_name}(*args, &block)
51
+ text helpers.#{method_name}(*args, &block)
52
+ end
53
+ METHOD_DEF
54
+ end
55
+
46
56
  def def_rails_form_helper(method_name, explicit_builder = nil)
47
57
  module_eval <<-METHOD_DEF, __FILE__, __LINE__+1
48
58
  def #{method_name}(*args, &block)
@@ -124,13 +134,7 @@ module Erector
124
134
  # and output return values that are html_safe
125
135
  def method_missing(name, *args, &block)
126
136
  if helpers.respond_to?(name)
127
- return_value = helpers.send(name, *args, &block)
128
-
129
- if return_value.try(:html_safe?)
130
- text return_value
131
- else
132
- return_value
133
- end
137
+ helpers.send(name, *args, &block)
134
138
  else
135
139
  super
136
140
  end
@@ -142,6 +146,72 @@ module Erector
142
146
  super || helpers.respond_to?(name)
143
147
  end
144
148
 
149
+ [
150
+ # UrlHelper
151
+ :link_to,
152
+ :button_to,
153
+ :link_to_unless_current,
154
+ :link_to_unless,
155
+ :link_to_if,
156
+ :mail_to,
157
+
158
+ # FormTagHelper
159
+ :form_tag,
160
+ :select_tag,
161
+ :text_field_tag,
162
+ :label_tag,
163
+ :hidden_field_tag,
164
+ :file_field_tag,
165
+ :password_field_tag,
166
+ :text_area_tag,
167
+ :check_box_tag,
168
+ :radio_button_tag,
169
+ :submit_tag,
170
+ :image_submit_tag,
171
+ :field_set_tag,
172
+
173
+ # FormHelper
174
+ :form_for,
175
+ :text_field,
176
+ :password_field,
177
+ :hidden_field,
178
+ :file_field,
179
+ :text_area,
180
+ :check_box,
181
+ :radio_button,
182
+
183
+ # AssetTagHelper
184
+ :auto_discovery_link_tag,
185
+ :javascript_include_tag,
186
+ :stylesheet_link_tag,
187
+ :favicon_link_tag,
188
+ :image_tag,
189
+
190
+ # ScriptaculousHelper
191
+ :sortable_element,
192
+ :sortable_element_js,
193
+ :text_field_with_auto_complete,
194
+ :draggable_element,
195
+ :drop_receiving_element,
196
+
197
+ # PrototypeHelper
198
+ :link_to_remote,
199
+ :button_to_remote,
200
+ :periodically_call_remote,
201
+ :form_remote_tag,
202
+ :submit_to_remote,
203
+ :update_page_tag,
204
+
205
+ # JavaScriptHelper
206
+ :javascript_tag,
207
+
208
+ # CsrfHelper
209
+ :csrf_meta_tag,
210
+ :csrf_meta_tags
211
+ ].each do |method_name|
212
+ def_simple_rails_helper(method_name)
213
+ end
214
+
145
215
  [:form_for, :fields_for].each do |method_name|
146
216
  def_rails_form_helper(method_name)
147
217
  end
@@ -1,3 +1,3 @@
1
1
  module Erector
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
@@ -40,26 +40,6 @@ describe Erector::Rails do
40
40
  end
41
41
  end
42
42
 
43
- describe "a helper intended to output" do
44
- it "renders when called" do
45
- test_render do
46
- user_role_safe
47
- end.should == %{admin}
48
- end
49
-
50
- it "cannot be combined directly with a built-in method" do
51
- test_render do
52
- image_tag user_role_safe
53
- end.should == %{admin<img src="" />}
54
- end
55
-
56
- it "can be combined with a built-in method by using capture" do
57
- test_render do
58
- image_tag capture {user_role_safe}
59
- end.should == %{<img alt="Admin" src="/images/admin" />}
60
- end
61
- end
62
-
63
43
  describe "#link_to" do
64
44
  it "renders a link" do
65
45
  test_render do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: erector-rails4
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alex Chaffee