gameboy 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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 7aae3e65043ff854332b61e513c161973c0a14f7
4
+ data.tar.gz: f78ed2fc7ee6a25a3827867ffb7c333ae8cb1b5a
5
+ SHA512:
6
+ metadata.gz: 884b3a502e18dd92774f156489a77af70d3219c76ed5c37941bf79a6c17164b6f3180127481454eabab0ae2cfc738f9d7174e08c3039a6128175b21e47d2fccb
7
+ data.tar.gz: afe362662d24ce8f61bdb1266eecc21a63cf9d0ee2fb7d644a5aa5c5babdb77b5c483c306635d9936cfcc2422aef14d2b8b5483963e21a2926c5ebf18266c3ea
data/.gitignore ADDED
@@ -0,0 +1 @@
1
+ pkg/*.gem
data/.ruby-gemset ADDED
@@ -0,0 +1 @@
1
+ gameboy
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 2.2
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in gameboy.gemspec
4
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,73 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ gameboy (0.1.0)
5
+ activesupport
6
+ hashie
7
+ json
8
+ rest-client
9
+
10
+ GEM
11
+ remote: https://rubygems.org/
12
+ specs:
13
+ activesupport (4.2.4)
14
+ i18n (~> 0.7)
15
+ json (~> 1.7, >= 1.7.7)
16
+ minitest (~> 5.1)
17
+ thread_safe (~> 0.3, >= 0.3.4)
18
+ tzinfo (~> 1.1)
19
+ addressable (2.3.8)
20
+ crack (0.4.2)
21
+ safe_yaml (~> 1.0.0)
22
+ diff-lcs (1.2.5)
23
+ domain_name (0.5.24)
24
+ unf (>= 0.0.5, < 1.0.0)
25
+ hashie (3.4.2)
26
+ http-cookie (1.0.2)
27
+ domain_name (~> 0.5)
28
+ i18n (0.7.0)
29
+ json (1.8.3)
30
+ mime-types (2.6.1)
31
+ minitest (5.8.0)
32
+ netrc (0.10.3)
33
+ rake (10.4.2)
34
+ rest-client (1.8.0)
35
+ http-cookie (>= 1.0.2, < 2.0)
36
+ mime-types (>= 1.16, < 3.0)
37
+ netrc (~> 0.7)
38
+ rspec (3.2.0)
39
+ rspec-core (~> 3.2.0)
40
+ rspec-expectations (~> 3.2.0)
41
+ rspec-mocks (~> 3.2.0)
42
+ rspec-core (3.2.3)
43
+ rspec-support (~> 3.2.0)
44
+ rspec-expectations (3.2.1)
45
+ diff-lcs (>= 1.2.0, < 2.0)
46
+ rspec-support (~> 3.2.0)
47
+ rspec-mocks (3.2.1)
48
+ diff-lcs (>= 1.2.0, < 2.0)
49
+ rspec-support (~> 3.2.0)
50
+ rspec-support (3.2.2)
51
+ safe_yaml (1.0.4)
52
+ thread_safe (0.3.5)
53
+ tzinfo (1.2.2)
54
+ thread_safe (~> 0.1)
55
+ unf (0.1.4)
56
+ unf_ext
57
+ unf_ext (0.0.7.1)
58
+ webmock (1.21.0)
59
+ addressable (>= 2.3.6)
60
+ crack (>= 0.3.2)
61
+
62
+ PLATFORMS
63
+ ruby
64
+
65
+ DEPENDENCIES
66
+ bundler (~> 1.9)
67
+ gameboy!
68
+ rake (~> 10.0)
69
+ rspec
70
+ webmock
71
+
72
+ BUNDLED WITH
73
+ 1.10.5
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 Jerry Luk
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,48 @@
1
+ # gameboy
2
+
3
+ Gamer Ruby Client
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'gameboy'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install gameboy
20
+
21
+ ## Usage
22
+
23
+ ```ruby
24
+ # Get upcoming achievements for user
25
+ gameboy.api_key = "YOUR_API_KEY"
26
+ gameboy.upcoming_achievements_for_user(1)
27
+
28
+ # Get one user stats
29
+ gameboy.user(1)
30
+
31
+ # Get multiple users stats
32
+ gameboy.users([1,2], page: 1)
33
+
34
+ ```
35
+
36
+ ## Development
37
+
38
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `bin/console` for an interactive prompt that will allow you to experiment.
39
+
40
+ 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` to create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
41
+
42
+ ## Contributing
43
+
44
+ 1. Fork it ( https://github.com/[my-github-username]/gameboy/fork )
45
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
46
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
47
+ 4. Push to the branch (`git push origin my-new-feature`)
48
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
data/bin/console ADDED
@@ -0,0 +1,13 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+
5
+ # You can add fixtures and/or initialization code here to make experimenting
6
+ # with your gem easier. You can also use a different console, if you like.
7
+
8
+ # (If you use this, don't forget to add pry to your Gemfile!)
9
+ # require "pry"
10
+ # Pry.start
11
+
12
+ require "irb"
13
+ IRB.start
data/bin/setup ADDED
@@ -0,0 +1,7 @@
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+
5
+ bundle install
6
+
7
+ # Do any other automated setup that you need to do here
data/gameboy.gemspec ADDED
@@ -0,0 +1,38 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'gameboy/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "gameboy"
8
+ spec.version = Gameboy::VERSION
9
+ spec.authors = ["Jerry Luk"]
10
+ spec.email = ["jerry@edmodo.com"]
11
+
12
+ spec.summary = %q{Ruby client for Gamer}
13
+ spec.description = %q{Ruby client for Gamer.}
14
+ spec.homepage = "https://github.com/edmodo/gameboy"
15
+ spec.license = "MIT"
16
+
17
+ # Prevent pushing this gem to RubyGems.org by setting 'allowed_push_host', or
18
+ # delete this section to allow pushing this gem to any host.
19
+ # if spec.respond_to?(:metadata)
20
+ # spec.metadata['allowed_push_host'] = "TODO: Set to 'http://mygemserver.com'"
21
+ # else
22
+ # raise "RubyGems 2.0 or newer is required to protect against public gem pushes."
23
+ # end
24
+
25
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
26
+ spec.bindir = "exe"
27
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
28
+ spec.require_paths = ["lib"]
29
+
30
+ spec.add_development_dependency "bundler", "~> 1.9"
31
+ spec.add_development_dependency "rake", "~> 10.0"
32
+ spec.add_development_dependency "rspec"
33
+ spec.add_development_dependency "webmock"
34
+ spec.add_runtime_dependency "activesupport"
35
+ spec.add_runtime_dependency "rest-client"
36
+ spec.add_runtime_dependency "json"
37
+ spec.add_runtime_dependency "hashie"
38
+ end
data/lib/gameboy.rb ADDED
@@ -0,0 +1,62 @@
1
+ require "gameboy/version"
2
+ require 'active_support/all'
3
+ require 'json'
4
+ require 'rest-client'
5
+ require 'hashie'
6
+
7
+ module Gameboy
8
+ REQUEST_TIMEOUT = 60
9
+ OPEN_TIMEOUT = 5
10
+ @@api_key = "SET_YOUR_API_KEY"
11
+ @@gamer_host = nil # Optional
12
+
13
+ def self.api_key=(key)
14
+ @@api_key = key
15
+ end
16
+
17
+ def self.gamer_host=(host)
18
+ @@gamer_host = host
19
+ end
20
+
21
+ def self.gamer_host
22
+ @@gamer_host ||= "https://gamer.edmodo.com"
23
+ end
24
+
25
+ def self.upcoming_achievements_for_user(user_id, options={})
26
+ api_key = options.delete(:api_key) || @@api_key
27
+
28
+ response = RestClient::Request.execute(
29
+ method: :get,
30
+ url: "#{self.gamer_host}/users/#{user_id}/achievements/upcoming?#{options.to_query}",
31
+ headers: {"Authorization" => "api_key #{api_key}", :content_type => :json, :accept => :json},
32
+ timeout: REQUEST_TIMEOUT,
33
+ open_timeout: OPEN_TIMEOUT
34
+ )
35
+ JSON.parse(response).map{|r| Hashie::Mash.new(r)}
36
+ end
37
+
38
+ def self.users(user_ids, options={})
39
+ api_key = options.delete(:api_key) || @@api_key
40
+ options[:ids] = Array.wrap(user_ids).join(',')
41
+ response = RestClient::Request.execute(
42
+ method: :get,
43
+ url: "#{self.gamer_host}/users?#{options.to_query}",
44
+ headers: {"Authorization" => "api_key #{api_key}", :content_type => :json, :accept => :json},
45
+ timeout: REQUEST_TIMEOUT,
46
+ open_timeout: OPEN_TIMEOUT
47
+ )
48
+ JSON.parse(response).map{|r| Hashie::Mash.new(r)}
49
+ end
50
+
51
+ def self.user(user_id, options={})
52
+ api_key = options.delete(:api_key) || @@api_key
53
+ response = RestClient::Request.execute(
54
+ method: :get,
55
+ url: "#{self.gamer_host}/users/#{user_id}?#{options.to_query}",
56
+ headers: {"Authorization" => "api_key #{api_key}", :content_type => :json, :accept => :json},
57
+ timeout: REQUEST_TIMEOUT,
58
+ open_timeout: OPEN_TIMEOUT
59
+ )
60
+ Hashie::Mash.new(JSON.parse(response))
61
+ end
62
+ end
@@ -0,0 +1,3 @@
1
+ module Gameboy
2
+ VERSION = "0.1.0"
3
+ end
metadata ADDED
@@ -0,0 +1,169 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: gameboy
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Jerry Luk
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2015-09-02 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.9'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.9'
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
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: webmock
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: activesupport
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rest-client
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: json
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :runtime
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: hashie
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :runtime
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ description: Ruby client for Gamer.
126
+ email:
127
+ - jerry@edmodo.com
128
+ executables: []
129
+ extensions: []
130
+ extra_rdoc_files: []
131
+ files:
132
+ - ".gitignore"
133
+ - ".ruby-gemset"
134
+ - ".ruby-version"
135
+ - Gemfile
136
+ - Gemfile.lock
137
+ - LICENSE.txt
138
+ - README.md
139
+ - Rakefile
140
+ - bin/console
141
+ - bin/setup
142
+ - gameboy.gemspec
143
+ - lib/gameboy.rb
144
+ - lib/gameboy/version.rb
145
+ homepage: https://github.com/edmodo/gameboy
146
+ licenses:
147
+ - MIT
148
+ metadata: {}
149
+ post_install_message:
150
+ rdoc_options: []
151
+ require_paths:
152
+ - lib
153
+ required_ruby_version: !ruby/object:Gem::Requirement
154
+ requirements:
155
+ - - ">="
156
+ - !ruby/object:Gem::Version
157
+ version: '0'
158
+ required_rubygems_version: !ruby/object:Gem::Requirement
159
+ requirements:
160
+ - - ">="
161
+ - !ruby/object:Gem::Version
162
+ version: '0'
163
+ requirements: []
164
+ rubyforge_project:
165
+ rubygems_version: 2.4.6
166
+ signing_key:
167
+ specification_version: 4
168
+ summary: Ruby client for Gamer
169
+ test_files: []