code-ruby 0.14.9 → 0.15.2
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/.node-version +1 -0
- data/.ruby-version +1 -1
- data/.tool-versions +3 -1
- data/Gemfile +1 -1
- data/Gemfile.lock +36 -34
- data/LICENSE +19 -0
- data/code-ruby.gemspec +6 -8
- data/lib/code/object/date.rb +23 -0
- data/lib/code/object/time.rb +14 -0
- data/lib/code/version.rb +1 -1
- data/package.json +7 -2
- data/spec/code_spec.rb +7 -0
- metadata +26 -24
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7e6eba1265272415b1eda42a338b9c94562e029d1292204f212b742de27a843f
|
4
|
+
data.tar.gz: 486093e952db39bfbebd74b158abfd5cd3e4329e322c6e59f17da20de01d13fc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 31763afb9a5ccb4b980cbba02e76606332f2e2f52723a9a8e20f2b3ebcc1783fec54c8c9bdadb7687e55fc9333e3b02d25e820a7cff3388cb2a47bb4d58677bd
|
7
|
+
data.tar.gz: 3a0702d4cfff571b4279746b9755a980e2fffd95f2f969e13bc8f3a60e9a8697c60ca01eb5b197d35329972ebadf3d998f0de31ce09845a1e11c8e2dcfbf9561
|
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/.node-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
21.7.2
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
3.3.
|
1
|
+
3.3.3
|
data/.tool-versions
CHANGED
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,18 +1,18 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
code-ruby (0.
|
5
|
-
activesupport
|
6
|
-
bigdecimal
|
7
|
-
did-you-mean
|
8
|
-
json
|
9
|
-
language-ruby
|
10
|
-
zeitwerk
|
4
|
+
code-ruby (0.15.2)
|
5
|
+
activesupport
|
6
|
+
bigdecimal
|
7
|
+
did-you-mean
|
8
|
+
json
|
9
|
+
language-ruby
|
10
|
+
zeitwerk
|
11
11
|
|
12
12
|
GEM
|
13
13
|
remote: https://rubygems.org/
|
14
14
|
specs:
|
15
|
-
activesupport (7.1.3.
|
15
|
+
activesupport (7.1.3.4)
|
16
16
|
base64
|
17
17
|
bigdecimal
|
18
18
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
@@ -24,68 +24,69 @@ GEM
|
|
24
24
|
tzinfo (~> 2.0)
|
25
25
|
ast (2.4.2)
|
26
26
|
base64 (0.2.0)
|
27
|
-
bigdecimal (3.1.
|
27
|
+
bigdecimal (3.1.8)
|
28
28
|
bundler-audit (0.9.1)
|
29
29
|
bundler (>= 1.2.0, < 3)
|
30
30
|
thor (~> 1.0)
|
31
|
-
concurrent-ruby (1.
|
31
|
+
concurrent-ruby (1.3.3)
|
32
32
|
connection_pool (2.4.1)
|
33
33
|
did-you-mean (0.1.1)
|
34
34
|
levenshtein (>= 0.2.0)
|
35
35
|
diff-lcs (1.5.1)
|
36
36
|
drb (2.2.1)
|
37
|
-
i18n (1.14.
|
37
|
+
i18n (1.14.5)
|
38
38
|
concurrent-ruby (~> 1.0)
|
39
|
-
json (2.7.
|
40
|
-
language-ruby (0.
|
41
|
-
zeitwerk
|
39
|
+
json (2.7.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
|
-
minitest (5.
|
44
|
+
minitest (5.24.1)
|
45
45
|
mutex_m (0.2.0)
|
46
|
-
parallel (1.
|
47
|
-
parser (3.3.0
|
46
|
+
parallel (1.25.1)
|
47
|
+
parser (3.3.4.0)
|
48
48
|
ast (~> 2.4.1)
|
49
49
|
racc
|
50
|
-
racc (1.
|
51
|
-
rack (3.
|
50
|
+
racc (1.8.0)
|
51
|
+
rack (3.1.7)
|
52
52
|
rainbow (3.1.1)
|
53
|
-
rake (13.1
|
54
|
-
regexp_parser (2.9.
|
55
|
-
rexml (3.2
|
53
|
+
rake (13.2.1)
|
54
|
+
regexp_parser (2.9.2)
|
55
|
+
rexml (3.3.2)
|
56
|
+
strscan
|
56
57
|
rspec (3.13.0)
|
57
58
|
rspec-core (~> 3.13.0)
|
58
59
|
rspec-expectations (~> 3.13.0)
|
59
60
|
rspec-mocks (~> 3.13.0)
|
60
61
|
rspec-core (3.13.0)
|
61
62
|
rspec-support (~> 3.13.0)
|
62
|
-
rspec-expectations (3.13.
|
63
|
+
rspec-expectations (3.13.1)
|
63
64
|
diff-lcs (>= 1.2.0, < 2.0)
|
64
65
|
rspec-support (~> 3.13.0)
|
65
|
-
rspec-mocks (3.13.
|
66
|
+
rspec-mocks (3.13.1)
|
66
67
|
diff-lcs (>= 1.2.0, < 2.0)
|
67
68
|
rspec-support (~> 3.13.0)
|
68
69
|
rspec-support (3.13.1)
|
69
|
-
rubocop (1.
|
70
|
+
rubocop (1.65.0)
|
70
71
|
json (~> 2.3)
|
71
72
|
language_server-protocol (>= 3.17.0)
|
72
73
|
parallel (~> 1.10)
|
73
74
|
parser (>= 3.3.0.2)
|
74
75
|
rainbow (>= 2.2.2, < 4.0)
|
75
|
-
regexp_parser (>=
|
76
|
+
regexp_parser (>= 2.4, < 3.0)
|
76
77
|
rexml (>= 3.2.5, < 4.0)
|
77
78
|
rubocop-ast (>= 1.31.1, < 2.0)
|
78
79
|
ruby-progressbar (~> 1.7)
|
79
80
|
unicode-display_width (>= 2.4.0, < 3.0)
|
80
|
-
rubocop-ast (1.31.
|
81
|
-
parser (>= 3.3.0
|
82
|
-
rubocop-minitest (0.35.
|
81
|
+
rubocop-ast (1.31.3)
|
82
|
+
parser (>= 3.3.1.0)
|
83
|
+
rubocop-minitest (0.35.1)
|
83
84
|
rubocop (>= 1.61, < 2.0)
|
84
85
|
rubocop-ast (>= 1.31.1, < 2.0)
|
85
|
-
rubocop-performance (1.21.
|
86
|
+
rubocop-performance (1.21.1)
|
86
87
|
rubocop (>= 1.48.1, < 2.0)
|
87
88
|
rubocop-ast (>= 1.31.1, < 2.0)
|
88
|
-
rubocop-rails (2.
|
89
|
+
rubocop-rails (2.25.1)
|
89
90
|
activesupport (>= 4.2.0)
|
90
91
|
rack (>= 1.1)
|
91
92
|
rubocop (>= 1.33.0, < 2.0)
|
@@ -97,11 +98,12 @@ GEM
|
|
97
98
|
rubocop-rails
|
98
99
|
ruby-prof (1.7.0)
|
99
100
|
ruby-progressbar (1.13.0)
|
101
|
+
strscan (3.1.0)
|
100
102
|
thor (1.3.1)
|
101
103
|
tzinfo (2.0.6)
|
102
104
|
concurrent-ruby (~> 1.0)
|
103
105
|
unicode-display_width (2.5.0)
|
104
|
-
zeitwerk (2.6.
|
106
|
+
zeitwerk (2.6.16)
|
105
107
|
|
106
108
|
PLATFORMS
|
107
109
|
arm64-darwin-23
|
@@ -116,7 +118,7 @@ DEPENDENCIES
|
|
116
118
|
ruby-prof
|
117
119
|
|
118
120
|
RUBY VERSION
|
119
|
-
ruby 3.3.
|
121
|
+
ruby 3.3.3p89
|
120
122
|
|
121
123
|
BUNDLED WITH
|
122
|
-
2.5.
|
124
|
+
2.5.15
|
data/LICENSE
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
Copyright 2024 Dorian Marié <dorian@dorianmarie.com>
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
4
|
+
this software and associated documentation files (the “Software”), to deal in
|
5
|
+
the Software without restriction, including without limitation the rights to
|
6
|
+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
|
7
|
+
of the Software, and to permit persons to whom the Software is furnished to
|
8
|
+
do so, subject to the following conditions:
|
9
|
+
|
10
|
+
The above copyright notice and this permission notice shall be included in
|
11
|
+
all copies or substantial portions of the Software.
|
12
|
+
|
13
|
+
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
16
|
+
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
19
|
+
THE SOFTWARE.
|
data/code-ruby.gemspec
CHANGED
@@ -16,12 +16,10 @@ Gem::Specification.new do |s|
|
|
16
16
|
s.license = "MIT"
|
17
17
|
s.executables = "code"
|
18
18
|
|
19
|
-
s.add_dependency "activesupport"
|
20
|
-
s.add_dependency "bigdecimal"
|
21
|
-
s.add_dependency "did-you-mean"
|
22
|
-
s.add_dependency "json"
|
23
|
-
s.add_dependency "language-ruby"
|
24
|
-
s.add_dependency "zeitwerk"
|
25
|
-
|
26
|
-
s.required_ruby_version = ">= 3.3.0"
|
19
|
+
s.add_dependency "activesupport"
|
20
|
+
s.add_dependency "bigdecimal"
|
21
|
+
s.add_dependency "did-you-mean"
|
22
|
+
s.add_dependency "json"
|
23
|
+
s.add_dependency "language-ruby"
|
24
|
+
s.add_dependency "zeitwerk"
|
27
25
|
end
|
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/version.rb
CHANGED
data/package.json
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)
|
metadata
CHANGED
@@ -1,99 +1,99 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: code-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.15.2
|
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-
|
11
|
+
date: 2024-07-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '0'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - "
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
26
|
+
version: '0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: bigdecimal
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - "
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
33
|
+
version: '0'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - "
|
38
|
+
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
40
|
+
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: did-you-mean
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - "
|
45
|
+
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: '0'
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- - "
|
52
|
+
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: json
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- - "
|
59
|
+
- - ">="
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: '
|
61
|
+
version: '0'
|
62
62
|
type: :runtime
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- - "
|
66
|
+
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: '
|
68
|
+
version: '0'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: language-ruby
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
|
-
- - "
|
73
|
+
- - ">="
|
74
74
|
- !ruby/object:Gem::Version
|
75
75
|
version: '0'
|
76
76
|
type: :runtime
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
|
-
- - "
|
80
|
+
- - ">="
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '0'
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: zeitwerk
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
|
-
- - "
|
87
|
+
- - ">="
|
88
88
|
- !ruby/object:Gem::Version
|
89
|
-
version: '
|
89
|
+
version: '0'
|
90
90
|
type: :runtime
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
|
-
- - "
|
94
|
+
- - ">="
|
95
95
|
- !ruby/object:Gem::Version
|
96
|
-
version: '
|
96
|
+
version: '0'
|
97
97
|
description: 'A programming language, like Code.evaluate("1 + 1") # => 2'
|
98
98
|
email: dorian@dorianmarie.fr
|
99
99
|
executables:
|
@@ -104,12 +104,14 @@ files:
|
|
104
104
|
- ".github/dependabot.yml"
|
105
105
|
- ".github/workflows/ci.yml"
|
106
106
|
- ".gitignore"
|
107
|
+
- ".node-version"
|
107
108
|
- ".rspec"
|
108
109
|
- ".rubocop.yml"
|
109
110
|
- ".ruby-version"
|
110
111
|
- ".tool-versions"
|
111
112
|
- Gemfile
|
112
113
|
- Gemfile.lock
|
114
|
+
- LICENSE
|
113
115
|
- README.md
|
114
116
|
- Rakefile
|
115
117
|
- bin/bundle-audit
|
@@ -256,14 +258,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
256
258
|
requirements:
|
257
259
|
- - ">="
|
258
260
|
- !ruby/object:Gem::Version
|
259
|
-
version:
|
261
|
+
version: '0'
|
260
262
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
261
263
|
requirements:
|
262
264
|
- - ">="
|
263
265
|
- !ruby/object:Gem::Version
|
264
266
|
version: '0'
|
265
267
|
requirements: []
|
266
|
-
rubygems_version: 3.5.
|
268
|
+
rubygems_version: 3.5.11
|
267
269
|
signing_key:
|
268
270
|
specification_version: 4
|
269
271
|
summary: A programming language
|