code-ruby 1.0.0 → 1.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (51) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ci.yml +3 -3
  3. data/.prettierignore +2 -0
  4. data/.rubocop.yml +123 -5
  5. data/.ruby-version +1 -1
  6. data/.tool-versions +1 -1
  7. data/Gemfile +10 -2
  8. data/Gemfile.lock +32 -29
  9. data/VERSION +1 -1
  10. data/bin/bundle +123 -0
  11. data/bin/code +9 -11
  12. data/code-ruby.gemspec +3 -1
  13. data/lib/code/node/dictionary.rb +1 -3
  14. data/lib/code/node/if.rb +20 -15
  15. data/lib/code/node/left_operation.rb +1 -3
  16. data/lib/code/node/right_operation.rb +6 -6
  17. data/lib/code/node/while.rb +6 -6
  18. data/lib/code/object/boolean.rb +1 -1
  19. data/lib/code/object/class.rb +1 -1
  20. data/lib/code/object/code.rb +1 -1
  21. data/lib/code/object/context.rb +1 -1
  22. data/lib/code/object/date.rb +1 -1
  23. data/lib/code/object/decimal.rb +2 -2
  24. data/lib/code/object/dictionary.rb +12 -34
  25. data/lib/code/object/duration.rb +1 -1
  26. data/lib/code/object/function.rb +1 -1
  27. data/lib/code/object/global.rb +1 -1
  28. data/lib/code/object/html.rb +1 -1
  29. data/lib/code/object/integer.rb +2 -2
  30. data/lib/code/object/json.rb +2 -4
  31. data/lib/code/object/list.rb +3 -5
  32. data/lib/code/object/nothing.rb +1 -1
  33. data/lib/code/object/parameter.rb +1 -5
  34. data/lib/code/object/range.rb +1 -1
  35. data/lib/code/object/string.rb +1 -1
  36. data/lib/code/object/time.rb +1 -1
  37. data/lib/code/object.rb +7 -13
  38. data/lib/code/parser/string.rb +7 -7
  39. data/lib/code/type/repeat.rb +1 -1
  40. data/lib/code/version.rb +1 -1
  41. data/lib/code-ruby.rb +1 -1
  42. data/package-lock.json +14 -0
  43. data/package.json +0 -1
  44. data/spec/code/node/call_spec.rb +0 -34
  45. data/spec/code/parser_spec.rb +2 -2
  46. data/spec/code/type_spec.rb +1 -1
  47. data/spec/code_spec.rb +78 -79
  48. metadata +14 -12
  49. data/bin/console +0 -6
  50. data/yarn.lock +0 -4
  51. /data/spec/code/parser/{chained_call.rb → chained_call_spec.rb} +0 -0
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c8fd1137d78771da7054494333cedcdf9ebb4d45402112d2694d227e4d44739b
4
- data.tar.gz: f494bfe408b64cd08e39f300b499d1634c8ec59534519306658d44ef908c2f72
3
+ metadata.gz: c18e14d70e0c59a4c750fc2d88d6409cbb369cea4720fed6df5bd996b95bc439
4
+ data.tar.gz: 69b55dfd20ced710c2704e0d47cdd64f48de1365a61ed353a30ccc8d13a5db14
5
5
  SHA512:
6
- metadata.gz: 641adcd7f50838888057e7f2c84464d89641a5648136a00f18955ae2128d35b59ac7d2a780544c0a3cf2f917110e7417cbe9dfc4d1f9c494eac80cf313abe2b4
7
- data.tar.gz: d42e4ab20e52db2ab7cbde25b12c43810ef8441076954cbe3fbf7fba6abb1ae861af48ea0b85b85d037e26c77aeb96cc4c6b26a96f42e651ea3e33ee4845ca89
6
+ metadata.gz: c045e1b470ef60bf92cdc3c8c92f67e70b075ad31e91f63a1ce6057e4fb0937271f9bfa3e697d09b3862f0dfd1086ef0d16319e8f05b17db6baec301111e6f93
7
+ data.tar.gz: edb8e5f65bfec67ac9db946112acfc40c449ec828983ab6dcf066d00976641c2448434eeb2e7fc845e57a02d1de73639911884baf0580312c70764de4f0522ed
@@ -28,10 +28,10 @@ jobs:
28
28
  with:
29
29
  bundler-cache: true
30
30
  - run: bin/rubocop
31
- yarn-audit:
32
- name: Yarn Audit
31
+ npm-audit:
32
+ name: npm Audit
33
33
  runs-on: ubuntu-latest
34
34
  steps:
35
35
  - uses: actions/checkout@v4
36
36
  - uses: actions/setup-node@v4
37
- - run: yarn audit
37
+ - run: npm audit
data/.prettierignore ADDED
@@ -0,0 +1,2 @@
1
+ node_modules
2
+ vendor
data/.rubocop.yml CHANGED
@@ -1,8 +1,126 @@
1
- inherit_gem:
2
- rubocop-rails-omakase: rubocop.yml
3
-
4
- Layout/SpaceInsideArrayLiteralBrackets:
1
+ ---
2
+ AllCops:
3
+ Exclude:
4
+ - "*/node_modules/**/*"
5
+ - "*/vendor/**/*"
6
+ - node_modules/**/*
7
+ - vendor/**/*
8
+ NewCops: enable
9
+ Layout/ClosingHeredocIndentation:
10
+ Enabled: false
11
+ Layout/FirstArgumentIndentation:
12
+ Enabled: false
13
+ Layout/HashAlignment:
14
+ Enabled: false
15
+ Layout/HeredocIndentation:
16
+ Enabled: false
17
+ Layout/LineEndStringConcatenationIndentation:
18
+ Enabled: false
19
+ Layout/LineLength:
20
+ Enabled: false
21
+ Layout/MultilineMethodCallIndentation:
22
+ Enabled: false
23
+ Layout/MultilineOperationIndentation:
24
+ Enabled: false
25
+ Lint/EmptyClass:
26
+ Enabled: false
27
+ Lint/MissingSuper:
28
+ Enabled: false
29
+ Lint/PercentStringArray:
30
+ Enabled: false
31
+ Lint/ShadowingOuterLocalVariable:
32
+ Enabled: false
33
+ Lint/SuppressedException:
34
+ Enabled: false
35
+ Lint/UnusedBlockArgument:
36
+ Enabled: false
37
+ Lint/UselessAssignment:
38
+ Enabled: false
39
+ Metrics/AbcSize:
40
+ Enabled: false
41
+ Metrics/BlockLength:
42
+ Enabled: false
43
+ Metrics/ClassLength:
44
+ Enabled: false
45
+ Metrics/CyclomaticComplexity:
46
+ Enabled: false
47
+ Metrics/MethodLength:
48
+ Enabled: false
49
+ Metrics/ModuleLength:
50
+ Enabled: false
51
+ Metrics/ParameterLists:
52
+ Enabled: false
53
+ Metrics/PerceivedComplexity:
54
+ Enabled: false
55
+ Naming/FileName:
56
+ Enabled: false
57
+ Naming/MethodParameterName:
58
+ Enabled: false
59
+ Naming/VariableNumber:
5
60
  Enabled: false
6
-
7
61
  Performance/UnfreezeString:
8
62
  Enabled: false
63
+ RSpec/AnyInstance:
64
+ Enabled: false
65
+ RSpec/ContextWording:
66
+ Enabled: false
67
+ RSpec/DescribeClass:
68
+ Enabled: false
69
+ RSpec/ExampleLength:
70
+ Enabled: false
71
+ RSpec/ExampleWording:
72
+ Enabled: false
73
+ RSpec/MultipleExpectations:
74
+ Enabled: false
75
+ RSpec/NoExpectationExample:
76
+ Enabled: false
77
+ RSpec/PendingWithoutReason:
78
+ Enabled: false
79
+ Rails/Delegate:
80
+ Enabled: false
81
+ Rails/DynamicFindBy:
82
+ Enabled: false
83
+ Rails/HelperInstanceVariable:
84
+ Enabled: false
85
+ Rails/NegateInclude:
86
+ Enabled: false
87
+ Rails/Output:
88
+ Enabled: false
89
+ Rails/Presence:
90
+ Enabled: false
91
+ Rails/Present:
92
+ Enabled: false
93
+ Rails/ThreeStateBooleanColumn:
94
+ Enabled: false
95
+ Rails/TimeZone:
96
+ Enabled: false
97
+ Security/Eval:
98
+ Enabled: false
99
+ Style/CaseEquality:
100
+ Enabled: false
101
+ Style/Documentation:
102
+ Enabled: false
103
+ Style/DoubleNegation:
104
+ Enabled: false
105
+ Style/EmptyMethod:
106
+ Enabled: false
107
+ Style/IfUnlessModifier:
108
+ Enabled: false
109
+ Style/MultilineBlockChain:
110
+ Enabled: false
111
+ Style/NestedTernaryOperator:
112
+ Enabled: false
113
+ Style/QuotedSymbols:
114
+ Enabled: false
115
+ Style/StringLiterals:
116
+ Enabled: false
117
+ Style/StringLiteralsInInterpolation:
118
+ Enabled: false
119
+ require:
120
+ - rubocop-factory_bot
121
+ - rubocop-performance
122
+ - rubocop-rails
123
+ - rubocop-rake
124
+ - rubocop-rspec
125
+ - rubocop-rspec_rails
126
+ - rubocop-capybara
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 3.3.4
1
+ 3.3.5
data/.tool-versions CHANGED
@@ -1,3 +1,3 @@
1
- ruby 3.3.4
1
+ ruby 3.3.5
2
2
  yarn 1.22.22
3
3
  nodejs 22.5.1
data/Gemfile CHANGED
@@ -4,10 +4,18 @@ source "https://rubygems.org"
4
4
 
5
5
  gemspec
6
6
 
7
- ruby "3.3.4"
7
+ ruby "3.3.5"
8
8
 
9
9
  gem "bundler-audit"
10
10
  gem "rake"
11
11
  gem "rspec"
12
- gem "rubocop-rails-omakase"
13
12
  gem "ruby-prof"
13
+
14
+ gem "rubocop-factory_bot"
15
+ gem "rubocop-performance"
16
+ gem "rubocop-rails"
17
+ gem "rubocop-rake"
18
+ gem "rubocop-rspec"
19
+ gem "rubocop-rspec_rails"
20
+
21
+ gem "rubocop-capybara"
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- code-ruby (1.0.0)
4
+ code-ruby (1.1.1)
5
5
  activesupport
6
6
  bigdecimal
7
7
  did-you-mean
@@ -35,24 +35,21 @@ GEM
35
35
  did-you-mean (0.1.1)
36
36
  levenshtein (>= 0.2.0)
37
37
  diff-lcs (1.5.1)
38
- dorian-arguments (0.4.1)
39
- activesupport
38
+ dorian-arguments (1.1.0)
40
39
  bigdecimal
41
- dorian-to_struct
42
- dorian-to_struct (0.6.0)
43
40
  drb (2.2.1)
44
41
  i18n (1.14.5)
45
42
  concurrent-ruby (~> 1.0)
46
43
  json (2.7.2)
47
- language-ruby (0.9.3)
44
+ language-ruby (1.0.1)
48
45
  dorian-arguments
49
46
  zeitwerk
50
47
  language_server-protocol (3.17.0.3)
51
48
  levenshtein (0.2.2)
52
- logger (1.6.0)
49
+ logger (1.6.1)
53
50
  minitest (5.25.1)
54
51
  parallel (1.26.3)
55
- parser (3.3.4.2)
52
+ parser (3.3.5.0)
56
53
  ast (~> 2.4.1)
57
54
  racc
58
55
  racc (1.8.1)
@@ -60,13 +57,11 @@ GEM
60
57
  rainbow (3.1.1)
61
58
  rake (13.2.1)
62
59
  regexp_parser (2.9.2)
63
- rexml (3.3.6)
64
- strscan
65
60
  rspec (3.13.0)
66
61
  rspec-core (~> 3.13.0)
67
62
  rspec-expectations (~> 3.13.0)
68
63
  rspec-mocks (~> 3.13.0)
69
- rspec-core (3.13.0)
64
+ rspec-core (3.13.1)
70
65
  rspec-support (~> 3.13.0)
71
66
  rspec-expectations (3.13.2)
72
67
  diff-lcs (>= 1.2.0, < 2.0)
@@ -75,22 +70,22 @@ GEM
75
70
  diff-lcs (>= 1.2.0, < 2.0)
76
71
  rspec-support (~> 3.13.0)
77
72
  rspec-support (3.13.1)
78
- rubocop (1.65.1)
73
+ rubocop (1.66.1)
79
74
  json (~> 2.3)
80
75
  language_server-protocol (>= 3.17.0)
81
76
  parallel (~> 1.10)
82
77
  parser (>= 3.3.0.2)
83
78
  rainbow (>= 2.2.2, < 4.0)
84
79
  regexp_parser (>= 2.4, < 3.0)
85
- rexml (>= 3.2.5, < 4.0)
86
- rubocop-ast (>= 1.31.1, < 2.0)
80
+ rubocop-ast (>= 1.32.2, < 2.0)
87
81
  ruby-progressbar (~> 1.7)
88
82
  unicode-display_width (>= 2.4.0, < 3.0)
89
- rubocop-ast (1.32.1)
83
+ rubocop-ast (1.32.3)
90
84
  parser (>= 3.3.1.0)
91
- rubocop-minitest (0.35.1)
92
- rubocop (>= 1.61, < 2.0)
93
- rubocop-ast (>= 1.31.1, < 2.0)
85
+ rubocop-capybara (2.21.0)
86
+ rubocop (~> 1.41)
87
+ rubocop-factory_bot (2.26.1)
88
+ rubocop (~> 1.61)
94
89
  rubocop-performance (1.21.1)
95
90
  rubocop (>= 1.48.1, < 2.0)
96
91
  rubocop-ast (>= 1.31.1, < 2.0)
@@ -99,35 +94,43 @@ GEM
99
94
  rack (>= 1.1)
100
95
  rubocop (>= 1.52.0, < 2.0)
101
96
  rubocop-ast (>= 1.31.1, < 2.0)
102
- rubocop-rails-omakase (1.0.0)
103
- rubocop
104
- rubocop-minitest
105
- rubocop-performance
106
- rubocop-rails
97
+ rubocop-rake (0.6.0)
98
+ rubocop (~> 1.0)
99
+ rubocop-rspec (3.0.4)
100
+ rubocop (~> 1.61)
101
+ rubocop-rspec_rails (2.30.0)
102
+ rubocop (~> 1.61)
103
+ rubocop-rspec (~> 3, >= 3.0.1)
107
104
  ruby-prof (1.7.0)
108
105
  ruby-progressbar (1.13.0)
109
106
  securerandom (0.3.1)
110
- strscan (3.1.0)
111
- thor (1.3.1)
107
+ thor (1.3.2)
112
108
  tzinfo (2.0.6)
113
109
  concurrent-ruby (~> 1.0)
114
110
  unicode-display_width (2.5.0)
115
- zeitwerk (2.6.17)
111
+ zeitwerk (2.6.18)
116
112
 
117
113
  PLATFORMS
118
114
  arm64-darwin-23
119
115
  ruby
116
+ x86_64-linux
120
117
 
121
118
  DEPENDENCIES
122
119
  bundler-audit
123
120
  code-ruby!
124
121
  rake
125
122
  rspec
126
- rubocop-rails-omakase
123
+ rubocop-capybara
124
+ rubocop-factory_bot
125
+ rubocop-performance
126
+ rubocop-rails
127
+ rubocop-rake
128
+ rubocop-rspec
129
+ rubocop-rspec_rails
127
130
  ruby-prof
128
131
 
129
132
  RUBY VERSION
130
- ruby 3.3.4p94
133
+ ruby 3.3.5p100
131
134
 
132
135
  BUNDLED WITH
133
- 2.5.17
136
+ 2.5.18
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.0.0
1
+ 1.1.1
data/bin/bundle ADDED
@@ -0,0 +1,123 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ #
5
+ # This file was generated by Bundler.
6
+ #
7
+ # The application 'bundle' is installed as part of a gem, and
8
+ # this file is here to facilitate running it.
9
+ #
10
+
11
+ require "rubygems"
12
+
13
+ m =
14
+ Module.new do
15
+ module_function
16
+
17
+ def invoked_as_script?
18
+ File.expand_path($PROGRAM_NAME) == File.expand_path(__FILE__)
19
+ end
20
+
21
+ def env_var_version
22
+ ENV.fetch("BUNDLER_VERSION", nil)
23
+ end
24
+
25
+ def cli_arg_version
26
+ return unless invoked_as_script? # don't want to hijack other binstubs
27
+ return unless "update".start_with?(ARGV.first || " ") # must be running `bundle update`
28
+
29
+ bundler_version = nil
30
+ update_index = nil
31
+ ARGV.each_with_index do |a, i|
32
+ if update_index && update_index.succ == i &&
33
+ a.match?(Gem::Version::ANCHORED_VERSION_PATTERN)
34
+ bundler_version = a
35
+ end
36
+ unless a =~ /\A--bundler(?:[= ](#{Gem::Version::VERSION_PATTERN}))?\z/o
37
+ next
38
+ end
39
+
40
+ bundler_version = Regexp.last_match(1)
41
+ update_index = i
42
+ end
43
+ bundler_version
44
+ end
45
+
46
+ def gemfile
47
+ gemfile = ENV.fetch("BUNDLE_GEMFILE", nil)
48
+ return gemfile if gemfile && !gemfile.empty?
49
+
50
+ File.expand_path("../Gemfile", __dir__)
51
+ end
52
+
53
+ def lockfile
54
+ lockfile =
55
+ case File.basename(gemfile)
56
+ when "gems.rb"
57
+ gemfile.sub(/\.rb$/, ".locked")
58
+ else
59
+ "#{gemfile}.lock"
60
+ end
61
+ File.expand_path(lockfile)
62
+ end
63
+
64
+ def lockfile_version
65
+ return unless File.file?(lockfile)
66
+
67
+ lockfile_contents = File.read(lockfile)
68
+ unless lockfile_contents =~
69
+ /\n\nBUNDLED WITH\n\s{2,}(#{Gem::Version::VERSION_PATTERN})\n/o
70
+ return
71
+ end
72
+
73
+ Regexp.last_match(1)
74
+ end
75
+
76
+ def bundler_requirement
77
+ @bundler_requirement ||=
78
+ env_var_version || cli_arg_version ||
79
+ bundler_requirement_for(lockfile_version)
80
+ end
81
+
82
+ def bundler_requirement_for(version)
83
+ return "#{Gem::Requirement.default}.a" unless version
84
+
85
+ bundler_gem_version = Gem::Version.new(version)
86
+
87
+ bundler_gem_version.approximate_recommendation
88
+ end
89
+
90
+ def load_bundler!
91
+ ENV["BUNDLE_GEMFILE"] ||= gemfile
92
+
93
+ activate_bundler
94
+ end
95
+
96
+ def activate_bundler
97
+ gem_error =
98
+ activation_error_handling { gem "bundler", bundler_requirement }
99
+ return if gem_error.nil?
100
+
101
+ require_error = activation_error_handling { require "bundler/version" }
102
+ if require_error.nil? &&
103
+ Gem::Requirement.new(bundler_requirement).satisfied_by?(
104
+ Gem::Version.new(Bundler::VERSION)
105
+ )
106
+ return
107
+ end
108
+
109
+ warn "Activating bundler (#{bundler_requirement}) failed:\n#{gem_error.message}\n\nTo install the version of bundler this project requires, run `gem install bundler -v '#{bundler_requirement}'`"
110
+ exit 42
111
+ end
112
+
113
+ def activation_error_handling
114
+ yield
115
+ nil
116
+ rescue StandardError, LoadError => e
117
+ e
118
+ end
119
+ end
120
+
121
+ m.load_bundler!
122
+
123
+ load Gem.bin_path("bundler", "bundle") if m.invoked_as_script?
data/bin/code CHANGED
@@ -34,13 +34,11 @@ abort Code::Version.to_s if parsed.options.version
34
34
  abort parsed.help if parsed.options.help
35
35
 
36
36
  input = parsed.options.input.to_s
37
- input = File.read(input) if File.exist?(input)
37
+ input += File.read(input) if File.exist?(input)
38
38
  input += parsed.arguments.join(" ")
39
39
  input += parsed.files.map { |file| File.read(file) }.join
40
40
 
41
- abort parsed.help if input.empty?
42
-
43
- profile = parsed.options.profile || !parsed.options.profiler.empty?
41
+ profile = parsed.options.profile || parsed.options.profiler
44
42
  require "ruby-prof" if profile
45
43
 
46
44
  RubyProf.start if profile
@@ -61,11 +59,11 @@ end
61
59
  if profile
62
60
  result = RubyProf.stop
63
61
 
64
- if parsed.options.profiler == "html"
65
- printer = RubyProf::GraphHtmlPrinter.new(result)
66
- printer.print($stdout)
67
- else
68
- printer = RubyProf::FlatPrinter.new(result)
69
- printer.print($stdout)
70
- end
62
+ printer =
63
+ if parsed.options.profiler == "html"
64
+ RubyProf::GraphHtmlPrinter.new(result)
65
+ else
66
+ RubyProf::FlatPrinter.new(result)
67
+ end
68
+ printer.print($stdout)
71
69
  end
data/code-ruby.gemspec CHANGED
@@ -16,8 +16,10 @@ Gem::Specification.new do |s|
16
16
  s.add_dependency "activesupport"
17
17
  s.add_dependency "bigdecimal"
18
18
  s.add_dependency "did-you-mean"
19
+ s.add_dependency "dorian-arguments"
19
20
  s.add_dependency "json"
20
21
  s.add_dependency "language-ruby"
21
22
  s.add_dependency "zeitwerk"
22
- s.add_dependency "dorian-arguments"
23
+ s.metadata["rubygems_mfa_required"] = "true"
24
+ s.required_ruby_version = ">= 3"
23
25
  end
@@ -41,9 +41,7 @@ class Code
41
41
 
42
42
  def evaluate(**args)
43
43
  ::Code::Object::Dictionary.new(
44
- (@key_values || [])
45
- .map { |key_value| key_value.evaluate(**args) }
46
- .to_h
44
+ (@key_values || []).to_h { |key_value| key_value.evaluate(**args) }
47
45
  )
48
46
  end
49
47
  end
data/lib/code/node/if.rb CHANGED
@@ -35,24 +35,29 @@ class Code
35
35
  end
36
36
 
37
37
  def evaluate(**args)
38
- if @first_operator == IF_KEYWORD &&
39
- @first_statement.evaluate(**args).truthy?
40
- @first_body.evaluate(**args)
41
- elsif @first_operator == UNLESS_KEYWORD &&
42
- @first_statement.evaluate(**args).falsy?
38
+ if (
39
+ @first_operator == IF_KEYWORD &&
40
+ @first_statement.evaluate(**args).truthy?
41
+ ) ||
42
+ (
43
+ @first_operator == UNLESS_KEYWORD &&
44
+ @first_statement.evaluate(**args).falsy?
45
+ )
43
46
  @first_body.evaluate(**args)
44
47
  else
45
48
  (@elses || []).each do |elses|
46
- if elses.operator == ELSIF_KEYWORD &&
47
- elses.statement.evaluate(**args).truthy?
48
- return elses.body.evaluate(**args)
49
- elsif elses.operator == IF_KEYWORD &&
50
- elses.statement.evaluate(**args).truthy?
51
- return elses.body.evaluate(**args)
52
- elsif elses.operator == UNLESS_KEYWORD &&
53
- elses.statement.evaluate(**args).falsy?
54
- return elses.body.evaluate(**args)
55
- elsif elses.operator == ELSE_KEYWORD
49
+ if (
50
+ elses.operator == ELSIF_KEYWORD &&
51
+ elses.statement.evaluate(**args).truthy?
52
+ ) ||
53
+ (
54
+ elses.operator == IF_KEYWORD &&
55
+ elses.statement.evaluate(**args).truthy?
56
+ ) ||
57
+ (
58
+ elses.operator == UNLESS_KEYWORD &&
59
+ elses.statement.evaluate(**args).falsy?
60
+ ) || (elses.operator == ELSE_KEYWORD)
56
61
  return elses.body.evaluate(**args)
57
62
  end
58
63
  end
@@ -58,9 +58,7 @@ class Code
58
58
  else
59
59
  right.statement.evaluate(**args, object: left)
60
60
  end
61
- elsif right.or? && left.truthy?
62
- left
63
- elsif right.and? && left.falsy?
61
+ elsif (right.or? && left.truthy?) || (right.and? && left.falsy?)
64
62
  left
65
63
  else
66
64
  left.call(
@@ -30,17 +30,17 @@ class Code
30
30
  when "while"
31
31
  left = Object::Nothing.new
32
32
 
33
- while (@right&.evaluate(**args) || Object::Nothing.new).truthy?
34
- left = @left&.evaluate(**args) || Object::Nothing.new
35
- end
33
+ left = @left&.evaluate(**args) || Object::Nothing.new while (
34
+ @right&.evaluate(**args) || Object::Nothing.new
35
+ ).truthy?
36
36
 
37
37
  left
38
38
  when "until"
39
39
  left = Object::Nothing.new
40
40
 
41
- while (@right&.evaluate(**args) || Object::Nothing.new).falsy?
42
- left = @left&.evaluate(**args) || Object::Nothing.new
43
- end
41
+ left = @left&.evaluate(**args) || Object::Nothing.new while (
42
+ @right&.evaluate(**args) || Object::Nothing.new
43
+ ).falsy?
44
44
 
45
45
  left
46
46
  when "rescue"
@@ -22,17 +22,17 @@ class Code
22
22
  when WHILE_KEYWORD
23
23
  last = Object::Nothing.new
24
24
 
25
- while (@statement&.evaluate(**args) || Object::Nothing.new).truthy?
26
- last = @body&.evaluate(**args) || Object::Nothing.new
27
- end
25
+ last = @body&.evaluate(**args) || Object::Nothing.new while (
26
+ @statement&.evaluate(**args) || Object::Nothing.new
27
+ ).truthy?
28
28
 
29
29
  last
30
30
  when UNTIL_KEYWORD
31
31
  last = Object::Nothing.new
32
32
 
33
- while (@statement&.evaluate(**args) || Object::Nothing.new).falsy?
34
- last = @body&.evaluate(**args) || Object::Nothing.new
35
- end
33
+ last = @body&.evaluate(**args) || Object::Nothing.new while (
34
+ @statement&.evaluate(**args) || Object::Nothing.new
35
+ ).falsy?
36
36
 
37
37
  last
38
38
  when LOOP_KEYWORD
@@ -3,7 +3,7 @@
3
3
  class Code
4
4
  class Object
5
5
  class Boolean < ::Code::Object
6
- def initialize(*args, **_kargs, &_block)
6
+ def initialize(*args, **_kargs, &)
7
7
  raw = args.first || Nothing.new
8
8
  raw = raw.raw if raw.is_a?(Object)
9
9
  @raw = !!raw
@@ -3,7 +3,7 @@
3
3
  class Code
4
4
  class Object
5
5
  class Class < Object
6
- def initialize(*args, **_kargs, &_block)
6
+ def initialize(*args, **_kargs, &)
7
7
  raw = args.first || Nothing.new
8
8
  raw = raw.raw if raw.is_a?(Class)
9
9
  raw = raw.class if raw.is_an?(Object)
@@ -3,7 +3,7 @@
3
3
  class Code
4
4
  class Object
5
5
  class Code < Object
6
- def initialize(*args, **_kargs, &_block)
6
+ def initialize(*args, **_kargs, &)
7
7
  raw = args.first.presence || Nothing.new
8
8
  @raw = raw.is_a?(Node) ? raw : Node::Code.new(::Code.parse(raw.to_s))
9
9
  end
@@ -5,7 +5,7 @@ class Code
5
5
  class Context < Dictionary
6
6
  attr_reader :parent
7
7
 
8
- def initialize(*args, **_kargs, &_block)
8
+ def initialize(*args, **_kargs, &)
9
9
  raw = args.first || Dictionary.new
10
10
  raw = raw.raw if raw.is_a?(Object)
11
11
  @raw = raw.to_h
@@ -3,7 +3,7 @@
3
3
  class Code
4
4
  class Object
5
5
  class Date < Object
6
- def initialize(*args, **_kargs, &_block)
6
+ def initialize(*args, **_kargs, &)
7
7
  raw = args.map(&:to_s).join("-").presence || ::Date.current.to_s
8
8
  @raw = ::Date.parse(raw)
9
9
  rescue ::Date::Error