git_multicast 0.0.7 → 0.0.8

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: e2d0bdfccafad675de94f29e53e2b85e9cad62b1
4
- data.tar.gz: fc56b9016cf59f35856aed2c677cd6819af66a14
3
+ metadata.gz: a88114b607c36efdb71e8a3ab4434a9be536a64d
4
+ data.tar.gz: 66adbc427e63be01db1dc6acdba5691131ad66dc
5
5
  SHA512:
6
- metadata.gz: c28ef49cf18cd09198685d1305b7d21efbc1867b0bf533ae1d1567543ecb90242e748d3ed9977e71983d1f08e1047491caab3e5463316e09a8bc86fba4959a63
7
- data.tar.gz: 436daa09aaffc718d6f7e6a59840ca658c2f675a7c1c96b237032b425fcd5e041b4b3c2a76574fb11c56efe4f72aa430b7547aa62ff5b3a4de8dd3cd5068adf5
6
+ metadata.gz: aca164e70a06e11308990ccf341358370ae9a89eefa3e7f4e679c2fb307c2152d18df904ca8c463268edcced7827eb5b16c1d89ab6da8264bd1e286952091853
7
+ data.tar.gz: 4e9e56f128245aa1ce104f5ac2686ed2f9343d44f7579bc25b4f4452c845af50846c3d815ad6a4d476f474c1aee226e04130fbbc9ac71d1f3f3c20365a09febc
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- git_multicast (0.0.7)
4
+ git_multicast (0.0.8.pre)
5
5
  recursive-open-struct (~> 0.5.0)
6
6
  thor (~> 0.19)
7
7
 
data/README.md CHANGED
@@ -1,3 +1,5 @@
1
+ [![git_multicast API Documentation](https://www.omniref.com/ruby/gems/git_multicast.png)](https://www.omniref.com/ruby/gems/git_multicast)
2
+
1
3
  # Multicast your git actions.
2
4
 
3
5
  Have you ever need to clone a whole bunch of repositories? Have you forgot to pull remote changes?
@@ -16,6 +16,11 @@ module GitMulticast
16
16
  Cloner.new(username, Dir.pwd).clone!
17
17
  end
18
18
 
19
+ desc 'git_multicast status', 'Shows status for each repository'
20
+ def status
21
+ Statuser.new(Dir.pwd).get_statuses
22
+ end
23
+
19
24
  desc 'git_multicast version', 'Shows currently installed version'
20
25
  def version
21
26
  puts GitMulticast::VERSION
@@ -0,0 +1,42 @@
1
+ module GitMulticast
2
+ class Statuser
3
+ include Process
4
+
5
+ attr_reader :dir
6
+
7
+ def initialize(dir)
8
+ @dir = dir
9
+ end
10
+
11
+ def get_statuses
12
+ start_time = Time.now
13
+ output_status_zip = statuses
14
+
15
+ OutputFormatter.format(output_status_zip, start_time)
16
+ end
17
+
18
+ def statuses
19
+ dirs = Dir.entries(dir)
20
+ .select { |f| File.directory? f }
21
+ .reject { |f| f =~ /^\./ } # ., .. and .git and the like
22
+
23
+ streams = dirs.map do |dir|
24
+ r, w = IO.pipe
25
+ w.write("Repo: #{dir}\n")
26
+ spawn("cd #{dir} && git status", out: w, err: w)
27
+ [r, w]
28
+ end
29
+ _, statuses = waitall.transpose
30
+
31
+ output = read_output(streams)
32
+ output.zip(statuses)
33
+ end
34
+
35
+ def read_output(streams)
36
+ streams.map do |r, w|
37
+ w.close unless w.closed?
38
+ r.read
39
+ end
40
+ end
41
+ end
42
+ end
@@ -1,3 +1,3 @@
1
1
  module GitMulticast
2
- VERSION = '0.0.7'
2
+ VERSION = '0.0.8'
3
3
  end
data/lib/git_multicast.rb CHANGED
@@ -2,6 +2,7 @@ require_relative 'git_multicast/version'
2
2
  require_relative 'git_multicast/cloner'
3
3
  require_relative 'git_multicast/puller'
4
4
  require_relative 'git_multicast/output_formatter'
5
+ require_relative 'git_multicast/statuser'
5
6
 
6
7
  require_relative 'git_multicast/adapters'
7
8
  require_relative 'git_multicast/repository_fetcher'
@@ -0,0 +1,44 @@
1
+ module GitMulticast
2
+ describe Statuser do
3
+ subject(:statuser) { described_class.new(dir) }
4
+
5
+ let(:dir) { '/ki/fita/' }
6
+ let(:entries) { ['fita1', 'fita2'] }
7
+
8
+ let(:pipe) { IO.pipe }
9
+ let(:r) { pipe.first }
10
+ let(:w) { pipe[1] }
11
+
12
+ before do
13
+ $stdout = StringIO.new
14
+
15
+ allow(statuser).to receive(:spawn).and_return(nil)
16
+ allow(statuser).to receive(:waitall).and_return(
17
+ [[nil, double(:success, success?: true)]] * 32
18
+ )
19
+
20
+ allow(IO).to receive(:pipe).and_return([r, w])
21
+ allow(File).to receive(:directory?).and_return(true)
22
+ allow(Dir).to receive(:entries).and_return(entries)
23
+
24
+ allow(OutputFormatter).to receive(:format)
25
+ end
26
+
27
+ after do
28
+ $stdout = STDOUT
29
+ end
30
+
31
+ describe '#get_statuses' do
32
+ subject(:get_statuses) { statuser.get_statuses }
33
+
34
+ it 'spawns a clone job for each repo' do
35
+ entries.each do |entry|
36
+ expect(statuser).to receive(:spawn)
37
+ .with("cd #{entry} && git status", out: w, err: w)
38
+ end
39
+
40
+ get_statuses
41
+ end
42
+ end
43
+ end
44
+ 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.0.7
4
+ version: 0.0.8
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-09-14 00:00:00.000000000 Z
11
+ date: 2014-09-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: recursive-open-struct
@@ -180,6 +180,7 @@ files:
180
180
  - lib/git_multicast/repository_fetcher.rb
181
181
  - lib/git_multicast/repository_fetcher/bitbucket.rb
182
182
  - lib/git_multicast/repository_fetcher/github.rb
183
+ - lib/git_multicast/statuser.rb
183
184
  - lib/git_multicast/version.rb
184
185
  - spec/fixtures/vcr_cassettes/bitbucket_all_user_repos.yml
185
186
  - spec/fixtures/vcr_cassettes/bitbucket_repo.yml
@@ -194,6 +195,7 @@ files:
194
195
  - spec/git_multicast/repository_fetcher/bitbucket_spec.rb
195
196
  - spec/git_multicast/repository_fetcher/github_spec.rb
196
197
  - spec/git_multicast/repository_fetcher_spec.rb
198
+ - spec/git_multicast/statuser_spec.rb
197
199
  - spec/spec_helper.rb
198
200
  homepage: http://github.com/rranelli/git_multicast
199
201
  licenses: