Skip to content

Commit

Permalink
Merge pull request #98 from alces-software/dev/allow-local-paths
Browse files Browse the repository at this point in the history
Allow local paths
  • Loading branch information
atoghill authored Mar 19, 2019
2 parents 9137420 + 4d0a440 commit 18683d3
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion lib/inventoryware/commands/parse.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@

require 'fileutils'
require 'xmlhasher'
require 'pathname'
require 'yaml'
require 'zip'

Expand All @@ -46,11 +47,30 @@ def run
config.string_keys = true
end

# determine if given path is absolute
file_name = @argv[0]
file_path = Pathname.new(file_name)
unless file_path.absolute?
file_path = Dir.glob("/**/#{file_name}")[0]
end

if file_path.nil?
raise ArgumentError, <<-ERROR.chomp
Please refine your search and try again.
ERROR
else
if not Utils.check_file_readable?(file_path)
raise ArgumentError, <<-ERROR.chomp
Zip file at #{file_path} inaccessible.
ERROR
end
end

begin
top_dir = Dir.mktmpdir('inv_ware_')

# get all zips in in the source, if it's a dir or not
top_lvl_zip_paths = expand_dir(@argv[0])
top_lvl_zip_paths = expand_dir(file_path)

# for each of these, extract to /tmp/
top_lvl_zip_paths.each { |zip_path| extract_zip(zip_path, top_dir) }
Expand Down

0 comments on commit 18683d3

Please sign in to comment.