tennpipes-init 3.6.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/LICENSE.txt +20 -0
- data/README.rdoc +163 -0
- data/Rakefile +1 -0
- data/bin/tennpipes-init +16 -0
- data/lib/tennpipes-init.rb +73 -0
- data/lib/tennpipes-init/command.rb +18 -0
- data/lib/tennpipes-init/generators/actions.rb +630 -0
- data/lib/tennpipes-init/generators/app.rb +75 -0
- data/lib/tennpipes-init/generators/app/app.rb.tt +72 -0
- data/lib/tennpipes-init/generators/app/app.rb.tt~ +72 -0
- data/lib/tennpipes-init/generators/cli.rb +57 -0
- data/lib/tennpipes-init/generators/component.rb +73 -0
- data/lib/tennpipes-init/generators/components/actions.rb +208 -0
- data/lib/tennpipes-init/generators/components/mocks/mocha.rb +10 -0
- data/lib/tennpipes-init/generators/components/mocks/rr.rb +13 -0
- data/lib/tennpipes-init/generators/components/orms/activerecord.rb +201 -0
- data/lib/tennpipes-init/generators/components/orms/couchrest.rb +55 -0
- data/lib/tennpipes-init/generators/components/orms/datamapper.rb +140 -0
- data/lib/tennpipes-init/generators/components/orms/dynamoid.rb +67 -0
- data/lib/tennpipes-init/generators/components/orms/minirecord.rb +165 -0
- data/lib/tennpipes-init/generators/components/orms/mongoid.rb +113 -0
- data/lib/tennpipes-init/generators/components/orms/mongomapper.rb +43 -0
- data/lib/tennpipes-init/generators/components/orms/mongomatic.rb +84 -0
- data/lib/tennpipes-init/generators/components/orms/ohm.rb +65 -0
- data/lib/tennpipes-init/generators/components/orms/ripple.rb +75 -0
- data/lib/tennpipes-init/generators/components/orms/sequel.rb +99 -0
- data/lib/tennpipes-init/generators/components/renderers/erb.rb +3 -0
- data/lib/tennpipes-init/generators/components/renderers/haml.rb +3 -0
- data/lib/tennpipes-init/generators/components/renderers/liquid.rb +4 -0
- data/lib/tennpipes-init/generators/components/renderers/slim.rb +3 -0
- data/lib/tennpipes-init/generators/components/scripts/dojo.rb +10 -0
- data/lib/tennpipes-init/generators/components/scripts/extcore.rb +10 -0
- data/lib/tennpipes-init/generators/components/scripts/jquery.rb +10 -0
- data/lib/tennpipes-init/generators/components/scripts/mootools.rb +10 -0
- data/lib/tennpipes-init/generators/components/scripts/prototype.rb +12 -0
- data/lib/tennpipes-init/generators/components/scripts/rightjs.rb +10 -0
- data/lib/tennpipes-init/generators/components/stylesheets/compass.rb +39 -0
- data/lib/tennpipes-init/generators/components/stylesheets/compass/application.scss +43 -0
- data/lib/tennpipes-init/generators/components/stylesheets/compass/partials/_base.scss +12 -0
- data/lib/tennpipes-init/generators/components/stylesheets/less.rb +25 -0
- data/lib/tennpipes-init/generators/components/stylesheets/sass.rb +15 -0
- data/lib/tennpipes-init/generators/components/stylesheets/scss.rb +16 -0
- data/lib/tennpipes-init/generators/components/tests/bacon.rb +103 -0
- data/lib/tennpipes-init/generators/components/tests/cucumber.rb +86 -0
- data/lib/tennpipes-init/generators/components/tests/minitest.rb +110 -0
- data/lib/tennpipes-init/generators/components/tests/riot.rb +117 -0
- data/lib/tennpipes-init/generators/components/tests/rspec.rb +111 -0
- data/lib/tennpipes-init/generators/components/tests/shoulda.rb +114 -0
- data/lib/tennpipes-init/generators/components/tests/steak.rb +114 -0
- data/lib/tennpipes-init/generators/controller.rb +77 -0
- data/lib/tennpipes-init/generators/helper.rb +50 -0
- data/lib/tennpipes-init/generators/mailer.rb +52 -0
- data/lib/tennpipes-init/generators/migration.rb +43 -0
- data/lib/tennpipes-init/generators/model.rb +113 -0
- data/lib/tennpipes-init/generators/plugin.rb +67 -0
- data/lib/tennpipes-init/generators/project.rb +160 -0
- data/lib/tennpipes-init/generators/project/config.ru +9 -0
- data/lib/tennpipes-init/generators/project/config/apps.rb.tt +35 -0
- data/lib/tennpipes-init/generators/project/config/boot.rb +49 -0
- data/lib/tennpipes-init/generators/project/public/favicon.ico +0 -0
- data/lib/tennpipes-init/generators/project/public/images/booking.com.png +0 -0
- data/lib/tennpipes-init/generators/project/public/images/causes.png +0 -0
- data/lib/tennpipes-init/generators/project/public/images/ennkeypee_bg.jpg +0 -0
- data/lib/tennpipes-init/generators/project/public/images/ennkeypee_bluelogo.png +0 -0
- data/lib/tennpipes-init/generators/project/public/images/ennkeypee_bluelogo.svg +68 -0
- data/lib/tennpipes-init/generators/project/public/images/ennkeypee_whitelogo.png +0 -0
- data/lib/tennpipes-init/generators/project/public/images/ennkeypee_whitelogo.svg +65 -0
- data/lib/tennpipes-init/generators/project/public/images/forever21.png +0 -0
- data/lib/tennpipes-init/generators/project/public/images/icons/foundation-icons.eot +0 -0
- data/lib/tennpipes-init/generators/project/public/images/icons/foundation-icons.svg +970 -0
- data/lib/tennpipes-init/generators/project/public/images/icons/foundation-icons.ttf +0 -0
- data/lib/tennpipes-init/generators/project/public/images/icons/foundation-icons.woff +0 -0
- data/lib/tennpipes-init/generators/project/public/images/icons/tennpipes-icons.css +598 -0
- data/lib/tennpipes-init/generators/project/public/images/image1.jpg +0 -0
- data/lib/tennpipes-init/generators/project/public/images/image11.jpg +0 -0
- data/lib/tennpipes-init/generators/project/public/images/image2.jpg +0 -0
- data/lib/tennpipes-init/generators/project/public/images/image3.jpg +0 -0
- data/lib/tennpipes-init/generators/project/public/images/intuit.png +0 -0
- data/lib/tennpipes-init/generators/project/public/images/krispykreme.png +0 -0
- data/lib/tennpipes-init/generators/project/public/images/placeholders/README.md +302 -0
- data/lib/tennpipes-init/generators/project/public/images/placeholders/bower.json +4 -0
- data/lib/tennpipes-init/generators/project/public/images/placeholders/composer.json +34 -0
- data/lib/tennpipes-init/generators/project/public/images/placeholders/gulpfile.js +92 -0
- data/lib/tennpipes-init/generators/project/public/images/placeholders/holder.js +1920 -0
- data/lib/tennpipes-init/generators/project/public/images/placeholders/holder.min.js +12 -0
- data/lib/tennpipes-init/generators/project/public/images/placeholders/package.json +46 -0
- data/lib/tennpipes-init/generators/project/public/images/placeholders/src/holder.js +1411 -0
- data/lib/tennpipes-init/generators/project/public/images/placeholders/src/lib/augment.js +27 -0
- data/lib/tennpipes-init/generators/project/public/images/placeholders/src/lib/ondomready.js +155 -0
- data/lib/tennpipes-init/generators/project/public/images/placeholders/src/lib/polyfills.js +177 -0
- data/lib/tennpipes-init/generators/project/public/images/placeholders/src/scenegraph.js +101 -0
- data/lib/tennpipes-init/generators/project/public/images/placeholders/src/utils.js +129 -0
- data/lib/tennpipes-init/generators/project/public/images/priceline.com.png +0 -0
- data/lib/tennpipes-init/generators/project/public/images/stripe.png +0 -0
- data/lib/tennpipes-init/generators/project/public/javascripts/tennpipes.min.js +6081 -0
- data/lib/tennpipes-init/generators/project/public/javascripts/tennpipes/tennpipes.abide.js +340 -0
- data/lib/tennpipes-init/generators/project/public/javascripts/tennpipes/tennpipes.accordion.js +67 -0
- data/lib/tennpipes-init/generators/project/public/javascripts/tennpipes/tennpipes.alert.js +43 -0
- data/lib/tennpipes-init/generators/project/public/javascripts/tennpipes/tennpipes.clearing.js +556 -0
- data/lib/tennpipes-init/generators/project/public/javascripts/tennpipes/tennpipes.dropdown.js +448 -0
- data/lib/tennpipes-init/generators/project/public/javascripts/tennpipes/tennpipes.equalizer.js +77 -0
- data/lib/tennpipes-init/generators/project/public/javascripts/tennpipes/tennpipes.interchange.js +354 -0
- data/lib/tennpipes-init/generators/project/public/javascripts/tennpipes/tennpipes.joyride.js +932 -0
- data/lib/tennpipes-init/generators/project/public/javascripts/tennpipes/tennpipes.js +703 -0
- data/lib/tennpipes-init/generators/project/public/javascripts/tennpipes/tennpipes.magellan.js +203 -0
- data/lib/tennpipes-init/generators/project/public/javascripts/tennpipes/tennpipes.offcanvas.js +152 -0
- data/lib/tennpipes-init/generators/project/public/javascripts/tennpipes/tennpipes.orbit.js +476 -0
- data/lib/tennpipes-init/generators/project/public/javascripts/tennpipes/tennpipes.reveal.js +471 -0
- data/lib/tennpipes-init/generators/project/public/javascripts/tennpipes/tennpipes.slider.js +263 -0
- data/lib/tennpipes-init/generators/project/public/javascripts/tennpipes/tennpipes.tab.js +237 -0
- data/lib/tennpipes-init/generators/project/public/javascripts/tennpipes/tennpipes.tooltip.js +307 -0
- data/lib/tennpipes-init/generators/project/public/javascripts/tennpipes/tennpipes.topbar.js +452 -0
- data/lib/tennpipes-init/generators/project/public/javascripts/vendor/fastclick.js +8 -0
- data/lib/tennpipes-init/generators/project/public/javascripts/vendor/jquery.cookie.js +8 -0
- data/lib/tennpipes-init/generators/project/public/javascripts/vendor/jquery.js +26 -0
- data/lib/tennpipes-init/generators/project/public/javascripts/vendor/modernizr.js +8 -0
- data/lib/tennpipes-init/generators/project/public/javascripts/vendor/placeholder.js +2 -0
- data/lib/tennpipes-init/generators/project/public/stylesheets/app.css~ +178 -0
- data/lib/tennpipes-init/generators/project/public/stylesheets/app1.css~ +177 -0
- data/lib/tennpipes-init/generators/project/public/stylesheets/ennkeypee.css +214 -0
- data/lib/tennpipes-init/generators/project/public/stylesheets/ennkeypee.css~ +214 -0
- data/lib/tennpipes-init/generators/project/public/stylesheets/normalize.css +427 -0
- data/lib/tennpipes-init/generators/project/public/stylesheets/tennpipes.css +6201 -0
- data/lib/tennpipes-init/generators/project/public/stylesheets/tennpipes.css~ +6201 -0
- data/lib/tennpipes-init/generators/project/public/stylesheets/tennpipes.min.css +1 -0
- data/lib/tennpipes-init/generators/runner.rb +139 -0
- data/lib/tennpipes-init/generators/task.rb +45 -0
- data/lib/tennpipes-init/generators/templates/Gemfile.tt +32 -0
- data/lib/tennpipes-init/generators/templates/Rakefile.tt +8 -0
- data/lib/tennpipes-init/generators/templates/controller.rb.tt +22 -0
- data/lib/tennpipes-init/generators/templates/gem/README.md.tt +29 -0
- data/lib/tennpipes-init/generators/templates/gem/gemspec.tt +19 -0
- data/lib/tennpipes-init/generators/templates/gem/lib/libname.tt +6 -0
- data/lib/tennpipes-init/generators/templates/gem/lib/libname/version.tt +3 -0
- data/lib/tennpipes-init/generators/templates/helper.rb.tt +13 -0
- data/lib/tennpipes-init/generators/templates/initializer.rb.tt +5 -0
- data/lib/tennpipes-init/generators/templates/mailer.rb.tt +54 -0
- data/lib/tennpipes-init/generators/templates/project_bin.tt +14 -0
- data/lib/tennpipes-init/generators/templates/task.rb.tt +7 -0
- data/lib/tennpipes-init/tennpipes-tasks/activerecord.rb +377 -0
- data/lib/tennpipes-init/tennpipes-tasks/database.rb +12 -0
- data/lib/tennpipes-init/tennpipes-tasks/datamapper.rb +94 -0
- data/lib/tennpipes-init/tennpipes-tasks/minirecord.rb +19 -0
- data/lib/tennpipes-init/tennpipes-tasks/mongoid.rb +215 -0
- data/lib/tennpipes-init/tennpipes-tasks/mongomapper.rb +55 -0
- data/lib/tennpipes-init/tennpipes-tasks/sequel.rb +85 -0
- data/lib/tennpipes-init/tennpipes-tasks/sql-helpers.rb +72 -0
- data/test/fixtures/admin_template.rb +7 -0
- data/test/fixtures/example_template.rb +15 -0
- data/test/fixtures/git_template.rb +4 -0
- data/test/fixtures/plugin_template.rb +13 -0
- data/test/fixtures/rake_template.rb +9 -0
- data/test/helper.rb +103 -0
- data/test/test_app_generator.rb +142 -0
- data/test/test_cli.rb +27 -0
- data/test/test_component_generator.rb +98 -0
- data/test/test_controller_generator.rb +272 -0
- data/test/test_generator.rb +13 -0
- data/test/test_helper_generator.rb +133 -0
- data/test/test_mailer_generator.rb +69 -0
- data/test/test_migration_generator.rb +222 -0
- data/test/test_model_generator.rb +553 -0
- data/test/test_plugin_generator.rb +152 -0
- data/test/test_project_generator.rb +757 -0
- data/test/test_task_generator.rb +53 -0
- metadata +285 -0
@@ -0,0 +1,75 @@
|
|
1
|
+
module Tennpipes
|
2
|
+
module Generators
|
3
|
+
|
4
|
+
##
|
5
|
+
# Responsible for applications within a Tennpipes project. Creates and mounts
|
6
|
+
# the application and gives the user related information.
|
7
|
+
#
|
8
|
+
class App < Thor::Group
|
9
|
+
|
10
|
+
Tennpipes::Generators.add_generator(:app, self)
|
11
|
+
|
12
|
+
def self.source_root; File.expand_path(File.dirname(__FILE__)); end
|
13
|
+
def self.banner; "tennpipes-init app [name]"; end
|
14
|
+
|
15
|
+
include Thor::Actions
|
16
|
+
include Tennpipes::Generators::Actions
|
17
|
+
|
18
|
+
desc "Description:\n\n\ttennpipes-init app generates a new Tennpipes application"
|
19
|
+
argument :name, :desc => 'The name of your tennpipes application'
|
20
|
+
class_option :root, :desc => 'The root destination', :aliases => '-r', :default => '.', :type => :string
|
21
|
+
class_option :destroy, :aliases => '-d', :default => false, :type => :boolean
|
22
|
+
class_option :tiny, :desc => 'Generate tiny app skeleton', :aliases => '-i', :default => false, :type => :boolean
|
23
|
+
class_option :namespace, :desc => 'The name space of your tennpipes project', :aliases => '-n', :default => '', :type => :string
|
24
|
+
class_option :force, :desc => 'Generate app files if app already exists', :aliases => '-f', :default => false, :type => :boolean
|
25
|
+
|
26
|
+
# Show help if no ARGV given
|
27
|
+
require_arguments!
|
28
|
+
|
29
|
+
##
|
30
|
+
# Copies over the Tennpipes base admin application.
|
31
|
+
#
|
32
|
+
def create_app
|
33
|
+
self.destination_root = options[:root]
|
34
|
+
underscore_name = name.gsub(/\W/, '_')
|
35
|
+
@app_folder = underscore_name.underscore
|
36
|
+
@app_name = underscore_name.camelize
|
37
|
+
if in_app_root?
|
38
|
+
@project_name = options[:namespace].underscore.camelize
|
39
|
+
@project_name = fetch_project_name(@app_folder) if @project_name.empty?
|
40
|
+
|
41
|
+
if options[:destroy]
|
42
|
+
self.behavior = :revoke
|
43
|
+
else
|
44
|
+
unless options[:force]
|
45
|
+
say "#{@app_name} already exists."
|
46
|
+
say "Please, change the name."
|
47
|
+
return
|
48
|
+
end
|
49
|
+
end if already_exists?(@app_name, @project_name)
|
50
|
+
|
51
|
+
lowercase_app_folder = @app_folder.downcase
|
52
|
+
app_skeleton(lowercase_app_folder, options[:tiny])
|
53
|
+
empty_directory destination_root("public/#{lowercase_app_folder}")
|
54
|
+
|
55
|
+
mount_command = "\nTennpipes.mount('#{@project_name}::#{@app_name}', :app_file => Tennpipes.root('#{lowercase_app_folder}/app.rb')).to('/#{lowercase_app_folder}')\n"
|
56
|
+
if File.read(destination_root('config/apps.rb')).match(/^Tennpipes.mount.*\.to\('\/'\)$/)
|
57
|
+
inject_into_file destination_root('config/apps.rb'), mount_command, :before => /^Tennpipes.mount.*\.to\('\/'\)$/
|
58
|
+
else
|
59
|
+
append_file destination_root('config/apps.rb'), mount_command
|
60
|
+
end
|
61
|
+
|
62
|
+
return if self.behavior == :revoke
|
63
|
+
say
|
64
|
+
say '=' * 65, :green
|
65
|
+
say "Your #{@app_name} application has been installed."
|
66
|
+
say '=' * 65, :green
|
67
|
+
say "This application has been mounted to /#{@app_name.downcase}"
|
68
|
+
say "You can configure a different path by editing 'config/apps.rb'"
|
69
|
+
else
|
70
|
+
say 'You are not at the root of a Tennpipes application! (config/boot.rb not found)'
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
@@ -0,0 +1,72 @@
|
|
1
|
+
module <%= @project_name %>
|
2
|
+
class <%= @app_name %> < Tennpipes::Application
|
3
|
+
register Tennpipes::Mailer
|
4
|
+
register Tennpipes::Helpers
|
5
|
+
|
6
|
+
enable :sessions
|
7
|
+
|
8
|
+
class <%= @project_name %>::<%= @app_name %>
|
9
|
+
get '/' do
|
10
|
+
erb :home
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
|
15
|
+
##
|
16
|
+
# Caching support.
|
17
|
+
#
|
18
|
+
# register Tennpipes::Cache
|
19
|
+
# enable :caching
|
20
|
+
#
|
21
|
+
# You can customize caching store engines:
|
22
|
+
#
|
23
|
+
# set :cache, Tennpipes::Cache.new(:LRUHash) # Keeps cached values in memory
|
24
|
+
# set :cache, Tennpipes::Cache.new(:Memcached) # Uses default server at localhost
|
25
|
+
# set :cache, Tennpipes::Cache.new(:Memcached, '127.0.0.1:11211', :exception_retry_limit => 1)
|
26
|
+
# set :cache, Tennpipes::Cache.new(:Memcached, :backend => memcached_or_dalli_instance)
|
27
|
+
# set :cache, Tennpipes::Cache.new(:Redis) # Uses default server at localhost
|
28
|
+
# set :cache, Tennpipes::Cache.new(:Redis, :host => '127.0.0.1', :port => 6379, :db => 0)
|
29
|
+
# set :cache, Tennpipes::Cache.new(:Redis, :backend => redis_instance)
|
30
|
+
# set :cache, Tennpipes::Cache.new(:Mongo) # Uses default server at localhost
|
31
|
+
# set :cache, Tennpipes::Cache.new(:Mongo, :backend => mongo_client_instance)
|
32
|
+
# set :cache, Tennpipes::Cache.new(:File, :dir => Tennpipes.root('tmp', app_name.to_s, 'cache')) # default choice
|
33
|
+
#
|
34
|
+
|
35
|
+
##
|
36
|
+
# Application configuration options.
|
37
|
+
#
|
38
|
+
# set :raise_errors, true # Raise exceptions (will stop application) (default for test)
|
39
|
+
# set :dump_errors, true # Exception backtraces are written to STDERR (default for production/development)
|
40
|
+
# set :show_exceptions, true # Shows a stack trace in browser (default for development)
|
41
|
+
# set :logging, true # Logging in STDOUT for development and file for production (default only for development)
|
42
|
+
# set :public_folder, 'foo/bar' # Location for static assets (default root/public)
|
43
|
+
# set :reload, false # Reload application files (default in development)
|
44
|
+
# set :default_builder, 'foo' # Set a custom form builder (default 'StandardFormBuilder')
|
45
|
+
# set :locale_path, 'bar' # Set path for I18n translations (default your_apps_root_path/locale)
|
46
|
+
# disable :sessions # Disabled sessions by default (enable if needed)
|
47
|
+
# disable :flash # Disables sinatra-flash (enabled by default if Sinatra::Flash is defined)
|
48
|
+
# layout :my_layout # Layout can be in views/layouts/foo.ext or views/foo.ext (default :application)
|
49
|
+
#
|
50
|
+
|
51
|
+
##
|
52
|
+
# You can configure for a specified environment like:
|
53
|
+
#
|
54
|
+
# configure :development do
|
55
|
+
# set :foo, :bar
|
56
|
+
# disable :asset_stamp # no asset timestamping for dev
|
57
|
+
# end
|
58
|
+
#
|
59
|
+
|
60
|
+
##
|
61
|
+
# You can manage errors like:
|
62
|
+
#
|
63
|
+
# error 404 do
|
64
|
+
# render 'errors/404'
|
65
|
+
# end
|
66
|
+
#
|
67
|
+
# error 500 do
|
68
|
+
# render 'errors/500'
|
69
|
+
# end
|
70
|
+
#
|
71
|
+
end
|
72
|
+
end
|
@@ -0,0 +1,72 @@
|
|
1
|
+
module <%= @project_name %>
|
2
|
+
class <%= @app_name %> < Tennpipes::Application
|
3
|
+
register Tennpipes::Mailer
|
4
|
+
register Tennpipes::Helpers
|
5
|
+
|
6
|
+
enable :sessions
|
7
|
+
|
8
|
+
class <%= @project_name %>::<%= @app_name %>
|
9
|
+
get '/' do
|
10
|
+
erb :<%= @app_name.downcase %>
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
|
15
|
+
##
|
16
|
+
# Caching support.
|
17
|
+
#
|
18
|
+
# register Tennpipes::Cache
|
19
|
+
# enable :caching
|
20
|
+
#
|
21
|
+
# You can customize caching store engines:
|
22
|
+
#
|
23
|
+
# set :cache, Tennpipes::Cache.new(:LRUHash) # Keeps cached values in memory
|
24
|
+
# set :cache, Tennpipes::Cache.new(:Memcached) # Uses default server at localhost
|
25
|
+
# set :cache, Tennpipes::Cache.new(:Memcached, '127.0.0.1:11211', :exception_retry_limit => 1)
|
26
|
+
# set :cache, Tennpipes::Cache.new(:Memcached, :backend => memcached_or_dalli_instance)
|
27
|
+
# set :cache, Tennpipes::Cache.new(:Redis) # Uses default server at localhost
|
28
|
+
# set :cache, Tennpipes::Cache.new(:Redis, :host => '127.0.0.1', :port => 6379, :db => 0)
|
29
|
+
# set :cache, Tennpipes::Cache.new(:Redis, :backend => redis_instance)
|
30
|
+
# set :cache, Tennpipes::Cache.new(:Mongo) # Uses default server at localhost
|
31
|
+
# set :cache, Tennpipes::Cache.new(:Mongo, :backend => mongo_client_instance)
|
32
|
+
# set :cache, Tennpipes::Cache.new(:File, :dir => Tennpipes.root('tmp', app_name.to_s, 'cache')) # default choice
|
33
|
+
#
|
34
|
+
|
35
|
+
##
|
36
|
+
# Application configuration options.
|
37
|
+
#
|
38
|
+
# set :raise_errors, true # Raise exceptions (will stop application) (default for test)
|
39
|
+
# set :dump_errors, true # Exception backtraces are written to STDERR (default for production/development)
|
40
|
+
# set :show_exceptions, true # Shows a stack trace in browser (default for development)
|
41
|
+
# set :logging, true # Logging in STDOUT for development and file for production (default only for development)
|
42
|
+
# set :public_folder, 'foo/bar' # Location for static assets (default root/public)
|
43
|
+
# set :reload, false # Reload application files (default in development)
|
44
|
+
# set :default_builder, 'foo' # Set a custom form builder (default 'StandardFormBuilder')
|
45
|
+
# set :locale_path, 'bar' # Set path for I18n translations (default your_apps_root_path/locale)
|
46
|
+
# disable :sessions # Disabled sessions by default (enable if needed)
|
47
|
+
# disable :flash # Disables sinatra-flash (enabled by default if Sinatra::Flash is defined)
|
48
|
+
# layout :my_layout # Layout can be in views/layouts/foo.ext or views/foo.ext (default :application)
|
49
|
+
#
|
50
|
+
|
51
|
+
##
|
52
|
+
# You can configure for a specified environment like:
|
53
|
+
#
|
54
|
+
# configure :development do
|
55
|
+
# set :foo, :bar
|
56
|
+
# disable :asset_stamp # no asset timestamping for dev
|
57
|
+
# end
|
58
|
+
#
|
59
|
+
|
60
|
+
##
|
61
|
+
# You can manage errors like:
|
62
|
+
#
|
63
|
+
# error 404 do
|
64
|
+
# render 'errors/404'
|
65
|
+
# end
|
66
|
+
#
|
67
|
+
# error 500 do
|
68
|
+
# render 'errors/500'
|
69
|
+
# end
|
70
|
+
#
|
71
|
+
end
|
72
|
+
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
require 'thor/group'
|
2
|
+
|
3
|
+
module Tennpipes
|
4
|
+
module Generators
|
5
|
+
##
|
6
|
+
# This class bootstrap +config/boot+ and perform
|
7
|
+
# +Tennpipes::Generators.load_components!+ for handle 3rd party generators.
|
8
|
+
#
|
9
|
+
class Cli < Thor::Group
|
10
|
+
|
11
|
+
include Thor::Actions
|
12
|
+
|
13
|
+
class_option :root, :desc => "The root destination", :aliases => '-r', :default => ".", :type => :string
|
14
|
+
class_option :help, :type => :boolean, :desc => "Show help usage"
|
15
|
+
|
16
|
+
##
|
17
|
+
# We need to try to load boot because some of our app dependencies maybe have
|
18
|
+
# custom generators, so is necessary know who are.
|
19
|
+
#
|
20
|
+
def load_boot
|
21
|
+
begin
|
22
|
+
ENV['TENNPIPES_LOG_LEVEL'] ||= 'test'
|
23
|
+
ENV['BUNDLE_GEMFILE'] = File.join(options[:root], 'Gemfile') if options[:root]
|
24
|
+
boot = options[:root] ? File.join(options[:root], 'config/boot.rb') : 'config/boot.rb'
|
25
|
+
if File.exist?(boot)
|
26
|
+
require File.expand_path(boot)
|
27
|
+
else
|
28
|
+
require 'tennpipes-assist'
|
29
|
+
end
|
30
|
+
rescue StandardError => e
|
31
|
+
puts "=> Problem loading #{boot}"
|
32
|
+
puts ["=> #{e.message}", *e.backtrace].join("\n ")
|
33
|
+
ensure
|
34
|
+
ENV.delete('BUNDLE_GEMFILE')
|
35
|
+
ENV.delete('TENNPIPES_LOG_LEVEL')
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
##
|
40
|
+
# Loads the components available for all generators.
|
41
|
+
#
|
42
|
+
def setup
|
43
|
+
Tennpipes::Generators.load_components!
|
44
|
+
|
45
|
+
generator_kind = ARGV.delete_at(0).to_s.downcase.to_sym if ARGV[0].present?
|
46
|
+
generator_class = Tennpipes::Generators.mappings[generator_kind]
|
47
|
+
|
48
|
+
if generator_class
|
49
|
+
args = ARGV.empty? && generator_class.require_arguments? ? ['-h'] : ARGV
|
50
|
+
generator_class.start(args)
|
51
|
+
else
|
52
|
+
puts "Please specify generator to use (#{Tennpipes::Generators.mappings.keys.join(", ")})"
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
@@ -0,0 +1,73 @@
|
|
1
|
+
module Tennpipes
|
2
|
+
module Generators
|
3
|
+
|
4
|
+
##
|
5
|
+
# Responsible for add components within a Tennpipes project.
|
6
|
+
#
|
7
|
+
class Component < Thor::Group
|
8
|
+
|
9
|
+
Tennpipes::Generators.add_generator(:component, self)
|
10
|
+
|
11
|
+
def self.source_root; File.expand_path(File.dirname(__FILE__)); end
|
12
|
+
def self.banner; "tennpipes-init component [options]"; end
|
13
|
+
|
14
|
+
include Thor::Actions
|
15
|
+
include Tennpipes::Generators::Actions
|
16
|
+
include Tennpipes::Generators::Components::Actions
|
17
|
+
|
18
|
+
desc "Description:\n\n\ttennpipes-init component add components into a Tennpipes project"
|
19
|
+
|
20
|
+
class_option :app, :desc => 'The application name', :aliases => '-n', :default => nil, :type => :string
|
21
|
+
class_option :root, :desc => 'The root destination', :aliases => '-r', :default => '.', :type => :string
|
22
|
+
class_option :adapter, :desc => 'SQL adapter for ORM (sqlite, mysql, mysql2, mysql-gem, postgres)', :aliases => '-a', :default => 'sqlite', :type => :string
|
23
|
+
|
24
|
+
defines_component_options :default => false
|
25
|
+
|
26
|
+
##
|
27
|
+
# For each component, retrieve a valid choice and then execute the associated generator.
|
28
|
+
#
|
29
|
+
def setup_components
|
30
|
+
self.destination_root = options[:root]
|
31
|
+
if in_app_root?
|
32
|
+
@_components = options.dup.slice(*self.class.component_types)
|
33
|
+
@app_name = (options[:app] || "App").gsub(/\W/, '_').camelize
|
34
|
+
if @_components.values.delete_if(&:blank?).empty?
|
35
|
+
self.class.start(["-h"])
|
36
|
+
say
|
37
|
+
say "Current Selected Components:"
|
38
|
+
list = []
|
39
|
+
self.class.component_types.each do |comp|
|
40
|
+
list << [comp, fetch_component_choice(comp)]
|
41
|
+
end
|
42
|
+
print_table(list, :indent => 2)
|
43
|
+
exit
|
44
|
+
end
|
45
|
+
|
46
|
+
self.class.component_types.each do |comp|
|
47
|
+
next if @_components[comp].blank?
|
48
|
+
|
49
|
+
choice = @_components[comp] = resolve_valid_choice(comp)
|
50
|
+
existing = fetch_component_choice(comp)
|
51
|
+
if existing != 'none' && existing != choice
|
52
|
+
next unless yes?("Switch #{comp} to '#{choice}' from '#{existing}' ?[yes/no]:")
|
53
|
+
end
|
54
|
+
@project_name = fetch_component_choice(:namespace)
|
55
|
+
if comp.to_s == 'test' && !already_exists?(@app_name, @project_name)
|
56
|
+
say "#{@project_name}::#{@app_name} does not exist."
|
57
|
+
say "Please, change app name."
|
58
|
+
next
|
59
|
+
end
|
60
|
+
execute_component_setup(comp, choice)
|
61
|
+
store_component_choice(comp, choice)
|
62
|
+
if comp.to_s == 'orm' && choice.to_s != 'none'
|
63
|
+
inject_into_file destination_root('Rakefile'), "TennpipesTasks.use(:database)\n", :before => "TennpipesTasks.init"
|
64
|
+
inject_into_file destination_root('Rakefile'), "TennpipesTasks.use(#{choice.to_sym.inspect})\n", :before => "TennpipesTasks.init"
|
65
|
+
end
|
66
|
+
end
|
67
|
+
else
|
68
|
+
say 'You are not at the root of a Tennpipes application! (config/boot.rb not found)'
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
@@ -0,0 +1,208 @@
|
|
1
|
+
module Tennpipes
|
2
|
+
module Generators
|
3
|
+
module Components
|
4
|
+
module Actions
|
5
|
+
##
|
6
|
+
# Generates the model migration file created when generating a new model.
|
7
|
+
#
|
8
|
+
# @param [String] filename
|
9
|
+
# File name of model migration.
|
10
|
+
# @param [String] name
|
11
|
+
# Name of model.
|
12
|
+
# @param [Array<String>] columns
|
13
|
+
# Array of column names and property type.
|
14
|
+
# @param [Hash] options
|
15
|
+
# Additional migration options, e.g
|
16
|
+
# { :base => "....text...", :up => "..text...",
|
17
|
+
# :down => "..text...", column_format => "t.column :#{field}, :#{kind}" }
|
18
|
+
# @example
|
19
|
+
# output_model_migration("AddPerson", "person", ["name:string", "age:integer"],
|
20
|
+
# :base => AR_MIGRATION,
|
21
|
+
# :column_format => Proc.new { |field, kind| "t.#{kind.underscore.gsub(/_/, '')} :#{field}" },
|
22
|
+
# :up => AR_MODEL_UP_MG, :down => AR_MODEL_DOWN_MG)
|
23
|
+
#
|
24
|
+
def output_model_migration(filename, name, columns, options={})
|
25
|
+
if behavior == :revoke
|
26
|
+
remove_migration(filename)
|
27
|
+
else
|
28
|
+
return if migration_exist?(filename)
|
29
|
+
model_name = name.to_s.pluralize
|
30
|
+
field_tuples = columns.map { |value| value.split(":") }
|
31
|
+
field_tuples.map! { |field, kind| kind =~ /datetime/i ? [field, 'DateTime'] : [field, kind] }
|
32
|
+
column_declarations = field_tuples.map(&options[:column_format]).join("\n ")
|
33
|
+
contents = options[:base].dup.gsub(/\s{4}!UP!\n/m, options[:up]).gsub(/!DOWN!\n/m, options[:down])
|
34
|
+
contents = contents.gsub(/!NAME!/, model_name.underscore.camelize).gsub(/!TABLE!/, model_name.underscore)
|
35
|
+
contents = contents.gsub(/!FILENAME!/, filename.underscore).gsub(/!FILECLASS!/, filename.underscore.camelize)
|
36
|
+
migration_number = current_migration_number
|
37
|
+
contents = contents.gsub(/!FIELDS!/, column_declarations).gsub(/!VERSION!/, migration_number)
|
38
|
+
migration_filename = "#{format("%03d", migration_number)}_#{filename.underscore}.rb"
|
39
|
+
create_file(destination_root('db/migrate/', migration_filename), contents, :skip => true)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
##
|
44
|
+
# Generates a standalone migration file based on the given options and columns.
|
45
|
+
#
|
46
|
+
# @param [String] filename
|
47
|
+
# File name of model migration.
|
48
|
+
# @param [String] name
|
49
|
+
# Name of model.
|
50
|
+
# @param [Array<String>] columns
|
51
|
+
# Array of column names and property type.
|
52
|
+
# @param [Hash] options
|
53
|
+
# Additional migration options, e.g
|
54
|
+
# { :base "...text...", :change_format => "...text...",
|
55
|
+
# :add => proc { |field, kind| "add_column :#{table_name}, :#{field}, :#{kind}" },
|
56
|
+
# :remove => proc { |field, kind| "remove_column :#{table_name}, :#{field}" }
|
57
|
+
# @example
|
58
|
+
# output_migration_file(migration_name, name, columns,
|
59
|
+
# :base => AR_MIGRATION, :change_format => AR_CHANGE_MG,
|
60
|
+
# :add => Proc.new { |field, kind| "t.#{kind.underscore.gsub(/_/, '')} :#{field}" },
|
61
|
+
# :remove => Proc.new { |field, kind| "t.remove :#{field}" }
|
62
|
+
# )
|
63
|
+
#
|
64
|
+
def output_migration_file(filename, name, columns, options={})
|
65
|
+
if behavior == :revoke
|
66
|
+
remove_migration(name)
|
67
|
+
else
|
68
|
+
return if migration_exist?(filename)
|
69
|
+
change_format = options[:change_format]
|
70
|
+
migration_scan = filename.underscore.camelize.scan(/(Add|Remove).*?(?:(?:To|From).+?)*(?:To|From)((?:To|From)?.*?)$/).flatten
|
71
|
+
direction, table_name = migration_scan[0].downcase, migration_scan[1].downcase.pluralize if migration_scan.any?
|
72
|
+
tuples = direction ? columns.map { |value| value.split(":") } : []
|
73
|
+
tuples.map! { |field, kind| kind =~ /datetime/i ? [field, 'DateTime'] : [field, kind] }
|
74
|
+
add_columns = tuples.map(&options[:add]).join("\n ")
|
75
|
+
remove_columns = tuples.map(&options[:remove]).join("\n ")
|
76
|
+
forward_text = change_format.gsub(/!TABLE!/, table_name).gsub(/!COLUMNS!/, add_columns) if tuples.any?
|
77
|
+
back_text = change_format.gsub(/!TABLE!/, table_name).gsub(/!COLUMNS!/, remove_columns) if tuples.any?
|
78
|
+
contents = options[:base].dup.gsub(/\s{4}!UP!\n/m, (direction == 'add' ? forward_text.to_s : back_text.to_s))
|
79
|
+
contents.gsub!(/\s{4}!DOWN!\n/m, (direction == 'add' ? back_text.to_s : forward_text.to_s))
|
80
|
+
contents = contents.gsub(/!FILENAME!/, filename.underscore).gsub(/!FILECLASS!/, filename.underscore.camelize)
|
81
|
+
migration_number = current_migration_number
|
82
|
+
contents.gsub!(/!VERSION!/, migration_number)
|
83
|
+
migration_filename = "#{format("%03d", migration_number)}_#{filename.underscore}.rb"
|
84
|
+
create_file(destination_root('db/migrate/', migration_filename), contents, :skip => true)
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
##
|
89
|
+
# Returns the number of the latest(most current) migration file.
|
90
|
+
#
|
91
|
+
def return_last_migration_number
|
92
|
+
Dir[destination_root('db/migrate/*.rb')].map { |f|
|
93
|
+
File.basename(f).match(/^(\d+)/)[0].to_i
|
94
|
+
}.max.to_i || 0
|
95
|
+
end
|
96
|
+
|
97
|
+
##
|
98
|
+
# Returns timestamp instead if :migration_format: in .components is "timestamp"
|
99
|
+
#
|
100
|
+
def current_migration_number
|
101
|
+
if fetch_component_choice(:migration_format).to_s == 'timestamp'
|
102
|
+
Time.now.utc.strftime("%Y%m%d%H%M%S")
|
103
|
+
else
|
104
|
+
return_last_migration_number + 1
|
105
|
+
end.to_s
|
106
|
+
end
|
107
|
+
|
108
|
+
##
|
109
|
+
# Return true if the migration already exist.
|
110
|
+
#
|
111
|
+
# @param [String] filename
|
112
|
+
# File name of the migration file.
|
113
|
+
#
|
114
|
+
def migration_exist?(filename)
|
115
|
+
Dir[destination_root("db/migrate/*_#{filename.underscore}.rb")].size > 0
|
116
|
+
end
|
117
|
+
|
118
|
+
##
|
119
|
+
# Removes the migration file based on the migration name.
|
120
|
+
#
|
121
|
+
# @param [String] name
|
122
|
+
# File name of the migration.
|
123
|
+
#
|
124
|
+
def remove_migration(name)
|
125
|
+
migration_path = Dir[destination_root('db/migrate/*.rb')].find do |f|
|
126
|
+
File.basename(f) =~ /#{name.to_s.underscore}/
|
127
|
+
end
|
128
|
+
return unless migration_path
|
129
|
+
if behavior == :revoke
|
130
|
+
create_file migration_path # we use create to reverse the operation of a revoke
|
131
|
+
end
|
132
|
+
end
|
133
|
+
|
134
|
+
##
|
135
|
+
# Injects the test class text into the test_config file for setting up the test gen.
|
136
|
+
#
|
137
|
+
# @param [String] suite_text
|
138
|
+
# Class name for test suite.
|
139
|
+
# @param [Hash] options
|
140
|
+
# Additional options to pass into injection.
|
141
|
+
#
|
142
|
+
# @example
|
143
|
+
# insert_test_suite_setup('...CLASS_NAME...')
|
144
|
+
# => inject_into_file("test/test_config.rb", TEST.gsub(/CLASS_NAME/, @app_name), :after => "set :environment, :test")
|
145
|
+
#
|
146
|
+
def insert_test_suite_setup(suite_text, options={})
|
147
|
+
options.reverse_merge!(:path => "test/test_config.rb")
|
148
|
+
create_file(options[:path], suite_text.gsub(/CLASS_NAME/, "#{@project_name}::#{@app_name}"))
|
149
|
+
end
|
150
|
+
|
151
|
+
##
|
152
|
+
# Injects the mock library include into the test class in test_config
|
153
|
+
# for setting up mock gen
|
154
|
+
#
|
155
|
+
# @param [String] library_name
|
156
|
+
# Name of mocking library.
|
157
|
+
# @param [Hash] options
|
158
|
+
#
|
159
|
+
# @example
|
160
|
+
# insert_mocking_include('Mocha::API'):
|
161
|
+
# => inject_into_file("test/test_config.rb", " include Mocha::API\n", :after => /class.*?\n/)
|
162
|
+
#
|
163
|
+
def insert_mocking_include(library_name, options={})
|
164
|
+
options.reverse_merge!(:indent => 2, :after => /class.*?\n/, :path => "test/test_config.rb")
|
165
|
+
return unless File.exist?(destination_root(options[:path]))
|
166
|
+
include_text = indent_spaces(2) + "include #{library_name}\n"
|
167
|
+
inject_into_file(options[:path], include_text, :after => options[:after])
|
168
|
+
end
|
169
|
+
|
170
|
+
##
|
171
|
+
# Returns space characters of given count.
|
172
|
+
#
|
173
|
+
# @example
|
174
|
+
# indent_spaces(2)
|
175
|
+
#
|
176
|
+
def indent_spaces(count)
|
177
|
+
' ' * count
|
178
|
+
end
|
179
|
+
|
180
|
+
##
|
181
|
+
# Takes in fields for routes in the form of get:index post:test delete:yada.
|
182
|
+
#
|
183
|
+
# @param [Array<String>] fields
|
184
|
+
# Array of controller actions and route name.
|
185
|
+
#
|
186
|
+
# @example
|
187
|
+
# controller_actions("get:index", "post:test")
|
188
|
+
#
|
189
|
+
def controller_actions(fields)
|
190
|
+
field_tuples = fields.map { |value| value.split(":") }
|
191
|
+
action_declarations = field_tuples.map do |request, name|
|
192
|
+
"#{request} :#{name} do\n\nend\n"
|
193
|
+
end
|
194
|
+
action_declarations.join("\n").gsub(/^/, " " * 2).gsub(/^\s*$/, "")
|
195
|
+
end
|
196
|
+
|
197
|
+
def create_helper_files(app, name)
|
198
|
+
@helper_name = "#{name.to_s.underscore.camelize}Helper"
|
199
|
+
template 'templates/helper.rb.tt', destination_root(app, 'helpers', "#{name.to_s.underscore}_helper.rb")
|
200
|
+
if test?
|
201
|
+
include_component_module_for(:test)
|
202
|
+
generate_helper_test(@helper_name, @project_name, @app_name)
|
203
|
+
end
|
204
|
+
end
|
205
|
+
end
|
206
|
+
end
|
207
|
+
end
|
208
|
+
end
|