-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support sprockets-rails3 #1
Conversation
ae31b8b
to
3b65d99
Compare
|
||
def register!(target, engine) | ||
klass = constantize(engine) | ||
return false if !klass || registered?(target) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[IMO]
klass.instance_of?(::Class)
seems better.
3b65d99
to
5148272
Compare
subject { -> { described_class.new(source_path) } } | ||
|
||
context 'when source path is relative' do | ||
let(:source_path) { 'foo.html' } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[IMO]
foo.html.erb
seems better because in most cases the format of a source file is something other than html
.
::Rails.public_path.join(logical_path) | ||
end | ||
|
||
def digest_path |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[IMO]
Related to this comment, you should implement this method as follows.
def digest_path_in_context(context)
# do something
end
17083e5
to
d9816f1
Compare
c4853cc
to
8fa12b1
Compare
8fa12b1
to
5deb445
Compare
I got the following error when I used this gem with sprockets-rails v3.0.0.
(You can see the full stack trace here.)
As far as I looked over sprockets-rails, it occurred due to the difference of how to define
Rails.application.assets
.In v2.x, it is defined as an instance method of
Rails::Application
class (ref. here).Therefore, we can access
Sprockets::Environment
ininitializer
blocks.On the other hand, in v3.0.0,
Rails.application.assets
is defined byattr_accessor
(ref. here).Then, the value is set in the
config.after_initialize
block (ref. here).Therefore, we can access
Sprockets::Environment
only inconfig.after_initialize
blocks.In addition, from the latest version,
Rails.application.assets
always returnsnil
whenconfig.assets.compile
is disabled (ref. README.md).For these reasons, we must add the following changes to support sprokets-rails3.
config.assets.configure
instead ofinitializer
.::Rails.application.assets.find_asset
to resove digest paths of templates