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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 05b2d916ed6c46782d47c40839e877d7b04e419f489db5b1f746beeed5214fdc
4
- data.tar.gz: 49e2aabc1848bc0bd108497be3f5c5f0a6c3d081a35020da4ff30feb4c473be9
3
+ metadata.gz: a8cb92e45566351aeeed3e6342753aacd4884373acec111b34f894a6050c3f75
4
+ data.tar.gz: '096b48175e5a2cd4b0a2ca68ecafcbe1a48aa5b722fd3c1190c784555be94ff1'
5
5
  SHA512:
6
- metadata.gz: 5f8049b904a8a62120f6c366ba2d184e870b978a1f493d88a3cf944c87f3c650ef5a045b58bbba2d317c7ade471eb71682df9e648db9651788cc289673788722
7
- data.tar.gz: 3bcb40acff9339c3333f142334026678e81654f9886550951d70c19ead358f1f24dd967f7e85a3ee00691cd726ea133fe062345377a5fb9da874fa4b998125d3
6
+ metadata.gz: da9b958da97dca2204e4e05e020da7391b0029b802a48f739f35be2ead70d9e42af2aebcb46e2fa95f79b23b0e35e07570c872319c7b24a66e9aa8de7e95fb02
7
+ data.tar.gz: 1033b92d484f70980f2b101f9667770ceb22f68aee3ec22f047fd62628725e1451fb79e0c80a30b637e9707845ba0818d4d0f3ff4f1c1a83f656a4aae82851f3
@@ -17,7 +17,6 @@ jobs:
17
17
  - uses: actions/checkout@v4
18
18
  - uses: ruby/setup-ruby@v1
19
19
  with:
20
- ruby-version: 3.3.1
21
20
  bundler-cache: true
22
21
  - run: bin/test
23
22
  rubocop:
data/.gitignore CHANGED
@@ -1,2 +1,29 @@
1
+ .DS_Store
1
2
  *.gem
2
- .env
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.0)
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.8.4)
41
- zeitwerk (~> 2)
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.3.0)
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.6)
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.1)
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.64.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 (>= 1.8, < 3.0)
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.0)
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.14
124
+ 2.5.15
@@ -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
@@ -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
@@ -7,6 +7,10 @@ class Code
7
7
  BitwiseOr
8
8
  end
9
9
 
10
+ def right_statement
11
+ Greater
12
+ end
13
+
10
14
  def greater
11
15
  str(">")
12
16
  end
data/lib/code/version.rb CHANGED
@@ -2,4 +2,4 @@
2
2
 
3
3
  require_relative "../code"
4
4
 
5
- Code::Version = Gem::Version.new("0.15.0")
5
+ Code::Version = Gem::Version.new("0.15.3")
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.0
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-05 00:00:00.000000000 Z
11
+ date: 2024-07-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport