ivapi 1.0.4 → 1.1.0

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.
@@ -13,15 +13,60 @@ describe Ivapi::Client do
13
13
  end
14
14
 
15
15
  describe 'authentication' do
16
- it 'is authenticated with username and password' do
16
+ after(:each) do
17
+ Ivapi.reset!
18
+ end
19
+
20
+ it 'should possible to authenticate with configure' do
21
+ Ivapi.configure do |config|
22
+ config.username = 'foo'
23
+ config.password = 'bar'
24
+ end
25
+ expect(Ivapi.client).to be_authenticated
26
+ end
27
+
28
+ it 'should possible to authenticate with basic username and password' do
17
29
  client = Ivapi::Client.new(username: 'foo', password: 'bar')
18
30
  expect(client).to be_authenticated
19
31
  end
20
32
 
21
- it 'is not authenticated without username and password' do
33
+ it 'should not possible to authenticate without username and password' do
22
34
  client = Ivapi::Client.new
23
35
  expect(client).to_not be_authenticated
24
36
  end
25
37
  end
26
38
 
39
+ describe 'setting server id from client' do
40
+ before(:each) do
41
+ Ivapi.reset!
42
+ end
43
+
44
+ it 'should not have server id' do
45
+ client = Ivapi::Client.new(username: 'foo', password: 'bar')
46
+ expect(client.server_id).to be_nil
47
+ end
48
+
49
+ it 'should have server id when set manualy' do
50
+ client = Ivapi::Client.new(username: 'foo', password: 'bar', server_id: 3)
51
+ expect(client.server_id).to eq(3)
52
+ end
53
+ end
54
+
55
+ describe 'manualy setting server id' do
56
+ before(:each) do
57
+ Ivapi.reset!
58
+ Ivapi.configure do |config|
59
+ config.username = 'foo'
60
+ config.password = 'bar'
61
+ end
62
+ end
63
+
64
+ it 'should not have server id' do
65
+ expect(Ivapi.server_id).to be_nil
66
+ end
67
+
68
+ it 'should have server id when set manualy' do
69
+ expect(Ivapi.server(3).server_id).to eq(3)
70
+ end
71
+ end
27
72
  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
6
- expect(Ivapi.respond_to?(:new, true)).to eq(true)
7
- end
8
- end
4
+ # describe '.respond_to?' do
5
+ # it 'is true if method exists' do
6
+ # expect(Ivapi.respond_to?(:new, true)).to eq(true)
7
+ # end
8
+ # end
9
9
 
10
- describe '.new' do
11
- it 'is a Ivapi::Client' do
12
- expect(Ivapi.new).to be_a Ivapi::Client
13
- end
14
- end
10
+ # describe '.new' do
11
+ # it 'is a Ivapi::Client' do
12
+ # expect(Ivapi.new).to be_a Ivapi::Client
13
+ # end
14
+ # end
15
15
 
16
16
  end
@@ -24,11 +24,10 @@ def stub_get(url)
24
24
  end
25
25
 
26
26
  def stub_command(command, options = {})
27
-
28
27
  params = { command: command }
29
28
  params.merge!(options)
30
- params.merge!(@client.authentication)
31
-
29
+ client = @client || Ivapi.client
30
+ params.merge!(client.authentication)
32
31
  stub_request(:get, 'https://api.iv.lt/json.php').with(query: params)
33
32
  end
34
33
 
metadata CHANGED
@@ -1,109 +1,114 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ivapi
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.4
4
+ version: 1.1.0
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-09-08 00:00:00.000000000 Z
11
+ date: 2014-06-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ~>
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
19
  version: '1.0'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ~>
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '1.0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: addressable
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ~>
31
+ - - "~>"
32
32
  - !ruby/object:Gem::Version
33
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
40
  version: '2.3'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: faraday
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ~>
45
+ - - ">="
46
46
  - !ruby/object:Gem::Version
47
- version: '0.8'
47
+ version: 0.8.4
48
+ - - "<"
49
+ - !ruby/object:Gem::Version
50
+ version: '0.9'
48
51
  type: :runtime
49
52
  prerelease: false
50
53
  version_requirements: !ruby/object:Gem::Requirement
51
54
  requirements:
52
- - - ~>
55
+ - - ">="
53
56
  - !ruby/object:Gem::Version
54
- version: '0.8'
57
+ version: 0.8.4
58
+ - - "<"
59
+ - !ruby/object:Gem::Version
60
+ version: '0.9'
55
61
  - !ruby/object:Gem::Dependency
56
62
  name: faraday_middleware
57
63
  requirement: !ruby/object:Gem::Requirement
58
64
  requirements:
59
- - - ~>
65
+ - - "~>"
60
66
  - !ruby/object:Gem::Version
61
67
  version: '0.9'
62
68
  type: :runtime
63
69
  prerelease: false
64
70
  version_requirements: !ruby/object:Gem::Requirement
65
71
  requirements:
66
- - - ~>
72
+ - - "~>"
67
73
  - !ruby/object:Gem::Version
68
74
  version: '0.9'
69
75
  - !ruby/object:Gem::Dependency
70
76
  name: hashie
71
77
  requirement: !ruby/object:Gem::Requirement
72
78
  requirements:
73
- - - ~>
79
+ - - "~>"
74
80
  - !ruby/object:Gem::Version
75
- version: '2.0'
81
+ version: '2.1'
76
82
  type: :runtime
77
83
  prerelease: false
78
84
  version_requirements: !ruby/object:Gem::Requirement
79
85
  requirements:
80
- - - ~>
86
+ - - "~>"
81
87
  - !ruby/object:Gem::Version
82
- version: '2.0'
88
+ version: '2.1'
83
89
  - !ruby/object:Gem::Dependency
84
90
  name: multi_json
85
91
  requirement: !ruby/object:Gem::Requirement
86
92
  requirements:
87
- - - ~>
93
+ - - "~>"
88
94
  - !ruby/object:Gem::Version
89
- version: '1.7'
95
+ version: '1.9'
90
96
  type: :runtime
91
97
  prerelease: false
92
98
  version_requirements: !ruby/object:Gem::Requirement
93
99
  requirements:
94
- - - ~>
100
+ - - "~>"
95
101
  - !ruby/object:Gem::Version
96
- version: '1.7'
97
- description: ' Gem which helps to communicate with iv.lt API '
98
- email:
99
- - justas@elish.lt
102
+ version: '1.9'
103
+ description: " Gem which helps to communicate with http://www.iv.lt API. "
104
+ email: jpalumickas@gmail.com
100
105
  executables: []
101
106
  extensions: []
102
107
  extra_rdoc_files: []
103
108
  files:
104
- - .gitignore
105
- - .rspec
106
- - .travis.yml
109
+ - ".gitignore"
110
+ - ".rspec"
111
+ - ".travis.yml"
107
112
  - CONTRIBUTING.md
108
113
  - Gemfile
109
114
  - Guardfile
@@ -111,16 +116,17 @@ files:
111
116
  - README.md
112
117
  - Rakefile
113
118
  - ivapi.gemspec
114
- - lib/faraday/response/raise_ivapi_error.rb
115
119
  - lib/ivapi.rb
116
120
  - lib/ivapi/authentication.rb
117
121
  - lib/ivapi/client.rb
118
122
  - lib/ivapi/client/account.rb
123
+ - lib/ivapi/client/base.rb
119
124
  - lib/ivapi/client/server.rb
120
125
  - lib/ivapi/configuration.rb
121
- - lib/ivapi/connection.rb
126
+ - lib/ivapi/default.rb
122
127
  - lib/ivapi/error.rb
123
- - lib/ivapi/request.rb
128
+ - lib/ivapi/response/raise_error.rb
129
+ - lib/ivapi/response/rename_keys.rb
124
130
  - lib/ivapi/version.rb
125
131
  - spec/fixtures/account_bonuses.json
126
132
  - spec/fixtures/account_info.json
@@ -153,20 +159,20 @@ require_paths:
153
159
  - lib
154
160
  required_ruby_version: !ruby/object:Gem::Requirement
155
161
  requirements:
156
- - - '>='
162
+ - - ">="
157
163
  - !ruby/object:Gem::Version
158
164
  version: '0'
159
165
  required_rubygems_version: !ruby/object:Gem::Requirement
160
166
  requirements:
161
- - - '>='
167
+ - - ">="
162
168
  - !ruby/object:Gem::Version
163
169
  version: '0'
164
170
  requirements: []
165
171
  rubyforge_project:
166
- rubygems_version: 2.0.7
172
+ rubygems_version: 2.2.2
167
173
  signing_key:
168
174
  specification_version: 4
169
- summary: Gem which helps to communicate with iv.lt API
175
+ summary: Gem which helps to communicate with http://www.iv.lt API.
170
176
  test_files:
171
177
  - spec/fixtures/account_bonuses.json
172
178
  - spec/fixtures/account_info.json
@@ -1,24 +0,0 @@
1
- require 'faraday'
2
- require 'multi_json'
3
-
4
- module Faraday
5
- class Response::RaiseIvapiError < Response::Middleware
6
- ERROR_MAP = {
7
- 400 => Ivapi::BadRequest,
8
- 401 => Ivapi::Unauthorized,
9
- 403 => Ivapi::Forbidden,
10
- 404 => Ivapi::NotFound,
11
- 406 => Ivapi::NotAcceptable,
12
- 422 => Ivapi::UnprocessableEntity,
13
- 500 => Ivapi::InternalServerError,
14
- 501 => Ivapi::NotImplemented,
15
- 502 => Ivapi::BadGateway,
16
- 503 => Ivapi::ServiceUnavailable
17
- }
18
-
19
- def on_complete(response)
20
- key = response[:status].to_i
21
- raise ERROR_MAP[key].new(response) if ERROR_MAP.has_key? key
22
- end
23
- end
24
- end
@@ -1,29 +0,0 @@
1
- require 'faraday_middleware'
2
- require 'faraday/response/raise_ivapi_error'
3
-
4
- module Ivapi
5
- module Connection
6
- private
7
-
8
- def connection(options = {})
9
- connection = Faraday.new(options) do |builder|
10
-
11
- builder.request :json
12
-
13
- builder.use Faraday::Response::RaiseIvapiError
14
- builder.use FaradayMiddleware::FollowRedirects
15
- builder.use FaradayMiddleware::Mashify
16
-
17
- builder.use FaradayMiddleware::ParseJson
18
-
19
- faraday_config_block.call(builder) if faraday_config_block
20
-
21
- builder.adapter *adapter
22
- end
23
-
24
- connection.headers[:user_agent] = user_agent
25
-
26
- connection
27
- end
28
- end
29
- end
@@ -1,22 +0,0 @@
1
- module Ivapi
2
- module Request
3
- def get(path, options = {})
4
- request(:get, path, options).body
5
- end
6
-
7
- def request(method, path, options = {})
8
-
9
- conn_options = {
10
- url: 'https://api.iv.lt'
11
- }
12
-
13
- options.merge!(authentication)
14
-
15
- response = connection(conn_options).send(method) do |request|
16
- request.url(path, options)
17
- end
18
-
19
- response
20
- end
21
- end
22
- end