branch-name 3.2.2 → 3.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: 589277a07c2a1a873385e77be6276f7b0f2aaecbe6d5047b4f6e56e436ffcf8a
4
- data.tar.gz: a185c55be39afb5611b25cecd50d39a761c0fedef40bf96b4927fd3e410ac3a2
3
+ metadata.gz: c8085a7825aafe9da8526d6738b3a6df3f407632f8b7dae29e49a3bb51495642
4
+ data.tar.gz: 5fbf55ee24b31c7499a8077155a13b621054cad17f207101bf66833557eba6d1
5
5
  SHA512:
6
- metadata.gz: 5418d3f1ad7aa1cdc5ab523fb1824ffcf022c5c16ad54d3f9be773eaa4f02b3ba5f040ab2b3b5f5a8f7c0aecbe58dc2be848464f5409f68468cfb0059b222e49
7
- data.tar.gz: eb1fc297bdd508848208e8b95a389d0ac8ff37e9c2310a865a209587ea42377206c17543595790ac7dabb8f90ac73171a0160c7fd4e3d3359ac963e7dc2679cd
6
+ metadata.gz: 1a5252cc84fb2d0ff6b521da27c2e3316bfba1cdd3e37c98b326ee4abca43cb9ec1272beceb72318948f4bc454a5e979c97d8cf6ba5abc563cabafd27dbdafd1
7
+ data.tar.gz: b445dca1d9b01df49e70ac2152502f57ac4afbdfb95c9dd94ee631b136f9d4ea009bd4830792e9792d09c777e8a1227247b403c6a13889464812f214b2b07cf4
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## ['3.3.0'] - 2022-09-27
2
+ * Enhancements:
3
+ * `branch-name config info` now displays the contents of both the Global and the local config files.
4
+
1
5
  ## ['3.2.2'] - 2022-09-27
2
6
  * Changes:
3
7
  * Refactor code that patches Thor incorrect display of nested commands (subcommangs).
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- branch-name (3.2.2)
4
+ branch-name (3.3.0)
5
5
  activesupport (~> 7.0, >= 7.0.4)
6
6
  colorize (~> 0.8.1)
7
7
  os (~> 1.1, >= 1.1.4)
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Branch
4
+ module Name
5
+ module Colorizable
6
+ SUCCESS = :green
7
+ WARNING = :yellow
8
+ ERROR = :red
9
+ end
10
+ end
11
+ end
@@ -3,14 +3,17 @@
3
3
  require 'colorize'
4
4
  require 'fileutils'
5
5
  require 'yaml'
6
+ require_relative 'colorizable'
6
7
  require_relative 'locatable'
7
8
 
8
9
  module Branch
9
10
  module Name
10
11
  module Configurable
12
+ include Colorizable
11
13
  include Locatable
12
14
 
13
15
  CONFIG_FILENAME = '.branch-name'
16
+
14
17
  # rubocop:disable Style/StringHashKeys - YAML writing/loading necessitates this
15
18
  DEFAULT_BRANCH_NAME_OPTIONS = {
16
19
  'create' => {
@@ -58,37 +61,62 @@ module Branch
58
61
  delete_config_file local_config_file
59
62
  end
60
63
 
64
+ def print_global_config_file
65
+ config_file = global_config_file
66
+ if global_config_file?
67
+ say "Global config file (#{config_file}) contents:", SUCCESS
68
+ print_config_file config_file
69
+ else
70
+ say "Global config file (#{config_file}) does not exist.", WARNING
71
+ end
72
+ end
73
+
74
+ def print_local_config_file
75
+ config_file = local_config_file
76
+ if local_config_file?
77
+ say "Local config file (#{config_file}) contents:", SUCCESS
78
+ print_config_file config_file
79
+ else
80
+ say "Local config file (#{config_file}) does not exist.", WARNING
81
+ end
82
+ end
83
+
61
84
  private
62
85
 
63
86
  def create_config_file(config_file)
64
87
  folder = File.dirname(config_file)
65
88
  unless Dir.exist?(folder)
66
- say "Destination folder for configuration file (#{folder}) does not exist".red
89
+ say "Destination folder for configuration file (#{folder}) does not exist", ERROR
67
90
  return false
68
91
  end
69
92
 
70
93
  if File.exist?(config_file)
71
- puts "Configuration file (#{config_file}) already exists".yellow
94
+ say "Configuration file (#{config_file}) already exists", WARNING
72
95
  return false
73
96
  end
74
97
 
75
98
  File.write(config_file, DEFAULT_BRANCH_NAME_OPTIONS.to_yaml)
76
- puts "Configuration file (#{config_file}) created".green
99
+ say "Configuration file (#{config_file}) created", SUCCESS
77
100
 
78
101
  true
79
102
  end
80
103
 
81
104
  def delete_config_file(config_file)
82
105
  unless File.exist?(config_file)
83
- puts "Configuration file (#{config_file}) does not exist".yellow
106
+ say "Configuration file (#{config_file}) does not exist", WARNING
84
107
  return false
85
108
  end
86
109
 
87
110
  File.delete config_file
88
- puts "Configuration file (#{config_file}) deleted".green
111
+ say "Configuration file (#{config_file}) deleted", SUCCESS
89
112
 
90
113
  true
91
114
  end
115
+
116
+ def print_config_file(config_file)
117
+ hash = YAML.load(File.open(config_file))
118
+ say hash.to_yaml.gsub("\n-", "\n\n-"), SUCCESS
119
+ end
92
120
  end
93
121
  end
94
122
  end
@@ -26,17 +26,9 @@ module Branch
26
26
  branch-name config info
27
27
  LONG_DESC
28
28
  def info
29
- if global_config_file?
30
- say "Global config file exists: \"#{global_config_file}\"", :green
31
- else
32
- say "Global config file does not exist at: \"#{global_folder}\"", :yellow
33
- end
34
-
35
- if local_config_file?
36
- say "Local config file exists: \"#{local_config_file}\"", :green
37
- else
38
- say "Local config file does not exist at: \"#{local_folder}\"", :yellow
39
- end
29
+ print_global_config_file
30
+ say ''
31
+ print_local_config_file
40
32
  end
41
33
 
42
34
  desc 'init SUBCOMMAND', 'Sets up config files for this gem'
@@ -3,6 +3,6 @@
3
3
  module Branch
4
4
  module Name
5
5
  # branch-name version
6
- VERSION = '3.2.2'
6
+ VERSION = '3.3.0'
7
7
  end
8
8
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: branch-name
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.2.2
4
+ version: 3.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gene M. Angelo, Jr.
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-09-27 00:00:00.000000000 Z
11
+ date: 2022-09-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -110,6 +110,7 @@ files:
110
110
  - lib/branch/name/cli.rb
111
111
  - lib/branch/name/cli/thor_ext/shell/basic/say_error.rb
112
112
  - lib/branch/name/clipable.rb
113
+ - lib/branch/name/colorizable.rb
113
114
  - lib/branch/name/configurable.rb
114
115
  - lib/branch/name/exitable.rb
115
116
  - lib/branch/name/loadable.rb