tension 0.10.0 → 0.10.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/tension/context.rb +5 -1
- data/lib/tension/environment.rb +1 -30
- data/lib/tension/railtie.rb +1 -6
- data/lib/tension/utils.rb +4 -4
- data/lib/tension/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3d39a310e3e3e2490fdb04a3c433b2507202974c
|
4
|
+
data.tar.gz: 0cc81a8bb2f40411c2551505111d7758b4481081
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f9e0850239953bd7dd608457d7b8c6e4675a1e73658687fde6af9a6145f542f401178a9d3466fa7d1ce96a7149211cf2bbddb76e4d24a2d44d2be12b1d8d7827
|
7
|
+
data.tar.gz: a362adf9f0915e6874c0a86041a554412600dbba0454ffe33f285e87c7a7fece7af64deeb457b5a9fb7bf8578072343efe6e1f93ff3d215a32b90af3f32d0cd2
|
data/lib/tension/context.rb
CHANGED
@@ -3,7 +3,11 @@ module Tension
|
|
3
3
|
attr_reader :controller_name, :action
|
4
4
|
|
5
5
|
def initialize(controller_path)
|
6
|
-
@controller_name =
|
6
|
+
@controller_name = controller_path.camelize
|
7
|
+
|
8
|
+
unless @controller_name.safe_constantize
|
9
|
+
@controller_name << "Controller"
|
10
|
+
end
|
7
11
|
end
|
8
12
|
|
9
13
|
def controller
|
data/lib/tension/environment.rb
CHANGED
@@ -7,12 +7,6 @@ module Tension
|
|
7
7
|
|
8
8
|
attr_reader :assets, :controllers
|
9
9
|
|
10
|
-
def initialize(assets_path)
|
11
|
-
if assets_cached?
|
12
|
-
cache_assets_from_manifest!(Sprockets::Manifest.new(assets_path))
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
10
|
# Loads a Context for the specified controller path.
|
17
11
|
#
|
18
12
|
def find_context(key)
|
@@ -41,20 +35,11 @@ module Tension
|
|
41
35
|
@controllers ||= Hash.new
|
42
36
|
end
|
43
37
|
|
44
|
-
# Determines whether or not a given path refers to an asset that requires
|
45
|
-
# precompilation.
|
46
|
-
#
|
47
|
-
def precompilation_needed?(path)
|
48
|
-
if cxt = find_context(path)
|
49
|
-
Tension::Utils.shared_asset?(path) || cxt.has_action?( Tension::Utils.action_name(path) )
|
50
|
-
end
|
51
|
-
end
|
52
|
-
|
53
38
|
|
54
39
|
private
|
55
40
|
|
56
41
|
def fetch(path)
|
57
|
-
contexts[path] || store(path)
|
42
|
+
(contexts[path] || store(path)) if path.present?
|
58
43
|
end
|
59
44
|
|
60
45
|
def store(path)
|
@@ -67,20 +52,6 @@ module Tension
|
|
67
52
|
end
|
68
53
|
end
|
69
54
|
|
70
|
-
def assets_cached?
|
71
|
-
! Rails.env.development? && ! Rails.application.config.assets.compile
|
72
|
-
end
|
73
|
-
|
74
|
-
def cache_assets_from_manifest!(manifest)
|
75
|
-
@assets = Hash.new
|
76
|
-
manifest.files.each do |full_path, info|
|
77
|
-
next unless full_path.match(/\.css|\.js\z/)
|
78
|
-
|
79
|
-
info = info.merge(full_path: full_path).with_indifferent_access
|
80
|
-
@assets[ info[:logical_path] ] = Asset.new(info)
|
81
|
-
end
|
82
|
-
end
|
83
|
-
|
84
55
|
# Routing defaults (including controller path and action name) for all
|
85
56
|
# configured GET routes.
|
86
57
|
#
|
data/lib/tension/railtie.rb
CHANGED
@@ -8,12 +8,7 @@ module Tension
|
|
8
8
|
initializer "tension.add_assets_to_precompile_list" do |app|
|
9
9
|
ActionView::Base.send(:include, Tension::Helper)
|
10
10
|
ActionController::Base.send(:include, Tension::Controller)
|
11
|
-
|
12
|
-
Tension.environment = Tension::Environment.new('public/assets')
|
13
|
-
|
14
|
-
Rails.application.config.assets.precompile << lambda do |path, filename|
|
15
|
-
Tension.environment.precompilation_needed?(path)
|
16
|
-
end
|
11
|
+
Tension.environment = Tension::Environment.new
|
17
12
|
end
|
18
13
|
|
19
14
|
end
|
data/lib/tension/utils.rb
CHANGED
@@ -52,6 +52,10 @@ module Tension
|
|
52
52
|
Tension.environment.find_asset( "application.#{type}" )
|
53
53
|
end
|
54
54
|
|
55
|
+
def strip_file_extension(path)
|
56
|
+
path.gsub(EXTENSION_REGEX, "")
|
57
|
+
end
|
58
|
+
|
55
59
|
private
|
56
60
|
|
57
61
|
# Builds a String path for an asset based on the given hash params.
|
@@ -84,10 +88,6 @@ module Tension
|
|
84
88
|
return parts.any? ? parts.join("/") : nil
|
85
89
|
end
|
86
90
|
|
87
|
-
def strip_file_extension(path)
|
88
|
-
path.gsub(EXTENSION_REGEX, "")
|
89
|
-
end
|
90
|
-
|
91
91
|
# Returns whether or not the given path represents an asset file
|
92
92
|
# for which Tension is useful: JavaScript or CSS.
|
93
93
|
# ARGS: path: a String path like "admin/blog_common.css"
|
data/lib/tension/version.rb
CHANGED