geordi 3.1.0 → 3.2.0

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: 3f2ea989e784592d99136278e2e7aeca1329d56460590dd0de0c713839d007f4
4
- data.tar.gz: c3c001d594fa572a4c562cb91c8796ca1f1170fbfb0168be4f5ec2efaac87556
3
+ metadata.gz: e775f88b224275cf01077937ba959b27666c1ae7ac18b58548a62bfa31161a12
4
+ data.tar.gz: 4e0efdb89bbf65b69a9753e8e05978b094915b613b1ded6ef1c1ea4716be0ea7
5
5
  SHA512:
6
- metadata.gz: c516cd2e6716be0c8e487b5aea0ff741e8d4f99660ee1f9bc2c2277abe275f5b07a31ecd79392cb94c3b804c6357391077d27acd36d8511a1b9dd510baa88e49
7
- data.tar.gz: be170bc924f84b7ea056a394348cef9aa24b4b89c2696ef4a400713ca03dad509e446c048217a5626390a459eafaaa52b63212d5990f6898b644acc120fb28c3
6
+ metadata.gz: 56146e32a18966efbe63a58074d158b888410cf19520150d175f3220be709820b7b05ed6f95df5f80993ed163ba9b59232f1d1f67c3bd43d2055e9b2d66cd812
7
+ data.tar.gz: e8e41bb61713a5f32dd4039cadee5b11a9f08bac20cad738e61975ea741bfd76cdf5e2d64a166579e701eda472f95f4f8ce15da27181fa0a8b11b748f5d222d3
data/.gitignore CHANGED
@@ -3,6 +3,5 @@
3
3
  .idea
4
4
  pkg/*
5
5
  .DS_Store
6
- .pt_project_id
7
6
  tmp
8
7
  .byebug_history
@@ -1,4 +1,5 @@
1
1
  # Changelog
2
+
2
3
  All notable changes to this project will be documented in this file.
3
4
 
4
5
  This project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
@@ -7,33 +8,36 @@ This project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html
7
8
  ## Unreleased
8
9
 
9
10
  ### Compatible changes
10
-
11
11
  ### Breaking changes
12
12
 
13
13
 
14
- ## 3.1.0 2020-06-03
14
+ ## 3.2.0 2020-07-15
15
15
 
16
16
  ### Compatible changes
17
+ - Improvement #43: `--select-server` option on `geordi shell` and `geordi console` can take the number of the server to connect to it directly and to skip the menu.
18
+ - Add a `.geordi.yml` file to change multiple settings in the project and `~/.config/geordi/global.yml` for global settings.
19
+ - Deprecated the `.pt_project_id` file in favor of `.geordi.yml`.
20
+ - Deprecated the `~/.gitpt` file in favor of `~/.config/geordi/global.yml`.
21
+ - Add #91: Now there is an option to start cucumber without a VNC session. This is configured by the .geordi.yml file.
22
+ - Fixed `git#staged_changes?` detection on Ruby < 2.5.
17
23
 
18
- - Update security-update for improved workflow (#89): Deploy staging first and ask user, if application is still running. Then deploy other stages.
19
24
 
20
- ### Breaking changes
25
+ ## 3.1.0 2020-06-03
26
+
27
+ ### Compatible changes
28
+ - Update security-update for improved workflow (#89): Deploy staging first and ask user, if application is still running. Then deploy other stages.
21
29
 
22
30
 
23
31
  ## 3.0.3 2020-05-27
24
32
 
25
33
  ### Compatible changes
26
-
27
34
  - Fix #98: Changing the `config/database.yml` reader from `YAML.load` to `YAML.safe_load` dropped the support for aliases. We now allow aliases and the classes `Time` and `Symbol`. If we encounter further issues with this approach a revert to `YAML.load` would be an option, too.
28
35
 
29
36
 
30
37
  ## 3.0.2 2020-05-18
31
38
 
32
39
  ### Compatible changes
33
-
34
- - Fix #95: Method change from `! *.include?` to `*.exclude?` was not valid as we do not have active support in Geordi. Affected commands where `geordi cucumber` and `geordi deploy`.
35
-
36
- ### Breaking changes
40
+ - Fix #95: Method change from `! *.include?` to `*.exclude?` was not valid as we do not have active support in Geordi. Affected commands were `geordi cucumber` and `geordi deploy`.
37
41
 
38
42
 
39
43
  ## 3.0.1 2020-05-13
@@ -45,8 +49,6 @@ This project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html
45
49
 
46
50
  ## 3.0.0 2020-05-04
47
51
 
48
- ### Compatible changes
49
-
50
52
  ### Breaking changes
51
53
  - Remove support for Ruby 1.8.7 and Ruby 1.9.3. Bug fixes might still be backported to 2.x, but we will not add any features to 2.x anymore. Please consider to upgrade the Ruby version of your project.
52
54
 
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- geordi (3.1.0)
4
+ geordi (3.2.0)
5
5
  thor (~> 1)
6
6
 
7
7
  GEM
data/README.md CHANGED
@@ -60,7 +60,7 @@ If there are no staged changes, prints a warning but will continue to create
60
60
  an empty commit.
61
61
 
62
62
  On the first execution we ask for your Pivotal Tracker API token. It will be
63
- stored in `~/.gitpt`.
63
+ stored in `~/.config/geordi/global.yml`.
64
64
 
65
65
 
66
66
  ### `geordi console [TARGET]`
@@ -71,6 +71,14 @@ Open a local Rails console: `geordi console`
71
71
 
72
72
  Open a Rails console on `staging`: `geordi console staging`
73
73
 
74
+ Lets you select the server to connect to from a menu when called with `--select-server` or the alias `-s`:
75
+
76
+ geordi console staging -s
77
+
78
+ If you already know the number of the server you want to connect to, just pass it along:
79
+
80
+ geordi console staging -s2
81
+
74
82
 
75
83
  ### `geordi cucumber [FILES and OPTIONS]`
76
84
 
@@ -92,6 +100,12 @@ or `-d`.
92
100
  - *Options:* Any unknown option will be passed through to Cucumber,
93
101
  e.g. `--format pretty`.
94
102
 
103
+ - *VNC:* By default, test browsers will run in a VNC session. When using a
104
+ headless test browser anyway, you can disable VNC by putting the following
105
+ config into `.geordi.yml` in the project root:
106
+
107
+ use_vnc: false
108
+
95
109
 
96
110
  ### `geordi delete-dumps [DIRECTORY]`
97
111
 
@@ -320,10 +334,14 @@ Open a shell on a Capistrano deploy target.
320
334
 
321
335
  Example: `geordi shell production`
322
336
 
323
- Lets you select the server to connect to when called with `--select-server`:
337
+ Lets you select the server to connect to from a menu when called with `--select-server` or the alias `-s`:
324
338
 
325
339
  geordi shell production -s
326
340
 
341
+ If you already know the number of the server you want to connect to, just pass it along:
342
+
343
+ geordi shell production -s2
344
+
327
345
 
328
346
  ### `geordi tests`
329
347
 
@@ -9,7 +9,7 @@ If there are no staged changes, prints a warning but will continue to create
9
9
  an empty commit.
10
10
 
11
11
  On the first execution we ask for your Pivotal Tracker API token. It will be
12
- stored in `~/.gitpt`.
12
+ stored in `~/.config/geordi/global.yml`.
13
13
  LONGDESC
14
14
 
15
15
  def commit(*git_args)
@@ -3,10 +3,18 @@ long_desc <<-LONGDESC
3
3
  Open a local Rails console: `geordi console`
4
4
 
5
5
  Open a Rails console on `staging`: `geordi console staging`
6
+
7
+ Lets you select the server to connect to from a menu when called with `--select-server` or the alias `-s`:
8
+
9
+ geordi console staging -s
10
+
11
+ If you already know the number of the server you want to connect to, just pass it along:
12
+
13
+ geordi console staging -s2
6
14
  LONGDESC
7
15
 
8
16
 
9
- option :select_server, default: false, type: :boolean, aliases: '-s'
17
+ option :select_server, type: :string, aliases: '-s'
10
18
 
11
19
  def console(target = 'development', *_args)
12
20
  require 'geordi/remote'
@@ -15,6 +15,13 @@ or `-d`.
15
15
 
16
16
  - *Options:* Any unknown option will be passed through to Cucumber,
17
17
  e.g. `--format pretty`.
18
+
19
+ - *VNC:* By default, test browsers will run in a VNC session. When using a
20
+ headless test browser anyway, you can disable VNC by putting the following
21
+ config into `.geordi.yml` in the project root:
22
+
23
+ use_vnc: false
24
+
18
25
  LONGDESC
19
26
 
20
27
  option :modified, aliases: '-m', type: :boolean,
@@ -21,7 +21,6 @@ dump into the development database after downloading it.
21
21
  DESC
22
22
 
23
23
  option :load, aliases: ['-l'], type: :string, desc: 'Load a dump'
24
- option :select_server, default: false, type: :boolean, aliases: '-s'
25
24
 
26
25
  def dump(target = nil, *_args)
27
26
  require 'geordi/dump_loader'
@@ -2,12 +2,16 @@ desc 'shell TARGET', 'Open a shell on a Capistrano deploy target'
2
2
  long_desc <<-LONGDESC
3
3
  Example: `geordi shell production`
4
4
 
5
- Lets you select the server to connect to when called with `--select-server`:
5
+ Lets you select the server to connect to from a menu when called with `--select-server` or the alias `-s`:
6
6
 
7
7
  geordi shell production -s
8
+
9
+ If you already know the number of the server you want to connect to, just pass it along:
10
+
11
+ geordi shell production -s2
8
12
  LONGDESC
9
13
 
10
- option :select_server, default: false, type: :boolean, aliases: '-s'
14
+ option :select_server, type: :string, aliases: '-s'
11
15
 
12
16
  # This method has a triple 'l' because :shell is a Thor reserved word. However,
13
17
  # it can still be called with `geordi shell` :)
@@ -5,6 +5,7 @@ require 'tempfile'
5
5
  # version of Geordi.
6
6
  require File.expand_path('interaction', __dir__)
7
7
  require File.expand_path('firefox_for_selenium', __dir__)
8
+ require File.expand_path('settings', __dir__)
8
9
 
9
10
  module Geordi
10
11
  class Cucumber
@@ -16,10 +17,11 @@ module Geordi
16
17
 
17
18
  def run(files, cucumber_options, options = {})
18
19
  self.argv = files + cucumber_options.map { |option| option.split('=') }.flatten
20
+ self.settings = Geordi::Settings.new
19
21
 
20
22
  consolidate_rerun_txt_files
21
23
  show_features_to_run
22
- setup_vnc
24
+ setup_vnc if settings.use_vnc?
23
25
 
24
26
  command = use_parallel_tests?(options) ? parallel_execution_command : serial_execution_command
25
27
  Interaction.note_cmd(command) if options[:verbose]
@@ -65,7 +67,7 @@ module Geordi
65
67
 
66
68
  private
67
69
 
68
- attr_accessor :argv
70
+ attr_accessor :argv, :settings
69
71
 
70
72
  def serial_execution_command
71
73
  format_args = []
@@ -3,12 +3,14 @@ class Gitpt
3
3
  require 'highline'
4
4
  require 'tracker_api'
5
5
 
6
- SETTINGS_FILE_NAME = '.gitpt'.freeze
7
- PROJECT_IDS_FILE_NAME = '.pt_project_id'.freeze
6
+ # This require-style is to prevent Ruby from loading files of a different
7
+ # version of Geordi.
8
+ require File.expand_path('settings', __dir__)
8
9
 
9
10
  def initialize
10
11
  self.highline = HighLine.new
11
- self.client = build_client(read_settings)
12
+ self.settings = Geordi::Settings.new
13
+ self.client = build_client
12
14
  end
13
15
 
14
16
  def run(git_args)
@@ -24,57 +26,17 @@ No staged changes. Will create an empty commit.
24
26
 
25
27
  private
26
28
 
27
- attr_accessor :highline, :client
29
+ attr_accessor :highline, :client, :settings
28
30
 
29
- def read_settings
30
- file_path = File.join(ENV['HOME'], SETTINGS_FILE_NAME)
31
-
32
- unless File.exist?(file_path)
33
- highline.say HighLine::RESET
34
- highline.say "Welcome to #{bold 'gitpt'}.\n\n"
35
-
36
- highline.say highlight('Your settings are missing or invalid.')
37
- highline.say "Please configure your Pivotal Tracker access.\n\n"
38
- token = highline.ask bold('Your API key:') + ' '
39
- highline.say "\n"
40
-
41
- settings = { token: token }
42
- File.open(file_path, 'w') do |file|
43
- file.write settings.to_yaml
44
- end
45
- end
46
-
47
- YAML.load_file(file_path)
48
- end
49
-
50
- def build_client(settings)
51
- TrackerApi::Client.new(token: settings.fetch(:token))
31
+ def build_client
32
+ TrackerApi::Client.new(token: settings.pivotal_tracker_api_key)
52
33
  end
53
34
 
54
35
  def load_projects
55
- project_ids = read_project_ids
36
+ project_ids = settings.pivotal_tracker_project_ids
56
37
  project_ids.collect { |project_id| client.project(project_id) }
57
38
  end
58
39
 
59
- def read_project_ids
60
- file_path = PROJECT_IDS_FILE_NAME
61
-
62
- if File.exist?(file_path)
63
- project_ids = File.read('.pt_project_id').split(/[\s]+/).map(&:to_i)
64
- end
65
-
66
- if project_ids && (project_ids.size > 0)
67
- project_ids
68
- else
69
- Geordi::Interaction.warn "Sorry, I could not find a project ID in #{file_path} :("
70
- puts
71
-
72
- puts "Please put at least one Pivotal Tracker project id into #{file_path} in this directory."
73
- puts 'You may add multiple IDs, separated using white space.'
74
- exit 1
75
- end
76
- end
77
-
78
40
  def applicable_stories
79
41
  projects = load_projects
80
42
  projects.collect do |project|
@@ -134,8 +96,4 @@ No staged changes. Will create an empty commit.
134
96
  HighLine::BOLD + string + HighLine::RESET
135
97
  end
136
98
 
137
- def highlight(string)
138
- bold HighLine::BLUE + string
139
- end
140
-
141
99
  end
@@ -34,7 +34,6 @@ module Geordi
34
34
  # Generate dump on the server
35
35
  shell options.merge({
36
36
  remote_command: "dumple #{@config.env} --for_download",
37
- select_server: nil, # Dump must be generated on the primary server
38
37
  })
39
38
 
40
39
  destination_directory = File.join(@config.root, 'tmp')
@@ -56,7 +55,20 @@ module Geordi
56
55
  end
57
56
 
58
57
  def shell(options = {})
59
- server = options[:select_server] ? select_server : @config.primary_server
58
+ server_option = options[:select_server]
59
+ server_number = server_option.to_i
60
+
61
+ server = if server_option == 'select_server'
62
+ select_server
63
+ elsif server_number != 0 && server_number <= @config.servers.count
64
+ server_index = server_number - 1
65
+ @config.servers[server_index]
66
+ elsif server_option.nil?
67
+ @config.primary_server
68
+ else
69
+ Interaction.warn "Invalid server number: #{server_option}"
70
+ select_server
71
+ end
60
72
 
61
73
  remote_command = "cd #{@config.remote_root} && #{@config.shell}"
62
74
  remote_command << " -c '#{options[:remote_command]}'" if options[:remote_command]
@@ -0,0 +1,155 @@
1
+ require 'yaml'
2
+
3
+ require File.expand_path('util', __dir__)
4
+ require File.expand_path('interaction', __dir__)
5
+
6
+ module Geordi
7
+ class Settings
8
+ GLOBAL_SETTINGS_FILE_NAME = Util.testing? ? './tmp/global_settings.yml'.freeze : File.join(ENV['HOME'], '.config/geordi/global.yml').freeze
9
+ LOCAL_SETTINGS_FILE_NAME = Util.testing? ? './tmp/local_settings.yml'.freeze : './.geordi.yml'.freeze
10
+
11
+ ALLOWED_GLOBAL_SETTINGS = %w[ pivotal_tracker_api_key ].freeze
12
+ ALLOWED_LOCAL_SETTINGS = %w[ use_vnc pivotal_tracker_project_ids ].freeze
13
+
14
+ def initialize
15
+ read_settings
16
+ end
17
+
18
+ # Global settings
19
+ def pivotal_tracker_api_key
20
+ @global_settings['pivotal_tracker_api_key'] || gitpt_api_key_old || inquire_pt_api_key
21
+ end
22
+
23
+ def pivotal_tracker_api_key=(value)
24
+ @global_settings['pivotal_tracker_api_key'] = value
25
+ save_global_settings
26
+ end
27
+
28
+ # Local settings
29
+ # They should not be changed by geordi to avoid unexpected diffs, therefore
30
+ # there are no setters for these settings
31
+ def use_vnc?
32
+ @local_settings.fetch('use_vnc', true)
33
+ end
34
+
35
+ def pivotal_tracker_project_ids
36
+ project_ids = @local_settings['pivotal_tracker_project_ids'] || pt_project_ids_old
37
+
38
+ case project_ids
39
+ when Array
40
+ # nothing to do
41
+ when String
42
+ project_ids = project_ids.split(/[\s]+/).map(&:to_i)
43
+ when Integer
44
+ project_ids = [project_ids]
45
+ else
46
+ project_ids = []
47
+ end
48
+
49
+ if project_ids.empty?
50
+ puts
51
+ Geordi::Interaction.warn "Sorry, I could not find a project ID in .geordi.yml :("
52
+ puts
53
+
54
+ puts "Please put at least one Pivotal Tracker project id into the .geordi.yml file in this directory, e.g."
55
+ puts
56
+ puts "pivotal_tracker_project_ids:"
57
+ puts "- 123456"
58
+ puts
59
+ puts 'You may add multiple IDs.'
60
+ exit 1
61
+ end
62
+
63
+ project_ids
64
+ end
65
+
66
+ private
67
+
68
+ def read_settings
69
+ global_path = GLOBAL_SETTINGS_FILE_NAME
70
+ local_path = LOCAL_SETTINGS_FILE_NAME
71
+
72
+ if File.exists?(global_path)
73
+ global_settings = YAML.safe_load(File.read(global_path))
74
+ check_for_invalid_keys(global_settings, ALLOWED_GLOBAL_SETTINGS, global_path)
75
+ end
76
+
77
+ if File.exists?(local_path)
78
+ local_settings = YAML.safe_load(File.read(local_path))
79
+ check_for_invalid_keys(local_settings, ALLOWED_LOCAL_SETTINGS, local_path)
80
+ end
81
+
82
+ @global_settings = global_settings || {}
83
+ @local_settings = local_settings || {}
84
+ end
85
+
86
+ def check_for_invalid_keys(settings, allowed_keys, file)
87
+ invalid_keys = settings.keys - allowed_keys
88
+ unless invalid_keys.empty?
89
+ Geordi::Interaction.warn "Geordi detected unknown keys in #{file}.\n"
90
+
91
+ invalid_keys.sort.each do |key|
92
+ puts "* #{key}"
93
+ end
94
+
95
+ puts "\nAllowed keys are:"
96
+ allowed_keys.sort.each do |key|
97
+ puts "* #{key}"
98
+ end
99
+ puts
100
+
101
+ exit 1
102
+ end
103
+ end
104
+
105
+ def save_global_settings
106
+ global_path = GLOBAL_SETTINGS_FILE_NAME
107
+ global_directory = File.dirname(global_path)
108
+ FileUtils.mkdir_p(global_directory) unless File.directory? global_directory
109
+ File.open(global_path, 'w') do |file|
110
+ file.write @global_settings.to_yaml
111
+ end
112
+ end
113
+
114
+ # deprecated
115
+ def gitpt_api_key_old
116
+ file_path = File.join(ENV['HOME'], '.gitpt')
117
+ if File.exist?(file_path) && !Util.testing?
118
+ token = YAML.load_file(file_path).fetch :token
119
+ self.pivotal_tracker_api_key = token
120
+
121
+ Geordi::Interaction.warn "The ~/.gitpt file is deprecated."
122
+ Geordi::Interaction.note "The contained setting has been moved to ~/.config/geordi/global.yml."
123
+ Geordi::Interaction.note "If you don't need to work with an older version of geordi you can delete ~/.gitpt now."
124
+
125
+ token
126
+ end
127
+ end
128
+
129
+ def inquire_pt_api_key
130
+ Geordi::Interaction.warn 'Your settings are missing or invalid.'
131
+ Geordi::Interaction.warn "Please configure your Pivotal Tracker access."
132
+ token = Geordi::Interaction.prompt 'Your API key:'
133
+ self.pivotal_tracker_api_key = token
134
+ puts
135
+
136
+ token
137
+ end
138
+
139
+ # deprecated
140
+ def pt_project_ids_old
141
+ if File.exist?('.pt_project_id')
142
+ project_ids = File.read('.pt_project_id')
143
+ puts # Make sure to start on a new line (e.g. when invoked after a #print)
144
+ Geordi::Interaction.warn "The usage of the .pt_project_id file is deprecated."
145
+ Geordi::Interaction.note Util.strip_heredoc(<<-INSTRUCTIONS)
146
+ Please remove this file from your project and add or extend the .geordi.yml file with the following content:
147
+ pivotal_tracker_project_ids: #{project_ids}
148
+ INSTRUCTIONS
149
+
150
+ project_ids
151
+ end
152
+ end
153
+
154
+ end
155
+ end
@@ -93,7 +93,7 @@ module Geordi
93
93
  ENV['GEORDI_TESTING_STAGED_CHANGES'] == 'true'
94
94
  else
95
95
  statuses = `git status --porcelain`.split("\n")
96
- statuses.any? { |l| l.start_with? /[A-Z]/i }
96
+ statuses.any? { |l| /^[A-Z]/i =~ l }
97
97
  end
98
98
  end
99
99
 
@@ -1,3 +1,3 @@
1
1
  module Geordi
2
- VERSION = '3.1.0'.freeze
2
+ VERSION = '3.2.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: 3.1.0
4
+ version: 3.2.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: 2020-06-03 00:00:00.000000000 Z
11
+ date: 2020-07-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thor
@@ -123,6 +123,7 @@ files:
123
123
  - lib/geordi/gitpt.rb
124
124
  - lib/geordi/interaction.rb
125
125
  - lib/geordi/remote.rb
126
+ - lib/geordi/settings.rb
126
127
  - lib/geordi/util.rb
127
128
  - lib/geordi/version.rb
128
129
  homepage: http://makandra.com
@@ -144,7 +145,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
144
145
  - !ruby/object:Gem::Version
145
146
  version: '0'
146
147
  requirements: []
147
- rubygems_version: 3.1.4
148
+ rubygems_version: 3.0.3
148
149
  signing_key:
149
150
  specification_version: 4
150
151
  summary: Collection of command line tools we use in our daily work with Ruby, Rails