geordi 9.2.0 → 9.3.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: 702407b6104865ae130f2c2793aa673f3c6f847d3652689a76e6d04c59a828e6
4
- data.tar.gz: 4718d6e956efa941c25452f382761dcb3727db98364cfd0847c4edb0b947a608
3
+ metadata.gz: e93051812acfd619f8d5a2db9c2641bb1ff19cf28835096cec1a2f6fd1487620
4
+ data.tar.gz: 4bc007b0985800b275de9dd0676cf0cbdf51a57800a4a426c0878738b9b00f43
5
5
  SHA512:
6
- metadata.gz: b43e0bf03b775a47bfbfee4ebd87aaa615cdd1d13b9f85d0952fabb23f2591d3d736cb6ef852695bdec56d562cabd18e87abd37a8f204ca5ce9af74575c4b5bb
7
- data.tar.gz: 4a8963f968e73e040a9486337881f52549563d019abf0601589cfaf64af28d950b921e990bd196d060c78212c5a1b7893d6f2d1fc3641c51697f18698406060c
6
+ metadata.gz: 07105d522e4ed9c4412e95f0e8bd5dfbfbd4c8ea7bb7a58f7f347473eafb5807f7ceeaf82dc18f80dd85c77699970342f91396eec35f4a113a5aad8e0b73dc6d
7
+ data.tar.gz: 7bb8747a1352e983c3c3cecc848ae2097a01341e8c1bd0d1b32537e0470085d43cec4a639dbdc36eaacdd8fad5f4bce981032c8d06efe11c8ab0951afe4bbaec
data/CHANGELOG.md CHANGED
@@ -10,13 +10,17 @@ This project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html
10
10
  ### Breaking changes
11
11
 
12
12
 
13
+ ## 9.3.0 2022-04-26
14
+
15
+ ### Compatible changes
16
+ * Add dump loading in multi-database-setups.
17
+
18
+
13
19
  ## 9.2.0 2022-02-18
14
20
 
15
21
  ### Compatible changes
16
22
  * 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.
17
23
 
18
- ### Breaking changes
19
-
20
24
 
21
25
  ## 9.1.0 2022-02-14
22
26
 
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- geordi (9.2.0)
4
+ geordi (9.3.0)
5
5
  thor (~> 1)
6
6
 
7
7
  GEM
data/README.md CHANGED
@@ -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]`
@@ -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.2.0'.freeze
2
+ VERSION = '9.3.0'.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.2.0
4
+ version: 9.3.0
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-18 00:00:00.000000000 Z
11
+ date: 2022-04-26 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.2.26
119
+ rubygems_version: 3.2.30
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