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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3156e8ffc1fbf7c48c30c1224bfccd2bf66c775b90cb802ada325c2ef2a5607e
4
- data.tar.gz: 02e04e9cb18a32f82cad2fceb59f1d567d33fe61330f1f0a26bb6e38ebf3b618
3
+ metadata.gz: e03b5fbcad7831986b704d75c798fc85ea1874b5e63a8970ef876db89841978f
4
+ data.tar.gz: 1cb64c7f6c9b14c8fdcc31e0e841813c5eb92bb707899187053f4af534327136
5
5
  SHA512:
6
- metadata.gz: b2a91d0af7f801951d65f288a3fcbc0012b3779e6736dfdd94d7703377834cad15d8a8680293b1800a8293e90cfb59d8d3f971e1e67abedf682b32a432e9920a
7
- data.tar.gz: b80916d58cdd4a167f8be8a9e5e43f4c56730457818b6cfee081ac4946d1e353284c7b6d087f9d030a03d7a705426e78fe871610dd5438dfe3c1c9bb1d426563
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.hash_branches<% if context.fullstack? %>
68
- # session[:locale] = 'pt-br'
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'<% end %><% if context.fullstack? %>,
8
+ jwt_secret: ENV["JWT_SECRET"] || 'DEV-ONLY',<% end %><% if context.fullstack? %>
9
9
  i18n: {
10
- translations: ["app/config/locales", "app/config/locales/foo"],
10
+ translations: [File.expand_path("locales", __dir__)],
11
11
  locale: ["en", "pt-br"]
12
- }<% end %><% if context.database? %>,
12
+ },<% end %><% if context.database? %>
13
13
  db: {
14
14
  url: not_production? ? <%= context.default_db_url %> : ENV["DATABASE_URL"]
15
- }<% end %><% if context.fullstack? %>,
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
- require_db_deps
43
- require_relative "../app/config/config"<% if context.postgresql? %>
44
- db_config =
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
- db_config = {
54
- host: uri.host,
55
- port: uri.port,
56
- user: uri.user,
57
- password: uri.password,
58
- dbname: uri.path.tr('/', '') # removes leading slash
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
- "CREATE DATABASE IF NOT EXISTS `#{db_config[:dbname]}`;" :
62
- "DROP DATABASE IF EXISTS `#{db_config[:dbname]}`;"
56
+ "CREATE DATABASE IF NOT EXISTS `#{dbname}`;" :
57
+ "DROP DATABASE IF EXISTS `#{dbname}`;"
63
58
  flags = []
64
- flags << "-h#{db_config[:host]}" if db_config[:host]
65
- flags << "-P#{db_config[:port]}" if db_config[:port]
66
- flags << "-u#{db_config[:user]}" if db_config[:user]
67
- env = { "MYSQL_PWD" => db_config[:password] }.compact
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 #{db_config[:dbname]} ✓" if ok
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<% end %>
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)<% end %>
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
@@ -2,6 +2,6 @@
2
2
 
3
3
  class Roda
4
4
  module Project
5
- VERSION = "0.1.13"
5
+ VERSION = "0.1.14"
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: roda-project
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.13
4
+ version: 0.1.14
5
5
  platform: ruby
6
6
  authors:
7
7
  - Henrique F. Teixeira