class BrickAndMortar::Brick::Config

Attributes

destination[R]
location[R]
name[R]
version[R]

Public Class Methods

new(data, brick_store, verbose = true) click to toggle source
# File lib/brick_and_mortar/brick.rb, line 81
def initialize(data, brick_store, verbose = true)
  @name = data['name']
  @version = data['version']
  @location = Location.new(data['location'])
  @destination = File.join(brick_store, name_with_version)
  @verbose = verbose
end

Public Instance Methods

create!() click to toggle source
# File lib/brick_and_mortar/brick.rb, line 99
def create!
  if exists?
    if @verbose
      puts "Using #{name_with_version} in #{@destination}"
    end
  else
    case @location.method
    when 'git'
      if @verbose
        puts "Installing #{name_with_version} to #{@destination} from #{@location.path} with git"
      end
      Git.clone_repo(@location.path, @destination)
    when 'svn'
      if @verbose
        puts "Installing #{@name_with_version} to #{@destination} from #{@location.path} with svn"
      end
      Svn.checkout_repo(@location.path, @destination)
    when 'download'
      if @verbose
        puts "Installing #{@name_with_version} to #{@destination} from #{@location.path}"
      end
      if @location.format == Location::FORMATS[:zip]
        Download.get_and_unpack_zip(@location.path, @destination)
      elsif @location.format == Location::FORMATS[:tar_gz]
        Download.get_and_unpack_tar_gz(@location.path, @destination)
      elsif @location.format == Location::FORMATS[:tar_bz2]
        Download.get_and_unpack_tar_bz2(@location.path, @destination)
      else
        raise UnrecognizedFormat.new(@location.format)
      end
    when 'copy'
      if @verbose
        puts "Copying #{@name_with_version} to #{@destination} from #{@location.path}"
      end
      dir = File.dirname(@destination)
      FileUtils.mkdir_p(dir) unless File.directory?(dir)
      FileUtils.cp_r @location.path, @destination
    else
      raise UnrecognizedRetrievalMethod.new(@location.method)
    end
  end
end
destroy!() click to toggle source
# File lib/brick_and_mortar/brick.rb, line 153
def destroy!
  FileUtils.rm_rf @destination, {:secure => true}
end
exist?()
Alias for: exists?
exists?() click to toggle source
# File lib/brick_and_mortar/brick.rb, line 93
def exists?
  File.exist? @destination
end
Also aliased as: exist?
laid?(project_vendor_dir) click to toggle source
# File lib/brick_and_mortar/brick.rb, line 142
def laid?(project_vendor_dir)
  File.exist? File.join(project_vendor_dir, name)
end
lay!(project_vendor_dir) click to toggle source
# File lib/brick_and_mortar/brick.rb, line 146
def lay!(project_vendor_dir)
  create!
  unless laid?(project_vendor_dir)
    File.symlink @destination, File.join(project_vendor_dir, name)
  end
end
name_with_version() click to toggle source
# File lib/brick_and_mortar/brick.rb, line 89
def name_with_version
  "#{@name}-#{@version}"
end