Skip to content

Commit 4fd92e8

Browse files
authored
Merge pull request #170 from bigcommerce/RUBY-17
RUBY-17: Add frozen_string_literal magic comment to all files
2 parents 69ca781 + 570f568 commit 4fd92e8

File tree

91 files changed

+199
-19
lines changed

Some content is hidden

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

91 files changed

+199
-19
lines changed

.rubocop.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,6 @@ Naming/VariableNumber:
3333
########################################################################################################################
3434
# TO FIX
3535
########################################################################################################################
36-
Style/FrozenStringLiteralComment:
37-
Enabled: false
38-
3936
Layout/EmptyLineAfterGuardClause:
4037
Enabled: false
4138

CHANGELOG.md

Lines changed: 1 addition & 0 deletions

Gemfile

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,5 @@
1+
# frozen_string_literal: true
2+
13
source 'https://rubygems.org'
24

35
gemspec
4-
5-
group :development do
6-
gem 'pry'
7-
gem 'rspec'
8-
gem 'rubocop'
9-
gem 'simplecov'
10-
end

Rakefile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
require 'bundler/gem_tasks'
1+
# frozen_string_literal: true
22

3+
require 'bundler/gem_tasks'
34
require 'rspec/core/rake_task'
5+
46
RSpec::Core::RakeTask.new do |spec|
57
spec.pattern = 'spec/**/*_spec.rb'
68
spec.verbose = false

bigcommerce.gemspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# frozen_string_literal : true
1+
# frozen_string_literal: true
22

33
$LOAD_PATH.unshift(File.expand_path('lib', __dir__))
44
require 'bigcommerce/version'

lib/bigcommerce/config.rb

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,28 @@
1+
# frozen_string_literal: true
2+
13
module Bigcommerce
24
class Config < Hashie::Mash
5+
BC_API_ENDPOINT_ENV_KEY = 'BC_API_ENDPOINT'
36
DEFAULTS = {
47
base_url: 'https://api.bigcommerce.com'
58
}.freeze
69

10+
##
11+
# @return [String]
12+
#
713
def api_url
814
return url if auth == 'legacy'
915

10-
base = ENV['BC_API_ENDPOINT'].to_s.empty? ? DEFAULTS[:base_url] : ENV['BC_API_ENDPOINT']
11-
"#{base}/stores/#{store_hash}/v2"
16+
"#{base_url}/stores/#{store_hash}/v2"
17+
end
18+
19+
private
20+
21+
##
22+
# @return [String]
23+
#
24+
def base_url
25+
ENV[BC_API_ENDPOINT_ENV_KEY].to_s.empty? ? DEFAULTS[:base_url] : ENV[BC_API_ENDPOINT_ENV_KEY]
1226
end
1327
end
1428
end

lib/bigcommerce/connection.rb

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
1+
# frozen_string_literal: true
2+
13
module Bigcommerce
24
module Connection
5+
LEGACY_AUTH_MODE = 'legacy'
36
HEADERS = {
47
'accept' => 'application/json',
58
'content-type' => 'application/json',
@@ -12,7 +15,7 @@ def self.build(config)
1215
Faraday.new(url: config.api_url, ssl: ssl_options) do |conn|
1316
conn.request :json
1417
conn.headers = HEADERS
15-
if config.auth == 'legacy'
18+
if config.auth == LEGACY_AUTH_MODE
1619
conn.use Faraday::Request::BasicAuthentication, config.username, config.api_key
1720
else
1821
conn.use Bigcommerce::Middleware::Auth, config

lib/bigcommerce/exception.rb

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,15 @@ module HttpErrors
4242
509 => Bigcommerce::BandwidthLimitExceeded
4343
}.freeze
4444

45+
X_RETRY_AFTER_HEADER_KEY = 'x-retry-after'
46+
4547
def throw_http_exception!(code, env)
4648
return unless ERRORS.key?(code)
4749

4850
response_headers = Faraday::Utils::Headers.new(env.response_headers)
4951

50-
unless response_headers['x-retry-after'].nil?
51-
response_headers[:retry_after] = response_headers['x-retry-after'].to_i
52+
unless response_headers[X_RETRY_AFTER_HEADER_KEY].nil?
53+
response_headers[:retry_after] = response_headers[X_RETRY_AFTER_HEADER_KEY].to_i
5254
end
5355

5456
raise ERRORS[code].new(response_headers), env.body

lib/bigcommerce/middleware/http_exception.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
require 'bigcommerce/exception'
24

35
module Bigcommerce

lib/bigcommerce/request.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
require 'json'
24

35
module Bigcommerce

0 commit comments

Comments
 (0)