Sha256: 6d04e9cac479c53106234e2fff975948ce62f94c020c71973bf6269685d584e3

Contents?: true

Size: 991 Bytes

Versions: 6

Compression:

Stored size: 991 Bytes

Contents

module LogicalConstruct
  class UnpackCookbook < Mattock::TaskLib
    def default_namespace
      :cookbook
    end

    def default_settings(provision)
      settings(
        :construct_dir => provision.construct_dir,
        :cookbook_metadata => nil,
        :cookbook_dir => nil,
        :cookbook_name => "cookbook",
        :cookbook_archive => nil
      )
    end

    def resolve_settings
      self.cookbook_archive ||= File::join(construct_dir, "cookbook.tbz")
      self.cookbook_dir ||= File::join(construct_dir, cookbook_name)

      self.cookbook_metadata ||= File::join(cookbook_dir, "metadata.rb")
    end

    def untar_command
      Mattock::CommandLine.new("tar", "-xjf") do |cmd|
        cmd.options << cookbook_archive
      end
    end

    def define
      in_namespace do
        file cookbook_archive
        file cookbook_metadata => cookbook_archive do
          untar_command.run
        end
        task :unpack => cookbook_metadata
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
logical-construct-0.0.5 lib/logical-construct/target/unpack-cookbook.rb
logical-construct-0.0.4 lib/logical-construct/target/unpack-cookbook.rb
logical-construct-0.0.3 lib/logical-construct/target/unpack-cookbook.rb
logical-construct-0.0.2 lib/logical-construct/target/unpack-cookbook.rb
logical-construct-0.0.1 lib/logical-construct/target/unpack-cookbook.rb
logical-construct-0.0.1.localtesting lib/logical-construct/target/unpack-cookbook.rb