nib 2.0.0 → 2.1.1

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
- SHA1:
3
- metadata.gz: 5c94574ceb002f4a62bae9dae565d4a9eb0f87cb
4
- data.tar.gz: 4240d6bce285b3fec1f54d8620dc4728c4e101ca
2
+ SHA256:
3
+ metadata.gz: b69fb8eb3b9ba8f08e35a98aecb2334e6ed064202851793609a2611928ac047f
4
+ data.tar.gz: f60ce60ae0b32ebd7bfe6adfa68aded161d3d35f3a038bc036121f86a9c2ddd7
5
5
  SHA512:
6
- metadata.gz: 8127154d0d106487d3b6e6b27f4527bf4e8c07bd61d73b1bbbb0ad4745597296791e74f40e8a8b76fefacc18356375eb1718a91a4506f2fb5751a93e9fd8aeab
7
- data.tar.gz: a89ecbee23a910e2ca8f8eec41144df1d5c2afc7049a83a74c6e98d5ae2254b8578038420c865f30d388d0e8be9ba3e66a7d39856c734be237c26ec6203357ac
6
+ metadata.gz: 9f487437d32af8de8e5f4cd31664a11f70661bd4290f9c6314b146f1f73cf382e47af8e2101826586214b8bbb2ecbc1efb34c91ddaaf9cd9fb594cdf06c677d8
7
+ data.tar.gz: 8bf1f908a299ea019744b92e7c0dd72a9f276ff2f45b119ca01e1cd8e186cf946b5954597aacff42ed9b9f5eb49c2636052ca64104b976fd893f6dd82b530c74
data/VERSION CHANGED
@@ -1 +1 @@
1
- 2.0.0
1
+ 2.1.1
data/bin/nib CHANGED
@@ -37,6 +37,7 @@ post do |global, command, options, args|
37
37
  # Use skips_post before a command to skip this
38
38
  # block on that command only
39
39
  if command.is_a? GLI::Commands::Help
40
+ Nib::Plugins.execute(options, args)
40
41
  Nib::UnrecognizedHelp.execute(options, args)
41
42
  Nib::CheckForUpdate.execute(options, args)
42
43
  end
@@ -15,3 +15,5 @@ Pry.config.ls.heading_color = :magenta
15
15
  Pry.config.ls.public_method_color = :green
16
16
  Pry.config.ls.protected_method_color = :yellow
17
17
  Pry.config.ls.private_method_color = :bright_black
18
+ # Disable paging - paging is broken in when using Alpine `less`
19
+ Pry.config.pager = false
@@ -1,7 +1,7 @@
1
1
  module CoreExtensions
2
2
  module Hash
3
3
  def symbolize_keys!
4
- map { |k, v| [k.to_sym, v] }.to_h
4
+ transform_keys(&:to_sym)
5
5
  end
6
6
  end
7
7
  end
@@ -0,0 +1,29 @@
1
+ require 'yaml'
2
+
3
+ module CoreExtensions
4
+ # Handle the fact that we are loading potentially "unsafe" YAML while still
5
+ # supporting Ruby 2.7 and 3.0.
6
+ module Psych
7
+ def flexible_load(string)
8
+ load_with = if ::Psych.respond_to?(:unsafe_load)
9
+ :unsafe_load
10
+ else
11
+ :load
12
+ end
13
+
14
+ ::Psych.send(load_with, string)
15
+ end
16
+
17
+ def flexible_load_file(path)
18
+ load_with = if ::Psych.respond_to?(:unsafe_load_file)
19
+ :unsafe_load_file
20
+ else
21
+ :load_file
22
+ end
23
+
24
+ ::Psych.send(load_with, path)
25
+ end
26
+ end
27
+ end
28
+
29
+ Psych.extend CoreExtensions::Psych
@@ -0,0 +1,6 @@
1
+ class String
2
+ # Implementation from active_support https://git.io/vNVlN
3
+ def strip_heredoc
4
+ gsub(/^#{scan(/^[ \t]*(?=\S)/).min}/, ''.freeze)
5
+ end
6
+ end
@@ -4,10 +4,10 @@ class Nib::CheckForUpdate
4
4
  def self.execute(_, _)
5
5
  return if installed == latest
6
6
 
7
- puts <<-MESSAGE
7
+ puts <<-MESSAGE.strip_heredoc
8
8
 
9
- An update is available for nib: #{latest}
10
- Use 'nib update' to install the latest version
9
+ An update is available for nib: #{latest}
10
+ Use 'nib update' to install the latest version
11
11
  MESSAGE
12
12
  end
13
13
 
data/lib/nib/debug.rb CHANGED
@@ -1,5 +1,3 @@
1
- require 'yaml'
2
-
3
1
  class Nib::Debug
4
2
  include Nib::Command
5
3
 
@@ -18,11 +16,15 @@ class Nib::Debug
18
16
  end
19
17
 
20
18
  def host
21
- if ENV.key?('DOCKER_HOST_URL') && ENV['DOCKER_HOST_URL'] != ''
19
+ return @host if @host
20
+
21
+ @host = if ENV.key?('DOCKER_HOST_URL') && ENV['DOCKER_HOST_URL'] != ''
22
22
  URI.parse(ENV['DOCKER_HOST_URL']).host
23
23
  else
24
- `ip route | awk 'NR==1 {print $3}'`.chomp
24
+ `ip route | head -n 1`.chomp
25
25
  end
26
+
27
+ @host = @host == '' ? '0.0.0.0' : @host
26
28
  end
27
29
 
28
30
  def compose_file
@@ -28,7 +28,9 @@ class Nib::History::Compose
28
28
  end
29
29
 
30
30
  def original_config
31
- @original_config ||= YAML.safe_load(docker_compose_config.gsub(/\$/, '$$'))
31
+ @original_config ||= Psych.flexible_load(
32
+ docker_compose_config.gsub(/\$/, '$$')
33
+ )
32
34
  end
33
35
 
34
36
  def file
@@ -55,8 +57,8 @@ class Nib::History::Compose
55
57
  end
56
58
 
57
59
  def config
58
- original_config.each_with_object({}) do |(name, definition), extended|
59
- extended[name] = Service.new(volume_name, definition).config
60
+ original_config.transform_values do |definition|
61
+ Service.new(volume_name, definition).config
60
62
  end
61
63
  end
62
64
  end
@@ -30,7 +30,7 @@ class Nib::History::Config
30
30
  def config_file
31
31
  @config_file ||= File.open("#{PATH}/#{type}", 'w+') do |file|
32
32
  file.write(config)
33
- file.write(history_command + "\n")
33
+ file.write("#{history_command}\n")
34
34
  file
35
35
  end
36
36
  end
data/lib/nib/options.rb CHANGED
@@ -2,7 +2,9 @@ module Nib::Options
2
2
  module_function
3
3
 
4
4
  def config
5
- @config ||= YAML.load_file("#{Nib::GEM_ROOT}/config/options.yml")
5
+ return @config if @config
6
+
7
+ @config = Psych.flexible_load_file("#{Nib::GEM_ROOT}/config/options.yml")
6
8
  end
7
9
 
8
10
  def options_for(type, name)
data/lib/nib/plugin.rb ADDED
@@ -0,0 +1,31 @@
1
+ class Nib::Plugin
2
+ attr_reader :path
3
+
4
+ def initialize(path)
5
+ @path = path
6
+ end
7
+
8
+ def basename
9
+ @basename ||= File.basename(path, '_plugin.rb')
10
+ end
11
+
12
+ def name
13
+ @name ||= basename.tr('_', '-')
14
+ end
15
+
16
+ def constant
17
+ @constant ||= Object.const_get(name.split('-').map(&:capitalize).join('::'))
18
+ end
19
+
20
+ def applies?
21
+ @applies ||= begin
22
+ require path
23
+
24
+ constant.applies?
25
+ end
26
+ end
27
+
28
+ def binstub
29
+ "#{path[0..-"/lib/#{basename}_plugin.rb".length]}bin/#{name}"
30
+ end
31
+ end
@@ -0,0 +1,20 @@
1
+ class Nib::Plugins
2
+ def self.execute(_, _)
3
+ puts ''
4
+ puts(
5
+ (['Installed plugins:'] | potential_plugins.map(&:name))
6
+ .join("\r\n - ")
7
+ )
8
+ end
9
+
10
+ def self.potential_plugins
11
+ @potential_plugins ||= Gem
12
+ .find_files('nib*_plugin.rb')
13
+ .sort
14
+ .map { |plugin_path| Nib::Plugin.new(plugin_path) }
15
+ end
16
+
17
+ def self.available_plugins
18
+ @available_plugins ||= potential_plugins.select(&:applies?)
19
+ end
20
+ end
@@ -1,6 +1,6 @@
1
1
  class Nib::UnrecognizedHelp
2
2
  def self.execute(_, _)
3
- puts <<-MESSAGE
3
+ puts <<-MESSAGE.strip_heredoc
4
4
 
5
5
  Note:
6
6
  Unrecognized commands will be delegated to docker-compose.
data/lib/nib/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Nib
2
- VERSION = File.read(File.expand_path('../../../VERSION', __FILE__)).freeze
2
+ VERSION = File.read(File.expand_path('../../VERSION', __dir__)).freeze
3
3
  end
data/lib/nib.rb CHANGED
@@ -1,11 +1,16 @@
1
1
  require 'nib/version'
2
2
 
3
3
  require 'core_extensions/hash'
4
+ require 'core_extensions/string'
5
+ require 'core_extensions/psych'
4
6
 
5
7
  require 'nib/options'
6
8
  require 'nib/options/augmenter'
7
9
  require 'nib/options/parser'
8
10
 
11
+ require 'nib/plugins'
12
+ require 'nib/plugin'
13
+
9
14
  require 'nib/command'
10
15
  require 'nib/history'
11
16
  require 'nib/history/compose'
@@ -22,26 +27,16 @@ require 'nib/shell'
22
27
  require 'nib/update'
23
28
 
24
29
  module Nib
25
- GEM_ROOT = File.expand_path('../..', __FILE__)
30
+ GEM_ROOT = File.expand_path('..', __dir__)
26
31
 
27
32
  module_function
28
33
 
29
- def available_plugins
30
- Gem.find_files('nib*_plugin.rb').sort.map do |plugin_path|
31
- name = File.basename plugin_path, '_plugin.rb'
32
-
33
- require plugin_path
34
-
35
- next unless const_for(name).applies?
36
-
37
- plugin_base_path = plugin_path[0..-"/lib/#{name}_plugin.rb".length]
38
-
39
- "#{plugin_base_path}bin/#{name.tr('_', '-')}"
40
- end.compact
34
+ def installed_plugins
35
+ Nib::Plugins.potential_plugins.map(&:name)
41
36
  end
42
37
 
43
- def const_for(name)
44
- Nib.const_get(name.split('_').map(&:capitalize).join('::'))
38
+ def available_plugins
39
+ Nib::Plugins.available_plugins.map(&:binstub)
45
40
  end
46
41
 
47
42
  def load_default_config(command, file_name)
metadata CHANGED
@@ -1,15 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nib
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 2.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Allen
8
8
  - Zach Blankenship
9
- autorequire:
9
+ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2018-01-15 00:00:00.000000000 Z
12
+ date: 2022-02-09 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: gli
@@ -39,6 +39,20 @@ dependencies:
39
39
  - - "~>"
40
40
  - !ruby/object:Gem::Version
41
41
  version: 1.0.7
42
+ - !ruby/object:Gem::Dependency
43
+ name: did_you_mean
44
+ requirement: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - ">="
47
+ - !ruby/object:Gem::Version
48
+ version: '0'
49
+ type: :development
50
+ prerelease: false
51
+ version_requirements: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - ">="
54
+ - !ruby/object:Gem::Version
55
+ version: '0'
42
56
  - !ruby/object:Gem::Dependency
43
57
  name: guard
44
58
  requirement: !ruby/object:Gem::Requirement
@@ -152,6 +166,8 @@ files:
152
166
  - config/commands/shell/pryrc
153
167
  - config/options.yml
154
168
  - lib/core_extensions/hash.rb
169
+ - lib/core_extensions/psych.rb
170
+ - lib/core_extensions/string.rb
155
171
  - lib/nib.rb
156
172
  - lib/nib/check_for_update.rb
157
173
  - lib/nib/code_climate.rb
@@ -165,6 +181,8 @@ files:
165
181
  - lib/nib/options.rb
166
182
  - lib/nib/options/augmenter.rb
167
183
  - lib/nib/options/parser.rb
184
+ - lib/nib/plugin.rb
185
+ - lib/nib/plugins.rb
168
186
  - lib/nib/run.rb
169
187
  - lib/nib/setup.rb
170
188
  - lib/nib/shell.rb
@@ -173,8 +191,9 @@ files:
173
191
  - lib/nib/version.rb
174
192
  homepage: https://github.com/technekes/nib
175
193
  licenses: []
176
- metadata: {}
177
- post_install_message:
194
+ metadata:
195
+ rubygems_mfa_required: 'true'
196
+ post_install_message:
178
197
  rdoc_options: []
179
198
  require_paths:
180
199
  - lib
@@ -183,16 +202,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
183
202
  requirements:
184
203
  - - ">="
185
204
  - !ruby/object:Gem::Version
186
- version: 2.2.0
205
+ version: 2.7.5
187
206
  required_rubygems_version: !ruby/object:Gem::Requirement
188
207
  requirements:
189
208
  - - ">="
190
209
  - !ruby/object:Gem::Version
191
210
  version: '0'
192
211
  requirements: []
193
- rubyforge_project:
194
- rubygems_version: 2.5.2.2
195
- signing_key:
212
+ rubygems_version: 3.3.3
213
+ signing_key:
196
214
  specification_version: 4
197
215
  summary: The tip of the pen (compose)
198
216
  test_files: []