lizarb 1.0.0 → 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.ruby-version +1 -1
- data/.tool-versions +1 -0
- data/Gemfile +2 -0
- data/Gemfile.lock +14 -3
- data/README.md +23 -64
- data/README_SYSTEMS.md +80 -0
- data/Rakefile +3 -1
- data/app/dev/benches/app_bench.rb +5 -0
- data/app/dev/benches/app_bench_test.rb +7 -0
- data/app/dev/benches/loops_bench.rb +183 -0
- data/app/dev/benches/loops_bench_test.rb +11 -0
- data/app/dev/commands/calculator_command.rb +69 -0
- data/app/dev/commands/calculator_command_test.rb +58 -0
- data/app/dev/commands/circle_command.rb +70 -0
- data/app/dev/commands/circle_command_test.rb +76 -0
- data/app/dev/commands/narrative_method_command.rb +60 -0
- data/app/dev/commands/narrative_method_command_test.rb +36 -0
- data/app/dev/commands/new_command.rb +1 -61
- data/app/dev/commands/quadratic_command.rb +66 -0
- data/app/dev/commands/quadratic_command_test.rb +47 -0
- data/app/dev/generators/bench_generator/bench.rb.erb +24 -0
- data/app/dev/generators/bench_generator/bench_test.rb.erb +12 -0
- data/app/dev/generators/bench_generator.rb +18 -0
- data/app/dev/generators/bench_generator_test.rb +12 -0
- data/app/dev/generators/command_generator/command.rb.erb +26 -0
- data/app/dev/generators/command_generator/command_test.rb.erb +12 -0
- data/app/dev/generators/command_generator.rb +18 -0
- data/app/dev/generators/command_generator_test.rb +12 -0
- data/app/dev/generators/record_generator.rb +46 -0
- data/app/dev/generators/record_generator_test.rb +12 -0
- data/app/dev/generators/request_generator.rb +63 -0
- data/app/dev/generators/request_generator_test.rb +12 -0
- data/app/net/databases/redis_db_test.rb +2 -2
- data/app/net/databases/sqlite_db_test.rb +2 -2
- data/app/net/{models/app_model.rb → records/app_record.rb} +2 -1
- data/app/net/{models/post_model_test.rb → records/app_record_test.rb} +2 -2
- data/app/net/records/post_record.rb +4 -0
- data/app/net/{models/app_model_test.rb → records/post_record_test.rb} +2 -2
- data/app/net/records/user_record.rb +4 -0
- data/app/net/{models/user_model_test.rb → records/user_record_test.rb} +2 -2
- data/app/net_box.rb +2 -2
- data/app/web/requests/api_request.rb +8 -7
- data/app/web/requests/assets_request.rb +12 -13
- data/app/web/requests/root_request.rb +6 -7
- data/app/web/requests/root_request_test.rb +1 -1
- data/app/web_box.rb +8 -0
- data/app_new/Procfile +1 -1
- data/exe/lrb +3 -0
- data/lib/app.rb +18 -14
- data/lib/dev_system/dev/controllers/bench/not_found_bench.rb +29 -0
- data/lib/dev_system/dev/controllers/bench/not_found_bench_test.rb +14 -0
- data/lib/dev_system/dev/controllers/bench.rb +11 -0
- data/lib/dev_system/dev/controllers/bench_dsl_main_part.rb +60 -0
- data/lib/dev_system/dev/controllers/{command/dev_command_test.rb → bench_test.rb} +2 -2
- data/lib/dev_system/dev/controllers/command/bench_command.rb +34 -0
- data/lib/dev_system/dev/controllers/command/bench_command_test.rb +14 -0
- data/lib/dev_system/dev/controllers/command/generate_command.rb +35 -0
- data/lib/dev_system/dev/controllers/command/generate_command_test.rb +14 -0
- data/lib/dev_system/dev/controllers/command/not_found_command.rb +29 -0
- data/lib/dev_system/dev/controllers/command/not_found_command_test.rb +14 -0
- data/lib/dev_system/dev/controllers/command/terminal_command.rb +24 -0
- data/lib/dev_system/dev/controllers/command/terminal_command_test.rb +14 -0
- data/lib/dev_system/dev/controllers/command/test_command.rb +6 -2
- data/lib/dev_system/dev/controllers/generator.rb +11 -0
- data/lib/dev_system/dev/controllers/generator_dsl_main_part.rb +54 -0
- data/lib/dev_system/dev/controllers/generator_test.rb +14 -0
- data/lib/dev_system/dev/controllers/generators/app_generator.rb +96 -0
- data/lib/dev_system/dev/controllers/generators/app_generator_test.rb +14 -0
- data/lib/dev_system/dev/controllers/generators/generator_generator/generator.rb.erb +18 -0
- data/lib/dev_system/dev/controllers/generators/generator_generator/generator_test.rb.erb +12 -0
- data/lib/dev_system/dev/controllers/generators/generator_generator/template.rb.erb +9 -0
- data/lib/dev_system/dev/controllers/generators/generator_generator/template_test.rb.erb +12 -0
- data/lib/dev_system/dev/controllers/generators/generator_generator.rb +30 -0
- data/lib/dev_system/dev/controllers/generators/generator_generator_test.rb +12 -0
- data/lib/dev_system/dev/controllers/generators/not_found_generator.rb +29 -0
- data/lib/dev_system/dev/controllers/generators/not_found_generator_test.rb +14 -0
- data/lib/dev_system/dev/controllers/shell/bin_shell.rb +22 -0
- data/lib/dev_system/dev/controllers/shell/bin_shell_test.rb +87 -0
- data/lib/dev_system/dev/controllers/shell/dir_shell.rb +27 -0
- data/lib/dev_system/dev/controllers/shell/dir_shell_test.rb +73 -0
- data/lib/dev_system/dev/controllers/shell/file_shell.rb +59 -0
- data/lib/dev_system/dev/controllers/shell/file_shell_test.rb +150 -0
- data/lib/dev_system/dev/controllers/shell/text_shell.rb +23 -0
- data/lib/dev_system/dev/controllers/shell/text_shell_test.rb +84 -0
- data/lib/dev_system/dev/controllers/shell.rb +31 -0
- data/lib/dev_system/dev/controllers/shell_test.rb +46 -0
- data/lib/dev_system/dev/controllers/{command/dev_command.rb → terminal/irb_terminal.rb} +2 -2
- data/lib/dev_system/dev/controllers/terminal/irb_terminal_test.rb +14 -0
- data/lib/dev_system/dev/controllers/terminal/pry_terminal.rb +12 -0
- data/lib/dev_system/dev/controllers/terminal/pry_terminal_test.rb +14 -0
- data/lib/dev_system/dev/controllers/terminal.rb +19 -0
- data/lib/dev_system/dev/controllers/terminal_test.rb +14 -0
- data/lib/dev_system/dev/dev_box.rb +3 -0
- data/lib/dev_system/dev/panels/command_panel.rb +21 -1
- data/lib/dev_system/dev/panels/log_panel.rb +1 -1
- data/lib/lerb.rb +106 -0
- data/lib/liza/base/controller.rb +2 -0
- data/lib/liza/base/panel.rb +6 -5
- data/lib/liza/base_parts/controller_renderer_part.rb +140 -0
- data/lib/liza/base_parts/controller_renderer_part_test.rb +16 -0
- data/lib/liza/meta/part_extension.rb +6 -1
- data/lib/liza/ruby_test.rb +9 -0
- data/lib/liza/ruby_tests/module_test.rb +21 -0
- data/lib/liza/ruby_tests/string_test.rb +59 -0
- data/lib/liza/test/test.rb +3 -1
- data/lib/liza/test/test_test.rb +108 -15
- data/lib/liza/test_parts/test_assertions_advanced_part.rb +127 -0
- data/lib/liza/test_parts/test_assertions_part.rb +7 -6
- data/lib/liza/test_parts/test_dsl_part.rb +37 -89
- data/lib/liza/test_parts/test_log_part.rb +124 -0
- data/lib/liza/test_parts/test_subject_part.rb +6 -1
- data/lib/liza/test_parts/test_tree_part.rb +139 -0
- data/lib/liza/unit.rb +2 -0
- data/lib/liza/unit_parts/unit_procedure_part.rb +17 -0
- data/lib/liza/unit_parts/unit_procedure_part_test.rb +65 -0
- data/lib/liza.rb +40 -7
- data/lib/lizarb/ruby/class.rb +2 -0
- data/lib/lizarb/ruby/module.rb +17 -0
- data/lib/lizarb/ruby/proc.rb +12 -0
- data/lib/lizarb/ruby/string.rb +26 -2
- data/lib/lizarb/version.rb +1 -1
- data/lib/lizarb.rb +24 -2
- data/lib/net_system/net/controllers/{adapter/redis_adapter.rb → client/redis_client.rb} +2 -2
- data/lib/net_system/net/controllers/{adapter/redis_adapter_test.rb → client/redis_client_test.rb} +2 -2
- data/lib/net_system/net/controllers/{adapter/sqlite_adapter.rb → client/sqlite_client.rb} +2 -2
- data/lib/net_system/net/controllers/{adapter/sqlite_adapter_test.rb → client/sqlite_client_test.rb} +2 -2
- data/lib/net_system/net/controllers/client.rb +5 -0
- data/lib/net_system/net/controllers/{model_test.rb → client_test.rb} +2 -2
- data/lib/net_system/net/controllers/database/redis_db.rb +2 -2
- data/lib/net_system/net/controllers/database/redis_db_test.rb +1 -1
- data/lib/net_system/net/controllers/database/sqlite_db.rb +2 -2
- data/lib/net_system/net/controllers/database/sqlite_db_test.rb +1 -1
- data/lib/net_system/net/controllers/database.rb +6 -6
- data/lib/net_system/net/controllers/record.rb +31 -0
- data/lib/net_system/net/controllers/{adapter_test.rb → record_test.rb} +2 -2
- data/lib/net_system/net/net_box.rb +5 -5
- data/lib/net_system/net/net_box_test.rb +1 -1
- data/lib/net_system/net/panels/client_panel.rb +5 -0
- data/lib/net_system/net/panels/{adapter_panel_test.rb → client_panel_test.rb} +2 -2
- data/lib/web_system/dev/rack_command.rb +26 -0
- data/lib/web_system/dev/request_command.rb +143 -0
- data/lib/web_system/dev/web_command.rb +3 -34
- data/lib/web_system/web/controllers/rack.rb +8 -0
- data/lib/web_system/web/controllers/rack_test.rb +18 -0
- data/lib/web_system/web/controllers/request/client_error_request.rb +0 -1
- data/lib/web_system/web/controllers/request/not_found_request.rb +0 -1
- data/lib/web_system/web/controllers/request/server_error_request.rb +0 -1
- data/lib/web_system/web/panels/rack_panel.rb +44 -0
- data/lib/web_system/web/panels/rack_panel_test.rb +14 -0
- data/lib/web_system/web/panels/request_panel.rb +51 -32
- data/lib/web_system/web/panels/request_panel_test.rb +28 -9
- data/lib/web_system/web/web_box.rb +12 -0
- data/lizarb.gemspec +2 -2
- data/tmp/.gitkeep +0 -0
- metadata +110 -31
- data/app/dev/commands/example_command.rb +0 -57
- data/app/dev/commands/example_command_test.rb +0 -43
- data/app/dev/commands/macro_child_command.rb +0 -32
- data/app/dev/commands/macro_child_command_test.rb +0 -7
- data/app/dev/commands/macro_parent_command.rb +0 -70
- data/app/dev/commands/macro_parent_command_test.rb +0 -7
- data/app/dev/commands/my_command.rb +0 -7
- data/app/dev/commands/my_command_test.rb +0 -7
- data/app/net/models/post_model.rb +0 -4
- data/app/net/models/user_model.rb +0 -4
- data/lib/liza/test_parts/test_context_part.rb +0 -81
- data/lib/net_system/net/controllers/adapter.rb +0 -5
- data/lib/net_system/net/controllers/model.rb +0 -31
- data/lib/net_system/net/panels/adapter_panel.rb +0 -5
data/lib/lizarb.rb
CHANGED
@@ -1,8 +1,10 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require "colorize"
|
4
|
+
require "json"
|
4
5
|
require "pathname"
|
5
6
|
require "zeitwerk"
|
7
|
+
require "lerb"
|
6
8
|
|
7
9
|
require_relative "lizarb/version"
|
8
10
|
|
@@ -11,7 +13,8 @@ module Lizarb
|
|
11
13
|
|
12
14
|
#
|
13
15
|
|
14
|
-
|
16
|
+
SPEC = Gem::Specification.find_by_name("lizarb")
|
17
|
+
GEM_DIR = SPEC.gem_dir
|
15
18
|
CUR_DIR = Dir.pwd
|
16
19
|
|
17
20
|
IS_APP_DIR = File.file? "#{CUR_DIR}/app.rb"
|
@@ -36,7 +39,10 @@ module Lizarb
|
|
36
39
|
|
37
40
|
require "#{APP_DIR}/app"
|
38
41
|
|
39
|
-
VERSION
|
42
|
+
versions = {ruby: RUBY_VERSION, bundler: Bundler::VERSION, zeitwerk: Zeitwerk::VERSION, lizarb: VERSION}
|
43
|
+
bugs = SPEC.metadata["bug_tracker_uri"]
|
44
|
+
puts versions.to_s.green
|
45
|
+
puts "Report bugs at #{bugs}"
|
40
46
|
end
|
41
47
|
|
42
48
|
# called from "#{APP_DIR}/app"
|
@@ -65,4 +71,20 @@ module Lizarb
|
|
65
71
|
: "#{GEM_DIR}/exe/Gemfile"
|
66
72
|
end
|
67
73
|
|
74
|
+
# threads
|
75
|
+
|
76
|
+
def thread_object_id
|
77
|
+
Thread.current.object_id
|
78
|
+
end
|
79
|
+
|
80
|
+
@thread_ids = {thread_object_id => 0}
|
81
|
+
@thread_ids_mutex = Mutex.new
|
82
|
+
|
83
|
+
def thread_id
|
84
|
+
@thread_ids[thread_object_id] ||=
|
85
|
+
@thread_ids_mutex.synchronize do
|
86
|
+
@thread_ids.count
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
68
90
|
end
|
@@ -1,10 +1,10 @@
|
|
1
1
|
class NetSystem
|
2
|
-
class
|
2
|
+
class RedisClient < Client
|
3
3
|
|
4
4
|
# https://redis.io/
|
5
5
|
# https://github.com/redis/redis-rb
|
6
6
|
def initialize *args
|
7
|
-
args = [url: Liza.const(:net_box).
|
7
|
+
args = [url: Liza.const(:net_box).clients.get(:redis_url)] if args.empty?
|
8
8
|
log "Connecting to #{args}"
|
9
9
|
@conn = Redis.new *args
|
10
10
|
end
|
data/lib/net_system/net/controllers/{adapter/redis_adapter_test.rb → client/redis_client_test.rb}
RENAMED
@@ -1,12 +1,12 @@
|
|
1
1
|
class NetSystem
|
2
|
-
class
|
2
|
+
class RedisClientTest < ClientTest
|
3
3
|
|
4
4
|
def subject
|
5
5
|
@subject ||= subject_class.new
|
6
6
|
end
|
7
7
|
|
8
8
|
test :subject_class do
|
9
|
-
assert subject_class == Liza::
|
9
|
+
assert subject_class == Liza::RedisClient
|
10
10
|
end
|
11
11
|
|
12
12
|
test :subject do
|
@@ -1,10 +1,10 @@
|
|
1
1
|
class NetSystem
|
2
|
-
class
|
2
|
+
class SqliteClient < Client
|
3
3
|
|
4
4
|
# https://www.sqlite.org/
|
5
5
|
# https://github.com/sparklemotion/sqlite3-ruby
|
6
6
|
def initialize *args
|
7
|
-
args = [Liza.const(:net_box).
|
7
|
+
args = [Liza.const(:net_box).clients.get(:sqlite)] if args.empty?
|
8
8
|
log "Connecting to #{args}"
|
9
9
|
@conn = SQLite3::Database.new *args
|
10
10
|
end
|
data/lib/net_system/net/controllers/{adapter/sqlite_adapter_test.rb → client/sqlite_client_test.rb}
RENAMED
@@ -1,12 +1,12 @@
|
|
1
1
|
class NetSystem
|
2
|
-
class
|
2
|
+
class SqliteClientTest < ClientTest
|
3
3
|
|
4
4
|
def subject
|
5
5
|
@subject ||= subject_class.new ":memory:"
|
6
6
|
end
|
7
7
|
|
8
8
|
test :subject_class do
|
9
|
-
assert subject_class == Liza::
|
9
|
+
assert subject_class == Liza::SqliteClient
|
10
10
|
end
|
11
11
|
|
12
12
|
test :subject do
|
@@ -9,14 +9,14 @@ class NetSystem
|
|
9
9
|
raise "please rename #{sub.name} to #{sub.name}Db"
|
10
10
|
end
|
11
11
|
|
12
|
-
attr_reader :
|
12
|
+
attr_reader :client
|
13
13
|
|
14
|
-
def initialize
|
15
|
-
@
|
14
|
+
def initialize client: get(:client).new
|
15
|
+
@client = client
|
16
16
|
end
|
17
17
|
|
18
|
-
def self.
|
19
|
-
set :
|
18
|
+
def self.set_client client_id
|
19
|
+
set :client, Liza.const("#{client_id}_client")
|
20
20
|
end
|
21
21
|
|
22
22
|
def self.current
|
@@ -27,7 +27,7 @@ class NetSystem
|
|
27
27
|
end
|
28
28
|
|
29
29
|
def self.call(...); current.call(...); end
|
30
|
-
def call(...); @
|
30
|
+
def call(...); @client.call(...); end
|
31
31
|
|
32
32
|
end
|
33
33
|
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
class NetSystem
|
2
|
+
class Record < Liza::Controller
|
3
|
+
|
4
|
+
def self.inherited sub
|
5
|
+
super
|
6
|
+
|
7
|
+
return if sub.name.nil?
|
8
|
+
return if sub.name.end_with? "Record"
|
9
|
+
raise "please rename #{sub.name} to #{sub.name}Record"
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.db database_id = nil
|
13
|
+
if database_id.nil?
|
14
|
+
db = get :db
|
15
|
+
if db
|
16
|
+
Liza.const(:NetBox).databases.get db
|
17
|
+
else
|
18
|
+
raise "please set a db to record #{self}"
|
19
|
+
end
|
20
|
+
else
|
21
|
+
valid = Liza.const(:NetBox).databases.settings.keys
|
22
|
+
if valid.include? database_id
|
23
|
+
set :db, database_id
|
24
|
+
else
|
25
|
+
raise "invalid db `#{database_id}`, valid options are #{valid}"
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
31
|
+
end
|
@@ -1,11 +1,11 @@
|
|
1
1
|
class NetSystem
|
2
2
|
class NetBox < Liza::Box
|
3
|
-
has_panel :
|
4
|
-
has_controller :
|
3
|
+
has_panel :client, :clients
|
4
|
+
has_controller :client, :clients
|
5
5
|
|
6
|
-
# Set up your
|
7
|
-
|
8
|
-
# set :log_level, ENV["net.
|
6
|
+
# Set up your client panel per the DSL in http://guides.lizarb.org/panels/client.html
|
7
|
+
clients do
|
8
|
+
# set :log_level, ENV["net.client.log_level"]
|
9
9
|
end
|
10
10
|
|
11
11
|
has_panel :database, :databases
|
@@ -0,0 +1,26 @@
|
|
1
|
+
class WebSystem
|
2
|
+
class RackCommand < Liza::Command
|
3
|
+
|
4
|
+
def self.call args
|
5
|
+
log "args #{args}"
|
6
|
+
|
7
|
+
strategy = nil
|
8
|
+
host = nil
|
9
|
+
port = nil
|
10
|
+
|
11
|
+
if args.any? && !args[0].include?("=")
|
12
|
+
strategy = args.shift
|
13
|
+
end
|
14
|
+
|
15
|
+
args.each do |arg|
|
16
|
+
host = arg.split("=")[1] if arg.start_with? "h="
|
17
|
+
port = arg.split("=")[1] if arg.start_with? "p="
|
18
|
+
end
|
19
|
+
|
20
|
+
log({strategy:, host:, port:})
|
21
|
+
|
22
|
+
Liza.const(:web_box).rack.call strategy, host, port
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,143 @@
|
|
1
|
+
class WebSystem::RequestCommand < Liza::Command
|
2
|
+
|
3
|
+
VALID_ACTIONS = %w[find get post]
|
4
|
+
|
5
|
+
def self.call(args)
|
6
|
+
log "Called #{self}.#{__method__} with args #{args}"
|
7
|
+
new.call(args)
|
8
|
+
end
|
9
|
+
|
10
|
+
# instance methods
|
11
|
+
|
12
|
+
def call(args)
|
13
|
+
log "Called #{self}.#{__method__} with args #{args}"
|
14
|
+
|
15
|
+
@command = args.shift
|
16
|
+
@args = args
|
17
|
+
|
18
|
+
return help unless VALID_ACTIONS.include? @command
|
19
|
+
perform
|
20
|
+
rescue StandardError => error
|
21
|
+
@error = error
|
22
|
+
handle
|
23
|
+
end
|
24
|
+
|
25
|
+
def perform
|
26
|
+
log "Called #{self}.#{__method__}"
|
27
|
+
|
28
|
+
case @command
|
29
|
+
when "find"
|
30
|
+
find
|
31
|
+
when "get"
|
32
|
+
get_request
|
33
|
+
when "post"
|
34
|
+
post_request
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
def handle
|
39
|
+
log "Called #{self}.#{__method__}"
|
40
|
+
log render "error.txt"
|
41
|
+
end
|
42
|
+
|
43
|
+
def help
|
44
|
+
log "Called #{self}.#{__method__}"
|
45
|
+
log render "help.txt"
|
46
|
+
end
|
47
|
+
|
48
|
+
# actions
|
49
|
+
|
50
|
+
def find
|
51
|
+
log "Called #{self}.#{__method__}"
|
52
|
+
path = @args.first
|
53
|
+
|
54
|
+
@env = {}
|
55
|
+
@env["REQUEST_PATH"] = path
|
56
|
+
|
57
|
+
request_panel.find @env
|
58
|
+
|
59
|
+
@request_class = @env["LIZA_REQUEST_CLASS"]
|
60
|
+
|
61
|
+
puts render "find.txt"
|
62
|
+
end
|
63
|
+
|
64
|
+
def get_request
|
65
|
+
log "Called #{self}.#{__method__}"
|
66
|
+
path = @args.first
|
67
|
+
|
68
|
+
@env = {}
|
69
|
+
@env["REQUEST_METHOD"] = "GET"
|
70
|
+
@env["REQUEST_PATH"] = path
|
71
|
+
|
72
|
+
@status, @headers, @body = request_panel.call @env
|
73
|
+
log "STATUS #{@status} with #{@headers.count} headers and a #{@body.first.size} byte body"
|
74
|
+
puts render "response.http"
|
75
|
+
end
|
76
|
+
|
77
|
+
def post_request
|
78
|
+
log "Called #{self}.#{__method__}"
|
79
|
+
path = @args.first
|
80
|
+
|
81
|
+
@env = {}
|
82
|
+
@env["REQUEST_METHOD"] = "POST"
|
83
|
+
@env["REQUEST_PATH"] = path
|
84
|
+
|
85
|
+
@status, @headers, @body = request_panel.call @env
|
86
|
+
log "STATUS #{@status} with #{@headers.count} headers and a #{@body.first.size} byte body"
|
87
|
+
puts render "response.http"
|
88
|
+
end
|
89
|
+
|
90
|
+
# helpers
|
91
|
+
|
92
|
+
def request_panel
|
93
|
+
Liza.const(:web_box).requests
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
__END__
|
98
|
+
|
99
|
+
# success.txt.erb
|
100
|
+
|
101
|
+
RESULT:
|
102
|
+
|
103
|
+
class <%= @result.class %>
|
104
|
+
value <%= @result %>
|
105
|
+
|
106
|
+
# error.txt.erb
|
107
|
+
|
108
|
+
ERROR:
|
109
|
+
|
110
|
+
class <%= @error.class %>
|
111
|
+
message <%= @error.message %>
|
112
|
+
backtrace <%= @error.backtrace.select { |s| @stop = true if s.include?("/exe/lizarb:"); !defined? @stop }.join "\n " %>
|
113
|
+
|
114
|
+
# help.txt.erb
|
115
|
+
|
116
|
+
USAGE:
|
117
|
+
|
118
|
+
liza request find /path/to/action.format
|
119
|
+
liza request get /path/to/action.format
|
120
|
+
liza request post /path/to/action.format
|
121
|
+
|
122
|
+
# find.txt.erb
|
123
|
+
|
124
|
+
ENV:
|
125
|
+
<% @env.each do |k, v| %>
|
126
|
+
env["<%= k %>"] = <%= v.inspect -%>
|
127
|
+
<% end %>
|
128
|
+
|
129
|
+
REQUEST CLASS:
|
130
|
+
|
131
|
+
# <%= @request_class.source_location.join ":" %>
|
132
|
+
class <%= @request_class %> < <%= @request_class.superclass %>
|
133
|
+
# ...
|
134
|
+
end
|
135
|
+
|
136
|
+
# response.http.erb
|
137
|
+
|
138
|
+
<%= @status %>
|
139
|
+
<% @headers.each do |k, v| -%>
|
140
|
+
<%= k %>: <%= v %>
|
141
|
+
<% end -%>
|
142
|
+
|
143
|
+
<%= @body.first %>
|
@@ -1,41 +1,10 @@
|
|
1
1
|
class WebSystem
|
2
2
|
class WebCommand < Liza::Command
|
3
3
|
|
4
|
-
set :files, App.root.join("web_files")
|
5
|
-
set :host, "localhost"
|
6
|
-
set :port, 3000
|
7
|
-
|
8
4
|
def self.call args
|
9
|
-
log
|
10
|
-
|
11
|
-
|
12
|
-
port = get :port
|
13
|
-
|
14
|
-
args.each do |arg|
|
15
|
-
host = arg.split("=")[1] if arg.start_with? "h="
|
16
|
-
port = arg.split("=")[1] if arg.start_with? "p="
|
17
|
-
end
|
18
|
-
|
19
|
-
if App.mode == :code
|
20
|
-
ENV["RACK_ENV"] = "development"
|
21
|
-
rack_app = method :_call
|
22
|
-
else
|
23
|
-
ENV["RACK_ENV"] = "production"
|
24
|
-
rack_app = ::WebBox.requests
|
25
|
-
end
|
26
|
-
|
27
|
-
rack_files = Rack::Files.new get(:files)
|
28
|
-
rack_app = Rack::Cascade.new [rack_files, rack_app]
|
29
|
-
|
30
|
-
require "rack/handler/puma"
|
31
|
-
Rack::Handler::Puma.run rack_app, Host: host, Port: port
|
32
|
-
end
|
33
|
-
|
34
|
-
def self._call app
|
35
|
-
App.reload do
|
36
|
-
log "reloading"
|
37
|
-
return ::WebBox.requests.call app
|
38
|
-
end
|
5
|
+
log "args #{args}"
|
6
|
+
log "DEPRECATED: please use `lizarb rack` instead"
|
7
|
+
RackCommand.call args
|
39
8
|
end
|
40
9
|
|
41
10
|
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
class WebSystem
|
2
|
+
class RackTest < Liza::ControllerTest
|
3
|
+
|
4
|
+
test :subject_class do
|
5
|
+
assert subject_class == WebSystem::Rack
|
6
|
+
end
|
7
|
+
|
8
|
+
test :settings do
|
9
|
+
assert subject_class.log_level == :normal
|
10
|
+
assert subject_class.log_color == :blue
|
11
|
+
end
|
12
|
+
|
13
|
+
# test :call do
|
14
|
+
# todo "write this"
|
15
|
+
# end
|
16
|
+
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
class WebSystem
|
2
|
+
class RackPanel < Liza::Panel
|
3
|
+
|
4
|
+
def call strategy, host, port
|
5
|
+
puts
|
6
|
+
log({strategy:, host:, port:})
|
7
|
+
|
8
|
+
strategy ||= get :strategy
|
9
|
+
host ||= get :host
|
10
|
+
port ||= 3000
|
11
|
+
files ||= get :files
|
12
|
+
|
13
|
+
log({strategy:, host:, port:})
|
14
|
+
|
15
|
+
x = App.mode == :code ? "development" : "production"
|
16
|
+
ENV["RACK_ENV"] = x
|
17
|
+
rack_app = send "get_rack_app_#{x}"
|
18
|
+
|
19
|
+
rack_files = Object::Rack::Files.new files
|
20
|
+
rack_app = Object::Rack::Cascade.new [rack_files, rack_app]
|
21
|
+
|
22
|
+
# TODO: PumaRack
|
23
|
+
# handler = Liza.const(:"#{strategy}_rack")
|
24
|
+
|
25
|
+
require "rack/handler/puma"
|
26
|
+
handler = Object::Rack::Handler::Puma
|
27
|
+
handler.run rack_app, Host: host, Port: port
|
28
|
+
end
|
29
|
+
|
30
|
+
def get_rack_app_production()= Liza.const(:web_box).requests
|
31
|
+
|
32
|
+
def get_rack_app_development
|
33
|
+
Proc.new do |env|
|
34
|
+
ret = nil
|
35
|
+
App.reload do
|
36
|
+
log "reloading"
|
37
|
+
ret = get_rack_app_production.call env
|
38
|
+
end
|
39
|
+
ret
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
44
|
+
end
|