assets_on_heroku 0.0.2 → 0.0.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.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.2
1
+ 0.0.3
@@ -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.2"
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"]
@@ -1,22 +1,10 @@
1
1
  module AssetsOnHeroku
2
- class Rack
3
- def initialize(app)
4
- @app = app
2
+ class Rack < ::Rack::Static
3
+ def initialize(app, options = { :urls => ["/stylesheets", "/javascripts"], :root => "tmp/public" })
4
+ @root = options[:root]
5
5
  setup
6
- end
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("tmp/public")
24
+ FileUtils.mkdir_p(@root)
37
25
  end
38
26
 
39
27
  def setup_sass
40
28
  Sass::Plugin.options = {
41
- :css_location => "tmp/public/stylesheets",
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", "tmp/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
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 0
8
- - 2
9
- version: 0.0.2
8
+ - 3
9
+ version: 0.0.3
10
10
  platform: ruby
11
11
  authors:
12
12
  - Jacek Becela