dnnbundler 0.1.0 → 0.1.1
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/dnnbundler.gemspec +6 -16
- data/exe/dnnbundler +5 -0
- data/lib/dnnbundler/cli.rb +21 -0
- data/lib/dnnbundler/fileEntry.rb +29 -0
- data/lib/dnnbundler/fileEntryType.rb +6 -0
- data/lib/dnnbundler/version.rb +1 -1
- data/lib/dnnbundler/zipFileGenerator.rb +73 -0
- data/lib/dnnbundler.rb +3 -2
- metadata +13 -22
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: ecc72eb4ba5ecd789f5a32acede4f1e1eed52ef1
|
|
4
|
+
data.tar.gz: 9821ccbf7e1fcee2de2b97ea5fe501f59093e324
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 82977794ab2a58803f2a540c4307b864e273100aa1b8749814a05a8e95d88e374653f71abaaf70d382b37b21152719043537034c7dbcd9e16b209fce2d4100ad
|
|
7
|
+
data.tar.gz: 8342e42a4fd538526327311d75a25e9bb4bc3a9759fc3475d6bef51c6f5e0f112ba75d626111e38eb8871cf5b2d6f28e7136c9304d7474269238c4cbb898bf01
|
data/dnnbundler.gemspec
CHANGED
|
@@ -9,20 +9,11 @@ Gem::Specification.new do |spec|
|
|
|
9
9
|
spec.authors = ["Le0Michine"]
|
|
10
10
|
spec.email = ["leomichine@gmail.com"]
|
|
11
11
|
|
|
12
|
-
spec.summary = %q{
|
|
13
|
-
spec.description = %q{
|
|
14
|
-
spec.homepage = "https://
|
|
12
|
+
spec.summary = %q{Write a short summary, because Rubygems requires one.}
|
|
13
|
+
spec.description = %q{Write a longer description or delete this line.}
|
|
14
|
+
spec.homepage = "https://github.com"
|
|
15
15
|
spec.license = "MIT"
|
|
16
16
|
|
|
17
|
-
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
|
|
18
|
-
# to allow pushing to a single host or delete this section to allow pushing to any host.
|
|
19
|
-
if spec.respond_to?(:metadata)
|
|
20
|
-
spec.metadata['allowed_push_host'] = "https://rubygems.org/"
|
|
21
|
-
else
|
|
22
|
-
raise "RubyGems 2.0 or newer is required to protect against " \
|
|
23
|
-
"public gem pushes."
|
|
24
|
-
end
|
|
25
|
-
|
|
26
17
|
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
|
27
18
|
f.match(%r{^(test|spec|features)/})
|
|
28
19
|
end
|
|
@@ -30,10 +21,9 @@ Gem::Specification.new do |spec|
|
|
|
30
21
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
|
31
22
|
spec.require_paths = ["lib"]
|
|
32
23
|
|
|
33
|
-
spec.add_dependency
|
|
34
|
-
spec.add_dependency
|
|
35
|
-
spec.add_dependency
|
|
36
|
-
spec.add_dependency 'zip'
|
|
24
|
+
spec.add_dependency "thor"
|
|
25
|
+
spec.add_dependency "rubyzip"
|
|
26
|
+
spec.add_dependency "json"
|
|
37
27
|
|
|
38
28
|
spec.add_development_dependency "bundler", "~> 1.14"
|
|
39
29
|
spec.add_development_dependency "rake", "~> 10.0"
|
data/exe/dnnbundler
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
require "dnnbundler/zipFileGenerator"
|
|
2
|
+
require "thor"
|
|
3
|
+
require "json"
|
|
4
|
+
|
|
5
|
+
module Dnnbundler
|
|
6
|
+
class CLI < Thor
|
|
7
|
+
desc "build CONFIG", ""
|
|
8
|
+
option :bumpBuild
|
|
9
|
+
def build( config )
|
|
10
|
+
puts "Build with config #{config}"
|
|
11
|
+
file = File.read(config)
|
|
12
|
+
data_hash = JSON.parse(file)
|
|
13
|
+
|
|
14
|
+
input_entries = data_hash["entries"]
|
|
15
|
+
ignore_entries = data_hash["excludeEntries"]
|
|
16
|
+
zip_file_name = data_hash["outFileName"]
|
|
17
|
+
generator = ZipFileGenerator.new(input_entries, ignore_entries, zip_file_name)
|
|
18
|
+
generator.write
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
module Dnnbundler
|
|
2
|
+
class FileEntry
|
|
3
|
+
def initialize(file_name, entry_type = FileEntryType::FILE, flatten_structure = false)
|
|
4
|
+
@type = entry_type
|
|
5
|
+
@name = file_name
|
|
6
|
+
@flatten = flatten_structure
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
def add_buffer(buffer)
|
|
10
|
+
@buffer = buffer
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def type
|
|
14
|
+
@type
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def name
|
|
18
|
+
@name
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def flatten
|
|
22
|
+
@flatten
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def buffer
|
|
26
|
+
@buffer
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
data/lib/dnnbundler/version.rb
CHANGED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
require "dnnbundler/fileEntryType"
|
|
2
|
+
require "dnnbundler/fileEntry"
|
|
3
|
+
require "zip"
|
|
4
|
+
|
|
5
|
+
module Dnnbundler
|
|
6
|
+
class ZipFileGenerator
|
|
7
|
+
# Initialize with the directory to zip and the location of the output archive.
|
|
8
|
+
def initialize(entries, ignore_entries, output_file)
|
|
9
|
+
@entries = entries
|
|
10
|
+
@ignore_entries = ignore_entries
|
|
11
|
+
@output_file = output_file
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
# Zip the input directory.
|
|
15
|
+
def write
|
|
16
|
+
buffer = create_zip @entries
|
|
17
|
+
File.open("newzip.zip", "wb") {|f| f.write buffer.string }
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
private
|
|
21
|
+
|
|
22
|
+
def filter_entries(fileEntry)
|
|
23
|
+
@ignore_entries.each do |entry|
|
|
24
|
+
return false if fileEntry.name.include? entry
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def get_entries(directory_or_file)
|
|
29
|
+
if File.directory? directory_or_file
|
|
30
|
+
get_dir_entries_recursively directory_or_file
|
|
31
|
+
else
|
|
32
|
+
FileEntry.new directory_or_file
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def get_dir_entries_recursively(dir)
|
|
37
|
+
(Dir.entries(dir) - %w(. ..)).map { |v|
|
|
38
|
+
path = File.join(dir, v)
|
|
39
|
+
if File.directory? path
|
|
40
|
+
get_dir_entries_recursively(path)
|
|
41
|
+
else
|
|
42
|
+
FileEntry.new path
|
|
43
|
+
end
|
|
44
|
+
}
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
def compress(entries)
|
|
48
|
+
buffer = Zip::File.add_buffer do |zio|
|
|
49
|
+
entries.each do |file|
|
|
50
|
+
if file.type == FileEntryType::FILE
|
|
51
|
+
zio.add(file.name, file.name)
|
|
52
|
+
else
|
|
53
|
+
zio.get_output_stream(file.name) { |os| os.write file.buffer.string }
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
def create_zip(entries)
|
|
60
|
+
compress entries.map { |x|
|
|
61
|
+
if x.is_a? String
|
|
62
|
+
get_entries x
|
|
63
|
+
elsif x["type"].casecmp(FileEntryType::FILE) == 0
|
|
64
|
+
get_entries x["name"]
|
|
65
|
+
elsif x["type"].casecmp(FileEntryType::ZIP) == 0
|
|
66
|
+
zip_file_entry = FileEntry.new x["name"], FileEntryType::ZIP
|
|
67
|
+
zip_file_entry.add_buffer create_zip x["entries"]
|
|
68
|
+
result = zip_file_entry
|
|
69
|
+
end
|
|
70
|
+
}.flatten.select{ |f| filter_entries f }.uniq{ |f| f.name }
|
|
71
|
+
end
|
|
72
|
+
end
|
|
73
|
+
end
|
data/lib/dnnbundler.rb
CHANGED
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.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Le0Michine
|
|
@@ -25,7 +25,7 @@ dependencies:
|
|
|
25
25
|
- !ruby/object:Gem::Version
|
|
26
26
|
version: '0'
|
|
27
27
|
- !ruby/object:Gem::Dependency
|
|
28
|
-
name:
|
|
28
|
+
name: rubyzip
|
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
|
30
30
|
requirements:
|
|
31
31
|
- - ">="
|
|
@@ -52,20 +52,6 @@ dependencies:
|
|
|
52
52
|
- - ">="
|
|
53
53
|
- !ruby/object:Gem::Version
|
|
54
54
|
version: '0'
|
|
55
|
-
- !ruby/object:Gem::Dependency
|
|
56
|
-
name: zip
|
|
57
|
-
requirement: !ruby/object:Gem::Requirement
|
|
58
|
-
requirements:
|
|
59
|
-
- - ">="
|
|
60
|
-
- !ruby/object:Gem::Version
|
|
61
|
-
version: '0'
|
|
62
|
-
type: :runtime
|
|
63
|
-
prerelease: false
|
|
64
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
65
|
-
requirements:
|
|
66
|
-
- - ">="
|
|
67
|
-
- !ruby/object:Gem::Version
|
|
68
|
-
version: '0'
|
|
69
55
|
- !ruby/object:Gem::Dependency
|
|
70
56
|
name: bundler
|
|
71
57
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -94,10 +80,11 @@ dependencies:
|
|
|
94
80
|
- - "~>"
|
|
95
81
|
- !ruby/object:Gem::Version
|
|
96
82
|
version: '10.0'
|
|
97
|
-
description:
|
|
83
|
+
description: Write a longer description or delete this line.
|
|
98
84
|
email:
|
|
99
85
|
- leomichine@gmail.com
|
|
100
|
-
executables:
|
|
86
|
+
executables:
|
|
87
|
+
- dnnbundler
|
|
101
88
|
extensions: []
|
|
102
89
|
extra_rdoc_files: []
|
|
103
90
|
files:
|
|
@@ -110,13 +97,17 @@ files:
|
|
|
110
97
|
- bin/console
|
|
111
98
|
- bin/setup
|
|
112
99
|
- dnnbundler.gemspec
|
|
100
|
+
- exe/dnnbundler
|
|
113
101
|
- lib/dnnbundler.rb
|
|
102
|
+
- lib/dnnbundler/cli.rb
|
|
103
|
+
- lib/dnnbundler/fileEntry.rb
|
|
104
|
+
- lib/dnnbundler/fileEntryType.rb
|
|
114
105
|
- lib/dnnbundler/version.rb
|
|
115
|
-
|
|
106
|
+
- lib/dnnbundler/zipFileGenerator.rb
|
|
107
|
+
homepage: https://github.com
|
|
116
108
|
licenses:
|
|
117
109
|
- MIT
|
|
118
|
-
metadata:
|
|
119
|
-
allowed_push_host: https://rubygems.org/
|
|
110
|
+
metadata: {}
|
|
120
111
|
post_install_message:
|
|
121
112
|
rdoc_options: []
|
|
122
113
|
require_paths:
|
|
@@ -136,5 +127,5 @@ rubyforge_project:
|
|
|
136
127
|
rubygems_version: 2.6.11
|
|
137
128
|
signing_key:
|
|
138
129
|
specification_version: 4
|
|
139
|
-
summary:
|
|
130
|
+
summary: Write a short summary, because Rubygems requires one.
|
|
140
131
|
test_files: []
|