dnnbundler 0.1.3 → 0.1.4
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 +4 -4
- data/README.md +4 -3
- data/lib/dnnbundler/cli.rb +1 -1
- data/lib/dnnbundler/jsonConfig.rb +10 -0
- data/lib/dnnbundler/version.rb +1 -1
- data/lib/dnnbundler/zipFileGenerator.rb +19 -17
- metadata +2 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 38fb92f25f2f1562aa75bc843eefed30a8da7e67
|
|
4
|
+
data.tar.gz: 75d959d795f88459d38a75d4825cbfed3d235c73
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: ea1801bd3d89ec4b032576b978fef3db985ed9bc14f46df557cb2606bd7563f198ed29bbaa6f37b1b035590f3ff02f88573bb3b314afb1276df45a36f3f56158
|
|
7
|
+
data.tar.gz: 8a5218f18c49447b8fe28fe487eadd284fd082bdbc249d35b9a05d3654169b85fdcdbc85093a420d2140e71c361e2aa28271223ae6ab953b8d34fa15a629d3c4
|
data/README.md
CHANGED
|
@@ -25,6 +25,7 @@ Or install it yourself as:
|
|
|
25
25
|
To configure packaging create a json config with the following schema:
|
|
26
26
|
|
|
27
27
|
{
|
|
28
|
+
"name": "out.zip",
|
|
28
29
|
"entries": [
|
|
29
30
|
"path_to_file",
|
|
30
31
|
"path_to_directory", // real path in file system to file or directory
|
|
@@ -36,6 +37,7 @@ To configure packaging create a json config with the following schema:
|
|
|
36
37
|
{
|
|
37
38
|
"type": "zip", // nested zip archive
|
|
38
39
|
"name": "test.zip", // name of nested zip archive, can include directories
|
|
40
|
+
"ignoreEntries": [ ... ] // local array of entries to ignore
|
|
39
41
|
"entries": [ // array of entries for nested zip file, same format as above
|
|
40
42
|
"file",
|
|
41
43
|
"dir",
|
|
@@ -43,10 +45,9 @@ To configure packaging create a json config with the following schema:
|
|
|
43
45
|
]
|
|
44
46
|
}
|
|
45
47
|
],
|
|
46
|
-
"
|
|
48
|
+
"ignoreEntries": [
|
|
47
49
|
".DS_Store"
|
|
48
|
-
]
|
|
49
|
-
"outFileName": "out.zip"
|
|
50
|
+
]
|
|
50
51
|
}
|
|
51
52
|
|
|
52
53
|
to create package run:
|
data/lib/dnnbundler/cli.rb
CHANGED
|
@@ -14,7 +14,7 @@ module Dnnbundler
|
|
|
14
14
|
input_entries = data_hash["entries"]
|
|
15
15
|
ignore_entries = data_hash["excludeEntries"]
|
|
16
16
|
zip_file_name = data_hash["outFileName"]
|
|
17
|
-
generator = ZipFileGenerator.new(
|
|
17
|
+
generator = ZipFileGenerator.new(data_hash)
|
|
18
18
|
generator.write
|
|
19
19
|
end
|
|
20
20
|
end
|
data/lib/dnnbundler/version.rb
CHANGED
|
@@ -1,28 +1,30 @@
|
|
|
1
1
|
require "dnnbundler/fileEntryType"
|
|
2
2
|
require "dnnbundler/fileEntry"
|
|
3
|
+
require "dnnbundler/jsonConfig"
|
|
3
4
|
require "zip"
|
|
4
5
|
|
|
5
6
|
module Dnnbundler
|
|
6
7
|
class ZipFileGenerator
|
|
7
8
|
# Initialize with the directory to zip and the location of the output archive.
|
|
8
|
-
def initialize(
|
|
9
|
-
@entries =
|
|
10
|
-
@ignore_entries =
|
|
11
|
-
@output_file =
|
|
9
|
+
def initialize(data)
|
|
10
|
+
@entries = data[JsonConfig::Entries]
|
|
11
|
+
@ignore_entries = data[JsonConfig::IgnoreEntries]
|
|
12
|
+
@output_file = data[JsonConfig::Name]
|
|
12
13
|
end
|
|
13
14
|
|
|
14
15
|
# Zip the input directory.
|
|
15
16
|
def write
|
|
16
|
-
buffer = create_zip @entries
|
|
17
|
+
buffer = create_zip @entries, @ignore_entries
|
|
17
18
|
File.open(@output_file, "wb") {|f| f.write buffer.string }
|
|
18
19
|
end
|
|
19
20
|
|
|
20
21
|
private
|
|
21
22
|
|
|
22
|
-
# True if +fileEntry+ isn't included into
|
|
23
|
-
def filter_entries(fileEntry)
|
|
24
|
-
|
|
25
|
-
|
|
23
|
+
# True if +fileEntry+ isn't included into +ignore_entries+ array'
|
|
24
|
+
def filter_entries(fileEntry, ignore_entries)
|
|
25
|
+
return true if ignore_entries == nil
|
|
26
|
+
ignore_entries.each do |entry|
|
|
27
|
+
return false if (fileEntry.type.casecmp(FileEntryType::FILE) != 0) && (fileEntry.name.include? entry)
|
|
26
28
|
end
|
|
27
29
|
end
|
|
28
30
|
|
|
@@ -64,7 +66,7 @@ module Dnnbundler
|
|
|
64
66
|
puts "#{ entries.map{ |x| x.name + ", " + x.path.to_s }.join("\n")}"
|
|
65
67
|
buffer = Zip::File.add_buffer do |zio|
|
|
66
68
|
entries.each do |file|
|
|
67
|
-
if file.type ==
|
|
69
|
+
if file.type.casecmp(FileEntryType::FILE) == 0
|
|
68
70
|
zio.add(file.path == nil ? file.name : file.path, file.name)
|
|
69
71
|
else
|
|
70
72
|
zio.get_output_stream(file.path == nil ? file.name : file.path) { |os| os.write file.buffer.string }
|
|
@@ -74,18 +76,18 @@ module Dnnbundler
|
|
|
74
76
|
end
|
|
75
77
|
|
|
76
78
|
# Creates from json array of entries
|
|
77
|
-
def create_zip(entries)
|
|
79
|
+
def create_zip(entries, ignore_entries)
|
|
78
80
|
compress entries.map { |x|
|
|
79
81
|
if x.is_a? String
|
|
80
82
|
get_entries x, nil
|
|
81
|
-
elsif x[
|
|
82
|
-
get_entries x[
|
|
83
|
-
elsif x[
|
|
84
|
-
zip_file_entry = FileEntry.new x[
|
|
85
|
-
zip_file_entry.add_buffer create_zip x[
|
|
83
|
+
elsif x[JsonConfig::Type].casecmp(FileEntryType::FILE) == 0
|
|
84
|
+
get_entries x[JsonConfig::Name], x[JsonConfig::Path]
|
|
85
|
+
elsif x[JsonConfig::Type].casecmp(FileEntryType::ZIP) == 0
|
|
86
|
+
zip_file_entry = FileEntry.new x[JsonConfig::Name], FileEntryType::ZIP, false, x[JsonConfig::Path]
|
|
87
|
+
zip_file_entry.add_buffer create_zip x[JsonConfig::Entries], x[JsonConfig::IgnoreEntries]
|
|
86
88
|
result = zip_file_entry
|
|
87
89
|
end
|
|
88
|
-
}.flatten.select{ |f| filter_entries f }.uniq{ |f| f.name }
|
|
90
|
+
}.flatten.select{ |f| filter_entries f, ignore_entries }.uniq{ |f| f.name }
|
|
89
91
|
end
|
|
90
92
|
end
|
|
91
93
|
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: dnnbundler
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
4
|
+
version: 0.1.4
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Le0Michine
|
|
@@ -102,6 +102,7 @@ files:
|
|
|
102
102
|
- lib/dnnbundler/cli.rb
|
|
103
103
|
- lib/dnnbundler/fileEntry.rb
|
|
104
104
|
- lib/dnnbundler/fileEntryType.rb
|
|
105
|
+
- lib/dnnbundler/jsonConfig.rb
|
|
105
106
|
- lib/dnnbundler/version.rb
|
|
106
107
|
- lib/dnnbundler/zipFileGenerator.rb
|
|
107
108
|
homepage: https://github.com/Le0Michine/dnnbundler
|