hyperloop-config 0.8.1 → 0.9.0
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/hyperloop-config-0.8.1.gem +0 -0
- data/hyperloop-config.gemspec +3 -1
- data/lib/components.rb.erb +1 -0
- data/lib/hyperloop-config.rb +19 -48
- data/lib/hyperloop-loader.js +2 -0
- data/lib/hyperloop-loader2.rb.erb +1 -0
- data/lib/hyperloop/client_readers.rb +19 -0
- data/lib/hyperloop/client_stubs.rb +12 -0
- data/lib/hyperloop/config_settings.rb +49 -0
- data/lib/hyperloop/on_client.rb +5 -0
- data/lib/hyperloop/rail_tie.rb +59 -0
- data/lib/hyperloop/requires.rb +76 -0
- metadata +26 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fbfe28115b632c56ba9de41cc1ddf85b03fca677
|
4
|
+
data.tar.gz: ba129aab203299356c2a014f5c46f24195d58918
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5ea1e85025c0ca6989ebe22b6d13867b66bd5e2db99febde06c7b438a5adcac6f69d618e1eb0324376318a3f2c413a167c32e2b0ca50db370ef530c54f600037
|
7
|
+
data.tar.gz: 5e94e29e21f7e202d0a301924b6401578fcfb05025d5b449a2e3b54faf82a20d03c96457fb0ae6502be8a018b9326ad37cc5187f7fc948ea4c038ef764891ef6
|
Binary file
|
data/hyperloop-config.gemspec
CHANGED
@@ -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.
|
7
|
+
spec.version = "0.9.0"
|
8
8
|
spec.authors = ["catmando"]
|
9
9
|
spec.email = ["mitch@catprint.com"]
|
10
10
|
|
@@ -17,6 +17,8 @@ Gem::Specification.new do |spec|
|
|
17
17
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
18
18
|
spec.require_paths = ["lib"]
|
19
19
|
|
20
|
+
spec.add_dependency 'opal'
|
21
|
+
|
20
22
|
spec.add_development_dependency "bundler", "~> 1.12"
|
21
23
|
spec.add_development_dependency "rake", "~> 10.0"
|
22
24
|
end
|
@@ -0,0 +1 @@
|
|
1
|
+
<%= Hyperloop.generate_requires(:prerendering, __FILE__) %>
|
data/lib/hyperloop-config.rb
CHANGED
@@ -1,49 +1,20 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
class_variable_set("@@#{name}", default)
|
21
|
-
|
22
|
-
define_class_method "#{name}=" do |value|
|
23
|
-
class_variable_set("@@#{name}", value)
|
24
|
-
block.call value if block
|
25
|
-
value
|
26
|
-
end
|
27
|
-
|
28
|
-
define_class_method name do
|
29
|
-
class_variable_get("@@#{name}")
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
def on_config_reset &block
|
34
|
-
reset_blocks << block
|
35
|
-
end
|
36
|
-
|
37
|
-
def on_config_initialized &block
|
38
|
-
initialized_blocks << block
|
39
|
-
end
|
40
|
-
|
41
|
-
private
|
42
|
-
|
43
|
-
def define_class_method(name, &block)
|
44
|
-
(class << self; self; end).instance_eval do
|
45
|
-
define_method name, &block
|
46
|
-
end
|
47
|
-
end
|
48
|
-
end
|
1
|
+
if RUBY_ENGINE == 'opal'
|
2
|
+
require 'hyperloop/client_stubs'
|
3
|
+
require 'hyperloop/on_client'
|
4
|
+
else
|
5
|
+
require 'opal'
|
6
|
+
require 'hyperloop/config_settings'
|
7
|
+
require 'hyperloop/requires'
|
8
|
+
require 'hyperloop/client_readers'
|
9
|
+
require 'hyperloop/on_client'
|
10
|
+
require 'hyperloop/rail_tie' if defined? Rails
|
11
|
+
Hyperloop.require 'opal', gem: true
|
12
|
+
Hyperloop.require 'hyperloop-config', gem: true
|
13
|
+
# class Sprockets::DirectiveProcessor
|
14
|
+
# def process_depend_on_config_directive(file)
|
15
|
+
# path = File.expand_path(file, "#{Rails.root}/config")
|
16
|
+
# resolve(path)
|
17
|
+
# end
|
18
|
+
# end
|
19
|
+
Opal.append_path(File.expand_path('../', __FILE__).untaint)
|
49
20
|
end
|
@@ -0,0 +1 @@
|
|
1
|
+
<%= Hyperloop.generate_requires(:client, __FILE__) %>
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module Hyperloop
|
2
|
+
# configuration utility
|
3
|
+
class << self
|
4
|
+
def client_readers
|
5
|
+
@client_readers ||= []
|
6
|
+
end
|
7
|
+
|
8
|
+
def client_reader_hash
|
9
|
+
@client_readers_hash ||= {}
|
10
|
+
end
|
11
|
+
|
12
|
+
def client_reader(*args)
|
13
|
+
# configuration.client_reader[:foo] = 12 initialize your own client value
|
14
|
+
# configuration.client_reader :foo, :bar make previous setting readable on client
|
15
|
+
client_readers += [*args]
|
16
|
+
client_reader_hash
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
module Hyperloop
|
2
|
+
class << self
|
3
|
+
def require(value, gem: nil, override_with: nil, client_only: nil, tree: nil)
|
4
|
+
end
|
5
|
+
|
6
|
+
def require_tree(value, override_with: nil, client_only: nil)
|
7
|
+
end
|
8
|
+
|
9
|
+
def require_gem(value, override_with: nil, client_only: nil)
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
module Hyperloop
|
2
|
+
# configuration utility
|
3
|
+
class << self
|
4
|
+
def initialized_blocks
|
5
|
+
@initialized_blocks ||= []
|
6
|
+
end
|
7
|
+
|
8
|
+
def reset_blocks
|
9
|
+
@reset_blocks ||= []
|
10
|
+
end
|
11
|
+
|
12
|
+
def configuration
|
13
|
+
reset_blocks.each(&:call)
|
14
|
+
yield self
|
15
|
+
initialized_blocks.each(&:call)
|
16
|
+
end
|
17
|
+
|
18
|
+
def define_setting(name, default = nil, &block)
|
19
|
+
class_variable_set("@@#{name}", default)
|
20
|
+
|
21
|
+
define_class_method "#{name}=" do |value|
|
22
|
+
class_variable_set("@@#{name}", value)
|
23
|
+
block.call value if block
|
24
|
+
value
|
25
|
+
end
|
26
|
+
|
27
|
+
define_class_method name do
|
28
|
+
class_variable_get("@@#{name}")
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
|
33
|
+
def on_config_reset &block
|
34
|
+
reset_blocks << block
|
35
|
+
end
|
36
|
+
|
37
|
+
def on_config_initialized &block
|
38
|
+
initialized_blocks << block
|
39
|
+
end
|
40
|
+
|
41
|
+
private
|
42
|
+
|
43
|
+
def define_class_method(name, &block)
|
44
|
+
(class << self; self; end).instance_eval do
|
45
|
+
define_method name, &block
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
module Hyperloop
|
2
|
+
define_setting :add_hyperloop_paths, true
|
3
|
+
class Railtie < ::Rails::Railtie
|
4
|
+
|
5
|
+
class Options < ActiveSupport::OrderedOptions
|
6
|
+
def delete_first(a, e)
|
7
|
+
a.delete_at(a.index(e) || a.length)
|
8
|
+
end
|
9
|
+
def add_paths=(x)
|
10
|
+
Rails.configuration.tap do |config|
|
11
|
+
if x
|
12
|
+
config.eager_load_paths += %W(#{config.root}/app/hyperloop/models)
|
13
|
+
config.autoload_paths += %W(#{config.root}/app/hyperloop/models)
|
14
|
+
# config.eager_load_paths += %W(#{config.root}/app/hyperloop/stores)
|
15
|
+
# config.autoload_paths += %W(#{config.root}/app/hyperloop/stores)
|
16
|
+
config.eager_load_paths += %W(#{config.root}/app/hyperloop/operations)
|
17
|
+
config.autoload_paths += %W(#{config.root}/app/hyperloop/operations)
|
18
|
+
|
19
|
+
config.assets.paths.unshift ::Rails.root.join('app', 'hyperloop').to_s
|
20
|
+
config.eager_load_paths += %W(#{config.root}/app/models/public)
|
21
|
+
config.autoload_paths += %W(#{config.root}/app/models/public)
|
22
|
+
config.assets.paths.unshift ::Rails.root.join('app', 'models').to_s
|
23
|
+
else
|
24
|
+
delete_first config.eager_load_paths, "#{config.root}/app/hyperloop/models"
|
25
|
+
delete_first config.autoload_paths, "#{config.root}/app/hyperloop/models"
|
26
|
+
# delete_first config.eager_load_paths, "#{config.root}/app/hyperloop/stores"
|
27
|
+
# delete_first config.autoload_paths, "#{config.root}/app/hyperloop/stores"
|
28
|
+
delete_first config.eager_load_paths, "#{config.root}/app/hyperloop/operations"
|
29
|
+
delete_first config.autoload_paths, "#{config.root}/app/hyperloop/operations"
|
30
|
+
|
31
|
+
delete_first config.assets.paths, ::Rails.root.join('app', 'hyperloop').to_s
|
32
|
+
delete_first config.eager_load_paths, %W(#{config.root}/app/models/public)
|
33
|
+
delete_first config.autoload_paths, %W(#{config.root}/app/models/public)
|
34
|
+
delete_first config.assets.paths, ::Rails.root.join('app', 'models').to_s
|
35
|
+
end
|
36
|
+
end
|
37
|
+
super
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
def add_hyperloop_directories(config)
|
42
|
+
return if config.hyperloop.key?(:add_directories) && !config.hyperloop.add_directories
|
43
|
+
Hyperloop.require_tree('views/components')
|
44
|
+
Hyperloop.require_tree('hyperloop')
|
45
|
+
Hyperloop.require_gem 'opal-jquery', override_with: :opal_jquery, client_only: true # move to hyper-component once things are working
|
46
|
+
end
|
47
|
+
|
48
|
+
# note in case of problems with eager load paths have a look at
|
49
|
+
# https://github.com/opal/opal-rails/blob/master/lib/opal/rails/engine.rb
|
50
|
+
config.hyperloop = Options.new
|
51
|
+
|
52
|
+
config.before_configuration do |app|
|
53
|
+
config.hyperloop.add_paths = true
|
54
|
+
end
|
55
|
+
config.after_initialize do |app|
|
56
|
+
add_hyperloop_directories(app.config)
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
@@ -0,0 +1,76 @@
|
|
1
|
+
module Hyperloop
|
2
|
+
class << self
|
3
|
+
def requires
|
4
|
+
@requires ||= []
|
5
|
+
end
|
6
|
+
|
7
|
+
def require(value, gem: nil, override_with: nil, client_only: nil, tree: nil)
|
8
|
+
if override_with
|
9
|
+
define_class_method "#{override_with}=" do |value|
|
10
|
+
requires.detect do |name, _value, _client_only, _kind|
|
11
|
+
name == override_with
|
12
|
+
end[1] = value
|
13
|
+
end
|
14
|
+
end
|
15
|
+
kind = if gem
|
16
|
+
:gem
|
17
|
+
elsif tree
|
18
|
+
:tree
|
19
|
+
end
|
20
|
+
requires << [override_with, value, client_only, kind]
|
21
|
+
end
|
22
|
+
|
23
|
+
def require_tree(value, override_with: nil, client_only: nil)
|
24
|
+
require(value, override_with: override_with, client_only: client_only, tree: true)
|
25
|
+
end
|
26
|
+
|
27
|
+
def require_gem(value, override_with: nil, client_only: nil)
|
28
|
+
require(value, override_with: override_with, client_only: client_only, gem: true)
|
29
|
+
end
|
30
|
+
|
31
|
+
def generate_requires(mode, file)
|
32
|
+
puts "***** generating requires for #{mode} - #{file}"
|
33
|
+
requires.collect do |name, value, client_only, kind|
|
34
|
+
next unless value
|
35
|
+
next if client_only && mode != :client
|
36
|
+
if kind == :tree
|
37
|
+
generate_require_tree(value, client_only)
|
38
|
+
elsif kind == :gem
|
39
|
+
r = "require '#{value}' #{client_guard(client_only)}"
|
40
|
+
puts r
|
41
|
+
"puts \"#{r}\"; #{r}"
|
42
|
+
else
|
43
|
+
generate_directive(:require, value, file, client_only)
|
44
|
+
end
|
45
|
+
end.compact.join("\n")
|
46
|
+
end
|
47
|
+
|
48
|
+
def generate_directive(directive, to, file, client_only = false)
|
49
|
+
gem_path = File.expand_path('../', file).split('/')
|
50
|
+
comp_path = Rails.root.join('app', 'hyperloop', to).to_s.split('/')
|
51
|
+
while comp_path.first == gem_path.first do
|
52
|
+
gem_path.shift
|
53
|
+
comp_path.shift
|
54
|
+
end
|
55
|
+
r = "#{directive} '#{(['.'] + ['..'] * gem_path.length + comp_path).join('/')}' #{client_guard(client_only)}"
|
56
|
+
puts r
|
57
|
+
"puts \"#{r}\"; #{r}"
|
58
|
+
end
|
59
|
+
|
60
|
+
def generate_require_tree(path, client_only)
|
61
|
+
base_name = Rails.root.join('app', path).to_s+'/'
|
62
|
+
Dir.glob(Rails.root.join('app', path, '**', '*')).collect do |fname|
|
63
|
+
if ['.js', '.rb', '.erb'].include? File.extname(fname)
|
64
|
+
r = "require '#{fname.gsub(base_name, '')}' #{client_guard(client_only)}"
|
65
|
+
puts r
|
66
|
+
"puts \"#{r}\"; #{r}"
|
67
|
+
end
|
68
|
+
end.compact.join("\n")
|
69
|
+
end
|
70
|
+
|
71
|
+
def client_guard(client_only)
|
72
|
+
"# CLIENT ONLY" if client_only
|
73
|
+
end
|
74
|
+
|
75
|
+
end
|
76
|
+
end
|
metadata
CHANGED
@@ -1,15 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hyperloop-config
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.9.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- catmando
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-03-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: opal
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
13
27
|
- !ruby/object:Gem::Dependency
|
14
28
|
name: bundler
|
15
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -51,8 +65,18 @@ files:
|
|
51
65
|
- LICENSE.txt
|
52
66
|
- README.md
|
53
67
|
- Rakefile
|
68
|
+
- hyperloop-config-0.8.1.gem
|
54
69
|
- hyperloop-config.gemspec
|
70
|
+
- lib/components.rb.erb
|
55
71
|
- lib/hyperloop-config.rb
|
72
|
+
- lib/hyperloop-loader.js
|
73
|
+
- lib/hyperloop-loader2.rb.erb
|
74
|
+
- lib/hyperloop/client_readers.rb
|
75
|
+
- lib/hyperloop/client_stubs.rb
|
76
|
+
- lib/hyperloop/config_settings.rb
|
77
|
+
- lib/hyperloop/on_client.rb
|
78
|
+
- lib/hyperloop/rail_tie.rb
|
79
|
+
- lib/hyperloop/requires.rb
|
56
80
|
homepage: http://ruby-hyperloop.io
|
57
81
|
licenses:
|
58
82
|
- MIT
|