geordi 2.9.0 → 2.12.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: d129fad452aa0ec9658552b68ceb58190d3fb93b722ca8913ad00a68784ce3dc
4
- data.tar.gz: 45905a2d5413c9cf5828b2a106f2bf32946efc6ab1229cfd9ed3012fa58a7cc0
3
+ metadata.gz: '080677a5fee73a4a5ddc02c2f68b5927ec66cb95b328ccbac62abf6aa26d0e19'
4
+ data.tar.gz: 78da560700b6bd7e72424fa1d7f5df556e88d2b80e834aaf7582f6012e31d94c
5
5
  SHA512:
6
- metadata.gz: e91aa9acdb965944b192c23d2a43bebc49d25933b7152f56b99a3175311f4e84a7c0460961bb076b16a4cdfde648e19dc8ac072db35fd4414a3ecbdefb806b7a
7
- data.tar.gz: b00fb2431da652f0cadd628bffb601c19434ba0fdd53d9ac99d463d7c6c2e365199efa271a90ada917e4d54e941c024a9f4dd990b7bc1bd4a24f4ffef87b55b0
6
+ metadata.gz: 10384fad288da0e83e9add107b9b46dcfb83c9f06c777389975127a10d98e94829ffd9414b1607246a31fbfc201d5f732934072ad93e95bb07f28eeac174388e
7
+ data.tar.gz: d76fae6a3b79ebf391aa51df3b9348c263e5903afb1dd89b53f99e2893469bac285b5a5f438d5d120cfa60f5938b22d84e882f7b2dd1aa0f6d966e3b82af8f4c
data/.gitignore CHANGED
@@ -5,3 +5,4 @@ pkg/*
5
5
  .DS_Store
6
6
  .pt_project_id
7
7
  tmp
8
+ .byebug_history
@@ -5,16 +5,42 @@ This project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html
5
5
 
6
6
 
7
7
  ## Unreleased
8
+
9
+ ### Compatible changes
10
+
11
+ ### Breaking changes
12
+
13
+
14
+ ## 2.11.0 2020-05-04
15
+
8
16
  ### Compatible changes
17
+ - Added the possibility to change the Rails root for the capistrano config via the environment variable `RAILS_ROOT`. This allows you as a gem developer to run a command like `RAILS_ROOT=~/Projects/my-blog geordi console staging` whereas `geordi` uses the capistrano config from `my-blog`. Otherwise you would need to follow the instructions of [this card](https://makandracards.com/makandra/46617-how-to-use-a-local-gem-in-your-gemfile) to test changes in the gem locally.
18
+ - Bug fix for "no staged changes" even if there are changes present (#83).
19
+ - Fixed deprecation warning for `Thor exit with status 0 on errors` (#84).
20
+ - Replaced `Bundler.with_unbundled_env` with `Bundler.with_original_env` (#77). This is a better replacement than 42cd1c4.
21
+ - Add deprecation warning `Deprecation warning: Ruby 1.8.7 and 1.9.3 support will be dropped in Geordi 3.x.` to Geordi 2.
22
+ - Fix error `thor requires Ruby version >= 2.0.0` for Ruby 1.8.7 and 1.9.3 (https://github.com/makandra/geordi/issues/79#issuecomment-598664191).
23
+
9
24
  ### Breaking changes
10
25
 
11
26
 
27
+ ## 2.10.1 2020-02-17
28
+
29
+ ### Compatible changes
30
+ - Add host parameter to mysql dump loader
31
+
32
+ ## 2.10.0 2020-02-11
33
+
34
+ ### Compatible changes
35
+ - Fixes [#78](https://github.com/makandra/geordi/pull/78): Add compatibility for more than 9 CPU cores in
36
+ `geordi drop-databases`.
37
+
38
+
12
39
  ## 2.9.0 2020-01-03
13
40
 
14
41
  ### Compatible changes
15
42
  - Fixes [#37](https://github.com/makandra/geordi/issues/37): `geordi cucumber` crashes with `--format=pretty`
16
43
  - Fixes [#27](https://github.com/makandra/geordi/issues/27): Cucumber rerun switch does work when passing files
17
- ### Breaking changes
18
44
 
19
45
 
20
46
  ## 2.8.0 2020-01-02
data/Gemfile CHANGED
@@ -4,6 +4,7 @@ source 'http://rubygems.org'
4
4
  gemspec
5
5
 
6
6
  gem 'aruba'
7
+ gem 'contracts', '=0.9'
7
8
  gem 'rspec-mocks'
8
9
  gem 'highline'
9
10
  gem 'parallel_tests'
@@ -1,66 +1,40 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- geordi (2.9.0)
5
- thor (>= 0.18.0)
4
+ geordi (2.12.1)
5
+ thor (~> 0.18.0)
6
6
 
7
7
  GEM
8
8
  remote: http://rubygems.org/
9
9
  specs:
10
10
  addressable (2.3.8)
11
- aruba (0.6.2)
12
- childprocess (>= 0.3.6)
13
- cucumber (>= 1.1.1)
14
- rspec-expectations (>= 2.7.0)
15
- axiom-types (0.1.1)
16
- descendants_tracker (~> 0.0.4)
17
- ice_nine (~> 0.11.0)
18
- thread_safe (~> 0.3, >= 0.3.1)
19
- builder (3.2.3)
20
- childprocess (1.0.1)
21
- rake (< 13.0)
22
- coderay (1.1.2)
23
- coercible (1.0.0)
24
- descendants_tracker (~> 0.0.1)
11
+ aruba (0.8.1)
12
+ childprocess (~> 0.5.6)
13
+ contracts (~> 0.9)
14
+ cucumber (>= 1.3.19)
15
+ rspec-expectations (>= 2.99)
16
+ builder (3.2.4)
17
+ childprocess (0.5.9)
18
+ ffi (~> 1.0, >= 1.0.11)
19
+ contracts (0.9)
25
20
  cucumber (1.3.20)
26
21
  builder (>= 2.1.2)
27
22
  diff-lcs (>= 1.1.3)
28
23
  gherkin (~> 2.12)
29
24
  multi_json (>= 1.7.5, < 2.0)
30
25
  multi_test (>= 0.1.2)
31
- declarative (0.0.10)
32
- declarative-option (0.1.0)
33
- descendants_tracker (0.0.4)
34
- thread_safe (~> 0.3, >= 0.3.1)
35
26
  diff-lcs (1.2.5)
36
- equalizer (0.0.11)
37
- excon (0.67.0)
38
- faraday (0.17.0)
39
- multipart-post (>= 1.2, < 3)
40
- faraday_middleware (0.13.1)
41
- faraday (>= 0.7.4, < 1.0)
27
+ ffi (1.9.18)
42
28
  gherkin (2.12.2)
43
29
  multi_json (~> 1.3)
44
30
  highline (1.6.21)
45
- ice_nine (0.11.2)
46
31
  launchy (2.4.3)
47
32
  addressable (~> 2.3)
48
- method_source (0.9.2)
49
- mimemagic (0.3.3)
50
- multi_json (1.13.1)
33
+ multi_json (1.15.0)
51
34
  multi_test (0.1.2)
52
- multipart-post (2.1.1)
53
35
  parallel (0.5.16)
54
36
  parallel_tests (0.6.18)
55
37
  parallel
56
- pry (0.12.2)
57
- coderay (~> 1.1.0)
58
- method_source (~> 0.9.0)
59
- rake (10.5.0)
60
- representable (3.0.4)
61
- declarative (< 0.1.0)
62
- declarative-option (< 0.2.0)
63
- uber (< 0.2.0)
64
38
  rspec-expectations (3.4.0)
65
39
  diff-lcs (>= 1.2.0, < 2.0)
66
40
  rspec-support (~> 3.4.0)
@@ -68,37 +42,19 @@ GEM
68
42
  diff-lcs (>= 1.2.0, < 2.0)
69
43
  rspec-support (~> 3.4.0)
70
44
  rspec-support (3.4.1)
71
- thor (0.20.3)
72
- thread_safe (0.3.6)
73
- tracker_api (1.10.0)
74
- addressable
75
- equalizer
76
- excon
77
- faraday
78
- faraday_middleware
79
- mimemagic
80
- multi_json
81
- representable
82
- virtus
83
- uber (0.1.0)
84
- virtus (1.0.5)
85
- axiom-types (~> 0.1)
86
- coercible (~> 1.0)
87
- descendants_tracker (~> 0.0, >= 0.0.3)
88
- equalizer (~> 0.0, >= 0.0.9)
45
+ thor (0.18.1)
89
46
 
90
47
  PLATFORMS
91
48
  ruby
92
49
 
93
50
  DEPENDENCIES
94
51
  aruba
52
+ contracts (= 0.9)
95
53
  geordi!
96
54
  highline
97
55
  launchy
98
56
  parallel_tests
99
- pry
100
57
  rspec-mocks
101
- tracker_api
102
58
 
103
59
  BUNDLED WITH
104
60
  1.17.3
data/README.md CHANGED
@@ -54,6 +54,11 @@ Commit using a story title from Pivotal Tracker.
54
54
 
55
55
  Example: `geordi commit`
56
56
 
57
+ Any extra arguments are forwarded to `git commit -m <message>`.
58
+
59
+ If there are no staged changes, prints a warning but will continue to create
60
+ an empty commit.
61
+
57
62
  On the first execution we ask for your Pivotal Tracker API token. It will be
58
63
  stored in `~/.gitpt`.
59
64
 
@@ -135,6 +140,23 @@ instead of `cap deploy:migrations`. You can force using `deploy` by passing the
135
140
  -M option: `geordi deploy -M staging`.
136
141
 
137
142
 
143
+ ### `geordi docker`
144
+
145
+ Manage docker containers for the current project.
146
+
147
+ Manage docker containers to run your project dockerized.
148
+
149
+ It expects a docker-compose file that specifies all services, and a service
150
+ named "main" that opens a shell for the project.
151
+
152
+ There are two subcommands:
153
+
154
+ - geordi docker setup
155
+ Builds all docker containers.
156
+ - geordi docker shell
157
+ Runs the docker service named 'main'.
158
+
159
+
138
160
  ### `geordi drop-databases`
139
161
 
140
162
  Interactively delete local databases.
@@ -385,6 +407,9 @@ calling your local geordi like so (adjust paths to your needs):
385
407
 
386
408
  # @option -I: add directory to load path
387
409
  ruby -I ../geordi/lib ../geordi/bin/geordi <command>
410
+
411
+ # with debugger
412
+ ruby -r byebug -I ../geordi/lib ../geordi/bin/geordi <command>
388
413
 
389
414
  Don't forget to update this README. The whole `geordi` section is auto-generated
390
415
  by `rake readme`. Also remember to add your changes to the CHANGELOG.
data/bin/geordi CHANGED
@@ -1,5 +1,7 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
+ $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
4
+
3
5
  require 'geordi/util'
4
6
 
5
7
  Geordi::Util.installing_missing_gems do
@@ -0,0 +1,62 @@
1
+ @same-process
2
+ Feature: The docker command
3
+
4
+ Scenario: Setup checks for existence of docker
5
+ Given the docker command cannot find the "docker" binary
6
+ When I run `geordi docker setup`
7
+ Then the output should contain "which docker"
8
+ And the output should contain "x You need to install docker first"
9
+
10
+
11
+ Scenario: Setup checks for existence of docker-compose
12
+ Given the docker command cannot find the "docker-compose" binary
13
+ When I run `geordi docker setup`
14
+ Then the output should contain "which docker-compose"
15
+ And the output should contain "x You need to install docker-compose first"
16
+
17
+
18
+ Scenario: Setup checks for existence of docker-compose.yml
19
+ When I run `geordi docker setup`
20
+ Then the output should contain "x Your project does not seem to be properly set up."
21
+
22
+
23
+ Scenario: Setup checks for service named "main"
24
+ Given a file named "docker-compose.yml" with:
25
+ """
26
+ foo: bar
27
+ """
28
+
29
+ When I run `geordi docker setup`
30
+ Then the output should contain "x Your project does not seem to be properly set up."
31
+
32
+
33
+ Scenario: Setup runs docker-compose pull
34
+ Given a file named "docker-compose.yml" with:
35
+ """
36
+ services:
37
+ main: foo
38
+ """
39
+
40
+ When I run `geordi docker setup`
41
+ Then the output should contain "docker-compose pull"
42
+
43
+
44
+ Scenario: Shell checks for existence of docker
45
+ Given the docker command cannot find the "docker" binary
46
+ When I run `geordi docker shell`
47
+ Then the output should contain "which docker"
48
+ And the output should contain "x You need to install docker first"
49
+
50
+
51
+ Scenario: Shell runs docker-compose run main
52
+ Given a file named "docker-compose.yml" with:
53
+ """
54
+ services:
55
+ main: foo
56
+ """
57
+ And I set the environment variables to:
58
+ | variable | value |
59
+ | SSH_AUTH_SOCK | /path/to/sock/ssh |
60
+
61
+ When I run `geordi docker shell`
62
+ Then the output should contain "docker-compose run --service-ports -v /path/to/sock:/path/to/sock -e SSH_AUTH_SOCK=/path/to/sock/ssh main"
@@ -0,0 +1,10 @@
1
+ Given(/the docker command cannot find the "(.*?)" binary/) do |command|
2
+ require 'geordi/docker'
3
+ expect_any_instance_of(Geordi::Docker).to receive(:mock_run).at_least(:once).and_wrap_original do |original, *args|
4
+ if args[0] =~ /which #{Regexp.escape(command)}/
5
+ false
6
+ else
7
+ original.call(*args)
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,60 @@
1
+ require 'aruba/cucumber'
2
+ require 'aruba/in_process'
3
+ require 'geordi/cli'
4
+
5
+ # https://github.com/erikhuda/thor/wiki/Integrating-with-Aruba-In-Process-Runs
6
+ class InProcessCliRunner
7
+
8
+ # Allow everything fun to be injected from the outside while defaulting to normal implementations.
9
+ def initialize(argv, stdin = STDIN, stdout = STDOUT, stderr = STDERR, kernel = Kernel)
10
+ @argv, @stdin, @stdout, @stderr, @kernel = argv, stdin, stdout, stderr, kernel
11
+ end
12
+
13
+ def execute!
14
+ exit_code = begin
15
+ # Thor accesses these streams directly rather than letting them be injected, so we replace them...
16
+ $stderr = @stderr
17
+ $stdin = @stdin
18
+ $stdout = @stdout
19
+
20
+ # Run our normal Thor app the way we know and love.
21
+ previous_program_name = $PROGRAM_NAME
22
+ $PROGRAM_NAME = 'geordi'
23
+ Geordi::CLI.start(@argv)
24
+
25
+ # Thor::Base#start does not have a return value, assume success if no exception is raised.
26
+ 0
27
+ rescue StandardError => e
28
+ # The ruby interpreter would pipe this to STDERR and exit 1 in the case of an unhandled exception
29
+ b = e.backtrace
30
+ @stderr.puts("#{b.shift}: #{e.message} (#{e.class})")
31
+ @stderr.puts(b.map{|s| "\tfrom #{s}"}.join("\n"))
32
+ 1
33
+ rescue SystemExit => e
34
+ e.status
35
+ ensure
36
+ # add additional cleanup code here
37
+
38
+ $stderr = STDERR
39
+ $stdin = STDIN
40
+ $stdout = STDOUT
41
+ $PROGRAM_NAME = previous_program_name
42
+ end
43
+
44
+ # Proxy our exit code back to the injected kernel.
45
+ @kernel.exit(exit_code)
46
+ end
47
+ end
48
+
49
+ Aruba.configure do |config|
50
+ config.main_class = InProcessCliRunner
51
+ config.command_launcher = :spawn
52
+ end
53
+
54
+ Before('@same-process') do
55
+ aruba.config.command_launcher = :in_process
56
+ end
57
+
58
+ Before do
59
+ @aruba_timeout_seconds = 5
60
+ end
@@ -1,4 +1,5 @@
1
- require 'aruba/cucumber'
1
+ require 'cucumber/rspec/doubles'
2
+
2
3
 
3
4
  if Gem::Version.new(RUBY_VERSION) > Gem::Version.new('1.8.7')
4
5
  require 'pry'
@@ -20,7 +20,7 @@ Gem::Specification.new do |s|
20
20
  s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
21
21
  s.require_paths = ["lib"]
22
22
 
23
- s.add_runtime_dependency 'thor', '>= 0.18.0'
23
+ s.add_runtime_dependency 'thor', '~> 0.18.0'
24
24
 
25
25
  s.post_install_message = <<-ATTENTION
26
26
  * Binary `geordi` installed
@@ -53,18 +53,21 @@ module Geordi
53
53
  end
54
54
 
55
55
  def find_project_root!
56
- current = Dir.pwd
57
- until File.exists?('Capfile')
58
- Dir.chdir '..'
59
- raise <<-ERROR if current == Dir.pwd
60
- Could not locate Capfile.
61
-
62
- Are you calling me from within a Rails project?
63
- Maybe Capistrano is not installed in this project.
64
- ERROR
65
-
66
- current = Dir.pwd
56
+ current = ENV['RAILS_ROOT'] || Dir.pwd
57
+
58
+ until File.exists?(File.join(current, 'Capfile'))
59
+ if current == '/' || current == '/home' || !File.directory?(current)
60
+ raise <<-ERROR
61
+ Could not locate Capfile.
62
+
63
+ Are you calling me from within a Rails project?
64
+ Maybe Capistrano is not installed in this project.
65
+ ERROR
66
+ else
67
+ current = File.dirname(current)
68
+ end
67
69
  end
70
+
68
71
  current
69
72
  end
70
73
 
@@ -5,8 +5,17 @@ require 'geordi/util'
5
5
 
6
6
  module Geordi
7
7
  class CLI < Thor
8
+
9
+ if Geordi::Util.ruby_version <= Gem::Version.new('2.0.0')
10
+ warn "Deprecation warning: Ruby 1.8.7 and 1.9.3 support will be dropped in Geordi 3.x."
11
+ end
12
+
8
13
  include Geordi::Interaction
9
14
 
15
+ def self.exit_on_failure?
16
+ true
17
+ end
18
+
10
19
  # load all tasks defined in lib/geordi/commands
11
20
  Dir[File.expand_path '../commands/*.rb', __FILE__].each do |file|
12
21
  class_eval File.read(file), file
@@ -0,0 +1,41 @@
1
+ class DockerCLI < Thor
2
+ desc 'setup', 'Setup docker and build required docker-container for the current project.'
3
+ def setup
4
+ docker.setup
5
+ end
6
+
7
+ desc 'shell', 'Open a shell in the main docker container for the current project.'
8
+ map 'shell' => '_shell'
9
+ def _shell
10
+ docker.shell
11
+ end
12
+
13
+ desc 'vnc', 'Open a vnc viewer connecting to the docker container.'
14
+ def vnc
15
+ docker.vnc
16
+ end
17
+
18
+ private
19
+
20
+ def docker
21
+ require 'geordi/docker'
22
+ Geordi::Docker.new
23
+ end
24
+ end
25
+
26
+ desc 'docker', 'Manage docker containers for the current project.'
27
+ long_desc <<-LONGDESC
28
+ Manage docker containers to run your project dockerized.
29
+
30
+ It expects a docker-compose file that specifies all services, and a service
31
+ named "main" that opens a shell for the project.
32
+
33
+ There are two subcommands:
34
+
35
+ - geordi docker setup
36
+ Builds all docker containers.
37
+ - geordi docker shell
38
+ Runs the docker service named 'main'.
39
+
40
+ LONGDESC
41
+ subcommand 'docker', DockerCLI
@@ -11,8 +11,9 @@ module Geordi
11
11
  include Geordi::Interaction
12
12
 
13
13
  VNC_DISPLAY = ':17'
14
- VNC_SERVER_COMMAND = "vncserver #{VNC_DISPLAY} -localhost -nolisten tcp -SecurityTypes None -geometry 1280x1024"
15
- VNC_VIEWER_COMMAND = "vncviewer #{VNC_DISPLAY}"
14
+ VNC_SERVER_DEFAULT_OPTIONS = '-localhost -nolisten tcp -SecurityTypes None -geometry 1280x1024'
15
+ VNC_SERVER_COMMAND = "vncserver #{VNC_DISPLAY} #{ENV.fetch('GEORDI_VNC_OPTIONS', VNC_SERVER_DEFAULT_OPTIONS)}"
16
+ VNC_VIEWER_COMMAND = "vncviewer"
16
17
  VNC_ENV_VARIABLES = %w[DISPLAY BROWSER LAUNCHY_BROWSER]
17
18
 
18
19
  def run(files, cucumber_options, options = {})
@@ -29,10 +30,10 @@ module Geordi
29
30
  system command # Util.system! would reset the Firefox PATH
30
31
  end
31
32
 
32
- def launch_vnc_viewer
33
+ def launch_vnc_viewer(source = VNC_DISPLAY)
33
34
  fork {
34
35
  error = capture_stderr do
35
- system(VNC_VIEWER_COMMAND)
36
+ system(VNC_VIEWER_COMMAND, source)
36
37
  end
37
38
  unless $?.success?
38
39
  if $?.exitstatus == 127
@@ -12,7 +12,7 @@ module Geordi
12
12
  puts ' and `sudo mysql` for MariaDB (which uses PAM auth)'
13
13
  `sudo true`
14
14
  fail 'sudo access is required for database operations as database users' if $? != 0
15
- @derivative_dbname = /_(test\d?|development|cucumber)$/
15
+ @derivative_dbname = /_(test\d*|development|cucumber)$/
16
16
  base_directory = ENV['XDG_CONFIG_HOME']
17
17
  base_directory = "#{Dir.home}" if base_directory.nil?
18
18
  @whitelist_directory = File.join(base_directory, '.config', 'geordi', 'whitelists')
@@ -34,7 +34,7 @@ module Geordi
34
34
  tmp.write <<-HEREDOC
35
35
  # Put each whitelisted database on a new line.
36
36
  # System databases will never be deleted.
37
- # When you whitelist foo, foo_development and foo_test\\d? are whitelisted, too.
37
+ # When you whitelist foo, foo_development and foo_test\\d* are whitelisted, too.
38
38
  # This works even if foo does not exist. Also, you will only see foo in this list.
39
39
  #
40
40
  # Syntax: keep foo
@@ -253,7 +253,7 @@ HEREDOC
253
253
  # Allow explicit whitelisting of derivative databases like projectname_test2
254
254
  if whitelist_content.include? database_name
255
255
  true
256
- # whitelisting `projectname` also whitelists `projectname_test\d+`, `projectname_development`
256
+ # whitelisting `projectname` also whitelists `projectname_test\d*`, `projectname_development`
257
257
  elsif whitelist_content.include? database_name.sub(@derivative_dbname, '')
258
258
  true
259
259
  else
@@ -0,0 +1,88 @@
1
+ require 'geordi/interaction'
2
+ require 'geordi/cucumber'
3
+ require 'yaml'
4
+
5
+ module Geordi
6
+ class Docker
7
+ DOCKER_COMPOSE_FILE = 'docker-compose.yml'.freeze
8
+
9
+ include Interaction
10
+
11
+ def setup
12
+ check_installation_and_config
13
+ announce('Building containers...')
14
+ if execute(:system, 'docker-compose', 'pull')
15
+ success('Build successful.')
16
+ else
17
+ fail('Build failed.')
18
+ end
19
+ end
20
+
21
+ def shell
22
+ check_installation_and_config
23
+ command = [:exec, 'docker-compose', 'run', '--service-ports']
24
+ command += ssh_agent_forward
25
+ command += ['main']
26
+ execute(*command)
27
+ end
28
+
29
+ def vnc
30
+ Cucumber.new.launch_vnc_viewer('::5967')
31
+ end
32
+
33
+ private
34
+
35
+ def execute(kind, *args)
36
+ if ENV['GEORDI_TESTING']
37
+ puts "Stubbed run #{args.join(' ')}"
38
+ mock_run(*args)
39
+ else
40
+ send(kind, *args)
41
+ end
42
+ end
43
+
44
+ def mock_run(*args)
45
+ # exists just to be stubbed in tests
46
+ true
47
+ end
48
+
49
+ def check_installation_and_config
50
+ unless command_exists?('docker')
51
+ fail('You need to install docker first with `sudo apt install docker`. After installation please log out and back in to your system once.')
52
+ end
53
+
54
+ unless command_exists?('docker-compose')
55
+ fail('You need to install docker-compose first with `sudo apt install docker-compose`.')
56
+ end
57
+
58
+ unless docker_compose_config && (services = docker_compose_config['services']) && services.key?('main')
59
+ fail('Your project does not seem to be properly set up. Expected to find a docker-compose.yml which defines a service named "main".')
60
+ end
61
+ end
62
+
63
+ def command_exists?(command)
64
+ execute(:system, "which #{command} > /dev/null")
65
+ end
66
+
67
+ def docker_compose_config
68
+ if File.exists?(DOCKER_COMPOSE_FILE)
69
+ if YAML.respond_to?(:safe_load)
70
+ YAML.safe_load(File.read(DOCKER_COMPOSE_FILE))
71
+ else
72
+ YAML.load(File.read(DOCKER_COMPOSE_FILE))
73
+ end
74
+ end
75
+ rescue
76
+ false
77
+ end
78
+
79
+ def ssh_agent_forward
80
+ if (auth_sock = ENV['SSH_AUTH_SOCK'])
81
+ dirname = File.dirname(auth_sock)
82
+ ['-v', "#{dirname}:#{dirname}", '-e', "SSH_AUTH_SOCK=#{auth_sock}"]
83
+ else
84
+ []
85
+ end
86
+ end
87
+ end
88
+ end
@@ -18,12 +18,13 @@ module Geordi
18
18
  @config['development']
19
19
  end
20
20
  alias_method :config, :development_database_config
21
-
21
+
22
22
  def mysql_command
23
23
  command = 'mysql --silent'
24
24
  command << ' -p' << config['password'].to_s if config['password']
25
25
  command << ' -u' << config['username'].to_s if config['username']
26
26
  command << ' --port=' << config['port'].to_s if config['port']
27
+ command << ' --host=' << config['host'].to_s if config['host']
27
28
  command << ' --default-character-set=utf8'
28
29
  command << ' ' << config['database'].to_s
29
30
  command << ' < ' << dump_file
@@ -51,8 +51,8 @@ module Geordi
51
51
  # Remove Geordi's Bundler environment when running commands.
52
52
  success = if !defined?(Bundler)
53
53
  system(*commands)
54
- elsif Gem::Version.new(Bundler::VERSION) >= Gem::Version.new('2.1.2')
55
- Bundler.with_unbundled_env do
54
+ elsif Gem::Version.new(Bundler::VERSION) >= Gem::Version.new('1.17.3')
55
+ Bundler.with_original_env do
56
56
  system(*commands)
57
57
  end
58
58
  else
@@ -94,7 +94,7 @@ module Geordi
94
94
  ENV['GEORDI_TESTING_STAGED_CHANGES'] == 'true'
95
95
  else
96
96
  statuses = `git status --porcelain`.split("\n")
97
- statuses.any? { |l| l.start_with? 'A' }
97
+ statuses.any? { |l| l.start_with? /[A-Z]/i }
98
98
  end
99
99
  end
100
100
 
@@ -161,6 +161,10 @@ module Geordi
161
161
  nil
162
162
  end
163
163
 
164
+ def ruby_version
165
+ Gem::Version.new(RUBY_VERSION)
166
+ end
167
+
164
168
  def file_containing?(file, regex)
165
169
  File.exists?(file) and File.read(file).scan(regex).any?
166
170
  end
@@ -1,3 +1,3 @@
1
1
  module Geordi
2
- VERSION = '2.9.0'
2
+ VERSION = '2.12.1'
3
3
  end
metadata CHANGED
@@ -1,27 +1,27 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: geordi
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.9.0
4
+ version: 2.12.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Henning Koch
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-01-03 00:00:00.000000000 Z
11
+ date: 2020-12-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ">="
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
19
  version: 0.18.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ">="
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: 0.18.0
27
27
  description: Collection of command line tools we use in our daily work with Ruby,
@@ -81,14 +81,17 @@ files:
81
81
  - features/console.feature
82
82
  - features/cucumber.feature
83
83
  - features/deploy.feature
84
+ - features/docker.feature
84
85
  - features/dump.feature
85
86
  - features/firefox.feature
86
87
  - features/server.feature
87
88
  - features/setup.feature
88
89
  - features/shell.feature
90
+ - features/step_definitions/docker_command_steps.rb
91
+ - features/step_definitions/miscellaneous_steps.rb
92
+ - features/support/aruba.rb
89
93
  - features/support/env.rb
90
94
  - features/support/step_definitions/aruba_backport_steps.rb
91
- - features/support/step_definitions/miscellaneous_steps.rb
92
95
  - geordi.gemspec
93
96
  - lib/geordi.rb
94
97
  - lib/geordi/COMMAND_TEMPLATE
@@ -108,6 +111,7 @@ files:
108
111
  - lib/geordi/commands/cucumber.rb
109
112
  - lib/geordi/commands/delete_dumps.rb
110
113
  - lib/geordi/commands/deploy.rb
114
+ - lib/geordi/commands/docker.rb
111
115
  - lib/geordi/commands/drop_databases.rb
112
116
  - lib/geordi/commands/dump.rb
113
117
  - lib/geordi/commands/eurest.rb
@@ -130,6 +134,7 @@ files:
130
134
  - lib/geordi/commands/yarn_install.rb
131
135
  - lib/geordi/cucumber.rb
132
136
  - lib/geordi/db_cleaner.rb
137
+ - lib/geordi/docker.rb
133
138
  - lib/geordi/dump_loader.rb
134
139
  - lib/geordi/firefox_for_selenium.rb
135
140
  - lib/geordi/gitpt.rb