triviacrack 0.6.0 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (52) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ci.yml +7 -2
  3. data/.github/workflows/publish.yml +8 -3
  4. data/.rubocop.yml +23 -0
  5. data/.ruby-version +1 -1
  6. data/Gemfile +1 -2
  7. data/Gemfile.lock +31 -10
  8. data/Rakefile +4 -2
  9. data/lib/triviacrack/api/client.rb +7 -7
  10. data/lib/triviacrack/api/common.rb +10 -11
  11. data/lib/triviacrack/api/game.rb +11 -13
  12. data/lib/triviacrack/api/login.rb +7 -8
  13. data/lib/triviacrack/api/profile.rb +4 -4
  14. data/lib/triviacrack/api/question.rb +14 -15
  15. data/lib/triviacrack/api/user.rb +9 -11
  16. data/lib/triviacrack/category_statistics.rb +2 -2
  17. data/lib/triviacrack/errors/parse_error.rb +2 -0
  18. data/lib/triviacrack/errors/request_error.rb +5 -3
  19. data/lib/triviacrack/game.rb +3 -3
  20. data/lib/triviacrack/game_statistics.rb +3 -3
  21. data/lib/triviacrack/parsers/category_statistics_parser.rb +13 -15
  22. data/lib/triviacrack/parsers/game_parser.rb +39 -39
  23. data/lib/triviacrack/parsers/game_statistics_parser.rb +15 -15
  24. data/lib/triviacrack/parsers/profile_parser.rb +28 -28
  25. data/lib/triviacrack/parsers/question_parser.rb +11 -11
  26. data/lib/triviacrack/parsers/session_parser.rb +10 -10
  27. data/lib/triviacrack/parsers/time_parser.rb +4 -4
  28. data/lib/triviacrack/parsers/user_parser.rb +21 -21
  29. data/lib/triviacrack/profile.rb +3 -3
  30. data/lib/triviacrack/question.rb +3 -3
  31. data/lib/triviacrack/session.rb +2 -2
  32. data/lib/triviacrack/user.rb +3 -3
  33. data/lib/triviacrack/version.rb +3 -1
  34. data/lib/triviacrack.rb +12 -10
  35. data/spec/api/game_spec.rb +49 -29
  36. data/spec/api/login_spec.rb +22 -15
  37. data/spec/api/profile_spec.rb +34 -20
  38. data/spec/api/question_spec.rb +49 -30
  39. data/spec/api/user_spec.rb +31 -20
  40. data/spec/game_spec.rb +4 -4
  41. data/spec/parsers/category_statistics_parser_spec.rb +8 -8
  42. data/spec/parsers/game_parser_spec.rb +21 -19
  43. data/spec/parsers/game_statistics_parser_spec.rb +11 -11
  44. data/spec/parsers/profile_parser_spec.rb +10 -10
  45. data/spec/parsers/question_parser_spec.rb +15 -11
  46. data/spec/parsers/session_parser_spec.rb +8 -8
  47. data/spec/parsers/time_parser_spec.rb +5 -5
  48. data/spec/parsers/user_parser_spec.rb +11 -11
  49. data/spec/spec_helper.rb +30 -32
  50. data/spec/user_spec.rb +4 -4
  51. data/triviacrack.gemspec +21 -20
  52. metadata +32 -45
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bac625736e1fdbe91e229596d95e3af90c22ea6b7b2de6373717994301bfe3b9
4
- data.tar.gz: 37afe95e8d8aa72297e85236c00af489bc6a8502c9f8b3d079062ed7157fec02
3
+ metadata.gz: 1655be2ef856891d2287a9c944212121c44c42dddc89a67d8f447c2bd7f7651d
4
+ data.tar.gz: 24495ecb87e3ab8f32938d5d60aadccb20f94836fee016548f18450f205f76ec
5
5
  SHA512:
6
- metadata.gz: d5f407ab7c8f5ca194efe7bdea42f90943b5f41c80fc5e2485f8d891afc076bbca76a0b016b75c9da96d598e436371ee8db7763b3771fd21942052e76825ba0e
7
- data.tar.gz: 28d4d34fb76d0fdaaa9c81b00fdf53bc7422406e701cf343275b0a81aebe0faabdb516dcdd1186309fba94bedfe33328111a70e03842c6f5acd17ea5af400fb9
6
+ metadata.gz: 35aaf68a6492fdaa6859cac4c79d0be62b38bd99e5b537a953581a206777b0c791dc22417e74c06df6a34f7eb9f35d4ef8d6bc88f4de7f1e5e3711dba5d4da77
7
+ data.tar.gz: 3ff4f392bc6d16b7f8f2113e791893859ec61f26ba11944b3129898f288cacbc4a06019efe8a8b3a1d144cc8c0583029ad66c3277493bd9fefc18645d4548b14
@@ -15,15 +15,20 @@ jobs:
15
15
  steps:
16
16
  - uses: actions/checkout@v1
17
17
 
18
- - uses: actions/setup-ruby@v1
18
+ - uses: ruby/setup-ruby@v1
19
19
  with:
20
- ruby-version: 3.0.2
20
+ ruby-version: 3.1.2
21
21
 
22
22
  - name: Bundle Install
23
23
  run: |
24
24
  gem install bundler
25
25
  bundle install --jobs 4 --retry 3
26
26
 
27
+ - name: RuboCop Linter Action
28
+ uses: andrewmcodes/rubocop-linter-action@v3.3.0
29
+ env:
30
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
31
+
27
32
  - name: Run RSpec and Code Coverage
28
33
  uses: paambaati/codeclimate-action@v2.4.0
29
34
  env:
@@ -3,7 +3,7 @@ name: Publish
3
3
  on:
4
4
  push:
5
5
  tags:
6
- - 'v*'
6
+ - "v*"
7
7
 
8
8
  jobs:
9
9
  build:
@@ -12,15 +12,20 @@ jobs:
12
12
  steps:
13
13
  - uses: actions/checkout@v1
14
14
 
15
- - uses: actions/setup-ruby@v1
15
+ - uses: ruby/setup-ruby@v1
16
16
  with:
17
- ruby-version: 3.0.2
17
+ ruby-version: 3.1.2
18
18
 
19
19
  - name: Bundle Install
20
20
  run: |
21
21
  gem install bundler
22
22
  bundle install --jobs 4 --retry 3
23
23
 
24
+ - name: RuboCop Linter Action
25
+ uses: andrewmcodes/rubocop-linter-action@v3.3.0
26
+ env:
27
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
28
+
24
29
  - name: Run RSpec and Code Coverage
25
30
  uses: paambaati/codeclimate-action@v2.4.0
26
31
  env:
data/.rubocop.yml ADDED
@@ -0,0 +1,23 @@
1
+ # The behavior of RuboCop can be controlled via the .rubocop.yml
2
+ # configuration file. It makes it possible to enable/disable
3
+ # certain cops (checks) and to alter their behavior if they accept
4
+ # any parameters. The file can be placed either in your home
5
+ # directory or in some project directory.
6
+ #
7
+ # RuboCop will start looking for the configuration file in the directory
8
+ # where the inspected file is and continue its way up to the root directory.
9
+ #
10
+ # See https://docs.rubocop.org/rubocop/configuration
11
+
12
+ AllCops:
13
+ TargetRubyVersion: 2.5
14
+ NewCops: enable
15
+
16
+ Metrics/BlockLength:
17
+ Enabled: false
18
+
19
+ Style/Documentation:
20
+ Enabled: false
21
+
22
+ Gemspec/RequireMFA:
23
+ Enabled: false
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 3.0.2
1
+ 3.1.2
data/Gemfile CHANGED
@@ -1,5 +1,4 @@
1
- #ruby=ruby-3.0.2
2
- #ruby-gemset=triviacrack
1
+ # frozen_string_literal: true
3
2
 
4
3
  source 'https://rubygems.org'
5
4
 
data/Gemfile.lock CHANGED
@@ -1,14 +1,15 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- triviacrack (0.6.0)
4
+ triviacrack (0.7.0)
5
5
  faraday (~> 1.7.2)
6
6
  json (~> 2.5.1)
7
7
 
8
8
  GEM
9
9
  remote: https://rubygems.org/
10
10
  specs:
11
- diff-lcs (1.4.4)
11
+ ast (2.4.2)
12
+ diff-lcs (1.5.0)
12
13
  docile (1.4.0)
13
14
  faraday (1.7.2)
14
15
  faraday-em_http (~> 1.0)
@@ -33,24 +34,42 @@ GEM
33
34
  rspec-core (~> 3.0)
34
35
  ruby-progressbar (~> 1.4)
35
36
  json (2.5.1)
36
- multipart-post (2.1.1)
37
+ multipart-post (2.2.3)
38
+ parallel (1.22.1)
39
+ parser (3.1.2.0)
40
+ ast (~> 2.4.1)
41
+ rainbow (3.1.1)
37
42
  rake (13.0.6)
43
+ regexp_parser (2.5.0)
44
+ rexml (3.2.5)
38
45
  rspec (3.10.0)
39
46
  rspec-core (~> 3.10.0)
40
47
  rspec-expectations (~> 3.10.0)
41
48
  rspec-mocks (~> 3.10.0)
42
- rspec-core (3.10.1)
49
+ rspec-core (3.10.2)
43
50
  rspec-support (~> 3.10.0)
44
- rspec-expectations (3.10.1)
51
+ rspec-expectations (3.10.2)
45
52
  diff-lcs (>= 1.2.0, < 2.0)
46
53
  rspec-support (~> 3.10.0)
47
54
  rspec-its (1.3.0)
48
55
  rspec-core (>= 3.0.0)
49
56
  rspec-expectations (>= 3.0.0)
50
- rspec-mocks (3.10.2)
57
+ rspec-mocks (3.10.3)
51
58
  diff-lcs (>= 1.2.0, < 2.0)
52
59
  rspec-support (~> 3.10.0)
53
- rspec-support (3.10.2)
60
+ rspec-support (3.10.3)
61
+ rubocop (1.31.2)
62
+ json (~> 2.3)
63
+ parallel (~> 1.10)
64
+ parser (>= 3.1.0.0)
65
+ rainbow (>= 2.2.2, < 4.0)
66
+ regexp_parser (>= 1.8, < 3.0)
67
+ rexml (>= 3.2.5, < 4.0)
68
+ rubocop-ast (>= 1.18.0, < 2.0)
69
+ ruby-progressbar (~> 1.7)
70
+ unicode-display_width (>= 1.4.0, < 3.0)
71
+ rubocop-ast (1.19.1)
72
+ parser (>= 3.1.1.0)
54
73
  ruby-progressbar (1.11.0)
55
74
  ruby2_keywords (0.0.5)
56
75
  simplecov (0.21.2)
@@ -58,19 +77,21 @@ GEM
58
77
  simplecov-html (~> 0.11)
59
78
  simplecov_json_formatter (~> 0.1)
60
79
  simplecov-html (0.12.3)
61
- simplecov_json_formatter (0.1.3)
80
+ simplecov_json_formatter (0.1.4)
81
+ unicode-display_width (2.2.0)
62
82
 
63
83
  PLATFORMS
64
84
  ruby
65
85
 
66
86
  DEPENDENCIES
67
- bundler (~> 2.2.27)
87
+ bundler (~> 2.3.18)
68
88
  fuubar (~> 2.5.1)
69
89
  rake (~> 13.0.6)
70
90
  rspec (~> 3.10.0)
71
91
  rspec-its (~> 1.3.0)
92
+ rubocop (~> 1.31.2)
72
93
  simplecov (~> 0.21.2)
73
94
  triviacrack!
74
95
 
75
96
  BUNDLED WITH
76
- 2.2.27
97
+ 2.3.18
data/Rakefile CHANGED
@@ -1,7 +1,9 @@
1
- require "bundler/gem_tasks"
1
+ # frozen_string_literal: true
2
+
3
+ require 'bundler/gem_tasks'
2
4
 
3
5
  begin
4
6
  require 'rspec/core/rake_task'
5
7
  RSpec::Core::RakeTask.new(:spec)
6
- rescue LoadError
8
+ rescue LoadError # rubocop:disable Lint/SuppressedException
7
9
  end
@@ -1,14 +1,15 @@
1
- require "triviacrack/api/game"
2
- require "triviacrack/api/login"
3
- require "triviacrack/api/profile"
4
- require "triviacrack/api/question"
5
- require "triviacrack/api/user"
1
+ # frozen_string_literal: true
2
+
3
+ require 'triviacrack/api/game'
4
+ require 'triviacrack/api/login'
5
+ require 'triviacrack/api/profile'
6
+ require 'triviacrack/api/question'
7
+ require 'triviacrack/api/user'
6
8
 
7
9
  # Public: Interface for interacting with the Trivia Crack API.
8
10
  module TriviaCrack
9
11
  module API
10
12
  class Client
11
-
12
13
  include TriviaCrack::API::Game
13
14
  include TriviaCrack::API::Login
14
15
  include TriviaCrack::API::User
@@ -25,7 +26,6 @@ module TriviaCrack
25
26
  @session = TriviaCrack::Session.new session_id: session_id,
26
27
  user_id: user_id
27
28
  end
28
-
29
29
  end
30
30
  end
31
31
  end
@@ -1,13 +1,14 @@
1
- require "json"
2
- require "faraday"
1
+ # frozen_string_literal: true
3
2
 
4
- require "triviacrack/errors/request_error"
3
+ require 'json'
4
+ require 'faraday'
5
+
6
+ require 'triviacrack/errors/request_error'
5
7
 
6
8
  # Internal: Common methods used for the Trivia Crack API.
7
9
  module TriviaCrack
8
10
  module API
9
11
  module Common
10
-
11
12
  # Internal: Makes a GET request to the Trivia Crack API using the set of
12
13
  # default headers.
13
14
  #
@@ -39,18 +40,16 @@ module TriviaCrack
39
40
  private
40
41
 
41
42
  # Internal: The host name of the Trivia Crack API.
42
- API_HOST = "https://api.preguntados.com"
43
+ API_HOST = 'https://api.preguntados.com'
43
44
 
44
45
  # Internal: Constructs the set of headers needed to make requests to the
45
46
  # Trivia Crack API.
46
47
  #
47
48
  # Returns a hash of headers.
48
49
  def default_headers
49
- headers = { "Content-Type": "application/json; charset=utf-8" }
50
+ headers = { 'Content-Type': 'application/json; charset=utf-8' }
50
51
 
51
- if @session
52
- headers["Cookie"] = "ap_session=#{@session.session_id}"
53
- end
52
+ headers['Cookie'] = "ap_session=#{@session.session_id}" if @session
54
53
 
55
54
  headers
56
55
  end
@@ -63,9 +62,9 @@ module TriviaCrack
63
62
  # Returns the response body parsed from JSON
64
63
  # Raises TriviaCrack:Errors::RequestError if the request failed.
65
64
  def check_response(url, response)
66
- if not response.status.between? 200, 299
65
+ unless response.status.between? 200, 299
67
66
  raise TriviaCrack::Errors::RequestError.new(response.status, url, response.body),
68
- "Request to #{API_HOST}#{url} failed with code #{response.status}."
67
+ "Request to #{API_HOST}#{url} failed with code #{response.status}."
69
68
  end
70
69
 
71
70
  JSON.parse(response.body)
@@ -1,13 +1,14 @@
1
- require "json"
2
- require "triviacrack/api/common"
3
- require "triviacrack/parsers/game_parser"
1
+ # frozen_string_literal: true
2
+
3
+ require 'json'
4
+ require 'triviacrack/api/common'
5
+ require 'triviacrack/parsers/game_parser'
4
6
 
5
7
  # Public: All methods in this module make requests to the Trivia Crack games
6
8
  # API.
7
9
  module TriviaCrack
8
10
  module API
9
11
  module Game
10
-
11
12
  include TriviaCrack::API::Common
12
13
 
13
14
  # Public: Uses the Trivia Crack API to fetch the list of games for the
@@ -19,17 +20,15 @@ module TriviaCrack
19
20
  #
20
21
  # Returns a list of TriviaCrack::Game.
21
22
  # Raises TriviaCrack:Errors::RequestError if the request fails.
22
- def get_games
23
+ def get_games # rubocop:disable Naming/AccessorMethodName
23
24
  response = get "/api/users/#{@session.user_id}/dashboard"
24
25
 
25
- games_data = response["list"]
26
+ games_data = response['list']
26
27
 
27
28
  games = []
28
- if games_data
29
- games_data.each do |game_data|
30
- game = TriviaCrack::Parsers::GameParser.parse game_data
31
- games << game
32
- end
29
+ games_data&.each do |game_data|
30
+ game = TriviaCrack::Parsers::GameParser.parse game_data
31
+ games << game
33
32
  end
34
33
 
35
34
  games
@@ -63,11 +62,10 @@ module TriviaCrack
63
62
  # Raises TriviaCrack::Errors::RequestError if the request fails
64
63
  def start_new_game
65
64
  response = post "/api/users/#{@session.user_id}/games",
66
- parameters: { language: "EN" }.to_json
65
+ parameters: { language: 'EN' }.to_json
67
66
 
68
67
  TriviaCrack::Parsers::GameParser.parse response
69
68
  end
70
-
71
69
  end
72
70
  end
73
71
  end
@@ -1,13 +1,14 @@
1
- require "json"
2
- require "triviacrack/api/common"
3
- require "triviacrack/parsers/session_parser"
1
+ # frozen_string_literal: true
2
+
3
+ require 'json'
4
+ require 'triviacrack/api/common'
5
+ require 'triviacrack/parsers/session_parser'
4
6
 
5
7
  # Public: All methods in this module make requests to the Trivia Crack login
6
8
  # API.
7
9
  module TriviaCrack
8
10
  module API
9
11
  module Login
10
-
11
12
  include TriviaCrack::API::Common
12
13
 
13
14
  # Public: Uses the given email and password to log in to Trivia Crack
@@ -23,14 +24,12 @@ module TriviaCrack
23
24
  # Returns the user_id and username of the user that has logged in.
24
25
  # Raises TriviaCrack::Errors::RequestError if the request fails.
25
26
  def login(email, password)
26
- response = post "/api/login", parameters: { email: email,
27
+ response = post '/api/login', parameters: { email: email,
27
28
  password: password,
28
- language: "en"
29
- }.to_json
29
+ language: 'en' }.to_json
30
30
 
31
31
  @session = TriviaCrack::Parsers::SessionParser.parse response
32
32
  end
33
-
34
33
  end
35
34
  end
36
35
  end
@@ -1,10 +1,11 @@
1
- require "triviacrack/api/common"
1
+ # frozen_string_literal: true
2
+
3
+ require 'triviacrack/api/common'
2
4
 
3
5
  # Public: Interface to the Trivia Crack Profile API.
4
6
  module TriviaCrack
5
7
  module API
6
8
  module Profile
7
-
8
9
  include TriviaCrack::API::Common
9
10
 
10
11
  # Public: Uses the Trivia Crack API to get the profile of the user with
@@ -32,13 +33,12 @@ module TriviaCrack
32
33
  #
33
34
  # Returns the TriviaCrack::Profile for the current user.
34
35
  # Raises TriviaCrack::Errors::RequestError if the request fails.
35
- def get_my_profile
36
+ def get_my_profile # rubocop:disable Naming/AccessorMethodName
36
37
  response =
37
38
  get "/api/users/#{@session.user_id}/profiles/#{@session.user_id}"
38
39
 
39
40
  TriviaCrack::Parsers::ProfileParser.parse response
40
41
  end
41
-
42
42
  end
43
43
  end
44
44
  end
@@ -1,13 +1,14 @@
1
- require "json"
2
- require "triviacrack/api/common"
3
- require "triviacrack/parsers/game_parser"
1
+ # frozen_string_literal: true
2
+
3
+ require 'json'
4
+ require 'triviacrack/api/common'
5
+ require 'triviacrack/parsers/game_parser'
4
6
 
5
7
  # Public: All methods in this module make requests to the Trivia Crack answers
6
8
  # API.
7
9
  module TriviaCrack
8
10
  module API
9
11
  module Question
10
-
11
12
  include TriviaCrack::API::Common
12
13
 
13
14
  # Public: Uses the Trivia Crack API to answer the given question.
@@ -26,13 +27,12 @@ module TriviaCrack
26
27
  def answer_question(game_id, question, answer)
27
28
  response =
28
29
  post "/api/users/#{@session.user_id}/games/#{game_id}/answers",
29
- parameters: { type: question.type.upcase,
30
- answers: [{
31
- id: question.id,
32
- answer: answer,
33
- category: question.category.upcase
34
- }]
35
- }.to_json
30
+ parameters: { type: question.type.upcase,
31
+ answers: [{
32
+ id: question.id,
33
+ answer: answer,
34
+ category: question.category.upcase
35
+ }] }.to_json
36
36
 
37
37
  game = TriviaCrack::Parsers::GameParser.parse response
38
38
 
@@ -57,11 +57,11 @@ module TriviaCrack
57
57
  # with an entry for each question ID and a boolean indicating if
58
58
  # the question was answered successfully.
59
59
  # Raises TriviaCrack::Errors::RequestError if the request fails
60
- def answer_questions(game_id, questions, answer_map)
60
+ def answer_questions(game_id, questions, answer_map) # rubocop:disable Metrics/MethodLength, Metrics/AbcSize
61
61
  answers = []
62
62
  correct_answers = {}
63
63
 
64
- for question in questions do
64
+ questions.each do |question|
65
65
  answer = {
66
66
  id: question.id,
67
67
  answer: answer_map[question.id],
@@ -73,13 +73,12 @@ module TriviaCrack
73
73
 
74
74
  response =
75
75
  post "/api/users/#{@session.user_id}/games/#{game_id}/answers",
76
- parameters: { type: questions.first.type.upcase, answers: answers }.to_json
76
+ parameters: { type: questions.first.type.upcase, answers: answers }.to_json
77
77
 
78
78
  game = TriviaCrack::Parsers::GameParser.parse response
79
79
 
80
80
  [game, correct_answers]
81
81
  end
82
-
83
82
  end
84
83
  end
85
84
  end
@@ -1,12 +1,13 @@
1
- require "triviacrack/api/common"
2
- require "triviacrack/parsers/user_parser"
1
+ # frozen_string_literal: true
2
+
3
+ require 'triviacrack/api/common'
4
+ require 'triviacrack/parsers/user_parser'
3
5
 
4
6
  # Public: All methods in this module make requests to the Trivia Crack users
5
7
  # API.
6
8
  module TriviaCrack
7
9
  module API
8
10
  module User
9
-
10
11
  include TriviaCrack::API::Common
11
12
 
12
13
  # Public: Uses the Trivia Crack Search API to find the numeric user id of
@@ -22,16 +23,14 @@ module TriviaCrack
22
23
  # Raises TriviaCrack:Errors::RequestError if the request fails.
23
24
  def get_user_id(username)
24
25
  # Trim the @ character from the start of the username
25
- if username.start_with? "@"
26
- username = username[1..-1]
27
- end
26
+ username = username[1..-1] if username.start_with? '@'
28
27
 
29
28
  body = get "/api/search?username=#{username}"
30
29
 
31
30
  user_id = false
32
- body["list"].each do |user|
33
- if user["username"] == username
34
- user_id = user["id"]
31
+ body['list'].each do |user|
32
+ if user['username'] == username
33
+ user_id = user['id']
35
34
  break
36
35
  end
37
36
  end
@@ -43,12 +42,11 @@ module TriviaCrack
43
42
  #
44
43
  # Returns a TriviaCrack::User representing the current user.
45
44
  # Raises TriviaCrack::Errors::RequestError if the request fails
46
- def get_user
45
+ def get_user # rubocop:disable Naming/AccessorMethodName
47
46
  response = get "/api/users/#{@session.user_id}"
48
47
 
49
48
  TriviaCrack::Parsers::UserParser.parse response
50
49
  end
51
-
52
50
  end
53
51
  end
54
52
  end
@@ -1,8 +1,9 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Public: An object representing category statistics for a player within a
2
4
  # single Trivia Crack game.
3
5
  module TriviaCrack
4
6
  class CategoryStatistics
5
-
6
7
  # Public: The category for these statistics (:arts, :geography, etc).
7
8
  attr_reader :category
8
9
 
@@ -22,6 +23,5 @@ module TriviaCrack
22
23
  @incorrect = incorrect
23
24
  @worst = worst
24
25
  end
25
-
26
26
  end
27
27
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Public: This error is raised when a block of data cannot be correctly parsed.
2
4
  module TriviaCrack
3
5
  module Errors
@@ -1,16 +1,17 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Public: This error is raised when a web request to the Trivia Crack API is
2
4
  # unsuccessful.
3
5
  module TriviaCrack
4
6
  module Errors
5
7
  class RequestError < StandardError
6
-
7
8
  # Public: The HTTP status code returned by the Trivia Crack server.
8
9
  attr_reader :code
9
10
 
10
- #Public: The URL that was requested.
11
+ # Public: The URL that was requested.
11
12
  attr_reader :url
12
13
 
13
- #Public: The response body that was returned by the Trivia Crack server.
14
+ # Public: The response body that was returned by the Trivia Crack server.
14
15
  attr_reader :body
15
16
 
16
17
  # Public: Initializes a RequestError.
@@ -19,6 +20,7 @@ module TriviaCrack
19
20
  # url - The URL that was requested.
20
21
  # body - The response body that was returned by the Trivia Crack server.
21
22
  def initialize(code, url, body)
23
+ super()
22
24
  @code = code
23
25
  @url = url
24
26
  @body = body
@@ -1,9 +1,10 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Public: An object representing a Trivia Crack Game, including information
2
4
  # about the questions to be asked in the game, the state of the game, opponent
3
5
  # information, and more.
4
6
  module TriviaCrack
5
7
  class Game
6
-
7
8
  # Public: The unique identifier of the game.
8
9
  attr_reader :id
9
10
 
@@ -58,7 +59,7 @@ module TriviaCrack
58
59
  # Public: TriviaCrack::GameStatistics for the opponent.
59
60
  attr_reader :opponent_statistics
60
61
 
61
- def initialize(id:, opponent: nil, game_status: nil, language: nil,
62
+ def initialize(id:, opponent: nil, game_status: nil, language: nil, # rubocop:disable Metrics/MethodLength, Metrics/ParameterLists
62
63
  created: nil, last_turn: nil, type: nil,
63
64
  expiration_date: nil, my_turn: nil, round_number: nil,
64
65
  is_random: nil, unread_messages: nil, status_version: nil,
@@ -95,6 +96,5 @@ module TriviaCrack
95
96
  def playable?
96
97
  @my_turn && @game_status != :ended
97
98
  end
98
-
99
99
  end
100
100
  end
@@ -1,7 +1,8 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Public: An object representing player statistics for a Trivia Crack game.
2
4
  module TriviaCrack
3
5
  class GameStatistics
4
-
5
6
  # Public: The number of questions answered correctly.
6
7
  attr_reader :correct_answers
7
8
 
@@ -20,7 +21,7 @@ module TriviaCrack
20
21
  # Public: A hash of category statistics.
21
22
  attr_reader :categories
22
23
 
23
- def initialize(correct_answers: nil, incorrect_answers: nil,
24
+ def initialize(correct_answers: nil, incorrect_answers: nil, # rubocop:disable Metrics/ParameterLists
24
25
  questions_answered: nil, challenges_won: nil,
25
26
  crowns: nil, categories: nil)
26
27
  @correct_answers = correct_answers
@@ -30,6 +31,5 @@ module TriviaCrack
30
31
  @crowns = crowns
31
32
  @categories = categories
32
33
  end
33
-
34
34
  end
35
35
  end