Class: ProjectBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/fox/library/project_builder.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name) ⇒ ProjectBuilder

Returns a new instance of ProjectBuilder.



14
15
16
17
18
19
20
21
22
# File 'lib/fox/library/project_builder.rb', line 14

def initialize name
  @name           = name
  @top_level_dir  = Dir.pwd
  @project_dir    = File.join(@top_level_dir, @name)

  FileUtils.mkdir_p( @project_dir )

  @cwd            = @project_dir
end

Class Method Details

.load(project_name, dsl) ⇒ Object



24
25
26
27
28
# File 'lib/fox/library/project_builder.rb', line 24

def self.load project_name, dsl
  proj = new( project_name )
  proj = proj.instance_eval( File.read(dsl), dsl )
  proj
end

Instance Method Details

#create_projectObject



31
32
33
# File 'lib/fox/library/project_builder.rb', line 31

def create_project
  yield
end

#dir(dir_name) ⇒ Object

of def create_project }}}



35
36
37
38
39
40
41
42
# File 'lib/fox/library/project_builder.rb', line 35

def dir dir_name
  old_cwd = @cwd
  @cwd    = File.join(@cwd, dir_name)
  FileUtils.mkdir_p(@cwd)
  yield self if block_given?
ensure
  @cwd = old_cwd
end

#touch(*file_names) ⇒ Object

of def dir }}}



44
45
46
47
48
# File 'lib/fox/library/project_builder.rb', line 44

def touch *file_names
  file_names.flatten.each do |file|
    FileUtils.touch( File.join(@cwd, "#{file}") )
  end
end