cbs 0.0.0 → 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/LICENSE.md +1 -1
- data/Rakefile +4 -0
- data/cbs.gemspec +12 -9
- data/lib/cbs.rb +11 -0
- data/lib/cbs/client.rb +29 -0
- data/lib/cbs/client/players.rb +25 -0
- data/lib/cbs/client/teams.rb +11 -0
- data/lib/cbs/configuration.rb +29 -0
- data/lib/cbs/request.rb +43 -0
- data/lib/cbs/version.rb +1 -1
- data/spec/spec_helper.rb +2 -0
- metadata +52 -21
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 3179cbc2cfd2be2bf23245d3f4382f72e5c88d1e
|
4
|
+
data.tar.gz: c801c162706168a8974e9423dec0913f0bd9aef8
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 850ed0376d55f4f072970c2b919a2a6c3e51f239f1a8f0a2f03ce4e50b92bfdb708cabb48921845ec04ec59e36ee48f1e98bd379dd9c34289c8983ad212200fd
|
7
|
+
data.tar.gz: dbb5ac8ba6a815b7ea4a6a862e05371e85c3f5345c3c0c37f5854b5a2bf36294e93f58f905dbb985aff511d321ab5eb450a6cba501a42ddce27030061a5b750f
|
data/LICENSE.md
CHANGED
data/Rakefile
CHANGED
data/cbs.gemspec
CHANGED
@@ -4,19 +4,22 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
4
|
require 'cbs/version'
|
5
5
|
|
6
6
|
Gem::Specification.new do |spec|
|
7
|
-
spec.
|
7
|
+
spec.name = 'cbs'
|
8
|
+
spec.licenses = ['MIT']
|
9
|
+
spec.summary = "Ruby client for the CBS Sports API"
|
10
|
+
spec.description = "Ruby client for the CBS Sports API"
|
11
|
+
|
8
12
|
spec.author = 'Andrew Thorp'
|
9
|
-
spec.description = %q{Simple wrapper for the CBS Sports API}
|
10
13
|
spec.email = 'andrewpthorp@gmail.com'
|
14
|
+
spec.homepage = 'https://github.com/andrewpthorp/cbs'
|
15
|
+
|
11
16
|
spec.files = %w(LICENSE.md README.md Rakefile cbs.gemspec)
|
12
17
|
spec.files += Dir.glob("lib/**/*.rb")
|
13
18
|
spec.files += Dir.glob("spec/**/*")
|
14
|
-
|
15
|
-
spec.license = 'MIT'
|
16
|
-
spec.name = 'cbs'
|
17
|
-
spec.require_paths = ['lib']
|
18
|
-
spec.required_rubygems_version = '>= 1.3.5'
|
19
|
-
spec.summary = "Ruby toolkit for working with the CBS Sports API"
|
20
|
-
spec.test_files = Dir.glob("spec/**/*")
|
19
|
+
|
21
20
|
spec.version = CBS::VERSION.dup
|
21
|
+
|
22
|
+
spec.add_runtime_dependency 'faraday', '0.11.0'
|
23
|
+
spec.add_runtime_dependency 'faraday_middleware', '0.11.0'
|
24
|
+
spec.add_runtime_dependency 'hashie', '~> 3.5'
|
22
25
|
end
|
data/lib/cbs.rb
CHANGED
data/lib/cbs/client.rb
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'cbs/request'
|
2
|
+
require 'cbs/configuration'
|
3
|
+
require 'cbs/client/players'
|
4
|
+
require 'cbs/client/teams'
|
5
|
+
|
6
|
+
module CBS
|
7
|
+
class Client
|
8
|
+
|
9
|
+
attr_accessor :timeout
|
10
|
+
attr_accessor :open_timeout
|
11
|
+
attr_accessor :sport
|
12
|
+
|
13
|
+
def initialize(opts={})
|
14
|
+
options = CBS.options.merge(opts)
|
15
|
+
Configuration::VALID_OPTIONS_KEYS.each do |key|
|
16
|
+
send("#{key}=", options[key])
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def api_url
|
21
|
+
"http://api.cbssports.com/fantasy/"
|
22
|
+
end
|
23
|
+
|
24
|
+
include CBS::Request
|
25
|
+
include CBS::Client::Players
|
26
|
+
include CBS::Client::Teams
|
27
|
+
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module CBS
|
2
|
+
class Client
|
3
|
+
module Players
|
4
|
+
|
5
|
+
def players(opts={})
|
6
|
+
get('players/list', opts).body.players
|
7
|
+
end
|
8
|
+
|
9
|
+
def profile(player_id, opts={})
|
10
|
+
opts.merge!(player_id: player_id)
|
11
|
+
|
12
|
+
|
13
|
+
get('players/profile', opts).body.player_profile.player
|
14
|
+
end
|
15
|
+
|
16
|
+
def player_search(name, opts={}, team_name: nil)
|
17
|
+
opts.merge!(name: name)
|
18
|
+
opts.merge!(team_name: team_name) if team_name
|
19
|
+
|
20
|
+
get('players/search', opts).body.players
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'faraday'
|
2
|
+
require 'cbs/version'
|
3
|
+
|
4
|
+
module CBS
|
5
|
+
|
6
|
+
module Configuration
|
7
|
+
|
8
|
+
VALID_OPTIONS_KEYS = [:timeout, :open_timeout, :sport].freeze
|
9
|
+
attr_accessor *VALID_OPTIONS_KEYS
|
10
|
+
|
11
|
+
def self.extended(base)
|
12
|
+
base.reset
|
13
|
+
end
|
14
|
+
|
15
|
+
def configure
|
16
|
+
yield self
|
17
|
+
end
|
18
|
+
|
19
|
+
def options
|
20
|
+
VALID_OPTIONS_KEYS.inject({}){|o,k| o.merge!(k => send(k)) }
|
21
|
+
end
|
22
|
+
|
23
|
+
def reset
|
24
|
+
self.timeout = 30
|
25
|
+
self.open_timeout = 10
|
26
|
+
self.sport = nil
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
data/lib/cbs/request.rb
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
require 'hashie'
|
2
|
+
require 'faraday_middleware'
|
3
|
+
|
4
|
+
module CBS
|
5
|
+
module Request
|
6
|
+
|
7
|
+
def get(path, opts={})
|
8
|
+
request(:get, path, opts)
|
9
|
+
end
|
10
|
+
|
11
|
+
private
|
12
|
+
|
13
|
+
def request(method, path, opts)
|
14
|
+
response = connection(opts).send(method) do |request|
|
15
|
+
request.url(path, opts)
|
16
|
+
|
17
|
+
request.options[:timeout] = timeout
|
18
|
+
request.options[:open_timeout] = open_timeout
|
19
|
+
end
|
20
|
+
|
21
|
+
Hashie::Mash.new(response.body)
|
22
|
+
end
|
23
|
+
|
24
|
+
def connection(opts={})
|
25
|
+
options = {
|
26
|
+
url: api_url,
|
27
|
+
params: {
|
28
|
+
response_format: :json,
|
29
|
+
version: 3.0,
|
30
|
+
SPORT: opts.fetch(:sport, sport),
|
31
|
+
},
|
32
|
+
}
|
33
|
+
|
34
|
+
connection = Faraday.new(options) do |conn|
|
35
|
+
conn.response :json
|
36
|
+
conn.adapter Faraday.default_adapter
|
37
|
+
end
|
38
|
+
|
39
|
+
connection
|
40
|
+
end
|
41
|
+
|
42
|
+
end
|
43
|
+
end
|
data/lib/cbs/version.rb
CHANGED
data/spec/spec_helper.rb
ADDED
metadata
CHANGED
@@ -1,33 +1,58 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cbs
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
5
|
-
prerelease:
|
4
|
+
version: 0.0.1
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Andrew Thorp
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
11
|
+
date: 2017-03-18 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
|
-
name:
|
14
|
+
name: faraday
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
16
|
requirements:
|
19
|
-
- -
|
17
|
+
- - '='
|
20
18
|
- !ruby/object:Gem::Version
|
21
|
-
version:
|
22
|
-
type: :
|
19
|
+
version: 0.11.0
|
20
|
+
type: :runtime
|
23
21
|
prerelease: false
|
24
22
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
23
|
requirements:
|
27
|
-
- -
|
24
|
+
- - '='
|
28
25
|
- !ruby/object:Gem::Version
|
29
|
-
version:
|
30
|
-
|
26
|
+
version: 0.11.0
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: faraday_middleware
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 0.11.0
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 0.11.0
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: hashie
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '3.5'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3.5'
|
55
|
+
description: Ruby client for the CBS Sports API
|
31
56
|
email: andrewpthorp@gmail.com
|
32
57
|
executables: []
|
33
58
|
extensions: []
|
@@ -37,31 +62,37 @@ files:
|
|
37
62
|
- README.md
|
38
63
|
- Rakefile
|
39
64
|
- cbs.gemspec
|
40
|
-
- lib/cbs/version.rb
|
41
65
|
- lib/cbs.rb
|
66
|
+
- lib/cbs/client.rb
|
67
|
+
- lib/cbs/client/players.rb
|
68
|
+
- lib/cbs/client/teams.rb
|
69
|
+
- lib/cbs/configuration.rb
|
70
|
+
- lib/cbs/request.rb
|
71
|
+
- lib/cbs/version.rb
|
72
|
+
- spec/spec_helper.rb
|
42
73
|
homepage: https://github.com/andrewpthorp/cbs
|
43
74
|
licenses:
|
44
75
|
- MIT
|
76
|
+
metadata: {}
|
45
77
|
post_install_message:
|
46
78
|
rdoc_options: []
|
47
79
|
require_paths:
|
48
80
|
- lib
|
49
81
|
required_ruby_version: !ruby/object:Gem::Requirement
|
50
|
-
none: false
|
51
82
|
requirements:
|
52
|
-
- -
|
83
|
+
- - ">="
|
53
84
|
- !ruby/object:Gem::Version
|
54
85
|
version: '0'
|
55
86
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
56
|
-
none: false
|
57
87
|
requirements:
|
58
|
-
- -
|
88
|
+
- - ">="
|
59
89
|
- !ruby/object:Gem::Version
|
60
|
-
version:
|
90
|
+
version: '0'
|
61
91
|
requirements: []
|
62
92
|
rubyforge_project:
|
63
|
-
rubygems_version:
|
93
|
+
rubygems_version: 2.4.5.1
|
64
94
|
signing_key:
|
65
|
-
specification_version:
|
66
|
-
summary: Ruby
|
95
|
+
specification_version: 4
|
96
|
+
summary: Ruby client for the CBS Sports API
|
67
97
|
test_files: []
|
98
|
+
has_rdoc:
|