code-ruby 1.4.0 → 1.5.1
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/.node-version +1 -1
- data/.npm-version +1 -1
- data/.rubocop.yml +8 -7
- data/.ruby-version +1 -1
- data/.tool-versions +2 -2
- data/Gemfile +1 -1
- data/Gemfile.lock +15 -15
- data/VERSION +1 -1
- data/bin/code +12 -8
- data/code-ruby.gemspec +2 -2
- data/lib/code/concerns/shared.rb +10 -59
- data/lib/code/node/code.rb +10 -0
- data/lib/code/node/dictionary.rb +34 -15
- data/lib/code/node/function_parameter.rb +1 -1
- data/lib/code/object/boolean.rb +2 -2
- data/lib/code/object/class.rb +2 -2
- data/lib/code/object/code.rb +2 -2
- data/lib/code/object/context.rb +1 -1
- data/lib/code/object/date.rb +3 -3
- data/lib/code/object/decimal.rb +3 -3
- data/lib/code/object/dictionary.rb +23 -7
- data/lib/code/object/duration.rb +3 -3
- data/lib/code/object/function.rb +2 -2
- data/lib/code/object/global.rb +1 -5
- data/lib/code/object/html.rb +4 -5
- data/lib/code/object/http.rb +0 -2
- data/lib/code/object/integer.rb +3 -3
- data/lib/code/object/list.rb +9 -2
- data/lib/code/object/nothing.rb +2 -2
- data/lib/code/object/parameter.rb +2 -2
- data/lib/code/object/range.rb +2 -2
- data/lib/code/object/string.rb +2 -2
- data/lib/code/object/time.rb +2 -6
- data/lib/code/object.rb +5 -5
- data/lib/code/parser/call.rb +7 -6
- data/lib/code/parser/dictionary.rb +7 -5
- data/lib/code/parser/equal.rb +0 -4
- data/lib/code/parser/function.rb +8 -2
- data/lib/code/parser/group.rb +20 -4
- data/lib/code/parser/if.rb +8 -2
- data/lib/code/parser/name.rb +4 -8
- data/lib/code/parser/while.rb +8 -2
- data/lib/code/type/sig.rb +2 -2
- data/lib/code/type.rb +1 -1
- data/lib/code.rb +7 -7
- data/package-lock.json +2 -2
- data/package.json +2 -2
- data/spec/code/object/http_spec.rb +70 -66
- data/spec/code_spec.rb +4 -2
- metadata +4 -6
- data/TODO +0 -219
- data/bin/console +0 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f23ca15ea80387f4c771b52dd51869b3be31b4a38f7e9f8e65cbfa42b29c8ae5
|
4
|
+
data.tar.gz: 596ff5205a84e50ce9d75214990a35826b9d991636f59d6baec8735bb883e7ad
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 174c9ab2b2046b7ef38e53cd974b716ed984688d9e95d0b1bbd06fabdb41d14bcfee1d2e5498a28f4a944c1633dbfcfdcd9b8e23ed40729c6bc8f05fdfdb9a3a
|
7
|
+
data.tar.gz: b8333e8f9f2bde24c722669d4ad398715daa621059f904f7b36042c65111f4b501486eafbeb10d8273dfcfc4878da695e9a201e5213d44752b8a139293b99835
|
data/.node-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
23.11.0
|
data/.npm-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
11.2.0
|
data/.rubocop.yml
CHANGED
@@ -1,12 +1,11 @@
|
|
1
1
|
---
|
2
2
|
AllCops:
|
3
3
|
Exclude:
|
4
|
-
- "
|
5
|
-
- "
|
6
|
-
-
|
7
|
-
- vendor/**/*
|
4
|
+
- "**/node_modules/**/*"
|
5
|
+
- "**/vendor/**/*"
|
6
|
+
- "**/db/schema.rb"
|
8
7
|
NewCops: enable
|
9
|
-
TargetRubyVersion: 3.
|
8
|
+
TargetRubyVersion: 3.0
|
10
9
|
Layout/ClosingHeredocIndentation:
|
11
10
|
Enabled: false
|
12
11
|
Layout/FirstArgumentIndentation:
|
@@ -23,6 +22,8 @@ Layout/MultilineMethodCallIndentation:
|
|
23
22
|
Enabled: false
|
24
23
|
Layout/MultilineOperationIndentation:
|
25
24
|
Enabled: false
|
25
|
+
Layout/SpaceInsideHashLiteralBraces:
|
26
|
+
Enabled: false
|
26
27
|
Lint/EmptyClass:
|
27
28
|
Enabled: false
|
28
29
|
Lint/MissingSuper:
|
@@ -119,11 +120,11 @@ Style/StringLiterals:
|
|
119
120
|
Enabled: false
|
120
121
|
Style/StringLiteralsInInterpolation:
|
121
122
|
Enabled: false
|
122
|
-
|
123
|
+
plugins:
|
123
124
|
- rubocop-factory_bot
|
124
125
|
- rubocop-performance
|
125
126
|
- rubocop-rails
|
126
127
|
- rubocop-rake
|
127
128
|
- rubocop-rspec
|
128
|
-
- rubocop-rspec_rails
|
129
129
|
- rubocop-capybara
|
130
|
+
- rubocop-rspec_rails
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
3.
|
1
|
+
3.4.2
|
data/.tool-versions
CHANGED
@@ -1,3 +1,3 @@
|
|
1
|
-
ruby 3.
|
1
|
+
ruby 3.4.2
|
2
2
|
yarn 1.22.22
|
3
|
-
nodejs
|
3
|
+
nodejs 23.11.0
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
code-ruby (1.
|
4
|
+
code-ruby (1.5.1)
|
5
5
|
activesupport
|
6
6
|
base64
|
7
7
|
bigdecimal
|
@@ -105,24 +105,24 @@ GEM
|
|
105
105
|
lint_roller (1.1.0)
|
106
106
|
logger (1.7.0)
|
107
107
|
mini_portile2 (2.8.8)
|
108
|
-
mini_racer (0.18.
|
108
|
+
mini_racer (0.18.1)
|
109
109
|
libv8-node (~> 23.6.1.0)
|
110
110
|
minitest (5.25.5)
|
111
111
|
mustermann (3.0.3)
|
112
112
|
ruby2_keywords (~> 0.0.1)
|
113
113
|
net-http (0.6.0)
|
114
114
|
uri
|
115
|
-
nokogiri (1.18.
|
115
|
+
nokogiri (1.18.7)
|
116
116
|
mini_portile2 (~> 2.8.2)
|
117
117
|
racc (~> 1.4)
|
118
|
-
nokogiri (1.18.
|
118
|
+
nokogiri (1.18.7-arm64-darwin)
|
119
119
|
racc (~> 1.4)
|
120
|
-
nokogiri (1.18.
|
120
|
+
nokogiri (1.18.7-x86_64-linux-gnu)
|
121
121
|
racc (~> 1.4)
|
122
122
|
openssl (3.3.0)
|
123
123
|
ostruct (0.6.1)
|
124
124
|
parallel (1.26.3)
|
125
|
-
parser (3.3.7.
|
125
|
+
parser (3.3.7.4)
|
126
126
|
ast (~> 2.4.1)
|
127
127
|
racc
|
128
128
|
prettier_print (1.2.1)
|
@@ -156,7 +156,7 @@ GEM
|
|
156
156
|
diff-lcs (>= 1.2.0, < 2.0)
|
157
157
|
rspec-support (~> 3.13.0)
|
158
158
|
rspec-support (3.13.2)
|
159
|
-
rubocop (1.75.
|
159
|
+
rubocop (1.75.2)
|
160
160
|
json (~> 2.3)
|
161
161
|
language_server-protocol (~> 3.17.0.2)
|
162
162
|
lint_roller (~> 1.1.0)
|
@@ -164,10 +164,10 @@ GEM
|
|
164
164
|
parser (>= 3.3.0.2)
|
165
165
|
rainbow (>= 2.2.2, < 4.0)
|
166
166
|
regexp_parser (>= 2.9.3, < 3.0)
|
167
|
-
rubocop-ast (>= 1.
|
167
|
+
rubocop-ast (>= 1.44.0, < 2.0)
|
168
168
|
ruby-progressbar (~> 1.7)
|
169
169
|
unicode-display_width (>= 2.4.0, < 4.0)
|
170
|
-
rubocop-ast (1.
|
170
|
+
rubocop-ast (1.44.0)
|
171
171
|
parser (>= 3.3.7.2)
|
172
172
|
prism (~> 1.4)
|
173
173
|
rubocop-capybara (2.22.1)
|
@@ -176,15 +176,15 @@ GEM
|
|
176
176
|
rubocop-factory_bot (2.27.1)
|
177
177
|
lint_roller (~> 1.1)
|
178
178
|
rubocop (~> 1.72, >= 1.72.1)
|
179
|
-
rubocop-performance (1.
|
179
|
+
rubocop-performance (1.25.0)
|
180
180
|
lint_roller (~> 1.1)
|
181
|
-
rubocop (>= 1.
|
181
|
+
rubocop (>= 1.75.0, < 2.0)
|
182
182
|
rubocop-ast (>= 1.38.0, < 2.0)
|
183
|
-
rubocop-rails (2.
|
183
|
+
rubocop-rails (2.31.0)
|
184
184
|
activesupport (>= 4.2.0)
|
185
185
|
lint_roller (~> 1.1)
|
186
186
|
rack (>= 1.1)
|
187
|
-
rubocop (>= 1.
|
187
|
+
rubocop (>= 1.75.0, < 2.0)
|
188
188
|
rubocop-ast (>= 1.38.0, < 2.0)
|
189
189
|
rubocop-rake (0.7.1)
|
190
190
|
lint_roller (~> 1.1)
|
@@ -261,7 +261,7 @@ DEPENDENCIES
|
|
261
261
|
webmock
|
262
262
|
|
263
263
|
RUBY VERSION
|
264
|
-
ruby 3.
|
264
|
+
ruby 3.4.2p28
|
265
265
|
|
266
266
|
BUNDLED WITH
|
267
|
-
2.6.
|
267
|
+
2.6.7
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.
|
1
|
+
1.5.1
|
data/bin/code
CHANGED
@@ -48,15 +48,19 @@ input = 'loop { print("> ") puts(evaluate(read)) }' if input.blank?
|
|
48
48
|
if parsed.options.parse
|
49
49
|
pp Code::Parser.parse(input).to_raw
|
50
50
|
else
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
51
|
+
begin
|
52
|
+
print(
|
53
|
+
Code.evaluate(
|
54
|
+
input,
|
55
|
+
output: $stdout,
|
56
|
+
error: $stderr,
|
57
|
+
input: $stdin,
|
58
|
+
timeout: parsed.options.timeout
|
59
|
+
)
|
58
60
|
)
|
59
|
-
|
61
|
+
rescue Code::Error => e
|
62
|
+
warn e.message
|
63
|
+
end
|
60
64
|
end
|
61
65
|
|
62
66
|
if profile
|
data/code-ruby.gemspec
CHANGED
@@ -6,7 +6,7 @@ Gem::Specification.new do |s|
|
|
6
6
|
s.summary = "a programming language for the internet"
|
7
7
|
s.description = s.summary
|
8
8
|
s.authors = ["Dorian Marié"]
|
9
|
-
s.email = "dorian@dorianmarie.
|
9
|
+
s.email = "dorian@dorianmarie.com"
|
10
10
|
s.files = `git ls-files`.lines.map(&:strip)
|
11
11
|
s.require_paths = ["lib"]
|
12
12
|
s.homepage = "https://github.com/dorianmariecom/code-ruby"
|
@@ -27,5 +27,5 @@ Gem::Specification.new do |s|
|
|
27
27
|
|
28
28
|
s.metadata["rubygems_mfa_required"] = "true"
|
29
29
|
|
30
|
-
s.required_ruby_version = ">= 3.
|
30
|
+
s.required_ruby_version = ">= 3.0"
|
31
31
|
end
|
data/lib/code/concerns/shared.rb
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
class Code
|
4
4
|
module Concerns
|
5
5
|
module Shared
|
6
|
-
|
6
|
+
attr_accessor :raw, :methods
|
7
7
|
|
8
8
|
def call(**args)
|
9
9
|
code_operator = args.fetch(:operator, nil).to_code
|
@@ -103,6 +103,9 @@ class Code
|
|
103
103
|
else
|
104
104
|
code_to_json
|
105
105
|
end
|
106
|
+
when "methods"
|
107
|
+
sig(args)
|
108
|
+
code_methods
|
106
109
|
when "name"
|
107
110
|
sig(args)
|
108
111
|
code_name
|
@@ -213,8 +216,8 @@ class Code
|
|
213
216
|
keys.to_h { |key| [key, hash.fetch(key)] }
|
214
217
|
end
|
215
218
|
|
216
|
-
def sig(args, &)
|
217
|
-
Type::Sig.sig(args, object: self, &)
|
219
|
+
def sig(args, &block)
|
220
|
+
Type::Sig.sig(args, object: self, &block)
|
218
221
|
|
219
222
|
Object::Nothing.new
|
220
223
|
end
|
@@ -287,62 +290,6 @@ class Code
|
|
287
290
|
code_to_string.code_parameterize
|
288
291
|
end
|
289
292
|
|
290
|
-
def code_falsy?
|
291
|
-
Object::Boolean.new(falsy?)
|
292
|
-
end
|
293
|
-
|
294
|
-
def code_truthy?
|
295
|
-
Object::Boolean.new(truthy?)
|
296
|
-
end
|
297
|
-
|
298
|
-
def code_to_boolean
|
299
|
-
Object::Boolean.new(self)
|
300
|
-
end
|
301
|
-
|
302
|
-
def code_to_class
|
303
|
-
Object::Class.new(self)
|
304
|
-
end
|
305
|
-
|
306
|
-
def code_to_date
|
307
|
-
Object::Date.new(self)
|
308
|
-
end
|
309
|
-
|
310
|
-
def code_to_decimal
|
311
|
-
Object::Decimal.new(self)
|
312
|
-
end
|
313
|
-
|
314
|
-
def code_to_dictionary
|
315
|
-
Object::Dictionary.new(self)
|
316
|
-
end
|
317
|
-
|
318
|
-
def code_to_duration
|
319
|
-
Object::Duration.new(self)
|
320
|
-
end
|
321
|
-
|
322
|
-
def code_to_integer
|
323
|
-
Object::Integer.new(self)
|
324
|
-
end
|
325
|
-
|
326
|
-
def code_to_list
|
327
|
-
Object::List.new(self)
|
328
|
-
end
|
329
|
-
|
330
|
-
def code_to_nothing
|
331
|
-
Object::Nothing.new(self)
|
332
|
-
end
|
333
|
-
|
334
|
-
def code_to_range
|
335
|
-
Object::Range.new(self)
|
336
|
-
end
|
337
|
-
|
338
|
-
def code_to_string
|
339
|
-
Object::String.new(self)
|
340
|
-
end
|
341
|
-
|
342
|
-
def code_to_time
|
343
|
-
Object::Time.new(self)
|
344
|
-
end
|
345
|
-
|
346
293
|
def to_s
|
347
294
|
code_to_string.raw
|
348
295
|
end
|
@@ -418,6 +365,10 @@ class Code
|
|
418
365
|
def code_name
|
419
366
|
Object::String.new(name.to_s.split("::")[2..].join("::"))
|
420
367
|
end
|
368
|
+
|
369
|
+
def code_methods
|
370
|
+
Object::List.new(methods)
|
371
|
+
end
|
421
372
|
end
|
422
373
|
end
|
423
374
|
end
|
data/lib/code/node/code.rb
CHANGED
data/lib/code/node/dictionary.rb
CHANGED
@@ -4,29 +4,48 @@ class Code
|
|
4
4
|
class Node
|
5
5
|
class Dictionary < Node
|
6
6
|
class KeyValue < Node
|
7
|
+
attr_reader :resolve_key
|
8
|
+
|
7
9
|
def initialize(parsed)
|
8
10
|
return if parsed.blank?
|
9
11
|
|
10
|
-
if parsed.
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
12
|
+
if (name_code = parsed.delete(:name_code))
|
13
|
+
if name_code.key?(:code)
|
14
|
+
@key =
|
15
|
+
Node::String.new([{ text: name_code.delete(:name).presence }])
|
16
|
+
@value = Node::Code.new(name_code.delete(:code).presence)
|
17
|
+
@resolve_key = false
|
18
|
+
else
|
19
|
+
@key = Node::Call.new({ name: name_code.delete(:name).presence })
|
20
|
+
@value = @key
|
21
|
+
@resolve_key = true
|
22
|
+
end
|
23
|
+
elsif (statement_code = parsed.delete(:statement_code))
|
24
|
+
@key =
|
25
|
+
Node::Statement.new(statement_code.delete(:statement).presence)
|
17
26
|
|
18
|
-
|
27
|
+
if statement_code.key?(:code)
|
28
|
+
@value = Node::Code.new(statement_code.delete(:code).presence)
|
29
|
+
@resolve_key = false
|
30
|
+
else
|
31
|
+
@value = @key
|
32
|
+
@resolve_key = true
|
33
|
+
end
|
34
|
+
else
|
35
|
+
@key = @value = Node::Code.new(parsed.delete(:code).presence)
|
36
|
+
@resolve_key = true
|
37
|
+
end
|
19
38
|
end
|
20
39
|
|
21
40
|
def evaluate(**args)
|
22
|
-
key = @key&.
|
41
|
+
key = resolve_key? ? @key&.resolve(**args) : @key&.evaluate(**args)
|
42
|
+
key ||= Object::Nothing.new
|
43
|
+
value = @value.evaluate(**args)
|
44
|
+
[key, value]
|
45
|
+
end
|
23
46
|
|
24
|
-
|
25
|
-
|
26
|
-
[key, value]
|
27
|
-
else
|
28
|
-
[key, key]
|
29
|
-
end
|
47
|
+
def resolve_key?
|
48
|
+
!!resolve_key
|
30
49
|
end
|
31
50
|
end
|
32
51
|
|
data/lib/code/object/boolean.rb
CHANGED
@@ -3,8 +3,8 @@
|
|
3
3
|
class Code
|
4
4
|
class Object
|
5
5
|
class Boolean < ::Code::Object
|
6
|
-
def initialize(*args, **_kargs, &)
|
7
|
-
|
6
|
+
def initialize(*args, **_kargs, &_block)
|
7
|
+
self.raw = (args.first.is_an?(Object) ? args.first.truthy? : !!args.first)
|
8
8
|
end
|
9
9
|
|
10
10
|
def call(**args)
|
data/lib/code/object/class.rb
CHANGED
data/lib/code/object/code.rb
CHANGED
data/lib/code/object/context.rb
CHANGED
data/lib/code/object/date.rb
CHANGED
@@ -3,10 +3,10 @@
|
|
3
3
|
class Code
|
4
4
|
class Object
|
5
5
|
class Date < Object
|
6
|
-
def initialize(*args, **_kargs, &)
|
7
|
-
|
6
|
+
def initialize(*args, **_kargs, &_block)
|
7
|
+
self.raw = ::Date.parse(args.map(&:to_s).join("-"))
|
8
8
|
rescue ::Date::Error
|
9
|
-
|
9
|
+
self.raw = ::Date.current
|
10
10
|
end
|
11
11
|
|
12
12
|
def self.call(**args)
|
data/lib/code/object/decimal.rb
CHANGED
@@ -3,8 +3,8 @@
|
|
3
3
|
class Code
|
4
4
|
class Object
|
5
5
|
class Decimal < Object
|
6
|
-
def initialize(*args, **_kargs, &)
|
7
|
-
|
6
|
+
def initialize(*args, **_kargs, &_block)
|
7
|
+
self.raw =
|
8
8
|
if args.first.class.in?(NUMBER_CLASSES)
|
9
9
|
if args.second.class.in?(NUMBER_CLASSES)
|
10
10
|
args.first.to_s.to_d * (10**args.second.to_s.to_d)
|
@@ -15,7 +15,7 @@ class Code
|
|
15
15
|
0.to_d
|
16
16
|
end
|
17
17
|
rescue FloatDomainError
|
18
|
-
|
18
|
+
self.raw = 0.to_d
|
19
19
|
end
|
20
20
|
|
21
21
|
def call(**args)
|
@@ -15,8 +15,8 @@ class Code
|
|
15
15
|
delegate :code_two?, to: :code_size
|
16
16
|
delegate :code_zero?, to: :code_size
|
17
17
|
|
18
|
-
def initialize(*args, **kargs, &)
|
19
|
-
|
18
|
+
def initialize(*args, **kargs, &_block)
|
19
|
+
self.raw =
|
20
20
|
args
|
21
21
|
.map do |arg|
|
22
22
|
if arg.is_an?(::Hash)
|
@@ -218,7 +218,7 @@ class Code
|
|
218
218
|
end
|
219
219
|
|
220
220
|
def code_clear
|
221
|
-
|
221
|
+
self.raw = {}
|
222
222
|
self
|
223
223
|
end
|
224
224
|
|
@@ -265,11 +265,19 @@ class Code
|
|
265
265
|
.map
|
266
266
|
.with_index do |code_argument, index|
|
267
267
|
if code_default.nothing?
|
268
|
-
[
|
268
|
+
[
|
269
|
+
code_argument,
|
270
|
+
code_delete(code_argument, index: index, **globals)
|
271
|
+
]
|
269
272
|
else
|
270
273
|
[
|
271
274
|
code_argument,
|
272
|
-
code_delete(
|
275
|
+
code_delete(
|
276
|
+
code_argument,
|
277
|
+
code_default,
|
278
|
+
index: index,
|
279
|
+
**globals
|
280
|
+
)
|
273
281
|
]
|
274
282
|
end
|
275
283
|
end
|
@@ -378,11 +386,19 @@ class Code
|
|
378
386
|
.map
|
379
387
|
.with_index do |code_argument, index|
|
380
388
|
if code_default.nothing?
|
381
|
-
[
|
389
|
+
[
|
390
|
+
code_argument,
|
391
|
+
code_fetch(code_argument, index: index, **globals)
|
392
|
+
]
|
382
393
|
else
|
383
394
|
[
|
384
395
|
code_argument,
|
385
|
-
code_fetch(
|
396
|
+
code_fetch(
|
397
|
+
code_argument,
|
398
|
+
code_default,
|
399
|
+
index: index,
|
400
|
+
**globals
|
401
|
+
)
|
386
402
|
]
|
387
403
|
end
|
388
404
|
end
|
data/lib/code/object/duration.rb
CHANGED
@@ -3,8 +3,8 @@
|
|
3
3
|
class Code
|
4
4
|
class Object
|
5
5
|
class Duration < Object
|
6
|
-
def initialize(*args, **_kargs, &)
|
7
|
-
|
6
|
+
def initialize(*args, **_kargs, &_block)
|
7
|
+
self.raw =
|
8
8
|
if args.first.is_an?(::ActiveSupport::Duration)
|
9
9
|
args.first
|
10
10
|
elsif args.first.is_a?(Duration)
|
@@ -13,7 +13,7 @@ class Code
|
|
13
13
|
::ActiveSupport::Duration.parse(args.first.to_s)
|
14
14
|
end
|
15
15
|
rescue ::ActiveSupport::Duration::ISO8601Parser::ParsingError
|
16
|
-
|
16
|
+
self.raw = 0.seconds
|
17
17
|
end
|
18
18
|
|
19
19
|
def call(**args)
|
data/lib/code/object/function.rb
CHANGED
@@ -5,7 +5,7 @@ class Code
|
|
5
5
|
class Function < Object
|
6
6
|
attr_reader :code_parameters, :code_body
|
7
7
|
|
8
|
-
def initialize(*args, **_kargs, &)
|
8
|
+
def initialize(*args, **_kargs, &_block)
|
9
9
|
@code_parameters =
|
10
10
|
List
|
11
11
|
.new(args.first)
|
@@ -15,7 +15,7 @@ class Code
|
|
15
15
|
|
16
16
|
@code_body = Code.new(args.second.presence)
|
17
17
|
|
18
|
-
|
18
|
+
self.raw = List.new([code_parameters, code_body])
|
19
19
|
end
|
20
20
|
|
21
21
|
def call(**args)
|
data/lib/code/object/global.rb
CHANGED
@@ -107,11 +107,7 @@ class Code
|
|
107
107
|
end
|
108
108
|
when "Time"
|
109
109
|
sig(args) { Object.repeat }
|
110
|
-
|
111
|
-
Time.zone.local(*code_arguments.raw)
|
112
|
-
else
|
113
|
-
Class.new(Time)
|
114
|
-
end
|
110
|
+
code_arguments.any? ? Time.new(*code_arguments.raw) : Class.new(Time)
|
115
111
|
when "Context"
|
116
112
|
sig(args) { Object.repeat }
|
117
113
|
if code_arguments.any?
|
data/lib/code/object/html.rb
CHANGED
@@ -3,13 +3,12 @@
|
|
3
3
|
class Code
|
4
4
|
class Object
|
5
5
|
class Html < Object
|
6
|
-
def initialize(*args, **_kargs, &)
|
7
|
-
|
6
|
+
def initialize(*args, **_kargs, &_block)
|
7
|
+
self.raw =
|
8
8
|
if args.first.is_an?(Html)
|
9
9
|
args.first.raw
|
10
|
-
elsif args.first.is_a?(::Nokogiri::XML::NodeSet)
|
11
|
-
|
12
|
-
elsif args.first.is_a?(Nokogiri::XML::Node)
|
10
|
+
elsif args.first.is_a?(::Nokogiri::XML::NodeSet) ||
|
11
|
+
args.first.is_a?(Nokogiri::XML::Node)
|
13
12
|
args.first
|
14
13
|
else
|
15
14
|
Nokogiri.HTML(args.first.to_s)
|
data/lib/code/object/http.rb
CHANGED
data/lib/code/object/integer.rb
CHANGED
@@ -3,8 +3,8 @@
|
|
3
3
|
class Code
|
4
4
|
class Object
|
5
5
|
class Integer < Object
|
6
|
-
def initialize(*args, **_kargs, &)
|
7
|
-
|
6
|
+
def initialize(*args, **_kargs, &_block)
|
7
|
+
self.raw =
|
8
8
|
if args.first.class.in?(NUMBER_CLASSES)
|
9
9
|
if args.second.class.in?(NUMBER_CLASSES)
|
10
10
|
(args.first.to_s.to_d * (10**args.second.to_s.to_d)).to_i
|
@@ -15,7 +15,7 @@ class Code
|
|
15
15
|
0
|
16
16
|
end
|
17
17
|
rescue FloatDomainError
|
18
|
-
|
18
|
+
self.raw = 0
|
19
19
|
end
|
20
20
|
|
21
21
|
def call(**args)
|