lib/dldinternet/mixlib/cli.rb in dldinternet-mixlib-cli-0.0.7 vs lib/dldinternet/mixlib/cli.rb in dldinternet-mixlib-cli-0.1.0

- old
+ new

@@ -1,51 +1,61 @@ -require "dldinternet/mixlib/cli/version" -require "mixlib/cli" +unless defined? ::DLDInternet::Mixlib::CLI::ClassMethods -module DLDInternet - module Mixlib - module CLI + require "dldinternet/mixlib/cli/version" + module DLDInternet + module Mixlib + module CLI + module ClassMethods + end - include ::Mixlib::CLI + # ---------------------------------------------------------------------------------------------------------------- + # InstanceMethods + # ---------------------------------------------------------------------------------------------------------------- - def self.included(receiver) - receiver.extend(::Mixlib::CLI::ClassMethods) + # -------------------------------------------------------------------------------- + def parseString(v) + v + end - receiver.class_eval do + # -------------------------------------------------------------------------------- + def parsePath(v) + File.expand_path(parseString(v)) + end - # -------------------------------------------------------------------------------- - def parseString(v) - v - end + # -------------------------------------------------------------------------------- + def parseList(v,s=',',method='parseString') + parts = [] + a = v.split(%r/#{s}/) + a.each{ |t| + parts << send(method,t) + } + parts + end - # -------------------------------------------------------------------------------- - def parsePath(v) - File.expand_path(parseString(v)) + # -------------------------------------------------------------------------------- + def parseOptionString(v,s=',',method='parseString') + bags = [] + if v.match(%r'#{s}') + bags << parseList(v,s,method) + else + bags << send(method,v) end + bags.flatten + end - # -------------------------------------------------------------------------------- - def parseList(v,s=',',method='parseString') - parts = [] - a = v.split(%r/#{s}/) - a.each{ |t| - parts << send(method,t) - } - parts - end + def self.included(receiver) - # -------------------------------------------------------------------------------- - def parseOptionString(v,s=',',method='parseString') - bags = [] - if v.match(%r'#{s}') - bags << parseList(v,s,method) - else - bags << send(method,v) - end - bags.flatten + receiver.class_eval do + require "mixlib/cli" + include ::Mixlib::CLI end + receiver.extend(::Mixlib::CLI::ClassMethods) + receiver.extend(ClassMethods) + end - end + end end end -end + +end \ No newline at end of file