gamelocker_api 0.1.1 → 0.1.2
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/README.md +6 -0
 - data/lib/gamelocker_api/abstract_parser.rb +3 -0
 - data/lib/gamelocker_api/match.rb +1 -1
 - data/lib/gamelocker_api/telemetry.rb +17 -0
 - data/lib/gamelocker_api/version.rb +1 -1
 - data/lib/gamelocker_api.rb +6 -3
 - metadata +3 -2
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA1:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: 418b843e6557d9e7fd0b973050fa2c03b064f53a
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: b8634c8c6add7675aacb95fb210b0439e4a5d05b
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: d7a596d17608a48881db6fdeac5e236825b49f032e985c1fad1b8d002bf834aa75463827e9f2c8ada6bbbe72f4b956181dfcb6d136a08ae8c6e31eb5b8fcf576
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: d7ef28ffd8772cdf118cbe8c9bf2d7e03cebf6fda1890424087031e62ae980cd56db39901437edf5627b4cdd6ba09b1dba17797d3ed76502ce94ca92d136e439
         
     | 
    
        data/README.md
    CHANGED
    
    | 
         @@ -21,6 +21,12 @@ Or install it yourself as: 
     | 
|
| 
       21 
21 
     | 
    
         
             
            ## Usage
         
     | 
| 
       22 
22 
     | 
    
         | 
| 
       23 
23 
     | 
    
         
             
            TODO: Write usage instructions here
         
     | 
| 
      
 24 
     | 
    
         
            +
            ```ruby
         
     | 
| 
      
 25 
     | 
    
         
            +
              # Api Key and Region
         
     | 
| 
      
 26 
     | 
    
         
            +
              api = GameLockerAPI.new("API_KEY", "na")
         
     | 
| 
      
 27 
     | 
    
         
            +
              response = api.players("Cyberarm")
         
     | 
| 
      
 28 
     | 
    
         
            +
              p response # => GameLockerAPI::Player
         
     | 
| 
      
 29 
     | 
    
         
            +
            ```
         
     | 
| 
       24 
30 
     | 
    
         | 
| 
       25 
31 
     | 
    
         
             
            ## Development
         
     | 
| 
       26 
32 
     | 
    
         
             
            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).
         
     | 
| 
         @@ -30,12 +30,14 @@ class GameLockerAPI 
     | 
|
| 
       30 
30 
     | 
    
         
             
                      temp_match.duration = match['attributes']['duration']
         
     | 
| 
       31 
31 
     | 
    
         
             
                      temp_match.gamemode = match['attributes']['gameMode']
         
     | 
| 
       32 
32 
     | 
    
         
             
                      temp_match.end_game_reason = match['attributes']['stats']['endGameReason']
         
     | 
| 
      
 33 
     | 
    
         
            +
                      temp_match.telemetry_url = nil
         
     | 
| 
       33 
34 
     | 
    
         
             
                      temp_match.rosters = []
         
     | 
| 
       34 
35 
     | 
    
         
             
                      temp_match.red_team = []
         
     | 
| 
       35 
36 
     | 
    
         
             
                      temp_match.blue_team= []
         
     | 
| 
       36 
37 
     | 
    
         
             
                      temp_match.players = []
         
     | 
| 
       37 
38 
     | 
    
         
             
                      temp_match.participants = []
         
     | 
| 
       38 
39 
     | 
    
         
             
                      data['included'].each do |wanted|
         
     | 
| 
      
 40 
     | 
    
         
            +
                        temp_match.telemetry_url = wanted['attributes']['URL'] if wanted['type'] == "asset" && match['relationships']['assets']['data'].first['id'] == wanted['id']
         
     | 
| 
       39 
41 
     | 
    
         
             
                        thing = nil
         
     | 
| 
       40 
42 
     | 
    
         
             
                        if wanted['id'] == match['relationships']['rosters']['data'][0]['id']
         
     | 
| 
       41 
43 
     | 
    
         
             
                          thing = match['relationships']['rosters']['data'][0]['id']
         
     | 
| 
         @@ -63,6 +65,7 @@ class GameLockerAPI 
     | 
|
| 
       63 
65 
     | 
    
         
             
                    temp_match.players = []
         
     | 
| 
       64 
66 
     | 
    
         
             
                    temp_match.participants = []
         
     | 
| 
       65 
67 
     | 
    
         
             
                    data['included'].each do |wanted|
         
     | 
| 
      
 68 
     | 
    
         
            +
                      temp_match.telemetry_url = wanted['attributes']['URL'] if wanted['type'] == "asset" && match['relationships']['assets']['data'].first['id'] == wanted['id']
         
     | 
| 
       66 
69 
     | 
    
         
             
                      thing = nil
         
     | 
| 
       67 
70 
     | 
    
         
             
                      if wanted['id'] == match['relationships']['rosters']['data'][0]['id']
         
     | 
| 
       68 
71 
     | 
    
         
             
                        thing = match['relationships']['rosters']['data'][0]['id']
         
     | 
    
        data/lib/gamelocker_api/match.rb
    CHANGED
    
    | 
         @@ -1,6 +1,6 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            class GameLockerAPI
         
     | 
| 
       2 
2 
     | 
    
         
             
              class Match
         
     | 
| 
       3 
3 
     | 
    
         
             
                attr_accessor :uuid, :shard_id, :blue_team, :red_team, :rosters, :participants, :players
         
     | 
| 
       4 
     | 
    
         
            -
                attr_accessor :created_at, :duration, :gamemode, :end_game_reason
         
     | 
| 
      
 4 
     | 
    
         
            +
                attr_accessor :created_at, :duration, :gamemode, :end_game_reason, :telemetry_url
         
     | 
| 
       5 
5 
     | 
    
         
             
              end
         
     | 
| 
       6 
6 
     | 
    
         
             
            end
         
     | 
| 
         @@ -0,0 +1,17 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            class GameLockerAPI
         
     | 
| 
      
 2 
     | 
    
         
            +
              class Telemetry
         
     | 
| 
      
 3 
     | 
    
         
            +
                attr_accessor :events
         
     | 
| 
      
 4 
     | 
    
         
            +
                Event = Struct.new(:time, :type, :payload)
         
     | 
| 
      
 5 
     | 
    
         
            +
                def initialize(telemetry_url)
         
     | 
| 
      
 6 
     | 
    
         
            +
                  @events  = []
         
     | 
| 
      
 7 
     | 
    
         
            +
                  response = RestClient.get(telemetry_url)
         
     | 
| 
      
 8 
     | 
    
         
            +
                  parse(response.body)
         
     | 
| 
      
 9 
     | 
    
         
            +
                end
         
     | 
| 
      
 10 
     | 
    
         
            +
             
     | 
| 
      
 11 
     | 
    
         
            +
                def parse(json)
         
     | 
| 
      
 12 
     | 
    
         
            +
                  Oj.load(json).each do |event|
         
     | 
| 
      
 13 
     | 
    
         
            +
                    @events << Event.new(event['time'], event['type'], event['payload'])
         
     | 
| 
      
 14 
     | 
    
         
            +
                  end
         
     | 
| 
      
 15 
     | 
    
         
            +
                end
         
     | 
| 
      
 16 
     | 
    
         
            +
              end
         
     | 
| 
      
 17 
     | 
    
         
            +
            end
         
     | 
    
        data/lib/gamelocker_api.rb
    CHANGED
    
    | 
         @@ -2,6 +2,7 @@ require "rest-client" 
     | 
|
| 
       2 
2 
     | 
    
         
             
            require "oj"
         
     | 
| 
       3 
3 
     | 
    
         
             
            require_relative "gamelocker_api/abstract_parser"
         
     | 
| 
       4 
4 
     | 
    
         
             
            require_relative "gamelocker_api/match"
         
     | 
| 
      
 5 
     | 
    
         
            +
            require_relative "gamelocker_api/telemetry"
         
     | 
| 
       5 
6 
     | 
    
         
             
            require_relative "gamelocker_api/player"
         
     | 
| 
       6 
7 
     | 
    
         
             
            require_relative "gamelocker_api/roster"
         
     | 
| 
       7 
8 
     | 
    
         
             
            require_relative "gamelocker_api/participant"
         
     | 
| 
         @@ -36,6 +37,10 @@ class GameLockerAPI 
     | 
|
| 
       36 
37 
     | 
    
         
             
                request("matches", match_params)
         
     | 
| 
       37 
38 
     | 
    
         
             
              end
         
     | 
| 
       38 
39 
     | 
    
         | 
| 
      
 40 
     | 
    
         
            +
              # def samples(samples_params = {})
         
     | 
| 
      
 41 
     | 
    
         
            +
              #   request("samples", samples_params)
         
     | 
| 
      
 42 
     | 
    
         
            +
              # end
         
     | 
| 
      
 43 
     | 
    
         
            +
             
     | 
| 
       39 
44 
     | 
    
         
             
              private
         
     | 
| 
       40 
45 
     | 
    
         
             
              def request(end_point, params = nil)
         
     | 
| 
       41 
46 
     | 
    
         
             
                api_headers = {
         
     | 
| 
         @@ -52,10 +57,8 @@ class GameLockerAPI 
     | 
|
| 
       52 
57 
     | 
    
         
             
                    response = RestClient.get(@base_url+@region+"/"+end_point, api_headers)
         
     | 
| 
       53 
58 
     | 
    
         
             
                  end
         
     | 
| 
       54 
59 
     | 
    
         
             
                  @headers = response.headers
         
     | 
| 
       55 
     | 
    
         
            -
                  open(Dir.pwd+"/response.dat", "w") do |file|
         
     | 
| 
       56 
     | 
    
         
            -
                    file.write(Oj.load(response.body))
         
     | 
| 
       57 
     | 
    
         
            -
                  end
         
     | 
| 
       58 
60 
     | 
    
         
             
                  parser(response, end_point)
         
     | 
| 
      
 61 
     | 
    
         
            +
             
     | 
| 
       59 
62 
     | 
    
         
             
                rescue RestClient::ExceptionWithResponse => e
         
     | 
| 
       60 
63 
     | 
    
         
             
                  response = VirtualResponse.new(e.response, e.response)
         
     | 
| 
       61 
64 
     | 
    
         
             
                  @headers = e.response.headers
         
     | 
    
        metadata
    CHANGED
    
    | 
         @@ -1,14 +1,14 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: gamelocker_api
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version
         
     | 
| 
       4 
     | 
    
         
            -
              version: 0.1. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 0.1.2
         
     | 
| 
       5 
5 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       6 
6 
     | 
    
         
             
            authors:
         
     | 
| 
       7 
7 
     | 
    
         
             
            - Cyberarm
         
     | 
| 
       8 
8 
     | 
    
         
             
            autorequire: 
         
     | 
| 
       9 
9 
     | 
    
         
             
            bindir: bin
         
     | 
| 
       10 
10 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       11 
     | 
    
         
            -
            date: 2017-04- 
     | 
| 
      
 11 
     | 
    
         
            +
            date: 2017-04-20 00:00:00.000000000 Z
         
     | 
| 
       12 
12 
     | 
    
         
             
            dependencies:
         
     | 
| 
       13 
13 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       14 
14 
     | 
    
         
             
              name: rest-client
         
     | 
| 
         @@ -100,6 +100,7 @@ files: 
     | 
|
| 
       100 
100 
     | 
    
         
             
            - lib/gamelocker_api/participant.rb
         
     | 
| 
       101 
101 
     | 
    
         
             
            - lib/gamelocker_api/player.rb
         
     | 
| 
       102 
102 
     | 
    
         
             
            - lib/gamelocker_api/roster.rb
         
     | 
| 
      
 103 
     | 
    
         
            +
            - lib/gamelocker_api/telemetry.rb
         
     | 
| 
       103 
104 
     | 
    
         
             
            - lib/gamelocker_api/version.rb
         
     | 
| 
       104 
105 
     | 
    
         
             
            homepage: https://github.com/cyberarm/gamelocker_api
         
     | 
| 
       105 
106 
     | 
    
         
             
            licenses:
         
     |