lizarb 0 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (139) hide show
  1. checksums.yaml +4 -4
  2. data/.ruby-version +1 -0
  3. data/CHANGELOG.md +13 -2
  4. data/Gemfile +21 -2
  5. data/Gemfile.lock +44 -0
  6. data/README.md +88 -12
  7. data/app/dev/commands/app_command.rb +5 -0
  8. data/app/dev/commands/app_command_test.rb +7 -0
  9. data/app/dev/commands/example_command.rb +57 -0
  10. data/app/dev/commands/example_command_test.rb +43 -0
  11. data/app/dev/commands/macro_child_command.rb +32 -0
  12. data/app/dev/commands/macro_child_command_test.rb +7 -0
  13. data/app/dev/commands/macro_parent_command.rb +70 -0
  14. data/app/dev/commands/macro_parent_command_test.rb +7 -0
  15. data/app/dev/commands/my_command.rb +7 -0
  16. data/app/dev/commands/my_command_test.rb +7 -0
  17. data/app/dev/commands/new_command.rb +69 -0
  18. data/app/dev/commands/new_command_test.rb +7 -0
  19. data/app/dev_box.rb +13 -0
  20. data/app/happy/axos/axo.rb +50 -0
  21. data/app/happy_box.rb +8 -0
  22. data/app/net/databases/redis_db.rb +5 -0
  23. data/app/net/databases/redis_db_test.rb +12 -0
  24. data/app/net/databases/sqlite_db.rb +11 -0
  25. data/app/net/databases/sqlite_db_test.rb +12 -0
  26. data/app/net/models/app_model.rb +20 -0
  27. data/app/net/models/app_model_test.rb +8 -0
  28. data/app/net/models/post_model.rb +4 -0
  29. data/app/net/models/post_model_test.rb +8 -0
  30. data/app/net/models/user_model.rb +4 -0
  31. data/app/net/models/user_model_test.rb +8 -0
  32. data/app/net_box.rb +21 -0
  33. data/app/web/requests/api_request.rb +61 -0
  34. data/app/web/requests/api_request_test.rb +31 -0
  35. data/app/web/requests/app_request.rb +5 -0
  36. data/app/web/requests/app_request_test.rb +7 -0
  37. data/app/web/requests/assets_request.rb +71 -0
  38. data/app/web/requests/assets_request_test.rb +33 -0
  39. data/app/web/requests/root_request.rb +55 -0
  40. data/app/web/requests/root_request_test.rb +31 -0
  41. data/app/web_box.rb +8 -0
  42. data/app.code.env +11 -0
  43. data/app.env +11 -0
  44. data/app.rb +17 -0
  45. data/app_new/.gitignore +4 -0
  46. data/app_new/Gemfile +31 -0
  47. data/app_new/Procfile +3 -0
  48. data/exe/Gemfile +3 -0
  49. data/exe/Gemfile.lock +13 -0
  50. data/exe/liza +3 -0
  51. data/exe/lizarb +11 -0
  52. data/lib/app.rb +200 -0
  53. data/lib/dev_system/dev/controllers/command/dev_command.rb +19 -0
  54. data/lib/dev_system/dev/controllers/command/dev_command_test.rb +14 -0
  55. data/lib/dev_system/dev/controllers/command/echo_command.rb +11 -0
  56. data/lib/dev_system/dev/controllers/command/echo_command_test.rb +14 -0
  57. data/lib/dev_system/dev/controllers/command/test_command.rb +70 -0
  58. data/lib/dev_system/dev/controllers/command/test_command_test.rb +14 -0
  59. data/lib/dev_system/dev/controllers/command/version_command.rb +9 -0
  60. data/lib/dev_system/dev/controllers/command/version_command_test.rb +14 -0
  61. data/lib/dev_system/dev/controllers/command.rb +19 -0
  62. data/lib/dev_system/dev/controllers/command_test.rb +14 -0
  63. data/lib/dev_system/dev/dev_box.rb +19 -0
  64. data/lib/dev_system/dev/dev_box_test.rb +19 -0
  65. data/lib/dev_system/dev/panels/command_panel.rb +10 -0
  66. data/lib/dev_system/dev/panels/command_panel_test.rb +23 -0
  67. data/lib/dev_system/dev/panels/log_panel.rb +10 -0
  68. data/lib/dev_system/dev/panels/log_panel_test.rb +18 -0
  69. data/lib/dev_system.rb +8 -0
  70. data/lib/happy_system/dev/happy_command.rb +11 -0
  71. data/lib/happy_system/happy/controllers/axo.rb +8 -0
  72. data/lib/happy_system/happy/happy_box.rb +12 -0
  73. data/lib/happy_system/happy/happy_box_test.rb +18 -0
  74. data/lib/happy_system/happy/panels/axo_panel.rb +5 -0
  75. data/lib/{viral.rb → happy_system.rb} +7 -3
  76. data/lib/liza/base/box.rb +40 -0
  77. data/lib/liza/base/box_test.rb +12 -0
  78. data/lib/liza/base/controller.rb +27 -0
  79. data/lib/liza/base/controller_test.rb +12 -0
  80. data/lib/liza/base/panel.rb +38 -0
  81. data/lib/liza/base/panel_test.rb +16 -0
  82. data/lib/liza/meta/part.rb +19 -0
  83. data/lib/liza/meta/part_extension.rb +13 -0
  84. data/lib/liza/meta/part_test.rb +8 -0
  85. data/lib/liza/meta/system.rb +20 -0
  86. data/lib/liza/meta/system_test.rb +13 -0
  87. data/lib/liza/test/test.rb +11 -0
  88. data/lib/liza/test/test_test.rb +108 -0
  89. data/lib/liza/test_parts/test_assertions_part.rb +110 -0
  90. data/lib/liza/test_parts/test_context_part.rb +81 -0
  91. data/lib/liza/test_parts/test_dsl_part.rb +122 -0
  92. data/lib/liza/test_parts/test_subject_part.rb +19 -0
  93. data/lib/liza/unit.rb +149 -0
  94. data/lib/liza/unit_test.rb +79 -0
  95. data/lib/liza.rb +34 -0
  96. data/lib/lizarb/ruby/class.rb +15 -0
  97. data/lib/lizarb/ruby/string.rb +9 -0
  98. data/lib/lizarb/ruby/time.rb +9 -0
  99. data/lib/{viral → lizarb}/version.rb +2 -2
  100. data/lib/lizarb.rb +68 -0
  101. data/lib/net_system/dev/net_command.rb +24 -0
  102. data/lib/net_system/net/controllers/adapter/redis_adapter.rb +28 -0
  103. data/lib/net_system/net/controllers/adapter/redis_adapter_test.rb +29 -0
  104. data/lib/net_system/net/controllers/adapter/sqlite_adapter.rb +28 -0
  105. data/lib/net_system/net/controllers/adapter/sqlite_adapter_test.rb +29 -0
  106. data/lib/net_system/net/controllers/adapter.rb +5 -0
  107. data/lib/net_system/net/controllers/adapter_test.rb +14 -0
  108. data/lib/net_system/net/controllers/database/redis_db.rb +11 -0
  109. data/lib/net_system/net/controllers/database/redis_db_test.rb +23 -0
  110. data/lib/net_system/net/controllers/database/sqlite_db.rb +11 -0
  111. data/lib/net_system/net/controllers/database/sqlite_db_test.rb +23 -0
  112. data/lib/net_system/net/controllers/database.rb +33 -0
  113. data/lib/net_system/net/controllers/database_test.rb +14 -0
  114. data/lib/net_system/net/controllers/model.rb +31 -0
  115. data/lib/net_system/net/controllers/model_test.rb +14 -0
  116. data/lib/net_system/net/net_box.rb +20 -0
  117. data/lib/net_system/net/net_box_test.rb +19 -0
  118. data/lib/net_system/net/panels/adapter_panel.rb +5 -0
  119. data/lib/net_system/net/panels/adapter_panel_test.rb +18 -0
  120. data/lib/net_system/net/panels/database_panel.rb +12 -0
  121. data/lib/net_system/net/panels/database_panel_test.rb +18 -0
  122. data/lib/net_system.rb +3 -0
  123. data/lib/web_system/dev/web_command.rb +42 -0
  124. data/lib/web_system/web/controllers/request/client_error_request.rb +18 -0
  125. data/lib/web_system/web/controllers/request/not_found_request.rb +18 -0
  126. data/lib/web_system/web/controllers/request/server_error_request.rb +20 -0
  127. data/lib/web_system/web/controllers/request.rb +5 -0
  128. data/lib/web_system/web/controllers/request_test.rb +18 -0
  129. data/lib/web_system/web/panels/request_panel.rb +55 -0
  130. data/lib/web_system/web/panels/request_panel_test.rb +14 -0
  131. data/lib/web_system/web/web_box.rb +12 -0
  132. data/lib/web_system/web/web_box_test.rb +18 -0
  133. data/lib/web_system.rb +5 -0
  134. data/lizarb.gemspec +44 -0
  135. data/sig/{viral.rbs → lizarb.rbs} +1 -1
  136. data/web_files/favicon.ico +0 -0
  137. data/web_files/favicon.svg +948 -0
  138. metadata +190 -13
  139. data/viral.gemspec +0 -45
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bdaa95f6c7eb9982be8bfad6a61cd875f48a2aecbdb31a10ea7cf79de78d9ded
4
- data.tar.gz: 89d87914888398be77d745450ac65643854e41056c4012704d187c760d729a54
3
+ metadata.gz: c859781b1927e69f516b2b6d057b19a4e8d6603945636ce0ec7306640fbd1956
4
+ data.tar.gz: d5849f4bcbf610ee5a94df16dbd92feab78a4f724e2ac77eeae05e93aebfbef5
5
5
  SHA512:
6
- metadata.gz: 6eeb9a8ae5e22359a80d97b2fda20460bd1d2412dbfcde448b032582e6a1ef3b8a26ab7f9b8fc3fb8122c8feb3173e2bb206a97bbf93716a1c2628a76cff41f7
7
- data.tar.gz: de69455fe9e66be7c22f01b545fc9f6e06903bd30670559f7a9bd4ca6f335dd81f8837b86c753d21979199c3dc3a7a950322a90c2f4537d80f1801b519d412df
6
+ metadata.gz: 4e4ffd81acfddf2a8aadebc0fcc10911141b3a8fc55e164d050fc3c8156a7ee560a7a84133c12d19e1491ff9c720b8a6afd857b6c22bdf14844ac03550c2dc6e
7
+ data.tar.gz: bd421065bc059d7ebeac4d3d805e2133a18d0bb31745bc95a4b62d785f2b2368fbd80482cd2a7cac2cec03a239dc58b988844c1a234f4a0aa9a84ef99fc77256
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 3.1.2
data/CHANGELOG.md CHANGED
@@ -1,5 +1,16 @@
1
1
  ## [Unreleased]
2
2
 
3
- ## [0.1.0] - 2022-07-03
3
+ -
4
4
 
5
- - Initial release
5
+ ## [1.0.0] - 2022-10-11
6
+
7
+ - App, Liza and Lizarb
8
+ - Liza::Unit, Liza::Part
9
+ - Liza::Test
10
+ - Liza::Unit has class/instance methods settings/set/set/add/fetch
11
+ - Liza::Unit has class/instance methods log/log_color/log_level/log?/log_level?
12
+ - Liza::System, Liza::Box, Liza::Panel, Liza::Controller
13
+ - DevSystem, Liza::DevBox, Liza::Command, AppCommand, and others
14
+ - HappySystem, Liza::HappyBox, Liza::Axo, Axo, and others
15
+ - NetSystem, Liza::NetBox, Liza::Adapter, Liza::Database, Liza::Model, AppModel, and others
16
+ - WebSystem, Liza::WebBox, Liza::Request, AppRequest, and others
data/Gemfile CHANGED
@@ -2,7 +2,26 @@
2
2
 
3
3
  source "https://rubygems.org"
4
4
 
5
- # Specify your gem's dependencies in viral.gemspec
5
+ # Specify your gem's dependencies in lizarb.gemspec
6
6
  gemspec
7
7
 
8
- # gem "rake", "~> 13.0"
8
+ group :dev do
9
+ # gems you only want to load if DevSystem is loaded
10
+ end
11
+
12
+ group :happy do
13
+ # gems you only want to load if HappySystem is loaded
14
+ end
15
+
16
+ group :net do
17
+ # gems you only want to load if NetSystem is loaded
18
+ gem "redis", "~> 5.0"
19
+ gem "sqlite3", "~> 1.5"
20
+ end
21
+
22
+ group :web do
23
+ # gems you only want to load if WebSystem is loaded
24
+ gem "rack", "~> 3.0"
25
+ gem "rackup", "~> 0.2.2"
26
+ gem "puma", "~> 5.6"
27
+ end
data/Gemfile.lock ADDED
@@ -0,0 +1,44 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ lizarb (1.0.0)
5
+ colorize (~> 0.8)
6
+ dotenv (~> 2.8)
7
+ zeitwerk (~> 2.6)
8
+
9
+ GEM
10
+ remote: https://rubygems.org/
11
+ specs:
12
+ colorize (0.8.1)
13
+ connection_pool (2.3.0)
14
+ dotenv (2.8.1)
15
+ nio4r (2.5.8)
16
+ puma (5.6.5)
17
+ nio4r (~> 2.0)
18
+ rack (3.0.0)
19
+ rackup (0.2.2)
20
+ rack (>= 3.0.0.beta1)
21
+ webrick
22
+ rake (13.0.6)
23
+ redis (5.0.5)
24
+ redis-client (>= 0.9.0)
25
+ redis-client (0.10.0)
26
+ connection_pool
27
+ sqlite3 (1.5.2-x86_64-linux)
28
+ webrick (1.7.0)
29
+ zeitwerk (2.6.1)
30
+
31
+ PLATFORMS
32
+ x86_64-linux
33
+
34
+ DEPENDENCIES
35
+ lizarb!
36
+ puma (~> 5.6)
37
+ rack (~> 3.0)
38
+ rackup (~> 0.2.2)
39
+ rake (~> 13.0)
40
+ redis (~> 5.0)
41
+ sqlite3 (~> 1.5)
42
+
43
+ BUNDLED WITH
44
+ 2.3.22
data/README.md CHANGED
@@ -1,18 +1,82 @@
1
- # Viral
1
+ # Liza
2
2
 
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/viral`. To experiment with that code, run `bin/console` for an interactive prompt.
3
+ Liza is a light, experimental framework primarily developed to help study the Ruby language and the Ruby ecosystem.
4
4
 
5
- TODO: Delete this and the text above, and describe your gem
5
+ ## Install
6
6
 
7
- ## Installation
7
+ Install the gem by executing:
8
8
 
9
- Install the gem and add to the application's Gemfile by executing:
9
+ $ gem install lizarb
10
10
 
11
- $ bundle add viral
11
+ You will get the following three shims:
12
12
 
13
- If bundler is not being used to manage dependencies, install the gem by executing:
13
+ $ lizarb version
14
+ $ liza version
14
15
 
15
- $ gem install viral
16
+ ## Try
17
+
18
+ Try Liza with an interactive prompt
19
+
20
+ $ liza dev
21
+
22
+ ## Running Tests
23
+
24
+ Run your Liza tests
25
+
26
+ $ liza test
27
+
28
+ ## Happy
29
+
30
+ Try Liza and build an ASCII game
31
+
32
+ $ liza happy axo
33
+
34
+ ## Networking
35
+
36
+ Try Liza to connect with Sqlite and Redis
37
+
38
+ $ liza net
39
+
40
+ ```ruby
41
+
42
+ NetBox.adapters.get :sqlite
43
+ NetBox.adapters.get :redis_url
44
+
45
+ NetBox.databases.sql
46
+ NetBox.databases.sqlite
47
+ NetBox.databases.redis
48
+
49
+ RedisDb.current
50
+ SqliteDb.current
51
+
52
+ RedisDb.current.call "TIME"
53
+ SqliteDb.current.call "SELECT name, sql FROM sqlite_master WHERE type = 'table';"
54
+
55
+ ```
56
+
57
+ ## Web Server
58
+
59
+ Try Liza with the Rack Web Server
60
+
61
+ $ liza web
62
+
63
+ http://localhost:3000/
64
+
65
+ http://localhost:3000/xxxxxxx
66
+
67
+ http://localhost:3000/api/xxxxxxx
68
+
69
+ http://localhost:3000/api/auth/sign_up
70
+
71
+ http://localhost:3000/api/auth/sign_in
72
+
73
+ http://localhost:3000/api/auth/account
74
+
75
+ http://localhost:3000/api/auth/sign_out
76
+
77
+ http://localhost:3000/assets/app.css
78
+
79
+ http://localhost:3000/assets/app.js
16
80
 
17
81
  ## Usage
18
82
 
@@ -20,13 +84,25 @@ TODO: Write usage instructions here
20
84
 
21
85
  ## Development
22
86
 
23
- After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
87
+ To install dependencies, run this bash script:
88
+
89
+ $ bin/setup
90
+
91
+ For development experiments, use the local executable script
92
+
93
+ $ exe/lizarb test
94
+
95
+ To build and install lizarb in your local machine
96
+
97
+ $ bundle exec rake install
98
+
99
+ ## Release
24
100
 
25
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
101
+ To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
26
102
 
27
103
  ## Contributing
28
104
 
29
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/viral. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/viral/blob/master/CODE_OF_CONDUCT.md).
105
+ Bug reports and pull requests are welcome on GitHub at https://github.com/rubyonrails-brasil/lizarb. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/rubyonrails-brasil/lizarb/blob/master/CODE_OF_CONDUCT.md).
30
106
 
31
107
  ## License
32
108
 
@@ -34,4 +110,4 @@ The gem is available as open source under the terms of the [MIT License](https:/
34
110
 
35
111
  ## Code of Conduct
36
112
 
37
- Everyone interacting in the Viral project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/viral/blob/master/CODE_OF_CONDUCT.md).
113
+ Everyone interacting in the Lizarb project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/rubyonrails-brasil/lizarb/blob/master/CODE_OF_CONDUCT.md).
@@ -0,0 +1,5 @@
1
+ class AppCommand < Liza::Command
2
+
3
+ # Set up your command controllers per the DSL in http://guides.lizarb.org/controllers/command.html
4
+
5
+ end
@@ -0,0 +1,7 @@
1
+ class AppCommandTest < Liza::CommandTest
2
+
3
+ test :subject_class do
4
+ assert subject_class == AppCommand
5
+ end
6
+
7
+ end
@@ -0,0 +1,57 @@
1
+ class ExampleCommand < AppCommand
2
+
3
+ def self.call(args)
4
+ log :higher, "Called #{self}.#{__method__} with args #{args}"
5
+
6
+ class_helper_method_1(args)
7
+ class_helper_method_2(args)
8
+ class_helper_method_3(args)
9
+
10
+ command = new(args)
11
+ command.helper_method_1(args)
12
+ command.helper_method_2(args)
13
+ command.helper_method_3(args)
14
+ end
15
+
16
+ #
17
+
18
+ def self.class_helper_method_1(args)
19
+ log :higher, "Called #{self}.#{__method__} with args #{args}"
20
+ 1
21
+ end
22
+
23
+ def self.class_helper_method_2(args)
24
+ log :higher, "Called #{self}.#{__method__} with args #{args}"
25
+ 2
26
+ end
27
+
28
+ def self.class_helper_method_3(args)
29
+ log :higher, "Called #{self}.#{__method__} with args #{args}"
30
+ 3
31
+ end
32
+
33
+ #
34
+
35
+ def initialize(args)
36
+ log :higher, "Called #{self}.#{__method__} with args #{args}"
37
+ @init_args = args
38
+ end
39
+
40
+ #
41
+
42
+ def helper_method_1(args)
43
+ log :higher, "Called #{self}.#{__method__} (which has @init_args #{@init_args}) with args #{args}"
44
+ @init_args[0]
45
+ end
46
+
47
+ def helper_method_2(args)
48
+ log :higher, "Called #{self}.#{__method__} (which has @init_args #{@init_args}) with args #{args}"
49
+ @init_args[1]
50
+ end
51
+
52
+ def helper_method_3(args)
53
+ log :higher, "Called #{self}.#{__method__} (which has @init_args #{@init_args}) with args #{args}"
54
+ @init_args[2]
55
+ end
56
+
57
+ end
@@ -0,0 +1,43 @@
1
+ class ExampleCommandTest < AppCommandTest
2
+
3
+ test :subject_class do
4
+ assert subject_class == ExampleCommand
5
+ end
6
+
7
+ group "class methods" do
8
+
9
+ test :class_helper_method_1 do
10
+ assert subject_class.class_helper_method_1([]) == 1
11
+ end
12
+
13
+ test :class_helper_method_2 do
14
+ assert subject_class.class_helper_method_2([]) == 2
15
+ end
16
+
17
+ test :class_helper_method_3 do
18
+ assert subject_class.class_helper_method_3([]) == 3
19
+ end
20
+
21
+ end
22
+
23
+ group "instance methods" do
24
+
25
+ before do
26
+ @subject = subject_class.new([1, 2, 3])
27
+ end
28
+
29
+ test :helper_method_1 do
30
+ assert @subject.helper_method_1([]) == 1
31
+ end
32
+
33
+ test :helper_method_2 do
34
+ assert @subject.helper_method_2([]) == 2
35
+ end
36
+
37
+ test :helper_method_3 do
38
+ assert @subject.helper_method_3([]) == 3
39
+ end
40
+
41
+ end
42
+
43
+ end
@@ -0,0 +1,32 @@
1
+ class MacroChildCommand < MacroParentCommand
2
+
3
+ class_macro_method_1 :important_thing
4
+ class_macro_method_2 :other_thing
5
+ class_macro_method_3 :other_important_thing
6
+ class_macro_method_4 :ruby_is_awesome
7
+
8
+ #
9
+
10
+ def call(args)
11
+ log :higher, "Called #{self}.#{__method__} (which has @init_args #{@init_args}) with args #{args}"
12
+
13
+ if @@class_macro_3
14
+ @result << :YES_from_instance_call
15
+ else
16
+ @result << :NO_from_instance_call
17
+ end
18
+
19
+ @result << helper_method(args)
20
+ end
21
+
22
+ def helper_method(args)
23
+ log :higher, "Called #{self}.#{__method__} (which has @init_args #{@init_args}) with args #{args}"
24
+
25
+ if @@class_macro_4
26
+ :Yes_from_helper_method
27
+ else
28
+ :No_from_helper_method
29
+ end
30
+ end
31
+
32
+ end
@@ -0,0 +1,7 @@
1
+ class MacroChildCommandTest < AppCommandTest
2
+
3
+ test :subject_class do
4
+ assert subject_class == MacroChildCommand
5
+ end
6
+
7
+ end
@@ -0,0 +1,70 @@
1
+ class MacroParentCommand < AppCommand
2
+
3
+ def self.class_macro_method_1(arg)
4
+ log :higher, "Called #{self}.#{__method__} with arg #{arg}"
5
+ @@class_macro_1 = arg
6
+ end
7
+
8
+ def self.class_macro_method_2(arg)
9
+ log :higher, "Called #{self}.#{__method__} with arg #{arg}"
10
+ @@class_macro_2 = arg
11
+ end
12
+
13
+ def self.class_macro_method_3(arg)
14
+ log :higher, "Called #{self}.#{__method__} with arg #{arg}"
15
+ @@class_macro_3 = arg
16
+ end
17
+
18
+ def self.class_macro_method_4(arg)
19
+ log :higher, "Called #{self}.#{__method__} with arg #{arg}"
20
+ @@class_macro_4 = arg
21
+ end
22
+
23
+ #
24
+
25
+ def self.call(args)
26
+ log :higher, "Called #{self}.#{__method__} with args #{args}"
27
+
28
+ if @@class_macro_1
29
+ args << :yes_from_class_call
30
+ else
31
+ args << :no_from_class_call
32
+ end
33
+
34
+ command = new(args)
35
+ result = command.call(args)
36
+
37
+ puts <<-OUTPUT
38
+
39
+ self: #{self}
40
+ args: #{args}
41
+ command: #{command}
42
+ result: #{result}
43
+
44
+ OUTPUT
45
+ end
46
+
47
+ #
48
+
49
+ attr_reader :result
50
+
51
+ def initialize(args)
52
+ log :higher, "Called #{self}.#{__method__} with args #{args}"
53
+ @init_args = args
54
+
55
+ @result = [args]
56
+
57
+ if @@class_macro_2
58
+ @result << :yes_from_initialize
59
+ else
60
+ @result << :no_from_initialize
61
+ end
62
+ end
63
+
64
+ #
65
+
66
+ def call(args)
67
+ raise NotImplementedError, "implement this on MacroChildCommand"
68
+ end
69
+
70
+ end
@@ -0,0 +1,7 @@
1
+ class MacroParentCommandTest < AppCommandTest
2
+
3
+ test :subject_class do
4
+ assert subject_class == MacroParentCommand
5
+ end
6
+
7
+ end
@@ -0,0 +1,7 @@
1
+ class MyCommand < AppCommand
2
+
3
+ def self.call args
4
+ log :higher, "Called #{self}.#{__method__} with args #{args}"
5
+ end
6
+
7
+ end
@@ -0,0 +1,7 @@
1
+ class MyCommandTest < AppCommandTest
2
+
3
+ test :subject_class do
4
+ assert subject_class == MyCommand
5
+ end
6
+
7
+ end
@@ -0,0 +1,69 @@
1
+ class NewCommand < AppCommand
2
+
3
+ def self.call args
4
+ log :higher, "Called #{self}.#{__method__} with args #{args}"
5
+
6
+ # setup
7
+
8
+ name = args.shift || "app_1"
9
+
10
+ from = "#{Lizarb::APP_DIR}/app_new"
11
+ to = name
12
+
13
+ return log "Directory #{to.light_green} already exists." if Dir.exist? to
14
+
15
+ log "Liza Application initializing at `#{to}`"
16
+
17
+ # init
18
+
19
+ require "fileutils"
20
+ FileUtils.cp_r from, to, verbose: true
21
+
22
+ `cd #{to}; git init .`
23
+
24
+ # extra
25
+
26
+ puts
27
+ FileUtils.mkdir_p "#{to}/app", verbose: true
28
+
29
+ FileUtils.mkdir_p "#{to}/lib", verbose: true
30
+ FileUtils.touch "#{to}/lib/.gitkeep", verbose: true
31
+ FileUtils.mkdir_p "#{to}/tmp", verbose: true
32
+ FileUtils.touch "#{to}/tmp/.gitkeep", verbose: true
33
+
34
+ # systems
35
+
36
+ App.systems.keys.each { |system_name| copy name, system_name }
37
+
38
+ FileUtils.rm "#{to}/app/dev/commands/new_command.rb"
39
+ FileUtils.rm "#{to}/app/dev/commands/new_command_test.rb"
40
+
41
+ FileUtils.cp_r "#{Lizarb::APP_DIR}/.ruby-version", "#{to}/.ruby-version", verbose: true
42
+ FileUtils.cp_r "#{Lizarb::APP_DIR}/README.md", "#{to}/README.md", verbose: true
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
+ puts
47
+
48
+ log "Liza Application initialized at `#{to}`"
49
+ end
50
+
51
+ def self.copy name, system_name
52
+ from = "#{Lizarb::APP_DIR}/app/#{system_name}_box.rb"
53
+ to = "#{name}/app"
54
+ if File.exist? from
55
+ FileUtils.cp_r from, to, verbose: true
56
+ else
57
+ puts "file not found #{from}"
58
+ end
59
+
60
+ from = "#{Lizarb::APP_DIR}/app/#{system_name}"
61
+ to = "#{name}/app"
62
+ if File.exist? from
63
+ FileUtils.cp_r from, to, verbose: true
64
+ else
65
+ puts "file not found #{from}"
66
+ end
67
+ end
68
+
69
+ end
@@ -0,0 +1,7 @@
1
+ class NewCommandTest < AppCommandTest
2
+
3
+ test :subject_class do
4
+ assert subject_class == NewCommand
5
+ end
6
+
7
+ end
data/app/dev_box.rb ADDED
@@ -0,0 +1,13 @@
1
+ class DevBox < Liza::DevBox
2
+
3
+ commands do
4
+ # Set up your command panel per the DSL in http://guides.lizarb.com/panels/command.html
5
+
6
+ end
7
+
8
+ logs do
9
+ # Set up your log panel per the DSL in http://guides.lizarb.com/panels/log.html
10
+
11
+ end
12
+
13
+ end
@@ -0,0 +1,50 @@
1
+ class Axo < Liza::Axo
2
+
3
+ # Set up your request controllers per the DSL in http://guides.lizarb.org/controllers/axo.html
4
+
5
+ def self.call args
6
+ cycles = args[0] || "3"
7
+ sleep_time = args[1] || "3"
8
+
9
+ cycles = cycles.to_i
10
+ sleep_time = sleep_time.to_f / 10
11
+
12
+ array = <<-HEREDOC.split("\n")
13
+ >(.___.)<
14
+ >(.__.)<
15
+ >(.___.)< code
16
+ >(.__.)< code to
17
+ >(.___.)< code to the
18
+ >(.__.)< code to the right
19
+ >(.___.)< code to the right
20
+ >(.__.)<
21
+ code >(.___.)<
22
+ code to >(.__.)<
23
+ code to the >(.___.)<
24
+ code to the left >(.__.)<
25
+ code to the left >(.___.)<
26
+ >(.__.)<
27
+ HEREDOC
28
+
29
+ cycles.times do |i|
30
+ array.each_with_index do |s, j|
31
+ system "clear"
32
+
33
+ puts "Axo v0"
34
+ puts "frame: #{j}/#{array.size}"
35
+ puts "cycle: #{i}/#{cycles} (#{sleep_time}spf)"
36
+ puts
37
+ puts
38
+ puts " " * 3 + s.bold.light_white
39
+ puts
40
+
41
+ sleep sleep_time
42
+ end
43
+ end
44
+
45
+ puts "That was actually quite a nice workout session!".black.on_white
46
+ puts " We should do this again some time. ".black.on_white
47
+
48
+ end
49
+
50
+ end
data/app/happy_box.rb ADDED
@@ -0,0 +1,8 @@
1
+ class HappyBox < Liza::HappyBox
2
+
3
+ axo do
4
+ # Set up your axo panel per the DSL in http://guides.lizarb.com/panels/axo.html
5
+
6
+ end
7
+
8
+ end
@@ -0,0 +1,5 @@
1
+ class RedisDb < Liza::RedisDb
2
+
3
+ # Set up your database controllers per the DSL in http://guides.lizarb.org/controllers/database.html
4
+
5
+ end
@@ -0,0 +1,12 @@
1
+ class RedisDbTest < Liza::RedisDbTest
2
+
3
+ test :subject_class do
4
+ assert subject_class == RedisDb
5
+ assert RedisDb.current.class == RedisDb
6
+ assert Liza::RedisDb.current.class == RedisDb
7
+ assert RedisDb.current == Liza::RedisDb.current
8
+ assert RedisDb.current.adapter == Liza::RedisDb.current.adapter
9
+ assert RedisDb.current.adapter.conn == Liza::RedisDb.current.adapter.conn
10
+ end
11
+
12
+ end
@@ -0,0 +1,11 @@
1
+ class SqliteDb < Liza::SqliteDb
2
+
3
+ # Set up your database controllers per the DSL in http://guides.lizarb.org/controllers/database.html
4
+
5
+ def table_names
6
+ result = call "SELECT name FROM sqlite_schema;"
7
+ result.delete_at 0
8
+ result.flatten
9
+ end
10
+
11
+ end