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

Inherits:
BaseTool show all
Defined in:
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:



31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/kamaze/project/tools/packager.rb', line 31

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



51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/kamaze/project/tools/packager.rb', line 51

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



29
30
31
# File 'lib/kamaze/project/tools/packager.rb', line 29

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)


47
48
49
# File 'lib/kamaze/project/tools/packager.rb', line 47

def initialized?
  @initialized
end

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

Returns:

  • (Boolean)


65
66
67
68
69
70
71
72
73
74
75
# File 'lib/kamaze/project/tools/packager.rb', line 65

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