rjs-rails 0.0.3 → 0.0.4
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/lib/rjs-rails/runtime/config.rb +1 -1
- data/lib/rjs-rails/version.rb +1 -1
- metadata +1 -5
- data/lib/rjs-rails/moved/build_env.rb +0 -72
- data/lib/rjs-rails/moved/env.rb +0 -46
- data/lib/rjs-rails/moved/railtie.rb +0 -17
- data/lib/rjs-rails/moved/runtime_env.rb +0 -89
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e8889a84c10cc22b3956c46984258f99bbb69333
|
4
|
+
data.tar.gz: 625eabe05d9ef05ce6ef80ec5f220fb3c91e109f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d2bcd107977ec772a5eb9cf0008752bd0844819986788404b5347438d3bcb91eb53f94af030be213f089efe6ba9863a293b38d992d75aab6cd2e8894796a58aa
|
7
|
+
data.tar.gz: 2089ed229f8cf5bdfcb0d23393ad2f212761eacfa359e55d8772c888fb8a79a08326111fe9cd0d0a88439111865f5d6886961b8b5ffac82c77724c2a203fd27e
|
data/lib/rjs-rails/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rjs-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- neeraj
|
@@ -52,10 +52,6 @@ files:
|
|
52
52
|
- lib/rjs-rails/build/api.rb
|
53
53
|
- lib/rjs-rails/build/config.rb
|
54
54
|
- lib/rjs-rails/env.rb
|
55
|
-
- lib/rjs-rails/moved/build_env.rb
|
56
|
-
- lib/rjs-rails/moved/env.rb
|
57
|
-
- lib/rjs-rails/moved/railtie.rb
|
58
|
-
- lib/rjs-rails/moved/runtime_env.rb
|
59
55
|
- lib/rjs-rails/railtie.rb
|
60
56
|
- lib/rjs-rails/rjs_helpers.rb
|
61
57
|
- lib/rjs-rails/runtime/api.rb
|
@@ -1,72 +0,0 @@
|
|
1
|
-
module RjsRails
|
2
|
-
class BuildEnv
|
3
|
-
|
4
|
-
attr_accessor :env
|
5
|
-
|
6
|
-
def initialize(env)
|
7
|
-
@env = env
|
8
|
-
config
|
9
|
-
end
|
10
|
-
|
11
|
-
def base_config
|
12
|
-
return @base_config if @base_config
|
13
|
-
base_config = {
|
14
|
-
"baseUrl" => env.source_dir,
|
15
|
-
"dir" => env.build_dir,
|
16
|
-
"optimize" => "none",
|
17
|
-
"skipDirOptimize" => true,
|
18
|
-
"keepBuildDir" => false,
|
19
|
-
"normalizeDirDefines" => "skip"
|
20
|
-
}
|
21
|
-
end
|
22
|
-
|
23
|
-
def user_config
|
24
|
-
@user_config ||= load_yml_config
|
25
|
-
end
|
26
|
-
|
27
|
-
def config
|
28
|
-
@config ||= base_config.merge(user_config)
|
29
|
-
end
|
30
|
-
|
31
|
-
def modules
|
32
|
-
config["modules"] || []
|
33
|
-
end
|
34
|
-
|
35
|
-
def module_names
|
36
|
-
modules.collect { |m| m["name"] }
|
37
|
-
end
|
38
|
-
|
39
|
-
def yml_exists?
|
40
|
-
File.exists? yml
|
41
|
-
end
|
42
|
-
|
43
|
-
def shims
|
44
|
-
config["shim"] || {}
|
45
|
-
end
|
46
|
-
|
47
|
-
def paths
|
48
|
-
config["paths"] || {}
|
49
|
-
end
|
50
|
-
|
51
|
-
def assets_for_precompile
|
52
|
-
js = []
|
53
|
-
js << 'require.js'
|
54
|
-
modules.each { |m| js << "#{m["name"]}.js" }
|
55
|
-
js
|
56
|
-
end
|
57
|
-
|
58
|
-
private
|
59
|
-
|
60
|
-
def yml
|
61
|
-
env.rjs_build_yml
|
62
|
-
end
|
63
|
-
|
64
|
-
def load_yml_config
|
65
|
-
return {} if not File.exists? yml
|
66
|
-
File.open(yml) { |f|
|
67
|
-
YAML.load(f.read)
|
68
|
-
}
|
69
|
-
end
|
70
|
-
|
71
|
-
end
|
72
|
-
end
|
data/lib/rjs-rails/moved/env.rb
DELETED
@@ -1,46 +0,0 @@
|
|
1
|
-
module RjsRails
|
2
|
-
class Env
|
3
|
-
|
4
|
-
def config
|
5
|
-
return @conf if @conf
|
6
|
-
c = ::ActiveSupport::OrderedOptions.new
|
7
|
-
c.extensions = [/.js$/]
|
8
|
-
c.source_dir = "#{Rails.root}/tmp/assets_source_dir"
|
9
|
-
c.build_dir = "#{Rails.root}/tmp/assets_build_dir"
|
10
|
-
c.rjs_build_yml = "#{Rails.root}/config/rjs_build.yml"
|
11
|
-
c.rjs_runtime_yml = "#{Rails.root}/config/rjs_runtime.yml"
|
12
|
-
c.rjs_path = File.expand_path("../../vendor/assets/javascripts/r.js", File.dirname(__FILE__))
|
13
|
-
c.template = File.expand_path("./build.js.erb", File.dirname(__FILE__))
|
14
|
-
c.build_js = "#{Rails.root}/tmp/build.js"
|
15
|
-
@conf = c
|
16
|
-
end
|
17
|
-
|
18
|
-
def build_env
|
19
|
-
@build_env ||= RjsRails::BuildEnv.new(config)
|
20
|
-
end
|
21
|
-
|
22
|
-
def runtime_env
|
23
|
-
@runtime_env ||= RjsRails::RuntimeEnv.new(config)
|
24
|
-
end
|
25
|
-
|
26
|
-
def reload!
|
27
|
-
@build_env = nil
|
28
|
-
@runtime_env = nil
|
29
|
-
build_env
|
30
|
-
runtime_env
|
31
|
-
end
|
32
|
-
|
33
|
-
def get_binding()
|
34
|
-
binding()
|
35
|
-
end
|
36
|
-
|
37
|
-
def precompile_required?
|
38
|
-
build_env.yml_exists?
|
39
|
-
end
|
40
|
-
|
41
|
-
def assets_for_precompile
|
42
|
-
build_env.assets_for_precompile
|
43
|
-
end
|
44
|
-
|
45
|
-
end
|
46
|
-
end
|
@@ -1,17 +0,0 @@
|
|
1
|
-
module RjsRails
|
2
|
-
class Railtie < Rails::Railtie
|
3
|
-
initializer "rjs_rails.configure_rails_initialization" do
|
4
|
-
config.rjs = RjsRails::Env.new
|
5
|
-
ActionView::Base.send :include, RjsRails::RjsHelpers
|
6
|
-
end
|
7
|
-
|
8
|
-
config.to_prepare do
|
9
|
-
Rails.application.config.rjs.reload!
|
10
|
-
end
|
11
|
-
|
12
|
-
rake_tasks do
|
13
|
-
load File.expand_path("../tasks/rjs-rails.rake", File.dirname(__FILE__))
|
14
|
-
end
|
15
|
-
|
16
|
-
end
|
17
|
-
end
|
@@ -1,89 +0,0 @@
|
|
1
|
-
module RjsRails
|
2
|
-
class RuntimeEnv
|
3
|
-
|
4
|
-
attr_accessor :env
|
5
|
-
|
6
|
-
def initialize(env)
|
7
|
-
@env = env
|
8
|
-
rjs_static_include
|
9
|
-
end
|
10
|
-
|
11
|
-
def base_config
|
12
|
-
return @base_config if @base_config
|
13
|
-
base_config = {
|
14
|
-
"baseUrl" => baseurl,
|
15
|
-
"paths" => paths,
|
16
|
-
"shim" => shims,
|
17
|
-
"waitSeconds" => 0
|
18
|
-
}
|
19
|
-
end
|
20
|
-
|
21
|
-
def user_config
|
22
|
-
@user_config ||= load_yml_config
|
23
|
-
end
|
24
|
-
|
25
|
-
def config
|
26
|
-
@config ||= base_config.merge(user_config)
|
27
|
-
end
|
28
|
-
|
29
|
-
def rjs_static_include
|
30
|
-
@static_template ||= build_static_include
|
31
|
-
end
|
32
|
-
|
33
|
-
|
34
|
-
def yml
|
35
|
-
env.rjs_runtime_yml
|
36
|
-
end
|
37
|
-
|
38
|
-
def baseurl
|
39
|
-
"#{Rails.application.config.asset_host}#{Rails.application.config.assets.prefix}/"
|
40
|
-
end
|
41
|
-
|
42
|
-
def module_names
|
43
|
-
Rails.application.config.rjs.build_env.module_names
|
44
|
-
end
|
45
|
-
|
46
|
-
def shims
|
47
|
-
Rails.application.config.rjs.build_env.shims
|
48
|
-
end
|
49
|
-
|
50
|
-
def helpers
|
51
|
-
ActionController::Base.helpers
|
52
|
-
end
|
53
|
-
|
54
|
-
def module_path(m)
|
55
|
-
helpers.javascript_path("#{m}.js").sub(/.js$/,"")
|
56
|
-
end
|
57
|
-
|
58
|
-
def module_paths
|
59
|
-
mpaths = {}
|
60
|
-
module_names.each { |m| paths[m] = module_path(m) }
|
61
|
-
mpaths
|
62
|
-
end
|
63
|
-
|
64
|
-
def paths
|
65
|
-
module_paths.merge(Rails.application.config.rjs.build_env.paths)
|
66
|
-
end
|
67
|
-
|
68
|
-
def static_template
|
69
|
-
erb_template = <<-EOF
|
70
|
-
<script>var require = <%= JSON.generate(config).html_safe %>;</script>
|
71
|
-
EOF
|
72
|
-
end
|
73
|
-
|
74
|
-
def build_static_include
|
75
|
-
erb = ERB.new(static_template)
|
76
|
-
p = Proc.new { config }
|
77
|
-
binding = Kernel.binding
|
78
|
-
erb.result(binding)
|
79
|
-
end
|
80
|
-
|
81
|
-
def load_yml_config
|
82
|
-
return {} if not File.exists? yml
|
83
|
-
File.open(yml) { |f|
|
84
|
-
return YAML.load(f.read)
|
85
|
-
}
|
86
|
-
end
|
87
|
-
|
88
|
-
end
|
89
|
-
end
|