geordi 9.6.0 → 9.6.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3c01ad424ea8f33ca03229ba4d0355201bba562ee1de253f0135838b8e4163c3
4
- data.tar.gz: 8d011dfa82297202b05c8620a95e828ba96dcb797fcef6dc60d514e881601cd3
3
+ metadata.gz: 8a4dc434853c2c8af63e6ac18e69cca013d3a15316401f710c90deab74cd9bbb
4
+ data.tar.gz: c158a1f4c095120bfbd3ce9aacbd6bf13424994cdfd1ea5c2d5d8b613db5179e
5
5
  SHA512:
6
- metadata.gz: b9f691c5367a2f41937703e18dda5be92f69a4bac77cb31f5c89429156576126675f1c4dd00b84d3eecb1dda328c45fd81eb92cf36c9fd2b8d5689b9c37587ff
7
- data.tar.gz: d25a7208ab06766bda59c11d0d1c4a331ee17b8ac2f60d9de82f608759b942c3d067db7d7984929a90ba43775b7772f0b424771489b9f440e711033c955dc9c1
6
+ metadata.gz: 2260516cf299c4202fbf276c36abbee42190fb9e48b0f583b1af05a457c7676f6d23ccaee7d2bd8ddc2bcdfa923a255cae706dc5c1414c97eab1be58635ad205
7
+ data.tar.gz: e556b2806dea5a5badbcdad1c22faad5fb56daf95923f1c5ac88f64f1a764d18aacf4d0d683ad0f2b050cbdb131482895da3d58157992af2e11d67e75d0e75bf
data/CHANGELOG.md CHANGED
@@ -10,10 +10,21 @@ This project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html
10
10
  ### Breaking changes
11
11
 
12
12
 
13
- # 9.5.1 - 2023-04-26
13
+ # 9.6.1 2023-09-22
14
14
 
15
15
  ### Compatible changes
16
+ * `chromedriver-update` command: Retrieve chromedriver from new location
16
17
 
18
+
19
+ # 9.6.0 2023-07-24
20
+
21
+ ### Compatible changes
22
+ * Add suggestions of related commands
23
+
24
+
25
+ # 9.5.1 2023-04-26
26
+
27
+ ### Compatible changes
17
28
  * `cucumber` command: Support the passing of options without "="
18
29
 
19
30
 
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- geordi (9.6.0)
4
+ geordi (9.6.1)
5
5
  thor (~> 1)
6
6
 
7
7
  GEM
@@ -1,9 +1,12 @@
1
1
  require 'open3'
2
2
  require 'net/http'
3
3
  require 'tempfile'
4
+ require 'json'
5
+ require 'fileutils'
4
6
 
5
7
  module Geordi
6
8
  class ChromedriverUpdater
9
+ VERSIONS_PER_MILESTONES_URL = "https://googlechromelabs.github.io/chrome-for-testing/latest-versions-per-milestone-with-downloads.json"
7
10
 
8
11
  def run(options)
9
12
  chrome_version = determine_chrome_version
@@ -11,7 +14,7 @@ module Geordi
11
14
 
12
15
  latest_chromedriver_version = latest_version(chrome_version)
13
16
  if current_chromedriver_version == latest_chromedriver_version
14
- Interaction.success "No update required: Chromedriver is already on the latest version v#{latest_chromedriver_version}!" unless options[:quiet_if_matching]
17
+ Interaction.note "No update required. Chromedriver is already on the latest version #{latest_chromedriver_version}." unless options[:quiet_if_matching]
15
18
  else
16
19
  update_chromedriver(latest_chromedriver_version)
17
20
  end
@@ -49,8 +52,8 @@ module Geordi
49
52
 
50
53
  # Check https://groups.google.com/a/chromium.org/g/chromium-discuss/c/4BB4jmsRyv8/m/TY3FXS4HBgAJ
51
54
  # for information how chrome version numbers work
52
- def major_version(full_version)
53
- full_version.match(/^(\d+\.\d+\.\d+)\.\d+$/)[1]
55
+ def milestone_version(full_version)
56
+ full_version.match(/^\d+/)[0]
54
57
  end
55
58
 
56
59
  def update_chromedriver(latest_chromedriver_version)
@@ -62,39 +65,68 @@ module Geordi
62
65
  Interaction.success "Chromedriver updated to v#{determine_chromedriver_version}."
63
66
  end
64
67
 
65
- def download_chromedriver(latest_version)
66
- uri = URI("https://chromedriver.storage.googleapis.com/#{latest_version}/chromedriver_linux64.zip")
67
- response = Net::HTTP.get_response(uri)
68
-
69
- if response.is_a?(Net::HTTPSuccess)
70
- file = Tempfile.new(['chromedriver', '.zip'])
68
+ def download_chromedriver(version)
69
+ fetch_response(chromedriver_url(version), "Could not download chromedriver v#{version}.") do |response|
70
+ file = Tempfile.new(%w[chromedriver .zip])
71
71
  file.write(response.body)
72
72
 
73
73
  file
74
- else
75
- Interaction.fail("Could not download chromedriver v#{latest_version}.")
76
74
  end
77
75
  end
78
76
 
79
- def latest_version(chrome_version)
80
- return @latest_version if @latest_version
81
-
82
- uri = URI("https://chromedriver.storage.googleapis.com/LATEST_RELEASE_#{major_version(chrome_version)}")
77
+ def fetch_response(url, error_message)
78
+ uri = URI(url)
83
79
  response = Net::HTTP.get_response(uri)
84
80
 
85
81
  if response.is_a?(Net::HTTPSuccess)
86
- @latest_version = response.body.to_s
82
+ yield(response)
87
83
  else
88
- Interaction.fail("Could not download the chromedriver v#{chrome_version}.")
84
+ Interaction.fail(error_message)
85
+ end
86
+ end
87
+
88
+ def chromedriver_url(chrome_version)
89
+ chromedriver_per_platform = chromedriver_download_data.dig("milestones", milestone_version(chrome_version), "downloads", "chromedriver")
90
+ chromedriver = chromedriver_per_platform&.find do |chromedriver|
91
+ chromedriver["platform"] == "linux64"
92
+ end
93
+
94
+ if chromedriver && chromedriver["url"]
95
+ chromedriver["url"]
96
+ else
97
+ Interaction.fail("Could not find chromedriver download url for Chrome version v#{chrome_version}.")
98
+ end
99
+ end
100
+
101
+ def chromedriver_download_data
102
+ return @chromedriver_download_data if @chromedriver_download_data
103
+
104
+ fetch_response(VERSIONS_PER_MILESTONES_URL, "Could not find chromedriver download data") do |response|
105
+ begin
106
+ chromedriver_download_data = JSON.parse(response.body)
107
+ rescue JSON::ParserError
108
+ Interaction.fail("Could not parse chromedriver download data.")
109
+ end
110
+ @chromedriver_download_data = chromedriver_download_data
89
111
  end
90
112
  end
91
113
 
114
+ def latest_version(chrome_version)
115
+ latest_version = chromedriver_download_data.dig("milestones", milestone_version(chrome_version), "version")
116
+ latest_version || Interaction.fail("Could not find matching chromedriver for Chrome v#{chrome_version}.")
117
+ end
118
+
92
119
  def unzip(zip, output_dir)
93
120
  _stdout_str, _error_str, status = Open3.capture3('unzip', '-d', output_dir, '-o', zip.path)
94
121
 
95
122
  unless status.success?
96
123
  Interaction.fail("Could not unzip #{zip.path}.")
97
124
  end
125
+
126
+ # the archive contains a folder in which the relevant files are located. These files must be moved to ~/bin.
127
+ FileUtils.mv("#{output_dir}/chromedriver-linux64/chromedriver", output_dir)
128
+ FileUtils.mv("#{output_dir}/chromedriver-linux64//LICENSE.chromedriver", output_dir)
129
+ FileUtils.rm_rf("#{output_dir}/chromedriver-linux64")
98
130
  end
99
131
  end
100
132
  end
@@ -1,3 +1,3 @@
1
1
  module Geordi
2
- VERSION = '9.6.0'.freeze
2
+ VERSION = '9.6.1'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: geordi
3
3
  version: !ruby/object:Gem::Version
4
- version: 9.6.0
4
+ version: 9.6.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Henning Koch
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-07-24 00:00:00.000000000 Z
11
+ date: 2023-09-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -117,7 +117,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
117
117
  - !ruby/object:Gem::Version
118
118
  version: '0'
119
119
  requirements: []
120
- rubygems_version: 3.2.3
120
+ rubygems_version: 3.1.6
121
121
  signing_key:
122
122
  specification_version: 4
123
123
  summary: Collection of command line tools we use in our daily work with Ruby, Rails