git_clone_url 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 44e25b0c0510721a7ef50c79d8161138156edce1
4
- data.tar.gz: 711729247df08a80167a0672460ae33cd1e9506e
3
+ metadata.gz: 7a065062d97efddcc19e9eebf13762f6ee904329
4
+ data.tar.gz: be75bc3c88635cc581ab860cded7de8de076456e
5
5
  SHA512:
6
- metadata.gz: a480c6ecb0feff3bd5b31e063fdf7e2e411fbc2bbf823b81da4f94a015ce3363da1b0159b35a181052e2289b6d39ac0b5f4562b83b9cd234003f99ae9ce51b9d
7
- data.tar.gz: 619c21ff2fe40fa0b7bfe1c4a4bc1543a12a6232efb7a434bf502132894cabd6ae8f0d94fe80ca54726b1bcea2c4be422dc631b2fdc05b4e158d4cf70f79f4a0
6
+ metadata.gz: 91cddbb4761db1d19834af49f0a0a1abc9606e19da8ba15361c2745e712863fde138a216ce7ff70758a96728be817a9d1e726aae72e8193207a7da52e843ed18
7
+ data.tar.gz: 65fd8ccf9d57536e8e41148bea21085d055ecc93618a22f9a5b25f1301fe607bd598607c0b13e8d247fa5e809b402cc763feb2183430ebbc056fa6df6a6b7df9
@@ -0,0 +1,17 @@
1
+ 'use strict';
2
+ var execSync = require('child_process').execSync;
3
+ var URI = require('urijs');
4
+
5
+ var gemspec = JSON.parse(execSync('bundle exec parse-gemspec-cli git_clone_url.gemspec'));
6
+ var homepageUrl = gemspec.homepage;
7
+ var url = new URI(homepageUrl);
8
+ var host = url.protocol() + '://' + url.authority();
9
+ var owner = url.pathname().split('/')[1];
10
+ var repository = url.pathname().split('/')[2];
11
+
12
+ module.exports = {
13
+ version: gemspec.version,
14
+ host: host,
15
+ owner: owner,
16
+ repository: repository
17
+ };
data/.gitignore CHANGED
@@ -7,3 +7,4 @@
7
7
  /pkg/
8
8
  /spec/reports/
9
9
  /tmp/
10
+ /node_modules
data/.rubocop.yml CHANGED
@@ -12,6 +12,3 @@ Metrics/LineLength:
12
12
  Style/FileName:
13
13
  Exclude:
14
14
  - exe/*
15
-
16
- Style/RegexpLiteral:
17
- MaxSlashes: 0
data/Gemfile CHANGED
@@ -2,3 +2,7 @@ source 'https://rubygems.org'
2
2
 
3
3
  # Specify your gem's dependencies in git_clone_url.gemspec
4
4
  gemspec
5
+
6
+ gem 'parse_gemspec-cli'
7
+ gem 'rubocop'
8
+ gem 'yard'
data/README.md CHANGED
@@ -3,6 +3,15 @@
3
3
  [![Gem Version](http://img.shields.io/gem/v/git_clone_url.svg?style=flat)](http://badge.fury.io/rb/git_clone_url)
4
4
  [![Build Status](http://img.shields.io/travis/packsaddle/ruby-git_clone_url/master.svg?style=flat)](https://travis-ci.org/packsaddle/ruby-git_clone_url)
5
5
 
6
+ > Easy to parse git repository-ish url.
7
+
8
+ * Parse by [URI.parse](http://ruby-doc.org/stdlib-2.2.3/libdoc/uri/rdoc/URI.html#method-c-parse)
9
+ * `git://github.com/schacon/ticgit.git`
10
+ * `https://github.com/schacon/ticgit.git`
11
+ * Parse by [URI::SshGit](https://rubygems.org/gems/uri-ssh_git)
12
+ * `git@github.com:schacon/ticgit.git`
13
+
14
+
6
15
  ```ruby
7
16
  require 'git_clone_url'
8
17
 
@@ -26,6 +35,47 @@ GitCloneUrl.parse(https_url_with_userinfo)
26
35
  # host: 'github.com', path: '/schacon/ticgit.git'}
27
36
  ```
28
37
 
38
+ ## Motivation
39
+
40
+ `URI.parse` and `Addressable::URI.parse`
41
+ can parse https protocol, git protocol and ssh protocol(`ssh://git@github.com...`),
42
+ but they can not parse `git@github.com:foo/bar.git` pattern of ssh protocol.
43
+
44
+ ```ruby
45
+ # URI
46
+ url = URI.parse('git@github.com:schacon/ticgit.git')
47
+ URI::InvalidURIError: bad URI(is not URI?): git@github.com:schacon/ticgit.git
48
+
49
+ # Addressable
50
+ url = Addressable::URI.parse('git@github.com:schacon/ticgit.git')
51
+ #=> #<Addressable::URI:0x3fedf48fb430 URI:git@github.com:schacon/ticgit.git>
52
+ url.path #=> "schacon/ticgit.git"
53
+ url.scheme #=> "git@github.com"
54
+
55
+ url.host #=> nil
56
+ url.userinfo #=> nil
57
+ url.user #=> nil
58
+ url.port #=> nil
59
+ ```
60
+
61
+
62
+ ## API
63
+
64
+ ### GitCloneUrl.parse(git_url) -> URI::*
65
+
66
+ Return `URI` namespaced object.
67
+ E.g. `URI::Generic`, `URI::HTTPS` and `URI::SshGit::Generic`.
68
+ See: [class URI::Generic](http://docs.ruby-lang.org/en/2.2.0/URI/Generic.html), [class URI::HTTPS](http://docs.ruby-lang.org/en/2.2.0/URI/HTTPS.html) and [URI::SshGit](https://github.com/packsaddle/ruby-uri-ssh_git).
69
+
70
+
71
+ #### git_url
72
+
73
+ *Required*
74
+ Type: `string`
75
+
76
+ Git repository-ish url.
77
+
78
+
29
79
  ## Installation
30
80
 
31
81
  Add this line to your application's Gemfile:
data/Rakefile CHANGED
@@ -8,3 +8,12 @@ Rake::TestTask.new(:test) do |t|
8
8
  end
9
9
 
10
10
  task default: :test
11
+
12
+ require 'yard'
13
+ require 'yard/rake/yardoc_task'
14
+ DOC_FILES = ['lib/**/*.rb']
15
+ DOC_OPTIONS = ['--debug', '--verbose']
16
+ YARD::Rake::YardocTask.new(:doc) do |t|
17
+ t.files = DOC_FILES
18
+ t.options = DOC_OPTIONS if Rake.application.options.trace
19
+ end
data/changelog.md ADDED
@@ -0,0 +1,4 @@
1
+ <a name="0.1.1"></a>
2
+ ## [0.1.1](https://github.com/packsaddle/ruby-git_clone_url/compare/v0.1.0...v0.1.1) (2015-11-21)
3
+
4
+ * Add changelog file
@@ -16,22 +16,22 @@ Gem::Specification.new do |spec|
16
16
 
17
17
  spec.files = \
18
18
  `git ls-files -z`
19
- .split("\x0")
20
- .reject { |f| f.match(%r{^(test|spec|features)/}) }
21
- .reject do |f|
22
- [
23
- '.travis.yml',
24
- 'circle.yml',
25
- '.tachikoma.yml'
26
- ].include?(f)
27
- end
19
+ .split("\x0")
20
+ .reject { |f| f.match(%r{^(test|spec|features)/}) }
21
+ .reject do |f|
22
+ [
23
+ '.travis.yml',
24
+ 'circle.yml',
25
+ '.tachikoma.yml'
26
+ ].include?(f)
27
+ end
28
28
  spec.bindir = 'exe'
29
29
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
30
30
  spec.require_paths = ['lib']
31
31
 
32
32
  spec.add_runtime_dependency 'uri-ssh_git'
33
33
 
34
- spec.add_development_dependency 'bundler', '~> 1.8'
35
- spec.add_development_dependency 'rake', '~> 10.0'
34
+ spec.add_development_dependency 'bundler'
35
+ spec.add_development_dependency 'rake'
36
36
  spec.add_development_dependency 'test-unit'
37
37
  end
@@ -1,3 +1,3 @@
1
1
  module GitCloneUrl
2
- VERSION = '0.1.0'
2
+ VERSION = '0.1.1'
3
3
  end
data/lib/git_clone_url.rb CHANGED
@@ -4,15 +4,27 @@ require 'uri/ssh_git'
4
4
  require 'git_clone_url/version'
5
5
 
6
6
  module GitCloneUrl
7
+ # Git clone url
7
8
  class << self
9
+ # @param url [String] git repository-ish url
10
+ #
11
+ # @return [URI::Generic] if url starts ssh
12
+ # @return [URI::HTTPS] if url starts https
13
+ # @return [URI::SshGit] if url is ssh+git e.g git@example.com:schacon/ticgit.git
8
14
  def parse(url)
9
15
  ssh_git_url?(url) ? URI::SshGit.parse(url) : URI.parse(url)
10
16
  end
11
17
 
18
+ # @param url [String] git repository-ish url
19
+ #
20
+ # @return [Boolean] true if url is git via ssh protocol
12
21
  def ssh_git_url?(url)
13
22
  !generic_url?(url)
14
23
  end
15
24
 
25
+ # @param url [String] git repository-ish url
26
+ #
27
+ # @return [Boolean] true if url is https, ssh protocol
16
28
  def generic_url?(url)
17
29
  match = %r{\A(\w*)://}.match(url)
18
30
  !match.nil?
data/package.json ADDED
@@ -0,0 +1,11 @@
1
+ {
2
+ "devDependencies": {
3
+ "conventional-changelog": "0.5.1",
4
+ "npm-check-updates": "^2.2.3",
5
+ "urijs": "^1.16.1"
6
+ },
7
+ "scripts": {
8
+ "changelog": "conventional-changelog -i CHANGELOG.md --overwrite --preset angular --context .conventional-changelog.context.js",
9
+ "ncu": "ncu -u"
10
+ }
11
+ }
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: git_clone_url
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - sanemat
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-03-06 00:00:00.000000000 Z
11
+ date: 2015-11-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: uri-ssh_git
@@ -28,30 +28,30 @@ dependencies:
28
28
  name: bundler
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - "~>"
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: '1.8'
33
+ version: '0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - "~>"
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
- version: '1.8'
40
+ version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rake
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - "~>"
45
+ - - ">="
46
46
  - !ruby/object:Gem::Version
47
- version: '10.0'
47
+ version: '0'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - "~>"
52
+ - - ">="
53
53
  - !ruby/object:Gem::Version
54
- version: '10.0'
54
+ version: '0'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: test-unit
57
57
  requirement: !ruby/object:Gem::Requirement
@@ -73,6 +73,7 @@ executables: []
73
73
  extensions: []
74
74
  extra_rdoc_files: []
75
75
  files:
76
+ - ".conventional-changelog.context.js"
76
77
  - ".gitignore"
77
78
  - ".rubocop.yml"
78
79
  - CODE_OF_CONDUCT.md
@@ -82,10 +83,12 @@ files:
82
83
  - Rakefile
83
84
  - bin/console
84
85
  - bin/setup
86
+ - changelog.md
85
87
  - example/simple.rb
86
88
  - git_clone_url.gemspec
87
89
  - lib/git_clone_url.rb
88
90
  - lib/git_clone_url/version.rb
91
+ - package.json
89
92
  homepage: https://github.com/packsaddle/ruby-git_clone_url
90
93
  licenses:
91
94
  - MIT
@@ -106,8 +109,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
106
109
  version: '0'
107
110
  requirements: []
108
111
  rubyforge_project:
109
- rubygems_version: 2.4.5
112
+ rubygems_version: 2.4.5.1
110
113
  signing_key:
111
114
  specification_version: 4
112
115
  summary: Parse git clone url
113
116
  test_files: []
117
+ has_rdoc: