From 4bdaacf723c800e64b5a94302aaac86ed4f3be51 Mon Sep 17 00:00:00 2001 From: Kamil Dubil Date: Sat, 6 Jul 2024 19:28:22 +0200 Subject: [PATCH 1/3] Fix Predicates documentation --- docsite/source/predicates.html.md | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/docsite/source/predicates.html.md b/docsite/source/predicates.html.md index 2d0cb46..264e706 100644 --- a/docsite/source/predicates.html.md +++ b/docsite/source/predicates.html.md @@ -14,7 +14,7 @@ Predicates can be chained together using operations such as `&` and `|` (see the is_https_url = build { uri?(:https) } is_https_url = build { uri?(/https?/) } is_http_url = build { uri?(:http) } -is_url = build { uri?([:http, :https]) } +is_url = build { uri?(['http', 'https']) } https_url = "https://example.com" http_url = "http://example.com" @@ -23,7 +23,7 @@ local_url = "example.local" is_https_url.call(https_url).success? # => true is_https_url.call(local_url).success? # => false is_http_url.call(http_url).success? # => true -is_url.call(https_url).success? # => false +is_url.call(https_url).success? # => true ``` ### UUID (`uuid_v1?`, `uuid_v2?`, `uuid_v3?`, `uuid_v4?`, `uuid_v5?`) @@ -384,15 +384,15 @@ is_float.call(1.0).success? # => true is_float.call(1).success? # => false ``` -### Number (`num?`) +### Integer (`int?`) > Returns true if the input is of type `Integer` ``` ruby -is_num = build { num? } +is_int = build { int? } -is_num.call(1).success? # => true -is_num.call(1.0).success? # => false +is_int.call(1).success? # => true +is_int.call(1.0).success? # => false ``` ### Time (`time?`) @@ -453,7 +453,7 @@ is_false = build { false? } is_true.call(true).success? # => true is_true.call(false).success? # => false is_false.call(false).success? # => true -is_true.call(true).success? # => false +is_false.call(true).success? # => false ``` ### Empty (`empty?`) @@ -540,6 +540,6 @@ is_named.call({ age: 30 }).success? # => false ``` ruby is_email_ish = build { format?(/^\S+@\S+$/) } -is_email_ish.call("hello@example.com") # => true -is_email_ish.call("nope|failed.com") # => false +is_email_ish.call("hello@example.com").success? # => true +is_email_ish.call("nope|failed.com").success? # => false ``` From eca115840786c451a3577dff0110ec2799433219 Mon Sep 17 00:00:00 2001 From: Kamil Dubil Date: Sat, 6 Jul 2024 19:53:26 +0200 Subject: [PATCH 2/3] Fix Operations documentation --- docsite/source/operations.html.md | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/docsite/source/operations.html.md b/docsite/source/operations.html.md index 70ab1c0..b3a03a3 100644 --- a/docsite/source/operations.html.md +++ b/docsite/source/operations.html.md @@ -31,7 +31,7 @@ end is_number.call(1).success? # => true is_number.call(2.0).success? # => true -is_number.call('3').success? # => false +is_number.call('3').success? # => true is_number.call('four').success? # => false ``` @@ -98,9 +98,9 @@ is_middle_aged = build do gt?(30) & lt?(50) end -is_child.call(20).success? # => false -is_child.call(40).success? # => true -is_child.call(60).success? # => true +is_middle_aged.call(20).success? # => false +is_middle_aged.call(40).success? # => true +is_middle_aged.call(60).success? # => false ``` ### Attribute (`attr`) @@ -138,10 +138,10 @@ is_only_odd.call([4, 6, 8]).success? # => false ``` ruby is_natural_and_odd = build do - set(int?, odd?, gt?(1)) + set { [int?, odd?, gt?(1)] } end -is_natural_and_odd.call('5').success? # => false +is_natural_and_odd.call('5').success? # => NoMethodError: undefined method `odd?' for "5":String is_natural_and_odd.call(5).success? # => true is_natural_and_odd.call(-1).success? # => false ``` @@ -152,7 +152,7 @@ is_natural_and_odd.call(-1).success? # => false ``` ruby is_present = build do - negation(empty?) + negation { empty? } end is_present.call([1]).success? # => true @@ -166,7 +166,7 @@ is_present.call("").success? # => false ``` ruby is_named = build do key name: [:user, :name] do - str? & negation(empty?) + str? & negation { empty? } end end From aa9891c24a67ceb9f05ec297cfa335a55d76c8e8 Mon Sep 17 00:00:00 2001 From: Kamil Dubil Date: Sat, 6 Jul 2024 20:00:28 +0200 Subject: [PATCH 3/3] Fix Builder documentation --- docsite/source/builder.html.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docsite/source/builder.html.md b/docsite/source/builder.html.md index 2651e1a..ac2611a 100644 --- a/docsite/source/builder.html.md +++ b/docsite/source/builder.html.md @@ -4,13 +4,13 @@ layout: gem-single name: dry-logic --- -Use Dry Logic's builder evaluate predicates and operations +Use Dry Logic's builder to evaluate predicates and operations. ``` ruby require "dry/logic/builder" is_zero = Dry::Logic::Builder.call do - lt?(0) ^ gt?(0) + lteq?(0) & gteq?(0) end is_zero.call(0).success? # => true