Sha256: 1647f065ad8039991c08157f4f46b968bba759f64b96f0b7996218480fb9ca8d

Contents?: true

Size: 1.4 KB

Versions: 7

Compression:

Stored size: 1.4 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
            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

7 entries across 7 versions & 1 rubygems

Version Path
high_five-0.2.6 lib/high_five/thor/task.rb
high_five-0.2.5 lib/high_five/thor/task.rb
high_five-0.2.4 lib/high_five/thor/task.rb
high_five-0.2.3 lib/high_five/thor/task.rb
high_five-0.2.2 lib/high_five/thor/task.rb
high_five-0.2.1 lib/high_five/thor/task.rb
high_five-0.2.0 lib/high_five/thor/task.rb