asgit 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/asgit/config.rb +7 -2
- data/lib/asgit/url.rb +1 -1
- data/lib/asgit/version.rb +1 -1
- data/spec/asgit/config_spec.rb +15 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cc550b94030a3e6bb0430a2880678522c6356cf2
|
4
|
+
data.tar.gz: cfa580b8bd83ac2a8b2f42abecb6ae6cb2d1d080
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d30037bfd83bffebb313c21ed15c826575fb24d469ff9378ab7a153f0bad396f1818a6aa54dc252e7639fd92c0aa0593f743057aa1e40fb6f69ebfa6481970d4
|
7
|
+
data.tar.gz: f32403eee3d40b47cf9ca4eacb67aa6f2259b18f88168db4ea352bc3e5389aa33914b20132ee84a16ba86e1e00685ea32b7a806ac14526e252bd6b5c6ca87635
|
data/lib/asgit/config.rb
CHANGED
@@ -2,13 +2,18 @@ module Asgit
|
|
2
2
|
class Config
|
3
3
|
|
4
4
|
attr_reader :service
|
5
|
+
attr_writer :default_branch
|
5
6
|
attr_accessor :organization, :project
|
6
7
|
|
7
8
|
def service= name
|
8
9
|
@service = Asgit::Services.send(name.to_sym)
|
9
10
|
end
|
10
11
|
|
11
|
-
def
|
12
|
+
def default_branch
|
13
|
+
@default_branch || 'master'
|
14
|
+
end
|
15
|
+
|
16
|
+
def required_attributes
|
12
17
|
[ :service, :organization, :project ]
|
13
18
|
end
|
14
19
|
|
@@ -24,7 +29,7 @@ module Asgit
|
|
24
29
|
end
|
25
30
|
|
26
31
|
def configured?
|
27
|
-
config.
|
32
|
+
config.required_attributes.each do |attr|
|
28
33
|
return false unless config.send(attr)
|
29
34
|
end
|
30
35
|
|
data/lib/asgit/url.rb
CHANGED
@@ -21,7 +21,7 @@ module Asgit
|
|
21
21
|
|
22
22
|
def file file_path, options={}
|
23
23
|
file_path = file_path.gsub( /^\//, '' )
|
24
|
-
branch = options.fetch(:branch) {
|
24
|
+
branch = options.fetch(:branch) { Asgit.config.default_branch }
|
25
25
|
line = options.has_key?(:line) ? format_lines(options[:line]) : ''
|
26
26
|
|
27
27
|
File.join( project, Asgit.config.service.file_uri % { file_path: file_path, branch: branch, line: line } )
|
data/lib/asgit/version.rb
CHANGED
data/spec/asgit/config_spec.rb
CHANGED
@@ -2,6 +2,21 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe Asgit::Config do
|
4
4
|
|
5
|
+
describe "#default_branch" do
|
6
|
+
context "when no branch is set" do
|
7
|
+
it "returns 'master'" do
|
8
|
+
expect( Asgit::Config.new.default_branch ).to eq 'master'
|
9
|
+
end
|
10
|
+
end
|
11
|
+
context "when a branch is set" do
|
12
|
+
it "returns the set branch" do
|
13
|
+
config = Asgit::Config.new
|
14
|
+
config.default_branch = 'foo'
|
15
|
+
expect( config.default_branch ).to eq 'foo'
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
5
20
|
describe "::config" do
|
6
21
|
it "returns a config" do
|
7
22
|
expect( Asgit.config.class ).to eq Asgit::Config
|