Module: Metc::Filelib

Defined in:
lib/metc/filelib.rb

Class Method Summary collapse

Class Method Details

.create_directory(name) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/metc/filelib.rb', line 5

def self.create_directory(name)

  unless name.nil?

    if File.directory?(name)
      puts "directory already exists"
    else
      FileUtils.mkdir_p(name)
      puts "directory #{name} created".green
    end

  end

end

.create_file(text, filename) ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/metc/filelib.rb', line 20

def self.create_file( text, filename )

  filename = File.basename( filename, File.extname(filename) ) + HTMLEXT

  reply = true

  if File.exists?(filename)
    reply = ask("file #{filename} exists, overwrite?")
  end

  if reply

    f = File.open( filename, "w" )
    f.write(text)
    f.close

    puts "file #{filename} created".green

  end

end

.get_contentsObject



48
49
50
51
52
# File 'lib/metc/filelib.rb', line 48

def self.get_contents()

  return Dir.glob( Metc::MARKDOWN, File::FNM_CASEFOLD )

end

.get_templatesObject



42
43
44
45
46
# File 'lib/metc/filelib.rb', line 42

def self.get_templates()

  return Dir.glob( Metc::HAML, File::FNM_CASEFOLD )

end