code-ruby 0.7.6 → 0.7.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +24 -1
- data/code-ruby.gemspec +1 -0
- data/lib/code/object/duration.rb +43 -0
- data/lib/code/object/integer.rb +9 -0
- data/lib/code/object/time.rb +25 -0
- data/lib/code/version.rb +1 -1
- data/lib/code-ruby.rb +1 -0
- data/spec/code_spec.rb +4 -0
- metadata +17 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d84bcfcb9ae6cbd546334c89b2aefd5a0b70bf4da537d0fe646c5f2a8030c4a3
|
4
|
+
data.tar.gz: d9894a0ee1a9c80fa1744b4b29c3b8065c6dedd310558d0f4210f252f5f330a2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f18605e6c94eccb892d45d09dddb06cf4f5fba5f2f1f30df077687812424ea97c0fde6c3c53f80bc075dfc362864307d17ef354ed5f45997c9ccc42faeb44658
|
7
|
+
data.tar.gz: 1333842f223896c4bff55a2359034420631680bfe6d2563458b1dc6546e95e7c1d50b42b577396866f3770592bc574b616aaf48d32acda843d80997a4179bb09
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
code-ruby (0.7.
|
4
|
+
code-ruby (0.7.6)
|
5
|
+
activesupport (~> 7)
|
5
6
|
bigdecimal (~> 3)
|
6
7
|
language-ruby (~> 0)
|
7
8
|
zeitwerk (~> 2)
|
@@ -9,10 +10,29 @@ PATH
|
|
9
10
|
GEM
|
10
11
|
remote: https://rubygems.org/
|
11
12
|
specs:
|
13
|
+
activesupport (7.1.3)
|
14
|
+
base64
|
15
|
+
bigdecimal
|
16
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
17
|
+
connection_pool (>= 2.2.5)
|
18
|
+
drb
|
19
|
+
i18n (>= 1.6, < 2)
|
20
|
+
minitest (>= 5.1)
|
21
|
+
mutex_m
|
22
|
+
tzinfo (~> 2.0)
|
23
|
+
base64 (0.2.0)
|
12
24
|
bigdecimal (3.1.6)
|
25
|
+
concurrent-ruby (1.2.3)
|
26
|
+
connection_pool (2.4.1)
|
13
27
|
diff-lcs (1.5.1)
|
28
|
+
drb (2.2.0)
|
29
|
+
ruby2_keywords
|
30
|
+
i18n (1.14.1)
|
31
|
+
concurrent-ruby (~> 1.0)
|
14
32
|
language-ruby (0.6.2)
|
15
33
|
zeitwerk (~> 2)
|
34
|
+
minitest (5.22.2)
|
35
|
+
mutex_m (0.2.0)
|
16
36
|
rspec (3.13.0)
|
17
37
|
rspec-core (~> 3.13.0)
|
18
38
|
rspec-expectations (~> 3.13.0)
|
@@ -27,6 +47,9 @@ GEM
|
|
27
47
|
rspec-support (~> 3.13.0)
|
28
48
|
rspec-support (3.13.0)
|
29
49
|
ruby-prof (1.7.0)
|
50
|
+
ruby2_keywords (0.0.5)
|
51
|
+
tzinfo (2.0.6)
|
52
|
+
concurrent-ruby (~> 1.0)
|
30
53
|
zeitwerk (2.6.13)
|
31
54
|
|
32
55
|
PLATFORMS
|
data/code-ruby.gemspec
CHANGED
@@ -0,0 +1,43 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "active_support/core_ext/numeric/time"
|
4
|
+
|
5
|
+
class Code
|
6
|
+
class Object
|
7
|
+
class Duration < Object
|
8
|
+
attr_reader :raw
|
9
|
+
|
10
|
+
def initialize(duration)
|
11
|
+
@raw = duration
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.name
|
15
|
+
"Duration"
|
16
|
+
end
|
17
|
+
|
18
|
+
def call(**args)
|
19
|
+
operator = args.fetch(:operator, nil)
|
20
|
+
|
21
|
+
case operator.to_s
|
22
|
+
when "from_now"
|
23
|
+
sig(args)
|
24
|
+
code_from_now
|
25
|
+
else
|
26
|
+
super
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def code_from_now
|
31
|
+
Time.new(raw.from_now)
|
32
|
+
end
|
33
|
+
|
34
|
+
def inspect
|
35
|
+
to_s
|
36
|
+
end
|
37
|
+
|
38
|
+
def to_s
|
39
|
+
raw.to_s
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
data/lib/code/object/integer.rb
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require "active_support/core_ext/numeric/time"
|
4
|
+
|
3
5
|
class Code
|
4
6
|
class Object
|
5
7
|
class Integer < Number
|
@@ -103,6 +105,9 @@ class Code
|
|
103
105
|
when "four?"
|
104
106
|
sig(args)
|
105
107
|
code_four?
|
108
|
+
when "hour", "hours"
|
109
|
+
sig(args)
|
110
|
+
code_hours
|
106
111
|
when "increment!"
|
107
112
|
sig(args) { Integer.maybe }
|
108
113
|
code_increment!(value)
|
@@ -382,6 +387,10 @@ class Code
|
|
382
387
|
Boolean.new(raw.zero?)
|
383
388
|
end
|
384
389
|
|
390
|
+
def code_hours
|
391
|
+
Duration.new(raw.hours)
|
392
|
+
end
|
393
|
+
|
385
394
|
def inspect
|
386
395
|
to_s
|
387
396
|
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
class Code
|
4
|
+
class Object
|
5
|
+
class Time < Object
|
6
|
+
attr_reader :raw
|
7
|
+
|
8
|
+
def initialize(time)
|
9
|
+
@raw = time
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.name
|
13
|
+
"Time"
|
14
|
+
end
|
15
|
+
|
16
|
+
def inspect
|
17
|
+
to_s
|
18
|
+
end
|
19
|
+
|
20
|
+
def to_s
|
21
|
+
raw.to_s
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
data/lib/code/version.rb
CHANGED
data/lib/code-ruby.rb
CHANGED
data/spec/code_spec.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: code-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.7.
|
4
|
+
version: 0.7.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dorian Marié
|
@@ -38,6 +38,20 @@ dependencies:
|
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: activesupport
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '7'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '7'
|
41
55
|
- !ruby/object:Gem::Dependency
|
42
56
|
name: zeitwerk
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -106,6 +120,7 @@ files:
|
|
106
120
|
- lib/code/object/context.rb
|
107
121
|
- lib/code/object/decimal.rb
|
108
122
|
- lib/code/object/dictionary.rb
|
123
|
+
- lib/code/object/duration.rb
|
109
124
|
- lib/code/object/function.rb
|
110
125
|
- lib/code/object/global.rb
|
111
126
|
- lib/code/object/identifier_list.rb
|
@@ -116,6 +131,7 @@ files:
|
|
116
131
|
- lib/code/object/range.rb
|
117
132
|
- lib/code/object/ruby_function.rb
|
118
133
|
- lib/code/object/string.rb
|
134
|
+
- lib/code/object/time.rb
|
119
135
|
- lib/code/parser.rb
|
120
136
|
- lib/code/parser/addition.rb
|
121
137
|
- lib/code/parser/and_operator.rb
|