tennpipes-init 3.6.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (167) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE.txt +20 -0
  3. data/README.rdoc +163 -0
  4. data/Rakefile +1 -0
  5. data/bin/tennpipes-init +16 -0
  6. data/lib/tennpipes-init.rb +73 -0
  7. data/lib/tennpipes-init/command.rb +18 -0
  8. data/lib/tennpipes-init/generators/actions.rb +630 -0
  9. data/lib/tennpipes-init/generators/app.rb +75 -0
  10. data/lib/tennpipes-init/generators/app/app.rb.tt +72 -0
  11. data/lib/tennpipes-init/generators/app/app.rb.tt~ +72 -0
  12. data/lib/tennpipes-init/generators/cli.rb +57 -0
  13. data/lib/tennpipes-init/generators/component.rb +73 -0
  14. data/lib/tennpipes-init/generators/components/actions.rb +208 -0
  15. data/lib/tennpipes-init/generators/components/mocks/mocha.rb +10 -0
  16. data/lib/tennpipes-init/generators/components/mocks/rr.rb +13 -0
  17. data/lib/tennpipes-init/generators/components/orms/activerecord.rb +201 -0
  18. data/lib/tennpipes-init/generators/components/orms/couchrest.rb +55 -0
  19. data/lib/tennpipes-init/generators/components/orms/datamapper.rb +140 -0
  20. data/lib/tennpipes-init/generators/components/orms/dynamoid.rb +67 -0
  21. data/lib/tennpipes-init/generators/components/orms/minirecord.rb +165 -0
  22. data/lib/tennpipes-init/generators/components/orms/mongoid.rb +113 -0
  23. data/lib/tennpipes-init/generators/components/orms/mongomapper.rb +43 -0
  24. data/lib/tennpipes-init/generators/components/orms/mongomatic.rb +84 -0
  25. data/lib/tennpipes-init/generators/components/orms/ohm.rb +65 -0
  26. data/lib/tennpipes-init/generators/components/orms/ripple.rb +75 -0
  27. data/lib/tennpipes-init/generators/components/orms/sequel.rb +99 -0
  28. data/lib/tennpipes-init/generators/components/renderers/erb.rb +3 -0
  29. data/lib/tennpipes-init/generators/components/renderers/haml.rb +3 -0
  30. data/lib/tennpipes-init/generators/components/renderers/liquid.rb +4 -0
  31. data/lib/tennpipes-init/generators/components/renderers/slim.rb +3 -0
  32. data/lib/tennpipes-init/generators/components/scripts/dojo.rb +10 -0
  33. data/lib/tennpipes-init/generators/components/scripts/extcore.rb +10 -0
  34. data/lib/tennpipes-init/generators/components/scripts/jquery.rb +10 -0
  35. data/lib/tennpipes-init/generators/components/scripts/mootools.rb +10 -0
  36. data/lib/tennpipes-init/generators/components/scripts/prototype.rb +12 -0
  37. data/lib/tennpipes-init/generators/components/scripts/rightjs.rb +10 -0
  38. data/lib/tennpipes-init/generators/components/stylesheets/compass.rb +39 -0
  39. data/lib/tennpipes-init/generators/components/stylesheets/compass/application.scss +43 -0
  40. data/lib/tennpipes-init/generators/components/stylesheets/compass/partials/_base.scss +12 -0
  41. data/lib/tennpipes-init/generators/components/stylesheets/less.rb +25 -0
  42. data/lib/tennpipes-init/generators/components/stylesheets/sass.rb +15 -0
  43. data/lib/tennpipes-init/generators/components/stylesheets/scss.rb +16 -0
  44. data/lib/tennpipes-init/generators/components/tests/bacon.rb +103 -0
  45. data/lib/tennpipes-init/generators/components/tests/cucumber.rb +86 -0
  46. data/lib/tennpipes-init/generators/components/tests/minitest.rb +110 -0
  47. data/lib/tennpipes-init/generators/components/tests/riot.rb +117 -0
  48. data/lib/tennpipes-init/generators/components/tests/rspec.rb +111 -0
  49. data/lib/tennpipes-init/generators/components/tests/shoulda.rb +114 -0
  50. data/lib/tennpipes-init/generators/components/tests/steak.rb +114 -0
  51. data/lib/tennpipes-init/generators/controller.rb +77 -0
  52. data/lib/tennpipes-init/generators/helper.rb +50 -0
  53. data/lib/tennpipes-init/generators/mailer.rb +52 -0
  54. data/lib/tennpipes-init/generators/migration.rb +43 -0
  55. data/lib/tennpipes-init/generators/model.rb +113 -0
  56. data/lib/tennpipes-init/generators/plugin.rb +67 -0
  57. data/lib/tennpipes-init/generators/project.rb +160 -0
  58. data/lib/tennpipes-init/generators/project/config.ru +9 -0
  59. data/lib/tennpipes-init/generators/project/config/apps.rb.tt +35 -0
  60. data/lib/tennpipes-init/generators/project/config/boot.rb +49 -0
  61. data/lib/tennpipes-init/generators/project/public/favicon.ico +0 -0
  62. data/lib/tennpipes-init/generators/project/public/images/booking.com.png +0 -0
  63. data/lib/tennpipes-init/generators/project/public/images/causes.png +0 -0
  64. data/lib/tennpipes-init/generators/project/public/images/ennkeypee_bg.jpg +0 -0
  65. data/lib/tennpipes-init/generators/project/public/images/ennkeypee_bluelogo.png +0 -0
  66. data/lib/tennpipes-init/generators/project/public/images/ennkeypee_bluelogo.svg +68 -0
  67. data/lib/tennpipes-init/generators/project/public/images/ennkeypee_whitelogo.png +0 -0
  68. data/lib/tennpipes-init/generators/project/public/images/ennkeypee_whitelogo.svg +65 -0
  69. data/lib/tennpipes-init/generators/project/public/images/forever21.png +0 -0
  70. data/lib/tennpipes-init/generators/project/public/images/icons/foundation-icons.eot +0 -0
  71. data/lib/tennpipes-init/generators/project/public/images/icons/foundation-icons.svg +970 -0
  72. data/lib/tennpipes-init/generators/project/public/images/icons/foundation-icons.ttf +0 -0
  73. data/lib/tennpipes-init/generators/project/public/images/icons/foundation-icons.woff +0 -0
  74. data/lib/tennpipes-init/generators/project/public/images/icons/tennpipes-icons.css +598 -0
  75. data/lib/tennpipes-init/generators/project/public/images/image1.jpg +0 -0
  76. data/lib/tennpipes-init/generators/project/public/images/image11.jpg +0 -0
  77. data/lib/tennpipes-init/generators/project/public/images/image2.jpg +0 -0
  78. data/lib/tennpipes-init/generators/project/public/images/image3.jpg +0 -0
  79. data/lib/tennpipes-init/generators/project/public/images/intuit.png +0 -0
  80. data/lib/tennpipes-init/generators/project/public/images/krispykreme.png +0 -0
  81. data/lib/tennpipes-init/generators/project/public/images/placeholders/README.md +302 -0
  82. data/lib/tennpipes-init/generators/project/public/images/placeholders/bower.json +4 -0
  83. data/lib/tennpipes-init/generators/project/public/images/placeholders/composer.json +34 -0
  84. data/lib/tennpipes-init/generators/project/public/images/placeholders/gulpfile.js +92 -0
  85. data/lib/tennpipes-init/generators/project/public/images/placeholders/holder.js +1920 -0
  86. data/lib/tennpipes-init/generators/project/public/images/placeholders/holder.min.js +12 -0
  87. data/lib/tennpipes-init/generators/project/public/images/placeholders/package.json +46 -0
  88. data/lib/tennpipes-init/generators/project/public/images/placeholders/src/holder.js +1411 -0
  89. data/lib/tennpipes-init/generators/project/public/images/placeholders/src/lib/augment.js +27 -0
  90. data/lib/tennpipes-init/generators/project/public/images/placeholders/src/lib/ondomready.js +155 -0
  91. data/lib/tennpipes-init/generators/project/public/images/placeholders/src/lib/polyfills.js +177 -0
  92. data/lib/tennpipes-init/generators/project/public/images/placeholders/src/scenegraph.js +101 -0
  93. data/lib/tennpipes-init/generators/project/public/images/placeholders/src/utils.js +129 -0
  94. data/lib/tennpipes-init/generators/project/public/images/priceline.com.png +0 -0
  95. data/lib/tennpipes-init/generators/project/public/images/stripe.png +0 -0
  96. data/lib/tennpipes-init/generators/project/public/javascripts/tennpipes.min.js +6081 -0
  97. data/lib/tennpipes-init/generators/project/public/javascripts/tennpipes/tennpipes.abide.js +340 -0
  98. data/lib/tennpipes-init/generators/project/public/javascripts/tennpipes/tennpipes.accordion.js +67 -0
  99. data/lib/tennpipes-init/generators/project/public/javascripts/tennpipes/tennpipes.alert.js +43 -0
  100. data/lib/tennpipes-init/generators/project/public/javascripts/tennpipes/tennpipes.clearing.js +556 -0
  101. data/lib/tennpipes-init/generators/project/public/javascripts/tennpipes/tennpipes.dropdown.js +448 -0
  102. data/lib/tennpipes-init/generators/project/public/javascripts/tennpipes/tennpipes.equalizer.js +77 -0
  103. data/lib/tennpipes-init/generators/project/public/javascripts/tennpipes/tennpipes.interchange.js +354 -0
  104. data/lib/tennpipes-init/generators/project/public/javascripts/tennpipes/tennpipes.joyride.js +932 -0
  105. data/lib/tennpipes-init/generators/project/public/javascripts/tennpipes/tennpipes.js +703 -0
  106. data/lib/tennpipes-init/generators/project/public/javascripts/tennpipes/tennpipes.magellan.js +203 -0
  107. data/lib/tennpipes-init/generators/project/public/javascripts/tennpipes/tennpipes.offcanvas.js +152 -0
  108. data/lib/tennpipes-init/generators/project/public/javascripts/tennpipes/tennpipes.orbit.js +476 -0
  109. data/lib/tennpipes-init/generators/project/public/javascripts/tennpipes/tennpipes.reveal.js +471 -0
  110. data/lib/tennpipes-init/generators/project/public/javascripts/tennpipes/tennpipes.slider.js +263 -0
  111. data/lib/tennpipes-init/generators/project/public/javascripts/tennpipes/tennpipes.tab.js +237 -0
  112. data/lib/tennpipes-init/generators/project/public/javascripts/tennpipes/tennpipes.tooltip.js +307 -0
  113. data/lib/tennpipes-init/generators/project/public/javascripts/tennpipes/tennpipes.topbar.js +452 -0
  114. data/lib/tennpipes-init/generators/project/public/javascripts/vendor/fastclick.js +8 -0
  115. data/lib/tennpipes-init/generators/project/public/javascripts/vendor/jquery.cookie.js +8 -0
  116. data/lib/tennpipes-init/generators/project/public/javascripts/vendor/jquery.js +26 -0
  117. data/lib/tennpipes-init/generators/project/public/javascripts/vendor/modernizr.js +8 -0
  118. data/lib/tennpipes-init/generators/project/public/javascripts/vendor/placeholder.js +2 -0
  119. data/lib/tennpipes-init/generators/project/public/stylesheets/app.css~ +178 -0
  120. data/lib/tennpipes-init/generators/project/public/stylesheets/app1.css~ +177 -0
  121. data/lib/tennpipes-init/generators/project/public/stylesheets/ennkeypee.css +214 -0
  122. data/lib/tennpipes-init/generators/project/public/stylesheets/ennkeypee.css~ +214 -0
  123. data/lib/tennpipes-init/generators/project/public/stylesheets/normalize.css +427 -0
  124. data/lib/tennpipes-init/generators/project/public/stylesheets/tennpipes.css +6201 -0
  125. data/lib/tennpipes-init/generators/project/public/stylesheets/tennpipes.css~ +6201 -0
  126. data/lib/tennpipes-init/generators/project/public/stylesheets/tennpipes.min.css +1 -0
  127. data/lib/tennpipes-init/generators/runner.rb +139 -0
  128. data/lib/tennpipes-init/generators/task.rb +45 -0
  129. data/lib/tennpipes-init/generators/templates/Gemfile.tt +32 -0
  130. data/lib/tennpipes-init/generators/templates/Rakefile.tt +8 -0
  131. data/lib/tennpipes-init/generators/templates/controller.rb.tt +22 -0
  132. data/lib/tennpipes-init/generators/templates/gem/README.md.tt +29 -0
  133. data/lib/tennpipes-init/generators/templates/gem/gemspec.tt +19 -0
  134. data/lib/tennpipes-init/generators/templates/gem/lib/libname.tt +6 -0
  135. data/lib/tennpipes-init/generators/templates/gem/lib/libname/version.tt +3 -0
  136. data/lib/tennpipes-init/generators/templates/helper.rb.tt +13 -0
  137. data/lib/tennpipes-init/generators/templates/initializer.rb.tt +5 -0
  138. data/lib/tennpipes-init/generators/templates/mailer.rb.tt +54 -0
  139. data/lib/tennpipes-init/generators/templates/project_bin.tt +14 -0
  140. data/lib/tennpipes-init/generators/templates/task.rb.tt +7 -0
  141. data/lib/tennpipes-init/tennpipes-tasks/activerecord.rb +377 -0
  142. data/lib/tennpipes-init/tennpipes-tasks/database.rb +12 -0
  143. data/lib/tennpipes-init/tennpipes-tasks/datamapper.rb +94 -0
  144. data/lib/tennpipes-init/tennpipes-tasks/minirecord.rb +19 -0
  145. data/lib/tennpipes-init/tennpipes-tasks/mongoid.rb +215 -0
  146. data/lib/tennpipes-init/tennpipes-tasks/mongomapper.rb +55 -0
  147. data/lib/tennpipes-init/tennpipes-tasks/sequel.rb +85 -0
  148. data/lib/tennpipes-init/tennpipes-tasks/sql-helpers.rb +72 -0
  149. data/test/fixtures/admin_template.rb +7 -0
  150. data/test/fixtures/example_template.rb +15 -0
  151. data/test/fixtures/git_template.rb +4 -0
  152. data/test/fixtures/plugin_template.rb +13 -0
  153. data/test/fixtures/rake_template.rb +9 -0
  154. data/test/helper.rb +103 -0
  155. data/test/test_app_generator.rb +142 -0
  156. data/test/test_cli.rb +27 -0
  157. data/test/test_component_generator.rb +98 -0
  158. data/test/test_controller_generator.rb +272 -0
  159. data/test/test_generator.rb +13 -0
  160. data/test/test_helper_generator.rb +133 -0
  161. data/test/test_mailer_generator.rb +69 -0
  162. data/test/test_migration_generator.rb +222 -0
  163. data/test/test_model_generator.rb +553 -0
  164. data/test/test_plugin_generator.rb +152 -0
  165. data/test/test_project_generator.rb +757 -0
  166. data/test/test_task_generator.rb +53 -0
  167. metadata +285 -0
@@ -0,0 +1,114 @@
1
+ STEAK_SETUP = (<<-TEST).gsub(/^ {12}/, '') unless defined?(STEAK_SETUP)
2
+ RACK_ENV = 'test' unless defined?(RACK_ENV)
3
+ require File.expand_path(File.dirname(__FILE__) + "/../config/boot")
4
+ Dir[File.expand_path(File.dirname(__FILE__) + "/../app/helpers/**/*.rb")].each(&method(:require))
5
+
6
+ RSpec.configure do |conf|
7
+ conf.include Rack::Test::Methods
8
+ conf.include Capybara
9
+ end
10
+
11
+ def app
12
+ ##
13
+ # You can handle all tennpipes applications using instead:
14
+ # Tennpipes.application
15
+ CLASS_NAME.tap { |app| }
16
+ end
17
+
18
+ Capybara.app = app
19
+ TEST
20
+
21
+ STEAK_CONTROLLER_TEST = (<<-TEST).gsub(/^ {12}/, '') unless defined?(STEAK_CONTROLLER_TEST)
22
+ require 'spec_helper'
23
+
24
+ describe "!PATH!" do
25
+ before do
26
+ get "!EXPANDED_PATH!"
27
+ end
28
+
29
+ it "returns hello world" do
30
+ last_response.body.should == "Hello World"
31
+ end
32
+ end
33
+ TEST
34
+
35
+ STEAK_CONTROLLER_ACCEPTANCE_TEST = (<<-TEST).gsub(/^ {12}/, '') unless defined?(STEAK_CONTROLLER_ACCEPTANCE_TEST)
36
+ require 'spec_helper'
37
+
38
+ feature "!PATH!" do
39
+ background do
40
+ visit "!EXPANDED_PATH!"
41
+ end
42
+
43
+ scenario "returns hello world" do
44
+ page.should.have_content == "Hello World"
45
+ end
46
+ end
47
+ TEST
48
+
49
+ STEAK_RAKE = (<<-TEST).gsub(/^ {12}/, '') unless defined?(STEAK_RAKE)
50
+ require 'rspec/core/rake_task'
51
+
52
+ spec_tasks = Dir['spec/*/'].map { |d| File.basename(d) }
53
+
54
+ spec_tasks.each do |folder|
55
+ RSpec::Core::RakeTask.new("spec:\#{folder}") do |t|
56
+ t.pattern = "./spec/\#{folder}/**/*_spec.rb"
57
+ t.rspec_opts = %w(-fs --color)
58
+ end
59
+ end
60
+
61
+ desc "Run complete application spec suite"
62
+ task 'spec' => spec_tasks.map { |f| "spec:\#{f}" }
63
+ TEST
64
+
65
+ STEAK_MODEL_TEST = (<<-TEST).gsub(/^ {12}/, '') unless defined?(STEAK_MODEL_TEST)
66
+ require 'spec_helper'
67
+
68
+ describe !NAME! do
69
+ end
70
+ TEST
71
+
72
+ STEAK_HELPER_TEST = <<-TEST unless defined?(STEAK_HELPER_TEST)
73
+ require 'spec_helper'
74
+
75
+ describe "!NAME!" do
76
+ let(:helpers){ Class.new }
77
+ before { helpers.extend !NAME! }
78
+ subject { helpers }
79
+
80
+ it "should return nil" do
81
+ expect(subject.foo).to be_nil
82
+ end
83
+ end
84
+ TEST
85
+
86
+ def setup_test
87
+ require_dependencies 'rack-test', :require => 'rack/test', :group => 'test'
88
+ require_dependencies 'steak', :group => 'test'
89
+ insert_test_suite_setup STEAK_SETUP, :path => "spec/spec_helper.rb"
90
+ create_file destination_root("spec/spec.rake"), STEAK_RAKE
91
+ end
92
+
93
+ # Generates a controller test given the controllers name
94
+ def generate_controller_test(name, path)
95
+ spec_contents = STEAK_CONTROLLER_TEST.gsub(/!PATH!/, path).gsub(/!EXPANDED_PATH!/, path.gsub(/:\w+?_id/, "1"))
96
+ controller_spec_path = File.join('spec',options[:app],'controllers',"#{name.to_s.underscore}_controller_spec.rb")
97
+ create_file destination_root(controller_spec_path), spec_contents, :skip => true
98
+
99
+ acceptance_contents = STEAK_CONTROLLER_ACCEPTANCE_TEST.gsub(/!PATH!/, path).gsub(/!EXPANDED_PATH!/, path.gsub(/:\w+?_id/, "1"))
100
+ controller_acceptance_path = File.join('spec',options[:app],'acceptance','controllers',"#{name.to_s.underscore}_controller_spec.rb")
101
+ create_file destination_root(controller_acceptance_path), acceptance_contents, :skip => true
102
+ end
103
+
104
+ def generate_model_test(name)
105
+ rspec_contents = STEAK_MODEL_TEST.gsub(/!NAME!/, name.to_s.underscore.camelize).gsub(/!DNAME!/, name.to_s.underscore)
106
+ model_spec_path = File.join('spec',options[:app],'models',"#{name.to_s.underscore}_spec.rb")
107
+ create_file destination_root(model_spec_path), rspec_contents, :skip => true
108
+ end
109
+
110
+ def generate_helper_test(name, project_name, app_name)
111
+ rspec_contents = STEAK_HELPER_TEST.gsub(/!NAME!/, "#{project_name}::#{app_name}::#{name}")
112
+ helper_spec_path = File.join('spec', options[:app], 'helpers', "#{name.underscore}_spec.rb")
113
+ create_file destination_root(helper_spec_path), rspec_contents, :skip => true
114
+ end
@@ -0,0 +1,77 @@
1
+ require 'tennpipes-base/application' unless defined?(Tennpipes::Application)
2
+
3
+ module Tennpipes
4
+ module Generators
5
+ ##
6
+ # Responsible for generating route controllers and associated tests within a Tennpipes application.
7
+ #
8
+ class Controller < Thor::Group
9
+
10
+ Tennpipes::Generators.add_generator(:controller, self)
11
+
12
+ def self.source_root; File.expand_path(File.dirname(__FILE__)); end
13
+ def self.banner; "tennpipes-init controller [name]"; end
14
+
15
+ include Thor::Actions
16
+ include Tennpipes::Generators::Actions
17
+ include Tennpipes::Generators::Components::Actions
18
+
19
+ desc "Description:\n\n\ttennpipes-init controller generates a new Tennpipes controller"
20
+
21
+ argument :name, :desc => 'The name of your tennpipes controller'
22
+ argument :fields, :desc => 'The fields for the controller', :default => [], :type => :array
23
+ class_option :root, :desc => 'The root destination', :aliases => '-r', :default => '.', :type => :string
24
+ class_option :app, :desc => 'The application destination path', :aliases => '-a', :default => '/app', :type => :string
25
+ class_option :destroy, :aliases => '-d', :default => false, :type => :boolean
26
+ class_option :namespace, :desc => 'The name space of your tennpipes project', :aliases => '-n', :default => '', :type => :string
27
+ class_option :layout, :desc => 'The layout for the controller', :aliases => '-l', :default => '', :type => :string
28
+ class_option :parent, :desc => 'The parent of the controller', :aliases => '-p', :default => '', :type => :string
29
+ class_option :provides, :desc => 'The formats provided by the controller', :aliases => '-f', :default => '', :type => :string
30
+ class_option :'no-helper',:desc => 'Not generate helper', :default => false, :type => :boolean
31
+
32
+ # Show help if no ARGV given
33
+ require_arguments!
34
+
35
+ ##
36
+ # Execute controller generation
37
+ #
38
+ def create_controller
39
+ self.destination_root = options[:root]
40
+ if in_app_root?
41
+ app = options[:app]
42
+ check_app_existence(app)
43
+ @project_name = options[:namespace].underscore.camelize
44
+ @project_name = fetch_project_name(app) if @project_name.empty?
45
+ @app_name = fetch_app_name(app)
46
+ @actions = controller_actions(fields)
47
+ @controller = name.to_s.underscore
48
+ @layout = options[:layout] if options[:layout] && !options[:layout].empty?
49
+
50
+ block_opts = []
51
+ block_opts << ":parent => :#{options[:parent]}" if options[:parent] && !options[:parent].empty?
52
+ block_opts << ":provides => [#{options[:provides]}]" if options[:provides] && !options[:provides].empty?
53
+ @block_opts_string = block_opts.join(', ') unless block_opts.empty?
54
+
55
+ self.behavior = :revoke if options[:destroy]
56
+ template 'templates/controller.rb.tt', destination_root(app, 'controllers', "#{name.to_s.underscore}.rb")
57
+ empty_directory destination_root(app, "/views/#{name.to_s.underscore}")
58
+
59
+ if test?
60
+ include_component_module_for(:test)
61
+ path = @controller.dup
62
+
63
+ if options[:parent] && !options[:parent].empty?
64
+ path = Application.process_path_for_parent_params(path, [options[:parent]]).prepend("/")
65
+ end
66
+ path.prepend("/") unless path.start_with?("/")
67
+ generate_controller_test(name, path)
68
+ end
69
+
70
+ create_helper_files(app, name) unless options[:'no-helper']
71
+ else
72
+ say 'You are not at the root of a Tennpipes application! (config/boot.rb not found)'
73
+ end
74
+ end
75
+ end
76
+ end
77
+ end
@@ -0,0 +1,50 @@
1
+ module Tennpipes
2
+ module Generators
3
+ ##
4
+ # Responsible for generating route helpers and associated tests within a Tennpipes application.
5
+ #
6
+ class Helper < Thor::Group
7
+
8
+ Tennpipes::Generators.add_generator(:helper, self)
9
+
10
+ def self.source_root; File.expand_path(File.dirname(__FILE__)); end
11
+ def self.banner; "tennpipes-init helper [name]"; end
12
+
13
+ include Thor::Actions
14
+ include Tennpipes::Generators::Actions
15
+ include Tennpipes::Generators::Components::Actions
16
+
17
+ desc "Description:\n\n\ttennpipes-init helper generates a new Tennpipes helper"
18
+
19
+ argument :name, :desc => 'The name of your tennpipes helper'
20
+ argument :fields, :desc => 'The fields for the helper', :default => [], :type => :array
21
+ class_option :root, :desc => 'The root destination', :aliases => '-r', :default => '.', :type => :string
22
+ class_option :app, :desc => 'The application destination path', :aliases => '-a', :default => '/app', :type => :string
23
+ class_option :destroy, :aliases => '-d', :default => false, :type => :boolean
24
+ class_option :namespace, :desc => 'The name space of your tennpipes project', :aliases => '-n', :default => '', :type => :string
25
+
26
+ # Show help if no ARGV given
27
+ require_arguments!
28
+
29
+ ##
30
+ # Execute helper generation
31
+ #
32
+ def create_helper
33
+ self.destination_root = options[:root]
34
+ if in_app_root?
35
+ app = options[:app]
36
+ check_app_existence(app)
37
+ @project_name = options[:namespace].underscore.camelize
38
+ @project_name = fetch_project_name(app) if @project_name.empty?
39
+ @app_name = fetch_app_name(app)
40
+
41
+ self.behavior = :revoke if options[:destroy]
42
+
43
+ create_helper_files(app, name)
44
+ else
45
+ say 'You are not at the root of a Tennpipes application! (config/boot.rb not found)'
46
+ end
47
+ end
48
+ end
49
+ end
50
+ end
@@ -0,0 +1,52 @@
1
+ module Tennpipes
2
+ module Generators
3
+ ##
4
+ # Responsible for the generating mailers and message definitions.
5
+ #
6
+ class Mailer < Thor::Group
7
+
8
+ Tennpipes::Generators.add_generator(:mailer, self)
9
+
10
+ def self.source_root; File.expand_path(File.dirname(__FILE__)); end
11
+ def self.banner; 'tennpipes-init mailer [name]'; end
12
+
13
+ include Thor::Actions
14
+ include Tennpipes::Generators::Actions
15
+ include Tennpipes::Generators::Components::Actions
16
+
17
+ desc "Description:\n\n\ttennpipes-init mailer generates a new Tennpipes mailer"
18
+
19
+ argument :name, :desc => 'The name of your tennpipes mailer'
20
+ argument :actions, :desc => 'The delivery actions to add to your mailer', :type => :array, :default => []
21
+ class_option :root, :desc => 'The root destination', :aliases => '-r', :default => '.', :type => :string
22
+ class_option :app, :desc => 'The application destination path', :aliases => '-a', :default => '/app', :type => :string
23
+ class_option :destroy, :aliases => '-d', :default => false, :type => :boolean
24
+ class_option :namespace, :desc => 'The name space of your tennpipes project', :aliases => '-n', :default => '', :type => :string
25
+
26
+ # Show help if no ARGV given.
27
+ require_arguments!
28
+
29
+ ##
30
+ # Execute mailer generation.
31
+ #
32
+ def create_mailer
33
+ self.destination_root = options[:root]
34
+ if in_app_root?
35
+ app = options[:app]
36
+ check_app_existence(app)
37
+ self.behavior = :revoke if options[:destroy]
38
+ @project_name = options[:namespace].underscore.camelize
39
+ @project_name = fetch_project_name(app) if @project_name.empty?
40
+ @app_name = fetch_app_name(app)
41
+ @actions = actions.map(&:to_sym)
42
+ @short_name = name.to_s.gsub(/_mailer/i, '').underscore.downcase
43
+ @mailer_basename = @short_name.underscore
44
+ template "templates/mailer.rb.tt", destination_root(app, 'mailers', "#{@mailer_basename}.rb")
45
+ empty_directory destination_root(app, 'views', 'mailers', @mailer_basename)
46
+ else
47
+ say 'You are not at the root of a Tennpipes application! (config/boot.rb not found)'
48
+ end
49
+ end
50
+ end
51
+ end
52
+ end
@@ -0,0 +1,43 @@
1
+ module Tennpipes
2
+ module Generators
3
+ ##
4
+ # Responsible for generating migration files for the appropriate ORM component.
5
+ #
6
+ class Migration < Thor::Group
7
+ Tennpipes::Generators.add_generator(:migration, self)
8
+
9
+ def self.source_root; File.expand_path(File.dirname(__FILE__)); end
10
+ def self.banner; "tennpipes-init migration [name] [fields]"; end
11
+
12
+ include Thor::Actions
13
+ include Tennpipes::Generators::Actions
14
+ include Tennpipes::Generators::Components::Actions
15
+
16
+ desc "Description:\n\n\ttennpipes-init migration generates a new migration file"
17
+
18
+ argument :name, :desc => 'The name of your tennpipes migration'
19
+ argument :columns, :desc => 'The columns for the migration', :type => :array, :default => []
20
+ class_option :root, :desc => 'The root destination', :aliases => '-r', :default => '.', :type => :string
21
+ class_option :destroy, :aliases => '-d', :default => false, :type => :boolean
22
+
23
+ # Show help if no ARGV given.
24
+ require_arguments!
25
+
26
+ # Creates the migration file within a Tennpipes project.
27
+ def create_migration
28
+ self.destination_root = options[:root]
29
+ if in_app_root?
30
+ self.behavior = :revoke if options[:destroy]
31
+ if include_component_module_for(:orm)
32
+ create_migration_file(name, name, columns)
33
+ else
34
+ say '<= You need an ORM adapter for run this generator. Sorry!'
35
+ raise SystemExit
36
+ end
37
+ else
38
+ say 'You are not at the root of a Tennpipes application! (config/boot.rb not found)'
39
+ end
40
+ end
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,113 @@
1
+ module Tennpipes
2
+ module Generators
3
+ ##
4
+ # Responsible for generating new models for the specified ORM component.
5
+ #
6
+ class Model < Thor::Group
7
+ Tennpipes::Generators.add_generator(:model, self)
8
+
9
+ def self.source_root; File.expand_path(File.dirname(__FILE__)); end
10
+ def self.banner; "tennpipes-init model [name] [fields]"; end
11
+
12
+ include Thor::Actions
13
+ include Tennpipes::Generators::Actions
14
+ include Tennpipes::Generators::Components::Actions
15
+
16
+ desc "Description:\n\n\ttennpipes-init model generates a new model and migration files"
17
+
18
+ argument :name, :desc => 'The name of your tennpipes model'
19
+ argument :fields, :desc => 'The fields for the model', :default => [], :type => :array
20
+ class_option :root, :desc => 'The root destination', :aliases => '-r', :default => '.', :type => :string
21
+ class_option :app, :desc => 'The application destination path', :aliases => '-a', :default => '.', :type => :string
22
+ class_option :destroy, :aliases => '-d', :default => false, :type => :boolean
23
+ class_option :skip_migration, :aliases => '-s', :default => false, :type => :boolean
24
+ class_option :force, :desc => 'Generate model files if app already exists', :aliases => '-f', :default => false, :type => :boolean
25
+
26
+ # Show help if no ARGV given.
27
+ require_arguments!
28
+
29
+ # Execute the model generation.
30
+ #
31
+ def create_model
32
+ app = options[:app]
33
+ return unless valid_model_for?(app)
34
+
35
+ include_component_module_for(:test)
36
+ migration_name = "create_#{name.pluralize.underscore}"
37
+ apply_default_fields fields
38
+ create_model_file(name, :fields => fields, :app => app)
39
+ generate_model_test(name) if test?
40
+ create_model_migration(migration_name, name, fields) unless options[:skip_migration]
41
+ end
42
+
43
+ private
44
+
45
+ ##
46
+ # Validate model characteristics
47
+ # Alert if the model name is being used
48
+ #
49
+ def valid_model_for?(app)
50
+ self.destination_root = options[:root]
51
+ return false unless correct_path?
52
+
53
+ check_app_existence(app)
54
+
55
+ if options[:destroy]
56
+ self.behavior = :revoke
57
+ else
58
+ unless options[:force]
59
+ say "#{@camel_name} already exists."
60
+ say "Please, change the name."
61
+ return false
62
+ end
63
+ end if model_name_already_exists?
64
+
65
+ return false if has_invalid_fields?
66
+
67
+ check_orm
68
+ end
69
+
70
+ ##
71
+ # Return false if the model name is being used
72
+ #
73
+ def model_name_already_exists?
74
+ @camel_name = name.to_s.underscore.camelize
75
+
76
+ @project_name = ""
77
+ @project_name = fetch_project_name
78
+
79
+ return false unless already_exists?(@camel_name, @project_name)
80
+ true
81
+ end
82
+
83
+ ##
84
+ # Alert if there is not an ORM Adapter
85
+ #
86
+ def check_orm
87
+ return true if include_component_module_for(:orm)
88
+
89
+ say "<= You need an ORM adapter for run this generator. Sorry!"
90
+ raise SystemExit
91
+ end
92
+
93
+ ##
94
+ # Check app path
95
+ #
96
+ def correct_path?
97
+ return true if in_app_root?
98
+ say 'You are not at the root of a Tennpipes application! (config/boot.rb not found)'
99
+ false
100
+ end
101
+
102
+ ##
103
+ # Check if the fields are valid
104
+ #
105
+ def has_invalid_fields?
106
+ if invalids = invalid_fields(fields)
107
+ say 'Invalid field name:', :red
108
+ say " #{invalids.join(", ")}"
109
+ end
110
+ end
111
+ end
112
+ end
113
+ end