closure 1.5.1 → 1.5.2

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: 7580eda4e1d93310622f704e9e7d57d8ed3ed89e
4
- data.tar.gz: b33c5bff5983957a745d57e5b5ed1379ee023224
3
+ metadata.gz: 4e951e3b96773444590a3d5f1060a9be62afd76f
4
+ data.tar.gz: 3a0cc745ebee4f9ccceb9e30b3c6dd79a446c6cf
5
5
  SHA512:
6
- metadata.gz: f1c65576762fc781deb2ec632ee8c4ab8187b78797081c5b7dd062b8f5be66b5dd05d2752d8fb78a131036a6074593d8194115c9a514b08ef6dce16ad7ac528d
7
- data.tar.gz: d13e4acf1706dce4e773dfffb94efa389480ef2907b6479be99951c86b0a9f5e74dc66eae8b95bda955cca89c97521fb1728379e5132bd4b7d5605d31ee94d8a
6
+ metadata.gz: 3f9a76cd5b00a9ba2ca0055aec82fd1b716255e60c9045b657f5aeb42aa05355e726f7fa8f70e454a5d20eb3ec5d0dd2607bea20f98a7f845d4d3d7aefa02fa5
7
+ data.tar.gz: 1e50ef92d268f2ec43dfcb8ddcf64e5769dddccfe05ea3d37ce67ee49834e9c49b77d2d04b628fb8bcdac91b94d2a7888fe69c7b0d74517896f61204243ea504
@@ -175,6 +175,13 @@ class Closure
175
175
  end
176
176
 
177
177
 
178
+ # The javascript snippet for module info
179
+ # @param [Array<Hash>] mods
180
+ def self.module_path(path, var = 'MODULE_PATH')
181
+ js = "var #{var} = #{path.dump};\n"
182
+ end
183
+
184
+
178
185
  # The javascript snippet for module info
179
186
  # @param [Array<Hash>] mods
180
187
  def self.module_info(mods, var = 'MODULE_INFO')
data/lib/closure/goog.rb CHANGED
@@ -24,6 +24,19 @@ class Closure
24
24
  @env = env
25
25
  @render_stack = render_stack
26
26
  @dependencies = []
27
+ @path = ''
28
+ end
29
+
30
+ # Specify an explicit host or path for loading scripts.
31
+ # e.g. '//example.com' or '/proxy/path'
32
+ # You may also include a protocol and path if necessary. e.g.
33
+ # 'http://example.com:8080/proxy/path'
34
+ # attr_reader :path
35
+ def path= p
36
+ @path = p if p.start_with?('/')
37
+ @path = p if p.start_with?('http://')
38
+ @path = p if p.start_with?('https://')
39
+ raise 'goog.path not valid' unless @path == p
27
40
  end
28
41
 
29
42
  # You can add additional files to have their mtimes scanned.
@@ -81,6 +94,7 @@ class Closure
81
94
  # Raw mode
82
95
  comp = Compiler::Compilation.new @env
83
96
  if mods
97
+ comp << Compiler::Util.module_path(@path)
84
98
  comp << Compiler::Util.module_info(mods)
85
99
  comp << Compiler::Util.module_uris_raw(mods, @sources)
86
100
  end
@@ -89,8 +103,8 @@ class Closure
89
103
  while args_index < args.length
90
104
  option, value = args[args_index, 2]
91
105
  if option == '--js'
92
- value = File.expand_path value, root
93
- script_tag = "<script src=#{src_for(value).dump}></script>"
106
+ value = File.expand_path(value, root)
107
+ script_tag = "<script src=#{(@path+src_for(value)).dump}></script>"
94
108
  comp << "document.write(#{script_tag.dump});\n"
95
109
  js_counter += 1
96
110
  # For modules, just the files for the first module
@@ -111,10 +125,12 @@ class Closure
111
125
  prefix = File.expand_path module_output_path_prefix, root
112
126
  if comp.js_output_file
113
127
  File.open comp.js_output_file, 'w' do |f|
128
+ f.write Compiler::Util.module_path @path
114
129
  f.write Compiler::Util.module_info mods
115
130
  f.write Compiler::Util.module_uris_compiled mods, @sources, prefix
116
131
  end
117
132
  else
133
+ comp << Compiler::Util.module_path(@path)
118
134
  comp << Compiler::Util.module_info(mods)
119
135
  comp << Compiler::Util.module_uris_compiled(mods, @sources, prefix)
120
136
  end
@@ -122,7 +138,7 @@ class Closure
122
138
  first_module_file = module_output_path_prefix + mods[0][:name] + '.js'
123
139
  first_module_file = File.expand_path first_module_file, root
124
140
  comp << '(function(){var e=document.createElement("script");e.type="text/javascript";e.src='
125
- comp << src_for(first_module_file).dump
141
+ comp << (@path + src_for(first_module_file)).dump
126
142
  comp << ";document.head.appendChild(e);})();\n"
127
143
  end
128
144
  end
@@ -14,5 +14,5 @@
14
14
 
15
15
 
16
16
  class Closure
17
- VERSION = "1.5.1"
17
+ VERSION = "1.5.2"
18
18
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: closure
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.1
4
+ version: 1.5.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Turnbull
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-05-13 00:00:00.000000000 Z
11
+ date: 2016-06-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rack