pad_utils 1.11.0 → 1.12.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: 164a7a9d1b5d575fa09d5a6912e78141cc8bd5aa
4
- data.tar.gz: 9d418e97d8519acb4bcaf3773d66f9c279df8225
3
+ metadata.gz: a57ad969adf349766fdd182d7584def31151f923
4
+ data.tar.gz: 7573d40a4b00a0840b4570f28feb8056c4392ce3
5
5
  SHA512:
6
- metadata.gz: 6d92e366b5ea10c6d66f9c5b34cd299cd58ff8aa5674050930d2ab7b55feeb7469372f126c769f0beb84016ad35c51d824ee5506d8aac46891803d827a02f653
7
- data.tar.gz: 217ef6fb0b8bd57926ea645fdb558c5abb1bcbf6a0c694c64afe6adb156311f0833faa4b91593fe90622c3ab568446dc0da9ebdce36952a48d3023421c326577
6
+ metadata.gz: ced60c55e799ddef2dc513d65dcfbae361294b06b612428b35d9903b7c8aa5b5b81d69fa1aafbd2b31af2ecff1df8ae622f4ea12f014fc2392f370f06b837a4a
7
+ data.tar.gz: 17a2ca11e5a148e33c0303433070a806e5030e9da97a2a76f2001d117ce474b424696b0386b59c904a57b68544b9cae6bb8aef7e52c54963dae3c3de428cd7c6
@@ -0,0 +1,27 @@
1
+ require 'zip'
2
+ require 'fileutils'
3
+
4
+ module PadUtils
5
+
6
+ # Extracts a zip file.
7
+ #
8
+ # @note If the target path doesn't exist, it will be created. Existing files
9
+ # will **not** be overwritten.
10
+ #
11
+ # @param filename [String] the path and name of the zip file
12
+ # @param target_path [String] the target directory where to extract the file
13
+ def self.extract_zip(filename, target_path)
14
+ # Unzip the content
15
+ Zip::File.open(filename) do |zip_file|
16
+ zip_file.each do |f|
17
+ f_path=File.join(target_path, f.name)
18
+ FileUtils.mkdir_p(File.dirname(f_path))
19
+ zip_file.extract(f, f_path) unless File.exist?(f_path)
20
+ end
21
+ end
22
+ # Get rid of these filthy OS X files
23
+ PadUtils.delete_directory "#{target_path}/__MACOSX" if PadUtils.file_exist?("#{target_path}/__MACOSX")
24
+ PadUtils.delete_recursive("#{target_path}", ".DS_Store")
25
+ end
26
+
27
+ end
@@ -16,6 +16,17 @@ module PadUtils
16
16
  FileUtils.rm(file_path, force: true)
17
17
  end
18
18
 
19
+ # Deletes a file recursively.
20
+ #
21
+ # @param path [String] the path to search recurively
22
+ # @param filename [String] the filename to search and delete. `*` wildcard accepted
23
+ # @return [Void] nothing
24
+ # @example
25
+ # PadUtils.delete_recursive("images/photos", ".DS_Store")
26
+ def self.delete_recursive(path, filename)
27
+ Dir.glob("#{path}/**/#{filename}").each { |f| File.delete(f) }
28
+ end
29
+
19
30
  # Checks if a file exists.
20
31
  #
21
32
  # @param file_path [String] the file path and name
@@ -1,4 +1,4 @@
1
1
  module PadUtils
2
2
  # PadUtils version number
3
- VERSION = "1.11.0"
3
+ VERSION = "1.12.0"
4
4
  end
data/lib/pad_utils.rb CHANGED
@@ -9,6 +9,7 @@ require_relative "pad_utils/pad_color"
9
9
  require_relative "pad_utils/pad_code"
10
10
  require_relative "pad_utils/pad_security"
11
11
  require_relative "pad_utils/pad_http"
12
+ require_relative "pad_utils/pad_compression"
12
13
  require_relative "pad_utils/padstone/connection"
13
14
 
14
15
  # Main namespace for PadUtils.
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pad_utils
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.11.0
4
+ version: 1.12.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nico Schuele
@@ -50,6 +50,26 @@ dependencies:
50
50
  - - "<"
51
51
  - !ruby/object:Gem::Version
52
52
  version: '0.14'
53
+ - !ruby/object:Gem::Dependency
54
+ name: rubyzip
55
+ requirement: !ruby/object:Gem::Requirement
56
+ requirements:
57
+ - - ">="
58
+ - !ruby/object:Gem::Version
59
+ version: '1.2'
60
+ - - "<"
61
+ - !ruby/object:Gem::Version
62
+ version: '1.3'
63
+ type: :runtime
64
+ prerelease: false
65
+ version_requirements: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - ">="
68
+ - !ruby/object:Gem::Version
69
+ version: '1.2'
70
+ - - "<"
71
+ - !ruby/object:Gem::Version
72
+ version: '1.3'
53
73
  description: PadUtils is a simple gem containing common utilities and shortcuts. It
54
74
  is used in the Padstone app builder but can be embedded in any other Ruby project.
55
75
  email:
@@ -66,6 +86,7 @@ files:
66
86
  - lib/pad_utils.rb
67
87
  - lib/pad_utils/pad_code.rb
68
88
  - lib/pad_utils/pad_color.rb
89
+ - lib/pad_utils/pad_compression.rb
69
90
  - lib/pad_utils/pad_files.rb
70
91
  - lib/pad_utils/pad_http.rb
71
92
  - lib/pad_utils/pad_json.rb