tedlinks 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 +7 -0
- data/lib/tedlinks.rb +81 -0
- data/lib/tedplayer.rb +33 -0
- metadata +45 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 98241bedbd1a08fba9694cbd32121b301accc6ce
|
4
|
+
data.tar.gz: 44f50942493b4bf3615d8c5783b7a64b83f0e08b
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: f1f93c67d33a9dfe24cf411cfdb4e92d6e8190f32d98dca506c13ea06cd94c60b2c64f2e249188b7d6cc2e48bd8dcde188edc8770ea441f38e72e35bbc0b15ed
|
7
|
+
data.tar.gz: d0e2ce41bae4fb2650da2b67e5a585b278f2ffee04c96d63fb229646e43026cf12d1dc6a24ac1dbc5ffd6f9e1908d6bc0419ea4e92ee896d78e7cf3232561444
|
data/lib/tedlinks.rb
ADDED
@@ -0,0 +1,81 @@
|
|
1
|
+
require 'net/http'
|
2
|
+
require 'tedplayer'
|
3
|
+
|
4
|
+
class TedLinks
|
5
|
+
|
6
|
+
@@base = "http://playground.fireleafstudios.uk/elliot/ted/ted.php"
|
7
|
+
|
8
|
+
def action(url)
|
9
|
+
uri = URI(@@base + url)
|
10
|
+
return Net::HTTP.get_response(uri).body
|
11
|
+
end
|
12
|
+
|
13
|
+
|
14
|
+
# General functions
|
15
|
+
def joinSession(gid, username)
|
16
|
+
res = self.action("?f=join&gid=" + gid.to_s + "&pname="+username).split(",")
|
17
|
+
if (res[0].strip() == "F") then
|
18
|
+
puts "Unable to join session: " + gid.to_s
|
19
|
+
puts res[1].strip()
|
20
|
+
return nil
|
21
|
+
else
|
22
|
+
puts "Successfully joins session: " + gid.to_s
|
23
|
+
return TedPlayer.new(res[1].strip().to_i, username, gid)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def getCurrentState(gid)
|
28
|
+
res = self.action("?f=state&gid="+gid.to_s).to_i
|
29
|
+
puts res
|
30
|
+
end
|
31
|
+
|
32
|
+
def submitLink(gid, pid, link)
|
33
|
+
res = self.action("?f=link&gid="+gid.to_s+"&pid="+pid.to_s+"&pl="+link).split(",")
|
34
|
+
if(res[0].strip() == "F") then
|
35
|
+
puts "Unable to submit link to session: " + gid.to_s
|
36
|
+
else
|
37
|
+
puts "Submitted link sucessfully"
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
def submitVote(gid, pid, vote)
|
42
|
+
res = self.action("?f=vote&gid="+gid.to_s+"&pid="+pid.to_s+"&v="+vote.to_s).split(",")
|
43
|
+
if(res[0].strip() == "F") then
|
44
|
+
puts "Unable to submit vote to session: " + gid.to_s
|
45
|
+
else
|
46
|
+
puts "Successfully submitted vote"
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
def getWinningLink(gid)
|
51
|
+
res = self.action("?f=winn&gid="+gid.to_s).split(",")
|
52
|
+
if(res[0].strip() == "F") then
|
53
|
+
puts "Unable to get last winning link in session: " + gid.to_s
|
54
|
+
else
|
55
|
+
puts res[1].strip()
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
# Admin functions
|
60
|
+
def hostSession(username)
|
61
|
+
res = self.action("?f=gen").split(",")
|
62
|
+
if(res[0].strip() == "F") then
|
63
|
+
puts "Error occured while trying to generate session"
|
64
|
+
return nil
|
65
|
+
else
|
66
|
+
puts "Successfully generated session"
|
67
|
+
gid = res[1].strip()
|
68
|
+
pin = res[2].strip().to_i
|
69
|
+
|
70
|
+
res = self.action("?f=join&gid="+gid+"&pname="+username)
|
71
|
+
if(res[0].strip() == "F") then
|
72
|
+
puts "Session was created but was unable to join"
|
73
|
+
return nil
|
74
|
+
else
|
75
|
+
puts "Successfully joined session: " + gid
|
76
|
+
return TedPlayer.new(res[1].strip().to_i, username, gid.to_i)
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
end
|
data/lib/tedplayer.rb
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
class TedPlayer
|
2
|
+
|
3
|
+
def initialize(pid, name, gid)
|
4
|
+
@pid = pid
|
5
|
+
@name = name
|
6
|
+
@admin = false
|
7
|
+
@pin = -1
|
8
|
+
@gid = gid
|
9
|
+
end
|
10
|
+
|
11
|
+
def setAdmin(pin)
|
12
|
+
@admin = true
|
13
|
+
@pin = pin
|
14
|
+
end
|
15
|
+
|
16
|
+
|
17
|
+
def isAdmin()
|
18
|
+
@admin
|
19
|
+
end
|
20
|
+
|
21
|
+
def getName()
|
22
|
+
@name
|
23
|
+
end
|
24
|
+
|
25
|
+
def getPin()
|
26
|
+
@pin
|
27
|
+
end
|
28
|
+
|
29
|
+
def getGid()
|
30
|
+
@gid
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
metadata
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: tedlinks
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Elliot Lee-Cerrino
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2017-08-17 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: API to access TED game, manage and join sessions
|
14
|
+
email: "@h2n0"
|
15
|
+
executables: []
|
16
|
+
extensions: []
|
17
|
+
extra_rdoc_files: []
|
18
|
+
files:
|
19
|
+
- lib/tedlinks.rb
|
20
|
+
- lib/tedplayer.rb
|
21
|
+
homepage:
|
22
|
+
licenses:
|
23
|
+
- MIT
|
24
|
+
metadata: {}
|
25
|
+
post_install_message:
|
26
|
+
rdoc_options: []
|
27
|
+
require_paths:
|
28
|
+
- lib
|
29
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
35
|
+
requirements:
|
36
|
+
- - ">="
|
37
|
+
- !ruby/object:Gem::Version
|
38
|
+
version: '0'
|
39
|
+
requirements: []
|
40
|
+
rubyforge_project:
|
41
|
+
rubygems_version: 2.5.1
|
42
|
+
signing_key:
|
43
|
+
specification_version: 4
|
44
|
+
summary: API to access TED
|
45
|
+
test_files: []
|