Module: WDI::Folder

Defined in:
lib/wdi/folder.rb

Class Method Summary collapse

Class Method Details

.create(remove_current_directory) ⇒ Object

Raises:



15
16
17
18
19
20
21
22
23
# File 'lib/wdi/folder.rb', line 15

def self.create(remove_current_directory)
  self.remove! if remove_current_directory

  raise WDI::FolderError, \
    "The .wdi folder already exists. Either remove it to initialize anew, " + \
    "or use `wdi config` to edit the config file."  if self.exists?

  Dir.mkdir self.path
end

.create_with_config(remove_current_directory, file) ⇒ Object



25
26
27
28
# File 'lib/wdi/folder.rb', line 25

def self.create_with_config(remove_current_directory, file)
  self.create(remove_current_directory)
  WDI::Config::create(file)
end

.exists?Boolean

Returns:

  • (Boolean)


11
12
13
# File 'lib/wdi/folder.rb', line 11

def self.exists?
  File.exists?(self.path)
end

.pathObject



7
8
9
# File 'lib/wdi/folder.rb', line 7

def self.path
  File.expand_path(".wdi", "~")
end

.remove!Object



30
31
32
# File 'lib/wdi/folder.rb', line 30

def self.remove!
  FileUtils.rm_rf(self.path) if self.exists?
end