pullable 1.0.1 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ba1c8bbf6d383e5772d0cf55811f4afc961e3b63
4
- data.tar.gz: e83d49e8d69e26d12babda9ccf6778720372995d
3
+ metadata.gz: 2cf7eb1ec2b03ee87fbf43db2856d60fcb247b28
4
+ data.tar.gz: b0519adbb9ed78955ef46ebdadf52a99b0a03a91
5
5
  SHA512:
6
- metadata.gz: ab68f3c9aacd86de1e4fc6f349bbfba9867b0f8302dbe41cb6b1762bcd4c29cc85d6fae38cd2f159fc0db087269238ca7c315c7199ac9f8890e9e3353ee52726
7
- data.tar.gz: 66c727d42f2cfccd7ea70789fd64b2b341a6bb5caed73554a629c9103b919858d3c5277982ebc43850e7b0f81a7fa322b4d8bf9e75deb85f20aaa0aa83218bfe
6
+ metadata.gz: 727c6285d78c34db3998537947f36e675ff2af81f5d74837e441bccd2fe8911329e1dd2867bcc3df9ee7c617bdb517ae9391179bf1ce28ee5fe81837db9cd68b
7
+ data.tar.gz: 60bc1fb5276cd152858964259e6ab3d828aa2dda6acff14eac80bec698902359ed49df00cc33fce0a8f434e362f36e6fc88735e5ba94df25ef111df85746bad3
@@ -0,0 +1,2 @@
1
+ mirror:
2
+ remote: :upstream
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- ruby-2.0.0-p0
1
+ ruby-2.0.0-p247
@@ -27,9 +27,8 @@ module Pullable
27
27
  unless SKIPPED_DIRECTORIES.include?(directory)
28
28
  FileUtils.cd(directory)
29
29
 
30
- if File.directory?('.git')
31
- puts "Updated:\t#{directory}"
32
- update!
30
+ if Dir.exists?('.git')
31
+ Pullable::Processor.update!(method, directory)
33
32
  end
34
33
 
35
34
  FileUtils.cd(path)
@@ -42,19 +41,5 @@ module Pullable
42
41
  new(path, method).process!
43
42
  end
44
43
 
45
- def update!
46
- system "git fetch -p && #{command} > /dev/null"
47
- end
48
-
49
- def command
50
- case @method
51
- when 'merge'
52
- 'git merge --ff-only origin/master'
53
- when 'pull'
54
- 'git pull origin master'
55
- else
56
- raise NotImplementedError
57
- end
58
- end
59
44
  end
60
45
  end
@@ -0,0 +1,50 @@
1
+ require 'yaml'
2
+
3
+ class Pullable::Processor
4
+
5
+ CONFIG_FILE = ".pullable.yml"
6
+
7
+ attr_reader :method, :directory, :options
8
+
9
+ def initialize(method, directory, options = {})
10
+ @method = method
11
+ @directory = directory
12
+ @options = options
13
+ end
14
+
15
+ def self.update!(method, directory)
16
+ options = File.exists?(CONFIG_FILE) ? YAML.load(File.read(CONFIG_FILE)) : {}
17
+ processor = new(method, directory, options)
18
+
19
+ if processor.options['mirror']
20
+ processor.mirror!(options)
21
+ else
22
+ processor.update!(options)
23
+ end
24
+ end
25
+
26
+ def mirror!(options = {})
27
+ remote = options['mirror']['remote'] rescue 'upstream'
28
+ run "git pull #{remote} master && git push origin master"
29
+ end
30
+
31
+ def update!(options = {})
32
+ run "git fetch -p && #{command}"
33
+ end
34
+
35
+ def run(command)
36
+ puts "Updating:\t#{directory}"
37
+ system "#{command} > /dev/null"
38
+ end
39
+
40
+ def command
41
+ case method
42
+ when 'merge'
43
+ 'git merge --ff-only origin/master'
44
+ when 'pull'
45
+ 'git pull origin master'
46
+ else
47
+ raise NotImplementedError
48
+ end
49
+ end
50
+ end
@@ -1,3 +1,3 @@
1
1
  module Pullable
2
- VERSION = "1.0.1"
2
+ VERSION = "1.1.0"
3
3
  end
data/lib/pullable.rb CHANGED
@@ -1,4 +1,5 @@
1
1
  require 'pullable/directory'
2
+ require 'pullable/processor'
2
3
  require 'pullable/version'
3
4
 
4
5
  module Pullable
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pullable
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Duncan Grazier
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-09-06 00:00:00.000000000 Z
11
+ date: 2013-10-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -89,6 +89,7 @@ extensions: []
89
89
  extra_rdoc_files: []
90
90
  files:
91
91
  - .gitignore
92
+ - .pullable.yml.example
92
93
  - .rspec
93
94
  - .ruby-gemset
94
95
  - .ruby-version
@@ -100,6 +101,7 @@ files:
100
101
  - bin/pullable
101
102
  - lib/pullable.rb
102
103
  - lib/pullable/directory.rb
104
+ - lib/pullable/processor.rb
103
105
  - lib/pullable/version.rb
104
106
  - pullable.gemspec
105
107
  - spec/lib/pullable/directory_spec.rb
@@ -125,7 +127,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
125
127
  version: '0'
126
128
  requirements: []
127
129
  rubyforge_project:
128
- rubygems_version: 2.0.3
130
+ rubygems_version: 2.1.5
129
131
  signing_key:
130
132
  specification_version: 4
131
133
  summary: A simple tool to update your local repositories