nib 1.7.0 → 2.1.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
- SHA1:
3
- metadata.gz: 0ae5c7c0fd0074c8bc59abecde13d264c9193b75
4
- data.tar.gz: 333886e4de7e6097560e04d17101be5df9eafc03
2
+ SHA256:
3
+ metadata.gz: 4222483b3c2ebfb88a93d8d6798d250bfac16bdd01e685d2c8397dacbd3e72f0
4
+ data.tar.gz: abd1e97f561ac535af89409e11fdf20f0c5be96404e6fa90e43561e9ce6a97b4
5
5
  SHA512:
6
- metadata.gz: ebdc8d550836d01e26a6462c258d73d9e888b7789dd737df13dbd9e1021e1f7364cf847a44bd3d4b9e1ead7098461d42205851bab95ed05d2b3cec04a6320348
7
- data.tar.gz: 317dc1f2302bbcf859b4f15b20b28340ca32c766750ec4bdb84ca6a9f250f0f2572809a192e4389b4a37da3b3e7629c9f50d899172a536d9c2a06e62739914af
6
+ metadata.gz: 5612ed97ecd998f1cf22fab6262bcde9fb1f4ac9e06588c1418c3c4fa7f6d68cbb9744ea2a89bdcccee9f2a5a80f926cafbce8e30349d8e6440707147393604e
7
+ data.tar.gz: b2a84a25909913a4941357727c0f6304a5f09a0f3358eaf892c04e9884a1a157b1254f74f4d66b36893eab65ca7b2978827cc3a0940126bb694abd960ff03f18
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.7.0
1
+ 2.1.0
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
@@ -197,4 +198,8 @@ command :update do |c|
197
198
  end
198
199
  end
199
200
 
201
+ Nib.available_plugins.each do |plugin|
202
+ load plugin
203
+ end
204
+
200
205
  exit run(ARGV)
@@ -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,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
@@ -18,11 +18,15 @@ class Nib::Debug
18
18
  end
19
19
 
20
20
  def host
21
- if ENV.key?('DOCKER_HOST_URL') && ENV['DOCKER_HOST_URL'] != ''
21
+ return @host if @host
22
+
23
+ @host = if ENV.key?('DOCKER_HOST_URL') && ENV['DOCKER_HOST_URL'] != ''
22
24
  URI.parse(ENV['DOCKER_HOST_URL']).host
23
25
  else
24
- `ip route | awk 'NR==1 {print $3}'`.chomp
26
+ `ip route | head -n 1`.chomp
25
27
  end
28
+
29
+ @host = @host == '' ? '0.0.0.0' : @host
26
30
  end
27
31
 
28
32
  def compose_file
@@ -55,8 +55,8 @@ class Nib::History::Compose
55
55
  end
56
56
 
57
57
  def config
58
- original_config.each_with_object({}) do |(name, definition), extended|
59
- extended[name] = Service.new(volume_name, definition).config
58
+ original_config.transform_values do |definition|
59
+ Service.new(volume_name, definition).config
60
60
  end
61
61
  end
62
62
  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,15 @@ 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
+ load_with = if YAML.respond_to?(:unsafe_load_file)
8
+ :unsafe_load_file
9
+ else
10
+ :load_file
11
+ end
12
+
13
+ @config = YAML.send(load_with, "#{Nib::GEM_ROOT}/config/options.yml")
6
14
  end
7
15
 
8
16
  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,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'
@@ -22,10 +26,18 @@ require 'nib/shell'
22
26
  require 'nib/update'
23
27
 
24
28
  module Nib
25
- GEM_ROOT = File.expand_path('../..', __FILE__)
29
+ GEM_ROOT = File.expand_path('..', __dir__)
26
30
 
27
31
  module_function
28
32
 
33
+ def installed_plugins
34
+ Nib::Plugins.potential_plugins.map(&:name)
35
+ end
36
+
37
+ def available_plugins
38
+ Nib::Plugins.available_plugins.map(&:binstub)
39
+ end
40
+
29
41
  def load_default_config(command, file_name)
30
42
  File.read("#{GEM_ROOT}/config/commands/#{command}/#{file_name}")
31
43
  end
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: 1.7.0
4
+ version: 2.1.0
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: 2017-06-06 00:00:00.000000000 Z
12
+ date: 2022-01-20 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: gli
@@ -26,7 +26,21 @@ dependencies:
26
26
  - !ruby/object:Gem::Version
27
27
  version: '2.16'
28
28
  - !ruby/object:Gem::Dependency
29
- name: pry
29
+ name: codeclimate-test-reporter
30
+ requirement: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - "~>"
33
+ - !ruby/object:Gem::Version
34
+ version: 1.0.7
35
+ type: :development
36
+ prerelease: false
37
+ version_requirements: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - "~>"
40
+ - !ruby/object:Gem::Version
41
+ version: 1.0.7
42
+ - !ruby/object:Gem::Dependency
43
+ name: did_you_mean
30
44
  requirement: !ruby/object:Gem::Requirement
31
45
  requirements:
32
46
  - - ">="
@@ -40,7 +54,7 @@ dependencies:
40
54
  - !ruby/object:Gem::Version
41
55
  version: '0'
42
56
  - !ruby/object:Gem::Dependency
43
- name: serverspec
57
+ name: guard
44
58
  requirement: !ruby/object:Gem::Requirement
45
59
  requirements:
46
60
  - - ">="
@@ -54,7 +68,7 @@ dependencies:
54
68
  - !ruby/object:Gem::Version
55
69
  version: '0'
56
70
  - !ruby/object:Gem::Dependency
57
- name: rake
71
+ name: guard-rspec
58
72
  requirement: !ruby/object:Gem::Requirement
59
73
  requirements:
60
74
  - - ">="
@@ -68,7 +82,7 @@ dependencies:
68
82
  - !ruby/object:Gem::Version
69
83
  version: '0'
70
84
  - !ruby/object:Gem::Dependency
71
- name: guard
85
+ name: guard-rubocop
72
86
  requirement: !ruby/object:Gem::Requirement
73
87
  requirements:
74
88
  - - ">="
@@ -82,7 +96,7 @@ dependencies:
82
96
  - !ruby/object:Gem::Version
83
97
  version: '0'
84
98
  - !ruby/object:Gem::Dependency
85
- name: guard-rspec
99
+ name: pry
86
100
  requirement: !ruby/object:Gem::Requirement
87
101
  requirements:
88
102
  - - ">="
@@ -96,7 +110,7 @@ dependencies:
96
110
  - !ruby/object:Gem::Version
97
111
  version: '0'
98
112
  - !ruby/object:Gem::Dependency
99
- name: guard-rubocop
113
+ name: rake
100
114
  requirement: !ruby/object:Gem::Requirement
101
115
  requirements:
102
116
  - - ">="
@@ -110,7 +124,7 @@ dependencies:
110
124
  - !ruby/object:Gem::Version
111
125
  version: '0'
112
126
  - !ruby/object:Gem::Dependency
113
- name: simplecov
127
+ name: serverspec
114
128
  requirement: !ruby/object:Gem::Requirement
115
129
  requirements:
116
130
  - - ">="
@@ -124,19 +138,19 @@ dependencies:
124
138
  - !ruby/object:Gem::Version
125
139
  version: '0'
126
140
  - !ruby/object:Gem::Dependency
127
- name: codeclimate-test-reporter
141
+ name: simplecov
128
142
  requirement: !ruby/object:Gem::Requirement
129
143
  requirements:
130
- - - "~>"
144
+ - - ">="
131
145
  - !ruby/object:Gem::Version
132
- version: 1.0.7
146
+ version: '0'
133
147
  type: :development
134
148
  prerelease: false
135
149
  version_requirements: !ruby/object:Gem::Requirement
136
150
  requirements:
137
- - - "~>"
151
+ - - ">="
138
152
  - !ruby/object:Gem::Version
139
- version: 1.0.7
153
+ version: '0'
140
154
  description: " nib is a docker-compose wrapper geared towards Ruby/Rails development.\n"
141
155
  email:
142
156
  - noreply@technekes.com
@@ -152,6 +166,7 @@ files:
152
166
  - config/commands/shell/pryrc
153
167
  - config/options.yml
154
168
  - lib/core_extensions/hash.rb
169
+ - lib/core_extensions/string.rb
155
170
  - lib/nib.rb
156
171
  - lib/nib/check_for_update.rb
157
172
  - lib/nib/code_climate.rb
@@ -165,6 +180,8 @@ files:
165
180
  - lib/nib/options.rb
166
181
  - lib/nib/options/augmenter.rb
167
182
  - lib/nib/options/parser.rb
183
+ - lib/nib/plugin.rb
184
+ - lib/nib/plugins.rb
168
185
  - lib/nib/run.rb
169
186
  - lib/nib/setup.rb
170
187
  - lib/nib/shell.rb
@@ -173,8 +190,9 @@ files:
173
190
  - lib/nib/version.rb
174
191
  homepage: https://github.com/technekes/nib
175
192
  licenses: []
176
- metadata: {}
177
- post_install_message:
193
+ metadata:
194
+ rubygems_mfa_required: 'true'
195
+ post_install_message:
178
196
  rdoc_options: []
179
197
  require_paths:
180
198
  - lib
@@ -183,16 +201,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
183
201
  requirements:
184
202
  - - ">="
185
203
  - !ruby/object:Gem::Version
186
- version: 2.2.0
204
+ version: 2.7.5
187
205
  required_rubygems_version: !ruby/object:Gem::Requirement
188
206
  requirements:
189
207
  - - ">="
190
208
  - !ruby/object:Gem::Version
191
209
  version: '0'
192
210
  requirements: []
193
- rubyforge_project:
194
- rubygems_version: 2.5.2
195
- signing_key:
211
+ rubygems_version: 3.2.22
212
+ signing_key:
196
213
  specification_version: 4
197
214
  summary: The tip of the pen (compose)
198
215
  test_files: []