class Nabokov::Syncer

Attributes

git_repo[R]
nabokovfile[R]

Public Class Methods

new(argv) click to toggle source
Calls superclass method Nabokov::Runner::new
# File lib/nabokov/commands/syncers/syncer.rb, line 15
def initialize(argv)
  nabokovfile = argv.option("nabokovfile")
  unless nabokovfile
    pwd_nabokovfile = Pathname.pwd + "Nabokovfile.yaml"
    nabokovfile = pwd_nabokovfile if File.exist?(pwd_nabokovfile)
  end
  raise "--nabokovfile is a required parameter and could not be nil" if nabokovfile.nil?

  @nabokovfile_path = nabokovfile if File.exist?(nabokovfile)
  super
end
options() click to toggle source
Calls superclass method
# File lib/nabokov/commands/syncers/syncer.rb, line 34
def self.options
  [
    ["--nabokovfile=<path/to/nabokovfile>", "The location of your Nabokovfile"]
  ].concat(super)
end

Public Instance Methods

checkout_master_branch() click to toggle source
# File lib/nabokov/commands/syncers/syncer.rb, line 63
def checkout_master_branch
  ui.say("Checkout master branch...") if self.verbose
  @git_repo.checkout_branch(@nabokovfile.localizations_repo_master_branch)
end
init_git_repo() click to toggle source
# File lib/nabokov/commands/syncers/syncer.rb, line 51
def init_git_repo
  @git_repo = GitRepo.new(@nabokovfile.localizations_repo_local_path, @nabokovfile.localizations_repo_url)
  if Dir.exist?(@git_repo.local_path)
    ui.say("Found existed repo at #{@git_repo.local_path}...") if self.verbose
    @git_repo.init
  else
    ui.say("Cloning the localization repo from #{@git_repo.remote_url} into #{@git_repo.local_path}...") if self.verbose
    @git_repo.clone
  end
  checkout_master_branch
end
initialize_nabokov_file() click to toggle source
# File lib/nabokov/commands/syncers/syncer.rb, line 46
def initialize_nabokov_file
  @nabokovfile = Nabokovfile.new(@nabokovfile_path)
  ui.say("Hooray, your Nabokovfile is valid...") if self.verbose
end
run() click to toggle source
# File lib/nabokov/commands/syncers/syncer.rb, line 40
def run
  initialize_nabokov_file
  init_git_repo
  self
end
validate!() click to toggle source
Calls superclass method
# File lib/nabokov/commands/syncers/syncer.rb, line 27
def validate!
  super
  if self.class == Syncer && !@nabokovfile_path
    help! "Could not find a Nabokovfile."
  end
end