gitable 0.2.1 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- data/gitable.gemspec +1 -1
- data/lib/gitable/scp_uri.rb +8 -0
- data/lib/gitable/uri.rb +39 -2
- data/spec/gitable_spec.rb +86 -0
- metadata +59 -84
data/gitable.gemspec
CHANGED
data/lib/gitable/scp_uri.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
require 'addressable/uri'
|
1
2
|
require 'gitable/uri'
|
2
3
|
|
3
4
|
module Gitable
|
@@ -85,6 +86,13 @@ module Gitable
|
|
85
86
|
true
|
86
87
|
end
|
87
88
|
|
89
|
+
# Is this an scp formatted uri? (Yes, always)
|
90
|
+
#
|
91
|
+
# @return [true] always scp formatted uri
|
92
|
+
def scp?
|
93
|
+
true
|
94
|
+
end
|
95
|
+
|
88
96
|
protected
|
89
97
|
|
90
98
|
def validate
|
data/lib/gitable/uri.rb
CHANGED
@@ -59,7 +59,8 @@ module Gitable
|
|
59
59
|
!!normalized_host.to_s.match(/\.?github.com$/)
|
60
60
|
end
|
61
61
|
|
62
|
-
# Create a web uri for repositories that follow the github pattern.
|
62
|
+
# Create a web link uri for repositories that follow the github pattern.
|
63
|
+
#
|
63
64
|
# This probably won't work for all git hosts, so it's a good idea to use
|
64
65
|
# this in conjunction with #github? to help ensure correct links.
|
65
66
|
#
|
@@ -67,7 +68,7 @@ module Gitable
|
|
67
68
|
# @return [Addressable::URI] https://#{host}/#{path_without_git_extension}
|
68
69
|
def to_web_uri(uri_scheme='https')
|
69
70
|
return nil if normalized_host.to_s.empty?
|
70
|
-
Addressable::URI.new(:scheme => uri_scheme, :host => normalized_host, :port => normalized_port, :path => normalized_path.sub(%r#\.git
|
71
|
+
Addressable::URI.new(:scheme => uri_scheme, :host => normalized_host, :port => normalized_port, :path => normalized_path.sub(%r#\.git/?$#, ''))
|
71
72
|
end
|
72
73
|
|
73
74
|
# Tries to guess the project name of the repository.
|
@@ -102,6 +103,13 @@ module Gitable
|
|
102
103
|
!!normalized_scheme.to_s.match(/ssh/)
|
103
104
|
end
|
104
105
|
|
106
|
+
# Is this an scp formatted uri? (No, always)
|
107
|
+
#
|
108
|
+
# @return [false] always false (overridden by scp formatted uris)
|
109
|
+
def scp?
|
110
|
+
false
|
111
|
+
end
|
112
|
+
|
105
113
|
# Detect URIs that will require some sort of authentication
|
106
114
|
#
|
107
115
|
# @return [Boolean] true if the URI uses ssh or has a user but no password
|
@@ -116,6 +124,35 @@ module Gitable
|
|
116
124
|
authenticated? && !ssh?
|
117
125
|
end
|
118
126
|
|
127
|
+
# Detect if two URIs are equivalent versions of the same uri.
|
128
|
+
#
|
129
|
+
# When both uris are github repositories, uses a more lenient matching
|
130
|
+
# system is used that takes github's repository organization into account.
|
131
|
+
#
|
132
|
+
# For non-github URIs this method requires the two URIs to have the same
|
133
|
+
# host, equivalent paths, and either the same user or an absolute path.
|
134
|
+
#
|
135
|
+
# @return [Boolean] true if the URI probably indicates the same repository.
|
136
|
+
def equivalent?(other_uri)
|
137
|
+
other = Gitable::URI.parse(other_uri)
|
138
|
+
|
139
|
+
same_host = normalized_host.to_s == other.normalized_host.to_s
|
140
|
+
|
141
|
+
if github? && other.github?
|
142
|
+
# github doesn't care about relative vs absolute paths in scp uris (so we can remove leading / for comparison)
|
143
|
+
same_path = normalized_path.sub(%r#\.git/?$#, '').sub(%r#^/#,'') == other.normalized_path.sub(%r#\.git/?$#, '').sub(%r#^/#,'')
|
144
|
+
same_host && same_path
|
145
|
+
else
|
146
|
+
same_path = normalized_path.sub(%r#/$#,'').to_s == other.normalized_path.sub(%r#/$#,'').to_s # remove trailing slashes.
|
147
|
+
same_user = normalized_user == other.normalized_user
|
148
|
+
|
149
|
+
# if the path is absolute, we can assume it's the same for all users (so the user doesn't have to match).
|
150
|
+
same_host && same_path && (path =~ %r#^/# || same_user)
|
151
|
+
end
|
152
|
+
rescue Gitable::URI::InvalidURIError
|
153
|
+
false
|
154
|
+
end
|
155
|
+
|
119
156
|
# Set an extension name, replacing one if it exists.
|
120
157
|
#
|
121
158
|
# If there is no basename (i.e. no words in the path) this method call will
|
data/spec/gitable_spec.rb
CHANGED
@@ -387,6 +387,11 @@ describe Gitable::URI do
|
|
387
387
|
|
388
388
|
describe_uri "user@host.xz:/path/to/repo.git/" do
|
389
389
|
it { subject.to_s.should == @uri }
|
390
|
+
it { subject.should be_equivalent('ssh://user@host.xz/path/to/repo.git') }
|
391
|
+
it { subject.should be_equivalent('user@host.xz:/path/to/repo.git') }
|
392
|
+
it { subject.should_not be_equivalent('user@host.xz:path/to/repo.git') } # not absolute
|
393
|
+
it { subject.should_not be_equivalent('/path/to/repo.git') }
|
394
|
+
it { subject.should_not be_equivalent('host.xz:path/to/repo.git') }
|
390
395
|
it_sets expected.merge({
|
391
396
|
:scheme => nil,
|
392
397
|
:inferred_scheme => 'ssh',
|
@@ -437,6 +442,10 @@ describe Gitable::URI do
|
|
437
442
|
|
438
443
|
describe_uri "user@host.xz:path/to/repo.git" do
|
439
444
|
it { subject.to_s.should == @uri }
|
445
|
+
it { subject.should_not be_equivalent('ssh://user@host.xz/path/to/repo.git') } # not absolute
|
446
|
+
it { subject.should_not be_equivalent('path/to/repo.git') }
|
447
|
+
it { subject.should_not be_equivalent('host.xz:path/to/repo.git') }
|
448
|
+
it { subject.should_not be_equivalent('user@host.xz:/path/to/repo.git') }
|
440
449
|
it_sets expected.merge({
|
441
450
|
:scheme => nil,
|
442
451
|
:inferred_scheme => "ssh",
|
@@ -449,6 +458,12 @@ describe Gitable::URI do
|
|
449
458
|
|
450
459
|
describe_uri "/path/to/repo.git/" do
|
451
460
|
it { subject.to_s.should == @uri }
|
461
|
+
it { subject.should be_equivalent(@uri) }
|
462
|
+
it { subject.should be_equivalent('/path/to/repo.git') }
|
463
|
+
it { subject.should be_equivalent('file:///path/to/repo.git') }
|
464
|
+
it { subject.should be_equivalent('file:///path/to/repo.git/') }
|
465
|
+
it { subject.should_not be_equivalent('/path/to/repo/.git') }
|
466
|
+
it { subject.should_not be_equivalent('file:///not/path/repo.git') }
|
452
467
|
it_sets expected.merge({
|
453
468
|
:scheme => nil,
|
454
469
|
:inferred_scheme => "file",
|
@@ -461,6 +476,12 @@ describe Gitable::URI do
|
|
461
476
|
|
462
477
|
describe_uri "file:///path/to/repo.git/" do
|
463
478
|
it { subject.to_s.should == @uri }
|
479
|
+
it { subject.should be_equivalent(@uri) }
|
480
|
+
it { subject.should be_equivalent('/path/to/repo.git') }
|
481
|
+
it { subject.should be_equivalent('file:///path/to/repo.git') }
|
482
|
+
it { subject.should be_equivalent('/path/to/repo.git/') }
|
483
|
+
it { subject.should_not be_equivalent('/path/to/repo/.git') }
|
484
|
+
it { subject.should_not be_equivalent('file:///not/path/repo.git') }
|
464
485
|
it_sets expected.merge({
|
465
486
|
:scheme => "file",
|
466
487
|
:inferred_scheme => "file",
|
@@ -473,6 +494,13 @@ describe Gitable::URI do
|
|
473
494
|
|
474
495
|
describe_uri "ssh://git@github.com/martinemde/gitable.git" do
|
475
496
|
it { subject.to_s.should == @uri }
|
497
|
+
it { subject.should be_equivalent(@uri) }
|
498
|
+
it { subject.should be_equivalent('git://github.com/martinemde/gitable.git') }
|
499
|
+
it { subject.should be_equivalent('git@github.com:martinemde/gitable.git') }
|
500
|
+
it { subject.should be_equivalent('git@github.com:/martinemde/gitable.git') }
|
501
|
+
it { subject.should be_equivalent('https://martinemde@github.com/martinemde/gitable.git') }
|
502
|
+
it { subject.should_not be_equivalent('git@othergit.com:martinemde/gitable.git') }
|
503
|
+
it { subject.should_not be_equivalent('git@github.com:martinemde/not_gitable.git') }
|
476
504
|
it_sets({
|
477
505
|
:scheme => "ssh",
|
478
506
|
:user => "git",
|
@@ -483,7 +511,9 @@ describe Gitable::URI do
|
|
483
511
|
:fragment => nil,
|
484
512
|
:basename => "gitable.git",
|
485
513
|
:ssh? => true,
|
514
|
+
:scp? => false,
|
486
515
|
:authenticated? => true,
|
516
|
+
:interactive_authenticated? => false,
|
487
517
|
:github? => true,
|
488
518
|
:to_web_uri => Addressable::URI.parse("https://github.com/martinemde/gitable"),
|
489
519
|
})
|
@@ -491,6 +521,13 @@ describe Gitable::URI do
|
|
491
521
|
|
492
522
|
describe_uri "https://github.com/martinemde/gitable.git" do
|
493
523
|
it { subject.to_s.should == @uri }
|
524
|
+
it { subject.should be_equivalent(@uri) }
|
525
|
+
it { subject.should be_equivalent('ssh://git@github.com/martinemde/gitable.git') }
|
526
|
+
it { subject.should be_equivalent('git://github.com/martinemde/gitable.git') }
|
527
|
+
it { subject.should be_equivalent('git@github.com:martinemde/gitable.git') }
|
528
|
+
it { subject.should be_equivalent('git@github.com:/martinemde/gitable.git') }
|
529
|
+
it { subject.should_not be_equivalent('git@othergit.com:martinemde/gitable.git') }
|
530
|
+
it { subject.should_not be_equivalent('git@github.com:martinemde/not_gitable.git') }
|
494
531
|
it_sets({
|
495
532
|
:scheme => "https",
|
496
533
|
:user => nil,
|
@@ -500,13 +537,50 @@ describe Gitable::URI do
|
|
500
537
|
:path => "/martinemde/gitable.git",
|
501
538
|
:fragment => nil,
|
502
539
|
:basename => "gitable.git",
|
540
|
+
:ssh? => false,
|
541
|
+
:scp? => false,
|
503
542
|
:github? => true,
|
504
543
|
:to_web_uri => Addressable::URI.parse("https://github.com/martinemde/gitable"),
|
505
544
|
})
|
506
545
|
end
|
507
546
|
|
547
|
+
describe_uri "https://martinemde@github.com/martinemde/gitable.git" do
|
548
|
+
it { subject.to_s.should == @uri }
|
549
|
+
it { subject.should be_equivalent(@uri) }
|
550
|
+
it { subject.should be_equivalent('ssh://git@github.com/martinemde/gitable.git') }
|
551
|
+
it { subject.should be_equivalent('git://github.com/martinemde/gitable.git') }
|
552
|
+
it { subject.should be_equivalent('git@github.com:martinemde/gitable.git') }
|
553
|
+
it { subject.should be_equivalent('git@github.com:/martinemde/gitable.git') }
|
554
|
+
it { subject.should be_equivalent('https://github.com/martinemde/gitable.git') }
|
555
|
+
it { subject.should_not be_equivalent('git@othergit.com:martinemde/gitable.git') }
|
556
|
+
it { subject.should_not be_equivalent('git@github.com:martinemde/not_gitable.git') }
|
557
|
+
it_sets({
|
558
|
+
:scheme => "https",
|
559
|
+
:user => "martinemde",
|
560
|
+
:password => nil,
|
561
|
+
:host => "github.com",
|
562
|
+
:port => nil,
|
563
|
+
:path => "/martinemde/gitable.git",
|
564
|
+
:fragment => nil,
|
565
|
+
:basename => "gitable.git",
|
566
|
+
:ssh? => false,
|
567
|
+
:scp? => false,
|
568
|
+
:github? => true,
|
569
|
+
:authenticated? => true,
|
570
|
+
:interactive_authenticated? => true,
|
571
|
+
:to_web_uri => Addressable::URI.parse("https://github.com/martinemde/gitable"),
|
572
|
+
})
|
573
|
+
end
|
574
|
+
|
508
575
|
describe_uri "git://github.com/martinemde/gitable.git" do
|
509
576
|
it { subject.to_s.should == @uri }
|
577
|
+
it { subject.should be_equivalent(@uri) }
|
578
|
+
it { subject.should be_equivalent('ssh://git@github.com/martinemde/gitable.git') }
|
579
|
+
it { subject.should be_equivalent('git@github.com:martinemde/gitable.git') }
|
580
|
+
it { subject.should be_equivalent('git@github.com:/martinemde/gitable.git') }
|
581
|
+
it { subject.should be_equivalent('https://martinemde@github.com/martinemde/gitable.git') }
|
582
|
+
it { subject.should_not be_equivalent('git@othergit.com:martinemde/gitable.git') }
|
583
|
+
it { subject.should_not be_equivalent('git@github.com:martinemde/not_gitable.git') }
|
510
584
|
it_sets({
|
511
585
|
:scheme => "git",
|
512
586
|
:user => nil,
|
@@ -516,13 +590,23 @@ describe Gitable::URI do
|
|
516
590
|
:path => "/martinemde/gitable.git",
|
517
591
|
:fragment => nil,
|
518
592
|
:basename => "gitable.git",
|
593
|
+
:ssh? => false,
|
594
|
+
:scp? => false,
|
519
595
|
:github? => true,
|
596
|
+
:authenticated? => false,
|
597
|
+
:interactive_authenticated? => false,
|
520
598
|
:to_web_uri => Addressable::URI.parse("https://github.com/martinemde/gitable"),
|
521
599
|
})
|
522
600
|
end
|
523
601
|
|
524
602
|
describe_uri "git@github.com:martinemde/gitable.git" do
|
525
603
|
it { subject.to_s.should == @uri }
|
604
|
+
it { subject.should be_equivalent(@uri) }
|
605
|
+
it { subject.should be_equivalent('ssh://git@github.com/martinemde/gitable.git') }
|
606
|
+
it { subject.should be_equivalent('git://github.com/martinemde/gitable.git') }
|
607
|
+
it { subject.should be_equivalent('https://martinemde@github.com/martinemde/gitable.git') }
|
608
|
+
it { subject.should_not be_equivalent('git@othergit.com:martinemde/gitable.git') }
|
609
|
+
it { subject.should_not be_equivalent('git@github.com:martinemde/not_gitable.git') }
|
526
610
|
it_sets({
|
527
611
|
:scheme => nil,
|
528
612
|
:inferred_scheme => 'ssh',
|
@@ -535,7 +619,9 @@ describe Gitable::URI do
|
|
535
619
|
:basename => "gitable.git",
|
536
620
|
:project_name => "gitable",
|
537
621
|
:ssh? => true,
|
622
|
+
:scp? => true,
|
538
623
|
:authenticated? => true,
|
624
|
+
:interactive_authenticated? => false,
|
539
625
|
:github? => true,
|
540
626
|
:to_web_uri => Addressable::URI.parse("https://github.com/martinemde/gitable"),
|
541
627
|
})
|
metadata
CHANGED
@@ -1,91 +1,70 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: gitable
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.2.2
|
5
5
|
prerelease:
|
6
|
-
segments:
|
7
|
-
- 0
|
8
|
-
- 2
|
9
|
-
- 1
|
10
|
-
version: 0.2.1
|
11
6
|
platform: ruby
|
12
|
-
authors:
|
7
|
+
authors:
|
13
8
|
- Martin Emde
|
14
9
|
autorequire:
|
15
10
|
bindir: bin
|
16
11
|
cert_chain: []
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
dependencies:
|
21
|
-
- !ruby/object:Gem::Dependency
|
12
|
+
date: 2012-01-04 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
22
15
|
name: addressable
|
23
|
-
|
24
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
16
|
+
requirement: &70179914661980 !ruby/object:Gem::Requirement
|
25
17
|
none: false
|
26
|
-
requirements:
|
27
|
-
- -
|
28
|
-
- !ruby/object:Gem::Version
|
29
|
-
|
30
|
-
segments:
|
31
|
-
- 0
|
32
|
-
version: "0"
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
33
22
|
type: :runtime
|
34
|
-
version_requirements: *id001
|
35
|
-
- !ruby/object:Gem::Dependency
|
36
|
-
name: rspec
|
37
23
|
prerelease: false
|
38
|
-
|
24
|
+
version_requirements: *70179914661980
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: rspec
|
27
|
+
requirement: &70179914661440 !ruby/object:Gem::Requirement
|
39
28
|
none: false
|
40
|
-
requirements:
|
29
|
+
requirements:
|
41
30
|
- - ~>
|
42
|
-
- !ruby/object:Gem::Version
|
43
|
-
|
44
|
-
segments:
|
45
|
-
- 2
|
46
|
-
- 0
|
47
|
-
version: "2.0"
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '2.0'
|
48
33
|
type: :development
|
49
|
-
version_requirements: *id002
|
50
|
-
- !ruby/object:Gem::Dependency
|
51
|
-
name: rake
|
52
34
|
prerelease: false
|
53
|
-
|
35
|
+
version_requirements: *70179914661440
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: rake
|
38
|
+
requirement: &70179914661020 !ruby/object:Gem::Requirement
|
54
39
|
none: false
|
55
|
-
requirements:
|
56
|
-
- -
|
57
|
-
- !ruby/object:Gem::Version
|
58
|
-
|
59
|
-
segments:
|
60
|
-
- 0
|
61
|
-
version: "0"
|
40
|
+
requirements:
|
41
|
+
- - ! '>='
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: '0'
|
62
44
|
type: :development
|
63
|
-
version_requirements: *id003
|
64
|
-
- !ruby/object:Gem::Dependency
|
65
|
-
name: rcov
|
66
45
|
prerelease: false
|
67
|
-
|
46
|
+
version_requirements: *70179914661020
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: rcov
|
49
|
+
requirement: &70179914660560 !ruby/object:Gem::Requirement
|
68
50
|
none: false
|
69
|
-
requirements:
|
70
|
-
- -
|
71
|
-
- !ruby/object:Gem::Version
|
72
|
-
|
73
|
-
segments:
|
74
|
-
- 0
|
75
|
-
version: "0"
|
51
|
+
requirements:
|
52
|
+
- - ! '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
76
55
|
type: :development
|
77
|
-
|
78
|
-
|
79
|
-
|
56
|
+
prerelease: false
|
57
|
+
version_requirements: *70179914660560
|
58
|
+
description: Addressable::URI for Git URIs with special handling for scp-style URIs
|
59
|
+
that Addressable doesn't like.
|
60
|
+
email:
|
80
61
|
- martin.emde@gmail.com
|
81
62
|
executables: []
|
82
|
-
|
83
63
|
extensions: []
|
84
|
-
|
85
|
-
extra_rdoc_files:
|
64
|
+
extra_rdoc_files:
|
86
65
|
- LICENSE
|
87
66
|
- README.rdoc
|
88
|
-
files:
|
67
|
+
files:
|
89
68
|
- .document
|
90
69
|
- .gitignore
|
91
70
|
- Gemfile
|
@@ -100,41 +79,37 @@ files:
|
|
100
79
|
- spec/gitable_spec.rb
|
101
80
|
- spec/heuristic_parse_spec.rb
|
102
81
|
- spec/spec_helper.rb
|
103
|
-
has_rdoc: true
|
104
82
|
homepage: http://github.org/martinemde/gitable
|
105
83
|
licenses: []
|
106
|
-
|
107
84
|
post_install_message:
|
108
85
|
rdoc_options: []
|
109
|
-
|
110
|
-
require_paths:
|
86
|
+
require_paths:
|
111
87
|
- lib
|
112
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
88
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
113
89
|
none: false
|
114
|
-
requirements:
|
115
|
-
- -
|
116
|
-
- !ruby/object:Gem::Version
|
117
|
-
|
118
|
-
segments:
|
90
|
+
requirements:
|
91
|
+
- - ! '>='
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: '0'
|
94
|
+
segments:
|
119
95
|
- 0
|
120
|
-
|
121
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
96
|
+
hash: 925310224133331721
|
97
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
122
98
|
none: false
|
123
|
-
requirements:
|
124
|
-
- -
|
125
|
-
- !ruby/object:Gem::Version
|
126
|
-
|
127
|
-
segments:
|
99
|
+
requirements:
|
100
|
+
- - ! '>='
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: '0'
|
103
|
+
segments:
|
128
104
|
- 0
|
129
|
-
|
105
|
+
hash: 925310224133331721
|
130
106
|
requirements: []
|
131
|
-
|
132
107
|
rubyforge_project:
|
133
|
-
rubygems_version: 1.
|
108
|
+
rubygems_version: 1.8.10
|
134
109
|
signing_key:
|
135
110
|
specification_version: 3
|
136
111
|
summary: Addressable::URI for Git. Gitable::URI.
|
137
|
-
test_files:
|
112
|
+
test_files:
|
138
113
|
- spec/describe_uri.rb
|
139
114
|
- spec/gitable_spec.rb
|
140
115
|
- spec/heuristic_parse_spec.rb
|