Class: Sinatra::Minify::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/sinatra/minify/config.rb

Instance Method Summary collapse

Constructor Details

#initialize(type, app_class = ::Main) ⇒ Config

Returns a new instance of Config.



4
5
6
7
# File 'lib/sinatra/minify/config.rb', line 4

def initialize(type, app_class = ::Main)
  @settings = app_class   
  @type     = type.to_s
end

Instance Method Details

#config_fileObject



29
30
31
# File 'lib/sinatra/minify/config.rb', line 29

def config_file
  @settings.minify_config
end

#css_urlObject



13
14
15
# File 'lib/sinatra/minify/config.rb', line 13

def css_url
  @settings.css_url
end

#js_urlObject



9
10
11
# File 'lib/sinatra/minify/config.rb', line 9

def js_url
  @settings.js_url
end

#public_dir(*args) ⇒ Object



17
18
19
# File 'lib/sinatra/minify/config.rb', line 17

def public_dir(*args)
  root_path(@settings.send("#{@type}_path"), *args)
end

#public_url(path) ⇒ Object



21
22
23
# File 'lib/sinatra/minify/config.rb', line 21

def public_url(path)
  File.join(@settings.send("#{@type}_url"), path).squeeze('/')
end

#root_path(*args) ⇒ Object



25
26
27
# File 'lib/sinatra/minify/config.rb', line 25

def root_path(*args)
  File.join(File.dirname(@settings.app_file), *args)
end

#setsObject



33
34
35
# File 'lib/sinatra/minify/config.rb', line 33

def sets
  YAML.load_file(root_path(config_file))[@type]
end