Class: Dicker::Build

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

Instance Method Summary collapse

Constructor Details

#initialize(project, source_dir) ⇒ Build

Returns a new instance of Build.



5
6
7
8
# File 'lib/dicker/build.rb', line 5

def initialize(project, source_dir)
  @project = project
  @source_dir = source_dir
end

Instance Method Details

#buildObject



10
11
12
13
# File 'lib/dicker/build.rb', line 10

def build
  self.copy_files
  self.init_git
end

#copy_filesObject



20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/dicker/build.rb', line 20

def copy_files
Find.find("#{@source_dir}") do |source|
  target = source.sub(/^#{@source_dir}/, @project)
  if File.directory? source
    Find.prune if File.basename(source) == '.git'
    FileUtils.mkdir target unless File.exists? target
  else
    FileUtils.copy source, target
    puts "Copying #{source}"
  end
end
end

#init_gitObject



15
16
17
18
# File 'lib/dicker/build.rb', line 15

def init_git
  Dir.chdir @project
  system('git init')
end