blade 0.4.0 → 0.4.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/blade.rb +6 -0
- data/lib/blade/assets.rb +19 -7
- data/lib/blade/assets/builder.rb +48 -0
- data/lib/blade/cli.rb +6 -0
- data/lib/blade/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4a205b84cda0e15047ee832ddd16ec0def59e788
|
4
|
+
data.tar.gz: 4544bf65ab82d61421825efcd7249e59c3ee454f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: efaa9386cb6042ad8720956badc98a551b837fdffe56df3bd0d547e7640f87124df9cab5560e1b2b3f8e710a12b5062ded7cf1764b96a00150b7804b2a84d660
|
7
|
+
data.tar.gz: afbac6fb74d822b8c866e0d3fd0c8d57c8bd2fb8b3a7b10e42c99630db05b03dd9416326011da5e7cb5bfa80f1bbf204774fb85cb766326caf0143210dca1937
|
data/lib/blade.rb
CHANGED
@@ -120,6 +120,12 @@ module Blade
|
|
120
120
|
options[:load_paths] = Array(options[:load_paths])
|
121
121
|
options[:logical_paths] = Array(options[:logical_paths])
|
122
122
|
|
123
|
+
if build_options = options.delete(:build)
|
124
|
+
build_options[:logical_paths] = Array(build_options[:logical_paths])
|
125
|
+
build_options[:path] ||= "."
|
126
|
+
options[:build] = OpenStruct.new(build_options)
|
127
|
+
end
|
128
|
+
|
123
129
|
@config = OpenStruct.new(options)
|
124
130
|
|
125
131
|
setup_plugin_config!
|
data/lib/blade/assets.rb
CHANGED
@@ -1,36 +1,48 @@
|
|
1
1
|
require "sprockets"
|
2
2
|
|
3
3
|
module Blade::Assets
|
4
|
+
autoload :Builder, "blade/assets/builder"
|
5
|
+
|
4
6
|
extend self
|
5
7
|
|
6
8
|
@environments = {}
|
7
9
|
|
8
|
-
def environment(name = :blade)
|
9
|
-
|
10
|
-
|
10
|
+
def environment(name = :blade, context_name = nil)
|
11
|
+
cache_name = [name, context_name].compact.map(&:to_s).uniq.join("-")
|
12
|
+
|
13
|
+
@environments[cache_name] ||= Sprockets::Environment.new do |env|
|
14
|
+
env.cache = Sprockets::Cache::FileStore.new(Blade.tmp_path.join(cache_name))
|
11
15
|
|
12
16
|
send("#{name}_load_paths").each do |path|
|
13
17
|
env.append_path(path)
|
14
18
|
end
|
15
19
|
|
16
20
|
env.context_class.class_eval do
|
17
|
-
|
18
|
-
|
21
|
+
delegate :logical_paths, to: Blade::Assets
|
22
|
+
|
23
|
+
define_method(:environment) { env }
|
24
|
+
define_method(:context_name) { name }
|
19
25
|
|
20
26
|
def with_asset(path, env_name)
|
21
|
-
if asset = environment(env_name)[path]
|
27
|
+
if asset = Blade::Assets.environment(env_name, context_name)[path]
|
22
28
|
depend_on(asset.pathname)
|
23
29
|
yield(asset)
|
24
30
|
end
|
25
31
|
end
|
26
32
|
|
27
|
-
def render_asset(path, env_name)
|
33
|
+
def render_asset(path, env_name = context_name)
|
28
34
|
with_asset(path, env_name) { |asset| asset.to_s }
|
29
35
|
end
|
30
36
|
end
|
31
37
|
end
|
32
38
|
end
|
33
39
|
|
40
|
+
def build(name = :user)
|
41
|
+
if Blade.config.build
|
42
|
+
Builder.new(environment(name)).build
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
34
46
|
def logical_paths(type = nil)
|
35
47
|
paths = Blade.config.logical_paths
|
36
48
|
paths.select! { |path| File.extname(path) == ".#{type}" } if type
|
@@ -0,0 +1,48 @@
|
|
1
|
+
class Blade::Assets::Builder
|
2
|
+
attr_accessor :environment
|
3
|
+
|
4
|
+
def initialize(environment)
|
5
|
+
@environment = environment
|
6
|
+
end
|
7
|
+
|
8
|
+
def build
|
9
|
+
clean
|
10
|
+
compile
|
11
|
+
install
|
12
|
+
end
|
13
|
+
|
14
|
+
private
|
15
|
+
def compile
|
16
|
+
environment.js_compressor = Blade.config.build.js_compressor.try(:to_sym)
|
17
|
+
environment.css_compressor = Blade.config.build.css_compressor.try(:to_sym)
|
18
|
+
manifest.compile(logical_paths)
|
19
|
+
end
|
20
|
+
|
21
|
+
def install
|
22
|
+
logical_paths.each do |logical_path|
|
23
|
+
fingerprint_path = manifest.assets[logical_path]
|
24
|
+
FileUtils.cp(compile_path.join(fingerprint_path), dist_path.join(logical_path))
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def manifest
|
29
|
+
@manifest ||= Sprockets::Manifest.new(environment.index, compile_path)
|
30
|
+
end
|
31
|
+
|
32
|
+
def clean
|
33
|
+
compile_path.rmtree if compile_path.exist?
|
34
|
+
compile_path.mkpath
|
35
|
+
end
|
36
|
+
|
37
|
+
def logical_paths
|
38
|
+
Blade.config.build.logical_paths
|
39
|
+
end
|
40
|
+
|
41
|
+
def dist_path
|
42
|
+
Pathname.new(Blade.config.build.path)
|
43
|
+
end
|
44
|
+
|
45
|
+
def compile_path
|
46
|
+
Blade.tmp_path.join("compile")
|
47
|
+
end
|
48
|
+
end
|
data/lib/blade/cli.rb
CHANGED
data/lib/blade/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: blade
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Javan Makhmali
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-10-
|
11
|
+
date: 2015-10-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -213,6 +213,7 @@ files:
|
|
213
213
|
- exe/blade
|
214
214
|
- lib/blade.rb
|
215
215
|
- lib/blade/assets.rb
|
216
|
+
- lib/blade/assets/builder.rb
|
216
217
|
- lib/blade/cli.rb
|
217
218
|
- lib/blade/combined_test_results.rb
|
218
219
|
- lib/blade/component.rb
|