Class: CG::Scratch

Inherits:
Object
  • Object
show all
Includes:
FileUtils
Defined in:
lib/cg/scratch.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeScratch

Returns a new instance of Scratch.



11
12
13
# File 'lib/cg/scratch.rb', line 11

def initialize
  @site = ARGV.first || 'example'
end

Class Method Details

.start!Object



15
16
17
# File 'lib/cg/scratch.rb', line 15

def self.start!
  new.start
end

Instance Method Details

#dir_exists?(name) ⇒ Boolean

Returns:

  • (Boolean)


24
25
26
27
28
29
30
31
# File 'lib/cg/scratch.rb', line 24

def dir_exists?(name)
  begin
    cd(name) { }
    true
  rescue Errno::ENOENT
    false
  end
end

#startObject



19
20
21
22
# File 'lib/cg/scratch.rb', line 19

def start
  mkdir(@site) unless dir_exists?(@site)
  cp_r(Dir.glob(SKEL_PATH + '/{*,.exclude}'), @site)
end