git_local 0.0.8 → 0.0.9

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: dbda12a56bce862f7a3aa3db2e8a3c321117b49c
4
- data.tar.gz: 283d7b31670a371b926a10dd1d29376c4b13ab1f
3
+ metadata.gz: 22266f5287de8aa48c572c13ba861a27f202b1f4
4
+ data.tar.gz: 2daf4f2fda66c794d3cd5215232ce858f3f6f46d
5
5
  SHA512:
6
- metadata.gz: 8eda22ed05ab8f70153aa8553c5f44ceed4b4e09783876063cc51efe65d4926a15dcff170173e077964c602fb41c928522d444f602c07c8e35fc418ad0bc0ac1
7
- data.tar.gz: 0b99c6ae86427664bd126952d5c369cd8700f6cb5cae960f232452495e3e4a0bc67aaa54ac9af7cb8741db6c44532ba4eeda1f0fdc2c54b8073abdc0597d968a
6
+ metadata.gz: bf3065a45ad15f27c83c473cb905b2147cd1895cb98f21a8a948dfc1a563cdde8737e5dcb3ee1c7cb38c80f28524c1c22693ebbea937fb42522ae4a5daa58074
7
+ data.tar.gz: bec1798210fe76a38154c4c0c5322ece1ac180f108c49e04b2523457300b670ae9f1d84060235806655e7e46b24196ea845c995cbbd4d8702dc16ba033f5fdb5
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- git_local (0.0.7)
4
+ git_local (0.0.9)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -60,4 +60,4 @@ DEPENDENCIES
60
60
  rubocop
61
61
 
62
62
  BUNDLED WITH
63
- 1.14.6
63
+ 1.15.1
@@ -6,15 +6,24 @@ module GitLocal
6
6
  class InvalidArgument < StandardError
7
7
  end
8
8
 
9
+ class InvalidProtocol < StandardError
10
+ end
11
+
9
12
  GITHUB_HOST = "github.com".freeze
13
+ VALID_PROTOCOLS = {
14
+ ssh: "SSH",
15
+ https: "HTTPS"
16
+ }.freeze
10
17
 
11
- def initialize(org:, repo:, branch:, local_directory:, host: GITHUB_HOST)
18
+ def initialize(org:, repo:, branch:, local_directory:, host: GITHUB_HOST, protocol: VALID_PROTOCOLS[:ssh])
12
19
  check_for_special_characters(org, repo, branch, local_directory)
13
20
  @branch = branch
14
21
  @host = host
15
22
  @local_directory = local_directory
16
23
  @org = org
17
24
  @repo = repo
25
+ @protocol = protocol
26
+ validate_protocol
18
27
  end
19
28
 
20
29
  def get
@@ -82,7 +91,7 @@ module GitLocal
82
91
  def clone_and_checkout
83
92
  FileUtils.makedirs(repo_path) unless Dir.exist?(repo_path)
84
93
 
85
- popened_io = IO.popen("(cd #{repo_path} && git clone git@#{host}:#{org_repo}.git --branch #{branch} --single-branch #{branch} && cd #{path}) 2>&1")
94
+ popened_io = IO.popen("(cd #{repo_path} && git clone #{repo_endpoint} --branch #{branch} --single-branch #{branch} && cd #{path}) 2>&1")
86
95
  out = popened_io.map(&:chomp) || []
87
96
  Process.wait(popened_io.pid)
88
97
 
@@ -104,5 +113,13 @@ module GitLocal
104
113
  def repo_path
105
114
  @repo_path ||= "#{local_directory}/#{org_repo}"
106
115
  end
116
+
117
+ def validate_protocol
118
+ raise InvalidProtocol, "Protocol must be either HTTPS or SSH." unless VALID_PROTOCOLS.values.include?(@protocol)
119
+ end
120
+
121
+ def repo_endpoint
122
+ @protocol == VALID_PROTOCOLS[:ssh] ? "git@#{host}:#{org_repo}.git" : "https://#{host}/#{org_repo}.git"
123
+ end
107
124
  end
108
125
  end
@@ -1,3 +1,3 @@
1
1
  module GitLocal
2
- VERSION = "0.0.8"
2
+ VERSION = "0.0.9"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: git_local
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.8
4
+ version: 0.0.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Galvanize Product
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-07-07 00:00:00.000000000 Z
11
+ date: 2017-07-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler