Class: WebServerConfigGenerator::Pathname

Inherits:
Pathname
  • Object
show all
Defined in:
lib/web_server_config_generator/pathname.rb

Direct Known Subclasses

ProjectDirectory

Instance Method Summary collapse

Instance Method Details

#+(other) ⇒ Object



3
4
5
6
# File 'lib/web_server_config_generator/pathname.rb', line 3

def +(other)
  other = self.class.new(other) unless self.class === other
  self.class.new(plus(@path, other.to_s))
end

#mkpathObject



8
9
10
11
12
13
14
# File 'lib/web_server_config_generator/pathname.rb', line 8

def mkpath
  if $TEST_MODE
    puts "test mode: mkpath #{self}"
  else
    super
  end
end

#readObject



25
26
27
28
29
30
31
# File 'lib/web_server_config_generator/pathname.rb', line 25

def read
  if self.exist?
    self.open("r") { |f| f.read }
  else
    ""
  end
end

#write(arg) ⇒ Object



16
17
18
19
20
21
22
23
# File 'lib/web_server_config_generator/pathname.rb', line 16

def write(arg)
  if $TEST_MODE
    puts "test mode: write #{self}, #{arg.to_s[0, 100]}..."
  else
    FileUtils.mkdir_p File.dirname(self)
    self.open("w") { |f| f.write arg }
  end
end