Sha256: f5752019d2b3b882b7ba1f2e4756b0341c824e86a7bf5ec85fcd54b100de85fc
Contents?: true
Size: 917 Bytes
Versions: 10
Compression:
Stored size: 917 Bytes
Contents
require 'active_support/core_ext/string' module Anvil class Task # Methods for inferring task class names from cli arguments module Naming def get_namespace(task_name) task_name.to_s.split ':' end # Returns a ruby class from a CLI name # # @param task_name [String] the CLI name for a task e.g. anvil:build # @return [Class] an {Anvil::Task} descendant def from_name(task_name) namespaced_task = get_namespace task_name camelized_task = "#{namespaced_task.pop}_task".camelize camelized_namespace = "#{namespaced_task.shift}".camelize "#{camelized_namespace}::#{camelized_task}".constantize end def task_name name[/(.*)Task/, 1].underscore.gsub('/', ':') end def description(str = nil) return @description unless str @description = str end end end end
Version data entries
10 entries across 10 versions & 1 rubygems