nhl_scores 0.1.1 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +1 -1
- data/Gemfile +2 -2
- data/Gemfile.lock +59 -44
- data/README.md +16 -8
- data/VERSION +1 -1
- data/example.png +0 -0
- data/lib/nhl_scores.rb +4 -3
- data/lib/nhl_scores/cli.rb +8 -14
- data/lib/nhl_scores/game.rb +5 -5
- data/lib/nhl_scores/games.rb +2 -3
- data/nhl_scores.gemspec +74 -0
- data/spec/nhl_scores_spec.rb +46 -70
- metadata +8 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5a21fc2eadb876847a1b8da4995563bbbb67a723
|
4
|
+
data.tar.gz: 041ec8b636d70be92e789707b2099687fda987a3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8d5d30cccbdc7f663125be63fa8a7a2918d7734acfdeb6cdfcc5822155a5098085a0943046822649b8b84c081c09a6cc095011c8911640dfe8b15ca7b170d814
|
7
|
+
data.tar.gz: b74f42f8ecf66092adbb3992df8830b557c84e8fb7d937fe5ce53c2e5f2fbe51962b72e8b99984f0fd4dad1266cd8ff9996eec07fa1a448b61d28a8ff5939b65
|
data/.travis.yml
CHANGED
data/Gemfile
CHANGED
@@ -8,8 +8,8 @@ gem "thor", '~> 0.19'
|
|
8
8
|
# Add dependencies to develop your gem here.
|
9
9
|
# Include everything needed to run rake, tests, features, etc.
|
10
10
|
group :development do
|
11
|
-
gem "rspec", "~>
|
11
|
+
gem "rspec", "~> 3.6"
|
12
12
|
gem "rdoc", "~> 3.12"
|
13
13
|
gem "bundler", "~> 1.0"
|
14
|
-
gem "jeweler", "~>
|
14
|
+
gem "jeweler", "~> 2.3.7"
|
15
15
|
end
|
data/Gemfile.lock
CHANGED
@@ -1,61 +1,73 @@
|
|
1
1
|
GEM
|
2
2
|
remote: http://rubygems.org/
|
3
3
|
specs:
|
4
|
-
addressable (2.
|
5
|
-
builder (3.2.
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
4
|
+
addressable (2.4.0)
|
5
|
+
builder (3.2.3)
|
6
|
+
descendants_tracker (0.0.4)
|
7
|
+
thread_safe (~> 0.3, >= 0.3.1)
|
8
|
+
diff-lcs (1.3)
|
9
|
+
faraday (0.9.2)
|
10
|
+
multipart-post (>= 1.2, < 3)
|
11
|
+
git (1.3.0)
|
12
|
+
github_api (0.16.0)
|
13
|
+
addressable (~> 2.4.0)
|
14
|
+
descendants_tracker (~> 0.0.4)
|
15
|
+
faraday (~> 0.8, < 0.10)
|
16
|
+
hashie (>= 3.4)
|
17
|
+
mime-types (>= 1.16, < 3.0)
|
18
|
+
oauth2 (~> 1.0)
|
19
|
+
hashie (3.5.6)
|
20
|
+
highline (1.7.8)
|
19
21
|
httparty (0.13.3)
|
20
22
|
json (~> 1.8)
|
21
23
|
multi_xml (>= 0.5.2)
|
22
|
-
|
23
|
-
jeweler (1.8.8)
|
24
|
+
jeweler (2.3.7)
|
24
25
|
builder
|
25
|
-
bundler (
|
26
|
+
bundler (>= 1)
|
26
27
|
git (>= 1.2.5)
|
27
|
-
github_api (
|
28
|
+
github_api (~> 0.16.0)
|
28
29
|
highline (>= 1.6.15)
|
29
|
-
nokogiri (
|
30
|
+
nokogiri (>= 1.5.10)
|
31
|
+
psych (~> 2.2)
|
30
32
|
rake
|
31
33
|
rdoc
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
34
|
+
semver2
|
35
|
+
json (1.8.6)
|
36
|
+
jwt (1.5.6)
|
37
|
+
mime-types (2.99.3)
|
38
|
+
mini_portile2 (2.3.0)
|
39
|
+
multi_json (1.12.2)
|
36
40
|
multi_xml (0.5.5)
|
37
|
-
multipart-post (
|
38
|
-
nokogiri (1.
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
jwt (~>
|
43
|
-
multi_json (~> 1.
|
41
|
+
multipart-post (2.0.0)
|
42
|
+
nokogiri (1.8.1)
|
43
|
+
mini_portile2 (~> 2.3.0)
|
44
|
+
oauth2 (1.4.0)
|
45
|
+
faraday (>= 0.8, < 0.13)
|
46
|
+
jwt (~> 1.0)
|
47
|
+
multi_json (~> 1.3)
|
44
48
|
multi_xml (~> 0.5)
|
45
|
-
rack (
|
46
|
-
|
47
|
-
|
49
|
+
rack (>= 1.2, < 3)
|
50
|
+
psych (2.2.4)
|
51
|
+
rack (2.0.3)
|
52
|
+
rake (12.1.0)
|
48
53
|
rdoc (3.12.2)
|
49
54
|
json (~> 1.4)
|
50
|
-
rspec (
|
51
|
-
rspec-core (~>
|
52
|
-
rspec-expectations (~>
|
53
|
-
rspec-mocks (~>
|
54
|
-
rspec-core (
|
55
|
-
|
56
|
-
|
57
|
-
|
55
|
+
rspec (3.6.0)
|
56
|
+
rspec-core (~> 3.6.0)
|
57
|
+
rspec-expectations (~> 3.6.0)
|
58
|
+
rspec-mocks (~> 3.6.0)
|
59
|
+
rspec-core (3.6.0)
|
60
|
+
rspec-support (~> 3.6.0)
|
61
|
+
rspec-expectations (3.6.0)
|
62
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
63
|
+
rspec-support (~> 3.6.0)
|
64
|
+
rspec-mocks (3.6.0)
|
65
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
66
|
+
rspec-support (~> 3.6.0)
|
67
|
+
rspec-support (3.6.0)
|
68
|
+
semver2 (3.4.2)
|
58
69
|
thor (0.19.1)
|
70
|
+
thread_safe (0.3.6)
|
59
71
|
|
60
72
|
PLATFORMS
|
61
73
|
ruby
|
@@ -63,7 +75,10 @@ PLATFORMS
|
|
63
75
|
DEPENDENCIES
|
64
76
|
bundler (~> 1.0)
|
65
77
|
httparty (~> 0.13)
|
66
|
-
jeweler (~>
|
78
|
+
jeweler (~> 2.3.7)
|
67
79
|
rdoc (~> 3.12)
|
68
|
-
rspec (~>
|
80
|
+
rspec (~> 3.6)
|
69
81
|
thor (~> 0.19)
|
82
|
+
|
83
|
+
BUNDLED WITH
|
84
|
+
1.13.6
|
data/README.md
CHANGED
@@ -9,9 +9,9 @@ Use Ruby to fetch details about recent, current, and upcoming regular season NHL
|
|
9
9
|
|
10
10
|
#### Installation
|
11
11
|
|
12
|
-
|
13
|
-
|
14
|
-
|
12
|
+
```shell
|
13
|
+
gem install nhl_scores
|
14
|
+
```
|
15
15
|
|
16
16
|
#### Usage Details
|
17
17
|
|
@@ -61,15 +61,21 @@ current, and upcoming games via the command line.
|
|
61
61
|
|
62
62
|
**Recent Scores**
|
63
63
|
|
64
|
-
|
64
|
+
```shell
|
65
|
+
nhl recent
|
66
|
+
```
|
65
67
|
|
66
68
|
**Current Scores**
|
67
69
|
|
68
|
-
|
70
|
+
```shell
|
71
|
+
nhl current
|
72
|
+
```
|
69
73
|
|
70
74
|
**Upcoming Games**
|
71
75
|
|
72
|
-
|
76
|
+
```shell
|
77
|
+
nhl upcoming
|
78
|
+
```
|
73
79
|
|
74
80
|
**Narrow the Response**
|
75
81
|
|
@@ -77,13 +83,15 @@ You can use the `--team (-t)` option with a team abbreviation to
|
|
77
83
|
narrow your results. The full list of team abbreviation-name mappings
|
78
84
|
can be found in `lib/nhl_scores.rb`.
|
79
85
|
|
80
|
-
|
86
|
+
```shell
|
87
|
+
nhl upcoming -t pit
|
88
|
+
```
|
81
89
|
|
82
90
|
Let's go Pens.
|
83
91
|
|
84
92
|
#### License
|
85
93
|
|
86
|
-
Copyright (c)
|
94
|
+
Copyright (c) 2017 Travis Loncar.
|
87
95
|
|
88
96
|
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
89
97
|
this software and associated documentation files (the "Software"), to deal in
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
1.0.0
|
data/example.png
CHANGED
Binary file
|
data/lib/nhl_scores.rb
CHANGED
@@ -3,9 +3,9 @@ require_relative 'nhl_scores/games'
|
|
3
3
|
require_relative 'nhl_scores/cli'
|
4
4
|
|
5
5
|
module NHLScores
|
6
|
-
ENDPOINT = "http://live.nhle.com/GameData/RegularSeasonScoreboardv3.jsonp"
|
6
|
+
ENDPOINT = "http://live.nhle.com/GameData/RegularSeasonScoreboardv3.jsonp".freeze
|
7
7
|
|
8
|
-
|
8
|
+
TEAM_ABBREVIATIONS = {
|
9
9
|
ana: "Anaheim Ducks",
|
10
10
|
bos: "Boston Bruins",
|
11
11
|
buf: "Buffalo Sabres",
|
@@ -34,7 +34,8 @@ module NHLScores
|
|
34
34
|
tb: "Tampa Bay Lightning",
|
35
35
|
tor: "Toronto Maple Leafs",
|
36
36
|
van: "Vancouver Canucks",
|
37
|
+
vgk: "Vegas Golden Knights",
|
37
38
|
wpg: "Winnipeg Jets",
|
38
39
|
wsh: "Washington Capitals"
|
39
|
-
}
|
40
|
+
}.freeze
|
40
41
|
end
|
data/lib/nhl_scores/cli.rb
CHANGED
@@ -34,38 +34,36 @@ module NHLScores
|
|
34
34
|
|
35
35
|
def output_games(games, type)
|
36
36
|
puts
|
37
|
-
title
|
38
|
-
|
39
|
-
puts TextHelpers.yellow(
|
40
|
-
puts TextHelpers.align(underline)
|
41
|
-
puts
|
37
|
+
title = "#{type.upcase} NHL GAMES"
|
38
|
+
puts TextHelpers.yellow(title)
|
39
|
+
puts TextHelpers.yellow("-" * title.length)
|
42
40
|
if games.any?
|
43
41
|
games.each do |game|
|
44
42
|
send("output_#{type}_game", game)
|
45
43
|
end
|
46
44
|
else
|
47
|
-
puts
|
45
|
+
puts "There are no #{type} games."
|
48
46
|
end
|
49
47
|
puts
|
50
48
|
end
|
51
49
|
|
52
50
|
def output_recent_game(game)
|
53
|
-
puts
|
51
|
+
puts "#{game.date}: #{game.winner} defeat #{game.loser} (#{game.winner_score}-#{game.loser_score})"
|
54
52
|
end
|
55
53
|
|
56
54
|
def output_current_game(game)
|
57
55
|
if game.started?
|
58
56
|
score_descriptor = score_descriptor_string(game)
|
59
|
-
output =
|
57
|
+
output = "IN PROGRESS: #{game.leader} #{score_descriptor} #{game.trailer} (#{game.leader_score}-#{game.trailer_score})"
|
60
58
|
else
|
61
|
-
output =
|
59
|
+
output = "PRE GAME: #{game.home_team} vs. #{game.away_team}"
|
62
60
|
end
|
63
61
|
output += tv_string(game)
|
64
62
|
puts output
|
65
63
|
end
|
66
64
|
|
67
65
|
def output_upcoming_game(game)
|
68
|
-
output =
|
66
|
+
output = "#{game.date} @ #{game.start_time} (PST):" + " #{game.home_team} vs. #{game.away_team}"
|
69
67
|
output += tv_string(game)
|
70
68
|
puts output
|
71
69
|
end
|
@@ -89,10 +87,6 @@ module NHLScores
|
|
89
87
|
color(str, "\e[0;33m")
|
90
88
|
end
|
91
89
|
|
92
|
-
def align(str)
|
93
|
-
str.rjust(32)
|
94
|
-
end
|
95
|
-
|
96
90
|
private
|
97
91
|
|
98
92
|
def color(text, color_code)
|
data/lib/nhl_scores/game.rb
CHANGED
@@ -3,8 +3,6 @@ module NHLScores
|
|
3
3
|
attr_reader :id, :date, :start_time, :home_team, :away_team, :home_team_score,
|
4
4
|
:away_team_score, :status, :ustv, :catv
|
5
5
|
|
6
|
-
require 'httparty'
|
7
|
-
|
8
6
|
def initialize(game_attributes)
|
9
7
|
@id = game_attributes["id"]
|
10
8
|
@date = game_attributes["ts"]
|
@@ -22,7 +20,7 @@ module NHLScores
|
|
22
20
|
return false if status.empty? || home_team_score.empty? || away_team_score.empty?
|
23
21
|
return true
|
24
22
|
end
|
25
|
-
|
23
|
+
|
26
24
|
def winner
|
27
25
|
not_final_message
|
28
26
|
high_score_team
|
@@ -68,7 +66,7 @@ module NHLScores
|
|
68
66
|
end
|
69
67
|
|
70
68
|
def team_name(team_abbrev)
|
71
|
-
return
|
69
|
+
return TEAM_ABBREVIATIONS[team_abbrev]
|
72
70
|
end
|
73
71
|
|
74
72
|
private
|
@@ -85,11 +83,13 @@ module NHLScores
|
|
85
83
|
return "Columbus Blue Jackets"
|
86
84
|
when "Detroit Redwings"
|
87
85
|
return "Detroit Red Wings"
|
86
|
+
when "Vegas Goldenknights"
|
87
|
+
return "Vegas Golden Knights"
|
88
88
|
else
|
89
89
|
return team_name
|
90
90
|
end
|
91
91
|
end
|
92
|
-
|
92
|
+
|
93
93
|
def high_score
|
94
94
|
return home_team_score if home_team_score == away_team_score
|
95
95
|
home_team_score > away_team_score ? home_team_score : away_team_score
|
data/lib/nhl_scores/games.rb
CHANGED
@@ -3,7 +3,7 @@ module NHLScores
|
|
3
3
|
attr_reader :games
|
4
4
|
|
5
5
|
require 'httparty'
|
6
|
-
|
6
|
+
|
7
7
|
def initialize
|
8
8
|
response = HTTParty.get(ENDPOINT).sub("loadScoreboard(", "").sub(")", "")
|
9
9
|
@games = JSON.parse(response)["games"].map { |game_attributes| Game.new(game_attributes) }
|
@@ -30,8 +30,7 @@ module NHLScores
|
|
30
30
|
private
|
31
31
|
|
32
32
|
def team_name(team_abbrev)
|
33
|
-
return
|
34
|
-
raise ArgumentError, 'Invalid abbreviation.'
|
33
|
+
return TEAM_ABBREVIATIONS.fetch(team_abbrev.to_sym)
|
35
34
|
end
|
36
35
|
end
|
37
36
|
end
|
data/nhl_scores.gemspec
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
# stub: nhl_scores 1.0.0 ruby lib
|
6
|
+
|
7
|
+
Gem::Specification.new do |s|
|
8
|
+
s.name = "nhl_scores"
|
9
|
+
s.version = "1.0.0"
|
10
|
+
|
11
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
12
|
+
s.require_paths = ["lib"]
|
13
|
+
s.authors = ["Travis Loncar"]
|
14
|
+
s.date = "2017-10-17"
|
15
|
+
s.description = "Use Ruby to grab live/recent NHL scores and upcoming matchup details. This gem ships with a minimal CLI."
|
16
|
+
s.email = "loncar.travis@gmail.com"
|
17
|
+
s.executables = ["nhl"]
|
18
|
+
s.extra_rdoc_files = [
|
19
|
+
"LICENSE.txt",
|
20
|
+
"README.md"
|
21
|
+
]
|
22
|
+
s.files = [
|
23
|
+
".document",
|
24
|
+
".rspec",
|
25
|
+
".travis.yml",
|
26
|
+
"Gemfile",
|
27
|
+
"Gemfile.lock",
|
28
|
+
"LICENSE.txt",
|
29
|
+
"README.md",
|
30
|
+
"Rakefile",
|
31
|
+
"VERSION",
|
32
|
+
"bin/nhl",
|
33
|
+
"example.png",
|
34
|
+
"lib/nhl_scores.rb",
|
35
|
+
"lib/nhl_scores/cli.rb",
|
36
|
+
"lib/nhl_scores/game.rb",
|
37
|
+
"lib/nhl_scores/games.rb",
|
38
|
+
"nhl_scores.gemspec",
|
39
|
+
"spec/nhl_scores_spec.rb",
|
40
|
+
"spec/spec_helper.rb"
|
41
|
+
]
|
42
|
+
s.homepage = "http://github.com/tbloncar/nhl_scores"
|
43
|
+
s.licenses = ["MIT"]
|
44
|
+
s.rubygems_version = "2.5.1"
|
45
|
+
s.summary = "Use Ruby to grab live/recent NHL scores and upcoming matchup details."
|
46
|
+
|
47
|
+
if s.respond_to? :specification_version then
|
48
|
+
s.specification_version = 4
|
49
|
+
|
50
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
51
|
+
s.add_runtime_dependency(%q<httparty>, ["~> 0.13"])
|
52
|
+
s.add_runtime_dependency(%q<thor>, ["~> 0.19"])
|
53
|
+
s.add_development_dependency(%q<rspec>, ["~> 3.6"])
|
54
|
+
s.add_development_dependency(%q<rdoc>, ["~> 3.12"])
|
55
|
+
s.add_development_dependency(%q<bundler>, ["~> 1.0"])
|
56
|
+
s.add_development_dependency(%q<jeweler>, ["~> 2.3.7"])
|
57
|
+
else
|
58
|
+
s.add_dependency(%q<httparty>, ["~> 0.13"])
|
59
|
+
s.add_dependency(%q<thor>, ["~> 0.19"])
|
60
|
+
s.add_dependency(%q<rspec>, ["~> 3.6"])
|
61
|
+
s.add_dependency(%q<rdoc>, ["~> 3.12"])
|
62
|
+
s.add_dependency(%q<bundler>, ["~> 1.0"])
|
63
|
+
s.add_dependency(%q<jeweler>, ["~> 2.3.7"])
|
64
|
+
end
|
65
|
+
else
|
66
|
+
s.add_dependency(%q<httparty>, ["~> 0.13"])
|
67
|
+
s.add_dependency(%q<thor>, ["~> 0.19"])
|
68
|
+
s.add_dependency(%q<rspec>, ["~> 3.6"])
|
69
|
+
s.add_dependency(%q<rdoc>, ["~> 3.12"])
|
70
|
+
s.add_dependency(%q<bundler>, ["~> 1.0"])
|
71
|
+
s.add_dependency(%q<jeweler>, ["~> 2.3.7"])
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
data/spec/nhl_scores_spec.rb
CHANGED
@@ -1,11 +1,12 @@
|
|
1
1
|
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
2
2
|
|
3
3
|
module NHLScores
|
4
|
+
# TODO: This is in need of some mocking love.
|
5
|
+
|
4
6
|
describe NHLScores do
|
5
7
|
it 'should include a team abbreviation to name map' do
|
6
|
-
|
7
|
-
|
8
|
-
TEAM_ABBREV_MAP[:mtl].should == "Montréal Canadiens"
|
8
|
+
expect(TEAM_ABBREVIATIONS[:pit]).to eq("Pittsburgh Penguins")
|
9
|
+
expect(TEAM_ABBREVIATIONS[:mtl]).to eq("Montréal Canadiens")
|
9
10
|
end
|
10
11
|
end
|
11
12
|
|
@@ -13,121 +14,96 @@ module NHLScores
|
|
13
14
|
subject(:games) { NHLScores::Games.new }
|
14
15
|
|
15
16
|
it 'should be valid' do
|
16
|
-
games.
|
17
|
+
expect(games).to be_truthy
|
17
18
|
end
|
18
19
|
|
19
20
|
it 'should be initialized with games' do
|
20
|
-
games.games.
|
21
|
-
games.games.first.class.
|
21
|
+
expect(games.games).to be_truthy
|
22
|
+
expect(games.games.first.class).to eq(NHLScores::Game)
|
22
23
|
end
|
23
24
|
|
24
25
|
it 'should provide an array of all games' do
|
25
|
-
games.all.class.
|
26
|
-
games.all.count.
|
26
|
+
expect(games.all.class).to eq(Array)
|
27
|
+
expect(games.all.count).to eq(games.games.count)
|
28
|
+
end
|
29
|
+
|
30
|
+
def expect_games_with_status(collection, status)
|
31
|
+
discovered_games = games.send(collection)
|
32
|
+
expect(discovered_games.class).to eq(Array)
|
33
|
+
return unless discovered_games.any?
|
34
|
+
|
35
|
+
expect(discovered_games.first.status).to eq(status)
|
36
|
+
expect(discovered_games.last.status).to eq(status)
|
27
37
|
end
|
28
38
|
|
29
39
|
it 'should provide an array of recent games' do
|
30
|
-
|
31
|
-
if games.recent.any?
|
32
|
-
games.recent.first.status.should == "final"
|
33
|
-
games.recent.last.status.should == "final"
|
34
|
-
end
|
40
|
+
expect_games_with_status(:recent, "final")
|
35
41
|
end
|
36
42
|
|
37
43
|
it 'should provide an array of games in progress' do
|
38
|
-
|
39
|
-
if games.in_progress.any?
|
40
|
-
games.in_progress.first.status.should == "progress"
|
41
|
-
games.in_progress.last.status.should == "progress"
|
42
|
-
end
|
44
|
+
expect_games_with_status(:in_progress, "progress")
|
43
45
|
end
|
44
46
|
|
45
47
|
it 'should provide an array of upcoming games' do
|
46
|
-
|
47
|
-
if games.upcoming.any?
|
48
|
-
games.upcoming.first.status.should == ""
|
49
|
-
games.upcoming.first.status.should == ""
|
50
|
-
end
|
48
|
+
expect_games_with_status(:upcoming, "")
|
51
49
|
end
|
52
50
|
|
53
51
|
context 'with team abbreviation provided' do
|
52
|
+
def expect_team_included(collection, team_abbrev)
|
53
|
+
discovered_games = games.send(collection, team_abbrev: team_abbrev)
|
54
|
+
|
55
|
+
return unless discovered_games.any?
|
56
|
+
expect(discovered_games.first.includes_team?(NHLScores::TEAM_ABBREVIATIONS[team_abbrev])).to be true
|
57
|
+
end
|
58
|
+
|
54
59
|
it 'should provide an array of all games including team' do
|
55
|
-
|
56
|
-
games.all(team_abbrev: :wsh).first.includes_team?("Washington Capitals").should be_true if games.all(team_abbrev: :wsh).any?
|
60
|
+
%i[pit wsh vgk].each { |abbrev| expect_team_included(:all, abbrev) }
|
57
61
|
end
|
58
62
|
|
59
63
|
it 'should provide an array of recent games including team' do
|
60
|
-
|
61
|
-
games.recent(team_abbrev: :phx).first.includes_team?("Phoenix Coyotes").should be_true if games.recent(team_abbrev: :phx).any?
|
64
|
+
%i[tb phx sj].each { |abbrev| expect_team_included(:recent, abbrev) }
|
62
65
|
end
|
63
|
-
|
66
|
+
|
64
67
|
it 'should provide an array of games in progress including team' do
|
65
|
-
|
66
|
-
games.in_progress(team_abbrev: :col).first.includes_team?("Colorado Avalanche").should be_true if games.in_progress(team_abbrev: :col).any?
|
68
|
+
%i[col wpg nj].each { |abbrev| expect_team_included(:in_progress, abbrev) }
|
67
69
|
end
|
68
70
|
|
69
71
|
it 'should provide an array of upcoming games including team' do
|
70
|
-
|
71
|
-
games.upcoming(team_abbrev: :nyr).first.includes_team?("New York Rangers").should be_true if games.upcoming(team_abbrev: :nyr).any?
|
72
|
+
%i[ana nyr chi].each { |abbrev| expect_team_included(:upcoming, abbrev) }
|
72
73
|
end
|
73
74
|
end
|
74
75
|
end
|
75
76
|
|
76
77
|
describe Game do
|
77
78
|
context 'when final' do
|
78
|
-
|
79
|
-
|
80
|
-
it 'should be valid' do
|
81
|
-
game.should be_true
|
82
|
-
end
|
83
|
-
|
84
|
-
it 'should be initialized with the appropriate attributes' do
|
85
|
-
game.should respond_to(:id)
|
86
|
-
game.should respond_to(:date)
|
87
|
-
game.should respond_to(:start_time)
|
88
|
-
game.should respond_to(:home_team)
|
89
|
-
game.should respond_to(:away_team)
|
90
|
-
game.should respond_to(:home_team_score)
|
91
|
-
game.should respond_to(:away_team_score)
|
92
|
-
game.should respond_to(:status)
|
93
|
-
game.should respond_to(:ustv)
|
94
|
-
game.should respond_to(:catv)
|
79
|
+
before(:all) do
|
80
|
+
@game = NHLScores::Games.new.recent.first
|
95
81
|
end
|
96
82
|
|
97
83
|
it 'should provide the winning team' do
|
98
|
-
winner = game.home_team_score > game.away_team_score ? game.home_team : game.away_team
|
99
|
-
game.winner.
|
84
|
+
winner = @game.home_team_score > @game.away_team_score ? @game.home_team : @game.away_team
|
85
|
+
expect(@game.winner).to eq(winner)
|
100
86
|
end
|
101
87
|
|
102
88
|
it 'should provide the losing team' do
|
103
|
-
loser = game.home_team_score > game.away_team_score ? game.away_team : game.home_team
|
104
|
-
game.loser.
|
89
|
+
loser = @game.home_team_score > @game.away_team_score ? @game.away_team : @game.home_team
|
90
|
+
expect(@game.loser).to eq(loser)
|
105
91
|
end
|
106
92
|
|
107
93
|
it 'should provide the winning team\'s score' do
|
108
|
-
winner_score = game.home_team_score > game.away_team_score ? game.home_team_score : game.away_team_score
|
109
|
-
game.winner_score.
|
94
|
+
winner_score = @game.home_team_score > @game.away_team_score ? @game.home_team_score : @game.away_team_score
|
95
|
+
expect(@game.winner_score).to eq(winner_score)
|
110
96
|
end
|
111
|
-
|
97
|
+
|
112
98
|
it 'should provide the losing team\'s score' do
|
113
|
-
loser_score = game.home_team_score > game.away_team_score ? game.away_team_score : game.home_team_score
|
114
|
-
game.loser_score.
|
99
|
+
loser_score = @game.home_team_score > @game.away_team_score ? @game.away_team_score : @game.home_team_score
|
100
|
+
expect(@game.loser_score).to eq(loser_score)
|
115
101
|
end
|
116
102
|
|
117
103
|
it 'should indicate whether or not a certain team was/is involved' do
|
118
|
-
game.includes_team?(game.home_team).
|
119
|
-
game.includes_team?(game.away_team).
|
104
|
+
expect(@game.includes_team?(@game.home_team)).to be true
|
105
|
+
expect(@game.includes_team?(@game.away_team)).to be true
|
120
106
|
end
|
121
107
|
end
|
122
|
-
|
123
|
-
context 'when in progress' do
|
124
|
-
|
125
|
-
end
|
126
|
-
end
|
127
|
-
|
128
|
-
describe CLI do
|
129
|
-
it 'should be initialized with games' do
|
130
|
-
subject.games.should be_true
|
131
|
-
end
|
132
108
|
end
|
133
109
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nhl_scores
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Travis Loncar
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-10-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httparty
|
@@ -44,14 +44,14 @@ dependencies:
|
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '
|
47
|
+
version: '3.6'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: '
|
54
|
+
version: '3.6'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: rdoc
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -86,14 +86,14 @@ dependencies:
|
|
86
86
|
requirements:
|
87
87
|
- - "~>"
|
88
88
|
- !ruby/object:Gem::Version
|
89
|
-
version:
|
89
|
+
version: 2.3.7
|
90
90
|
type: :development
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
94
|
- - "~>"
|
95
95
|
- !ruby/object:Gem::Version
|
96
|
-
version:
|
96
|
+
version: 2.3.7
|
97
97
|
description: Use Ruby to grab live/recent NHL scores and upcoming matchup details.
|
98
98
|
This gem ships with a minimal CLI.
|
99
99
|
email: loncar.travis@gmail.com
|
@@ -119,6 +119,7 @@ files:
|
|
119
119
|
- lib/nhl_scores/cli.rb
|
120
120
|
- lib/nhl_scores/game.rb
|
121
121
|
- lib/nhl_scores/games.rb
|
122
|
+
- nhl_scores.gemspec
|
122
123
|
- spec/nhl_scores_spec.rb
|
123
124
|
- spec/spec_helper.rb
|
124
125
|
homepage: http://github.com/tbloncar/nhl_scores
|
@@ -141,7 +142,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
141
142
|
version: '0'
|
142
143
|
requirements: []
|
143
144
|
rubyforge_project:
|
144
|
-
rubygems_version: 2.
|
145
|
+
rubygems_version: 2.5.1
|
145
146
|
signing_key:
|
146
147
|
specification_version: 4
|
147
148
|
summary: Use Ruby to grab live/recent NHL scores and upcoming matchup details.
|