Skip to content

Commit d60548a

Browse files
authored
Fix frozen string literal issue for ruby 3.4 (#300)
* Fix frozen string literal issue * Remove base64 instead of adding it since it's never used + fix ruby 3.4 warning
1 parent 767f353 commit d60548a

File tree

12 files changed

+35
-22
lines changed

12 files changed

+35
-22
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.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
# external core dependencies
2-
require "base64"
32
require "cgi"
43
require "uri"
54
require "excon"

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/fog/storage.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ def self.parse_data(data)
5959
headers: {
6060
"Content-Length" => get_body_size(data),
6161
"Content-Type" => get_content_type(data)
62-
# "Content-MD5" => Base64.encode64(Digest::MD5.digest(metadata[:body])).strip
6362
}
6463
}
6564
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

0 commit comments

Comments
 (0)