asgit 0.0.3 → 0.0.4

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: 2f65ffd8d253ea3d44fe78e58222c82634b21478
4
- data.tar.gz: 79d2e45d7d8c0fcda2b7dcbb058e0d68a39c80be
3
+ metadata.gz: cc550b94030a3e6bb0430a2880678522c6356cf2
4
+ data.tar.gz: cfa580b8bd83ac2a8b2f42abecb6ae6cb2d1d080
5
5
  SHA512:
6
- metadata.gz: 806b184a313a4eab9ca590693537b4e0c33cba0a521d160d3a55a3b95724278b7b2ff8c63c7cb31571e3c9366fe08ec9dce41d02371532edb063bcc291a26746
7
- data.tar.gz: 3e00a8879e1155ee895d8b3c02db0130c40eadf8cece5ae0d11734c339b46c92fd144067aa0de51f84d99f1a35932840eee16f2e1e137802897525f0dd10f8de
6
+ metadata.gz: d30037bfd83bffebb313c21ed15c826575fb24d469ff9378ab7a153f0bad396f1818a6aa54dc252e7639fd92c0aa0593f743057aa1e40fb6f69ebfa6481970d4
7
+ data.tar.gz: f32403eee3d40b47cf9ca4eacb67aa6f2259b18f88168db4ea352bc3e5389aa33914b20132ee84a16ba86e1e00685ea32b7a806ac14526e252bd6b5c6ca87635
@@ -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 attributes
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.attributes.each do |attr|
32
+ config.required_attributes.each do |attr|
28
33
  return false unless config.send(attr)
29
34
  end
30
35
 
@@ -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) { 'master' }
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 } )
@@ -1,3 +1,3 @@
1
1
  module Asgit
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
@@ -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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: asgit
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Steven Sloan