Module: Jem::Build

Defined in:
lib/jem/build.rb

Class Method Summary collapse

Class Method Details

.build(project_name) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/jem/build.rb', line 12

def Build.build project_name
  return puts "Please specify a project name." if project_name == nil 
  
  if !File.exists? project_name
    print "* Building structure in directory: #{project_name}/\n" 
    options = {:verbose => true}
    print "\t=> " 
    FileUtils.mkdir_p File.expand_path(project_name) + '/lib/' + File.basename(project_name), options
    FileUtils.cd project_name
    print "\t=> " 
    FileUtils.mkdir %w(test docs examples bin), options
    print "\t=> " 
    FileUtils.touch %w(LICENCE README CHANGELOG VERSION Rakefile), options
    project_name = File.basename(project_name)
    print "\t=> " 
    FileUtils.touch project_name + '.gemspec', options
    FileUtils.cd 'lib' 
    print "\t=> " 
    FileUtils.touch project_name + '.rb', options
    puts "* Done."
  else
    print "Directory \"#{project_name}\" already exists.\n"
  end
end

.command_line_optionsObject



37
38
39
40
41
42
43
# File 'lib/jem/build.rb', line 37

def Build.command_line_options
  opts = Trollop::options do
    opt :build, "Initialise directory structure.E.g. jem --build project_name."
    opt :help,  "You're here."
  end
  return opts
end

.execute(project_name) ⇒ Object



8
9
10
# File 'lib/jem/build.rb', line 8

def Build.execute project_name
  build project_name[0] if command_line_options[:build] 
end