lotusrb 0.5.0 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (103) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +57 -14
  3. data/FEATURES.md +21 -0
  4. data/LICENSE.md +1 -1
  5. data/README.md +8 -7
  6. data/bin/lotus +1 -0
  7. data/lib/lotus.rb +6 -0
  8. data/lib/lotus/action/csrf_protection.rb +1 -1
  9. data/lib/lotus/application.rb +4 -4
  10. data/lib/lotus/application_name.rb +8 -6
  11. data/lib/lotus/cli.rb +75 -66
  12. data/lib/lotus/cli_sub_commands/assets.rb +29 -0
  13. data/lib/lotus/{commands → cli_sub_commands}/db.rb +24 -29
  14. data/lib/lotus/cli_sub_commands/destroy.rb +102 -0
  15. data/lib/lotus/cli_sub_commands/generate.rb +127 -0
  16. data/lib/lotus/commands/assets/precompile.rb +35 -0
  17. data/lib/lotus/commands/console.rb +28 -8
  18. data/lib/lotus/commands/db/abstract.rb +6 -2
  19. data/lib/lotus/commands/db/console.rb +5 -5
  20. data/lib/lotus/commands/generate/abstract.rb +63 -0
  21. data/lib/lotus/commands/generate/action.rb +262 -0
  22. data/lib/lotus/commands/generate/app.rb +116 -0
  23. data/lib/lotus/commands/generate/mailer.rb +118 -0
  24. data/lib/lotus/commands/generate/migration.rb +63 -0
  25. data/lib/lotus/commands/generate/model.rb +96 -0
  26. data/lib/lotus/commands/new/abstract.rb +128 -0
  27. data/lib/lotus/commands/new/app.rb +116 -0
  28. data/lib/lotus/commands/new/container.rb +102 -0
  29. data/lib/lotus/commands/routes.rb +19 -2
  30. data/lib/lotus/commands/server.rb +16 -2
  31. data/lib/lotus/config/framework_configuration.rb +13 -1
  32. data/lib/lotus/configuration.rb +24 -76
  33. data/lib/lotus/container.rb +15 -2
  34. data/lib/lotus/environment.rb +43 -4
  35. data/lib/lotus/frameworks.rb +1 -0
  36. data/lib/lotus/generators/action/action_spec.minitest.tt +1 -1
  37. data/lib/lotus/generators/action/action_spec.rspec.tt +1 -1
  38. data/lib/lotus/generators/action/view_spec.minitest.tt +1 -1
  39. data/lib/lotus/generators/action/view_spec.rspec.tt +1 -1
  40. data/lib/lotus/generators/{slice → app}/.gitkeep.tt +0 -0
  41. data/lib/lotus/generators/{slice → app}/application.rb.tt +61 -23
  42. data/lib/lotus/generators/app/config/initializers/.gitkeep +0 -0
  43. data/lib/lotus/generators/{slice → app}/config/routes.rb.tt +0 -0
  44. data/lib/lotus/generators/app/favicon.ico +0 -0
  45. data/lib/lotus/generators/{slice → app}/templates/application.html.erb.tt +2 -1
  46. data/lib/lotus/generators/app/views/application_layout.rb.tt +7 -0
  47. data/lib/lotus/generators/application/app/.env.development.tt +1 -0
  48. data/lib/lotus/generators/application/app/.env.test.tt +1 -0
  49. data/lib/lotus/generators/application/app/Gemfile.tt +1 -0
  50. data/lib/lotus/generators/application/app/Rakefile.minitest.tt +1 -0
  51. data/lib/lotus/generators/application/app/Rakefile.rspec.tt +1 -0
  52. data/lib/lotus/generators/application/app/config/application.rb.tt +56 -18
  53. data/lib/lotus/generators/application/app/config/initializers/.gitkeep +0 -0
  54. data/lib/lotus/generators/application/app/favicon.ico +0 -0
  55. data/lib/lotus/generators/application/app/gitignore.tt +2 -0
  56. data/lib/lotus/generators/application/app/lotusrc.tt +3 -3
  57. data/lib/lotus/generators/application/app/spec_helper.rb.rspec.tt +5 -1
  58. data/lib/lotus/generators/application/app/templates/application.html.erb.tt +1 -0
  59. data/lib/lotus/generators/application/container/.env.development.tt +1 -0
  60. data/lib/lotus/generators/application/container/.env.test.tt +1 -0
  61. data/lib/lotus/generators/application/container/Gemfile.tt +1 -1
  62. data/lib/lotus/generators/application/container/Rakefile.minitest.tt +1 -0
  63. data/lib/lotus/generators/application/container/Rakefile.rspec.tt +1 -0
  64. data/lib/lotus/generators/application/container/config/initializers/.gitkeep +0 -0
  65. data/lib/lotus/generators/application/container/gitignore.tt +2 -0
  66. data/lib/lotus/generators/application/container/lib/chirp/mailers/.gitkeep +0 -0
  67. data/lib/lotus/generators/application/container/lib/chirp/mailers/templates/.gitkeep +0 -0
  68. data/lib/lotus/generators/application/container/lotusrc.tt +3 -3
  69. data/lib/lotus/generators/application/container/spec_helper.rb.rspec.tt +5 -1
  70. data/lib/lotus/generators/database_config.rb +17 -4
  71. data/lib/lotus/generators/generatable.rb +51 -0
  72. data/lib/lotus/generators/generator.rb +35 -0
  73. data/lib/lotus/generators/test_framework.rb +42 -0
  74. data/lib/lotus/loader.rb +43 -0
  75. data/lib/lotus/lotusrc.rb +50 -49
  76. data/lib/lotus/middleware.rb +28 -10
  77. data/lib/lotus/rake_helper.rb +68 -0
  78. data/lib/lotus/rake_tasks.rb +2 -0
  79. data/lib/lotus/rendering_policy.rb +2 -2
  80. data/lib/lotus/repositories/car_repository.rb +3 -0
  81. data/lib/lotus/repositories/name_repository.rb +3 -0
  82. data/lib/lotus/setup.rb +1 -3
  83. data/lib/lotus/static.rb +77 -0
  84. data/lib/lotus/templates/welcome.html.erb +7 -4
  85. data/lib/lotus/version.rb +1 -1
  86. data/lib/lotus/views/default.rb +2 -1
  87. data/lib/lotus/views/default_template_finder.rb +4 -3
  88. data/lotusrb.gemspec +11 -9
  89. metadata +79 -60
  90. data/lib/lotus/commands/generate.rb +0 -97
  91. data/lib/lotus/commands/new.rb +0 -43
  92. data/lib/lotus/config/assets.rb +0 -81
  93. data/lib/lotus/generators/abstract.rb +0 -31
  94. data/lib/lotus/generators/action.rb +0 -235
  95. data/lib/lotus/generators/app.rb +0 -39
  96. data/lib/lotus/generators/app/.gitkeep +0 -1
  97. data/lib/lotus/generators/application/app.rb +0 -129
  98. data/lib/lotus/generators/application/container.rb +0 -111
  99. data/lib/lotus/generators/mailer.rb +0 -112
  100. data/lib/lotus/generators/migration.rb +0 -58
  101. data/lib/lotus/generators/model.rb +0 -90
  102. data/lib/lotus/generators/slice.rb +0 -94
  103. data/lib/lotus/generators/slice/views/application_layout.rb.tt +0 -7
@@ -5,6 +5,7 @@ require 'lotus/action/glue'
5
5
  require 'lotus/action/csrf_protection'
6
6
  require 'lotus/mailer'
7
7
  require 'lotus/mailer/glue'
8
+ require 'lotus/assets'
8
9
 
9
10
  Lotus::Controller.configure do
10
11
  prepare do
@@ -5,7 +5,7 @@ describe <%= config[:app] %>::Controllers::<%= config[:controller] %>::<%= confi
5
5
  let(:action) { <%= config[:app] %>::Controllers::<%= config[:controller] %>::<%= config[:action] %>.new }
6
6
  let(:params) { Hash[] }
7
7
 
8
- it "is successful" do
8
+ it 'is successful' do
9
9
  response = action.call(params)
10
10
  response[0].must_equal 200
11
11
  end
@@ -1,6 +1,6 @@
1
1
  require_relative '<%= config[:relative_action_path] %>'
2
2
 
3
- describe <%= config[:app] %>::Controllers::<%= config[:controller] %>::<%= config[:action] %> do
3
+ RSpec.describe <%= config[:app] %>::Controllers::<%= config[:controller] %>::<%= config[:action] %> do
4
4
  let(:action) { described_class.new }
5
5
  let(:params) { Hash[] }
6
6
 
@@ -7,7 +7,7 @@ describe <%= config[:app] %>::Views::<%= config[:controller] %>::<%= config[:act
7
7
  let(:view) { <%= config[:app] %>::Views::<%= config[:controller] %>::<%= config[:action] %>.new(template, exposures) }
8
8
  let(:rendered) { view.render }
9
9
 
10
- it "exposes #foo" do
10
+ it 'exposes #foo' do
11
11
  view.foo.must_equal exposures.fetch(:foo)
12
12
  end
13
13
  end
@@ -1,6 +1,6 @@
1
1
  require_relative '<%= config[:relative_view_path] %>'
2
2
 
3
- describe <%= config[:app] %>::Views::<%= config[:controller] %>::<%= config[:action] %> do
3
+ RSpec.describe <%= config[:app] %>::Views::<%= config[:controller] %>::<%= config[:action] %> do
4
4
  let(:exposures) { Hash[foo: 'bar'] }
5
5
  let(:template) { Lotus::View::Template.new('<%= config[:template_path] %>') }
6
6
  let(:view) { described_class.new(template, exposures) }
File without changes
@@ -1,6 +1,7 @@
1
1
  require 'lotus/helpers'
2
+ require 'lotus/assets'
2
3
 
3
- module <%= config[:classified_slice_name] %>
4
+ module <%= config[:classified_app_name] %>
4
5
  class Application < Lotus::Application
5
6
  configure do
6
7
  ##
@@ -73,7 +74,7 @@ module <%= config[:classified_slice_name] %>
73
74
  #
74
75
  # See: http://www.rubydoc.info/gems/rack/Rack/Session/Cookie
75
76
  #
76
- # sessions :cookie, secret: ENV['<%= config[:upcase_slice_name] %>_SESSIONS_SECRET']
77
+ # sessions :cookie, secret: ENV['<%= config[:upcase_app_name] %>_SESSIONS_SECRET']
77
78
 
78
79
  # Configure Rack middleware for this application
79
80
  #
@@ -107,7 +108,7 @@ module <%= config[:classified_slice_name] %>
107
108
 
108
109
  # The layout to be used by all views
109
110
  #
110
- layout :application # It will load <%= config[:classified_slice_name] %>::Views::ApplicationLayout
111
+ layout :application # It will load <%= config[:classified_app_name] %>::Views::ApplicationLayout
111
112
 
112
113
  # The relative path to templates
113
114
  #
@@ -116,18 +117,40 @@ module <%= config[:classified_slice_name] %>
116
117
  ##
117
118
  # ASSETS
118
119
  #
119
-
120
- # Specify sources for assets
121
- # The directory `public/` is added by default
122
- #
123
- # assets << [
124
- # 'vendor/javascripts'
125
- # ]
126
-
127
- # Enabling serving assets
128
- # Defaults to false
129
- #
130
- # serve_assets false
120
+ assets do
121
+ # JavaScript compressor
122
+ #
123
+ # Supported engines:
124
+ #
125
+ # * :builtin
126
+ # * :uglifier
127
+ # * :yui
128
+ # * :closure
129
+ #
130
+ # See: http://lotusrb.org/guides/assets/compressors
131
+ #
132
+ # In order to skip JavaScript compression comment the following line
133
+ javascript_compressor :builtin
134
+
135
+ # Stylesheet compressor
136
+ #
137
+ # Supported engines:
138
+ #
139
+ # * :builtin
140
+ # * :yui
141
+ # * :sass
142
+ #
143
+ # See: http://lotusrb.org/guides/assets/compressors
144
+ #
145
+ # In order to skip stylesheet compression comment the following line
146
+ stylesheet_compressor :builtin
147
+
148
+ # Specify sources for assets
149
+ #
150
+ sources << [
151
+ 'assets'
152
+ ]
153
+ end
131
154
 
132
155
  ##
133
156
  # SECURITY
@@ -183,7 +206,7 @@ module <%= config[:classified_slice_name] %>
183
206
  # FRAMEWORKS
184
207
  #
185
208
 
186
- # Configure the code that will yield each time <%= config[:classified_slice_name] %>::Action is included
209
+ # Configure the code that will yield each time <%= config[:classified_app_name] %>::Action is included
187
210
  # This is useful for sharing common functionality
188
211
  #
189
212
  # See: http://www.rubydoc.info/gems/lotus-controller#Configuration
@@ -192,12 +215,13 @@ module <%= config[:classified_slice_name] %>
192
215
  # before :authenticate! # run an authentication before callback
193
216
  end
194
217
 
195
- # Configure the code that will yield each time <%= config[:classified_slice_name] %>::View is included
218
+ # Configure the code that will yield each time <%= config[:classified_app_name] %>::View is included
196
219
  # This is useful for sharing common functionality
197
220
  #
198
221
  # See: http://www.rubydoc.info/gems/lotus-view#Configuration
199
222
  view.prepare do
200
223
  include Lotus::Helpers
224
+ include <%= config[:classified_app_name] %>::Assets::Helpers
201
225
  end
202
226
  end
203
227
 
@@ -207,9 +231,6 @@ module <%= config[:classified_slice_name] %>
207
231
  configure :development do
208
232
  # Don't handle exceptions, render the stack trace
209
233
  handle_exceptions false
210
-
211
- # Serve static assets during development
212
- serve_assets true
213
234
  end
214
235
 
215
236
  ##
@@ -218,9 +239,6 @@ module <%= config[:classified_slice_name] %>
218
239
  configure :test do
219
240
  # Don't handle exceptions, render the stack trace
220
241
  handle_exceptions false
221
-
222
- # Serve static assets during development
223
- serve_assets true
224
242
  end
225
243
 
226
244
  ##
@@ -230,6 +248,26 @@ module <%= config[:classified_slice_name] %>
230
248
  # scheme 'https'
231
249
  # host 'example.org'
232
250
  # port 443
251
+
252
+ assets do
253
+ # Don't compile static assets in production mode (eg. Sass, ES6)
254
+ #
255
+ # See: http://www.rubydoc.info/gems/lotus-assets#Configuration
256
+ compile false
257
+
258
+ # Use digest file name for asset paths
259
+ #
260
+ # See: http://lotusrb.org/guides/assets/digest
261
+ digest true
262
+
263
+ # Content Delivery Network (CDN)
264
+ #
265
+ # See: http://lotusrb.org/guides/assets/content-delivery-network
266
+ #
267
+ # scheme 'https'
268
+ # host 'cdn.example.org'
269
+ # port 443
270
+ end
233
271
  end
234
272
  end
235
273
  end
@@ -1,7 +1,8 @@
1
1
  <!DOCTYPE html>
2
2
  <html>
3
3
  <head>
4
- <title><%= config[:classified_slice_name] %></title>
4
+ <title><%= config[:classified_app_name] %></title>
5
+ <%%= favicon %>
5
6
  </head>
6
7
  <body>
7
8
  <%%= yield %>
@@ -0,0 +1,7 @@
1
+ module <%= config[:classified_app_name] %>
2
+ module Views
3
+ class ApplicationLayout
4
+ include <%= config[:classified_app_name] %>::Layout
5
+ end
6
+ end
7
+ end
@@ -1,3 +1,4 @@
1
1
  # Define ENV variables for development environment
2
2
  <%= config[:upcase_app_name] %>_DATABASE_URL="<%= config[:database_config][:uri][:development] %>"
3
3
  <%= config[:upcase_app_name] %>_SESSIONS_SECRET="<%= SecureRandom.hex(32) %>"
4
+ SERVE_STATIC_ASSETS="true"
@@ -1,3 +1,4 @@
1
1
  # Define ENV variables for test environment
2
2
  <%= config[:app_name].to_env_s %>_DATABASE_URL="<%= config[:database_config][:uri][:test] %>"
3
3
  <%= config[:upcase_app_name] %>_SESSIONS_SECRET="<%= SecureRandom.hex(32) %>"
4
+ SERVE_STATIC_ASSETS="true"
@@ -12,6 +12,7 @@ gem 'lotus-controller', require: false, github: 'lotus/controller'
12
12
  gem 'lotus-view', require: false, github: 'lotus/view'
13
13
  gem 'lotus-model', require: false, github: 'lotus/model'
14
14
  gem 'lotus-mailer', require: false, github: 'lotus/mailer'
15
+ gem 'lotus-assets', require: false, github: 'lotus/assets'
15
16
  gem 'lotusrb', github: 'lotus/lotus'
16
17
  <%- else -%>
17
18
  gem 'lotusrb', '<%= Lotus::VERSION %>'
@@ -1,4 +1,5 @@
1
1
  require 'rake'
2
+ require 'lotus/rake_tasks'
2
3
  require 'rake/testtask'
3
4
 
4
5
  Rake::TestTask.new do |t|
@@ -1,4 +1,5 @@
1
1
  require 'rake'
2
+ require 'lotus/rake_tasks'
2
3
  require 'rspec/core/rake_task'
3
4
 
4
5
  RSpec::Core::RakeTask.new(:spec)
@@ -1,4 +1,5 @@
1
1
  require 'lotus/helpers'
2
+ require 'lotus/assets'
2
3
 
3
4
  module <%= config[:classified_app_name] %>
4
5
  class Application < Lotus::Application
@@ -113,18 +114,40 @@ module <%= config[:classified_app_name] %>
113
114
  ##
114
115
  # ASSETS
115
116
  #
116
-
117
- # Specify sources for assets
118
- # The directory `public/` is added by default
119
- #
120
- # assets << [
121
- # 'vendor/javascripts'
122
- # ]
123
-
124
- # Enabling serving assets
125
- # Defaults to false
126
- #
127
- # serve_assets false
117
+ assets do
118
+ # JavaScript compressor
119
+ #
120
+ # Supported engines:
121
+ #
122
+ # * :builtin
123
+ # * :uglifier
124
+ # * :yui
125
+ # * :closure
126
+ #
127
+ # See: http://lotusrb.org/guides/assets/compressors
128
+ #
129
+ # In order to skip JavaScript compression comment the following line
130
+ javascript_compressor :builtin
131
+
132
+ # Stylesheet compressor
133
+ #
134
+ # Supported engines:
135
+ #
136
+ # * :builtin
137
+ # * :yui
138
+ # * :sass
139
+ #
140
+ # See: http://lotusrb.org/guides/assets/compressors
141
+ #
142
+ # In order to skip stylesheet compression comment the following line
143
+ stylesheet_compressor :builtin
144
+
145
+ # Specify sources for assets
146
+ #
147
+ sources << [
148
+ 'app/assets'
149
+ ]
150
+ end
128
151
 
129
152
  ##
130
153
  # SECURITY
@@ -195,6 +218,7 @@ module <%= config[:classified_app_name] %>
195
218
  # See: http://www.rubydoc.info/gems/lotus-view#Configuration
196
219
  view.prepare do
197
220
  include Lotus::Helpers
221
+ include <%= config[:classified_app_name] %>::Assets::Helpers
198
222
  end
199
223
  end
200
224
 
@@ -204,9 +228,6 @@ module <%= config[:classified_app_name] %>
204
228
  configure :development do
205
229
  # Don't handle exceptions, render the stack trace
206
230
  handle_exceptions false
207
-
208
- # Serve static assets during development
209
- serve_assets true
210
231
  end
211
232
 
212
233
  ##
@@ -215,9 +236,6 @@ module <%= config[:classified_app_name] %>
215
236
  configure :test do
216
237
  # Don't handle exceptions, render the stack trace
217
238
  handle_exceptions false
218
-
219
- # Serve static assets during development
220
- serve_assets true
221
239
  end
222
240
 
223
241
  ##
@@ -227,6 +245,26 @@ module <%= config[:classified_app_name] %>
227
245
  # scheme 'https'
228
246
  # host 'example.org'
229
247
  # port 443
248
+
249
+ assets do
250
+ # Don't compile static assets in production mode (eg. Sass, ES6)
251
+ #
252
+ # See: http://www.rubydoc.info/gems/lotus-assets#Configuration
253
+ compile false
254
+
255
+ # Use digest file name for asset paths
256
+ #
257
+ # See: http://lotusrb.org/guides/assets/digest
258
+ digest true
259
+
260
+ # Content Delivery Network (CDN)
261
+ #
262
+ # See: http://lotusrb.org/guides/assets/content-delivery-network
263
+ #
264
+ # scheme 'https'
265
+ # host 'cdn.example.org'
266
+ # port 443
267
+ end
230
268
  end
231
269
  end
232
270
  end
@@ -1,2 +1,4 @@
1
1
  /db/<%= config[:app_name] %>_development
2
2
  /db/<%= config[:app_name] %>_test
3
+ /public/assets*
4
+ /tmp
@@ -1,3 +1,3 @@
1
- architecture=app
2
- test=<%= config[:test] %>
3
- template=erb
1
+ <%= Lotus::Lotusrc::ARCHITECTURE_KEY %>=<%= Lotus::Lotusrc::APP_ARCHITECTURE %>
2
+ <%= Lotus::Lotusrc::TEST_KEY %>=<%= config[:test] %>
3
+ <%= Lotus::Lotusrc::TEMPLATE_KEY %>=<%= Lotus::Lotusrc::DEFAULT_TEMPLATE %>
@@ -58,6 +58,11 @@ RSpec.configure do |config|
58
58
  config.filter_run :focus
59
59
  config.run_all_when_everything_filtered = true
60
60
 
61
+ # Allows RSpec to persist some state between runs in order to support
62
+ # the `--only-failures` and `--next-failure` CLI options. We recommend
63
+ # you configure your source control system to ignore this file.
64
+ config.example_status_persistence_file_path = "spec/examples.txt"
65
+
61
66
  # Limits the available syntax to the non-monkey patched syntax that is
62
67
  # recommended. For more details, see:
63
68
  # - http://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-syntax
@@ -97,4 +102,3 @@ RSpec.configure do |config|
97
102
  Kernel.srand config.seed
98
103
  =end
99
104
  end
100
-
@@ -2,6 +2,7 @@
2
2
  <html>
3
3
  <head>
4
4
  <title><%= config[:classified_app_name] %></title>
5
+ <%%= favicon %>
5
6
  </head>
6
7
  <body>
7
8
  <%%= yield %>
@@ -1,2 +1,3 @@
1
1
  # Define ENV variables for development environment
2
2
  <%= config[:app_name].to_env_s %>_DATABASE_URL="<%= config[:database_config][:uri][:development] %>"
3
+ SERVE_STATIC_ASSETS="true"
@@ -1,2 +1,3 @@
1
1
  # Define ENV variables for test environment
2
2
  <%= config[:app_name].to_env_s %>_DATABASE_URL="<%= config[:database_config][:uri][:test] %>"
3
+ SERVE_STATIC_ASSETS="true"
@@ -2,7 +2,6 @@ source 'https://rubygems.org'
2
2
 
3
3
  gem 'bundler'
4
4
  gem 'rake'
5
-
6
5
  <%- if config[:lotus_head] -%>
7
6
  gem 'lotus-utils', require: false, github: 'lotus/utils'
8
7
  gem 'lotus-router', require: false, github: 'lotus/router'
@@ -12,6 +11,7 @@ gem 'lotus-controller', require: false, github: 'lotus/controller'
12
11
  gem 'lotus-view', require: false, github: 'lotus/view'
13
12
  gem 'lotus-model', require: false, github: 'lotus/model'
14
13
  gem 'lotus-mailer', require: false, github: 'lotus/mailer'
14
+ gem 'lotus-assets', require: false, github: 'lotus/assets'
15
15
  gem 'lotusrb', github: 'lotus/lotus'
16
16
  <%- else -%>
17
17
  gem 'lotusrb', '<%= Lotus::VERSION %>'