ryanb-nifty-generators 0.1.4 → 0.1.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (39) hide show
  1. data/CHANGELOG +6 -0
  2. data/Manifest +30 -23
  3. data/nifty-generators.gemspec +5 -5
  4. data/rails_generators/nifty_layout/nifty_layout_generator.rb +17 -4
  5. data/rails_generators/nifty_layout/templates/layout.html.haml +19 -0
  6. data/rails_generators/nifty_layout/templates/stylesheet.css +5 -7
  7. data/rails_generators/nifty_layout/templates/stylesheet.sass +66 -0
  8. data/rails_generators/nifty_scaffold/nifty_scaffold_generator.rb +18 -10
  9. data/rails_generators/nifty_scaffold/templates/{action_specs → tests/rspec/actions}/create.rb +0 -0
  10. data/rails_generators/nifty_scaffold/templates/{action_specs → tests/rspec/actions}/destroy.rb +0 -0
  11. data/rails_generators/nifty_scaffold/templates/{action_specs → tests/rspec/actions}/edit.rb +0 -0
  12. data/rails_generators/nifty_scaffold/templates/{action_specs → tests/rspec/actions}/index.rb +0 -0
  13. data/rails_generators/nifty_scaffold/templates/{action_specs → tests/rspec/actions}/new.rb +0 -0
  14. data/rails_generators/nifty_scaffold/templates/{action_specs → tests/rspec/actions}/show.rb +0 -0
  15. data/rails_generators/nifty_scaffold/templates/{action_specs → tests/rspec/actions}/update.rb +0 -0
  16. data/rails_generators/nifty_scaffold/templates/{controller_spec.rb → tests/rspec/controller.rb} +1 -1
  17. data/rails_generators/nifty_scaffold/templates/{model_spec.rb → tests/rspec/model.rb} +0 -0
  18. data/rails_generators/nifty_scaffold/templates/{action_tests → tests/testunit/actions}/create.rb +0 -0
  19. data/rails_generators/nifty_scaffold/templates/{action_tests → tests/testunit/actions}/destroy.rb +0 -0
  20. data/rails_generators/nifty_scaffold/templates/{action_tests → tests/testunit/actions}/edit.rb +0 -0
  21. data/rails_generators/nifty_scaffold/templates/{action_tests → tests/testunit/actions}/index.rb +0 -0
  22. data/rails_generators/nifty_scaffold/templates/{action_tests → tests/testunit/actions}/new.rb +0 -0
  23. data/rails_generators/nifty_scaffold/templates/{action_tests → tests/testunit/actions}/show.rb +0 -0
  24. data/rails_generators/nifty_scaffold/templates/{action_tests → tests/testunit/actions}/update.rb +0 -0
  25. data/rails_generators/nifty_scaffold/templates/{controller_test.rb → tests/testunit/controller.rb} +1 -1
  26. data/rails_generators/nifty_scaffold/templates/{model_test.rb → tests/testunit/model.rb} +0 -0
  27. data/rails_generators/nifty_scaffold/templates/views/{_form.html.erb → erb/_form.html.erb} +0 -0
  28. data/rails_generators/nifty_scaffold/templates/views/{edit.html.erb → erb/edit.html.erb} +0 -0
  29. data/rails_generators/nifty_scaffold/templates/views/{index.html.erb → erb/index.html.erb} +0 -0
  30. data/rails_generators/nifty_scaffold/templates/views/{new.html.erb → erb/new.html.erb} +0 -0
  31. data/rails_generators/nifty_scaffold/templates/views/{show.html.erb → erb/show.html.erb} +0 -0
  32. data/rails_generators/nifty_scaffold/templates/views/haml/_form.html.haml +11 -0
  33. data/rails_generators/nifty_scaffold/templates/views/haml/edit.html.haml +14 -0
  34. data/rails_generators/nifty_scaffold/templates/views/haml/index.html.haml +25 -0
  35. data/rails_generators/nifty_scaffold/templates/views/haml/new.html.haml +7 -0
  36. data/rails_generators/nifty_scaffold/templates/views/haml/show.html.haml +20 -0
  37. data/test/test_nifty_layout_generator.rb +6 -0
  38. data/test/test_nifty_scaffold_generator.rb +16 -0
  39. metadata +32 -25
data/CHANGELOG CHANGED
@@ -1,3 +1,9 @@
1
+ *0.1.5* (August 7th, 2008)
2
+
3
+ * adding option to nifty layout to generate HAML views and SASS stylesheets
4
+
5
+ * adding option to nifty scaffold to generate HAML views
6
+
1
7
  *0.1.4* (July 21st, 2008)
2
8
 
3
9
  * using same logic as model spec in model test for scaffold
data/Manifest CHANGED
@@ -9,23 +9,11 @@ rails_generators/nifty_config/USAGE
9
9
  rails_generators/nifty_layout/nifty_layout_generator.rb
10
10
  rails_generators/nifty_layout/templates/helper.rb
11
11
  rails_generators/nifty_layout/templates/layout.html.erb
12
+ rails_generators/nifty_layout/templates/layout.html.haml
12
13
  rails_generators/nifty_layout/templates/stylesheet.css
14
+ rails_generators/nifty_layout/templates/stylesheet.sass
13
15
  rails_generators/nifty_layout/USAGE
14
16
  rails_generators/nifty_scaffold/nifty_scaffold_generator.rb
15
- rails_generators/nifty_scaffold/templates/action_specs/create.rb
16
- rails_generators/nifty_scaffold/templates/action_specs/destroy.rb
17
- rails_generators/nifty_scaffold/templates/action_specs/edit.rb
18
- rails_generators/nifty_scaffold/templates/action_specs/index.rb
19
- rails_generators/nifty_scaffold/templates/action_specs/new.rb
20
- rails_generators/nifty_scaffold/templates/action_specs/show.rb
21
- rails_generators/nifty_scaffold/templates/action_specs/update.rb
22
- rails_generators/nifty_scaffold/templates/action_tests/create.rb
23
- rails_generators/nifty_scaffold/templates/action_tests/destroy.rb
24
- rails_generators/nifty_scaffold/templates/action_tests/edit.rb
25
- rails_generators/nifty_scaffold/templates/action_tests/index.rb
26
- rails_generators/nifty_scaffold/templates/action_tests/new.rb
27
- rails_generators/nifty_scaffold/templates/action_tests/show.rb
28
- rails_generators/nifty_scaffold/templates/action_tests/update.rb
29
17
  rails_generators/nifty_scaffold/templates/actions/create.rb
30
18
  rails_generators/nifty_scaffold/templates/actions/destroy.rb
31
19
  rails_generators/nifty_scaffold/templates/actions/edit.rb
@@ -34,19 +22,38 @@ rails_generators/nifty_scaffold/templates/actions/new.rb
34
22
  rails_generators/nifty_scaffold/templates/actions/show.rb
35
23
  rails_generators/nifty_scaffold/templates/actions/update.rb
36
24
  rails_generators/nifty_scaffold/templates/controller.rb
37
- rails_generators/nifty_scaffold/templates/controller_spec.rb
38
- rails_generators/nifty_scaffold/templates/controller_test.rb
39
25
  rails_generators/nifty_scaffold/templates/fixtures.yml
40
26
  rails_generators/nifty_scaffold/templates/helper.rb
41
27
  rails_generators/nifty_scaffold/templates/migration.rb
42
28
  rails_generators/nifty_scaffold/templates/model.rb
43
- rails_generators/nifty_scaffold/templates/model_spec.rb
44
- rails_generators/nifty_scaffold/templates/model_test.rb
45
- rails_generators/nifty_scaffold/templates/views/_form.html.erb
46
- rails_generators/nifty_scaffold/templates/views/edit.html.erb
47
- rails_generators/nifty_scaffold/templates/views/index.html.erb
48
- rails_generators/nifty_scaffold/templates/views/new.html.erb
49
- rails_generators/nifty_scaffold/templates/views/show.html.erb
29
+ rails_generators/nifty_scaffold/templates/tests/rspec/actions/create.rb
30
+ rails_generators/nifty_scaffold/templates/tests/rspec/actions/destroy.rb
31
+ rails_generators/nifty_scaffold/templates/tests/rspec/actions/edit.rb
32
+ rails_generators/nifty_scaffold/templates/tests/rspec/actions/index.rb
33
+ rails_generators/nifty_scaffold/templates/tests/rspec/actions/new.rb
34
+ rails_generators/nifty_scaffold/templates/tests/rspec/actions/show.rb
35
+ rails_generators/nifty_scaffold/templates/tests/rspec/actions/update.rb
36
+ rails_generators/nifty_scaffold/templates/tests/rspec/controller.rb
37
+ rails_generators/nifty_scaffold/templates/tests/rspec/model.rb
38
+ rails_generators/nifty_scaffold/templates/tests/testunit/actions/create.rb
39
+ rails_generators/nifty_scaffold/templates/tests/testunit/actions/destroy.rb
40
+ rails_generators/nifty_scaffold/templates/tests/testunit/actions/edit.rb
41
+ rails_generators/nifty_scaffold/templates/tests/testunit/actions/index.rb
42
+ rails_generators/nifty_scaffold/templates/tests/testunit/actions/new.rb
43
+ rails_generators/nifty_scaffold/templates/tests/testunit/actions/show.rb
44
+ rails_generators/nifty_scaffold/templates/tests/testunit/actions/update.rb
45
+ rails_generators/nifty_scaffold/templates/tests/testunit/controller.rb
46
+ rails_generators/nifty_scaffold/templates/tests/testunit/model.rb
47
+ rails_generators/nifty_scaffold/templates/views/erb/_form.html.erb
48
+ rails_generators/nifty_scaffold/templates/views/erb/edit.html.erb
49
+ rails_generators/nifty_scaffold/templates/views/erb/index.html.erb
50
+ rails_generators/nifty_scaffold/templates/views/erb/new.html.erb
51
+ rails_generators/nifty_scaffold/templates/views/erb/show.html.erb
52
+ rails_generators/nifty_scaffold/templates/views/haml/_form.html.haml
53
+ rails_generators/nifty_scaffold/templates/views/haml/edit.html.haml
54
+ rails_generators/nifty_scaffold/templates/views/haml/index.html.haml
55
+ rails_generators/nifty_scaffold/templates/views/haml/new.html.haml
56
+ rails_generators/nifty_scaffold/templates/views/haml/show.html.haml
50
57
  rails_generators/nifty_scaffold/USAGE
51
58
  README
52
59
  tasks/deployment.rake
@@ -1,18 +1,18 @@
1
1
 
2
- # Gem::Specification for Nifty-generators-0.1.4
2
+ # Gem::Specification for Nifty-generators-0.1.5
3
3
  # Originally generated by Echoe
4
4
 
5
5
  Gem::Specification.new do |s|
6
6
  s.name = %q{nifty-generators}
7
- s.version = "0.1.4"
7
+ s.version = "0.1.5"
8
8
 
9
9
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
10
10
  s.authors = ["Ryan Bates"]
11
- s.date = %q{2008-07-21}
11
+ s.date = %q{2008-08-07}
12
12
  s.description = %q{A collection of useful generator scripts for Rails.}
13
13
  s.email = %q{ryan (at) railscasts (dot) com}
14
14
  s.extra_rdoc_files = ["CHANGELOG", "lib/nifty_generators.rb", "LICENSE", "README", "tasks/deployment.rake", "TODO"]
15
- s.files = ["CHANGELOG", "lib/nifty_generators.rb", "LICENSE", "Manifest", "rails_generators/nifty_config/nifty_config_generator.rb", "rails_generators/nifty_config/templates/config.yml", "rails_generators/nifty_config/templates/load_config.rb", "rails_generators/nifty_config/USAGE", "rails_generators/nifty_layout/nifty_layout_generator.rb", "rails_generators/nifty_layout/templates/helper.rb", "rails_generators/nifty_layout/templates/layout.html.erb", "rails_generators/nifty_layout/templates/stylesheet.css", "rails_generators/nifty_layout/USAGE", "rails_generators/nifty_scaffold/nifty_scaffold_generator.rb", "rails_generators/nifty_scaffold/templates/action_specs/create.rb", "rails_generators/nifty_scaffold/templates/action_specs/destroy.rb", "rails_generators/nifty_scaffold/templates/action_specs/edit.rb", "rails_generators/nifty_scaffold/templates/action_specs/index.rb", "rails_generators/nifty_scaffold/templates/action_specs/new.rb", "rails_generators/nifty_scaffold/templates/action_specs/show.rb", "rails_generators/nifty_scaffold/templates/action_specs/update.rb", "rails_generators/nifty_scaffold/templates/action_tests/create.rb", "rails_generators/nifty_scaffold/templates/action_tests/destroy.rb", "rails_generators/nifty_scaffold/templates/action_tests/edit.rb", "rails_generators/nifty_scaffold/templates/action_tests/index.rb", "rails_generators/nifty_scaffold/templates/action_tests/new.rb", "rails_generators/nifty_scaffold/templates/action_tests/show.rb", "rails_generators/nifty_scaffold/templates/action_tests/update.rb", "rails_generators/nifty_scaffold/templates/actions/create.rb", "rails_generators/nifty_scaffold/templates/actions/destroy.rb", "rails_generators/nifty_scaffold/templates/actions/edit.rb", "rails_generators/nifty_scaffold/templates/actions/index.rb", "rails_generators/nifty_scaffold/templates/actions/new.rb", "rails_generators/nifty_scaffold/templates/actions/show.rb", "rails_generators/nifty_scaffold/templates/actions/update.rb", "rails_generators/nifty_scaffold/templates/controller.rb", "rails_generators/nifty_scaffold/templates/controller_spec.rb", "rails_generators/nifty_scaffold/templates/controller_test.rb", "rails_generators/nifty_scaffold/templates/fixtures.yml", "rails_generators/nifty_scaffold/templates/helper.rb", "rails_generators/nifty_scaffold/templates/migration.rb", "rails_generators/nifty_scaffold/templates/model.rb", "rails_generators/nifty_scaffold/templates/model_spec.rb", "rails_generators/nifty_scaffold/templates/model_test.rb", "rails_generators/nifty_scaffold/templates/views/_form.html.erb", "rails_generators/nifty_scaffold/templates/views/edit.html.erb", "rails_generators/nifty_scaffold/templates/views/index.html.erb", "rails_generators/nifty_scaffold/templates/views/new.html.erb", "rails_generators/nifty_scaffold/templates/views/show.html.erb", "rails_generators/nifty_scaffold/USAGE", "README", "tasks/deployment.rake", "test/test_helper.rb", "test/test_nifty_config_generator.rb", "test/test_nifty_layout_generator.rb", "test/test_nifty_scaffold_generator.rb", "TODO", "nifty-generators.gemspec"]
15
+ s.files = ["CHANGELOG", "lib/nifty_generators.rb", "LICENSE", "Manifest", "rails_generators/nifty_config/nifty_config_generator.rb", "rails_generators/nifty_config/templates/config.yml", "rails_generators/nifty_config/templates/load_config.rb", "rails_generators/nifty_config/USAGE", "rails_generators/nifty_layout/nifty_layout_generator.rb", "rails_generators/nifty_layout/templates/helper.rb", "rails_generators/nifty_layout/templates/layout.html.erb", "rails_generators/nifty_layout/templates/layout.html.haml", "rails_generators/nifty_layout/templates/stylesheet.css", "rails_generators/nifty_layout/templates/stylesheet.sass", "rails_generators/nifty_layout/USAGE", "rails_generators/nifty_scaffold/nifty_scaffold_generator.rb", "rails_generators/nifty_scaffold/templates/actions/create.rb", "rails_generators/nifty_scaffold/templates/actions/destroy.rb", "rails_generators/nifty_scaffold/templates/actions/edit.rb", "rails_generators/nifty_scaffold/templates/actions/index.rb", "rails_generators/nifty_scaffold/templates/actions/new.rb", "rails_generators/nifty_scaffold/templates/actions/show.rb", "rails_generators/nifty_scaffold/templates/actions/update.rb", "rails_generators/nifty_scaffold/templates/controller.rb", "rails_generators/nifty_scaffold/templates/fixtures.yml", "rails_generators/nifty_scaffold/templates/helper.rb", "rails_generators/nifty_scaffold/templates/migration.rb", "rails_generators/nifty_scaffold/templates/model.rb", "rails_generators/nifty_scaffold/templates/tests/rspec/actions/create.rb", "rails_generators/nifty_scaffold/templates/tests/rspec/actions/destroy.rb", "rails_generators/nifty_scaffold/templates/tests/rspec/actions/edit.rb", "rails_generators/nifty_scaffold/templates/tests/rspec/actions/index.rb", "rails_generators/nifty_scaffold/templates/tests/rspec/actions/new.rb", "rails_generators/nifty_scaffold/templates/tests/rspec/actions/show.rb", "rails_generators/nifty_scaffold/templates/tests/rspec/actions/update.rb", "rails_generators/nifty_scaffold/templates/tests/rspec/controller.rb", "rails_generators/nifty_scaffold/templates/tests/rspec/model.rb", "rails_generators/nifty_scaffold/templates/tests/testunit/actions/create.rb", "rails_generators/nifty_scaffold/templates/tests/testunit/actions/destroy.rb", "rails_generators/nifty_scaffold/templates/tests/testunit/actions/edit.rb", "rails_generators/nifty_scaffold/templates/tests/testunit/actions/index.rb", "rails_generators/nifty_scaffold/templates/tests/testunit/actions/new.rb", "rails_generators/nifty_scaffold/templates/tests/testunit/actions/show.rb", "rails_generators/nifty_scaffold/templates/tests/testunit/actions/update.rb", "rails_generators/nifty_scaffold/templates/tests/testunit/controller.rb", "rails_generators/nifty_scaffold/templates/tests/testunit/model.rb", "rails_generators/nifty_scaffold/templates/views/erb/_form.html.erb", "rails_generators/nifty_scaffold/templates/views/erb/edit.html.erb", "rails_generators/nifty_scaffold/templates/views/erb/index.html.erb", "rails_generators/nifty_scaffold/templates/views/erb/new.html.erb", "rails_generators/nifty_scaffold/templates/views/erb/show.html.erb", "rails_generators/nifty_scaffold/templates/views/haml/_form.html.haml", "rails_generators/nifty_scaffold/templates/views/haml/edit.html.haml", "rails_generators/nifty_scaffold/templates/views/haml/index.html.haml", "rails_generators/nifty_scaffold/templates/views/haml/new.html.haml", "rails_generators/nifty_scaffold/templates/views/haml/show.html.haml", "rails_generators/nifty_scaffold/USAGE", "README", "tasks/deployment.rake", "test/test_helper.rb", "test/test_nifty_config_generator.rb", "test/test_nifty_layout_generator.rb", "test/test_nifty_scaffold_generator.rb", "TODO", "nifty-generators.gemspec"]
16
16
  s.has_rdoc = true
17
17
  s.homepage = %q{http://github.com/ryanb/nifty-generators}
18
18
  s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Nifty-generators", "--main", "README"]
@@ -42,7 +42,7 @@ end
42
42
  # begin
43
43
  # require 'echoe'
44
44
  #
45
- # Echoe.new('nifty-generators', '0.1.4') do |p|
45
+ # Echoe.new('nifty-generators', '0.1.5') do |p|
46
46
  # p.summary = "A collection of useful generator scripts for Rails."
47
47
  # p.description = "A collection of useful generator scripts for Rails."
48
48
  # p.url = "http://github.com/ryanb/nifty-generators"
@@ -9,10 +9,16 @@ class NiftyLayoutGenerator < Rails::Generator::Base
9
9
  m.directory 'app/views/layouts'
10
10
  m.directory 'public/stylesheets'
11
11
  m.directory 'app/helpers'
12
-
13
- m.template "layout.html.erb", "app/views/layouts/#{file_name}.html.erb"
14
- m.file "stylesheet.css", "public/stylesheets/#{file_name}.css"
15
- m.file "helper.rb", "app/helpers/layout_helper.rb"
12
+
13
+ if options[:haml]
14
+ m.directory 'public/stylesheets/sass'
15
+ m.template "layout.html.haml", "app/views/layouts/#{file_name}.html.haml"
16
+ m.file "stylesheet.sass", "public/stylesheets/sass/#{file_name}.sass"
17
+ else
18
+ m.template "layout.html.erb", "app/views/layouts/#{file_name}.html.erb"
19
+ m.file "stylesheet.css", "public/stylesheets/#{file_name}.css"
20
+ end
21
+ m.file "helper.rb", "app/helpers/layout_helper.rb"
16
22
  end
17
23
  end
18
24
 
@@ -21,6 +27,13 @@ class NiftyLayoutGenerator < Rails::Generator::Base
21
27
  end
22
28
 
23
29
  protected
30
+
31
+ def add_options!(opt)
32
+ opt.separator ''
33
+ opt.separator 'Options:'
34
+ opt.on("--haml", "Generate HAML for view, and SASS for stylesheet.") { |v| options[:haml] = v }
35
+ end
36
+
24
37
  def banner
25
38
  <<-EOS
26
39
  Creates generic layout, stylesheet, and helper files.
@@ -0,0 +1,19 @@
1
+ !!! Strict
2
+ %html{html_attrs}
3
+
4
+ %head
5
+ %title
6
+ = h(yield(:title) || "Untitled")
7
+ %meta{"http-equiv"=>"Content-Type", :content=>"text/html; charset=utf-8"}/
8
+ = stylesheet_link_tag '<%= file_name %>'
9
+ = yield(:head)
10
+
11
+ %body
12
+ #container
13
+ - flash.each do |name, msg|
14
+ = content_tag :div, msg, :id => "flash_#{name}"
15
+
16
+ - if show_title?
17
+ %h1=h yield(:title)
18
+
19
+ = yield
@@ -1,5 +1,5 @@
1
1
  body {
2
- background-color: #FFF;
2
+ background-color: #4B7399;
3
3
  font-family: Verdana, Helvetica, Arial;
4
4
  font-size: 14px;
5
5
  }
@@ -12,8 +12,10 @@ a {
12
12
  color: #0000FF;
13
13
  }
14
14
 
15
- body {
16
- background-color: #4B7399;
15
+ .clear {
16
+ clear: both;
17
+ height: 0px;
18
+ overflow: hidden;
17
19
  }
18
20
 
19
21
  #container {
@@ -40,10 +42,6 @@ body {
40
42
  border: solid 1px #C66;
41
43
  }
42
44
 
43
- .clear {
44
- clear: both;
45
- }
46
-
47
45
 
48
46
 
49
47
  .fieldWithErrors {
@@ -0,0 +1,66 @@
1
+ !primary_color = #4B7399
2
+
3
+ body
4
+ :background-color = !primary_color
5
+ :font
6
+ :family Verdana, Helvetica, Arial
7
+ :size 14px
8
+
9
+ ul li
10
+ :list-style none
11
+
12
+ a
13
+ :color #0000FF
14
+ img
15
+ :border none
16
+
17
+ .clear
18
+ :clear both
19
+ :height 0px
20
+ :overflow hidden
21
+
22
+ #container
23
+ :width 75%
24
+ :margin 0 auto
25
+ :background #fff
26
+ :padding 20px 40px
27
+ :border solid 1px black
28
+ :margin-top 20px
29
+
30
+ #flash_notice,
31
+ #flash_error
32
+ :padding 5px 8px
33
+ :margin 10px 0
34
+
35
+ #flash_notice
36
+ :background-color #CFC
37
+ :border solid 1px #6C6
38
+
39
+ #flash_error
40
+ :background-color #FCC
41
+ :border solid 1px #C66
42
+
43
+ #errorExplanation
44
+ :width 400px
45
+ :border 2px solid #CF0000
46
+ :padding 0px
47
+ :padding-bottom 12px
48
+ :margin-bottom 20px
49
+ :background-color #f0f0f0
50
+ h2
51
+ :text-align left
52
+ :font-weight bold
53
+ :padding 5px 5px 5px 15px
54
+ :font-size 12px
55
+ :margin 0px
56
+ :background-color #c00
57
+ :color #fff
58
+ p
59
+ :color #333
60
+ :margin-bottom 0
61
+ :padding 8px
62
+ ul
63
+ :margin 2px 24px
64
+ li
65
+ :font-size 12px
66
+ :list-style disc
@@ -5,7 +5,6 @@ class NiftyScaffoldGenerator < Rails::Generator::Base
5
5
  super
6
6
  usage if @args.empty?
7
7
 
8
-
9
8
  @name = @args.first
10
9
  @controller_actions = []
11
10
  @attributes = []
@@ -52,12 +51,12 @@ class NiftyScaffoldGenerator < Rails::Generator::Base
52
51
 
53
52
  if spec_dir?
54
53
  m.directory "spec/models"
55
- m.template "model_spec.rb", "spec/models/#{singular_name}_spec.rb"
54
+ m.template "tests/rspec/model.rb", "spec/models/#{singular_name}_spec.rb"
56
55
  m.directory "spec/fixtures"
57
56
  m.template "fixtures.yml", "spec/fixtures/#{plural_name}.yml"
58
57
  else
59
58
  m.directory "test/unit"
60
- m.template "model_test.rb", "test/unit/#{singular_name}_test.rb"
59
+ m.template "tests/testunit/model.rb", "test/unit/#{singular_name}_test.rb"
61
60
  m.directory "test/fixtures"
62
61
  m.template "fixtures.yml", "test/fixtures/#{plural_name}.yml"
63
62
  end
@@ -72,23 +71,23 @@ class NiftyScaffoldGenerator < Rails::Generator::Base
72
71
 
73
72
  m.directory "app/views/#{plural_name}"
74
73
  controller_actions.each do |action|
75
- if File.exist? source_path("views/#{action}.html.erb")
76
- m.template "views/#{action}.html.erb", "app/views/#{plural_name}/#{action}.html.erb"
74
+ if File.exist? source_path("views/#{view_language}/#{action}.html.#{view_language}")
75
+ m.template "views/#{view_language}/#{action}.html.#{view_language}", "app/views/#{plural_name}/#{action}.html.#{view_language}"
77
76
  end
78
77
  end
79
78
 
80
79
  if form_partial?
81
- m.template "views/_form.html.erb", "app/views/#{plural_name}/_form.html.erb"
80
+ m.template "views/#{view_language}/_form.html.#{view_language}", "app/views/#{plural_name}/_form.html.#{view_language}"
82
81
  end
83
82
 
84
83
  m.route_resources plural_name
85
84
 
86
85
  if spec_dir?
87
86
  m.directory "spec/controllers"
88
- m.template "controller_spec.rb", "spec/controllers/#{plural_name}_controller_spec.rb"
87
+ m.template "tests/rspec/controller.rb", "spec/controllers/#{plural_name}_controller_spec.rb"
89
88
  else
90
89
  m.directory "test/functional"
91
- m.template "controller_test.rb", "test/functional/#{plural_name}_controller_test.rb"
90
+ m.template "tests/testunit/controller.rb", "test/functional/#{plural_name}_controller_test.rb"
92
91
  end
93
92
  end
94
93
  end
@@ -134,9 +133,13 @@ class NiftyScaffoldGenerator < Rails::Generator::Base
134
133
 
135
134
  def render_form
136
135
  if form_partial?
137
- "<%= render :partial => 'form' %>"
136
+ if options[:haml]
137
+ "= render :partial => 'form'"
138
+ else
139
+ "<%= render :partial => 'form' %>"
140
+ end
138
141
  else
139
- read_template("views/_form.html.erb")
142
+ read_template("views/#{view_language}/_form.html.#{view_language}")
140
143
  end
141
144
  end
142
145
 
@@ -176,6 +179,10 @@ class NiftyScaffoldGenerator < Rails::Generator::Base
176
179
 
177
180
  protected
178
181
 
182
+ def view_language
183
+ options[:haml] ? 'haml' : 'erb'
184
+ end
185
+
179
186
  def add_options!(opt)
180
187
  opt.separator ''
181
188
  opt.separator 'Options:'
@@ -184,6 +191,7 @@ protected
184
191
  opt.on("--skip-timestamps", "Don't add timestamps to migration file.") { |v| options[:skip_timestamps] = v }
185
192
  opt.on("--skip-controller", "Don't generate controller, helper, or views.") { |v| options[:skip_controller] = v }
186
193
  opt.on("--invert", "Generate all controller actions except these mentioned.") { |v| options[:invert] = v }
194
+ opt.on("--haml", "Generate HAML views instead of ERB.") { |v| options[:haml] = v }
187
195
  end
188
196
 
189
197
  # is there a better way to do this? Perhaps with const_defined?
@@ -4,5 +4,5 @@ describe <%= plural_class_name %>Controller do
4
4
  fixtures :all
5
5
  integrate_views
6
6
 
7
- <%= controller_methods :action_specs %>
7
+ <%= controller_methods 'tests/rspec/actions' %>
8
8
  end
@@ -1,5 +1,5 @@
1
1
  require 'test_helper'
2
2
 
3
3
  class <%= plural_class_name %>ControllerTest < ActionController::TestCase
4
- <%= controller_methods :action_tests %>
4
+ <%= controller_methods 'tests/testunit/actions' %>
5
5
  end
@@ -0,0 +1,11 @@
1
+ = error_messages_for :<%= singular_name %>
2
+
3
+ - form_for @<%= singular_name %> do |f|
4
+ <%- for attribute in attributes -%>
5
+ %p
6
+ =f.label :<%=attribute.name %>
7
+ %br
8
+ = f.<%= attribute.field_type %> :<%= attribute.name %>
9
+ <%- end -%>
10
+ %p
11
+ = f.submit "Submit"
@@ -0,0 +1,14 @@
1
+ - title "Edit <%= singular_name.titleize %>"
2
+
3
+ <%= render_form %>
4
+
5
+ <%- if actions? :show, :index -%>
6
+ %p
7
+ <%- if action? :show -%>
8
+ = link_to "Edit", edit_<%= singular_name %>_path(@<%= singular_name %>)
9
+ |
10
+ <%- end -%>
11
+ <%- if action? :index -%>
12
+ = link_to "View All", <%= plural_name %>_path
13
+ <%- end -%>
14
+ <%- end -%>
@@ -0,0 +1,25 @@
1
+ - title "<%= plural_name.titleize %>"
2
+
3
+ %table
4
+ %tr
5
+ <%- for attribute in attributes -%>
6
+ %th <%= attribute.column.human_name %>
7
+ <%- end -%>
8
+ - for <%= singular_name %> in @<%= plural_name %>
9
+ %tr
10
+ <%- for attribute in attributes -%>
11
+ %td= h <%= singular_name %>.<%= attribute.name %>
12
+ <%- end -%>
13
+ <%- if action? :show -%>
14
+ %td= link_to 'Show', <%= singular_name %>
15
+ <%- end -%>
16
+ <%- if action? :edit -%>
17
+ %td= link_to 'Edit', edit_<%= singular_name %>_path(<%= singular_name %>)
18
+ <%- end -%>
19
+ <%- if action? :destroy -%>
20
+ %td= link_to 'Destroy', <%= singular_name %>, :confirm => 'Are you sure?', :method => :delete
21
+ <%- end -%>
22
+
23
+ <%- if actions? :new -%>
24
+ %p= link_to "New <%= singular_name.titleize %>", new_<%= singular_name %>_path
25
+ <%- end -%>
@@ -0,0 +1,7 @@
1
+ - title "New <%= singular_name.titleize %>"
2
+
3
+ <%= render_form %>
4
+
5
+ <%- if action? :index -%>
6
+ %p= link_to "Back to List", <%= plural_name %>_path
7
+ <%- end -%>
@@ -0,0 +1,20 @@
1
+ - title "<%= singular_name.titleize %>"
2
+
3
+ <%- for attribute in attributes -%>
4
+ %p
5
+ %strong <%= attribute.column.human_name.titleize %>:
6
+ =h @<%= singular_name %>.<%= attribute.name %>
7
+ <%- end -%>
8
+
9
+ %p
10
+ <%- if action? :edit -%>
11
+ = link_to "Edit", edit_<%= singular_name %>_path(@<%= singular_name %>)
12
+ |
13
+ <%- end -%>
14
+ <%- if action? :destroy -%>
15
+ = link_to "Destroy", @<%= singular_name %>, :confirm => 'Are you sure?', :method => :delete
16
+ |
17
+ <%- end -%>
18
+ <%- if action? :index -%>
19
+ = link_to "View All", <%= plural_name %>_path
20
+ <%- end -%>
@@ -33,4 +33,10 @@ class TestNiftyLayoutGenerator < Test::Unit::TestCase
33
33
  rails_generator :nifty_layout, "FooBar"
34
34
  should_generate_file 'app/views/layouts/foo_bar.html.erb'
35
35
  end
36
+
37
+ context "generator with haml option" do
38
+ rails_generator :nifty_layout, "foobar", :haml => true
39
+ should_generate_file 'app/views/layouts/foobar.html.haml'
40
+ should_generate_file 'public/stylesheets/sass/foobar.sass'
41
+ end
36
42
  end
@@ -476,6 +476,22 @@ class TestNiftyScaffoldGenerator < Test::Unit::TestCase
476
476
  end
477
477
  end
478
478
  end
479
+
480
+ context "generator with haml option" do
481
+ rails_generator :nifty_scaffold, "LineItem", :haml => true
482
+
483
+ %w[index show new edit _form].each do |action|
484
+ should_generate_file "app/views/line_items/#{action}.html.haml"
485
+ end
486
+
487
+ should "render the form partial in views" do
488
+ %w[new edit].each do |action|
489
+ assert_generated_file "app/views/line_items/#{action}.html.haml" do |body|
490
+ assert_match /^= render :partial => 'form'$/, body
491
+ end
492
+ end
493
+ end
494
+ end
479
495
  end
480
496
  end
481
497
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ryanb-nifty-generators
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Bates
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-07-21 00:00:00 -07:00
12
+ date: 2008-08-07 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies: []
15
15
 
@@ -38,23 +38,11 @@ files:
38
38
  - rails_generators/nifty_layout/nifty_layout_generator.rb
39
39
  - rails_generators/nifty_layout/templates/helper.rb
40
40
  - rails_generators/nifty_layout/templates/layout.html.erb
41
+ - rails_generators/nifty_layout/templates/layout.html.haml
41
42
  - rails_generators/nifty_layout/templates/stylesheet.css
43
+ - rails_generators/nifty_layout/templates/stylesheet.sass
42
44
  - rails_generators/nifty_layout/USAGE
43
45
  - rails_generators/nifty_scaffold/nifty_scaffold_generator.rb
44
- - rails_generators/nifty_scaffold/templates/action_specs/create.rb
45
- - rails_generators/nifty_scaffold/templates/action_specs/destroy.rb
46
- - rails_generators/nifty_scaffold/templates/action_specs/edit.rb
47
- - rails_generators/nifty_scaffold/templates/action_specs/index.rb
48
- - rails_generators/nifty_scaffold/templates/action_specs/new.rb
49
- - rails_generators/nifty_scaffold/templates/action_specs/show.rb
50
- - rails_generators/nifty_scaffold/templates/action_specs/update.rb
51
- - rails_generators/nifty_scaffold/templates/action_tests/create.rb
52
- - rails_generators/nifty_scaffold/templates/action_tests/destroy.rb
53
- - rails_generators/nifty_scaffold/templates/action_tests/edit.rb
54
- - rails_generators/nifty_scaffold/templates/action_tests/index.rb
55
- - rails_generators/nifty_scaffold/templates/action_tests/new.rb
56
- - rails_generators/nifty_scaffold/templates/action_tests/show.rb
57
- - rails_generators/nifty_scaffold/templates/action_tests/update.rb
58
46
  - rails_generators/nifty_scaffold/templates/actions/create.rb
59
47
  - rails_generators/nifty_scaffold/templates/actions/destroy.rb
60
48
  - rails_generators/nifty_scaffold/templates/actions/edit.rb
@@ -63,19 +51,38 @@ files:
63
51
  - rails_generators/nifty_scaffold/templates/actions/show.rb
64
52
  - rails_generators/nifty_scaffold/templates/actions/update.rb
65
53
  - rails_generators/nifty_scaffold/templates/controller.rb
66
- - rails_generators/nifty_scaffold/templates/controller_spec.rb
67
- - rails_generators/nifty_scaffold/templates/controller_test.rb
68
54
  - rails_generators/nifty_scaffold/templates/fixtures.yml
69
55
  - rails_generators/nifty_scaffold/templates/helper.rb
70
56
  - rails_generators/nifty_scaffold/templates/migration.rb
71
57
  - rails_generators/nifty_scaffold/templates/model.rb
72
- - rails_generators/nifty_scaffold/templates/model_spec.rb
73
- - rails_generators/nifty_scaffold/templates/model_test.rb
74
- - rails_generators/nifty_scaffold/templates/views/_form.html.erb
75
- - rails_generators/nifty_scaffold/templates/views/edit.html.erb
76
- - rails_generators/nifty_scaffold/templates/views/index.html.erb
77
- - rails_generators/nifty_scaffold/templates/views/new.html.erb
78
- - rails_generators/nifty_scaffold/templates/views/show.html.erb
58
+ - rails_generators/nifty_scaffold/templates/tests/rspec/actions/create.rb
59
+ - rails_generators/nifty_scaffold/templates/tests/rspec/actions/destroy.rb
60
+ - rails_generators/nifty_scaffold/templates/tests/rspec/actions/edit.rb
61
+ - rails_generators/nifty_scaffold/templates/tests/rspec/actions/index.rb
62
+ - rails_generators/nifty_scaffold/templates/tests/rspec/actions/new.rb
63
+ - rails_generators/nifty_scaffold/templates/tests/rspec/actions/show.rb
64
+ - rails_generators/nifty_scaffold/templates/tests/rspec/actions/update.rb
65
+ - rails_generators/nifty_scaffold/templates/tests/rspec/controller.rb
66
+ - rails_generators/nifty_scaffold/templates/tests/rspec/model.rb
67
+ - rails_generators/nifty_scaffold/templates/tests/testunit/actions/create.rb
68
+ - rails_generators/nifty_scaffold/templates/tests/testunit/actions/destroy.rb
69
+ - rails_generators/nifty_scaffold/templates/tests/testunit/actions/edit.rb
70
+ - rails_generators/nifty_scaffold/templates/tests/testunit/actions/index.rb
71
+ - rails_generators/nifty_scaffold/templates/tests/testunit/actions/new.rb
72
+ - rails_generators/nifty_scaffold/templates/tests/testunit/actions/show.rb
73
+ - rails_generators/nifty_scaffold/templates/tests/testunit/actions/update.rb
74
+ - rails_generators/nifty_scaffold/templates/tests/testunit/controller.rb
75
+ - rails_generators/nifty_scaffold/templates/tests/testunit/model.rb
76
+ - rails_generators/nifty_scaffold/templates/views/erb/_form.html.erb
77
+ - rails_generators/nifty_scaffold/templates/views/erb/edit.html.erb
78
+ - rails_generators/nifty_scaffold/templates/views/erb/index.html.erb
79
+ - rails_generators/nifty_scaffold/templates/views/erb/new.html.erb
80
+ - rails_generators/nifty_scaffold/templates/views/erb/show.html.erb
81
+ - rails_generators/nifty_scaffold/templates/views/haml/_form.html.haml
82
+ - rails_generators/nifty_scaffold/templates/views/haml/edit.html.haml
83
+ - rails_generators/nifty_scaffold/templates/views/haml/index.html.haml
84
+ - rails_generators/nifty_scaffold/templates/views/haml/new.html.haml
85
+ - rails_generators/nifty_scaffold/templates/views/haml/show.html.haml
79
86
  - rails_generators/nifty_scaffold/USAGE
80
87
  - README
81
88
  - tasks/deployment.rake