asgit 0.0.1 → 0.0.2
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 +7 -0
- data/lib/asgit/services.rb +2 -1
- data/lib/asgit/url.rb +18 -0
- data/lib/asgit/version.rb +1 -1
- data/lib/asgit.rb +4 -4
- data/spec/asgit/url_spec.rb +28 -0
- metadata +8 -11
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 2a3ef352b417a8256bb2ebd10497bcc8c75204ba
|
4
|
+
data.tar.gz: 171ef7978ea71218aa65d57ee60a044014079217
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: b54bbbd61edbe4f8c67ef66c6e79f180c09c65bdfc6ea142a3dd28608c4e45be493697b7d7422dfea8c1de764656ccb79c2c2adeb9a3fc55fe93e966f69cc10c
|
7
|
+
data.tar.gz: 610f6e59d1f2fc4a1c437b37e806317138027093f9a09365ceb771889064a1452737cbb729f07a4455b8a4adc05144c4616a1d7f30c5b529c89bfbce48c2adc6
|
data/lib/asgit/services.rb
CHANGED
@@ -6,7 +6,8 @@ module Asgit
|
|
6
6
|
base_url: 'https://github.com',
|
7
7
|
base_structure: "%{base_url}/%{organization}/%{project}",
|
8
8
|
commit_uri: "commit/%{commit}",
|
9
|
-
branch_uri: "tree/%{branch}"
|
9
|
+
branch_uri: "tree/%{branch}",
|
10
|
+
file_uri: "blob/%{branch}/%{file_path}%{line}"
|
10
11
|
}
|
11
12
|
}
|
12
13
|
|
data/lib/asgit/url.rb
CHANGED
@@ -19,6 +19,24 @@ module Asgit
|
|
19
19
|
File.join( project, Asgit.config.service.branch_uri % { branch: name } )
|
20
20
|
end
|
21
21
|
|
22
|
+
def file file_path, options={}
|
23
|
+
file_path = file_path.gsub( /^\//, '' )
|
24
|
+
branch = options.fetch(:branch) { 'master' }
|
25
|
+
line = options.has_key?(:line) ? format_lines(options[:line]) : ''
|
26
|
+
|
27
|
+
File.join( project, Asgit.config.service.file_uri % { file_path: file_path, branch: branch, line: line } )
|
28
|
+
end
|
29
|
+
|
30
|
+
private
|
31
|
+
|
32
|
+
def format_lines input
|
33
|
+
if input.respond_to?(:begin) && input.respond_to?(:end)
|
34
|
+
return "#L#{input.begin}-L#{input.end}"
|
35
|
+
else
|
36
|
+
return "#L#{input}"
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
22
40
|
end
|
23
41
|
|
24
42
|
end
|
data/lib/asgit/version.rb
CHANGED
data/lib/asgit.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
1
|
+
require_relative 'asgit/shell'
|
2
|
+
require_relative 'asgit/url'
|
3
|
+
require_relative 'asgit/config'
|
4
|
+
require_relative 'asgit/services'
|
5
5
|
|
6
6
|
module Asgit
|
7
7
|
class << self
|
data/spec/asgit/url_spec.rb
CHANGED
@@ -14,6 +14,12 @@ describe Asgit::Url do
|
|
14
14
|
Asgit::Services.send(:remove_instance_variable, "@_github")
|
15
15
|
end
|
16
16
|
|
17
|
+
describe "::project" do
|
18
|
+
it "returns correct url for the project" do
|
19
|
+
expect( Asgit::Url.project ).to eq "https://github.com/wu/tang"
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
17
23
|
describe "::commit" do
|
18
24
|
it "returns the correct url for the provided commit" do
|
19
25
|
expect( Asgit::Url.commit "woot" ).to eq "https://github.com/wu/tang/commit/woot"
|
@@ -26,4 +32,26 @@ describe Asgit::Url do
|
|
26
32
|
end
|
27
33
|
end
|
28
34
|
|
35
|
+
describe "::file" do
|
36
|
+
it "returns the correct url for a file" do
|
37
|
+
expect( Asgit::Url.file "lib/tang.rb" ).to eq "https://github.com/wu/tang/blob/master/lib/tang.rb"
|
38
|
+
end
|
39
|
+
|
40
|
+
it "adjust for fives given with a leading slash" do
|
41
|
+
expect( Asgit::Url.file "/lib/tang.rb" ).to eq "https://github.com/wu/tang/blob/master/lib/tang.rb"
|
42
|
+
end
|
43
|
+
|
44
|
+
it "returns the correct url for a file with a passed branch" do
|
45
|
+
expect( Asgit::Url.file "/lib/tang.rb", branch: 'dev' ).to eq "https://github.com/wu/tang/blob/dev/lib/tang.rb"
|
46
|
+
end
|
47
|
+
|
48
|
+
it "returns the correct url for a file with a line number" do
|
49
|
+
expect( Asgit::Url.file "/lib/tang.rb", branch: 'dev', line: "15" ).to eq "https://github.com/wu/tang/blob/dev/lib/tang.rb#L15"
|
50
|
+
end
|
51
|
+
|
52
|
+
it "returns the correct url for a file with a range of line numbers" do
|
53
|
+
expect( Asgit::Url.file "/lib/tang.rb", branch: 'dev', line: (15..18) ).to eq "https://github.com/wu/tang/blob/dev/lib/tang.rb#L15-L18"
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
29
57
|
end
|
metadata
CHANGED
@@ -1,17 +1,16 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: asgit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
5
|
-
prerelease:
|
4
|
+
version: 0.0.2
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Steven Sloan
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date: 2013-
|
11
|
+
date: 2013-11-01 00:00:00.000000000 Z
|
13
12
|
dependencies: []
|
14
|
-
description:
|
13
|
+
description: ' A simple query interface for git. '
|
15
14
|
email:
|
16
15
|
- stevenosloan@gmail.com
|
17
16
|
executables: []
|
@@ -34,27 +33,26 @@ files:
|
|
34
33
|
homepage: http://github.com/stevenosloan/asgit
|
35
34
|
licenses:
|
36
35
|
- MIT
|
36
|
+
metadata: {}
|
37
37
|
post_install_message:
|
38
38
|
rdoc_options: []
|
39
39
|
require_paths:
|
40
40
|
- lib
|
41
41
|
required_ruby_version: !ruby/object:Gem::Requirement
|
42
|
-
none: false
|
43
42
|
requirements:
|
44
|
-
- -
|
43
|
+
- - '>='
|
45
44
|
- !ruby/object:Gem::Version
|
46
45
|
version: '0'
|
47
46
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
48
|
-
none: false
|
49
47
|
requirements:
|
50
|
-
- -
|
48
|
+
- - '>='
|
51
49
|
- !ruby/object:Gem::Version
|
52
50
|
version: '0'
|
53
51
|
requirements: []
|
54
52
|
rubyforge_project:
|
55
|
-
rubygems_version:
|
53
|
+
rubygems_version: 2.0.5
|
56
54
|
signing_key:
|
57
|
-
specification_version:
|
55
|
+
specification_version: 4
|
58
56
|
summary: A simple query interface for git
|
59
57
|
test_files:
|
60
58
|
- spec/asgit/config_spec.rb
|
@@ -64,4 +62,3 @@ test_files:
|
|
64
62
|
- spec/spec_helper.rb
|
65
63
|
- spec/support/eat_stdout.rb
|
66
64
|
- spec/support/fake_stdout.rb
|
67
|
-
has_rdoc:
|