Sha256: 5b6be82ef77eaf9a78e2bf0739fc810160a9bd74d8f6d7b4c8f1506d370af2ec

Contents?: true

Size: 867 Bytes

Versions: 4

Compression:

Stored size: 867 Bytes

Contents

module Resource

  class Base

    include ::BlockAttr
    include ::ClassAttr

    # Access child's class_name statically
    class_attr :class_name

    # This resource should be executed always??
    # *boolean*
    block_attr :always_run

    # Setup class name
    def self.inherited name
      @class_name = name
    end

    # Translate octal to decimal modes
    def unix_mode
      @mode.to_i.to_s(8)
    end

    # Configure default settings for any resource
    def set_base_defaults
      @not_if     = false
      @owner      = 'root'
      @always_run = false
    end

    def not_if condition = nil, &block
      if condition.is_a?(String)
        if system(condition)
          @not_if = true
        end
      end
      if block_given? && yield
        @not_if = true
      end
    end

    def should_skip?
      @not_if == true
    end

  end

end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
atesta-0.0.4 lib/resource/base.rb
atesta-0.0.3 lib/resource/base.rb
atesta-0.0.2 lib/resource/base.rb
atesta-0.0.1 lib/resource/base.rb