Skip to content

Commit 4ab1868

Browse files
committed
updating gemspec, readme, Gemfile, RSpec, and rvmrc
1 parent 013a558 commit 4ab1868

16 files changed

+58
-67
lines changed

.gitignore

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
1-
pkg/*
2-
*.gem
1+
*.swp
2+
**/*.swp
3+
*.gem

.rspec

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
--color

.rvmrc

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
rvm use 1.9.2@nested_form --create

Gemfile

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
source :gemcutter
1+
source "http://rubygems.org"
22

3-
# Specify your gem's dependencies in nested_form.gemspec
4-
gemspec
3+
gemspec

Gemfile.lock

+11-14
Original file line numberDiff line numberDiff line change
@@ -65,17 +65,15 @@ GEM
6565
rake (>= 0.8.4)
6666
thor (~> 0.14.0)
6767
rake (0.8.7)
68-
rr (1.0.0)
69-
rspec (2.0.0)
70-
rspec-core (= 2.0.0)
71-
rspec-expectations (= 2.0.0)
72-
rspec-mocks (= 2.0.0)
73-
rspec-core (2.0.0)
74-
rspec-expectations (2.0.0)
75-
diff-lcs (>= 1.1.2)
76-
rspec-mocks (2.0.0)
77-
rspec-core (= 2.0.0)
78-
rspec-expectations (= 2.0.0)
68+
rr (0.10.11)
69+
rspec (2.1.0)
70+
rspec-core (~> 2.1.0)
71+
rspec-expectations (~> 2.1.0)
72+
rspec-mocks (~> 2.1.0)
73+
rspec-core (2.1.0)
74+
rspec-expectations (2.1.0)
75+
diff-lcs (~> 1.1.2)
76+
rspec-mocks (2.1.0)
7977
thor (0.14.3)
8078
treetop (1.4.8)
8179
polyglot (>= 0.3.1)
@@ -85,8 +83,7 @@ PLATFORMS
8583
ruby
8684

8785
DEPENDENCIES
88-
bundler (>= 1.0.0.rc.5)
8986
nested_form!
9087
rails (~> 3.0.0)
91-
rr
92-
rspec (~> 2.0.0.beta.22)
88+
rr (~> 0.10.11)
89+
rspec (~> 2.1.0)

LICENSE

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Copyright (c) 2010 Ryan Bates
1+
Copyright (c) 2011 Ryan Bates
22

33
Permission is hereby granted, free of charge, to any person obtaining
44
a copy of this software and associated documentation files (the
@@ -17,4 +17,4 @@ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
1717
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
1818
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
1919
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20-
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
20+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

README.rdoc

+10-5
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,12 @@ A Rails gem to conveniently manage multiple nested models in a single form. It d
44

55
To learn more about how this works under the hood: http://blog.madebydna.com/dynamic-nested-forms-in-rails-3-with-the-nest
66

7+
78
== Install
89

910
Add it to your Gemfile
1011

11-
gem "nested_form", :git => "git://github.com/madebydna/nested_form.git"
12+
gem "nested_form"
1213

1314
Run
1415

@@ -18,17 +19,18 @@ Run the generator
1819

1920
rails generate nested_form:install
2021

22+
2123
== Usage
2224

23-
Running the generator will add a file at public/javascripts/nested_form.js which should be included after jQuery.
25+
Running the generator will add a file at public/javascripts/nested_form.js which should be included after the jQuery or Prototype framework.
2426

25-
<%= javascript_include_tag 'jquery', 'nested_form' %>
27+
<%= javascript_include_tag :defaults, "nested_form" %>
2628

2729
You can then generate a nested form using the nested_form_for helper method.
2830

2931
<%= nested_form_for @project do |f| %>
3032

31-
Use this form just like normal, including the fields_for helper method for nesting models. The benefit of this plugin comes from the link_to_add and link_to_remove helper methods on the form builder.
33+
Use this form just like normal, including the +fields_for+ helper method for nesting models. The benefit of this plugin comes from the +link_to_add+ and +link_to_remove+ helper methods on the form builder.
3234

3335
<%= f.fields_for :tasks do |task_form| %>
3436
<%= task_form.text_field :name %>
@@ -38,6 +40,7 @@ Use this form just like normal, including the fields_for helper method for nesti
3840

3941
This generates links which dynamically add and remove fields.
4042

43+
4144
== Partials
4245

4346
It is often desirable to move the nested fields into a partial to keep things organized. If you don't supply a block to fields_for it will look for a partial and use that.
@@ -46,7 +49,9 @@ It is often desirable to move the nested fields into a partial to keep things or
4649

4750
In this case it will look for a partial called "task_fields" and pass the form builder as an f variable to it.
4851

52+
4953
== Special Thanks
5054

51-
This gem is based on the plugin by Ryan Bates: http://github.com/ryanb/nested_form
55+
This gem was originally based on the solution by Tim Riley in his {complex-form-examples fork}[https://github.com/timriley/complex-form-examples/tree/unobtrusive-jquery-deep-fix2].
5256

57+
Thank you Andrew Manshin for the Rails 3 transition, {Andrea Singh}[https://github.com/madebydna] for converting to a gem and {Peter Giacomo Lombardo}[https://github.com/pglombardo] for Prototype support.

Rakefile

+4-10
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,10 @@
1-
require 'bundler'
2-
Bundler::GemHelper.install_tasks
3-
41
require 'rubygems'
52
require 'rake'
6-
require 'spec/rake/spectask'
7-
8-
spec_files = Rake::FileList["spec/**/*_spec.rb"]
3+
require 'rspec/core/rake_task'
94

10-
desc "Run specs"
11-
Spec::Rake::SpecTask.new do |t|
12-
t.spec_files = spec_files
13-
t.spec_opts = ["-c"]
5+
desc "Run RSpec"
6+
RSpec::Core::RakeTask.new do |t|
7+
t.verbose = false
148
end
159

1610
task :default => :spec

lib/nested_form.rb

+1-2
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,4 @@
22
require "nested_form/view_helper"
33

44
module NestedForm
5-
6-
end
5+
end

lib/nested_form/builder.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,4 @@ def fields_for_nested_model(name, association, args, block)
3131
output
3232
end
3333
end
34-
end
34+
end

lib/nested_form/version.rb

-3
This file was deleted.

lib/nested_form/view_helper.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,4 @@ def after_nested_form(association, &block)
2323

2424
class ActionView::Base
2525
include NestedForm::ViewHelper
26-
end
26+
end

nested_form.gemspec

+10-17
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,19 @@
1-
# -*- encoding: utf-8 -*-
2-
$LOAD_PATH.unshift File.expand_path('../lib', __FILE__)
3-
require 'nested_form/version'
4-
51
Gem::Specification.new do |s|
62
s.name = "nested_form"
7-
s.version = NestedForm::VERSION
8-
s.platform = Gem::Platform::RUBY
3+
s.version = "0.0.0"
94
s.authors = ["Ryan Bates", "Andrea Singh"]
10-
s.email = ["info@madebydna.com"]
11-
s.homepage = "http://github.com/madebydna/nested_form"
5+
s.email = "ryan@railscasts.com"
6+
s.homepage = "http://github.com/ryanb/nested_form"
127
s.summary = "Gem to conveniently handle multiple models in a single form."
13-
s.description = "Gem to conveniently handle multiple models in a single form. Rails 2 plugin by Ryan Bates converted into a gem."
8+
s.description = "Gem to conveniently handle multiple models in a single form with Rails 3 and jQuery or Prototype."
9+
10+
s.files = Dir["{lib,spec}/**/*", "[A-Z]*"] - ["Gemfile.lock"]
11+
s.require_path = "lib"
1412

1513
s.required_rubygems_version = ">= 1.3.6"
1614
s.rubyforge_project = "nested_form"
1715

18-
s.add_development_dependency "bundler", ">= 1.0.0.rc.5"
19-
s.add_development_dependency "rspec", "~> 2.0.0.beta.22"
20-
s.add_development_dependency "rr"
16+
s.add_development_dependency "rspec", "~> 2.1.0"
17+
s.add_development_dependency "rr", "~> 0.10.11" # 1.0.0 has respond_to? issues: http://github.com/btakita/rr/issues/issue/43
2118
s.add_development_dependency "rails", "~> 3.0.0"
22-
23-
s.files = `git ls-files`.split("\n")
24-
s.executables = `git ls-files`.split("\n").select{|f| f =~ /^bin/}
25-
s.require_path = 'lib'
26-
end
19+
end

spec/nested_form/builder_spec.rb

+3-4
Original file line numberDiff line numberDiff line change
@@ -8,23 +8,22 @@
88
@template.output_buffer = ""
99
@builder = NestedForm::Builder.new(:item, @project, @template, {}, proc {})
1010
end
11-
11+
1212
it "should have an add link" do
1313
@builder.link_to_add("Add", :tasks).should == '<a href="javascript:void(0)" class="add_nested_fields" data-association="tasks">Add</a>'
1414
end
15-
1615

1716
it "should have a remove link" do
1817
@builder.link_to_remove("Remove").should == '<input id="item__destroy" name="item[_destroy]" type="hidden" value="false" /><a href="javascript:void(0)" class="remove_nested_fields">Remove</a>'
1918
end
20-
19+
2120
it "should wrap nested fields each in a div with class" do
2221
2.times { @project.tasks.build }
2322
@builder.fields_for(:tasks) do
2423
"Task"
2524
end.should == '<div class="fields">Task</div><div class="fields">Task</div>'
2625
end
27-
26+
2827
it "should add task fields to hidden div after form" do
2928
output = ""
3029
mock(@template).after_nested_form(:tasks) { |arg, block| output << block.call }

spec/nested_form/view_helper_spec.rb

+3-3
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,20 @@
88
stub(@template).projects_path { "" }
99
stub(@template).protect_against_forgery? { false }
1010
end
11-
11+
1212
it "should pass nested form builder to form_for along with other options" do
1313
mock.proxy(@template).form_for(:first, :as => :second, :other => :arg, :builder => NestedForm::Builder) do |form_html|
1414
form_html
1515
end
1616
@template.nested_form_for(:first, :as => :second, :other => :arg) {"form"}
1717
end
18-
18+
1919
it "should pass instance of NestedForm::Builder to nested_form_for block" do
2020
@template.nested_form_for(Project.new) do |f|
2121
f.should be_instance_of(NestedForm::Builder)
2222
end
2323
end
24-
24+
2525
it "should append content to end of nested form" do
2626
@template.after_nested_form(:tasks) { @template.concat("123") }
2727
@template.after_nested_form(:milestones) { @template.concat("456") }

spec/spec_helper.rb

+5
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
require 'rubygems'
2+
require 'bundler/setup'
3+
4+
Bundler.require(:default)
5+
16
require 'active_model'
27
require 'active_record'
38
require 'action_controller'

0 commit comments

Comments
 (0)