gitable 0.0.3 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore CHANGED
@@ -25,4 +25,3 @@ vendor/gems
25
25
  Gemfile.lock
26
26
 
27
27
  ## PROJECT::SPECIFIC
28
- gitable.gemspec
data/Gemfile CHANGED
@@ -1,26 +1,3 @@
1
- source :gemcutter
1
+ source "http://rubygems.org"
2
2
 
3
- group :runtime do
4
- gem 'addressable', :require => 'addressable/uri'
5
- end
6
-
7
- group :release do
8
- gem 'bundler'
9
- gem 'jeweler'
10
- end
11
-
12
- group :development do
13
- gem 'rspec', :require => 'spec'
14
- gem 'ZenTest'
15
- gem 'rake'
16
- gem 'rcov'
17
- gem 'ruby-debug'
18
- gem 'yard'
19
- gem 'reek'
20
- gem 'roodi'
21
- end
22
-
23
- group :release do
24
- gem 'jeweler'
25
- gem 'bundler', '>=0.9.7'
26
- end
3
+ gemspec
data/Rakefile CHANGED
@@ -1,25 +1,5 @@
1
- require 'rubygems'
2
1
  require 'bundler'
3
-
4
- begin
5
- require 'jeweler'
6
- Jeweler::Tasks.new do |gem|
7
- gem.name = "gitable"
8
- gem.summary = %Q{Addressable::URI for Git}
9
- gem.description = %Q{It's like Addressable::URI but for Git. Gitable.}
10
- gem.email = "martin.emde@gmail.com"
11
- gem.homepage = "http://github.com/martinemde/gitable"
12
- gem.authors = ["Martin Emde"]
13
-
14
- bundle = Bundler::Definition.from_gemfile('Gemfile')
15
- bundle.dependencies.each do |dep|
16
- gem.add_dependency(dep.name, dep.requirement.to_s) if dep.groups.include?(:runtime)
17
- end
18
- end
19
- Jeweler::GemcutterTasks.new
20
- rescue LoadError
21
- puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
22
- end
2
+ Bundler::GemHelper.install_tasks
23
3
 
24
4
  require 'spec/rake/spectask'
25
5
  Spec::Rake::SpecTask.new(:spec) do |spec|
@@ -27,45 +7,11 @@ Spec::Rake::SpecTask.new(:spec) do |spec|
27
7
  spec.spec_files = FileList['spec/**/*_spec.rb']
28
8
  end
29
9
 
10
+ task :default => :spec
11
+
30
12
  Spec::Rake::SpecTask.new(:rcov) do |spec|
31
13
  spec.libs << 'lib' << 'spec'
32
14
  spec.pattern = 'spec/**/*_spec.rb'
33
15
  spec.rcov = true
34
- spec.rcov_opts << '--exclude' << 'spec,vendor,Library'
35
- end
36
-
37
- begin
38
- require 'reek/adapters/rake_task'
39
- Reek::RakeTask.new do |t|
40
- t.fail_on_error = true
41
- t.verbose = false
42
- t.source_files = 'lib/**/*.rb'
43
- end
44
- rescue LoadError
45
- task :reek do
46
- abort "Reek is not available. In order to run reek, you must: sudo gem install reek"
47
- end
48
- end
49
-
50
- begin
51
- require 'roodi'
52
- require 'roodi_task'
53
- RoodiTask.new do |t|
54
- t.verbose = false
55
- end
56
- rescue LoadError
57
- task :roodi do
58
- abort "Roodi is not available. In order to run roodi, you must: sudo gem install roodi"
59
- end
60
- end
61
-
62
- task :default => :spec
63
-
64
- begin
65
- require 'yard'
66
- YARD::Rake::YardocTask.new
67
- rescue LoadError
68
- task :yardoc do
69
- abort "YARD is not available. In order to run yardoc, you must: sudo gem install yard"
70
- end
16
+ spec.rcov_opts << '--exclude' << 'spec,vendor,Library,.bundle'
71
17
  end
data/gitable.gemspec ADDED
@@ -0,0 +1,20 @@
1
+ # -*- encoding: utf-8 -*-
2
+ Gem::Specification.new do |s|
3
+ s.name = "gitable"
4
+ s.version = "0.1.0"
5
+ s.authors = ["Martin Emde"]
6
+ s.email = ["martin.emde@gmail.com"]
7
+ s.homepage = "http://github.org/martinemde/gitable"
8
+ s.summary = %q{Addressable::URI for Git. Gitable::URI.}
9
+ s.description = %q{Addressable::URI for Git URIs with special handling for scp-style URIs that Addressable doesn't like.}
10
+
11
+ s.add_dependency "addressable"
12
+ s.add_development_dependency "rspec"
13
+ s.add_development_dependency "rake"
14
+
15
+ s.files = `git ls-files`.split("\n")
16
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
17
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
18
+ s.require_paths = ["lib"]
19
+ s.extra_rdoc_files = ["LICENSE", "README.rdoc"]
20
+ end
@@ -15,7 +15,7 @@ module Gitable
15
15
  # @return [String] The same path passed in.
16
16
  def path=(new_path)
17
17
  super
18
- @path = path.sub(%r|^/|,'') if new_path[0] != ?/
18
+ @path = path.sub(%r|^/|,'') if new_path[0] != ?/ # addressable likes to add a /
19
19
  @path
20
20
  end
21
21
 
@@ -38,21 +38,21 @@ module Gitable
38
38
  protected
39
39
 
40
40
  def validate
41
- return if !!@validation_deferred
42
- if scheme != nil &&
43
- (host == nil || host == "") &&
44
- (path == nil || path == "")
45
- raise InvalidURIError,
46
- "Absolute URI missing hierarchical segment: '#{to_s}'"
41
+ return if @validation_deferred
42
+
43
+ if !scheme.to_s.empty? && host.to_s.empty? && path.to_s.empty?
44
+ raise InvalidURIError, "Absolute URI missing hierarchical segment: '#{to_s}'"
47
45
  end
48
- if host == nil
49
- if port != nil ||
50
- user != nil ||
51
- password != nil
52
- raise InvalidURIError, "Hostname not supplied: '#{to_s}'"
53
- end
46
+
47
+ if host.nil? && !path_only?
48
+ raise InvalidURIError, "Hostname not supplied: '#{to_s}'"
54
49
  end
55
- return nil
50
+
51
+ nil
52
+ end
53
+
54
+ def path_only?
55
+ host.nil? && port.nil? && user.nil? && password.nil?
56
56
  end
57
57
  end
58
58
  end
data/lib/gitable/uri.rb CHANGED
@@ -81,12 +81,11 @@ module Gitable
81
81
  extname
82
82
  end
83
83
 
84
- # Addressable does basename wrong with there's no basename.
84
+ # Addressable does basename wrong when there's no basename.
85
85
  # It returns "/" for something like "http://host.com/"
86
86
  def basename
87
87
  base = super
88
- return "" if base == "/"
89
- base
88
+ base == "/" ? "" : base
90
89
  end
91
90
 
92
91
  # Set the basename, replacing it if it exists.
@@ -104,5 +103,16 @@ module Gitable
104
103
  end
105
104
  basename
106
105
  end
106
+
107
+ protected
108
+
109
+ def validate
110
+ return if @validation_deferred
111
+ super
112
+
113
+ if user && scheme != 'ssh'
114
+ raise InvalidURIError, "Git does not support URIs with 'user@' other than ssh:// and scp-style"
115
+ end
116
+ end
107
117
  end
108
118
  end
data/spec/gitable_spec.rb CHANGED
@@ -1,4 +1,4 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
1
+ require 'spec_helper'
2
2
 
3
3
  describe Gitable::URI do
4
4
  before do
@@ -41,28 +41,29 @@ describe Gitable::URI do
41
41
  # Valid Git URIs according to git-clone documentation at this url:
42
42
  # http://www.kernel.org/pub/software/scm/git/docs/git-clone.html#_git_urls_a_id_urls_a
43
43
  #
44
- # rsync://host.xz/path/to/repo.git/
45
- # http://host.xz[:port]/path/to/repo.git/
46
- # https://host.xz[:port]/path/to/repo.git/
47
- # git://host.xz[:port]/path/to/repo.git/
48
- # git://host.xz[:port]/~user/path/to/repo.git/
44
+ # Git natively supports ssh, git, http, https, ftp, ftps, and rsync protocols. The following syntaxes may be used with them:
45
+ #
49
46
  # ssh://[user@]host.xz[:port]/path/to/repo.git/
50
- # ssh://[user@]host.xz/path/to/repo.git/
51
- # ssh://[user@]host.xz/~user/path/to/repo.git/
52
- # ssh://[user@]host.xz/~/path/to/repo.git
47
+ # git://host.xz[:port]/path/to/repo.git/
48
+ # http[s]://host.xz[:port]/path/to/repo.git/
49
+ # ftp[s]://host.xz[:port]/path/to/repo.git/
50
+ # rsync://host.xz/path/to/repo.git/
51
+ #
52
+ # An alternative scp-like syntax may also be used with the ssh protocol:
53
53
  #
54
- # (from the git docs)
55
- # SSH is the default transport protocol over the network. You can optionally specify which user to log-in as, and an alternate, scp-like syntax is also supported. Both syntaxes support username expansion, as does the native git protocol, but only the former supports port specification. The following three are identical to the last three above, respectively:
54
+ # [user@]host.xz:path/to/repo.git/
56
55
  #
57
- # [user@]host.xz:/path/to/repo.git/
58
- # [user@]host.xz:~user/path/to/repo.git/
59
- # [user@]host.xz:path/to/repo.git
56
+ # The ssh and git protocols additionally support ~username expansion:
60
57
  #
61
- # To sync with a local directory, you can use:
58
+ # ssh://[user@]host.xz[:port]/~[user]/path/to/repo.git/
59
+ # git://host.xz[:port]/~[user]/path/to/repo.git/
60
+ # [user@]host.xz:/~[user]/path/to/repo.git/
61
+ #
62
+ # For local repositories, also supported by git natively, the following syntaxes may be used:
62
63
  #
63
64
  # /path/to/repo.git/
64
65
  # file:///path/to/repo.git/
65
- #
66
+ #
66
67
 
67
68
  describe ".parse" do
68
69
  it "returns a Gitable::URI" do
@@ -87,7 +88,8 @@ describe Gitable::URI do
87
88
  context "(bad uris)" do
88
89
  [
89
90
  "http://",
90
- "blah:"
91
+ "blah:",
92
+ "git://user@are.not/allowed/on/normal/uris.git" # if I'm reading the docs correctly
91
93
  ].each do |uri|
92
94
  it "raises an Gitable::URI::InvalidURIError with #{uri.inspect}" do
93
95
  lambda {
data/spec/spec_helper.rb CHANGED
@@ -1,9 +1,15 @@
1
+ unless defined? Bundler
2
+ require 'rubygems'
3
+ require 'bundler'
4
+ Bundler.setup
5
+ end
6
+
1
7
  $LOAD_PATH.unshift(File.dirname(__FILE__))
2
8
  $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
3
9
  require 'gitable'
4
10
  require 'spec'
5
11
  require 'spec/autorun'
6
- require File.join(File.dirname(__FILE__), 'describe_uri')
12
+ require 'describe_uri'
7
13
 
8
14
  Spec::Runner.configure do |config|
9
15
  config.extend DescribeURI
metadata CHANGED
@@ -1,12 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gitable
3
3
  version: !ruby/object:Gem::Version
4
+ hash: 27
4
5
  prerelease: false
5
6
  segments:
6
7
  - 0
8
+ - 1
7
9
  - 0
8
- - 3
9
- version: 0.0.3
10
+ version: 0.1.0
10
11
  platform: ruby
11
12
  authors:
12
13
  - Martin Emde
@@ -14,23 +15,54 @@ autorequire:
14
15
  bindir: bin
15
16
  cert_chain: []
16
17
 
17
- date: 2010-04-27 00:00:00 -07:00
18
+ date: 2010-12-04 00:00:00 -08:00
18
19
  default_executable:
19
20
  dependencies:
20
21
  - !ruby/object:Gem::Dependency
22
+ name: addressable
23
+ prerelease: false
24
+ requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ hash: 3
30
+ segments:
31
+ - 0
32
+ version: "0"
21
33
  type: :runtime
22
- version_requirements: &id001 !ruby/object:Gem::Requirement
34
+ version_requirements: *id001
35
+ - !ruby/object:Gem::Dependency
36
+ name: rspec
37
+ prerelease: false
38
+ requirement: &id002 !ruby/object:Gem::Requirement
39
+ none: false
23
40
  requirements:
24
41
  - - ">="
25
42
  - !ruby/object:Gem::Version
43
+ hash: 3
26
44
  segments:
27
45
  - 0
28
46
  version: "0"
29
- requirement: *id001
30
- name: addressable
47
+ type: :development
48
+ version_requirements: *id002
49
+ - !ruby/object:Gem::Dependency
50
+ name: rake
31
51
  prerelease: false
32
- description: It's like Addressable::URI but for Git. Gitable.
33
- email: martin.emde@gmail.com
52
+ requirement: &id003 !ruby/object:Gem::Requirement
53
+ none: false
54
+ requirements:
55
+ - - ">="
56
+ - !ruby/object:Gem::Version
57
+ hash: 3
58
+ segments:
59
+ - 0
60
+ version: "0"
61
+ type: :development
62
+ version_requirements: *id003
63
+ description: Addressable::URI for Git URIs with special handling for scp-style URIs that Addressable doesn't like.
64
+ email:
65
+ - martin.emde@gmail.com
34
66
  executables: []
35
67
 
36
68
  extensions: []
@@ -46,6 +78,7 @@ files:
46
78
  - README.rdoc
47
79
  - Rakefile
48
80
  - VERSION.yml
81
+ - gitable.gemspec
49
82
  - lib/gitable.rb
50
83
  - lib/gitable/scp_uri.rb
51
84
  - lib/gitable/uri.rb
@@ -55,37 +88,42 @@ files:
55
88
  - spec/spec.opts
56
89
  - spec/spec_helper.rb
57
90
  has_rdoc: true
58
- homepage: http://github.com/martinemde/gitable
91
+ homepage: http://github.org/martinemde/gitable
59
92
  licenses: []
60
93
 
61
94
  post_install_message:
62
- rdoc_options:
63
- - --charset=UTF-8
95
+ rdoc_options: []
96
+
64
97
  require_paths:
65
98
  - lib
66
99
  required_ruby_version: !ruby/object:Gem::Requirement
100
+ none: false
67
101
  requirements:
68
102
  - - ">="
69
103
  - !ruby/object:Gem::Version
104
+ hash: 3
70
105
  segments:
71
106
  - 0
72
107
  version: "0"
73
108
  required_rubygems_version: !ruby/object:Gem::Requirement
109
+ none: false
74
110
  requirements:
75
111
  - - ">="
76
112
  - !ruby/object:Gem::Version
113
+ hash: 3
77
114
  segments:
78
115
  - 0
79
116
  version: "0"
80
117
  requirements: []
81
118
 
82
119
  rubyforge_project:
83
- rubygems_version: 1.3.6
120
+ rubygems_version: 1.3.7
84
121
  signing_key:
85
122
  specification_version: 3
86
- summary: Addressable::URI for Git
123
+ summary: Addressable::URI for Git. Gitable::URI.
87
124
  test_files:
88
125
  - spec/describe_uri.rb
89
126
  - spec/gitable_spec.rb
90
127
  - spec/heuristic_parse_spec.rb
128
+ - spec/spec.opts
91
129
  - spec/spec_helper.rb