board-game-gem 0.3.4 → 0.3.5

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: 4c0d95d7c92b9e52b31b0fc82224219a461d8b96
4
- data.tar.gz: 8a4458b65ab925ee050b6a289f4848dd1f54292f
3
+ metadata.gz: 636c8a96112b8fa8b537dc0860ec1c35632b5811
4
+ data.tar.gz: 643fe217c6569f87ccce896e4a7ba24e5b668e68
5
5
  SHA512:
6
- metadata.gz: 626417aee8d66e1837c750578d7e77aa9560aff9af7ba2c2d2e52b6a856957f533dd4f5e44a6c4217967f0fa0439cfbf0798803311b7f87bb5a6c11740b03bfa
7
- data.tar.gz: 4f71a194f2372ca65f027312260ab753272c03a445e052dda125be4194e107fef3ef3c745b055d6f7bace228718ea43731d5da31b515710611d5f574baf14007
6
+ metadata.gz: 0d13c7319cc3d62f1c4110721a2ba69eec7b008ee2ba67c94ead790a71c00de5b6ee643fc02f26f6a4a64a78777e96312eb37ec4d79fd723f2323d22ed86ea1b
7
+ data.tar.gz: a2676e3598c3fa162d5dd7f3449be77068b84fcd7f5adc01766f9c8948ccc31fd1b2faa7decfdd07d14f92759e7cf4a38e2a8388e4af92aeed677e4beca78196
@@ -5,14 +5,14 @@ module BoardGameGem
5
5
  API_ROOT = "https://www.boardgamegeek.com/xmlapi2"
6
6
  MAX_ATTEMPTS = 10
7
7
 
8
- def BoardGameGem.get_item(id, statistics = false, options = {})
8
+ def self.get_item(id, statistics = false, options = {})
9
9
  options[:id] = id
10
10
  options[:stats] = statistics ? 1 : 0
11
11
  item = BGGItem.new(BoardGameGem.request_xml("thing", options))
12
12
  item.id == 0 ? nil : item
13
13
  end
14
14
 
15
- def BoardGameGem.get_items(ids, statistics = false, options = {})
15
+ def self.get_items(ids, statistics = false, options = {})
16
16
  options[:id] = ids.join(",")
17
17
  options[:stats] = statistics ? 1 : 0
18
18
  item_xml = BoardGameGem.request_xml("thing", options)
@@ -24,19 +24,19 @@ module BoardGameGem
24
24
  item_list
25
25
  end
26
26
 
27
- def BoardGameGem.get_family(id, options = {})
27
+ def self.get_family(id, options = {})
28
28
  options[:id] = id
29
29
  family = BGGFamily.new(BoardGameGem.request_xml("family", options))
30
30
  family.id == 0 ? nil : family
31
31
  end
32
32
 
33
- def BoardGameGem.get_user(username, options = {})
33
+ def self.get_user(username, options = {})
34
34
  options[:name] = username
35
35
  user = BGGUser.new(BoardGameGem.request_xml("user", options))
36
36
  user.id == 0 ? nil : user
37
37
  end
38
38
 
39
- def BoardGameGem.get_collection(username, options = {})
39
+ def self.get_collection(username, options = {})
40
40
  options[:username] = username
41
41
  collection_xml = BoardGameGem.request_xml("collection", options)
42
42
  if collection_xml.css("error").length > 0
@@ -46,7 +46,7 @@ module BoardGameGem
46
46
  end
47
47
  end
48
48
 
49
- def BoardGameGem.search(query, options = {})
49
+ def self.search(query, options = {})
50
50
  options[:query] = query
51
51
  xml = BoardGameGem.request_xml("search", options)
52
52
  {
@@ -57,7 +57,7 @@ module BoardGameGem
57
57
 
58
58
  private
59
59
 
60
- def BoardGameGem.request_xml(method, hash, attempt = 0)
60
+ def self.request_xml(method, hash, attempt = 0)
61
61
  params = BoardGameGem.hash_to_uri(hash)
62
62
  value = BoardGameGem.retryable(tries: MAX_ATTEMPTS, on: OpenURI::HTTPError) do
63
63
  open("#{API_ROOT}/#{method}?#{params}") do |file|
@@ -72,11 +72,11 @@ module BoardGameGem
72
72
  value
73
73
  end
74
74
 
75
- def BoardGameGem.hash_to_uri(hash)
75
+ def self.hash_to_uri(hash)
76
76
  return hash.to_a.map { |x| "#{x[0]}=#{x[1]}" }.join("&")
77
77
  end
78
78
 
79
- def BoardGameGem.retryable(options = {}, &block)
79
+ def self.retryable(options = {}, &block)
80
80
  opts = { :tries => 1, :on => Exception }.merge(options)
81
81
 
82
82
  retry_exception, retries = opts[:on], opts[:tries]
@@ -1,3 +1,3 @@
1
1
  module BoardGameGem
2
- VERSION = "0.3.4"
2
+ VERSION = "0.3.5"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: board-game-gem
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.4
4
+ version: 0.3.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jake Roussel