roda-project 0.1.13 → 0.1.14
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 +4 -4
- data/lib/roda/project/templates/base/app/app.rb.erb +3 -4
- data/lib/roda/project/templates/base/scaffold/app/config/config.rb.erb +4 -4
- data/lib/roda/project/templates/base/scaffold/bin/roda.erb +19 -24
- data/lib/roda/project/templates/tests/minitest/spec/app/app_spec.rb.erb +2 -1
- data/lib/roda/project/templates/tests/rspec/spec/app/app_spec.rb.erb +2 -1
- data/lib/roda/project/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: e03b5fbcad7831986b704d75c798fc85ea1874b5e63a8970ef876db89841978f
|
|
4
|
+
data.tar.gz: 1cb64c7f6c9b14c8fdcc31e0e841813c5eb92bb707899187053f4af534327136
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 9abfe5001b17316fb5ddd00d0f568b96b7b028c96e41a49d6696523d6397965ebd46acd980c3e4d918ff69c5d9aaf6032a155b0fb7736970ed64f78342a6a709
|
|
7
|
+
data.tar.gz: ad3464a71e558d327e0492b0c4e56f06bf82c7ae524d8767a99b03a7ca0408aaf9f814cb71a8b17c5e0077b9d06499980fe296f8302aec96bfbcc7ffc19ce362
|
|
@@ -63,10 +63,9 @@ class <%= context.const_project_name %> < Roda
|
|
|
63
63
|
<% end %>
|
|
64
64
|
def config = @config ||= Config.get
|
|
65
65
|
|
|
66
|
-
route do |r
|
|
67
|
-
r.
|
|
68
|
-
|
|
69
|
-
# r.i18n_set_locale_from(:session)<% end %>
|
|
66
|
+
route do |r|<% if context.fullstack? %>
|
|
67
|
+
r.i18n_set_locale_from(:http)<% end %>
|
|
68
|
+
r.hash_branches
|
|
70
69
|
<% if context.rodauth? %>
|
|
71
70
|
r.rodauth
|
|
72
71
|
<% end %>
|
|
@@ -5,14 +5,14 @@ module Config
|
|
|
5
5
|
secret: ENV["SESSION_SECRET"] || 'DEV-ONLY-8<FQF8HiF)>l0hbPk£vBQ#IrYsoO}14k\l+-/gIU[j}l0hbPk£vBQ#IrY',
|
|
6
6
|
environment:,<% if context.rodauth? %>
|
|
7
7
|
hmac_secret: ENV["RODAUTH_HMAC_SECRET"] || 'DEV-ONLY',
|
|
8
|
-
jwt_secret: ENV["JWT_SECRET"] || 'DEV-ONLY'
|
|
8
|
+
jwt_secret: ENV["JWT_SECRET"] || 'DEV-ONLY',<% end %><% if context.fullstack? %>
|
|
9
9
|
i18n: {
|
|
10
|
-
translations: ["
|
|
10
|
+
translations: [File.expand_path("locales", __dir__)],
|
|
11
11
|
locale: ["en", "pt-br"]
|
|
12
|
-
}
|
|
12
|
+
},<% end %><% if context.database? %>
|
|
13
13
|
db: {
|
|
14
14
|
url: not_production? ? <%= context.default_db_url %> : ENV["DATABASE_URL"]
|
|
15
|
-
}
|
|
15
|
+
},<% end %><% if context.fullstack? %>
|
|
16
16
|
render: {
|
|
17
17
|
layout: "./layout",
|
|
18
18
|
assume_fixed_locals: true, # Optimize plugin by assuming all templates use fixed locals
|
|
@@ -39,34 +39,29 @@ class Db < Thor
|
|
|
39
39
|
[:drop, :create].each do |action|
|
|
40
40
|
desc action.to_s, "#{action.capitalize} the database"
|
|
41
41
|
define_method(action) do
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
PG::Connection
|
|
46
|
-
.conninfo_parse(Config.get[:db][:url])
|
|
47
|
-
.each_with_object({}) { |h, o|
|
|
48
|
-
o[h[:keyword].to_sym] = h[:val] if h[:val]
|
|
49
|
-
}
|
|
50
|
-
ok = system("PGPASSWORD='#{db_config[:password]}' #{action}db -h #{db_config[:host]} -p #{db_config[:port]} -U #{db_confi
|
|
51
|
-
g[:user]} #{db_config[:dbname]}")<% end %><% if context.mysql? %>
|
|
42
|
+
require "<%= context.db_gem %>"
|
|
43
|
+
require "uri"
|
|
44
|
+
require_relative "../app/config/config"
|
|
52
45
|
uri = URI.parse(Config.get[:db][:url])
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
46
|
+
dbname = uri.path.to_s.delete_prefix("/")<% if context.postgresql? %>
|
|
47
|
+
env = {}
|
|
48
|
+
env["PGPASSWORD"] = uri.password if uri.password
|
|
49
|
+
args = ["#{action}db"]
|
|
50
|
+
args.push("-h", uri.host) if uri.host
|
|
51
|
+
args.push("-p", uri.port.to_s) if uri.port
|
|
52
|
+
args.push("-U", uri.user) if uri.user
|
|
53
|
+
args << dbname
|
|
54
|
+
ok = system(env, *args)<% end %><% if context.mysql? %>
|
|
60
55
|
sql = action == :create ?
|
|
61
|
-
|
|
62
|
-
|
|
56
|
+
"CREATE DATABASE IF NOT EXISTS `#{dbname}`;" :
|
|
57
|
+
"DROP DATABASE IF EXISTS `#{dbname}`;"
|
|
63
58
|
flags = []
|
|
64
|
-
flags << "-h#{
|
|
65
|
-
flags << "-P#{
|
|
66
|
-
flags << "-u#{
|
|
67
|
-
env = { "MYSQL_PWD" =>
|
|
59
|
+
flags << "-h#{uri.host}" if uri.host
|
|
60
|
+
flags << "-P#{uri.port}" if uri.port
|
|
61
|
+
flags << "-u#{uri.user}" if uri.user
|
|
62
|
+
env = { "MYSQL_PWD" => uri.password }.compact
|
|
68
63
|
ok = system(env, "mysql", *flags, "-e", sql)<% end %>
|
|
69
|
-
puts "* #{action} database #{
|
|
64
|
+
puts "* #{action} database #{dbname} ✓" if ok
|
|
70
65
|
end
|
|
71
66
|
end
|
|
72
67
|
<% end %>
|
|
@@ -4,7 +4,8 @@ describe "hello" do
|
|
|
4
4
|
it "test requests" do
|
|
5
5
|
get "/"<% if context.rodauth? %>
|
|
6
6
|
_(last_response.status).must_equal 302<% else %>
|
|
7
|
-
_(last_response.status).must_equal 200<%
|
|
7
|
+
_(last_response.status).must_equal 200<% if context.fullstack? %>
|
|
8
|
+
_(last_response.body).must_include "Hello world"<% end %><% end %>
|
|
8
9
|
end
|
|
9
10
|
<% if context.rodauth? %>
|
|
10
11
|
it "test models" do
|
|
@@ -4,7 +4,8 @@ describe "hello" do
|
|
|
4
4
|
it "test requests" do
|
|
5
5
|
get "/"<% if context.rodauth? %>
|
|
6
6
|
expect(last_response.status).to eq(302)<% else %>
|
|
7
|
-
expect(last_response.status).to eq(200)<%
|
|
7
|
+
expect(last_response.status).to eq(200)<% if context.fullstack? %>
|
|
8
|
+
expect(last_response.body).to include("Hello world")<% end %><% end %>
|
|
8
9
|
end
|
|
9
10
|
<% if context.rodauth? %>
|
|
10
11
|
it "test models" do
|
data/lib/roda/project/version.rb
CHANGED