nib 2.0.0 → 2.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/VERSION +1 -1
- data/bin/nib +1 -0
- data/config/commands/shell/pryrc +2 -0
- data/lib/core_extensions/hash.rb +1 -1
- data/lib/core_extensions/psych.rb +29 -0
- data/lib/core_extensions/string.rb +6 -0
- data/lib/nib/check_for_update.rb +3 -3
- data/lib/nib/debug.rb +6 -4
- data/lib/nib/history/compose.rb +5 -3
- data/lib/nib/history/config.rb +1 -1
- data/lib/nib/options.rb +3 -1
- data/lib/nib/plugin.rb +31 -0
- data/lib/nib/plugins.rb +20 -0
- data/lib/nib/unrecognized_help.rb +1 -1
- data/lib/nib/version.rb +1 -1
- data/lib/nib.rb +10 -15
- metadata +27 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: b69fb8eb3b9ba8f08e35a98aecb2334e6ed064202851793609a2611928ac047f
|
4
|
+
data.tar.gz: f60ce60ae0b32ebd7bfe6adfa68aded161d3d35f3a038bc036121f86a9c2ddd7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9f487437d32af8de8e5f4cd31664a11f70661bd4290f9c6314b146f1f73cf382e47af8e2101826586214b8bbb2ecbc1efb34c91ddaaf9cd9fb594cdf06c677d8
|
7
|
+
data.tar.gz: 8bf1f908a299ea019744b92e7c0dd72a9f276ff2f45b119ca01e1cd8e186cf946b5954597aacff42ed9b9f5eb49c2636052ca64104b976fd893f6dd82b530c74
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.
|
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
|
data/config/commands/shell/pryrc
CHANGED
@@ -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
|
data/lib/core_extensions/hash.rb
CHANGED
@@ -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
|
data/lib/nib/check_for_update.rb
CHANGED
@@ -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
|
-
|
10
|
-
|
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
|
-
|
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 |
|
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
|
data/lib/nib/history/compose.rb
CHANGED
@@ -28,7 +28,9 @@ class Nib::History::Compose
|
|
28
28
|
end
|
29
29
|
|
30
30
|
def original_config
|
31
|
-
@original_config ||=
|
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.
|
59
|
-
|
60
|
+
original_config.transform_values do |definition|
|
61
|
+
Service.new(volume_name, definition).config
|
60
62
|
end
|
61
63
|
end
|
62
64
|
end
|
data/lib/nib/history/config.rb
CHANGED
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
|
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
|
data/lib/nib/plugins.rb
ADDED
@@ -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
|
data/lib/nib/version.rb
CHANGED
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('
|
30
|
+
GEM_ROOT = File.expand_path('..', __dir__)
|
26
31
|
|
27
32
|
module_function
|
28
33
|
|
29
|
-
def
|
30
|
-
|
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
|
44
|
-
Nib.
|
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.
|
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:
|
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
|
-
|
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.
|
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
|
-
|
194
|
-
|
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: []
|