Skip to content

Commit

Permalink
Merge pull request #10 from xing/set-correct-mime-type-for-cover
Browse files Browse the repository at this point in the history
Set correct mime type for cover
  • Loading branch information
Juan González committed Nov 28, 2019
2 parents 994e59e + 158bebd commit ef4229a
Show file tree
Hide file tree
Showing 9 changed files with 33 additions and 11 deletions.
5 changes: 0 additions & 5 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,6 @@ AllCops:
- 'db/migrate/*.rb'
- 'spec/dummy/**/*'

# By default, the rails cops are not run. Override in project or home
# directory .rubocop.yml files, or by giving the -R/--rails option.
Rails:
Enabled: true

# Indent private/protected/public as deep as method definitions
AccessModifierIndentation:
Description: Check indentation of private/protected visibility modifiers.
Expand Down
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
language: ruby
rvm:
- 2.2.6
- 2.3.4
- 2.5.7
- 2.6.5
gemfile:
- gemfiles/4.2.gemfile
- gemfiles/5.0.gemfile
Expand Down
20 changes: 20 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,26 @@ All notable changes to this project will be documented in this file.

This project adheres to [Semantic Versioning](http://semver.org/).

## [0.3.1] - 2019-11-26
### Added
- Enforce JPEG content type for carrierwave [Pull Request](https://github.com/xing/pdf_cover/pull/10)

## [0.2.4] - 2017-10-18
### Added
- Handle quotes in windows when calling GS [Pull Request](https://github.com/xing/pdf_cover/pull/9)

## [0.2.3] - 2017-08-21
### Added
- Remove `dTextAlphaBits` parameter to GS [Pull Request](https://github.com/xing/pdf_cover/pull/8)

## [0.2.3] - 2017-08-21
### Added
- Remove `dTextAlphaBits` parameter to GS [Pull Request](https://github.com/xing/pdf_cover/pull/8)

## [0.2.2] - 2017-07-05
### Added
- Add support for rails 5 [Pull Request](https://github.com/xing/pdf_cover/pull/7)

## [0.2.1] - 2016-10-24
### Added
- Add default antialias [Pull Request](https://github.com/xing/pdf_cover/pull/6)
Expand Down
5 changes: 5 additions & 0 deletions lib/pdf_cover.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ module CarrierWave
# end
def pdf_cover_attachment(options = {})
process pdf_cover: [options[:quality], options[:resolution]]
process enforce_content_type: "image/jpeg"

define_method :full_filename do |for_file = model.logo.file|
for_file.gsub(/pdf$/i, "jpeg")
Expand Down Expand Up @@ -96,4 +97,8 @@ def pdf_cover(quality, resolution)
converted_file = PdfCover::Converter.new(file, options).converted_file
FileUtils.cp(converted_file, current_path)
end

def enforce_content_type(content_type)
file.content_type = content_type
end
end
2 changes: 1 addition & 1 deletion lib/pdf_cover/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module PdfCover
VERSION = "0.2.4".freeze
VERSION = "0.3.1".freeze
end
4 changes: 2 additions & 2 deletions pdf_cover.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Gem::Specification.new do |spec|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
spec.require_paths = ["lib"]

spec.add_development_dependency "activesupport", ">= 4.2"
spec.add_development_dependency "activesupport", ">= 4.2", "< 6.0.0"

spec.add_development_dependency "appraisal"

Expand All @@ -32,7 +32,7 @@ Gem::Specification.new do |spec|
spec.add_development_dependency "simplecov"
spec.add_development_dependency "rspec", "~> 3.0"
spec.add_development_dependency "rubocop", "~> 0.37.2"
spec.add_development_dependency "sqlite3"
spec.add_development_dependency "sqlite3", "~> 1.3.6"

spec.add_development_dependency "byebug"
spec.add_development_dependency "fivemat"
Expand Down
2 changes: 2 additions & 0 deletions spec/carrierwave/with_carrierwave_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
let(:pdf_cover) { Magick::Image.read(pdf_cover_path).first }
let(:pdf_cover_digest) { pdf_cover.signature }
let(:pdf_cover_path) { subject.pdf.image.path }
let(:pdf_cover_content_type) { subject.pdf.image.content_type }

let(:sample_image) { Magick::Image.read(sample_image_name).first }
let(:sample_image_digest) { sample_image.signature }
Expand All @@ -22,6 +23,7 @@
it "creates the pdf cover image" do
expect(pdf_cover_path).to match(/.*jpeg$/)
expect(pdf_cover_digest).to eq(sample_image_digest)
expect(pdf_cover_content_type).to eq("image/jpeg")
end
end

Expand Down
Empty file.
2 changes: 1 addition & 1 deletion spec/dummy/config/environment.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Load the Rails application.
require File.expand_path('../application', __FILE__)
require File.expand_path("../application", __FILE__)

require "paperclip"
require "carrierwave"
Expand Down

0 comments on commit ef4229a

Please sign in to comment.