tension 0.9.14 → 0.9.15

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a75cab3b3ef65c9590305e2ae0743398a5326968
4
- data.tar.gz: 9ff656abe44e288d6ee0e8ea2a8c3bfbcf0725f6
3
+ metadata.gz: 4eaa058ee2622eb39b664cc7ba46ec0764421d94
4
+ data.tar.gz: 552a3bff4bbae5383b983151b881729bab24acaf
5
5
  SHA512:
6
- metadata.gz: 94bfedf19b85e67862a66b352e9cc2b439a357d3389a031993ba6236b0e213f7f7d97d3089f441c6a826d31a2f849a78ca88b418942cee37115b2afaeddad31a
7
- data.tar.gz: fc08ff6e486a0c43564c7ee934617bde46a33cc58d99926dfcbd77622052737e799cc9838cab327d39391a1eff0d38a6d49f8f1e9834041ce0c68087959cce81
6
+ metadata.gz: a711ab02daf23f6f578a2a006864ebf422668317e5f09d11b63104403bdf587041ec4779985efcd4fe6714b0f4e1e0ab1a363dcf8e05b010a3822106a11c270d
7
+ data.tar.gz: 03efbcd1cdd7f00fc53c8da818c2ff9a0942a348463414b361a5d56d61d23836eb0ca0d5f902131e84e3fae589b58e44bbaef4cb3da8bf16a5073bd863638c0d
@@ -8,8 +8,9 @@ module Tension
8
8
  attr_reader :assets
9
9
 
10
10
  def initialize(assets_path)
11
- @manifest = Sprockets::Manifest.new(assets_path)
12
- process_assets!
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
- alias_method :[], :find_context
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 process_assets!
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
- @manifest.files.each do |full_path, info|
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.assets[ logical_asset_path(options) ]
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.assets[ "application.#{type}" ]
52
+ Tension.environment.find_asset( "application.#{type}" )
53
53
  end
54
54
 
55
55
  private
@@ -1,3 +1,3 @@
1
1
  module Tension
2
- VERSION = "0.9.14".freeze
2
+ VERSION = "0.9.15".freeze
3
3
  end
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.14
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: