gitable 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
data/gitable.gemspec CHANGED
@@ -1,7 +1,7 @@
1
1
  # -*- encoding: utf-8 -*-
2
2
  Gem::Specification.new do |s|
3
3
  s.name = "gitable"
4
- s.version = "0.1.0"
4
+ s.version = "0.1.1"
5
5
  s.authors = ["Martin Emde"]
6
6
  s.email = ["martin.emde@gmail.com"]
7
7
  s.homepage = "http://github.org/martinemde/gitable"
@@ -8,7 +8,7 @@ module Gitable
8
8
  # git@github.com:martinemde/gitable.git
9
9
  #
10
10
  # Without breaking URIs like these:
11
- #
11
+ #
12
12
  # git@host.com:/home/martinemde/gitable.git
13
13
  #
14
14
  # @param [String] new_path The new path to be set.
@@ -35,6 +35,13 @@ module Gitable
35
35
  end
36
36
  end
37
37
 
38
+ # Return the actual scheme even though we don't show it
39
+ #
40
+ # @return [String] always 'ssh' for scp style URIs
41
+ def normalized_scheme
42
+ 'ssh'
43
+ end
44
+
38
45
  protected
39
46
 
40
47
  def validate
data/lib/gitable/uri.rb CHANGED
@@ -59,7 +59,6 @@ module Gitable
59
59
  add
60
60
  end
61
61
 
62
- ##
63
62
  # Tries to guess the project name of the repository.
64
63
  #
65
64
  # @return [String] Project name without .git
@@ -67,6 +66,20 @@ module Gitable
67
66
  basename.sub(/\.git$/,'')
68
67
  end
69
68
 
69
+ # Detect local filesystem URIs.
70
+ #
71
+ # @return [Boolean] Is the URI local
72
+ def local?
73
+ scheme == 'file' || host.nil?
74
+ end
75
+
76
+ # Detect URIs that connect over ssh
77
+ #
78
+ # @return [Boolean] true if the URI uses ssh?
79
+ def ssh?
80
+ !!(normalized_scheme =~ /ssh/)
81
+ end
82
+
70
83
  # Set an extension name, replacing one if it exists.
71
84
  #
72
85
  # If there is no basename (i.e. no words in the path) this method call will
data/spec/gitable_spec.rb CHANGED
@@ -100,15 +100,17 @@ describe Gitable::URI do
100
100
  end
101
101
 
102
102
  expected = {
103
- :user => nil,
104
- :password => nil,
105
- :host => "host.xz",
106
- :port => nil,
107
- :path => "/path/to/repo.git/",
108
- :basename => "repo.git",
109
- :query => nil,
110
- :fragment => nil,
111
- :project_name => "repo"
103
+ :user => nil,
104
+ :password => nil,
105
+ :host => "host.xz",
106
+ :port => nil,
107
+ :path => "/path/to/repo.git/",
108
+ :basename => "repo.git",
109
+ :query => nil,
110
+ :fragment => nil,
111
+ :project_name => "repo",
112
+ :local? => false,
113
+ :ssh? => false,
112
114
  }
113
115
 
114
116
  describe_uri "rsync://host.xz/path/to/repo.git/" do
@@ -168,7 +170,8 @@ describe Gitable::URI do
168
170
  describe_uri "git+ssh://host.xz/path/to/repo.git/" do
169
171
  it { subject.to_s.should == @uri }
170
172
  it_sets expected.merge({
171
- :scheme => "git+ssh",
173
+ :scheme => "git+ssh",
174
+ :ssh? => true,
172
175
  })
173
176
  end
174
177
 
@@ -207,136 +210,158 @@ describe Gitable::URI do
207
210
  describe_uri "ssh://host.xz/path/to/repo.git/" do
208
211
  it { subject.to_s.should == @uri }
209
212
  it_sets expected.merge({
210
- :scheme => "ssh",
213
+ :scheme => "ssh",
214
+ :ssh? => true,
211
215
  })
212
216
  end
213
217
 
214
218
  describe_uri "ssh://user@host.xz/path/to/repo.git/" do
215
219
  it { subject.to_s.should == @uri }
216
220
  it_sets expected.merge({
217
- :scheme => "ssh",
218
- :user => "user",
221
+ :scheme => "ssh",
222
+ :user => "user",
223
+ :ssh? => true,
219
224
  })
220
225
  end
221
226
 
222
227
  describe_uri "ssh://host.xz/path/to/repo.git/" do
223
228
  it { subject.to_s.should == @uri }
224
229
  it_sets expected.merge({
225
- :scheme => "ssh",
230
+ :scheme => "ssh",
231
+ :ssh? => true,
226
232
  })
227
233
  end
228
234
 
229
235
  describe_uri "ssh://host.xz:8888/path/to/repo.git/" do
230
236
  it { subject.to_s.should == @uri }
231
237
  it_sets expected.merge({
232
- :scheme => "ssh",
233
- :port => 8888,
238
+ :scheme => "ssh",
239
+ :port => 8888,
240
+ :ssh? => true,
234
241
  })
235
242
  end
236
243
 
237
244
  describe_uri "ssh://user@host.xz/path/to/repo.git/" do
238
245
  it { subject.to_s.should == @uri }
239
246
  it_sets expected.merge({
240
- :user => "user",
241
- :scheme => "ssh",
247
+ :user => "user",
248
+ :scheme => "ssh",
249
+ :ssh? => true,
242
250
  })
243
251
  end
244
252
 
245
253
  describe_uri "ssh://user@host.xz:8888/path/to/repo.git/" do
246
254
  it { subject.to_s.should == @uri }
247
255
  it_sets expected.merge({
248
- :scheme => "ssh",
249
- :user => "user",
250
- :port => 8888,
256
+ :scheme => "ssh",
257
+ :user => "user",
258
+ :port => 8888,
259
+ :ssh? => true,
251
260
  })
252
261
  end
253
262
 
254
263
  describe_uri "ssh://host.xz/~user/path/to/repo.git/" do
255
264
  it { subject.to_s.should == @uri }
256
265
  it_sets expected.merge({
257
- :scheme => "ssh",
258
- :user => nil,
259
- :path => "/~user/path/to/repo.git/",
266
+ :scheme => "ssh",
267
+ :user => nil,
268
+ :path => "/~user/path/to/repo.git/",
269
+ :ssh? => true,
260
270
  })
261
271
  end
262
272
 
263
273
  describe_uri "ssh://user@host.xz/~user/path/to/repo.git/" do
264
274
  it { subject.to_s.should == @uri }
265
275
  it_sets expected.merge({
266
- :scheme => "ssh",
267
- :user => "user",
268
- :path => "/~user/path/to/repo.git/",
276
+ :scheme => "ssh",
277
+ :user => "user",
278
+ :path => "/~user/path/to/repo.git/",
279
+ :ssh? => true,
269
280
  })
270
281
  end
271
282
 
272
283
  describe_uri "ssh://host.xz/~/path/to/repo.git" do
273
284
  it { subject.to_s.should == @uri }
274
285
  it_sets expected.merge({
275
- :scheme => "ssh",
276
- :path => "/~/path/to/repo.git",
286
+ :scheme => "ssh",
287
+ :path => "/~/path/to/repo.git",
288
+ :ssh? => true,
277
289
  })
278
290
  end
279
291
 
280
292
  describe_uri "ssh://user@host.xz/~/path/to/repo.git" do
281
293
  it { subject.to_s.should == @uri }
282
294
  it_sets expected.merge({
283
- :scheme => "ssh",
284
- :user => "user",
285
- :path => "/~/path/to/repo.git",
295
+ :scheme => "ssh",
296
+ :user => "user",
297
+ :path => "/~/path/to/repo.git",
298
+ :ssh? => true,
286
299
  })
287
300
  end
288
301
 
289
302
  describe_uri "host.xz:/path/to/repo.git/" do
290
303
  it { subject.to_s.should == @uri }
291
304
  it_sets expected.merge({
292
- :scheme => nil,
293
- :user => nil,
294
- :path => "/path/to/repo.git/",
305
+ :scheme => nil,
306
+ :normalized_scheme => 'ssh',
307
+ :user => nil,
308
+ :path => "/path/to/repo.git/",
309
+ :ssh? => true,
295
310
  })
296
311
  end
297
312
 
298
313
  describe_uri "user@host.xz:/path/to/repo.git/" do
299
314
  it { subject.to_s.should == @uri }
300
315
  it_sets expected.merge({
301
- :scheme => nil,
302
- :user => "user",
303
- :path => "/path/to/repo.git/",
316
+ :scheme => nil,
317
+ :normalized_scheme => 'ssh',
318
+ :user => "user",
319
+ :path => "/path/to/repo.git/",
320
+ :ssh? => true,
304
321
  })
305
322
  end
306
323
 
307
324
  describe_uri "host.xz:~user/path/to/repo.git/" do
308
325
  it { subject.to_s.should == @uri }
309
326
  it_sets expected.merge({
310
- :scheme => nil,
311
- :user => nil,
312
- :path => "~user/path/to/repo.git/",
327
+ :scheme => nil,
328
+ :normalized_scheme => 'ssh',
329
+ :user => nil,
330
+ :path => "~user/path/to/repo.git/",
331
+ :ssh? => true,
313
332
  })
314
333
  end
315
334
 
316
335
  describe_uri "user@host.xz:~user/path/to/repo.git/" do
317
336
  it { subject.to_s.should == @uri }
318
337
  it_sets expected.merge({
319
- :scheme => nil,
320
- :user => "user",
321
- :path => "~user/path/to/repo.git/",
338
+ :scheme => nil,
339
+ :normalized_scheme => 'ssh',
340
+ :user => "user",
341
+ :path => "~user/path/to/repo.git/",
342
+ :ssh? => true,
322
343
  })
323
344
  end
324
345
 
325
346
  describe_uri "host.xz:path/to/repo.git" do
326
347
  it { subject.to_s.should == @uri }
327
348
  it_sets expected.merge({
328
- :scheme => nil,
329
- :user => nil,
330
- :path => "path/to/repo.git",
349
+ :scheme => nil,
350
+ :normalized_scheme => 'ssh',
351
+ :user => nil,
352
+ :path => "path/to/repo.git",
353
+ :ssh? => true,
331
354
  })
332
355
  end
333
356
 
334
357
  describe_uri "user@host.xz:path/to/repo.git" do
335
358
  it { subject.to_s.should == @uri }
336
359
  it_sets expected.merge({
337
- :scheme => nil,
338
- :user => "user",
339
- :path => "path/to/repo.git",
360
+ :scheme => nil,
361
+ :normalized_scheme => 'ssh',
362
+ :user => "user",
363
+ :path => "path/to/repo.git",
364
+ :ssh? => true,
340
365
  })
341
366
  end
342
367
 
@@ -346,6 +371,7 @@ describe Gitable::URI do
346
371
  :scheme => nil,
347
372
  :host => nil,
348
373
  :path => "/path/to/repo.git/",
374
+ :local? => true,
349
375
  })
350
376
  end
351
377
 
@@ -355,20 +381,22 @@ describe Gitable::URI do
355
381
  :scheme => "file",
356
382
  :host => "", # I don't really like this but it doesn't hurt anything.
357
383
  :path => "/path/to/repo.git/",
384
+ :local? => true,
358
385
  })
359
386
  end
360
387
 
361
388
  describe_uri "ssh://git@github.com/martinemde/gitable.git" do
362
389
  it { subject.to_s.should == @uri }
363
390
  it_sets({
364
- :scheme => "ssh",
365
- :user => "git",
366
- :password => nil,
367
- :host => "github.com",
368
- :port => nil,
369
- :path => "/martinemde/gitable.git",
370
- :fragment => nil,
371
- :basename => "gitable.git",
391
+ :scheme => "ssh",
392
+ :user => "git",
393
+ :password => nil,
394
+ :host => "github.com",
395
+ :port => nil,
396
+ :path => "/martinemde/gitable.git",
397
+ :fragment => nil,
398
+ :basename => "gitable.git",
399
+ :ssh? => true,
372
400
  })
373
401
  end
374
402
 
@@ -403,15 +431,17 @@ describe Gitable::URI do
403
431
  describe_uri "git@github.com:martinemde/gitable.git" do
404
432
  it { subject.to_s.should == @uri }
405
433
  it_sets({
406
- :scheme => nil,
407
- :user => "git",
408
- :password => nil,
409
- :host => "github.com",
410
- :port => nil,
411
- :path => "martinemde/gitable.git",
412
- :fragment => nil,
413
- :basename => "gitable.git",
414
- :project_name => "gitable",
434
+ :scheme => nil,
435
+ :normalized_scheme => 'ssh',
436
+ :user => "git",
437
+ :password => nil,
438
+ :host => "github.com",
439
+ :port => nil,
440
+ :path => "martinemde/gitable.git",
441
+ :fragment => nil,
442
+ :basename => "gitable.git",
443
+ :project_name => "gitable",
444
+ :ssh? => true,
415
445
  })
416
446
  end
417
447
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gitable
3
3
  version: !ruby/object:Gem::Version
4
- hash: 27
4
+ hash: 25
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 0
10
- version: 0.1.0
9
+ - 1
10
+ version: 0.1.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - Martin Emde
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-12-04 00:00:00 -08:00
18
+ date: 2010-12-05 00:00:00 -08:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency