halo_stats 1.0.1 → 1.0.3
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 +4 -4
- data/Gemfile +1 -1
- data/README.md +57 -0
- data/circle.yml +28 -0
- data/halo_stats.gemspec +1 -1
- data/lib/halo_stats/stats.rb +18 -30
- data/lib/halo_stats/version.rb +1 -1
- data/spec/.DS_Store +0 -0
- data/spec/metadata_spec.rb +91 -0
- data/spec/profile_spec.rb +15 -0
- data/spec/spec_helper.rb +104 -0
- data/spec/stats_spec.rb +43 -0
- data/spec/support/.DS_Store +0 -0
- data/spec/support/fake_test_api.rb +56 -0
- data/spec/support/fixtures/matches.json +3 -0
- data/spec/support/fixtures/posts.json +8 -0
- metadata +25 -6
- data/README +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0804dfa25b49e6110de9567c8d5b5fb7cca0eb4e
|
4
|
+
data.tar.gz: 6e2b31bfdb25dc986d2c41dc6835ea572e26620f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b6b96c79c8fdc8deed179d2b5762c9ce4956e7e5c38fb23b6995d0091e8c2c426a9ba2fdd227dba7fa90c0f097dc95bd2233315e4d3953f890fe58e1a806e5f9
|
7
|
+
data.tar.gz: 05ecadddd4ba799110119732ed2561b581146d6e008d940730ce4836b761a8f690bfab3ca2d366a65790d3fd0fcd4de0c36b549feb0152a8f68ff0b2792c7ad8
|
data/Gemfile
CHANGED
data/README.md
ADDED
@@ -0,0 +1,57 @@
|
|
1
|
+
# HaloStats
|
2
|
+
[](http://badge.fury.io/rb/halo_stats)
|
3
|
+
[](https://codeclimate.com/github/kylegrantlucas/halo_stats)
|
4
|
+
[](https://codeclimate.com/github/kylegrantlucas/halo_stats/coverage)
|
5
|
+
[](https://circleci.com/gh/kylegrantlucas/halo_stats/tree/master)
|
6
|
+
[](http://inch-ci.org/github/kylegrantlucas/halo_stats)
|
7
|
+
[](https://gitter.im/kylegrantlucas/halo_stats?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
|
8
|
+
[](https://github.com/igrigorik/ga-beacon)
|
9
|
+
|
10
|
+
A ruby gem wrapper for the Halo 5 API.
|
11
|
+
|
12
|
+
## Requirements
|
13
|
+
|
14
|
+
All versions of MRI 1.9.3+ and up are supported (and tested via CircleCI), the gem is currently unsupported on JRuby, MRI 1.8-1.9.2, and Rubinus.
|
15
|
+
Support of these platforms is a future goal for the project.
|
16
|
+
|
17
|
+
## Installation
|
18
|
+
|
19
|
+
Add this line to your application's Gemfile:
|
20
|
+
|
21
|
+
gem 'halo_stats'
|
22
|
+
|
23
|
+
And then execute:
|
24
|
+
|
25
|
+
$ bundle
|
26
|
+
|
27
|
+
Or install it yourself as:
|
28
|
+
|
29
|
+
$ gem install halo_stats
|
30
|
+
|
31
|
+
## Usage
|
32
|
+
|
33
|
+
### Quick Use
|
34
|
+
|
35
|
+
The first step is to instantiate some clients for the data we would like to grab:
|
36
|
+
|
37
|
+
stats_client = Halo::StatsClient.new(api_key: 'APIKEY')
|
38
|
+
profile_client = Halo::StatsClient.new(api_key: 'APIKEY')
|
39
|
+
metadata_client = Halo::StatsClient.new(api_key: 'APIKEY')
|
40
|
+
|
41
|
+
From here you can begin calling your any api methods!
|
42
|
+
So an example of call flow would be:
|
43
|
+
|
44
|
+
matches_response = stats_client.get_matches('GAMERTAG')
|
45
|
+
arena_match_response = stats_client.get_arena_carnage_report(match_response.first["Id"]["MatchId"])
|
46
|
+
game_variant_response = metadata_client.get_game_variants(match_response["GameVariantId"])
|
47
|
+
spartan_image_url = profile_client.get_spartan_image('GAMERTAG')
|
48
|
+
|
49
|
+
Results are returned as parsed ruby objects (generally a hash or an array of hashes).
|
50
|
+
|
51
|
+
## Contributing
|
52
|
+
|
53
|
+
1. Fork it ( https://github.com/kylegrantlucas/halo_stats/fork )
|
54
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
55
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
56
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
57
|
+
5. Create a new Pull Request
|
data/circle.yml
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
notify:
|
2
|
+
webhooks:
|
3
|
+
# A list of hook hashes, containing the url field
|
4
|
+
# gitter hook
|
5
|
+
- url: https://webhooks.gitter.im/e/c114cd659f05cf6ad19f
|
6
|
+
|
7
|
+
dependencies:
|
8
|
+
override:
|
9
|
+
- >
|
10
|
+
case $CIRCLE_NODE_INDEX in
|
11
|
+
0)
|
12
|
+
rvm-exec 1.9.3-p0 bash -c "bundle check --path=vendor/bundle || bundle install --path=vendor/bundle"
|
13
|
+
;;
|
14
|
+
1)
|
15
|
+
rvm-exec 2.0.0-p0 bash -c "bundle check --path=vendor/bundle || bundle install --path=vendor/bundle"
|
16
|
+
;;
|
17
|
+
2)
|
18
|
+
rvm-exec 2.2.0 bash -c "bundle check --path=vendor/bundle || bundle install --path=vendor/bundle"
|
19
|
+
;;
|
20
|
+
3)
|
21
|
+
rvm-exec 2.1.0 bash -c "bundle check --path=vendor/bundle || bundle install --path=vendor/bundle"
|
22
|
+
;;
|
23
|
+
esac
|
24
|
+
|
25
|
+
test:
|
26
|
+
override:
|
27
|
+
- case $CIRCLE_NODE_INDEX in 0) rvm-exec 1.9.3-p0 bundle exec rspec ;; 1) rvm-exec 2.0.0-p0 bundle exec rspec ;; 2) rvm-exec 2.2.0 bundle exec rspec ;; 3) rvm-exec 2.1.0 bundle exec rspec ;; esac:
|
28
|
+
parallel: true
|
data/halo_stats.gemspec
CHANGED
@@ -21,7 +21,7 @@ Gem::Specification.new do |spec|
|
|
21
21
|
|
22
22
|
spec.add_development_dependency "bundler", "~> 1.6"
|
23
23
|
spec.add_development_dependency "rake"
|
24
|
-
spec.add_runtime_dependency "takeout", "~> 1.0.
|
24
|
+
spec.add_runtime_dependency "takeout", "~> 1.0.4"
|
25
25
|
spec.add_development_dependency "rspec"
|
26
26
|
spec.add_development_dependency "sinatra"
|
27
27
|
spec.add_development_dependency "webmock"
|
data/lib/halo_stats/stats.rb
CHANGED
@@ -2,8 +2,9 @@ module HaloStats
|
|
2
2
|
class Stats
|
3
3
|
require 'takeout'
|
4
4
|
attr_accessor :stats_client
|
5
|
-
|
6
5
|
|
6
|
+
GAME_TYPES = [:arena, :warzone, :campaign, :custom_game]
|
7
|
+
|
7
8
|
def initialize(options={})
|
8
9
|
title = 'h5'
|
9
10
|
key = options[:api_key]
|
@@ -11,7 +12,7 @@ module HaloStats
|
|
11
12
|
stats_schemas = { get: {
|
12
13
|
player_matches: "#{stats_prefix}/players/{{gamertag}}/matches",
|
13
14
|
arena_matches: "#{stats_prefix}/arena/matches/{{id}}",
|
14
|
-
|
15
|
+
campaign_matches: "#{stats_prefix}/campaign/matches/{{id}}",
|
15
16
|
warzone_matches: "#{stats_prefix}/warzone/matches/{{id}}",
|
16
17
|
custom_game_matches: "#{stats_prefix}/custom/matches/{{id}}",
|
17
18
|
arena_service_record: "#{stats_prefix}/servicerecords/arena",
|
@@ -23,6 +24,9 @@ module HaloStats
|
|
23
24
|
|
24
25
|
self.stats_client = Takeout::Client.new(uri: "www.haloapi.com", schemas: stats_schemas, headers: {'Ocp-Apim-Subscription-Key' => key}, ssl: true)
|
25
26
|
|
27
|
+
generate_carnage_report_methods
|
28
|
+
generate_service_record_methods
|
29
|
+
|
26
30
|
return self
|
27
31
|
end
|
28
32
|
|
@@ -30,36 +34,20 @@ module HaloStats
|
|
30
34
|
return stats_client.get_player_matches(gamertag: gamertag).body
|
31
35
|
end
|
32
36
|
|
33
|
-
def
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
end
|
40
|
-
|
41
|
-
def get_warzone_carnage_report(id)
|
42
|
-
return stats_client.get_warzone_matches(id: id).body
|
43
|
-
end
|
44
|
-
|
45
|
-
def custom_game_carnage_report(id)
|
46
|
-
return stats_client.get_custom_game_matches(id: id).body
|
47
|
-
end
|
48
|
-
|
49
|
-
def get_arena_service_record(gamertags)
|
50
|
-
return stats_client.get_arena_service_record(players: [gamertags].flatten(1).join(',')).body
|
51
|
-
end
|
52
|
-
|
53
|
-
def get_campaign_service_record(gamertags)
|
54
|
-
return stats_client.get_campaign_service_record(players: [gamertags].flatten(1).join(',')).body
|
55
|
-
end
|
56
|
-
|
57
|
-
def get_custom_game_service_record(gamertags)
|
58
|
-
return stats_client.get_custom_game_service_record(players: [gamertags].flatten(1).join(',')).body
|
37
|
+
def generate_carnage_report_methods
|
38
|
+
GAME_TYPES.each do |game_type|
|
39
|
+
self.define_singleton_method("get_#{game_type.to_s}_carnage_report") do |id, &block|
|
40
|
+
return stats_client.send("get_#{game_type.to_s}_matches".to_sym, {id: id}).body
|
41
|
+
end
|
42
|
+
end
|
59
43
|
end
|
60
44
|
|
61
|
-
def
|
62
|
-
|
45
|
+
def generate_service_record_methods
|
46
|
+
GAME_TYPES.each do |game_type|
|
47
|
+
self.define_singleton_method("get_#{game_type.to_s}_service_record") do |gamertags, &block|
|
48
|
+
return stats_client.send("get_#{game_type.to_s}_service_record".to_sym, {players: [gamertags].flatten(1).join(',')}).body
|
49
|
+
end
|
50
|
+
end
|
63
51
|
end
|
64
52
|
end
|
65
53
|
end
|
data/lib/halo_stats/version.rb
CHANGED
data/spec/.DS_Store
ADDED
Binary file
|
@@ -0,0 +1,91 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe HaloStats::Metadata do
|
4
|
+
let (:metadata_client) {HaloStats::Metadata.new(api_key: 'fakekey')}
|
5
|
+
|
6
|
+
context 'get' do
|
7
|
+
it 'returns a hash for get_campaign_missions' do
|
8
|
+
expect(metadata_client.get_campaign_missions).to be_a(Array)
|
9
|
+
end
|
10
|
+
|
11
|
+
it 'returns a hash for get_commendations' do
|
12
|
+
expect(metadata_client.get_commendations).to be_a(Array)
|
13
|
+
end
|
14
|
+
|
15
|
+
it 'returns a hash for get_csr_designations' do
|
16
|
+
expect(metadata_client.get_csr_designations).to be_a(Array)
|
17
|
+
end
|
18
|
+
|
19
|
+
it 'returns a hash for get_enemies' do
|
20
|
+
expect(metadata_client.get_enemies).to be_a(Array)
|
21
|
+
end
|
22
|
+
|
23
|
+
it 'returns a hash for get_flexible_stats' do
|
24
|
+
expect(metadata_client.get_flexible_stats).to be_a(Array)
|
25
|
+
end
|
26
|
+
|
27
|
+
it 'returns a hash for get_game_base_variants' do
|
28
|
+
expect(metadata_client.get_game_base_variants).to be_a(Array)
|
29
|
+
end
|
30
|
+
|
31
|
+
it 'returns a hash for get_game_variants' do
|
32
|
+
expect(metadata_client.get_game_variants(1)).to be_a(Array)
|
33
|
+
end
|
34
|
+
|
35
|
+
it 'returns a hash for get_impulses' do
|
36
|
+
expect(metadata_client.get_impulses).to be_a(Array)
|
37
|
+
end
|
38
|
+
|
39
|
+
it 'returns a hash for get_map_variants' do
|
40
|
+
expect(metadata_client.get_map_variants(1)).to be_a(Array)
|
41
|
+
end
|
42
|
+
|
43
|
+
it 'returns a hash for get_maps' do
|
44
|
+
expect(metadata_client.get_maps).to be_a(Array)
|
45
|
+
end
|
46
|
+
|
47
|
+
it 'returns a hash for get_medals' do
|
48
|
+
expect(metadata_client.get_medals).to be_a(Array)
|
49
|
+
end
|
50
|
+
|
51
|
+
it 'returns a hash for get_playlists' do
|
52
|
+
expect(metadata_client.get_playlists).to be_a(Array)
|
53
|
+
end
|
54
|
+
|
55
|
+
it 'returns a hash for get_requisition_packs' do
|
56
|
+
expect(metadata_client.get_requisition_packs(1)).to be_a(Array)
|
57
|
+
end
|
58
|
+
|
59
|
+
it 'returns a hash for get_requisitions' do
|
60
|
+
expect(metadata_client.get_requisitions(1)).to be_a(Array)
|
61
|
+
end
|
62
|
+
|
63
|
+
it 'returns a hash for get_seasons' do
|
64
|
+
expect(metadata_client.get_seasons).to be_a(Array)
|
65
|
+
end
|
66
|
+
|
67
|
+
it 'returns a hash for get_skulls' do
|
68
|
+
expect(metadata_client.get_skulls).to be_a(Array)
|
69
|
+
end
|
70
|
+
|
71
|
+
it 'returns a hash for get_spartan_ranks' do
|
72
|
+
expect(metadata_client.get_spartan_ranks).to be_a(Array)
|
73
|
+
end
|
74
|
+
|
75
|
+
it 'returns a hash for get_team_colors' do
|
76
|
+
expect(metadata_client.get_team_colors).to be_a(Array)
|
77
|
+
end
|
78
|
+
|
79
|
+
it 'returns a hash for get_vehicles' do
|
80
|
+
expect(metadata_client.get_vehicles).to be_a(Array)
|
81
|
+
end
|
82
|
+
|
83
|
+
it 'returns a hash for get_weapons' do
|
84
|
+
expect(metadata_client.get_weapons).to be_a(Array)
|
85
|
+
end
|
86
|
+
|
87
|
+
it 'returns a hash for get_weapons' do
|
88
|
+
expect(metadata_client.get_weapons).to be_a(Array)
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe HaloStats::Profile do
|
4
|
+
let (:profile_client) {HaloStats::Profile.new(api_key: 'fakekey')}
|
5
|
+
|
6
|
+
context 'get' do
|
7
|
+
it 'returns a string for get_emblem' do
|
8
|
+
expect(profile_client.get_emblem('faketag')).to be_an(String)
|
9
|
+
end
|
10
|
+
|
11
|
+
it 'returns a string for get_spartan_image' do
|
12
|
+
expect(profile_client.get_spartan_image('faketag')).to be_an(String)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,104 @@
|
|
1
|
+
require "codeclimate-test-reporter"
|
2
|
+
CodeClimate::TestReporter.start
|
3
|
+
require 'bundler/setup'
|
4
|
+
Bundler.setup
|
5
|
+
require 'halo_stats'
|
6
|
+
require 'webmock/rspec'
|
7
|
+
WebMock.disable_net_connect!(:allow => "codeclimate.com")
|
8
|
+
|
9
|
+
Dir["./spec/support/**/*.rb"].sort.each { |f| require f}
|
10
|
+
# This file was generated by the `rspec --init` command. Conventionally, all
|
11
|
+
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
|
12
|
+
# The generated `.rspec` file contains `--require spec_helper` which will cause
|
13
|
+
# this file to always be loaded, without a need to explicitly require it in any
|
14
|
+
# files.
|
15
|
+
#
|
16
|
+
# Given that it is always loaded, you are encouraged to keep this file as
|
17
|
+
# light-weight as possible. Requiring heavyweight dependencies from this file
|
18
|
+
# will add to the boot time of your test suite on EVERY test run, even for an
|
19
|
+
# individual file that may not need all of that loaded. Instead, consider making
|
20
|
+
# a separate helper file that requires the additional dependencies and performs
|
21
|
+
# the additional setup, and require it from the spec files that actually need
|
22
|
+
# it.
|
23
|
+
#
|
24
|
+
# The `.rspec` file also contains a few flags that are not defaults but that
|
25
|
+
# users commonly want.
|
26
|
+
#
|
27
|
+
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
|
28
|
+
RSpec.configure do |config|
|
29
|
+
# rspec-expectations config goes here. You can use an alternate
|
30
|
+
# assertion/expectation library such as wrong or the stdlib/minitest
|
31
|
+
# assertions if you prefer.
|
32
|
+
config.expect_with :rspec do |expectations|
|
33
|
+
# This option will default to `true` in RSpec 4. It makes the `description`
|
34
|
+
# and `failure_message` of custom matchers include text for helper methods
|
35
|
+
# defined using `chain`, e.g.:
|
36
|
+
# be_bigger_than(2).and_smaller_than(4).description
|
37
|
+
# # => "be bigger than 2 and smaller than 4"
|
38
|
+
# ...rather than:
|
39
|
+
# # => "be bigger than 2"
|
40
|
+
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
|
41
|
+
end
|
42
|
+
|
43
|
+
# rspec-mocks config goes here. You can use an alternate test double
|
44
|
+
# library (such as bogus or mocha) by changing the `mock_with` option here.
|
45
|
+
config.mock_with :rspec do |mocks|
|
46
|
+
# Prevents you from mocking or stubbing a method that does not exist on
|
47
|
+
# a real object. This is generally recommended, and will default to
|
48
|
+
# `true` in RSpec 4.
|
49
|
+
mocks.verify_partial_doubles = true
|
50
|
+
end
|
51
|
+
|
52
|
+
# The settings below are suggested to provide a good initial experience
|
53
|
+
# with RSpec, but feel free to customize to your heart's content.
|
54
|
+
=begin
|
55
|
+
# These two settings work together to allow you to limit a spec run
|
56
|
+
# to individual examples or groups you care about by tagging them with
|
57
|
+
# `:focus` metadata. When nothing is tagged with `:focus`, all examples
|
58
|
+
# get run.
|
59
|
+
config.filter_run :focus
|
60
|
+
config.run_all_when_everything_filtered = true
|
61
|
+
|
62
|
+
# Limits the available syntax to the non-monkey patched syntax that is
|
63
|
+
# recommended. For more details, see:
|
64
|
+
# - http://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-syntax
|
65
|
+
# - http://teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
|
66
|
+
# - http://myronmars.to/n/dev-blog/2014/05/notable-changes-in-rspec-3#new__config_option_to_disable_rspeccore_monkey_patching
|
67
|
+
config.disable_monkey_patching!
|
68
|
+
|
69
|
+
# This setting enables warnings. It's recommended, but in some cases may
|
70
|
+
# be too noisy due to issues in dependencies.
|
71
|
+
config.warnings = true
|
72
|
+
|
73
|
+
# Many RSpec users commonly either run the entire suite or an individual
|
74
|
+
# file, and it's useful to allow more verbose output when running an
|
75
|
+
# individual spec file.
|
76
|
+
if config.files_to_run.one?
|
77
|
+
# Use the documentation formatter for detailed output,
|
78
|
+
# unless a formatter has already been configured
|
79
|
+
# (e.g. via a command-line flag).
|
80
|
+
config.default_formatter = 'doc'
|
81
|
+
end
|
82
|
+
|
83
|
+
# Print the 10 slowest examples and example groups at the
|
84
|
+
# end of the spec run, to help surface which specs are running
|
85
|
+
# particularly slow.
|
86
|
+
config.profile_examples = 10
|
87
|
+
|
88
|
+
# Run specs in random order to surface order dependencies. If you find an
|
89
|
+
# order dependency and want to debug it, you can fix the order by providing
|
90
|
+
# the seed, which is printed after each run.
|
91
|
+
# --seed 1234
|
92
|
+
config.order = :random
|
93
|
+
|
94
|
+
# Seed global randomization in this process using the `--seed` CLI option.
|
95
|
+
# Setting this allows you to use `--seed` to deterministically reproduce
|
96
|
+
# test failures related to randomization by passing the same `--seed` value
|
97
|
+
# as the one that triggered the failure.
|
98
|
+
Kernel.srand config.seed
|
99
|
+
=end
|
100
|
+
|
101
|
+
config.before(:each) do
|
102
|
+
stub_request(:any, /haloapi.com/).to_rack(FakeTestApi)
|
103
|
+
end
|
104
|
+
end
|
data/spec/stats_spec.rb
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe HaloStats::Stats do
|
4
|
+
let (:stats_client) {HaloStats::Stats.new(api_key: 'fakekey')}
|
5
|
+
|
6
|
+
context 'get' do
|
7
|
+
it 'returns a hash for get_matches' do
|
8
|
+
expect(stats_client.get_matches('faketag')).to be_an(Hash)
|
9
|
+
end
|
10
|
+
|
11
|
+
it 'returns a hash for get_arena_carnage_report' do
|
12
|
+
expect(stats_client.get_arena_carnage_report(1)).to be_an(Hash)
|
13
|
+
end
|
14
|
+
|
15
|
+
it 'returns a hash for get_campaign_carnage_report' do
|
16
|
+
expect(stats_client.get_campaign_carnage_report(1)).to be_an(Hash)
|
17
|
+
end
|
18
|
+
|
19
|
+
it 'returns a hash for get_warzone_carnage_report' do
|
20
|
+
expect(stats_client.get_warzone_carnage_report(1)).to be_an(Hash)
|
21
|
+
end
|
22
|
+
|
23
|
+
it 'returns a hash for get_custom_game_carnage_report' do
|
24
|
+
expect(stats_client.get_custom_game_carnage_report(1)).to be_an(Hash)
|
25
|
+
end
|
26
|
+
|
27
|
+
it 'returns a hash for get_arena_service_record' do
|
28
|
+
expect(stats_client.get_arena_service_record('faketag')).to be_an(Hash)
|
29
|
+
end
|
30
|
+
|
31
|
+
it 'returns a hash for get_warzone_service_record' do
|
32
|
+
expect(stats_client.get_warzone_service_record('faketag')).to be_an(Hash)
|
33
|
+
end
|
34
|
+
|
35
|
+
it 'returns a hash for get_campaign_service_record' do
|
36
|
+
expect(stats_client.get_campaign_service_record('faketag')).to be_an(Hash)
|
37
|
+
end
|
38
|
+
|
39
|
+
it 'returns a hash for get_custom_game_service_record' do
|
40
|
+
expect(stats_client.get_custom_game_service_record('faketag')).to be_an(Hash)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
Binary file
|
@@ -0,0 +1,56 @@
|
|
1
|
+
require 'sinatra/base'
|
2
|
+
|
3
|
+
class FakeTestApi < Sinatra::Base
|
4
|
+
REQUEST_TYPES = [:get]
|
5
|
+
#
|
6
|
+
# /stats endpoints
|
7
|
+
#
|
8
|
+
get('/stats/h5/players/faketag/matches') {json_response 200, 'matches.json'}
|
9
|
+
get('/stats/h5/arena/matches/1') {json_response 200, 'matches.json'}
|
10
|
+
get('/stats/h5/campaign/matches/1') {json_response 200, 'matches.json'}
|
11
|
+
get('/stats/h5/custom/matches/1') {json_response 200, 'matches.json'}
|
12
|
+
get('/stats/h5/warzone/matches/1') {json_response 200, 'matches.json'}
|
13
|
+
get('/stats/h5/arena/matches/1') {json_response 200, 'matches.json'}
|
14
|
+
get('/stats/h5/servicerecords/arena') {json_response 200, 'matches.json'}
|
15
|
+
get('/stats/h5/servicerecords/custom') {json_response 200, 'matches.json'}
|
16
|
+
get('/stats/h5/servicerecords/campaign') {json_response 200, 'matches.json'}
|
17
|
+
get('/stats/h5/servicerecords/warzone') {json_response 200, 'matches.json'}
|
18
|
+
|
19
|
+
#
|
20
|
+
# /profile endpoints
|
21
|
+
#
|
22
|
+
get('/profile/h5/profiles/faketag/emblem') {json_response 302, 'posts.json'}
|
23
|
+
get('/profile/h5/profiles/faketag/spartan') {json_response 302, 'posts.json'}
|
24
|
+
|
25
|
+
#
|
26
|
+
# /metadata endpoints
|
27
|
+
#
|
28
|
+
get('/metadata/h5/metadata/campaign-missions') {json_response 200, 'posts.json'}
|
29
|
+
get('/metadata/h5/metadata/commendations') {json_response 200, 'posts.json'}
|
30
|
+
get('/metadata/h5/metadata/csr-designations') {json_response 200, 'posts.json'}
|
31
|
+
get('/metadata/h5/metadata/enemies') {json_response 200, 'posts.json'}
|
32
|
+
get('/metadata/h5/metadata/flexible-stats') {json_response 200, 'posts.json'}
|
33
|
+
get('/metadata/h5/metadata/game-base-variants') {json_response 200, 'posts.json'}
|
34
|
+
get('/metadata/h5/metadata/game-variants/1') {json_response 200, 'posts.json'}
|
35
|
+
get('/metadata/h5/metadata/impulses') {json_response 200, 'posts.json'}
|
36
|
+
get('/metadata/h5/metadata/map-variants/1') {json_response 200, 'posts.json'}
|
37
|
+
get('/metadata/h5/metadata/maps') {json_response 200, 'posts.json'}
|
38
|
+
get('/metadata/h5/metadata/medals') {json_response 200, 'posts.json'}
|
39
|
+
get('/metadata/h5/metadata/playlists') {json_response 200, 'posts.json'}
|
40
|
+
get('/metadata/h5/metadata/requisition-packs/1') {json_response 200, 'posts.json'}
|
41
|
+
get('/metadata/h5/metadata/requisitions/1') {json_response 200, 'posts.json'}
|
42
|
+
get('/metadata/h5/metadata/seasons') {json_response 200, 'posts.json'}
|
43
|
+
get('/metadata/h5/metadata/skulls') {json_response 200, 'posts.json'}
|
44
|
+
get('/metadata/h5/metadata/spartan-ranks') {json_response 200, 'posts.json'}
|
45
|
+
get('/metadata/h5/metadata/team-colors') {json_response 200, 'posts.json'}
|
46
|
+
get('/metadata/h5/metadata/vehicles') {json_response 200, 'posts.json'}
|
47
|
+
get('/metadata/h5/metadata/weapons') {json_response 200, 'posts.json'}
|
48
|
+
|
49
|
+
private
|
50
|
+
|
51
|
+
def json_response(response_code, file_name)
|
52
|
+
content_type :json
|
53
|
+
status response_code
|
54
|
+
File.open(File.dirname(__FILE__) + '/fixtures/' + file_name, 'rb').read if file_name
|
55
|
+
end
|
56
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: halo_stats
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kyle Lucas
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-02-
|
11
|
+
date: 2016-02-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -44,14 +44,14 @@ dependencies:
|
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: 1.0.
|
47
|
+
version: 1.0.4
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: 1.0.
|
54
|
+
version: 1.0.4
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: rspec
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -118,14 +118,24 @@ files:
|
|
118
118
|
- ".gitignore"
|
119
119
|
- Gemfile
|
120
120
|
- Guardfile
|
121
|
-
- README
|
121
|
+
- README.md
|
122
122
|
- Rakefile
|
123
|
+
- circle.yml
|
123
124
|
- halo_stats.gemspec
|
124
125
|
- lib/halo_stats.rb
|
125
126
|
- lib/halo_stats/metadata.rb
|
126
127
|
- lib/halo_stats/profile.rb
|
127
128
|
- lib/halo_stats/stats.rb
|
128
129
|
- lib/halo_stats/version.rb
|
130
|
+
- spec/.DS_Store
|
131
|
+
- spec/metadata_spec.rb
|
132
|
+
- spec/profile_spec.rb
|
133
|
+
- spec/spec_helper.rb
|
134
|
+
- spec/stats_spec.rb
|
135
|
+
- spec/support/.DS_Store
|
136
|
+
- spec/support/fake_test_api.rb
|
137
|
+
- spec/support/fixtures/matches.json
|
138
|
+
- spec/support/fixtures/posts.json
|
129
139
|
homepage: http://github.com/kylegrantlucas/halo_stats
|
130
140
|
licenses:
|
131
141
|
- MIT
|
@@ -150,5 +160,14 @@ rubygems_version: 2.2.2
|
|
150
160
|
signing_key:
|
151
161
|
specification_version: 4
|
152
162
|
summary: A stats gem for Halo 5.
|
153
|
-
test_files:
|
163
|
+
test_files:
|
164
|
+
- spec/.DS_Store
|
165
|
+
- spec/metadata_spec.rb
|
166
|
+
- spec/profile_spec.rb
|
167
|
+
- spec/spec_helper.rb
|
168
|
+
- spec/stats_spec.rb
|
169
|
+
- spec/support/.DS_Store
|
170
|
+
- spec/support/fake_test_api.rb
|
171
|
+
- spec/support/fixtures/matches.json
|
172
|
+
- spec/support/fixtures/posts.json
|
154
173
|
has_rdoc:
|
data/README
DELETED
File without changes
|