assets_on_heroku 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/assets_on_heroku.gemspec +1 -1
- data/lib/assets_on_heroku.rb +8 -20
- metadata +2 -2
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.3
|
data/assets_on_heroku.gemspec
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{assets_on_heroku}
|
8
|
-
s.version = "0.0.
|
8
|
+
s.version = "0.0.3"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Jacek Becela", "Tomasz Mazur"]
|
data/lib/assets_on_heroku.rb
CHANGED
@@ -1,22 +1,10 @@
|
|
1
1
|
module AssetsOnHeroku
|
2
|
-
class Rack
|
3
|
-
def initialize(app)
|
4
|
-
@
|
2
|
+
class Rack < ::Rack::Static
|
3
|
+
def initialize(app, options = { :urls => ["/stylesheets", "/javascripts"], :root => "tmp/public" })
|
4
|
+
@root = options[:root]
|
5
5
|
setup
|
6
|
-
|
7
|
-
|
8
|
-
def call(env)
|
9
|
-
root = "tmp/public"
|
10
|
-
path = ::Rack::Request.new(env).path
|
11
|
-
|
12
|
-
is_stylesheet_request = path.start_with?("/stylesheets/") && path.end_with?(".css")
|
13
|
-
is_javascript_request = path.start_with?("/javascripts/") && path.end_with?(".js")
|
14
|
-
|
15
|
-
if is_stylesheet_request || is_javascript_request
|
16
|
-
::Rack::File.new(root).call(env)
|
17
|
-
else
|
18
|
-
@app.call(env)
|
19
|
-
end
|
6
|
+
|
7
|
+
super(app, options)
|
20
8
|
end
|
21
9
|
|
22
10
|
private
|
@@ -33,12 +21,12 @@ module AssetsOnHeroku
|
|
33
21
|
|
34
22
|
def setup_heroku
|
35
23
|
require "fileutils"
|
36
|
-
FileUtils.mkdir_p(
|
24
|
+
FileUtils.mkdir_p(@root)
|
37
25
|
end
|
38
26
|
|
39
27
|
def setup_sass
|
40
28
|
Sass::Plugin.options = {
|
41
|
-
:css_location => "
|
29
|
+
:css_location => "#{root}/stylesheets",
|
42
30
|
:template_location => "public/stylesheets/sass"
|
43
31
|
} if defined?(Sass::Plugin)
|
44
32
|
end
|
@@ -46,7 +34,7 @@ module AssetsOnHeroku
|
|
46
34
|
def setup_rails
|
47
35
|
ActionView::Helpers::AssetTagHelper.module_eval do
|
48
36
|
def write_asset_file_contents_with_heroku(broken_joined_asset_path, asset_paths)
|
49
|
-
fixed_joined_asset_path = broken_joined_asset_path.sub("public",
|
37
|
+
fixed_joined_asset_path = broken_joined_asset_path.sub("public", @root)
|
50
38
|
write_asset_file_contents_without_heroku(fixed_joined_asset_path, asset_paths)
|
51
39
|
end
|
52
40
|
alias_method_chain :write_asset_file_contents, :heroku
|