Class: Kamaze::Project::Tools::Packager Abstract

Inherits:
BaseTool show all
Defined in:
lib/kamaze/project/tools/packager.rb,
lib/kamaze/project/tools/packager.rb

Overview

This class is abstract.

Provides a packager

Packager is intended to provide basic packaging operations

Direct Known Subclasses

Gemspec::Packager

Defined Under Namespace

Classes: Filesystem

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize {|_self| ... } ⇒ Packager

Returns a new instance of Packager.

Yields:

  • (_self)

Yield Parameters:



41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/kamaze/project/tools/packager.rb', line 41

def initialize
  @initialized = false
  # fs mutable attributes are accessibles during initialization
  # @see method_missing
  @fs = Filesystem.new

  yield self if block_given?

  super

  @initialized = true
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *args, &block) ⇒ Object



61
62
63
64
65
66
67
68
69
70
71
72
73
# File 'lib/kamaze/project/tools/packager.rb', line 61

def method_missing(method, *args, &block)
  if respond_to_missing?(method)
    unless initialized?
      mutable = fs.mutable_attribute?(method)

      return fs.__send__(method, *args, &block) if mutable
    end

    return fs.public_send(method, *args, &block)
  end

  super
end

Instance Attribute Details

#fsKamaze::Project::Tools::Packager::Filesystem (readonly)

Get filesystem



39
40
41
# File 'lib/kamaze/project/tools/packager.rb', line 39

def fs
  @fs
end

#observer_peersHash|nil (readonly, protected) Originally defined in module Concern::Observable

Returns:

  • (Hash|nil)

Instance Method Details

#initialized?Boolean

Denote class is initialized

Returns:

  • (Boolean)


57
58
59
# File 'lib/kamaze/project/tools/packager.rb', line 57

def initialized?
  @initialized
end

#respond_to_missing?(method, include_private = false) ⇒ Boolean

Returns:

  • (Boolean)


75
76
77
78
79
80
81
82
83
84
85
# File 'lib/kamaze/project/tools/packager.rb', line 75

def respond_to_missing?(method, include_private = false)
  if method.to_s[-1] == '='
    unless initialized?
      return true if fs.mutable_attribute?(method)
    end
  end

  return true if fs.respond_to?(method, include_private)

  super(method, include_private)
end