Module: Crawling
- Defined in:
- lib/crawling.rb,
lib/crawling/version.rb
Defined Under Namespace
Constant Summary collapse
- N_LINES_DIFF_CONTEXT =
3- VERSION =
"0.3.5"
Class Method Summary collapse
- .child_files_recursive(path) ⇒ Object
-
.copy_file(src_file, dest_file) ⇒ Object
Like File.cp but also creates the parent directory at destination if it doesn’t exist.
-
.relative_path_to(target, relative_to) ⇒ Object
relative_to must be an absolute Pathname.
Class Method Details
.child_files_recursive(path) ⇒ Object
8 9 10 |
# File 'lib/crawling.rb', line 8 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
18 19 20 21 22 23 24 25 26 |
# File 'lib/crawling.rb', line 18 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
13 14 15 |
# File 'lib/crawling.rb', line 13 def self.relative_path_to target, relative_to Pathname.new(target)..relative_path_from relative_to end |