modulation 0.28 → 0.29

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 630df5ec1eef61abafa86781e8f73c892dcf01c738bc02b695e767586208c728
4
- data.tar.gz: 4f98dbd921afc4c3e0f33d82d19083e56cfacffee7192bf0ad621e638b5cf6a0
3
+ metadata.gz: 933737f36bc12f47d347cb770b7f8d4464cd993b26da4d8d309be64c53dc551a
4
+ data.tar.gz: 5f385daa43a1ce9312243804be00fc2ddb1a1e728d37d7807d806eae08197ab7
5
5
  SHA512:
6
- metadata.gz: 726ac2711660e422fac0caeeb41828d4fafea79c3ef6da7abb24ea0160990248b2c1830b4c69f278b2f798a0038bd9c2b361dc8152bd33f726bda4f67eb71fca
7
- data.tar.gz: 4ccfd538a57c5a8183409e42e04d9a5df14f22068d2900b269841690fbec878473c1b52ed84e8e2ec1b87736a4f915463d829670731f80e732fe1dee8068cc26
6
+ metadata.gz: 8c411047feeb3ca76646b62db47434ff135d8e6645cfaf3b11a5994a65630e2ac13be18a96999410078d05dc68c3a70b108206a7cc8e9afea695d50cbd62851e
7
+ data.tar.gz: 5aa45a4ba33c41b0f25c73c70e247952b9943783823f47920296d0583fbbc2a357ecb82beac948fe7656eae7829f9c9c1d7e635b3a8e61d327be759b59410e57
data/CHANGELOG.md CHANGED
@@ -1,3 +1,9 @@
1
+ 0.29 2019-08-23
2
+ ---------------
3
+
4
+ * Implement auto_import_map
5
+ * Add preliminary inline Gemfile to packaged apps
6
+
1
7
  0.28 2019-08-23
2
8
  ---------------
3
9
 
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
@@ -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
@@ -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
@@ -7,16 +7,15 @@ require 'zlib'
7
7
  module Modulation
8
8
  # Implements packing functionality
9
9
  module Packer
10
- BOOTSTRAP_CODE = <<~SRC.encode('ASCII-8BIT').chomp
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(BOOTSTRAP_CODE, modulation_version: Modulation::VERSION,
70
- dictionary: dictionary.inspect,
71
- entry_point: entry_point.inspect,
72
- data: data)
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
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Modulation
4
- VERSION = '0.28'
4
+ VERSION = '0.29'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: modulation
3
3
  version: !ruby/object:Gem::Version
4
- version: '0.28'
4
+ version: '0.29'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sharon Rosner