Class: ProjectBuilder
- Inherits:
-
Object
- Object
- ProjectBuilder
- Defined in:
- lib/fox/library/project_builder.rb
Constant Summary collapse
- TEMPLATES =
{ :exe => <<-EOT #!/usr/bin/ruby -w require 'rubygems' require 'commandline require '%name%' class %name.capitalize%App < CommandLine::Application def initialize end def main end end#class %name.capitalize%App EOT }
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Class Method Summary collapse
-
.load(project_name, dsl) ⇒ Object
of def create_project }}}.
Instance Method Summary collapse
- #create_project ⇒ Object
-
#dir(dir_name) ⇒ Object
of def self.load }}}.
-
#initialize(name) ⇒ ProjectBuilder
constructor
A new instance of ProjectBuilder.
-
#touch(*file_names) ⇒ Object
of def dir }}}.
Constructor Details
#initialize(name) ⇒ ProjectBuilder
Returns a new instance of ProjectBuilder.
34 35 36 37 38 39 40 41 42 |
# File 'lib/fox/library/project_builder.rb', line 34 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 |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
13 14 15 |
# File 'lib/fox/library/project_builder.rb', line 13 def name @name end |
Class Method Details
.load(project_name, dsl) ⇒ Object
of def create_project }}}
48 49 50 51 52 |
# File 'lib/fox/library/project_builder.rb', line 48 def self.load project_name, dsl proj = new( project_name ) proj = proj.instance_eval( File.read(dsl), dsl ) proj end |
Instance Method Details
#create_project ⇒ Object
44 45 46 |
# File 'lib/fox/library/project_builder.rb', line 44 def create_project yield end |
#dir(dir_name) ⇒ Object
of def self.load }}}
54 55 56 57 58 59 60 61 |
# File 'lib/fox/library/project_builder.rb', line 54 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 }}}
63 64 65 66 67 |
# File 'lib/fox/library/project_builder.rb', line 63 def touch *file_names file_names.flatten.each do |file| FileUtils.touch( File.join(@cwd, "#{file}") ) end end |