Sha256: 6187a95c4589d580af79a014ae4a080057b5efab40803e8703ddc53148cb5ae3

Contents?: true

Size: 1.34 KB

Versions: 24

Compression:

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


      class << self
        def inherited(base) #:nodoc:
          base.send :extend,  ClassMethods
        end
      end

      no_tasks {
        def invoke(name=nil, *args)
          name.sub!(/^high_five:/, '') if name && $high_five_runner
          super
        end

        def base_config
          begin
            @base_config ||= HighFive::Config.load
          rescue StandardError => e
            raise e
            say e.message, :red
            exit
          end
        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

24 entries across 24 versions & 1 rubygems

Version Path
high_five-0.3.23 lib/high_five/thor/task.rb
high_five-0.3.22 lib/high_five/thor/task.rb
high_five-0.3.21 lib/high_five/thor/task.rb
high_five-0.3.20 lib/high_five/thor/task.rb
high_five-0.3.19 lib/high_five/thor/task.rb
high_five-0.3.18 lib/high_five/thor/task.rb
high_five-0.3.17 lib/high_five/thor/task.rb
high_five-0.3.16 lib/high_five/thor/task.rb
high_five-0.3.15 lib/high_five/thor/task.rb
high_five-0.3.14 lib/high_five/thor/task.rb
high_five-0.3.13 lib/high_five/thor/task.rb
high_five-0.3.12 lib/high_five/thor/task.rb
high_five-0.3.11 lib/high_five/thor/task.rb
high_five-0.3.10 lib/high_five/thor/task.rb
high_five-0.3.9 lib/high_five/thor/task.rb
high_five-0.3.8 lib/high_five/thor/task.rb
high_five-0.3.7 lib/high_five/thor/task.rb
high_five-0.3.6 lib/high_five/thor/task.rb
high_five-0.3.5 lib/high_five/thor/task.rb
high_five-0.3.4 lib/high_five/thor/task.rb