Class: S3imageoptim::Command

Inherits:
Thor::Group
  • Object
show all
Defined in:
lib/s3imageoptim/command.rb

Instance Method Summary collapse

Instance Method Details

#compressObject



19
20
21
# File 'lib/s3imageoptim/command.rb', line 19

def compress
  ImageOptim.new(pngout: false, svgo: false).optimize_images!(local_files)
end

#getObject



9
10
11
12
13
14
15
16
17
# File 'lib/s3imageoptim/command.rb', line 9

def get
  s3cmd("get --exclude '*' --rinclude '\.(#{extensions("|")})$' --recursive #{bucket} #{tmpdir}") do |error|
    abort("An error ocurred while getting the files: #{error}")
  end

  if local_files.empty?
    abort("No images were found in the bucket")
  end
end

#putObject



23
24
25
26
27
# File 'lib/s3imageoptim/command.rb', line 23

def put
  s3cmd("sync #{tmpdir}/ #{bucket}") do |error|
    abort("An error ocurred while putting the files: #{error}")
  end
end

#removeObject



29
30
31
# File 'lib/s3imageoptim/command.rb', line 29

def remove
  FileUtils.remove_entry(tmpdir)
end