Skip to content

Commit 0146ece

Browse files
format
1 parent b788a37 commit 0146ece

55 files changed

Lines changed: 3845 additions & 3983 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/ci.yml

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,45 +4,45 @@ jobs:
44
name: Bundler Audit
55
runs-on: ubuntu-24.04
66
steps:
7-
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
8-
- uses: ruby/setup-ruby@afeafc3d1ab54a631816aba4c914a0081c12ff2f # v1
7+
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5
8+
- uses: ruby/setup-ruby@afeafc3d1ab54a631816aba4c914a0081c12ff2f
99
with:
1010
bundler-cache: true
1111
- run: bundle exec bundler-audit check --update
1212
npm-audit:
1313
name: npm Audit
1414
runs-on: ubuntu-24.04
1515
steps:
16-
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
17-
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4
16+
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5
17+
- uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020
1818
with:
19-
node-version-file: .node-version
19+
node-version-file: ".node-version"
2020
- run: node --version && npm --version
2121
- run: npm audit
2222
rspec:
2323
name: Test
2424
runs-on: ubuntu-24.04
2525
steps:
26-
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
27-
- uses: ruby/setup-ruby@afeafc3d1ab54a631816aba4c914a0081c12ff2f # v1
26+
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5
27+
- uses: ruby/setup-ruby@afeafc3d1ab54a631816aba4c914a0081c12ff2f
2828
with:
2929
bundler-cache: true
3030
- run: bin/test
3131
rubocop:
3232
name: Rubocop
3333
runs-on: ubuntu-24.04
3434
steps:
35-
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
36-
- uses: ruby/setup-ruby@afeafc3d1ab54a631816aba4c914a0081c12ff2f # v1
35+
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5
36+
- uses: ruby/setup-ruby@afeafc3d1ab54a631816aba4c914a0081c12ff2f
3737
with:
3838
bundler-cache: true
3939
- run: bin/rubocop
4040
name: CI
41-
permissions:
42-
contents: read
4341
'on':
4442
pull_request:
4543
push:
4644
schedule:
4745
- cron: 0 6 * * *
4846
workflow_dispatch:
47+
permissions:
48+
contents: read

.rubocop.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,10 @@ Metrics/ParameterLists:
6666
Enabled: false
6767
Metrics/PerceivedComplexity:
6868
Enabled: false
69-
Naming/FileName:
70-
Enabled: false
7169
Naming/BlockForwarding:
7270
Enabled: false
71+
Naming/FileName:
72+
Enabled: false
7373
Naming/MethodParameterName:
7474
Enabled: false
7575
Naming/VariableNumber:
@@ -114,10 +114,10 @@ Rails/TimeZone:
114114
Enabled: false
115115
Security/Eval:
116116
Enabled: false
117-
Style/CaseEquality:
118-
Enabled: false
119117
Style/ArgumentsForwarding:
120118
Enabled: false
119+
Style/CaseEquality:
120+
Enabled: false
121121
Style/Documentation:
122122
Enabled: false
123123
Style/DoubleNegation:

bin/code

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -95,16 +95,17 @@ def expand_arguments(arguments)
9595
remaining_arguments << argument
9696
end
9797

98-
raise Code::Error, "too many input files" if expanded_files.size > MAX_ARGUMENT_FILES
98+
if expanded_files.size > MAX_ARGUMENT_FILES
99+
raise Code::Error, "too many input files"
100+
end
99101
end
100102

101103
[expanded_files, remaining_arguments]
102104
end
103105

104106
begin
105-
@parsed_timeout = Code.normalize_timeout!(
106-
parsed.options.timeout || Code::DEFAULT_TIMEOUT
107-
)
107+
@parsed_timeout =
108+
Code.normalize_timeout!(parsed.options.timeout || Code::DEFAULT_TIMEOUT)
108109
rescue Code::Error => e
109110
abort "#{e.class}: #{e.message}"
110111
end
@@ -126,7 +127,9 @@ begin
126127
append_limited(buffer, remaining_arguments.join(" "))
127128

128129
input_files = parsed.files + expanded_argument_files
129-
raise Code::Error, "too many input files" if input_files.size > MAX_ARGUMENT_FILES
130+
if input_files.size > MAX_ARGUMENT_FILES
131+
raise Code::Error, "too many input files"
132+
end
130133

131134
input_files.each.with_index do |file, index|
132135
append_limited(buffer, "\n\n") if index.positive?

code-ruby.gemspec

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,11 @@ Gem::Specification.new do |s|
77
s.description = s.summary
88
s.authors = ["Dorian Marié"]
99
s.email = "dorian@dorianmarie.com"
10-
s.files = IO.popen(
11-
%w[git ls-files -z -- lib bin/code LICENSE README.md VERSION],
12-
&:read
13-
).split("\x0")
10+
s.files =
11+
IO.popen(
12+
%w[git ls-files -z -- lib bin/code LICENSE README.md VERSION],
13+
&:read
14+
).split("\x0")
1415
s.require_paths = ["lib"]
1516
s.homepage = "https://github.com/dorianmariecom/code-ruby"
1617
s.license = "MIT"

lib/code/concerns/shared.rb

Lines changed: 102 additions & 98 deletions
Original file line numberDiff line numberDiff line change
@@ -5,96 +5,96 @@ module Concerns
55
module Shared
66
attr_accessor :raw, :functions
77

8-
COMPOUND_ASSIGNMENT_OPERATORS = [
9-
"+=",
10-
"-=",
11-
"*=",
12-
"/=",
13-
"%=",
14-
"<<=",
15-
">>=",
16-
"&=",
17-
"|=",
18-
"^=",
19-
"||=",
20-
"&&="
8+
COMPOUND_ASSIGNMENT_OPERATORS = %w[
9+
+=
10+
-=
11+
*=
12+
/=
13+
%=
14+
<<=
15+
>>=
16+
&=
17+
|=
18+
^=
19+
||=
20+
&&=
2121
].freeze
22-
SHARED_OPERATORS = [
23-
"documentation",
24-
"present?",
25-
"blank?",
26-
"presence",
27-
"presence_in",
28-
"is_a?",
29-
"is_an?",
30-
"kind_of?",
31-
"instance_of?",
32-
"new",
33-
"!",
34-
"not",
35-
"!=",
36-
"different",
37-
"&&",
38-
"and",
39-
"+",
40-
"self",
41-
"..",
42-
"inclusive_range",
43-
"...",
44-
"exclusive_range",
45-
"==",
46-
"equal",
47-
"equal?",
48-
"same_object?",
49-
">",
50-
"greater",
51-
">=",
52-
"greater_or_equal",
53-
"<=>",
54-
"compare",
55-
"<",
56-
"less",
57-
"<=",
58-
"less_or_equal",
59-
"===",
60-
"strict_equal",
61-
"!==",
62-
"strict_different",
63-
"falsy?",
64-
"truthy?",
65-
"true?",
66-
"false?",
67-
"||",
68-
"or",
69-
"to_boolean",
70-
"to_class",
71-
"to_date",
72-
"to_decimal",
73-
"to_dictionary",
74-
"to_duration",
75-
"to_integer",
76-
"to_list",
77-
"to_nothing",
78-
"to_range",
79-
"to_string",
80-
"inspect",
81-
"to_time",
82-
"as_json",
83-
"duplicate",
84-
"deep_duplicate",
85-
"to_parameter",
86-
"to_json",
87-
"functions",
88-
"instance_functions",
89-
"class_functions",
90-
"respond_to?",
91-
"send",
92-
"itself",
93-
"tap",
94-
"then",
95-
"name",
96-
"nothing?",
97-
"something?"
22+
SHARED_OPERATORS = %w[
23+
documentation
24+
present?
25+
blank?
26+
presence
27+
presence_in
28+
is_a?
29+
is_an?
30+
kind_of?
31+
instance_of?
32+
new
33+
!
34+
not
35+
!=
36+
different
37+
&&
38+
and
39+
+
40+
self
41+
..
42+
inclusive_range
43+
...
44+
exclusive_range
45+
==
46+
equal
47+
equal?
48+
same_object?
49+
>
50+
greater
51+
>=
52+
greater_or_equal
53+
<=>
54+
compare
55+
<
56+
less
57+
<=
58+
less_or_equal
59+
===
60+
strict_equal
61+
!==
62+
strict_different
63+
falsy?
64+
truthy?
65+
true?
66+
false?
67+
||
68+
or
69+
to_boolean
70+
to_class
71+
to_date
72+
to_decimal
73+
to_dictionary
74+
to_duration
75+
to_integer
76+
to_list
77+
to_nothing
78+
to_range
79+
to_string
80+
inspect
81+
to_time
82+
as_json
83+
duplicate
84+
deep_duplicate
85+
to_parameter
86+
to_json
87+
functions
88+
instance_functions
89+
class_functions
90+
respond_to?
91+
send
92+
itself
93+
tap
94+
then
95+
name
96+
nothing?
97+
something?
9898
].freeze
9999
OPERATOR_METHOD_ALIASES = {
100100
"[]" => "get",
@@ -519,7 +519,9 @@ def code_dynamic_call(operator, **args)
519519
return nil unless code_dynamic_functions.code_has_key?(operator).truthy?
520520

521521
stored_value = code_dynamic_functions.code_fetch(operator)
522-
return stored_value.call(**args, operator: nil, bound_self: self) if stored_value.is_a?(Object::Function)
522+
if stored_value.is_a?(Object::Function)
523+
return stored_value.call(**args, operator: nil, bound_self: self)
524+
end
523525

524526
sig(args)
525527
stored_value
@@ -641,9 +643,10 @@ def code_functions
641643

642644
def code_instance_functions
643645
Object.sorted_dictionary(
644-
Object.documented_functions_for(self.class, :instance).code_merge(
645-
dynamic_functions_documentation
646-
).raw
646+
Object
647+
.documented_functions_for(self.class, :instance)
648+
.code_merge(dynamic_functions_documentation)
649+
.raw
647650
)
648651
end
649652

@@ -755,7 +758,8 @@ def code_respond_to_operator?(operator)
755758
end
756759

757760
def code_operator_method_defined?(operator_name)
758-
method_name = :"code_#{OPERATOR_METHOD_ALIASES.fetch(operator_name, operator_name)}"
761+
method_name =
762+
:"code_#{OPERATOR_METHOD_ALIASES.fetch(operator_name, operator_name)}"
759763
return false unless respond_to?(method_name)
760764

761765
method(method_name).owner != Shared
@@ -775,10 +779,10 @@ def dynamic_functions_documentation
775779
name,
776780
Object::Dictionary.new(
777781
"name" => Object::String.new(name),
778-
"description" => Object::String.new(
779-
dynamic_function_description(value)
780-
),
781-
"examples" => Object::List.new(dynamic_function_examples(value)),
782+
"description" =>
783+
Object::String.new(dynamic_function_description(value)),
784+
"examples" =>
785+
Object::List.new(dynamic_function_examples(value)),
782786
"function" => value
783787
)
784788
]

0 commit comments

Comments
 (0)