Class: Gonzui::FileFetcher
Class Method Summary
collapse
Instance Method Summary
collapse
#add_finishing_proc, #exclude?, #finish, #package_name
Methods included from Util
assert, assert_equal, assert_equal_all, assert_non_nil, assert_not_reached, benchmark, command_exist?, commify, eprintf, format_bytes, program_name, protect_from_signals, require_command, set_verbosity, shell_escape, unix?, vprintf, windows?, wprintf
Constructor Details
#initialize(config, source_uri, options) ⇒ FileFetcher
Returns a new instance of FileFetcher.
101
102
103
104
105
106
107
108
|
# File 'lib/gonzui/fetcher.rb', line 101
def initialize(config, source_uri, options)
super(config, source_uri, options)
begin
File.ftype(source_uri.path)
rescue => e
raise FetchFailed.new(e.message)
end
end
|
Class Method Details
.scheme ⇒ Object
97
98
99
|
# File 'lib/gonzui/fetcher.rb', line 97
def self.scheme
"file"
end
|
Instance Method Details
#collect ⇒ Object
131
132
133
134
135
136
137
138
139
140
|
# File 'lib/gonzui/fetcher.rb', line 131
def collect
directory = @base_uri.path
relative_paths = []
Dir.all_files(directory).map {|file_name|
next if exclude?(file_name)
relative_path = File.relative_path(file_name, directory)
relative_paths.push(relative_path)
}
return relative_paths
end
|
#fetch(relative_path) ⇒ Object
124
125
126
127
128
129
|
# File 'lib/gonzui/fetcher.rb', line 124
def fetch(relative_path)
path = restore_path(relative_path)
content = File.read(path)
mtime = File.mtime(path)
return Content.new(content, mtime, path)
end
|
120
121
122
|
# File 'lib/gonzui/fetcher.rb', line 120
def
return Extractor.new(@config, @source_uri.path)
end
|
116
117
118
|
# File 'lib/gonzui/fetcher.rb', line 116
def
not File.directory?(@source_uri.path)
end
|