Sha256: 90fa9f59347157506335b80efc96cb8155d261c454996827fe9b601a2e7c4c21

Contents?: true

Size: 1.42 KB

Versions: 4

Compression:

Stored size: 1.42 KB

Contents

require 'high_five/config'

module HighFive
  module Thor
    class Task < ::Thor
      def self.banner(task, namespace = false, subcommand = true)
        if self.namespace == "high_five"
          ns = ""
        else
          ns = "#{self.namespace}:"
        end
        "hi5 #{ns}" + task.formatted_usage(self, namespace, subcommand)
      end

      no_tasks {
        def invoke(name=nil, *args)
          name.sub!(/^high_five:/, '') if name && $high_five_runner
          super
        end
        
        class << self
          def inherited(base) #:nodoc:
            base.send :extend,  ClassMethods
          end
        end

        def base_config
          begin 
            @base_config ||= HighFive::Config.load
          rescue StandardError => e
            raise e
            say e.message, :red
            exit
          end
        end
      }

      def initialize(*args)
        super
       
      end
    
      module ClassMethods
        def namespace(name=nil)
          case name
          when nil
            constant = self.to_s.gsub(/^Thor::Sandbox::/, "")
            strip = $high_five_runner ? /^HighFive::Thor::Tasks::/ : /(?<=HighFive::)Thor::Tasks::/
            constant = constant.gsub(strip, "")
            constant =  ::Thor::Util.snake_case(constant).squeeze(":")          
            @namespace ||= constant
          else
            super
          end
        end
      end
    end  
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
high_five-0.2.10 lib/high_five/thor/task.rb
high_five-0.2.9 lib/high_five/thor/task.rb
high_five-0.2.8 lib/high_five/thor/task.rb
high_five-0.2.7 lib/high_five/thor/task.rb