ivapi 1.0.3 → 1.0.4

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.
Files changed (42) hide show
  1. checksums.yaml +4 -4
  2. data/.rspec +1 -1
  3. data/.travis.yml +2 -1
  4. data/CONTRIBUTING.md +8 -4
  5. data/Gemfile +6 -6
  6. data/LICENSE +21 -0
  7. data/README.md +2 -1
  8. data/Rakefile +1 -1
  9. data/ivapi.gemspec +2 -2
  10. data/lib/faraday/response/raise_ivapi_error.rb +1 -1
  11. data/lib/ivapi.rb +1 -1
  12. data/lib/ivapi/authentication.rb +1 -1
  13. data/lib/ivapi/client.rb +2 -2
  14. data/lib/ivapi/client/account.rb +12 -8
  15. data/lib/ivapi/client/server.rb +72 -42
  16. data/lib/ivapi/configuration.rb +3 -2
  17. data/lib/ivapi/connection.rb +2 -2
  18. data/lib/ivapi/error.rb +1 -1
  19. data/lib/ivapi/request.rb +4 -4
  20. data/lib/ivapi/version.rb +1 -1
  21. data/spec/fixtures/account_bonuses.json +1 -1
  22. data/spec/fixtures/account_info.json +1 -1
  23. data/spec/fixtures/account_orders.json +1 -1
  24. data/spec/fixtures/account_services.json +1 -1
  25. data/spec/fixtures/server_change.json +1 -1
  26. data/spec/fixtures/server_domain.json +1 -1
  27. data/spec/fixtures/server_flush_iptables.json +1 -1
  28. data/spec/fixtures/server_graphs.json +1 -1
  29. data/spec/fixtures/server_info.json +1 -1
  30. data/spec/fixtures/server_os.json +1 -1
  31. data/spec/fixtures/server_reboot.json +1 -1
  32. data/spec/fixtures/server_recreate.json +1 -1
  33. data/spec/fixtures/server_reset_password.json +1 -1
  34. data/spec/fixtures/server_tasks.json +1 -1
  35. data/spec/fixtures/version.json +1 -1
  36. data/spec/ivapi/client/account_spec.rb +26 -13
  37. data/spec/ivapi/client/server_spec.rb +53 -41
  38. data/spec/ivapi/client_spec.rb +21 -7
  39. data/spec/ivapi_spec.rb +5 -5
  40. data/spec/spec_helper.rb +8 -8
  41. metadata +8 -8
  42. data/LICENSE.md +0 -22
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 535ebd41e87d2ce434325939ed2cce35cdc8a556
4
- data.tar.gz: e7f94686b9a33f2a30f54a7dfd2868e143f17714
3
+ metadata.gz: 14d8f0abbc80a600939fc7ac3a1c81a3ea22e47b
4
+ data.tar.gz: 6cbbf8322b4186982f36db9230a57e77d1dc596b
5
5
  SHA512:
6
- metadata.gz: dc7dbcdfb2bae8e214856d0c3b7ce581bdef424039bd1dde5dfb99eaaf35a413372aaeac7e9c8a6a37545e5d7fb404515a2fe5d5c96e67780b8c42f2ac265fba
7
- data.tar.gz: 53d8ea927d775fc9d9ffaca25734e887033f23ab27963b32cc5e4c98dcebaa723a19a4382d98c9d3923166ae7c7b4beb51519e59d4cb8a1d61262fe3d75078da
6
+ metadata.gz: cbb878f44d033f5828404fdf56bbe666e80349c81f40812797f7645b4d97face5408cfdd08fd348c98b11c273822540d1f82ed1a5cc3cf87ac4daa09dc13f318
7
+ data.tar.gz: ac15b5f60eb95e680cf72ee609861ea499da56e05dbfeef6172c425f7fc7f549c2593af1ae4ff96a3549f6a9f4b93b75ae49a6e597ccda985c0ca46e10df98ca
data/.rspec CHANGED
@@ -1,3 +1,3 @@
1
1
  --color
2
2
  --fail-fast
3
- --order random
3
+ --order random
@@ -1,7 +1,8 @@
1
+ bundler_args: --without development
1
2
  language: ruby
2
3
  rvm:
3
4
  - jruby-19mode
4
5
  - rbx-19mode
5
6
  - 1.9.2
6
7
  - 1.9.3
7
- - 2.0.0
8
+ - 2.0.0
@@ -8,17 +8,19 @@ The following guidelines for contribution should be followed if you want to subm
8
8
 
9
9
  * You need a [GitHub account](https://github.com/signup/free)
10
10
  * Submit an [issue ticket](https://github.com/jpalumickas/ivapi/issues) for your issue if the is no one yet.
11
- * Describe the issue and include steps to reproduce when it's a bug.
11
+ * Describe the issue and include steps to reproduce if it's a bug.
12
12
  * Ensure to mention the earliest version that you know is affected.
13
- * Fork the repository on GitHub
13
+ * If you are able and want to fix this, fork the repository on GitHub
14
14
 
15
15
  ## Make Changes
16
16
 
17
- * In your forked repository, create a topic branch for your upcoming patch.
17
+ * In your forked repository, create a topic branch for your upcoming patch. (e.g. `feature--autoplay` or `bugfix--ios-crash`)
18
18
  * Usually this is based on the master branch.
19
19
  * Create a branch based on master; `git branch
20
20
  fix/master/my_contribution master` then checkout the new branch with `git
21
21
  checkout fix/master/my_contribution`. Please avoid working directly on the `master` branch.
22
+ * Make sure you stick to the coding style that is used already.
23
+ * Make use of the `.editorconfig`-file if provided with the repository.
22
24
  * Make commits of logical units and describe them properly.
23
25
  * Check for unnecessary whitespace with `git diff --check` before committing.
24
26
 
@@ -29,7 +31,9 @@ The following guidelines for contribution should be followed if you want to subm
29
31
 
30
32
  * Push your changes to a topic branch in your fork of the repository.
31
33
  * Open a pull request to the original repository and choose the right original branch you want to patch.
32
- * If not done in commit messages (which you really should do) please reference and update your issue with the code changes.
34
+ _Advanced users may use [`hub`](https://github.com/defunkt/hub#git-pull-request) gem for that._
35
+ * If not done in commit messages (which you really should do) please reference and update your issue with the code changes. But _please do not close the issue yourself_.
36
+ _Notice: You can [turn your previously filed issues into a pull-request here](http://issue2pr.herokuapp.com/)._
33
37
  * Even if you have write access to the repository, do not directly push or merge pull-requests. Let another team member review your pull request and approve.
34
38
 
35
39
  # Additional Resources
data/Gemfile CHANGED
@@ -3,12 +3,12 @@ source 'https://rubygems.org'
3
3
  gem 'rake'
4
4
 
5
5
  group :test do
6
- gem 'json', '~> 1.7', platforms: [:ruby_18, :jruby]
7
- gem 'rspec', '>= 2.13'
8
- gem 'simplecov', require: false
9
- gem 'webmock'
10
- gem 'coveralls', require: false
11
- gem 'guard-rspec'
6
+ gem 'json', '~> 1.8.0', platforms: [:ruby_18, :jruby]
7
+ gem 'rspec', '~> 2.14.1'
8
+ gem 'simplecov', '~> 0.7.1', require: false
9
+ gem 'webmock', '~> 1.13.0'
10
+ gem 'coveralls', '~> 0.6.7', require: false
11
+ gem 'guard-rspec', '~> 3.0.2'
12
12
  end
13
13
 
14
14
  gemspec
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+
2
+ The MIT License (MIT)
3
+
4
+ Copyright (c) 2012 Justas Palumickas
5
+
6
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
7
+ this software and associated documentation files (the "Software"), to deal in
8
+ the Software without restriction, including without limitation the rights to
9
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
10
+ the Software, and to permit persons to whom the Software is furnished to do so,
11
+ subject to the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be included in all
14
+ copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
18
+ FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
19
+ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
20
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Ivapi
2
2
 
3
- Gem which helps to communicate with [iv.lt][] API
3
+ Gem which helps to communicate with [http://iv.lt][iv.lt] ([http://dedikuoti.lt][dedikuoti.lt]) API.
4
4
 
5
5
  [![Gem Version](https://badge.fury.io/rb/ivapi.png)][rubygems]
6
6
  [![Build Status](https://secure.travis-ci.org/jpalumickas/ivapi.png?branch=master)][travis]
@@ -56,4 +56,5 @@ See [LICENSE][] for details.
56
56
  [codeclimate]: https://codeclimate.com/github/jpalumickas/ivapi
57
57
 
58
58
  [iv.lt]: http://www.iv.lt
59
+ [dedikuoti.lt]: http://www.dedikuoti.lt
59
60
  [license]: LICENSE.md
data/Rakefile CHANGED
@@ -5,4 +5,4 @@ require 'rspec/core/rake_task'
5
5
  RSpec::Core::RakeTask.new(:spec)
6
6
 
7
7
  task test: :spec
8
- task default: :spec
8
+ task default: :spec
@@ -18,11 +18,11 @@ Gem::Specification.new do |gem|
18
18
  gem.require_paths = ["lib"]
19
19
 
20
20
  gem.add_development_dependency 'bundler', '~> 1.0'
21
- gem.add_dependency 'addressable', '~> 2.2'
21
+ gem.add_dependency 'addressable', '~> 2.3'
22
22
  gem.add_dependency 'faraday', '~> 0.8'
23
23
  gem.add_dependency 'faraday_middleware', '~> 0.9'
24
24
  gem.add_dependency 'hashie', '~> 2.0'
25
- gem.add_dependency 'multi_json', '~> 1.3'
25
+ gem.add_dependency 'multi_json', '~> 1.7'
26
26
 
27
27
  gem.version = Ivapi::VERSION
28
28
  end
@@ -21,4 +21,4 @@ module Faraday
21
21
  raise ERROR_MAP[key].new(response) if ERROR_MAP.has_key? key
22
22
  end
23
23
  end
24
- end
24
+ end
@@ -7,7 +7,7 @@ module Ivapi
7
7
 
8
8
  class << self
9
9
 
10
- def new(options={})
10
+ def new(options = {})
11
11
  Ivapi::Client.new(options)
12
12
  end
13
13
 
@@ -12,4 +12,4 @@ module Ivapi
12
12
  !authentication.empty?
13
13
  end
14
14
  end
15
- end
15
+ end
@@ -9,7 +9,7 @@ module Ivapi
9
9
  class Client
10
10
  attr_accessor(*Configuration::VALID_OPTIONS_KEYS)
11
11
 
12
- def initialize(options={})
12
+ def initialize(options = {})
13
13
  options = Ivapi.options.merge(options)
14
14
  Configuration::VALID_OPTIONS_KEYS.each do |key|
15
15
  send("#{key}=", options[key])
@@ -24,4 +24,4 @@ module Ivapi
24
24
  include Ivapi::Client::Server
25
25
 
26
26
  end
27
- end
27
+ end
@@ -2,9 +2,9 @@ module Ivapi
2
2
  class Client
3
3
  module Account
4
4
 
5
- # Get account information.
5
+ # Get information about account.
6
6
  #
7
- # Returns the hash of account information.
7
+ # Returns the Hash of account information.
8
8
  def account_info
9
9
  params = { command: 'account_info' }
10
10
  get('/json.php', params)
@@ -12,7 +12,7 @@ module Ivapi
12
12
 
13
13
  # Get account orders.
14
14
  #
15
- # Returns the hash of account orders.
15
+ # Returns the Hash of account orders.
16
16
  def account_orders
17
17
  params = { command: 'account_orders' }
18
18
  get('/json.php', params)
@@ -20,7 +20,7 @@ module Ivapi
20
20
 
21
21
  # Get account services.
22
22
  #
23
- # Returns the hash of account services.
23
+ # Returns the Hash of account services.
24
24
  def account_services
25
25
  params = { command: 'account_services' }
26
26
  get('/json.php', params)
@@ -28,17 +28,21 @@ module Ivapi
28
28
 
29
29
  # Get account credits.
30
30
  #
31
- # Returns the hash of account credits.
31
+ # count - The Integer of how many rows need to return (default: 10).
32
+ #
33
+ # Returns the Hash of account credits.
32
34
  def account_credits(count = 10)
33
- options = { command: 'account_credits', count: count }
35
+ params = { command: 'account_credits', count: count }
34
36
  get('/json.php', params)
35
37
  end
36
38
 
37
39
  # Get account bonuses.
38
40
  #
39
- # Returns the hash of account bonuses.
41
+ # count - The Integer of how many rows need to return (default: 10).
42
+ #
43
+ # Returns the Hash of account bonuses.
40
44
  def account_bonuses(count = 10)
41
- params = { :command => 'account_bonuses', count: count }
45
+ params = { command: 'account_bonuses', count: count }
42
46
  get('/json.php', params)
43
47
  end
44
48
  end
@@ -2,9 +2,9 @@ module Ivapi
2
2
  class Client
3
3
  module Server
4
4
 
5
- # Get server information.
5
+ # Get information about server.
6
6
  #
7
- # Returns the hash of server information.
7
+ # Returns the Hash of server information.
8
8
  def server_info
9
9
  params = { command: 'server_info', id: server_id }
10
10
  get('/json.php', params)
@@ -12,29 +12,39 @@ module Ivapi
12
12
 
13
13
  # Get server tasks.
14
14
  #
15
- # count - The Integer number of results count (Max 1000).
16
- # options - The Hash of options (Available: task, task_id).
15
+ # count - The Integer number of results count (max: 1000).
16
+ # options - The Hash options (default: {}):
17
+ # :task - The String of task name (optional).
18
+ # :task_id - The Integer of task id (optional).
17
19
  #
18
- # Returns The Hash of server tasks.
19
- def server_tasks(count, options={})
20
- params = options.merge({ command: 'server_tasks', id: server_id, count: count })
20
+ # Returns the Hash of server tasks.
21
+ def server_tasks(count, options = {})
22
+ params = options.merge({
23
+ command: 'server_tasks', id: server_id, count: count })
24
+
21
25
  get('/json.php', params)
22
26
  end
23
27
 
24
28
  # Get server graphs.
25
29
  #
26
- # width - The Integer number of graphs width (Max 1000, Optimal: 768).
27
- # ip - The String of IP, who can view graphs.
30
+ # width - The Integer number of graphs width (max: 1000, optimal: 768).
31
+ # ip - The String of ip, from which graphs can be viewed.
28
32
  #
29
- # Returns the hash of server graphs.
33
+ # Returns the Hash of server graphs.
30
34
  def server_graphs(width, ip)
31
- params = { command: 'server_graphs' , id: server_id, width: width, ip: ip }
35
+ params = {
36
+ command: 'server_graphs',
37
+ id: server_id,
38
+ width: width,
39
+ ip: ip
40
+ }
41
+
32
42
  get('/json.php', params)
33
43
  end
34
44
 
35
- # Get all available server os.
45
+ # Get all available server operating systems.
36
46
  #
37
- # Returns the hash of server os.
47
+ # Returns the Hash of available server os.
38
48
  def server_os
39
49
  params = { command: 'server_os', id: server_id }
40
50
  get('/json.php', params)
@@ -42,7 +52,7 @@ module Ivapi
42
52
 
43
53
  # Send command to reboot the server.
44
54
  #
45
- # Returns The Integer of task id.
55
+ # Returns the Integer of task id.
46
56
  def server_reboot
47
57
  params = { command: 'server_reboot', id: server_id }
48
58
  get('/json.php', params)
@@ -50,56 +60,76 @@ module Ivapi
50
60
 
51
61
  # Send command to recreate the server.
52
62
  #
53
- # os - The String of OS id.
54
- # new_password - The String of new server password (8-64 lenght).
55
- #
56
- # Returns The Integer of task id.
57
- def server_recreate(os, options={})
58
- params = options.merge({ command: 'server_recreate', id: server_id, os: os })
63
+ # os - The String of os (operating system) id.
64
+ # options - The Hash options (default: {}):
65
+ # :new_password - The String of new server
66
+ # password (min: 8, max: 64).
67
+ #
68
+ # Returns the Integer of task id.
69
+ def server_recreate(os, options = {})
70
+ params = options.merge({
71
+ command: 'server_recreate',
72
+ id: server_id,
73
+ os: os
74
+ })
75
+
59
76
  get('/json.php', params)
60
77
  end
61
78
 
62
79
  # Send command to reset server password.
63
80
  #
64
- # new_password - The String of new server password (8-64 lenght).
81
+ # options - The Hash options (default: {}):
82
+ # :new_password - The String of new server
83
+ # password (min: 8, max: 64).
65
84
  #
66
- # Returns The Integer of task id.
67
- def server_reset_password(options={})
68
- params = options.merge({ command: 'server_reset_password', id: server_id })
85
+ # Returns the Integer of task id.
86
+ def server_reset_password(options = {})
87
+ params = options.merge({
88
+ command: 'server_reset_password',
89
+ id: server_id
90
+ })
91
+
69
92
  get('/json.php', params)
70
93
  end
71
94
 
72
95
  # Send command to clean server firewall rules.
73
96
  #
74
- # Returns The Integer of task id.
97
+ # Returns the Integer of task id.
75
98
  def server_flush_iptables
76
99
  params = { command: 'server_flush_iptables', id: server_id }
77
100
  get('/json.php', params)
78
101
  end
79
102
 
80
- # Send command to change firewall settings
81
- #
82
- # pps - The Integer of incoming ICMP, UDP, TCP joins per second (1000 - 5000).
83
- # pps_icmp - The Integer of ICMP packets per second (0 or 10 - 500).
84
- # pps_udp - The Integer of UDP packets per second (0 or 10 - 500).
85
- # pps_syn - The Integer of TCP SYN packets per second from one IP (0 or 2 - 20).
86
- # connlimit - The Integer of collateral connections from one IP (0 or 16 - 512).
87
- #
88
- # Returns The Hash of new firewall settings.
89
- def server_firewall(options={})
103
+ # Send command to change firewall settings.
104
+ #
105
+ # options - The Hash options (default: {}):
106
+ # :pps - The Integer of incoming ICMP, UDP, TCP joins per
107
+ # second (min: 1000, max: 5000).
108
+ # :pps_icmp - The Integer of ICMP packets per
109
+ # second (0 or min: 10, max: 500).
110
+ # :pps_udp - The Integer of UDP packets per
111
+ # second (0 or min: 10, max: 500).
112
+ # :pps_syn - The Integer of TCP SYN packets per second from
113
+ # one IP (0 or min: 2, max: 20).
114
+ # :connlimit - The Integer of collateral connections from one
115
+ # IP (0 or min: 16, max: 512).
116
+ #
117
+ # Returns the Hash of new firewall settings.
118
+ def server_firewall(options = {})
90
119
  params = options.merge({ command: 'server_firewall', id: server_id })
91
120
  get('/json.php', params)
92
121
  end
93
122
 
94
123
  # Send command to change server plan.
95
124
  #
96
- # cpu - The Integer of GHz (2 - 16)
97
- # ram - The Integer of MB (2048 - 16384)
98
- # quota - The Integer of GB (20 - 800)
99
- # bandwidth - The Integer of Mbps (20 - 400)
125
+ # options - The Hash options (default: {}):
126
+ # :cpu - The Integer of GHz (min: 2, max: 16).
127
+ # :ram - The Integer of MB (min: 2048, max: 16384).
128
+ # :quota - The Integer of GB (min: 20, max: 800).
129
+ # :bandwidth - The Integer of Mbps (min: 20, max: 400).
100
130
  #
101
- # Returns The Integer of task id.
102
- def server_change(options={})
131
+ # Returns the Integer of task id.
132
+ def server_change(options = {})
103
133
  params = options.merge({ command: 'server_change', id: server_id })
104
134
  get('/json.php', params)
105
135
  end
@@ -108,7 +138,7 @@ module Ivapi
108
138
  #
109
139
  # domain - The String of new server hostname.
110
140
  #
111
- # Returns The Integer of task id.
141
+ # Returns the Integer of task id.
112
142
  def server_domain(domain)
113
143
  params = { command: 'server_domain', id: server_id, domain: domain }
114
144
  get('/json.php', params)
@@ -26,7 +26,7 @@ module Ivapi
26
26
  end
27
27
 
28
28
  def options
29
- VALID_OPTIONS_KEYS.inject({}){|o,k| o.merge!(k => send(k)) }
29
+ VALID_OPTIONS_KEYS.reduce({}) { |a, e| a.merge!(e => send(e)) }
30
30
  end
31
31
 
32
32
  def faraday_config(&block)
@@ -37,7 +37,8 @@ module Ivapi
37
37
  self.adapter = DEFAULT_ADAPTER
38
38
  self.username = nil
39
39
  self.password = nil
40
+ self.server_id = nil
40
41
  self.user_agent = DEFAULT_USER_AGENT
41
42
  end
42
43
  end
43
- end
44
+ end
@@ -5,7 +5,7 @@ module Ivapi
5
5
  module Connection
6
6
  private
7
7
 
8
- def connection(options={})
8
+ def connection(options = {})
9
9
  connection = Faraday.new(options) do |builder|
10
10
 
11
11
  builder.request :json
@@ -26,4 +26,4 @@ module Ivapi
26
26
  connection
27
27
  end
28
28
  end
29
- end
29
+ end
@@ -32,4 +32,4 @@ module Ivapi
32
32
 
33
33
  # Raised when iv.lt returns a 503 HTTP status code
34
34
  class ServiceUnavailable < Error; end
35
- end
35
+ end
@@ -1,13 +1,13 @@
1
1
  module Ivapi
2
2
  module Request
3
- def get(path, options={})
3
+ def get(path, options = {})
4
4
  request(:get, path, options).body
5
5
  end
6
6
 
7
- def request(method, path, options={})
7
+ def request(method, path, options = {})
8
8
 
9
9
  conn_options = {
10
- :url => "https://api.iv.lt"
10
+ url: 'https://api.iv.lt'
11
11
  }
12
12
 
13
13
  options.merge!(authentication)
@@ -19,4 +19,4 @@ module Ivapi
19
19
  response
20
20
  end
21
21
  end
22
- end
22
+ end
@@ -1,3 +1,3 @@
1
1
  module Ivapi
2
- VERSION = '1.0.3'
2
+ VERSION = '1.0.4'
3
3
  end
@@ -17,4 +17,4 @@
17
17
  "bo_amount": "3.00",
18
18
  "bo_description": "SMS +370.61234569 (example)"
19
19
  }
20
- ]
20
+ ]
@@ -39,4 +39,4 @@
39
39
  "us_description":"API"
40
40
  }
41
41
  ]
42
- }
42
+ }
@@ -26,4 +26,4 @@
26
26
  "or_cost": "13.13",
27
27
  "or_url": "https://saskaitos.iv.lt/"
28
28
  }
29
- ]
29
+ ]
@@ -32,4 +32,4 @@
32
32
  "se_unit": "mėn.",
33
33
  "se_description": "Serverio nuoma (planas 1GHz:1024MB:10GB:10Mbps, server.example.com)"
34
34
  }
35
- ]
35
+ ]
@@ -1,3 +1,3 @@
1
1
  {
2
2
  "task_id": "14"
3
- }
3
+ }
@@ -1,3 +1,3 @@
1
1
  {
2
2
  "task_id": "15"
3
- }
3
+ }
@@ -1,3 +1,3 @@
1
1
  {
2
2
  "task_id": "16"
3
- }
3
+ }
@@ -23,4 +23,4 @@
23
23
  "cpu_weekly": "//stats.serveriai.lt/graph.php?Ds252x+6Lek1o0SV2+u99fqhNaiflbCcb6QuGzlRJ9yy2R1VycHOc6baz3zRB6Am1RJcniVrpCjj+A47DMwkyfQ==",
24
24
  "cpu_monthly": "//stats.serveriai.lt/graph.php?Ds252x+6Lek1o0SV2+u99fqhNaiflbCcb6QuGzlRJ9yxK/MZyMfdX4eflJC8xIf8j1/FtFwPGQkKJH2lwumDXzw==",
25
25
  "cpu_yearly": "//stats.serveriai.lt/graph.php?Ds252x+6Lek1o0SV2+u99fqhNaiflbCcb6QuGzlRJ9yxZA7jroJOYQwMT3OKsz00xRJcniVrpCjj+A47DMwkyfQ=="
26
- }
26
+ }
@@ -27,4 +27,4 @@
27
27
  "in_mm_usage": "1297",
28
28
  "in_ips": "12.23.34.45"
29
29
  }
30
- }
30
+ }
@@ -129,4 +129,4 @@
129
129
  "title": "Ubuntu 12.04",
130
130
  "arch": "64-bit"
131
131
  }
132
- }
132
+ }
@@ -1,3 +1,3 @@
1
1
  {
2
2
  "task_id": "11"
3
- }
3
+ }
@@ -1,3 +1,3 @@
1
1
  {
2
2
  "task_id": "12"
3
- }
3
+ }
@@ -1,3 +1,3 @@
1
1
  {
2
2
  "task_id": "13"
3
- }
3
+ }
@@ -11,4 +11,4 @@
11
11
  },
12
12
  "ta_results": "Stopping container ...\nContainer was stopped\nContainer is unmounted\nDestroying container private area: /vz/private/11\nContainer private area was destroyed\nCreating container private area (debian-6.0-x86_64)\nPerforming postcreate actions\nCT configuration saved to /etc/vz/conf/1.conf\nContainer private area was created\nStarting container...\nContainer is mounted\nContainer start in progress...\nKilling container ...\nContainer was stopped\nContainer is unmounted\nCT configuration saved to /etc/vz/conf/1.conf\nCT configuration saved to /etc/vz/conf/1.conf\nStarting container...\nContainer is mounted\nAdding IP address(es): 12.23.34.45\nSetting CPU limit: 0\nSetting CPU units: 200\nSetting CPUs: 1\nContainer start in progress...\n\nID: 1\nHost: server.example.com\nBandwidth: 10240 Kbps\nQuota: 10 GB\nCPU: 1 unit(s)\nRAM: 1024 MB\nIP: 12.23.34.45\nPassword: secret"
13
13
  }
14
- ]
14
+ ]
@@ -1,3 +1,3 @@
1
1
  {
2
2
  "version":"0.1"
3
- }
3
+ }
@@ -6,29 +6,42 @@ describe Ivapi::Client::Account do
6
6
  @client = Ivapi::Client.new(username: 'foo', password: 'bar')
7
7
  end
8
8
 
9
- it "returns account information" do
10
- stub_command("account_info").to_return(json_response("account_info.json"))
9
+ it 'returns account information' do
10
+ stub_command('account_info').to_return(json_response('account_info.json'))
11
+
11
12
  account_info = @client.account_info
12
- expect(account_info.ac_name).to eq("Name Surname")
13
+
14
+ expect(account_info.ac_name).to eq('Name Surname')
13
15
  end
14
16
 
15
- it "returns account orders" do
16
- stub_command("account_orders").to_return(json_response("account_orders.json"))
17
+ it 'returns account orders' do
18
+ stub_command('account_orders')
19
+ .to_return(json_response('account_orders.json'))
20
+
17
21
  account_orders = @client.account_orders
22
+
18
23
  expect(account_orders.count).to eq(3)
19
- expect(account_orders.first.or_cost).to eq("11.11")
24
+ expect(account_orders.first.or_cost).to eq('11.11')
20
25
  end
21
26
 
22
- it "returns account services" do
23
- stub_command("account_services").to_return(json_response("account_services.json"))
27
+ it 'returns account services' do
28
+ stub_command('account_services')
29
+ .to_return(json_response('account_services.json'))
30
+
24
31
  account_services = @client.account_services
32
+
25
33
  expect(account_services.count).to eq(3)
26
- expect(account_services.first.se_description).to eq("Adreso metinis mokestis (example.com)")
34
+ expect(account_services.first.se_description)
35
+ .to eq('Adreso metinis mokestis (example.com)')
27
36
  end
28
37
 
29
- it "returns account bonuses" do
30
- stub_command("account_bonuses", {count: 10}).to_return(json_response("account_bonuses.json"))
38
+ it 'returns account bonuses' do
39
+ stub_command('account_bonuses', { count: 10 })
40
+ .to_return(json_response('account_bonuses.json'))
41
+
31
42
  account_bonuses = @client.account_bonuses
32
- expect(account_bonuses[2].bo_description).to eq("SMS +370.61234569 (example)")
43
+
44
+ expect(account_bonuses[2].bo_description)
45
+ .to eq('SMS +370.61234569 (example)')
33
46
  end
34
- end
47
+ end
@@ -6,77 +6,89 @@ describe Ivapi::Client::Server do
6
6
  @client = Ivapi::Client.new(username: 'foo', password: 'bar', server_id: 3)
7
7
  end
8
8
 
9
- it "should return server information" do
10
- stub_command("server_info", {id: 3}).to_return(json_response("server_info.json"))
9
+ it 'should return server information' do
10
+ stub_command('server_info', { id: 3 })
11
+ .to_return(json_response('server_info.json'))
11
12
  server_info = @client.server_info
12
- expect(server_info.se_domain).to eq("server.example.com")
13
- expect(server_info.se_info.in_node).to eq("Robinija")
13
+ expect(server_info.se_domain).to eq('server.example.com')
14
+ expect(server_info.se_info.in_node).to eq('Robinija')
14
15
  end
15
16
 
16
- it "should return server tasks" do
17
- stub_command("server_tasks", {id: 3, count: 1}).to_return(json_response("server_tasks.json"))
17
+ it 'should return server tasks' do
18
+ stub_command('server_tasks', { id: 3, count: 1 })
19
+ .to_return(json_response('server_tasks.json'))
18
20
  server_tasks = @client.server_tasks(1)
19
- expect(server_tasks.first.ta_params.domain).to eq("server.example.com")
21
+ expect(server_tasks.first.ta_params.domain).to eq('server.example.com')
20
22
  end
21
23
 
22
- it "should return server tasks with specified options" do
23
- stub_command("server_tasks", {id: 3, count: 1, task_id: 1}).to_return(json_response("server_tasks.json"))
24
- server_tasks = @client.server_tasks(1, {task_id: 1})
25
- expect(server_tasks.first.ta_params.domain).to eq("server.example.com")
24
+ it 'should return server tasks with specified options' do
25
+ stub_command('server_tasks', { id: 3, count: 1, task_id: 1 })
26
+ .to_return(json_response('server_tasks.json'))
27
+ server_tasks = @client.server_tasks(1, { task_id: 1 })
28
+ expect(server_tasks.first.ta_params.domain).to eq('server.example.com')
26
29
  end
27
30
 
28
- it "should return server graphs" do
29
- stub_command("server_graphs", {id: 3, width: 1000, ip: "12.23.34.45"}).to_return(json_response("server_graphs.json"))
30
- server_graphs = @client.server_graphs(1000, "12.23.34.45")
31
- expect(server_graphs.cpu_weekly).to eq("//stats.serveriai.lt/graph.php?Ds252x+6Lek1o0SV2+u99fqhNaiflbCcb6QuGzlRJ9yy2R1VycHOc6baz3zRB6Am1RJcniVrpCjj+A47DMwkyfQ==")
31
+ it 'should return server graphs' do
32
+ stub_command('server_graphs', { id: 3, width: 1000, ip: '12.23.34.45' })
33
+ .to_return(json_response('server_graphs.json'))
34
+ server_graphs = @client.server_graphs(1000, '12.23.34.45')
35
+ expect(server_graphs.cpu_weekly).to eq('//stats.serveriai.lt/graph.php?Ds252x+6Lek1o0SV2+u99fqhNaiflbCcb6QuGzlRJ9yy2R1VycHOc6baz3zRB6Am1RJcniVrpCjj+A47DMwkyfQ==')
32
36
  end
33
37
 
34
- it "should return server os" do
35
- stub_command("server_os", {id: 3}).to_return(json_response("server_os.json"))
38
+ it 'should return server os' do
39
+ stub_command('server_os', { id: 3 })
40
+ .to_return(json_response('server_os.json'))
36
41
  server_os = @client.server_os
37
- expect(server_os["debian-6.0-x86_64"].title).to eq("Debian 6")
42
+ expect(server_os['debian-6.0-x86_64'].title).to eq('Debian 6')
38
43
  end
39
44
 
40
- it "should reboot server" do
41
- stub_command("server_reboot", {id: 3}).to_return(json_response("server_reboot.json"))
45
+ it 'should reboot server' do
46
+ stub_command('server_reboot', { id: 3 })
47
+ .to_return(json_response('server_reboot.json'))
42
48
  server_reboot = @client.server_reboot
43
- expect(server_reboot.task_id).to eq("11")
49
+ expect(server_reboot.task_id).to eq('11')
44
50
  end
45
51
 
46
- it "should recreate server" do
47
- stub_command("server_recreate", {id: 3, os: "debian-6.0-x86_64"}).to_return(json_response("server_recreate.json"))
48
- server_recreate = @client.server_recreate("debian-6.0-x86_64")
49
- expect(server_recreate.task_id).to eq("12")
52
+ it 'should recreate server' do
53
+ stub_command('server_recreate', { id: 3, os: 'debian-6.0-x86_64' })
54
+ .to_return(json_response('server_recreate.json'))
55
+ server_recreate = @client.server_recreate('debian-6.0-x86_64')
56
+ expect(server_recreate.task_id).to eq('12')
50
57
  end
51
58
 
52
- it "should reset server password" do
53
- stub_command("server_reset_password", {id: 3}).to_return(json_response("server_reset_password.json"))
59
+ it 'should reset server password' do
60
+ stub_command('server_reset_password', { id: 3 })
61
+ .to_return(json_response('server_reset_password.json'))
54
62
  server_reset_password = @client.server_reset_password
55
- expect(server_reset_password.task_id).to eq("13")
63
+ expect(server_reset_password.task_id).to eq('13')
56
64
  end
57
65
 
58
- it "should flush server iptables" do
59
- stub_command("server_flush_iptables", {id: 3}).to_return(json_response("server_flush_iptables.json"))
66
+ it 'should flush server iptables' do
67
+ stub_command('server_flush_iptables', { id: 3 })
68
+ .to_return(json_response('server_flush_iptables.json'))
60
69
  server_flush_iptables = @client.server_flush_iptables
61
- expect(server_flush_iptables.task_id).to eq("16")
70
+ expect(server_flush_iptables.task_id).to eq('16')
62
71
  end
63
72
 
64
- it "should change server firewall settings" do
65
- stub_command("server_firewall", {id: 3}).to_return(json_response("server_firewall.json"))
73
+ it 'should change server firewall settings' do
74
+ stub_command('server_firewall', { id: 3 })
75
+ .to_return(json_response('server_firewall.json'))
66
76
  server_firewall = @client.server_firewall
67
- expect(server_firewall.pps).to eq("1000")
77
+ expect(server_firewall.pps).to eq('1000')
68
78
  end
69
79
 
70
- it "should change server plan" do
71
- stub_command("server_change", {id: 3}).to_return(json_response("server_change.json"))
80
+ it 'should change server plan' do
81
+ stub_command('server_change', { id: 3 })
82
+ .to_return(json_response('server_change.json'))
72
83
  server_change = @client.server_change
73
- expect(server_change.task_id).to eq("14")
84
+ expect(server_change.task_id).to eq('14')
74
85
  end
75
86
 
76
- it "should change server hostname" do
77
- stub_command("server_domain", {id: 3, domain: "example.com"}).to_return(json_response("server_domain.json"))
78
- server_domain = @client.server_domain("example.com")
79
- expect(server_domain.task_id).to eq("15")
87
+ it 'should change server hostname' do
88
+ stub_command('server_domain', { id: 3, domain: 'example.com' })
89
+ .to_return(json_response('server_domain.json'))
90
+ server_domain = @client.server_domain('example.com')
91
+ expect(server_domain.task_id).to eq('15')
80
92
  end
81
93
 
82
94
  end
@@ -2,12 +2,26 @@ require 'spec_helper'
2
2
 
3
3
  describe Ivapi::Client do
4
4
 
5
- it "works with basic auth and password" do
6
- stub_request(:get, "https://api.iv.lt/json.php?nick=foo&password=bar&command=version").
7
- to_return(:status => 200, :body => '{"commits":[]}', :headers => {})
8
- expect {
9
- Ivapi::Client.new(:username => 'foo', :password => 'bar')
10
- }.not_to raise_exception
5
+ it 'works with basic auth and password' do
6
+ url = 'https://api.iv.lt/json.php?nick=foo&password=bar&command=version'
7
+
8
+ stub_request(:get, url)
9
+ .to_return(status: 200, body: '{"commits":[]}', headers: {})
10
+
11
+ expect { Ivapi::Client.new(username: 'foo', password: 'bar') }
12
+ .not_to raise_exception
13
+ end
14
+
15
+ describe 'authentication' do
16
+ it 'is authenticated with username and password' do
17
+ client = Ivapi::Client.new(username: 'foo', password: 'bar')
18
+ expect(client).to be_authenticated
19
+ end
20
+
21
+ it 'is not authenticated without username and password' do
22
+ client = Ivapi::Client.new
23
+ expect(client).to_not be_authenticated
24
+ end
11
25
  end
12
26
 
13
- end
27
+ end
@@ -1,16 +1,16 @@
1
1
  require 'spec_helper'
2
2
  describe Ivapi do
3
3
 
4
- describe ".respond_to?" do
5
- it "is true if method exists" do
4
+ describe '.respond_to?' do
5
+ it 'is true if method exists' do
6
6
  expect(Ivapi.respond_to?(:new, true)).to eq(true)
7
7
  end
8
8
  end
9
9
 
10
- describe ".new" do
11
- it "is a Ivapi::Client" do
10
+ describe '.new' do
11
+ it 'is a Ivapi::Client' do
12
12
  expect(Ivapi.new).to be_a Ivapi::Client
13
13
  end
14
14
  end
15
15
 
16
- end
16
+ end
@@ -23,17 +23,17 @@ def stub_get(url)
23
23
  stub_request(:get, iv_url(url))
24
24
  end
25
25
 
26
- def stub_command(command, options={})
26
+ def stub_command(command, options = {})
27
27
 
28
28
  params = { command: command }
29
29
  params.merge!(options)
30
30
  params.merge!(@client.authentication)
31
31
 
32
- stub_request(:get, "https://api.iv.lt/json.php").with(query: params)
32
+ stub_request(:get, 'https://api.iv.lt/json.php').with(query: params)
33
33
  end
34
34
 
35
35
  def fixture_path
36
- File.expand_path("../fixtures", __FILE__)
36
+ File.expand_path('../fixtures', __FILE__)
37
37
  end
38
38
 
39
39
  def fixture(file)
@@ -42,9 +42,9 @@ end
42
42
 
43
43
  def json_response(file)
44
44
  {
45
- :body => fixture(file),
46
- :headers => {
47
- :content_type => 'application/json; charset=utf-8'
45
+ body: fixture(file),
46
+ headers: {
47
+ content_type: 'application/json; charset=utf-8'
48
48
  }
49
49
  }
50
50
  end
@@ -59,8 +59,8 @@ end
59
59
 
60
60
  def iv_command_url(command)
61
61
  if @client && @client.authenticated?
62
- "https://api.iv.lt?nick=#{@client.username}&password=#{@client.password}&command=#{command}"
62
+ iv_url("?nick=#{@client.username}&password=#{@client.password}&command=#{command}")
63
63
  else
64
- "https://api.iv.lt?command=#{command}"
64
+ iv_url("?command=#{command}")
65
65
  end
66
66
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ivapi
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.3
4
+ version: 1.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Justas Palumickas
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-07-15 00:00:00.000000000 Z
11
+ date: 2013-09-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -30,14 +30,14 @@ dependencies:
30
30
  requirements:
31
31
  - - ~>
32
32
  - !ruby/object:Gem::Version
33
- version: '2.2'
33
+ version: '2.3'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - ~>
39
39
  - !ruby/object:Gem::Version
40
- version: '2.2'
40
+ version: '2.3'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: faraday
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -86,14 +86,14 @@ dependencies:
86
86
  requirements:
87
87
  - - ~>
88
88
  - !ruby/object:Gem::Version
89
- version: '1.3'
89
+ version: '1.7'
90
90
  type: :runtime
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
94
  - - ~>
95
95
  - !ruby/object:Gem::Version
96
- version: '1.3'
96
+ version: '1.7'
97
97
  description: ' Gem which helps to communicate with iv.lt API '
98
98
  email:
99
99
  - justas@elish.lt
@@ -107,7 +107,7 @@ files:
107
107
  - CONTRIBUTING.md
108
108
  - Gemfile
109
109
  - Guardfile
110
- - LICENSE.md
110
+ - LICENSE
111
111
  - README.md
112
112
  - Rakefile
113
113
  - ivapi.gemspec
@@ -163,7 +163,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
163
163
  version: '0'
164
164
  requirements: []
165
165
  rubyforge_project:
166
- rubygems_version: 2.0.3
166
+ rubygems_version: 2.0.7
167
167
  signing_key:
168
168
  specification_version: 4
169
169
  summary: Gem which helps to communicate with iv.lt API
data/LICENSE.md DELETED
@@ -1,22 +0,0 @@
1
- Copyright (c) 2012 Justas Palumickas
2
-
3
- MIT License
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining
6
- a copy of this software and associated documentation files (the
7
- "Software"), to deal in the Software without restriction, including
8
- without limitation the rights to use, copy, modify, merge, publish,
9
- distribute, sublicense, and/or sell copies of the Software, and to
10
- permit persons to whom the Software is furnished to do so, subject to
11
- the following conditions:
12
-
13
- The above copyright notice and this permission notice shall be
14
- included in all copies or substantial portions of the Software.
15
-
16
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.