code-ruby 0.15.0 → 0.15.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/ci.yml +0 -1
- data/.gitignore +28 -1
- data/Gemfile.lock +10 -10
- data/lib/code/object/date.rb +23 -0
- data/lib/code/object/time.rb +14 -0
- data/lib/code/parser/greater.rb +4 -0
- data/lib/code/version.rb +1 -1
- data/spec/code_spec.rb +11 -0
- 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: a8cb92e45566351aeeed3e6342753aacd4884373acec111b34f894a6050c3f75
|
4
|
+
data.tar.gz: '096b48175e5a2cd4b0a2ca68ecafcbe1a48aa5b722fd3c1190c784555be94ff1'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: da9b958da97dca2204e4e05e020da7391b0029b802a48f739f35be2ead70d9e42af2aebcb46e2fa95f79b23b0e35e07570c872319c7b24a66e9aa8de7e95fb02
|
7
|
+
data.tar.gz: 1033b92d484f70980f2b101f9667770ceb22f68aee3ec22f047fd62628725e1451fb79e0c80a30b637e9707845ba0818d4d0f3ff4f1c1a83f656a4aae82851f3
|
data/.github/workflows/ci.yml
CHANGED
data/.gitignore
CHANGED
@@ -1,2 +1,29 @@
|
|
1
|
+
.DS_Store
|
1
2
|
*.gem
|
2
|
-
|
3
|
+
/.bundle
|
4
|
+
/.env
|
5
|
+
/.env.prod
|
6
|
+
/.env.staging
|
7
|
+
/.env.*.local
|
8
|
+
/app/assets/builds
|
9
|
+
/config/*.key
|
10
|
+
/config/credentials/*.key
|
11
|
+
/log
|
12
|
+
/node_modules
|
13
|
+
/public/assets
|
14
|
+
/spec/examples.txt
|
15
|
+
/storage
|
16
|
+
/tmp
|
17
|
+
/tmp/pids
|
18
|
+
/tmp/storage
|
19
|
+
/vendor/bundle
|
20
|
+
!/.env*.erb
|
21
|
+
!/app/assets/builds/.keep
|
22
|
+
!/db/.keep
|
23
|
+
!/log/.keep
|
24
|
+
!/storage/.keep
|
25
|
+
!/tmp/.keep
|
26
|
+
!/tmp/pids/
|
27
|
+
!/tmp/pids/.keep
|
28
|
+
!/tmp/storage/
|
29
|
+
!/tmp/storage/.keep
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
code-ruby (0.15.
|
4
|
+
code-ruby (0.15.3)
|
5
5
|
activesupport
|
6
6
|
bigdecimal
|
7
7
|
did-you-mean
|
@@ -37,22 +37,22 @@ GEM
|
|
37
37
|
i18n (1.14.5)
|
38
38
|
concurrent-ruby (~> 1.0)
|
39
39
|
json (2.7.2)
|
40
|
-
language-ruby (0.
|
41
|
-
zeitwerk
|
40
|
+
language-ruby (0.9.0)
|
41
|
+
zeitwerk
|
42
42
|
language_server-protocol (3.17.0.3)
|
43
43
|
levenshtein (0.2.2)
|
44
44
|
minitest (5.24.1)
|
45
45
|
mutex_m (0.2.0)
|
46
46
|
parallel (1.25.1)
|
47
|
-
parser (3.3.
|
47
|
+
parser (3.3.4.0)
|
48
48
|
ast (~> 2.4.1)
|
49
49
|
racc
|
50
50
|
racc (1.8.0)
|
51
|
-
rack (3.1.
|
51
|
+
rack (3.1.7)
|
52
52
|
rainbow (3.1.1)
|
53
53
|
rake (13.2.1)
|
54
54
|
regexp_parser (2.9.2)
|
55
|
-
rexml (3.3.
|
55
|
+
rexml (3.3.2)
|
56
56
|
strscan
|
57
57
|
rspec (3.13.0)
|
58
58
|
rspec-core (~> 3.13.0)
|
@@ -67,20 +67,20 @@ GEM
|
|
67
67
|
diff-lcs (>= 1.2.0, < 2.0)
|
68
68
|
rspec-support (~> 3.13.0)
|
69
69
|
rspec-support (3.13.1)
|
70
|
-
rubocop (1.
|
70
|
+
rubocop (1.65.0)
|
71
71
|
json (~> 2.3)
|
72
72
|
language_server-protocol (>= 3.17.0)
|
73
73
|
parallel (~> 1.10)
|
74
74
|
parser (>= 3.3.0.2)
|
75
75
|
rainbow (>= 2.2.2, < 4.0)
|
76
|
-
regexp_parser (>=
|
76
|
+
regexp_parser (>= 2.4, < 3.0)
|
77
77
|
rexml (>= 3.2.5, < 4.0)
|
78
78
|
rubocop-ast (>= 1.31.1, < 2.0)
|
79
79
|
ruby-progressbar (~> 1.7)
|
80
80
|
unicode-display_width (>= 2.4.0, < 3.0)
|
81
81
|
rubocop-ast (1.31.3)
|
82
82
|
parser (>= 3.3.1.0)
|
83
|
-
rubocop-minitest (0.35.
|
83
|
+
rubocop-minitest (0.35.1)
|
84
84
|
rubocop (>= 1.61, < 2.0)
|
85
85
|
rubocop-ast (>= 1.31.1, < 2.0)
|
86
86
|
rubocop-performance (1.21.1)
|
@@ -121,4 +121,4 @@ RUBY VERSION
|
|
121
121
|
ruby 3.3.3p89
|
122
122
|
|
123
123
|
BUNDLED WITH
|
124
|
-
2.5.
|
124
|
+
2.5.15
|
data/lib/code/object/date.rb
CHANGED
@@ -26,11 +26,18 @@ class Code
|
|
26
26
|
when "now"
|
27
27
|
sig(args)
|
28
28
|
code_now
|
29
|
+
when "hour"
|
30
|
+
sig(args)
|
31
|
+
code_hour
|
29
32
|
else
|
30
33
|
super
|
31
34
|
end
|
32
35
|
end
|
33
36
|
|
37
|
+
def self.code_hour
|
38
|
+
code_today.code_hour
|
39
|
+
end
|
40
|
+
|
34
41
|
def self.code_now
|
35
42
|
::Time.zone ||= Time::DEFAULT_ZONE
|
36
43
|
new(::Time.zone.now.beginning_of_day)
|
@@ -50,6 +57,22 @@ class Code
|
|
50
57
|
::Time.zone ||= Time::DEFAULT_ZONE
|
51
58
|
new(::Time.zone.yesterday.beginning_of_day)
|
52
59
|
end
|
60
|
+
|
61
|
+
def call(**args)
|
62
|
+
operator = args.fetch(:operator, nil)
|
63
|
+
|
64
|
+
case operator.to_s
|
65
|
+
when "hour"
|
66
|
+
sig(args)
|
67
|
+
code_hour
|
68
|
+
else
|
69
|
+
super
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
def code_hour
|
74
|
+
Integer.new(0)
|
75
|
+
end
|
53
76
|
end
|
54
77
|
end
|
55
78
|
end
|
data/lib/code/object/time.rb
CHANGED
@@ -26,11 +26,18 @@ class Code
|
|
26
26
|
when "yesterday"
|
27
27
|
sig(args)
|
28
28
|
code_yesterday
|
29
|
+
when "hour"
|
30
|
+
sig(args)
|
31
|
+
code_hour
|
29
32
|
else
|
30
33
|
super
|
31
34
|
end
|
32
35
|
end
|
33
36
|
|
37
|
+
def self.code_hour
|
38
|
+
code_now.code_hour
|
39
|
+
end
|
40
|
+
|
34
41
|
def self.code_tomorrow
|
35
42
|
::Time.zone ||= DEFAULT_ZONE
|
36
43
|
new(::Time.zone.tomorrow)
|
@@ -64,6 +71,9 @@ class Code
|
|
64
71
|
when "future?"
|
65
72
|
sig(args)
|
66
73
|
code_future?
|
74
|
+
when "hour"
|
75
|
+
sig(args)
|
76
|
+
code_hour
|
67
77
|
else
|
68
78
|
super
|
69
79
|
end
|
@@ -86,6 +96,10 @@ class Code
|
|
86
96
|
def code_future?
|
87
97
|
code_after?
|
88
98
|
end
|
99
|
+
|
100
|
+
def code_hour
|
101
|
+
Integer.new(raw.hour)
|
102
|
+
end
|
89
103
|
end
|
90
104
|
end
|
91
105
|
end
|
data/lib/code/parser/greater.rb
CHANGED
data/lib/code/version.rb
CHANGED
data/spec/code_spec.rb
CHANGED
@@ -11,7 +11,11 @@ RSpec.describe Code do
|
|
11
11
|
2.days.ago
|
12
12
|
2.days.from_now
|
13
13
|
2.hours.ago
|
14
|
+
2.hours.ago.hour
|
14
15
|
2.hours.from_now
|
16
|
+
2.hours.from_now.hour
|
17
|
+
Time.hour
|
18
|
+
Date.hour
|
15
19
|
Boolean.new
|
16
20
|
Boolean.new(true)
|
17
21
|
Boolean.new(false)
|
@@ -21,10 +25,13 @@ RSpec.describe Code do
|
|
21
25
|
Context.new
|
22
26
|
Context.new(a:1)
|
23
27
|
Date.new
|
28
|
+
Date.new.hour
|
24
29
|
Date.new("2024-03-05")
|
30
|
+
Date.new("2024-03-05").hour
|
25
31
|
Date.today
|
26
32
|
Date.yesterday
|
27
33
|
Date.tomorrow
|
34
|
+
Date.tomorrow.hour
|
28
35
|
Decimal.new
|
29
36
|
Decimal.new(0)
|
30
37
|
Decimal.new(1.2)
|
@@ -65,6 +72,10 @@ RSpec.describe Code do
|
|
65
72
|
Time.new(nothing).before?
|
66
73
|
].each { |input| it(input) { Code.evaluate(input) } }
|
67
74
|
|
75
|
+
[
|
76
|
+
"Time.hour >= 6 and Time.hour <= 23"
|
77
|
+
].each { |input| it(input) { Code.evaluate(input) } }
|
78
|
+
|
68
79
|
[
|
69
80
|
[
|
70
81
|
"user = { name: :Dorian, age: 31 } user.delete_if(String) user.keys",
|
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.15.
|
4
|
+
version: 0.15.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-07-
|
11
|
+
date: 2024-07-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|