sinatra_more 0.2.3 → 0.2.4
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +1 -0
- data/Rakefile +0 -1
- data/TODO +8 -11
- data/VERSION +1 -1
- data/lib/sinatra_more/markup_plugin/form_builder/abstract_form_builder.rb +9 -3
- data/lib/sinatra_more/warden_plugin.rb +1 -0
- data/sinatra_more.gemspec +2 -5
- data/test/fixtures/markup_app/views/form_for.erb +4 -0
- data/test/markup_plugin/test_form_builder.rb +7 -0
- metadata +2 -12
data/README.rdoc
CHANGED
@@ -208,6 +208,7 @@ A form_tag might look like:
|
|
208
208
|
* Supports form methods 'put' and 'delete' through hidden field
|
209
209
|
* Defaults to StandardFormBuilder but you can easily create your own!
|
210
210
|
* <tt>form_for(@user, '/register', :id => 'register') { |f| ...field-elements... }</tt>
|
211
|
+
* <tt>form_for(:user, '/register', :id => 'register') { |f| ...field-elements... }</tt>
|
211
212
|
|
212
213
|
The following are fields provided by AbstractFormBuilder that can be used within a form_for:
|
213
214
|
|
data/Rakefile
CHANGED
@@ -14,7 +14,6 @@ begin
|
|
14
14
|
gem.authors = ["Nathan Esquenazi"]
|
15
15
|
gem.add_runtime_dependency "sinatra", ">= 0.9.2"
|
16
16
|
gem.add_runtime_dependency "activesupport", ">= 2.2.2"
|
17
|
-
gem.add_runtime_dependency "warden", ">= 0.4.0"
|
18
17
|
gem.add_development_dependency "haml", ">= 2.2.1"
|
19
18
|
gem.add_development_dependency "shoulda", ">= 2.10.2"
|
20
19
|
gem.add_development_dependency "mocha", ">= 0.9.7"
|
data/TODO
CHANGED
@@ -1,24 +1,21 @@
|
|
1
1
|
= UNFINISHED
|
2
2
|
|
3
|
+
* Add support for a MailerPlugin which will make sending emails a breeze (http://github.com/hiroshi/pony)
|
4
|
+
* Add support for fields_for tag in formbuilder
|
5
|
+
* Add support for button tag method, mail_to helper
|
6
|
+
* Add support for check_box_group, radio_button_group which create a set of checkboxes or radio buttons
|
7
|
+
* Look into creating sinatra generators using rubigen (http://github.com/drnic/rubigen)
|
8
|
+
* http://github.com/quirkey/sinatra-gen
|
9
|
+
* http://github.com/monkrb/monk
|
3
10
|
* Become total warden solution (basically just require warden gem installed, do everything else)
|
4
11
|
* Look into removing overlapping methods and simply leverage sinatra_warden
|
5
12
|
* Take advantage of shared strategies: http://github.com/hassox/warden_strategies/tree/master/lib/
|
6
13
|
* Make warden password strategy support a callback which explains what to do with username, password
|
7
14
|
* WardenPlugin.authenticate_callback { |username, password| User.authenticate(username, password) }
|
8
|
-
* Add support for fields_for tag in formbuilder
|
9
|
-
* Add support for missing formbuilder fields (select, and standard_form_builder methods i.e check_box_group)
|
10
|
-
* Look into creating sinatra generators using rubigen (http://github.com/drnic/rubigen)
|
11
|
-
* http://github.com/quirkey/sinatra-gen
|
12
|
-
* http://github.com/monkrb/monk
|
13
|
-
* Look into adding any missing helpers from:
|
14
|
-
* http://github.com/brianjlandau/nice-n-easy
|
15
|
-
* http://github.com/brianjlandau/nice-n-easy/blob/master/lib/sinatra/nice_easy_helpers.rb
|
16
|
-
* http://github.com/kelredd/sinatra-helpers/blob/master/lib/sinatra_helpers/erb/links.rb
|
17
|
-
* http://github.com/kelredd/sinatra-helpers/blob/master/lib/sinatra_helpers/erb/forms.rb
|
18
|
-
* http://github.com/twilson63/sinatra-formhelpers/blob/master/lib/sinatra/formhelpers.rb
|
19
15
|
|
20
16
|
= COMPLETED
|
21
17
|
|
18
|
+
* Add support for missing formbuilder fields (select, and standard_form_builder methods i.e check_box_group)
|
22
19
|
* Add support for missing formhelpers/fields (radio_button_tag, select_tag)
|
23
20
|
* Add support for select_tag :multiple => true
|
24
21
|
* Add support for forms with method => put, delete using hidden field
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.2.
|
1
|
+
0.2.4
|
@@ -3,9 +3,8 @@ class AbstractFormBuilder
|
|
3
3
|
|
4
4
|
def initialize(template, object)
|
5
5
|
raise "FormBuilder template must be initialized!" unless template
|
6
|
-
raise "FormBuilder object must be initialized!" unless object
|
7
6
|
@template = template
|
8
|
-
@object = object
|
7
|
+
@object = build_object(object)
|
9
8
|
end
|
10
9
|
|
11
10
|
# f.error_messages
|
@@ -92,7 +91,7 @@ class AbstractFormBuilder
|
|
92
91
|
# Returns the object's models name
|
93
92
|
# => user_assignment
|
94
93
|
def object_name
|
95
|
-
object.class.to_s.underscore
|
94
|
+
object.is_a?(Symbol) ? object : object.class.to_s.underscore
|
96
95
|
end
|
97
96
|
|
98
97
|
# Returns true if the value matches the value in the field
|
@@ -119,4 +118,11 @@ class AbstractFormBuilder
|
|
119
118
|
def field_id(field, value=nil)
|
120
119
|
value.blank? ? "#{object_name}_#{field}" : "#{object_name}_#{field}_#{value}"
|
121
120
|
end
|
121
|
+
|
122
|
+
# Either a symbol or a record
|
123
|
+
def build_object(explicit_object)
|
124
|
+
explicit_object.is_a?(Symbol) ? explicit_object.to_s.classify.constantize.new : explicit_object
|
125
|
+
raise "FormBuilder object must be initialized or use a symbol instead! (i.e :user)" unless explicit_object
|
126
|
+
explicit_object
|
127
|
+
end
|
122
128
|
end
|
@@ -5,6 +5,7 @@ Dir[File.dirname(__FILE__) + '/warden_plugin/**/*.rb'].each {|file| load file }
|
|
5
5
|
module SinatraMore
|
6
6
|
module WardenPlugin
|
7
7
|
def self.registered(app)
|
8
|
+
raise "WardenPlugin::Error - Install with 'sudo gem install warden' or require 'warden' in your app." unless Warden::Manager
|
8
9
|
app.use Warden::Manager do |manager|
|
9
10
|
manager.default_strategies :password
|
10
11
|
manager.failure_app = app
|
data/sinatra_more.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{sinatra_more}
|
8
|
-
s.version = "0.2.
|
8
|
+
s.version = "0.2.4"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Nathan Esquenazi"]
|
12
|
-
s.date = %q{2009-10-
|
12
|
+
s.date = %q{2009-10-29}
|
13
13
|
s.description = %q{Expands sinatra with standard helpers and tools to allow for complex applications}
|
14
14
|
s.email = %q{nesquena@gmail.com}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -97,7 +97,6 @@ Gem::Specification.new do |s|
|
|
97
97
|
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
98
98
|
s.add_runtime_dependency(%q<sinatra>, [">= 0.9.2"])
|
99
99
|
s.add_runtime_dependency(%q<activesupport>, [">= 2.2.2"])
|
100
|
-
s.add_runtime_dependency(%q<warden>, [">= 0.4.0"])
|
101
100
|
s.add_development_dependency(%q<haml>, [">= 2.2.1"])
|
102
101
|
s.add_development_dependency(%q<shoulda>, [">= 2.10.2"])
|
103
102
|
s.add_development_dependency(%q<mocha>, [">= 0.9.7"])
|
@@ -106,7 +105,6 @@ Gem::Specification.new do |s|
|
|
106
105
|
else
|
107
106
|
s.add_dependency(%q<sinatra>, [">= 0.9.2"])
|
108
107
|
s.add_dependency(%q<activesupport>, [">= 2.2.2"])
|
109
|
-
s.add_dependency(%q<warden>, [">= 0.4.0"])
|
110
108
|
s.add_dependency(%q<haml>, [">= 2.2.1"])
|
111
109
|
s.add_dependency(%q<shoulda>, [">= 2.10.2"])
|
112
110
|
s.add_dependency(%q<mocha>, [">= 0.9.7"])
|
@@ -116,7 +114,6 @@ Gem::Specification.new do |s|
|
|
116
114
|
else
|
117
115
|
s.add_dependency(%q<sinatra>, [">= 0.9.2"])
|
118
116
|
s.add_dependency(%q<activesupport>, [">= 2.2.2"])
|
119
|
-
s.add_dependency(%q<warden>, [">= 0.4.0"])
|
120
117
|
s.add_dependency(%q<haml>, [">= 2.2.1"])
|
121
118
|
s.add_dependency(%q<shoulda>, [">= 2.10.2"])
|
122
119
|
s.add_dependency(%q<mocha>, [">= 0.9.7"])
|
@@ -49,4 +49,8 @@
|
|
49
49
|
<%= f.select_block :state, :options => ['California', 'Texas'], :class => 'selector' %>
|
50
50
|
<%= f.submit_block "Create", { :class => 'button' } %>
|
51
51
|
<%= f.image_submit_block "buttons/ok.png", { :class => 'image' } %>
|
52
|
+
<% end %>
|
53
|
+
|
54
|
+
<% form_for :markup_user, '/third_demo', :id => 'demo3', :method => 'get' do |f| %>
|
55
|
+
<%= f.text_field_block :username %>
|
52
56
|
<% end %>
|
@@ -26,6 +26,13 @@ class TestFormBuilder < Test::Unit::TestCase
|
|
26
26
|
assert_has_tag('form', :action => '/register', :id => 'register', :method => 'post', :content => "Demo") { actual_html }
|
27
27
|
assert_has_tag('form input[type=hidden]', :name => '_method', :count => 0) { actual_html } # no method action field
|
28
28
|
end
|
29
|
+
|
30
|
+
should "display correct form html with fake object" do
|
31
|
+
actual_html = form_for(:markup_user, '/register', :id => 'register', :method => 'post') { |f| f.text_field :username }
|
32
|
+
assert_has_tag('form', :action => '/register', :id => 'register', :method => 'post') { actual_html }
|
33
|
+
assert_has_tag('form input', :type => 'text', :name => 'markup_user[username]') { actual_html }
|
34
|
+
assert_has_tag('form input[type=hidden]', :name => '_method', :count => 0) { actual_html } # no method action field
|
35
|
+
end
|
29
36
|
|
30
37
|
should "display correct form html with method :post" do
|
31
38
|
actual_html = form_for(@user, '/update', :method => 'put') { "Demo" }
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sinatra_more
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nathan Esquenazi
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-10-
|
12
|
+
date: 2009-10-29 00:00:00 -07:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -32,16 +32,6 @@ dependencies:
|
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: 2.2.2
|
34
34
|
version:
|
35
|
-
- !ruby/object:Gem::Dependency
|
36
|
-
name: warden
|
37
|
-
type: :runtime
|
38
|
-
version_requirement:
|
39
|
-
version_requirements: !ruby/object:Gem::Requirement
|
40
|
-
requirements:
|
41
|
-
- - ">="
|
42
|
-
- !ruby/object:Gem::Version
|
43
|
-
version: 0.4.0
|
44
|
-
version:
|
45
35
|
- !ruby/object:Gem::Dependency
|
46
36
|
name: haml
|
47
37
|
type: :development
|