nib 2.0.0 → 2.0.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
2
  SHA1:
3
- metadata.gz: 5c94574ceb002f4a62bae9dae565d4a9eb0f87cb
4
- data.tar.gz: 4240d6bce285b3fec1f54d8620dc4728c4e101ca
3
+ metadata.gz: 3a530144db0f77985c7ccb94753ee135c0da31fc
4
+ data.tar.gz: ea52052132b01ef750b4f9a72b4d7a3f5b6aa397
5
5
  SHA512:
6
- metadata.gz: 8127154d0d106487d3b6e6b27f4527bf4e8c07bd61d73b1bbbb0ad4745597296791e74f40e8a8b76fefacc18356375eb1718a91a4506f2fb5751a93e9fd8aeab
7
- data.tar.gz: a89ecbee23a910e2ca8f8eec41144df1d5c2afc7049a83a74c6e98d5ae2254b8578038420c865f30d388d0e8be9ba3e66a7d39856c734be237c26ec6203357ac
6
+ metadata.gz: cbcceb1be4b3c10ea873ac59f67583a4ea13d6b7e3c642354697c62d022198e6b973dc343ea53fb4948a55cd269a822ff777670b5a017df258a66e35c405b358
7
+ data.tar.gz: de2ead11b0aadd1e1a06489ebe24dd973b4a1778c749a89f04f75934ee204b9d6bad5436e6901fc449585b88e8de7cfb0b8182865651f509e64b7e374ecd2dbb
data/VERSION CHANGED
@@ -1 +1 @@
1
- 2.0.0
1
+ 2.0.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
@@ -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
data/lib/nib.rb CHANGED
@@ -1,11 +1,15 @@
1
1
  require 'nib/version'
2
2
 
3
3
  require 'core_extensions/hash'
4
+ require 'core_extensions/string'
4
5
 
5
6
  require 'nib/options'
6
7
  require 'nib/options/augmenter'
7
8
  require 'nib/options/parser'
8
9
 
10
+ require 'nib/plugins'
11
+ require 'nib/plugin'
12
+
9
13
  require 'nib/command'
10
14
  require 'nib/history'
11
15
  require 'nib/history/compose'
@@ -26,22 +30,12 @@ module Nib
26
30
 
27
31
  module_function
28
32
 
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
33
+ def installed_plugins
34
+ Nib::Plugins.potential_plugins.map(&:name)
41
35
  end
42
36
 
43
- def const_for(name)
44
- Nib.const_get(name.split('_').map(&:capitalize).join('::'))
37
+ def available_plugins
38
+ Nib::Plugins.available_plugins.map(&:binstub)
45
39
  end
46
40
 
47
41
  def load_default_config(command, file_name)
@@ -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
 
@@ -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.
metadata CHANGED
@@ -1,7 +1,7 @@
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.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - John Allen
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2018-01-15 00:00:00.000000000 Z
12
+ date: 2018-02-02 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: gli
@@ -152,6 +152,7 @@ files:
152
152
  - config/commands/shell/pryrc
153
153
  - config/options.yml
154
154
  - lib/core_extensions/hash.rb
155
+ - lib/core_extensions/string.rb
155
156
  - lib/nib.rb
156
157
  - lib/nib/check_for_update.rb
157
158
  - lib/nib/code_climate.rb
@@ -165,6 +166,8 @@ files:
165
166
  - lib/nib/options.rb
166
167
  - lib/nib/options/augmenter.rb
167
168
  - lib/nib/options/parser.rb
169
+ - lib/nib/plugin.rb
170
+ - lib/nib/plugins.rb
168
171
  - lib/nib/run.rb
169
172
  - lib/nib/setup.rb
170
173
  - lib/nib/shell.rb