hyperloop-config 0.9.7 → 0.9.8

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
  SHA1:
3
- metadata.gz: 2c41197bc6c05a542ac1a8391163396b9a984685
4
- data.tar.gz: ea192d13f4b1cf7d12cf4c649d2d33c5d2eda624
3
+ metadata.gz: 2872a3f9d6a90ec66a9369ce75e5360b96395caf
4
+ data.tar.gz: 1b383039726c4f07ffcad90fcb5675af5b4cfa34
5
5
  SHA512:
6
- metadata.gz: 216ce489e927e8a361526e1f62cca7fb974ae71901a98fd0f39154a5ef9862dae74fd0c5c400a40dd5d02a16baafb3aad701c3126a9e9a62868f769977014117
7
- data.tar.gz: 4033e9734d79d0741ee381c4a08dd7a575603c4a4c0810003607ca9f3ef2f5316db5f26154300b912021212f2960b3f28c0d52976a28f86c1d9f979f8e95f854
6
+ metadata.gz: 769dc1d55d1713c217d7b23d52bcfe195914594af58364fdf4bded13ff8a6fc1883c6e0f864266cd799c6a11335a126afd045e663c84279bbeae0a2e65bce2dd
7
+ data.tar.gz: 905757403f027995677d6d42f3deb1f741fd672ca4ef61d3037999974ab2ffa6dd19e44dd1178af1add9dd64164e220ed835b43bf2831cd0e3d791b4e571b725
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
 
5
5
  Gem::Specification.new do |spec|
6
6
  spec.name = "hyperloop-config"
7
- spec.version = "0.9.7"
7
+ spec.version = "0.9.8"
8
8
  spec.authors = ["catmando"]
9
9
  spec.email = ["mitch@catprint.com"]
10
10
 
@@ -0,0 +1 @@
1
+ <%= Hyperloop.generate_requires(:client, false, __FILE__) %>
@@ -0,0 +1 @@
1
+ <%= Hyperloop.generate_requires(:client, true, __FILE__) %>
@@ -0,0 +1 @@
1
+ <%= Hyperloop.compile_and_compress('hyperloop-loader-system-code') %>
@@ -1,2 +1,4 @@
1
- //= require hyperloop-loader2
2
- Opal.load('hyperloop-loader2')
1
+ //= require hyperloop-loader-system
2
+ //= require hyperloop-loader-application
3
+ Opal.load('hyperloop-loader-system-code')
4
+ Opal.load('hyperloop-loader-application')
@@ -0,0 +1 @@
1
+ <%= Hyperloop.generate_requires(:server, false, __FILE__) %>
@@ -0,0 +1 @@
1
+ <%= Hyperloop.generate_requires(:server, true, __FILE__) %>
@@ -0,0 +1 @@
1
+ <%= Hyperloop.compile_and_compress('hyperloop-prerender-loader-system-code', never_compress: true) %>
@@ -0,0 +1,4 @@
1
+ //= require hyperloop-prerender-loader-system
2
+ //= require hyperloop-prerender-loader-application
3
+ Opal.load('hyperloop-prerender-loader-system-code')
4
+ Opal.load('hyperloop-prerender-loader-application')
@@ -1,4 +1,5 @@
1
1
  module Hyperloop
2
+
2
3
  class << self
3
4
  def import_list
4
5
  @import_list ||= []
@@ -36,17 +37,18 @@ module Hyperloop
36
37
  import(nil, instead_of: value)
37
38
  end
38
39
 
39
- def generate_requires(mode, file)
40
+ def generate_requires(mode, sys, file)
40
41
  puts "***** generating requires for #{mode} - #{file}"
41
42
  import_list.collect do |value, render_on_server, render_on_client, kind|
42
43
  next unless value
44
+ next if (sys && kind == :tree) || (!sys && kind != :tree)
43
45
  next if mode == :client && !render_on_client
44
46
  next if mode == :server && !render_on_server
45
47
  if kind == :tree
46
48
  generate_require_tree(value, render_on_server, render_on_client)
47
49
  elsif kind == :gem
48
50
  r = "require '#{value}' #{client_guard(render_on_server, render_on_client)}"
49
- puts r
51
+ puts " #{r}"
50
52
  "puts \"#{r}\"; #{r}"
51
53
  else
52
54
  generate_directive(:require, value, file, render_on_server, render_on_client)
@@ -62,7 +64,7 @@ module Hyperloop
62
64
  comp_path.shift
63
65
  end
64
66
  r = "#{directive} '#{(['.'] + ['..'] * gem_path.length + comp_path).join('/')}' #{client_guard(render_on_server, render_on_client)}"
65
- puts r
67
+ puts " #{r}"
66
68
  "puts \"#{r}\"; #{r}"
67
69
  end
68
70
 
@@ -74,7 +76,7 @@ module Hyperloop
74
76
  if fname =~ /(\.js$)|(\.rb$)/
75
77
  fname = fname.gsub(/(\.js$)|(\.rb$)/, '')
76
78
  r = "require '#{fname}' #{client_guard(render_on_server, render_on_client)}"
77
- puts r
79
+ puts " #{r}"
78
80
  "puts \"#{r}\"; #{r}"
79
81
  end
80
82
  end.compact.join("\n")
@@ -88,5 +90,31 @@ module Hyperloop
88
90
  end
89
91
  end
90
92
 
93
+ Hyperloop.define_setting :compress_system_assets, true
94
+
95
+ def compile_and_compress(name, never_compress: false)
96
+ start_time = Time.now
97
+
98
+ Rails.logger.info "\n\n##########################################################################\n"
99
+ Rails.logger.info " HYPERLOOP LIBRARIES PRECOMPILING AND MINIFYING\n"
100
+ Rails.logger.info " FIRST TIME BOOTING YOUR APP IT CAN TAKE 1 OR 2 MINUTES\n"
101
+ Rails.logger.info " NB: You can force precompiling again by cleaning cache: rm -rf tmp/cache \n"
102
+ Rails.logger.info "##########################################################################\n\n"
103
+
104
+ Rails.logger.info "Compiling the system assets for #{name}"
105
+
106
+ compiled_code = Rails.application.assets[name].to_s
107
+ compilation_time = Time.now
108
+ compiled_code_length = compiled_code.length
109
+ Rails.logger.info " compiled - length: #{compiled_code_length}"
110
+ if Hyperloop.compress_system_assets && !never_compress
111
+ compiled_code = Uglifier.new.compile(compiled_code)
112
+ Rails.logger.info " minimized - length: #{compiled_code.length}"
113
+ Rails.logger.info " minification ratio #{(compiled_code.length*100.0/compiled_code_length).round}%"
114
+ end
115
+ Rails.logger.info " total time: #{(Time.now-start_time).to_f.round(2)} seconds"
116
+ compiled_code
117
+ end
118
+
91
119
  end
92
120
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hyperloop-config
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.7
4
+ version: 0.9.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - catmando
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-03-28 00:00:00.000000000 Z
11
+ date: 2017-04-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: opal
@@ -193,9 +193,14 @@ files:
193
193
  - Rakefile
194
194
  - hyperloop-config.gemspec
195
195
  - lib/hyperloop-config.rb
196
+ - lib/hyperloop-loader-application.rb.erb
197
+ - lib/hyperloop-loader-system-code.rb.erb
198
+ - lib/hyperloop-loader-system.js.erb
196
199
  - lib/hyperloop-loader.js
197
- - lib/hyperloop-loader2.rb.erb
198
- - lib/hyperloop-prerender-loader.rb.erb
200
+ - lib/hyperloop-prerender-loader-application.rb.erb
201
+ - lib/hyperloop-prerender-loader-system-code.rb.erb
202
+ - lib/hyperloop-prerender-loader-system.js.erb
203
+ - lib/hyperloop-prerender-loader.js
199
204
  - lib/hyperloop/client_readers.rb
200
205
  - lib/hyperloop/client_stubs.rb
201
206
  - lib/hyperloop/config_settings.rb
@@ -1 +0,0 @@
1
- <%= Hyperloop.generate_requires(:client, __FILE__) %>
@@ -1 +0,0 @@
1
- <%= Hyperloop.generate_requires(:server, __FILE__) %>