modulation 0.28 → 0.29
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -0
- data/README.md +1 -0
- data/lib/modulation/core.rb +12 -0
- data/lib/modulation/ext.rb +4 -0
- data/lib/modulation/packer.rb +11 -13
- data/lib/modulation/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 933737f36bc12f47d347cb770b7f8d4464cd993b26da4d8d309be64c53dc551a
|
4
|
+
data.tar.gz: 5f385daa43a1ce9312243804be00fc2ddb1a1e728d37d7807d806eae08197ab7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8c411047feeb3ca76646b62db47434ff135d8e6645cfaf3b11a5994a65630e2ac13be18a96999410078d05dc68c3a70b108206a7cc8e9afea695d50cbd62851e
|
7
|
+
data.tar.gz: 5aa45a4ba33c41b0f25c73c70e247952b9943783823f47920296d0583fbbc2a357ecb82beac948fe7656eae7829f9c9c1d7e635b3a8e61d327be759b59410e57
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -588,6 +588,7 @@ Modulation can also be used to package your entire application into a single
|
|
588
588
|
portable file that can be copied to another machine and run as is. To package
|
589
589
|
your app, use `mdl pack`. This command will perform a dynamic analysis of all
|
590
590
|
the app's dependencies and will put them together into a single Ruby file.
|
591
|
+
|
591
592
|
For more information have a look at the [app](examples/app) example.
|
592
593
|
|
593
594
|
## Writing gems using Modulation
|
data/lib/modulation/core.rb
CHANGED
@@ -70,6 +70,18 @@ module Modulation
|
|
70
70
|
end
|
71
71
|
end
|
72
72
|
|
73
|
+
def auto_import_map(path, caller_location = caller(1..1).first)
|
74
|
+
abs_path = Paths.absolute_dir_path(path, caller_location)
|
75
|
+
Hash.new do |h, k|
|
76
|
+
fn = Paths.check_path(File.join(abs_path, k.to_s))
|
77
|
+
return nil unless fn
|
78
|
+
|
79
|
+
mod = @loaded_modules[fn] || create_module_from_file(fn)
|
80
|
+
k = yield k, mod if block_given?
|
81
|
+
h[k] = mod
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
73
85
|
# Creates a new module from a source file
|
74
86
|
# @param path [String] source file name
|
75
87
|
# @return [Module] module
|
data/lib/modulation/ext.rb
CHANGED
@@ -26,6 +26,10 @@ module Kernel
|
|
26
26
|
def import_map(path, caller_location = caller(1..1).first, &block)
|
27
27
|
Modulation.import_map(path, caller_location, &block)
|
28
28
|
end
|
29
|
+
|
30
|
+
def auto_import_map(path, caller_location = caller(1..1).first, &block)
|
31
|
+
Modulation.auto_import_map(path, caller_location, &block)
|
32
|
+
end
|
29
33
|
end
|
30
34
|
|
31
35
|
# Module extensions
|
data/lib/modulation/packer.rb
CHANGED
@@ -7,16 +7,15 @@ require 'zlib'
|
|
7
7
|
module Modulation
|
8
8
|
# Implements packing functionality
|
9
9
|
module Packer
|
10
|
-
BOOTSTRAP_CODE = <<~SRC
|
10
|
+
BOOTSTRAP_CODE = <<~SRC
|
11
11
|
# encoding: ASCII-8BIT
|
12
12
|
require 'bundler/inline'
|
13
13
|
|
14
14
|
gemfile do
|
15
15
|
source 'https://rubygems.org'
|
16
|
-
gem 'modulation', '~> %<modulation_version>s'
|
16
|
+
gem 'modulation', '~> %<modulation_version>s', require: 'modulation/packer'
|
17
17
|
end
|
18
18
|
|
19
|
-
require 'modulation/packer'
|
20
19
|
Modulation::Bootstrap.setup(DATA, %<dictionary>s)
|
21
20
|
import(%<entry_point>s).send(:main)
|
22
21
|
__END__
|
@@ -43,7 +42,6 @@ module Modulation
|
|
43
42
|
files = deps.each_with_object({}) do |path, dict|
|
44
43
|
dict[path] = IO.read(path)
|
45
44
|
end
|
46
|
-
# files[INLINE_GEMFILE_PATH] = generate_gemfile
|
47
45
|
pack_files(files)
|
48
46
|
end
|
49
47
|
|
@@ -53,7 +51,7 @@ module Modulation
|
|
53
51
|
dictionary = files.each_with_object({}) do |(path, content), dict|
|
54
52
|
zipped = Zlib::Deflate.deflate(content)
|
55
53
|
size = zipped.bytesize
|
56
|
-
|
54
|
+
|
57
55
|
data << zipped
|
58
56
|
dict[path] = [last_offset, size]
|
59
57
|
last_offset += size
|
@@ -61,15 +59,15 @@ module Modulation
|
|
61
59
|
[dictionary, data]
|
62
60
|
end
|
63
61
|
|
64
|
-
# def self.generate_gemfile
|
65
|
-
# format(INLINE_GEMFILE_CODE)
|
66
|
-
# end
|
67
|
-
|
68
62
|
def self.generate_bootstrap(dictionary, data, entry_point)
|
69
|
-
format(
|
70
|
-
|
71
|
-
|
72
|
-
|
63
|
+
format(bootstrap_template, modulation_version: Modulation::VERSION,
|
64
|
+
dictionary: dictionary.inspect,
|
65
|
+
entry_point: entry_point.inspect,
|
66
|
+
data: data)
|
67
|
+
end
|
68
|
+
|
69
|
+
def self.bootstrap_template
|
70
|
+
BOOTSTRAP_CODE.encode('ASCII-8BIT').gsub(/^\s+/, '').chomp
|
73
71
|
end
|
74
72
|
end
|
75
73
|
|
data/lib/modulation/version.rb
CHANGED