scoreoid 1.1.1.alpha → 1.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +2 -6
- data/README.md +18 -42
- data/lib/scoreoid/api.rb +5 -8
- data/lib/scoreoid/player.rb +4 -141
- data/lib/scoreoid/version.rb +1 -1
- data/scoreoid.gemspec +0 -2
- data/spec/{scoreoid/api_spec.rb → api_spec.rb} +0 -0
- data/spec/player_spec.rb +20 -0
- data/spec/version_spec.rb +7 -0
- metadata +32 -24
- checksums.yaml +0 -7
- data/.travis.yml +0 -2
- data/spec/scoreoid/player_spec.rb +0 -73
- data/spec/scoreoid/version_spec.rb +0 -9
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -1,79 +1,62 @@
|
|
1
|
-
## NOTICE: Project is unmaintained because the Scoroid API no longer exists.
|
2
|
-
|
3
|
-
This repository is left for historical reasons.
|
4
|
-
|
5
1
|
Scoreoid Ruby
|
6
2
|
=============
|
7
3
|
|
8
|
-
[![Build Status](https://travis-ci.org/xtagon/scoreoid-gem.png)](https://travis-ci.org/xtagon/scoreoid-gem)
|
9
|
-
|
10
4
|
Summary
|
11
5
|
-------
|
12
6
|
|
13
|
-
Scoreoid Ruby is a wrapper for the [Scoreoid]
|
7
|
+
Scoreoid Ruby is a wrapper for the [Scoreoid](https://www.scoreoid.com/) API.
|
14
8
|
|
15
9
|
Installation
|
16
10
|
------------
|
17
11
|
|
18
12
|
Add this line to your application's Gemfile:
|
19
13
|
|
20
|
-
|
21
|
-
gem 'scoreoid'
|
22
|
-
```
|
14
|
+
gem 'scoreoid'
|
23
15
|
|
24
16
|
And then execute:
|
25
17
|
|
26
|
-
|
27
|
-
$ bundle
|
28
|
-
```
|
18
|
+
$ bundle
|
29
19
|
|
30
20
|
Or install it yourself as:
|
31
21
|
|
32
|
-
|
33
|
-
$ gem install scoreoid
|
34
|
-
```
|
22
|
+
$ gem install scoreoid
|
35
23
|
|
36
24
|
Usage
|
37
25
|
-----
|
38
26
|
|
39
|
-
Full documentation is [available online]
|
27
|
+
Full documentation is [available online](http://rubydoc.info/gems/scoreoid/frames).
|
40
28
|
|
41
29
|
To get started, configure Scoreoid Ruby with your API key and game ID:
|
42
30
|
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
Scoreoid.configure(api_key: 'YOUR_API_KEY', game_id: 'YOUR_GAME_ID')
|
47
|
-
```
|
31
|
+
require 'scoreoid'
|
32
|
+
|
33
|
+
Scoreoid.configure(api_key: 'YOUR_API_KEY', game_id: 'YOUR_GAME_ID')
|
48
34
|
|
49
35
|
Then you can start querying Scoreoid API methods:
|
50
36
|
|
51
|
-
|
52
|
-
new_players_count = Scoreoid::API.query('countPlayers', start_date: '2009-08-04')
|
53
|
-
new_players_count['players'] # => 34
|
54
|
-
```
|
55
|
-
|
56
|
-
Any Scoreoid API method may be called in this manner. See the [Scoreoid Wiki][3] for information on available API methods.
|
37
|
+
new_players_count = Scoreoid::API.query('countPlayers', start_date: '2009-08-04')
|
57
38
|
|
58
|
-
|
39
|
+
Any Scoreoid API method may be called in this mannor. See the [Scoreoid Wiki](http://wiki.scoreoid.net/category/api/) for information on available API methods.
|
59
40
|
|
60
|
-
|
61
|
-
Scoreoid::Player.count # => 34
|
62
|
-
```
|
41
|
+
Future versions of Scoreoid Ruby will provide a more object-oriented mannor of querying data. See the `Scoreoid::Player` class for a basic example of this.
|
63
42
|
|
64
43
|
Contributing
|
65
44
|
------------
|
66
45
|
|
67
46
|
Contributions are most welcome!
|
68
47
|
|
69
|
-
|
48
|
+
1. [Fork it on Bitbucket](https://bitbucket.org/xtagon/scoreoid-ruby-gem/fork)
|
49
|
+
2. Create your feature branch (`git checkout -b feature/my-new-feature`)
|
50
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
51
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
52
|
+
5. Create new Pull Request
|
70
53
|
|
71
|
-
Please use the [issue tracker]
|
54
|
+
Please use the [issue tracker](https://bitbucket.org/xtagon/scoreoid-ruby-gem/issues?status=new&status=open) if you encounter a bug or have a feature request.
|
72
55
|
|
73
56
|
License
|
74
57
|
-------
|
75
58
|
|
76
|
-
Copyright © 2012
|
59
|
+
Copyright © 2012 [Justin Workman](mailto:xtagon@gmail.com)
|
77
60
|
|
78
61
|
MIT License
|
79
62
|
|
@@ -95,10 +78,3 @@ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
95
78
|
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
96
79
|
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
97
80
|
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
98
|
-
|
99
|
-
[1]: https://rubygems.org/gems/scoreoid
|
100
|
-
[2]: http://rubydoc.info/gems/scoreoid/frames
|
101
|
-
[3]: http://wiki.scoreoid.net/category/api/
|
102
|
-
[4]: https://github.com/xtagon/scoreoid-gem
|
103
|
-
[5]: https://bitbucket.org/xtagon/scoreoid-gem
|
104
|
-
[6]: https://github.com/xtagon/scoreoid-gem/issues
|
data/lib/scoreoid/api.rb
CHANGED
@@ -9,11 +9,6 @@ module Scoreoid
|
|
9
9
|
# A singleton class with methods for querying the Scoreoid API.
|
10
10
|
class API
|
11
11
|
class << self
|
12
|
-
# Default API request parameters used by {.query}
|
13
|
-
#
|
14
|
-
# This would normally be set with {Scoreoid.configure}
|
15
|
-
attr_accessor :default_params
|
16
|
-
|
17
12
|
# Query a given Scoreoid API method and return the repsonse as a string.
|
18
13
|
#
|
19
14
|
# Supplied parameters will be prepared with {.prepare_params} before sending.
|
@@ -59,13 +54,10 @@ module Scoreoid
|
|
59
54
|
api_response.sub!(/\]\Z/, '') # Remove trailing bracket
|
60
55
|
end
|
61
56
|
|
62
|
-
# Parse the response
|
63
57
|
parsed_result = MultiJson.load(api_response)
|
64
58
|
|
65
|
-
# Raise an error if the response JSON contained one
|
66
59
|
raise APIError, parsed_result['error'] if parsed_result.key? 'error'
|
67
60
|
|
68
|
-
# Return the parsed result
|
69
61
|
parsed_result
|
70
62
|
end
|
71
63
|
|
@@ -94,6 +86,11 @@ module Scoreoid
|
|
94
86
|
end
|
95
87
|
params
|
96
88
|
end
|
89
|
+
|
90
|
+
# Default API request parameters used by {.query}
|
91
|
+
#
|
92
|
+
# This would normally be set with {Scoreoid.configure}
|
93
|
+
attr_accessor :default_params
|
97
94
|
end
|
98
95
|
end
|
99
96
|
end
|
data/lib/scoreoid/player.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
module Scoreoid
|
2
2
|
# Represents the game players.
|
3
3
|
class Player
|
4
|
-
# Get the number of players for
|
4
|
+
# Get the number of players for the game.
|
5
5
|
#
|
6
6
|
# @example Count the total number of players
|
7
7
|
# puts "This game has #{Scoreoid::Player.count} total players."
|
@@ -10,150 +10,13 @@ module Scoreoid
|
|
10
10
|
# count = Scoreoid::Player.count(start_date: '2012-11-01')
|
11
11
|
# puts "There are #{count} new players since 2012-11-01."
|
12
12
|
#
|
13
|
-
# @param [Hash] params
|
14
|
-
#
|
15
|
-
#
|
16
|
-
# @option params [String] :api_key Your Scoreoid API key
|
17
|
-
# @option params [String] :game_id The game ID
|
18
|
-
# @option params [Date, Time, String] :start_date optional
|
19
|
-
# @option params [Date, Time, String] :end_date optional
|
13
|
+
# @param [Hash] params Optional criteria for counting players.
|
14
|
+
# @option params [Date, Time, String] :start_date Start date ("YYYY-MM-DD" if passed as String)
|
15
|
+
# @option params [Date, Time, String] :end_date End date ("YYYY-MM-DD" if passed as String)
|
20
16
|
#
|
21
17
|
# @return [Integer] The number of players.
|
22
18
|
def self.count(params={})
|
23
19
|
Scoreoid::API.query_and_parse('countPlayers', params)['players']
|
24
20
|
end
|
25
|
-
|
26
|
-
# Create a new player for a game.
|
27
|
-
#
|
28
|
-
# @example Create a player named Bob
|
29
|
-
# Scoreoid::Player.create(username: 'bob', first_name: 'Bob', last_name: 'Ross')
|
30
|
-
#
|
31
|
-
# @param [Hash] params Parameters to include in the API request.
|
32
|
-
# Default parameters set with {Scoreoid.configure} will be included for you.
|
33
|
-
#
|
34
|
-
# @option params [String] :api_key Your Scoreoid API key
|
35
|
-
# @option params [String] :game_id The game ID
|
36
|
-
# @option params [String] :username The player's username (required)
|
37
|
-
# @option params [String] :password Optional
|
38
|
-
# @option params [String] :score optional
|
39
|
-
# @option params [String] :difficulty optional
|
40
|
-
# @option params [String] :unique_id optional
|
41
|
-
# @option params [String] :first_name optional
|
42
|
-
# @option params [String] :last_name optional
|
43
|
-
# @option params [String] :email optional
|
44
|
-
# @option params [String] :created optional
|
45
|
-
# @option params [String] :updated optional
|
46
|
-
# @option params [String] :bonus optional
|
47
|
-
# @option params [String] :achievements optional
|
48
|
-
# @option params [String] :best_score optional
|
49
|
-
# @option params [String] :gold optional
|
50
|
-
# @option params [String] :money optional
|
51
|
-
# @option params [String] :kills optional
|
52
|
-
# @option params [String] :lives optional
|
53
|
-
# @option params [String] :time_played optional
|
54
|
-
# @option params [String] :unlocked_levels optional
|
55
|
-
# @option params [String] :unlocked_items optional
|
56
|
-
# @option params [String] :inventory optional
|
57
|
-
# @option params [String] :last_level optional
|
58
|
-
# @option params [String] :current_level optional
|
59
|
-
# @option params [String] :current_time optional
|
60
|
-
# @option params [String] :current_bonus optional
|
61
|
-
# @option params [String] :current_kills optional
|
62
|
-
# @option params [String] :current_achievements optional
|
63
|
-
# @option params [String] :current_gold optional
|
64
|
-
# @option params [String] :current_unlocked_levels optional
|
65
|
-
# @option params [String] :current_unlocked_items optional
|
66
|
-
# @option params [String] :current_lives optional
|
67
|
-
# @option params [String] :xp optional
|
68
|
-
# @option params [String] :energy optional
|
69
|
-
# @option params [String] :boost optional
|
70
|
-
# @option params [String] :latitude optional
|
71
|
-
# @option params [String] :longitude optional
|
72
|
-
# @option params [String] :game_state optional
|
73
|
-
# @option params [String] :platform optional
|
74
|
-
#
|
75
|
-
# @raise [Scoreoid::APIError] if the player could not be created
|
76
|
-
#
|
77
|
-
# @return [Hash] The API response from Scoreoid (should contain a success message)
|
78
|
-
def self.create(params={})
|
79
|
-
Scoreoid::API.query_and_parse('createPlayer', params)
|
80
|
-
end
|
81
|
-
|
82
|
-
# Edit player information.
|
83
|
-
#
|
84
|
-
# @example Update John's first and last name
|
85
|
-
# Scoreoid::Player.edit(username: 'john', first_name: 'John', last_name: 'Dough')
|
86
|
-
#
|
87
|
-
# @param [Hash] params Parameters to include in the API request.
|
88
|
-
# Default parameters set with {Scoreoid.configure} will be included for you.
|
89
|
-
#
|
90
|
-
# @option params [String] :api_key Your Scoreoid API key
|
91
|
-
# @option params [String] :game_id The game ID
|
92
|
-
# @option params [String] :username The player's username (required)
|
93
|
-
# @option params [String] :password Optional
|
94
|
-
# @option params [String] :score optional
|
95
|
-
# @option params [String] :difficulty optional
|
96
|
-
# @option params [String] :unique_id optional
|
97
|
-
# @option params [String] :first_name optional
|
98
|
-
# @option params [String] :last_name optional
|
99
|
-
# @option params [String] :email optional
|
100
|
-
# @option params [String] :created optional
|
101
|
-
# @option params [String] :updated optional
|
102
|
-
# @option params [String] :bonus optional
|
103
|
-
# @option params [String] :achievements optional
|
104
|
-
# @option params [String] :best_score optional
|
105
|
-
# @option params [String] :gold optional
|
106
|
-
# @option params [String] :money optional
|
107
|
-
# @option params [String] :kills optional
|
108
|
-
# @option params [String] :lives optional
|
109
|
-
# @option params [String] :time_played optional
|
110
|
-
# @option params [String] :unlocked_levels optional
|
111
|
-
# @option params [String] :unlocked_items optional
|
112
|
-
# @option params [String] :inventory optional
|
113
|
-
# @option params [String] :last_level optional
|
114
|
-
# @option params [String] :current_level optional
|
115
|
-
# @option params [String] :current_time optional
|
116
|
-
# @option params [String] :current_bonus optional
|
117
|
-
# @option params [String] :current_kills optional
|
118
|
-
# @option params [String] :current_achievements optional
|
119
|
-
# @option params [String] :current_gold optional
|
120
|
-
# @option params [String] :current_unlocked_levels optional
|
121
|
-
# @option params [String] :current_unlocked_items optional
|
122
|
-
# @option params [String] :current_lives optional
|
123
|
-
# @option params [String] :xp optional
|
124
|
-
# @option params [String] :energy optional
|
125
|
-
# @option params [String] :boost optional
|
126
|
-
# @option params [String] :latitude optional
|
127
|
-
# @option params [String] :longitude optional
|
128
|
-
# @option params [String] :game_state optional
|
129
|
-
# @option params [String] :platform optional
|
130
|
-
#
|
131
|
-
# @raise [Scoreoid::APIError] if the player could not be updated
|
132
|
-
#
|
133
|
-
# @return [Hash] The API response from Scoreoid (should contain a success message)
|
134
|
-
def self.edit(params={})
|
135
|
-
Scoreoid::API.query_and_parse('editPlayer', params)
|
136
|
-
end
|
137
|
-
|
138
|
-
# Updates a players field.
|
139
|
-
#
|
140
|
-
# @example Update John's e-mail address
|
141
|
-
# Scoreoid::Player.update_field(username: 'john', field: 'email', value: 'john@example.com')
|
142
|
-
#
|
143
|
-
# @param [Hash] params Parameters to include in the API request.
|
144
|
-
# Default parameters set with {Scoreoid.configure} will be included for you.
|
145
|
-
#
|
146
|
-
# @option params [String] :api_key Your Scoreoid API key
|
147
|
-
# @option params [String] :game_id The game ID
|
148
|
-
# @option params [String] :username The player's username (required)
|
149
|
-
# @option params [String] :field The field name to update (see {.edit})
|
150
|
-
# @option params [String] :value The value to set
|
151
|
-
#
|
152
|
-
# @raise [Scoreoid::APIError] if the field could not be updated
|
153
|
-
#
|
154
|
-
# @return [Hash] The API response from Scoreoid (should contain a success message)
|
155
|
-
def self.update_field(params={})
|
156
|
-
Scoreoid::API.query_and_parse('updatePlayerField', params)
|
157
|
-
end
|
158
21
|
end
|
159
22
|
end
|
data/lib/scoreoid/version.rb
CHANGED
data/scoreoid.gemspec
CHANGED
@@ -11,8 +11,6 @@ Gem::Specification.new do |gem|
|
|
11
11
|
gem.summary = 'Scoreoid Ruby is a wrapper for the Scoreoid API.'
|
12
12
|
gem.license = 'MIT'
|
13
13
|
|
14
|
-
gem.metadata = { 'rubygems_mfa_required' => 'true' }
|
15
|
-
|
16
14
|
gem.required_ruby_version = '1.9.2'
|
17
15
|
gem.add_runtime_dependency 'chronic', '~> 0.8.0'
|
18
16
|
gem.add_runtime_dependency 'multi_json', '~> 1.3'
|
File without changes
|
data/spec/player_spec.rb
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Scoreoid::Player do
|
4
|
+
describe '.count' do
|
5
|
+
it 'should count players with no query parameters' do
|
6
|
+
Scoreoid::API.stub(:query_and_parse).and_return({'players' => 7})
|
7
|
+
Scoreoid::API.should_receive(:query_and_parse).with('countPlayers', {})
|
8
|
+
count = Scoreoid::Player.count
|
9
|
+
count.should == 7
|
10
|
+
end
|
11
|
+
|
12
|
+
it 'should count players with query parameters' do
|
13
|
+
params = {start_date: '2011-11-01', end_date: Time.now}
|
14
|
+
Scoreoid::API.stub(:query_and_parse).and_return({'players' => 7})
|
15
|
+
Scoreoid::API.should_receive(:query_and_parse).with('countPlayers', params)
|
16
|
+
count = Scoreoid::Player.count(params)
|
17
|
+
count.should == 7
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
metadata
CHANGED
@@ -1,55 +1,62 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: scoreoid
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.1
|
4
|
+
version: 1.1.1
|
5
|
+
prerelease:
|
5
6
|
platform: ruby
|
6
7
|
authors:
|
7
8
|
- Justin Workman
|
8
9
|
autorequire:
|
9
10
|
bindir: bin
|
10
11
|
cert_chain: []
|
11
|
-
date:
|
12
|
+
date: 2012-11-26 00:00:00.000000000 Z
|
12
13
|
dependencies:
|
13
14
|
- !ruby/object:Gem::Dependency
|
14
15
|
name: chronic
|
15
16
|
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
16
18
|
requirements:
|
17
|
-
- -
|
19
|
+
- - ~>
|
18
20
|
- !ruby/object:Gem::Version
|
19
21
|
version: 0.8.0
|
20
22
|
type: :runtime
|
21
23
|
prerelease: false
|
22
24
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
23
26
|
requirements:
|
24
|
-
- -
|
27
|
+
- - ~>
|
25
28
|
- !ruby/object:Gem::Version
|
26
29
|
version: 0.8.0
|
27
30
|
- !ruby/object:Gem::Dependency
|
28
31
|
name: multi_json
|
29
32
|
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
30
34
|
requirements:
|
31
|
-
- -
|
35
|
+
- - ~>
|
32
36
|
- !ruby/object:Gem::Version
|
33
37
|
version: '1.3'
|
34
38
|
type: :runtime
|
35
39
|
prerelease: false
|
36
40
|
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
37
42
|
requirements:
|
38
|
-
- -
|
43
|
+
- - ~>
|
39
44
|
- !ruby/object:Gem::Version
|
40
45
|
version: '1.3'
|
41
46
|
- !ruby/object:Gem::Dependency
|
42
47
|
name: rest-client
|
43
48
|
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
44
50
|
requirements:
|
45
|
-
- -
|
51
|
+
- - ~>
|
46
52
|
- !ruby/object:Gem::Version
|
47
53
|
version: '1.6'
|
48
54
|
type: :runtime
|
49
55
|
prerelease: false
|
50
56
|
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
51
58
|
requirements:
|
52
|
-
- -
|
59
|
+
- - ~>
|
53
60
|
- !ruby/object:Gem::Version
|
54
61
|
version: '1.6'
|
55
62
|
description:
|
@@ -58,10 +65,9 @@ executables: []
|
|
58
65
|
extensions: []
|
59
66
|
extra_rdoc_files: []
|
60
67
|
files:
|
61
|
-
-
|
62
|
-
-
|
63
|
-
-
|
64
|
-
- ".yardopts"
|
68
|
+
- .gitignore
|
69
|
+
- .rspec
|
70
|
+
- .yardopts
|
65
71
|
- CHANGES.md
|
66
72
|
- Gemfile
|
67
73
|
- LICENSE.txt
|
@@ -72,38 +78,40 @@ files:
|
|
72
78
|
- lib/scoreoid/player.rb
|
73
79
|
- lib/scoreoid/version.rb
|
74
80
|
- scoreoid.gemspec
|
75
|
-
- spec/
|
76
|
-
- spec/
|
77
|
-
- spec/scoreoid/version_spec.rb
|
81
|
+
- spec/api_spec.rb
|
82
|
+
- spec/player_spec.rb
|
78
83
|
- spec/scoreoid_spec.rb
|
79
84
|
- spec/spec_helper.rb
|
85
|
+
- spec/version_spec.rb
|
80
86
|
homepage:
|
81
87
|
licenses:
|
82
88
|
- MIT
|
83
|
-
metadata:
|
84
|
-
rubygems_mfa_required: 'true'
|
85
89
|
post_install_message:
|
86
90
|
rdoc_options: []
|
87
91
|
require_paths:
|
88
92
|
- lib
|
89
93
|
required_ruby_version: !ruby/object:Gem::Requirement
|
94
|
+
none: false
|
90
95
|
requirements:
|
91
96
|
- - '='
|
92
97
|
- !ruby/object:Gem::Version
|
93
98
|
version: 1.9.2
|
94
99
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
100
|
+
none: false
|
95
101
|
requirements:
|
96
|
-
- -
|
102
|
+
- - ! '>='
|
97
103
|
- !ruby/object:Gem::Version
|
98
|
-
version:
|
104
|
+
version: '0'
|
99
105
|
requirements: []
|
100
|
-
|
106
|
+
rubyforge_project:
|
107
|
+
rubygems_version: 1.8.24
|
101
108
|
signing_key:
|
102
|
-
specification_version:
|
109
|
+
specification_version: 3
|
103
110
|
summary: Scoreoid Ruby is a wrapper for the Scoreoid API.
|
104
111
|
test_files:
|
105
|
-
- spec/
|
106
|
-
- spec/
|
107
|
-
- spec/scoreoid/version_spec.rb
|
112
|
+
- spec/api_spec.rb
|
113
|
+
- spec/player_spec.rb
|
108
114
|
- spec/scoreoid_spec.rb
|
109
115
|
- spec/spec_helper.rb
|
116
|
+
- spec/version_spec.rb
|
117
|
+
has_rdoc:
|
checksums.yaml
DELETED
@@ -1,7 +0,0 @@
|
|
1
|
-
---
|
2
|
-
SHA256:
|
3
|
-
metadata.gz: 053fe26edc9947c41476ce2e2539a66d6e928e5dc09ef8cf9883e3d606af0c06
|
4
|
-
data.tar.gz: 7d03f92f8fb9d44337f494a60ccd715e0c61e226e5c0ee84e7e740c4d9e58865
|
5
|
-
SHA512:
|
6
|
-
metadata.gz: 7bebbfe865785aa65cec817db5b8032c2aa896c0ce2fb9b45331d2256d12b75d52601c2befe262900818eef835b7e87c7065f1bbd4fa8211480fd7821d89515a
|
7
|
-
data.tar.gz: 80b430ad30cfe62d0f010141a2a9c55e7393118e72daeb73662f0ac67d2563e0e8203e4dfea22b82c1078191649d6dc1da7dba19ed9c452a167e95794dc0f825
|
data/.travis.yml
DELETED
@@ -1,73 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Scoreoid::Player do
|
4
|
-
describe '.create' do
|
5
|
-
it 'should return true on successfully creating a player' do
|
6
|
-
success_response = %q({"success":["The player has been created"]})
|
7
|
-
params = {username: 'AzureDiamond', password: 'hunter2'}
|
8
|
-
|
9
|
-
Scoreoid::API.stub(:query_and_parse).and_return(success_response)
|
10
|
-
Scoreoid::API.should_receive(:query_and_parse).with('createPlayer', params)
|
11
|
-
|
12
|
-
expect do
|
13
|
-
Scoreoid::Player.create(params).should be_true
|
14
|
-
end.to_not raise_error
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
describe '.count' do
|
19
|
-
it 'should count players with no query parameters' do
|
20
|
-
Scoreoid::API.stub(:query_and_parse).and_return({'players' => 7})
|
21
|
-
Scoreoid::API.should_receive(:query_and_parse).with('countPlayers', {})
|
22
|
-
count = Scoreoid::Player.count
|
23
|
-
count.should == 7
|
24
|
-
end
|
25
|
-
|
26
|
-
it 'should count players with query parameters' do
|
27
|
-
params = {start_date: '2011-11-01', end_date: Time.now}
|
28
|
-
Scoreoid::API.stub(:query_and_parse).and_return({'players' => 7})
|
29
|
-
Scoreoid::API.should_receive(:query_and_parse).with('countPlayers', params)
|
30
|
-
count = Scoreoid::Player.count(params)
|
31
|
-
count.should == 7
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
describe '.create' do
|
36
|
-
it 'should create the player and return the parsed API response' do
|
37
|
-
success_response = {'success' => ['The player has been created']}
|
38
|
-
params = {username: 'AzureDiamond', password: 'hunter2'}
|
39
|
-
|
40
|
-
Scoreoid::API.stub(:query_and_parse).and_return(success_response)
|
41
|
-
Scoreoid::API.should_receive(:query_and_parse).with('createPlayer', params)
|
42
|
-
|
43
|
-
response = Scoreoid::Player.create(params)
|
44
|
-
response.should == success_response
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
describe '.edit' do
|
49
|
-
it 'should edit the player and return the parsed API response' do
|
50
|
-
success_response = {'success' => ['The player has been updated']}
|
51
|
-
params = {username: 'AzureDiamond', password: '*******'}
|
52
|
-
|
53
|
-
Scoreoid::API.stub(:query_and_parse).and_return(success_response)
|
54
|
-
Scoreoid::API.should_receive(:query_and_parse).with('editPlayer', params)
|
55
|
-
|
56
|
-
response = Scoreoid::Player.edit(params)
|
57
|
-
response.should == success_response
|
58
|
-
end
|
59
|
-
end
|
60
|
-
|
61
|
-
describe '.update_field' do
|
62
|
-
it 'should update the player field and return the parsed API response' do
|
63
|
-
success_response = {'success' => ['The player field last_name has been updated']}
|
64
|
-
params = {username: 'john', field: 'last_name', value: 'Doe'}
|
65
|
-
|
66
|
-
Scoreoid::API.stub(:query_and_parse).and_return(success_response)
|
67
|
-
Scoreoid::API.should_receive(:query_and_parse).with('updatePlayerField', params)
|
68
|
-
|
69
|
-
response = Scoreoid::Player.update_field(params)
|
70
|
-
response.should == success_response
|
71
|
-
end
|
72
|
-
end
|
73
|
-
end
|
@@ -1,9 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Scoreoid do
|
4
|
-
it 'has a valid version constant' do
|
5
|
-
# This regex is far from perfect, but it should keep me from accidentally
|
6
|
-
# doing something stupid to the version.
|
7
|
-
Scoreoid::VERSION.should =~ /\A\d+\.\d+\.\d+(\.\w+)?\Z/
|
8
|
-
end
|
9
|
-
end
|