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,10 @@
1
+ def setup_mock
2
+ require_dependencies 'mocha', :group => 'test', :require => false
3
+ case options[:test].to_s
4
+ when 'rspec'
5
+ inject_into_file 'spec/spec_helper.rb', " conf.mock_with :mocha\n", :after => "RSpec.configure do |conf|\n"
6
+ else
7
+ inject_into_file 'test/test_config.rb', "require 'mocha/api'", :after => "require File.expand_path(File.dirname(__FILE__) + \"/../config/boot\")\n"
8
+ insert_mocking_include "Mocha::API"
9
+ end
10
+ end
@@ -0,0 +1,13 @@
1
+ def setup_mock
2
+ require_dependencies 'rr', :require => false, :group => 'test'
3
+ case options[:test].to_s
4
+ when 'rspec'
5
+ inject_into_file 'spec/spec_helper.rb', "require 'rr'\n", :after => "\"/../config/boot\")\n"
6
+ when 'riot'
7
+ inject_into_file "test/test_config.rb","require 'riot/rr'\n", :after => "\"/../config/boot\")\n"
8
+ when 'minitest'
9
+ insert_mocking_include "RR::Adapters::MiniTest", :path => "test/test_config.rb"
10
+ else
11
+ insert_mocking_include "RR::Adapters::TestUnit", :path => "test/test_config.rb"
12
+ end
13
+ end
@@ -0,0 +1,201 @@
1
+ AR = (<<-AR) unless defined?(AR)
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
+ AR
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 = AR
113
+ db = @project_name.underscore
114
+ # We're now defaulting to mysql2 since mysql is deprecated
115
+ case options[:adapter]
116
+ when 'mysql-gem'
117
+ ar.sub! /!DB_DEVELOPMENT!/, MYSQL.sub(/!DB_NAME!/,"'#{db}_development'")
118
+ ar.sub! /!DB_PRODUCTION!/, MYSQL.sub(/!DB_NAME!/,"'#{db}_production'")
119
+ ar.sub! /!DB_TEST!/, MYSQL.sub(/!DB_NAME!/,"'#{db}_test'")
120
+ require_dependencies 'mysql', :version => "~> 2.8.1"
121
+ when 'mysql', 'mysql2'
122
+ ar.sub! /!DB_DEVELOPMENT!/, MYSQL2.sub(/!DB_NAME!/,"'#{db}_development'")
123
+ ar.sub! /!DB_PRODUCTION!/, MYSQL2.sub(/!DB_NAME!/,"'#{db}_production'")
124
+ ar.sub! /!DB_TEST!/, MYSQL2.sub(/!DB_NAME!/,"'#{db}_test'")
125
+ require_dependencies 'mysql2'
126
+ when 'postgres'
127
+ ar.sub! /!DB_DEVELOPMENT!/, POSTGRES.sub(/!DB_NAME!/,"'#{db}_development'")
128
+ ar.sub! /!DB_PRODUCTION!/, POSTGRES.sub(/!DB_NAME!/,"'#{db}_production'")
129
+ ar.sub! /!DB_TEST!/, POSTGRES.sub(/!DB_NAME!/,"'#{db}_test'")
130
+ require_dependencies 'pg'
131
+ else
132
+ ar.sub! /!DB_DEVELOPMENT!/, SQLITE.sub(/!DB_NAME!/,"Tennpipes.root('db', '#{db}_development.db')")
133
+ ar.sub! /!DB_PRODUCTION!/, SQLITE.sub(/!DB_NAME!/,"Tennpipes.root('db', '#{db}_production.db')")
134
+ ar.sub! /!DB_TEST!/, SQLITE.sub(/!DB_NAME!/,"Tennpipes.root('db', '#{db}_test.db')")
135
+ require_dependencies 'sqlite3'
136
+ end
137
+ require_dependencies 'activerecord', :require => 'active_record', :version => ">= 3.1"
138
+ create_file("config/database.rb", ar)
139
+ middleware :connection_pool_management, CONNECTION_POOL_MIDDLEWARE
140
+ end
141
+
142
+ AR_MODEL = (<<-MODEL) unless defined?(AR_MODEL)
143
+ class !NAME! < ActiveRecord::Base
144
+
145
+ end
146
+ MODEL
147
+
148
+ # options => { :fields => ["title:string", "body:string"], :app => 'app' }
149
+ def create_model_file(name, options={})
150
+ model_path = destination_root(options[:app], 'models', "#{name.to_s.underscore}.rb")
151
+ model_contents = AR_MODEL.sub(/!NAME!/, name.to_s.underscore.camelize)
152
+ create_file(model_path, model_contents,:skip => true)
153
+ end
154
+
155
+
156
+ AR_MIGRATION = (<<-MIGRATION) unless defined?(AR_MIGRATION)
157
+ class !FILECLASS! < ActiveRecord::Migration
158
+ def self.up
159
+ !UP!
160
+ end
161
+
162
+ def self.down
163
+ !DOWN!
164
+ end
165
+ end
166
+ MIGRATION
167
+
168
+ AR_MODEL_UP_MG = (<<-MIGRATION).gsub(/^/,' ') unless defined?(AR_MODEL_UP_MG)
169
+ create_table :!TABLE! do |t|
170
+ !FIELDS!
171
+ t.timestamps
172
+ end
173
+ MIGRATION
174
+
175
+ AR_MODEL_DOWN_MG = (<<-MIGRATION) unless defined?(AR_MODEL_DOWN_MG)
176
+ drop_table :!TABLE!
177
+ MIGRATION
178
+
179
+ def create_model_migration(migration_name, name, columns)
180
+ output_model_migration(migration_name, name, columns,
181
+ :base => AR_MIGRATION,
182
+ :column_format => Proc.new { |field, kind| "t.#{kind.underscore.gsub(/_/, '')} :#{field}" },
183
+ :up => AR_MODEL_UP_MG,
184
+ :down => AR_MODEL_DOWN_MG
185
+ )
186
+ end
187
+
188
+ AR_CHANGE_MG = (<<-MIGRATION).gsub(/^/, ' ') unless defined?(AR_CHANGE_MG)
189
+ change_table :!TABLE! do |t|
190
+ !COLUMNS!
191
+ end
192
+ MIGRATION
193
+
194
+ def create_migration_file(migration_name, name, columns)
195
+ output_migration_file(migration_name, name, columns,
196
+ :base => AR_MIGRATION,
197
+ :change_format => AR_CHANGE_MG,
198
+ :add => Proc.new { |field, kind| "t.#{kind.underscore.gsub(/_/, '')} :#{field}" },
199
+ :remove => Proc.new { |field, kind| "t.remove :#{field}" }
200
+ )
201
+ end
@@ -0,0 +1,55 @@
1
+ COUCHREST = (<<-COUCHREST) unless defined?(COUCHREST)
2
+ case Tennpipes.env
3
+ when :development then db_name = '!NAME!_development'
4
+ when :production then db_name = '!NAME!_production'
5
+ when :test then db_name = '!NAME!_test'
6
+ end
7
+
8
+ CouchRest::Model::Base.configure do |conf|
9
+ conf.model_type_key = 'type' # compatibility with CouchModel 1.1
10
+ conf.database = CouchRest.database!(db_name)
11
+ conf.environment = Tennpipes.env
12
+ # conf.connection = {
13
+ # :protocol => 'http',
14
+ # :host => 'localhost',
15
+ # :port => '5984',
16
+ # :prefix => 'tennpipes',
17
+ # :suffix => nil,
18
+ # :join => '_',
19
+ # :username => nil,
20
+ # :password => nil
21
+ # }
22
+ end
23
+ COUCHREST
24
+
25
+ def setup_orm
26
+ require_dependencies 'couchrest_model', :version => '~>1.1.0'
27
+ require_dependencies 'json_pure'
28
+ create_file("config/database.rb", COUCHREST.gsub(/!NAME!/, @project_name.underscore))
29
+ end
30
+
31
+ CR_MODEL = (<<-MODEL) unless defined?(CR_MODEL)
32
+ class !NAME! < CouchRest::Model::Base
33
+ unique_id :id
34
+ # property <name>
35
+ !FIELDS!
36
+ end
37
+ MODEL
38
+
39
+ # options => { :fields => ["title:string", "body:string"], :app => 'app' }
40
+ def create_model_file(name, options={})
41
+ model_path = destination_root(options[:app], 'models', "#{name.to_s.underscore}.rb")
42
+ field_tuples = options[:fields].map { |value| value.split(":") }
43
+ column_declarations = field_tuples.map { |field, kind| "property :#{field}" }.join("\n ")
44
+ model_contents = CR_MODEL.gsub(/!NAME!/, name.to_s.underscore.camelize)
45
+ model_contents.gsub!(/!FIELDS!/, column_declarations)
46
+ create_file(model_path, model_contents)
47
+ end
48
+
49
+ def create_model_migration(filename, name, fields)
50
+ # NO MIGRATION NEEDED
51
+ end
52
+
53
+ def create_migration_file(migration_name, name, columns)
54
+ # NO MIGRATION NEEDED
55
+ end
@@ -0,0 +1,140 @@
1
+ DM = (<<-DM) unless defined?(DM)
2
+ ##
3
+ # A MySQL connection:
4
+ # DataMapper.setup(:default, 'mysql://user:password@localhost/the_database_name')
5
+ #
6
+ # # A Postgres connection:
7
+ # DataMapper.setup(:default, 'postgres://user:password@localhost/the_database_name')
8
+ #
9
+ # # A Sqlite3 connection
10
+ # DataMapper.setup(:default, "sqlite3://" + Tennpipes.root('db', "development.db"))
11
+ #
12
+ # # Setup DataMapper using config/database.yml
13
+ # DataMapper.setup(:default, YAML.load_file(Tennpipes.root('config/database.yml'))[RACK_ENV])
14
+ #
15
+ # config/database.yml file:
16
+ #
17
+ # ---
18
+ # development: &defaults
19
+ # adapter: mysql
20
+ # database: example_development
21
+ # username: user
22
+ # password: Pa55w0rd
23
+ # host: 127.0.0.1
24
+ #
25
+ # test:
26
+ # <<: *defaults
27
+ # database: example_test
28
+ #
29
+ # production:
30
+ # <<: *defaults
31
+ # database: example_production
32
+ #
33
+
34
+ DataMapper.logger = logger
35
+ DataMapper::Property::String.length(255)
36
+
37
+ case Tennpipes.env
38
+ when :development then DataMapper.setup(:default, !DB_DEVELOPMENT!)
39
+ when :production then DataMapper.setup(:default, !DB_PRODUCTION!)
40
+ when :test then DataMapper.setup(:default, !DB_TEST!)
41
+ end
42
+ DM
43
+
44
+ def setup_orm
45
+ dm = DM
46
+ db = @project_name.underscore
47
+ %w(
48
+ dm-core
49
+ dm-types
50
+ dm-aggregates
51
+ dm-constraints
52
+ dm-migrations
53
+ dm-timestamps
54
+ dm-validations
55
+ ).each { |dep| require_dependencies dep }
56
+ require_dependencies case options[:adapter]
57
+ when 'mysql', 'mysql2'
58
+ dm.gsub!(/!DB_DEVELOPMENT!/,"\"mysql://root@localhost/#{db}_development\"")
59
+ dm.gsub!(/!DB_PRODUCTION!/,"\"mysql://root@localhost/#{db}_production\"")
60
+ dm.gsub!(/!DB_TEST!/,"\"mysql://root@localhost/#{db}_test\"")
61
+ 'dm-mysql-adapter'
62
+ when 'postgres'
63
+ dm.gsub!(/!DB_DEVELOPMENT!/,"\"postgres://root@localhost/#{db}_development\"")
64
+ dm.gsub!(/!DB_PRODUCTION!/,"\"postgres://root@localhost/#{db}_production\"")
65
+ dm.gsub!(/!DB_TEST!/,"\"postgres://root@localhost/#{db}_test\"")
66
+ 'dm-postgres-adapter'
67
+ else
68
+ dm.gsub!(/!DB_DEVELOPMENT!/,"\"sqlite3://\" + Tennpipes.root('db', \"#{db}_development.db\")")
69
+ dm.gsub!(/!DB_PRODUCTION!/,"\"sqlite3://\" + Tennpipes.root('db', \"#{db}_production.db\")")
70
+ dm.gsub!(/!DB_TEST!/,"\"sqlite3://\" + Tennpipes.root('db', \"#{db}_test.db\")")
71
+ 'dm-sqlite-adapter'
72
+ end
73
+
74
+ create_file("config/database.rb", dm)
75
+ insert_hook("DataMapper.finalize", :after_load)
76
+ end
77
+
78
+ DM_MODEL = (<<-MODEL) unless defined?(DM_MODEL)
79
+ class !NAME!
80
+ include DataMapper::Resource
81
+
82
+ # property <name>, <type>
83
+ property :id, Serial
84
+ !FIELDS!
85
+ end
86
+ MODEL
87
+
88
+ # options => { :fields => ["title:string", "body:string"], :app => 'app' }
89
+ def create_model_file(name, options={})
90
+ model_path = destination_root(options[:app], 'models', "#{name.to_s.underscore}.rb")
91
+ model_contents = DM_MODEL.gsub(/!NAME!/, name.to_s.underscore.camelize)
92
+ field_tuples = options[:fields].map { |value| value.split(":") }
93
+ field_tuples.map! { |field, kind| kind =~ /datetime/i ? [field, 'DateTime'] : [field, kind] } # fix datetime
94
+ column_declarations = field_tuples.map { |field, kind|"property :#{field}, #{kind.underscore.camelize}" }.join("\n ")
95
+ model_contents.gsub!(/!FIELDS!/, column_declarations)
96
+ create_file(model_path, model_contents)
97
+ end
98
+
99
+ DM_MIGRATION = (<<-MIGRATION) unless defined?(DM_MIGRATION)
100
+ migration !VERSION!, :!FILENAME! do
101
+ up do
102
+ !UP!
103
+ end
104
+
105
+ down do
106
+ !DOWN!
107
+ end
108
+ end
109
+ MIGRATION
110
+
111
+ DM_MODEL_UP_MG = (<<-MIGRATION).gsub(/^/, ' ') unless defined?(DM_MODEL_UP_MG)
112
+ create_table :!TABLE! do
113
+ column :id, Integer, :serial => true
114
+ !FIELDS!
115
+ end
116
+ MIGRATION
117
+
118
+ DM_MODEL_DOWN_MG = (<<-MIGRATION) unless defined?(DM_MODEL_DOWN_MG)
119
+ drop_table :!TABLE!
120
+ MIGRATION
121
+
122
+ def create_model_migration(migration_name, name, columns)
123
+ output_model_migration(migration_name, name, columns,
124
+ :column_format => Proc.new { |field, kind| "column :#{field}, DataMapper::Property::#{kind.classify}#{', :length => 255' if kind =~ /string/i}" },
125
+ :base => DM_MIGRATION, :up => DM_MODEL_UP_MG, :down => DM_MODEL_DOWN_MG)
126
+ end
127
+
128
+ DM_CHANGE_MG = (<<-MIGRATION).gsub(/^/, ' ') unless defined?(DM_CHANGE_MG)
129
+ modify_table :!TABLE! do
130
+ !COLUMNS!
131
+ end
132
+ MIGRATION
133
+
134
+ def create_migration_file(migration_name, name, columns)
135
+ output_migration_file(migration_name, name, columns,
136
+ :base => DM_MIGRATION, :change_format => DM_CHANGE_MG,
137
+ :add => Proc.new { |field, kind| "add_column :#{field}, #{kind.classify}" },
138
+ :remove => Proc.new { |field, kind| "drop_column :#{field}" }
139
+ )
140
+ end
@@ -0,0 +1,67 @@
1
+ DYNAMOID = (<<-DYNAMOID) unless defined?(DYNAMOID)
2
+
3
+ AWS.config({
4
+ :access_key_id => ENV['AWS_ACCESS_KEY'],
5
+ :secret_access_key => ENV['AWS_SECRET_KEY'],
6
+ :dynamo_db_endpoint => 'dynamodb.ap-southeast-1.amazonaws.com'
7
+ })
8
+
9
+ Dynamoid.configure do |config|
10
+ config.adapter = 'aws_sdk' # This adapter establishes a connection to the DynamoDB servers using Amazon's own AWS gem.
11
+ config.read_capacity = 100 # Read capacity for your tables
12
+ config.write_capacity = 20 # Write capacity for your tables
13
+ end
14
+
15
+ # If you use mock in testing [for example in case of using fake_dynamo],
16
+ # the way is as following:
17
+ #
18
+ # - install fake_dynamo
19
+ # gem install fake_dynamo --version 0.1.3
20
+ # - run
21
+ # fake_dynamo --port 4567
22
+ #
23
+ # And then setting for AWS.config is as following:
24
+ #
25
+ # AWS.config({
26
+ # :access_key_id => 'xxx', # everything is ok
27
+ # :secret_access_key => 'xxx', # everything is ok
28
+ # :dynamo_db_endpoint => 'localhost', # fake_dynamo runs hostname
29
+ # :dynamo_db_port => 4567, # fake_dynamo listens port
30
+ # :use_ssl => false # fake_dynamo don't speak ssl
31
+ # })
32
+ #
33
+ # Additional information on https://github.com/ananthakumaran/fake_dynamo
34
+ DYNAMOID
35
+
36
+ def setup_orm
37
+ require_dependencies 'aws-sdk'
38
+ require_dependencies 'dynamoid', :version => '~>0.7.1'
39
+ create_file("config/database.rb", DYNAMOID.gsub(/!NAME!/, @project_name.underscore))
40
+ end
41
+
42
+ DYNAMOID_MODEL = (<<-MODEL) unless defined?(DYNAMOID_MODEL)
43
+ class !NAME!
44
+ include Dynamoid::Document
45
+
46
+ !FIELDS!
47
+
48
+ end
49
+ MODEL
50
+
51
+ # options => { :fields => ["title:string", "body:string"], :app => 'app' }
52
+ def create_model_file(name, options={})
53
+ model_path = destination_root(options[:app], 'models', "#{name.to_s.underscore}.rb")
54
+ field_tuples = options[:fields].map { |value| value.split(":") }
55
+ column_declarations = field_tuples.map { |field, kind| "field :#{field}, :#{kind}" }.join("\n ")
56
+ model_contents = DYNAMOID_MODEL.gsub(/!NAME!/, name.to_s.underscore.camelize)
57
+ model_contents.gsub!(/!FIELDS!/, column_declarations)
58
+ create_file(model_path, model_contents)
59
+ end
60
+
61
+ def create_model_migration(filename, name, fields)
62
+ # NO MIGRATION NEEDED
63
+ end
64
+
65
+ def create_migration_file(migration_name, name, columns)
66
+ # NO MIGRATION NEEDED
67
+ end