tzispa 0.8.3 → 0.9.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/CHANGELOG.md +4 -0
- data/lib/tzispa/app.rb +4 -11
- data/lib/tzispa/{config/app_config.rb → app_config.rb} +0 -0
- data/lib/tzispa/commands/command.rb +1 -2
- data/lib/tzispa/commands/project.rb +2 -2
- data/lib/tzispa/commands/repository.rb +2 -2
- data/lib/tzispa/controller/base.rb +3 -3
- data/lib/tzispa/controller/http.rb +2 -1
- data/lib/tzispa/domain.rb +5 -1
- data/lib/tzispa/engine/rig/auth/basic_layout.rb +50 -0
- data/lib/tzispa/engine/rig/{auth_layout.rb → auth/session_layout.rb} +6 -4
- data/lib/tzispa/route_set.rb +23 -9
- data/lib/tzispa/server.rb +2 -2
- data/lib/tzispa/version.rb +1 -1
- data/tzispa.gemspec +7 -7
- metadata +49 -42
- data/lib/tzispa/config/base.rb +0 -17
- data/lib/tzispa/config/db_config.rb +0 -67
- data/lib/tzispa/config/environment.rb +0 -53
- data/lib/tzispa/config/rc.rb +0 -21
- data/lib/tzispa/config/yaml.rb +0 -23
- data/lib/tzispa/env.rb +0 -38
- data/lib/tzispa/environment.rb +0 -201
- data/lib/tzispa/tzisparc.rb +0 -66
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: d56df85ed27a10a1ea95fa328fafd0609edcc1ea65e506f8eb1f65769e7d5c47
|
4
|
+
data.tar.gz: 14e72d45df799982e624c41c1c26110f2cc1c36f128aab693f562d30f5d0e31d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b4b5633c0c9bba5425c9b314d301676c50165fd937a9779433e10ce69f6c569334713f713253a0322ef6c44eae39d33b76302ab622f8e33c0f43f28410ca1123
|
7
|
+
data.tar.gz: 4708778807c9260ad414a4a526b07864aba6a47c0edd6910e73cf62baa0e9457724152e109f76a072ddd6e4994ee35b5da01e4b28dc4d1492905354816d10f69
|
data/CHANGELOG.md
CHANGED
data/lib/tzispa/app.rb
CHANGED
@@ -5,7 +5,6 @@ require 'logger'
|
|
5
5
|
require 'i18n'
|
6
6
|
require 'tzispa/domain'
|
7
7
|
require 'tzispa/config/app_config'
|
8
|
-
require 'tzispa/config/db_config'
|
9
8
|
require 'tzispa/engine'
|
10
9
|
require 'tzispa_data'
|
11
10
|
|
@@ -16,6 +15,7 @@ module Tzispa
|
|
16
15
|
|
17
16
|
include Tzispa::Engine
|
18
17
|
|
18
|
+
# rubocop:disable Style/ClassVars
|
19
19
|
@@appmutex = Mutex.new
|
20
20
|
|
21
21
|
attr_reader :domain, :logger, :map_path, :engine, :routes
|
@@ -28,7 +28,6 @@ module Tzispa
|
|
28
28
|
__new__(*args, &block).tap { |app| add app }
|
29
29
|
end
|
30
30
|
|
31
|
-
# rubocop:disable Style/ClassVars
|
32
31
|
def applications
|
33
32
|
return __applications_container if @@appmutex.locked?
|
34
33
|
synchronize do
|
@@ -57,6 +56,7 @@ module Tzispa
|
|
57
56
|
@@applications ||= Hash.new { |_, key| raise UnknownApplication(key.to_s) }
|
58
57
|
end
|
59
58
|
end
|
59
|
+
# rubocop:enable Style/ClassVars
|
60
60
|
|
61
61
|
def initialize(appid, engine:, on: nil, &block)
|
62
62
|
@domain = Domain.new(appid)
|
@@ -74,7 +74,7 @@ module Tzispa
|
|
74
74
|
app.class.synchronize do
|
75
75
|
logging_setup
|
76
76
|
locales_setup
|
77
|
-
|
77
|
+
Data::Repository.load!(domain)
|
78
78
|
domain.setup
|
79
79
|
routes_setup
|
80
80
|
end
|
@@ -86,20 +86,13 @@ module Tzispa
|
|
86
86
|
end
|
87
87
|
|
88
88
|
def env
|
89
|
-
|
89
|
+
Environment.instance
|
90
90
|
end
|
91
91
|
|
92
92
|
def config
|
93
93
|
@config ||= Config::AppConfig.new(@domain).load!
|
94
94
|
end
|
95
95
|
|
96
|
-
def repository
|
97
|
-
@repository ||= begin
|
98
|
-
dbcfg = Config::DbConfig.new(env.environment)&.to_h
|
99
|
-
Data::Repository.new(dbcfg) if dbcfg&.count&.positive?
|
100
|
-
end
|
101
|
-
end
|
102
|
-
|
103
96
|
private
|
104
97
|
|
105
98
|
def routes_setup
|
File without changes
|
@@ -1,12 +1,11 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require '
|
3
|
+
require 'tzispa_config'
|
4
4
|
|
5
5
|
module Tzispa
|
6
6
|
module Commands
|
7
7
|
|
8
8
|
class Command
|
9
|
-
|
10
9
|
NO_PROJECT_FOLDER = 'You must be located in a Tzispa project folder to run this command'
|
11
10
|
|
12
11
|
def initialize(options)
|
@@ -5,7 +5,7 @@ require 'base64'
|
|
5
5
|
require 'zlib'
|
6
6
|
require 'pathname'
|
7
7
|
require 'tzispa/tzisparc'
|
8
|
-
require '
|
8
|
+
require 'tzispa_config'
|
9
9
|
require 'tzispa_helpers'
|
10
10
|
require 'tzispa/commands/helpers/project'
|
11
11
|
require 'tzispa/commands/helpers/i18n'
|
@@ -92,7 +92,7 @@ module Tzispa
|
|
92
92
|
end
|
93
93
|
|
94
94
|
def generate_database_config
|
95
|
-
Tzispa::Config
|
95
|
+
Tzispa::Data::Config.create_default name
|
96
96
|
end
|
97
97
|
|
98
98
|
def generate_boot
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require 'tzispa/config
|
3
|
+
require 'tzispa/data/config'
|
4
4
|
require 'tzispa/commands/helpers/repository'
|
5
5
|
|
6
6
|
module Tzispa
|
@@ -19,7 +19,7 @@ module Tzispa
|
|
19
19
|
|
20
20
|
def generate
|
21
21
|
return unless generate_structure
|
22
|
-
Tzispa::Config
|
22
|
+
Tzispa::Data::Config.add_repository(name, adapter, database)
|
23
23
|
return unless (db = Sequel.connect "#{adapter}://#{database}")
|
24
24
|
tables = db.tables
|
25
25
|
generate_models tables
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'tzispa_helpers'
|
4
|
-
require '
|
4
|
+
require 'tzispa_config'
|
5
5
|
require 'tzispa/context'
|
6
6
|
|
7
7
|
module Tzispa
|
@@ -28,11 +28,11 @@ module Tzispa
|
|
28
28
|
private
|
29
29
|
|
30
30
|
def invoke
|
31
|
-
catch(:halt)
|
31
|
+
catch(:halt) do
|
32
32
|
do_before
|
33
33
|
send callmethod
|
34
34
|
do_after
|
35
|
-
|
35
|
+
end
|
36
36
|
end
|
37
37
|
|
38
38
|
end
|
data/lib/tzispa/domain.rb
CHANGED
@@ -12,7 +12,7 @@ module Tzispa
|
|
12
12
|
def initialize(name)
|
13
13
|
@name = name
|
14
14
|
@root = "#{Tzispa::Environment.instance.root}/#{Tzispa::Environment.instance.apps_path}"
|
15
|
-
instance_eval "module ::#{name.to_s.capitalize}; end"
|
15
|
+
instance_eval "module ::#{name.to_s.capitalize}; end", __FILE__, __LINE__
|
16
16
|
end
|
17
17
|
|
18
18
|
def setup
|
@@ -27,6 +27,10 @@ module Tzispa
|
|
27
27
|
@path ||= root % name.to_s.downcase
|
28
28
|
end
|
29
29
|
|
30
|
+
def exist?(file)
|
31
|
+
File.exist? "#{path}/#{file}"
|
32
|
+
end
|
33
|
+
|
30
34
|
def require(file)
|
31
35
|
Kernel.require "#{path}/#{file}"
|
32
36
|
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'tzispa/engine/rig/layout'
|
4
|
+
require 'tzispa_helpers'
|
5
|
+
|
6
|
+
module Tzispa
|
7
|
+
module Engine
|
8
|
+
module Rig
|
9
|
+
module Auth
|
10
|
+
|
11
|
+
class BasicLayout < Tzispa::Engine::Rig::Layout
|
12
|
+
before :do_auth
|
13
|
+
|
14
|
+
def do_auth
|
15
|
+
# if settings.environment == :production
|
16
|
+
# unless (@env['HTTP_X_FORWARDED_PROTO'] || @env['rack.url_scheme']) == 'https'
|
17
|
+
# redirect "https://#{request.env['HTTP_HOST']}#{request.env['REQUEST_PATH']}"
|
18
|
+
# end
|
19
|
+
# end
|
20
|
+
protected!
|
21
|
+
end
|
22
|
+
|
23
|
+
private
|
24
|
+
|
25
|
+
def protected!
|
26
|
+
return if authorized?
|
27
|
+
response['WWW-Authenticate'] = %(Basic realm="Testing HTTP Auth")
|
28
|
+
throw(:halt, [401, 'Not authorized'])
|
29
|
+
end
|
30
|
+
|
31
|
+
def auth
|
32
|
+
@auth ||= Rack::Auth::Basic::Request.new(request.env)
|
33
|
+
end
|
34
|
+
|
35
|
+
def authorized?
|
36
|
+
auth.provided? &&
|
37
|
+
auth.basic? &&
|
38
|
+
auth.credentials &&
|
39
|
+
auth.credentials == allowed_authorization
|
40
|
+
end
|
41
|
+
|
42
|
+
def allowed_authorization
|
43
|
+
@allowed_authorization ||= [config.auth.basic.user, config.auth.basic.password].freeze
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
@@ -6,13 +6,15 @@ require 'tzispa_helpers'
|
|
6
6
|
module Tzispa
|
7
7
|
module Engine
|
8
8
|
module Rig
|
9
|
+
module Auth
|
9
10
|
|
10
|
-
|
11
|
-
|
11
|
+
class SessionLayout < Tzispa::Engine::Rig::Layout
|
12
|
+
include Tzispa::Helpers::SessionAuth
|
12
13
|
|
13
|
-
|
14
|
-
|
14
|
+
before :login_redirect
|
15
|
+
end
|
15
16
|
|
17
|
+
end
|
16
18
|
end
|
17
19
|
end
|
18
20
|
end
|
data/lib/tzispa/route_set.rb
CHANGED
@@ -76,15 +76,29 @@ module Tzispa
|
|
76
76
|
end
|
77
77
|
|
78
78
|
def controller_class(mpath)
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
79
|
+
name = mpath.pop
|
80
|
+
"#{require_controller(mpath, name)}::#{name.camelize}".constantize
|
81
|
+
end
|
82
|
+
|
83
|
+
def require_controller(mpath, name)
|
84
|
+
app_controller(mpath, name) || tz_controller(mpath, name)
|
85
|
+
end
|
86
|
+
|
87
|
+
def app_controller(mpath, name)
|
88
|
+
ac = "controller/#{mpath.join('/')}/#{name}"
|
89
|
+
return unless app.domain.exist? ac
|
90
|
+
app.domain.require ac
|
91
|
+
mpath.collect(&:capitalize).join('::')
|
92
|
+
end
|
93
|
+
|
94
|
+
def tz_controller(mpath, name)
|
95
|
+
if mpath.count.positive?
|
96
|
+
require "#{ctl_module.underscore}/#{mpath.join('/')}/#{name}"
|
97
|
+
[ctl_module, mpath.collect(&:capitalize).join('::')].join('::')
|
98
|
+
else
|
99
|
+
require "#{ctl_module.underscore}/#{name}"
|
100
|
+
ctl_module
|
101
|
+
end
|
88
102
|
end
|
89
103
|
end
|
90
104
|
|
data/lib/tzispa/server.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'rack'
|
4
|
-
require '
|
4
|
+
require 'tzispa_config'
|
5
5
|
|
6
6
|
module Tzispa
|
7
7
|
# provides rack-based web server interface
|
@@ -21,7 +21,7 @@ module Tzispa
|
|
21
21
|
private
|
22
22
|
|
23
23
|
def setup
|
24
|
-
instance_eval 'load "./config/boot.rb"'
|
24
|
+
instance_eval 'load "./config/boot.rb"', __FILE__, __LINE__
|
25
25
|
@app = if code_reloading?
|
26
26
|
puts 'Tzispa is booting server with code reloading'
|
27
27
|
Shotgun::Loader.new(rackup_file)
|
data/lib/tzispa/version.rb
CHANGED
data/tzispa.gemspec
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
# coding: utf-8
|
2
1
|
# frozen_string_literal: true
|
3
2
|
|
4
3
|
require File.expand_path('../lib/tzispa/version', __FILE__)
|
@@ -18,15 +17,16 @@ Gem::Specification.new do |s|
|
|
18
17
|
s.required_ruby_version = '~> 2.4'
|
19
18
|
|
20
19
|
s.add_dependency 'bundler', '~> 1.14'
|
21
|
-
s.add_dependency '
|
20
|
+
s.add_dependency 'dotenv', '~> 2.2'
|
21
|
+
s.add_dependency 'http_router', '~> 0.11.2'
|
22
22
|
s.add_dependency 'i18n', '~> 0.8.0'
|
23
|
+
s.add_dependency 'rack', '~> 2.0', '>= 2.0.1'
|
23
24
|
s.add_dependency 'thor', '~> 0.19.0'
|
24
|
-
s.add_dependency '
|
25
|
-
s.add_dependency '
|
26
|
-
s.add_dependency '
|
25
|
+
s.add_dependency 'tzispa_config', '~> 0.1.0'
|
26
|
+
s.add_dependency 'tzispa_data', '~> 0.5.0'
|
27
|
+
s.add_dependency 'tzispa_helpers', '~> 0.3.6'
|
27
28
|
s.add_dependency 'tzispa_rig', '~> 0.5.10'
|
28
|
-
s.add_dependency '
|
29
|
-
s.add_dependency 'dotenv', '~> 2.2'
|
29
|
+
s.add_dependency 'tzispa_utils', '~> 0.3.6'
|
30
30
|
|
31
31
|
s.add_development_dependency 'shotgun', '~> 0.9'
|
32
32
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tzispa
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.9.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Juan Antonio Piñero
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-12-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -25,25 +25,33 @@ dependencies:
|
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '1.14'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
|
-
name:
|
28
|
+
name: dotenv
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '2.
|
34
|
-
- - ">="
|
35
|
-
- !ruby/object:Gem::Version
|
36
|
-
version: 2.0.1
|
33
|
+
version: '2.2'
|
37
34
|
type: :runtime
|
38
35
|
prerelease: false
|
39
36
|
version_requirements: !ruby/object:Gem::Requirement
|
40
37
|
requirements:
|
41
38
|
- - "~>"
|
42
39
|
- !ruby/object:Gem::Version
|
43
|
-
version: '2.
|
44
|
-
|
40
|
+
version: '2.2'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: http_router
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
45
46
|
- !ruby/object:Gem::Version
|
46
|
-
version:
|
47
|
+
version: 0.11.2
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 0.11.2
|
47
55
|
- !ruby/object:Gem::Dependency
|
48
56
|
name: i18n
|
49
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -59,103 +67,109 @@ dependencies:
|
|
59
67
|
- !ruby/object:Gem::Version
|
60
68
|
version: 0.8.0
|
61
69
|
- !ruby/object:Gem::Dependency
|
62
|
-
name:
|
70
|
+
name: rack
|
63
71
|
requirement: !ruby/object:Gem::Requirement
|
64
72
|
requirements:
|
65
73
|
- - "~>"
|
66
74
|
- !ruby/object:Gem::Version
|
67
|
-
version:
|
75
|
+
version: '2.0'
|
76
|
+
- - ">="
|
77
|
+
- !ruby/object:Gem::Version
|
78
|
+
version: 2.0.1
|
68
79
|
type: :runtime
|
69
80
|
prerelease: false
|
70
81
|
version_requirements: !ruby/object:Gem::Requirement
|
71
82
|
requirements:
|
72
83
|
- - "~>"
|
73
84
|
- !ruby/object:Gem::Version
|
74
|
-
version:
|
85
|
+
version: '2.0'
|
86
|
+
- - ">="
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
version: 2.0.1
|
75
89
|
- !ruby/object:Gem::Dependency
|
76
|
-
name:
|
90
|
+
name: thor
|
77
91
|
requirement: !ruby/object:Gem::Requirement
|
78
92
|
requirements:
|
79
93
|
- - "~>"
|
80
94
|
- !ruby/object:Gem::Version
|
81
|
-
version: 0.
|
95
|
+
version: 0.19.0
|
82
96
|
type: :runtime
|
83
97
|
prerelease: false
|
84
98
|
version_requirements: !ruby/object:Gem::Requirement
|
85
99
|
requirements:
|
86
100
|
- - "~>"
|
87
101
|
- !ruby/object:Gem::Version
|
88
|
-
version: 0.
|
102
|
+
version: 0.19.0
|
89
103
|
- !ruby/object:Gem::Dependency
|
90
|
-
name:
|
104
|
+
name: tzispa_config
|
91
105
|
requirement: !ruby/object:Gem::Requirement
|
92
106
|
requirements:
|
93
107
|
- - "~>"
|
94
108
|
- !ruby/object:Gem::Version
|
95
|
-
version: 0.
|
109
|
+
version: 0.1.0
|
96
110
|
type: :runtime
|
97
111
|
prerelease: false
|
98
112
|
version_requirements: !ruby/object:Gem::Requirement
|
99
113
|
requirements:
|
100
114
|
- - "~>"
|
101
115
|
- !ruby/object:Gem::Version
|
102
|
-
version: 0.
|
116
|
+
version: 0.1.0
|
103
117
|
- !ruby/object:Gem::Dependency
|
104
|
-
name:
|
118
|
+
name: tzispa_data
|
105
119
|
requirement: !ruby/object:Gem::Requirement
|
106
120
|
requirements:
|
107
121
|
- - "~>"
|
108
122
|
- !ruby/object:Gem::Version
|
109
|
-
version: 0.
|
123
|
+
version: 0.5.0
|
110
124
|
type: :runtime
|
111
125
|
prerelease: false
|
112
126
|
version_requirements: !ruby/object:Gem::Requirement
|
113
127
|
requirements:
|
114
128
|
- - "~>"
|
115
129
|
- !ruby/object:Gem::Version
|
116
|
-
version: 0.
|
130
|
+
version: 0.5.0
|
117
131
|
- !ruby/object:Gem::Dependency
|
118
|
-
name:
|
132
|
+
name: tzispa_helpers
|
119
133
|
requirement: !ruby/object:Gem::Requirement
|
120
134
|
requirements:
|
121
135
|
- - "~>"
|
122
136
|
- !ruby/object:Gem::Version
|
123
|
-
version: 0.
|
137
|
+
version: 0.3.6
|
124
138
|
type: :runtime
|
125
139
|
prerelease: false
|
126
140
|
version_requirements: !ruby/object:Gem::Requirement
|
127
141
|
requirements:
|
128
142
|
- - "~>"
|
129
143
|
- !ruby/object:Gem::Version
|
130
|
-
version: 0.
|
144
|
+
version: 0.3.6
|
131
145
|
- !ruby/object:Gem::Dependency
|
132
|
-
name:
|
146
|
+
name: tzispa_rig
|
133
147
|
requirement: !ruby/object:Gem::Requirement
|
134
148
|
requirements:
|
135
149
|
- - "~>"
|
136
150
|
- !ruby/object:Gem::Version
|
137
|
-
version: 0.
|
151
|
+
version: 0.5.10
|
138
152
|
type: :runtime
|
139
153
|
prerelease: false
|
140
154
|
version_requirements: !ruby/object:Gem::Requirement
|
141
155
|
requirements:
|
142
156
|
- - "~>"
|
143
157
|
- !ruby/object:Gem::Version
|
144
|
-
version: 0.
|
158
|
+
version: 0.5.10
|
145
159
|
- !ruby/object:Gem::Dependency
|
146
|
-
name:
|
160
|
+
name: tzispa_utils
|
147
161
|
requirement: !ruby/object:Gem::Requirement
|
148
162
|
requirements:
|
149
163
|
- - "~>"
|
150
164
|
- !ruby/object:Gem::Version
|
151
|
-
version:
|
165
|
+
version: 0.3.6
|
152
166
|
type: :runtime
|
153
167
|
prerelease: false
|
154
168
|
version_requirements: !ruby/object:Gem::Requirement
|
155
169
|
requirements:
|
156
170
|
- - "~>"
|
157
171
|
- !ruby/object:Gem::Version
|
158
|
-
version:
|
172
|
+
version: 0.3.6
|
159
173
|
- !ruby/object:Gem::Dependency
|
160
174
|
name: shotgun
|
161
175
|
requirement: !ruby/object:Gem::Requirement
|
@@ -184,6 +198,7 @@ files:
|
|
184
198
|
- bin/tzispa
|
185
199
|
- lib/tzispa.rb
|
186
200
|
- lib/tzispa/app.rb
|
201
|
+
- lib/tzispa/app_config.rb
|
187
202
|
- lib/tzispa/bin/tzispa
|
188
203
|
- lib/tzispa/cli.rb
|
189
204
|
- lib/tzispa/commands/api.rb
|
@@ -198,12 +213,6 @@ files:
|
|
198
213
|
- lib/tzispa/commands/repository.rb
|
199
214
|
- lib/tzispa/commands/rig.rb
|
200
215
|
- lib/tzispa/commands/server.rb
|
201
|
-
- lib/tzispa/config/app_config.rb
|
202
|
-
- lib/tzispa/config/base.rb
|
203
|
-
- lib/tzispa/config/db_config.rb
|
204
|
-
- lib/tzispa/config/environment.rb
|
205
|
-
- lib/tzispa/config/rc.rb
|
206
|
-
- lib/tzispa/config/yaml.rb
|
207
216
|
- lib/tzispa/context.rb
|
208
217
|
- lib/tzispa/controller/base.rb
|
209
218
|
- lib/tzispa/controller/exceptions.rb
|
@@ -212,18 +221,16 @@ files:
|
|
212
221
|
- lib/tzispa/domain.rb
|
213
222
|
- lib/tzispa/engine.rb
|
214
223
|
- lib/tzispa/engine/rig/api.rb
|
215
|
-
- lib/tzispa/engine/rig/
|
224
|
+
- lib/tzispa/engine/rig/auth/basic_layout.rb
|
225
|
+
- lib/tzispa/engine/rig/auth/session_layout.rb
|
216
226
|
- lib/tzispa/engine/rig/context.rb
|
217
227
|
- lib/tzispa/engine/rig/layout.rb
|
218
228
|
- lib/tzispa/engine/rig/router.rb
|
219
|
-
- lib/tzispa/env.rb
|
220
|
-
- lib/tzispa/environment.rb
|
221
229
|
- lib/tzispa/http/context.rb
|
222
230
|
- lib/tzispa/http/request.rb
|
223
231
|
- lib/tzispa/http/response.rb
|
224
232
|
- lib/tzispa/route_set.rb
|
225
233
|
- lib/tzispa/server.rb
|
226
|
-
- lib/tzispa/tzisparc.rb
|
227
234
|
- lib/tzispa/version.rb
|
228
235
|
- tzispa.gemspec
|
229
236
|
homepage: https://github.com/japiber/tzispa
|
@@ -246,7 +253,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
246
253
|
version: '0'
|
247
254
|
requirements: []
|
248
255
|
rubyforge_project:
|
249
|
-
rubygems_version: 2.
|
256
|
+
rubygems_version: 2.7.3
|
250
257
|
signing_key:
|
251
258
|
specification_version: 4
|
252
259
|
summary: A sparkling web framework
|
data/lib/tzispa/config/base.rb
DELETED
@@ -1,17 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'ostruct'
|
4
|
-
|
5
|
-
module Tzispa
|
6
|
-
module Config
|
7
|
-
|
8
|
-
class Base < Struct
|
9
|
-
def self.parametrize(params)
|
10
|
-
new(*params&.keys&.map(&:to_sym)).new(*(params&.values&.map do |v|
|
11
|
-
v.is_a?(Hash) ? parametrize(v) : v
|
12
|
-
end))
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
end
|
17
|
-
end
|
@@ -1,67 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'tzispa/config/yaml'
|
4
|
-
|
5
|
-
module Tzispa
|
6
|
-
module Config
|
7
|
-
|
8
|
-
class DbConfig
|
9
|
-
attr_reader :env, :config
|
10
|
-
|
11
|
-
CONFIG_FILENAME = 'database'
|
12
|
-
|
13
|
-
def initialize(env)
|
14
|
-
@cftime = nil
|
15
|
-
@env = env.to_sym
|
16
|
-
end
|
17
|
-
|
18
|
-
def to_h
|
19
|
-
load!
|
20
|
-
config.to_h[env]&.to_h
|
21
|
-
end
|
22
|
-
|
23
|
-
def load!
|
24
|
-
if @cftime.nil?
|
25
|
-
@cftime = File.ctime(filename)
|
26
|
-
elsif @cftime != File.ctime(filename)
|
27
|
-
@config = nil
|
28
|
-
@cftime = File.ctime(filename)
|
29
|
-
end
|
30
|
-
@config ||= Tzispa::Config::Yaml.load(filename)
|
31
|
-
end
|
32
|
-
|
33
|
-
def filename
|
34
|
-
DbConfig.filename
|
35
|
-
end
|
36
|
-
|
37
|
-
class << self
|
38
|
-
def filename
|
39
|
-
@filename ||= "config/#{CONFIG_FILENAME}.yml"
|
40
|
-
end
|
41
|
-
|
42
|
-
def create_default(path)
|
43
|
-
hcfg = {}.tap do |cfg|
|
44
|
-
cfg['development'] = ''
|
45
|
-
cfg['deployment'] = ''
|
46
|
-
cfg['test'] = ''
|
47
|
-
end
|
48
|
-
Yaml.save(hcfg, File.join(path, filename))
|
49
|
-
end
|
50
|
-
|
51
|
-
def add_repository(name, adapter, dbconn)
|
52
|
-
hs = YAML.safe_load(File.open(filename))
|
53
|
-
hs.each do |_, v|
|
54
|
-
v[name] = {
|
55
|
-
'adapter' => adapter,
|
56
|
-
'database' => dbconn,
|
57
|
-
'connection_validation' => 'No',
|
58
|
-
'local' => 'Yes'
|
59
|
-
}
|
60
|
-
end
|
61
|
-
Yaml.save(hs, filename)
|
62
|
-
end
|
63
|
-
end
|
64
|
-
end
|
65
|
-
|
66
|
-
end
|
67
|
-
end
|
@@ -1,53 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Tzispa
|
4
|
-
module Config
|
5
|
-
module Environment
|
6
|
-
|
7
|
-
RACK_ENV = 'RACK_ENV'
|
8
|
-
|
9
|
-
TZISPA_ENV = 'TZISPA_ENV'
|
10
|
-
|
11
|
-
DEVELOPMENT_ENV = 'development'
|
12
|
-
|
13
|
-
DEFAULT_ENV = 'development'
|
14
|
-
|
15
|
-
PRODUCTION_ENV = 'deployment'
|
16
|
-
|
17
|
-
RACK_ENV_DEPLOYMENT = 'deployment'
|
18
|
-
|
19
|
-
DEFAULT_DOTENV_ENV = '.env.%s'
|
20
|
-
|
21
|
-
DEFAULT_CONFIG = 'config'
|
22
|
-
|
23
|
-
TZISPA_HOST = 'TZISPA_HOST'
|
24
|
-
|
25
|
-
TZISPA_SSL = 'TZISPA_SSL'
|
26
|
-
|
27
|
-
TZISPA_SERVER_HOST = 'TZISPA_SERVER_HOST'
|
28
|
-
|
29
|
-
DEFAULT_HOST = 'localhost'
|
30
|
-
|
31
|
-
TZISPA_PORT = 'TZISPA_PORT'
|
32
|
-
|
33
|
-
TZISPA_SERVER_PORT = 'TZISPA_SERVER_PORT'
|
34
|
-
|
35
|
-
DEFAULT_PORT = 9412
|
36
|
-
|
37
|
-
DEFAULT_RACKUP = 'tzispa.ru'
|
38
|
-
|
39
|
-
DEFAULT_ENVIRONMENT_CONFIG = 'environment'
|
40
|
-
|
41
|
-
DEFAULT_DOMAINS_PATH = 'apps'
|
42
|
-
|
43
|
-
DOMAINS = 'domains'
|
44
|
-
|
45
|
-
DOMAINS_PATH = 'apps/%s'
|
46
|
-
|
47
|
-
APPLICATION = 'application'
|
48
|
-
|
49
|
-
APPLICATION_PATH = 'app'
|
50
|
-
|
51
|
-
end
|
52
|
-
end
|
53
|
-
end
|
data/lib/tzispa/config/rc.rb
DELETED
@@ -1,21 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Tzispa
|
4
|
-
module Config
|
5
|
-
module Rc
|
6
|
-
|
7
|
-
DEFAULT_ARCHITECTURE = 'domains'
|
8
|
-
|
9
|
-
APP_ARCHITECTURE = 'app'
|
10
|
-
|
11
|
-
ARCHITECTURE_KEY = 'architecture'
|
12
|
-
|
13
|
-
PROJECT_NAME = 'project'
|
14
|
-
|
15
|
-
DEFAULT_TEST_SUITE = 'minitest'
|
16
|
-
|
17
|
-
TEST_KEY = 'test'
|
18
|
-
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
data/lib/tzispa/config/yaml.rb
DELETED
@@ -1,23 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'yaml'
|
4
|
-
require 'tzispa/config/base'
|
5
|
-
|
6
|
-
module Tzispa
|
7
|
-
module Config
|
8
|
-
|
9
|
-
class Yaml < Tzispa::Config::Base
|
10
|
-
def self.load(filename)
|
11
|
-
params = YAML.safe_load(File.open(filename))
|
12
|
-
parametrize params
|
13
|
-
end
|
14
|
-
|
15
|
-
def self.save(cfg, filename)
|
16
|
-
File.open(filename, 'w') do |f|
|
17
|
-
f.write cfg.to_yaml
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
end
|
23
|
-
end
|
data/lib/tzispa/env.rb
DELETED
@@ -1,38 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'dotenv'
|
4
|
-
|
5
|
-
module Tzispa
|
6
|
-
|
7
|
-
class Env
|
8
|
-
def initialize(env: ENV)
|
9
|
-
@env = env
|
10
|
-
end
|
11
|
-
|
12
|
-
def [](key)
|
13
|
-
@env[key]
|
14
|
-
end
|
15
|
-
|
16
|
-
def []=(key, value)
|
17
|
-
@env[key] = value
|
18
|
-
end
|
19
|
-
|
20
|
-
def key?(key)
|
21
|
-
@env.key? key
|
22
|
-
end
|
23
|
-
|
24
|
-
def load!(path)
|
25
|
-
return unless defined?(Dotenv)
|
26
|
-
|
27
|
-
contents = ::File.open(path, 'rb:bom|utf-8', &:read)
|
28
|
-
parsed = Dotenv::Parser.call(contents)
|
29
|
-
|
30
|
-
parsed.each do |k, v|
|
31
|
-
next if @env.key?(k)
|
32
|
-
@env[k] = v
|
33
|
-
end
|
34
|
-
nil
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
end
|
data/lib/tzispa/environment.rb
DELETED
@@ -1,201 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'thread'
|
4
|
-
require 'pathname'
|
5
|
-
require 'singleton'
|
6
|
-
require 'tzispa/env'
|
7
|
-
require 'tzispa/tzisparc'
|
8
|
-
require 'tzispa_utils'
|
9
|
-
require 'tzispa/config/environment'
|
10
|
-
|
11
|
-
module Tzispa
|
12
|
-
|
13
|
-
class Environment
|
14
|
-
include Singleton
|
15
|
-
include Tzispa::Config::Environment
|
16
|
-
using Tzispa::Utils::TzHash
|
17
|
-
|
18
|
-
LOCK = Mutex.new
|
19
|
-
|
20
|
-
# rubocop:disable Style/ClassVars
|
21
|
-
@@opts = {}
|
22
|
-
|
23
|
-
def initialize
|
24
|
-
@env = Tzispa::Env.new(env: @@opts.delete(:env) || ENV)
|
25
|
-
@options = Tzispa::Tzisparc.new(root).options
|
26
|
-
@options.merge! @@opts.clone.symbolize!
|
27
|
-
LOCK.synchronize { set_env_vars! }
|
28
|
-
end
|
29
|
-
|
30
|
-
class << self
|
31
|
-
def opts=(hash)
|
32
|
-
@@opts = hash.to_h.dup
|
33
|
-
end
|
34
|
-
|
35
|
-
def [](key)
|
36
|
-
instance[key]
|
37
|
-
end
|
38
|
-
|
39
|
-
def method_missing(name, *args, &block)
|
40
|
-
if instance.respond_to? name
|
41
|
-
instance.send name, *args, &block
|
42
|
-
elsif instance.key? ekup = name.to_s.upcase
|
43
|
-
instance[ekup]
|
44
|
-
else
|
45
|
-
super
|
46
|
-
end
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
|
-
def [](key)
|
51
|
-
@env[key]
|
52
|
-
end
|
53
|
-
|
54
|
-
def key?(key)
|
55
|
-
@env.key? key
|
56
|
-
end
|
57
|
-
|
58
|
-
def environment
|
59
|
-
@environment ||= env[TZISPA_ENV] || rack_env || DEFAULT_ENV
|
60
|
-
end
|
61
|
-
|
62
|
-
def development?
|
63
|
-
environment == DEVELOPMENT_ENV
|
64
|
-
end
|
65
|
-
|
66
|
-
def code_reloading?
|
67
|
-
development?
|
68
|
-
end
|
69
|
-
|
70
|
-
def environment?(*names)
|
71
|
-
names.map(&:to_s).include?(environment)
|
72
|
-
end
|
73
|
-
|
74
|
-
def bundler_groups
|
75
|
-
[:default, environment.to_sym]
|
76
|
-
end
|
77
|
-
|
78
|
-
def root
|
79
|
-
@root ||= Pathname.new(Dir.pwd)
|
80
|
-
end
|
81
|
-
|
82
|
-
def config
|
83
|
-
@config ||= root.join(@options.fetch(:config) { DEFAULT_CONFIG })
|
84
|
-
end
|
85
|
-
|
86
|
-
def project_name
|
87
|
-
@options.fetch(:project)
|
88
|
-
end
|
89
|
-
|
90
|
-
def architecture
|
91
|
-
@options.fetch(:architecture) do
|
92
|
-
warn "Tzispa architecture unknown: see `.tzisparc'"
|
93
|
-
exit 1
|
94
|
-
end
|
95
|
-
end
|
96
|
-
|
97
|
-
def apps_path
|
98
|
-
@options.fetch(:path) do
|
99
|
-
case architecture
|
100
|
-
when DOMAINS
|
101
|
-
DOMAINS_PATH
|
102
|
-
when APPLICATION
|
103
|
-
APPLICATION_PATH
|
104
|
-
end
|
105
|
-
end
|
106
|
-
end
|
107
|
-
|
108
|
-
def host
|
109
|
-
@host ||= @options.fetch(:host) do
|
110
|
-
env[TZISPA_HOST] || DEFAULT_HOST
|
111
|
-
end
|
112
|
-
end
|
113
|
-
|
114
|
-
def server_host
|
115
|
-
@server_host ||= @options.fetch(:server_host) do
|
116
|
-
env[TZISPA_SERVER_HOST] || host
|
117
|
-
end
|
118
|
-
end
|
119
|
-
|
120
|
-
def port
|
121
|
-
@port ||= @options.fetch(:port) do
|
122
|
-
env[TZISPA_PORT] || DEFAULT_PORT
|
123
|
-
end.to_i
|
124
|
-
end
|
125
|
-
|
126
|
-
def server_port
|
127
|
-
@server_port ||= @options.fetch(:server_port) do
|
128
|
-
env[TZISPA_SERVER_PORT] || port
|
129
|
-
end.to_i
|
130
|
-
end
|
131
|
-
|
132
|
-
def uri_port
|
133
|
-
if ssl?
|
134
|
-
":#{port}" unless port == 443
|
135
|
-
else
|
136
|
-
":#{port}" unless port == 80
|
137
|
-
end
|
138
|
-
end
|
139
|
-
|
140
|
-
def domains_path
|
141
|
-
@domains_path ||= @options.fetch(:domains_path) do
|
142
|
-
env[DOMAINS_PATH] || DEFAULT_DOMAINS_PATH
|
143
|
-
end
|
144
|
-
end
|
145
|
-
|
146
|
-
def default_port?
|
147
|
-
port == DEFAULT_PORT
|
148
|
-
end
|
149
|
-
|
150
|
-
def ssl?
|
151
|
-
env[TZISPA_SSL] == 'yes'
|
152
|
-
end
|
153
|
-
|
154
|
-
def rackup
|
155
|
-
root.join(@options.fetch(:rackup) { DEFAULT_RACKUP })
|
156
|
-
end
|
157
|
-
|
158
|
-
def daemonize?
|
159
|
-
@options.key?(:daemonize) && @options.fetch(:daemonize)
|
160
|
-
end
|
161
|
-
|
162
|
-
def to_options
|
163
|
-
@options.to_h.merge(
|
164
|
-
environment: environment,
|
165
|
-
apps_path: apps_path,
|
166
|
-
rackup: rackup,
|
167
|
-
host: server_host,
|
168
|
-
port: server_port
|
169
|
-
)
|
170
|
-
end
|
171
|
-
|
172
|
-
private
|
173
|
-
|
174
|
-
attr_reader :env
|
175
|
-
|
176
|
-
def set_env_vars!
|
177
|
-
set_application_env_vars!
|
178
|
-
set_tzispa_env_vars!
|
179
|
-
end
|
180
|
-
|
181
|
-
def set_tzispa_env_vars!
|
182
|
-
env[TZISPA_ENV] = env[RACK_ENV] = environment
|
183
|
-
env[TZISPA_HOST] = host
|
184
|
-
env[TZISPA_PORT] = port.to_s
|
185
|
-
end
|
186
|
-
|
187
|
-
def set_application_env_vars!
|
188
|
-
dotenv = root.join(DEFAULT_DOTENV_ENV % environment)
|
189
|
-
env.load!(dotenv) if dotenv.exist?
|
190
|
-
end
|
191
|
-
|
192
|
-
def rack_env
|
193
|
-
case env[RACK_ENV]
|
194
|
-
when RACK_ENV_DEPLOYMENT
|
195
|
-
PRODUCTION_ENV
|
196
|
-
else
|
197
|
-
env[RACK_ENV]
|
198
|
-
end
|
199
|
-
end
|
200
|
-
end
|
201
|
-
end
|
data/lib/tzispa/tzisparc.rb
DELETED
@@ -1,66 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'pathname'
|
4
|
-
require 'tzispa_utils'
|
5
|
-
require 'tzispa/config/rc'
|
6
|
-
|
7
|
-
module Tzispa
|
8
|
-
|
9
|
-
class Tzisparc
|
10
|
-
using Tzispa::Utils::TzHash
|
11
|
-
|
12
|
-
include Tzispa::Config::Rc
|
13
|
-
|
14
|
-
FILE_NAME = '.tzisparc'
|
15
|
-
|
16
|
-
SEPARATOR = '='
|
17
|
-
|
18
|
-
def initialize(root)
|
19
|
-
@root = root
|
20
|
-
end
|
21
|
-
|
22
|
-
def options
|
23
|
-
@options ||= default_options.merge(file_options).symbolize!
|
24
|
-
end
|
25
|
-
|
26
|
-
def default_options
|
27
|
-
@default_options ||= { ARCHITECTURE_KEY => DEFAULT_ARCHITECTURE,
|
28
|
-
PROJECT_NAME => project_name,
|
29
|
-
TEST_KEY => DEFAULT_TEST_SUITE }
|
30
|
-
end
|
31
|
-
|
32
|
-
def exists?
|
33
|
-
path_file.exist?
|
34
|
-
end
|
35
|
-
|
36
|
-
def generate
|
37
|
-
File.open(path_file, 'w') do |file|
|
38
|
-
default_options.each { |k, v| file.puts("#{k}#{SEPARATOR}#{v}") }
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
private
|
43
|
-
|
44
|
-
def file_options
|
45
|
-
exists? ? parse_file(path_file) : {}
|
46
|
-
end
|
47
|
-
|
48
|
-
def parse_file(path)
|
49
|
-
{}.tap do |hash|
|
50
|
-
File.readlines(path).each do |line|
|
51
|
-
key, value = line.split(SEPARATOR)
|
52
|
-
hash[key] = value.strip
|
53
|
-
end
|
54
|
-
end
|
55
|
-
end
|
56
|
-
|
57
|
-
def path_file
|
58
|
-
@root.join FILE_NAME
|
59
|
-
end
|
60
|
-
|
61
|
-
def project_name
|
62
|
-
::File.basename(@root)
|
63
|
-
end
|
64
|
-
end
|
65
|
-
|
66
|
-
end
|