class Bookbinder::Commands::UpdateLocalDocRepos

Attributes

configuration_fetcher[R]
streams[R]
version_control_system[R]

Public Class Methods

new(streams, configuration_fetcher, version_control_system) click to toggle source
# File lib/bookbinder/commands/update_local_doc_repos.rb, line 6
def initialize(streams, configuration_fetcher, version_control_system)
  @streams = streams
  @configuration_fetcher = configuration_fetcher
  @version_control_system = version_control_system
end

Public Instance Methods

run() click to toggle source
# File lib/bookbinder/commands/update_local_doc_repos.rb, line 12
def run
  urls = configuration_fetcher.fetch_config.sections.map(&:repo_url)
  paths(urls).each do |path|
    streams[:out] << "\nUpdating #{path}:"
    report(version_control_system.update(path))
  end
  streams[:out].puts
  0
end

Private Instance Methods

paths(urls) click to toggle source
# File lib/bookbinder/commands/update_local_doc_repos.rb, line 37
def paths(urls)
  urls.map {|url| File.absolute_path("../#{Ingest::DestinationDirectory.new(url)}")}
end
report(result) click to toggle source
# File lib/bookbinder/commands/update_local_doc_repos.rb, line 28
def report(result)
  messages = { true => "updated", false => "skipping (#{result.reason})" }
  streams[stream_types[result.success?]] << " #{messages[result.success?]}"
end
stream_types() click to toggle source
# File lib/bookbinder/commands/update_local_doc_repos.rb, line 33
def stream_types
  { true => :success, false => :out }
end