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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 595da194a9ed8fd8cf200463247c600a87e29e79
4
- data.tar.gz: 7a2292976753fde54678aa9d25e19ee351df971b
3
+ metadata.gz: f37eaa1b94b6fb0d31a7d65756b3c020d46e11cf
4
+ data.tar.gz: 47327435fb477799e0edea1f61618237493164f3
5
5
  SHA512:
6
- metadata.gz: 71b49cf8e32632ff33f65cea8fc42aacaa6cb13e2498c8d96ae1c3f49f69ecb686078d47d9ba18c67e4444758652526824d052561e35c848e0ba36461ff36d8c
7
- data.tar.gz: e6bd6af6413e4cbf44be2baca02c31df14b71724bb70f82bc9405b5c560ab3d9eed584f1ac9a1381c5fb9cd07b0d138e5481b7b39145787bed4d6c859b22b16c
6
+ metadata.gz: bf13ab6669adf49a0ad29c80a9948f59f0e0ab01bdd0f0638f8bed7b48c83b0d74d33003479106a857139b2311452b69d6328957a2662d4f790a35fad8a01f58
7
+ data.tar.gz: 9f65f21102d46cae68f37be9d6f95b297da379fdba017981a592149c36bcef761f01aee2d8c028c132b1e99cf05e815324830aa8ae518b0154676a14b36e6d66
data/README.md CHANGED
@@ -1,8 +1,5 @@
1
- # Boardgamegem
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
- TODO: Write usage instructions here
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
- ## Development
86
+ A `BGGItem` version of this object can be requested with `to_item([statistics])`.
28
87
 
29
- After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
88
+ ### But the BGG API has more than just this!
30
89
 
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 tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
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/[USERNAME]/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.
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
- spec.add_development_dependency "bundler", "~> 1.12"
29
- spec.add_development_dependency "rake", "~> 10.0"
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
@@ -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
  }
@@ -1,3 +1,3 @@
1
1
  module BoardGameGem
2
- VERSION = "0.1.5"
2
+ VERSION = "0.1.6"
3
3
  end
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.5
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-09 00:00:00.000000000 Z
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: '1.12'
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: '1.12'
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: '10.0'
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: '10.0'
54
+ version: '0'
41
55
  description:
42
56
  email:
43
57
  - jakeroussel@mac.com