Module: Rpub::FilesystemSource

Defined in:
lib/rpub/filesystem_source.rb

Class Method Summary (collapse)

Class Method Details

+ (Boolean) exists?(filename)

Returns:

  • (Boolean)


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

def exists?(filename)
  File.exists?(filename)
end

+ (Object) force_write(filename, content)



28
29
30
# File 'lib/rpub/filesystem_source.rb', line 28

def force_write(filename, content)
  write filename, content, true
end

+ (Object) own_or_support_file(filename)



42
43
44
45
# File 'lib/rpub/filesystem_source.rb', line 42

def own_or_support_file(filename)
  return filename if exists?(filename)
  Rpub.support_file(filename)
end

+ (Object) read(filename)



5
6
7
# File 'lib/rpub/filesystem_source.rb', line 5

def read(filename)
  File.read(filename)
end

+ (Object) remove(filename, dry_run = false)



32
33
34
35
36
37
38
39
40
# File 'lib/rpub/filesystem_source.rb', line 32

def remove(filename, dry_run = false)
  if File.exist?(filename)
    if dry_run
      puts filename
    else
      File.unlink(filename)
    end
  end
end

+ (Object) source_files



13
14
15
# File 'lib/rpub/filesystem_source.rb', line 13

def source_files
  Dir['*{.md,.markdown,.mdown,.markd}']
end

+ (Object) write(filename, content, force = false)



17
18
19
20
21
22
23
24
25
26
# File 'lib/rpub/filesystem_source.rb', line 17

def write(filename, content, force = false)
  return if content.nil?
  if !force && File.exist?(filename)
    warn "Not overriding #{filename}"
    return
  end
  File.open(filename, 'w') do |f|
    f.write content
  end
end