stevenson 2.2.2 → 2.3.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: 9085412145e88fbe98c683633a26ffb6c6616380
4
- data.tar.gz: 91a2c10e1f490f9a0b446eaef403b96ae72ad3b0
3
+ metadata.gz: 2626791a8038889e6ac36440208c3625a5adf3ae
4
+ data.tar.gz: 839f9c26cd3f01c0ccf9ab5fde9d328013c7e750
5
5
  SHA512:
6
- metadata.gz: d31b0a9d249e5881ad59c42f2f2579d92d411d4d0534c73e7305280cf68b9a38031129b33543ee10fbe0c19a9e49d2c5536711eb93e542ce7d13c746ee27307d
7
- data.tar.gz: 68b0e3f40bb7c978697f502b921e78a65d65a3070920570dd9ea341cb893ca8f6ff6e3cd3237ffe14fa41db47aee551e8600d8f01170d51ce4ffb014f6c02f90
6
+ metadata.gz: ee524f0970ac01c4acfefb25669d98f546d84f0a5edf63f31b2a567cc14d35cbab8ed22d28983f659d110536c04adff180591119397aa9aa62152b1dcbf77ae2
7
+ data.tar.gz: a06f034f5885649317729a9cd2b53e87ada3671c5c713f0b8cb9b63102bd0018d199a06e4606b89a1be730a29446ca5d4cf9feae88731d622a43607d3cb6c04a
@@ -1,3 +1,8 @@
1
+ 2.3.0 (December 30th, 2015)
2
+ - Fix zip creation
3
+ - Add ability to specify zip filename
4
+ - Pass CLI options to Output Filters
5
+
1
6
  2.2.2 (December 11th, 2015)
2
7
  - Add a clearer error message to Template message
3
8
  - Refactor user directory fetch to try ENV (or default to root on
@@ -29,7 +29,6 @@ module Stevenson
29
29
  aliases: "-o",
30
30
  desc: 'Array of output filters to be applied in order'
31
31
  method_option :zip,
32
- type: :boolean,
33
32
  aliases: "-z",
34
33
  desc: 'Zip compresses the output directory'
35
34
 
@@ -13,12 +13,22 @@ module Stevenson
13
13
  end
14
14
 
15
15
  def deploy!(directory)
16
- Dir.glob("#{directory}/**/*").each do |file|
16
+ entries_for(directory).each do |file_path, file_name|
17
17
  s3_bucket.files.create(
18
- key: File.join(deployment_key, file.partition(directory).last),
19
- body: File.read(file),
18
+ key: File.join(deployment_key, file_name),
19
+ body: File.read(file_path),
20
20
  public: true,
21
- ) if File.file?(file)
21
+ ) if File.file?(file_path)
22
+ end
23
+ end
24
+
25
+ def entries_for(directory)
26
+ if File.file?(directory)
27
+ [
28
+ [directory, File.basename(directory)]
29
+ ]
30
+ else
31
+ Dir.glob("#{directory}/**/*").collect { |f| [f, f.partition(directory).last] }
22
32
  end
23
33
  end
24
34
 
@@ -6,7 +6,7 @@ module Stevenson
6
6
  autoload :Generator, 'stevenson/output_filter/generator'
7
7
 
8
8
  class Base
9
- attr_reader :directory
9
+ attr_reader :directory, :options
10
10
 
11
11
  def self.included(filter)
12
12
  filter.extend ClassMethods
@@ -20,8 +20,8 @@ module Stevenson
20
20
  end
21
21
  end
22
22
 
23
- def initialize(directory)
24
- @directory = directory
23
+ def initialize(directory, options)
24
+ @directory, @options = directory, options
25
25
  end
26
26
 
27
27
  def output
@@ -9,7 +9,7 @@ module Stevenson
9
9
 
10
10
  def generate!(template)
11
11
  filters.inject(template.local_directory) do |rendered, filter|
12
- OutputFilter.filter_for(filter).new(rendered).output
12
+ OutputFilter.filter_for(filter).new(rendered, options).output
13
13
  end
14
14
  end
15
15
 
@@ -8,7 +8,7 @@ module Stevenson
8
8
  `jekyll b`
9
9
  end
10
10
 
11
- File.join(directory, '_site', '.')
11
+ File.join(directory, '_site')
12
12
  end
13
13
  end
14
14
  end
@@ -5,12 +5,16 @@ module Stevenson
5
5
  class Zip < Base
6
6
 
7
7
  def output
8
- "#{directory}.zip".tap do |dir|
8
+ File.join(directory, "#{zip_file_name}.zip").tap do |output_zip_path|
9
9
  # Zip up the output directory
10
- write directory, dir
10
+ write directory, output_zip_path
11
11
  end
12
12
  end
13
13
 
14
+ def zip_file_name
15
+ options[:zip] == "zip" ? File.basename(directory) : options[:zip]
16
+ end
17
+
14
18
  private
15
19
 
16
20
  def write(inputDir, outputFile)
@@ -31,7 +35,7 @@ module Stevenson
31
35
  zipFilePath = path == "" ? entry : File.join(path, entry)
32
36
  diskFilePath = File.join(@inputDir, zipFilePath)
33
37
  if File.directory?(diskFilePath)
34
- io.mkdir(zipFilePath)
38
+ io.mkdir(zipFilePath) unless io.find_entry(zipFilePath)
35
39
  subdir = Dir.entries(diskFilePath); subdir.delete("."); subdir.delete("..")
36
40
  writeEntries(subdir, zipFilePath, io)
37
41
  else
@@ -1,3 +1,3 @@
1
1
  module Stevenson
2
- VERSION = "2.2.2"
2
+ VERSION = "2.3.1"
3
3
  end
@@ -11,7 +11,7 @@ describe Stevenson::OutputFilter::Generator do
11
11
  end
12
12
 
13
13
  it "should create a new filter for the jekyll filter's output" do
14
- expect(Stevenson::OutputFilter::Jekyll).to receive(:new).with(template.local_directory).and_call_original
14
+ expect(Stevenson::OutputFilter::Jekyll).to receive(:new).with(template.local_directory, options).and_call_original
15
15
  subject.generate!(template)
16
16
  end
17
17
 
@@ -20,16 +20,16 @@ describe Stevenson::OutputFilter::Generator do
20
20
  end
21
21
 
22
22
  context "when more than one filter exists" do
23
- let(:options) { { zip: true } }
23
+ let(:options) { { zip: "zip" } }
24
24
  let(:zip_filter) { double(:zip_filter, output: zip_output) }
25
25
 
26
26
  it "should build subsequent filters with the previous' output" do
27
- expect(Stevenson::OutputFilter::Zip).to receive(:new).with(jekyll_output).and_return(zip_filter)
27
+ expect(Stevenson::OutputFilter::Zip).to receive(:new).with(jekyll_output, options).and_return(zip_filter)
28
28
  subject.generate!(template)
29
29
  end
30
30
 
31
31
  it "should return the subsequent filter's output" do
32
- allow(Stevenson::OutputFilter::Zip).to receive(:new).with(jekyll_output).and_return(zip_filter)
32
+ allow(Stevenson::OutputFilter::Zip).to receive(:new).with(jekyll_output, options).and_return(zip_filter)
33
33
  expect(subject.generate!(template)).to eq zip_output
34
34
  end
35
35
  end
@@ -1,7 +1,8 @@
1
1
  describe Stevenson::OutputFilter::Jekyll do
2
+ let(:options) { {} }
2
3
  let(:temporary_directory) { '/tmp/directory' }
3
4
  let(:template) { double(:template, local_directory: temporary_directory) }
4
- subject { described_class.new(template.local_directory) }
5
+ subject { described_class.new(template.local_directory, options) }
5
6
 
6
7
  describe '#output' do
7
8
  it "should change into the template's directory" do
@@ -17,7 +18,7 @@ describe Stevenson::OutputFilter::Jekyll do
17
18
 
18
19
  it 'outputs a jekyll compiled directory' do
19
20
  allow(Dir).to receive(:chdir).with(temporary_directory)
20
- expect(subject.output).to eq File.join(temporary_directory, '_site', '.')
21
+ expect(subject.output).to eq File.join(temporary_directory, '_site')
21
22
  end
22
23
  end
23
24
  end
@@ -1,10 +1,11 @@
1
1
  describe Stevenson::OutputFilter::Zip do
2
+ let(:options) { { zip: "zip"} }
2
3
  let(:temporary_directory) { '/tmp/directory' }
3
4
  let(:template) { double(:template, local_directory: temporary_directory) }
4
- subject { described_class.new(template.local_directory) }
5
+ subject { described_class.new(template.local_directory, options) }
5
6
 
6
7
  describe '#output' do
7
- let(:output_zip) { "#{temporary_directory}.zip" }
8
+ let(:output_zip) { "#{temporary_directory}/#{File.basename(temporary_directory)}.zip" }
8
9
 
9
10
  it "should zip the files in temporary_directory to the zip" do
10
11
  expect(subject).to receive(:write).with(temporary_directory, output_zip).and_return(true)
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.2.2
4
+ version: 2.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - RootsRated
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-12-11 00:00:00.000000000 Z
11
+ date: 2016-01-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler