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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: de0fd230ae66b1f7bb75d7bc0dbaad374d929efe3102638f0dfd2a7558312bc5
4
- data.tar.gz: 03bc89ff9e8880b053e022dfdf8bbab94f107e153e174402d9ce5c83b9644c2f
3
+ metadata.gz: 84b4f67bd8240b412f78b91e8e8e52af841e6438694bb51013519d3ba6e28fe7
4
+ data.tar.gz: 63ac12eba2aee98ecf595aa948d457babc3533ce66b2d9fa20eee5257e26bcf1
5
5
  SHA512:
6
- metadata.gz: de7f4335062b9feefca507ef70b058d1561efe6d3fd69ccf764c2b1e4809d17bd3378380b752cf5c1108957dc7ca94a249b276fe1058c1fe6d9abbecc8d1f060
7
- data.tar.gz: b50d6ddb3cc4ab37d0d2514d3852c95dbedd6c4cb756cbcb7fe7fcf8937189e7137961704bc1a284a9777f5ee83bd8fe263f9bad99e71f45ea5e29d1da6c864e
6
+ metadata.gz: 193556d2bf1093e16c1229162e579113c3d4a75c472cf37c071db593f4d1506405de0c7eaf1bccfcb9b2555335ed304c64d25f1cd08231c7c084a58bfa9ba731
7
+ data.tar.gz: a8ab3b783bc7f40527f05b15d7c32e971f70518cb9a4769f5d0312590ff866773debe986dcfb93ab36e8cf61a95dc40f9b91db842557633b36333296ffaf6fbf
@@ -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
- -> (msg, model) { outer.call(msg, model) && inner.call(msg, model) }
44
+ CombinedGuard.new(inner:, outer:)
39
45
  else
40
46
  outer
41
47
  end
@@ -8,5 +8,5 @@
8
8
  module Rooibos
9
9
  # The version of this gem.
10
10
  # See https://semver.org/spec/v2.0.0.html
11
- VERSION = "0.7.0"
11
+ VERSION = "0.7.2"
12
12
  end
@@ -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
- "lib/saturday.rb" => Styles::FILENAME,
50
+ LIB_FILE => Styles::FILENAME,
34
51
  ". The tests that verify it are at " => Styles::TEXT,
35
- "test/test_saturday.rb" => Styles::FILENAME,
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
@@ -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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rooibos
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.0
4
+ version: 0.7.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kerrick Long