erector-rails4 0.0.1 → 0.0.2

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: 8d7ab718f35dd1c6ddbc0f0a94c9a5970a640409
4
- data.tar.gz: f5845d25690158ac26bb5a93b15dfe26f8ae89c4
3
+ metadata.gz: 698a798895f015322b464b08fa3fa1ee83921818
4
+ data.tar.gz: ab61ab0f8af649554dd0c3b70fbdabe565ef159f
5
5
  SHA512:
6
- metadata.gz: 14a5c297ce93d70031a2fd4256b4b59bf24cbe96062dffe710696e6ac2052b9608572394d70039af2f8b366d92b51fde1eb6ac1ac551593ca44a6fa6e370b51e
7
- data.tar.gz: 9acefa6d9f2baf9dec0f2a1629b0084f4d37d15f39b9fa28a674f9c57be3c3f9991c0a3d25c9d3a52f25d83aefff7bca3136103c17619ada35d19ac6378d07de
6
+ metadata.gz: 9848215dcb48b74b4a39de690d00ddcd5da95f2426c53252fd81390d0032cb460c01df0ec586a8bd5279e3cabdbd77ef35aa63735b36d3dafd091e2f16c3573a
7
+ data.tar.gz: ba35747f63989b18c9d248000a20b1e8195923089ac9fe15d4c7b4b71ec40448d1059441b6161c70c9e102bbb8050b92634f4f39b7891da4514f39f529cd7578
data/.gitignore CHANGED
@@ -7,4 +7,5 @@ spec/dummy/tmp/
7
7
  spec/dummy/.sass-cache
8
8
  spec/dummy/public/uploads/*
9
9
  tmp/*
10
- coverage/*
10
+ coverage/*
11
+ *.gem
data/.travis.yml CHANGED
@@ -1,5 +1,8 @@
1
1
  language: ruby
2
2
  cache: bundler
3
+ script: bundle exec rspec
4
+ notifications:
5
+ email: false
3
6
 
4
7
  rvm:
5
8
  - 2.0.0
data/Gemfile.lock CHANGED
@@ -96,6 +96,9 @@ GEM
96
96
  sexp_processor (~> 4.1)
97
97
  sass (3.2.12)
98
98
  sexp_processor (4.4.0)
99
+ simple_form (3.0.1)
100
+ actionpack (>= 4.0.0, < 4.1)
101
+ activemodel (>= 4.0.0, < 4.1)
99
102
  simplecov (0.7.1)
100
103
  multi_json (~> 1.0)
101
104
  simplecov-html (~> 0.7.1)
@@ -139,5 +142,6 @@ DEPENDENCIES
139
142
  rr
140
143
  rspec-rails (= 2.12.2)
141
144
  sass
145
+ simple_form
142
146
  sqlite3
143
147
  wrong (>= 0.5.4)
data/LICENSE.md ADDED
@@ -0,0 +1,20 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2013 Adam Becker
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
6
+ this software and associated documentation files (the "Software"), to deal in
7
+ the Software without restriction, including without limitation the rights to
8
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9
+ the Software, and to permit persons to whom the Software is furnished to do so,
10
+ subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17
+ FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18
+ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md CHANGED
@@ -1,4 +1,10 @@
1
- Erector for Rails 4 [![Build Status](https://travis-ci.org/adamjacobbecker/erector-rails4.png?branch=master)](https://travis-ci.org/adamjacobbecker/erector-rails4) [![Coverage Status](https://coveralls.io/repos/adamjacobbecker/erector-rails4/badge.png)](https://coveralls.io/r/adamjacobbecker/erector-rails4)
1
+ Erector for Rails 4
2
2
  =====
3
3
 
4
+ [![Gem Version](https://badge.fury.io/rb/erector-rails4.png)](http://badge.fury.io/rb/erector-rails4) [![Build Status](https://travis-ci.org/adamjacobbecker/erector-rails4.png?branch=master)](https://travis-ci.org/adamjacobbecker/erector-rails4) [![Coverage Status](https://coveralls.io/repos/adamjacobbecker/erector-rails4/badge.png)](https://coveralls.io/r/adamjacobbecker/erector-rails4) [![Code Climate](https://codeclimate.com/github/adamjacobbecker/erector-rails4.png)](https://codeclimate.com/github/adamjacobbecker/erector-rails4)
5
+
4
6
  This is a fork of [Erector](https://github.com/erector/erector) with a lotta old crap removed. Currently under active development, but in regular use at [DOBT](https://www.github.com/dobtco).
7
+
8
+ ```ruby
9
+ gem 'erector-rails4', require: 'erector'
10
+ ```
@@ -30,6 +30,7 @@ Gem::Specification.new do |s|
30
30
  s.add_development_dependency 'rr'
31
31
  s.add_development_dependency 'rspec-rails', '2.12.2'
32
32
  s.add_development_dependency 'sass'
33
+ s.add_development_dependency 'simple_form'
33
34
  s.add_development_dependency 'sqlite3'
34
35
  s.add_development_dependency 'wrong', ">=0.5.4"
35
36
 
data/lib/erector/rails.rb CHANGED
@@ -53,11 +53,11 @@ module Erector
53
53
  METHOD_DEF
54
54
  end
55
55
 
56
- def def_rails_form_helper(method_name)
56
+ def def_rails_form_helper(method_name, explicit_builder = nil)
57
57
  module_eval <<-METHOD_DEF, __FILE__, __LINE__+1
58
58
  def #{method_name}(*args, &block)
59
59
  options = args.extract_options!
60
- args << options.merge(:builder => FormBuilder.wrapping(options[:builder]))
60
+ args << options.merge(:builder => FormBuilder.wrapping(#{explicit_builder || 'options[:builder]'}))
61
61
  text helpers.#{method_name}(*args, &block)
62
62
  end
63
63
  METHOD_DEF
@@ -216,6 +216,10 @@ module Erector
216
216
  def_rails_form_helper(method_name)
217
217
  end
218
218
 
219
+ [:simple_form_for, :simple_fields_for].each do |method_name|
220
+ def_rails_form_helper(method_name, "SimpleForm::FormBuilder")
221
+ end
222
+
219
223
  Erector::Widget.send :include, self
220
224
  end
221
225
  end
@@ -1,5 +1,5 @@
1
1
  # Erector view framework
2
2
  module Erector
3
- VERSION = "0.0.1"
3
+ VERSION = "0.0.2"
4
4
  end
5
5
 
@@ -1,3 +1,4 @@
1
1
  class ApplicationController < ActionController::Base
2
2
  protect_from_forgery
3
+ include ApplicationHelper
3
4
  end
@@ -1,2 +1,7 @@
1
1
  module ApplicationHelper
2
+
3
+ def user_role
4
+ 'admin'
5
+ end
6
+
2
7
  end
@@ -0,0 +1,6 @@
1
+ class Views::Test::SimpleForm < Erector::Widget
2
+ def content
3
+ simple_form_for :foo do |f|
4
+ end
5
+ end
6
+ end
@@ -1,8 +1,9 @@
1
1
  require File.expand_path("#{File.dirname(__FILE__)}/rails_spec_helper")
2
+ require 'simple_form'
2
3
 
3
4
  describe Erector::Rails do
4
5
  before do
5
- @controller = ActionController::Base.new
6
+ @controller = ApplicationController.new
6
7
  @controller.request = ActionController::TestRequest.new
7
8
 
8
9
  @view = ActionView::Base.new
@@ -17,6 +18,16 @@ describe Erector::Rails do
17
18
  Erector::Rails.render(Erector.inline(&block), @controller.view_context)
18
19
  end
19
20
 
21
+ describe "a non-output helper" do
22
+ it "does not render to the output buffer" do
23
+ test_render do
24
+ if user_role == 'admin'
25
+ text 'foo'
26
+ end
27
+ end.should == %{foo}
28
+ end
29
+ end
30
+
20
31
  describe "#link_to" do
21
32
  it "renders a link" do
22
33
  test_render do
@@ -233,4 +244,15 @@ describe Erector::Rails do
233
244
  end.should =~ /foo/
234
245
  end
235
246
  end
247
+
248
+ describe "#simple_form_for" do
249
+ it "instantiates a SimpleForm builder" do
250
+ test_render do
251
+ simple_form_for(:something, :url => "/test") do |form|
252
+ form.input :foobar
253
+ end
254
+ end.should =~ /foobar/
255
+ end
256
+ end
257
+
236
258
  end
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.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alex Chaffee
@@ -127,6 +127,20 @@ dependencies:
127
127
  - - '>='
128
128
  - !ruby/object:Gem::Version
129
129
  version: '0'
130
+ - !ruby/object:Gem::Dependency
131
+ name: simple_form
132
+ requirement: !ruby/object:Gem::Requirement
133
+ requirements:
134
+ - - '>='
135
+ - !ruby/object:Gem::Version
136
+ version: '0'
137
+ type: :development
138
+ prerelease: false
139
+ version_requirements: !ruby/object:Gem::Requirement
140
+ requirements:
141
+ - - '>='
142
+ - !ruby/object:Gem::Version
143
+ version: '0'
130
144
  - !ruby/object:Gem::Dependency
131
145
  name: sqlite3
132
146
  requirement: !ruby/object:Gem::Requirement
@@ -169,6 +183,7 @@ files:
169
183
  - .travis.yml
170
184
  - Gemfile
171
185
  - Gemfile.lock
186
+ - LICENSE.md
172
187
  - README.md
173
188
  - Rakefile
174
189
  - erector-rails4.gemspec
@@ -230,6 +245,7 @@ files:
230
245
  - spec/dummy/app/views/test/render_partial.html.rb
231
246
  - spec/dummy/app/views/test/render_with_widget_as_layout.rb
232
247
  - spec/dummy/app/views/test/render_with_widget_as_layout_using_content_for.rb
248
+ - spec/dummy/app/views/test/simple_form.html.rb
233
249
  - spec/dummy/config.ru
234
250
  - spec/dummy/config/application.rb
235
251
  - spec/dummy/config/boot.rb
@@ -322,6 +338,7 @@ test_files:
322
338
  - spec/dummy/app/views/test/render_partial.html.rb
323
339
  - spec/dummy/app/views/test/render_with_widget_as_layout.rb
324
340
  - spec/dummy/app/views/test/render_with_widget_as_layout_using_content_for.rb
341
+ - spec/dummy/app/views/test/simple_form.html.rb
325
342
  - spec/dummy/config.ru
326
343
  - spec/dummy/config/application.rb
327
344
  - spec/dummy/config/boot.rb