Class: StaticFM::Asset
- Inherits:
-
Object
- Object
- StaticFM::Asset
- Defined in:
- lib/static_fm/asset.rb
Instance Attribute Summary collapse
-
#compressed ⇒ Object
Returns the value of attribute compressed.
-
#compressed_url ⇒ Object
Returns the value of attribute compressed_url.
-
#dependencies ⇒ Object
Returns the value of attribute dependencies.
-
#description ⇒ Object
Returns the value of attribute description.
-
#file_name ⇒ Object
Returns the value of attribute file_name.
-
#name ⇒ Object
Returns the value of attribute name.
-
#url ⇒ Object
Returns the value of attribute url.
-
#version ⇒ Object
Returns the value of attribute version.
Class Method Summary collapse
- .add(attributes) ⇒ Object
- .config ⇒ Object
- .config=(attributes) ⇒ Object
- .default_config ⇒ Object
- .dir ⇒ Object
- .find(name) ⇒ Object
- .recipe_names ⇒ Object
- .reset ⇒ Object
Instance Method Summary collapse
- #basename ⇒ Object
- #display_name ⇒ Object
- #host ⇒ Object
-
#initialize(name, attributes = {}) ⇒ Asset
constructor
A new instance of Asset.
- #path ⇒ Object
- #url_with_options(options = {}) ⇒ Object
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
#compressed ⇒ Object
Returns the value of attribute compressed.
45 46 47 |
# File 'lib/static_fm/asset.rb', line 45 def compressed @compressed end |
#compressed_url ⇒ Object
Returns the value of attribute compressed_url.
45 46 47 |
# File 'lib/static_fm/asset.rb', line 45 def compressed_url @compressed_url end |
#dependencies ⇒ Object
Returns the value of attribute dependencies.
45 46 47 |
# File 'lib/static_fm/asset.rb', line 45 def dependencies @dependencies end |
#description ⇒ Object
Returns the value of attribute description.
45 46 47 |
# File 'lib/static_fm/asset.rb', line 45 def description @description end |
#file_name ⇒ Object
Returns the value of attribute file_name.
45 46 47 |
# File 'lib/static_fm/asset.rb', line 45 def file_name @file_name end |
#name ⇒ Object
Returns the value of attribute name.
45 46 47 |
# File 'lib/static_fm/asset.rb', line 45 def name @name end |
#url ⇒ Object
Returns the value of attribute url.
45 46 47 |
# File 'lib/static_fm/asset.rb', line 45 def url @url end |
#version ⇒ Object
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 |
.config ⇒ Object
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_config ⇒ Object
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 |
.dir ⇒ Object
14 15 16 |
# File 'lib/static_fm/asset.rb', line 14 def dir @dir ||= File.join(File.dirname(File.(__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_names ⇒ Object
38 39 40 |
# File 'lib/static_fm/asset.rb', line 38 def recipe_names config.keys end |
.reset ⇒ Object
26 27 28 |
# File 'lib/static_fm/asset.rb', line 26 def reset @config = default_config end |
Instance Method Details
#basename ⇒ Object
68 69 70 |
# File 'lib/static_fm/asset.rb', line 68 def basename File.basename(@url) end |
#display_name ⇒ Object
80 81 82 |
# File 'lib/static_fm/asset.rb', line 80 def display_name [name, version].compact.join(':') end |
#host ⇒ Object
60 61 62 |
# File 'lib/static_fm/asset.rb', line 60 def host parsed_uri.host end |
#path ⇒ Object
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 ( = {}) calculated_url = [:compress] ? compressed_url : url update_url_with_version(calculated_url, @version) end |