board-game-gem 0.4.0 → 0.4.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
  SHA1:
3
- metadata.gz: fc068b33bb86956486f67fd7361578490a65ccb8
4
- data.tar.gz: 630af575a044c82480b02fe8cfa8e3d0ca9d889d
3
+ metadata.gz: d084e0f7625cd38c06127158de1f1c32ae833992
4
+ data.tar.gz: 48f6aa31a49d6ae62ab5daf4580447a5b2108f33
5
5
  SHA512:
6
- metadata.gz: dfb84f9b20fe3ec8326402e5374f6cd0861efb887ddc6effe1ce4b3de664a9160216613f1cf266bfc947b223680dccebfe82a0767cf471100c22b9bb47dab609
7
- data.tar.gz: 1a3abbffb70a69dcfd56de1792f121657abe45cf2635d7b38a5f5e60ec48145caba4d7fc02180505318e18fb0141b131d0ad7fa1bad27f6615989a149b07c4af
6
+ metadata.gz: 8f674af38a2287eca67f0a2975a13a66a7abdba71eddc77df98c9921e94680338a6c69b822c3b5d60a0bf918cc617627512395d5c8aea78f73324dd06ec225e0
7
+ data.tar.gz: 7633aead387e96650ce34dbc3e83127a5cb0d5c39b2863fa514cf71c2019f38012379921b80589f5b2a5051691e3c4a0f4fd1f529e5518a0c240b9dec03f1797
data/README.md CHANGED
@@ -25,25 +25,29 @@ The `options` argument is a hash which allows any other parameter. For example,
25
25
 
26
26
  ---
27
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.
28
+ `get_item(id, [statistics], [api] [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
29
 
30
- If `statistics` is true, averages, weights, and rankings will be retrieved as well. By default, `statistics` is false.
30
+ If `statistics` is true, averages, weights, and rankings will be retrieved as well. By default, `statistics` is false and `api` is 2.
31
31
 
32
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`.
33
+ `id, api, type, thumbnail, name, alternate_names, description, year_published, min_players, max_players,
34
+ playing_time, min_playing_time, max_playing_time, statistics`. If `api` is 1, `alternate_names` will always be `nil`.
35
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`.
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
+ `get_items(ids, [statistics], [api], [options])` exists as well, which is functionally equivelent to `get_item`, except it takes
39
+ an array of IDs and returns an array of `BGGItem` objects. `get_items` should be used when making many requests in succession,
40
+ as it makes one HTTP request for the batch.
37
41
 
38
42
  ---
39
43
 
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.
44
+ `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
45
 
42
46
  ---
43
47
 
44
48
  `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
49
 
46
- `get_user` returns a `BGGUser` object, which has the following attributes: `:id, :name, :avatar, :year_registered, :last_login, :state, :trade_rating`
50
+ `get_user` returns a `BGGUser` object, which has the following attributes: `id, name, avatar, year_registered, last_login, state, trade_rating`
47
51
 
48
52
  #### Methods
49
53
  `get_collection`: Returns this user's collection, as if `BoardGameGem.get_collection` was called using this user's name.
@@ -71,17 +75,17 @@ The BGG API queues requests to retrieve a user's collection, returning a 202 sta
71
75
 
72
76
  #### BGGCollectionItem
73
77
 
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`.
78
+ 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
79
 
76
80
  `BGGCollectionItem` contains one other method, `to_item([statistics])`, which returns the `BGGItem` version of this object.
77
81
 
78
82
  ---
79
83
 
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.
84
+ `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
85
 
82
86
  #### BGGSearchResult
83
87
 
84
- Much like `BGGCollectionItem`, `BGGSearchResult` is a subset of `BGGItem`, and contains the following attributes: `:id, :type, :name, :year_published`.
88
+ Much like `BGGCollectionItem`, `BGGSearchResult` is a subset of `BGGItem`, and contains the following attributes: `id, type, name, year_published`.
85
89
 
86
90
  A `BGGItem` version of this object can be requested with `to_item([statistics])`.
87
91
 
@@ -1,7 +1,7 @@
1
1
  module BoardGameGem
2
2
  class BGGCollection < BGGBase
3
3
 
4
- attr_reader :count, :items
4
+ attr_accessor :count, :items
5
5
 
6
6
  def initialize(xml)
7
7
  if !xml.nil?
@@ -69,13 +69,13 @@ module BoardGameGem
69
69
 
70
70
  def self.request_xml(method, hash, api = 2)
71
71
  params = BoardGameGem.hash_to_uri(hash)
72
+ if api == 2
73
+ api_path = "#{API_2_ROOT}/#{method}?#{params}"
74
+ else
75
+ api_path = "#{API_1_ROOT}/#{method}/#{hash[:id]}?stats=#{hash[:stats] ? 1 : 0}"
76
+ end
77
+ p api_path
72
78
  value = BoardGameGem.retryable(tries: MAX_ATTEMPTS, on: OpenURI::HTTPError) do
73
- if api == 2
74
- api_path = "#{API_2_ROOT}/#{method}?#{params}"
75
- else
76
- api_path = "#{API_1_ROOT}/#{method}/#{hash[:id]}?stats=#{hash[:stats] ? 1 : 0}"
77
- end
78
- p api_path
79
79
  open(api_path) do |file|
80
80
  if file.status[0] != "200"
81
81
  sleep 0.05
@@ -1,3 +1,3 @@
1
1
  module BoardGameGem
2
- VERSION = "0.4.0"
2
+ VERSION = "0.4.1"
3
3
  end
data/test.rb CHANGED
@@ -1,8 +1,2 @@
1
1
  require_relative 'lib/board-game-gem'
2
- #p BoardGameGem.get_items([15944, 15955, 15956]).to_s
3
-
4
- p BoardGameGem.get_items([123260, 123265, 61001], true).map { |x| x.type }
5
-
6
-
7
- p BoardGameGem.get_item(123260, true)
8
-
2
+ p BoardGameGem.get_collection("sos1", subtype: "boardgame,videogame,rpgitem").items.select { |x| x.type == "videogame" }
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: board-game-gem
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.4.1
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-19 00:00:00.000000000 Z
11
+ date: 2016-05-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake