Commit c0dcc1a3 authored by charlie-ablett's avatar charlie-ablett

Better integrate Semantically Tagged Manifest. Remove superfluous filesystem...

Better integrate Semantically Tagged Manifest. Remove superfluous filesystem scans. Use Cumulative File Manifest. Add Human Readable Name.
parent 7920763a
PATH
remote: .
specs:
ink_step (1.2.0)
ink_step (1.2.1)
awesome_print
httparty
rubyzip
......
......@@ -11,41 +11,42 @@ module InkStep
attr_accessor :errors, :status_code, :process_step, :started_at, :finished_at,
:position, :chain_file_location, :successful, :notes, :process_log,
:combined_parameters, :input_file_manifest, :output_file_manifest
:combined_parameters, :input_file_manifest, :output_file_manifest,
:cumulative_file_manifest
INPUT_FILE_DIRECTORY_NAME = "input_files"
OUTPUT_FILE_DIRECTORY_NAME = "output_files"
def initialize(chain_file_location:, position:, incoming_file_manifest:)
def initialize(chain_file_location:, position:)
@position = position
@chain_file_location = chain_file_location
@input_file_manifest = incoming_file_manifest
@successful = nil
@errors = []
@notes = []
@combined_parameters = {}
ap "incoming manifest"
ap @input_file_manifest
create_directory_if_needed(working_directory)
get_input_files
end
def execute(options: {})
@combined_parameters = options || {}
@started_at = Time.now
check_parameters(combined_parameters)
create_directory_if_needed(working_directory)
get_input_files
input_file_manifest = assemble_manifest(directory: working_directory)
self.input_file_manifest = input_manifest_from_cumulative
log_as_step "Incoming file manifest:"
log_as_step input_file_manifest
log_as_step "Using version #{version}"
log_as_step "Execution parameters:"
log_as_step combined_parameters
log_as_step "Previous step manifest:"
log_as_step input_file_manifest
log_as_step @combined_parameters
perform_step
rescue => e
raise_and_log_error(e)
@successful = false
ensure
self.output_file_manifest = semantically_tagged_manifest
log_as_step "Wrote output file manifest:"
log_as_step output_file_manifest
@finished_at = Time.now
log_as_step "Finished at #{@finished_at.utc.strftime("%Y-%m-%d %H:%M:%S UTC")}"
log_as_step "Errors: #{@errors}"
......@@ -65,8 +66,7 @@ module InkStep
end
def check_parameters(options)
ap "checking parameters"
ap "required params"
ap "checking parameters: required params"
ap required_parameters
missing_parameters = required_parameters - options.keys - default_parameter_values.keys
raise ArgumentError.new("Missing parameters: #{missing_parameters.join(", ")}") if missing_parameters.any?
......@@ -121,6 +121,11 @@ module InkStep
raise NotImplementedError.new("You need to provide a Description method in your step (#{self.class.name}) that returns a string - a brief summary of what your step does (see CokoDemoSteps for an example)")
end
def self.human_readable_name
return "Base Step" if self.name == "InkStep::Base"
raise NotImplementedError.new("You need to provide a Human Readable Name method in your step (#{self.class.name}) that returns a string - a concise name for your step (see CokoDemoSteps for an example)")
end
def working_directory
@working_directory ||= File.join(chain_file_location, position.to_s)
end
......@@ -130,7 +135,7 @@ module InkStep
end
def get_input_files
if position == 1
if first_step_in_chain?
source = File.join(chain_file_location, INPUT_FILE_DIRECTORY_NAME)
else
source = File.join(chain_file_location, "#{position-1}")
......@@ -139,6 +144,21 @@ module InkStep
raise "Cannot find source directory #{source}" unless File.directory?(source)
raise "Source directory #{source} is empty" if Dir["#{source}/*"].empty?
copy_files_recursively(source, working_directory)
log_as_step "Files retrieved successfully from #{source}"
end
def semantically_tagged_manifest
file_manifest_at_end = assemble_manifest(directory: working_directory)
file_manifest_at_end.each do |file_hash|
start_file_hash = find_start_file(file_hash)
if start_file_hash.nil?
file_hash[:tag] = :new
elsif file_hash[:checksum] == start_file_hash[:checksum]
file_hash[:tag] = :identical
else
file_hash[:tag] = :modified
end
end
end
protected
......@@ -155,32 +175,21 @@ module InkStep
private
def write_manifest
semantically_tagged_manifest(working_directory, input_file_manifest)
def input_manifest_from_cumulative
if first_step_in_chain?
cumulative_file_manifest[:input]
else
cumulative_file_manifest[position-1]
end
end
def semantically_tagged_manifest(working_directory, manifest_at_start)
file_manifest_at_end = assemble_manifest(directory: working_directory)
file_manifest_at_end.each do |file_hash|
start_file_hash = find_start_file(file_hash, manifest_at_start)
if start_file_hash.nil?
if file_hash[:path] == "basic_doc.html"
ap "NEW FILE #{file_hash[:path]}"
end
file_hash[:tag] = :new
elsif file_hash[:checksum] == start_file_hash[:checksum]
if file_hash[:path] == "basic_doc.html"
ap "IDENTICAL FILE #{file_hash[:path]}"
end
file_hash[:tag] = :identical
else
file_hash[:tag] = :modified
end
end
def first_step_in_chain?
position == 1
end
def assemble_manifest(directory:)
files = recursive_file_list(directory)
def assemble_manifest(directory: working_directory)
files = recursive_file_list(directory: directory)
log_as_step recursive_file_list(directory: directory)
files.inject([]) do |result, file_relative_path|
file_info_hash = {}
file_info_hash[:path] = file_relative_path
......@@ -192,13 +201,21 @@ module InkStep
end
end
def recursive_file_list(directory_path)
Dir.chdir(directory_path) do
files = Dir["**/*"] # Dir["**/*.*"]
def recursive_file_list(directory: working_directory)
Dir.chdir(directory) do
files = Dir["**/*.*"]
files_only = []
files.each do |file|
full_path = File.join(directory_path, file)
files_only << file if File.file?(full_path)
full_path = File.join(directory, file)
next unless File.file?(full_path)
ap "Adding #{full_path}"
if "#{File::SEPARATOR}#{file}".match(/#{directory}/)
relative_path = "#{File::SEPARATOR}#{file}".gsub(/#{directory}\//, "")
else
relative_path = file
end
files_only << relative_path
end
files_only
end
......@@ -215,8 +232,9 @@ module InkStep
end
end
def find_start_file(current_file_hash, manifest_at_start)
manifest_at_start.collect{|f| return f if f[:path] == current_file_hash[:path]}.first
def find_start_file(current_file_hash)
return unless input_file_manifest
input_file_manifest.collect{|f| return f if f[:path] == current_file_hash[:path]}.first
end
end
end
\ No newline at end of file
......@@ -45,7 +45,8 @@ module InkStep
end
def matching_manifest_files(regex)
@input_file_manifest.select do |file_hash|
self.input_file_manifest = semantically_tagged_manifest if input_file_manifest.nil?
input_file_manifest.select do |file_hash|
file_hash[:path].match(regex)
end
end
......
require 'zip'
module InkStep
module Mixins
module ZipMethods
def unzip_archive(input_file_path)
Zip::File.open(input_file_path) do |zip_file|
@docx_archive_name = File.basename(zip_file.name,File.extname(zip_file.name))
log_as_step "Unzipping #{@docx_archive_name} as #{zip_file.name}"
zip_file.each do |f|
path = File.join(unzip_directory, f.name)
log_as_step "Unzipping #{f} to #{path}"
FileUtils.mkdir_p(File.dirname(path)) unless File.exists?(File.dirname(path))
f.extract(path)
end
end
end
def create_archive
log_as_step "Creating archive #{archive_file_name}..."
Zip::File.open(archive_file_name, Zip::File::CREATE) do |zipfile|
Dir.chdir working_directory
Dir.glob("**/*").reject {|fn| File.directory?(fn) }.each do |file|
file_relative_path = file.gsub(working_directory + '/', '')
log_as_step "Adding #{file_relative_path}"
zipfile.add(file_relative_path, File.join(working_directory, file))
end
end
end
def document_xml_path
@document_xml_path ||= File.join(unzip_directory, "word", "document.xml")
end
def unzip_directory
File.join(working_directory, @docx_archive_name)
end
end
end
end
\ No newline at end of file
......@@ -13,6 +13,10 @@ module InkStep::UtilitySteps
"Keeps all new and modified files from the previous step, discards any unchanged files"
end
def self.human_readable_name
"Modified File Collector"
end
def version
InkStep::VERSION
end
......@@ -21,6 +25,12 @@ module InkStep::UtilitySteps
def discard_identical_files
identical_files = input_file_manifest.select{|file_hash| file_hash[:tag] == :identical}
log_as_step "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~1"
log_as_step "Input files"
log_as_step input_file_manifest
log_as_step "Identical files"
log_as_step identical_files
log_as_step "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~2"
identical_files.map do |file_hash|
log_as_step("Removing #{file_hash[:path]}")
File.delete(File.join(working_directory, file_hash[:path]))
......
require 'ink_step/base'
require 'zip'
require 'ink_step/mixins/zip_methods'
module InkStep::UtilitySteps
class UnzipStep < ::InkStep::Base
include InkStep::Mixins::ZipMethods
def perform_step
source_file_path = find_source_file(regex: /\.#{parameter(:zip_file_extension)}$/)
unzip_file(File.join(working_directory, source_file_path))
unzip_archive(File.join(working_directory, source_file_path))
# cleanup - destroy original archive
File.delete(File.join(working_directory, source_file_path))
......@@ -18,6 +19,10 @@ module InkStep::UtilitySteps
"Unzips target archive"
end
def self.human_readable_name
"Unzip Step"
end
def version
InkStep::VERSION
end
......@@ -34,23 +39,5 @@ module InkStep::UtilitySteps
def default_parameter_values
{zip_file_extension: "zip"}
end
protected
def unzip_file(input_file_path)
log_as_step "Unzipping archive..."
Zip::File.open(input_file_path) do |archive|
archive.each do |f|
@archive_name = f.name unless @archive_name
path = File.join(unzip_directory, f.name)
FileUtils.mkdir_p(File.dirname(path)) unless File.exists?(File.dirname(path))
f.extract(path)
end
end
end
def unzip_directory
File.join(working_directory, @archive_name)
end
end
end
\ No newline at end of file
require 'ink_step/base'
require 'ink_step/mixins/shell_methods'
require 'ink_step/mixins/zip_methods'
module InkStep::UtilitySteps
class ZipStep < ::InkStep::Base
include InkStep::Mixins::ZipMethods
def perform_step
create_archive
......@@ -15,6 +17,10 @@ module InkStep::UtilitySteps
"Zips all files in the working directory into an archive"
end
def self.human_readable_name
"Zip Step"
end
def version
InkStep::VERSION
end
......@@ -53,17 +59,5 @@ module InkStep::UtilitySteps
end
end
end
def create_archive
log_as_step "Zipping archive #{archive_file_name}..."
Zip::File.open(archive_file_name, Zip::File::CREATE) do |zipfile|
Dir.chdir working_directory
Dir.glob("**/*").reject {|fn| File.directory?(fn) }.each do |file|
log_as_step "Adding #{file}"
zipfile.add(file.sub(working_directory + '/', ''), file)
end
end
end
end
end
\ No newline at end of file
......@@ -27,6 +27,10 @@ module InkStep
def self.description
"A demo validator that returns the result you tell it to."
end
def self.human_readable_name
"Arbitrary Validator"
end
end
end
end
\ No newline at end of file
module InkStep
VERSION = '1.2.0'
VERSION = '1.3.0'
end
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<Types xmlns="http://schemas.openxmlformats.org/package/2006/content-types"><Override PartName="/_rels/.rels" ContentType="application/vnd.openxmlformats-package.relationships+xml"/><Override PartName="/word/_rels/document.xml.rels" ContentType="application/vnd.openxmlformats-package.relationships+xml"/><Override PartName="/word/settings.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.settings+xml"/><Override PartName="/word/styles.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.styles+xml"/><Override PartName="/word/document.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml"/><Override PartName="/word/numbering.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.numbering+xml"/><Override PartName="/word/fontTable.xml" ContentType="application/vnd.openxmlformats-officedocument.wordprocessingml.fontTable+xml"/><Override PartName="/docProps/app.xml" ContentType="application/vnd.openxmlformats-officedocument.extended-properties+xml"/><Override PartName="/docProps/core.xml" ContentType="application/vnd.openxmlformats-package.core-properties+xml"/>
</Types>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships"><Relationship Id="rId1" Type="http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties" Target="docProps/core.xml"/><Relationship Id="rId2" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/extended-properties" Target="docProps/app.xml"/><Relationship Id="rId3" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument" Target="word/document.xml"/>
</Relationships>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Properties xmlns="http://schemas.openxmlformats.org/officeDocument/2006/extended-properties" xmlns:vt="http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes"><Template></Template><TotalTime>0</TotalTime><Application>LibreOffice/5.1.6.2$Linux_X86_64 LibreOffice_project/10m0$Build-2</Application><Pages>1</Pages><Words>9</Words><Characters>49</Characters><CharactersWithSpaces>56</CharactersWithSpaces><Paragraphs>2</Paragraphs></Properties>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<cp:coreProperties xmlns:cp="http://schemas.openxmlformats.org/package/2006/metadata/core-properties" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:dcterms="http://purl.org/dc/terms/" xmlns:dcmitype="http://purl.org/dc/dcmitype/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><dcterms:created xsi:type="dcterms:W3CDTF">2016-11-23T11:58:21Z</dcterms:created><dc:creator></dc:creator><dc:description></dc:description><dc:language>en-NZ</dc:language><cp:lastModifiedBy></cp:lastModifiedBy><dcterms:modified xsi:type="dcterms:W3CDTF">2017-04-19T21:13:48Z</dcterms:modified><cp:revision>2</cp:revision><dc:subject></dc:subject><dc:title></dc:title></cp:coreProperties>
\ No newline at end of file
<html xmlns="http://www.w3.org/1999/xhtml"><head><meta charset="UTF-8"/><style type="text/css">
.Heading1 { ; /* Normal*/ text-align: left; /* Heading*/ margin-top: 12pt; margin-bottom: 6pt; /* Heading1*/ margin-top: 12pt; margin-bottom: 6pt; margin-left: 0pt; margin-right: 0pt; text-indent: -0pt; padding-left: 0pt }
.TextBody { ; /* Normal*/ text-align: left; /* TextBody*/ margin-top: 0pt; margin-bottom: 7pt }</style></head><body><div class="docx-body"><p class="Heading1" style="text-align: left; margin-top: 12pt; margin-bottom: 6pt; margin-left: 0pt; margin-right: 0pt; text-indent: -0pt; padding-left: 0pt">Test document with some content</p><p class="TextBody" style="text-align: left; margin-top: 0pt; margin-bottom: 7pt">Exciting test document #1</p><p class="TextBody" style="text-align: left; margin-top: 0pt; margin-bottom: 7pt"/></div><div class="docx-endnotes"/><div class="docx-footnotes"/></body></html>
\ No newline at end of file
# FYI - The process chain working directory has been replaced with "$process_chain_working_directory".
17-08-01 10:49:02 [InkStep::Coko::XsweetPipeline::DocxExtract::DocxToHtmlExtractStep] - Getting files from directory: $process_chain_working_directory/input_files...
17-08-01 10:49:02 [InkStep::Coko::XsweetPipeline::DocxExtract::DocxToHtmlExtractStep] - Copying files from $process_chain_working_directory/input_files to $process_chain_working_directory/1
17-08-01 10:49:02 [InkStep::Coko::XsweetPipeline::DocxExtract::DocxToHtmlExtractStep] - Using version 1.0.0
17-08-01 10:49:02 [InkStep::Coko::XsweetPipeline::DocxExtract::DocxToHtmlExtractStep] - Execution parameters:
17-08-01 10:49:02 [InkStep::Coko::XsweetPipeline::DocxExtract::DocxToHtmlExtractStep] - {}
17-08-01 10:49:02 [InkStep::Coko::XsweetPipeline::DocxExtract::DocxToHtmlExtractStep] - converting important_document.docx to important_document.html
17-08-01 10:49:02 [InkStep::Coko::XsweetPipeline::DocxExtract::DocxToHtmlExtractStep] - Downloading https://gitlab.coko.foundation/wendell/XSweet/raw/ink-api-publish/applications/docx-extract/docx-html-extract.xsl to $process_chain_working_directory/1...
17-08-01 10:49:04 [InkStep::Coko::XsweetPipeline::DocxExtract::DocxToHtmlExtractStep] - Applying xsl...
17-08-01 10:49:04 [InkStep::Coko::XsweetPipeline::DocxExtract::DocxToHtmlExtractStep] - Running command 'java -jar /home/charlie/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/bundler/gems/inkstep_coko_conversion-10810863cda6/lib/coko_conversion/utilities/Saxon-HE-9.7.0-4.jar -s:$process_chain_working_directory/1/unzip/word/document.xml -xsl:$process_chain_working_directory/1/docx-html-extract.xsl -o:$process_chain_working_directory/1/important_document.html'
17-08-01 10:49:06 [InkStep::Coko::XsweetPipeline::DocxExtract::DocxToHtmlExtractStep] - Finished at 2017-08-01 10:49:06 UTC
17-08-01 10:49:06 [InkStep::Coko::XsweetPipeline::DocxExtract::DocxToHtmlExtractStep] - Errors: []
<?xml version="1.0" encoding="UTF-8"?>
<Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships"><Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles" Target="styles.xml"/><Relationship Id="rId2" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/numbering" Target="numbering.xml"/><Relationship Id="rId3" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/fontTable" Target="fontTable.xml"/><Relationship Id="rId4" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/settings" Target="settings.xml"/>
</Relationships>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<w:document xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main" xmlns:w10="urn:schemas-microsoft-com:office:word" xmlns:wp="http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing" xmlns:wps="http://schemas.microsoft.com/office/word/2010/wordprocessingShape" xmlns:wpg="http://schemas.microsoft.com/office/word/2010/wordprocessingGroup" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:wp14="http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing" xmlns:w14="http://schemas.microsoft.com/office/word/2010/wordml" mc:Ignorable="w14 wp14"><w:body><w:p><w:pPr><w:pStyle w:val="Heading1"/><w:numPr><w:ilvl w:val="0"/><w:numId w:val="2"/></w:numPr><w:spacing w:before="240" w:after="120"/><w:ind w:left="0" w:right="0" w:hanging="0"/><w:rPr></w:rPr></w:pPr><w:r><w:rPr></w:rPr><w:t>Test document with some content</w:t></w:r></w:p><w:p><w:pPr><w:pStyle w:val="TextBody"/><w:rPr></w:rPr></w:pPr><w:r><w:rPr></w:rPr><w:t>Exciting test document #1</w:t></w:r></w:p><w:p><w:pPr><w:pStyle w:val="TextBody"/><w:spacing w:before="0" w:after="140"/><w:rPr></w:rPr></w:pPr><w:r><w:rPr></w:rPr></w:r></w:p><w:sectPr><w:type w:val="nextPage"/><w:pgSz w:w="12240" w:h="15840"/><w:pgMar w:left="1134" w:right="1134" w:header="0" w:top="1134" w:footer="0" w:bottom="1134" w:gutter="0"/><w:pgNumType w:fmt="decimal"/><w:formProt w:val="false"/><w:textDirection w:val="lrTb"/><w:docGrid w:type="default" w:linePitch="240" w:charSpace="4294961151"/></w:sectPr></w:body></w:document>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<w:fonts xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships"><w:font w:name="Times New Roman"><w:charset w:val="00"/><w:family w:val="roman"/><w:pitch w:val="variable"/></w:font><w:font w:name="Symbol"><w:charset w:val="02"/><w:family w:val="roman"/><w:pitch w:val="variable"/></w:font><w:font w:name="Arial"><w:charset w:val="00"/><w:family w:val="swiss"/><w:pitch w:val="variable"/></w:font><w:font w:name="Liberation Serif"><w:altName w:val="Times New Roman"/><w:charset w:val="01"/><w:family w:val="roman"/><w:pitch w:val="variable"/></w:font><w:font w:name="Liberation Sans"><w:altName w:val="Arial"/><w:charset w:val="01"/><w:family w:val="roman"/><w:pitch w:val="variable"/></w:font></w:fonts>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<w:numbering xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" xmlns:v="urn:schemas-microsoft-com:vml"><w:abstractNum w:abstractNumId="1"><w:lvl w:ilvl="0"><w:start w:val="1"/><w:pStyle w:val="Heading1"/><w:numFmt w:val="none"/><w:suff w:val="nothing"/><w:lvlText w:val=""/><w:lvlJc w:val="left"/><w:pPr><w:ind w:left="432" w:hanging="432"/></w:pPr></w:lvl><w:lvl w:ilvl="1"><w:start w:val="1"/><w:numFmt w:val="none"/><w:suff w:val="nothing"/><w:lvlText w:val=""/><w:lvlJc w:val="left"/><w:pPr><w:tabs><w:tab w:val="num" w:pos="576"/></w:tabs><w:ind w:left="576" w:hanging="576"/></w:pPr></w:lvl><w:lvl w:ilvl="2"><w:start w:val="1"/><w:numFmt w:val="none"/><w:suff w:val="nothing"/><w:lvlText w:val=""/><w:lvlJc w:val="left"/><w:pPr><w:tabs><w:tab w:val="num" w:pos="720"/></w:tabs><w:ind w:left="720" w:hanging="720"/></w:pPr></w:lvl><w:lvl w:ilvl="3"><w:start w:val="1"/><w:numFmt w:val="none"/><w:suff w:val="nothing"/><w:lvlText w:val=""/><w:lvlJc w:val="left"/><w:pPr><w:tabs><w:tab w:val="num" w:pos="864"/></w:tabs><w:ind w:left="864" w:hanging="864"/></w:pPr></w:lvl><w:lvl w:ilvl="4"><w:start w:val="1"/><w:numFmt w:val="none"/><w:suff w:val="nothing"/><w:lvlText w:val=""/><w:lvlJc w:val="left"/><w:pPr><w:tabs><w:tab w:val="num" w:pos="1008"/></w:tabs><w:ind w:left="1008" w:hanging="1008"/></w:pPr></w:lvl><w:lvl w:ilvl="5"><w:start w:val="1"/><w:numFmt w:val="none"/><w:suff w:val="nothing"/><w:lvlText w:val=""/><w:lvlJc w:val="left"/><w:pPr><w:tabs><w:tab w:val="num" w:pos="1152"/></w:tabs><w:ind w:left="1152" w:hanging="1152"/></w:pPr></w:lvl><w:lvl w:ilvl="6"><w:start w:val="1"/><w:numFmt w:val="none"/><w:suff w:val="nothing"/><w:lvlText w:val=""/><w:lvlJc w:val="left"/><w:pPr><w:tabs><w:tab w:val="num" w:pos="1296"/></w:tabs><w:ind w:left="1296" w:hanging="1296"/></w:pPr></w:lvl><w:lvl w:ilvl="7"><w:start w:val="1"/><w:numFmt w:val="none"/><w:suff w:val="nothing"/><w:lvlText w:val=""/><w:lvlJc w:val="left"/><w:pPr><w:tabs><w:tab w:val="num" w:pos="1440"/></w:tabs><w:ind w:left="1440" w:hanging="1440"/></w:pPr></w:lvl><w:lvl w:ilvl="8"><w:start w:val="1"/><w:numFmt w:val="none"/><w:suff w:val="nothing"/><w:lvlText w:val=""/><w:lvlJc w:val="left"/><w:pPr><w:tabs><w:tab w:val="num" w:pos="1584"/></w:tabs><w:ind w:left="1584" w:hanging="1584"/></w:pPr></w:lvl></w:abstractNum><w:abstractNum w:abstractNumId="2"><w:lvl w:ilvl="0"><w:start w:val="1"/><w:numFmt w:val="none"/><w:suff w:val="nothing"/><w:lvlText w:val=""/><w:lvlJc w:val="left"/><w:pPr><w:ind w:left="432" w:hanging="432"/></w:pPr></w:lvl><w:lvl w:ilvl="1"><w:start w:val="1"/><w:numFmt w:val="none"/><w:suff w:val="nothing"/><w:lvlText w:val=""/><w:lvlJc w:val="left"/><w:pPr><w:ind w:left="576" w:hanging="576"/></w:pPr></w:lvl><w:lvl w:ilvl="2"><w:start w:val="1"/><w:numFmt w:val="none"/><w:suff w:val="nothing"/><w:lvlText w:val=""/><w:lvlJc w:val="left"/><w:pPr><w:ind w:left="720" w:hanging="720"/></w:pPr></w:lvl><w:lvl w:ilvl="3"><w:start w:val="1"/><w:numFmt w:val="none"/><w:suff w:val="nothing"/><w:lvlText w:val=""/><w:lvlJc w:val="left"/><w:pPr><w:ind w:left="864" w:hanging="864"/></w:pPr></w:lvl><w:lvl w:ilvl="4"><w:start w:val="1"/><w:numFmt w:val="none"/><w:suff w:val="nothing"/><w:lvlText w:val=""/><w:lvlJc w:val="left"/><w:pPr><w:ind w:left="1008" w:hanging="1008"/></w:pPr></w:lvl><w:lvl w:ilvl="5"><w:start w:val="1"/><w:numFmt w:val="none"/><w:suff w:val="nothing"/><w:lvlText w:val=""/><w:lvlJc w:val="left"/><w:pPr><w:ind w:left="1152" w:hanging="1152"/></w:pPr></w:lvl><w:lvl w:ilvl="6"><w:start w:val="1"/><w:numFmt w:val="none"/><w:suff w:val="nothing"/><w:lvlText w:val=""/><w:lvlJc w:val="left"/><w:pPr><w:ind w:left="1296" w:hanging="1296"/></w:pPr></w:lvl><w:lvl w:ilvl="7"><w:start w:val="1"/><w:numFmt w:val="none"/><w:suff w:val="nothing"/><w:lvlText w:val=""/><w:lvlJc w:val="left"/><w:pPr><w:ind w:left="1440" w:hanging="1440"/></w:pPr></w:lvl><w:lvl w:ilvl="8"><w:start w:val="1"/><w:numFmt w:val="none"/><w:suff w:val="nothing"/><w:lvlText w:val=""/><w:lvlJc w:val="left"/><w:pPr><w:ind w:left="1584" w:hanging="1584"/></w:pPr></w:lvl></w:abstractNum><w:num w:numId="1"><w:abstractNumId w:val="1"/></w:num><w:num w:numId="2"><w:abstractNumId w:val="2"/></w:num></w:numbering>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<w:settings xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main"><w:zoom w:percent="100"/><w:defaultTabStop w:val="709"/><w:compat></w:compat><w:themeFontLang w:val="" w:eastAsia="" w:bidi=""/></w:settings>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<w:styles xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main" xmlns:w14="http://schemas.microsoft.com/office/word/2010/wordml" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="w14"><w:docDefaults><w:rPrDefault><w:rPr><w:rFonts w:ascii="Liberation Serif" w:hAnsi="Liberation Serif" w:eastAsia="Noto Sans CJK SC Regular" w:cs="FreeSans"/><w:szCs w:val="24"/><w:lang w:val="en-NZ" w:eastAsia="zh-CN" w:bidi="hi-IN"/></w:rPr></w:rPrDefault><w:pPrDefault><w:pPr></w:pPr></w:pPrDefault></w:docDefaults><w:style w:type="paragraph" w:styleId="Normal"><w:name w:val="Normal"/><w:qFormat/><w:pPr><w:widowControl/><w:overflowPunct w:val="false"/><w:bidi w:val="0"/><w:jc w:val="left"/></w:pPr><w:rPr><w:rFonts w:ascii="Liberation Serif" w:hAnsi="Liberation Serif" w:eastAsia="Noto Sans CJK SC Regular" w:cs="FreeSans"/><w:color w:val="00000A"/><w:sz w:val="24"/><w:szCs w:val="24"/><w:lang w:val="en-NZ" w:eastAsia="zh-CN" w:bidi="hi-IN"/></w:rPr></w:style><w:style w:type="paragraph" w:styleId="Heading1"><w:name w:val="Heading 1"/><w:basedOn w:val="Heading"/><w:qFormat/><w:pPr><w:numPr><w:ilvl w:val="0"/><w:numId w:val="1"/></w:numPr><w:spacing w:before="240" w:after="120"/><w:ind w:left="0" w:right="0" w:hanging="0"/><w:outlineLvl w:val="0"/><w:outlineLvl w:val="0"/></w:pPr><w:rPr><w:b/><w:bCs/><w:sz w:val="36"/><w:szCs w:val="36"/></w:rPr></w:style><w:style w:type="paragraph" w:styleId="Heading"><w:name w:val="Heading"/><w:basedOn w:val="Normal"/><w:next w:val="TextBody"/><w:qFormat/><w:pPr><w:keepNext/><w:spacing w:before="240" w:after="120"/></w:pPr><w:rPr><w:rFonts w:ascii="Liberation Sans" w:hAnsi="Liberation Sans" w:eastAsia="Noto Sans CJK SC Regular" w:cs="FreeSans"/><w:sz w:val="28"/><w:szCs w:val="28"/></w:rPr></w:style><w:style w:type="paragraph" w:styleId="TextBody"><w:name w:val="Body Text"/><w:basedOn w:val="Normal"/><w:pPr><w:spacing w:lineRule="auto" w:line="288" w:before="0" w:after="140"/></w:pPr><w:rPr></w:rPr></w:style><w:style w:type="paragraph" w:styleId="List"><w:name w:val="List"/><w:basedOn w:val="TextBody"/><w:pPr></w:pPr><w:rPr><w:rFonts w:cs="FreeSans"/></w:rPr></w:style><w:style w:type="paragraph" w:styleId="Caption"><w:name w:val="Caption"/><w:basedOn w:val="Normal"/><w:qFormat/><w:pPr><w:suppressLineNumbers/><w:spacing w:before="120" w:after="120"/></w:pPr><w:rPr><w:rFonts w:cs="FreeSans"/><w:i/><w:iCs/><w:sz w:val="24"/><w:szCs w:val="24"/></w:rPr></w:style><w:style w:type="paragraph" w:styleId="Index"><w:name w:val="Index"/><w:basedOn w:val="Normal"/><w:qFormat/><w:pPr><w:suppressLineNumbers/></w:pPr><w:rPr><w:rFonts w:cs="FreeSans"/></w:rPr></w:style></w:styles>
\ No newline at end of file
......@@ -7,7 +7,7 @@ describe "#perform_step" do
let(:target_file) { File.join(Dir.pwd, "spec", "fixtures", "files", target_file_name) }
let!(:input_file_path) { File.join(temp_directory, InkStep::Base::INPUT_FILE_DIRECTORY_NAME) }
subject { InkStep::UtilitySteps::UnzipStep.new(chain_file_location: temp_directory, position: 1, incoming_file_manifest: [path: target_file_name]) }
subject { InkStep::UtilitySteps::UnzipStep.new(chain_file_location: temp_directory, position: 1) }
before do
create_directory_if_needed(subject.working_directory)
......@@ -17,10 +17,23 @@ describe "#perform_step" do
describe '#perform_step' do
specify do
subject.input_file_manifest = subject.semantically_tagged_manifest
subject.perform_step
expect(subject.errors).to match_array([])
end
end
describe '#description' do
it 'has a description' do
expect{subject.class.description}.to_not raise_error
end
end
describe '#human_readable_name' do
it 'has a human readable name' do
expect{subject.class.human_readable_name}.to_not raise_error
end
end
end
......@@ -8,7 +8,7 @@ describe "Testing validators" do
let(:target_file) { File.join(Dir.pwd, "spec", "fixtures", "files", target_file_name) }
let!(:input_file_path) { File.join(temp_directory, InkStep::Base::INPUT_FILE_DIRECTORY_NAME) }
subject { InkStep::ValidationSteps::ArbitraryValidator.new(chain_file_location: temp_directory, position: 1, incoming_file_manifest: [path: target_file_name]) }
subject { InkStep::ValidationSteps::ArbitraryValidator.new(chain_file_location: temp_directory, position: 1) }
before do
create_directory_if_needed(temp_directory)
......@@ -45,5 +45,17 @@ describe "Testing validators" do
end
end
end
describe '#description' do
it 'has a description' do
expect{subject.class.description}.to_not raise_error
end
end
describe '#human_readable_name' do
it 'has a human readable name' do
expect{subject.class.human_readable_name}.to_not raise_error
end
end
end
......@@ -3,28 +3,45 @@ require 'spec_helper'
require 'ink_step/utility_steps/zip_step'
require 'zip'
describe "#perform_step" do
describe InkStep::UtilitySteps::ZipStep do
let(:target_file_name) { "some_text.html" }
let(:target_file) { File.join(Dir.pwd, "spec", "fixtures", "files", target_file_name) }
let!(:input_file_path) { File.join(temp_directory, InkStep::Base::INPUT_FILE_DIRECTORY_NAME) }
subject { InkStep::UtilitySteps::ZipStep.new(chain_file_location: temp_directory, position: 1, incoming_file_manifest: [path: target_file_name]) }
let(:input_directory) { File.join(temp_directory, InkStep::Base::INPUT_FILE_DIRECTORY_NAME) }
before do
create_directory_if_needed(subject.working_directory)
create_directory_if_needed(input_file_path)
FileUtils.cp(target_file, subject.working_directory)
create_directory_if_needed(input_directory)
FileUtils.cp(target_file, input_directory)
end
subject { InkStep::UtilitySteps::ZipStep.new(chain_file_location: temp_directory, position: 1) }
after do
FileUtils.rm_rf(Dir.glob("#{subject.working_directory}/*"))
FileUtils.rm_rf(Dir.glob("#{temp_directory}/*"))
end
describe '#perform_step' do
specify do
subject.perform_step
expect(subject.errors).to match_array([])
manifest = subject.send(:semantically_tagged_manifest)
expect(manifest.size).to eq 1
first_manifest_item = manifest.first
expect(first_manifest_item[:path]).to eq "archive.zip"
expect(first_manifest_item[:tag]).to eq :new
end
end
describe '#description' do
it 'has a description' do
expect{subject.class.description}.to_not raise_error
end
end
describe '#human_readable_name' do
it 'has a human readable name' do
expect{subject.class.human_readable_name}.to_not raise_error
end
end
end
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment