Class: Decoct::Dscript

Inherits:
Object
  • Object
show all
Includes:
Dmeta
Defined in:
lib/dscript.rb

Constant Summary

Constants included from Dconstants

Decoct::Dconstants::LIB, Decoct::Dconstants::PUBLIC, Decoct::Dconstants::SPEC, Decoct::Dconstants::TEMPLATES, Decoct::Dconstants::VIEWS

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Dmeta

#copy_file, included

Constructor Details

#initialize(app_name) ⇒ Dscript

Returns a new instance of Dscript.



13
14
15
16
# File 'lib/dscript.rb', line 13

def initialize(app_name)
  fail "app name cannot be nil or empty!!!" if app_name.eql?(nil) || app_name.empty?
  @app_name = app_name      
end

Instance Attribute Details

#app_nameObject

Returns the value of attribute app_name.



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

def app_name
  @app_name
end

Instance Method Details

#copy_app_fileObject



48
49
50
51
# File 'lib/dscript.rb', line 48

def copy_app_file
  copy_file("generic_app.rb", "#{app_name}#{File::SEPARATOR}#{app_name}.rb")
  puts "Copied application file" 
end

#copy_autotest_fileObject



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

def copy_autotest_file
  copy_file(".autotest", "#{app_name}#{File::SEPARATOR}.autotest")
  puts "Copied autotest files" 
end

#copy_iconsObject



53
54
55
56
57
58
# File 'lib/dscript.rb', line 53

def copy_icons
  from = ["icons#{File::SEPARATOR}fail.png", "icons#{File::SEPARATOR}ok.png"]
  to = [ "#{app_name}#{File::SEPARATOR}icons#{File::SEPARATOR}fail.png",  "#{app_name}#{File::SEPARATOR}icons#{File::SEPARATOR}ok.png"]
  copy_file(from, to)
  puts "Copied icons" 
end

#copy_rspec_filesObject



41
42
43
44
45
46
# File 'lib/dscript.rb', line 41

def copy_rspec_files
	from = ["spec#{File::SEPARATOR}spec.opts", "spec#{File::SEPARATOR}rcov.opts", "spec#{File::SEPARATOR}spec_helper.rb", "spec#{File::SEPARATOR}app_spec.rb"]
	to = ["#{app_name}#{File::SEPARATOR}spec#{File::SEPARATOR}spec.opts", "#{app_name}#{File::SEPARATOR}spec#{File::SEPARATOR}rcov.opts", "#{app_name}#{File::SEPARATOR}spec#{File::SEPARATOR}spec_helper.rb", "#{app_name}#{File::SEPARATOR}spec#{File::SEPARATOR}#{app_name}_spec.rb"]
	copy_file(from, to)
	puts "Copied rspec files" 
end

#create_app_dirObject



31
32
33
34
# File 'lib/dscript.rb', line 31

def create_app_dir
  Dir.mkdir("#{app_name}") if !test(?d, "#{app_name}")
  puts "Created application directory - #{app_name}"
end

#runObject



18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/dscript.rb', line 18

def run
  create_app_dir
  create_lib
  create_spec
  create_views
  create_public
  create_icons
  copy_autotest_file
  copy_rspec_files
  copy_app_file
  copy_icons
end