Skip to content

Commit

Permalink
Prevent application error when config/asset_packages.yml is missing
Browse files Browse the repository at this point in the history
  • Loading branch information
kennon committed Jan 14, 2009
1 parent e6a0303 commit a267165
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lib/synthesis/asset_package.rb
Expand Up @@ -3,7 +3,7 @@ class AssetPackage

# class variables
@@asset_packages_yml = $asset_packages_yml ||
(File.exists?("#{RAILS_ROOT}/config/asset_packages.yml") ? YAML.load_file("#{RAILS_ROOT}/config/asset_packages.yml") : nil)
(File.exists?("#{RAILS_ROOT}/config/asset_packages.yml") ? YAML.load_file("#{RAILS_ROOT}/config/asset_packages.yml") : {})

# singleton methods
class << self
Expand All @@ -25,7 +25,7 @@ def find_by_type(asset_type)
end

def find_by_target(asset_type, target)
package_hash = @@asset_packages_yml[asset_type].find {|p| p.keys.first == target }
package_hash = @@asset_packages_yml[asset_type].find {|p| p.keys.first == target } unless @@asset_packages_yml[asset_type].nil?
package_hash ? self.new(asset_type, package_hash) : nil
end

Expand All @@ -34,7 +34,7 @@ def find_by_source(asset_type, source)
package_hash = @@asset_packages_yml[asset_type].find do |p|
key = p.keys.first
p[key].include?(path_parts[2]) && (parse_path(key)[1] == path_parts[1])
end
end unless @@asset_packages_yml[asset_type].nil?
package_hash ? self.new(asset_type, package_hash) : nil
end

Expand Down

0 comments on commit a267165

Please sign in to comment.