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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d75b90927be1866e18b536c5f39f2b86c18d7ed7
4
- data.tar.gz: e822130015caa3e56725a21067779f8bceddbac1
3
+ metadata.gz: 01d4bc8b6fcd92dd763ef3636193814bc43f9e94
4
+ data.tar.gz: 17854f76b472eaaf82e054ab9bdc4d9def5e1970
5
5
  SHA512:
6
- metadata.gz: cacd6c947f89ce14c1ac19dcc6aaa15454ab9668d9629549665ab8cefe48154636e75d3e08b29685c639dfc2043c90e93c7338ee87f2fd91784126fc6d331951
7
- data.tar.gz: 2f2ed25c97b7efdd3423d30d02224ec18eb4ae16c10e831f94a58844a8d5809b1a3d2fe37a91b00f9636b3ac16c34a717146e3a42910b3f176b506afc90e54b0
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
@@ -12,7 +12,7 @@ module Asgit
12
12
  end
13
13
 
14
14
  def fetch service
15
- registered.fetch(service) do
15
+ registered.fetch(service.to_sym) do
16
16
  raise UndefinedService, "undefined service #{service}"
17
17
  end
18
18
  end
@@ -5,7 +5,7 @@ module Asgit
5
5
  register_as :github
6
6
 
7
7
  def base_url
8
- "https://github.com"
8
+ details.base_url || "https://github.com"
9
9
  end
10
10
 
11
11
  def base_structure
@@ -8,6 +8,12 @@ module Asgit
8
8
  end
9
9
  end
10
10
 
11
+ attr_reader :details
12
+
13
+ def initialize(details)
14
+ @details = details
15
+ end
16
+
11
17
  [ :base_url, :base_structure,
12
18
  :commit_uri, :branch_uri, :file_uri,
13
19
  :file_at_commit_uri, :compare_uri
data/lib/asgit/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Asgit
2
- VERSION = "0.2.1"
2
+ VERSION = "0.3.0"
3
3
  end
@@ -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
@@ -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.2.1
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-02-19 00:00:00.000000000 Z
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