lotusrb 0.4.0 → 0.4.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +12 -0
- data/FEATURES.md +2 -0
- data/lib/lotus/cli.rb +4 -4
- data/lib/lotus/commands/console.rb +9 -1
- data/lib/lotus/commands/routes.rb +13 -2
- data/lib/lotus/environment.rb +8 -1
- data/lib/lotus/generators/action.rb +16 -2
- data/lib/lotus/generators/application/app.rb +4 -2
- data/lib/lotus/generators/application/app/.env.development.tt +1 -1
- data/lib/lotus/generators/application/app/.env.test.tt +1 -1
- data/lib/lotus/generators/application/app/.gitignore +0 -0
- data/lib/lotus/generators/application/container.rb +4 -3
- data/lib/lotus/generators/application/container/.gitignore +0 -0
- data/lib/lotus/generators/model.rb +10 -0
- data/lib/lotus/middleware.rb +1 -1
- data/lib/lotus/version.rb +1 -1
- data/lotusrb.gemspec +5 -5
- metadata +22 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 935451417df1119d39a85bc9f5a4ab0b254f5f4a
|
4
|
+
data.tar.gz: 35a84423b6d404016700fb068965dcc1649742db
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 804e4de1c16d7840bcf859608af64eeb68687ccc0dc64f10de35b06bf8660d9c74e6bdaebca9636ec0ecadafc928252a5d989a89548b20e5ff1cacb66da325b0
|
7
|
+
data.tar.gz: e2ba8789564318ad4d99d489eeed5d42b8484cf21a7124140f6bcfa57d65442ce401217e6ae68a27a425bf0db7c20d2d914c53869fad85b28803e62f0e639035
|
data/CHANGELOG.md
CHANGED
@@ -1,6 +1,18 @@
|
|
1
1
|
# Lotus
|
2
2
|
A complete web framework for Ruby
|
3
3
|
|
4
|
+
## v0.4.1 - 2015-07-10
|
5
|
+
### Added
|
6
|
+
- [Trung Lê] Alias `--database` as `--db` for `lotus new`
|
7
|
+
|
8
|
+
### Fixed
|
9
|
+
- [Alfonso Uceda Pompa] Ensure to load correctly apps in `lotus console`
|
10
|
+
- [Alfonso Uceda Pompa] Ensure to not duplicate prefix for Container mounted apps (eg `/admin/admin/dashboard`)
|
11
|
+
- [Alfonso Uceda Pompa] Ensure generator for application arch to generate session secret
|
12
|
+
- [Alfonso Uceda Pompa & Trung Lê & Hiếu Nguyễn] Exit unsuccessfully when `lotus generate model` doesn't receive a mandatory name for model
|
13
|
+
- [Miguel Molina] Exit unsuccessfully when `lotus new --database` receives an unknown value
|
14
|
+
- [Luca Guidi] Ensure to prepend sessions middleware, so other Rack components can have access to HTTP session
|
15
|
+
|
4
16
|
## v0.4.0 - 2015-06-23
|
5
17
|
### Added
|
6
18
|
- [Luca Guidi] Database migrations and new CLI commands for database operations
|
data/FEATURES.md
CHANGED
data/lib/lotus/cli.rb
CHANGED
@@ -61,12 +61,12 @@ module Lotus
|
|
61
61
|
end
|
62
62
|
|
63
63
|
desc 'new', 'generates a new application'
|
64
|
-
method_option :database, aliases: '-d',
|
65
|
-
method_option :architecture, aliases: ['-a', '--arch'], desc: 'application architecture', type: :string,
|
64
|
+
method_option :database, aliases: ['-d', '--db'], desc: 'application database (filesystem/memory/postgresql/sqlite3/mysql)', type: :string, default: 'filesystem'
|
65
|
+
method_option :architecture, aliases: ['-a', '--arch'], desc: 'application architecture (container/app)', type: :string, default: 'container'
|
66
66
|
method_option :application, desc: 'application name', type: :string, default: 'web'
|
67
67
|
method_option :application_base_url, desc: 'application base url', type: :string, default: '/'
|
68
68
|
method_option :path, desc: 'path', type: :string
|
69
|
-
method_option :test, desc: 'application test framework (rspec/minitest)', type: :string,
|
69
|
+
method_option :test, desc: 'application test framework (rspec/minitest)', type: :string, default: 'minitest'
|
70
70
|
method_option :lotus_head, desc: 'use Lotus HEAD', type: :boolean, default: false
|
71
71
|
method_option :help, aliases: '-h', desc: 'displays the usage method'
|
72
72
|
|
@@ -79,7 +79,7 @@ module Lotus
|
|
79
79
|
end
|
80
80
|
end
|
81
81
|
|
82
|
-
desc 'generate', 'generates action, model or migration'
|
82
|
+
desc 'generate', 'generates app, action, model or migration'
|
83
83
|
method_option :application_base_url, desc: 'application base url', type: :string
|
84
84
|
method_option :path, desc: 'applications path', type: :string
|
85
85
|
method_option :url, desc: 'relative URL for action', type: :string
|
@@ -28,8 +28,8 @@ module Lotus
|
|
28
28
|
|
29
29
|
# Add convenience methods to the main:Object binding
|
30
30
|
TOPLEVEL_BINDING.eval('self').send(:include, Methods)
|
31
|
-
Lotus::Application.preload_applications!
|
32
31
|
|
32
|
+
load_application
|
33
33
|
engine.start
|
34
34
|
end
|
35
35
|
|
@@ -57,6 +57,14 @@ module Lotus
|
|
57
57
|
}
|
58
58
|
)
|
59
59
|
end
|
60
|
+
|
61
|
+
def load_application
|
62
|
+
if @environment.container?
|
63
|
+
Lotus::Container.new
|
64
|
+
else
|
65
|
+
Lotus::Application.preload_applications!
|
66
|
+
end
|
67
|
+
end
|
60
68
|
end
|
61
69
|
end
|
62
70
|
end
|
@@ -2,11 +2,22 @@ module Lotus
|
|
2
2
|
module Commands
|
3
3
|
class Routes
|
4
4
|
def initialize(environment)
|
5
|
-
environment
|
5
|
+
@environment = environment
|
6
|
+
@environment.require_application_environment
|
6
7
|
end
|
7
8
|
|
8
9
|
def start
|
9
|
-
puts
|
10
|
+
puts app.routes.inspector.to_s
|
11
|
+
end
|
12
|
+
|
13
|
+
private
|
14
|
+
|
15
|
+
def app
|
16
|
+
if @environment.container?
|
17
|
+
Lotus::Container.new
|
18
|
+
else
|
19
|
+
Lotus::Application.applications.first.new
|
20
|
+
end
|
10
21
|
end
|
11
22
|
end
|
12
23
|
end
|
data/lib/lotus/environment.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
require 'thread'
|
2
2
|
require 'pathname'
|
3
3
|
require 'dotenv'
|
4
|
+
require 'lotus/utils'
|
4
5
|
require 'lotus/utils/hash'
|
5
6
|
require 'lotus/lotusrc'
|
6
7
|
|
@@ -360,7 +361,13 @@ module Lotus
|
|
360
361
|
# @see Lotus::Commands::Server
|
361
362
|
# @see Lotus::Environment::CODE_RELOADING
|
362
363
|
def code_reloading?
|
363
|
-
|
364
|
+
# JRuby doesn't implement fork that's why shotgun cannot be used.
|
365
|
+
if Utils.jruby?
|
366
|
+
puts "JRuby doesn't support code reloading."
|
367
|
+
false
|
368
|
+
else
|
369
|
+
@options.fetch(:code_reloading) { !!CODE_RELOADING[environment] }
|
370
|
+
end
|
364
371
|
end
|
365
372
|
|
366
373
|
# @since 0.4.0
|
@@ -10,6 +10,14 @@ module Lotus
|
|
10
10
|
# @api private
|
11
11
|
ACTION_SEPARATOR = /\/|\#/
|
12
12
|
|
13
|
+
# @since 0.4.1
|
14
|
+
# @api private
|
15
|
+
ROUTE_ENDPOINT_SEPARATOR = '#'.freeze
|
16
|
+
|
17
|
+
# @since 0.4.1
|
18
|
+
# @api private
|
19
|
+
QUOTED_NAME = /(\"|\'|\\)/
|
20
|
+
|
13
21
|
# @since 0.3.0
|
14
22
|
# @api private
|
15
23
|
SUFFIX = '.rb'.freeze
|
@@ -27,7 +35,7 @@ module Lotus
|
|
27
35
|
def initialize(command)
|
28
36
|
super
|
29
37
|
|
30
|
-
@name = Utils::String.new(name).underscore
|
38
|
+
@name = Utils::String.new(name).underscore.gsub(QUOTED_NAME, '')
|
31
39
|
@controller, @action = @name.split(ACTION_SEPARATOR)
|
32
40
|
@controller_name = Utils::String.new(@controller).classify
|
33
41
|
@action_name = Utils::String.new(@action).classify
|
@@ -119,7 +127,7 @@ module Lotus
|
|
119
127
|
|
120
128
|
# Insert at the top of the file
|
121
129
|
cli.insert_into_file _routes_path, before: /\A(.*)/ do
|
122
|
-
"get '#{ _route_url }', to: '#{
|
130
|
+
"get '#{ _route_url }', to: '#{ _route_endpoint }'\n"
|
123
131
|
end
|
124
132
|
end
|
125
133
|
|
@@ -129,6 +137,12 @@ module Lotus
|
|
129
137
|
options.fetch(:url, "/#{ @controller }")
|
130
138
|
end
|
131
139
|
|
140
|
+
# @since 0.4.1
|
141
|
+
# @api private
|
142
|
+
def _route_endpoint
|
143
|
+
"#{ @controller }#{ROUTE_ENDPOINT_SEPARATOR}#{ @action }"
|
144
|
+
end
|
145
|
+
|
132
146
|
# @since 0.3.0
|
133
147
|
# @api private
|
134
148
|
def _routes_path
|
@@ -110,7 +110,7 @@ module Lotus
|
|
110
110
|
end
|
111
111
|
|
112
112
|
unless git_dir_present?
|
113
|
-
cli.template(source.join('gitignore.tt'), target.join('.gitignore'), opts)
|
113
|
+
cli.template(source.join(database_type == :file_system ? 'gitignore.tt' : '.gitignore'), target.join('.gitignore'), opts)
|
114
114
|
cli.run("git init #{Shellwords.escape(target)}", capture: true)
|
115
115
|
end
|
116
116
|
end
|
@@ -174,8 +174,10 @@ module Lotus
|
|
174
174
|
"sqlite://db/#{Shellwords.escape(app_name)}"
|
175
175
|
when 'memory'
|
176
176
|
"memory://localhost/#{app_name}"
|
177
|
-
|
177
|
+
when 'filesystem'
|
178
178
|
"file:///db/#{app_name}"
|
179
|
+
else
|
180
|
+
raise "\"#{@database}\" is not a valid database type"
|
179
181
|
end
|
180
182
|
end
|
181
183
|
end
|
@@ -1,3 +1,3 @@
|
|
1
1
|
# Define ENV variables for development environment
|
2
2
|
<%= config[:upcase_app_name] %>_DATABASE_URL="<%= config[:database_config][:uri][:development] %>"
|
3
|
-
<%= config[:upcase_app_name] %>_SESSIONS_SECRET="
|
3
|
+
<%= config[:upcase_app_name] %>_SESSIONS_SECRET="<%= SecureRandom.hex(32) %>"
|
@@ -1,3 +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
|
-
<%= config[:upcase_app_name] %>_SESSIONS_SECRET="
|
3
|
+
<%= config[:upcase_app_name] %>_SESSIONS_SECRET="<%= SecureRandom.hex(32) %>"
|
File without changes
|
@@ -19,7 +19,6 @@ module Lotus
|
|
19
19
|
end
|
20
20
|
|
21
21
|
def start
|
22
|
-
|
23
22
|
opts = {
|
24
23
|
app_name: app_name,
|
25
24
|
lotus_head: @lotus_head,
|
@@ -91,7 +90,7 @@ module Lotus
|
|
91
90
|
end
|
92
91
|
|
93
92
|
unless git_dir_present?
|
94
|
-
cli.template(source.join('gitignore.tt'), target.join('.gitignore'), opts)
|
93
|
+
cli.template(source.join(database_type == :file_system ? 'gitignore.tt' : '.gitignore'), target.join('.gitignore'), opts)
|
95
94
|
cli.run("git init #{Shellwords.escape(target)}", capture: true)
|
96
95
|
end
|
97
96
|
|
@@ -157,8 +156,10 @@ module Lotus
|
|
157
156
|
"sqlite://db/#{Shellwords.escape(app_name)}"
|
158
157
|
when 'memory'
|
159
158
|
"memory://localhost/#{app_name}"
|
160
|
-
|
159
|
+
when 'filesystem'
|
161
160
|
"file:///db/#{app_name}"
|
161
|
+
else
|
162
|
+
raise "\"#{@database}\" is not a valid database type"
|
162
163
|
end
|
163
164
|
end
|
164
165
|
|
File without changes
|
@@ -17,6 +17,8 @@ module Lotus
|
|
17
17
|
# @since 0.3.1
|
18
18
|
# @api private
|
19
19
|
def start
|
20
|
+
assert_model!
|
21
|
+
|
20
22
|
opts = {
|
21
23
|
model_name: @model_name
|
22
24
|
}
|
@@ -75,6 +77,14 @@ module Lotus
|
|
75
77
|
def name
|
76
78
|
Utils::String.new(app_name || super).underscore
|
77
79
|
end
|
80
|
+
|
81
|
+
# @since 0.4.1
|
82
|
+
# @api private
|
83
|
+
def assert_model!
|
84
|
+
if @model_name.nil? || @model_name.empty?
|
85
|
+
raise Lotus::Commands::Generate::Error.new("Missing model name")
|
86
|
+
end
|
87
|
+
end
|
78
88
|
end
|
79
89
|
end
|
80
90
|
end
|
data/lib/lotus/middleware.rb
CHANGED
data/lib/lotus/version.rb
CHANGED
data/lotusrb.gemspec
CHANGED
@@ -6,8 +6,8 @@ require 'lotus/version'
|
|
6
6
|
Gem::Specification.new do |spec|
|
7
7
|
spec.name = 'lotusrb'
|
8
8
|
spec.version = Lotus::VERSION
|
9
|
-
spec.authors = ['Luca Guidi']
|
10
|
-
spec.email = ['me@lucaguidi.com']
|
9
|
+
spec.authors = ['Luca Guidi', 'Trung Lê', 'Alfonso Uceda Pompa']
|
10
|
+
spec.email = ['me@lucaguidi.com', 'trung.le@ruby-journal.com', 'uceda73@gmail.com']
|
11
11
|
spec.summary = %q{A complete web framework for Ruby}
|
12
12
|
spec.description = %q{A complete web framework for Ruby}
|
13
13
|
spec.homepage = 'http://lotusrb.org'
|
@@ -19,10 +19,10 @@ Gem::Specification.new do |spec|
|
|
19
19
|
spec.require_paths = ['lib']
|
20
20
|
spec.required_ruby_version = '>= 2.0.0'
|
21
21
|
|
22
|
-
spec.add_dependency 'lotus-utils', '~> 0.5'
|
23
|
-
spec.add_dependency 'lotus-router', '~> 0.4', '>= 0.4.
|
22
|
+
spec.add_dependency 'lotus-utils', '~> 0.5', '>= 0.5.1'
|
23
|
+
spec.add_dependency 'lotus-router', '~> 0.4', '>= 0.4.2'
|
24
24
|
spec.add_dependency 'lotus-controller', '~> 0.4', '>= 0.4.4'
|
25
|
-
spec.add_dependency 'lotus-view', '~> 0.4'
|
25
|
+
spec.add_dependency 'lotus-view', '~> 0.4', '>= 0.4.3'
|
26
26
|
spec.add_dependency 'lotus-helpers', '~> 0.2'
|
27
27
|
spec.add_dependency 'shotgun', '~> 0.9'
|
28
28
|
spec.add_dependency 'dotenv', '~> 2.0'
|
metadata
CHANGED
@@ -1,14 +1,16 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lotusrb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Luca Guidi
|
8
|
+
- Trung Lê
|
9
|
+
- Alfonso Uceda Pompa
|
8
10
|
autorequire:
|
9
11
|
bindir: bin
|
10
12
|
cert_chain: []
|
11
|
-
date: 2015-
|
13
|
+
date: 2015-07-10 00:00:00.000000000 Z
|
12
14
|
dependencies:
|
13
15
|
- !ruby/object:Gem::Dependency
|
14
16
|
name: lotus-utils
|
@@ -17,6 +19,9 @@ dependencies:
|
|
17
19
|
- - "~>"
|
18
20
|
- !ruby/object:Gem::Version
|
19
21
|
version: '0.5'
|
22
|
+
- - ">="
|
23
|
+
- !ruby/object:Gem::Version
|
24
|
+
version: 0.5.1
|
20
25
|
type: :runtime
|
21
26
|
prerelease: false
|
22
27
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -24,6 +29,9 @@ dependencies:
|
|
24
29
|
- - "~>"
|
25
30
|
- !ruby/object:Gem::Version
|
26
31
|
version: '0.5'
|
32
|
+
- - ">="
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: 0.5.1
|
27
35
|
- !ruby/object:Gem::Dependency
|
28
36
|
name: lotus-router
|
29
37
|
requirement: !ruby/object:Gem::Requirement
|
@@ -33,7 +41,7 @@ dependencies:
|
|
33
41
|
version: '0.4'
|
34
42
|
- - ">="
|
35
43
|
- !ruby/object:Gem::Version
|
36
|
-
version: 0.4.
|
44
|
+
version: 0.4.2
|
37
45
|
type: :runtime
|
38
46
|
prerelease: false
|
39
47
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -43,7 +51,7 @@ dependencies:
|
|
43
51
|
version: '0.4'
|
44
52
|
- - ">="
|
45
53
|
- !ruby/object:Gem::Version
|
46
|
-
version: 0.4.
|
54
|
+
version: 0.4.2
|
47
55
|
- !ruby/object:Gem::Dependency
|
48
56
|
name: lotus-controller
|
49
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -71,6 +79,9 @@ dependencies:
|
|
71
79
|
- - "~>"
|
72
80
|
- !ruby/object:Gem::Version
|
73
81
|
version: '0.4'
|
82
|
+
- - ">="
|
83
|
+
- !ruby/object:Gem::Version
|
84
|
+
version: 0.4.3
|
74
85
|
type: :runtime
|
75
86
|
prerelease: false
|
76
87
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -78,6 +89,9 @@ dependencies:
|
|
78
89
|
- - "~>"
|
79
90
|
- !ruby/object:Gem::Version
|
80
91
|
version: '0.4'
|
92
|
+
- - ">="
|
93
|
+
- !ruby/object:Gem::Version
|
94
|
+
version: 0.4.3
|
81
95
|
- !ruby/object:Gem::Dependency
|
82
96
|
name: lotus-helpers
|
83
97
|
requirement: !ruby/object:Gem::Requirement
|
@@ -193,6 +207,8 @@ dependencies:
|
|
193
207
|
description: A complete web framework for Ruby
|
194
208
|
email:
|
195
209
|
- me@lucaguidi.com
|
210
|
+
- trung.le@ruby-journal.com
|
211
|
+
- uceda73@gmail.com
|
196
212
|
executables:
|
197
213
|
- lotus
|
198
214
|
extensions: []
|
@@ -253,6 +269,7 @@ files:
|
|
253
269
|
- lib/lotus/generators/application/app/.env.development.tt
|
254
270
|
- lib/lotus/generators/application/app/.env.test.tt
|
255
271
|
- lib/lotus/generators/application/app/.env.tt
|
272
|
+
- lib/lotus/generators/application/app/.gitignore
|
256
273
|
- lib/lotus/generators/application/app/.gitkeep
|
257
274
|
- lib/lotus/generators/application/app/Gemfile.tt
|
258
275
|
- lib/lotus/generators/application/app/Rakefile.minitest.tt
|
@@ -282,6 +299,7 @@ files:
|
|
282
299
|
- lib/lotus/generators/application/container/.env.development.tt
|
283
300
|
- lib/lotus/generators/application/container/.env.test.tt
|
284
301
|
- lib/lotus/generators/application/container/.env.tt
|
302
|
+
- lib/lotus/generators/application/container/.gitignore
|
285
303
|
- lib/lotus/generators/application/container/.gitkeep
|
286
304
|
- lib/lotus/generators/application/container/Gemfile.tt
|
287
305
|
- lib/lotus/generators/application/container/Rakefile.minitest.tt
|