forme 0.6.0 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +28 -0
- data/MIT-LICENSE +1 -1
- data/README.rdoc +18 -2
- data/Rakefile +14 -8
- data/lib/forme.rb +65 -14
- data/lib/forme/rails.rb +99 -0
- data/lib/forme/sinatra.rb +41 -23
- data/lib/forme/version.rb +1 -1
- data/lib/sequel/plugins/forme.rb +22 -10
- data/spec/forme_spec.rb +44 -0
- data/spec/rails_integration_spec.rb +195 -0
- data/spec/sequel_helper.rb +71 -0
- data/spec/sequel_plugin_spec.rb +41 -96
- data/spec/sinatra_integration_spec.rb +94 -2
- metadata +31 -44
@@ -1,4 +1,5 @@
|
|
1
1
|
require File.join(File.dirname(File.expand_path(__FILE__)), 'spec_helper.rb')
|
2
|
+
require File.join(File.dirname(File.expand_path(__FILE__)), 'sequel_helper.rb')
|
2
3
|
|
3
4
|
require 'rubygems'
|
4
5
|
require 'sinatra/base'
|
@@ -6,7 +7,7 @@ require 'forme/sinatra'
|
|
6
7
|
require(ENV['ERUBIS'] ? 'erubis' : 'erb')
|
7
8
|
|
8
9
|
class FormeSinatraTest < Sinatra::Base
|
9
|
-
helpers(
|
10
|
+
helpers(Forme::Sinatra::ERB)
|
10
11
|
disable :show_exceptions
|
11
12
|
enable :raise_errors
|
12
13
|
|
@@ -16,6 +17,27 @@ class FormeSinatraTest < Sinatra::Base
|
|
16
17
|
<p>FBB</p>
|
17
18
|
<%= f.input(:first) %>
|
18
19
|
<%= f.input(:last) %>
|
20
|
+
<%= f.button('Save') %>
|
21
|
+
<% end %>
|
22
|
+
END
|
23
|
+
end
|
24
|
+
|
25
|
+
get '/inputs_block' do
|
26
|
+
erb <<END
|
27
|
+
<% form([:foo, :bar], :action=>'/baz') do |f| %>
|
28
|
+
<% f.inputs(:legend=>'FBB') do %>
|
29
|
+
<%= f.input(:last) %>
|
30
|
+
<% end %>
|
31
|
+
<% end %>
|
32
|
+
END
|
33
|
+
end
|
34
|
+
|
35
|
+
get '/inputs_block_wrapper' do
|
36
|
+
erb <<END
|
37
|
+
<% form([:foo, :bar], {:action=>'/baz'}, :inputs_wrapper=>:fieldset_ol) do |f| %>
|
38
|
+
<% f.inputs(:legend=>'FBB') do %>
|
39
|
+
<%= f.input(:last) %>
|
40
|
+
<% end %>
|
19
41
|
<% end %>
|
20
42
|
END
|
21
43
|
end
|
@@ -33,6 +55,59 @@ END
|
|
33
55
|
END
|
34
56
|
end
|
35
57
|
|
58
|
+
get '/nest_sep' do
|
59
|
+
@nest = <<END
|
60
|
+
n1
|
61
|
+
<% f.tag(:div) do %>
|
62
|
+
n2
|
63
|
+
<%= f.input(:first) %>
|
64
|
+
<%= f.input(:last) %>
|
65
|
+
n3
|
66
|
+
<% end %>
|
67
|
+
n4
|
68
|
+
<%= f.inputs([:first, :last], :legend=>'Foo') %>
|
69
|
+
n5
|
70
|
+
END
|
71
|
+
erb <<END
|
72
|
+
0
|
73
|
+
<% form([:foo, :bar], :action=>'/baz') do |f| %>
|
74
|
+
1
|
75
|
+
<%= f.tag(:p, {}, 'FBB') %>
|
76
|
+
2
|
77
|
+
<%= erb(@nest, :locals=>{:f=>f}) %>
|
78
|
+
3
|
79
|
+
<% end %>
|
80
|
+
4
|
81
|
+
END
|
82
|
+
end
|
83
|
+
|
84
|
+
get '/nest_seq' do
|
85
|
+
@album = Album.load(:name=>'N', :copies_sold=>2, :id=>1)
|
86
|
+
@album.associations[:artist] = Artist.load(:name=>'A', :id=>2)
|
87
|
+
@nest = <<END
|
88
|
+
n1
|
89
|
+
<% f.subform(:artist) do %>
|
90
|
+
n2
|
91
|
+
<%= f.input(:name2) %>
|
92
|
+
n3
|
93
|
+
<% end %>
|
94
|
+
n4
|
95
|
+
<%= f.subform(:artist, :inputs=>[:name3], :legend=>'Bar') %>
|
96
|
+
n5
|
97
|
+
END
|
98
|
+
erb <<END
|
99
|
+
0
|
100
|
+
<% form(@album, :action=>'/baz') do |f| %>
|
101
|
+
1
|
102
|
+
<%= f.subform(:artist, :inputs=>[:name], :legend=>'Foo') %>
|
103
|
+
2
|
104
|
+
<%= erb(@nest, :locals=>{:f=>f}) %>
|
105
|
+
3
|
106
|
+
<% end %>
|
107
|
+
4
|
108
|
+
END
|
109
|
+
end
|
110
|
+
|
36
111
|
get '/hash' do
|
37
112
|
erb "<% form({:action=>'/baz'}, :obj=>[:foo]) do |f| %> <%= f.input(:first) %> <% end %>"
|
38
113
|
end
|
@@ -70,14 +145,31 @@ describe "Forme Sinatra ERB integration" do
|
|
70
145
|
def o.puts(*) end
|
71
146
|
@rack = {'rack.input'=>'', 'REQUEST_METHOD'=>'GET', 'rack.errors'=>o}
|
72
147
|
end
|
148
|
+
|
73
149
|
specify "#form should add start and end tags and yield Forme::Form instance" do
|
74
|
-
sin_get('/').should == '<form action="/baz"> <p>FBB</p> <input id="first" name="first" type="text" value="foo"/> <input id="last" name="last" type="text" value="bar"/> </form>'
|
150
|
+
sin_get('/').should == '<form action="/baz"> <p>FBB</p> <input id="first" name="first" type="text" value="foo"/> <input id="last" name="last" type="text" value="bar"/> <input type="submit" value="Save"/> </form>'
|
151
|
+
end
|
152
|
+
|
153
|
+
specify "#form should have inputs work with a block" do
|
154
|
+
sin_get('/inputs_block').should == '<form action="/baz"><fieldset class="inputs"><legend>FBB</legend> <input id="last" name="last" type="text" value="bar"/> </fieldset></form>'
|
155
|
+
end
|
156
|
+
|
157
|
+
specify "#form should have inputs with fieldset_ol wrapper work with block" do
|
158
|
+
sin_get('/inputs_block_wrapper').should == '<form action="/baz"><fieldset class="inputs"><legend>FBB</legend><ol> <input id="last" name="last" type="text" value="bar"/> </ol></fieldset></form>'
|
75
159
|
end
|
76
160
|
|
77
161
|
specify "#form should add start and end tags and yield Forme::Form instance" do
|
78
162
|
sin_get('/nest').should == '<form action="/baz"> <p>FBB</p> <div> <input id="first" name="first" type="text" value="foo"/> <input id="last" name="last" type="text" value="bar"/> </div> </form>'
|
79
163
|
end
|
80
164
|
|
165
|
+
specify "#form should correctly handle situation where multiple templates are used with same form object" do
|
166
|
+
sin_get('/nest_sep').should == "0 <form action=\"/baz\"> 1 <p>FBB</p> 2 n1 <div> n2 <input id=\"first\" name=\"first\" type=\"text\" value=\"foo\"/> <input id=\"last\" name=\"last\" type=\"text\" value=\"bar\"/> n3 </div> n4 <fieldset class=\"inputs\"><legend>Foo</legend><input id=\"first\" name=\"first\" type=\"text\" value=\"foo\"/><input id=\"last\" name=\"last\" type=\"text\" value=\"bar\"/></fieldset> n5 3 </form>4"
|
167
|
+
end
|
168
|
+
|
169
|
+
specify "#form should correctly handle situation Sequel integration with subforms where multiple templates are used with same form object" do
|
170
|
+
sin_get('/nest_seq').should == "0 <form action=\"/baz\" class=\"forme album\" method=\"post\"> 1 <input id=\"album_artist_attributes_id\" name=\"album[artist_attributes][id]\" type=\"hidden\" value=\"2\"/><fieldset class=\"inputs\"><legend>Foo</legend><label>Name: <input id=\"album_artist_attributes_name\" name=\"album[artist_attributes][name]\" type=\"text\" value=\"A\"/></label></fieldset> 2 n1 <input id=\"album_artist_attributes_id\" name=\"album[artist_attributes][id]\" type=\"hidden\" value=\"2\"/> n2 <label>Name2: <input id=\"album_artist_attributes_name2\" name=\"album[artist_attributes][name2]\" type=\"text\" value=\"A2\"/></label> n3 n4 <input id=\"album_artist_attributes_id\" name=\"album[artist_attributes][id]\" type=\"hidden\" value=\"2\"/><fieldset class=\"inputs\"><legend>Bar</legend><label>Name3: <input id=\"album_artist_attributes_name3\" name=\"album[artist_attributes][name3]\" type=\"text\" value=\"A3\"/></label></fieldset> n5 3 </form>4"
|
171
|
+
end
|
172
|
+
|
81
173
|
specify "#form should accept two hashes instead of requiring obj as first argument" do
|
82
174
|
sin_get('/hash').should == '<form action="/baz"> <input id="first" name="first" type="text" value="foo"/> </form>'
|
83
175
|
end
|
metadata
CHANGED
@@ -1,42 +1,36 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: forme
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
prerelease:
|
6
|
-
segments:
|
7
|
-
- 0
|
8
|
-
- 6
|
9
|
-
- 0
|
10
|
-
version: 0.6.0
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.7.0
|
5
|
+
prerelease:
|
11
6
|
platform: ruby
|
12
|
-
authors:
|
7
|
+
authors:
|
13
8
|
- Jeremy Evans
|
14
9
|
autorequire:
|
15
10
|
bindir: bin
|
16
11
|
cert_chain: []
|
17
|
-
|
18
|
-
date: 2011-08-01 00:00:00 -07:00
|
19
|
-
default_executable:
|
12
|
+
date: 2012-05-02 00:00:00.000000000 Z
|
20
13
|
dependencies: []
|
14
|
+
description: ! 'Forme is a forms library with the following goals:
|
15
|
+
|
21
16
|
|
22
|
-
description: |
|
23
|
-
Forme is a forms library with the following goals:
|
24
|
-
|
25
17
|
1) Have no external dependencies
|
18
|
+
|
26
19
|
2) Have a simple API
|
20
|
+
|
27
21
|
3) Support forms both with and without related objects
|
22
|
+
|
28
23
|
4) Allow compiling down to different types of output
|
29
24
|
|
25
|
+
'
|
30
26
|
email: code@jeremyevans.net
|
31
27
|
executables: []
|
32
|
-
|
33
28
|
extensions: []
|
34
|
-
|
35
|
-
extra_rdoc_files:
|
29
|
+
extra_rdoc_files:
|
36
30
|
- README.rdoc
|
37
31
|
- CHANGELOG
|
38
32
|
- MIT-LICENSE
|
39
|
-
files:
|
33
|
+
files:
|
40
34
|
- MIT-LICENSE
|
41
35
|
- CHANGELOG
|
42
36
|
- README.rdoc
|
@@ -45,49 +39,42 @@ files:
|
|
45
39
|
- spec/spec_helper.rb
|
46
40
|
- spec/sequel_plugin_spec.rb
|
47
41
|
- spec/sinatra_integration_spec.rb
|
42
|
+
- spec/sequel_helper.rb
|
43
|
+
- spec/rails_integration_spec.rb
|
48
44
|
- lib/forme.rb
|
49
45
|
- lib/forme/version.rb
|
50
46
|
- lib/forme/sinatra.rb
|
47
|
+
- lib/forme/rails.rb
|
51
48
|
- lib/sequel/plugins/forme.rb
|
52
|
-
has_rdoc: true
|
53
49
|
homepage: http://gihub.com/jeremyevans/forme
|
54
50
|
licenses: []
|
55
|
-
|
56
51
|
post_install_message:
|
57
|
-
rdoc_options:
|
52
|
+
rdoc_options:
|
58
53
|
- --quiet
|
59
54
|
- --line-numbers
|
60
55
|
- --inline-source
|
61
56
|
- --title
|
62
|
-
-
|
57
|
+
- ! 'Forme: HTML forms library'
|
63
58
|
- --main
|
64
59
|
- README.rdoc
|
65
|
-
require_paths:
|
60
|
+
require_paths:
|
66
61
|
- lib
|
67
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
62
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
68
63
|
none: false
|
69
|
-
requirements:
|
70
|
-
- -
|
71
|
-
- !ruby/object:Gem::Version
|
72
|
-
|
73
|
-
|
74
|
-
- 0
|
75
|
-
version: "0"
|
76
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
64
|
+
requirements:
|
65
|
+
- - ! '>='
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: '0'
|
68
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
77
69
|
none: false
|
78
|
-
requirements:
|
79
|
-
- -
|
80
|
-
- !ruby/object:Gem::Version
|
81
|
-
|
82
|
-
segments:
|
83
|
-
- 0
|
84
|
-
version: "0"
|
70
|
+
requirements:
|
71
|
+
- - ! '>='
|
72
|
+
- !ruby/object:Gem::Version
|
73
|
+
version: '0'
|
85
74
|
requirements: []
|
86
|
-
|
87
75
|
rubyforge_project:
|
88
|
-
rubygems_version: 1.
|
76
|
+
rubygems_version: 1.8.11
|
89
77
|
signing_key:
|
90
78
|
specification_version: 3
|
91
79
|
summary: HTML forms library
|
92
80
|
test_files: []
|
93
|
-
|