Skip to content

Commit

Permalink
Sprockets internals: further work on detailing what goes on, up to tr…
Browse files Browse the repository at this point in the history
…ailw
  • Loading branch information
radar committed Aug 25, 2011
1 parent 89f9bea commit 98df724
Showing 1 changed file with 41 additions and 6 deletions.
47 changes: 41 additions & 6 deletions sprockets/sprockets.md
Expand Up @@ -355,12 +355,6 @@ method look like this:
<div class="example" data-repo='sprockets' data-file='lib/sprockets/static_compilation.rb' data-start='49'>
pathname = Pathname.new(static_root.join(logical_path))
attributes = attributes_for(pathname)

entries = entries(pathname.dirname)

if entries.empty?
return nil
end
</div>

The method defines a new `pathname` object, joining the `static_root`
Expand Down Expand Up @@ -389,6 +383,47 @@ def initialize(environment, path)
end
</div>

We've passed in the current `Sprockets::Environment` object into this
method which is received as the `environment` object and stored in the
instance variable `@environment`. The path that's passed in is the
`#{Rails.root}/public/assets/application.css` `Pathname` object that was created earlier. If
this path wasn't a `Pathname` already, this method would convert it into
one.

Back to `find_asset_in_static_root` now, and the next thing this method
does is these couple of lines:

<div class="example" data-repo='sprockets' data-file='lib/sprockets/static_compilation.rb' data-start='53'>
entries = entries(pathname.dirname)

if entries.empty?
return nil
end
</div>

The `entries` method that is used here is defined in
`lib/sprockets/base.rb` like this:

<div class="example" data-repo='sprockets' data-file='lib/sprockets/static_compilation.rb' data-start='53'>
def entries(pathname)
trail.entries(pathname)
end
</div>

The `trail` method is defined by an `attr_reader` call in
`Sprockets::Trail`'s `self.included` method in `lib/sprockets/trail.rb`:

<div class="example" data-repo='sprockets' data-file='lib/sprockets/trail.rb' data-start='6'>
def self.included(base)
base.instance_eval do
attr_reader :trail
protected :trail
end
end
</div>

TODO: Find where/how `@trail` is defined.

# Here be dragons

** I am currently in the process of re-working this document using
Expand Down

0 comments on commit 98df724

Please sign in to comment.