Permalink
Browse files

Upgraded to support Rails 3.2 with the asset pipeline. Also added a g…

…enerator test and a dummy app to test it on.
  • Loading branch information...
1 parent 9596300 commit 1cff9cb0a0c91e980e6770f29cee03de5f5a6de6 @freakent freakent committed Mar 15, 2012
Showing with 1,056 additions and 108 deletions.
  1. +8 −0 .gitignore
  2. +18 −0 .project
  3. +16 −10 Gemfile
  4. +89 −8 Gemfile.lock
  5. +29 −37 Rakefile
  6. +1 −1 lib/generators/USAGE
  7. +6 −3 lib/generators/nested_scaffold_generator.rb
  8. +7 −49 nested_scaffold.gemspec
  9. +3 −0 test/dummy/README.rdoc
  10. +7 −0 test/dummy/Rakefile
  11. +15 −0 test/dummy/app/assets/javascripts/application.js
  12. +2 −0 test/dummy/app/assets/javascripts/boxes.js
  13. +13 −0 test/dummy/app/assets/stylesheets/application.css
  14. +4 −0 test/dummy/app/assets/stylesheets/boxes.css
  15. +3 −0 test/dummy/app/controllers/application_controller.rb
  16. +83 −0 test/dummy/app/controllers/boxes_controller.rb
  17. +2 −0 test/dummy/app/helpers/application_helper.rb
  18. +2 −0 test/dummy/app/helpers/boxes_helper.rb
  19. 0 test/dummy/app/mailers/.gitkeep
  20. 0 test/dummy/app/models/.gitkeep
  21. +2 −0 test/dummy/app/models/box.rb
  22. +25 −0 test/dummy/app/views/boxes/_form.html.erb
  23. +6 −0 test/dummy/app/views/boxes/edit.html.erb
  24. +25 −0 test/dummy/app/views/boxes/index.html.erb
  25. +5 −0 test/dummy/app/views/boxes/new.html.erb
  26. +15 −0 test/dummy/app/views/boxes/show.html.erb
  27. +14 −0 test/dummy/app/views/layouts/application.html.erb
  28. +4 −0 test/dummy/config.ru
  29. +56 −0 test/dummy/config/application.rb
  30. +10 −0 test/dummy/config/boot.rb
  31. +25 −0 test/dummy/config/database.yml
  32. +5 −0 test/dummy/config/environment.rb
  33. +37 −0 test/dummy/config/environments/development.rb
  34. +67 −0 test/dummy/config/environments/production.rb
  35. +37 −0 test/dummy/config/environments/test.rb
  36. +7 −0 test/dummy/config/initializers/backtrace_silencers.rb
  37. +15 −0 test/dummy/config/initializers/inflections.rb
  38. +5 −0 test/dummy/config/initializers/mime_types.rb
  39. +7 −0 test/dummy/config/initializers/secret_token.rb
  40. +8 −0 test/dummy/config/initializers/session_store.rb
  41. +14 −0 test/dummy/config/initializers/wrap_parameters.rb
  42. +5 −0 test/dummy/config/locales/en.yml
  43. +60 −0 test/dummy/config/routes.rb
  44. +10 −0 test/dummy/db/migrate/20120313224522_create_boxes.rb
  45. +44 −0 test/dummy/db/schema.rb
  46. 0 test/dummy/lib/assets/.gitkeep
  47. +26 −0 test/dummy/public/404.html
  48. +26 −0 test/dummy/public/422.html
  49. +25 −0 test/dummy/public/500.html
  50. 0 test/dummy/public/favicon.ico
  51. +6 −0 test/dummy/script/rails
  52. +9 −0 test/dummy/test/fixtures/boxes.yml
  53. +49 −0 test/dummy/test/functional/boxes_controller_test.rb
  54. +7 −0 test/dummy/test/unit/box_test.rb
  55. +4 −0 test/dummy/test/unit/helpers/boxes_helper_test.rb
  56. +70 −0 test/nested_scaffold_test.rb
  57. +18 −0 test/test_helper.rb
View
@@ -14,6 +14,14 @@ doc
# jeweler generated
pkg
+# OS Files
+.DS_Store
+
+# Transient Files
+tmp
+log
+*.sqlite3
+
# Have editor/IDE/OS specific files you need to ignore? Consider using a global gitignore:
#
# * Create a file at ~/.gitignore
View
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>nested_scaffold</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>com.aptana.ide.core.unifiedBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.radrails.rails.core.railsnature</nature>
+ <nature>com.aptana.ruby.core.rubynature</nature>
+ </natures>
+</projectDescription>
View
26 Gemfile
@@ -1,11 +1,17 @@
source "http://rubygems.org"
-# Add dependencies required to use your gem here.
-# Example:
-# gem "activesupport", ">= 2.3.5"
-
-# Add dependencies to develop your gem here.
-# Include everything needed to run rake, tests, features, etc.
-group :development do
- gem "bundler", "~> 1.0.0"
- gem "jeweler", "~> 1.5.1"
-end
+
+# Declare your gem's dependencies in nested_scaffold.gemspec.
+# Bundler will treat runtime dependencies like base dependencies, and
+# development dependencies will be added by default to the :development group.
+gemspec
+
+# jquery-rails is used by the dummy application
+gem "jquery-rails"
+
+# Declare any dependencies that are still in development here instead of in
+# your gemspec. These might include edge Rails or gems from your path or
+# Git. Remember to move these dependencies to your gemspec before releasing
+# your gem to rubygems.org.
+
+# To use debugger
+# gem 'ruby-debug19', :require => 'ruby-debug'
View
@@ -1,16 +1,97 @@
+PATH
+ remote: .
+ specs:
+ nested_scaffold (0.1.0)
+ rails (~> 3.2.2)
+
GEM
remote: http://rubygems.org/
specs:
- git (1.2.5)
- jeweler (1.5.1)
- bundler (~> 1.0.0)
- git (>= 1.2.5)
- rake
- rake (0.8.7)
+ actionmailer (3.2.2)
+ actionpack (= 3.2.2)
+ mail (~> 2.4.0)
+ actionpack (3.2.2)
+ activemodel (= 3.2.2)
+ activesupport (= 3.2.2)
+ builder (~> 3.0.0)
+ erubis (~> 2.7.0)
+ journey (~> 1.0.1)
+ rack (~> 1.4.0)
+ rack-cache (~> 1.1)
+ rack-test (~> 0.6.1)
+ sprockets (~> 2.1.2)
+ activemodel (3.2.2)
+ activesupport (= 3.2.2)
+ builder (~> 3.0.0)
+ activerecord (3.2.2)
+ activemodel (= 3.2.2)
+ activesupport (= 3.2.2)
+ arel (~> 3.0.2)
+ tzinfo (~> 0.3.29)
+ activeresource (3.2.2)
+ activemodel (= 3.2.2)
+ activesupport (= 3.2.2)
+ activesupport (3.2.2)
+ i18n (~> 0.6)
+ multi_json (~> 1.0)
+ arel (3.0.2)
+ builder (3.0.0)
+ erubis (2.7.0)
+ hike (1.2.1)
+ i18n (0.6.0)
+ journey (1.0.3)
+ jquery-rails (2.0.1)
+ railties (>= 3.2.0, < 5.0)
+ thor (~> 0.14)
+ json (1.6.5)
+ mail (2.4.3)
+ i18n (>= 0.4.0)
+ mime-types (~> 1.16)
+ treetop (~> 1.4.8)
+ mime-types (1.17.2)
+ multi_json (1.1.0)
+ polyglot (0.3.3)
+ rack (1.4.1)
+ rack-cache (1.2)
+ rack (>= 0.4)
+ rack-ssl (1.3.2)
+ rack
+ rack-test (0.6.1)
+ rack (>= 1.0)
+ rails (3.2.2)
+ actionmailer (= 3.2.2)
+ actionpack (= 3.2.2)
+ activerecord (= 3.2.2)
+ activeresource (= 3.2.2)
+ activesupport (= 3.2.2)
+ bundler (~> 1.0)
+ railties (= 3.2.2)
+ railties (3.2.2)
+ actionpack (= 3.2.2)
+ activesupport (= 3.2.2)
+ rack-ssl (~> 1.3.2)
+ rake (>= 0.8.7)
+ rdoc (~> 3.4)
+ thor (~> 0.14.6)
+ rake (0.9.2.2)
+ rdoc (3.12)
+ json (~> 1.4)
+ sprockets (2.1.2)
+ hike (~> 1.2)
+ rack (~> 1.0)
+ tilt (~> 1.1, != 1.3.0)
+ sqlite3 (1.3.5)
+ thor (0.14.6)
+ tilt (1.3.3)
+ treetop (1.4.10)
+ polyglot
+ polyglot (>= 0.3.1)
+ tzinfo (0.3.32)
PLATFORMS
ruby
DEPENDENCIES
- bundler (~> 1.0.0)
- jeweler (~> 1.5.1)
+ jquery-rails
+ nested_scaffold!
+ sqlite3
View
@@ -1,46 +1,38 @@
-require 'rubygems'
-require 'bundler'
+#!/usr/bin/env rake
begin
- Bundler.setup(:default, :development)
-rescue Bundler::BundlerError => e
- $stderr.puts e.message
- $stderr.puts "Run `bundle install` to install missing gems"
- exit e.status_code
+ require 'bundler/setup'
+rescue LoadError
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
end
-require 'rake'
-
-require 'jeweler'
-Jeweler::Tasks.new do |gem|
- # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
- gem.name = "nested_scaffold"
- gem.homepage = "http://github.com/amatsuda/nested_scaffold"
- gem.license = "MIT"
- gem.summary = 'Nested scaffold generator for Rails 3'
- gem.description = 'Nested scaffold generator for Rails 3'
- gem.email = "ronnie@dio.jp"
- gem.authors = ["Akira Matsuda"]
- # Include your dependencies below. Runtime dependencies are required when using your gem,
- # and development dependencies are only needed for development (ie running rake tasks, tests, etc)
- # gem.add_runtime_dependency 'jabber4r', '> 0.1'
- # gem.add_development_dependency 'rspec', '> 1.2.3'
+begin
+ require 'rdoc/task'
+rescue LoadError
+ require 'rdoc/rdoc'
+ require 'rake/rdoctask'
+ RDoc::Task = Rake::RDocTask
end
-Jeweler::RubygemsDotOrgTasks.new
-require 'rake/testtask'
-Rake::TestTask.new(:test) do |test|
- test.libs << 'lib' << 'test'
- test.pattern = 'test/**/test_*.rb'
- test.verbose = true
+RDoc::Task.new(:rdoc) do |rdoc|
+ rdoc.rdoc_dir = 'rdoc'
+ rdoc.title = 'Nested Scaffold'
+ rdoc.options << '--line-numbers'
+ rdoc.rdoc_files.include('README.rdoc')
+ rdoc.rdoc_files.include('lib/**/*.rb')
end
-task :default => :test
-require 'rake/rdoctask'
-Rake::RDocTask.new do |rdoc|
- version = File.exist?('VERSION') ? File.read('VERSION') : ""
- rdoc.rdoc_dir = 'rdoc'
- rdoc.title = "nested_scaffold #{version}"
- rdoc.rdoc_files.include('README*')
- rdoc.rdoc_files.include('lib/**/*.rb')
+
+Bundler::GemHelper.install_tasks
+
+require 'rake/testtask'
+
+Rake::TestTask.new(:test) do |t|
+ t.libs << 'lib'
+ t.libs << 'test'
+ t.pattern = 'test/**/*_test.rb'
+ t.verbose = false
end
+
+
+task :default => :test
View
@@ -1,5 +1,5 @@
Description:
- Generats nested scaffold
+ Generates nested scaffold
Example:
rails g nested_scaffold group/user name:string age:integer
@@ -2,7 +2,6 @@
require File.join(File.dirname(__FILE__), 'base')
require File.join(File.dirname(__FILE__), 'scaffold_controller/scaffold_controller_generator')
require File.join(File.dirname(__FILE__), 'active_record/active_record_generator')
-require File.join(File.dirname(__FILE__), 'stylesheets/stylesheets_generator')
module NestedScaffold
module Generators
@@ -11,8 +10,12 @@ class NestedScaffoldGenerator < ::Rails::Generators::ScaffoldGenerator
# override ScaffoldGenerator
hook_for :scaffold_controller, :required => true
- # override ScaffoldGenerator
- hook_for :stylesheets
+
+ # Ensure assets get created with the correct name
+ hook_for :assets, :in => :rails do |source, generator|
+ source.invoke generator, [ source.file_name.pluralize ]
+ end
+
# override ModelGenerator
hook_for :orm, :required => true
View
@@ -16,60 +16,18 @@ Gem::Specification.new do |s|
"LICENSE.txt",
"README.rdoc"
]
- s.files = [
- ".document",
- "Gemfile",
- "Gemfile.lock",
- "LICENSE.txt",
- "README.rdoc",
- "Rakefile",
- "VERSION",
- "lib/generators/USAGE",
- "lib/generators/active_record/active_record_generator.rb",
- "lib/generators/base.rb",
- "lib/generators/erb/erb_generator.rb",
- "lib/generators/erb/templates/_form.html.erb",
- "lib/generators/erb/templates/edit.html.erb",
- "lib/generators/erb/templates/index.html.erb",
- "lib/generators/erb/templates/new.html.erb",
- "lib/generators/erb/templates/show.html.erb",
- "lib/generators/haml/haml_generator.rb",
- "lib/generators/haml/templates/_form.html.haml",
- "lib/generators/haml/templates/edit.html.haml",
- "lib/generators/haml/templates/index.html.haml",
- "lib/generators/haml/templates/new.html.haml",
- "lib/generators/haml/templates/show.html.haml",
- "lib/generators/helper/helper_generator.rb",
- "lib/generators/nested_scaffold_generator.rb",
- "lib/generators/scaffold_controller/scaffold_controller_generator.rb",
- "lib/generators/scaffold_controller/templates/controller.rb",
- "lib/generators/stylesheets/stylesheets_generator.rb",
- "lib/generators/test_unit/helper_generator.rb",
- "lib/generators/test_unit/model_generator.rb",
- "lib/generators/test_unit/scaffold_generator.rb",
- "lib/generators/test_unit/templates/functional_test.rb",
- "nested_scaffold.gemspec"
- ]
+
s.homepage = %q{http://github.com/amatsuda/nested_scaffold}
s.licenses = ["MIT"]
s.require_paths = ["lib"]
s.rubygems_version = %q{1.3.7}
- s.summary = %q{Nested scaffold generator for Rails 3}
+ s.summary = %q{Nested scaffold generator for Rails 3.2}
+
+ s.files = Dir["{app,config,db,lib}/**/*"] + ["MIT-LICENSE", "Rakefile", "README.rdoc"]
+ s.test_files = Dir["test/**/*"]
- if s.respond_to? :specification_version then
- current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
- s.specification_version = 3
+ s.add_dependency "rails", "~> 3.2.2"
- if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
- s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
- s.add_development_dependency(%q<jeweler>, ["~> 1.5.1"])
- else
- s.add_dependency(%q<bundler>, ["~> 1.0.0"])
- s.add_dependency(%q<jeweler>, ["~> 1.5.1"])
- end
- else
- s.add_dependency(%q<bundler>, ["~> 1.0.0"])
- s.add_dependency(%q<jeweler>, ["~> 1.5.1"])
- end
+ s.add_development_dependency "sqlite3"
end
View
@@ -0,0 +1,3 @@
+== This is a Dummy Rails app for testing Nested Scaffold
+
+If the nested scaffold is generated properly, you should be able to fire up rails and run this application in the usual way.
View
@@ -0,0 +1,7 @@
+#!/usr/bin/env rake
+# Add your own tasks in files placed in lib/tasks ending in .rake,
+# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
+
+require File.expand_path('../config/application', __FILE__)
+
+Dummy::Application.load_tasks
@@ -0,0 +1,15 @@
+// This is a manifest file that'll be compiled into application.js, which will include all the files
+// listed below.
+//
+// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
+// or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
+//
+// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
+// the compiled file.
+//
+// WARNING: THE FIRST BLANK LINE MARKS THE END OF WHAT'S TO BE PROCESSED, ANY BLANK LINE SHOULD
+// GO AFTER THE REQUIRES BELOW.
+//
+//= require jquery
+//= require jquery_ujs
+//= require_tree .
@@ -0,0 +1,2 @@
+// Place all the behaviors and hooks related to the matching controller here.
+// All this logic will automatically be available in application.js.
@@ -0,0 +1,13 @@
+/*
+ * This is a manifest file that'll be compiled into application.css, which will include all the files
+ * listed below.
+ *
+ * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
+ * or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
+ *
+ * You're free to add application-wide styles to this file and they'll appear at the top of the
+ * compiled file, but it's generally better to create a new file per style scope.
+ *
+ *= require_self
+ *= require_tree .
+*/
@@ -0,0 +1,4 @@
+/*
+ Place all the styles related to the matching controller here.
+ They will automatically be included in application.css.
+*/
@@ -0,0 +1,3 @@
+class ApplicationController < ActionController::Base
+ protect_from_forgery
+end
Oops, something went wrong.

0 comments on commit 1cff9cb

Please sign in to comment.