Sha256: d08524de515d8a1e828a95cdd7b1352f49bf2dc8eb02ebcebae52b32551143b7
Contents?: true
Size: 1.16 KB
Versions: 3
Compression:
Stored size: 1.16 KB
Contents
module Cornucopia module Util class FileAsset class << self def asset(asset_name) @@asset_list ||= {} @@asset_list[asset_name.to_sym] = FileAsset.new(asset_name) unless @@asset_list[asset_name.to_sym] @@asset_list[asset_name.to_sym] end end def initialize(asset_name) @asset_name = asset_name end def body=(asset_body) @asset_body = asset_body end def source_file=(source_file_name) # We read the file into memory in case the file moves or is temporary. @asset_body = File.read(source_file_name) end def add_file(output_location) unless (File.exists?(output_location)) create_file(output_location) end end def create_file(output_location) if @asset_body File.open(output_location, "w+") do |write_file| write_file << @asset_body end else FileUtils.cp path, output_location end end def path File.absolute_path(File.join(File.dirname(__FILE__), "../source_files/", @asset_name)) end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
cornucopia-0.1.14 | lib/cornucopia/util/file_asset.rb |
cornucopia-0.1.13 | lib/cornucopia/util/file_asset.rb |
cornucopia-0.1.12 | lib/cornucopia/util/file_asset.rb |