BoardGameGem 0.1.0
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 +7 -0
- data/.gitignore +9 -0
- data/CODE_OF_CONDUCT.md +49 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +41 -0
- data/Rakefile +2 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/boardgamegem.gemspec +30 -0
- data/lib/bgg_base.rb +65 -0
- data/lib/bgg_collection.rb +48 -0
- data/lib/bgg_collection_item.rb +33 -0
- data/lib/bgg_family.rb +16 -0
- data/lib/bgg_item.rb +49 -0
- data/lib/bgg_search_result.rb +18 -0
- data/lib/bgg_user.rb +21 -0
- data/lib/boardgamegem/version.rb +3 -0
- data/lib/boardgamegem.rb +67 -0
- metadata +90 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: a86f9c4a37fe7b3836e74fef82739dabe3e6c24b
|
4
|
+
data.tar.gz: 6ae5089ea0641f2ead913e8da289c58d8ef43c6c
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: fc569af1eaafe2cea670ab293108f6bdf75f5934be1404932402a6fb2f81406fb86416cc80ca76c8cfafb41fc0e2438c91bd13b09643b14a8214ee9c65a32581
|
7
|
+
data.tar.gz: 2e16c83787fbc3d37c2ec2f374430db7aa6d73d0237f43ef797df66f2f1e1340a76ac6d2b806018b9cce16462863c6c83f0c4251f3710c37a4abe67247e9b8c3
|
data/.gitignore
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
# Contributor Code of Conduct
|
2
|
+
|
3
|
+
As contributors and maintainers of this project, and in the interest of
|
4
|
+
fostering an open and welcoming community, we pledge to respect all people who
|
5
|
+
contribute through reporting issues, posting feature requests, updating
|
6
|
+
documentation, submitting pull requests or patches, and other activities.
|
7
|
+
|
8
|
+
We are committed to making participation in this project a harassment-free
|
9
|
+
experience for everyone, regardless of level of experience, gender, gender
|
10
|
+
identity and expression, sexual orientation, disability, personal appearance,
|
11
|
+
body size, race, ethnicity, age, religion, or nationality.
|
12
|
+
|
13
|
+
Examples of unacceptable behavior by participants include:
|
14
|
+
|
15
|
+
* The use of sexualized language or imagery
|
16
|
+
* Personal attacks
|
17
|
+
* Trolling or insulting/derogatory comments
|
18
|
+
* Public or private harassment
|
19
|
+
* Publishing other's private information, such as physical or electronic
|
20
|
+
addresses, without explicit permission
|
21
|
+
* Other unethical or unprofessional conduct
|
22
|
+
|
23
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
24
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
25
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
26
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
27
|
+
threatening, offensive, or harmful.
|
28
|
+
|
29
|
+
By adopting this Code of Conduct, project maintainers commit themselves to
|
30
|
+
fairly and consistently applying these principles to every aspect of managing
|
31
|
+
this project. Project maintainers who do not follow or enforce the Code of
|
32
|
+
Conduct may be permanently removed from the project team.
|
33
|
+
|
34
|
+
This code of conduct applies both within project spaces and in public spaces
|
35
|
+
when an individual is representing the project or its community.
|
36
|
+
|
37
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
38
|
+
reported by contacting a project maintainer at jakeroussel@mac.com. All
|
39
|
+
complaints will be reviewed and investigated and will result in a response that
|
40
|
+
is deemed necessary and appropriate to the circumstances. Maintainers are
|
41
|
+
obligated to maintain confidentiality with regard to the reporter of an
|
42
|
+
incident.
|
43
|
+
|
44
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
|
45
|
+
version 1.3.0, available at
|
46
|
+
[http://contributor-covenant.org/version/1/3/0/][version]
|
47
|
+
|
48
|
+
[homepage]: http://contributor-covenant.org
|
49
|
+
[version]: http://contributor-covenant.org/version/1/3/0/
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2016 Jake Roussel
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,41 @@
|
|
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
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem 'boardgamegem'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install boardgamegem
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
TODO: Write usage instructions here
|
26
|
+
|
27
|
+
## Development
|
28
|
+
|
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.
|
30
|
+
|
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).
|
32
|
+
|
33
|
+
## Contributing
|
34
|
+
|
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.
|
36
|
+
|
37
|
+
|
38
|
+
## License
|
39
|
+
|
40
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
41
|
+
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "boardgamegem"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start
|
data/bin/setup
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'boardgamegem/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "BoardGameGem"
|
8
|
+
spec.version = BoardGameGem::VERSION
|
9
|
+
spec.authors = ["Jake Roussel"]
|
10
|
+
spec.email = ["jakeroussel@mac.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{Provides a Ruby interface to the BoardGameGeek API}
|
13
|
+
spec.homepage = "http://www.github.com/acceptableice/boardgamegem"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
|
17
|
+
# to allow pushing to a single host or delete this section to allow pushing to any host.
|
18
|
+
if spec.respond_to?(:metadata)
|
19
|
+
else
|
20
|
+
raise "RubyGems 2.0 or newer is required to protect against public gem pushes."
|
21
|
+
end
|
22
|
+
|
23
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
24
|
+
spec.bindir = "exe"
|
25
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
26
|
+
spec.require_paths = ["lib"]
|
27
|
+
|
28
|
+
spec.add_development_dependency "bundler", "~> 1.12"
|
29
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
30
|
+
end
|
data/lib/bgg_base.rb
ADDED
@@ -0,0 +1,65 @@
|
|
1
|
+
module BoardGameGem
|
2
|
+
class BGGBase
|
3
|
+
def initialize(xml)
|
4
|
+
@xml = xml
|
5
|
+
end
|
6
|
+
|
7
|
+
def to_s
|
8
|
+
return instance_variables.map{|ivar| "#{ivar} => #{instance_variable_get ivar}" }
|
9
|
+
end
|
10
|
+
|
11
|
+
protected
|
12
|
+
|
13
|
+
def get_value(path, key = nil)
|
14
|
+
item = @xml.at_css(path)
|
15
|
+
if item.nil?
|
16
|
+
return nil
|
17
|
+
end
|
18
|
+
if key.nil?
|
19
|
+
return item.content
|
20
|
+
else
|
21
|
+
return item[key]
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def get_values(path, key = nil)
|
26
|
+
results = []
|
27
|
+
@xml.css(path).each do |item|
|
28
|
+
if key.nil?
|
29
|
+
results.push(item.content)
|
30
|
+
else
|
31
|
+
results.push(item[key])
|
32
|
+
end
|
33
|
+
end
|
34
|
+
return results
|
35
|
+
end
|
36
|
+
|
37
|
+
def get_boolean(path, key = nil)
|
38
|
+
return get_integer(path, key) == 1 rescue nil
|
39
|
+
end
|
40
|
+
|
41
|
+
def get_integer(path, key = nil)
|
42
|
+
return get_value(path, key).to_i rescue nil
|
43
|
+
end
|
44
|
+
|
45
|
+
def get_integers(path, key = nil)
|
46
|
+
return get_values(path, key).map {|x| x.to_i } rescue nil
|
47
|
+
end
|
48
|
+
|
49
|
+
def get_string(path, key = nil)
|
50
|
+
return get_value(path, key).to_s rescue nil
|
51
|
+
end
|
52
|
+
|
53
|
+
def get_strings(path, key = nil)
|
54
|
+
return get_values(path, key).map {|x| x.to_s } rescue nil
|
55
|
+
end
|
56
|
+
|
57
|
+
def get_float(path, key = nil)
|
58
|
+
return get_value(path, key).to_f rescue nil
|
59
|
+
end
|
60
|
+
|
61
|
+
def get_datetime(path, key)
|
62
|
+
return DateTime.strptime(get_string(path, key), '%F %T')
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
module BoardGameGem
|
2
|
+
class BGGCollection < BGGBase
|
3
|
+
|
4
|
+
attr_reader :count, :items
|
5
|
+
|
6
|
+
def initialize(xml)
|
7
|
+
super
|
8
|
+
@count = get_integer("items", "totalitems")
|
9
|
+
@items = []
|
10
|
+
@xml.css("item").each do |item|
|
11
|
+
@items.push(BGGCollectionItem.new(item))
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def get_owned
|
16
|
+
return filter_by(:own)
|
17
|
+
end
|
18
|
+
|
19
|
+
def get_previously_owned
|
20
|
+
return filter_by(:prev_owned)
|
21
|
+
end
|
22
|
+
|
23
|
+
def get_wants
|
24
|
+
return filter_by(:want)
|
25
|
+
end
|
26
|
+
|
27
|
+
def get_want_to_play
|
28
|
+
return filter_by(:want_to_play)
|
29
|
+
end
|
30
|
+
|
31
|
+
def get_want_to_buy
|
32
|
+
return filter_by(:want_to_buy)
|
33
|
+
end
|
34
|
+
|
35
|
+
def get_wishlist
|
36
|
+
return filter_by(:wishlist)
|
37
|
+
end
|
38
|
+
|
39
|
+
def get_preordered
|
40
|
+
return filter_by(:preordered)
|
41
|
+
end
|
42
|
+
private
|
43
|
+
|
44
|
+
def filter_by(key)
|
45
|
+
return @items.select { |x| x.status[key] }
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
module BoardGameGem
|
2
|
+
class BGGCollectionItem < BGGBase
|
3
|
+
|
4
|
+
attr_reader :id, :type, :name, :year_published, :image, :thumbnail, :num_players, :status, :num_plays
|
5
|
+
|
6
|
+
def initialize(xml)
|
7
|
+
super
|
8
|
+
@id = xml["objectid"].to_i
|
9
|
+
@type = xml["subtype"]
|
10
|
+
@name = get_string("name")
|
11
|
+
@year_published = get_string("yearpublished")
|
12
|
+
@image = get_string("image")
|
13
|
+
@thumbnail = get_string("thumbnail")
|
14
|
+
@num_players = get_string("numplayers")
|
15
|
+
@status = {
|
16
|
+
:own => get_boolean("status", "own"),
|
17
|
+
:prev_owned => get_boolean("status", "prevowned"),
|
18
|
+
:for_trade => get_boolean("status", "fortrade"),
|
19
|
+
:want => get_boolean("status", "want"),
|
20
|
+
:want_to_play => get_boolean("status", "wanttoplay"),
|
21
|
+
:want_to_buy => get_boolean("status", "wanttobuy"),
|
22
|
+
:wishlist => get_boolean("status", "wishlist"),
|
23
|
+
:preordered => get_boolean("status", "preordered"),
|
24
|
+
:last_modified => get_datetime("status", "lastmodified")
|
25
|
+
}
|
26
|
+
@num_plays = get_integer("numplays")
|
27
|
+
end
|
28
|
+
|
29
|
+
def to_item(statistics = false)
|
30
|
+
return BoardGameGem.get_item(@id, statistics)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
data/lib/bgg_family.rb
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
module BoardGameGem
|
2
|
+
class BGGFamily < BGGBase
|
3
|
+
|
4
|
+
attr_reader :id, :thumbnail, :image, :name, :alternate_names, :description
|
5
|
+
|
6
|
+
def initialize(xml)
|
7
|
+
super
|
8
|
+
@id = get_integer("item", "id")
|
9
|
+
@thumbnail = get_string("thumbnail")
|
10
|
+
@image = get_string("image")
|
11
|
+
@name = get_string("name[type='primary']", "value")
|
12
|
+
@alternate_names = get_strings("name[type='alternate']", "value")
|
13
|
+
@description = get_string("description")
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
data/lib/bgg_item.rb
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
module BoardGameGem
|
2
|
+
class BGGItem < BGGBase
|
3
|
+
|
4
|
+
attr_reader :id, :type, :thumbnail, :name, :description, :year_published, :min_players, :max_players,
|
5
|
+
:playing_time, :min_playing_time, :max_playing_time, :statistics
|
6
|
+
|
7
|
+
def initialize(xml)
|
8
|
+
super
|
9
|
+
@id = get_integer("item", "id")
|
10
|
+
@type = get_string("item", "type")
|
11
|
+
@thumbnail = get_string("thumbnail")
|
12
|
+
@name = get_string("name[type='primary']", "value")
|
13
|
+
@alternate_names = get_strings("name[type='alternate']", "value")
|
14
|
+
@description = get_string("description")
|
15
|
+
@year_published = get_integer("yearpublished", "value")
|
16
|
+
@min_players = get_integer("minplayers", "value")
|
17
|
+
@max_players = get_integer("maxplayers", "value")
|
18
|
+
@playing_time = get_integer("playingtime", "value")
|
19
|
+
@min_playing_time = get_integer("minplaytime", "value")
|
20
|
+
@max_playing_time = get_integer("maxplaytime", "value")
|
21
|
+
@statistics = nil
|
22
|
+
if !@xml.at_css("statistics").nil?
|
23
|
+
@statistics = {}
|
24
|
+
@statistics[:user_ratings] = get_integer("usersrated", "value")
|
25
|
+
@statistics[:average] = get_float("average", "value")
|
26
|
+
@statistics[:bayes] = get_float("bayesaverage", "value")
|
27
|
+
@statistics[:ranks] = []
|
28
|
+
@xml.css("rank").each do |rank|
|
29
|
+
rank_data = {}
|
30
|
+
rank_data[:type] = rank["type"]
|
31
|
+
rank_data[:name] = rank["name"]
|
32
|
+
rank_data[:value] = rank["value"].to_i
|
33
|
+
rank_data[:bayes] = rank["bayesaverage"].to_f
|
34
|
+
@statistics[:ranks].push(rank_data)
|
35
|
+
end
|
36
|
+
@statistics[:stddev] = get_float("stddev", "value")
|
37
|
+
@statistics[:median] = get_float("median", "value")
|
38
|
+
@statistics[:owned] = get_integer("owned", "value")
|
39
|
+
@statistics[:trading] = get_integer("trading", "value")
|
40
|
+
@statistics[:wanting] = get_integer("wanting", "value")
|
41
|
+
@statistics[:wishing] = get_integer("wishing", "value")
|
42
|
+
@statistics[:num_comments] = get_integer("numcomments", "value")
|
43
|
+
@statistics[:num_weights] = get_integer("numweights", "value")
|
44
|
+
@statistics[:average_weight] = get_integer("averageweight", "value")
|
45
|
+
end
|
46
|
+
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module BoardGameGem
|
2
|
+
class BGGSearchResult < BGGBase
|
3
|
+
|
4
|
+
attr_reader :id, :type, :name, :year_published
|
5
|
+
|
6
|
+
def initialize(xml)
|
7
|
+
super
|
8
|
+
@id = xml["id"].to_i
|
9
|
+
@type = xml["type"]
|
10
|
+
@name = get_string("name", "value")
|
11
|
+
@year_published = get_string("yearpublished", "value")
|
12
|
+
end
|
13
|
+
|
14
|
+
def to_item(statistics = false)
|
15
|
+
return BoardGameGem.get_item(@id, statistics)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
data/lib/bgg_user.rb
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
module BoardGameGem
|
2
|
+
class BGGUser < BGGBase
|
3
|
+
|
4
|
+
attr_reader :id, :name, :avatar, :year_registered, :last_login, :state, :trade_rating
|
5
|
+
|
6
|
+
def initialize(xml)
|
7
|
+
super
|
8
|
+
@id = get_integer("user", "id")
|
9
|
+
@name = get_string("user", "name")
|
10
|
+
@avatar = get_string("avatarlink", "value")
|
11
|
+
@year_registered = get_integer("yearregistered", "value")
|
12
|
+
@last_login = get_string("lastlogin", "value")
|
13
|
+
@state = get_string("stateorprovince", "value")
|
14
|
+
@trade_rating = get_integer("traderating", "value")
|
15
|
+
end
|
16
|
+
|
17
|
+
def get_collection
|
18
|
+
return BoardGameGem.get_collection(@name)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
data/lib/boardgamegem.rb
ADDED
@@ -0,0 +1,67 @@
|
|
1
|
+
require 'nokogiri'
|
2
|
+
require 'open-uri'
|
3
|
+
|
4
|
+
module BoardGameGem
|
5
|
+
API_ROOT = "http://www.boardgamegeek.com/xmlapi2"
|
6
|
+
MAX_ATTEMPTS = 10
|
7
|
+
|
8
|
+
def BoardGameGem.get_item(id, statistics = false, options = {})
|
9
|
+
options[:id] = id
|
10
|
+
options[:stats] = statistics ? 1 : 0
|
11
|
+
return BGGItem.new(BoardGameGem.request_xml("thing", options))
|
12
|
+
end
|
13
|
+
|
14
|
+
def BoardGameGem.get_family(id, options = {})
|
15
|
+
options[:id] = id
|
16
|
+
return BGGFamily.new(BoardGameGem.request_xml("family", options))
|
17
|
+
end
|
18
|
+
|
19
|
+
def BoardGameGem.get_user(username, options = {})
|
20
|
+
options[:name] = username
|
21
|
+
return BGGUser.new(BoardGameGem.request_xml("user", options))
|
22
|
+
end
|
23
|
+
|
24
|
+
def BoardGameGem.get_collection(username, options = {})
|
25
|
+
options[:username] = username
|
26
|
+
return BGGCollection.new(BoardGameGem.request_xml("collection", options))
|
27
|
+
end
|
28
|
+
|
29
|
+
def BoardGameGem.search(query, options = {})
|
30
|
+
options[:query] = query
|
31
|
+
xml = BoardGameGem.request_xml("search", options)
|
32
|
+
return {
|
33
|
+
:total => xml["total"].to_i,
|
34
|
+
:items => xml.css("item").map { |x| BGGSearchResult.new(x) }
|
35
|
+
}
|
36
|
+
end
|
37
|
+
|
38
|
+
private
|
39
|
+
|
40
|
+
def BoardGameGem.request_xml(method, hash, attempt = 0)
|
41
|
+
params = BoardGameGem.hash_to_uri(hash)
|
42
|
+
open("#{API_ROOT}/#{method}?#{params}") do |file|
|
43
|
+
if file.status == 202
|
44
|
+
if attempt < MAX_ATTEMPTS
|
45
|
+
sleep 0.05
|
46
|
+
BoardGameGem.request_xml(method, hash, attempt + 1)
|
47
|
+
else
|
48
|
+
return nil
|
49
|
+
end
|
50
|
+
else
|
51
|
+
Nokogiri::XML(file.read)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
def BoardGameGem.hash_to_uri(hash)
|
57
|
+
return hash.to_a.map { |x| "#{x[0]}=#{x[1]}" }.join("&")
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
require 'bgg_base'
|
62
|
+
require 'bgg_item'
|
63
|
+
require 'bgg_family'
|
64
|
+
require 'bgg_user'
|
65
|
+
require 'bgg_collection'
|
66
|
+
require 'bgg_collection_item'
|
67
|
+
require 'bgg_search_result'
|
metadata
ADDED
@@ -0,0 +1,90 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: BoardGameGem
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Jake Roussel
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-05-08 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.12'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.12'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
description:
|
42
|
+
email:
|
43
|
+
- jakeroussel@mac.com
|
44
|
+
executables: []
|
45
|
+
extensions: []
|
46
|
+
extra_rdoc_files: []
|
47
|
+
files:
|
48
|
+
- ".gitignore"
|
49
|
+
- CODE_OF_CONDUCT.md
|
50
|
+
- Gemfile
|
51
|
+
- LICENSE.txt
|
52
|
+
- README.md
|
53
|
+
- Rakefile
|
54
|
+
- bin/console
|
55
|
+
- bin/setup
|
56
|
+
- boardgamegem.gemspec
|
57
|
+
- lib/bgg_base.rb
|
58
|
+
- lib/bgg_collection.rb
|
59
|
+
- lib/bgg_collection_item.rb
|
60
|
+
- lib/bgg_family.rb
|
61
|
+
- lib/bgg_item.rb
|
62
|
+
- lib/bgg_search_result.rb
|
63
|
+
- lib/bgg_user.rb
|
64
|
+
- lib/boardgamegem.rb
|
65
|
+
- lib/boardgamegem/version.rb
|
66
|
+
homepage: http://www.github.com/acceptableice/boardgamegem
|
67
|
+
licenses:
|
68
|
+
- MIT
|
69
|
+
metadata: {}
|
70
|
+
post_install_message:
|
71
|
+
rdoc_options: []
|
72
|
+
require_paths:
|
73
|
+
- lib
|
74
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
75
|
+
requirements:
|
76
|
+
- - ">="
|
77
|
+
- !ruby/object:Gem::Version
|
78
|
+
version: '0'
|
79
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
80
|
+
requirements:
|
81
|
+
- - ">="
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
version: '0'
|
84
|
+
requirements: []
|
85
|
+
rubyforge_project:
|
86
|
+
rubygems_version: 2.5.1
|
87
|
+
signing_key:
|
88
|
+
specification_version: 4
|
89
|
+
summary: Provides a Ruby interface to the BoardGameGeek API
|
90
|
+
test_files: []
|