nested_scaffold 0.2.1 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (68) hide show
  1. checksums.yaml +7 -0
  2. data/.document +5 -0
  3. data/.gitignore +9 -0
  4. data/.travis.yml +10 -0
  5. data/Gemfile +4 -0
  6. data/README.rdoc +4 -13
  7. data/Rakefile +5 -33
  8. data/gemfiles/Gemfile-rails.4.2.x +7 -0
  9. data/gemfiles/Gemfile-rails.4.2.x.lock +114 -0
  10. data/gemfiles/Gemfile-rails.5.0.0.beta3 +7 -0
  11. data/gemfiles/Gemfile-rails.5.0.0.beta3.lock +124 -0
  12. data/lib/generators/active_record/active_record_generator.rb +2 -2
  13. data/lib/generators/haml/templates/edit.html.haml +1 -1
  14. data/lib/generators/nested_scaffold_generator.rb +5 -3
  15. data/lib/generators/scaffold_controller/scaffold_controller_generator.rb +2 -2
  16. data/lib/generators/scaffold_controller/templates/controller.rb +32 -54
  17. data/lib/generators/test_unit/model_generator.rb +9 -0
  18. data/lib/generators/test_unit/templates/functional_test.rb +9 -10
  19. data/nested_scaffold.gemspec +26 -0
  20. metadata +84 -129
  21. data/test/dummy/README.rdoc +0 -3
  22. data/test/dummy/Rakefile +0 -7
  23. data/test/dummy/app/assets/javascripts/application.js +0 -15
  24. data/test/dummy/app/assets/javascripts/boxes.js +0 -2
  25. data/test/dummy/app/assets/stylesheets/application.css +0 -13
  26. data/test/dummy/app/assets/stylesheets/boxes.css +0 -4
  27. data/test/dummy/app/controllers/application_controller.rb +0 -3
  28. data/test/dummy/app/controllers/boxes_controller.rb +0 -83
  29. data/test/dummy/app/helpers/application_helper.rb +0 -2
  30. data/test/dummy/app/helpers/boxes_helper.rb +0 -2
  31. data/test/dummy/app/models/box.rb +0 -2
  32. data/test/dummy/app/views/boxes/_form.html.erb +0 -25
  33. data/test/dummy/app/views/boxes/edit.html.erb +0 -6
  34. data/test/dummy/app/views/boxes/index.html.erb +0 -25
  35. data/test/dummy/app/views/boxes/new.html.erb +0 -5
  36. data/test/dummy/app/views/boxes/show.html.erb +0 -15
  37. data/test/dummy/app/views/layouts/application.html.erb +0 -14
  38. data/test/dummy/config.ru +0 -4
  39. data/test/dummy/config/application.rb +0 -56
  40. data/test/dummy/config/boot.rb +0 -10
  41. data/test/dummy/config/database.yml +0 -25
  42. data/test/dummy/config/environment.rb +0 -5
  43. data/test/dummy/config/environments/development.rb +0 -37
  44. data/test/dummy/config/environments/production.rb +0 -67
  45. data/test/dummy/config/environments/test.rb +0 -37
  46. data/test/dummy/config/initializers/backtrace_silencers.rb +0 -7
  47. data/test/dummy/config/initializers/inflections.rb +0 -15
  48. data/test/dummy/config/initializers/mime_types.rb +0 -5
  49. data/test/dummy/config/initializers/secret_token.rb +0 -7
  50. data/test/dummy/config/initializers/session_store.rb +0 -8
  51. data/test/dummy/config/initializers/wrap_parameters.rb +0 -14
  52. data/test/dummy/config/locales/en.yml +0 -5
  53. data/test/dummy/config/routes.rb +0 -60
  54. data/test/dummy/db/migrate/20120313224522_create_boxes.rb +0 -10
  55. data/test/dummy/db/schema.rb +0 -44
  56. data/test/dummy/db/test.sqlite3 +0 -0
  57. data/test/dummy/log/test.log +0 -18
  58. data/test/dummy/public/404.html +0 -26
  59. data/test/dummy/public/422.html +0 -26
  60. data/test/dummy/public/500.html +0 -25
  61. data/test/dummy/public/favicon.ico +0 -0
  62. data/test/dummy/script/rails +0 -6
  63. data/test/dummy/test/fixtures/boxes.yml +0 -9
  64. data/test/dummy/test/functional/boxes_controller_test.rb +0 -49
  65. data/test/dummy/test/unit/box_test.rb +0 -7
  66. data/test/dummy/test/unit/helpers/boxes_helper_test.rb +0 -4
  67. data/test/nested_scaffold_test.rb +0 -70
  68. data/test/test_helper.rb +0 -18
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 35eb563998b1b281828b5a8b05ff7b37f0ea463c
4
+ data.tar.gz: 63b63f87acafcec2c3715fe637aa112bcd3d22a4
5
+ SHA512:
6
+ metadata.gz: 4abb6ee4fb63417bd9b49f1e432d55abda952cfc125f154ff311a1c67b1da8a65f7e2fb95a43c06fe59d72c66d49194a397b047f75528f9ef799c0a4aa15d6e8
7
+ data.tar.gz: 5973a992263ad1fbd07e8379a09dd76d21a404948b02a3739a6576ee3cf84076b55124cfc1322e73f9c2b2e37913606edd5fb2e935867cd2a27087803978f1db
@@ -0,0 +1,5 @@
1
+ lib/**/*.rb
2
+ bin/*
3
+ -
4
+ features/**/*.feature
5
+ LICENSE.txt
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
@@ -0,0 +1,10 @@
1
+ language: ruby
2
+
3
+ sudo: false
4
+
5
+ rvm:
6
+ - 2.3.0
7
+
8
+ gemfile:
9
+ - gemfiles/Gemfile-rails.4.2.x
10
+ - gemfiles/Gemfile-rails.5.0.0.beta3
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in nested_scaffold.gemspec
4
+ gemspec
@@ -1,6 +1,6 @@
1
1
  = nested_scaffold
2
2
 
3
- A scaffold command that generates a set of perfectly working nested resource for Rails 3.
3
+ A scaffold command that generates a set of perfectly working nested resource for Rails 4.2 and 5
4
4
 
5
5
  == Features
6
6
 
@@ -11,7 +11,7 @@ A scaffold command that generates a set of perfectly working nested resource for
11
11
 
12
12
  == Rails versions
13
13
 
14
- 3.0.x, 3.1 and 3.2
14
+ 4.2, 5.0
15
15
 
16
16
  == Install
17
17
 
@@ -45,22 +45,13 @@ Basically same as the original scaffold.
45
45
  == TODO / known issues
46
46
 
47
47
  * namespace (who needs?)
48
- * valid fixtures (who uses?)
49
- * some generated functional tests fail (who cares?)
50
- * RSpec
51
48
  * third party orms
52
49
  * fixture replacements
53
50
 
54
51
  == Contributing to nested_scaffold
55
52
 
56
- * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
57
- * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
58
- * Fork the project
59
- * Start a feature/bugfix branch
60
- * Commit and push until you are happy with your contribution
61
- * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
53
+ Pull requests are welcome on GitHub at https://github.com/amatsuda/nested_scaffold
62
54
 
63
55
  == Copyright
64
56
 
65
- Copyright (c) 2010 Akira Matsuda. See LICENSE.txt for
66
- further details.
57
+ Copyright (c) 2010 Akira Matsuda. The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
data/Rakefile CHANGED
@@ -1,38 +1,10 @@
1
- #!/usr/bin/env rake
2
- begin
3
- require 'bundler/setup'
4
- rescue LoadError
5
- puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
6
- end
7
- begin
8
- require 'rdoc/task'
9
- rescue LoadError
10
- require 'rdoc/rdoc'
11
- require 'rake/rdoctask'
12
- RDoc::Task = Rake::RDocTask
13
- end
14
-
15
- RDoc::Task.new(:rdoc) do |rdoc|
16
- rdoc.rdoc_dir = 'rdoc'
17
- rdoc.title = 'Nested Scaffold'
18
- rdoc.options << '--line-numbers'
19
- rdoc.rdoc_files.include('README.rdoc')
20
- rdoc.rdoc_files.include('lib/**/*.rb')
21
- end
22
-
23
-
24
-
25
-
26
- Bundler::GemHelper.install_tasks
27
-
28
- require 'rake/testtask'
1
+ require "bundler/gem_tasks"
2
+ require "rake/testtask"
29
3
 
30
4
  Rake::TestTask.new(:test) do |t|
31
- t.libs << 'lib'
32
- t.libs << 'test'
33
- t.pattern = 'test/**/*_test.rb'
34
- t.verbose = false
5
+ t.libs << "test"
6
+ t.libs << "lib"
7
+ t.test_files = FileList['test/**/*_test.rb'].reject {|f| f.start_with?('test/dummy/test') }
35
8
  end
36
9
 
37
-
38
10
  task :default => :test
@@ -0,0 +1,7 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gem 'nested_scaffold', path: '..'
4
+
5
+ gem 'rails', '~> 4.2.0'
6
+ gem 'sqlite3'
7
+ gem 'minitest', '~> 5.0'
@@ -0,0 +1,114 @@
1
+ PATH
2
+ remote: ..
3
+ specs:
4
+ nested_scaffold (1.0.0)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ actionmailer (4.2.6)
10
+ actionpack (= 4.2.6)
11
+ actionview (= 4.2.6)
12
+ activejob (= 4.2.6)
13
+ mail (~> 2.5, >= 2.5.4)
14
+ rails-dom-testing (~> 1.0, >= 1.0.5)
15
+ actionpack (4.2.6)
16
+ actionview (= 4.2.6)
17
+ activesupport (= 4.2.6)
18
+ rack (~> 1.6)
19
+ rack-test (~> 0.6.2)
20
+ rails-dom-testing (~> 1.0, >= 1.0.5)
21
+ rails-html-sanitizer (~> 1.0, >= 1.0.2)
22
+ actionview (4.2.6)
23
+ activesupport (= 4.2.6)
24
+ builder (~> 3.1)
25
+ erubis (~> 2.7.0)
26
+ rails-dom-testing (~> 1.0, >= 1.0.5)
27
+ rails-html-sanitizer (~> 1.0, >= 1.0.2)
28
+ activejob (4.2.6)
29
+ activesupport (= 4.2.6)
30
+ globalid (>= 0.3.0)
31
+ activemodel (4.2.6)
32
+ activesupport (= 4.2.6)
33
+ builder (~> 3.1)
34
+ activerecord (4.2.6)
35
+ activemodel (= 4.2.6)
36
+ activesupport (= 4.2.6)
37
+ arel (~> 6.0)
38
+ activesupport (4.2.6)
39
+ i18n (~> 0.7)
40
+ json (~> 1.7, >= 1.7.7)
41
+ minitest (~> 5.1)
42
+ thread_safe (~> 0.3, >= 0.3.4)
43
+ tzinfo (~> 1.1)
44
+ arel (6.0.3)
45
+ builder (3.2.2)
46
+ concurrent-ruby (1.0.1)
47
+ erubis (2.7.0)
48
+ globalid (0.3.6)
49
+ activesupport (>= 4.1.0)
50
+ i18n (0.7.0)
51
+ json (1.8.3)
52
+ loofah (2.0.3)
53
+ nokogiri (>= 1.5.9)
54
+ mail (2.6.4)
55
+ mime-types (>= 1.16, < 4)
56
+ mime-types (3.0)
57
+ mime-types-data (~> 3.2015)
58
+ mime-types-data (3.2016.0221)
59
+ mini_portile2 (2.0.0)
60
+ minitest (5.8.4)
61
+ nokogiri (1.6.7.2)
62
+ mini_portile2 (~> 2.0.0.rc2)
63
+ rack (1.6.4)
64
+ rack-test (0.6.3)
65
+ rack (>= 1.0)
66
+ rails (4.2.6)
67
+ actionmailer (= 4.2.6)
68
+ actionpack (= 4.2.6)
69
+ actionview (= 4.2.6)
70
+ activejob (= 4.2.6)
71
+ activemodel (= 4.2.6)
72
+ activerecord (= 4.2.6)
73
+ activesupport (= 4.2.6)
74
+ bundler (>= 1.3.0, < 2.0)
75
+ railties (= 4.2.6)
76
+ sprockets-rails
77
+ rails-deprecated_sanitizer (1.0.3)
78
+ activesupport (>= 4.2.0.alpha)
79
+ rails-dom-testing (1.0.7)
80
+ activesupport (>= 4.2.0.beta, < 5.0)
81
+ nokogiri (~> 1.6.0)
82
+ rails-deprecated_sanitizer (>= 1.0.1)
83
+ rails-html-sanitizer (1.0.3)
84
+ loofah (~> 2.0)
85
+ railties (4.2.6)
86
+ actionpack (= 4.2.6)
87
+ activesupport (= 4.2.6)
88
+ rake (>= 0.8.7)
89
+ thor (>= 0.18.1, < 2.0)
90
+ rake (11.1.2)
91
+ sprockets (3.5.2)
92
+ concurrent-ruby (~> 1.0)
93
+ rack (> 1, < 3)
94
+ sprockets-rails (3.0.4)
95
+ actionpack (>= 4.0)
96
+ activesupport (>= 4.0)
97
+ sprockets (>= 3.0.0)
98
+ sqlite3 (1.3.11)
99
+ thor (0.19.1)
100
+ thread_safe (0.3.5)
101
+ tzinfo (1.2.2)
102
+ thread_safe (~> 0.1)
103
+
104
+ PLATFORMS
105
+ ruby
106
+
107
+ DEPENDENCIES
108
+ minitest (~> 5.0)
109
+ nested_scaffold!
110
+ rails (~> 4.2.0)
111
+ sqlite3
112
+
113
+ BUNDLED WITH
114
+ 1.11.2
@@ -0,0 +1,7 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gem 'nested_scaffold', path: '..'
4
+
5
+ gem 'rails', '~> 5.0.0.beta3'
6
+ gem 'sqlite3'
7
+ gem 'minitest', '~> 5.0'
@@ -0,0 +1,124 @@
1
+ PATH
2
+ remote: ..
3
+ specs:
4
+ nested_scaffold (1.0.0)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ actioncable (5.0.0.beta3)
10
+ actionpack (= 5.0.0.beta3)
11
+ nio4r (~> 1.2)
12
+ websocket-driver (~> 0.6.1)
13
+ actionmailer (5.0.0.beta3)
14
+ actionpack (= 5.0.0.beta3)
15
+ actionview (= 5.0.0.beta3)
16
+ activejob (= 5.0.0.beta3)
17
+ mail (~> 2.5, >= 2.5.4)
18
+ rails-dom-testing (~> 1.0, >= 1.0.5)
19
+ actionpack (5.0.0.beta3)
20
+ actionview (= 5.0.0.beta3)
21
+ activesupport (= 5.0.0.beta3)
22
+ rack (~> 2.x)
23
+ rack-test (~> 0.6.3)
24
+ rails-dom-testing (~> 1.0, >= 1.0.5)
25
+ rails-html-sanitizer (~> 1.0, >= 1.0.2)
26
+ actionview (5.0.0.beta3)
27
+ activesupport (= 5.0.0.beta3)
28
+ builder (~> 3.1)
29
+ erubis (~> 2.7.0)
30
+ rails-dom-testing (~> 1.0, >= 1.0.5)
31
+ rails-html-sanitizer (~> 1.0, >= 1.0.2)
32
+ activejob (5.0.0.beta3)
33
+ activesupport (= 5.0.0.beta3)
34
+ globalid (>= 0.3.6)
35
+ activemodel (5.0.0.beta3)
36
+ activesupport (= 5.0.0.beta3)
37
+ activerecord (5.0.0.beta3)
38
+ activemodel (= 5.0.0.beta3)
39
+ activesupport (= 5.0.0.beta3)
40
+ arel (~> 7.0)
41
+ activesupport (5.0.0.beta3)
42
+ concurrent-ruby (~> 1.0)
43
+ i18n (~> 0.7)
44
+ minitest (~> 5.1)
45
+ tzinfo (~> 1.1)
46
+ arel (7.0.0)
47
+ builder (3.2.2)
48
+ concurrent-ruby (1.0.1)
49
+ erubis (2.7.0)
50
+ globalid (0.3.6)
51
+ activesupport (>= 4.1.0)
52
+ i18n (0.7.0)
53
+ json (1.8.3)
54
+ loofah (2.0.3)
55
+ nokogiri (>= 1.5.9)
56
+ mail (2.6.4)
57
+ mime-types (>= 1.16, < 4)
58
+ method_source (0.8.2)
59
+ mime-types (3.0)
60
+ mime-types-data (~> 3.2015)
61
+ mime-types-data (3.2016.0221)
62
+ mini_portile2 (2.0.0)
63
+ minitest (5.8.4)
64
+ nio4r (1.2.1)
65
+ nokogiri (1.6.7.2)
66
+ mini_portile2 (~> 2.0.0.rc2)
67
+ rack (2.0.0.alpha)
68
+ json
69
+ rack-test (0.6.3)
70
+ rack (>= 1.0)
71
+ rails (5.0.0.beta3)
72
+ actioncable (= 5.0.0.beta3)
73
+ actionmailer (= 5.0.0.beta3)
74
+ actionpack (= 5.0.0.beta3)
75
+ actionview (= 5.0.0.beta3)
76
+ activejob (= 5.0.0.beta3)
77
+ activemodel (= 5.0.0.beta3)
78
+ activerecord (= 5.0.0.beta3)
79
+ activesupport (= 5.0.0.beta3)
80
+ bundler (>= 1.3.0, < 2.0)
81
+ railties (= 5.0.0.beta3)
82
+ sprockets-rails (>= 2.0.0)
83
+ rails-deprecated_sanitizer (1.0.3)
84
+ activesupport (>= 4.2.0.alpha)
85
+ rails-dom-testing (1.0.7)
86
+ activesupport (>= 4.2.0.beta, < 5.0)
87
+ nokogiri (~> 1.6.0)
88
+ rails-deprecated_sanitizer (>= 1.0.1)
89
+ rails-html-sanitizer (1.0.3)
90
+ loofah (~> 2.0)
91
+ railties (5.0.0.beta3)
92
+ actionpack (= 5.0.0.beta3)
93
+ activesupport (= 5.0.0.beta3)
94
+ method_source
95
+ rake (>= 0.8.7)
96
+ thor (>= 0.18.1, < 2.0)
97
+ rake (11.1.2)
98
+ sprockets (3.5.2)
99
+ concurrent-ruby (~> 1.0)
100
+ rack (> 1, < 3)
101
+ sprockets-rails (3.0.4)
102
+ actionpack (>= 4.0)
103
+ activesupport (>= 4.0)
104
+ sprockets (>= 3.0.0)
105
+ sqlite3 (1.3.11)
106
+ thor (0.19.1)
107
+ thread_safe (0.3.5)
108
+ tzinfo (1.2.2)
109
+ thread_safe (~> 0.1)
110
+ websocket-driver (0.6.3)
111
+ websocket-extensions (>= 0.1.0)
112
+ websocket-extensions (0.1.2)
113
+
114
+ PLATFORMS
115
+ ruby
116
+
117
+ DEPENDENCIES
118
+ minitest (~> 5.0)
119
+ nested_scaffold!
120
+ rails (~> 5.0.0.beta3)
121
+ sqlite3
122
+
123
+ BUNDLED WITH
124
+ 1.11.2
@@ -21,14 +21,14 @@ module NestedScaffold
21
21
  attributes.delete_if {|a| (a.name == nested_parent_id) && (a.type.to_s == 'integer')}
22
22
  unless attributes.map {|a| [a.name, a.type.to_s]}.include? [nested_parent_name, 'references']
23
23
  #DIRTY HACK add 'references' attribute
24
- attributes.insert 0, Rails::Generators::GeneratedAttribute.new(nested_parent_name, 'references')
24
+ attributes.insert 0, Rails::Generators::GeneratedAttribute.new(nested_parent_name, :references)
25
25
  end
26
26
  end
27
27
 
28
28
  # add has_many_association to parent model
29
29
  def add_association
30
30
  if File.exist?(parent_file = File.join('app/models', "#{nested_parent_name}.rb"))
31
- inject_into_file parent_file, " has_many :#{table_name}\n", :after => " < ActiveRecord::Base\n"
31
+ inject_into_file parent_file, " has_many :#{table_name}\n", :after => / < (ActiveRecord::Base|ApplicationRecord)\n/
32
32
  end
33
33
  end
34
34
 
@@ -2,6 +2,6 @@
2
2
 
3
3
  = render 'form'
4
4
 
5
- = link_to 'Show', [@<%= singular_table_name %>.<%= nested_parent_name %>, @<%= singular_table_name %>] %>
5
+ = link_to 'Show', [@<%= singular_table_name %>.<%= nested_parent_name %>, @<%= singular_table_name %>]
6
6
  \|
7
7
  = link_to 'Back', <%= nested_parent_name %>_<%= index_helper %>_path(@<%= singular_table_name %>.<%= nested_parent_name %>)
@@ -9,15 +9,15 @@ module NestedScaffold
9
9
  include ::NestedScaffold::Base
10
10
 
11
11
  # override ScaffoldGenerator
12
- hook_for :scaffold_controller, :required => true
12
+ hook_for :scaffold_controller, required: true
13
13
 
14
14
  # Ensure assets get created with the correct name
15
- hook_for :assets, :in => :rails do |source, generator|
15
+ hook_for :assets, in: :rails do |source, generator|
16
16
  source.invoke generator, [ source.file_name.pluralize ]
17
17
  end
18
18
 
19
19
  # override ModelGenerator
20
- hook_for :orm, :required => true
20
+ hook_for :orm, required: true
21
21
 
22
22
  # replacing hook for adding config/routes
23
23
  remove_hook_for :resource_route
@@ -28,6 +28,8 @@ module NestedScaffold
28
28
  route_config << " resources :#{file_name.pluralize}\n"
29
29
  route_config << " end"
30
30
  route route_config
31
+
32
+ gsub_file 'config/routes.rb', / *resources :#{plural_nested_parent_name}\n/, ''
31
33
  end
32
34
  end
33
35
  end
@@ -14,10 +14,10 @@ module NestedScaffold
14
14
 
15
15
  # override ScaffoldControllerGenerator
16
16
  hook_for :template_engine
17
- hook_for :test_framework, :in => 'nested_scaffold:scaffold'
17
+ hook_for :test_framework, in: 'nested_scaffold:scaffold'
18
18
 
19
19
  # override ScaffoldControllerGenerator
20
- hook_for :helper, :as => :scaffold do |invoked|
20
+ hook_for :helper, as: :scaffold do |invoked|
21
21
  invoke invoked, [ controller_name ]
22
22
  end
23
23
  end