lizarb 0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (175) hide show
  1. checksums.yaml +4 -4
  2. data/.ruby-version +1 -0
  3. data/CHANGELOG.md +13 -2
  4. data/Gemfile +22 -2
  5. data/Gemfile.lock +52 -0
  6. data/README.md +88 -12
  7. data/app/dev/benches/app_bench.rb +5 -0
  8. data/app/dev/benches/app_bench_test.rb +7 -0
  9. data/app/dev/benches/loops_bench.rb +148 -0
  10. data/app/dev/benches/loops_bench_test.rb +11 -0
  11. data/app/dev/commands/app_command.rb +5 -0
  12. data/app/dev/commands/app_command_test.rb +7 -0
  13. data/app/dev/commands/example_command.rb +57 -0
  14. data/app/dev/commands/example_command_test.rb +43 -0
  15. data/app/dev/commands/macro_child_command.rb +32 -0
  16. data/app/dev/commands/macro_child_command_test.rb +7 -0
  17. data/app/dev/commands/macro_parent_command.rb +70 -0
  18. data/app/dev/commands/macro_parent_command_test.rb +7 -0
  19. data/app/dev/commands/my_command.rb +7 -0
  20. data/app/dev/commands/my_command_test.rb +7 -0
  21. data/app/dev/commands/new_command.rb +9 -0
  22. data/app/dev/commands/new_command_test.rb +7 -0
  23. data/app/dev/generators/bench_generator.rb +67 -0
  24. data/app/dev/generators/bench_generator_test.rb +12 -0
  25. data/app/dev/generators/command_generator.rb +51 -0
  26. data/app/dev/generators/command_generator_test.rb +12 -0
  27. data/app/dev/generators/model_generator.rb +46 -0
  28. data/app/dev/generators/model_generator_test.rb +12 -0
  29. data/app/dev/generators/request_generator.rb +63 -0
  30. data/app/dev/generators/request_generator_test.rb +12 -0
  31. data/app/dev_box.rb +13 -0
  32. data/app/happy/axos/axo.rb +50 -0
  33. data/app/happy_box.rb +8 -0
  34. data/app/net/databases/redis_db.rb +5 -0
  35. data/app/net/databases/redis_db_test.rb +12 -0
  36. data/app/net/databases/sqlite_db.rb +11 -0
  37. data/app/net/databases/sqlite_db_test.rb +12 -0
  38. data/app/net/models/app_model.rb +20 -0
  39. data/app/net/models/app_model_test.rb +8 -0
  40. data/app/net/models/post_model.rb +4 -0
  41. data/app/net/models/post_model_test.rb +8 -0
  42. data/app/net/models/user_model.rb +4 -0
  43. data/app/net/models/user_model_test.rb +8 -0
  44. data/app/net_box.rb +21 -0
  45. data/app/web/requests/api_request.rb +61 -0
  46. data/app/web/requests/api_request_test.rb +31 -0
  47. data/app/web/requests/app_request.rb +5 -0
  48. data/app/web/requests/app_request_test.rb +7 -0
  49. data/app/web/requests/assets_request.rb +71 -0
  50. data/app/web/requests/assets_request_test.rb +33 -0
  51. data/app/web/requests/root_request.rb +55 -0
  52. data/app/web/requests/root_request_test.rb +31 -0
  53. data/app/web_box.rb +8 -0
  54. data/app.code.env +11 -0
  55. data/app.env +11 -0
  56. data/app.rb +17 -0
  57. data/app_new/.gitignore +4 -0
  58. data/app_new/Gemfile +31 -0
  59. data/app_new/Procfile +3 -0
  60. data/exe/Gemfile +3 -0
  61. data/exe/Gemfile.lock +13 -0
  62. data/exe/liza +3 -0
  63. data/exe/lizarb +11 -0
  64. data/lib/app.rb +200 -0
  65. data/lib/dev_system/dev/controllers/bench.rb +11 -0
  66. data/lib/dev_system/dev/controllers/bench_dsl_main_part.rb +60 -0
  67. data/lib/dev_system/dev/controllers/bench_test.rb +14 -0
  68. data/lib/dev_system/dev/controllers/command/bench_command.rb +24 -0
  69. data/lib/dev_system/dev/controllers/command/bench_command_test.rb +14 -0
  70. data/lib/dev_system/dev/controllers/command/dev_command.rb +24 -0
  71. data/lib/dev_system/dev/controllers/command/dev_command_test.rb +14 -0
  72. data/lib/dev_system/dev/controllers/command/echo_command.rb +11 -0
  73. data/lib/dev_system/dev/controllers/command/echo_command_test.rb +14 -0
  74. data/lib/dev_system/dev/controllers/command/generate_command.rb +23 -0
  75. data/lib/dev_system/dev/controllers/command/generate_command_test.rb +14 -0
  76. data/lib/dev_system/dev/controllers/command/test_command.rb +70 -0
  77. data/lib/dev_system/dev/controllers/command/test_command_test.rb +14 -0
  78. data/lib/dev_system/dev/controllers/command/version_command.rb +9 -0
  79. data/lib/dev_system/dev/controllers/command/version_command_test.rb +14 -0
  80. data/lib/dev_system/dev/controllers/command.rb +19 -0
  81. data/lib/dev_system/dev/controllers/command_test.rb +14 -0
  82. data/lib/dev_system/dev/controllers/generator.rb +11 -0
  83. data/lib/dev_system/dev/controllers/generator_dsl_main_part.rb +54 -0
  84. data/lib/dev_system/dev/controllers/generator_test.rb +14 -0
  85. data/lib/dev_system/dev/controllers/generators/app_generator.rb +71 -0
  86. data/lib/dev_system/dev/controllers/generators/app_generator_test.rb +14 -0
  87. data/lib/dev_system/dev/controllers/shell/file_shell.rb +29 -0
  88. data/lib/dev_system/dev/controllers/shell/file_shell_test.rb +14 -0
  89. data/lib/dev_system/dev/controllers/shell.rb +19 -0
  90. data/lib/dev_system/dev/controllers/shell_test.rb +13 -0
  91. data/lib/dev_system/dev/controllers/terminal/irb_terminal.rb +19 -0
  92. data/lib/dev_system/dev/controllers/terminal/irb_terminal_test.rb +14 -0
  93. data/lib/dev_system/dev/controllers/terminal/pry_terminal.rb +12 -0
  94. data/lib/dev_system/dev/controllers/terminal/pry_terminal_test.rb +14 -0
  95. data/lib/dev_system/dev/controllers/terminal.rb +19 -0
  96. data/lib/dev_system/dev/controllers/terminal_test.rb +14 -0
  97. data/lib/dev_system/dev/dev_box.rb +22 -0
  98. data/lib/dev_system/dev/dev_box_test.rb +19 -0
  99. data/lib/dev_system/dev/panels/command_panel.rb +10 -0
  100. data/lib/dev_system/dev/panels/command_panel_test.rb +23 -0
  101. data/lib/dev_system/dev/panels/log_panel.rb +10 -0
  102. data/lib/dev_system/dev/panels/log_panel_test.rb +18 -0
  103. data/lib/dev_system.rb +8 -0
  104. data/lib/happy_system/dev/happy_command.rb +11 -0
  105. data/lib/happy_system/happy/controllers/axo.rb +8 -0
  106. data/lib/happy_system/happy/happy_box.rb +12 -0
  107. data/lib/happy_system/happy/happy_box_test.rb +18 -0
  108. data/lib/happy_system/happy/panels/axo_panel.rb +5 -0
  109. data/lib/{viral.rb → happy_system.rb} +7 -3
  110. data/lib/liza/base/box.rb +40 -0
  111. data/lib/liza/base/box_test.rb +12 -0
  112. data/lib/liza/base/controller.rb +27 -0
  113. data/lib/liza/base/controller_test.rb +12 -0
  114. data/lib/liza/base/panel.rb +38 -0
  115. data/lib/liza/base/panel_test.rb +16 -0
  116. data/lib/liza/meta/part.rb +19 -0
  117. data/lib/liza/meta/part_extension.rb +13 -0
  118. data/lib/liza/meta/part_test.rb +8 -0
  119. data/lib/liza/meta/system.rb +20 -0
  120. data/lib/liza/meta/system_test.rb +13 -0
  121. data/lib/liza/test/test.rb +11 -0
  122. data/lib/liza/test/test_test.rb +108 -0
  123. data/lib/liza/test_parts/test_assertions_part.rb +110 -0
  124. data/lib/liza/test_parts/test_context_part.rb +81 -0
  125. data/lib/liza/test_parts/test_dsl_part.rb +122 -0
  126. data/lib/liza/test_parts/test_subject_part.rb +24 -0
  127. data/lib/liza/unit.rb +149 -0
  128. data/lib/liza/unit_test.rb +79 -0
  129. data/lib/liza.rb +62 -0
  130. data/lib/lizarb/ruby/class.rb +17 -0
  131. data/lib/lizarb/ruby/proc.rb +12 -0
  132. data/lib/lizarb/ruby/string.rb +25 -0
  133. data/lib/lizarb/ruby/time.rb +9 -0
  134. data/lib/{viral → lizarb}/version.rb +2 -2
  135. data/lib/lizarb.rb +68 -0
  136. data/lib/net_system/dev/net_command.rb +24 -0
  137. data/lib/net_system/net/controllers/client/redis_client.rb +28 -0
  138. data/lib/net_system/net/controllers/client/redis_client_test.rb +29 -0
  139. data/lib/net_system/net/controllers/client/sqlite_client.rb +28 -0
  140. data/lib/net_system/net/controllers/client/sqlite_client_test.rb +29 -0
  141. data/lib/net_system/net/controllers/client.rb +5 -0
  142. data/lib/net_system/net/controllers/client_test.rb +14 -0
  143. data/lib/net_system/net/controllers/database/redis_db.rb +11 -0
  144. data/lib/net_system/net/controllers/database/redis_db_test.rb +23 -0
  145. data/lib/net_system/net/controllers/database/sqlite_db.rb +11 -0
  146. data/lib/net_system/net/controllers/database/sqlite_db_test.rb +23 -0
  147. data/lib/net_system/net/controllers/database.rb +33 -0
  148. data/lib/net_system/net/controllers/database_test.rb +14 -0
  149. data/lib/net_system/net/controllers/model.rb +31 -0
  150. data/lib/net_system/net/controllers/model_test.rb +14 -0
  151. data/lib/net_system/net/net_box.rb +20 -0
  152. data/lib/net_system/net/net_box_test.rb +19 -0
  153. data/lib/net_system/net/panels/client_panel.rb +5 -0
  154. data/lib/net_system/net/panels/client_panel_test.rb +18 -0
  155. data/lib/net_system/net/panels/database_panel.rb +12 -0
  156. data/lib/net_system/net/panels/database_panel_test.rb +18 -0
  157. data/lib/net_system.rb +3 -0
  158. data/lib/web_system/dev/web_command.rb +42 -0
  159. data/lib/web_system/web/controllers/request/client_error_request.rb +18 -0
  160. data/lib/web_system/web/controllers/request/not_found_request.rb +18 -0
  161. data/lib/web_system/web/controllers/request/server_error_request.rb +20 -0
  162. data/lib/web_system/web/controllers/request.rb +5 -0
  163. data/lib/web_system/web/controllers/request_test.rb +18 -0
  164. data/lib/web_system/web/panels/request_panel.rb +55 -0
  165. data/lib/web_system/web/panels/request_panel_test.rb +14 -0
  166. data/lib/web_system/web/web_box.rb +12 -0
  167. data/lib/web_system/web/web_box_test.rb +18 -0
  168. data/lib/web_system.rb +5 -0
  169. data/lizarb.gemspec +44 -0
  170. data/sig/{viral.rbs → lizarb.rbs} +1 -1
  171. data/tmp/.gitkeep +0 -0
  172. data/web_files/favicon.ico +0 -0
  173. data/web_files/favicon.svg +948 -0
  174. metadata +226 -13
  175. 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: c4e73803f6fe207c86ff2e6799e3bdbe50979bbe9fb409750c067ef6ce299c5b
4
+ data.tar.gz: 46c590ae60a43c0fd0b901f800da5f8761cc70baae0ace96e64a772941c6512f
5
5
  SHA512:
6
- metadata.gz: 6eeb9a8ae5e22359a80d97b2fda20460bd1d2412dbfcde448b032582e6a1ef3b8a26ab7f9b8fc3fb8122c8feb3173e2bb206a97bbf93716a1c2628a76cff41f7
7
- data.tar.gz: de69455fe9e66be7c22f01b545fc9f6e06903bd30670559f7a9bd4ca6f335dd81f8837b86c753d21979199c3dc3a7a950322a90c2f4537d80f1801b519d412df
6
+ metadata.gz: 1c83f9babff78a0487784c8c62bf98cf3dd44e64a01267c57bcb1bd4938c980ec09759f4069ef6819088511e25ef6e29f6acc3920ae950c71d00e43d362970c9
7
+ data.tar.gz: 043bbe7ac4dc5102f3a2b8b261ff13e7a8784d6217a5474b40d8110005b4060d281cf73f938172e0487564c80427d7f63f3e2c1df6c9a3b252f6fd214052070a
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,27 @@
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
+ gem "pry", "~> 0.14.1"
11
+ end
12
+
13
+ group :happy do
14
+ # gems you only want to load if HappySystem is loaded
15
+ end
16
+
17
+ group :net do
18
+ # gems you only want to load if NetSystem is loaded
19
+ gem "redis", "~> 5.0"
20
+ gem "sqlite3", "~> 1.5"
21
+ end
22
+
23
+ group :web do
24
+ # gems you only want to load if WebSystem is loaded
25
+ gem "rack", "~> 3.0"
26
+ gem "rackup", "~> 0.2.2"
27
+ gem "puma", "~> 5.6"
28
+ end
data/Gemfile.lock ADDED
@@ -0,0 +1,52 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ lizarb (1.0.1)
5
+ colorize (~> 0.8)
6
+ dotenv (~> 2.8)
7
+ zeitwerk (~> 2.6)
8
+
9
+ GEM
10
+ remote: https://rubygems.org/
11
+ specs:
12
+ coderay (1.1.3)
13
+ colorize (0.8.1)
14
+ connection_pool (2.3.0)
15
+ dotenv (2.8.1)
16
+ method_source (1.0.0)
17
+ nio4r (2.5.8)
18
+ pry (0.14.1)
19
+ coderay (~> 1.1)
20
+ method_source (~> 1.0)
21
+ puma (5.6.5)
22
+ nio4r (~> 2.0)
23
+ rack (3.0.0)
24
+ rackup (0.2.2)
25
+ rack (>= 3.0.0.beta1)
26
+ webrick
27
+ rake (13.0.6)
28
+ redis (5.0.5)
29
+ redis-client (>= 0.9.0)
30
+ redis-client (0.10.0)
31
+ connection_pool
32
+ sqlite3 (1.5.3-arm64-darwin)
33
+ sqlite3 (1.5.3-x86_64-linux)
34
+ webrick (1.7.0)
35
+ zeitwerk (2.6.1)
36
+
37
+ PLATFORMS
38
+ arm64-darwin-21
39
+ x86_64-linux
40
+
41
+ DEPENDENCIES
42
+ lizarb!
43
+ pry (~> 0.14.1)
44
+ puma (~> 5.6)
45
+ rack (~> 3.0)
46
+ rackup (~> 0.2.2)
47
+ rake (~> 13.0)
48
+ redis (~> 5.0)
49
+ sqlite3 (~> 1.5)
50
+
51
+ BUNDLED WITH
52
+ 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.clients.get :sqlite
43
+ NetBox.clients.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 AppBench < Liza::Bench
2
+
3
+ # Set up your bench controllers per the DSL in http://guides.lizarb.org/controllers/bench.html
4
+
5
+ end
@@ -0,0 +1,7 @@
1
+ class AppBenchTest < Liza::BenchTest
2
+
3
+ test :subject_class do
4
+ assert subject_class == AppBench
5
+ end
6
+
7
+ end
@@ -0,0 +1,148 @@
1
+ class LoopsBench < AppBench
2
+ main_dsl
3
+
4
+ setup do
5
+ N = 1_000_000
6
+ RANGE = 1..N
7
+ ARRAY = Array RANGE
8
+ HASH_INT = RANGE.map { |i| [i, i] }.to_h
9
+ HASH_STR = RANGE.map { |i| ["a#{i}", i] }.to_h
10
+ HASH_SYM = RANGE.map { |i| [:"a#{i}", i] }.to_h
11
+ end
12
+
13
+ mark "for i in RANGE" do
14
+ for i in RANGE
15
+ a = "1"
16
+ end
17
+ end
18
+
19
+ mark "for i in ARRAY" do
20
+ for i in ARRAY
21
+ a = "1"
22
+ end
23
+ end
24
+
25
+ mark "for i, iv in HASH_INT" do
26
+ for i, iv in HASH_INT
27
+ a = "1"
28
+ end
29
+ end
30
+
31
+ mark "for i, iv in HASH_STR" do
32
+ for i, iv in HASH_STR
33
+ a = "1"
34
+ end
35
+ end
36
+
37
+ mark "for i, iv in HASH_SYM" do
38
+ for i, iv in HASH_SYM
39
+ a = "1"
40
+ end
41
+ end
42
+
43
+ mark "RANGE.each do |i|" do
44
+ RANGE.each do |i|
45
+ a = "1"
46
+ end
47
+ end
48
+
49
+ mark "ARRAY.each do |i|" do
50
+ ARRAY.each do |i|
51
+ a = "1"
52
+ end
53
+ end
54
+
55
+ mark "HASH_INT.each do |i, iv|" do
56
+ HASH_INT.each do |i, iv|
57
+ a = "1"
58
+ end
59
+ end
60
+
61
+ mark "HASH_STR.each do |i, iv|" do
62
+ HASH_STR.each do |i, iv|
63
+ a = "1"
64
+ end
65
+ end
66
+
67
+ mark "HASH_SYM.each do |i, iv|" do
68
+ HASH_SYM.each do |i, iv|
69
+ a = "1"
70
+ end
71
+ end
72
+
73
+ mark "RANGE.map do |i|" do
74
+ RANGE.map do |i|
75
+ a = "1"
76
+ end
77
+ end
78
+
79
+ mark "ARRAY.map do |i|" do
80
+ ARRAY.map do |i|
81
+ a = "1"
82
+ end
83
+ end
84
+
85
+ mark "HASH_INT.map do |i, iv|" do
86
+ HASH_INT.map do |i, iv|
87
+ a = "1"
88
+ end
89
+ end
90
+
91
+ mark "HASH_STR.map do |i, iv|" do
92
+ HASH_STR.map do |i, iv|
93
+ a = "1"
94
+ end
95
+ end
96
+
97
+ mark "HASH_SYM.map do |i, iv|" do
98
+ HASH_SYM.map do |i, iv|
99
+ a = "1"
100
+ end
101
+ end
102
+
103
+ mark "N.times do |i|" do
104
+ N.times do |i|
105
+ a = "1"
106
+ end
107
+ end
108
+
109
+ mark "1.upto N do |i|" do
110
+ 1.upto N do |i|
111
+ a = "1"
112
+ end
113
+ end
114
+
115
+ mark "loop break" do
116
+ i = 0
117
+
118
+ loop do
119
+ a = "1"
120
+ break unless (i += 1) <= N
121
+ end
122
+ end
123
+
124
+ mark "while" do
125
+ i = 0
126
+
127
+ while (i += 1) <= N
128
+ a = "1"
129
+ end
130
+ end
131
+
132
+ mark "begin end while" do
133
+ i = 0
134
+
135
+ begin
136
+ a = "1"
137
+ end while (i += 1) <= N
138
+ end
139
+
140
+ mark "begin end until" do
141
+ i = 0
142
+
143
+ begin
144
+ a = "1"
145
+ end until (i += 1) == N
146
+ end
147
+
148
+ end
@@ -0,0 +1,11 @@
1
+ class LoopsBenchTest < AppBenchTest
2
+
3
+ test :subject_class do
4
+ assert subject_class == LoopsBench
5
+ end
6
+
7
+ test :marks do
8
+ assert subject_class.marks.keys.count.positive?
9
+ end
10
+
11
+ end
@@ -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,9 @@
1
+ class NewCommand < AppCommand
2
+
3
+ def self.call args
4
+ log :higher, "Called #{self}.#{__method__} with args #{args}"
5
+
6
+ Liza::GenerateCommand.call ["app", *args]
7
+ end
8
+
9
+ 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