rooibos 0.7.0 → 0.7.2
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.
- checksums.yaml +4 -4
- data/lib/rooibos/router/guard.rb +7 -1
- data/lib/rooibos/version.rb +1 -1
- data/lib/rooibos/welcome.rb +19 -2
- data/sig/rooibos/router/guard.rbs +8 -0
- data/sig/rooibos/welcome.rbs +3 -0
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 84b4f67bd8240b412f78b91e8e8e52af841e6438694bb51013519d3ba6e28fe7
|
|
4
|
+
data.tar.gz: 63ac12eba2aee98ecf595aa948d457babc3533ce66b2d9fa20eee5257e26bcf1
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 193556d2bf1093e16c1229162e579113c3d4a75c472cf37c071db593f4d1506405de0c7eaf1bccfcb9b2555335ed304c64d25f1cd08231c7c084a58bfa9ba731
|
|
7
|
+
data.tar.gz: a8ab3b783bc7f40527f05b15d7c32e971f70518cb9a4769f5d0312590ff866773debe986dcfb93ab36e8cf61a95dc40f9b91db842557633b36333296ffaf6fbf
|
data/lib/rooibos/router/guard.rb
CHANGED
|
@@ -32,10 +32,16 @@ module Rooibos
|
|
|
32
32
|
new(callable: apply_scope(normalized))
|
|
33
33
|
end
|
|
34
34
|
|
|
35
|
+
# Combines two guards into a single callable without creating a closure.
|
|
36
|
+
class CombinedGuard < Data.define(:inner, :outer)
|
|
37
|
+
def arity = 2
|
|
38
|
+
def call(msg, model) = inner.call(msg, model) && outer.call(msg, model)
|
|
39
|
+
end
|
|
40
|
+
|
|
35
41
|
private_class_method def self.apply_scope(callable)
|
|
36
42
|
@scope.inject(callable) do |inner, outer|
|
|
37
43
|
if inner
|
|
38
|
-
|
|
44
|
+
CombinedGuard.new(inner:, outer:)
|
|
39
45
|
else
|
|
40
46
|
outer
|
|
41
47
|
end
|
data/lib/rooibos/version.rb
CHANGED
data/lib/rooibos/welcome.rb
CHANGED
|
@@ -8,6 +8,20 @@
|
|
|
8
8
|
module Rooibos
|
|
9
9
|
# Built-in welcome screen used by scaffolded applications.
|
|
10
10
|
module Welcome
|
|
11
|
+
# Detect the gem name from the file that required this welcome screen.
|
|
12
|
+
# A scaffolded app's main lib file (e.g. lib/hello_rooibos.rb) lives
|
|
13
|
+
# directly under lib/ with no subdirectory — that distinguishes it from
|
|
14
|
+
# gem internals (lib/rooibos/welcome.rb) and test files (test/*.rb).
|
|
15
|
+
# Evaluated once at require-time; nil when loaded outside a lib/ context.
|
|
16
|
+
SOURCE_GEM = begin
|
|
17
|
+
rooibos_lib = File.expand_path("..", String(__dir__)) # this gem's lib/ dir
|
|
18
|
+
caller_locations
|
|
19
|
+
&.filter_map(&:absolute_path)
|
|
20
|
+
&.find { |p| p.match?(%r{/lib/[^/]+\.rb\z}) && !p.start_with?(rooibos_lib) }
|
|
21
|
+
&.then { |p| File.basename(p, ".rb") }
|
|
22
|
+
end
|
|
23
|
+
private_constant :SOURCE_GEM
|
|
24
|
+
|
|
11
25
|
module UI # :nodoc:
|
|
12
26
|
module Styles # :nodoc:
|
|
13
27
|
TEXT = RatatuiRuby::Style::Style.new
|
|
@@ -27,12 +41,15 @@ module Rooibos
|
|
|
27
41
|
end
|
|
28
42
|
|
|
29
43
|
module Widgets # :nodoc:
|
|
44
|
+
LIB_FILE = SOURCE_GEM ? "lib/#{SOURCE_GEM}.rb" : "lib/your_app.rb"
|
|
45
|
+
TEST_FILE = SOURCE_GEM ? "test/test_#{SOURCE_GEM}.rb" : "test/test_your_app.rb"
|
|
46
|
+
|
|
30
47
|
WELCOME_TEXT = {
|
|
31
48
|
"Welcome to Rooibos! You will find the Ruby code " \
|
|
32
49
|
"for this application in " => Styles::TEXT,
|
|
33
|
-
|
|
50
|
+
LIB_FILE => Styles::FILENAME,
|
|
34
51
|
". The tests that verify it are at " => Styles::TEXT,
|
|
35
|
-
|
|
52
|
+
TEST_FILE => Styles::FILENAME,
|
|
36
53
|
". You can run the tests with " => Styles::TEXT,
|
|
37
54
|
"bundle exec rake test" => Styles::COMMAND,
|
|
38
55
|
". Visit " => Styles::TEXT,
|
|
@@ -16,6 +16,14 @@ module Rooibos
|
|
|
16
16
|
|
|
17
17
|
# Evaluates the guard. Returns true if no callable.
|
|
18
18
|
def call: (message, _DataModel) -> boolish
|
|
19
|
+
|
|
20
|
+
class CombinedGuard < Data
|
|
21
|
+
attr_reader inner: guard
|
|
22
|
+
attr_reader outer: guard
|
|
23
|
+
|
|
24
|
+
def arity: () -> Integer
|
|
25
|
+
def call: (message, _DataModel) -> boolish
|
|
26
|
+
end
|
|
19
27
|
end
|
|
20
28
|
end
|
|
21
29
|
end
|
data/sig/rooibos/welcome.rbs
CHANGED
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
module Rooibos
|
|
7
7
|
# Built-in welcome screen used by scaffolded applications.
|
|
8
8
|
module Welcome
|
|
9
|
+
SOURCE_GEM: String?
|
|
9
10
|
WEBSITE_URL: String
|
|
10
11
|
|
|
11
12
|
# Internal UI module for styles and widgets.
|
|
@@ -26,6 +27,8 @@ module Rooibos
|
|
|
26
27
|
end
|
|
27
28
|
|
|
28
29
|
module Widgets
|
|
30
|
+
LIB_FILE: String
|
|
31
|
+
TEST_FILE: String
|
|
29
32
|
WELCOME_TEXT: Hash[String, RatatuiRuby::Style::Style]
|
|
30
33
|
PARAGRAPH: RatatuiRuby::Widgets::Paragraph
|
|
31
34
|
def self.website_button: (?focused: bool, ?hovered: bool) -> RatatuiRuby::Text::Span
|