vpr 2.0.1 → 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5ed95c7f4431bf7413b0b3009ca6783be6d0d4b4c67dedeccf0656c32faa5b31
4
- data.tar.gz: 4211affce4e144a15898517e99d8462ffb69e3b22517629c045c611229f4ce5e
3
+ metadata.gz: 0f2b50b7f24767c045785625093f2899cf4f73e8d72fe2274d8024a1e0288d17
4
+ data.tar.gz: 6fa5994c36cdb70e5d2b463e5a1bc46881e42e4d815a24495defda8c9b342d0f
5
5
  SHA512:
6
- metadata.gz: 6acefb0c142308f56d058d9a5927d9e7c44243a3b8c58105afe3f3b660ccf6100cfd67312dd13a9f06cae2c9a11c47a28c93fb4fb78e25ea2ac8f910274719bc
7
- data.tar.gz: e08fe20d7870122a41382ddb72bfc15ebb63c28db7abd9c8cf72824355a2d51e8b012a483b602ceb18ed1b0be3dc18b41165f584f6ac6ab7a8c2225250926088
6
+ metadata.gz: e2a03178f51fe9c5e5ec57004cfce96ca220268e124bc50f3354139d8aea02b2a6f4d236d7a5dd85587ce0ac2baafb6d8a2943a248fe239010c956f7b57bdb41
7
+ data.tar.gz: 2e873e016ba661bbba0974d94da5bcfadf2815e9561e9c2905ec01a04404a38731d114d638723fe2ee3348439f8228bf52b1301beb423619c621822a8fd7a91c
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- vpr (2.0.1)
4
+ vpr (2.1.0)
5
5
  git (~> 1.5)
6
6
  launchy (~> 2.4)
7
7
  thor (~> 0.20)
data/lib/vpr.rb CHANGED
@@ -5,4 +5,5 @@ module Vpr
5
5
  autoload :GitParser, "vpr/git_parser"
6
6
  autoload :Url, "vpr/url"
7
7
  autoload :CLI, "vpr/cli"
8
+ autoload :Services, "vpr/services"
8
9
  end
@@ -9,6 +9,7 @@ module Vpr
9
9
  def initialize(args = [], local_options = {}, config = {})
10
10
  super
11
11
  select_remote
12
+ @url = Url.new
12
13
  end
13
14
 
14
15
  map "--version" => :version
@@ -16,42 +17,42 @@ module Vpr
16
17
 
17
18
  desc "home", "visit the project page in github"
18
19
  def home
19
- Launchy.open(Url.home_url)
20
+ Launchy.open(url.home_url)
20
21
  end
21
22
 
22
23
  desc "pulls", "visit the project pull requests page in github"
23
24
  def pulls
24
- Launchy.open(Url.pulls_url)
25
+ Launchy.open(url.pulls_url)
25
26
  end
26
27
 
27
28
  desc "issues", "visit the project issues page in github"
28
29
  def issues
29
- Launchy.open(Url.issues_url)
30
+ Launchy.open(url.issues_url)
30
31
  end
31
32
 
32
33
  desc "branches", "visit the project branches page in github"
33
34
  def branches
34
- Launchy.open(Url.branches_url)
35
+ Launchy.open(url.branches_url)
35
36
  end
36
37
 
37
38
  desc "branch", "visit the current branch in github"
38
39
  def branch
39
- Launchy.open(Url.branch_url)
40
+ Launchy.open(url.branch_url)
40
41
  end
41
42
 
42
43
  desc "pull", "visit the pull request for the current branch (if exist) in github"
43
44
  def pull
44
- Launchy.open(Url.pull_url)
45
+ Launchy.open(url.pull_url)
45
46
  end
46
47
 
47
48
  desc "visit COMMIT", "visit the commit in github"
48
49
  def visit(commit)
49
- Launchy.open(Url.commit_url(commit))
50
+ Launchy.open(url.commit_url(commit))
50
51
  end
51
52
 
52
53
  desc "search COMMIT", "search the commit in github"
53
54
  def search(commit)
54
- Launchy.open(Url.search_url(commit))
55
+ Launchy.open(url.search_url(commit))
55
56
  end
56
57
 
57
58
  desc "version", "show the gem version"
@@ -64,5 +65,7 @@ module Vpr
64
65
  def select_remote
65
66
  Configuration.remote = options[:remote].to_sym
66
67
  end
68
+
69
+ attr_reader :url
67
70
  end
68
71
  end
@@ -0,0 +1,6 @@
1
+ module Vpr
2
+ module Services
3
+ autoload :GitHub, "vpr/services/github"
4
+ autoload :Bitbucket, "vpr/services/bitbucket"
5
+ end
6
+ end
@@ -0,0 +1,39 @@
1
+ require "vpr/git_parser"
2
+
3
+ module Vpr
4
+ module Services
5
+ class Bitbucket
6
+ def self.home_url
7
+ GitParser.repo_url
8
+ end
9
+
10
+ def self.pulls_url
11
+ "#{GitParser.repo_url}/pull-requests"
12
+ end
13
+
14
+ def self.issues_url
15
+ "#{GitParser.repo_url}/issues"
16
+ end
17
+
18
+ def self.branches_url
19
+ "#{GitParser.repo_url}/branches"
20
+ end
21
+
22
+ def self.branch_url
23
+ "#{GitParser.repo_url}/branch/#{GitParser.current_branch}"
24
+ end
25
+
26
+ def self.pull_url
27
+ "#{GitParser.repo_url}/pull-requests/new?source=#{GitParser.current_branch}"
28
+ end
29
+
30
+ def self.commit_url(commit)
31
+ "#{GitParser.repo_url}/commits/#{commit}"
32
+ end
33
+
34
+ def self.search_url(commit)
35
+ "#{GitParser.repo_url}/commits/all?search=#{commit}"
36
+ end
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,39 @@
1
+ require "vpr/git_parser"
2
+
3
+ module Vpr
4
+ module Services
5
+ class GitHub
6
+ def self.home_url
7
+ GitParser.repo_url
8
+ end
9
+
10
+ def self.pulls_url
11
+ "#{GitParser.repo_url}/pulls"
12
+ end
13
+
14
+ def self.issues_url
15
+ "#{GitParser.repo_url}/issues"
16
+ end
17
+
18
+ def self.branches_url
19
+ "#{GitParser.repo_url}/branches"
20
+ end
21
+
22
+ def self.branch_url
23
+ "#{GitParser.repo_url}/tree/#{GitParser.current_branch}"
24
+ end
25
+
26
+ def self.pull_url
27
+ "#{GitParser.repo_url}/pull/#{GitParser.current_branch}"
28
+ end
29
+
30
+ def self.commit_url(commit)
31
+ "#{GitParser.repo_url}/commit/#{commit}"
32
+ end
33
+
34
+ def self.search_url(commit)
35
+ "#{GitParser.repo_url}/search?q=#{commit}"
36
+ end
37
+ end
38
+ end
39
+ end
@@ -1,60 +1,53 @@
1
1
  require "vpr/git_parser"
2
+ require "vpr/services"
2
3
 
3
4
  module Vpr
4
5
  class Url
5
- def self.home_url
6
- GitParser.repo_url
6
+ def initialize
7
+ @service = services[GitParser.host.to_sym]
7
8
  end
8
9
 
9
- def self.pulls_url
10
- path = {
11
- 'github.com': "pulls",
12
- 'bitbucket.org': "pull-requests",
13
- }
14
-
15
- "#{GitParser.repo_url}/#{path[GitParser.host.to_sym]}"
10
+ def home_url
11
+ service.home_url
16
12
  end
17
13
 
18
- def self.issues_url
19
- "#{GitParser.repo_url}/issues"
14
+ def pulls_url
15
+ service.pulls_url
20
16
  end
21
17
 
22
- def self.branches_url
23
- "#{GitParser.repo_url}/branches"
18
+ def issues_url
19
+ service.issues_url
24
20
  end
25
21
 
26
- def self.branch_url
27
- path = {
28
- 'github.com': "tree",
29
- 'bitbucket.org': "branch",
30
- }
31
- "#{GitParser.repo_url}/#{path[GitParser.host.to_sym]}/#{GitParser.current_branch}"
22
+ def branches_url
23
+ service.branches_url
32
24
  end
33
25
 
34
- def self.pull_url
35
- path = {
36
- 'github.com': "pull/#{GitParser.current_branch}",
37
- 'bitbucket.org': "pull-requests/new?source=#{GitParser.current_branch}",
38
- }
26
+ def branch_url
27
+ service.branch_url
28
+ end
39
29
 
40
- "#{GitParser.repo_url}/#{path[GitParser.host.to_sym]}"
30
+ def pull_url
31
+ service.pull_url
41
32
  end
42
33
 
43
- def self.commit_url(commit)
44
- path = {
45
- 'github.com': "commit",
46
- 'bitbucket.org': "commits",
47
- }
34
+ def commit_url(commit)
35
+ service.commit_url(commit)
36
+ end
48
37
 
49
- "#{GitParser.repo_url}/#{path[GitParser.host.to_sym]}/#{commit}"
38
+ def search_url(commit)
39
+ service.search_url(commit)
50
40
  end
51
41
 
52
- def self.search_url(commit)
53
- path = {
54
- 'github.com': "search?q=",
55
- 'bitbucket.org': "commits/all?search=",
42
+ private
43
+
44
+ def services
45
+ {
46
+ 'github.com': Vpr::Services::GitHub,
47
+ 'bitbucket.org': Vpr::Services::Bitbucket,
56
48
  }
57
- "#{GitParser.repo_url}/#{path[GitParser.host.to_sym]}#{commit}"
58
49
  end
50
+
51
+ attr_reader :service
59
52
  end
60
53
  end
@@ -1,3 +1,3 @@
1
1
  module Vpr
2
- VERSION = "2.0.1"
2
+ VERSION = "2.1.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vpr
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.1
4
+ version: 2.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Juan Carlos Ruiz
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-12-04 00:00:00.000000000 Z
11
+ date: 2019-12-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -162,6 +162,9 @@ files:
162
162
  - lib/vpr/cli.rb
163
163
  - lib/vpr/configuration.rb
164
164
  - lib/vpr/git_parser.rb
165
+ - lib/vpr/services.rb
166
+ - lib/vpr/services/bitbucket.rb
167
+ - lib/vpr/services/github.rb
165
168
  - lib/vpr/url.rb
166
169
  - lib/vpr/version.rb
167
170
  - vpr.gemspec