BoardGameGem 0.1.5 → 0.1.6
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/README.md +69 -10
- data/boardgamegem.gemspec +14 -2
- data/lib/bgg_collection_item.rb +1 -0
- data/lib/boardgamegem/version.rb +1 -1
- metadata +24 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f37eaa1b94b6fb0d31a7d65756b3c020d46e11cf
|
4
|
+
data.tar.gz: 47327435fb477799e0edea1f61618237493164f3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bf13ab6669adf49a0ad29c80a9948f59f0e0ab01bdd0f0638f8bed7b48c83b0d74d33003479106a857139b2311452b69d6328957a2662d4f790a35fad8a01f58
|
7
|
+
data.tar.gz: 9f65f21102d46cae68f37be9d6f95b297da379fdba017981a592149c36bcef761f01aee2d8c028c132b1e99cf05e815324830aa8ae518b0154676a14b36e6d66
|
data/README.md
CHANGED
@@ -1,8 +1,5 @@
|
|
1
|
-
#
|
2
|
-
|
3
|
-
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/boardgamegem`. To experiment with that code, run `bin/console` for an interactive prompt.
|
4
|
-
|
5
|
-
TODO: Delete this and the text above, and describe your gem
|
1
|
+
# BoardGameGem
|
2
|
+
BoardGameGem provides a Ruby interface to the [BoardGameGeek XML API](http://www.boardgamegeek.com/xmlapi2) (version 2). It's designed to work with the Rails cache to reduce the number of requests when working with Rails.
|
6
3
|
|
7
4
|
## Installation
|
8
5
|
|
@@ -22,17 +19,79 @@ Or install it yourself as:
|
|
22
19
|
|
23
20
|
## Usage
|
24
21
|
|
25
|
-
|
22
|
+
Requests to retrieve data can be made using any of the methods in the BoardGameGem module. Arguments in brackets are optional.
|
23
|
+
|
24
|
+
The `options` argument is a hash which allows any other parameter. For example, if you wished to limit a collection by subtype, you could pass the hash `{ subtype: "boardgame" }` as `options`.
|
25
|
+
|
26
|
+
---
|
27
|
+
|
28
|
+
`get_item(id, [statistics], [options])`: Retreive a specific item from BGG by ID. Within the BGG API, this is called a 'thing' rather than an 'item'. If an item with that ID is not found, `nil` is returned.
|
29
|
+
|
30
|
+
If `statistics` is true, averages, weights, and rankings will be retrieved as well. By default, `statistics` is false.
|
31
|
+
|
32
|
+
`get_item` returns a `BGGItem` object, which has the following attributes:
|
33
|
+
`:id, :type, :thumbnail, :name, :description, :year_published, :min_players, :max_players,
|
34
|
+
:playing_time, :min_playing_time, :max_playing_time, :statistics`.
|
35
|
+
|
36
|
+
`:statistics` is a hash, with the following keys: `:user_ratings, :average, :bayes, :ranks, :stddev, :median, :owned, :trading, :wanted, :wishing, :num_comments, :num_weights, :average_weight`. Within this, `:ranks` is an array, containing hashes with the following keys: `:type, :name, :friendly_name, :value, :bayes`.
|
37
|
+
|
38
|
+
---
|
39
|
+
|
40
|
+
`get_family(id, [options])`: Retrieves information on a data family. Returns a `BGGFamily` object, which has the following attributes: `:id, :thumbnail, :image, :name, :alternate_names, :description`. Within this, `:alternate_names` is an array of strings. If a family with that ID is not found, `nil` is returned.
|
41
|
+
|
42
|
+
---
|
43
|
+
|
44
|
+
`get_user(username, [options])`: Retreives information on a specific user by name. If a user with that name does not exist, `nil` is returned.
|
45
|
+
|
46
|
+
`get_user` returns a `BGGUser` object, which has the following attributes: `:id, :name, :avatar, :year_registered, :last_login, :state, :trade_rating`
|
47
|
+
|
48
|
+
#### Methods
|
49
|
+
`get_collection`: Returns this user's collection, as if `BoardGameGem.get_collection` was called using this user's name.
|
50
|
+
|
51
|
+
---
|
52
|
+
|
53
|
+
`get_collection(username, [options])`: Returns a user's collection by username. Returns a `BGGCollection` object, which has two attributes: `:count`, the number of items in the collection, and `:items`, an array consisting of many `BGGCollectionItem` objects.
|
54
|
+
|
55
|
+
The BGG API queues requests to retrieve a user's collection, returning a 202 status code and a 'please wait' message. When BoardGameGem makes a request and sees a 202 code, it waits a short time before issuing the request again. After 10 tries, BoardGameGem will give up and return `nil`. **You should not make multiple `get_collection` requests to handle queueing yourself.**
|
56
|
+
|
57
|
+
#### Methods
|
58
|
+
`get_owned`: Returns itmes in this collection that are flagged as 'owned'.
|
59
|
+
|
60
|
+
`get_previously_owned`: Returns items in this collection that are flagged as 'previously owned'.
|
61
|
+
|
62
|
+
`get_wants`: Returns items in this collection that are flagged as 'want'.
|
63
|
+
|
64
|
+
`get_want_to_play`: Returns items in this collection that are flagged as 'want to play'.
|
65
|
+
|
66
|
+
`get_want_to_buy`: Returns items in this collection that are flagged as 'want to buy'.
|
67
|
+
|
68
|
+
`get_wishlist`: Returns items in this collection that are on the collection owner's wishlist.
|
69
|
+
|
70
|
+
`get_preordered`: Returns items in this collection that are flagged as 'preordered'.
|
71
|
+
|
72
|
+
#### BGGCollectionItem
|
73
|
+
|
74
|
+
The BGG API returns a subset of an item's data when including it in a collection request. As a result, a `BGGCollectionItem` contains the following attributes: `:id, :type, :name, :year_published, :image, :thumbnail, :num_players, :status, :num_plays`. Within this, `:status` is a hash containing the following keys: `:own, :prev_owned, :for_trade, :want, :want_to_play, :want_to_buy, :wishlist, :preordered:, :last_modified`.
|
75
|
+
|
76
|
+
`BGGCollectionItem` contains one other method, `to_item([statistics])`, which returns the `BGGItem` version of this object.
|
77
|
+
|
78
|
+
---
|
79
|
+
|
80
|
+
`search(query, [options])`: Performs a search request, returning any items which are like the query. Returns a hash with the keys `:total`, the number of items found in the search, and `:items`, an array of `BGGSearchResult` objects.
|
81
|
+
|
82
|
+
#### BGGSearchResult
|
83
|
+
|
84
|
+
Much like `BGGCollectionItem`, `BGGSearchResult` is a subset of `BGGItem`, and contains the following attributes: `:id, :type, :name, :year_published`.
|
26
85
|
|
27
|
-
|
86
|
+
A `BGGItem` version of this object can be requested with `to_item([statistics])`.
|
28
87
|
|
29
|
-
|
88
|
+
### But the BGG API has more than just this!
|
30
89
|
|
31
|
-
|
90
|
+
I made this gem to help make requests for another one of my projects, [Math Trade Manager](http://www.github.com/acceptableice/math-trade-manager), and thus haven't finished implementing the other BGG API features that Math Trade Manager didn't require. If you need something specific for your application, log an issue, message me on Twitter ([@AcceptableIce](http://www.twitter.com/acceptableice)), or email me at [jakeroussel@mac.com](mailto:jakeroussel@mac.com). This is my first gem, so there are probably some issues. Let me know!
|
32
91
|
|
33
92
|
## Contributing
|
34
93
|
|
35
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/
|
94
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/acceptableice/boardgamegem. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
36
95
|
|
37
96
|
|
38
97
|
## License
|
data/boardgamegem.gemspec
CHANGED
@@ -24,7 +24,19 @@ Gem::Specification.new do |spec|
|
|
24
24
|
spec.bindir = "exe"
|
25
25
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
26
26
|
spec.require_paths = ["lib"]
|
27
|
+
|
28
|
+
dependencies = [
|
29
|
+
# Examples:
|
30
|
+
[:runtime, "nokogiri"],
|
31
|
+
[:development, "bundler"],
|
32
|
+
[:development, "rake"]
|
33
|
+
]
|
27
34
|
|
28
|
-
|
29
|
-
|
35
|
+
dependencies.each do |type, name, version|
|
36
|
+
if spec.respond_to?("add_#{type}_dependency")
|
37
|
+
spec.send("add_#{type}_dependency", name, version)
|
38
|
+
else
|
39
|
+
spec.add_dependency(name, version)
|
40
|
+
end
|
41
|
+
end
|
30
42
|
end
|
data/lib/bgg_collection_item.rb
CHANGED
@@ -19,6 +19,7 @@ module BoardGameGem
|
|
19
19
|
:want_to_play => get_boolean(xml, "status", "wanttoplay"),
|
20
20
|
:want_to_buy => get_boolean(xml, "status", "wanttobuy"),
|
21
21
|
:wishlist => get_boolean(xml, "status", "wishlist"),
|
22
|
+
:wishlist_priority => get_integer(xml, "status", "wishlistpriority"),
|
22
23
|
:preordered => get_boolean(xml, "status", "preordered"),
|
23
24
|
:last_modified => get_datetime(xml, "status", "lastmodified")
|
24
25
|
}
|
data/lib/boardgamegem/version.rb
CHANGED
metadata
CHANGED
@@ -1,43 +1,57 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: BoardGameGem
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jake Roussel
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-05-
|
11
|
+
date: 2016-05-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: nokogiri
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
13
27
|
- !ruby/object:Gem::Dependency
|
14
28
|
name: bundler
|
15
29
|
requirement: !ruby/object:Gem::Requirement
|
16
30
|
requirements:
|
17
|
-
- - "
|
31
|
+
- - ">="
|
18
32
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
33
|
+
version: '0'
|
20
34
|
type: :development
|
21
35
|
prerelease: false
|
22
36
|
version_requirements: !ruby/object:Gem::Requirement
|
23
37
|
requirements:
|
24
|
-
- - "
|
38
|
+
- - ">="
|
25
39
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
40
|
+
version: '0'
|
27
41
|
- !ruby/object:Gem::Dependency
|
28
42
|
name: rake
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|
30
44
|
requirements:
|
31
|
-
- - "
|
45
|
+
- - ">="
|
32
46
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
47
|
+
version: '0'
|
34
48
|
type: :development
|
35
49
|
prerelease: false
|
36
50
|
version_requirements: !ruby/object:Gem::Requirement
|
37
51
|
requirements:
|
38
|
-
- - "
|
52
|
+
- - ">="
|
39
53
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
54
|
+
version: '0'
|
41
55
|
description:
|
42
56
|
email:
|
43
57
|
- jakeroussel@mac.com
|