Sha256: 1c153a1a978b9d521706f11fb38f10b4cebe5d33131c540a31d92241bfd01701
Contents?: true
Size: 1.08 KB
Versions: 1
Compression:
Stored size: 1.08 KB
Contents
module Iconly class Project class Downloader def initialize(project) @project = project end def call return unless @project.icons.any? generate zip_file_path rescue => e Rails.logger.error e nil end private def generate with_glyphs do |path| Project::FontGenerator.new(path, output_path).call end ZipFileGenerator.new(output_path, zip_file_path).write end def with_glyphs Dir.mktmpdir do |dir| FileUtils.cp @project.icons.map(&:svg_path), dir yield dir if block_given? end end def output_path @output_path ||= Dir.mktmpdir end def svg_path unless @svg_path icon = @project.icons.first @svg_path = File.dirname(Rails.root.join("public#{icon.svg.url}")) end @svg_path end def zip_file_path @zip_file_path ||= File.join(Iconly.downloads_folder, "#{@project.slug}_#{Time.current.to_i}.zip") end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
iconly-1.0.0 | app/models/iconly/project/downloader.rb |