Class: StaticFM::Asset

Inherits:
Object
  • Object
show all
Defined in:
lib/static_fm/asset.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, attributes = {}) ⇒ Asset

Returns a new instance of Asset.



48
49
50
51
52
53
# File 'lib/static_fm/asset.rb', line 48

def initialize(name, attributes = {})
  @name = name
  attributes.each_pair do |attribute, value|
    self.send("#{attribute}=", value)
  end
end

Instance Attribute Details

#compressedObject

Returns the value of attribute compressed.



45
46
47
# File 'lib/static_fm/asset.rb', line 45

def compressed
  @compressed
end

#compressed_urlObject

Returns the value of attribute compressed_url.



45
46
47
# File 'lib/static_fm/asset.rb', line 45

def compressed_url
  @compressed_url
end

#dependenciesObject

Returns the value of attribute dependencies.



45
46
47
# File 'lib/static_fm/asset.rb', line 45

def dependencies
  @dependencies
end

#descriptionObject

Returns the value of attribute description.



45
46
47
# File 'lib/static_fm/asset.rb', line 45

def description
  @description
end

#file_nameObject

Returns the value of attribute file_name.



45
46
47
# File 'lib/static_fm/asset.rb', line 45

def file_name
  @file_name
end

#nameObject

Returns the value of attribute name.



45
46
47
# File 'lib/static_fm/asset.rb', line 45

def name
  @name
end

#urlObject

Returns the value of attribute url.



45
46
47
# File 'lib/static_fm/asset.rb', line 45

def url
  @url
end

#versionObject

Returns the value of attribute version.



45
46
47
# File 'lib/static_fm/asset.rb', line 45

def version
  @version
end

Class Method Details

.add(attributes) ⇒ Object



18
19
20
# File 'lib/static_fm/asset.rb', line 18

def add(attributes)
  config.merge!(attributes)
end

.configObject



22
23
24
# File 'lib/static_fm/asset.rb', line 22

def config
  @config ||= default_config
end

.config=(attributes) ⇒ Object



30
31
32
# File 'lib/static_fm/asset.rb', line 30

def config=(attributes)
  @config = attributes
end

.default_configObject



34
35
36
# File 'lib/static_fm/asset.rb', line 34

def default_config
  @default_config ||= YAML::load_file(File.join(dir, "config", "static.yml"))
end

.dirObject



14
15
16
# File 'lib/static_fm/asset.rb', line 14

def dir
  @dir ||= File.join(File.dirname(File.expand_path(__FILE__)), "..", "..")
end

.find(name) ⇒ Object



10
11
12
# File 'lib/static_fm/asset.rb', line 10

def find(name)
  new(name, config[name])
end

.recipe_namesObject



38
39
40
# File 'lib/static_fm/asset.rb', line 38

def recipe_names
  config.keys
end

.resetObject



26
27
28
# File 'lib/static_fm/asset.rb', line 26

def reset
  @config = default_config
end

Instance Method Details

#basenameObject



68
69
70
# File 'lib/static_fm/asset.rb', line 68

def basename
  File.basename(@url)
end

#display_nameObject



80
81
82
# File 'lib/static_fm/asset.rb', line 80

def display_name
  [name, version].compact.join(':')
end

#hostObject



60
61
62
# File 'lib/static_fm/asset.rb', line 60

def host
  parsed_uri.host
end

#pathObject



64
65
66
# File 'lib/static_fm/asset.rb', line 64

def path
  parsed_uri.path
end

#url_with_options(options = {}) ⇒ Object



55
56
57
58
# File 'lib/static_fm/asset.rb', line 55

def url_with_options(options = {})
  calculated_url = options[:compress] ? compressed_url : url
  update_url_with_version(calculated_url, @version)
end