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.
- 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,165 @@
|
|
|
1
|
+
MR = (<<-MR) unless defined?(MR)
|
|
2
|
+
##
|
|
3
|
+
# You can use other adapters like:
|
|
4
|
+
#
|
|
5
|
+
# ActiveRecord::Base.configurations[:development] = {
|
|
6
|
+
# :adapter => 'mysql2',
|
|
7
|
+
# :encoding => 'utf8',
|
|
8
|
+
# :reconnect => true,
|
|
9
|
+
# :database => 'your_database',
|
|
10
|
+
# :pool => 5,
|
|
11
|
+
# :username => 'root',
|
|
12
|
+
# :password => '',
|
|
13
|
+
# :host => 'localhost',
|
|
14
|
+
# :socket => '/tmp/mysql.sock'
|
|
15
|
+
# }
|
|
16
|
+
#
|
|
17
|
+
ActiveRecord::Base.configurations[:development] = {
|
|
18
|
+
!DB_DEVELOPMENT!
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
ActiveRecord::Base.configurations[:production] = {
|
|
22
|
+
!DB_PRODUCTION!
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
ActiveRecord::Base.configurations[:test] = {
|
|
26
|
+
!DB_TEST!
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
# Setup our logger.
|
|
30
|
+
ActiveRecord::Base.logger = logger
|
|
31
|
+
|
|
32
|
+
if ActiveRecord::VERSION::MAJOR.to_i < 4
|
|
33
|
+
# Raise exception on mass assignment protection for Active Record models.
|
|
34
|
+
ActiveRecord::Base.mass_assignment_sanitizer = :strict
|
|
35
|
+
|
|
36
|
+
# Log the query plan for queries taking more than this (works
|
|
37
|
+
# with SQLite, MySQL, and PostgreSQL).
|
|
38
|
+
ActiveRecord::Base.auto_explain_threshold_in_seconds = 0.5
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
# Doesn't include Active Record class name as root for JSON serialized output.
|
|
42
|
+
ActiveRecord::Base.include_root_in_json = false
|
|
43
|
+
|
|
44
|
+
# Store the full class name (including module namespace) in STI type column.
|
|
45
|
+
ActiveRecord::Base.store_full_sti_class = true
|
|
46
|
+
|
|
47
|
+
# Use ISO 8601 format for JSON serialized times and dates.
|
|
48
|
+
ActiveSupport.use_standard_json_time_format = true
|
|
49
|
+
|
|
50
|
+
# Don't escape HTML entities in JSON, leave that for the #json_escape helper
|
|
51
|
+
# if you're including raw JSON in an HTML page.
|
|
52
|
+
ActiveSupport.escape_html_entities_in_json = false
|
|
53
|
+
|
|
54
|
+
# Now we can establish connection with our db.
|
|
55
|
+
ActiveRecord::Base.establish_connection(ActiveRecord::Base.configurations[Tennpipes.env])
|
|
56
|
+
|
|
57
|
+
# Timestamps are in the utc by default.
|
|
58
|
+
ActiveRecord::Base.default_timezone = :utc
|
|
59
|
+
MR
|
|
60
|
+
|
|
61
|
+
MYSQL = (<<-MYSQL) unless defined?(MYSQL)
|
|
62
|
+
:adapter => 'mysql',
|
|
63
|
+
:encoding => 'utf8',
|
|
64
|
+
:reconnect => true,
|
|
65
|
+
:database => !DB_NAME!,
|
|
66
|
+
:pool => 5,
|
|
67
|
+
:username => 'root',
|
|
68
|
+
:password => '',
|
|
69
|
+
:host => 'localhost',
|
|
70
|
+
:socket => '/tmp/mysql.sock'
|
|
71
|
+
MYSQL
|
|
72
|
+
|
|
73
|
+
MYSQL2 = (<<-MYSQL2) unless defined?(MYSQL2)
|
|
74
|
+
:adapter => 'mysql2',
|
|
75
|
+
:encoding => 'utf8',
|
|
76
|
+
:reconnect => true,
|
|
77
|
+
:database => !DB_NAME!,
|
|
78
|
+
:pool => 5,
|
|
79
|
+
:username => 'root',
|
|
80
|
+
:password => '',
|
|
81
|
+
:host => 'localhost',
|
|
82
|
+
:socket => '/tmp/mysql.sock'
|
|
83
|
+
MYSQL2
|
|
84
|
+
|
|
85
|
+
POSTGRES = (<<-POSTGRES) unless defined?(POSTGRES)
|
|
86
|
+
:adapter => 'postgresql',
|
|
87
|
+
:database => !DB_NAME!,
|
|
88
|
+
:username => 'root',
|
|
89
|
+
:password => '',
|
|
90
|
+
:host => 'localhost',
|
|
91
|
+
:port => 5432
|
|
92
|
+
POSTGRES
|
|
93
|
+
|
|
94
|
+
SQLITE = (<<-SQLITE) unless defined?(SQLITE)
|
|
95
|
+
:adapter => 'sqlite3',
|
|
96
|
+
:database => !DB_NAME!
|
|
97
|
+
SQLITE
|
|
98
|
+
|
|
99
|
+
CONNECTION_POOL_MIDDLEWARE = <<-MIDDLEWARE
|
|
100
|
+
class ConnectionPoolManagement
|
|
101
|
+
def initialize(app)
|
|
102
|
+
@app = app
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
def call(env)
|
|
106
|
+
ActiveRecord::Base.connection_pool.with_connection { @app.call(env) }
|
|
107
|
+
end
|
|
108
|
+
end
|
|
109
|
+
MIDDLEWARE
|
|
110
|
+
|
|
111
|
+
def setup_orm
|
|
112
|
+
ar = MR
|
|
113
|
+
db = @project_name.underscore
|
|
114
|
+
case options[:adapter]
|
|
115
|
+
when 'mysql-gem'
|
|
116
|
+
ar.gsub! /!DB_DEVELOPMENT!/, MYSQL.gsub(/!DB_NAME!/,"'#{db}_development'")
|
|
117
|
+
ar.gsub! /!DB_PRODUCTION!/, MYSQL.gsub(/!DB_NAME!/,"'#{db}_production'")
|
|
118
|
+
ar.gsub! /!DB_TEST!/, MYSQL.gsub(/!DB_NAME!/,"'#{db}_test'")
|
|
119
|
+
require_dependencies 'mysql', :version => "~> 2.8.1"
|
|
120
|
+
when 'mysql', 'mysql2'
|
|
121
|
+
ar.gsub! /!DB_DEVELOPMENT!/, MYSQL2.gsub(/!DB_NAME!/,"'#{db}_development'")
|
|
122
|
+
ar.gsub! /!DB_PRODUCTION!/, MYSQL2.gsub(/!DB_NAME!/,"'#{db}_production'")
|
|
123
|
+
ar.gsub! /!DB_TEST!/, MYSQL2.gsub(/!DB_NAME!/,"'#{db}_test'")
|
|
124
|
+
require_dependencies 'mysql2'
|
|
125
|
+
when 'postgres'
|
|
126
|
+
ar.gsub! /!DB_DEVELOPMENT!/, POSTGRES.gsub(/!DB_NAME!/,"'#{db}_development'")
|
|
127
|
+
ar.gsub! /!DB_PRODUCTION!/, POSTGRES.gsub(/!DB_NAME!/,"'#{db}_production'")
|
|
128
|
+
ar.gsub! /!DB_TEST!/, POSTGRES.gsub(/!DB_NAME!/,"'#{db}_test'")
|
|
129
|
+
require_dependencies 'pg'
|
|
130
|
+
else
|
|
131
|
+
ar.gsub! /!DB_DEVELOPMENT!/, SQLITE.gsub(/!DB_NAME!/,"Tennpipes.root('db', '#{db}_development.db')")
|
|
132
|
+
ar.gsub! /!DB_PRODUCTION!/, SQLITE.gsub(/!DB_NAME!/,"Tennpipes.root('db', '#{db}_production.db')")
|
|
133
|
+
ar.gsub! /!DB_TEST!/, SQLITE.gsub(/!DB_NAME!/,"Tennpipes.root('db', '#{db}_test.db')")
|
|
134
|
+
require_dependencies 'sqlite3'
|
|
135
|
+
end
|
|
136
|
+
require_dependencies 'mini_record'
|
|
137
|
+
create_file('config/database.rb', ar)
|
|
138
|
+
insert_hook('ActiveRecord::Base.auto_upgrade!', :after_load)
|
|
139
|
+
middleware :connection_pool_management, CONNECTION_POOL_MIDDLEWARE
|
|
140
|
+
end
|
|
141
|
+
|
|
142
|
+
MR_MODEL = (<<-MODEL) unless defined?(MR_MODEL)
|
|
143
|
+
class !NAME! < ActiveRecord::Base
|
|
144
|
+
# Fields
|
|
145
|
+
!FIELDS!
|
|
146
|
+
end
|
|
147
|
+
MODEL
|
|
148
|
+
|
|
149
|
+
# options => { :fields => ["title:string", "body:string"], :app => 'app' }
|
|
150
|
+
def create_model_file(name, options={})
|
|
151
|
+
model_path = destination_root(options[:app], 'models', "#{name.to_s.underscore}.rb")
|
|
152
|
+
field_tuples = options[:fields].map { |value| value.split(":") }
|
|
153
|
+
column_declarations = field_tuples.map { |field, kind| "field :#{field}, :as => :#{kind}" }.join("\n ")
|
|
154
|
+
model_contents = MR_MODEL.gsub(/!NAME!/, name.to_s.underscore.camelize)
|
|
155
|
+
model_contents.gsub!(/!FIELDS!/, column_declarations)
|
|
156
|
+
create_file(model_path, model_contents)
|
|
157
|
+
end
|
|
158
|
+
|
|
159
|
+
def create_model_migration(migration_name, name, columns)
|
|
160
|
+
# NO MIGRATION NEEDED
|
|
161
|
+
end
|
|
162
|
+
|
|
163
|
+
def create_migration_file(migration_name, name, columns)
|
|
164
|
+
# NO MIGRATION NEEDED
|
|
165
|
+
end
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
MONGOID = (<<-MONGO) unless defined?(MONGOID)
|
|
2
|
+
# Connection.new takes host and port
|
|
3
|
+
host = 'localhost'
|
|
4
|
+
port = Mongo::Connection::DEFAULT_PORT
|
|
5
|
+
|
|
6
|
+
database_name = case Tennpipes.env
|
|
7
|
+
when :development then '!NAME!_development'
|
|
8
|
+
when :production then '!NAME!_production'
|
|
9
|
+
when :test then '!NAME!_test'
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
Mongoid.database = Mongo::Connection.new(host, port).db(database_name)
|
|
13
|
+
|
|
14
|
+
# You can also configure Mongoid this way:
|
|
15
|
+
# Mongoid.configure do |config|
|
|
16
|
+
# name = @settings["database"]
|
|
17
|
+
# host = @settings["host"]
|
|
18
|
+
# config.master = Mongo::Connection.new.db(name)
|
|
19
|
+
# config.slaves = [
|
|
20
|
+
# Mongo::Connection.new(host, @settings["slave_one"]["port"], :slave_ok => true).db(name),
|
|
21
|
+
# Mongo::Connection.new(host, @settings["slave_two"]["port"], :slave_ok => true).db(name)
|
|
22
|
+
# ]
|
|
23
|
+
# end
|
|
24
|
+
#
|
|
25
|
+
# More installation and setup notes are on http://mongoid.org/.
|
|
26
|
+
MONGO
|
|
27
|
+
|
|
28
|
+
MONGOID3 = (<<-MONGO) unless defined?(MONGOID3)
|
|
29
|
+
# Connection.new takes host and port.
|
|
30
|
+
|
|
31
|
+
host = 'localhost'
|
|
32
|
+
port = 27017
|
|
33
|
+
|
|
34
|
+
database_name = case Tennpipes.env
|
|
35
|
+
when :development then '!NAME!_development'
|
|
36
|
+
when :production then '!NAME!_production'
|
|
37
|
+
when :test then '!NAME!_test'
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
# Use MONGO_URI if it's set as an environmental variable.
|
|
41
|
+
Mongoid::Config.sessions =
|
|
42
|
+
if ENV['MONGO_URI']
|
|
43
|
+
{default: {uri: ENV['MONGO_URI'] }}
|
|
44
|
+
else
|
|
45
|
+
{default: {hosts: ["#\{host\}:#\{port\}"], database: database_name}}
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
# If you want to use a YML file for config, use this instead:
|
|
49
|
+
#
|
|
50
|
+
# Mongoid.load!(File.join(Tennpipes.root, 'config', 'database.yml'), Tennpipes.env)
|
|
51
|
+
#
|
|
52
|
+
# And add a config/database.yml file like this:
|
|
53
|
+
# development:
|
|
54
|
+
# sessions:
|
|
55
|
+
# default:
|
|
56
|
+
# database: !NAME!_development
|
|
57
|
+
# hosts:
|
|
58
|
+
# - localhost:27017
|
|
59
|
+
# production:
|
|
60
|
+
# sessions:
|
|
61
|
+
# default:
|
|
62
|
+
# database: !NAME!_production
|
|
63
|
+
# hosts:
|
|
64
|
+
# - localhost:27017
|
|
65
|
+
# test:
|
|
66
|
+
# sessions:
|
|
67
|
+
# default:
|
|
68
|
+
# database: !NAME!_test
|
|
69
|
+
# hosts:
|
|
70
|
+
# - localhost:27017
|
|
71
|
+
#
|
|
72
|
+
#
|
|
73
|
+
# More installation and setup notes are on http://mongoid.org/en/mongoid/docs/installation.html#configuration
|
|
74
|
+
MONGO
|
|
75
|
+
|
|
76
|
+
def setup_orm
|
|
77
|
+
require_dependencies 'mongoid', :version => '>= 3.0.0'
|
|
78
|
+
create_file('config/database.rb', MONGOID3.gsub(/!NAME!/, @project_name.underscore))
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
MONGOID_MODEL = (<<-MODEL) unless defined?(MONGOID_MODEL)
|
|
82
|
+
class !NAME!
|
|
83
|
+
include Mongoid::Document
|
|
84
|
+
include Mongoid::Timestamps # adds created_at and updated_at fields
|
|
85
|
+
|
|
86
|
+
# field <name>, :type => <type>, :default => <value>
|
|
87
|
+
!FIELDS!
|
|
88
|
+
|
|
89
|
+
# You can define indexes on documents using the index macro:
|
|
90
|
+
# index :field <, :unique => true>
|
|
91
|
+
|
|
92
|
+
# You can create a composite key in mongoid to replace the default id using the key macro:
|
|
93
|
+
# key :field <, :another_field, :one_more ....>
|
|
94
|
+
end
|
|
95
|
+
MODEL
|
|
96
|
+
|
|
97
|
+
# options => { :fields => ["title:string", "body:string"], :app => 'app' }
|
|
98
|
+
def create_model_file(name, options={})
|
|
99
|
+
model_path = destination_root(options[:app], 'models', "#{name.to_s.underscore}.rb")
|
|
100
|
+
field_tuples = options[:fields].map { |value| value.split(":") }
|
|
101
|
+
column_declarations = field_tuples.map { |field, kind| "field :#{field}, :type => #{kind.underscore.camelize}" }.join("\n ")
|
|
102
|
+
model_contents = MONGOID_MODEL.gsub(/!NAME!/, name.to_s.underscore.camelize)
|
|
103
|
+
model_contents.gsub!(/!FIELDS!/, column_declarations)
|
|
104
|
+
create_file(model_path, model_contents)
|
|
105
|
+
end
|
|
106
|
+
|
|
107
|
+
def create_model_migration(filename, name, fields)
|
|
108
|
+
# NO MIGRATION NEEDED
|
|
109
|
+
end
|
|
110
|
+
|
|
111
|
+
def create_migration_file(migration_name, name, columns)
|
|
112
|
+
# NO MIGRATION NEEDED
|
|
113
|
+
end
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
MONGO = (<<-MONGO) unless defined?(MONGO)
|
|
2
|
+
MongoMapper.connection = Mongo::Connection.new('localhost', nil, :logger => logger)
|
|
3
|
+
|
|
4
|
+
case Tennpipes.env
|
|
5
|
+
when :development then MongoMapper.database = '!NAME!_development'
|
|
6
|
+
when :production then MongoMapper.database = '!NAME!_production'
|
|
7
|
+
when :test then MongoMapper.database = '!NAME!_test'
|
|
8
|
+
end
|
|
9
|
+
MONGO
|
|
10
|
+
|
|
11
|
+
def setup_orm
|
|
12
|
+
require_dependencies 'mongo_mapper'
|
|
13
|
+
require_dependencies 'bson_ext', :require => 'mongo'
|
|
14
|
+
create_file("config/database.rb", MONGO.gsub(/!NAME!/, @project_name.underscore))
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
MM_MODEL = (<<-MODEL) unless defined?(MM_MODEL)
|
|
18
|
+
class !NAME!
|
|
19
|
+
include MongoMapper::Document
|
|
20
|
+
|
|
21
|
+
# key <name>, <type>
|
|
22
|
+
!FIELDS!
|
|
23
|
+
timestamps!
|
|
24
|
+
end
|
|
25
|
+
MODEL
|
|
26
|
+
|
|
27
|
+
# options => { :fields => ["title:string", "body:string"], :app => 'app' }
|
|
28
|
+
def create_model_file(name, options={})
|
|
29
|
+
model_path = destination_root(options[:app], 'models', "#{name.to_s.underscore}.rb")
|
|
30
|
+
field_tuples = options[:fields].map { |value| value.split(":") }
|
|
31
|
+
column_declarations = field_tuples.map { |field, kind| "key :#{field}, #{kind.underscore.camelize}" }.join("\n ")
|
|
32
|
+
model_contents = MM_MODEL.gsub(/!NAME!/, name.to_s.underscore.camelize)
|
|
33
|
+
model_contents.gsub!(/!FIELDS!/, column_declarations)
|
|
34
|
+
create_file(model_path, model_contents)
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def create_model_migration(filename, name, fields)
|
|
38
|
+
# NO MIGRATION NEEDED
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def create_migration_file(migration_name, name, columns)
|
|
42
|
+
# NO MIGRATION NEEDED
|
|
43
|
+
end
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
MONGOMATIC = (<<-MONGO) unless defined?(MONGOMATIC)
|
|
2
|
+
|
|
3
|
+
case Tennpipes.env
|
|
4
|
+
when :development then Mongomatic.db = Mongo::Connection.new.db("!NAME!_development")
|
|
5
|
+
when :production then Mongomatic.db = Mongo::Connection.new.db("!NAME!_production")
|
|
6
|
+
when :test then Mongomatic.db = Mongo::Connection.new.db("!NAME!_test")
|
|
7
|
+
end
|
|
8
|
+
MONGO
|
|
9
|
+
|
|
10
|
+
def setup_orm
|
|
11
|
+
mongomatic = MONGOMATIC
|
|
12
|
+
require_dependencies 'mongomatic'
|
|
13
|
+
require_dependencies 'bson_ext', :require => 'mongo'
|
|
14
|
+
create_file("config/database.rb", MONGOMATIC.gsub(/!NAME!/, @project_name.underscore))
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
MONGOMATIC_MODEL = (<<-MODEL) unless defined?(MONGOMATIC_MODEL)
|
|
18
|
+
class !NAME! < Mongomatic::Base
|
|
19
|
+
include Mongomatic::Expectations::Helper
|
|
20
|
+
|
|
21
|
+
# Mongomatic does not have the traditional
|
|
22
|
+
# model definition that AR/MM/DM et. al. have.
|
|
23
|
+
# Staying true to the "ad-hoc" nature of MongoDB,
|
|
24
|
+
# there are no explicit column definitions in the
|
|
25
|
+
# model file.
|
|
26
|
+
|
|
27
|
+
# However you can "fake it" by making a column
|
|
28
|
+
# required using expectations
|
|
29
|
+
# For the sake of tennpipes g model,
|
|
30
|
+
# we'll assume that any property defined
|
|
31
|
+
# on the command-line is required
|
|
32
|
+
# In the case of Integer types, we'll add
|
|
33
|
+
# the expectation: be_a_number
|
|
34
|
+
# Future enhancement may allow a regex for
|
|
35
|
+
# String datatypes
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
# Examples:
|
|
39
|
+
# def validate
|
|
40
|
+
# expectations do
|
|
41
|
+
# be_present self['name'], "Name cannot be blank"
|
|
42
|
+
# be_present self['email'], "Email cannot be blank"
|
|
43
|
+
# be_present self['age'], "Age cannot be blank"
|
|
44
|
+
# be_present self['password'], "Password cannot be blank"
|
|
45
|
+
# be_a_number self['age'], "Age must be a number"
|
|
46
|
+
# be_of_length self['password'], "Password must be at least 8 characters", :minimum => 8
|
|
47
|
+
# end
|
|
48
|
+
# end
|
|
49
|
+
|
|
50
|
+
# def create_indexes
|
|
51
|
+
# self.collection.create_index('name', :unique => true)
|
|
52
|
+
# self.collection.create_index('email', :unique => true)
|
|
53
|
+
# self.collection.create_index('age')
|
|
54
|
+
# end
|
|
55
|
+
def validate
|
|
56
|
+
expectations do
|
|
57
|
+
!FIELDS!
|
|
58
|
+
!INTEGERS!
|
|
59
|
+
end
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
end
|
|
63
|
+
MODEL
|
|
64
|
+
|
|
65
|
+
# options => { :fields => ["title:string", "body:string"], :app => 'app' }
|
|
66
|
+
def create_model_file(name, options={})
|
|
67
|
+
model_path = destination_root(options[:app], 'models', "#{name.to_s.underscore}.rb")
|
|
68
|
+
field_tuples = options[:fields].map { |value| value.split(":") }
|
|
69
|
+
column_declarations = field_tuples.map { |field, kind| "be_present self['#{field}'], '#{field} cannot be blank'" }.join("\n ")
|
|
70
|
+
# Really ugly oneliner
|
|
71
|
+
integers = field_tuples.select { |col, type| type =~ /[Ii]nteger/ }.map { |field, kind| "be_a_number self['#{field}'], '#{field} must be a number'" }.join("\n ")
|
|
72
|
+
model_contents = MONGOMATIC_MODEL.gsub(/!NAME!/, name.to_s.underscore.camelize)
|
|
73
|
+
model_contents.gsub!(/!FIELDS!/, column_declarations)
|
|
74
|
+
model_contents.gsub!(/!INTEGERS!/, integers)
|
|
75
|
+
create_file(model_path, model_contents)
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
def create_model_migration(filename, name, fields)
|
|
79
|
+
# NO MIGRATION NEEDED
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
def create_migration_file(migration_name, name, columns)
|
|
83
|
+
# NO MIGRATION NEEDED
|
|
84
|
+
end
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
OHM = (<<-OHM) unless defined?(OHM)
|
|
2
|
+
# Ohm does not have the concept of namespaces.
|
|
3
|
+
# This means that you will not be able to have
|
|
4
|
+
# a distinct test, development, or production database.
|
|
5
|
+
#
|
|
6
|
+
# You can, however, run multiple redis servers on the same host
|
|
7
|
+
# and point to them based on the environment:
|
|
8
|
+
#
|
|
9
|
+
# case Tennpipes.env
|
|
10
|
+
# when :development then Ohm.connect(:port => 6379)
|
|
11
|
+
# when :production then Ohm.connect(:port => 6380)
|
|
12
|
+
# when :test then Ohm.connect(:port => 6381)
|
|
13
|
+
# end
|
|
14
|
+
|
|
15
|
+
# Alternatively, you can try specifying a difference :db
|
|
16
|
+
# which, outside of confirmation, appears to provide distinct
|
|
17
|
+
# namespaces from testing:
|
|
18
|
+
# case Tennpipes.env
|
|
19
|
+
# when :development then Ohm.connect(:db => 0)
|
|
20
|
+
# when :production then Ohm.connect(:db => 1)
|
|
21
|
+
# when :test then Ohm.connect(:db => 2)
|
|
22
|
+
# end
|
|
23
|
+
OHM
|
|
24
|
+
|
|
25
|
+
def setup_orm
|
|
26
|
+
require_dependencies 'ohm', :version => "~> 1.3.0"
|
|
27
|
+
create_file("config/database.rb", OHM)
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
OHM_MODEL = (<<-MODEL) unless defined?(OHM_MODEL)
|
|
31
|
+
class !NAME! < Ohm::Model
|
|
32
|
+
# Examples:
|
|
33
|
+
# attribute :name
|
|
34
|
+
# attribute :email
|
|
35
|
+
# reference :venue, Venue
|
|
36
|
+
# set :participants, Person
|
|
37
|
+
# counter :votes
|
|
38
|
+
#
|
|
39
|
+
# index :name
|
|
40
|
+
#
|
|
41
|
+
# def validate
|
|
42
|
+
# assert_present :name
|
|
43
|
+
# end
|
|
44
|
+
|
|
45
|
+
!FIELDS!
|
|
46
|
+
end
|
|
47
|
+
MODEL
|
|
48
|
+
|
|
49
|
+
# options => { :fields => ["title:string", "body:string"], :app => 'app' }
|
|
50
|
+
def create_model_file(name, options={})
|
|
51
|
+
model_path = destination_root(options[:app], 'models', "#{name.to_s.underscore}.rb")
|
|
52
|
+
field_tuples = options[:fields].map { |value| value.split(":") }
|
|
53
|
+
column_declarations = field_tuples.map { |field, kind| "attribute :#{field}" }.join("\n ")
|
|
54
|
+
model_contents = OHM_MODEL.gsub(/!NAME!/, name.to_s.underscore.camelize)
|
|
55
|
+
model_contents.gsub!(/!FIELDS!/, column_declarations)
|
|
56
|
+
create_file(model_path, model_contents)
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
def create_model_migration(filename, name, fields)
|
|
60
|
+
# NO MIGRATION NEEDED
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
def create_migration_file(migration_name, name, columns)
|
|
64
|
+
# NO MIGRATION NEEDED
|
|
65
|
+
end
|