tension 0.9.1 → 0.9.3
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/tension/environment.rb +14 -26
- data/lib/tension/railtie.rb +4 -4
- data/lib/tension/tension_helper.rb +7 -6
- data/lib/tension/version.rb +3 -0
- data/lib/tension.rb +0 -12
- data/tension.gemspec +5 -2
- 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: 69774653d546060ae567082eed766dec21e960e1
|
4
|
+
data.tar.gz: b2010ae61c8cac4764b644747df83ec5424f2c4f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 54f20566dabb047d69083bad4f754cccffd35daddecfdf5ac6f0b7447d85063e2a65ec60dbb0851dfc1049035ba6b08468c9c913a57b021a3cf38af104d51de0
|
7
|
+
data.tar.gz: 815605457bed700c1edaa25abba43fc10abd2415d653ede03515557b3cf0d553726315ba784fa3ea6e81f9018b8e8338b7d336da2947b90441eabe71ce016373
|
data/lib/tension/environment.rb
CHANGED
@@ -49,9 +49,11 @@ module Tension
|
|
49
49
|
# }
|
50
50
|
#
|
51
51
|
def asset_map
|
52
|
-
if
|
53
|
-
|
54
|
-
|
52
|
+
@asset_map = nil if Rails.env.development?
|
53
|
+
|
54
|
+
@asset_map ||= begin
|
55
|
+
map = Hash.new
|
56
|
+
globals = Hash.new
|
55
57
|
|
56
58
|
ASSET_TYPES.each do |type|
|
57
59
|
# Find and store the global asset for this type.
|
@@ -61,9 +63,7 @@ module Tension
|
|
61
63
|
|
62
64
|
# TODO: add support for looking up the tree...
|
63
65
|
search_paths.each_pair do |controller_path, actions|
|
64
|
-
|
65
|
-
|
66
|
-
@asset_map.store( controller_path, Hash.new )
|
66
|
+
map.store( controller_path, Hash.new )
|
67
67
|
|
68
68
|
ASSET_TYPES.each do |type|
|
69
69
|
# Attempt to locate a common asset for this controller.
|
@@ -71,22 +71,21 @@ module Tension
|
|
71
71
|
common_asset = valid_asset( common_path ) || globals.fetch( type[:extension] )
|
72
72
|
|
73
73
|
actions.each do |action|
|
74
|
-
|
75
|
-
|
76
|
-
.store( action, Hash.new )
|
74
|
+
unless map[ controller_path ].has_key?( action )
|
75
|
+
map.fetch( controller_path ).store( action, Hash.new )
|
77
76
|
end
|
78
77
|
|
79
78
|
action_asset = valid_asset( "#{ [ controller_path, action ].join("/") }.#{ type[:extension] }" )
|
80
|
-
|
81
|
-
|
82
|
-
|
79
|
+
map.fetch( controller_path )
|
80
|
+
.fetch( action )
|
81
|
+
.store( type[:extension], action_asset || common_asset )
|
83
82
|
end
|
84
83
|
end
|
85
84
|
|
86
85
|
end
|
87
|
-
end
|
88
86
|
|
89
|
-
|
87
|
+
map
|
88
|
+
end
|
90
89
|
end
|
91
90
|
|
92
91
|
# All unique, existing asset paths.
|
@@ -131,7 +130,7 @@ module Tension
|
|
131
130
|
# configured GET routes.
|
132
131
|
#
|
133
132
|
def configured_route_defaults
|
134
|
-
|
133
|
+
@configured_route_defaults ||= begin
|
135
134
|
get_routes = Rails.application.routes.routes.find_all do |route|
|
136
135
|
route.verb.match("GET")
|
137
136
|
end
|
@@ -142,8 +141,6 @@ module Tension
|
|
142
141
|
|
143
142
|
@configured_route_defaults.compact!
|
144
143
|
end
|
145
|
-
|
146
|
-
@configured_route_defaults
|
147
144
|
end
|
148
145
|
|
149
146
|
# Returns: a real BundledAsset present in the Sprockets index, or nil
|
@@ -152,15 +149,6 @@ module Tension
|
|
152
149
|
def valid_asset asset_path
|
153
150
|
Rails.application.assets.find_asset( asset_path )
|
154
151
|
end
|
155
|
-
|
156
|
-
# Returns: true if the controller targeted in the routes is present in this
|
157
|
-
# app's local code rather than in a gem. Gems are responsible for ensuring
|
158
|
-
# availability of their own assets.
|
159
|
-
#
|
160
|
-
def local_controller? controller_path
|
161
|
-
File.exists?("#{ Rails.root }/app/controllers/#{ controller_path }_controller.rb")
|
162
|
-
end
|
163
|
-
|
164
152
|
end
|
165
153
|
|
166
154
|
end
|
data/lib/tension/railtie.rb
CHANGED
@@ -1,16 +1,16 @@
|
|
1
|
-
require
|
1
|
+
require 'tension'
|
2
2
|
|
3
3
|
module Tension
|
4
|
-
require
|
4
|
+
require 'rails'
|
5
5
|
|
6
6
|
class Railtie < Rails::Railtie
|
7
7
|
initializer "tension.add_assets_to_precompile_list" do |app|
|
8
8
|
ActiveSupport.on_load :after_initialize do
|
9
9
|
|
10
10
|
Rails.application.reload_routes!
|
11
|
-
Tension.load_assets!
|
11
|
+
Tension.load_assets! unless Rails.env.development? or Rails.env.test?
|
12
12
|
|
13
|
-
|
13
|
+
ActionView::Base.send(:include, Tension::TensionHelper)
|
14
14
|
|
15
15
|
Rails.application.config.assets.precompile << lambda do |path, filename|
|
16
16
|
Tension::Environment.asset_paths.include?( filename )
|
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'active_support/concern'
|
2
|
+
|
1
3
|
module Tension
|
2
4
|
|
3
5
|
# Tagger is included in ActionView::Helpers so it can be called from
|
@@ -5,12 +7,11 @@ module Tension
|
|
5
7
|
module TensionHelper
|
6
8
|
extend ActiveSupport::Concern
|
7
9
|
|
8
|
-
# Just call
|
9
10
|
def asset_for type, *args
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
11
|
+
controller = request.params[:controller]
|
12
|
+
action = request.params[:action]
|
13
|
+
|
14
|
+
asset = Tension::Environment.asset_map[ controller ][ action ][ type.to_s ]
|
14
15
|
|
15
16
|
include_method = case type
|
16
17
|
when :js
|
@@ -19,7 +20,7 @@ module Tension
|
|
19
20
|
:stylesheet_link_tag
|
20
21
|
end
|
21
22
|
|
22
|
-
send( include_method, asset.logical_path, *args )
|
23
|
+
send( include_method, asset.logical_path, *args ) unless asset.nil?
|
23
24
|
end
|
24
25
|
end
|
25
26
|
|
data/lib/tension.rb
CHANGED
@@ -1,5 +1,3 @@
|
|
1
|
-
require 'active_support/ordered_options'
|
2
|
-
|
3
1
|
require 'tension/environment'
|
4
2
|
require 'tension/railtie' if defined?(Rails)
|
5
3
|
require 'tension/tension_helper'
|
@@ -8,14 +6,4 @@ module Tension
|
|
8
6
|
def self.load_assets!
|
9
7
|
!!Tension::Environment.asset_map
|
10
8
|
end
|
11
|
-
|
12
|
-
# def self.config
|
13
|
-
# @config ||= begin
|
14
|
-
# config = ActiveSupport::OrderedOptions.new
|
15
|
-
|
16
|
-
# config.enabled = !Rails.env.development? && !Rails.env.test?
|
17
|
-
|
18
|
-
# config
|
19
|
-
# end
|
20
|
-
# end
|
21
9
|
end
|
data/tension.gemspec
CHANGED
@@ -1,8 +1,11 @@
|
|
1
|
+
$LOAD_PATH.push File.expand_path("../lib", __FILE__)
|
2
|
+
require 'tension/version'
|
3
|
+
|
1
4
|
Gem::Specification.new do |s|
|
2
5
|
s.name = "tension"
|
3
6
|
|
4
|
-
s.version =
|
5
|
-
s.date = "2013-
|
7
|
+
s.version = Tension::VERSION
|
8
|
+
s.date = "2013-04-10"
|
6
9
|
s.license = "MIT"
|
7
10
|
|
8
11
|
s.summary = "Tighten up Rails's asset pipeline for CSS & JS."
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
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.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Piers Mainwaring
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-04-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -37,6 +37,7 @@ files:
|
|
37
37
|
- lib/tension/environment.rb
|
38
38
|
- lib/tension/railtie.rb
|
39
39
|
- lib/tension/tension_helper.rb
|
40
|
+
- lib/tension/version.rb
|
40
41
|
- tension.gemspec
|
41
42
|
homepage: https://github.com/piersadrian/tension
|
42
43
|
licenses:
|