git_multicast 0.0.6 → 0.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5a9ce770391d551120cec8646c9960fc45aa7471
4
- data.tar.gz: ed4ac6bd223ad655bd0d83ed0ce3bd6576329354
3
+ metadata.gz: e2d0bdfccafad675de94f29e53e2b85e9cad62b1
4
+ data.tar.gz: fc56b9016cf59f35856aed2c677cd6819af66a14
5
5
  SHA512:
6
- metadata.gz: 56165a2911f3039b28111770c85bcc90445f622bc2ec1d24eb6fbb69b4f92f6dd4b6cf93865c94ef9bfab2c62d86755b7e7c991a3048d45831d53149ba1cb642
7
- data.tar.gz: fe5b862932a72ef2a505187d44f9ed51480abb60e55d4f7ee48765652983cd4471c4d2033562c1582c8d55bf68a742bb1761986d8e4cca9d7d9356027b4eedca
6
+ metadata.gz: c28ef49cf18cd09198685d1305b7d21efbc1867b0bf533ae1d1567543ecb90242e748d3ed9977e71983d1f08e1047491caab3e5463316e09a8bc86fba4959a63
7
+ data.tar.gz: 436daa09aaffc718d6f7e6a59840ca658c2f675a7c1c96b237032b425fcd5e041b4b3c2a76574fb11c56efe4f72aa430b7547aa62ff5b3a4de8dd3cd5068adf5
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- git_multicast (0.0.6.pre)
4
+ git_multicast (0.0.7)
5
5
  recursive-open-struct (~> 0.5.0)
6
6
  thor (~> 0.19)
7
7
 
@@ -1,5 +1,7 @@
1
1
  require_relative 'adapters/bitbucket'
2
2
  require_relative 'adapters/github'
3
3
 
4
- module Adapters
4
+ module GitMulticast
5
+ module Adapters
6
+ end
5
7
  end
@@ -13,9 +13,9 @@ module GitMulticast
13
13
  def clone!
14
14
  start_time = Time.now
15
15
  repos = RepositoryFetcher.get_all_repos_from_user(username)
16
- statuses = clone_em_all!(repos)
16
+ output_status_zip = clone_em_all!(repos)
17
17
 
18
- OutputFormatter.format(repos, statuses, start_time)
18
+ OutputFormatter.format(output_status_zip, start_time)
19
19
  end
20
20
 
21
21
  protected
@@ -23,10 +23,28 @@ module GitMulticast
23
23
  attr_reader :username, :dir
24
24
 
25
25
  def clone_em_all!(repos)
26
+ streams = spawn_processes(repos)
27
+
28
+ _, statuses = waitall.transpose
29
+
30
+ output = read_output(streams)
31
+ output.zip(statuses)
32
+ end
33
+
34
+ def spawn_processes(repos)
26
35
  repos.map do |repo|
27
- spawn(make_command(repo))
36
+ r, w = IO.pipe
37
+ w.write("Clonning: #{repo.name}\n")
38
+ spawn(make_command(repo), out: w, err: w)
39
+ [r, w]
40
+ end
41
+ end
42
+
43
+ def read_output(streams)
44
+ streams.map do |r, w|
45
+ w.close unless w.closed?
46
+ r.read
28
47
  end
29
- waitall.map { |_, status| status }
30
48
  end
31
49
 
32
50
  def make_command(repo)
@@ -1,16 +1,19 @@
1
1
  module GitMulticast
2
2
  class OutputFormatter
3
- def self.format(repos, statuses, start_time = nil)
4
- repo_status_pairs = repos.zip(statuses)
5
-
3
+ def self.format(output_status_zip, start_time = nil)
6
4
  # get successes and failures
7
- success_pairs = repo_status_pairs.select { |_, status| status.success? }
8
- failure_pairs = repo_status_pairs.reject { |_, status| status.success? }
5
+ success_pairs = output_status_zip.select { |_, status| status.success? }
6
+ failure_pairs = output_status_zip.reject { |_, status| status.success? }
9
7
 
10
- success_pairs.each { |repo, _| puts "#{repo.name} cloned successfully." }
11
- failure_pairs.each { |repo, _| puts "failure to clone #{repo.name}." }
8
+ success_pairs.each do |output, _|
9
+ puts(
10
+ "#{output} \nsuccess.\n" \
11
+ '=============================================='
12
+ )
13
+ end
14
+ failure_pairs.each { |output, _| puts "#{output}\nFAILURE!!" }
12
15
 
13
- puts '=========================================='
16
+ puts '#############################################'
14
17
  puts "Finished in #{Time.now - start_time} seconds." if start_time
15
18
  end
16
19
  end
@@ -1,3 +1,3 @@
1
1
  module GitMulticast
2
- VERSION = '0.0.6'
2
+ VERSION = '0.0.7'
3
3
  end