johki 0.1.8
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 +13 -0
- data/.travis.yml +6 -0
- data/CHANGELOG.md +1 -0
- data/Gemfile +8 -0
- data/Gemfile.lock +40 -0
- data/LICENSE.txt +21 -0
- data/README.md +42 -0
- data/Rakefile +10 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/johki.gemspec +26 -0
- data/lib/johki.rb +3 -0
- data/lib/johki/client.rb +45 -0
- data/lib/johki/dota2_match.rb +25 -0
- data/lib/johki/econ_dota2.rb +20 -0
- data/lib/johki/error.rb +7 -0
- data/lib/johki/id.rb +18 -0
- data/lib/johki/interface.rb +13 -0
- data/lib/johki/steam_user.rb +15 -0
- data/lib/johki/version.rb +3 -0
- metadata +65 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 3a7953e57ce2f6e74c14c03b0aa5a8d760ab05ada3325c684c0b290e5d30b4c7
|
|
4
|
+
data.tar.gz: 0b20d02e8ea74de0341c9817ede206f1177494699d0f3d022814701b75e6a2d0
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: e1c4cb6e9aaac94ef3a0b4d913faa3a9a8d5214e8a905c0349c52b0dd6fada7563a8dc82529ccf5169e9a9dadb2e74444ace8793458a0895cf6cec0918d32400
|
|
7
|
+
data.tar.gz: 1815b400d67235667ec39d5a3fe42268cda88fc53b6145f6434a29ed71f90e33f0445ee4162cc534f6255566dedde3fcde4fff1c64cd45a6a63ef2eac077564e
|
data/.gitignore
ADDED
data/.travis.yml
ADDED
data/CHANGELOG.md
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# Change Log
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
PATH
|
|
2
|
+
remote: .
|
|
3
|
+
specs:
|
|
4
|
+
johki (0.1.0)
|
|
5
|
+
|
|
6
|
+
GEM
|
|
7
|
+
remote: https://rubygems.org/
|
|
8
|
+
specs:
|
|
9
|
+
coderay (1.1.2)
|
|
10
|
+
diff-lcs (1.3)
|
|
11
|
+
method_source (0.9.2)
|
|
12
|
+
pry (0.12.2)
|
|
13
|
+
coderay (~> 1.1.0)
|
|
14
|
+
method_source (~> 0.9.0)
|
|
15
|
+
rake (12.3.3)
|
|
16
|
+
rspec (3.9.0)
|
|
17
|
+
rspec-core (~> 3.9.0)
|
|
18
|
+
rspec-expectations (~> 3.9.0)
|
|
19
|
+
rspec-mocks (~> 3.9.0)
|
|
20
|
+
rspec-core (3.9.1)
|
|
21
|
+
rspec-support (~> 3.9.1)
|
|
22
|
+
rspec-expectations (3.9.0)
|
|
23
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
|
24
|
+
rspec-support (~> 3.9.0)
|
|
25
|
+
rspec-mocks (3.9.1)
|
|
26
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
|
27
|
+
rspec-support (~> 3.9.0)
|
|
28
|
+
rspec-support (3.9.2)
|
|
29
|
+
|
|
30
|
+
PLATFORMS
|
|
31
|
+
ruby
|
|
32
|
+
|
|
33
|
+
DEPENDENCIES
|
|
34
|
+
johki!
|
|
35
|
+
pry (~> 0.12.2)
|
|
36
|
+
rake (~> 12.0)
|
|
37
|
+
rspec (~> 3.0)
|
|
38
|
+
|
|
39
|
+
BUNDLED WITH
|
|
40
|
+
2.1.4
|
data/LICENSE.txt
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2020 aoisensi
|
|
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,42 @@
|
|
|
1
|
+
# Johki
|
|
2
|
+
|
|
3
|
+
This is simple Steam Web API Library for Ruby.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
Add this line to your application's Gemfile:
|
|
8
|
+
|
|
9
|
+
```ruby
|
|
10
|
+
gem 'johki'
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
And then execute:
|
|
14
|
+
|
|
15
|
+
$ bundle install
|
|
16
|
+
|
|
17
|
+
Or install it yourself as:
|
|
18
|
+
|
|
19
|
+
$ gem install johki
|
|
20
|
+
|
|
21
|
+
## Usage
|
|
22
|
+
|
|
23
|
+
```ruby
|
|
24
|
+
require "johki"
|
|
25
|
+
|
|
26
|
+
client = Johki::Client.new(ENV["STEAM_API_KEY"])
|
|
27
|
+
|
|
28
|
+
summaries = client.steam_user.get_player_summaries(steamids: 76561198049739081)
|
|
29
|
+
|
|
30
|
+
puts summaries[:response][:players][0][:personaname] # aoisensi
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## Development
|
|
34
|
+
|
|
35
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
|
36
|
+
|
|
37
|
+
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).
|
|
38
|
+
|
|
39
|
+
## Contributing
|
|
40
|
+
|
|
41
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/johki.
|
|
42
|
+
|
data/Rakefile
ADDED
data/bin/console
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
|
|
3
|
+
require "bundler/setup"
|
|
4
|
+
require "johki"
|
|
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(__FILE__)
|
data/bin/setup
ADDED
data/johki.gemspec
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
require_relative 'lib/johki/version'
|
|
2
|
+
|
|
3
|
+
Gem::Specification.new do |spec|
|
|
4
|
+
spec.name = "johki"
|
|
5
|
+
spec.version = Johki::VERSION
|
|
6
|
+
spec.authors = ["aoisensi"]
|
|
7
|
+
spec.email = ["aoisensi@outlook.jp"]
|
|
8
|
+
|
|
9
|
+
spec.summary = %q{Simple Steam Web API Library.}
|
|
10
|
+
spec.description = %q{Simple Steam Web API Library.}
|
|
11
|
+
spec.homepage = "https://github.com/aoisensi/johki"
|
|
12
|
+
spec.required_ruby_version = Gem::Requirement.new(">= 2.3.0")
|
|
13
|
+
|
|
14
|
+
spec.metadata["homepage_uri"] = spec.homepage
|
|
15
|
+
spec.metadata["source_code_uri"] = "https://github.com/aoisensi/johki"
|
|
16
|
+
spec.metadata["changelog_uri"] = "https://github.com/aoisensi/johki/blob/master/CHANGELOG.md"
|
|
17
|
+
|
|
18
|
+
# Specify which files should be added to the gem when it is released.
|
|
19
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
|
20
|
+
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
|
21
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
|
22
|
+
end
|
|
23
|
+
spec.bindir = "exe"
|
|
24
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
|
25
|
+
spec.require_paths = ["lib"]
|
|
26
|
+
end
|
data/lib/johki.rb
ADDED
data/lib/johki/client.rb
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
require "net/http"
|
|
2
|
+
require "uri"
|
|
3
|
+
require "json"
|
|
4
|
+
|
|
5
|
+
require "johki/dota2_match"
|
|
6
|
+
require "johki/econ_dota2"
|
|
7
|
+
require "johki/steam_user"
|
|
8
|
+
require "johki/error"
|
|
9
|
+
|
|
10
|
+
module Johki
|
|
11
|
+
class Client
|
|
12
|
+
ROOT_URL = "https://api.steampowered.com/"
|
|
13
|
+
|
|
14
|
+
def initialize(token)
|
|
15
|
+
@token = token
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def get(path, params = {})
|
|
19
|
+
params[:key] = @token
|
|
20
|
+
path += "?" + URI.encode_www_form(params)
|
|
21
|
+
uri = URI.parse(ROOT_URL + path)
|
|
22
|
+
result = Net::HTTP.get_response(uri)
|
|
23
|
+
self.parse(result)
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def parse(result)
|
|
27
|
+
if result.code != "200"
|
|
28
|
+
raise JohkiError.new(result.body)
|
|
29
|
+
end
|
|
30
|
+
JSON.parse(result.body, symbolize_names: true)
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def dota2_match(appid = 570)
|
|
34
|
+
IDOTA2Match.new(self, appid)
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def econ_dota2(appid = 570)
|
|
38
|
+
IEconDota2.new(self, appid)
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def steam_user
|
|
42
|
+
ISteamUser.new(self)
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
end
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
require "johki/client"
|
|
2
|
+
require "johki/interface"
|
|
3
|
+
|
|
4
|
+
module Johki
|
|
5
|
+
class IDOTA2Match < Interface
|
|
6
|
+
def initialize(client, appid)
|
|
7
|
+
super(client, "IDOTA2Match_#{appid}")
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def get_match_details(params={})
|
|
11
|
+
path = path("GetMatchDetails/v1")
|
|
12
|
+
@client.get(path, params)
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def get_match_history(params={})
|
|
16
|
+
path = path("GetMatchHistory/v1")
|
|
17
|
+
@client.get(path, params)
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def get_match_history_by_sequence_num(params={})
|
|
21
|
+
path = path("GetMatchHistoryBySequenceNum/v1")
|
|
22
|
+
@client.get(path, params)
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
require "johki/client"
|
|
2
|
+
require "johki/interface"
|
|
3
|
+
|
|
4
|
+
module Johki
|
|
5
|
+
class IEconDota2 < Interface
|
|
6
|
+
def initialize(client, appid)
|
|
7
|
+
super(client, "IEconDota2_#{appid}")
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def get_game_items(params={})
|
|
11
|
+
path = path("GetGameItems/v1")
|
|
12
|
+
@client.get(path, params)
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def get_heroes(params={})
|
|
16
|
+
path = path("GetHeroes/v1")
|
|
17
|
+
@client.get(path, params)
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
data/lib/johki/error.rb
ADDED
data/lib/johki/id.rb
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
module Johki
|
|
2
|
+
ID_MAGIC_NUMBER = 76561197960265728.freeze
|
|
3
|
+
ID_ANONYMOUS = 4294967295.freeze
|
|
4
|
+
|
|
5
|
+
class << self
|
|
6
|
+
def account_id_to_steam_id(account_id)
|
|
7
|
+
account_id + ID_MAGIC_NUMBER
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def steam_id_to_account_id(steam_id)
|
|
11
|
+
steam_id - ID_MAGIC_NUMBER
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def anonymous?(account_id)
|
|
15
|
+
account_id == ID_ANONYMOUS
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
require "johki/client"
|
|
2
|
+
require "johki/interface"
|
|
3
|
+
|
|
4
|
+
module Johki
|
|
5
|
+
class ISteamUser < Interface
|
|
6
|
+
def initialize(client)
|
|
7
|
+
super(client, "ISteamUser")
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def get_player_summaries(params={})
|
|
11
|
+
path = path("GetPlayerSummaries/v2")
|
|
12
|
+
@client.get(path, params)
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: johki
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.1.8
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- aoisensi
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: exe
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2020-03-09 00:00:00.000000000 Z
|
|
12
|
+
dependencies: []
|
|
13
|
+
description: Simple Steam Web API Library.
|
|
14
|
+
email:
|
|
15
|
+
- aoisensi@outlook.jp
|
|
16
|
+
executables: []
|
|
17
|
+
extensions: []
|
|
18
|
+
extra_rdoc_files: []
|
|
19
|
+
files:
|
|
20
|
+
- ".gitignore"
|
|
21
|
+
- ".travis.yml"
|
|
22
|
+
- CHANGELOG.md
|
|
23
|
+
- Gemfile
|
|
24
|
+
- Gemfile.lock
|
|
25
|
+
- LICENSE.txt
|
|
26
|
+
- README.md
|
|
27
|
+
- Rakefile
|
|
28
|
+
- bin/console
|
|
29
|
+
- bin/setup
|
|
30
|
+
- johki.gemspec
|
|
31
|
+
- lib/johki.rb
|
|
32
|
+
- lib/johki/client.rb
|
|
33
|
+
- lib/johki/dota2_match.rb
|
|
34
|
+
- lib/johki/econ_dota2.rb
|
|
35
|
+
- lib/johki/error.rb
|
|
36
|
+
- lib/johki/id.rb
|
|
37
|
+
- lib/johki/interface.rb
|
|
38
|
+
- lib/johki/steam_user.rb
|
|
39
|
+
- lib/johki/version.rb
|
|
40
|
+
homepage: https://github.com/aoisensi/johki
|
|
41
|
+
licenses: []
|
|
42
|
+
metadata:
|
|
43
|
+
homepage_uri: https://github.com/aoisensi/johki
|
|
44
|
+
source_code_uri: https://github.com/aoisensi/johki
|
|
45
|
+
changelog_uri: https://github.com/aoisensi/johki/blob/master/CHANGELOG.md
|
|
46
|
+
post_install_message:
|
|
47
|
+
rdoc_options: []
|
|
48
|
+
require_paths:
|
|
49
|
+
- lib
|
|
50
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
51
|
+
requirements:
|
|
52
|
+
- - ">="
|
|
53
|
+
- !ruby/object:Gem::Version
|
|
54
|
+
version: 2.3.0
|
|
55
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
56
|
+
requirements:
|
|
57
|
+
- - ">="
|
|
58
|
+
- !ruby/object:Gem::Version
|
|
59
|
+
version: '0'
|
|
60
|
+
requirements: []
|
|
61
|
+
rubygems_version: 3.1.2
|
|
62
|
+
signing_key:
|
|
63
|
+
specification_version: 4
|
|
64
|
+
summary: Simple Steam Web API Library.
|
|
65
|
+
test_files: []
|