class Pullable::Processor
Constants
- CONFIG_FILE
Attributes
branch[R]
directory[R]
method[R]
options[R]
Public Class Methods
new(method, directory, options = {})
click to toggle source
# File lib/pullable/processor.rb, line 9 def initialize(method, directory, options = {}) @method = method @directory = directory @options = options @branch = `git rev-parse --abbrev-ref HEAD` || 'master' end
update!(method, directory)
click to toggle source
# File lib/pullable/processor.rb, line 17 def self.update!(method, directory) options = File.exists?(CONFIG_FILE) ? YAML.load(File.read(CONFIG_FILE)) : {} processor = new(method, directory, options) if processor.options['mirror'] processor.mirror!(options) else processor.update!(options) end end
Public Instance Methods
command()
click to toggle source
# File lib/pullable/processor.rb, line 42 def command case method when 'merge' "git merge --ff-only origin/#{branch}" when 'pull' "git pull origin #{branch}" else raise NotImplementedError end end
mirror!(options = {})
click to toggle source
# File lib/pullable/processor.rb, line 28 def mirror!(options = {}) remote = options['mirror']['remote'] rescue 'upstream' run "git pull #{remote} #{branch} && git push origin #{branch}" end
run(command)
click to toggle source
# File lib/pullable/processor.rb, line 37 def run(command) puts "Updating:\t#{directory}" system "#{command} > /dev/null" end
update!(options = {})
click to toggle source
# File lib/pullable/processor.rb, line 33 def update!(options = {}) run "git fetch -p && #{command}" end