git_multicast 0.2.0 → 0.3.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: e05ac031d27eae835462ae840eaf7e0bcdb188bd
4
- data.tar.gz: 12cd3e8e2e5ca64546bccc77bacdf0513bbd73b2
3
+ metadata.gz: fcd2ce8c7a7c7b5c661a85f2cc4f6eb9d4160cd0
4
+ data.tar.gz: 2078820519daa9dbad320b526a841d51d576016a
5
5
  SHA512:
6
- metadata.gz: 7dfbeb2fc26d6986b771b9a9ecf604653f8c17882499e01b67bd5e6470e550cac6b28c1ba3f556275040ac91073db6a848c379f30ff70a74f2b60f2311de2127
7
- data.tar.gz: 2e53d5c76dfa85e8e656a67668a2d1b516a9f020436deb2e6bea54dcffe30f7cc890f0213ca8b57da4dc4ed19d9074d6734180238b9be6ddd6db67c157e21a4d
6
+ metadata.gz: 3122aad848355fb6ea23aaaa6f5108cb090b5b9a7fc6dd22b6742a8b5759f7c786a4938dffd1bd38dd5e82834ae532f9100b106860809dfc56b5a34f1dbdd284
7
+ data.tar.gz: 3886bb80fce62fbd54790536cf2d04cde3dc2b45905058686162627335744cb1c21a81948f18ef8c8c90d6599eec25c3bc145eec14a7ca70bfbde333cb3e0a39
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- git_multicast (0.2.0)
4
+ git_multicast (0.3.0)
5
5
  colorize (~> 0.7)
6
6
  recursive-open-struct (~> 0.5.0)
7
7
  thor (~> 0.19)
@@ -4,7 +4,7 @@ require 'git_multicast'
4
4
 
5
5
  module GitMulticast
6
6
  class Cli < Thor
7
- class_option :version, :type => :boolean
7
+ class_option :version, type: :boolean
8
8
 
9
9
  desc 'git_multicast pull', 'Git pulls all repositories contained in\
10
10
  current directory.'
@@ -18,6 +18,18 @@ module GitMulticast
18
18
  end
19
19
  end
20
20
 
21
+ desc 'git_multicast cast :command', 'Casts custom command to all git\
22
+ repositories in current directory.'
23
+ option :quiet, type: :boolean
24
+ option :verbose, type: :boolean
25
+ def cast(command)
26
+ if formatter
27
+ puts multicaster(:generic).new(Dir.pwd, command, formatter).execute!
28
+ else
29
+ puts multicaster(:generic).new(Dir.pwd, command).execute!
30
+ end
31
+ end
32
+
21
33
  desc 'git_multicast clone :username', 'Git clone all repositories\
22
34
  for given username.'
23
35
  option :quiet, type: :boolean
@@ -35,7 +47,7 @@ module GitMulticast
35
47
  puts multicaster(:status).new(Dir.pwd).execute!
36
48
  end
37
49
 
38
- desc "version", "Show thor_app version"
50
+ desc 'version', 'Show thor_app version'
39
51
  def version
40
52
  puts GitMulticast::VERSION
41
53
  end
@@ -1,4 +1,5 @@
1
1
  require_relative 'multicaster/clone'
2
+ require_relative 'multicaster/generic'
2
3
  require_relative 'multicaster/pull'
3
4
  require_relative 'multicaster/status'
4
5
 
@@ -0,0 +1,31 @@
1
+ module GitMulticast
2
+ class Multicaster
3
+ class Generic < Multicaster
4
+ def initialize(dir, command, formatter = Formatter::Standard.new(Time.now))
5
+ @dir = dir
6
+ @command = command
7
+
8
+ super(formatter)
9
+ end
10
+
11
+ protected
12
+
13
+ attr_reader :dir
14
+
15
+ def tasks
16
+ Dir.entries(dir)
17
+ .select { |f| File.directory? f }
18
+ .reject { |f| f =~ /^\./ } # ., .. and .git and the like
19
+ .map { |dir| Task.new(description(dir), command(dir)) }
20
+ end
21
+
22
+ def command(dir)
23
+ "git -C #{dir} #{@command}"
24
+ end
25
+
26
+ def description(dir)
27
+ File.basename(dir)
28
+ end
29
+ end
30
+ end
31
+ end
@@ -1,29 +1,8 @@
1
1
  module GitMulticast
2
2
  class Multicaster
3
- class Pull < Multicaster
3
+ class Pull < Generic
4
4
  def initialize(dir, formatter = Formatter::Standard.new(Time.now))
5
- @dir = dir
6
-
7
- super(formatter)
8
- end
9
-
10
- protected
11
-
12
- attr_reader :dir
13
-
14
- def tasks
15
- Dir.entries(dir)
16
- .select { |f| File.directory? f }
17
- .reject { |f| f =~ /^\./ } # ., .. and .git and the like
18
- .map { |dir| Task.new(description(dir), command(dir)) }
19
- end
20
-
21
- def command(dir)
22
- "git -C #{dir} pull -r origin"
23
- end
24
-
25
- def description(dir)
26
- File.basename(dir)
5
+ super(dir, 'pull -r origin', formatter)
27
6
  end
28
7
  end
29
8
  end
@@ -1,3 +1,3 @@
1
1
  module GitMulticast
2
- VERSION = '0.2.0'
2
+ VERSION = '0.3.0'
3
3
  end
@@ -43,5 +43,15 @@ module GitMulticast
43
43
  clone
44
44
  end
45
45
  end
46
+
47
+ describe '#cast' do
48
+ subject(:cast) { cli.cast('some command') }
49
+
50
+ it do
51
+ expect(Multicaster::Generic).to receive_message_chain(:new, :execute!)
52
+
53
+ cast
54
+ end
55
+ end
46
56
  end
47
57
  end
@@ -0,0 +1,43 @@
1
+ module GitMulticast
2
+ class Multicaster
3
+ describe Generic do
4
+ subject(:generic) { described_class.new(dir, command) }
5
+
6
+ let(:dir) { '/home/' }
7
+ let(:entries) { %w(one two) }
8
+
9
+ let(:task) { instance_double(Task, call: result) }
10
+ let(:result) { Task::Result.new('fitas', 'success', 0) }
11
+
12
+ let(:command) { 'pull -r origin' }
13
+
14
+ before do
15
+ allow(File).to receive(:directory?).and_return(true)
16
+ allow(Dir).to receive(:entries).and_return(entries)
17
+
18
+ allow(Task).to receive(:new)
19
+ .and_return(task)
20
+ end
21
+
22
+ describe '#execute!' do
23
+ subject(:execute!) { generic.execute! }
24
+
25
+ it 'creates a task for each repository' do
26
+ entries.each do |entry|
27
+ expect(Task).to receive(:new)
28
+ .with(entry, "git -C #{entry} pull -r origin")
29
+ end
30
+
31
+ execute!
32
+ end
33
+
34
+ it 'runs tasks using a runner' do
35
+ expect(Task::Runner).to receive(:new)
36
+ .with([task, task]).and_call_original
37
+
38
+ execute!
39
+ end
40
+ end
41
+ end
42
+ end
43
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: git_multicast
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Renan Ranelli
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-12-10 00:00:00.000000000 Z
11
+ date: 2014-12-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: recursive-open-struct
@@ -210,6 +210,7 @@ files:
210
210
  - lib/git_multicast/formatter/status.rb
211
211
  - lib/git_multicast/multicaster.rb
212
212
  - lib/git_multicast/multicaster/clone.rb
213
+ - lib/git_multicast/multicaster/generic.rb
213
214
  - lib/git_multicast/multicaster/pull.rb
214
215
  - lib/git_multicast/multicaster/status.rb
215
216
  - lib/git_multicast/repository_fetcher.rb
@@ -233,6 +234,7 @@ files:
233
234
  - spec/git_multicast/formatter/standard_spec.rb
234
235
  - spec/git_multicast/formatter/status_spec.rb
235
236
  - spec/git_multicast/multicaster/clone_spec.rb
237
+ - spec/git_multicast/multicaster/generic_spec.rb
236
238
  - spec/git_multicast/multicaster/pull_spec.rb
237
239
  - spec/git_multicast/multicaster/status_spec.rb
238
240
  - spec/git_multicast/repository_fetcher/bitbucket_spec.rb