tba 0.2.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.
- checksums.yaml +7 -0
- data/lib/tba.rb +128 -0
- metadata +45 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA1:
|
|
3
|
+
metadata.gz: 1d95a253ac0fb5b628115cdbe359545e9ea0246a
|
|
4
|
+
data.tar.gz: 933d8560ce73af112e7354aa3f2ac522383ddc3e
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 8d39de8767c1ddd85b2f5a45e0a0554beefe7c222ccb4cd11f0ac65fdd4e9a2f33279b57a05ee7f22960e5fce0a3a46f8102873377805efc4816cba053645670
|
|
7
|
+
data.tar.gz: 73eb4bf365cd92e4093cdcdbf8ba605687873e0152c59a1736a302c51b93d6e7d04d2e2dd678c8b08e728a2ee951dcce8a8ed1a12a46e71930a5a41b4d3b324f
|
data/lib/tba.rb
ADDED
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
require 'net/http'
|
|
2
|
+
require 'uri'
|
|
3
|
+
require 'json'
|
|
4
|
+
|
|
5
|
+
class TBA
|
|
6
|
+
|
|
7
|
+
@@URL_PRE = 'https://www.thebluealliance.com/api/v2/'
|
|
8
|
+
@@URL_POST = '?X-TBA-App-Id='
|
|
9
|
+
@app_id = ''
|
|
10
|
+
|
|
11
|
+
def initialize(id)
|
|
12
|
+
@app_id = id
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def fetch(url)
|
|
16
|
+
JSON.parse(Net::HTTP.get(URI.parse(@@URL_PRE + url + @@URL_POST + @app_id)))
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def get_teams(index)
|
|
20
|
+
fetch('teams/' + index.to_s)
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def get_team(team)
|
|
24
|
+
fetch('team/frc' + team.to_s)
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def get_team_events(team, year)
|
|
28
|
+
fetch('team/frc' + team + '/' + year)
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def get_team_awards(team, *event)
|
|
32
|
+
if event[0]
|
|
33
|
+
fetch('team/frc' + team.to_s + '/event/' + event[0] + '/awards')
|
|
34
|
+
else
|
|
35
|
+
fetch('team/frc' + team.to_s)
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def get_team_matches(team, event)
|
|
40
|
+
fetch('team/frc' + team + '/event/' + event + '/matches')
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def get_team_years(team)
|
|
44
|
+
fetch('team/frc' + team + '/years_participated')
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
def get_team_media(team, *year)
|
|
48
|
+
if year[0]
|
|
49
|
+
fetch('team/frc' + team.to_s + '/' + year[0].to_s + '/media')
|
|
50
|
+
else
|
|
51
|
+
fetch('team/frc' + team.to_s + '/media')
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
def get_team_history_events(team)
|
|
56
|
+
fetch('team/frc' + team + '/history/events')
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
def get_team_history_awards(team)
|
|
60
|
+
fetch('team/frc' + team + '/history/awards')
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
def get_team_history_robots(team)
|
|
64
|
+
fetch('team/frc' + team + '/history/robots')
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
def get_team_history_districts(team)
|
|
68
|
+
fetch('team/frc' + team + '/history/districts')
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
def get_event_list(*year)
|
|
72
|
+
if year[0]
|
|
73
|
+
fetch('events/' + year)
|
|
74
|
+
else
|
|
75
|
+
fetch('events/')
|
|
76
|
+
end
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
def get_event(event)
|
|
80
|
+
fetch('event/' + event)
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
def get_event_teams(event)
|
|
84
|
+
fetch('event/' + event + '/teams')
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
def get_event_stats(event)
|
|
88
|
+
fetch('event/' + event + '/stats')
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
def get_event_rankings(event)
|
|
92
|
+
fetch('event/' + event + '/rankings')
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
def get_event_awards(event)
|
|
96
|
+
fetch('event/' + event + '/awards')
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
def get_event_matches(event)
|
|
100
|
+
fetch('event/' + event + '/matches')
|
|
101
|
+
end
|
|
102
|
+
|
|
103
|
+
def get_district_points(event)
|
|
104
|
+
fetch('event/' + event + '/district_points')
|
|
105
|
+
end
|
|
106
|
+
|
|
107
|
+
# TODO: Make this a bit more accessible. Add automatic key generation, etc.
|
|
108
|
+
def get_match(match)
|
|
109
|
+
fetch('match/' + match)
|
|
110
|
+
end
|
|
111
|
+
|
|
112
|
+
def get_districts(year)
|
|
113
|
+
fetch('districts/' + year.to_s)
|
|
114
|
+
end
|
|
115
|
+
|
|
116
|
+
def get_district_events(district, year)
|
|
117
|
+
fetch('district/' + district + '/' + year + '/events')
|
|
118
|
+
end
|
|
119
|
+
|
|
120
|
+
def get_district_rankings(district, year)
|
|
121
|
+
fetch('district/' + district + '/' + year + '/rankings')
|
|
122
|
+
end
|
|
123
|
+
|
|
124
|
+
def get_district_teams(district, year)
|
|
125
|
+
fetch('district/' + district + '/' + year + '/teams')
|
|
126
|
+
end
|
|
127
|
+
|
|
128
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: tba
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.2.0
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Erik Boesen
|
|
8
|
+
- Team 1418
|
|
9
|
+
autorequire:
|
|
10
|
+
bindir: bin
|
|
11
|
+
cert_chain: []
|
|
12
|
+
date: 2016-10-25 00:00:00.000000000 Z
|
|
13
|
+
dependencies: []
|
|
14
|
+
description: A simple set of functions to easily fetch data from The Blue Alliance.
|
|
15
|
+
email: robotics1418@gmail.com
|
|
16
|
+
executables: []
|
|
17
|
+
extensions: []
|
|
18
|
+
extra_rdoc_files: []
|
|
19
|
+
files:
|
|
20
|
+
- lib/tba.rb
|
|
21
|
+
homepage: https://github.com/frc1418/tba.rb
|
|
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.0.14
|
|
42
|
+
signing_key:
|
|
43
|
+
specification_version: 4
|
|
44
|
+
summary: A
|
|
45
|
+
test_files: []
|