cricketer 0.0.1 → 0.0.2

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.
@@ -0,0 +1,86 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: http://www.espncricinfo.com/wc2007/engine/series/509587.json?view=pointstable
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ Accept-Encoding:
11
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
12
+ Accept:
13
+ - "*/*"
14
+ User-Agent:
15
+ - Ruby
16
+ Host:
17
+ - www.espncricinfo.com
18
+ response:
19
+ status:
20
+ code: 200
21
+ message: OK
22
+ headers:
23
+ Server:
24
+ - Apache
25
+ Cache-Control:
26
+ - public, max-age=60
27
+ Emea-Info:
28
+ - wci064 0.043
29
+ Content-Type:
30
+ - application/json; charset=UTF-8
31
+ X-Varnish:
32
+ - 1524686238 1524681695
33
+ - '1765889925'
34
+ X-Varnish-Cache:
35
+ - HIT
36
+ X-Varnish-Hits:
37
+ - '3'
38
+ Vary:
39
+ - Accept-Encoding
40
+ Date:
41
+ - Tue, 24 Feb 2015 18:41:49 GMT
42
+ Content-Length:
43
+ - '4094'
44
+ Connection:
45
+ - keep-alive
46
+ body:
47
+ encoding: UTF-8
48
+ string: '{"graph":{"Pool A":{"1":{"points":[{"date":"2015-02-14","match_id":"53331","match_info":"Aus
49
+ 2 - Eng 0","points":0},{"date":"2015-02-20","match_id":"53345","match_info":"NZ
50
+ 2 - Eng 0","points":0},{"date":"2015-02-23","match_id":"53355","match_info":"Eng
51
+ 2 - Scot 0","points":2}],"team_abbreviation":"Eng","team_id":"1","team_name":"England","team_short_name":"England"},"2":{"points":[{"date":"2015-02-14","match_id":"53331","match_info":"Aus
52
+ 2 - Eng 0","points":2},{"date":"2015-02-21","match_id":"53349","match_info":"Aus
53
+ 1 - Ban 1","points":3}],"team_abbreviation":"Aus","team_id":"2","team_name":"Australia","team_short_name":"Australia"},"25":{"points":[{"date":"2015-02-18","match_id":"53341","match_info":"Afg
54
+ 0 - Ban 2","points":2},{"date":"2015-02-21","match_id":"53349","match_info":"Aus
55
+ 1 - Ban 1","points":3}],"team_abbreviation":"Ban","team_id":"25","team_name":"Bangladesh","team_short_name":"Bangladesh"},"30":{"points":[{"date":"2015-02-17","match_id":"53339","match_info":"NZ
56
+ 2 - Scot 0","points":0},{"date":"2015-02-23","match_id":"53355","match_info":"Eng
57
+ 2 - Scot 0","points":0}],"team_abbreviation":"Scot","team_id":"30","team_name":"Scotland","team_short_name":"Scotland"},"40":{"points":[{"date":"2015-02-18","match_id":"53341","match_info":"Afg
58
+ 0 - Ban 2","points":0},{"date":"2015-02-22","match_id":"53351","match_info":"Afg
59
+ 0 - SL 2","points":0}],"team_abbreviation":"Afg","team_id":"40","team_name":"Afghanistan","team_short_name":"Afghanistan"},"5":{"points":[{"date":"2015-02-14","match_id":"53329","match_info":"NZ
60
+ 2 - SL 0","points":2},{"date":"2015-02-17","match_id":"53339","match_info":"NZ
61
+ 2 - Scot 0","points":4},{"date":"2015-02-20","match_id":"53345","match_info":"NZ
62
+ 2 - Eng 0","points":6}],"team_abbreviation":"NZ","team_id":"5","team_name":"New
63
+ Zealand","team_short_name":"New Zealand"},"8":{"points":[{"date":"2015-02-14","match_id":"53329","match_info":"NZ
64
+ 2 - SL 0","points":0},{"date":"2015-02-22","match_id":"53351","match_info":"Afg
65
+ 0 - SL 2","points":2}],"team_abbreviation":"SL","team_id":"8","team_name":"Sri
66
+ Lanka","team_short_name":"Sri Lanka"}},"Pool B":{"27":{"points":[{"date":"2015-02-19","match_id":"53343","match_info":"UAE
67
+ 0 - Zim 2","points":0}],"team_abbreviation":"UAE","team_id":"27","team_name":"United
68
+ Arab Emirates","team_short_name":"U.A.E."},"29":{"points":[{"date":"2015-02-16","match_id":"53337","match_info":"Ire
69
+ 2 - WI 0","points":2}],"team_abbreviation":"Ire","team_id":"29","team_name":"Ireland","team_short_name":"Ireland"},"3":{"points":[{"date":"2015-02-15","match_id":"53333","match_info":"SA
70
+ 2 - Zim 0","points":2},{"date":"2015-02-22","match_id":"53353","match_info":"India
71
+ 2 - SA 0","points":2}],"team_abbreviation":"SA","team_id":"3","team_name":"South
72
+ Africa","team_short_name":"South Africa"},"4":{"points":[{"date":"2015-02-16","match_id":"53337","match_info":"Ire
73
+ 2 - WI 0","points":0},{"date":"2015-02-21","match_id":"53347","match_info":"Pak
74
+ 0 - WI 2","points":2},{"date":"2015-02-24","match_id":"53357","match_info":"WI
75
+ 2 - Zim 0","points":4}],"team_abbreviation":"WI","team_id":"4","team_name":"West
76
+ Indies","team_short_name":"West Indies"},"6":{"points":[{"date":"2015-02-15","match_id":"53335","match_info":"India
77
+ 2 - Pak 0","points":2},{"date":"2015-02-22","match_id":"53353","match_info":"India
78
+ 2 - SA 0","points":4}],"team_abbreviation":"India","team_id":"6","team_name":"India","team_short_name":"India"},"7":{"points":[{"date":"2015-02-15","match_id":"53335","match_info":"India
79
+ 2 - Pak 0","points":0},{"date":"2015-02-21","match_id":"53347","match_info":"Pak
80
+ 0 - WI 2","points":0}],"team_abbreviation":"Pak","team_id":"7","team_name":"Pakistan","team_short_name":"Pakistan"},"9":{"points":[{"date":"2015-02-15","match_id":"53333","match_info":"SA
81
+ 2 - Zim 0","points":0},{"date":"2015-02-19","match_id":"53343","match_info":"UAE
82
+ 0 - Zim 2","points":2},{"date":"2015-02-24","match_id":"53357","match_info":"WI
83
+ 2 - Zim 0","points":2}],"team_abbreviation":"Zim","team_id":"9","team_name":"Zimbabwe","team_short_name":"Zimbabwe"}},"end_date":"2015-03-15","minimum_points":12,"start_date":"2015-02-14"}}'
84
+ http_version:
85
+ recorded_at: Tue, 24 Feb 2015 18:41:50 GMT
86
+ recorded_with: VCR 2.9.3
@@ -0,0 +1,28 @@
1
+ require 'spec_helper'
2
+
3
+ RSpec.describe Cricketer::Match do
4
+ subject { Cricketer::Match }
5
+ let(:match_id) { 656399 }
6
+
7
+ let(:match) do
8
+ VCR.use_cassette("match_#{match_id}") do
9
+ subject.create match_id
10
+ end
11
+ end
12
+
13
+ context 'produces valid data' do
14
+
15
+ it 'describes the match with #to_s' do
16
+ expect(match.to_s).to eq 'ICC Cricket World Cup, 1st Match, Pool A: New Zealand v Sri Lanka at Christchurch, Feb 14, 2015'
17
+ end
18
+
19
+ it 'returns the current status' do
20
+ expect(match.current_status).to eq 'New Zealand won by 98 runs'
21
+ end
22
+
23
+ it 'returns team data' do
24
+ expect(match.team1.name).to eq 'New Zealand'
25
+ end
26
+ end
27
+
28
+ end
@@ -0,0 +1,40 @@
1
+ require 'vcr'
2
+
3
+ # Ensure that the load path has the lib folder accessible
4
+ # in the test environment
5
+ lib = File.expand_path('../../lib', __FILE__)
6
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
7
+
8
+ # Require the entry point for the gem
9
+ require 'cricketer'
10
+
11
+ VCR.configure do |config|
12
+ config.cassette_library_dir = 'spec/cassettes'
13
+ config.hook_into :webmock # or :fakeweb
14
+ end
15
+
16
+ RSpec.configure do |config|
17
+ config.expect_with :rspec do |expectations|
18
+ expectations.include_chain_clauses_in_custom_matcher_descriptions = true
19
+ end
20
+
21
+ config.mock_with :rspec do |mocks|
22
+ mocks.verify_partial_doubles = true
23
+ end
24
+
25
+ config.filter_run :focus
26
+ config.run_all_when_everything_filtered = true
27
+
28
+ # Limits the available syntax to the non-monkey patched syntax that is
29
+ # recommended. For more details, see:
30
+ # - http://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-syntax
31
+ # - http://teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
32
+ # - http://myronmars.to/n/dev-blog/2014/05/notable-changes-in-rspec-3#new__config_option_to_disable_rspeccore_monkey_patching
33
+ config.disable_monkey_patching!
34
+
35
+ if config.files_to_run.one?
36
+ config.default_formatter = 'doc'
37
+ end
38
+
39
+ config.order = :random
40
+ end
@@ -0,0 +1,19 @@
1
+ require 'spec_helper'
2
+
3
+ RSpec.describe Cricketer::WorldCup do
4
+ subject { Cricketer::WorldCup }
5
+
6
+ let(:points_table) do
7
+ VCR.use_cassette("points_table") do
8
+ subject.points_table
9
+ end
10
+ end
11
+
12
+ context 'produces valid data' do
13
+
14
+ it 'describes the first team in the first pool by name' do
15
+ expect(points_table[0][0][:name]).to eq 'New Zealand'
16
+ end
17
+ end
18
+
19
+ end
metadata CHANGED
@@ -1,15 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cricketer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Derek Willis
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-02-17 00:00:00.000000000 Z
11
+ date: 2015-02-24 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: fast_attributes
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '0.7'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '0.7'
13
27
  - !ruby/object:Gem::Dependency
14
28
  name: bundler
15
29
  requirement: !ruby/object:Gem::Requirement
@@ -38,6 +52,34 @@ dependencies:
38
52
  - - "~>"
39
53
  - !ruby/object:Gem::Version
40
54
  version: '10.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: 3.2.0
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: 3.2.0
69
+ - !ruby/object:Gem::Dependency
70
+ name: vcr
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: 2.9.3
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: 2.9.3
41
83
  description: Parses live scores and game data.
42
84
  email:
43
85
  - dwillis@gmail.com
@@ -46,14 +88,24 @@ extensions: []
46
88
  extra_rdoc_files: []
47
89
  files:
48
90
  - ".gitignore"
91
+ - ".rspec"
49
92
  - Gemfile
50
93
  - LICENSE.txt
51
94
  - README.md
52
95
  - Rakefile
53
96
  - cricketer.gemspec
97
+ - lib/api.rb
54
98
  - lib/cricketer.rb
55
99
  - lib/match.rb
100
+ - lib/team.rb
56
101
  - lib/version.rb
102
+ - lib/world_cup.rb
103
+ - spec/api_spec.rb
104
+ - spec/cassettes/match_656399.yml
105
+ - spec/cassettes/points_table.yml
106
+ - spec/match_spec.rb
107
+ - spec/spec_helper.rb
108
+ - spec/world_cup_spec.rb
57
109
  homepage: https://github.com/dwillis/cricketer
58
110
  licenses:
59
111
  - MIT
@@ -78,4 +130,10 @@ rubygems_version: 2.2.2
78
130
  signing_key:
79
131
  specification_version: 4
80
132
  summary: A Ruby library for parsing data from ESPN's Cricinfo site.
81
- test_files: []
133
+ test_files:
134
+ - spec/api_spec.rb
135
+ - spec/cassettes/match_656399.yml
136
+ - spec/cassettes/points_table.yml
137
+ - spec/match_spec.rb
138
+ - spec/spec_helper.rb
139
+ - spec/world_cup_spec.rb