Skip to content

Commit da0c8e8

Browse files
committed
Fix frozen string literal issue
1 parent 5560d23 commit da0c8e8

File tree

10 files changed

+35
-20
lines changed

10 files changed

+35
-20
lines changed

.github/workflows/ci.yml

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,21 @@ permissions:
1212
contents: read
1313

1414
jobs:
15-
Shared:
16-
uses: fog/.github/.github/workflows/[email protected]
15+
test:
16+
17+
runs-on: ubuntu-latest
18+
19+
strategy:
20+
matrix:
21+
ruby-version: ['3.0', '3.1', '3.2', '3.3', 'head']
22+
continue-on-error: ${{ matrix.ruby-version == 'head' }}
23+
24+
steps:
25+
- uses: actions/checkout@v4
26+
- name: Set up Ruby
27+
uses: ruby/setup-ruby@v1
28+
with:
29+
ruby-version: ${{ matrix.ruby-version }}
30+
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
31+
- name: Run tests
32+
run: bundle exec rake RUBYOPT="--enable-frozen-string-literal"

lib/fog/compute.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ def self.new(orig_attributes)
2929
Fog::Compute::DigitalOcean.new(attributes)
3030
end
3131
else
32-
super(orig_attributes)
32+
super
3333
end
3434
end
3535

lib/fog/core/mock.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ def self.random_letters_and_numbers(length)
8181
end
8282

8383
def self.random_selection(characters, length)
84-
selection = ""
84+
selection = +""
8585
length.times do
8686
position = rand(characters.length)
8787
selection << characters[position..position]

lib/fog/core/provider.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ def extended(base)
1818
private
1919

2020
def underscore_name(string)
21-
string.gsub(/::/, "/")
21+
string.gsub("::", "/")
2222
.gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2')
2323
.gsub(/([a-z\d])([A-Z])/,'\1_\2')
2424
.tr("-", "_")

lib/fog/core/service.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ def secrets(*args)
212212
@secrets ||= []
213213
else
214214
args.reduce(secrets) do |secrets, secret|
215-
secrets << "@#{secret}".to_sym
215+
secrets << :"@#{secret}"
216216
end
217217
end
218218
end

lib/fog/formatador.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ def self.formatador
1010
end
1111

1212
def self.format(object, opts = { include_nested: true })
13-
string = init_string(object)
13+
string = +init_string(object)
1414
indent { string << object_string(object, opts) }
1515
string << "#{indentation}>"
1616
end
@@ -48,7 +48,7 @@ def self.init_string(object)
4848
end
4949

5050
def self.object_string(object, opts)
51-
string = attribute_string(object).to_s
51+
string = +attribute_string(object).to_s
5252
string << nested_objects_string(object).to_s if opts[:include_nested]
5353
string
5454
end
@@ -68,7 +68,7 @@ def self.nested_objects_string(object)
6868
return nested if object.respond_to?(:empty) and object.empty?
6969
return nested unless object.is_a?(Enumerable)
7070

71-
nested = "#{indentation}[\n"
71+
nested = +"#{indentation}[\n"
7272
indent { nested << indentation + inspect_object(object) }
7373
nested << "#{indentation}\n#{indentation}]\n"
7474
end

lib/tasks/test_task.rb

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,9 @@ def initialize
2222
def tests(mocked)
2323
Fog::Formatador.display_line
2424
start = Time.now.to_i
25-
threads = []
2625
Thread.main[:results] = []
27-
Fog.providers.each do |key, value|
28-
threads << Thread.new do
26+
threads = Fog.providers.map do |key, value|
27+
Thread.new do
2928
Thread.main[:results] << {
3029
provider: value,
3130
success: sh("export FOG_MOCK=#{mocked} && bundle exec shindont +#{key}")

spec/core/collection_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
require "securerandom"
33

44
class FogTestModelForCollection < Fog::Model
5-
identity :id
5+
identity :id
66
end
77

88
class FogTestCollection < Fog::Collection

spec/formatador_spec.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ def all
4242
end
4343

4444
it "returns formatted representation" do
45-
Fog::Formatador.format(@collection).must_equal @expected
45+
_(Fog::Formatador.format(@collection)).must_equal @expected
4646
end
4747
end
4848

@@ -65,7 +65,7 @@ def all
6565
end
6666

6767
it "returns formatted representation" do
68-
Fog::Formatador.format(@collection).must_equal @expected
68+
_(Fog::Formatador.format(@collection)).must_equal @expected
6969
end
7070
end
7171

@@ -90,7 +90,7 @@ def all
9090
EOS
9191

9292
opts = { include_nested: false }
93-
Fog::Formatador.format(@collection, opts).must_equal @expected
93+
_(Fog::Formatador.format(@collection, opts)).must_equal @expected
9494
end
9595
end
9696

@@ -105,7 +105,7 @@ def all
105105
end
106106

107107
it "returns formatted representation" do
108-
Fog::Formatador.format(@subject).must_equal @expected
108+
_(Fog::Formatador.format(@subject)).must_equal @expected
109109
end
110110
end
111111

@@ -148,7 +148,7 @@ def all
148148
end
149149

150150
it "returns formatted representation" do
151-
Fog::Formatador.format(@collection).must_equal @expected
151+
_(Fog::Formatador.format(@collection)).must_equal @expected
152152
end
153153
end
154154
end

spec/service_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ class Mock; def initialize(*_args); end; end
8888
it "returns the real service" do
8989
Fog.stub :mocking?, false do
9090
service = TestService.new(generic_api_key: "abc")
91-
service.must_be_instance_of TestService::Real
91+
_(service).must_be_instance_of TestService::Real
9292
end
9393
end
9494

@@ -115,7 +115,7 @@ class Mock; def initialize(*_args); end; end
115115
it "returns mocked service" do
116116
Fog.stub :mocking?, true do
117117
service = TestService.new(generic_api_key: "abc")
118-
service.must_be_instance_of TestService::Mock
118+
_(service).must_be_instance_of TestService::Mock
119119
end
120120
end
121121

0 commit comments

Comments
 (0)