gitable 0.3.1 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +6 -14
- data/.gitignore +1 -0
- data/.travis.yml +9 -3
- data/LICENSE +1 -1
- data/README.md +108 -0
- data/gitable.gemspec +6 -6
- data/lib/gitable/scp_uri.rb +9 -5
- data/lib/gitable/uri.rb +24 -15
- data/spec/gitable_spec.rb +155 -0
- metadata +29 -23
- data/README.rdoc +0 -82
checksums.yaml
CHANGED
@@ -1,15 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
metadata.gz: !binary |-
|
9
|
-
ZDRlMzdlOGJjYWU4ZGJiNjY5NTFjMzdhNTViYjZmZDlkNzBhODJjYzhhMDA3
|
10
|
-
NTI3NWMxZTJmNGQxNGFhMzUzOTRkNTY0ZGMxN2VkZmU4ZjIzOTJmMjRjN2Yx
|
11
|
-
NWY2ZDFjZDE5M2U3ZmFiNTJlNWFkYTQyZDY3NzVjNDk1ZGM3NWI=
|
12
|
-
data.tar.gz: !binary |-
|
13
|
-
OGJhNjcwNDk3Mjg2MjE4NWM0NzAyMGFiZWJlMzg3YzI0OWJjZTYxMDg3NTdk
|
14
|
-
YzQ3MzU3MjZlZWQwMzYxNWZjM2UwM2E2Zjg3MTYwZjJiOWRiNmJlMDhiOTkx
|
15
|
-
OWQ5Y2NiMWRmZDA2OTFhNDcyZWZkYmYyMTJhMGU2NjkzY2YyNzg=
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: b8946d8df934b379e9bb04017f8d42c3aa9f0d0a
|
4
|
+
data.tar.gz: 9d3b013c3ccd4609d545f9c58b8dd87cc16856ac
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 3c696b9586345ffd296491fdf911c08639aa5672be3be4f2d860655920ff5f91fa906fb00b9b9d10aafd8e1529b99c369b3b54743a65f420246dc7f966a1399e
|
7
|
+
data.tar.gz: 4a78d11b69c5a66b550e68d380e4001f20e40e21bd765ce88ccc3343e496ee20c11be5fcfffa1cdb223fb61e65f3d31d330c638d03eddb68ff7a2ea72648f82f
|
data/.gitignore
CHANGED
data/.travis.yml
CHANGED
data/LICENSE
CHANGED
data/README.md
ADDED
@@ -0,0 +1,108 @@
|
|
1
|
+
# Gitable
|
2
|
+
|
3
|
+
[![Gem Version](https://badge.fury.io/rb/gitable.png)][gem]
|
4
|
+
[![Build Status](https://travis-ci.org/martinemde/gitable.png?branch=master)][travis]
|
5
|
+
[![Dependency Status](https://gemnasium.com/martinemde/gitable.png?travis)][gemnasium]
|
6
|
+
[![Code Climate](https://codeclimate.com/github/martinemde/gitable.png)][codeclimate]
|
7
|
+
|
8
|
+
[gem]: https://rubygems.org/gems/gitable
|
9
|
+
[travis]: https://travis-ci.org/martinemde/gitable
|
10
|
+
[gemnasium]: https://gemnasium.com/martinemde/gitable
|
11
|
+
[codeclimate]: https://codeclimate.com/github/martinemde/gitable
|
12
|
+
|
13
|
+
## A git remote URI parser backed by Addressable
|
14
|
+
|
15
|
+
Works with any valid Git URI as described in the git docs.
|
16
|
+
|
17
|
+
`git clone` accepts many different URI formats for remote repositories.
|
18
|
+
Unfortunately, not all of them are actually URIs. Addressable is able to parse
|
19
|
+
many of the standard URIs accepted by git, and this library extends Addressable
|
20
|
+
to handle the non-standard scp-style repository locations.
|
21
|
+
|
22
|
+
Gitable provides a uniform way to parse a git repository location and determine
|
23
|
+
information about the project. Gitable can determine whether or not a repository
|
24
|
+
will require authentication before actually using `git` to clone the repository.
|
25
|
+
Gitable is also very useful for determining equivalence between git remotes that
|
26
|
+
are entered slightly differently (e.g. trailing slashes, uri scheme, uri format)
|
27
|
+
|
28
|
+
This is *not* a general substitute for Addressable, but rather a specific solution
|
29
|
+
for accepting git repository addresses and confirming validity and authentication.
|
30
|
+
Gitable *should not* be used as a general URI parser for anything other than git
|
31
|
+
repository locations.
|
32
|
+
|
33
|
+
Many thanks to [Bob Aman (sporkmonger)](https://github.com/sporkmonger) for his
|
34
|
+
work on Addressable and for his feedback on this gem.
|
35
|
+
|
36
|
+
## Example
|
37
|
+
|
38
|
+
require 'gitable/uri'
|
39
|
+
uri = Gitable::URI.parse('git@github.com:martinemde/gitable.git')
|
40
|
+
|
41
|
+
uri.path # => 'martinemde/gitable.git'
|
42
|
+
uri.user # => 'git'
|
43
|
+
uri.host # => 'github.com'
|
44
|
+
|
45
|
+
Maintain the same url format.
|
46
|
+
|
47
|
+
uri.to_s # => 'git@github.com:martinemde/gitable.git'
|
48
|
+
|
49
|
+
Uses ssh?
|
50
|
+
|
51
|
+
uri.ssh? # => true
|
52
|
+
|
53
|
+
SCP format?
|
54
|
+
|
55
|
+
uri.scp? # => true
|
56
|
+
|
57
|
+
If it can't guess the name, you named your repository wrong.
|
58
|
+
|
59
|
+
uri.project_name # => 'gitable'
|
60
|
+
|
61
|
+
Will this uri require authentication?
|
62
|
+
|
63
|
+
uri.authenticated? # => true
|
64
|
+
|
65
|
+
Will I have to interactively type something into git (a password)?
|
66
|
+
|
67
|
+
uri.interactive_authenticated? # => false
|
68
|
+
|
69
|
+
Matching public to private git uris?
|
70
|
+
|
71
|
+
uri.equivalent?('git://github.com/martinemde/gitable.git') # => true
|
72
|
+
uri.equivalent?('https://martinemde@github.com/martinemde/gitable.git') # => true
|
73
|
+
|
74
|
+
Link to the web page for a project (github)
|
75
|
+
|
76
|
+
if uri.github?
|
77
|
+
uri.to_web_uri # => <Addressable::URI https://github.com/martinemde/gitable>
|
78
|
+
end
|
79
|
+
|
80
|
+
Inherited from Addressable::URI
|
81
|
+
|
82
|
+
uri.kind_of?(Addressable::URI) # => true
|
83
|
+
|
84
|
+
Teenage Mutant Ninja Urls (mutable uris like Addressable, if you want)
|
85
|
+
|
86
|
+
uri.path = 'someotheruser/gitable.git'
|
87
|
+
uri.basename = 'umm.git'
|
88
|
+
uri.to_s # => 'git@github.com:someotheruser/umm.git'
|
89
|
+
|
90
|
+
## `Gitable::URI.heuristic_parse`
|
91
|
+
|
92
|
+
`Gitable::URI.heuristic_parse` can be used to accept user input.
|
93
|
+
|
94
|
+
Currently this supports the mistake of copying the url bar instead of the git
|
95
|
+
uri for a few of the popular git webhosts. It also runs through Addressable's
|
96
|
+
`heuristic_parse` so it will correct some poorly typed URIs.
|
97
|
+
|
98
|
+
uri = Gitable::URI.heuristic_parse('http://github.com:martinemde/gitable')
|
99
|
+
uri.to_s # => 'git://github.com/martinemde/gitable.git'
|
100
|
+
|
101
|
+
`heuristic_parse` is currently very limited. If the url doesn't end in .git, it
|
102
|
+
switches http:// to git:// and adds .git to the basename.
|
103
|
+
This works fine for github.com and gitorious.org but will happily screw up other
|
104
|
+
URIs.
|
105
|
+
|
106
|
+
## Copyright
|
107
|
+
|
108
|
+
Copyright (c) 2014 Martin Emde. See LICENSE for details.
|
data/gitable.gemspec
CHANGED
@@ -1,16 +1,16 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
2
|
Gem::Specification.new do |s|
|
3
3
|
s.name = "gitable"
|
4
|
-
s.version = "0.
|
4
|
+
s.version = "0.4.0"
|
5
5
|
s.authors = ["Martin Emde"]
|
6
6
|
s.email = ["martin.emde@gmail.com"]
|
7
7
|
s.homepage = "http://github.org/martinemde/gitable"
|
8
|
-
s.summary = %q{Addressable::URI for Git
|
9
|
-
s.description = %q{Addressable::URI for Git URIs with special handling for scp-style
|
8
|
+
s.summary = %q{Addressable::URI with additional support for Git "URIs"}
|
9
|
+
s.description = %q{Addressable::URI for Git "URIs" with special handling for scp-style remotes that Addressable intentionally doesn't parse.}
|
10
10
|
s.license = 'MIT'
|
11
11
|
|
12
|
-
s.add_dependency "addressable", ">= 2.2.7"
|
13
|
-
s.add_development_dependency "rspec", "~>
|
12
|
+
s.add_dependency "addressable", "~> 2.2", ">= 2.2.7"
|
13
|
+
s.add_development_dependency "rspec", "~> 3.0"
|
14
14
|
s.add_development_dependency "rake"
|
15
15
|
s.add_development_dependency "simplecov"
|
16
16
|
|
@@ -18,5 +18,5 @@ Gem::Specification.new do |s|
|
|
18
18
|
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
19
19
|
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
20
20
|
s.require_paths = ["lib"]
|
21
|
-
s.extra_rdoc_files = ["LICENSE", "README.
|
21
|
+
s.extra_rdoc_files = ["LICENSE", "README.md"]
|
22
22
|
end
|
data/lib/gitable/scp_uri.rb
CHANGED
@@ -83,22 +83,26 @@ module Gitable
|
|
83
83
|
return if @validation_deferred
|
84
84
|
|
85
85
|
if host.to_s.empty?
|
86
|
-
|
86
|
+
invalid! "Hostname segment missing"
|
87
87
|
end
|
88
88
|
|
89
|
-
|
90
|
-
|
89
|
+
if !scheme.to_s.empty?
|
90
|
+
invalid! "Scp style URI must not have a scheme"
|
91
91
|
end
|
92
92
|
|
93
93
|
if !port.to_s.empty?
|
94
|
-
|
94
|
+
invalid! "Scp style URI cannot have a port"
|
95
95
|
end
|
96
96
|
|
97
97
|
if path.to_s.empty?
|
98
|
-
|
98
|
+
invalid! "Absolute URI missing hierarchical segment"
|
99
99
|
end
|
100
100
|
|
101
101
|
nil
|
102
102
|
end
|
103
|
+
|
104
|
+
def invalid!(reason)
|
105
|
+
raise InvalidURIError, "#{reason}: '#{to_s}'"
|
106
|
+
end
|
103
107
|
end
|
104
108
|
end
|
data/lib/gitable/uri.rb
CHANGED
@@ -44,14 +44,15 @@ module Gitable
|
|
44
44
|
query = fragments[6]
|
45
45
|
fragment = fragments[8]
|
46
46
|
host = nil
|
47
|
+
|
47
48
|
if authority
|
48
49
|
host = authority.gsub(/^([^\[\]]*)@/, '').gsub(/:([^:@\[\]]*?)$/, '')
|
49
50
|
else
|
50
51
|
authority = scheme
|
51
52
|
end
|
52
53
|
|
53
|
-
if host.nil? &&
|
54
|
-
Gitable::ScpURI.new(:authority =>
|
54
|
+
if host.nil? && uri =~ SCP_REGEXP
|
55
|
+
Gitable::ScpURI.new(:authority => $1, :path => $2)
|
55
56
|
else
|
56
57
|
new(
|
57
58
|
:scheme => scheme,
|
@@ -96,7 +97,7 @@ module Gitable
|
|
96
97
|
# Addressable::URI.heuristic_parse _does_ return the correct type :)
|
97
98
|
gitable = super # boo inconsistency
|
98
99
|
|
99
|
-
if gitable.github?
|
100
|
+
if gitable.github? || gitable.bitbucket?
|
100
101
|
gitable.extname = "git"
|
101
102
|
end
|
102
103
|
gitable
|
@@ -109,10 +110,18 @@ module Gitable
|
|
109
110
|
!!normalized_host.to_s.match(/\.?github.com$/)
|
110
111
|
end
|
111
112
|
|
113
|
+
# Is this uri a bitbucket uri?
|
114
|
+
#
|
115
|
+
# @return [Boolean] bitbucket.org is the host?
|
116
|
+
def bitbucket?
|
117
|
+
!!normalized_host.to_s.match(/\.?bitbucket.org$/)
|
118
|
+
end
|
119
|
+
|
112
120
|
# Create a web link uri for repositories that follow the github pattern.
|
113
121
|
#
|
114
122
|
# This probably won't work for all git hosts, so it's a good idea to use
|
115
|
-
# this in conjunction with #github? to help ensure correct
|
123
|
+
# this in conjunction with #github? or #bitbucket? to help ensure correct
|
124
|
+
# links.
|
116
125
|
#
|
117
126
|
# @param [String] Scheme of the web uri (smart defaults)
|
118
127
|
# @return [Addressable::URI] https://#{host}/#{path_without_git_extension}
|
@@ -125,7 +134,11 @@ module Gitable
|
|
125
134
|
#
|
126
135
|
# @return [String] Project name without .git
|
127
136
|
def project_name
|
128
|
-
basename.sub(/\.git
|
137
|
+
basename.sub(/\.git\/?$/,'')
|
138
|
+
end
|
139
|
+
|
140
|
+
def org_project
|
141
|
+
normalized_path.sub(/^\//,'').sub(/\.git\/?$/,'')
|
129
142
|
end
|
130
143
|
|
131
144
|
# Detect local filesystem URIs.
|
@@ -186,19 +199,15 @@ module Gitable
|
|
186
199
|
def equivalent?(other_uri)
|
187
200
|
other = Gitable::URI.parse_when_valid(other_uri)
|
188
201
|
return false unless other
|
202
|
+
return false unless normalized_host.to_s == other.normalized_host.to_s
|
189
203
|
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
# github doesn't care about relative vs absolute paths in scp uris (so we can remove leading / for comparison)
|
194
|
-
same_path = normalized_path.sub(%r#\.git/?$#, '').sub(%r#^/#,'') == other.normalized_path.sub(%r#\.git/?$#, '').sub(%r#^/#,'')
|
195
|
-
same_host && same_path
|
204
|
+
if github? || bitbucket?
|
205
|
+
# github doesn't care about relative vs absolute paths in scp uris
|
206
|
+
org_project == other.org_project
|
196
207
|
else
|
197
|
-
same_path = normalized_path.sub(%r#/$#,'').to_s == other.normalized_path.sub(%r#/$#,'').to_s # remove trailing slashes.
|
198
|
-
same_user = normalized_user == other.normalized_user
|
199
|
-
|
200
208
|
# if the path is absolute, we can assume it's the same for all users (so the user doesn't have to match).
|
201
|
-
|
209
|
+
normalized_path.sub(/\/$/,'') == other.normalized_path.sub(/\/$/,'') &&
|
210
|
+
(path[0] == '/' || normalized_user == other.normalized_user)
|
202
211
|
end
|
203
212
|
end
|
204
213
|
|
data/spec/gitable_spec.rb
CHANGED
@@ -574,6 +574,7 @@ describe Gitable::URI do
|
|
574
574
|
:authenticated? => true,
|
575
575
|
:interactive_authenticated? => false,
|
576
576
|
:github? => true,
|
577
|
+
:bitbucket? => false,
|
577
578
|
:to_web_uri => Addressable::URI.parse("https://github.com/martinemde/gitable"),
|
578
579
|
})
|
579
580
|
end
|
@@ -601,6 +602,7 @@ describe Gitable::URI do
|
|
601
602
|
:ssh? => false,
|
602
603
|
:scp? => false,
|
603
604
|
:github? => true,
|
605
|
+
:bitbucket? => false,
|
604
606
|
:to_web_uri => Addressable::URI.parse("https://github.com/martinemde/gitable"),
|
605
607
|
})
|
606
608
|
end
|
@@ -629,6 +631,7 @@ describe Gitable::URI do
|
|
629
631
|
:ssh? => false,
|
630
632
|
:scp? => false,
|
631
633
|
:github? => true,
|
634
|
+
:bitbucket? => false,
|
632
635
|
:authenticated? => true,
|
633
636
|
:interactive_authenticated? => true,
|
634
637
|
:to_web_uri => Addressable::URI.parse("https://github.com/martinemde/gitable"),
|
@@ -658,6 +661,7 @@ describe Gitable::URI do
|
|
658
661
|
:ssh? => false,
|
659
662
|
:scp? => false,
|
660
663
|
:github? => true,
|
664
|
+
:bitbucket? => false,
|
661
665
|
:authenticated? => false,
|
662
666
|
:interactive_authenticated? => false,
|
663
667
|
:to_web_uri => Addressable::URI.parse("https://github.com/martinemde/gitable"),
|
@@ -690,8 +694,159 @@ describe Gitable::URI do
|
|
690
694
|
:authenticated? => true,
|
691
695
|
:interactive_authenticated? => false,
|
692
696
|
:github? => true,
|
697
|
+
:bitbucket? => false,
|
693
698
|
:to_web_uri => Addressable::URI.parse("https://github.com/martinemde/gitable"),
|
694
699
|
})
|
695
700
|
end
|
701
|
+
|
702
|
+
describe_uri "ssh://git@bitbucket.org/martinemde/gitable.git" do
|
703
|
+
it { expect(subject.to_s).to eq(@uri) }
|
704
|
+
it { expect("#{subject}").to eq(@uri) }
|
705
|
+
it { expect(subject.inspect).to match(%r|^#<Gitable::URI #{@uri}>$|) }
|
706
|
+
it { expect(subject).to be_equivalent(@uri) }
|
707
|
+
it { expect(subject).to be_equivalent('git://bitbucket.org/martinemde/gitable.git') }
|
708
|
+
it { expect(subject).to be_equivalent('git@bitbucket.org:martinemde/gitable.git') }
|
709
|
+
it { expect(subject).to be_equivalent('git@bitbucket.org:/martinemde/gitable.git') }
|
710
|
+
it { expect(subject).to be_equivalent('https://martinemde@bitbucket.org/martinemde/gitable.git') }
|
711
|
+
it { expect(subject).to_not be_equivalent('git@othergit.com:martinemde/gitable.git') }
|
712
|
+
it { expect(subject).to_not be_equivalent('git@bitbucket.org:martinemde/not_gitable.git') }
|
713
|
+
it_sets({
|
714
|
+
:scheme => "ssh",
|
715
|
+
:user => "git",
|
716
|
+
:password => nil,
|
717
|
+
:host => "bitbucket.org",
|
718
|
+
:port => nil,
|
719
|
+
:path => "/martinemde/gitable.git",
|
720
|
+
:fragment => nil,
|
721
|
+
:basename => "gitable.git",
|
722
|
+
:ssh? => true,
|
723
|
+
:scp? => false,
|
724
|
+
:authenticated? => true,
|
725
|
+
:interactive_authenticated? => false,
|
726
|
+
:github? => false,
|
727
|
+
:bitbucket? => true,
|
728
|
+
:to_web_uri => Addressable::URI.parse("https://bitbucket.org/martinemde/gitable"),
|
729
|
+
})
|
730
|
+
end
|
731
|
+
|
732
|
+
describe_uri "https://bitbucket.org/martinemde/gitable.git" do
|
733
|
+
it { expect(subject.to_s).to eq(@uri) }
|
734
|
+
it { expect("#{subject}").to eq(@uri) }
|
735
|
+
it { expect(subject.inspect).to match(%r|^#<Gitable::URI #{@uri}>$|) }
|
736
|
+
it { expect(subject).to be_equivalent(@uri) }
|
737
|
+
it { expect(subject).to be_equivalent('ssh://git@bitbucket.org/martinemde/gitable.git') }
|
738
|
+
it { expect(subject).to be_equivalent('git://bitbucket.org/martinemde/gitable.git') }
|
739
|
+
it { expect(subject).to be_equivalent('git@bitbucket.org:martinemde/gitable.git') }
|
740
|
+
it { expect(subject).to be_equivalent('git@bitbucket.org:/martinemde/gitable.git') }
|
741
|
+
it { expect(subject).to_not be_equivalent('git@othergit.com:martinemde/gitable.git') }
|
742
|
+
it { expect(subject).to_not be_equivalent('git@bitbucket.org:martinemde/not_gitable.git') }
|
743
|
+
it_sets({
|
744
|
+
:scheme => "https",
|
745
|
+
:user => nil,
|
746
|
+
:password => nil,
|
747
|
+
:host => "bitbucket.org",
|
748
|
+
:port => nil,
|
749
|
+
:path => "/martinemde/gitable.git",
|
750
|
+
:fragment => nil,
|
751
|
+
:basename => "gitable.git",
|
752
|
+
:ssh? => false,
|
753
|
+
:scp? => false,
|
754
|
+
:github? => false,
|
755
|
+
:bitbucket? => true,
|
756
|
+
:to_web_uri => Addressable::URI.parse("https://bitbucket.org/martinemde/gitable"),
|
757
|
+
})
|
758
|
+
end
|
759
|
+
|
760
|
+
describe_uri "https://martinemde@bitbucket.org/martinemde/gitable.git" do
|
761
|
+
it { expect(subject.to_s).to eq(@uri) }
|
762
|
+
it { expect("#{subject}").to eq(@uri) }
|
763
|
+
it { expect(subject.inspect).to match(%r|^#<Gitable::URI #{@uri}>$|) }
|
764
|
+
it { expect(subject).to be_equivalent(@uri) }
|
765
|
+
it { expect(subject).to be_equivalent('ssh://git@bitbucket.org/martinemde/gitable.git') }
|
766
|
+
it { expect(subject).to be_equivalent('git://bitbucket.org/martinemde/gitable.git') }
|
767
|
+
it { expect(subject).to be_equivalent('git@bitbucket.org:martinemde/gitable.git') }
|
768
|
+
it { expect(subject).to be_equivalent('git@bitbucket.org:/martinemde/gitable.git') }
|
769
|
+
it { expect(subject).to be_equivalent('https://bitbucket.org/martinemde/gitable.git') }
|
770
|
+
it { expect(subject).to_not be_equivalent('git@othergit.com:martinemde/gitable.git') }
|
771
|
+
it { expect(subject).to_not be_equivalent('git@bitbucket.org:martinemde/not_gitable.git') }
|
772
|
+
it_sets({
|
773
|
+
:scheme => "https",
|
774
|
+
:user => "martinemde",
|
775
|
+
:password => nil,
|
776
|
+
:host => "bitbucket.org",
|
777
|
+
:port => nil,
|
778
|
+
:path => "/martinemde/gitable.git",
|
779
|
+
:fragment => nil,
|
780
|
+
:basename => "gitable.git",
|
781
|
+
:ssh? => false,
|
782
|
+
:scp? => false,
|
783
|
+
:github? => false,
|
784
|
+
:bitbucket? => true,
|
785
|
+
:authenticated? => true,
|
786
|
+
:interactive_authenticated? => true,
|
787
|
+
:to_web_uri => Addressable::URI.parse("https://bitbucket.org/martinemde/gitable"),
|
788
|
+
})
|
789
|
+
end
|
790
|
+
|
791
|
+
describe_uri "git://bitbucket.org/martinemde/gitable.git" do
|
792
|
+
it { expect(subject.to_s).to eq(@uri) }
|
793
|
+
it { expect("#{subject}").to eq(@uri) }
|
794
|
+
it { expect(subject.inspect).to match(%r|^#<Gitable::URI #{@uri}>$|) }
|
795
|
+
it { expect(subject).to be_equivalent(@uri) }
|
796
|
+
it { expect(subject).to be_equivalent('ssh://git@bitbucket.org/martinemde/gitable.git') }
|
797
|
+
it { expect(subject).to be_equivalent('git@bitbucket.org:martinemde/gitable.git') }
|
798
|
+
it { expect(subject).to be_equivalent('git@bitbucket.org:/martinemde/gitable.git') }
|
799
|
+
it { expect(subject).to be_equivalent('https://martinemde@bitbucket.org/martinemde/gitable.git') }
|
800
|
+
it { expect(subject).to_not be_equivalent('git@othergit.com:martinemde/gitable.git') }
|
801
|
+
it { expect(subject).to_not be_equivalent('git@bitbucket.org:martinemde/not_gitable.git') }
|
802
|
+
it_sets({
|
803
|
+
:scheme => "git",
|
804
|
+
:user => nil,
|
805
|
+
:password => nil,
|
806
|
+
:host => "bitbucket.org",
|
807
|
+
:port => nil,
|
808
|
+
:path => "/martinemde/gitable.git",
|
809
|
+
:fragment => nil,
|
810
|
+
:basename => "gitable.git",
|
811
|
+
:ssh? => false,
|
812
|
+
:scp? => false,
|
813
|
+
:github? => false,
|
814
|
+
:bitbucket? => true,
|
815
|
+
:authenticated? => false,
|
816
|
+
:interactive_authenticated? => false,
|
817
|
+
:to_web_uri => Addressable::URI.parse("https://bitbucket.org/martinemde/gitable"),
|
818
|
+
})
|
819
|
+
end
|
820
|
+
|
821
|
+
describe_uri "git@bitbucket.org:martinemde/gitable.git" do
|
822
|
+
it { expect(subject.to_s).to eq(@uri) }
|
823
|
+
it { expect("#{subject}").to eq(@uri) }
|
824
|
+
it { expect(subject.inspect).to match(%r|^#<Gitable::ScpURI #{@uri}>$|) }
|
825
|
+
it { expect(subject).to be_equivalent(@uri) }
|
826
|
+
it { expect(subject).to be_equivalent('ssh://git@bitbucket.org/martinemde/gitable.git') }
|
827
|
+
it { expect(subject).to be_equivalent('git://bitbucket.org/martinemde/gitable.git') }
|
828
|
+
it { expect(subject).to be_equivalent('https://martinemde@bitbucket.org/martinemde/gitable.git') }
|
829
|
+
it { expect(subject).to_not be_equivalent('git@othergit.com:martinemde/gitable.git') }
|
830
|
+
it { expect(subject).to_not be_equivalent('git@bitbucket.org:martinemde/not_gitable.git') }
|
831
|
+
it_sets({
|
832
|
+
:scheme => nil,
|
833
|
+
:inferred_scheme => 'ssh',
|
834
|
+
:user => "git",
|
835
|
+
:password => nil,
|
836
|
+
:host => "bitbucket.org",
|
837
|
+
:port => nil,
|
838
|
+
:path => "martinemde/gitable.git",
|
839
|
+
:fragment => nil,
|
840
|
+
:basename => "gitable.git",
|
841
|
+
:project_name => "gitable",
|
842
|
+
:ssh? => true,
|
843
|
+
:scp? => true,
|
844
|
+
:authenticated? => true,
|
845
|
+
:interactive_authenticated? => false,
|
846
|
+
:github? => false,
|
847
|
+
:bitbucket? => true,
|
848
|
+
:to_web_uri => Addressable::URI.parse("https://bitbucket.org/martinemde/gitable"),
|
849
|
+
})
|
850
|
+
end
|
696
851
|
end
|
697
852
|
end
|
metadata
CHANGED
@@ -1,87 +1,93 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gitable
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Martin Emde
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-12-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: addressable
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '2.2'
|
20
|
+
- - ">="
|
18
21
|
- !ruby/object:Gem::Version
|
19
22
|
version: 2.2.7
|
20
23
|
type: :runtime
|
21
24
|
prerelease: false
|
22
25
|
version_requirements: !ruby/object:Gem::Requirement
|
23
26
|
requirements:
|
24
|
-
- -
|
27
|
+
- - "~>"
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '2.2'
|
30
|
+
- - ">="
|
25
31
|
- !ruby/object:Gem::Version
|
26
32
|
version: 2.2.7
|
27
33
|
- !ruby/object:Gem::Dependency
|
28
34
|
name: rspec
|
29
35
|
requirement: !ruby/object:Gem::Requirement
|
30
36
|
requirements:
|
31
|
-
- - ~>
|
37
|
+
- - "~>"
|
32
38
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
39
|
+
version: '3.0'
|
34
40
|
type: :development
|
35
41
|
prerelease: false
|
36
42
|
version_requirements: !ruby/object:Gem::Requirement
|
37
43
|
requirements:
|
38
|
-
- - ~>
|
44
|
+
- - "~>"
|
39
45
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
46
|
+
version: '3.0'
|
41
47
|
- !ruby/object:Gem::Dependency
|
42
48
|
name: rake
|
43
49
|
requirement: !ruby/object:Gem::Requirement
|
44
50
|
requirements:
|
45
|
-
- -
|
51
|
+
- - ">="
|
46
52
|
- !ruby/object:Gem::Version
|
47
53
|
version: '0'
|
48
54
|
type: :development
|
49
55
|
prerelease: false
|
50
56
|
version_requirements: !ruby/object:Gem::Requirement
|
51
57
|
requirements:
|
52
|
-
- -
|
58
|
+
- - ">="
|
53
59
|
- !ruby/object:Gem::Version
|
54
60
|
version: '0'
|
55
61
|
- !ruby/object:Gem::Dependency
|
56
62
|
name: simplecov
|
57
63
|
requirement: !ruby/object:Gem::Requirement
|
58
64
|
requirements:
|
59
|
-
- -
|
65
|
+
- - ">="
|
60
66
|
- !ruby/object:Gem::Version
|
61
67
|
version: '0'
|
62
68
|
type: :development
|
63
69
|
prerelease: false
|
64
70
|
version_requirements: !ruby/object:Gem::Requirement
|
65
71
|
requirements:
|
66
|
-
- -
|
72
|
+
- - ">="
|
67
73
|
- !ruby/object:Gem::Version
|
68
74
|
version: '0'
|
69
|
-
description: Addressable::URI for Git URIs with special handling for scp-style
|
70
|
-
that Addressable doesn't
|
75
|
+
description: Addressable::URI for Git "URIs" with special handling for scp-style remotes
|
76
|
+
that Addressable intentionally doesn't parse.
|
71
77
|
email:
|
72
78
|
- martin.emde@gmail.com
|
73
79
|
executables: []
|
74
80
|
extensions: []
|
75
81
|
extra_rdoc_files:
|
76
82
|
- LICENSE
|
77
|
-
- README.
|
83
|
+
- README.md
|
78
84
|
files:
|
79
|
-
- .document
|
80
|
-
- .gitignore
|
81
|
-
- .travis.yml
|
85
|
+
- ".document"
|
86
|
+
- ".gitignore"
|
87
|
+
- ".travis.yml"
|
82
88
|
- Gemfile
|
83
89
|
- LICENSE
|
84
|
-
- README.
|
90
|
+
- README.md
|
85
91
|
- Rakefile
|
86
92
|
- gitable.gemspec
|
87
93
|
- lib/gitable.rb
|
@@ -101,20 +107,20 @@ require_paths:
|
|
101
107
|
- lib
|
102
108
|
required_ruby_version: !ruby/object:Gem::Requirement
|
103
109
|
requirements:
|
104
|
-
- -
|
110
|
+
- - ">="
|
105
111
|
- !ruby/object:Gem::Version
|
106
112
|
version: '0'
|
107
113
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
108
114
|
requirements:
|
109
|
-
- -
|
115
|
+
- - ">="
|
110
116
|
- !ruby/object:Gem::Version
|
111
117
|
version: '0'
|
112
118
|
requirements: []
|
113
119
|
rubyforge_project:
|
114
|
-
rubygems_version: 2.
|
120
|
+
rubygems_version: 2.5.2
|
115
121
|
signing_key:
|
116
122
|
specification_version: 4
|
117
|
-
summary: Addressable::URI for Git
|
123
|
+
summary: Addressable::URI with additional support for Git "URIs"
|
118
124
|
test_files:
|
119
125
|
- spec/describe_uri.rb
|
120
126
|
- spec/gitable_spec.rb
|
data/README.rdoc
DELETED
@@ -1,82 +0,0 @@
|
|
1
|
-
= Gitable
|
2
|
-
|
3
|
-
== Addressable::URI for Git.
|
4
|
-
|
5
|
-
Works with any valid Git URI, because Addressable doesn't.
|
6
|
-
|
7
|
-
== Example!?
|
8
|
-
|
9
|
-
require 'gitable/uri'
|
10
|
-
uri = Gitable::URI.parse('git@github.com:martinemde/gitable.git')
|
11
|
-
|
12
|
-
uri.path # => 'martinemde/gitable.git'
|
13
|
-
uri.user # => 'git'
|
14
|
-
uri.host # => 'github.com'
|
15
|
-
|
16
|
-
Maintain the same url format.
|
17
|
-
|
18
|
-
uri.to_s # => 'git@github.com:martinemde/gitable.git'
|
19
|
-
|
20
|
-
Uses ssh?
|
21
|
-
|
22
|
-
uri.ssh? # => true
|
23
|
-
|
24
|
-
SCP format?
|
25
|
-
|
26
|
-
uri.scp? # => true
|
27
|
-
|
28
|
-
If it can't guess the name, you named your repository wrong.
|
29
|
-
|
30
|
-
uri.project_name # => 'gitable'
|
31
|
-
|
32
|
-
Will this uri require authentication?
|
33
|
-
|
34
|
-
uri.authenticated? # => true
|
35
|
-
|
36
|
-
Will I have to interactively type something into git (a password)?
|
37
|
-
|
38
|
-
uri.interactive_authenticated? # => false
|
39
|
-
|
40
|
-
Matching public to private git uris?
|
41
|
-
|
42
|
-
uri.equivalent?('git://github.com/martinemde/gitable.git') # => true
|
43
|
-
uri.equivalent?('https://martinemde@github.com/martinemde/gitable.git') # => true
|
44
|
-
|
45
|
-
Link to the web page for a project (github)
|
46
|
-
|
47
|
-
if uri.github?
|
48
|
-
uri.to_web_uri # => <Addressable::URI https://github.com/martinemde/gitable>
|
49
|
-
end
|
50
|
-
|
51
|
-
Inherited from Addressable::URI
|
52
|
-
|
53
|
-
uri.kind_of?(Addressable::URI) # => true
|
54
|
-
|
55
|
-
Teenage Mutant Ninja Urls (mutable uris like Addressable, if you want)
|
56
|
-
|
57
|
-
uri.path = 'someotheruser/gitable.git'
|
58
|
-
uri.basename = 'umm.git'
|
59
|
-
uri.to_s # => 'git@github.com:someotheruser/umm.git'
|
60
|
-
|
61
|
-
== heuristic_parse
|
62
|
-
|
63
|
-
You can use Gitable::URI.heuristic_parse to take user input.
|
64
|
-
|
65
|
-
Currently this supports the mistake of copying the url bar instead of the git
|
66
|
-
uri for a few of the popular git webhosts. It also runs through Addressable's
|
67
|
-
heuristic_parse so it will correct some poorly typed URIs.
|
68
|
-
|
69
|
-
uri = Gitable::URI.heuristic_parse('http://github.com:martinemde/gitable')
|
70
|
-
uri.to_s # => 'git://github.com/martinemde/gitable.git'
|
71
|
-
|
72
|
-
heuristic_parse is currently very limited. If the url doesn't end in .git, it
|
73
|
-
switches http:// to git:// and adds .git to the basename.
|
74
|
-
This works fine for github.com and gitorious.org but will happily screw up other URIs.
|
75
|
-
|
76
|
-
== That's it?
|
77
|
-
|
78
|
-
Yep. What else did you expect? (let me know or write a patch)
|
79
|
-
|
80
|
-
== Copyright
|
81
|
-
|
82
|
-
Copyright (c) 2010 Martin Emde. See LICENSE for details.
|