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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 65c934219c82cb57f9ed0cb87eda58348cc6219d
4
- data.tar.gz: ffc0f55365499f06312e1ae956f5f6847eb25072
3
+ metadata.gz: dd0ac5e39c4a0da159e938d8aeaeca92cc11e280
4
+ data.tar.gz: 0073320152769d1e6c12575c495fc20802cd42d7
5
5
  SHA512:
6
- metadata.gz: 6adb7a7c86cc0f9616e9d44568180a3017eb3c31899e10ddeccaccf8699bcb372793c24197bb2b37425279ce34f88557776cdd03ff2204b168d5fab0b8559555
7
- data.tar.gz: bf375e0bc19e27e9b26151d3573dbb4ad786aea0ae4bded4c906d624eedd207b76ede31bd9a315583d18d828ab0224f31385b5f2ce7725980358cf3c6e23241f
6
+ metadata.gz: 8717e56f0725f28ebd7b647dac66da635a073d397876f62a9c17214dcb62732570432114db507938945564ebe672723ac6541fa4172710889bc9ec465dcf9a05
7
+ data.tar.gz: 421342ffb5e4804a1467caceeaa615fa8f5a1f5a7b7bafedde6a0077815115d6d6017a4d427c29c4805f77721dae46f14bc2b7cea5ee78e1285f55c492a9080c
data/CHANGELOG.md CHANGED
@@ -1,3 +1,6 @@
1
+ 2.2.0 (October 9th, 2015)
2
+ - Add subdirectory option to Git template
3
+
1
4
  2.1.0 (October 3rd, 2015)
2
5
  - Add deployer logic
3
6
  - Add S3 deployer class for sending compiled projects to S3 buckets
@@ -2,7 +2,7 @@ require 'git'
2
2
 
3
3
  module Stevenson
4
4
  module Template
5
- class Git < Base
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 ||= Dir.mktmpdir.tap do |dir|
14
- # Clone the repo to a temporary directory for later use
15
- ::Git.clone(template_url, dir).tap do |repo|
16
- # Switch_branch if set
17
- repo.checkout(options[:branch]) if options.has_key?(:branch)
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
@@ -1,3 +1,3 @@
1
1
  module Stevenson
2
- VERSION = "2.1.0"
2
+ VERSION = "2.2.0"
3
3
  end
@@ -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
- before { allow(Dir).to receive(:mktmpdir).and_return(tmp_dir) }
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 { allow(::Git).to receive(:clone).and_return(git_repo) }
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 tmp_dir
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.1.0
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-03 00:00:00.000000000 Z
11
+ date: 2015-10-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler