lizarb 1.0.1 → 1.0.3
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 +1 -0
- data/Gemfile.lock +7 -4
- data/README.md +23 -64
- data/README_SYSTEMS.md +80 -0
- data/Rakefile +3 -1
- data/app/dev/benches/loops_bench.rb +35 -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/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 +2 -51
- 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 +2 -35
- data/app/dev/generators/record_generator.rb +46 -0
- data/app/dev/generators/{model_generator_test.rb → record_generator_test.rb} +2 -2
- data/app/dev_box.rb +24 -4
- data/app/happy_box.rb +1 -1
- data/app/net/databases/sqlite_db_test.rb +5 -5
- data/app/net/{models/app_model.rb → records/app_record.rb} +2 -1
- data/app/net/records/app_record_test.rb +8 -0
- data/app/net/records/post_record.rb +4 -0
- data/app/net/records/post_record_test.rb +8 -0
- data/app/net/records/user_record.rb +4 -0
- data/app/net/records/user_record_test.rb +8 -0
- data/app/net_box.rb +7 -7
- 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 +9 -1
- data/exe/lrb +3 -0
- data/lib/app.rb +19 -15
- data/lib/dev_system/dev/controllers/bench/not_found_bench.rb +27 -0
- data/lib/dev_system/dev/controllers/{command/dev_command_test.rb → bench/not_found_bench_test.rb} +3 -5
- data/lib/dev_system/dev/controllers/bench.rb +5 -7
- data/lib/dev_system/dev/controllers/bench_dsl_main_part.rb +37 -39
- data/lib/dev_system/dev/controllers/bench_test.rb +8 -10
- data/lib/dev_system/dev/controllers/command/bench_command.rb +20 -12
- data/lib/dev_system/dev/controllers/command/bench_command_test.rb +8 -10
- data/lib/dev_system/dev/controllers/command/echo_command.rb +5 -7
- data/lib/dev_system/dev/controllers/command/echo_command_test.rb +8 -10
- data/lib/dev_system/dev/controllers/command/generate_command.rb +22 -12
- data/lib/dev_system/dev/controllers/command/generate_command_test.rb +8 -10
- data/lib/dev_system/dev/controllers/command/not_found_command.rb +27 -0
- data/lib/dev_system/dev/controllers/command/not_found_command_test.rb +12 -0
- data/lib/dev_system/dev/controllers/command/terminal_command.rb +22 -0
- data/lib/dev_system/dev/controllers/command/terminal_command_test.rb +12 -0
- data/lib/dev_system/dev/controllers/command/test_command.rb +64 -49
- data/lib/dev_system/dev/controllers/command/test_command_test.rb +8 -10
- data/lib/dev_system/dev/controllers/command/version_command.rb +4 -6
- data/lib/dev_system/dev/controllers/command/version_command_test.rb +8 -10
- data/lib/dev_system/dev/controllers/command.rb +11 -13
- data/lib/dev_system/dev/controllers/command_test.rb +8 -10
- data/lib/dev_system/dev/controllers/generator.rb +5 -7
- data/lib/dev_system/dev/controllers/generator_dsl_main_part.rb +35 -37
- data/lib/dev_system/dev/controllers/generator_test.rb +8 -10
- data/lib/dev_system/dev/controllers/generators/app_generator.rb +122 -47
- data/lib/dev_system/dev/controllers/generators/app_generator_test.rb +8 -10
- 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 +27 -0
- data/lib/dev_system/dev/controllers/generators/not_found_generator_test.rb +12 -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 +56 -26
- data/lib/dev_system/dev/controllers/shell/file_shell_test.rb +143 -7
- 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 +26 -14
- data/lib/dev_system/dev/controllers/shell_test.rb +42 -9
- data/lib/dev_system/dev/controllers/terminal/irb_terminal.rb +11 -13
- data/lib/dev_system/dev/controllers/terminal/irb_terminal_test.rb +8 -10
- data/lib/dev_system/dev/controllers/terminal/pry_terminal.rb +6 -8
- data/lib/dev_system/dev/controllers/terminal/pry_terminal_test.rb +8 -10
- data/lib/dev_system/dev/controllers/terminal.rb +11 -13
- data/lib/dev_system/dev/controllers/terminal_test.rb +8 -10
- data/lib/dev_system/dev/dev_box.rb +33 -16
- data/lib/dev_system/dev/dev_box_test.rb +12 -14
- data/lib/dev_system/dev/panels/bench_panel.rb +3 -0
- data/lib/dev_system/dev/panels/bench_panel_test.rb +12 -0
- data/lib/dev_system/dev/panels/command_panel.rb +24 -6
- data/lib/dev_system/dev/panels/command_panel_test.rb +15 -17
- data/lib/dev_system/dev/panels/generator_panel.rb +3 -0
- data/lib/dev_system/dev/panels/generator_panel_test.rb +12 -0
- data/lib/dev_system/dev/panels/log_panel.rb +9 -6
- data/lib/dev_system/dev/panels/log_panel_test.rb +11 -13
- data/lib/dev_system/dev/panels/shell_panel.rb +3 -0
- data/lib/dev_system/dev/panels/shell_panel_test.rb +12 -0
- data/lib/dev_system/dev/panels/terminal_panel.rb +3 -0
- data/lib/dev_system/dev/panels/terminal_panel_test.rb +12 -0
- data/lib/happy_system/happy/controllers/axo.rb +4 -5
- data/lib/happy_system/happy/happy_box.rb +6 -9
- data/lib/happy_system/happy/happy_box_test.rb +11 -13
- data/lib/happy_system/happy/panels/axo_panel.rb +1 -3
- data/lib/lerb.rb +106 -0
- data/lib/liza/base/box.rb +71 -26
- data/lib/liza/base/box_test.rb +7 -9
- data/lib/liza/base/controller.rb +19 -19
- data/lib/liza/base/controller_test.rb +7 -9
- data/lib/liza/base/panel.rb +40 -24
- data/lib/liza/base/panel_test.rb +10 -12
- 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.rb +12 -14
- data/lib/liza/meta/part_extension.rb +14 -11
- data/lib/liza/meta/part_test.rb +4 -6
- data/lib/liza/meta/system.rb +12 -14
- data/lib/liza/meta/system_test.rb +8 -10
- data/lib/liza/ruby_test.rb +7 -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 +7 -8
- data/lib/liza/test/test_test.rb +168 -76
- data/lib/liza/test_parts/test_assertions_advanced_part.rb +125 -0
- data/lib/liza/test_parts/test_assertions_part.rb +81 -82
- data/lib/liza/test_parts/test_dsl_part.rb +44 -98
- data/lib/liza/test_parts/test_log_part.rb +122 -0
- data/lib/liza/test_parts/test_subject_part.rb +16 -18
- data/lib/liza/test_parts/test_tree_part.rb +137 -0
- data/lib/liza/unit.rb +108 -102
- 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/unit_test.rb +69 -71
- data/lib/liza.rb +5 -0
- data/lib/lizarb/ruby/module.rb +17 -0
- data/lib/lizarb/ruby/string.rb +10 -2
- data/lib/lizarb/version.rb +1 -1
- data/lib/lizarb.rb +24 -2
- data/lib/net_system/dev/net_command.rb +10 -12
- data/lib/net_system/net/controllers/client/redis_client.rb +19 -21
- data/lib/net_system/net/controllers/client/redis_client_test.rb +20 -22
- data/lib/net_system/net/controllers/client/sqlite_client.rb +19 -21
- data/lib/net_system/net/controllers/client/sqlite_client_test.rb +20 -22
- data/lib/net_system/net/controllers/client.rb +1 -3
- data/lib/net_system/net/controllers/client_test.rb +8 -10
- data/lib/net_system/net/controllers/database/redis_db.rb +6 -8
- data/lib/net_system/net/controllers/database/redis_db_test.rb +15 -17
- data/lib/net_system/net/controllers/database/sqlite_db.rb +6 -8
- data/lib/net_system/net/controllers/database/sqlite_db_test.rb +15 -17
- data/lib/net_system/net/controllers/database.rb +21 -23
- data/lib/net_system/net/controllers/database_test.rb +8 -10
- data/lib/net_system/net/controllers/record.rb +29 -0
- data/lib/net_system/net/controllers/record_test.rb +12 -0
- data/lib/net_system/net/net_box.rb +11 -16
- data/lib/net_system/net/net_box_test.rb +12 -14
- data/lib/net_system/net/panels/client_panel.rb +1 -3
- data/lib/net_system/net/panels/client_panel_test.rb +11 -13
- data/lib/net_system/net/panels/database_panel.rb +6 -8
- data/lib/net_system/net/panels/database_panel_test.rb +11 -13
- data/lib/web_system/dev/rack_command.rb +35 -0
- data/lib/web_system/dev/request_command.rb +143 -0
- data/lib/web_system/dev/web_command.rb +6 -39
- data/lib/web_system/web/controllers/rack.rb +6 -0
- data/lib/web_system/web/controllers/rack_test.rb +16 -0
- data/lib/web_system/web/controllers/request/client_error_request.rb +9 -12
- data/lib/web_system/web/controllers/request/not_found_request.rb +9 -12
- data/lib/web_system/web/controllers/request/server_error_request.rb +10 -13
- data/lib/web_system/web/controllers/request.rb +1 -3
- data/lib/web_system/web/controllers/request_test.rb +11 -13
- data/lib/web_system/web/panels/rack_panel.rb +42 -0
- data/lib/web_system/web/panels/rack_panel_test.rb +12 -0
- data/lib/web_system/web/panels/request_panel.rb +54 -37
- data/lib/web_system/web/panels/request_panel_test.rb +28 -9
- data/lib/web_system/web/web_box.rb +16 -8
- data/lib/web_system/web/web_box_test.rb +11 -13
- data/lizarb.gemspec +2 -2
- metadata +76 -28
- 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/dev/generators/model_generator.rb +0 -46
- data/app/net/models/app_model_test.rb +0 -8
- data/app/net/models/post_model.rb +0 -4
- data/app/net/models/post_model_test.rb +0 -8
- data/app/net/models/user_model.rb +0 -4
- data/app/net/models/user_model_test.rb +0 -8
- data/app_new/.gitignore +0 -4
- data/app_new/Gemfile +0 -31
- data/app_new/Procfile +0 -3
- data/lib/dev_system/dev/controllers/command/dev_command.rb +0 -24
- data/lib/liza/test_parts/test_context_part.rb +0 -81
- data/lib/net_system/net/controllers/model.rb +0 -31
- data/lib/net_system/net/controllers/model_test.rb +0 -14
@@ -1,14 +1,12 @@
|
|
1
|
-
class DevSystem
|
2
|
-
class TestCommandTest < CommandTest
|
1
|
+
class DevSystem::TestCommandTest < DevSystem::CommandTest
|
3
2
|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
test :settings do
|
9
|
-
assert subject_class.log_level == :normal
|
10
|
-
assert subject_class.log_color == :green
|
11
|
-
end
|
3
|
+
test :subject_class do
|
4
|
+
assert subject_class == DevSystem::TestCommand
|
5
|
+
end
|
12
6
|
|
7
|
+
test :settings do
|
8
|
+
assert subject_class.log_level == :normal
|
9
|
+
assert subject_class.log_color == :green
|
13
10
|
end
|
11
|
+
|
14
12
|
end
|
@@ -1,14 +1,12 @@
|
|
1
|
-
class DevSystem
|
2
|
-
class VersionCommandTest < CommandTest
|
1
|
+
class DevSystem::VersionCommandTest < DevSystem::CommandTest
|
3
2
|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
test :settings do
|
9
|
-
assert subject_class.log_level == :normal
|
10
|
-
assert subject_class.log_color == :green
|
11
|
-
end
|
3
|
+
test :subject_class do
|
4
|
+
assert subject_class == DevSystem::VersionCommand
|
5
|
+
end
|
12
6
|
|
7
|
+
test :settings do
|
8
|
+
assert subject_class.log_level == :normal
|
9
|
+
assert subject_class.log_color == :green
|
13
10
|
end
|
11
|
+
|
14
12
|
end
|
@@ -1,19 +1,17 @@
|
|
1
|
-
class DevSystem
|
2
|
-
class Command < Liza::Controller
|
1
|
+
class DevSystem::Command < Liza::Controller
|
3
2
|
|
4
|
-
|
5
|
-
|
6
|
-
|
3
|
+
# def self.call args
|
4
|
+
# new.call args
|
5
|
+
# end
|
7
6
|
|
8
|
-
|
9
|
-
|
10
|
-
|
7
|
+
# def initialize args
|
8
|
+
# @args = args
|
9
|
+
# end
|
11
10
|
|
12
|
-
|
11
|
+
# attr_reader :args
|
13
12
|
|
14
|
-
|
15
|
-
|
16
|
-
|
13
|
+
# def call args
|
14
|
+
#
|
15
|
+
# end
|
17
16
|
|
18
|
-
end
|
19
17
|
end
|
@@ -1,14 +1,12 @@
|
|
1
|
-
class DevSystem
|
2
|
-
class CommandTest < Liza::ControllerTest
|
1
|
+
class DevSystem::CommandTest < Liza::ControllerTest
|
3
2
|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
test :settings do
|
9
|
-
assert subject_class.log_level == :normal
|
10
|
-
assert subject_class.log_color == :green
|
11
|
-
end
|
3
|
+
test :subject_class do
|
4
|
+
assert subject_class == DevSystem::Command
|
5
|
+
end
|
12
6
|
|
7
|
+
test :settings do
|
8
|
+
assert subject_class.log_level == :normal
|
9
|
+
assert subject_class.log_color == :green
|
13
10
|
end
|
11
|
+
|
14
12
|
end
|
@@ -1,11 +1,9 @@
|
|
1
|
-
class DevSystem
|
2
|
-
class Generator < Liza::Controller
|
1
|
+
class DevSystem::Generator < Liza::Controller
|
3
2
|
|
4
|
-
|
5
|
-
|
6
|
-
def self.main_dsl
|
7
|
-
part :"generator_dsl_main", system: :dev
|
8
|
-
end
|
3
|
+
# DSLS
|
9
4
|
|
5
|
+
def self.main_dsl
|
6
|
+
part :"generator_dsl_main", system: :dev
|
10
7
|
end
|
8
|
+
|
11
9
|
end
|
@@ -1,54 +1,52 @@
|
|
1
|
-
class DevSystem
|
2
|
-
class GeneratorDslMainPart < Liza::Part
|
1
|
+
class DevSystem::GeneratorDslMainPart < Liza::Part
|
3
2
|
|
4
|
-
|
3
|
+
insertion do
|
5
4
|
|
6
|
-
|
7
|
-
|
5
|
+
def self.call args
|
6
|
+
log :higher, "Called #{self}.#{__method__} with args #{args}"
|
8
7
|
|
9
|
-
|
10
|
-
|
8
|
+
name = args.shift || raise("args[0] should contain NAME")
|
9
|
+
name = name.downcase
|
11
10
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
end
|
18
|
-
|
19
|
-
puts
|
20
|
-
log "done"
|
11
|
+
memo.each do |label, bl|
|
12
|
+
log "Generating #{label}"
|
13
|
+
g = new label, name, args
|
14
|
+
g.instance_exec &bl
|
15
|
+
g.call
|
21
16
|
end
|
22
17
|
|
23
|
-
|
18
|
+
puts
|
19
|
+
log "done"
|
20
|
+
end
|
24
21
|
|
25
|
-
|
22
|
+
def self.memo()= @memo ||= {}
|
26
23
|
|
27
|
-
|
24
|
+
def self.generate(label, &block)= memo[label] = block
|
28
25
|
|
29
|
-
|
30
|
-
@label, @name, @args = label, name, args
|
31
|
-
end
|
26
|
+
attr_reader :label, :name, :args
|
32
27
|
|
33
|
-
|
34
|
-
|
35
|
-
|
28
|
+
def initialize label, name, args
|
29
|
+
@label, @name, @args = label, name, args
|
30
|
+
end
|
36
31
|
|
37
|
-
|
38
|
-
|
39
|
-
|
32
|
+
def call
|
33
|
+
TextShell.write "#{folder}/#{filename}", "#{content}\n"
|
34
|
+
end
|
40
35
|
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
else
|
45
|
-
@#{s}
|
46
|
-
end
|
47
|
-
end
|
48
|
-
CODE
|
49
|
-
end
|
36
|
+
%w|folder filename content|.each do |s|
|
37
|
+
class_eval <<-CODE, __FILE__, __LINE__ + 1
|
38
|
+
attr_reader :#{s}
|
50
39
|
|
40
|
+
def #{s} #{s} = nil
|
41
|
+
if #{s}
|
42
|
+
@#{s} = #{s}
|
43
|
+
else
|
44
|
+
@#{s}
|
45
|
+
end
|
46
|
+
end
|
47
|
+
CODE
|
51
48
|
end
|
52
49
|
|
53
50
|
end
|
51
|
+
|
54
52
|
end
|
@@ -1,14 +1,12 @@
|
|
1
|
-
class DevSystem
|
2
|
-
class GeneratorTest < Liza::ControllerTest
|
1
|
+
class DevSystem::GeneratorTest < Liza::ControllerTest
|
3
2
|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
test :settings do
|
9
|
-
assert subject_class.log_level == :normal
|
10
|
-
assert subject_class.log_color == :green
|
11
|
-
end
|
3
|
+
test :subject_class do
|
4
|
+
assert subject_class == DevSystem::Generator
|
5
|
+
end
|
12
6
|
|
7
|
+
test :settings do
|
8
|
+
assert subject_class.log_level == :normal
|
9
|
+
assert subject_class.log_color == :green
|
13
10
|
end
|
11
|
+
|
14
12
|
end
|
@@ -1,71 +1,146 @@
|
|
1
|
-
class DevSystem
|
2
|
-
class AppGenerator < Generator
|
1
|
+
class DevSystem::AppGenerator < DevSystem::Generator
|
3
2
|
|
4
|
-
|
5
|
-
|
3
|
+
def self.call args
|
4
|
+
log :higher, "Called #{self}.#{__method__} with args #{args}"
|
5
|
+
new.call args
|
6
|
+
end
|
6
7
|
|
7
|
-
|
8
|
+
def call args
|
9
|
+
# setup
|
8
10
|
|
9
|
-
|
11
|
+
name = args.shift || "app_1"
|
10
12
|
|
11
|
-
|
12
|
-
|
13
|
+
from = "#{Lizarb::APP_DIR}/app_new"
|
14
|
+
to = name
|
13
15
|
|
14
|
-
|
16
|
+
return log "Directory #{to.light_green} already exists." if Dir.exist? to
|
15
17
|
|
16
|
-
|
18
|
+
log "Liza Application initializing at `#{to}`"
|
17
19
|
|
18
|
-
|
20
|
+
# init
|
19
21
|
|
20
|
-
|
21
|
-
|
22
|
+
DirShell.create to
|
23
|
+
TextShell.write "#{to}/.gitignore", render("hidden.gitignore")
|
24
|
+
TextShell.write "#{to}/Gemfile", render("Gemfile.rb")
|
25
|
+
TextShell.write "#{to}/Procfile", render("Procfile.yml")
|
22
26
|
|
23
|
-
|
27
|
+
`cd #{to}; git init -b main`
|
24
28
|
|
25
|
-
|
29
|
+
# extra
|
26
30
|
|
27
|
-
|
31
|
+
puts
|
28
32
|
|
29
|
-
|
30
|
-
|
33
|
+
FileShell.gitkeep "#{to}/lib"
|
34
|
+
FileShell.gitkeep "#{to}/tmp"
|
31
35
|
|
32
|
-
|
36
|
+
DirShell.create "#{to}/app"
|
33
37
|
|
34
|
-
|
38
|
+
# systems
|
35
39
|
|
36
|
-
|
40
|
+
# App.systems.keys.each { |system_name| copy to, system_name }
|
41
|
+
copy to, :dev
|
37
42
|
|
38
|
-
|
39
|
-
|
43
|
+
FileUtils.rm "#{to}/app/dev/commands/new_command.rb"
|
44
|
+
FileUtils.rm "#{to}/app/dev/commands/new_command_test.rb"
|
40
45
|
|
41
|
-
|
42
|
-
|
43
|
-
FileUtils.cp_r "#{Lizarb::APP_DIR}/app.rb", "#{to}/app.rb", verbose: true
|
44
|
-
FileUtils.cp_r "#{Lizarb::APP_DIR}/app.env", "#{to}/app.env", verbose: true
|
45
|
-
FileUtils.cp_r "#{Lizarb::APP_DIR}/app.code.env", "#{to}/app.code.env", verbose: true
|
46
|
+
`rm -rf #{to}/app/dev/generators/record_generator*`
|
47
|
+
`rm -rf #{to}/app/dev/generators/request_generator*`
|
46
48
|
|
47
|
-
|
49
|
+
FileUtils.cp_r "#{Lizarb::APP_DIR}/.ruby-version", "#{to}/.ruby-version", verbose: true
|
50
|
+
FileUtils.cp_r "#{Lizarb::APP_DIR}/README.md", "#{to}/README.md", verbose: true
|
51
|
+
TextShell.write "#{to}/app.rb", render("app.rb")
|
52
|
+
FileUtils.cp_r "#{Lizarb::APP_DIR}/app.env", "#{to}/app.env", verbose: true
|
53
|
+
FileUtils.cp_r "#{Lizarb::APP_DIR}/app.code.env", "#{to}/app.code.env", verbose: true
|
48
54
|
|
49
|
-
|
50
|
-
|
55
|
+
puts
|
56
|
+
|
57
|
+
log "Liza Application initialized at `#{to}`"
|
58
|
+
end
|
51
59
|
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
end
|
60
|
-
|
61
|
-
from = "#{Lizarb::APP_DIR}/app/#{system_name}"
|
62
|
-
to = "#{name}/app"
|
63
|
-
if File.exist? from
|
64
|
-
FileUtils.cp_r from, to, verbose: true
|
65
|
-
else
|
66
|
-
puts "file not found #{from}"
|
67
|
-
end
|
60
|
+
def copy name, system_name
|
61
|
+
from = "#{Lizarb::APP_DIR}/app/#{system_name}_box.rb"
|
62
|
+
to = "#{name}/app"
|
63
|
+
if File.exist? from
|
64
|
+
FileUtils.cp_r from, to, verbose: true
|
65
|
+
else
|
66
|
+
puts "file not found #{from}"
|
68
67
|
end
|
69
68
|
|
69
|
+
from = "#{Lizarb::APP_DIR}/app/#{system_name}"
|
70
|
+
to = "#{name}/app"
|
71
|
+
if File.exist? from
|
72
|
+
FileUtils.cp_r from, to, verbose: true
|
73
|
+
else
|
74
|
+
puts "file not found #{from}"
|
75
|
+
end
|
70
76
|
end
|
77
|
+
|
78
|
+
end
|
79
|
+
|
80
|
+
__END__
|
81
|
+
|
82
|
+
# app.rb.erb
|
83
|
+
App.call ARGV do
|
84
|
+
|
85
|
+
# Systems help you organize your application's dependencies and RAM memory usage.
|
86
|
+
# Learn more: http://guides.lizarb.org/systems.html
|
87
|
+
|
88
|
+
system :dev
|
89
|
+
|
90
|
+
# Modes help you organize your application's behavior and settings.
|
91
|
+
# Learn more: http://guides.lizarb.org/modes.html
|
92
|
+
|
93
|
+
mode :code
|
94
|
+
mode :demo
|
95
|
+
|
96
|
+
end
|
97
|
+
|
98
|
+
# hidden.gitignore.erb
|
99
|
+
|
100
|
+
# Ignore all files in all subdirectories
|
101
|
+
.gitignore/.bundle/
|
102
|
+
/tmp/
|
103
|
+
*.sqlite
|
104
|
+
*.rdb
|
105
|
+
|
106
|
+
# Procfile.yml.erb
|
107
|
+
|
108
|
+
<%= "# HEROKU EXAMPLE" %>
|
109
|
+
|
110
|
+
web: LIZA_MODE=demo bundle exec liza rack h=0.0.0.0 p=$PORT
|
111
|
+
|
112
|
+
# Gemfile.rb.erb
|
113
|
+
|
114
|
+
<%= "# frozen_string_literal: true" %>
|
115
|
+
|
116
|
+
source "https://rubygems.org"
|
117
|
+
|
118
|
+
ruby File.read(".ruby-version").strip
|
119
|
+
|
120
|
+
group :default do
|
121
|
+
gem "lizarb", "~> <%= Lizarb::VERSION %>"
|
122
|
+
# gem "lizarb", github: "rubyonrails-brasil/lizarb"
|
123
|
+
end
|
124
|
+
|
125
|
+
group :dev do
|
126
|
+
# gems you only want to load if DevSystem is loaded
|
127
|
+
# gem "pry", "~> 0.14.1"
|
128
|
+
end
|
129
|
+
|
130
|
+
group :happy do
|
131
|
+
# gems you only want to load if HappySystem is loaded
|
132
|
+
end
|
133
|
+
|
134
|
+
group :net do
|
135
|
+
# gems you only want to load if NetSystem is loaded
|
136
|
+
# gem "redis", "~> 5.0"
|
137
|
+
# gem "sqlite3", "~> 1.5"
|
138
|
+
end
|
139
|
+
|
140
|
+
group :web do
|
141
|
+
# gems you only want to load if WebSystem is loaded
|
142
|
+
# gem "rack", "~> 3.0"
|
143
|
+
# gem "rackup", "~> 0.2.2"
|
144
|
+
# gem "puma", "~> 5.6"
|
145
|
+
# gem "htmlbeautifier", "~> 1.4"
|
71
146
|
end
|
@@ -1,14 +1,12 @@
|
|
1
|
-
class DevSystem
|
2
|
-
class AppGeneratorTest < GeneratorTest
|
1
|
+
class DevSystem::AppGeneratorTest < DevSystem::GeneratorTest
|
3
2
|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
test :settings do
|
9
|
-
assert subject_class.log_level == :normal
|
10
|
-
assert subject_class.log_color == :green
|
11
|
-
end
|
3
|
+
test :subject_class do
|
4
|
+
assert subject_class == DevSystem::AppGenerator
|
5
|
+
end
|
12
6
|
|
7
|
+
test :settings do
|
8
|
+
assert subject_class.log_level == :normal
|
9
|
+
assert subject_class.log_color == :green
|
13
10
|
end
|
11
|
+
|
14
12
|
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
class <%= name.camelize %>Generator < Liza::Generator
|
2
|
+
main_dsl
|
3
|
+
|
4
|
+
FOLDER = "app/dev/<%= name %>s"
|
5
|
+
|
6
|
+
generate :controller do
|
7
|
+
folder FOLDER
|
8
|
+
filename "#{name}_<%= name %>.rb"
|
9
|
+
content render "<%= name %>.rb"
|
10
|
+
end
|
11
|
+
|
12
|
+
generate :controller_test do
|
13
|
+
folder FOLDER
|
14
|
+
filename "#{name}_<%= name %>_test.rb"
|
15
|
+
content render "<%= name %>_test.rb"
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
class <%= name.camelize %>GeneratorTest < Liza::GeneratorTest
|
2
|
+
|
3
|
+
test :subject_class do
|
4
|
+
assert subject_class == <%= name.camelize %>Generator
|
5
|
+
end
|
6
|
+
|
7
|
+
test :settings do
|
8
|
+
assert subject_class.log_level == :normal
|
9
|
+
assert subject_class.log_color == :green
|
10
|
+
end
|
11
|
+
|
12
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
class <%%= name.camelize %><%= name.camelize %>Test < Liza::<%= name.camelize %>Test
|
2
|
+
|
3
|
+
test :subject_class do
|
4
|
+
assert subject_class == <%%= name.camelize %><%= name.camelize %>
|
5
|
+
end
|
6
|
+
|
7
|
+
test :settings do
|
8
|
+
assert subject_class.log_level == :normal
|
9
|
+
assert subject_class.log_color == :green
|
10
|
+
end
|
11
|
+
|
12
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
class DevSystem::GeneratorGenerator < Liza::Generator
|
2
|
+
main_dsl
|
3
|
+
|
4
|
+
FOLDER = "app/dev/generators"
|
5
|
+
|
6
|
+
generate :controller do
|
7
|
+
folder FOLDER
|
8
|
+
filename "#{name}_generator.rb"
|
9
|
+
content render "generator.rb"
|
10
|
+
end
|
11
|
+
|
12
|
+
generate :controller_test do
|
13
|
+
folder FOLDER
|
14
|
+
filename "#{name}_generator_test.rb"
|
15
|
+
content render "generator_test.rb"
|
16
|
+
end
|
17
|
+
|
18
|
+
generate :template do
|
19
|
+
folder "#{FOLDER}/#{name}_generator"
|
20
|
+
filename "#{name}.rb.erb"
|
21
|
+
content render "template.rb"
|
22
|
+
end
|
23
|
+
|
24
|
+
generate :template_test do
|
25
|
+
folder "#{FOLDER}/#{name}_generator"
|
26
|
+
filename "#{name}_test.rb.erb"
|
27
|
+
content render "template_test.rb"
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
class DevSystem::GeneratorGeneratorTest < Liza::GeneratorTest
|
2
|
+
|
3
|
+
test :subject_class do
|
4
|
+
assert subject_class == DevSystem::GeneratorGenerator
|
5
|
+
end
|
6
|
+
|
7
|
+
test :settings do
|
8
|
+
assert subject_class.log_level == :normal
|
9
|
+
assert subject_class.log_color == :green
|
10
|
+
end
|
11
|
+
|
12
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
class DevSystem::NotFoundGenerator < DevSystem::Generator
|
2
|
+
|
3
|
+
def self.call args
|
4
|
+
# 1. LOG
|
5
|
+
|
6
|
+
log :higher, "Called #{self}.#{__method__} with args #{args}"
|
7
|
+
puts
|
8
|
+
|
9
|
+
# 2. FIND generators
|
10
|
+
|
11
|
+
App.eager_load_all
|
12
|
+
generators = Liza::Generator.descendants
|
13
|
+
|
14
|
+
log "Liza comes with #{generators.count} generators you can use."
|
15
|
+
puts
|
16
|
+
|
17
|
+
log "Here they are:"
|
18
|
+
puts
|
19
|
+
|
20
|
+
# 3. LIST generators
|
21
|
+
|
22
|
+
keys = generators.map { |k| k.last_namespace.snakecase[0..-11] }.sort
|
23
|
+
keys.reject! { |s| s == "not_found" }
|
24
|
+
keys.each { |s| log "liza generate #{s}" }
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
class DevSystem::NotFoundGeneratorTest < DevSystem::GeneratorTest
|
2
|
+
|
3
|
+
test :subject_class do
|
4
|
+
assert subject_class == DevSystem::NotFoundGenerator
|
5
|
+
end
|
6
|
+
|
7
|
+
test :settings do
|
8
|
+
assert subject_class.log_level == :normal
|
9
|
+
assert subject_class.log_color == :green
|
10
|
+
end
|
11
|
+
|
12
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
class DevSystem::BinShell < DevSystem::FileShell
|
2
|
+
|
3
|
+
set :create_dir, true
|
4
|
+
|
5
|
+
def self.read path
|
6
|
+
log "Reading #{path}"
|
7
|
+
_raise_if_blank path
|
8
|
+
_raise_if_not_exists path
|
9
|
+
|
10
|
+
File.binread path
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.write path, content, create_dir: nil
|
14
|
+
log "Writing #{content&.size.to_i} bytes (#{content.encoding}) to #{path}"
|
15
|
+
_raise_if_blank path
|
16
|
+
|
17
|
+
create_dir = get :create_dir if create_dir.nil?
|
18
|
+
DevSystem::DirShell.create File.dirname path if create_dir
|
19
|
+
|
20
|
+
File.binwrite path, content
|
21
|
+
end
|
22
|
+
end
|