Module: Miniatura
- Defined in:
- lib/miniatura.rb,
lib/miniatura/logger.rb,
lib/miniatura/options.rb,
lib/miniatura/version.rb,
lib/miniatura/generate_command.rb
Defined Under Namespace
Classes: GenerateCommand, Logger, Options
Constant Summary collapse
- VERSION =
"0.1.1"
Instance Method Summary collapse
Instance Method Details
#generate_thumb(options = {}) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/miniatura.rb', line 8 def generate_thumb = {} [:file_extension] ||= 'jpeg' [:logger] = Rails.logger [:rotate] = 0 tmp_path = File.join( File.dirname(current_path), "tmpfile.#{[:file_extension]}") thumbnail = GenerateCommand.new(current_path, tmp_path) cmd = thumbnail.generate_command() logger = Miniatura::Logger.new().logger logger.info("Running command: #{cmd}") exit_code, error = nil raise Errno::ENOENT unless File.exist?(current_path) Open3.popen3(cmd) do |stdin, stdout, stderr, wait_thr| error = stderr.read exit_code = wait_thr.value end handle_exit_code(exit_code, error, logger) File.rename tmp_path, current_path end |