tension 0.9.14 → 0.9.15
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/tension/environment.rb +21 -5
- data/lib/tension/utils.rb +2 -2
- data/lib/tension/version.rb +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4eaa058ee2622eb39b664cc7ba46ec0764421d94
|
4
|
+
data.tar.gz: 552a3bff4bbae5383b983151b881729bab24acaf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a711ab02daf23f6f578a2a006864ebf422668317e5f09d11b63104403bdf587041ec4779985efcd4fe6714b0f4e1e0ab1a363dcf8e05b010a3822106a11c270d
|
7
|
+
data.tar.gz: 03efbcd1cdd7f00fc53c8da818c2ff9a0942a348463414b361a5d56d61d23836eb0ca0d5f902131e84e3fae589b58e44bbaef4cb3da8bf16a5073bd863638c0d
|
data/lib/tension/environment.rb
CHANGED
@@ -8,8 +8,9 @@ module Tension
|
|
8
8
|
attr_reader :assets
|
9
9
|
|
10
10
|
def initialize(assets_path)
|
11
|
-
|
12
|
-
|
11
|
+
if assets_cached?
|
12
|
+
cache_assets_from_manifest!(Sprockets::Manifest.new(assets_path))
|
13
|
+
end
|
13
14
|
end
|
14
15
|
|
15
16
|
# Loads a Context for the specified controller path.
|
@@ -17,7 +18,18 @@ module Tension
|
|
17
18
|
def find_context(key)
|
18
19
|
fetch( Tension::Utils.controller_path(key) )
|
19
20
|
end
|
20
|
-
|
21
|
+
|
22
|
+
# Returns a Sprockets::Asset for the given logical path. Will load assets
|
23
|
+
# cached from a manifest if available, but in development falls back to
|
24
|
+
# the Sprockets::Index as assets may be under development.
|
25
|
+
#
|
26
|
+
def find_asset(logical_path)
|
27
|
+
if assets_cached?
|
28
|
+
assets[logical_path]
|
29
|
+
else
|
30
|
+
Rails.application.assets.find_asset(logical_path)
|
31
|
+
end
|
32
|
+
end
|
21
33
|
|
22
34
|
# A Hash mapping controller paths to Contexts.
|
23
35
|
#
|
@@ -51,9 +63,13 @@ module Tension
|
|
51
63
|
end
|
52
64
|
end
|
53
65
|
|
54
|
-
def
|
66
|
+
def assets_cached?
|
67
|
+
! Rails.env.development? && ! Rails.application.config.assets.compile
|
68
|
+
end
|
69
|
+
|
70
|
+
def cache_assets_from_manifest!(manifest)
|
55
71
|
@assets = Hash.new
|
56
|
-
|
72
|
+
manifest.files.each do |full_path, info|
|
57
73
|
next unless full_path.match(/\.css|\.js\z/)
|
58
74
|
|
59
75
|
info = info.merge(full_path: full_path).with_indifferent_access
|
data/lib/tension/utils.rb
CHANGED
@@ -42,14 +42,14 @@ module Tension
|
|
42
42
|
# type: Tension::CSS
|
43
43
|
#
|
44
44
|
def find_asset(options)
|
45
|
-
Tension.environment.
|
45
|
+
Tension.environment.find_asset( logical_asset_path(options) )
|
46
46
|
end
|
47
47
|
|
48
48
|
# Returns the application-wide Sprockets Asset for the given type.
|
49
49
|
# ARGS: type: Tension::JS or Tension::CSS
|
50
50
|
#
|
51
51
|
def global_asset(type)
|
52
|
-
Tension.environment.
|
52
|
+
Tension.environment.find_asset( "application.#{type}" )
|
53
53
|
end
|
54
54
|
|
55
55
|
private
|
data/lib/tension/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tension
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
4
|
+
version: 0.9.15
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Piers Mainwaring
|
@@ -67,3 +67,4 @@ signing_key:
|
|
67
67
|
specification_version: 4
|
68
68
|
summary: Tighten up Rails's asset pipeline for CSS & JS.
|
69
69
|
test_files: []
|
70
|
+
has_rdoc:
|