git_multicast 0.0.5 → 0.0.6
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 +4 -4
- data/.rubocop.yml +11 -0
- data/Gemfile.lock +17 -1
- data/README.md +3 -3
- data/git_multicast.gemspec +29 -18
- data/lib/git_multicast/.rubocop.yml +11 -0
- data/lib/git_multicast/adapters/bitbucket.rb +35 -0
- data/lib/git_multicast/adapters/github.rb +17 -0
- data/lib/git_multicast/adapters.rb +5 -0
- data/lib/git_multicast/cli.rb +9 -2
- data/lib/git_multicast/cloner.rb +3 -3
- data/lib/git_multicast/output_formatter.rb +12 -10
- data/lib/git_multicast/repository_fetcher/bitbucket.rb +34 -0
- data/lib/git_multicast/repository_fetcher/github.rb +25 -0
- data/lib/git_multicast/repository_fetcher.rb +33 -14
- data/lib/git_multicast/version.rb +1 -1
- data/lib/git_multicast.rb +1 -3
- data/spec/fixtures/vcr_cassettes/bitbucket_all_user_repos.yml +170 -0
- data/spec/fixtures/vcr_cassettes/bitbucket_repo.yml +79 -0
- data/spec/fixtures/vcr_cassettes/github_all_user_repos.yml +107 -0
- data/spec/fixtures/vcr_cassettes/github_repo.yml +77 -0
- data/spec/fixtures/vcr_cassettes/github_repo_parent.yml +79 -0
- data/spec/fixtures/vcr_cassettes/repos_from_all_services.yml +274 -0
- data/spec/git_multicast/adapters/bitbucket_spec.rb +25 -0
- data/spec/git_multicast/puller_spec.rb +4 -0
- data/spec/git_multicast/repository_fetcher/bitbucket_spec.rb +80 -0
- data/spec/git_multicast/repository_fetcher/github_spec.rb +81 -0
- data/spec/git_multicast/repository_fetcher_spec.rb +101 -18
- data/spec/spec_helper.rb +5 -3
- metadata +76 -9
- data/lib/git_multicast/bitbucket_adapter.rb +0 -33
- data/lib/git_multicast/bitbucket_fetcher.rb +0 -36
- data/lib/git_multicast/github_fetcher.rb +0 -31
- data/spec/git_multicast/bitbucket_adapter_spec.rb +0 -25
- data/spec/git_multicast/bitbucket_fetcher_spec.rb +0 -97
- data/spec/git_multicast/github_fetcher_spec.rb +0 -74
@@ -1,97 +0,0 @@
|
|
1
|
-
describe GitMulticast::BitbucketFetcher do
|
2
|
-
subject(:fetcher) { described_class }
|
3
|
-
|
4
|
-
let(:uri) { URI(url) }
|
5
|
-
let(:response) { instance_double(Net::HTTPResponse) }
|
6
|
-
let(:body) do
|
7
|
-
'{ "values": [\
|
8
|
-
{ "links": { "clone": "I be a body" } },\
|
9
|
-
{ "links": { "clone": "I be other body" } }\
|
10
|
-
]}'
|
11
|
-
end
|
12
|
-
|
13
|
-
let(:json) do
|
14
|
-
{ 'values' =>
|
15
|
-
[
|
16
|
-
{ 'links' => { 'clone' => 'I be a body' } },
|
17
|
-
{ 'links' => { 'clone' => 'I be other body' } }
|
18
|
-
]
|
19
|
-
}
|
20
|
-
end
|
21
|
-
|
22
|
-
let(:adapter) do
|
23
|
-
instance_double(GitMulticast::BitbucketAdapter, adapt: adapted_repo)
|
24
|
-
end
|
25
|
-
let(:adapted_repo) { double(:adapted_repo) }
|
26
|
-
|
27
|
-
before do
|
28
|
-
allow(JSON).to receive(:parse).and_return(json)
|
29
|
-
|
30
|
-
allow(Net::HTTP).to receive(:get_response).and_return(response)
|
31
|
-
allow(response).to receive(:body).and_return(body)
|
32
|
-
|
33
|
-
allow(GitMulticast::BitbucketAdapter).to receive(:new).and_return(adapter)
|
34
|
-
end
|
35
|
-
|
36
|
-
describe '.get_repo' do
|
37
|
-
subject(:get_repo) { fetcher.get_repo(url) }
|
38
|
-
|
39
|
-
let(:url) { 'http://example.com/foo/bar/33' }
|
40
|
-
|
41
|
-
it 'calls http get' do
|
42
|
-
expect(Net::HTTP).to receive(:get_response).with(uri)
|
43
|
-
|
44
|
-
get_repo
|
45
|
-
end
|
46
|
-
|
47
|
-
it 'parses the resulting json' do
|
48
|
-
expect(JSON).to receive(:parse).with(body)
|
49
|
-
|
50
|
-
get_repo
|
51
|
-
end
|
52
|
-
|
53
|
-
it 'makes a struct with the result body' do
|
54
|
-
expect(RecursiveOpenStruct).to receive(:new).with(
|
55
|
-
json, recurse_over_arrays: true
|
56
|
-
)
|
57
|
-
|
58
|
-
get_repo
|
59
|
-
end
|
60
|
-
|
61
|
-
it 'adapts result to the standard interface' do
|
62
|
-
expect(adapter).to receive(:adapt)
|
63
|
-
is_expected.to eq(adapted_repo)
|
64
|
-
end
|
65
|
-
end
|
66
|
-
|
67
|
-
describe '.get_all_repos_from_user' do
|
68
|
-
subject(:get_all_repos_from_user) { fetcher.get_all_repos_from_user(user) }
|
69
|
-
|
70
|
-
let(:user) { 'mrwhite' }
|
71
|
-
let(:url) { 'https://bitbucket.org/api/2.0/repositories/mrwhite' }
|
72
|
-
|
73
|
-
it 'calls http get' do
|
74
|
-
expect(Net::HTTP).to receive(:get_response).with(uri)
|
75
|
-
|
76
|
-
get_all_repos_from_user
|
77
|
-
end
|
78
|
-
|
79
|
-
it 'parses the resulting json' do
|
80
|
-
expect(JSON).to receive(:parse).with(body)
|
81
|
-
|
82
|
-
get_all_repos_from_user
|
83
|
-
end
|
84
|
-
|
85
|
-
it 'builds each repository as a RecursiveOpenStruct' do
|
86
|
-
expect(RecursiveOpenStruct).to receive(:new).twice
|
87
|
-
|
88
|
-
get_all_repos_from_user
|
89
|
-
end
|
90
|
-
|
91
|
-
it 'adapts each struct' do
|
92
|
-
expect(adapter).to receive(:adapt).twice
|
93
|
-
|
94
|
-
get_all_repos_from_user
|
95
|
-
end
|
96
|
-
end
|
97
|
-
end
|
@@ -1,74 +0,0 @@
|
|
1
|
-
describe GitMulticast::GithubFetcher do
|
2
|
-
subject(:fetcher) { described_class }
|
3
|
-
|
4
|
-
let(:uri) { URI(url) }
|
5
|
-
let(:response) { instance_double(Net::HTTPResponse) }
|
6
|
-
let(:body) { '{"value": "I be a body", "b": "c"}' }
|
7
|
-
|
8
|
-
let(:json) { { 'value' => 'I be a body', 'b' => 'c' } }
|
9
|
-
|
10
|
-
before do
|
11
|
-
allow(JSON).to receive(:parse).and_return(json)
|
12
|
-
|
13
|
-
allow(Net::HTTP).to receive(:get_response).and_return(response)
|
14
|
-
allow(response).to receive(:body).and_return(body)
|
15
|
-
end
|
16
|
-
|
17
|
-
describe '.get_repo' do
|
18
|
-
subject(:get_repo) { fetcher.get_repo(url) }
|
19
|
-
|
20
|
-
let(:url) { 'http://example.com/foo/bar/33' }
|
21
|
-
|
22
|
-
it 'calls http get' do
|
23
|
-
expect(Net::HTTP).to receive(:get_response).with(uri)
|
24
|
-
|
25
|
-
get_repo
|
26
|
-
end
|
27
|
-
|
28
|
-
it 'parses the resulting json' do
|
29
|
-
expect(JSON).to receive(:parse).with(body)
|
30
|
-
|
31
|
-
get_repo
|
32
|
-
end
|
33
|
-
|
34
|
-
it 'Makes a struct with the result body' do
|
35
|
-
expect(RecursiveOpenStruct).to receive(:new).with(
|
36
|
-
json, recurse_over_arrays: true
|
37
|
-
)
|
38
|
-
|
39
|
-
get_repo
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
describe '.get_all_repos_from_user' do
|
44
|
-
subject(:get_all_repos_from_user) { fetcher.get_all_repos_from_user(user) }
|
45
|
-
|
46
|
-
let(:user) { 'mrwhite' }
|
47
|
-
let(:url) { 'https://api.github.com/users/mrwhite/repos' }
|
48
|
-
|
49
|
-
let(:json) do
|
50
|
-
[
|
51
|
-
{ 'value' => 'I be a body' },
|
52
|
-
{ 'b' => 'c' }
|
53
|
-
]
|
54
|
-
end
|
55
|
-
|
56
|
-
it 'calls http get' do
|
57
|
-
expect(Net::HTTP).to receive(:get_response).with(uri)
|
58
|
-
|
59
|
-
get_all_repos_from_user
|
60
|
-
end
|
61
|
-
|
62
|
-
it 'parses the resulting json' do
|
63
|
-
expect(JSON).to receive(:parse).with(body)
|
64
|
-
|
65
|
-
get_all_repos_from_user
|
66
|
-
end
|
67
|
-
|
68
|
-
it 'builds each repository as an OpenStruct' do
|
69
|
-
expect(RecursiveOpenStruct).to receive(:new).twice
|
70
|
-
|
71
|
-
get_all_repos_from_user
|
72
|
-
end
|
73
|
-
end
|
74
|
-
end
|