stevenson 2.1.0 → 2.2.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 +4 -4
- data/CHANGELOG.md +3 -0
- data/lib/stevenson/templates/git.rb +16 -7
- data/lib/stevenson/version.rb +1 -1
- data/spec/lib/templates/git_spec.rb +8 -3
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dd0ac5e39c4a0da159e938d8aeaeca92cc11e280
|
4
|
+
data.tar.gz: 0073320152769d1e6c12575c495fc20802cd42d7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8717e56f0725f28ebd7b647dac66da635a073d397876f62a9c17214dcb62732570432114db507938945564ebe672723ac6541fa4172710889bc9ec465dcf9a05
|
7
|
+
data.tar.gz: 421342ffb5e4804a1467caceeaa615fa8f5a1f5a7b7bafedde6a0077815115d6d6017a4d427c29c4805f77721dae46f14bc2b7cea5ee78e1285f55c492a9080c
|
data/CHANGELOG.md
CHANGED
@@ -2,7 +2,7 @@ require 'git'
|
|
2
2
|
|
3
3
|
module Stevenson
|
4
4
|
module Template
|
5
|
-
class Git <
|
5
|
+
class Git < Local
|
6
6
|
attr_reader :template_url, :options
|
7
7
|
|
8
8
|
def initialize(template_url, options)
|
@@ -10,16 +10,25 @@ module Stevenson
|
|
10
10
|
end
|
11
11
|
|
12
12
|
def local_directory
|
13
|
-
@_local_directory ||=
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
13
|
+
@_local_directory ||= begin
|
14
|
+
@template_path ||= Dir.mktmpdir.tap do |dir|
|
15
|
+
# Clone the repo to a temporary directory for later use
|
16
|
+
::Git.clone(template_url, dir).tap do |repo|
|
17
|
+
# Switch_branch if set
|
18
|
+
repo.checkout(options[:branch]) if options.has_key?(:branch)
|
19
|
+
end
|
18
20
|
end
|
21
|
+
|
22
|
+
super
|
19
23
|
end
|
20
24
|
rescue ::Git::GitExecuteError
|
21
25
|
# If the given repo URL is not valid, raise an exception
|
22
|
-
raise InvalidTemplateException.new('Failed to clone the repository')
|
26
|
+
raise InvalidTemplateException.new('Failed to clone the repository and/or branch')
|
27
|
+
end
|
28
|
+
|
29
|
+
def close
|
30
|
+
FileUtils.rm_rf template_path if template_path
|
31
|
+
super
|
23
32
|
end
|
24
33
|
end
|
25
34
|
end
|
data/lib/stevenson/version.rb
CHANGED
@@ -5,14 +5,19 @@ describe Stevenson::Template::Git do
|
|
5
5
|
|
6
6
|
describe '#local_directory' do
|
7
7
|
let(:tmp_dir) { '/tmp/dir/to/template' }
|
8
|
-
|
8
|
+
let(:local_tmp_dir) { '/tmp/dir/to/local_template' }
|
9
|
+
before { allow(Dir).to receive(:mktmpdir).and_return(tmp_dir, local_tmp_dir) }
|
9
10
|
|
10
11
|
context 'when template_url is a valid URL' do
|
11
12
|
let(:git_repo) { double(:git_repo) }
|
12
|
-
before
|
13
|
+
before do
|
14
|
+
allow(::Git).to receive(:clone).and_return(git_repo)
|
15
|
+
allow(File).to receive(:directory?).with(tmp_dir).and_return(true)
|
16
|
+
allow(FileUtils).to receive(:cp_r).with("#{tmp_dir}/.", local_tmp_dir).and_return(true)
|
17
|
+
end
|
13
18
|
|
14
19
|
it 'returns a temp directory' do
|
15
|
-
expect(subject.local_directory).to eq
|
20
|
+
expect(subject.local_directory).to eq local_tmp_dir
|
16
21
|
end
|
17
22
|
|
18
23
|
it 'clones the given repository to the working template path' do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: stevenson
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- RootsRated
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-10-
|
11
|
+
date: 2015-10-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|