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 +4 -4
- data/CHANGELOG.md +5 -1
- data/README.md +60 -21
- data/lib/bgg_remote/api.rb +2 -2
- data/lib/bgg_remote/client.rb +3 -4
- data/lib/bgg_remote/version.rb +1 -1
- data/lib/bgg_remote.rb +2 -2
- metadata +4 -4
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 7d574a6f1b8d82304adc264c9d02f9048a6e4402e191ae97ab26760389be8842
|
|
4
|
+
data.tar.gz: 9556f9e6c9822ae909fa4da90f326050451f6ee894e7043ff64e43812e35d165
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 685cfbf8b85ea35b40f571c76846b9ffa112de7ceb42ee68d1f115eae6424e91a35e57a4619d8430d7e80e6da9d6054302ba2d161ef95c42098ec5e60e8e5b56
|
|
7
|
+
data.tar.gz: 340d387999062553e66be9f782868ab2dd376b48d203a535c4df7e34f5c8e556e4fa31393611fcdd4cd02d64a3669c76b4b0c61f24d2c7628c053530a46feea1
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
|
@@ -1,43 +1,82 @@
|
|
|
1
1
|
# BggRemote
|
|
2
2
|
|
|
3
|
-
|
|
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
|
-
|
|
8
|
+
Add this line to your application's `Gemfile`:
|
|
10
9
|
|
|
11
|
-
|
|
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
|
-
|
|
16
|
+
## Usage
|
|
18
17
|
|
|
19
|
-
```
|
|
20
|
-
|
|
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
|
-
|
|
35
|
+
You can also instantiate the client manually if you prefer:
|
|
24
36
|
|
|
25
|
-
|
|
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
|
-
|
|
42
|
+
bgg_api.thing(id: 222)
|
|
43
|
+
```
|
|
28
44
|
|
|
29
|
-
|
|
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
|
-
|
|
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/
|
|
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
|
-
|
|
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).
|
data/lib/bgg_remote/api.rb
CHANGED
|
@@ -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,
|
|
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,
|
|
46
|
+
request("plays", username: username, id: id, **params)
|
|
47
47
|
end
|
|
48
48
|
|
|
49
49
|
def hot_items(type:)
|
data/lib/bgg_remote/client.rb
CHANGED
|
@@ -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
|
|
data/lib/bgg_remote/version.rb
CHANGED
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
|
|
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
|
|
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.
|
|
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-
|
|
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
|
|
84
|
-
|
|
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: []
|