binarybeast 0.0.1pre

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in binarybeast.gemspec
4
+ gemspec
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2012 Crispin Schäffler
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.
@@ -0,0 +1,29 @@
1
+ # Binarybeast
2
+
3
+ TODO: Write a gem description
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'binarybeast'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install binarybeast
18
+
19
+ ## Usage
20
+
21
+ TODO: Write usage instructions here
22
+
23
+ ## Contributing
24
+
25
+ 1. Fork it
26
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
27
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
28
+ 4. Push to the branch (`git push origin my-new-feature`)
29
+ 5. Create new Pull Request
@@ -0,0 +1,6 @@
1
+ require 'bundler/gem_tasks'
2
+ require "rake/testtask"
3
+ require 'rspec/core/rake_task'
4
+
5
+ RSpec::Core::RakeTask.new('spec')
6
+ task :default => :spec
@@ -0,0 +1,23 @@
1
+ # -*- encoding: utf-8 -*-
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'binarybeast/version'
5
+
6
+ Gem::Specification.new do |gem|
7
+ gem.name = "binarybeast"
8
+ gem.version = Binarybeast::VERSION
9
+ gem.authors = ["Crispin Schaeffler"]
10
+ gem.email = ["crispinschaeffler@googlemail.com"]
11
+ gem.description = %q{Ruby gem to access the binary beast api.}
12
+ gem.summary = %q{Ruby gem to access the binary beast api.}
13
+ gem.homepage = ""
14
+
15
+ gem.files = `git ls-files`.split($/)
16
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
17
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
18
+ gem.require_paths = ["lib"]
19
+ gem.add_runtime_dependency 'httparty'
20
+ gem.add_development_dependency 'rspec'
21
+ gem.add_development_dependency 'turn'
22
+ gem.add_development_dependency 'rake'
23
+ end
@@ -0,0 +1,222 @@
1
+ require "HTTParty"
2
+ Dir[File.dirname(__FILE__) + '/binarybeast/*.rb'].each do |file|
3
+ require file
4
+ end
5
+
6
+ # Binarybeast
7
+ # Module
8
+ # ---------------------
9
+ # has 1 variable called apikey, this is your apikey. the default is the apikey from gamkoi.com
10
+ # Example
11
+ # Binarybeast.apikey = "12345"
12
+ # => "12345"
13
+ # ---------------------
14
+ # does contain all the classes that interact with binarybeast api.
15
+
16
+ module Binarybeast
17
+ include HTTParty
18
+ # Base URI for the BinaryBeast API
19
+ base_uri 'https://binarybeast.com/api'
20
+ # Set HTTParty standard format to JSON, its standard what binarybeast api returns.
21
+ format :json
22
+ # Default APIKey, this one is taken from my personal account.
23
+ @@apikey = "3c8955130c6e1406420d6202649651fe.50c9faa593f9c6.00530099"
24
+
25
+ # Getter for APIKey Variable
26
+ def self.apikey
27
+ @@apikey
28
+ end
29
+
30
+ # Setter for APIKey Variable
31
+ def self.apikey=(apikey)
32
+ @@apikey=apikey
33
+ end
34
+
35
+ # Tourney
36
+ # Class
37
+ # ---------------
38
+ # This is the Tourney class. It will be used to most. It gives you a brand new Tourney object to call methods on.
39
+ # Example:
40
+ # tourney = Binarybeast::Tourney.new("Gamkoi Test")
41
+ # ---------------
42
+ # gives you a tourney object
43
+
44
+ class Tourney
45
+ include HTTParty
46
+ base_uri 'https://binarybeast.com/api'
47
+ format :json
48
+ attr_accessor :apikey, :tourneyid, :title, :publish, :gamecode, :typeid, :elimination, :teammode, :groupcount, :teamsfromgroup, :datestart, :location, :maxteams, :replayuploads, :replaydownloads, :description, :returndata
49
+
50
+
51
+
52
+ # Constructor
53
+ # Method
54
+ # ----------------
55
+ # all tourney attributes can be given here. The Name parameter is needed, all else is optional.
56
+ # Example:
57
+ # Tourney.new(:title => "Gamkoi DevCup")
58
+ # ----------------
59
+
60
+ def initialize(options={:title => "Gamkoi DevTest"})
61
+ self.tourneyid = options[:tourneyid] if options[:tourneyid]
62
+ options[:title] ? self.title = options[:title] : self.title = "Test"
63
+ options[:public] ? self.publish = options[:public] : self.publish = 0
64
+ options[:gamecode] ? self.gamecode = options[:gamecode] : self.gamecode = ""
65
+ options[:typeid] ? self.typeid = options[:typeid] : self.typeid = 0
66
+ options[:elimination] ? self.elimination = options[:elimination] : self.elimination = 1
67
+ options[:teammode] ? self.teammode = options[:teammode] : self.teammode = 1
68
+ options[:groupcount] ? self.groupcount = options[:groupcount] : self.groupcount = 1
69
+ options[:teamsfromgroup] ? self.teamsfromgroup = options[:teamsfromgroup] : self.teamsfromgroup = 2
70
+ options[:datestart] ? self.datestart = options[:datestart] : self.datestart = nil
71
+ options[:location] ? self.location = options[:location] : self.location = ""
72
+ options[:maxteams] ? self.maxteams = options[:maxteams] : self.maxteams = 16
73
+ options[:replayuploads] ? self.replayuploads = options[:replayuploads] : self.replayuploads = 1
74
+ options[:replaydownloads] ? self.replaydownloads = options[:replaydownloads] : self.replaydownloads = 1
75
+ options[:description] ? self.description = options[:description] : self.description = ""
76
+ options[:returndata] ? self.returndata = options[:returndata] : self.returndata = 0
77
+ options[:apikey] ? self.apikey = options[:apikey] : self.apikey = Binarybeast.apikey
78
+ end
79
+
80
+
81
+ # Update
82
+ # Method
83
+ # ----------------
84
+ # Pushes the attributes from the object to the binarybeast api. Pushes updates from object to Binarybeast
85
+ # Example:
86
+ # @tourney = Binarybeast::Tourney.new(:title => "lol")
87
+ # @tourney.update
88
+ # ----------------
89
+
90
+ def update(options={:force => false})
91
+ response = self.class.get("", :query => {:TourneyID => self.tourneyid, :APIKey => self.apikey, :APIService => "Tourney.TourneyUpdate.Settings",
92
+ :Title => self.title, :Public => self.publish, :GameCode => self.gamecode,
93
+ :TypeID => self.typeid, :Elimination => self.elimination,
94
+ :TeamMode => self.teammode, :GroupCount => self.groupcount,
95
+ :TeamsFromGroup => self.teamsfromgroup, :DateStart => self.datestart,
96
+ :Location => self.location, :MaxTeams => self.maxteams, :ReplayUploads => self.replayuploads,
97
+ :ReplayDownloads => self.replaydownloads, :Description => self.description, :ReturnData => self.returndata})
98
+ options[:force] ? response : response["Result"] == 200 ? true : false
99
+ end
100
+
101
+ # Create
102
+ # Method
103
+ # ----------------
104
+ # Creates the tournament object at binarybeast. You want to call this once after setting up your local Tourney object.
105
+ # Example:
106
+ # @tourney = Binarybeast::Tourny.new
107
+ # @tourney.title = "Blabla"
108
+ # @tourney.description = "Changing some attributes locally..."
109
+ # @tourney.create
110
+ # ----------------
111
+
112
+ def create(options={:force => false})
113
+ response = self.class.get("", :query => {:APIKey => self.apikey, :APIService => "Tourney.TourneyCreate.Create",
114
+ :Title => self.title, :Public => self.publish, :GameCode => self.gamecode,
115
+ :TypeID => self.typeid, :Elimination => self.elimination,
116
+ :TeamMode => self.teammode, :GroupCount => self.groupcount,
117
+ :TeamsFromGroup => self.teamsfromgroup, :DateStart => self.datestart,
118
+ :Location => self.location, :MaxTeams => self.maxteams, :ReplayUploads => self.replayuploads,
119
+ :ReplayDownloads => self.replaydownloads, :Description => self.description, :ReturnData => self.returndata})
120
+ self.tourneyid = response["TourneyID"] if response["Result"] == 200
121
+ options[:force] ? response : response["Result"] == 200 ? true : false
122
+ end
123
+
124
+ # Delete
125
+ # Method
126
+ # ----------------
127
+ # Deletes the tourney object from binarybeast. Does not delete the tourney object itself locally.
128
+ # Example:
129
+ # @tourney = Binarybeast::Tourney.new(:title => "Test")
130
+ # @tourney.create
131
+ # @tourney.delete
132
+ # ----------------
133
+
134
+ def delete(options={:force => false})
135
+ response = self.class.get("", :query => {:APIKey => self.apikey, :APIService => "Tourney.TourneyDelete.Delete", :TourneyID => self.tourneyid})
136
+ options[:force] ? response : response["Result"] == 200 ? true : false
137
+ end
138
+
139
+ # Start
140
+ # Method
141
+ # ----------------
142
+ # Starts the object tourney on binarybeast.
143
+ # Example:
144
+ # @tourney = Binarybeast::Tourney.new(:title => "test")
145
+ # @tourney.create
146
+ # @tourney.start
147
+ # ----------------
148
+
149
+ def start(options={:force => false})
150
+ options[:force] ? force = true : force = false
151
+ options[:seeding] ? seeding = options[:seeding] : seeding = "random"
152
+ options[:teams] ? teams = options[:teams] : teams = nil
153
+ response = self.class.get("", :query => {:APIKey => self.apikey, :APIService => "Tourney.TourneyStart.Start", :Seeding => seeding, :Teams => teams})
154
+ options[:force] ? response : response["Result"] == 200 ? true : false
155
+ end
156
+
157
+ # Load
158
+ # Method
159
+ # ----------------
160
+ # Loads the information of a binarybeast tourney and saving it in the object. Pulling information - inverse of update
161
+ # Example:
162
+ # @tourney = Binarybeast::Tourney.new(:tourneyid => "xSC21212194")
163
+ # @tourney.load
164
+ # ----------------
165
+
166
+ def load(options={:force => false})
167
+ response = self.class.get("", :query => {:APIKey => self.apikey, :APIService => "Tourney.TourneyLoad.Info", :TourneyID => self.tourneyid})
168
+ return response if options[:force]
169
+ if response["Result"] == 200
170
+ self.title = response["TourneyInfo"]["Title"]
171
+ self.publish = response["TourneyInfo"]["Public"]
172
+ self.gamecode = response["TourneyInfo"]["GameCode"]
173
+ self.typeid = response["TourneyInfo"]["TypeID"]
174
+ self.elimination = response["TourneyInfo"]["Elimination"]
175
+ self.teammode = response["TourneyInfo"]["TeamMode"]
176
+ self.groupcount = response["TourneyInfo"]["GroupCount"]
177
+ self.teamsfromgroup = response["TourneyInfo"]["TeamsFromGroup"]
178
+ self.datestart = response["TourneyInfo"]["DateStart"]
179
+ self.location = response["TourneyInfo"]["Location"]
180
+ self.maxteams = response["TourneyInfo"]["MaxTeams"]
181
+ self.replayuploads = response["TourneyInfo"]["ReplayUploads"]
182
+ self.replaydownloads = response["TourneyInfo"]["ReplayDownloads"]
183
+ self.description = response["TourneyInfo"]["Description"]
184
+ self.returndata = response["TourneyInfo"]["ReturnData"]
185
+ return true
186
+ else
187
+ return false
188
+ end
189
+ end
190
+
191
+ # setBuilding
192
+ # Method
193
+ # ----------------
194
+ # Sets the status of the tourney correlating to the object to: Status: Building
195
+ # Example:
196
+ # @tourney = Binarybeast::Tourney.new
197
+ # @tourney.setBuilding
198
+ # ----------------
199
+
200
+ def setBuilding(options={:force => false})
201
+ response = self.class.get("", :query => {:APIKey => self.apikey, :APIService => "Tourney.TourneySetStatus.Building", :TourneyID => self.tourneyid})
202
+ options[:force] ? response : response["Result"] == 200 ? true : false
203
+ end
204
+
205
+ # setConfirmation
206
+ # Method
207
+ # ----------------
208
+ # Sets the status of the tourney correlating to the object to: Status: Confirmation
209
+ # Example:
210
+ # @tourney = Binarybeast::Tourney.new
211
+ # @tourney.setConfirmation
212
+ # ----------------
213
+
214
+ def setConfirmation(options={:force => false})
215
+ response = self.class.get("", :query => {:APIKey => self.apikey, :APIService => "Tourney.TourneySetStatus.Confirmation", :TourneyID => self.tourneyid})
216
+ options[:force] ? response : response["Result"] == 200 ? true : false
217
+ end
218
+
219
+ end
220
+ # END Class Tourney
221
+
222
+ end
@@ -0,0 +1,3 @@
1
+ module Binarybeast
2
+ VERSION = "0.0.1pre"
3
+ end
@@ -0,0 +1,7 @@
1
+ require 'spec_helper'
2
+
3
+ describe Binarybeast do
4
+ it "must have apikey variable" do
5
+ Binarybeast.apikey.should == "3c8955130c6e1406420d6202649651fe.50c9faa593f9c6.00530099"
6
+ end
7
+ end
@@ -0,0 +1,7 @@
1
+ require_relative '../lib/binarybeast'
2
+ require 'rspec'
3
+
4
+ RSpec.configure do |c|
5
+ c.color_enabled = true
6
+ c.formatter = 'documentation'
7
+ end
@@ -0,0 +1,93 @@
1
+ require 'spec_helper'
2
+
3
+ describe Binarybeast::Tourney do
4
+ before :all do
5
+ @tourney = Binarybeast::Tourney.new(:title => "Gamkoi DevTest Ruby", :description => "This is a tourney created via the Gamkoi.com ruby gem.")
6
+ end
7
+ describe "new" do
8
+ it "takes one to all parameters and returns an tourney object" do
9
+ @tourney.should be_an_instance_of Binarybeast::Tourney
10
+ end
11
+ it "should respond to title" do
12
+ @tourney.title.should eq("Gamkoi DevTest Ruby")
13
+ end
14
+ it "should respond to description" do
15
+ @tourney.description.should eq("This is a tourney created via the Gamkoi.com ruby gem.")
16
+ end
17
+ it "should respond to all attributes" do
18
+ @tourney.should respond_to(:title)
19
+ @tourney.should respond_to(:tourneyid)
20
+ @tourney.should respond_to(:publish)
21
+ @tourney.should respond_to(:gamecode)
22
+ @tourney.should respond_to(:typeid)
23
+ @tourney.should respond_to(:elimination)
24
+ @tourney.should respond_to(:teammode)
25
+ @tourney.should respond_to(:groupcount)
26
+ @tourney.should respond_to(:teamsfromgroup)
27
+ @tourney.should respond_to(:datestart)
28
+ @tourney.should respond_to(:location)
29
+ @tourney.should respond_to(:maxteams)
30
+ @tourney.should respond_to(:replayuploads)
31
+ @tourney.should respond_to(:replaydownloads)
32
+ @tourney.should respond_to(:description)
33
+ @tourney.should respond_to(:returndata)
34
+ @tourney.should respond_to(:apikey)
35
+ end
36
+ end
37
+ describe "update" do
38
+ it "should respond to update" do
39
+ @tourney.should respond_to(:update)
40
+ response = @tourney.update(:force => true)
41
+ response.should be_instance_of Hash
42
+ end
43
+ end
44
+ describe "create" do
45
+ it "should respond to publish" do
46
+ @tourney.should respond_to(:publish)
47
+ end
48
+ it "should return parsed json array" do
49
+ @tourney.create.should eq(true)
50
+ end
51
+ it "should return forced broadcast" do
52
+ response = @tourney.create(:force => true)
53
+ response["Result"].should eq(200)
54
+ response.should be_instance_of Hash
55
+ end
56
+ end
57
+ describe "delete" do
58
+ it "should respond to delete" do
59
+ @tourney.should respond_to(:delete)
60
+ end
61
+ it "should delete the tourney" do
62
+ tourney = Binarybeast::Tourney.new(:title => "Delete Test")
63
+ tourney.create
64
+ response = tourney.delete(:force => true)
65
+ response.should be_instance_of Hash
66
+ end
67
+ end
68
+ describe "start" do
69
+ it "should respond to start" do
70
+ @tourney.should respond_to(:start)
71
+ end
72
+ it "should start the tourney" do
73
+ end
74
+ end
75
+ describe "load" do
76
+ it "should respond to load" do
77
+ @tourney.should respond_to(:load)
78
+ end
79
+ it "should load a tourney and set attributes" do
80
+ tourney = Binarybeast::Tourney.new(:tourneyid => "xSC21212194")
81
+ tourney.load
82
+ tourney.title.should eq("Gamkoi Dev Dummy")
83
+ end
84
+ end
85
+ describe "set status" do
86
+ it "should respond to building" do
87
+ @tourney.should respond_to(:setBuilding)
88
+ end
89
+ it "should respond to confirmation" do
90
+ @tourney.should respond_to(:setConfirmation)
91
+ end
92
+ end
93
+ end
metadata ADDED
@@ -0,0 +1,123 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: binarybeast
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1pre
5
+ prerelease: 5
6
+ platform: ruby
7
+ authors:
8
+ - Crispin Schaeffler
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-12-19 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: httparty
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
30
+ - !ruby/object:Gem::Dependency
31
+ name: rspec
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ type: :development
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ - !ruby/object:Gem::Dependency
47
+ name: turn
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ - !ruby/object:Gem::Dependency
63
+ name: rake
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ! '>='
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ type: :development
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
78
+ description: Ruby gem to access the binary beast api.
79
+ email:
80
+ - crispinschaeffler@googlemail.com
81
+ executables: []
82
+ extensions: []
83
+ extra_rdoc_files: []
84
+ files:
85
+ - .gitignore
86
+ - Gemfile
87
+ - LICENSE.txt
88
+ - README.md
89
+ - Rakefile
90
+ - binarybeast.gemspec
91
+ - lib/binarybeast.rb
92
+ - lib/binarybeast/version.rb
93
+ - spec/binarybeast_spec.rb
94
+ - spec/spec_helper.rb
95
+ - spec/tourney_spec.rb
96
+ homepage: ''
97
+ licenses: []
98
+ post_install_message:
99
+ rdoc_options: []
100
+ require_paths:
101
+ - lib
102
+ required_ruby_version: !ruby/object:Gem::Requirement
103
+ none: false
104
+ requirements:
105
+ - - ! '>='
106
+ - !ruby/object:Gem::Version
107
+ version: '0'
108
+ required_rubygems_version: !ruby/object:Gem::Requirement
109
+ none: false
110
+ requirements:
111
+ - - ! '>'
112
+ - !ruby/object:Gem::Version
113
+ version: 1.3.1
114
+ requirements: []
115
+ rubyforge_project:
116
+ rubygems_version: 1.8.24
117
+ signing_key:
118
+ specification_version: 3
119
+ summary: Ruby gem to access the binary beast api.
120
+ test_files:
121
+ - spec/binarybeast_spec.rb
122
+ - spec/spec_helper.rb
123
+ - spec/tourney_spec.rb