bgg_remote 0.1.0 → 0.1.1

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b13c746ba96509bfa7959c390fb604f177eb5c0663312c0038e1485a984ed7cf
4
- data.tar.gz: c7b7aba64f3036947cede0af9c7828c703e043066f1cfd30d10a7cc57e8f52f8
3
+ metadata.gz: 7d574a6f1b8d82304adc264c9d02f9048a6e4402e191ae97ab26760389be8842
4
+ data.tar.gz: 9556f9e6c9822ae909fa4da90f326050451f6ee894e7043ff64e43812e35d165
5
5
  SHA512:
6
- metadata.gz: c3511bc789b8823dfdc6ef5648892bb40f29d3fca5be45589981b0a8c0f51bca6bf8f4df24898f57d33a909db84d28ead90828f5a4464d0099002e4c860da9a4
7
- data.tar.gz: b6e799f7bc9b8225d4634b39376a5347e601ac4ab631dce5f8a08d0ba796501a4f2126bc3028179ae9533d35274d054c398df098d7553db546c36be72354b101
6
+ metadata.gz: 685cfbf8b85ea35b40f571c76846b9ffa112de7ceb42ee68d1f115eae6424e91a35e57a4619d8430d7e80e6da9d6054302ba2d161ef95c42098ec5e60e8e5b56
7
+ data.tar.gz: 340d387999062553e66be9f782868ab2dd376b48d203a535c4df7e34f5c8e556e4fa31393611fcdd4cd02d64a3669c76b4b0c61f24d2c7628c053530a46feea1
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  ## [Unreleased]
2
2
 
3
- ## [0.1.0] - 2025-12-22
3
+ ## [0.1.1] - 2025-12-29
4
+ - Add support for plays lookup without type
5
+ - Improve header handling when token is empty
6
+ - Internal refactor in client initialization
4
7
 
8
+ ## [0.1.0] - 2025-12-22
5
9
  - Initial release
data/README.md CHANGED
@@ -1,43 +1,82 @@
1
1
  # BggRemote
2
2
 
3
- TODO: Delete this and the text below, and describe your gem
3
+ BggRemote is a Ruby client for the [BoardGameGeek XML API](https://boardgamegeek.com/wiki/page/BGG_XML_API2), providing easy access to board game data. It can optionally parse XML responses into Ruby hashes for easier usage.
4
4
 
5
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/bgg_remote`. To experiment with that code, run `bin/console` for an interactive prompt.
6
5
 
7
6
  ## Installation
8
7
 
9
- TODO: Replace `UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG` with your gem name right after releasing it to RubyGems.org. Please do not do it earlier due to security reasons. Alternatively, replace this section with instructions to install your gem from git if you don't plan to release to RubyGems.org.
8
+ Add this line to your application's `Gemfile`:
10
9
 
11
- Install the gem and add to the application's Gemfile by executing:
12
-
13
- ```bash
14
- bundle add UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG
10
+ ```ruby
11
+ gem "bgg_remote", "~> 0.1.0"
15
12
  ```
13
+ then execute ```bundle install```
14
+ Or install it yourself as a gem ``` gem install bgg_remote ```
16
15
 
17
- If bundler is not being used to manage dependencies, install the gem by executing:
16
+ ## Usage
18
17
 
19
- ```bash
20
- gem install UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG
18
+ ```ruby
19
+ BggRemote.configure do |config|
20
+ config.token = "your-api-token"
21
+ config.timeout = 8 # optional, default is 10
22
+ config.convert_to_hash = true # optional, set to false if you want raw XML
23
+ end
24
+
25
+ # Alternatively, minimal configuration:
26
+ # BggRemote.configure do |config|
27
+ # config.token = "your-api-token"
28
+ # end
29
+
30
+ bgg_api = BggRemote.api
31
+ bgg_api.thing(id: 21) # Fetch a boardgame by ID
32
+ bgg_api.user(name: "geek") # Fetch a user by name
21
33
  ```
22
34
 
23
- ## Usage
35
+ You can also instantiate the client manually if you prefer:
24
36
 
25
- TODO: Write usage instructions here
37
+ ```ruby
38
+ client = BggRemote::Client.new("your_api_token", timeout: 21)
39
+ bgg_api = BggRemote::Api.new(client, convert_to_hash: true)
40
+ # convert_to_hash and timeout are optional
26
41
 
27
- ## Development
42
+ bgg_api.thing(id: 222)
43
+ ```
28
44
 
29
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
45
+ ## API Endpoints
46
+ - thing(id:, **params)
47
+ - family(id:, type: nil)
48
+ - forum_list(id:, type: nil)
49
+ - forum(id:, page: nil)
50
+ - thread(id:, **params)
51
+ - user(name:, **params)
52
+ - guild(id:, **params)
53
+ - search(query:, **params)
54
+ - plays(username: nil, id: nil, **params) – validates at least one of username or id
55
+ - hot_items(type:)
56
+ - collection(username:, **params)
57
+
58
+ **Notes:**
59
+ - `**params` can be used for extra parameters, e.g., `bgg_api.thing(id: 3214, stats: 1)`.
60
+ - `stats` is an example of an extra parameter.
61
+ - **Sending Multiple Parameters** \
62
+ Some endpoints support multiple values ​​for a single parameter, such as `id` or `type`. You can pass:
63
+
64
+ ```ruby
65
+ #Multiple values as a comma-separated string:
66
+ BggRemote.api.family(id: "20,111815", type: "boardgamefamily,rpg")
67
+ ```
30
68
 
31
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
69
+ ## Details
70
+ - The API client also provides error classes for retry logic if needed.
71
+ See: [error.rb](https://github.com/nicollinoxx/bgg_remote/blob/master/lib/bgg_remote/error.rb)
72
+ - This gem uses [HTTParty](https://github.com/jnunemaker/httparty) to make HTTP requests and [Crack](https://github.com/jnunemaker/crack) to parse XML into hashes. You can choose to receive raw XML instead by setting `convert_to_hash = false`.
73
+ - The gem does not process the XML content itself; it only wraps HTTP requests
74
+ and optionally converts XML to Ruby hashes.
32
75
 
33
76
  ## Contributing
34
77
 
35
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/bgg_remote. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/bgg_remote/blob/master/CODE_OF_CONDUCT.md).
78
+ Bug reports and pull requests are welcome on GitHub at https://github.com/nicollinoxx/bgg_remote. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](https://www.contributor-covenant.org/) code of conduct.
36
79
 
37
80
  ## License
38
81
 
39
- The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
40
-
41
- ## Code of Conduct
42
-
43
- Everyone interacting in the BggRemote project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/bgg_remote/blob/master/CODE_OF_CONDUCT.md).
82
+ This gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
@@ -40,10 +40,10 @@ class BggRemote::Api
40
40
  request("search", query: query, **params)
41
41
  end
42
42
 
43
- def plays(username: nil, id: nil, type: nil, **params)
43
+ def plays(username: nil, id: nil, **params)
44
44
  validate_at_least_one_of!(username: username, id: id)
45
45
 
46
- request("plays", username: username, id: id, type: type, **params)
46
+ request("plays", username: username, id: id, **params)
47
47
  end
48
48
 
49
49
  def hot_items(type:)
@@ -18,10 +18,10 @@ class BggRemote::Client
18
18
  }.freeze
19
19
 
20
20
  def initialize(token, timeout: 10)
21
- @token = token
22
- @timeout = timeout || 10
23
-
24
21
  raise BggRemote::Error::MissingToken, "token is required" if token.nil?
22
+
23
+ @token = token
24
+ @timeout = timeout
25
25
  end
26
26
 
27
27
  def perform_request(path, **params)
@@ -34,7 +34,6 @@ class BggRemote::Client
34
34
  private
35
35
 
36
36
  def headers
37
- return { "Accept" => "application/xml" } unless token
38
37
  { "Accept" => "application/xml", "Authorization" => "Bearer #{token}" }
39
38
  end
40
39
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module BggRemote
4
- VERSION = "0.1.0"
4
+ VERSION = "0.1.1"
5
5
  end
data/lib/bgg_remote.rb CHANGED
@@ -12,11 +12,11 @@ module BggRemote
12
12
  attr_reader :api
13
13
 
14
14
  def configure
15
- config ||= Config.new
15
+ config = Config.new(timeout: 10, convert_to_hash: true)
16
16
  yield config if block_given?
17
17
 
18
18
  client = Client.new(config.token, timeout: config.timeout)
19
- @api = Api.new(client, convert_to_hash: config.convert_to_hash)
19
+ @api = Api.new(client, convert_to_hash: config.convert_to_hash)
20
20
  end
21
21
  end
22
22
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bgg_remote
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nícolas Amaral
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2025-12-24 00:00:00.000000000 Z
11
+ date: 2025-12-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty
@@ -80,8 +80,8 @@ dependencies:
80
80
  - - '='
81
81
  - !ruby/object:Gem::Version
82
82
  version: '3.26'
83
- description: A simple Ruby interface to the BoardGameGeek XML API2, providing easy
84
- access to board game data with XML parsing to Ruby hashes.
83
+ description: A simple Ruby client to the BoardGameGeek XML API2, providing easy access
84
+ to board game data with XML parsing to Ruby hashes.
85
85
  email:
86
86
  - nicolasalmeida321@gmail.com
87
87
  executables: []