geordi 9.1.0 → 9.3.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: 337e7767788852ee10b537112f4151f4b12e267740fa20557b7786e12babd97d
4
- data.tar.gz: 0dd146812562eb28fa115cbbdefa1bffcc8b172f1b509d44414bcca667ce3774
3
+ metadata.gz: 53000c0f7a45eb1abdbda692ef86f6add4b03a526a663d2080ae893d739e5e79
4
+ data.tar.gz: 92f23443438253a43960d00b726646a57e1e9a2c413f167bbce1c4d747addd99
5
5
  SHA512:
6
- metadata.gz: '07256569d49cf31224e4a69d5fc0e240d9c8df820e527fd615b1e5956f320fa01077572b4e79401bf7a5ee8b8d9bf135b94c369ef807a2bc40c36aa76eb7180a'
7
- data.tar.gz: 18bf3b9d1026575a5c0c3d33281de6b211ffa38c8c0d316656c6aee90bcdc2b81e5cec2feae0f006f2ef3fb8458834c1813dcd8d2aff5adcdf17bed732a06217
6
+ metadata.gz: 37e18e79036a4d13cec85463458f2be6e1752485f747d10873c8a8a8ae29be92580233bb895d8fb73c059d0905cc2a646db34d5fd163228d66d59a215f4c4757
7
+ data.tar.gz: 9a58e6558bcd390d1f1749764fef54c6b590e3c67899256797afaaf9ebcb4efc10d5cfd91fcbdda113ed2ed8301903d5ecbbf16dc8c1c5a6c8c04f219d1a03a7
data/CHANGELOG.md CHANGED
@@ -3,14 +3,26 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  This project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
5
5
 
6
-
7
6
  ## Unreleased
8
7
 
9
8
  ### Compatible changes
9
+ * Use YAML.safe_load in dumple and allow aliases
10
10
 
11
11
  ### Breaking changes
12
12
 
13
13
 
14
+ ## 9.3.0 2022-04-26
15
+
16
+ ### Compatible changes
17
+ * Add dump loading in multi-database-setups.
18
+
19
+
20
+ ## 9.2.0 2022-02-18
21
+
22
+ ### Compatible changes
23
+ * Change the update mechanism of `geordi chromedriver-update`: This command (and `geordi cucumber`/`geordi tests` if the `auto_update_chromedriver` option is active) will now always update to the latest version of chromedriver for the current chrome version.
24
+
25
+
14
26
  ## 9.1.0 2022-02-14
15
27
 
16
28
  ### Compatible changes
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- geordi (9.1.0)
4
+ geordi (9.3.1)
5
5
  thor (~> 1)
6
6
 
7
7
  GEM
@@ -165,4 +165,4 @@ DEPENDENCIES
165
165
  tracker_api
166
166
 
167
167
  BUNDLED WITH
168
- 2.2.27
168
+ 2.3.6
data/README.md CHANGED
@@ -53,10 +53,10 @@ installed Chrome.
53
53
 
54
54
  Setting `auto_update_chromedriver` to `true` in your global Geordi config file
55
55
  (`~/.config/geordi/global.yml`), will automatically update chromedriver before
56
- cucumber tests, in case Chrome and chromedriver versions don't match
56
+ cucumber tests if a newer chromedriver version is available.
57
57
 
58
58
  **Options**
59
- - `[--quiet-if-matching], [--no-quiet-if-matching]`: Suppress notification if chromedriver and chrome versions match
59
+ - `[--quiet-if-matching], [--no-quiet-if-matching]`: Suppress notification if chromedriver is already on the latest version
60
60
 
61
61
 
62
62
  ### `geordi clean`
@@ -195,16 +195,20 @@ specified target's database and downloads it to `tmp/`.
195
195
  option) sources the dump into the development database after downloading it.
196
196
 
197
197
  If you are using multiple databases per environment, Geordi defaults to the
198
- "primary" database, or the first entry in database.yml. To dump a specific
198
+ "primary" database, or the first entry in database.yml. To target a specific
199
199
  database, pass the database name like this:
200
+ ```
201
+ geordi dump -d primary
202
+ ```
200
203
 
201
- geordi dump -d primary
202
-
203
- Loading a dump into one of multiple local databases is not supported yet.
204
+ When used with the blank `load` option ("dump and source"), the `database` option
205
+ will be respected both for the remote *and* the local database. If these should
206
+ not match, please issue separate commands for dumping (`dump -d`) and sourcing
207
+ (`dump -l -d`).
204
208
 
205
209
  **Options**
206
210
  - `-l, [--load=[DUMP_FILE]]`: Load a dump
207
- - `-d, [--database=NAME]`: Database name, if there are multiple databases
211
+ - `-d, [--database=NAME]`: Target database, if there are multiple databases
208
212
 
209
213
 
210
214
  ### `geordi help [COMMAND]`
data/exe/dumple CHANGED
@@ -92,7 +92,11 @@ end
92
92
  def find_database_config(config_path, environment, database)
93
93
  environment ||= 'production'
94
94
  database_yml = ERB.new(File.read(config_path)).result
95
- config = YAML::load(database_yml)
95
+ config = if Gem::Version.new(Psych::VERSION) >= Gem::Version.new('3.1.0')
96
+ YAML.safe_load(database_yml, aliases: true)
97
+ else
98
+ YAML.safe_load(database_yml, [], [], true)
99
+ end
96
100
  config = config[environment] or raise "x No #{environment} database found.\nUsage: dumple ENVIRONMENT [DATABASE]"
97
101
 
98
102
  if config.values[0].is_a? Hash # Multi-db setup
@@ -7,18 +7,13 @@ module Geordi
7
7
 
8
8
  def run(options)
9
9
  chrome_version = determine_chrome_version
10
- chromedriver_version = determine_chromedriver_version
10
+ current_chromedriver_version = determine_chromedriver_version
11
11
 
12
- if skip_update?(chrome_version, chromedriver_version)
13
- Interaction.success "No update required: both Chrome and chromedriver are on v#{chrome_version}!" unless options[:quiet_if_matching]
12
+ latest_chromedriver_version = latest_version(chrome_version)
13
+ 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]
14
15
  else
15
- chromedriver_zip = download_chromedriver(chrome_version)
16
- unzip(chromedriver_zip, File.expand_path('~/bin'))
17
-
18
- chromedriver_zip.unlink
19
-
20
- # We need to determine the version again, as it could be nil in case no chromedriver was installed before
21
- Interaction.success "Chromedriver updated to v#{determine_chromedriver_version}."
16
+ update_chromedriver(latest_chromedriver_version)
22
17
  end
23
18
  end
24
19
 
@@ -27,13 +22,13 @@ module Geordi
27
22
  def determine_chrome_version
28
23
  stdout_str, _error_str, status = Open3.capture3('google-chrome', '--version')
29
24
  chrome_version = unless stdout_str.nil?
30
- stdout_str[/\AGoogle Chrome (\d+)/, 1]
25
+ stdout_str[/\AGoogle Chrome ([\d.]+)/, 1]
31
26
  end
32
27
 
33
28
  if !status.success? || chrome_version.nil?
34
29
  Interaction.fail('Could not determine the version of Google Chrome.')
35
30
  else
36
- chrome_version.to_i
31
+ chrome_version
37
32
  end
38
33
  end
39
34
 
@@ -42,23 +37,32 @@ module Geordi
42
37
 
43
38
  stdout_str, _error_str, status = Open3.capture3('chromedriver', '-v')
44
39
  chromedriver_version = unless stdout_str.nil?
45
- stdout_str[/\AChromeDriver (\d+)/, 1]
40
+ stdout_str[/\AChromeDriver ([\d.]+)/, 1]
46
41
  end
47
42
 
48
43
  if !status.success? || chromedriver_version.nil?
49
44
  Interaction.fail('Could not determine the version of chromedriver.')
50
45
  else
51
- chromedriver_version.to_i
46
+ chromedriver_version
52
47
  end
53
48
  end
54
49
 
55
- def skip_update?(chrome_version, chromedriver_version)
56
- chrome_version == chromedriver_version
50
+ # Check https://groups.google.com/a/chromium.org/g/chromium-discuss/c/4BB4jmsRyv8/m/TY3FXS4HBgAJ
51
+ # for information how chrome version numbers work
52
+ def major_version(full_version)
53
+ full_version.match(/^(\d+\.\d+\.\d+)\.\d+$/)[1]
57
54
  end
58
55
 
59
- def download_chromedriver(chrome_version)
60
- latest_version = latest_version(chrome_version)
56
+ def update_chromedriver(latest_chromedriver_version)
57
+ chromedriver_zip = download_chromedriver(latest_chromedriver_version)
58
+
59
+ unzip(chromedriver_zip, File.expand_path('~/bin'))
61
60
 
61
+ # We need to determine the version again, as it could be nil in case no chromedriver was installed before
62
+ Interaction.success "Chromedriver updated to v#{determine_chromedriver_version}."
63
+ end
64
+
65
+ def download_chromedriver(latest_version)
62
66
  uri = URI("https://chromedriver.storage.googleapis.com/#{latest_version}/chromedriver_linux64.zip")
63
67
  response = Net::HTTP.get_response(uri)
64
68
 
@@ -73,11 +77,13 @@ module Geordi
73
77
  end
74
78
 
75
79
  def latest_version(chrome_version)
76
- uri = URI("https://chromedriver.storage.googleapis.com/LATEST_RELEASE_#{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
83
  response = Net::HTTP.get_response(uri)
78
84
 
79
85
  if response.is_a?(Net::HTTPSuccess)
80
- response.body.to_s
86
+ @latest_version = response.body.to_s
81
87
  else
82
88
  Interaction.fail("Could not download the chromedriver v#{chrome_version}.")
83
89
  end
@@ -7,11 +7,11 @@ installed Chrome.
7
7
 
8
8
  Setting `auto_update_chromedriver` to `true` in your global Geordi config file
9
9
  (`~/.config/geordi/global.yml`), will automatically update chromedriver before
10
- cucumber tests, in case Chrome and chromedriver versions don't match
10
+ cucumber tests if a newer chromedriver version is available.
11
11
  LONGDESC
12
12
 
13
13
  option :quiet_if_matching, type: :boolean, default: false,
14
- desc: 'Suppress notification if chromedriver and chrome versions match'
14
+ desc: 'Suppress notification if chromedriver is already on the latest version'
15
15
 
16
16
  def chromedriver_update
17
17
  require 'geordi/chromedriver_updater'
@@ -12,16 +12,20 @@ specified target's database and downloads it to `tmp/`.
12
12
  option) sources the dump into the development database after downloading it.
13
13
 
14
14
  If you are using multiple databases per environment, Geordi defaults to the
15
- "primary" database, or the first entry in database.yml. To dump a specific
15
+ "primary" database, or the first entry in database.yml. To target a specific
16
16
  database, pass the database name like this:
17
-
18
- geordi dump -d primary
19
-
20
- Loading a dump into one of multiple local databases is not supported yet.
17
+ ```
18
+ geordi dump -d primary
19
+ ```
20
+
21
+ When used with the blank `load` option ("dump and source"), the `database` option
22
+ will be respected both for the remote *and* the local database. If these should
23
+ not match, please issue separate commands for dumping (`dump -d`) and sourcing
24
+ (`dump -l -d`).
21
25
  DESC
22
26
 
23
27
  option :load, aliases: '-l', type: :string, desc: 'Load a dump', banner: '[DUMP_FILE]'
24
- option :database, aliases: '-d', type: :string, desc: 'Database name, if there are multiple databases', banner: 'NAME'
28
+ option :database, aliases: '-d', type: :string, desc: 'Target database, if there are multiple databases', banner: 'NAME'
25
29
 
26
30
  def dump(target = nil, *_args)
27
31
  require 'geordi/dump_loader'
@@ -33,7 +37,7 @@ def dump(target = nil, *_args)
33
37
  Interaction.fail 'Missing a dump file.' if options.load == 'load'
34
38
  File.exist?(options.load) || raise('Could not find the given dump file: ' + options.load)
35
39
 
36
- loader = DumpLoader.new(options.load)
40
+ loader = DumpLoader.new(options.load, options.database)
37
41
 
38
42
  Interaction.announce "Sourcing dump into the #{loader.config['database']} db"
39
43
  loader.load
@@ -53,7 +57,7 @@ def dump(target = nil, *_args)
53
57
  dump_path = Geordi::Remote.new(target).dump(options)
54
58
 
55
59
  if options.load # … and dump loading
56
- loader = DumpLoader.new(dump_path)
60
+ loader = DumpLoader.new(dump_path, options.database)
57
61
 
58
62
  Interaction.announce "Sourcing dump into the #{loader.config['database']} db"
59
63
  loader.load
@@ -6,24 +6,45 @@ require 'geordi/util'
6
6
  module Geordi
7
7
  class DumpLoader
8
8
 
9
- def initialize(file)
9
+ def initialize(file, database)
10
10
  @dump_file = file
11
+ @database = database
11
12
  end
12
13
 
13
14
  def development_database_config
15
+ return @config if @config
16
+
14
17
  require 'yaml'
15
18
 
16
19
  evaluated_config_file = ERB.new(File.read('config/database.yml')).result
17
20
 
18
21
  # Allow aliases and a special set of classes like symbols and time objects
19
22
  permitted_classes = [Symbol, Time]
20
- @config ||= if Gem::Version.new(Psych::VERSION) >= Gem::Version.new('3.1.0')
23
+ database_config = if Gem::Version.new(Psych::VERSION) >= Gem::Version.new('3.1.0')
21
24
  YAML.safe_load(evaluated_config_file, permitted_classes: permitted_classes, aliases: true)
22
25
  else
23
26
  YAML.safe_load(evaluated_config_file, permitted_classes, [], true)
24
27
  end
25
28
 
26
- @config['development']
29
+ development_config = database_config['development']
30
+
31
+ if development_config.values[0].is_a? Hash # Multi-db setup
32
+ @config = if @database
33
+ development_config[@database] || Interaction.fail(%(Unknown development database "#{@database}".))
34
+ elsif development_config.has_key? 'primary'
35
+ development_config['primary']
36
+ else
37
+ development_config.values[0]
38
+ end
39
+ else # Single-db setup
40
+ if @database
41
+ Interaction.fail %(Could not select "#{@database}" database in a single-db setup.)
42
+ else
43
+ @config = development_config
44
+ end
45
+ end
46
+
47
+ @config
27
48
  end
28
49
  alias_method :config, :development_database_config
29
50
 
@@ -61,9 +82,12 @@ module Geordi
61
82
  end
62
83
 
63
84
  def load
85
+ adapter_command = "#{config['adapter']}_command"
86
+ Interaction.fail "Unknown database adapter #{config['adapter'].inspect} in config/database.yml." unless respond_to? adapter_command
87
+
64
88
  Interaction.note 'Source file: ' + dump_file
65
89
 
66
- source_command = send("#{config['adapter']}_command")
90
+ source_command = send(adapter_command)
67
91
  Util.run! source_command, fail_message: "An error occurred loading #{File.basename(dump_file)}"
68
92
  end
69
93
 
@@ -1,3 +1,3 @@
1
1
  module Geordi
2
- VERSION = '9.1.0'.freeze
2
+ VERSION = '9.3.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.1.0
4
+ version: 9.3.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: 2022-02-14 00:00:00.000000000 Z
11
+ date: 2022-06-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -116,7 +116,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
116
116
  - !ruby/object:Gem::Version
117
117
  version: '0'
118
118
  requirements: []
119
- rubygems_version: 3.0.3
119
+ rubygems_version: 3.2.3
120
120
  signing_key:
121
121
  specification_version: 4
122
122
  summary: Collection of command line tools we use in our daily work with Ruby, Rails