Sha256: c95fdd909404af6f313a44f2d017161b994b29af2466fe9cf321d8e3cbe79baa
Contents?: true
Size: 1.01 KB
Versions: 3
Compression:
Stored size: 1.01 KB
Contents
# coding: utf-8 require 'pathname' module WriteDown module Model # 代表 js, css, 图片等资产 class Asset def initialize(source_file, target_file = nil, option = {}) @source_file = source_file @base_name = source_file.split("/").last.split(".").first @ext_name = source_file.split("/").last.split(".").last if target_file @target_file = target_file else @target_file = "dist/#{target_file}" end @option = option end def build hash_file_name = "#{@base_name}-#{Time.now.to_s}.#{@ext_name}" output = Pathname.new("#{@target_file}") output.dirname.mkpath @final_path = @source_file.gsub("#{@base_name}.#{@ext_name}", hash_file_name) `cp #{source_file} #{@final_path}` end def sync # TODO 使用配置文件传入七牛的 key 和 secret QiniuSync.new("", "").sync @final_path #TODO @final_path 放在 initialize 里 end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
write_down-0.2.2 | lib/write_down/model/asset.rb |
write_down-0.2.1 | lib/write_down/model/asset.rb |
write_down-0.2.0 | lib/write_down/model/asset.rb |