code-ruby 0.8.1 → 0.8.3
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/Gemfile.lock +2 -2
- data/lib/code/object/duration.rb +7 -0
- data/lib/code/object/integer.rb +7 -0
- data/lib/code/object.rb +4 -1
- data/lib/code/type/sig.rb +6 -0
- data/lib/code/version.rb +1 -1
- data/spec/code_spec.rb +8 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f85a852d230055ba09e08dc5691e178c3ca77de8fa9eb98fd34bc4bd0af483fb
|
4
|
+
data.tar.gz: b10269160b66c41ae45c60100ac8a992783c4ea7b7a5d17f162cc986a842aa80
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3bf9ee8ec6e9227127f9f32ad80e6ab70831b61fa51e3007eedf1abe263b36a68ef5c11b50b60c28c449e46f33a2de00dfaa1897af610a82ebee77904e3618f8
|
7
|
+
data.tar.gz: 9cb74bab622fa84ebe83786d9f576a777b248a4f4ad372872b1b3ee9865a46a94174a12e4c1b093e0c54a53612b36fb6c26e877d9884968646fd226104cd207c
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
code-ruby (0.
|
4
|
+
code-ruby (0.8.2)
|
5
5
|
activesupport (~> 7)
|
6
6
|
bigdecimal (~> 3)
|
7
7
|
language-ruby (~> 0)
|
@@ -10,7 +10,7 @@ PATH
|
|
10
10
|
GEM
|
11
11
|
remote: https://rubygems.org/
|
12
12
|
specs:
|
13
|
-
activesupport (7.1.3)
|
13
|
+
activesupport (7.1.3.2)
|
14
14
|
base64
|
15
15
|
bigdecimal
|
16
16
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
data/lib/code/object/duration.rb
CHANGED
@@ -17,6 +17,9 @@ class Code
|
|
17
17
|
operator = args.fetch(:operator, nil)
|
18
18
|
|
19
19
|
case operator.to_s
|
20
|
+
when "ago"
|
21
|
+
sig(args)
|
22
|
+
code_ago
|
20
23
|
when "from_now"
|
21
24
|
sig(args)
|
22
25
|
code_from_now
|
@@ -25,6 +28,10 @@ class Code
|
|
25
28
|
end
|
26
29
|
end
|
27
30
|
|
31
|
+
def code_ago
|
32
|
+
Time.new(raw.ago)
|
33
|
+
end
|
34
|
+
|
28
35
|
def code_from_now
|
29
36
|
Time.new(raw.from_now)
|
30
37
|
end
|
data/lib/code/object/integer.rb
CHANGED
@@ -82,6 +82,9 @@ class Code
|
|
82
82
|
when "clone"
|
83
83
|
sig(args)
|
84
84
|
code_clone
|
85
|
+
when "day", "days"
|
86
|
+
sig(args)
|
87
|
+
code_days
|
85
88
|
when "decrement!"
|
86
89
|
sig(args) { Integer.maybe }
|
87
90
|
code_decrement!(value)
|
@@ -389,6 +392,10 @@ class Code
|
|
389
392
|
Duration.new(raw.hours)
|
390
393
|
end
|
391
394
|
|
395
|
+
def code_days
|
396
|
+
Duration.new(raw.days)
|
397
|
+
end
|
398
|
+
|
392
399
|
def inspect
|
393
400
|
to_s
|
394
401
|
end
|
data/lib/code/object.rb
CHANGED
@@ -20,6 +20,7 @@ class Code
|
|
20
20
|
|
21
21
|
def self.sig(args, &block)
|
22
22
|
Type::Sig.sig(args, object: self, &block)
|
23
|
+
nil
|
23
24
|
end
|
24
25
|
|
25
26
|
def self.call(**args)
|
@@ -141,10 +142,11 @@ class Code
|
|
141
142
|
|
142
143
|
def self.sig(args, &block)
|
143
144
|
Type::Sig.sig(args, object: self, &block)
|
145
|
+
nil
|
144
146
|
end
|
145
147
|
|
146
148
|
def self.name
|
147
|
-
|
149
|
+
"Object"
|
148
150
|
end
|
149
151
|
|
150
152
|
def self.to_s
|
@@ -303,6 +305,7 @@ class Code
|
|
303
305
|
|
304
306
|
def sig(args, &block)
|
305
307
|
Type::Sig.sig(args, object: self, &block)
|
308
|
+
nil
|
306
309
|
end
|
307
310
|
|
308
311
|
def to_s
|
data/lib/code/type/sig.rb
CHANGED
@@ -11,11 +11,13 @@ class Code
|
|
11
11
|
|
12
12
|
def self.sig(...)
|
13
13
|
new(...).sig
|
14
|
+
nil
|
14
15
|
end
|
15
16
|
|
16
17
|
def sig
|
17
18
|
check_number_of_arguments!
|
18
19
|
check_types_of_arguments!
|
20
|
+
nil
|
19
21
|
end
|
20
22
|
|
21
23
|
private
|
@@ -92,6 +94,8 @@ class Code
|
|
92
94
|
Error::ArityError,
|
93
95
|
"#{function}: Expected #{expected_count} but got #{actual_count}"
|
94
96
|
)
|
97
|
+
|
98
|
+
nil
|
95
99
|
end
|
96
100
|
|
97
101
|
def valid_for?(expected:, actual:)
|
@@ -130,6 +134,8 @@ class Code
|
|
130
134
|
)
|
131
135
|
end
|
132
136
|
end
|
137
|
+
|
138
|
+
nil
|
133
139
|
end
|
134
140
|
end
|
135
141
|
end
|
data/lib/code/version.rb
CHANGED
data/spec/code_spec.rb
CHANGED
@@ -191,9 +191,16 @@ RSpec.describe Code do
|
|
191
191
|
end
|
192
192
|
|
193
193
|
[
|
194
|
+
"1.day.ago",
|
195
|
+
"1.day.from_now",
|
196
|
+
"1.hour.ago",
|
194
197
|
"1.hour.from_now",
|
198
|
+
"2.days.ago",
|
199
|
+
"2.days.from_now",
|
200
|
+
"2.hours.ago",
|
201
|
+
"2.hours.from_now",
|
202
|
+
"Date.tomorrow",
|
195
203
|
"Time.tomorrow",
|
196
|
-
"Date.tomorrow"
|
197
204
|
].each do |input|
|
198
205
|
it(input) { Code.evaluate(input) }
|
199
206
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: code-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.8.
|
4
|
+
version: 0.8.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dorian Marié
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-02-
|
11
|
+
date: 2024-02-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bigdecimal
|