Class: Rack::MusicIndex

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

Instance Method Summary collapse

Constructor Details

#initialize(app, options = {}) ⇒ MusicIndex

Returns a new instance of MusicIndex.



7
8
9
10
11
# File 'lib/rack/musicindex.rb', line 7

def initialize(app, options = {})
  @app = app

  init(options)
end

Instance Method Details

#call(env) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/rack/musicindex.rb', line 17

def call(env)
  path_info = env['PATH_INFO']

  # to compare with static_path which is utf-8 encoding
  path_info.force_encoding('UTF-8') if path_info.respond_to? :force_encoding

  update_files

  if dirs[path_info]
    serve_podcast(env)
  elsif static_paths.include?(unescape(path_info))
    serve_mp3(env)
  else
    status, headers, response = @app.call(env)
  end
end

#init(options) ⇒ Object



13
14
15
# File 'lib/rack/musicindex.rb', line 13

def init(options)
  @dirs = options
end