lizarb 0 → 1.0.0
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 -0
- data/CHANGELOG.md +13 -2
- data/Gemfile +21 -2
- data/Gemfile.lock +44 -0
- data/README.md +88 -12
- data/app/dev/commands/app_command.rb +5 -0
- data/app/dev/commands/app_command_test.rb +7 -0
- data/app/dev/commands/example_command.rb +57 -0
- data/app/dev/commands/example_command_test.rb +43 -0
- data/app/dev/commands/macro_child_command.rb +32 -0
- data/app/dev/commands/macro_child_command_test.rb +7 -0
- data/app/dev/commands/macro_parent_command.rb +70 -0
- data/app/dev/commands/macro_parent_command_test.rb +7 -0
- data/app/dev/commands/my_command.rb +7 -0
- data/app/dev/commands/my_command_test.rb +7 -0
- data/app/dev/commands/new_command.rb +69 -0
- data/app/dev/commands/new_command_test.rb +7 -0
- data/app/dev_box.rb +13 -0
- data/app/happy/axos/axo.rb +50 -0
- data/app/happy_box.rb +8 -0
- data/app/net/databases/redis_db.rb +5 -0
- data/app/net/databases/redis_db_test.rb +12 -0
- data/app/net/databases/sqlite_db.rb +11 -0
- data/app/net/databases/sqlite_db_test.rb +12 -0
- data/app/net/models/app_model.rb +20 -0
- data/app/net/models/app_model_test.rb +8 -0
- data/app/net/models/post_model.rb +4 -0
- data/app/net/models/post_model_test.rb +8 -0
- data/app/net/models/user_model.rb +4 -0
- data/app/net/models/user_model_test.rb +8 -0
- data/app/net_box.rb +21 -0
- data/app/web/requests/api_request.rb +61 -0
- data/app/web/requests/api_request_test.rb +31 -0
- data/app/web/requests/app_request.rb +5 -0
- data/app/web/requests/app_request_test.rb +7 -0
- data/app/web/requests/assets_request.rb +71 -0
- data/app/web/requests/assets_request_test.rb +33 -0
- data/app/web/requests/root_request.rb +55 -0
- data/app/web/requests/root_request_test.rb +31 -0
- data/app/web_box.rb +8 -0
- data/app.code.env +11 -0
- data/app.env +11 -0
- data/app.rb +17 -0
- data/app_new/.gitignore +4 -0
- data/app_new/Gemfile +31 -0
- data/app_new/Procfile +3 -0
- data/exe/Gemfile +3 -0
- data/exe/Gemfile.lock +13 -0
- data/exe/liza +3 -0
- data/exe/lizarb +11 -0
- data/lib/app.rb +200 -0
- data/lib/dev_system/dev/controllers/command/dev_command.rb +19 -0
- data/lib/dev_system/dev/controllers/command/dev_command_test.rb +14 -0
- data/lib/dev_system/dev/controllers/command/echo_command.rb +11 -0
- data/lib/dev_system/dev/controllers/command/echo_command_test.rb +14 -0
- data/lib/dev_system/dev/controllers/command/test_command.rb +70 -0
- data/lib/dev_system/dev/controllers/command/test_command_test.rb +14 -0
- data/lib/dev_system/dev/controllers/command/version_command.rb +9 -0
- data/lib/dev_system/dev/controllers/command/version_command_test.rb +14 -0
- data/lib/dev_system/dev/controllers/command.rb +19 -0
- data/lib/dev_system/dev/controllers/command_test.rb +14 -0
- data/lib/dev_system/dev/dev_box.rb +19 -0
- data/lib/dev_system/dev/dev_box_test.rb +19 -0
- data/lib/dev_system/dev/panels/command_panel.rb +10 -0
- data/lib/dev_system/dev/panels/command_panel_test.rb +23 -0
- data/lib/dev_system/dev/panels/log_panel.rb +10 -0
- data/lib/dev_system/dev/panels/log_panel_test.rb +18 -0
- data/lib/dev_system.rb +8 -0
- data/lib/happy_system/dev/happy_command.rb +11 -0
- data/lib/happy_system/happy/controllers/axo.rb +8 -0
- data/lib/happy_system/happy/happy_box.rb +12 -0
- data/lib/happy_system/happy/happy_box_test.rb +18 -0
- data/lib/happy_system/happy/panels/axo_panel.rb +5 -0
- data/lib/{viral.rb → happy_system.rb} +7 -3
- data/lib/liza/base/box.rb +40 -0
- data/lib/liza/base/box_test.rb +12 -0
- data/lib/liza/base/controller.rb +27 -0
- data/lib/liza/base/controller_test.rb +12 -0
- data/lib/liza/base/panel.rb +38 -0
- data/lib/liza/base/panel_test.rb +16 -0
- data/lib/liza/meta/part.rb +19 -0
- data/lib/liza/meta/part_extension.rb +13 -0
- data/lib/liza/meta/part_test.rb +8 -0
- data/lib/liza/meta/system.rb +20 -0
- data/lib/liza/meta/system_test.rb +13 -0
- data/lib/liza/test/test.rb +11 -0
- data/lib/liza/test/test_test.rb +108 -0
- data/lib/liza/test_parts/test_assertions_part.rb +110 -0
- data/lib/liza/test_parts/test_context_part.rb +81 -0
- data/lib/liza/test_parts/test_dsl_part.rb +122 -0
- data/lib/liza/test_parts/test_subject_part.rb +19 -0
- data/lib/liza/unit.rb +149 -0
- data/lib/liza/unit_test.rb +79 -0
- data/lib/liza.rb +34 -0
- data/lib/lizarb/ruby/class.rb +15 -0
- data/lib/lizarb/ruby/string.rb +9 -0
- data/lib/lizarb/ruby/time.rb +9 -0
- data/lib/{viral → lizarb}/version.rb +2 -2
- data/lib/lizarb.rb +68 -0
- data/lib/net_system/dev/net_command.rb +24 -0
- data/lib/net_system/net/controllers/adapter/redis_adapter.rb +28 -0
- data/lib/net_system/net/controllers/adapter/redis_adapter_test.rb +29 -0
- data/lib/net_system/net/controllers/adapter/sqlite_adapter.rb +28 -0
- data/lib/net_system/net/controllers/adapter/sqlite_adapter_test.rb +29 -0
- data/lib/net_system/net/controllers/adapter.rb +5 -0
- data/lib/net_system/net/controllers/adapter_test.rb +14 -0
- data/lib/net_system/net/controllers/database/redis_db.rb +11 -0
- data/lib/net_system/net/controllers/database/redis_db_test.rb +23 -0
- data/lib/net_system/net/controllers/database/sqlite_db.rb +11 -0
- data/lib/net_system/net/controllers/database/sqlite_db_test.rb +23 -0
- data/lib/net_system/net/controllers/database.rb +33 -0
- data/lib/net_system/net/controllers/database_test.rb +14 -0
- data/lib/net_system/net/controllers/model.rb +31 -0
- data/lib/net_system/net/controllers/model_test.rb +14 -0
- data/lib/net_system/net/net_box.rb +20 -0
- data/lib/net_system/net/net_box_test.rb +19 -0
- data/lib/net_system/net/panels/adapter_panel.rb +5 -0
- data/lib/net_system/net/panels/adapter_panel_test.rb +18 -0
- data/lib/net_system/net/panels/database_panel.rb +12 -0
- data/lib/net_system/net/panels/database_panel_test.rb +18 -0
- data/lib/net_system.rb +3 -0
- data/lib/web_system/dev/web_command.rb +42 -0
- data/lib/web_system/web/controllers/request/client_error_request.rb +18 -0
- data/lib/web_system/web/controllers/request/not_found_request.rb +18 -0
- data/lib/web_system/web/controllers/request/server_error_request.rb +20 -0
- data/lib/web_system/web/controllers/request.rb +5 -0
- data/lib/web_system/web/controllers/request_test.rb +18 -0
- data/lib/web_system/web/panels/request_panel.rb +55 -0
- data/lib/web_system/web/panels/request_panel_test.rb +14 -0
- data/lib/web_system/web/web_box.rb +12 -0
- data/lib/web_system/web/web_box_test.rb +18 -0
- data/lib/web_system.rb +5 -0
- data/lizarb.gemspec +44 -0
- data/sig/{viral.rbs → lizarb.rbs} +1 -1
- data/web_files/favicon.ico +0 -0
- data/web_files/favicon.svg +948 -0
- metadata +190 -13
- data/viral.gemspec +0 -45
@@ -0,0 +1,12 @@
|
|
1
|
+
class SqliteDbTest < Liza::SqliteDbTest
|
2
|
+
|
3
|
+
test :subject_class do
|
4
|
+
assert subject_class == SqliteDb
|
5
|
+
assert SqliteDb.current.class == SqliteDb
|
6
|
+
assert Liza::SqliteDb.current.class == SqliteDb
|
7
|
+
assert SqliteDb.current == Liza::SqliteDb.current
|
8
|
+
assert SqliteDb.current.adapter == Liza::SqliteDb.current.adapter
|
9
|
+
assert SqliteDb.current.adapter.conn == Liza::SqliteDb.current.adapter.conn
|
10
|
+
end
|
11
|
+
|
12
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
class AppModel < Liza::Model
|
2
|
+
db :sqlite
|
3
|
+
|
4
|
+
def self.create_tables!
|
5
|
+
db.call <<-SQLITE
|
6
|
+
CREATE TABLE #{get :table} (
|
7
|
+
id integer,
|
8
|
+
name text,
|
9
|
+
text text
|
10
|
+
);
|
11
|
+
SQLITE
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.drop_tables!
|
15
|
+
db.call <<-SQLITE
|
16
|
+
DROP TABLE #{get :table};
|
17
|
+
SQLITE
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
data/app/net_box.rb
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
class NetBox < Liza::NetBox
|
2
|
+
|
3
|
+
adapters do
|
4
|
+
# Set up your adapter panel per the DSL in http://guides.lizarb.org/panels/adapter.html
|
5
|
+
|
6
|
+
set :redis_url, "redis://localhost:6379/15"
|
7
|
+
set :sqlite, "tmp/app.#{Time.now.to_i}.sqlite" if App.mode == :code
|
8
|
+
set :sqlite, "app.#{App.mode}.sqlite"
|
9
|
+
|
10
|
+
end
|
11
|
+
|
12
|
+
databases do
|
13
|
+
# Set up your database panel per the DSL in http://guides.lizarb.org/panels/database.html
|
14
|
+
|
15
|
+
define :redis, RedisDb.current
|
16
|
+
define :sql, SqliteDb.current
|
17
|
+
define :sqlite, SqliteDb.current
|
18
|
+
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
@@ -0,0 +1,61 @@
|
|
1
|
+
class ApiRequest < AppRequest
|
2
|
+
|
3
|
+
def self.call env
|
4
|
+
path = env["REQUEST_PATH"]
|
5
|
+
|
6
|
+
#
|
7
|
+
|
8
|
+
status = 200
|
9
|
+
headers = {
|
10
|
+
"Framework" => "Liza #{Lizarb::VERSION}"
|
11
|
+
}
|
12
|
+
body = ""
|
13
|
+
|
14
|
+
#
|
15
|
+
|
16
|
+
segments = Array path.split("/")[1..-1]
|
17
|
+
|
18
|
+
case segments
|
19
|
+
in "api", "auth", "sign_up"
|
20
|
+
body = render_route_api_auth_sign_up
|
21
|
+
in "api", "auth", "sign_in"
|
22
|
+
body = render_route_api_auth_sign_in
|
23
|
+
in "api", "auth", "account"
|
24
|
+
body = render_route_api_auth_account
|
25
|
+
in "api", "auth", "sign_out"
|
26
|
+
body = render_route_api_auth_sign_out
|
27
|
+
in "api", "users"
|
28
|
+
body = render_route_api_users
|
29
|
+
else
|
30
|
+
status = 404
|
31
|
+
body = render_route_not_found env["LIZA_PATH"]
|
32
|
+
end
|
33
|
+
|
34
|
+
log status
|
35
|
+
[status, headers, [body]]
|
36
|
+
end
|
37
|
+
|
38
|
+
def self.render_route_api_auth_sign_up
|
39
|
+
"route: render_route_api_auth_sign_up"
|
40
|
+
end
|
41
|
+
|
42
|
+
def self.render_route_api_auth_sign_in
|
43
|
+
"route: render_route_api_auth_sign_in"
|
44
|
+
end
|
45
|
+
|
46
|
+
def self.render_route_api_auth_account
|
47
|
+
"route: render_route_api_auth_account"
|
48
|
+
end
|
49
|
+
|
50
|
+
def self.render_route_api_auth_sign_out
|
51
|
+
"route: render_route_api_auth_sign_out"
|
52
|
+
end
|
53
|
+
|
54
|
+
def self.render_route_api_users
|
55
|
+
"route: render_route_api_users"
|
56
|
+
end
|
57
|
+
|
58
|
+
def self.render_route_not_found path
|
59
|
+
"route: render_route_not_found #{path}"
|
60
|
+
end
|
61
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
class ApiRequestTest < AppRequestTest
|
2
|
+
|
3
|
+
test :subject_class do
|
4
|
+
assert subject_class == ApiRequest
|
5
|
+
end
|
6
|
+
|
7
|
+
test :actions, :root do
|
8
|
+
env = {
|
9
|
+
"REQUEST_PATH" => "/",
|
10
|
+
}
|
11
|
+
|
12
|
+
status, headers, body = subject_class.call env
|
13
|
+
|
14
|
+
assert status == 404
|
15
|
+
assert headers["Framework"].to_s.start_with? "Liza"
|
16
|
+
assert body.first.include? "render_route_not_found"
|
17
|
+
end
|
18
|
+
|
19
|
+
test :actions, :sign_up do
|
20
|
+
env = {
|
21
|
+
"REQUEST_PATH" => "/api/auth/sign_up",
|
22
|
+
}
|
23
|
+
|
24
|
+
status, headers, body = subject_class.call env
|
25
|
+
|
26
|
+
assert status == 200
|
27
|
+
assert headers["Framework"].to_s.start_with? "Liza"
|
28
|
+
assert body.first.include? "render_route_api_auth_sign_up"
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
@@ -0,0 +1,71 @@
|
|
1
|
+
class AssetsRequest < AppRequest
|
2
|
+
|
3
|
+
def self.call env
|
4
|
+
new.call env
|
5
|
+
end
|
6
|
+
|
7
|
+
def call env
|
8
|
+
action = env["LIZA_ACTION"].to_sym
|
9
|
+
format = env["LIZA_FORMAT"].to_sym
|
10
|
+
|
11
|
+
#
|
12
|
+
|
13
|
+
@status = 200
|
14
|
+
@headers = {
|
15
|
+
"Framework" => "Liza #{Lizarb::VERSION}"
|
16
|
+
}
|
17
|
+
@body = ""
|
18
|
+
|
19
|
+
render_action_admin_format_js if action == :admin && format == :js
|
20
|
+
render_action_admin_format_css if action == :admin && format == :css
|
21
|
+
render_action_app_format_js if action == :app && format == :js
|
22
|
+
render_action_app_format_css if action == :app && format == :css
|
23
|
+
|
24
|
+
log @status
|
25
|
+
[@status, @headers, [@body]]
|
26
|
+
end
|
27
|
+
|
28
|
+
# helper methods
|
29
|
+
|
30
|
+
def render_action_admin_format_js
|
31
|
+
@body = "alert('it works')"
|
32
|
+
end
|
33
|
+
|
34
|
+
def render_action_admin_format_css
|
35
|
+
@body = "body { background: gray }"
|
36
|
+
end
|
37
|
+
|
38
|
+
def render_action_app_format_js
|
39
|
+
@body = <<-CODE
|
40
|
+
window.onload = () => {
|
41
|
+
var h1 = document.createElement("h1");
|
42
|
+
h1.setAttribute("style", "color: white");
|
43
|
+
h1.innerHTML="JS file has been loaded. Random String: #{random_string}";
|
44
|
+
document.body.append(h1);
|
45
|
+
}
|
46
|
+
CODE
|
47
|
+
end
|
48
|
+
|
49
|
+
def render_action_app_format_css
|
50
|
+
@body = <<-CODE
|
51
|
+
body {
|
52
|
+
background: ##{random_color};
|
53
|
+
font-family: Roboto;
|
54
|
+
}
|
55
|
+
CODE
|
56
|
+
end
|
57
|
+
|
58
|
+
def random_string
|
59
|
+
Array("A".."z").sample(16).join
|
60
|
+
end
|
61
|
+
|
62
|
+
def random_color
|
63
|
+
s = ""
|
64
|
+
3.times do |i|
|
65
|
+
s += Array(3..9).sample.to_s(16)
|
66
|
+
s += "0"
|
67
|
+
end
|
68
|
+
s
|
69
|
+
end
|
70
|
+
|
71
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
class AssetsRequestTest < AppRequestTest
|
2
|
+
|
3
|
+
test :subject_class do
|
4
|
+
assert subject_class == AssetsRequest
|
5
|
+
end
|
6
|
+
|
7
|
+
test :actions, :app, :js do
|
8
|
+
env = {
|
9
|
+
"LIZA_ACTION" => "app",
|
10
|
+
"LIZA_FORMAT" => "js",
|
11
|
+
}
|
12
|
+
|
13
|
+
status, headers, body = subject_class.call env
|
14
|
+
|
15
|
+
assert status == 200
|
16
|
+
assert headers["Framework"].to_s.start_with? "Liza"
|
17
|
+
assert body.first.include? "JS file has been loaded"
|
18
|
+
end
|
19
|
+
|
20
|
+
test :actions, :app, :css do
|
21
|
+
env = {
|
22
|
+
"LIZA_ACTION" => "app",
|
23
|
+
"LIZA_FORMAT" => "css",
|
24
|
+
}
|
25
|
+
|
26
|
+
status, headers, body = subject_class.call env
|
27
|
+
|
28
|
+
assert status == 200
|
29
|
+
assert headers["Framework"].to_s.start_with? "Liza"
|
30
|
+
assert body.first.include? "body {"
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
class RootRequest < AppRequest
|
2
|
+
|
3
|
+
# NOTE: There's a bug in this file. Can you find it?
|
4
|
+
def self.call env
|
5
|
+
action = env["LIZA_ACTION"]
|
6
|
+
|
7
|
+
#
|
8
|
+
|
9
|
+
@status = 200
|
10
|
+
|
11
|
+
@headers = {
|
12
|
+
"Framework" => "Liza #{Lizarb::VERSION}"
|
13
|
+
}
|
14
|
+
|
15
|
+
@body = ""
|
16
|
+
|
17
|
+
if action == "root"
|
18
|
+
render_action_root
|
19
|
+
else
|
20
|
+
@status = 404
|
21
|
+
render_action_not_found
|
22
|
+
end
|
23
|
+
|
24
|
+
log @status
|
25
|
+
[@status, @headers, [@body]]
|
26
|
+
rescue => e
|
27
|
+
@status = 500
|
28
|
+
@body = "#{e.class} - #{e.message}"
|
29
|
+
|
30
|
+
log @status
|
31
|
+
[@status, @headers, [@body]]
|
32
|
+
end
|
33
|
+
|
34
|
+
def self.render_action_root
|
35
|
+
h1 = "Ruby Works!"
|
36
|
+
|
37
|
+
@body = <<~CODE
|
38
|
+
<html>
|
39
|
+
<head>
|
40
|
+
<title>Ruby</title>
|
41
|
+
<link rel="stylesheet" href="/assets/app.css" />
|
42
|
+
<script type="application/javascript" src="/assets/app.js"></script>
|
43
|
+
</head>
|
44
|
+
<body>
|
45
|
+
<h1>#{h1}</h1>
|
46
|
+
</body>
|
47
|
+
</html>
|
48
|
+
CODE
|
49
|
+
end
|
50
|
+
|
51
|
+
def self.render_action_not_found
|
52
|
+
@body = "Ruby couldn't find your page!"
|
53
|
+
end
|
54
|
+
|
55
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
class RootRequestTest < AppRequestTest
|
2
|
+
|
3
|
+
test :subject_class do
|
4
|
+
assert subject_class == RootRequest
|
5
|
+
end
|
6
|
+
|
7
|
+
test :actions, :root do
|
8
|
+
env = {
|
9
|
+
"LIZA_ACTION" => "root",
|
10
|
+
}
|
11
|
+
|
12
|
+
status, headers, body = subject_class.call env
|
13
|
+
|
14
|
+
assert status == 200
|
15
|
+
assert headers["Framework"].to_s.start_with? "Liza"
|
16
|
+
assert body.first.include? "<h1>Ruby Works"
|
17
|
+
end
|
18
|
+
|
19
|
+
test :actions, :other do
|
20
|
+
env = {
|
21
|
+
"LIZA_ACTION" => "other",
|
22
|
+
}
|
23
|
+
|
24
|
+
status, headers, body = subject_class.call env
|
25
|
+
|
26
|
+
assert status == 404
|
27
|
+
assert headers["Framework"].to_s.start_with? "Liza"
|
28
|
+
assert body.first.include? "couldn't find your page"
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
data/app/web_box.rb
ADDED
data/app.code.env
ADDED
data/app.env
ADDED
data/app.rb
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
App.call ARGV do
|
2
|
+
|
3
|
+
# Systems help you organize your application's dependencies and RAM memory usage.
|
4
|
+
# Learn more: http://guides.lizarb.org/systems.html
|
5
|
+
|
6
|
+
system :dev
|
7
|
+
system :happy
|
8
|
+
system :net
|
9
|
+
system :web
|
10
|
+
|
11
|
+
# Modes help you organize your application's behavior and settings.
|
12
|
+
# Learn more: http://guides.lizarb.org/modes.html
|
13
|
+
|
14
|
+
mode :code
|
15
|
+
mode :demo
|
16
|
+
|
17
|
+
end
|
data/app_new/.gitignore
ADDED
data/app_new/Gemfile
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
source "https://rubygems.org"
|
4
|
+
|
5
|
+
ruby File.read(".ruby-version").strip
|
6
|
+
|
7
|
+
group :default do
|
8
|
+
gem "lizarb", "~> 1.0"
|
9
|
+
# gem "lizarb", github: "rubyonrails-brasil/lizarb"
|
10
|
+
end
|
11
|
+
|
12
|
+
group :dev do
|
13
|
+
# gems you only want to load if DevSystem is loaded
|
14
|
+
end
|
15
|
+
|
16
|
+
group :happy do
|
17
|
+
# gems you only want to load if HappySystem is loaded
|
18
|
+
end
|
19
|
+
|
20
|
+
group :net do
|
21
|
+
# gems you only want to load if NetSystem is loaded
|
22
|
+
gem "redis", "~> 5.0"
|
23
|
+
gem "sqlite3", "~> 1.5"
|
24
|
+
end
|
25
|
+
|
26
|
+
group :web do
|
27
|
+
# gems you only want to load if WebSystem is loaded
|
28
|
+
gem "rack", "~> 3.0"
|
29
|
+
gem "rackup", "~> 0.2.2"
|
30
|
+
gem "puma", "~> 5.6"
|
31
|
+
end
|
data/app_new/Procfile
ADDED
data/exe/Gemfile
ADDED
data/exe/Gemfile.lock
ADDED
data/exe/liza
ADDED