Sha256: fc9d351cf93c24ffdb56e11cb5cebe2ca3f2c8cf0a42ca623b972d15b22b0f78

Contents?: true

Size: 673 Bytes

Versions: 3

Compression:

Stored size: 673 Bytes

Contents

require 'active_support/core_ext/string'

module Anvil
  class Task
    module Naming
      def get_namespace(task_name)
        task_name.to_s.split ':'
      end

      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

3 entries across 3 versions & 1 rubygems

Version Path
anvil-core-0.0.1.pre.alpha.3 lib/anvil/task/naming.rb
anvil-core-0.0.1.pre.alpha.2 lib/anvil/task/naming.rb
anvil-core-0.0.1.alpha.1 lib/anvil/task/naming.rb