Skip to content

Commit

Permalink
Merge pull request #8 from sosolidkk/run-standardrb
Browse files Browse the repository at this point in the history
Run standardrb on project
  • Loading branch information
sosolidkk authored Jul 27, 2024
2 parents 8ebd1fc + 2592d3c commit 0a5ce49
Show file tree
Hide file tree
Showing 72 changed files with 399 additions and 395 deletions.
14 changes: 7 additions & 7 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,34 +1,34 @@
# frozen_string_literal: true

source 'https://rubygems.org'
source "https://rubygems.org"

# Specify your gem's dependencies in steam_api.gemspec
gemspec

group :development, :test do
# Ruby's bikeshed-proof linter and formatter.
# See: [https://rubygems.org/gems/standard]
gem 'standard', '~> 1.3'
gem "standard", "~> 1.3"

# Debugging tool for Ruby.
# See: [https://rubygems.org/gems/debug]
gem 'debug', '~> 1.9'
gem "debug", "~> 1.9"

# A Ruby gem to test Ruby code.
# See: [https://github.com/rspec]
gem 'rspec', '~> 3.4'
gem "rspec", "~> 3.4"

# Record your test suite's HTTP interactions and replay them during future test runs for fast, deterministic, and
# accurate tests [https://rubygems.org/gems/vcr]
gem 'vcr', '~> 6.2'
gem "vcr", "~> 6.2"

# Library for stubbing and setting expectations on HTTP requests in Ruby.
# See: [https://rubygems.org/gems/webmock]
gem 'webmock', '~> 3.23'
gem "webmock", "~> 3.23"
end

group :test do
# A code coverage analysis tool for Ruby.
# See: [https://rubygems.org/gems/simplecov]
gem 'simplecov', '~> 0.22', require: false
gem "simplecov", "~> 0.22", require: false
end
126 changes: 63 additions & 63 deletions lib/steam_api.rb
Original file line number Diff line number Diff line change
@@ -1,75 +1,75 @@
# frozen_string_literal: true

require 'active_support/all'
require "active_support/all"

require 'dry-configurable'
require 'dry-struct'
require 'singleton'
require 'typhoeus'
require "dry-configurable"
require "dry-struct"
require "singleton"
require "typhoeus"

require 'steam_api/version'
require 'steam_api/request'
require 'steam_api/response'
require 'steam_api/failure_handler'
require "steam_api/version"
require "steam_api/request"
require "steam_api/response"
require "steam_api/failure_handler"

require 'steam_api/errors/api_error'
require 'steam_api/errors/url_error'
require "steam_api/errors/api_error"
require "steam_api/errors/url_error"

require 'steam_api/requestors/base'
require 'steam_api/requestors/app_details'
require 'steam_api/requestors/app_global_achievements'
require 'steam_api/requestors/app_news'
require 'steam_api/requestors/game_current_players'
require 'steam_api/requestors/player_achievements'
require 'steam_api/requestors/player_friends'
require 'steam_api/requestors/player_game_stats'
require 'steam_api/requestors/player_level'
require 'steam_api/requestors/player_owned_games'
require 'steam_api/requestors/player_recent_games'
require 'steam_api/requestors/player_steamid'
require 'steam_api/requestors/player_summaries'
require "steam_api/requestors/base"
require "steam_api/requestors/app_details"
require "steam_api/requestors/app_global_achievements"
require "steam_api/requestors/app_news"
require "steam_api/requestors/game_current_players"
require "steam_api/requestors/player_achievements"
require "steam_api/requestors/player_friends"
require "steam_api/requestors/player_game_stats"
require "steam_api/requestors/player_level"
require "steam_api/requestors/player_owned_games"
require "steam_api/requestors/player_recent_games"
require "steam_api/requestors/player_steamid"
require "steam_api/requestors/player_summaries"

require 'steam_api/structs/types'
require 'steam_api/structs/base'
require 'steam_api/structs/app_details/achievement'
require 'steam_api/structs/app_details/category'
require 'steam_api/structs/app_details/genre'
require 'steam_api/structs/app_details/movie'
require 'steam_api/structs/app_details/sub'
require 'steam_api/structs/app_details/package_group'
require 'steam_api/structs/app_details/requirements'
require 'steam_api/structs/app_details/screenshot'
require 'steam_api/structs/app_details/details'
require 'steam_api/structs/app_global_achievements'
require 'steam_api/structs/app_new'
require 'steam_api/structs/app_news'
require 'steam_api/structs/game_current_players'
require 'steam_api/structs/player_summary'
require 'steam_api/structs/player_achievements'
require 'steam_api/structs/player_friends'
require 'steam_api/structs/player_game_stats'
require 'steam_api/structs/player_level'
require 'steam_api/structs/player_owned_games'
require 'steam_api/structs/player_recent_games'
require 'steam_api/structs/player_steamid'
require 'steam_api/structs/player_summaries'
require "steam_api/structs/types"
require "steam_api/structs/base"
require "steam_api/structs/app_details/achievement"
require "steam_api/structs/app_details/category"
require "steam_api/structs/app_details/genre"
require "steam_api/structs/app_details/movie"
require "steam_api/structs/app_details/sub"
require "steam_api/structs/app_details/package_group"
require "steam_api/structs/app_details/requirements"
require "steam_api/structs/app_details/screenshot"
require "steam_api/structs/app_details/details"
require "steam_api/structs/app_global_achievements"
require "steam_api/structs/app_new"
require "steam_api/structs/app_news"
require "steam_api/structs/game_current_players"
require "steam_api/structs/player_summary"
require "steam_api/structs/player_achievements"
require "steam_api/structs/player_friends"
require "steam_api/structs/player_game_stats"
require "steam_api/structs/player_level"
require "steam_api/structs/player_owned_games"
require "steam_api/structs/player_recent_games"
require "steam_api/structs/player_steamid"
require "steam_api/structs/player_summaries"

require 'steam_api/structs/requests/abstract'
require 'steam_api/structs/requests/storefront_abstract'
require 'steam_api/structs/requests/get_app_details'
require 'steam_api/structs/requests/get_app_global_achievements'
require 'steam_api/structs/requests/get_app_news'
require 'steam_api/structs/requests/get_game_current_players'
require 'steam_api/structs/requests/get_player_achievements'
require 'steam_api/structs/requests/get_player_friends'
require 'steam_api/structs/requests/get_player_game_stats'
require 'steam_api/structs/requests/get_player_level'
require 'steam_api/structs/requests/get_player_owned_games'
require 'steam_api/structs/requests/get_player_recent_games'
require 'steam_api/structs/requests/get_player_steamid'
require 'steam_api/structs/requests/get_player_summaries'
require "steam_api/structs/requests/abstract"
require "steam_api/structs/requests/storefront_abstract"
require "steam_api/structs/requests/get_app_details"
require "steam_api/structs/requests/get_app_global_achievements"
require "steam_api/structs/requests/get_app_news"
require "steam_api/structs/requests/get_game_current_players"
require "steam_api/structs/requests/get_player_achievements"
require "steam_api/structs/requests/get_player_friends"
require "steam_api/structs/requests/get_player_game_stats"
require "steam_api/structs/requests/get_player_level"
require "steam_api/structs/requests/get_player_owned_games"
require "steam_api/structs/requests/get_player_recent_games"
require "steam_api/structs/requests/get_player_steamid"
require "steam_api/structs/requests/get_player_summaries"

require 'steam_api/client'
require "steam_api/client"

# Main module
module SteamApi; end
4 changes: 2 additions & 2 deletions lib/steam_api/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ module SteamApi
class Client
extend ::Dry::Configurable

BASE_ENDPOINT = 'https://api.steampowered.com'
STOREFRONT_API_ENDPOINT = 'https://store.steampowered.com/api/'
BASE_ENDPOINT = "https://api.steampowered.com"
STOREFRONT_API_ENDPOINT = "https://store.steampowered.com/api/"

setting :api_token

Expand Down
5 changes: 5 additions & 0 deletions lib/steam_api/errors/api_error.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,19 @@ def build_description_message

# status_code: 400
class HttpBadRequest < ApiError; end

# status_code: 401
class HttpUnauthorized < ApiError; end

# status_code: 403
class HttpForbidden < ApiError; end

# status_code: 404
class HttpNotFound < ApiError; end

# status_code: 408
class HttpTimeout < ApiError; end

# status_code: 500
class HttpInternalServerError < ApiError; end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/steam_api/request.rb
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def build_options
end

def default_headers
{'Content-Type' => 'application/json'}
{"Content-Type" => "application/json"}
end
end
end
2 changes: 1 addition & 1 deletion lib/steam_api/requestors/app_details.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class AppDetails < Base
# Defaults to en
# @return [SteamApi::Structs::AppDetails::Details] instance with the
# app details.
def retrieve(appid:, filters: [], country_code: 'US', locale: 'en')
def retrieve(appid:, filters: [], country_code: "US", locale: "en")
build_request_and_run(
SteamApi::Structs::Requests::GetAppDetails,
SteamApi::Structs::AppDetails::Details,
Expand Down
2 changes: 1 addition & 1 deletion lib/steam_api/requestors/app_news.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class AppNews < Base
# @param [Integer] maxlength - The max length of the news content
# @return [SteamApi::Structs::AppNews] instance with the
# player summary details.
def retrieve(appid, count, maxlength=300)
def retrieve(appid, count, maxlength = 300)
build_request_and_run(
SteamApi::Structs::Requests::GetAppNews,
SteamApi::Structs::AppNews,
Expand Down
2 changes: 1 addition & 1 deletion lib/steam_api/requestors/player_friends.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class PlayerFriends < Base
# @param [String] relationship - Relationship filter. Possibles values: 'all', 'friend1'.
# @return [SteamApi::Structs::PlayerFriends] instance with the
# player friends list.
def retrieve(steamid, relationship='all')
def retrieve(steamid, relationship = "all")
build_request_and_run(
SteamApi::Structs::Requests::GetPlayerFriends,
SteamApi::Structs::PlayerFriends,
Expand Down
2 changes: 1 addition & 1 deletion lib/steam_api/requestors/player_recent_games.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class PlayerRecentGames < Base
# @param [Integer] count - The number of games that should return
# @return [SteamApi::Structs::PlayerRecentGames] instance with the
# player summary details.
def retrieve(steamid, count=5)
def retrieve(steamid, count = 5)
build_request_and_run(
SteamApi::Structs::Requests::GetPlayerRecentGames,
SteamApi::Structs::PlayerRecentGames,
Expand Down
2 changes: 1 addition & 1 deletion lib/steam_api/response.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
require 'forwardable'
require "forwardable"

module SteamApi
# Wraps the raw response received from the Api
Expand Down
2 changes: 1 addition & 1 deletion lib/steam_api/structs/app_details/details.rb
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ class Details < Base

def self.build_from_response(json_response)
outer_key = json_response.keys.first
new(**{appid: outer_key.to_s, response: json_response[outer_key]})
new(appid: outer_key.to_s, response: json_response[outer_key])
end
end
end
Expand Down
6 changes: 3 additions & 3 deletions lib/steam_api/structs/requests/abstract.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,21 @@ class Abstract < SteamApi::Structs::Base
# @abstract
# @return [String] the version of the request path
def version
raise NoMethodError, 'Override this method'
raise NoMethodError, "Override this method"
end

# Returns the interface value to create the request path
# @abstract
# @return [String] the interface of the request path
def interface
raise NoMethodError, 'Override this method'
raise NoMethodError, "Override this method"
end

# Returns the API path value to create the request path
# @abstract
# @return [String] the API path of the request path
def path
raise NoMethodError, 'Override this method'
raise NoMethodError, "Override this method"
end

# Returns the HTTP method used by the request.
Expand Down
4 changes: 2 additions & 2 deletions lib/steam_api/structs/requests/get_app_details.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def self.build_from_params(params)
# Returns the API path value to create the request path
# @return [String] the API path of the request path
def path
'appdetails/'
"appdetails/"
end

# Returns the query params needed for the HTTP request
Expand All @@ -30,7 +30,7 @@ def query_params
super.merge(
{
appids: appid,
filters: filters.join(','),
filters: filters.join(","),
cc: cc,
l: l
}
Expand Down
8 changes: 4 additions & 4 deletions lib/steam_api/structs/requests/get_app_global_achievements.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,27 +8,27 @@ class GetAppGlobalAchievements < Abstract
# @params [Hash] params - The hash params.
# @return an instance of the Struct
def self.build_from_params(params)
raise StandardError, ':gameid is missing' unless params.key?(:gameid)
raise StandardError, ":gameid is missing" unless params.key?(:gameid)

new(params)
end

# Returns the version value to create the request path
# @return [String] the version of the request path
def version
'v0002/'
"v0002/"
end

# Returns the interface value to create the request path
# @return [String] the interface of the request path
def interface
'ISteamUserStats/'
"ISteamUserStats/"
end

# Returns the API path value to create the request path
# @return [String] the API path of the request path
def path
'GetGlobalAchievementPercentagesForApp/'
"GetGlobalAchievementPercentagesForApp/"
end

# Returns the query params needed for the HTTP request
Expand Down
6 changes: 3 additions & 3 deletions lib/steam_api/structs/requests/get_app_news.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,19 @@ def self.build_from_params(params)
# Returns the version value to create the request path
# @return [String] the version of the request path
def version
'v0002/'
"v0002/"
end

# Returns the interface value to create the request path
# @return [String] the interface of the request path
def interface
'ISteamNews/'
"ISteamNews/"
end

# Returns the API path value to create the request path
# @return [String] the API path of the request path
def path
'GetNewsForApp/'
"GetNewsForApp/"
end

# Returns the query params needed for the HTTP request
Expand Down
Loading

0 comments on commit 0a5ce49

Please sign in to comment.