Class: Pullable::Processor
- Inherits:
-
Object
- Object
- Pullable::Processor
- Defined in:
- lib/pullable/processor.rb
Constant Summary collapse
- CONFIG_FILE =
".pullable.yml"
Instance Attribute Summary collapse
-
#directory ⇒ Object
readonly
Returns the value of attribute directory.
-
#method ⇒ Object
readonly
Returns the value of attribute method.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Class Method Summary collapse
Instance Method Summary collapse
- #command ⇒ Object
-
#initialize(method, directory, options = {}) ⇒ Processor
constructor
A new instance of Processor.
- #mirror!(options = {}) ⇒ Object
- #run(command) ⇒ Object
- #update!(options = {}) ⇒ Object
Constructor Details
#initialize(method, directory, options = {}) ⇒ Processor
Returns a new instance of Processor.
9 10 11 12 13 |
# File 'lib/pullable/processor.rb', line 9 def initialize(method, directory, = {}) @method = method @directory = directory @options = end |
Instance Attribute Details
#directory ⇒ Object (readonly)
Returns the value of attribute directory.
7 8 9 |
# File 'lib/pullable/processor.rb', line 7 def directory @directory end |
#method ⇒ Object (readonly)
Returns the value of attribute method.
7 8 9 |
# File 'lib/pullable/processor.rb', line 7 def method @method end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
7 8 9 |
# File 'lib/pullable/processor.rb', line 7 def @options end |
Class Method Details
.update!(method, directory) ⇒ Object
15 16 17 18 19 20 21 22 23 24 |
# File 'lib/pullable/processor.rb', line 15 def self.update!(method, directory) = File.exists?(CONFIG_FILE) ? YAML.load(File.read(CONFIG_FILE)) : {} processor = new(method, directory, ) if processor.['mirror'] processor.mirror!() else processor.update!() end end |
Instance Method Details
#command ⇒ Object
40 41 42 43 44 45 46 47 48 49 |
# File 'lib/pullable/processor.rb', line 40 def command case method when 'merge' 'git merge --ff-only origin/master' when 'pull' 'git pull origin master' else raise NotImplementedError end end |
#mirror!(options = {}) ⇒ Object
26 27 28 29 |
# File 'lib/pullable/processor.rb', line 26 def mirror!( = {}) remote = ['mirror']['remote'] rescue 'upstream' run "git pull #{remote} master && git push origin master" end |
#run(command) ⇒ Object
35 36 37 38 |
# File 'lib/pullable/processor.rb', line 35 def run(command) puts "Updating:\t#{directory}" system "#{command} > /dev/null" end |
#update!(options = {}) ⇒ Object
31 32 33 |
# File 'lib/pullable/processor.rb', line 31 def update!( = {}) run "git fetch -p && #{command}" end |