Module: Crawling

Defined in:
lib/crawling.rb,
lib/crawling/version.rb

Defined Under Namespace

Classes: Instance, Store

Constant Summary collapse

HOME_PARENT_DIR =

path to repository for user(s)

'home'
SYSTEM_PARENT_DIR =

path to repository for the system

'system'
N_LINES_DIFF_CONTEXT =
3
VERSION =
"0.3.3"

Class Method Summary collapse

Class Method Details

.child_files_recursive(path) ⇒ Object



14
15
16
# File 'lib/crawling.rb', line 14

def self.child_files_recursive path
  Dir.glob("#{path}/**/*", File::FNM_DOTMATCH).reject(&File.method(:directory?))
end

.copy_file(src_file, dest_file) ⇒ Object

Like File.cp but also creates the parent directory at destination if it doesn’t exist



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

def self.copy_file src_file, dest_file
  dest_parent_dir = File.dirname dest_file
  FileUtils.mkdir_p dest_parent_dir unless Dir.exist? dest_parent_dir
  begin
    FileUtils.cp(src_file, dest_file)
  rescue
    raise "could not copy from #{src_file} to #{dest_file}"
  end
end

.relative_path_to(target, relative_to) ⇒ Object

relative_to must be an absolute Pathname



19
20
21
# File 'lib/crawling.rb', line 19

def self.relative_path_to target, relative_to
  Pathname.new(target).expand_path.relative_path_from relative_to
end