fpl_gsheet 0.1.1 → 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3a417d8474122e918abc03aab2dcce5f7687c9383ec4b5cea648f8533834f345
4
- data.tar.gz: 94023b75aeb24c1257a1a7fa3d26a865b7c5b996b674c14a219777e050e2aed5
3
+ metadata.gz: 21c9e082024e848d7bce1cde916dd2af099188aa29c7088961dfea2bfb7a8c88
4
+ data.tar.gz: '038a7049bf9d921b6c80940fbf2ae96ec4bfafc54233e6c221117ca0d0fb5f6c'
5
5
  SHA512:
6
- metadata.gz: cad9ce0b39d10ae267506741a8176b7665d3d2cf74a78e5c240a11540acd457ef90306a436ffb3fae0acbdd0ed8396626400081142194ca838cc73d951f77b08
7
- data.tar.gz: 9e1fa97be9a71370bfd090feb5b16a1aa8d8c0132c346558e20440e856dd43ff35aec41b09e5ac805a67f7f75c636c2d047d81716c969274654d2ca50f2dfc10
6
+ metadata.gz: 9eafec5afc91026d2764bccf6f77f2ee579f1823a69abccd36d86972a20ec99a4baac43e7855a65ae0818c94406169b7c10f288bfc13328ecc060e9fa6108ce5
7
+ data.tar.gz: 107fa3ab205e4c7a0b72d1d8c1b32cd9fa582ad40a6a4b8395bdf217a15efbb81d65ebdeaef12fdaa763a4a91c80c7873f98942e36b9655048ea09f563b589a8
data/.gitignore CHANGED
@@ -1,12 +1,14 @@
1
- /.bundle/
2
- /.yardoc
3
- /_yardoc/
4
- /coverage/
5
- /doc/
6
- /pkg/
7
- /spec/reports/
8
- /tmp/
9
-
10
- # rspec failure tracking
11
- .rspec_status
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+
10
+ # rspec failure tracking
11
+ .rspec_status
12
+
13
+
12
14
  client_secret.json
data/.rspec CHANGED
@@ -1,3 +1,3 @@
1
- --format documentation
2
- --color
3
- --require spec_helper
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.travis.yml CHANGED
@@ -1,5 +1,5 @@
1
- sudo: false
2
- language: ruby
3
- rvm:
4
- - 2.2.5
5
- before_install: gem install bundler -v 1.16.1
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.2.5
5
+ before_install: gem install bundler -v 1.16.1
data/Gemfile CHANGED
@@ -1,6 +1,6 @@
1
- source "https://rubygems.org"
2
-
3
- git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
-
5
- # Specify your gem's dependencies in fpl_gsheet.gemspec
6
- gemspec
1
+ source "https://rubygems.org"
2
+
3
+ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
+
5
+ # Specify your gem's dependencies in fpl_gsheet.gemspec
6
+ gemspec
data/Gemfile.lock CHANGED
@@ -1,77 +1,74 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- fpl_gsheet (0.1.0)
4
+ fpl_gsheet (0.2.0)
5
5
  google_drive (~> 2.1)
6
6
  recursive-open-struct (~> 1.1)
7
7
 
8
8
  GEM
9
9
  remote: https://rubygems.org/
10
10
  specs:
11
- addressable (2.5.2)
12
- public_suffix (>= 2.0.2, < 4.0)
11
+ addressable (2.7.0)
12
+ public_suffix (>= 2.0.2, < 5.0)
13
13
  declarative (0.0.10)
14
14
  declarative-option (0.1.0)
15
- diff-lcs (1.2.5)
16
- faraday (0.15.0)
15
+ diff-lcs (1.3)
16
+ faraday (0.17.3)
17
17
  multipart-post (>= 1.2, < 3)
18
- google-api-client (0.19.8)
18
+ google-api-client (0.21.2)
19
19
  addressable (~> 2.5, >= 2.5.1)
20
20
  googleauth (>= 0.5, < 0.7.0)
21
21
  httpclient (>= 2.8.1, < 3.0)
22
22
  mime-types (~> 3.0)
23
23
  representable (~> 3.0)
24
24
  retriable (>= 2.0, < 4.0)
25
- google_drive (2.1.10)
26
- google-api-client (>= 0.11.0, < 0.20.0)
25
+ google_drive (2.1.12)
26
+ google-api-client (>= 0.11.0, < 0.22.0)
27
27
  googleauth (>= 0.5.0, < 1.0.0)
28
28
  nokogiri (>= 1.5.3, < 2.0.0)
29
- googleauth (0.6.2)
29
+ googleauth (0.6.7)
30
30
  faraday (~> 0.12)
31
31
  jwt (>= 1.4, < 3.0)
32
- logging (~> 2.0)
33
- memoist (~> 0.12)
32
+ memoist (~> 0.16)
34
33
  multi_json (~> 1.11)
35
- os (~> 0.9)
34
+ os (>= 0.9, < 2.0)
36
35
  signet (~> 0.7)
37
36
  httpclient (2.8.3)
38
- jwt (2.1.0)
39
- little-plugger (1.1.4)
40
- logging (2.2.2)
41
- little-plugger (~> 1.1)
42
- multi_json (~> 1.10)
43
- memoist (0.16.0)
44
- mime-types (3.1)
37
+ jwt (2.2.1)
38
+ memoist (0.16.2)
39
+ mime-types (3.3.1)
45
40
  mime-types-data (~> 3.2015)
46
- mime-types-data (3.2016.0521)
47
- mini_portile2 (2.3.0)
48
- multi_json (1.13.1)
49
- multipart-post (2.0.0)
50
- nokogiri (1.8.2-x86-mingw32)
51
- mini_portile2 (~> 2.3.0)
52
- os (0.9.6)
53
- public_suffix (3.0.2)
54
- rake (10.4.2)
41
+ mime-types-data (3.2019.1009)
42
+ mini_portile2 (2.4.0)
43
+ multi_json (1.14.1)
44
+ multipart-post (2.1.1)
45
+ nokogiri (1.10.7-x64-mingw32)
46
+ mini_portile2 (~> 2.4.0)
47
+ nokogiri (1.10.7-x86-mingw32)
48
+ mini_portile2 (~> 2.4.0)
49
+ os (1.0.1)
50
+ public_suffix (4.0.3)
51
+ rake (10.5.0)
55
52
  recursive-open-struct (1.1.0)
56
53
  representable (3.0.4)
57
54
  declarative (< 0.1.0)
58
55
  declarative-option (< 0.2.0)
59
56
  uber (< 0.2.0)
60
- retriable (3.1.1)
61
- rspec (3.5.0)
62
- rspec-core (~> 3.5.0)
63
- rspec-expectations (~> 3.5.0)
64
- rspec-mocks (~> 3.5.0)
65
- rspec-core (3.5.2)
66
- rspec-support (~> 3.5.0)
67
- rspec-expectations (3.5.0)
57
+ retriable (3.1.2)
58
+ rspec (3.9.0)
59
+ rspec-core (~> 3.9.0)
60
+ rspec-expectations (~> 3.9.0)
61
+ rspec-mocks (~> 3.9.0)
62
+ rspec-core (3.9.1)
63
+ rspec-support (~> 3.9.1)
64
+ rspec-expectations (3.9.0)
68
65
  diff-lcs (>= 1.2.0, < 2.0)
69
- rspec-support (~> 3.5.0)
70
- rspec-mocks (3.5.0)
66
+ rspec-support (~> 3.9.0)
67
+ rspec-mocks (3.9.1)
71
68
  diff-lcs (>= 1.2.0, < 2.0)
72
- rspec-support (~> 3.5.0)
73
- rspec-support (3.5.0)
74
- signet (0.8.1)
69
+ rspec-support (~> 3.9.0)
70
+ rspec-support (3.9.2)
71
+ signet (0.12.0)
75
72
  addressable (~> 2.3)
76
73
  faraday (~> 0.9)
77
74
  jwt (>= 1.5, < 3.0)
@@ -79,6 +76,7 @@ GEM
79
76
  uber (0.1.0)
80
77
 
81
78
  PLATFORMS
79
+ x64-mingw32
82
80
  x86-mingw32
83
81
 
84
82
  DEPENDENCIES
@@ -88,4 +86,4 @@ DEPENDENCIES
88
86
  rspec (~> 3.0)
89
87
 
90
88
  BUNDLED WITH
91
- 1.16.1
89
+ 1.17.2
data/LICENSE.txt CHANGED
@@ -1,21 +1,21 @@
1
- The MIT License (MIT)
2
-
3
- Copyright (c) 2018 reedstonefood
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in
13
- all copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
- THE SOFTWARE.
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2020 reedstonefood
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md CHANGED
@@ -1,59 +1,60 @@
1
- # Fpl_Gsheet
2
-
3
- A Ruby gem for extracting information from [Fantasy Premier League](https://fantasy.premierleague.com/a/home) & storing the information in a Google Sheet, for onwards analysis.
4
-
5
- For example, you could use Tableau Public to access the Google Sheet and create some great visualisations.
6
-
7
- ## Installation
8
-
9
- 1. Install the gem.
10
- gem install fpl_gsheet
11
-
12
- 2. To allow the gem access to a Google sheet, the following steps must be followed.
13
- -- Create a Google service account
14
- -- Store the client_secret.json file in the same location as the script you write that uses this gem
15
- -- Create a google sheet & share it (giving it edit access) with the user created in the first step
16
- More detailed instructions & a nice animated gif can be [found here](https://www.twilio.com/blog/2017/03/google-spreadsheets-ruby.html).
17
-
18
-
19
- ## Usage
20
-
21
- ```ruby
22
- gem 'fpl_gsheet'
23
-
24
- # stores all "generic" data, eg teams, players, fixtures
25
- databank = FplGsheet::Databank.new
26
-
27
- # put the reference to your spreadsheet here.
28
- # This must already exist & have been shared with the service account
29
- spreadsheet = FplGsheet::Spreadsheet.new('FplGsheet sample')
30
-
31
- # Put all team names into the spreadsheet
32
- spreadsheet.new_sheet('Teams')
33
- spreadsheet.add_row(['Team ID', 'Team Name']) # header row
34
- databank.teams.each do |t|
35
- spreadsheet.insert_new_row([t['id'], t['name'])
36
- end
37
- spreadsheet.save # commits the changes you've written
38
-
39
- # load a league - the ID can be found in the URL of the league table page,
40
- # eg https://fantasy.premierleague.com/a/leagues/standings/487590/classic
41
- league = FplGsheet::League.new(487590)
42
-
43
- # Put team names & score into spreadsheet
44
- spreadsheet.new_sheet('League')
45
- spreadsheet.insert_new_row(%w(Rank Team Score))
46
-
47
- league.standings.each do |s|
48
- spreadsheet.insert_new_row([
49
- s['rank'],
50
- s['entry_name'],
51
- s['total']
52
- ])
53
- end
54
- spreadsheet.save
55
- ```
56
-
57
- ## More usage information
58
-
1
+ # Fpl_Gsheet
2
+
3
+ A Ruby gem for extracting information from [Fantasy Premier League](https://fantasy.premierleague.com/a/home) & storing the information in a Google Sheet, for onwards analysis.
4
+
5
+ For example, you could use Tableau Public to access the Google Sheet and create some great visualisations.
6
+
7
+ ## Installation
8
+
9
+ 1. Install the gem.
10
+ gem install fpl_gsheet
11
+
12
+ 2. To allow the gem access to a Google sheet, the following steps must be followed.
13
+
14
+ * Create a Google service account
15
+ * Store the client_secret.json file in the same location as the script you write that uses this gem
16
+ * Create a google sheet & share it (giving it edit access) with the user created in the first step
17
+ More detailed instructions & a nice animated gif can be [found here](https://www.twilio.com/blog/2017/03/google-spreadsheets-ruby.html).
18
+
19
+
20
+ ## Usage
21
+
22
+ ```ruby
23
+ gem 'fpl_gsheet'
24
+
25
+ # stores all "generic" data, eg teams, players, fixtures
26
+ databank = FplGsheet::Databank.new
27
+
28
+ # put the reference to your spreadsheet here.
29
+ # This must already exist & have been shared with the service account
30
+ spreadsheet = FplGsheet::Spreadsheet.new('FplGsheet sample')
31
+
32
+ # Put all team names into the spreadsheet
33
+ spreadsheet.new_sheet('Teams')
34
+ spreadsheet.add_row(['Team ID', 'Team Name']) # header row
35
+ databank.teams.each do |t|
36
+ spreadsheet.insert_new_row([t['id'], t['name'])
37
+ end
38
+ spreadsheet.save # commits the changes you've written
39
+
40
+ # load a league - the ID can be found in the URL of the league table page,
41
+ # eg https://fantasy.premierleague.com/a/leagues/standings/487590/classic
42
+ league = FplGsheet::League.new(487590)
43
+
44
+ # Put team names & score into spreadsheet
45
+ spreadsheet.new_sheet('League')
46
+ spreadsheet.insert_new_row(%w(Rank Team Score))
47
+
48
+ league.standings.each do |s|
49
+ spreadsheet.insert_new_row([
50
+ s['rank'],
51
+ s['entry_name'],
52
+ s['total']
53
+ ])
54
+ end
55
+ spreadsheet.save
56
+ ```
57
+
58
+ ## More usage information
59
+
59
60
  See the wiki on the [GitHub repo page](https://github.com/reedstonefood/fpl_gsheet).
data/Rakefile CHANGED
@@ -1,6 +1,6 @@
1
- require "bundler/gem_tasks"
2
- require "rspec/core/rake_task"
3
-
4
- RSpec::Core::RakeTask.new(:spec)
5
-
6
- task :default => :spec
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
data/bin/console CHANGED
@@ -1,14 +1,14 @@
1
- #!/usr/bin/env ruby
2
-
3
- require "bundler/setup"
4
- require "fpl/gsheet"
5
-
6
- # You can add fixtures and/or initialization code here to make experimenting
7
- # with your gem easier. You can also use a different console, if you like.
8
-
9
- # (If you use this, don't forget to add pry to your Gemfile!)
10
- # require "pry"
11
- # Pry.start
12
-
13
- require "irb"
14
- IRB.start(__FILE__)
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "fpl/gsheet"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
data/bin/setup CHANGED
@@ -1,8 +1,8 @@
1
- #!/usr/bin/env bash
2
- set -euo pipefail
3
- IFS=$'\n\t'
4
- set -vx
5
-
6
- bundle install
7
-
8
- # Do any other automated setup that you need to do here
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
data/fpl_gsheet.gemspec CHANGED
@@ -1,31 +1,30 @@
1
-
2
- lib = File.expand_path("../lib", __FILE__)
3
- $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require "fpl_gsheet/version"
5
-
6
- Gem::Specification.new do |spec|
7
- spec.name = "fpl_gsheet"
8
- spec.version = FplGsheet::VERSION
9
- spec.authors = ["reedstonefood"]
10
- spec.email = ["reedstonefood@users.noreply.github.com"]
11
-
12
- spec.summary = %q{Get Premier League Fantasy Football data into Google Sheets.}
13
- spec.description = %q{Data comes from fantasy.premierleague.com.}
14
- spec.homepage = "https://github.com/reedstonefood"
15
- spec.license = "MIT"
16
-
17
-
18
- spec.files = `git ls-files -z`.split("\x0").reject do |f|
19
- f.match(%r{^(test|spec|features)/})
20
- end
21
- spec.bindir = "exe"
22
- spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
23
- spec.require_paths = ["lib"]
24
-
25
- spec.add_development_dependency "bundler", "~> 1.16"
26
- spec.add_development_dependency "rake", "~> 10.0"
27
- spec.add_development_dependency "rspec", "~> 3.0"
28
- spec.add_dependency "google_drive", "~> 2.1"
29
- #spec.add_dependency "google_api_client", "~> 0.4.3" #really?
30
- spec.add_dependency "recursive-open-struct", "~> 1.1"
31
- end
1
+
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "fpl_gsheet/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "fpl_gsheet"
8
+ spec.version = FplGsheet::VERSION
9
+ spec.authors = ["reedstonefood"]
10
+ spec.email = ["reedstonefood@users.noreply.github.com"]
11
+
12
+ spec.summary = %q{Get Premier League Fantasy Football data into Google Sheets.}
13
+ spec.description = %q{Data comes from fantasy.premierleague.com.}
14
+ spec.homepage = "https://github.com/reedstonefood"
15
+ spec.license = "MIT"
16
+
17
+
18
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
19
+ f.match(%r{^(test|spec|features)/})
20
+ end
21
+ spec.bindir = "exe"
22
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
23
+ spec.require_paths = ["lib"]
24
+
25
+ spec.add_development_dependency "bundler", "~> 1.16"
26
+ spec.add_development_dependency "rake", "~> 10.0"
27
+ spec.add_development_dependency "rspec", "~> 3.0"
28
+ spec.add_dependency "google_drive", "~> 2.1"
29
+ spec.add_dependency "recursive-open-struct", "~> 1.1"
30
+ end
@@ -11,36 +11,36 @@ module FplGsheet
11
11
  def initialize
12
12
  #some stuff outside the scope of this review
13
13
  #just assume the fixtures and teams methods work
14
- @all_data=JSON.load(open("https://fantasy.premierleague.com/drf/bootstrap-static", {ssl_verify_mode: 0}))
15
- @fixture_data=JSON.load(open("https://fantasy.premierleague.com/drf/fixtures", {ssl_verify_mode: 0}))
14
+ @all_data=JSON.load(open("https://fantasy.premierleague.com/api/bootstrap-static/", {ssl_verify_mode: 0}))
15
+ @fixture_data=JSON.load(open("https://fantasy.premierleague.com/api/fixtures/", {ssl_verify_mode: 0}))
16
16
  end
17
17
 
18
18
  def fixtures
19
19
  #returns array of all Fixtures
20
20
  @fixtures ||= @fixture_data.map { |f| Fixture.new(f, self) }
21
21
  end
22
-
22
+
23
23
  def teams
24
24
  #returns array of all Teams
25
25
  return @teams if defined? @teams
26
- @teams = @all_data['teams'].map do |t|
26
+ @teams = @all_data['teams'].map do |t|
27
27
  Team.new(t, self)
28
28
  end
29
29
  end
30
-
30
+
31
31
  def players
32
32
  return @players if defined? @players
33
- @players = @all_data['elements'].map do |t|
33
+ @players = @all_data['elements'].map do |t|
34
34
  Player.new(t, self)
35
35
  end
36
36
  end
37
-
37
+
38
38
  def fixtures_for_team(id)
39
39
  fixtures.select do |f|
40
40
  id==f.data['team_h'] || id==f.data['team_a']
41
41
  end
42
42
  end
43
-
43
+
44
44
  def gameweeks
45
45
  @gameweeks ||= @all_data['events']
46
46
  end
@@ -69,14 +69,14 @@ module FplGsheet
69
69
  # @h_score = fixture.data['team_h_score']
70
70
  # @a_score = fixture.data['team_a_score']
71
71
  # end
72
- #
72
+ #
73
73
  # def result
74
74
  # return '-' if @h_score=='null'
75
75
  # return 'D' if @h_score==a_score
76
76
  # winner = @h_score==@a_score ? 'H' : 'A'
77
77
  # return @venue==winner ? 'W' : 'L'
78
78
  # end
79
- #
79
+ #
80
80
  # def own_score
81
81
  # @venue=='H' ? @h_score : @a_score
82
82
  # end
@@ -84,14 +84,14 @@ module FplGsheet
84
84
  # def opp_score
85
85
  # @venue=='H' ? @a_score : @h_score
86
86
  # end
87
- #
87
+ #
88
88
  # def opponent
89
89
  # id = @venue=='H' ? @fixture['team_a'] : @fixture['team_h']
90
90
  # # How to get from this id to the Team object it represents?
91
91
  # end
92
92
  #end
93
93
  end
94
-
94
+
95
95
  #d = Databank.new
96
96
  #d.teams.each do |t|
97
97
  # puts "#{t.data['name'].upcase} are playing these teams..."
@@ -1,54 +1,54 @@
1
+ require 'open-uri'
1
2
 
2
3
  module FplGsheet
3
4
  class Entry
4
5
  attr_reader :name, :id
5
6
  def initialize(entry_id)
6
- entry_json=JSON.load(open("https://fantasy.premierleague.com/drf/entry/#{entry_id}/transfers", {ssl_verify_mode: 0}))
7
- @entry_data=entry_json['entry']
7
+ entry_json=JSON.load(open("https://fantasy.premierleague.com/api/entry/#{entry_id}/", {ssl_verify_mode: 0}))
8
+ @entry_data=entry_json.reject { |e| e.is_a? Hash }
8
9
  @league_data=entry_json['leagues']
9
10
  @name=@entry_data['name']
10
11
  @id=@entry_data['id']
11
12
  @historical_gameweeks = Hash.new()
12
13
  #@fixtures = fixtures.map { |f| TeamFixture.new(f, @data['id']) }
13
14
  end
14
-
15
+
15
16
  def manager_name
16
17
  @entry_data['player_first_name'] + ' ' + @entry_data['player_last_name']
17
18
  end
18
-
19
+
19
20
  def history
20
- @history ||= JSON.load(open("https://fantasy.premierleague.com/drf/entry/#{id}/history", {ssl_verify_mode: 0}))
21
+ @history ||= JSON.load(open("https://fantasy.premierleague.com/api/entry/#{id}/history/", {ssl_verify_mode: 0}))
21
22
  end
22
-
23
-
23
+
24
+
24
25
  def transfers
25
- @transfer_data ||= JSON.load(open("https://fantasy.premierleague.com/drf/entry/#{id}/transfers", {ssl_verify_mode: 0}))
26
- @transfer_data["history"]
26
+ @transfer_data ||= JSON.load(open("https://fantasy.premierleague.com/api/entry/#{id}/transfers/", {ssl_verify_mode: 0}))
27
+ @transfer_data.reverse # At some point FPL changed to have newest transfers first; that's just silly
27
28
  end
28
-
29
+
29
30
  def chips; history["chips"]; end
30
-
31
+
31
32
  def summary; history["entry"]; end
32
-
33
- def past_seasons; history["season"]; end
34
-
35
- def gameweek_history; history["history"]; end
36
-
33
+
34
+ def past_seasons; history["past"]; end
35
+
36
+ def gameweek_history; history["current"]; end
37
+
37
38
  def picks
38
39
  latest_gameweek = gameweek_history.last['event']
39
40
  picks_for_gameweek[latest_gameweek]
40
41
  end
41
-
42
+
42
43
  def picks_for_gameweek(gw)
43
44
  return @historical_gameweeks[gw] if @historical_gameweeks.key?(gw)
44
- api ||= JSON.load(open("https://fantasy.premierleague.com/drf/entry/#{id}/event/#{gw}/picks", {ssl_verify_mode: 0}))
45
+ api ||= JSON.load(open("https://fantasy.premierleague.com/api/entry/#{id}/event/#{gw}/picks/", {ssl_verify_mode: 0}))
45
46
  @historical_gameweeks[gw] = api['picks'].map { |p| Pick.new(p)}
46
47
  end
47
-
48
48
  end
49
-
49
+
50
50
  class Entries < Hash
51
-
51
+
52
52
  def [](key)
53
53
  val = super
54
54
  if val.nil?
@@ -61,5 +61,5 @@ module FplGsheet
61
61
  val
62
62
  end
63
63
  end
64
-
64
+
65
65
  end
@@ -3,16 +3,16 @@ module FplGsheet
3
3
  class League
4
4
  attr_reader :name, :id
5
5
  def initialize(league_id)
6
- @league_data=JSON.load(open("https://fantasy.premierleague.com/drf/leagues-classic-standings/#{league_id}", {ssl_verify_mode: 0}))
6
+ @league_data=JSON.load(open("https://fantasy.premierleague.com/api/leagues-classic/#{league_id}/standings/", {ssl_verify_mode: 0}))
7
7
  @name=@league_data['league']['name']
8
8
  @id=@league_data['league']['id']
9
9
  #@fixtures = fixtures.map { |f| TeamFixture.new(f, @data['id']) }
10
10
  end
11
-
11
+
12
12
  def standings
13
13
  @standings ||= @league_data['standings']['results']
14
14
  end
15
-
15
+
16
16
  end
17
-
17
+
18
18
  end
@@ -1,3 +1,3 @@
1
- module FplGsheet
2
- VERSION = "0.1.1"
3
- end
1
+ module FplGsheet
2
+ VERSION = "0.2.0"
3
+ end
data/lib/fpl_gsheet.rb CHANGED
@@ -1,13 +1,13 @@
1
- require "fpl_gsheet/version"
2
- require "fpl_gsheet/spreadsheet"
3
- require "fpl_gsheet/databank"
4
- require "fpl_gsheet/fixture"
5
- require "fpl_gsheet/league"
6
- require "fpl_gsheet/player"
7
- require "fpl_gsheet/team"
8
- require "fpl_gsheet/entry"
9
- require "fpl_gsheet/pick"
10
-
11
- module FplGsheet
12
- # Your code goes here...
13
- end
1
+ require "fpl_gsheet/version"
2
+ require "fpl_gsheet/spreadsheet"
3
+ require "fpl_gsheet/databank"
4
+ require "fpl_gsheet/fixture"
5
+ require "fpl_gsheet/league"
6
+ require "fpl_gsheet/player"
7
+ require "fpl_gsheet/team"
8
+ require "fpl_gsheet/entry"
9
+ require "fpl_gsheet/pick"
10
+
11
+ module FplGsheet
12
+ # Your code goes here...
13
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fpl_gsheet
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - reedstonefood
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-10-10 00:00:00.000000000 Z
11
+ date: 2020-01-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -97,7 +97,6 @@ files:
97
97
  - Rakefile
98
98
  - bin/console
99
99
  - bin/setup
100
- - client_secret.json
101
100
  - fpl_gsheet.gemspec
102
101
  - lib/fpl_gsheet.rb
103
102
  - lib/fpl_gsheet/databank.rb
@@ -128,8 +127,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
128
127
  - !ruby/object:Gem::Version
129
128
  version: '0'
130
129
  requirements: []
131
- rubyforge_project:
132
- rubygems_version: 2.7.6
130
+ rubygems_version: 3.0.3
133
131
  signing_key:
134
132
  specification_version: 4
135
133
  summary: Get Premier League Fantasy Football data into Google Sheets.
data/client_secret.json DELETED
@@ -1,12 +0,0 @@
1
- {
2
- "type": "service_account",
3
- "project_id": "innate-works-201616",
4
- "private_key_id": "f1d63496e3156e67fee7fd2cf3393c61b6335691",
5
- "private_key": "-----BEGIN PRIVATE KEY-----\nMIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQCqYVuGNfyOBfl3\nJgvNJZ0Zvpc1zD1u2pwZ0pMnl7dXPim+2XL1h53s761gATvLSuqleQDMvZbxZ6iR\nbtISlcpW1q+dhYmk8r1ZyHO3Xjf8hrSg5T5NsxgJk5TG81BrQNkDyxhhF7VYuAtK\nU08fcZ5N6PWbyEHovbq2KisLGSjzC3xqdTGmUmM3FIgL19NdVgw09uKJlgUPXyHl\nYh8o7PGjgKYbX4Xura9iyqkZ1CEnA66r/DgU0+ff8Ayxfa8rZ9WZKGfo4dCGiRSd\noanaweWdRpAG6b7imXlhpKdU24YBoLgeLo9eA78IwZClu1fOEdc74mYvsS/+67I6\nxbko9SoJAgMBAAECggEAGvueLgwgujFSB7+bwNqDHc+kTN3SoNq4PBKwQWXyoDt1\nCwePADmBFkQC9iBb4t8zeA9IxCQGYqbi+F1PoafdSpFncI/0c44J1M09Hj4qqbB/\nrLeBfXauiN25gySHiOTVOZeRfdbuXmWPTC8TacxpoLcTJp+5aG2bwzu8Y16RsKPP\nqGjKWgQeDcXrLqMRADZXaQkBtfNZoi0GI3qxigec6fA4K6M6am908Jkm6zOv8Sh2\n+rBrQGsgtipUKQDz7xXek3c4r9gkCQEHh+QVYHhPx/HkCG05RoIpnt/imNjvxUnj\n/Xl9m2s30keAIowJaQtep1348CfSCE47ATk0GXvdLQKBgQDi66KwGRjFUoybinIx\nM5uOlARP7vNX/6CaljLN3ZFqoEIKBhDPynce7t+L7Yz/ZttP/G5DPxAjmKRaA9Bu\nUrWjnMVYifNHhO/CttrqH0uXfU7mx7XJCfLCj4EZY1r+2C9wJhC68iOe1NL+vW0i\nYUzlHwwMOytCxEn46mVZ37R/kwKBgQDANtzlYF9HXrLEtPDtPKmz+0LdN6C82+G+\nIKuhMRXZgQ70MNlBKarTo7FPh9HxqEWR76yXjib91v585m23ohFJtJ3Cae/Ly8ci\neOcHcesQYa7/fkP5s18O/3xWZ2nFfDosFqoyhXUlne9ZWVeCLlKOWTPGjYb7jnAE\nEB5V5XuZcwKBgCPqkex3fHE2+KRhzGM3PObbTLduJbwG7N+q6E2nRS3wQaOehCiv\nbh1KR725ErkWCZ5mYPlp0N8heNn6gpIDq1ZDKQUziHsIcn6KPKoT2/4VSljCwWYZ\nmf/rgM6I6E0v4IpKrBk63CJ2oxLI3q4zYl1dhaWl89n0gZTRXMtV2hbbAoGBAIu3\nFUexjnAdOIpdD4cSAjSuHYMZDUBZ/7OoobiQKlaoRctfuntwIxilMpwhmIw0iSUz\n9ttO267FWMRG5leFeVV+8PFA+anEHKJFCYFS389Pgdl62UQmiqEnOiTAFJUU4F/t\ntZb1hRpru2/Rzhb1PtLzqfvYIda2SVvar4I2RWpbAoGBAMalwnqw4NbS22qrZBG/\n6NU49X81C0jZcBRoVWUOsv9GPWHqB4p2+hA2a9sgZwVaqsqO8rmG06pr7urwi0gL\nrHuQ/KtYfdaZY9uHDqXgxSuvK4nzpv5I9MO/W8SeLArU61ZwNl5Nn6u+eqjY6JKD\nBwelbhBAxYvzdcNRKnM5WaK7\n-----END PRIVATE KEY-----\n",
6
- "client_email": "ruby-service-account@innate-works-201616.iam.gserviceaccount.com",
7
- "client_id": "117713227265954709342",
8
- "auth_uri": "https://accounts.google.com/o/oauth2/auth",
9
- "token_uri": "https://accounts.google.com/o/oauth2/token",
10
- "auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
11
- "client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/ruby-service-account%40innate-works-201616.iam.gserviceaccount.com"
12
- }