Class: Gonzui::AbstractFetcher

Inherits:
Object
  • Object
show all
Includes:
Util
Defined in:
lib/gonzui/fetcher.rb

Instance Method Summary collapse

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 = {}) ⇒ AbstractFetcher

Returns a new instance of AbstractFetcher.



54
55
56
57
58
59
60
# File 'lib/gonzui/fetcher.rb', line 54

def initialize(config, source_uri, options = {})
  @config = config
  @source_uri = source_uri
  @exclude_pattern = (options[:exclude_pattern] or @config.exclude_pattern)
  @finishing_procs = []
  @base_uri = source_uri
end

Instance Method Details

#add_finishing_proc(proc) ⇒ Object



63
64
65
# File 'lib/gonzui/fetcher.rb', line 63

def add_finishing_proc (proc)
  @finishing_procs.push(proc)
end

#collectObject

Raises:

  • (NotImplementedError)


67
68
69
# File 'lib/gonzui/fetcher.rb', line 67

def collect
  raise NotImplementedError.new
end

#exclude?(relative_path) ⇒ Boolean

Returns:

  • (Boolean)


71
72
73
# File 'lib/gonzui/fetcher.rb', line 71

def exclude?(relative_path)
  @exclude_pattern.match(relative_path)
end

#fetch(relative_path) ⇒ Object

Raises:

  • (NotImplementedError)


75
76
77
# File 'lib/gonzui/fetcher.rb', line 75

def fetch(relative_path)
  raise NotImplementedError.new
end

#finishObject



79
80
81
# File 'lib/gonzui/fetcher.rb', line 79

def finish
  @finishing_procs.each {|proc| proc.call }
end

#get_extractorObject

Raises:

  • (NotImplementedError)


83
84
85
# File 'lib/gonzui/fetcher.rb', line 83

def get_extractor
  raise NotImplementedError.new
end

#need_extraction?Boolean

Returns:

  • (Boolean)

Raises:

  • (NotImplementedError)


87
88
89
# File 'lib/gonzui/fetcher.rb', line 87

def need_extraction?
  raise NotImplementedError.new
end

#package_nameObject



91
92
93
# File 'lib/gonzui/fetcher.rb', line 91

def package_name
  File.basename(@base_uri.path)
end