wot_api_ru 0.0.1

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: 5e784df485fc14dd6db77fdecca58b2257864e6a
4
+ data.tar.gz: bcf73b0afcc842d3684854c9b19ba2e087421ee5
5
+ SHA512:
6
+ metadata.gz: af49872f2e85690b29b0343feb613a55e6dd72086b1a9c990e6625f8671613b1e505d49b9aa245ee81e5e331cc9fb4160b02318060161f14d18d3f913a831bd4
7
+ data.tar.gz: ec46ac5a4d4a1ef882a83cda4174a53ec2253d01a334dd49503fbf3e71bd33018f4f10abafb174244190d11286debb8d0ec0d00df9c932b68797bca23506b00e
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright 2014 Ivan Bondarenko
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,42 @@
1
+ WotApi
2
+ =======
3
+
4
+ Ruby gem for [Wargaming.net Public API](http://ru.wargaming.net/developers/documentation/guide/getting-started/)
5
+
6
+ ## Getting started
7
+
8
+ WotApi works with Rails 4.1 onwards. You can add it to your Gemfile with:
9
+
10
+ ```ruby
11
+ gem 'wot_api_ru', github: 'shved270189/wot_api', :tag => 'v0.0.1'
12
+ ```
13
+
14
+ Run the bundle command to install it.
15
+
16
+ After you install WotApi and add it to your Gemfile, you need to run the generator:
17
+
18
+ ```console
19
+ rails generate wot_api:install
20
+ ```
21
+
22
+ The generator will install an initializer. Set your [application id](https://ru.wargaming.net/developers/applications/) in config/initializers/wot_api.rb :
23
+
24
+ ```ruby
25
+ # Set your application Wargaming key here!
26
+ WotApi::Settings[:application_id] = ENV['WOT_API_APP_ID']
27
+ ```
28
+
29
+ After this steps you can create WotApi client and call to Wargaming.net Public API:
30
+
31
+ ```ruby
32
+ client = WotApi::Client.new
33
+ client.account_list(search: 'saltovka')
34
+ ```
35
+ All API's method you can see on [API dicumentation](http://ru.wargaming.net/developers/api_reference).
36
+ If you want call [api.worldoftanks.ru/wot/account/list](http://ru.wargaming.net/developers/api_reference/wot/account/list/) then you can use WotApi::Client#account_list with parameters of API etc.
37
+
38
+ ## License
39
+
40
+ Copyright (c) 2014 Ivan Bondarenko. See [LICENSE][] for details.
41
+
42
+ [license]: MIT-LICENSE
data/Rakefile ADDED
@@ -0,0 +1,21 @@
1
+ begin
2
+ require 'bundler/setup'
3
+ rescue LoadError
4
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
5
+ end
6
+
7
+ require 'rdoc/task'
8
+
9
+ RDoc::Task.new(:rdoc) do |rdoc|
10
+ rdoc.rdoc_dir = 'rdoc'
11
+ rdoc.title = 'WotApi'
12
+ rdoc.options << '--line-numbers'
13
+ rdoc.rdoc_files.include('README.rdoc')
14
+ rdoc.rdoc_files.include('lib/**/*.rb')
15
+ end
16
+
17
+
18
+
19
+
20
+ Bundler::GemHelper.install_tasks
21
+
@@ -0,0 +1,18 @@
1
+ require 'rails/generators'
2
+
3
+ module WotApi
4
+ class InstallGenerator < Rails::Generators::Base
5
+ include Rails::Generators::ResourceHelpers
6
+ desc "Some description of my generator here"
7
+
8
+ def name
9
+ "wot_api"
10
+ end
11
+
12
+ source_root File.expand_path("../templates", __FILE__)
13
+
14
+ def copy_initializer_file
15
+ copy_file "wot_api.rb", "config/initializers/wot_api.rb"
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,2 @@
1
+ # Set your application Wargaming key here!
2
+ WotApi::Settings[:application_id] = ENV['WOT_API_APP_ID']
@@ -0,0 +1,4 @@
1
+ # desc "Explaining what the task does"
2
+ # task :wot_api do
3
+ # # Task goes here
4
+ # end
@@ -0,0 +1,23 @@
1
+ require 'wot_api/constants'
2
+ require 'wot_api/settings'
3
+ require 'rest_client'
4
+
5
+ module WotApi
6
+ class Client
7
+
8
+ def method_missing(meth, *args, &block)
9
+ raise NoMethodError, "undefined method #{meth} for #{self.class.to_s}" if WotApi::Constants::PATH[meth.to_sym].nil?
10
+ options = args[0]
11
+ options[:application_id] ||= WotApi::Settings[:application_id]
12
+ path = WotApi::Constants::HOST + WotApi::Constants::PATH[meth.to_sym]
13
+ invoke(path, options)
14
+ end
15
+
16
+ private
17
+
18
+ def invoke(path, options)
19
+ response = RestClient.post(path, options)
20
+ JSON.parse response.body
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,90 @@
1
+ module WotApi
2
+ module Constants
3
+
4
+ HOST = 'https://api.worldoftanks.ru/wot/'
5
+
6
+ PATH = {
7
+ # All pathes require: application_id
8
+
9
+ # require: search
10
+ account_list: 'account/list/',
11
+ # require: account_id
12
+ account_info: 'account/info',
13
+ # require: account_id
14
+ account_tanks: 'account/tanks',
15
+ # require: account_id
16
+ account_achievements: 'account/achievements',
17
+
18
+ # TODO uncomment when complete authentication
19
+ # auth_login: 'auth/login',
20
+ # require: access_token
21
+ auth_prolongate: 'auth/prolongate',
22
+ # require: access_token
23
+ auth_logout: 'auth/logout',
24
+
25
+ clan_list: 'clan/list',
26
+ # require: clan_id
27
+ clan_info: 'clan/info',
28
+ # TODO method should be disable
29
+ # require: clan_id
30
+ clan_battles: 'clan/battles',
31
+ clan_top: 'clan/top',
32
+ # require: clan_id
33
+ clan_provinces: 'clan/provinces',
34
+ # TODO method should be disable
35
+ # require: clan_id
36
+ clan_victorypoints: 'clan/victorypoints',
37
+ # TODO method should be disable
38
+ # require: clan_id
39
+ clan_victorypointshistory: 'clan/victorypointshistory',
40
+ # require: member_id
41
+ clan_membersinfo: 'clan/membersinfo',
42
+
43
+ # require: map_id
44
+ globalwar_clans: 'globalwar/clans',
45
+ # require: map_id, account_id
46
+ globalwar_famepoints: 'globalwar/famepoints',
47
+ globalwar_maps: 'globalwar/maps',
48
+ # require: map_id
49
+ globalwar_provinces: 'globalwar/provinces',
50
+ # require: map_id, order_by
51
+ globalwar_top: 'globalwar/top',
52
+ # require: map_id, province_id
53
+ globalwar_tournaments: 'globalwar/tournaments',
54
+ # require: map_id, access_token
55
+ globalwar_famepointshistory: 'globalwar/famepointshistory',
56
+ # require: map_id
57
+ globalwar_alleyoffame: 'globalwar/alleyoffame',
58
+ # require: map_id, clan_id
59
+ globalwar_battles: 'globalwar/battles',
60
+ # require: map_id, clan_id
61
+ globalwar_victorypointshistory: 'globalwar/victorypointshistory',
62
+
63
+ encyclopedia_tanks: 'encyclopedia/tanks',
64
+ # require: tank_id
65
+ encyclopedia_tankinfo: 'encyclopedia/tankinfo',
66
+ encyclopedia_tankengines: 'encyclopedia/tankengines',
67
+ encyclopedia_tankturrets: 'encyclopedia/tankturrets',
68
+ encyclopedia_tankradios: 'encyclopedia/tankradios',
69
+ encyclopedia_tankchassis: 'encyclopedia/tankchassis',
70
+ encyclopedia_tankguns: 'encyclopedia/tankguns',
71
+ encyclopedia_achievements: 'encyclopedia/achievements',
72
+ encyclopedia_info: 'encyclopedia/info',
73
+
74
+ ratings_types: 'ratings/types',
75
+ # require: account_id, type
76
+ ratings_accounts: 'ratings/accounts',
77
+ # require: account_id, type, rank_field
78
+ ratings_neighbors: 'ratings/neighbors',
79
+ # require: type, rank_field
80
+ ratings_top: 'ratings/top',
81
+ # require: type
82
+ ratings_dates: 'ratings/dates',
83
+
84
+ # require: account_id
85
+ tanks_stats: 'tanks/stats',
86
+ # require: account_id
87
+ tanks_achievements: 'tanks/achievements'
88
+ }
89
+ end
90
+ end
@@ -0,0 +1,16 @@
1
+ module WotApi
2
+ class Settings
3
+
4
+ @@options = Hash.new
5
+
6
+ class << self
7
+ def [](ind)
8
+ @@options[ind.to_sym]
9
+ end
10
+
11
+ def []=(ind, val)
12
+ @@options[ind.to_sym] = val.to_s
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,3 @@
1
+ module WotApi
2
+ VERSION = "0.0.1"
3
+ end
data/lib/wot_api.rb ADDED
@@ -0,0 +1,5 @@
1
+ require 'generators/wot_api/install_generator'
2
+ require 'wot_api/client'
3
+
4
+ module WotApi
5
+ end
metadata ADDED
@@ -0,0 +1,131 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: wot_api_ru
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Ivan Bondarenko
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-07-16 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rails
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '4.1'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '4.1'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rest_client
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.7'
34
+ - - ">="
35
+ - !ruby/object:Gem::Version
36
+ version: 1.7.3
37
+ type: :runtime
38
+ prerelease: false
39
+ version_requirements: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - "~>"
42
+ - !ruby/object:Gem::Version
43
+ version: '1.7'
44
+ - - ">="
45
+ - !ruby/object:Gem::Version
46
+ version: 1.7.3
47
+ - !ruby/object:Gem::Dependency
48
+ name: sqlite3
49
+ requirement: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - "~>"
52
+ - !ruby/object:Gem::Version
53
+ version: '1.3'
54
+ - - ">="
55
+ - !ruby/object:Gem::Version
56
+ version: 1.3.9
57
+ type: :development
58
+ prerelease: false
59
+ version_requirements: !ruby/object:Gem::Requirement
60
+ requirements:
61
+ - - "~>"
62
+ - !ruby/object:Gem::Version
63
+ version: '1.3'
64
+ - - ">="
65
+ - !ruby/object:Gem::Version
66
+ version: 1.3.9
67
+ - !ruby/object:Gem::Dependency
68
+ name: rspec-rails
69
+ requirement: !ruby/object:Gem::Requirement
70
+ requirements:
71
+ - - "~>"
72
+ - !ruby/object:Gem::Version
73
+ version: '3.0'
74
+ - - ">="
75
+ - !ruby/object:Gem::Version
76
+ version: 3.0.1
77
+ type: :development
78
+ prerelease: false
79
+ version_requirements: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - "~>"
82
+ - !ruby/object:Gem::Version
83
+ version: '3.0'
84
+ - - ">="
85
+ - !ruby/object:Gem::Version
86
+ version: 3.0.1
87
+ description: Gem for Wargaming.net Public API http://ru.wargaming.net/developers/api_reference
88
+ .
89
+ email:
90
+ - bondarenko.dev@gmail.com
91
+ executables: []
92
+ extensions: []
93
+ extra_rdoc_files:
94
+ - README.md
95
+ files:
96
+ - MIT-LICENSE
97
+ - README.md
98
+ - Rakefile
99
+ - lib/generators/wot_api/install_generator.rb
100
+ - lib/generators/wot_api/templates/wot_api.rb
101
+ - lib/tasks/wot_api_tasks.rake
102
+ - lib/wot_api.rb
103
+ - lib/wot_api/client.rb
104
+ - lib/wot_api/constants.rb
105
+ - lib/wot_api/settings.rb
106
+ - lib/wot_api/version.rb
107
+ homepage: https://github.com/shved270189/wot_api
108
+ licenses:
109
+ - MIT
110
+ metadata: {}
111
+ post_install_message:
112
+ rdoc_options: []
113
+ require_paths:
114
+ - lib
115
+ required_ruby_version: !ruby/object:Gem::Requirement
116
+ requirements:
117
+ - - ">="
118
+ - !ruby/object:Gem::Version
119
+ version: '0'
120
+ required_rubygems_version: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ requirements: []
126
+ rubyforge_project:
127
+ rubygems_version: 2.3.0
128
+ signing_key:
129
+ specification_version: 4
130
+ summary: Wargaming.net Public API.
131
+ test_files: []