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.



101
102
103
104
105
106
107
108
109
110
111
# File 'lib/rack/scriptstacker.rb', line 101

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)


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

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



117
118
119
# File 'lib/rack/scriptstacker.rb', line 117

def serve_path
  normalize_end_slash normalize_begin_slash(@serve_path)
end

#source_pathObject



113
114
115
# File 'lib/rack/scriptstacker.rb', line 113

def source_path
  normalize_end_slash @source_path
end