Class: Casket

Inherits:
Object
  • Object
show all
Defined in:
lib/casket.rb

Instance Method Summary collapse

Constructor Details

#initializeCasket

Initializes enivironment configuration. Constructor of Cascet instance.



8
9
10
11
# File 'lib/casket.rb', line 8

def initialize
  @fs = File::SEPARATOR
  @ext = "casket"
end

Instance Method Details

#bundleObject

Method running “bundle instal” on application.



41
42
43
44
# File 'lib/casket.rb', line 41

def bundle
  Dir.chdir @temp_dir
  system("bundle install")
end

#closeObject

Method that removes temporary files from system temp.



36
37
38
# File 'lib/casket.rb', line 36

def close
  FileUtils.rm_rf @temp_dir
end

#pack(directory_path) ⇒ Object

Method that checks directory and packs it into a package. It uses tar algorithm. Parameter directory_path points on directory to pack.



15
16
17
18
19
20
21
22
# File 'lib/casket.rb', line 15

def pack directory_path
  Dir.chdir directory_path
  name = Dir.pwd.split(@fs).last
  files = Dir.glob "**#{@fs}*"
  File.open([name, @ext].join("."), "wb") do |tar|
    Minitar.pack(files, tar)
  end
end

#rakeObject

Method running “rake” on application.



47
48
49
50
# File 'lib/casket.rb', line 47

def rake
  Dir.chdir @temp_dir
  system("rake")
end

#unpack(file_path) ⇒ Object

Method that unpacks Casket package to system temporary directory. Parameter file_path points on Casket package.



26
27
28
29
30
31
32
33
# File 'lib/casket.rb', line 26

def unpack file_path
  name = file_path.split(@fs).last
  Dir.chdir Dir.tmpdir
  Dir.mkdir name
  Minitar.unpack(file_path, name)
  Dir.chdir name
  @temp_dir = Dir.pwd
end