claide 0.3.2 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a0f10891f088c7ed12152cf4cd351af675e9401b
4
- data.tar.gz: cfbb878d8b1db4611f61e68f7e79fd000b1276f2
3
+ metadata.gz: 36f21c6747d3cf6f375f617e2e9a5dda06c6bf62
4
+ data.tar.gz: 8e127974a2cca76d6c727eed4f3c2afaf5bac18a
5
5
  SHA512:
6
- metadata.gz: 91a4eeeef6175030caaf4e9be9e642e3c2e61078552615ce97c8c1d54877a074156f4c8f0c8a5e86310bcd0c213a0a3ddba63386117f531d4efa379383255e1f
7
- data.tar.gz: 309d3ad380dcb43d99cdb2f0cde5b83407b793650a53b4fd055c4ea166d3b5bfcf6d47d6a36a2d877eb29786ded0ff7e755e5a9f172a46af5e52ac4bdb3ebee1
6
+ metadata.gz: b9a061458ebfb79695b865f757f09e6f46e775a2695612b810d7bdb813e4ef1a6c4e79346b89fcc69a4a3d9a855039a305a84bbe669c2f8baafc76ab96dc5688
7
+ data.tar.gz: 68f8dfc688c182c00ac906789c5cb74d89534b5b76c8d9bf8c5e8d4cea19b61af4c0778371be238c18aca1d50e47e7932439e4b4819d31633779ea0546c182b5
@@ -89,7 +89,7 @@ method, which performs the following three steps:
89
89
 
90
90
  2. Asks the command instance to validate its parameters, but only _after_
91
91
  calling the `super` implementation. The `super` implementation will show a
92
- help banner in case the `--help` flag is specified, not all parameters where
92
+ help banner in case the `--help` flag is specified, not all parameters were
93
93
  removed from the parameter list, or the command is an abstract command.
94
94
 
95
95
  3. Calls the `run` method on the command instance, where it may do its work.
@@ -9,7 +9,7 @@ module CLAide
9
9
  #
10
10
  # CLAide’s version, following [semver](http://semver.org).
11
11
  #
12
- VERSION = '0.3.2'
12
+ VERSION = '0.4.0'
13
13
 
14
14
  require 'claide/argv.rb'
15
15
  require 'claide/command.rb'
@@ -69,6 +69,12 @@ module CLAide
69
69
  #
70
70
  attr_accessor :description
71
71
 
72
+ # @return [String] The prefix for loading CLAide plugins for this
73
+ # command. Plugins are loaded via their
74
+ # <plugin_prefix>_plugin.rb file.
75
+ #
76
+ attr_accessor :plugin_prefix
77
+
72
78
  # @return [String] A list of arguments the command handles. This is shown
73
79
  # in the usage section of the command’s help banner.
74
80
  #
@@ -201,6 +207,7 @@ module CLAide
201
207
  # @return [void]
202
208
  #
203
209
  def run(argv)
210
+ load_plugins
204
211
  command = parse(argv)
205
212
  command.validate!
206
213
  command.run
@@ -261,6 +268,45 @@ module CLAide
261
268
  Banner.new(self, colorize).formatted_banner
262
269
  end
263
270
 
271
+ # Load additional plugins via rubygems looking for:
272
+ #
273
+ # <command-path>/plugin.rb
274
+ #
275
+ # where <command-path> is the namespace of the Command converted to a
276
+ # path, for example:
277
+ #
278
+ # Pod::Command
279
+ #
280
+ # maps to
281
+ #
282
+ # pod/command
283
+ #
284
+ def load_plugins
285
+ return unless plugin_prefix
286
+ files_to_require = if Gem.respond_to? :find_latest_files
287
+ Gem.find_latest_files("#{plugin_prefix}_plugin")
288
+ else
289
+ Gem.find_files("#{plugin_prefix}_plugin")
290
+ end
291
+ files_to_require.each { |path| require_plugin_path(path) }
292
+ end
293
+
294
+ # Loads the plugin file at the given path, catching any failure.
295
+ #
296
+ # @param [String] path
297
+ # The path to load.
298
+ #
299
+ def require_plugin_path(path)
300
+ require path
301
+ rescue Exception => exception
302
+ message = "\n---------------------------------------------"
303
+ message << "\nError loading the plugin with path `#{path}`.\n"
304
+ message << "\n#{exception.class} - #{exception.message}"
305
+ message << "\n#{exception.backtrace.join("\n")}"
306
+ message << "\n---------------------------------------------\n"
307
+ message = colorize_output ? message.yellow : message
308
+ puts message
309
+ end
264
310
  end
265
311
 
266
312
  #-------------------------------------------------------------------------#
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: claide
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.2
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eloy Duran
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-05-23 00:00:00.000000000 Z
12
+ date: 2013-11-14 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description:
15
15
  email: