roadie-rails 1.0.2 → 1.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2a4b35fded61973ac9cbda12c4cbf1796becd78f
4
- data.tar.gz: 6b0b437288261047b9b81693bbb0deed2807a2d4
3
+ metadata.gz: 6af45ff8198c174ab196aa56d43b41c9a6fe4beb
4
+ data.tar.gz: 1dccbfa2e869c0e4bdac53aa5216d7dc943586a6
5
5
  SHA512:
6
- metadata.gz: 4b8a7542c61077ac912f2bf2d94eb5a35896d318c7e1c6e016ccb866a9db0e6785b22a58ab2e983216c64d9c33306bb736feb2bbe5afd741faf547aff06c242c
7
- data.tar.gz: da357a8a917fee88860c6583acd0dbc9000778953d1bd4b3824bcd78143cc799469fb21d3f6b401acdd761f5288d201464c11c2b3c61a437d8119edc90e6219d
6
+ metadata.gz: abc12ed74b832165ae530fd1a177e543ee09aafca39674923d52479aa0d916f9385e9a233a6de436e0bf73b1ca2f7d19ce31816f88432c0ab99f20eb49e337c2
7
+ data.tar.gz: 5c5863831c581517ab0c7e6f1a6cc3623f3690e2c5538e305184c9bac0ad2e2c184e119e4019918f7c222fc8653924b1d66f4ba039125650e6c78136373b38e2
data/Changelog.md CHANGED
@@ -1,6 +1,18 @@
1
1
  ### development version
2
2
 
3
- [full changelog](https://github.com/Mange/roadie/compare/v1.0.2...master)
3
+ [full changelog](https://github.com/Mange/roadie/compare/v1.0.3...master)
4
+
5
+ * Nothing yet
6
+
7
+ ### 1.0.3
8
+
9
+ [full changelog](https://github.com/Mange/roadie/compare/v1.0.2...v1.0.3)
10
+
11
+ * Bug fixes
12
+ * Don't change `asset_providers` of a `Roadie::Document` when applying Options with no `asset_providers` set.
13
+ * Support assets inside subdirectories.
14
+ * Don't add `AssetPipelineProvider` when asset pipeline is unavailable (e.g. inside Rails engines).
15
+ * Raise error when initializing `AssetPipelineProvider` with `nil` provider.
4
16
 
5
17
  ### 1.0.2
6
18
 
data/README.md CHANGED
@@ -254,6 +254,23 @@ class Admin::EmailsController < AdminController
254
254
  end
255
255
  ```
256
256
 
257
+ ## Known issues ##
258
+
259
+ Roadie will not be able to find your stylesheets if you have an `asset_host` configured and will ignore those lines when inlining.
260
+
261
+ A workaround for this is to not use `asset_host` in your mailers:
262
+
263
+ ```ruby
264
+ config.action_controller.asset_host = # ...
265
+ config.action_mailer.asset_host = nil
266
+
267
+ # or
268
+
269
+ class MyMailer < ActionMailer::Base
270
+ self.asset_host = nil
271
+ end
272
+ ```
273
+
257
274
  ## Build status ##
258
275
 
259
276
  Tested with [Travis CI](http://travis-ci.org) using [almost all combinations of](http://travis-ci.org/#!/Mange/roadie-rails):
@@ -5,6 +5,7 @@ module Roadie
5
5
  attr_reader :pipeline
6
6
 
7
7
  def initialize(pipeline)
8
+ raise ArgumentError, "You need to pass a pipeline to initialize AssetPipelineProvider" unless pipeline
8
9
  super()
9
10
  @pipeline = pipeline
10
11
  end
@@ -17,7 +18,15 @@ module Roadie
17
18
 
18
19
  private
19
20
  def normalize_asset_name(href)
20
- File.basename href.split('?').first
21
+ remove_asset_prefix href.split('?').first
22
+ end
23
+
24
+ def remove_asset_prefix(path)
25
+ path.sub(Regexp.new("^#{Regexp.quote(asset_prefix)}/?"), "")
26
+ end
27
+
28
+ def asset_prefix
29
+ ::Rails.application.try(:config).try(:assets).try(:prefix) || "/assets"
21
30
  end
22
31
  end
23
32
  end
@@ -30,6 +30,9 @@ module Roadie
30
30
  def asset_providers=(providers)
31
31
  if providers
32
32
  @asset_providers = ProviderList.wrap providers
33
+ # TODO: Raise an error when setting to nil in order to make this not a silent error.
34
+ # else
35
+ # raise ArgumentError, "Cannot set asset_providers to nil. Set to Roadie::NullProvider if you want no external assets inlined."
33
36
  end
34
37
  end
35
38
 
@@ -37,7 +40,9 @@ module Roadie
37
40
  document.url_options = url_options
38
41
  document.before_transformation = before_transformation
39
42
  document.after_transformation = after_transformation
40
- document.asset_providers = asset_providers
43
+ # #asset_providers default to nil in this class and it's the one option
44
+ # that is not allowed to be nil on Document.
45
+ document.asset_providers = asset_providers if asset_providers
41
46
  end
42
47
 
43
48
  def merge(options)
@@ -78,7 +83,7 @@ module Roadie
78
83
 
79
84
  def combine_providers(first, second)
80
85
  combine_nilable(first, second) do |a, b|
81
- ProviderList.new a.to_a + Array.wrap(b)
86
+ ProviderList.new(a.to_a + Array.wrap(b))
82
87
  end
83
88
  end
84
89
 
@@ -13,7 +13,7 @@ module Roadie
13
13
  # Saying config.assets.enabled here does not work in Rails 3.1-3.2, but
14
14
  # APP.config.assets work. There is a difference between "config" and
15
15
  # "app.config" on those versions.
16
- if app.config.respond_to?(:assets) && app.config.assets.enabled != false
16
+ if app.config.respond_to?(:assets) && app.config.assets.enabled != false && app.assets
17
17
  config.roadie.asset_providers << AssetPipelineProvider.new(app.assets)
18
18
  end
19
19
  end
@@ -1,5 +1,5 @@
1
1
  module Roadie
2
2
  module Rails
3
- VERSION = "1.0.2"
3
+ VERSION = "1.0.3"
4
4
  end
5
5
  end
@@ -6,6 +6,12 @@ module Roadie
6
6
  describe AssetPipelineProvider do
7
7
  let(:pipeline) { FakePipeline.new }
8
8
 
9
+ it "requires a passed pipeline" do
10
+ expect {
11
+ AssetPipelineProvider.new(nil)
12
+ }.to raise_error(ArgumentError)
13
+ end
14
+
9
15
  it_behaves_like "roadie asset provider", valid_name: "existing.css", invalid_name: "bad.css" do
10
16
  subject { AssetPipelineProvider.new(pipeline) }
11
17
  before do
@@ -28,6 +34,15 @@ module Roadie
28
34
  provider = AssetPipelineProvider.new(pipeline)
29
35
  expect(provider.find_stylesheet("/assets/good.css?body=1")).not_to be_nil
30
36
  end
37
+
38
+ it "supports stylesheets inside subdirectories" do
39
+ pipeline.add_asset "sub/deep.css", "/path/to/sub/deep.css.scss", "body { color: green; }"
40
+ provider = AssetPipelineProvider.new(pipeline)
41
+
42
+ stylesheet = provider.find_stylesheet("sub/deep.css")
43
+ expect(stylesheet.name).to eq("/path/to/sub/deep.css.scss (live compiled)")
44
+ expect(stylesheet.to_s).to eq("body{color:green}")
45
+ end
31
46
  end
32
47
 
33
48
  class FakePipeline
@@ -131,6 +131,14 @@ module Roadie
131
131
  expect(options.asset_providers.to_a).to eq([provider])
132
132
  end
133
133
  end
134
+
135
+ describe "applying to a document" do
136
+ it "does not change the default asset_providers if option is never set" do
137
+ fake_document = OpenStruct.new(asset_providers: "original")
138
+ Options.new.apply_to(fake_document)
139
+ expect(fake_document.asset_providers).to eq("original")
140
+ end
141
+ end
134
142
  end
135
143
  end
136
144
  end
@@ -42,6 +42,19 @@ module Roadie
42
42
  expect(providers[1]).to be_instance_of(AssetPipelineProvider)
43
43
  expect(providers[1].pipeline).to eq(asset_pipeline)
44
44
  end
45
+
46
+ # This happens inside a Rails engine as the parent app is the one
47
+ # holding on to the pipeline.
48
+ it "gets no AssetPipelineProvider if assets are enabled but not available" do
49
+ rails_application.config.assets = ActiveSupport::OrderedOptions.new(enabled: true)
50
+ allow(rails_application).to receive(:assets).and_return nil
51
+
52
+ run_initializer
53
+
54
+ providers = Railtie.config.roadie.asset_providers.to_a
55
+ expect(providers).to have(1).item
56
+ expect(providers[0]).to be_instance_of(FilesystemProvider)
57
+ end
45
58
  end
46
59
  end
47
60
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: roadie-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 1.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Magnus Bergmark
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-07-02 00:00:00.000000000 Z
11
+ date: 2014-08-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: roadie