Class: Rack::ScriptStackerUtils::PathSpec

Inherits:
Object
  • Object
show all
Defined in:
lib/rack/scriptstacker.rb

Instance Method Summary collapse

Constructor Details

#initialize(paths) ⇒ PathSpec

Returns a new instance of PathSpec.



107
108
109
110
111
112
113
114
115
116
117
# File 'lib/rack/scriptstacker.rb', line 107

def initialize paths
  if paths.respond_to? :key
    # this is just for pretty method calls, eg.
    # css 'stylesheets' => 'static/css'
    @source_path, @serve_path = paths.to_a.flatten
  else
    # if only one path is given, use the same for both;
    # this is just like how Rack::Static works
    @source_path = @serve_path = paths
  end
end

Instance Method Details

#paths_identical?Boolean

Returns:

  • (Boolean)


127
128
129
130
131
132
# File 'lib/rack/scriptstacker.rb', line 127

def paths_identical?
  # Paths are normalized differently, so this check isn't doable from
  # outside the instance; but we still want to know if they're basically
  # the same so we can easily configure Rack::Static to match.
  @source_path == @serve_path
end

#serve_pathObject



123
124
125
# File 'lib/rack/scriptstacker.rb', line 123

def serve_path
  normalize_end_slash normalize_begin_slash(@serve_path)
end

#source_pathObject



119
120
121
# File 'lib/rack/scriptstacker.rb', line 119

def source_path
  normalize_end_slash @source_path
end