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

lib/bigcommerce/resource_actions.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
module Bigcommerce
24
class ResourceActions < Module
35
attr_reader :options

lib/bigcommerce/resources/content/blog_post.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
# Blog Post
24
# Content entries in the store's blog.
35
# https://developer.bigcommerce.com/api/stores/v2/blog/posts

lib/bigcommerce/resources/content/blog_tag.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
# Blog Tag
24
# Index of tags used on the store's blog.
35
# https://developer.bigcommerce.com/api/stores/v2/blog/tags

lib/bigcommerce/resources/content/redirect.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
# Redirect
24
# Redirects are used to create custom URL paths that map to resources on the
35
# storefront (such as products, categories, brands, etc.) or manually defined

lib/bigcommerce/resources/customers/customer.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 'jwt'
24
require 'securerandom'
35

lib/bigcommerce/resources/customers/customer_address.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
# Customer Address
24
# Postal addresses belonging to a customer.
35
# https://developer.bigcommerce.com/api/stores/v2/customers/addresses

lib/bigcommerce/resources/customers/customer_group.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
# Customer Group
24
# Groups of customers who share the same level of access and discounts
35
# at a store.

lib/bigcommerce/resources/geography/country.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
# Country
24
# Countries and territories, identified by their ISO 3166 country codes.
35
# https://developer.bigcommerce.com/api/stores/v2/countries

lib/bigcommerce/resources/geography/state.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
# State
24
# States and subdivisions belonging to countries.
35
# https://developer.bigcommerce.com/api/stores/v2/countries/states

lib/bigcommerce/resources/marketing/banner.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
# Banner
24
# HTML element on webpages to advertise discounts or other content relevant to shoppers.
35
# https://developer.bigcommerce.com/api/stores/v2/banners

lib/bigcommerce/resources/marketing/coupon.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
# Coupon
24
# Category or product discounts that can be applied to orders for customers
35
# who enter a given code.

lib/bigcommerce/resources/marketing/gift_certificates.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
# Gift Certificates
24
# Code that can be applied by customers to their order to provide full or partial payment.
35
# https://developer.bigcommerce.com/api/stores/v2/gift_certificates

lib/bigcommerce/resources/orders/order.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
# Order
24
# Purchases from a store.
35
# https://developer.bigcommerce.com/api/stores/v2/orders

lib/bigcommerce/resources/orders/order_coupon.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
# Order Coupon
24
# Coupons applied to an order.
35
# https://developer.bigcommerce.com/api/stores/v2/orders/coupons

lib/bigcommerce/resources/orders/order_message.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
# Order Message
24
# Messages associated with an order.
35
# https://developer.bigcommerce.com/api/stores/v2/orders/messages

lib/bigcommerce/resources/orders/order_product.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
# Order Product
24
# Product line items associated with an order.
35
# https://developer.bigcommerce.com/api/stores/v2/orders/products

lib/bigcommerce/resources/orders/order_shipping_address.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
# Order Shipping Addresses
24
# Shipping addresses associated with an order.
35
# https://developer.bigcommerce.com/api/stores/v2/orders/shipping_addresses

lib/bigcommerce/resources/orders/order_status.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
# Order Status
24
# Statuses that can be assigned to orders. Each status represents a state in
35
# the fulfilment workflow.

lib/bigcommerce/resources/orders/order_tax.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
# Order Shipping Addresses
24
# Shipping addresses associated with an order.
35
# https://developer.bigcommerce.com/api/stores/v2/orders/shipping_addresses

lib/bigcommerce/resources/orders/shipment.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
# Order Shipment
24
# Shipping package consignments tracked from an order.
35
# https://developer.bigcommerce.com/api/stores/v2/orders/shipments

lib/bigcommerce/resources/payments/payment_method.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
# Payment Method
24
# Enabled payment methods.
35
# https://developer.bigcommerce.com/api/stores/v2/payments/methods

lib/bigcommerce/resources/products/brand.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
# Brand
24
# Brand facets for identifying and categorising products according
35
# to their manufacturer or company metonym.

lib/bigcommerce/resources/products/bulk_pricing_rule.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
# Bulk Pricing Rule
24
# Bulk pricing rules applied to a product.
35
# https://developer.bigcommerce.com/api/stores/v2/products/discount_rules

lib/bigcommerce/resources/products/category.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
# Category
24
# Index of hierarchical categories used to organise and group products.
35
# https://developer.bigcommerce.com/api/stores/v2/categories

lib/bigcommerce/resources/products/configurable_field.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
# Configurable Field
24
# Configurable fields associated with a product.
35
# https://developer.bigcommerce.com/api/stores/v2/products/configurable_fields

lib/bigcommerce/resources/products/custom_field.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
# Custom Field
24
# Custom fields associated with a product.
35
# https://developer.bigcommerce.com/api/stores/v2/products/custom_fields

lib/bigcommerce/resources/products/google_product_search_mapping.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
# Google Product Search Mapping
24
# Google Product Search mappings for a product.
35
# https://developer.bigcommerce.com/api/stores/v2/products/googleproductsearch

lib/bigcommerce/resources/products/option.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
# Option
24
# Shared attributes that control value facets on a product.
35
# https://developer.bigcommerce.com/api/stores/v2/options

lib/bigcommerce/resources/products/option_set.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
# Option Set
24
# A reusable set of option facets that can be applied to products.
35
# https://developer.bigcommerce.com/api/stores/v2/options_sets

lib/bigcommerce/resources/products/option_set_option.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
# Option Set Option
24
# Options belonging to an option set.
35
# https://developer.bigcommerce.com/api/stores/v2/option_sets/options

lib/bigcommerce/resources/products/option_value.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
# Option Value
24
# Values that can be selected for an option.
35
# https://developer.bigcommerce.com/api/stores/v2/options/values

lib/bigcommerce/resources/products/product.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
# Product
24
# Catalog of saleable items in the store.
35
# https://developer.bigcommerce.com/api/stores/v2/products

lib/bigcommerce/resources/products/product_image.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
# Product Image
24
# Images associated with a product.
35
# https://developer.bigcommerce.com/api/stores/v2/products/images

lib/bigcommerce/resources/products/product_option.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
# Product Option
24
# Options associated directly with a product.
35
# https://developer.bigcommerce.com/api/stores/v2/products/options

lib/bigcommerce/resources/products/product_review.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
# Product Review
24
# Options associated directly with a product.
35
# https://developer.bigcommerce.com/api/stores/v2/products/reviews

lib/bigcommerce/resources/products/product_rule.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
# Product Rule
24
# Rules that modify the default behaviour of products.
35
# https://developer.bigcommerce.com/api/stores/v2/products/rules

lib/bigcommerce/resources/products/product_video.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
# Product Video
24
# Embedded videos displayed on product listings.
35
# https://developer.bigcommerce.com/api/stores/v2/products/videos

lib/bigcommerce/resources/products/sku.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
# SKU
24
# Stock Keeping Unit identifiers associated with products.
35
# https://developer.bigcommerce.com/api/stores/v2/products/skus

lib/bigcommerce/resources/resource.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/request'
24
require 'bigcommerce/resource_actions'
35
require 'bigcommerce/subresource_actions'

lib/bigcommerce/resources/shipping/shipping_method.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
# Shipping Method
24
# List of enabled shipping methods.
35
# https://developer.bigcommerce.com/api/stores/v2/shipping/methods

lib/bigcommerce/resources/store/store_information.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
# Store Information
24
# Metadata that describes the store.
35
# https://developer.bigcommerce.com/api/stores/v2/store_information

lib/bigcommerce/resources/system/time.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
# Time
24
# Timestamp ping to check the system status.
35
# https://developer.bigcommerce.com/api/stores/v2/time

lib/bigcommerce/resources/tax/tax_class.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
# Tax Class
24
# Tax classes are used to apply different tax rates for specific types
35
# of products and orders.

lib/bigcommerce/resources/webhooks/webhook.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
# Webhook
24
# Register and manage webhooks that connect events from a store to
35
# external URLs.

lib/bigcommerce/subresource_actions.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
module Bigcommerce
24
class SubresourceActions < ResourceActions
35
def included(base)

0 commit comments

Comments
 (0)