Class: Dply::Archive
Instance Attribute Summary collapse
-
#checksum_path ⇒ Object
readonly
Returns the value of attribute checksum_path.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
-
#uri ⇒ Object
readonly
Returns the value of attribute uri.
Instance Method Summary collapse
- #extract(&block) ⇒ Object
-
#initialize(url, verify_checksum: true) ⇒ Archive
constructor
A new instance of Archive.
Methods included from Helper
#cmd, #error, #git, #logger, #stringify_values!, #symlink
Constructor Details
#initialize(url, verify_checksum: true) ⇒ Archive
Returns a new instance of Archive.
13 14 15 16 17 18 19 |
# File 'lib/dply/archive.rb', line 13 def initialize(url, verify_checksum: true) @uri = URI.parse url @verify_checksum = verify_checksum @name = File.basename(uri.path) @path = "tmp/archive/#{name}" @checksum_path = "tmp/archive/#{name}.md5" end |
Instance Attribute Details
#checksum_path ⇒ Object (readonly)
Returns the value of attribute checksum_path.
11 12 13 |
# File 'lib/dply/archive.rb', line 11 def checksum_path @checksum_path end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
11 12 13 |
# File 'lib/dply/archive.rb', line 11 def name @name end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
11 12 13 |
# File 'lib/dply/archive.rb', line 11 def path @path end |
#uri ⇒ Object (readonly)
Returns the value of attribute uri.
11 12 13 |
# File 'lib/dply/archive.rb', line 11 def uri @uri end |
Instance Method Details
#extract(&block) ⇒ Object
21 22 23 24 25 26 27 28 29 30 |
# File 'lib/dply/archive.rb', line 21 def extract(&block) download_file Dir.mktmpdir "tmp", "./" do |d| extracted = "#{d}/extracted" FileUtils.mkdir extracted cmd "tar xf #{path} -C #{extracted}", display: true yield extracted end cleanup end |