terraformation 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (57) hide show
  1. data/LICENSE +20 -0
  2. data/README.rdoc +14 -0
  3. data/Rakefile +25 -0
  4. data/bin/terrarails +95 -0
  5. data/rails_generators/terracontroller/USAGE +26 -0
  6. data/rails_generators/terracontroller/templates/controller_spec.rb.erb +19 -0
  7. data/rails_generators/terracontroller/templates/view.builder.erb +2 -0
  8. data/rails_generators/terracontroller/templates/view.erb +2 -0
  9. data/rails_generators/terracontroller/templates/view.haml.erb +2 -0
  10. data/rails_generators/terracontroller/templates/view.rjs.erb +1 -0
  11. data/rails_generators/terracontroller/templates/view.rss.builder.erb +18 -0
  12. data/rails_generators/terracontroller/templates/view_spec.rb.erb +16 -0
  13. data/rails_generators/terracontroller/terracontroller_generator.rb +44 -0
  14. data/rails_generators/terraformation/USAGE +2 -0
  15. data/rails_generators/terraformation/templates/application.html.haml.erb +25 -0
  16. data/rails_generators/terraformation/templates/blueprint/ie.css +22 -0
  17. data/rails_generators/terraformation/templates/blueprint/print.css +29 -0
  18. data/rails_generators/terraformation/templates/blueprint/screen.css +226 -0
  19. data/rails_generators/terraformation/templates/clear_test_default.rake +3 -0
  20. data/rails_generators/terraformation/templates/cucumber +9 -0
  21. data/rails_generators/terraformation/templates/cucumber.rake +36 -0
  22. data/rails_generators/terraformation/templates/cucumber_environment.rb +1 -0
  23. data/rails_generators/terraformation/templates/gitignore +10 -0
  24. data/rails_generators/terraformation/templates/jquery.js +19 -0
  25. data/rails_generators/terraformation/templates/null_gitignore +2 -0
  26. data/rails_generators/terraformation/templates/paths.rb +23 -0
  27. data/rails_generators/terraformation/templates/rcov.opts +2 -0
  28. data/rails_generators/terraformation/templates/spec.opts +2 -0
  29. data/rails_generators/terraformation/templates/spec_helper.rb +12 -0
  30. data/rails_generators/terraformation/terraformation_generator.rb +99 -0
  31. data/rails_generators/terraforming.rb +51 -0
  32. data/rails_generators/terrahelper/USAGE +9 -0
  33. data/rails_generators/terrahelper/templates/helper.rb.erb +10 -0
  34. data/rails_generators/terrahelper/templates/helper_spec.rb.erb +13 -0
  35. data/rails_generators/terrahelper/terrahelper_generator.rb +27 -0
  36. data/rails_generators/terramodel/USAGE +11 -0
  37. data/rails_generators/terramodel/templates/model_exemplar.rb.erb +5 -0
  38. data/rails_generators/terramodel/templates/model_factory.rb.erb +5 -0
  39. data/rails_generators/terramodel/templates/model_spec.rb.erb +17 -0
  40. data/rails_generators/terramodel/terramodel_generator.rb +54 -0
  41. data/rails_generators/terraresource/USAGE +20 -0
  42. data/rails_generators/terraresource/terraresource_generator.rb +93 -0
  43. data/rails_generators/terrascaffold/USAGE +2 -0
  44. data/rails_generators/terrascaffold/templates/controller.rb.erb +85 -0
  45. data/rails_generators/terrascaffold/templates/controller_spec.rb.erb +173 -0
  46. data/rails_generators/terrascaffold/templates/partial_form.html.haml.erb +7 -0
  47. data/rails_generators/terrascaffold/templates/view_edit.html.haml.erb +8 -0
  48. data/rails_generators/terrascaffold/templates/view_edit.html_spec.rb.erb +26 -0
  49. data/rails_generators/terrascaffold/templates/view_index.html.haml.erb +18 -0
  50. data/rails_generators/terrascaffold/templates/view_index.html_spec.rb.erb +29 -0
  51. data/rails_generators/terrascaffold/templates/view_new.html.haml.erb +7 -0
  52. data/rails_generators/terrascaffold/templates/view_new.html_spec.rb.erb +26 -0
  53. data/rails_generators/terrascaffold/templates/view_show.html.haml.erb +8 -0
  54. data/rails_generators/terrascaffold/templates/view_show.html_spec.rb.erb +25 -0
  55. data/rails_generators/terrascaffold/terrascaffold_generator.rb +128 -0
  56. data/rails_generators/terraview/terraview_generator.rb +38 -0
  57. metadata +111 -0
@@ -0,0 +1,7 @@
1
+ %h2 New <%= singular_name.humanize %>
2
+
3
+ - form_for @<%= singular_name %> do |f|
4
+ = render :partial => 'form', :object => f
5
+ %div= f.submit "Create"
6
+
7
+ %p= link_to 'Back', <%= plural_name %>_path
@@ -0,0 +1,26 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '<%= '/..' * class_nesting_depth %>/../../spec_helper')
2
+
3
+ <% output_attributes = attributes.reject{|attribute| [:datetime, :timestamp, :time, :date].include?(attribute.type) } -%>
4
+ describe "/<%= plural_name %>/new.html" do
5
+ before do
6
+ assigns[:<%= file_name %>] = stub_model(<%= class_name %>,
7
+ :new_record? => true<%= output_attributes.empty? ? '' : ',' %>
8
+ <% output_attributes.each_with_index do |attribute, attribute_index| -%>
9
+ :<%= attribute.name %> => <%= attribute.default.inspect %><%= attribute_index == output_attributes.length - 1 ? '' : ','%>
10
+ <% end -%>
11
+ )
12
+ end
13
+
14
+ subject do
15
+ render "<%= plural_name %>/new.html"
16
+ response
17
+ end
18
+
19
+ it "should render new form" do
20
+ should have_tag("form[action=?][method=post]", <%= plural_name %>_path) do
21
+ <% for attribute in output_attributes -%>
22
+ with_tag("#<%= file_name %>_<%= attribute.name %>[name=?]", "<%= file_name %>[<%= attribute.name %>]")
23
+ <% end -%>
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,8 @@
1
+ %dl[@<%= singular_name %>]
2
+ <% for attribute in attributes -%>
3
+ %dt <%= attribute.column.human_name %>
4
+ %dd= h @<%= singular_name %>.<%= attribute.name %>
5
+
6
+ <% end -%>
7
+ %p= link_to 'Edit', [:edit, @<%= singular_name %>]
8
+ %p= link_to 'Back', <%= plural_name %>_path
@@ -0,0 +1,25 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '<%= '/..' * class_nesting_depth %>/../../spec_helper')
2
+
3
+ <% output_attributes = attributes.reject{|attribute| [:datetime, :timestamp, :time, :date].include?(attribute.type) } -%>
4
+ describe "/<%= plural_name %>/show.html" do
5
+ before do
6
+ assigns[:<%= file_name %>] = @<%= file_name %> = stub_model(<%= class_name %><%= output_attributes.empty? ? ')' : ',' %>
7
+ <% output_attributes.each_with_index do |attribute, attribute_index| -%>
8
+ :<%= attribute.name %> => <%= attribute.default.inspect %><%= attribute_index == output_attributes.length - 1 ? '' : ','%>
9
+ <% end -%>
10
+ <% if !output_attributes.empty? -%>
11
+ )
12
+ <% end -%>
13
+ end
14
+
15
+ subject do
16
+ render "<%= plural_name %>/show.html"
17
+ response
18
+ end
19
+
20
+ it "should render attributes in <p>" do
21
+ <% for attribute in output_attributes -%>
22
+ should have_text(/<%= Regexp.escape(attribute.default.inspect).gsub(/^"|"$/, '')%>/)
23
+ <% end -%>
24
+ end
25
+ end
@@ -0,0 +1,128 @@
1
+ require File.dirname(__FILE__) + '/../terraforming'
2
+
3
+ class TerrascaffoldGenerator < Rails::Generator::NamedBase
4
+ include Terraforming
5
+
6
+ default_options :skip_migration => false
7
+
8
+ attr_reader :controller_class_path,
9
+ :controller_class_name,
10
+ :controller_file_name
11
+
12
+ def mocha?
13
+ if @mocha.nil?
14
+ @mocha = Rails.configuration.gems.any? {|g| g.name == "mocha"}
15
+ end
16
+ @mocha
17
+ end
18
+
19
+ def stub
20
+ if mocha?
21
+ "stubs"
22
+ else
23
+ "stub!"
24
+ end
25
+ end
26
+
27
+ def should_receive
28
+ if mocha?
29
+ "expects"
30
+ else
31
+ "should_receive"
32
+ end
33
+ end
34
+
35
+ def and_return
36
+ if mocha?
37
+ "returns"
38
+ else
39
+ "and_return"
40
+ end
41
+ end
42
+
43
+ def initialize(runtime_args, runtime_options = {})
44
+ super
45
+
46
+ @controller_name = @name.pluralize
47
+
48
+ base_name, @controller_class_path, @controller_file_path, @controller_class_nesting, @controller_class_nesting_depth = extract_modules(@controller_name)
49
+ @controller_class_name_without_nesting, @controller_file_name = inflect_names(base_name)
50
+
51
+ if @controller_class_nesting.empty?
52
+ @controller_class_name = @controller_class_name_without_nesting
53
+ else
54
+ @controller_class_name = "#{@controller_class_nesting}::#{@controller_class_name_without_nesting}"
55
+ end
56
+
57
+ end
58
+
59
+ def manifest
60
+ record do |m|
61
+
62
+ m.class_collisions(controller_class_path, "#{controller_class_name}Controller")
63
+ m.class_collisions(class_path, "#{class_name}")
64
+
65
+ m.directory(File.join('app/controllers', controller_class_path))
66
+ m.directory(File.join('app/views', controller_class_path, controller_file_name))
67
+ m.directory(File.join('spec/controllers', controller_class_path))
68
+ m.directory File.join('spec/views', controller_class_path, controller_file_name)
69
+
70
+ m.template 'controller_spec.rb.erb',
71
+ File.join('spec/controllers', controller_class_path, "#{controller_file_name}_controller_spec.rb")
72
+
73
+ m.template 'controller.rb.erb',
74
+ File.join('app/controllers', controller_class_path, "#{controller_file_name}_controller.rb")
75
+
76
+ for action in scaffold_views
77
+ m.template "view_#{action}.html_spec.rb.erb",
78
+ File.join('spec/views', controller_class_path, controller_file_name, "#{action}.html_spec.rb")
79
+ if defined?(Haml)
80
+ m.template(
81
+ "view_#{action}.html.haml.erb",
82
+ File.join('app/views', controller_class_path, controller_file_name, "#{action}.html.haml")
83
+ )
84
+ else
85
+ m.template(
86
+ "scaffold:view_#{action}.html.erb",
87
+ File.join('app/views', controller_class_path, controller_file_name, "#{action}.html.erb")
88
+ )
89
+ end
90
+ end
91
+ if defined?(Haml)
92
+ m.template(
93
+ "partial_form.html.haml.erb",
94
+ File.join('app/views', controller_class_path, controller_file_name, "_form.html.haml")
95
+ )
96
+ end
97
+
98
+ m.dependency 'terramodel', [name] + args, :collision => 'skip'
99
+
100
+ m.route_resources controller_file_name
101
+
102
+ end
103
+ end
104
+
105
+ protected
106
+
107
+ def banner
108
+ "Usage: #{$0} terrascaffold ModelName [field:type field:type]"
109
+ end
110
+
111
+ def add_options!(opt)
112
+ opt.separator ''
113
+ opt.separator 'Options:'
114
+ opt.on("--skip-migration",
115
+ "Don't generate a migration file for this model") { |v| options[:skip_migration] = v }
116
+ opt.on("--[no-]exemplar", "Create Object Daddy Exemplar") { |v| options[:exemplar] = v }
117
+ opt.on("--[no-]factory", "Create Factory Girl Factory") { |v| options[:factory] = v }
118
+ end
119
+
120
+ def scaffold_views
121
+ %w[ index show new edit ]
122
+ end
123
+
124
+ def model_name
125
+ class_name.demodulize
126
+ end
127
+
128
+ end
@@ -0,0 +1,38 @@
1
+ require File.dirname(__FILE__) + '/../terraforming'
2
+
3
+ class TerraviewGenerator < Rails::Generator::Base
4
+ include Terraforming
5
+
6
+ def manifest
7
+ record do |m|
8
+ views
9
+ usage unless args.empty?
10
+ usage unless views.all? {|view| view.include?("/") ? true : p(view)}
11
+
12
+ views.map {|view| File.dirname(view)}.each do |dir|
13
+ m.directory File.join('app/views', dir)
14
+ m.directory File.join('spec/views', dir)
15
+ end
16
+
17
+ views.each do |view|
18
+ full_name, format, engine = view.split('.')
19
+ class_name, name = File.dirname(full_name).camelize, File.basename(full_name)
20
+ m.template 'terracontroller:view_spec.rb.erb',
21
+ File.join('spec/views', "#{full_name}.#{format}_spec.rb"),
22
+ :assigns => { :class_name => class_name, :name => name, :format => format, :engine => engine }
23
+ path = File.join('app/views', view)
24
+ template = ["terracontroller:view.#{format}.#{engine}.erb", "terracontroller:view.#{engine}.erb", "terracontroller:view.erb"].detect {|f| File.exist?(source_path(f))}
25
+ m.template template,
26
+ path,
27
+ :assigns => { :class_name => class_name, :action => "#{name}.#{format}", :path => path }
28
+ end
29
+ end
30
+ end
31
+
32
+ protected
33
+
34
+ def banner
35
+ "Usage: #{$0} terraview [controller/action[.format[.engine]]] ..."
36
+ end
37
+
38
+ end
metadata ADDED
@@ -0,0 +1,111 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: terraformation
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.2
5
+ platform: ruby
6
+ authors:
7
+ - Hashrocket
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2009-11-22 00:00:00 -05:00
13
+ default_executable:
14
+ dependencies: []
15
+
16
+ description:
17
+ email: info@hashrocket.com
18
+ executables:
19
+ - terrarails
20
+ extensions: []
21
+
22
+ extra_rdoc_files:
23
+ - README.rdoc
24
+ - LICENSE
25
+ files:
26
+ - LICENSE
27
+ - README.rdoc
28
+ - Rakefile
29
+ - bin/terrarails
30
+ - rails_generators/terracontroller/USAGE
31
+ - rails_generators/terracontroller/templates/controller_spec.rb.erb
32
+ - rails_generators/terracontroller/templates/view.builder.erb
33
+ - rails_generators/terracontroller/templates/view.erb
34
+ - rails_generators/terracontroller/templates/view.haml.erb
35
+ - rails_generators/terracontroller/templates/view.rjs.erb
36
+ - rails_generators/terracontroller/templates/view.rss.builder.erb
37
+ - rails_generators/terracontroller/templates/view_spec.rb.erb
38
+ - rails_generators/terracontroller/terracontroller_generator.rb
39
+ - rails_generators/terraformation/USAGE
40
+ - rails_generators/terraformation/templates/application.html.haml.erb
41
+ - rails_generators/terraformation/templates/blueprint/ie.css
42
+ - rails_generators/terraformation/templates/blueprint/print.css
43
+ - rails_generators/terraformation/templates/blueprint/screen.css
44
+ - rails_generators/terraformation/templates/clear_test_default.rake
45
+ - rails_generators/terraformation/templates/cucumber
46
+ - rails_generators/terraformation/templates/cucumber.rake
47
+ - rails_generators/terraformation/templates/cucumber_environment.rb
48
+ - rails_generators/terraformation/templates/gitignore
49
+ - rails_generators/terraformation/templates/jquery.js
50
+ - rails_generators/terraformation/templates/null_gitignore
51
+ - rails_generators/terraformation/templates/paths.rb
52
+ - rails_generators/terraformation/templates/rcov.opts
53
+ - rails_generators/terraformation/templates/spec.opts
54
+ - rails_generators/terraformation/templates/spec_helper.rb
55
+ - rails_generators/terraformation/terraformation_generator.rb
56
+ - rails_generators/terraforming.rb
57
+ - rails_generators/terrahelper/USAGE
58
+ - rails_generators/terrahelper/templates/helper.rb.erb
59
+ - rails_generators/terrahelper/templates/helper_spec.rb.erb
60
+ - rails_generators/terrahelper/terrahelper_generator.rb
61
+ - rails_generators/terramodel/USAGE
62
+ - rails_generators/terramodel/templates/model_exemplar.rb.erb
63
+ - rails_generators/terramodel/templates/model_factory.rb.erb
64
+ - rails_generators/terramodel/templates/model_spec.rb.erb
65
+ - rails_generators/terramodel/terramodel_generator.rb
66
+ - rails_generators/terraresource/USAGE
67
+ - rails_generators/terraresource/terraresource_generator.rb
68
+ - rails_generators/terrascaffold/USAGE
69
+ - rails_generators/terrascaffold/templates/controller.rb.erb
70
+ - rails_generators/terrascaffold/templates/controller_spec.rb.erb
71
+ - rails_generators/terrascaffold/templates/partial_form.html.haml.erb
72
+ - rails_generators/terrascaffold/templates/view_edit.html.haml.erb
73
+ - rails_generators/terrascaffold/templates/view_edit.html_spec.rb.erb
74
+ - rails_generators/terrascaffold/templates/view_index.html.haml.erb
75
+ - rails_generators/terrascaffold/templates/view_index.html_spec.rb.erb
76
+ - rails_generators/terrascaffold/templates/view_new.html.haml.erb
77
+ - rails_generators/terrascaffold/templates/view_new.html_spec.rb.erb
78
+ - rails_generators/terrascaffold/templates/view_show.html.haml.erb
79
+ - rails_generators/terrascaffold/templates/view_show.html_spec.rb.erb
80
+ - rails_generators/terrascaffold/terrascaffold_generator.rb
81
+ - rails_generators/terraview/terraview_generator.rb
82
+ has_rdoc: false
83
+ homepage: http://github.com/hashrocket/terraformation
84
+ licenses: []
85
+
86
+ post_install_message:
87
+ rdoc_options: []
88
+
89
+ require_paths:
90
+ - lib
91
+ required_ruby_version: !ruby/object:Gem::Requirement
92
+ requirements:
93
+ - - ">="
94
+ - !ruby/object:Gem::Version
95
+ version: "0"
96
+ version:
97
+ required_rubygems_version: !ruby/object:Gem::Requirement
98
+ requirements:
99
+ - - ">="
100
+ - !ruby/object:Gem::Version
101
+ version: "0"
102
+ version:
103
+ requirements: []
104
+
105
+ rubyforge_project:
106
+ rubygems_version: 1.3.5
107
+ signing_key:
108
+ specification_version: 3
109
+ summary: Terraform your app with style
110
+ test_files: []
111
+