asgit 0.2.1 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/asgit/project.rb +3 -5
- data/lib/asgit/services.rb +1 -1
- data/lib/asgit/services/github.rb +1 -1
- data/lib/asgit/services/service.rb +6 -0
- data/lib/asgit/version.rb +1 -1
- data/spec/lib/asgit/project_spec.rb +3 -1
- data/spec/lib/asgit/services_spec.rb +16 -1
- data/spec/lib/asgit/url_spec.rb +20 -3
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 01d4bc8b6fcd92dd763ef3636193814bc43f9e94
|
4
|
+
data.tar.gz: 17854f76b472eaaf82e054ab9bdc4d9def5e1970
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1daa1878102ef11b1124f089d8cfa7b977d3030c6b878358123857fde7d0e6bc50e2e9c878f929f50ad982da609b2b62ba43198aecd1879685402f03d2216b25
|
7
|
+
data.tar.gz: 48a3795503735215a0836714c47b06e45fbeaad3748aa380449105279f69cdfaefe286eef74f021d3eec7ca43031de9bc6737ad19c442662658f44c72caa7189
|
data/lib/asgit/project.rb
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
module Asgit
|
2
2
|
class Project
|
3
3
|
|
4
|
+
Details = Struct.new :service, :organization, :project, :default_branch, :base_url
|
5
|
+
|
4
6
|
def initialize project_details={}
|
5
7
|
project_details.each do |k,v|
|
6
8
|
begin
|
@@ -16,16 +18,12 @@ module Asgit
|
|
16
18
|
end
|
17
19
|
|
18
20
|
def service
|
19
|
-
@_service ||= Services.fetch( details.service ).new
|
21
|
+
@_service ||= Services.fetch( details.service ).new( details )
|
20
22
|
end
|
21
23
|
|
22
24
|
def urls
|
23
25
|
@_urls ||= Url.new details, service
|
24
26
|
end
|
25
27
|
|
26
|
-
class Details
|
27
|
-
attr_accessor :service, :organization, :project, :default_branch
|
28
|
-
end
|
29
|
-
|
30
28
|
end
|
31
29
|
end
|
data/lib/asgit/services.rb
CHANGED
data/lib/asgit/version.rb
CHANGED
@@ -7,7 +7,8 @@ describe Asgit::Project do
|
|
7
7
|
service: :github,
|
8
8
|
organization: 'stevenosloan',
|
9
9
|
project: 'asgit',
|
10
|
-
default_branch: 'master'
|
10
|
+
default_branch: 'master',
|
11
|
+
base_url: "https://my.repo.url"
|
11
12
|
}
|
12
13
|
end
|
13
14
|
|
@@ -22,6 +23,7 @@ describe Asgit::Project do
|
|
22
23
|
expect( details_double ).to receive(:organization=).with('stevenosloan')
|
23
24
|
expect( details_double ).to receive(:project=).with('asgit')
|
24
25
|
expect( details_double ).to receive(:default_branch=).with('master')
|
26
|
+
expect( details_double ).to receive(:base_url=).with('https://my.repo.url')
|
25
27
|
|
26
28
|
described_class.new( default_details )
|
27
29
|
end
|
@@ -24,7 +24,6 @@ describe Asgit::Services do
|
|
24
24
|
end
|
25
25
|
|
26
26
|
describe "::register" do
|
27
|
-
|
28
27
|
it "adds a service to the registered" do
|
29
28
|
expect{ described_class.register(Foo,:foo) }.to change{ Asgit::Services.registered.keys.count }.by(1)
|
30
29
|
end
|
@@ -46,6 +45,22 @@ describe Asgit::Services do
|
|
46
45
|
described_class.fetch(:foo)
|
47
46
|
}.to raise_error Asgit::Services::UndefinedService
|
48
47
|
end
|
48
|
+
|
49
|
+
it "finds services if string given" do
|
50
|
+
described_class.register( Foo, :github )
|
51
|
+
expect( described_class.fetch('github') ).to eq Foo
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
|
57
|
+
describe Asgit::Services::Service do
|
58
|
+
|
59
|
+
describe "#initialize" do
|
60
|
+
it "sets given details to #details" do
|
61
|
+
details_double = instance_double("Asgit::Project::Details")
|
62
|
+
expect( described_class.new(details_double).details ).to eq details_double
|
63
|
+
end
|
49
64
|
end
|
50
65
|
|
51
66
|
end
|
data/spec/lib/asgit/url_spec.rb
CHANGED
@@ -8,13 +8,14 @@ describe Asgit::Url do
|
|
8
8
|
end
|
9
9
|
end
|
10
10
|
|
11
|
-
let(:service) { Asgit::Services.fetch(:github).new.dup }
|
12
|
-
let(:null_service) { Asgit::Services.fetch(:null).new.dup }
|
11
|
+
let(:service) { Asgit::Services.fetch(:github).new(details).dup }
|
12
|
+
let(:null_service) { Asgit::Services.fetch(:null).new(details).dup }
|
13
13
|
let(:details) do
|
14
14
|
instance_double( "Asgit::Project::Details",
|
15
15
|
organization: 'stevenosloan',
|
16
16
|
project: 'asgit',
|
17
|
-
default_branch: 'master'
|
17
|
+
default_branch: 'master',
|
18
|
+
base_url: nil
|
18
19
|
)
|
19
20
|
end
|
20
21
|
|
@@ -32,6 +33,22 @@ describe Asgit::Url do
|
|
32
33
|
it "returns expected url" do
|
33
34
|
expect( subject.project ).to eq 'https://github.com/stevenosloan/asgit'
|
34
35
|
end
|
36
|
+
|
37
|
+
context "with configured base_url" do
|
38
|
+
let(:details) do
|
39
|
+
instance_double( "Asgit::Project::Details",
|
40
|
+
organization: 'stevenosloan',
|
41
|
+
project: 'asgit',
|
42
|
+
default_branch: 'master',
|
43
|
+
base_url: "https://enterprise.github.com"
|
44
|
+
)
|
45
|
+
end
|
46
|
+
|
47
|
+
it "returns expected url" do
|
48
|
+
expect( subject.project ).to eq 'https://enterprise.github.com/stevenosloan/asgit'
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
35
52
|
it "raises MissingUrlStructure if service doesn't implement #base_structure" do
|
36
53
|
expect{
|
37
54
|
null_subject.project
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: asgit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Steven Sloan
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-04-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: here_or_there
|