ack-paperclip-meta 1.2.3 → 3.0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4323d9c2f7e241a7624b1ecbbcf0432939c33be9
4
- data.tar.gz: 2cd1f8c4ebfd7dea7e4a9af21f8e6def1a5231d9
3
+ metadata.gz: 694a6136ef56089c20e41c1b6295e2527233dd79
4
+ data.tar.gz: 032d53f654ba5a2e30e42cb461f89caa32c6cc85
5
5
  SHA512:
6
- metadata.gz: 69c035adac5c49fff249478103ba546646ab4c3fa6818759f3d3258ccac4faba1f542d31094a671c77b71d20f17baab30e0c7e83e650b5172b5d70916823bca6
7
- data.tar.gz: 1677324403f4e4fb433962a30f3771752e091e8eeb7af98b10439588a7091c13603530669ee6efafac9c9b2e477291b5634e303c5829715adce9c1340c309d40
6
+ metadata.gz: f357bdeec11356c7e43e4f70884dd7771caee68e8ed21b5199caeac6cfea352f2d72ec229ae88ebb5cda17545e1a935df7ec28a963720ba7eef6a0c9389a6506
7
+ data.tar.gz: c471f45698ffc461ee147ef27115689fe3111910580dd125ab5782ffed769a155cc06a815c6fba241aa7b54125c3912d9b124b0dc665e49e2e57420d5f7729d4
data/README.md CHANGED
@@ -1,13 +1,14 @@
1
- # Paperclip Meta
1
+ # Ack Paperclip Meta
2
2
 
3
- [![Gem Version](https://badge.fury.io/rb/paperclip-meta.svg)](http://rubygems.org/gems/paperclip-meta)
4
- [![Build Status](https://travis-ci.org/teeparham/paperclip-meta.svg?branch=master)](https://travis-ci.org/teeparham/paperclip-meta)
3
+ Mongoid support
5
4
 
6
5
  Add width, height, and size to paperclip images.
7
6
 
8
7
  Paperclip Meta gets image dimensions after `post_process_styles` using paperclip's `Geometry.from_file`.
9
8
 
10
- Paperclip Meta works with paperclip versions 3.x and 4.x.
9
+ Paperclip Meta works with paperclip version 5.x.
10
+
11
+ Version 2.x works with paperclip version 4.x.
11
12
 
12
13
  ### Setup
13
14
 
@@ -51,7 +52,7 @@ style: {
51
52
 
52
53
  This hash will be marshaled and base64 encoded before writing to model attribute.
53
54
 
54
- `height`, `width`, and `image_size` methods are provided:
55
+ `height`, `width`, `image_size` and `aspect_ratio` methods are provided:
55
56
 
56
57
  ```ruby
57
58
  user.avatar.width(:thumb)
@@ -60,6 +61,8 @@ user.avatar.height(:medium)
60
61
  => 200
61
62
  user.avatar.image_size
62
63
  => '60x70'
64
+ user.avatar.aspect_ratio
65
+ => 1.5
63
66
  ```
64
67
 
65
68
  You can pass the image style to these methods. If a style is not passed, the default style will be used.
@@ -74,19 +77,5 @@ Test:
74
77
 
75
78
  ```sh
76
79
  bundle
77
- rake
78
- ```
79
-
80
- Test paperclip 3.x:
81
-
82
- ```sh
83
- BUNDLE_GEMFILE=./spec/gemfiles/Gemfile.paperclip-3 bundle
84
- BUNDLE_GEMFILE=./spec/gemfiles/Gemfile.paperclip-3 rake
85
- ```
86
-
87
- Test paperclip 4.x:
88
-
89
- ```sh
90
- BUNDLE_GEMFILE=./spec/gemfiles/Gemfile.paperclip-4 bundle
91
- BUNDLE_GEMFILE=./spec/gemfiles/Gemfile.paperclip-4 rake
80
+ bundle exec rake
92
81
  ```
@@ -1,110 +1,98 @@
1
1
  module Paperclip
2
2
  module Meta
3
3
  module Attachment
4
- def self.included(base)
5
- base.send :include, InstanceMethods
6
- base.alias_method_chain :save, :meta_data
7
- base.alias_method_chain :post_process_styles, :meta_data
8
- base.alias_method_chain :size, :meta_data
4
+ def assign_attributes
5
+ super
6
+ assign_meta
9
7
  end
10
8
 
11
- module InstanceMethods
12
- def save_with_meta_data
13
- if @queued_for_delete and @queued_for_delete.any? and (@queued_for_write.nil? or @queued_for_write.empty?)
14
- instance_write(:meta, meta_encode({}))
15
- elsif !@queued_for_write.nil? and !@queued_for_write.empty?
16
- post_process_styles_with_meta_data(@queued_for_write.keys.flatten)
17
- end
18
- save_without_meta_data
9
+ def save
10
+ if @queued_for_delete.any? && @queued_for_write.empty?
11
+ instance_write(:meta, meta_encode({}))
19
12
  end
13
+ super
14
+ end
20
15
 
21
- def post_process_styles_with_meta_data(*styles)
22
- post_process_styles_without_meta_data(*styles)
23
- return unless instance.respond_to?(:"#{name}_meta=")
16
+ def post_process_styles(*styles)
17
+ super(*styles)
18
+ assign_meta
19
+ end
24
20
 
25
- process_meta_for_styles(@queued_for_write)
26
- end
21
+ # Use meta info for style if required
22
+ def size(style = nil)
23
+ style ? read_meta(style, :size) : super()
24
+ end
27
25
 
28
- def process_meta_for_styles(queue)
29
- meta = populate_meta(queue)
30
- return if meta == {}
26
+ def height(style = default_style)
27
+ read_meta style, :height
28
+ end
31
29
 
32
- write_meta(meta)
33
- end
30
+ def width(style = default_style)
31
+ read_meta style, :width
32
+ end
34
33
 
35
- # Use meta info for style if required
36
- def size_with_meta_data(style = nil)
37
- style ? read_meta(style, :size) : size_without_meta_data
38
- end
34
+ def aspect_ratio(style = default_style)
35
+ width(style).to_f / height(style).to_f
36
+ end
39
37
 
40
- def height(style = default_style)
41
- read_meta style, :height
42
- end
38
+ # Return image dimesions ("WxH") for given style name. If style name not given,
39
+ # return dimesions for default_style.
40
+ def image_size(style = default_style)
41
+ "#{width(style)}x#{height(style)}"
42
+ end
43
43
 
44
- def width(style = default_style)
45
- read_meta style, :width
46
- end
44
+ private
47
45
 
48
- # Return image dimesions ("WxH") for given style name. If style name not given,
49
- # return dimesions for default_style.
50
- def image_size(style = default_style)
51
- w = width(style)
52
- h = height(style)
53
- "#{w}#{h && "x#{h}"}" if w || h
54
- end
46
+ def assign_meta
47
+ return unless instance.respond_to?(:"#{name}_meta=")
48
+ meta = populate_meta(@queued_for_write)
49
+ return if meta == {}
55
50
 
56
- def meta_data
57
- if instance.respond_to?(:"#{name}_meta") && instance_read(:meta)
58
- meta_decode(instance_read(:meta)).freeze
59
- end
60
- end
51
+ write_meta(meta)
52
+ end
61
53
 
62
- private
63
-
64
- def populate_meta(queue)
65
- meta = {}
66
- queue.each do |style, file|
67
- begin
68
- geo = Geometry.from_file file
69
- # geo.auto_orient
70
- meta[style] = { width: geo.width.to_i, height: geo.height.to_i, size: file.size }
71
- rescue Paperclip::Errors::NotIdentifiedByImageMagickError
72
- meta[style] = {}
73
- end
54
+ def populate_meta(queue)
55
+ meta = {}
56
+ queue.each do |style, file|
57
+ begin
58
+ geo = Geometry.from_file file
59
+ meta[style] = { width: geo.width.to_i, height: geo.height.to_i, size: file.size }
60
+ rescue Paperclip::Errors::NotIdentifiedByImageMagickError
61
+ meta[style] = {}
74
62
  end
75
- meta
76
63
  end
64
+ meta
65
+ end
77
66
 
78
- def write_meta(meta)
79
- merge_existing_meta_hash meta
80
- instance.send("#{name}_meta=", meta_encode(meta))
81
- end
67
+ def write_meta(meta)
68
+ merge_existing_meta_hash meta
69
+ instance.send("#{name}_meta=", meta_encode(meta))
70
+ end
82
71
 
83
- # Return meta data for given style
84
- def read_meta(style, item)
85
- if instance.respond_to?(:"#{name}_meta") && instance_read(:meta)
86
- if (meta = meta_decode(instance_read(:meta)))
87
- meta[style] && meta[style][item]
88
- end
72
+ # Return meta data for given style
73
+ def read_meta(style, item)
74
+ if instance.respond_to?(:"#{name}_meta") && instance_read(:meta)
75
+ if (meta = meta_decode(instance_read(:meta)))
76
+ meta[style] && meta[style][item]
89
77
  end
90
78
  end
79
+ end
91
80
 
92
- # Return encoded metadata as String
93
- def meta_encode(meta)
94
- Base64.encode64(Marshal.dump(meta))
95
- end
81
+ # Return encoded metadata as String
82
+ def meta_encode(meta)
83
+ Base64.encode64(Marshal.dump(meta))
84
+ end
96
85
 
97
- # Return decoded metadata as Object
98
- def meta_decode(meta)
99
- Marshal.load(Base64.decode64(meta))
100
- end
86
+ # Return decoded metadata as Object
87
+ def meta_decode(meta)
88
+ Marshal.load(Base64.decode64(meta))
89
+ end
101
90
 
102
- # Retain existing meta values that will not be recalculated when
103
- # reprocessing a subset of styles
104
- def merge_existing_meta_hash(meta)
105
- return unless (original_meta = instance.send("#{name}_meta"))
106
- meta.reverse_merge! meta_decode(original_meta)
107
- end
91
+ # Retain existing meta values that will not be recalculated when
92
+ # reprocessing a subset of styles
93
+ def merge_existing_meta_hash(meta)
94
+ return unless (original_meta = instance.send("#{name}_meta"))
95
+ meta.reverse_merge! meta_decode(original_meta)
108
96
  end
109
97
  end
110
98
  end
@@ -1,8 +1,5 @@
1
- require 'paperclip/meta'
2
-
3
1
  module Paperclip
4
2
  module Meta
5
-
6
3
  if defined? ::Rails::Railtie
7
4
  class Railtie < ::Rails::Railtie
8
5
  initializer :paperclip_meta do
@@ -23,9 +20,8 @@ module Paperclip
23
20
 
24
21
  class Railtie
25
22
  def self.insert
26
- Paperclip::Attachment.send(:include, Paperclip::Meta::Attachment)
23
+ Paperclip::Attachment.prepend Paperclip::Meta::Attachment
27
24
  end
28
25
  end
29
-
30
26
  end
31
27
  end
@@ -1,5 +1,5 @@
1
1
  module Paperclip
2
2
  module Meta
3
- VERSION = "1.2.3"
3
+ VERSION = "3.0.0.1"
4
4
  end
5
5
  end
@@ -1 +1,2 @@
1
- require 'paperclip/meta'
1
+ require 'paperclip'
2
+ require 'paperclip/meta'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ack-paperclip-meta
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.3
4
+ version: 3.0.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - ack
@@ -10,70 +10,64 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2015-04-27 00:00:00.000000000 Z
13
+ date: 2017-03-27 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: paperclip
17
17
  requirement: !ruby/object:Gem::Requirement
18
18
  requirements:
19
- - - ">="
20
- - !ruby/object:Gem::Version
21
- version: 3.0.2
22
19
  - - "<"
23
20
  - !ruby/object:Gem::Version
24
- version: '5.0'
21
+ version: '6.0'
25
22
  type: :runtime
26
23
  prerelease: false
27
24
  version_requirements: !ruby/object:Gem::Requirement
28
25
  requirements:
29
- - - ">="
30
- - !ruby/object:Gem::Version
31
- version: 3.0.2
32
26
  - - "<"
33
27
  - !ruby/object:Gem::Version
34
- version: '5.0'
28
+ version: '6.0'
35
29
  - !ruby/object:Gem::Dependency
36
30
  name: bundler
37
31
  requirement: !ruby/object:Gem::Requirement
38
32
  requirements:
39
33
  - - "~>"
40
34
  - !ruby/object:Gem::Version
41
- version: '1.5'
35
+ version: '1.13'
42
36
  type: :development
43
37
  prerelease: false
44
38
  version_requirements: !ruby/object:Gem::Requirement
45
39
  requirements:
46
40
  - - "~>"
47
41
  - !ruby/object:Gem::Version
48
- version: '1.5'
42
+ version: '1.13'
49
43
  - !ruby/object:Gem::Dependency
50
44
  name: rake
51
45
  requirement: !ruby/object:Gem::Requirement
52
46
  requirements:
53
47
  - - "~>"
54
48
  - !ruby/object:Gem::Version
55
- version: '10.1'
49
+ version: '11.3'
56
50
  type: :development
57
51
  prerelease: false
58
52
  version_requirements: !ruby/object:Gem::Requirement
59
53
  requirements:
60
54
  - - "~>"
61
55
  - !ruby/object:Gem::Version
62
- version: '10.1'
56
+ version: '11.3'
63
57
  - !ruby/object:Gem::Dependency
64
58
  name: mocha
65
59
  requirement: !ruby/object:Gem::Requirement
66
60
  requirements:
67
61
  - - "~>"
68
62
  - !ruby/object:Gem::Version
69
- version: '1.0'
63
+ version: '1.2'
70
64
  type: :development
71
65
  prerelease: false
72
66
  version_requirements: !ruby/object:Gem::Requirement
73
67
  requirements:
74
68
  - - "~>"
75
69
  - !ruby/object:Gem::Version
76
- version: '1.0'
70
+ version: '1.2'
77
71
  description: Add width, height and size methods to paperclip images
78
72
  email:
79
73
  - i43ack@gmail.com
@@ -83,14 +77,8 @@ executables: []
83
77
  extensions: []
84
78
  extra_rdoc_files: []
85
79
  files:
86
- - ".gitignore"
87
- - ".ruby-gemset"
88
- - ".ruby-version"
89
- - ".travis.yml"
90
- - Gemfile
91
80
  - LICENSE.txt
92
81
  - README.md
93
- - Rakefile
94
82
  - lib/ack-paperclip-meta.rb
95
83
  - lib/paperclip-meta.rb
96
84
  - lib/paperclip/meta.rb
@@ -98,17 +86,6 @@ files:
98
86
  - lib/paperclip/meta/process_meta_service.rb
99
87
  - lib/paperclip/meta/railtie.rb
100
88
  - lib/paperclip/meta/version.rb
101
- - paperclip-meta.gemspec
102
- - release.sh
103
- - spec/attachment_spec.rb
104
- - spec/fixtures/big.jpg
105
- - spec/fixtures/big.zip
106
- - spec/fixtures/small.png
107
- - spec/gemfiles/Gemfile.paperclip-3
108
- - spec/gemfiles/Gemfile.paperclip-4
109
- - spec/schema.rb
110
- - spec/spec_helper.rb
111
- - tasks/reprocess_meta.rake
112
89
  homepage: http://github.com/ack43/paperclip-meta
113
90
  licenses:
114
91
  - MIT
@@ -121,7 +98,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
121
98
  requirements:
122
99
  - - ">="
123
100
  - !ruby/object:Gem::Version
124
- version: 1.9.3
101
+ version: 2.2.2
125
102
  required_rubygems_version: !ruby/object:Gem::Requirement
126
103
  requirements:
127
104
  - - ">="
@@ -129,7 +106,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
129
106
  version: '0'
130
107
  requirements: []
131
108
  rubyforge_project:
132
- rubygems_version: 2.4.6
109
+ rubygems_version: 2.4.8
133
110
  signing_key:
134
111
  specification_version: 4
135
112
  summary: Add width, height, and size to paperclip images
data/.gitignore DELETED
@@ -1,8 +0,0 @@
1
- .idea
2
- .idea/*
3
-
4
- .bundle/
5
- Gemfile.lock
6
- pkg/*
7
- spec/gemfiles/*.lock
8
- spec/tmp/*/**
data/.ruby-gemset DELETED
@@ -1 +0,0 @@
1
- ack_paperclip-meta
data/.ruby-version DELETED
@@ -1 +0,0 @@
1
- 2.2.2
data/.travis.yml DELETED
@@ -1,10 +0,0 @@
1
- rvm:
2
- - 2.1.4
3
- - 2.0.0
4
- - 1.9.3
5
- - rbx-2
6
- gemfile:
7
- - spec/gemfiles/Gemfile.paperclip-4
8
- - spec/gemfiles/Gemfile.paperclip-3
9
- install:
10
- - bundle install --retry=3
data/Gemfile DELETED
@@ -1,10 +0,0 @@
1
- source 'https://rubygems.org'
2
-
3
- platforms :jruby do
4
- gem 'activerecord-jdbcsqlite3-adapter'
5
- end
6
-
7
- # See paperclip-meta.gemspec
8
- gemspec
9
-
10
- gem 'paperclip'
data/Rakefile DELETED
@@ -1,10 +0,0 @@
1
- require 'bundler/gem_tasks'
2
- require 'rake/testtask'
3
-
4
- Rake::TestTask.new(:spec) do |t|
5
- t.libs << 'spec'
6
- t.test_files = %w(spec/**/*_spec.rb)
7
- t.verbose = false
8
- end
9
-
10
- task default: :spec
@@ -1,32 +0,0 @@
1
- # -*- encoding: utf-8 -*-
2
- $:.push File.expand_path("../lib", __FILE__)
3
- require "paperclip/meta/version"
4
-
5
- Gem::Specification.new do |s|
6
- s.name = "ack-paperclip-meta"
7
- s.version = Paperclip::Meta::VERSION
8
- s.authors = ["ack", "Alexey Bondar", "Tee Parham"]
9
- s.email = ["i43ack@gmail.com", "y8@ya.ru", "tee@neighborland.com"]
10
- s.homepage = "http://github.com/ack43/paperclip-meta"
11
- s.summary = %q{Add width, height, and size to paperclip images}
12
- s.description = %q{Add width, height and size methods to paperclip images}
13
- s.license = "MIT"
14
-
15
- s.files = `git ls-files`.split("\n")
16
- s.test_files = `git ls-files -- {test,spec}/*`.split("\n")
17
- s.executables = []
18
- s.require_paths = ["lib"]
19
-
20
- s.required_ruby_version = ">= 1.9.3"
21
-
22
- s.add_dependency "paperclip", ">= 3.0.2", "< 5.0"
23
-
24
- s.add_development_dependency "bundler", "~> 1.5"
25
- s.add_development_dependency "rake", "~> 10.1"
26
- s.add_development_dependency "mocha", "~> 1.0"
27
- # s.add_development_dependency "activerecord", ">= 4.0"
28
-
29
- # sqlite3 1.3.9 does not work with rubinius 2.2.5:
30
- # https://github.com/sparklemotion/sqlite3-ruby/issues/122
31
- # s.add_development_dependency "sqlite3", "1.3.8"
32
- end
data/release.sh DELETED
@@ -1,7 +0,0 @@
1
- #!/usr/bin/bash
2
- bundle update
3
- git add --all .
4
- git commit -am "${*:1}"
5
- git push
6
- git push gh master
7
- rake release
@@ -1,144 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe "Attachment" do
4
- it "saves image geometry for original image" do
5
- img = Image.create(small_image: small_image)
6
- img.reload
7
- geometry = geometry_for(small_path)
8
- assert_equal geometry.width, img.small_image.width
9
- assert_equal geometry.height, img.small_image.height
10
- assert_equal "50x64", img.small_image.image_size
11
- end
12
-
13
- it "saves geometry for styles" do
14
- img = Image.create(small_image: small_image, big_image: big_image)
15
- assert_equal 100, img.big_image.width(:thumb)
16
- assert_equal 100, img.big_image.height(:thumb)
17
- end
18
-
19
- it "saves original style geometry" do
20
- img = Image.create(small_image: small_image)
21
- assert_equal 50, img.small_image.width(:original)
22
- assert_equal 64, img.small_image.height(:original)
23
- end
24
-
25
- it "sets geometry on update" do
26
- img = Image.create!
27
- img.small_image = small_image
28
- img.save
29
- geometry = geometry_for(small_path)
30
- assert_equal geometry.width, img.small_image.width
31
- assert_equal geometry.height, img.small_image.height
32
- end
33
-
34
- describe '#size' do
35
- before do
36
- @image = Image.create(big_image: big_image)
37
- end
38
-
39
- it 'should save file size with meta data ' do
40
- path = File.join(File.dirname(__FILE__), "tmp/fixtures/tmp/thumb/#{@image.id}.jpg")
41
- size = File.stat(path).size
42
- assert_equal size, @image.big_image.size(:thumb)
43
- end
44
-
45
- it 'should access normal paperclip method when no style passed' do
46
- @image.big_image.expects size_without_meta_data: 1234
47
- assert_equal 1234, @image.big_image.size
48
- end
49
-
50
- it 'should have access to original file size' do
51
- assert_equal 37042, @image.big_image.size
52
- end
53
- end
54
-
55
- it "clears geometry fields when image is destroyed" do
56
- img = Image.create(small_image: small_image, big_image: big_image)
57
- assert_equal 100, img.big_image.width(:thumb)
58
- img.big_image = nil
59
- img.save!
60
- assert_nil img.big_image.width(:thumb)
61
- end
62
-
63
- it "does not save when file is not an image" do
64
- img = Image.new
65
- img.small_image = not_image
66
- refute img.save
67
- assert_nil img.small_image.width
68
- end
69
-
70
- it "returns nil attributes when file is not an image" do
71
- img = ImageWithNoValidation.new
72
- img.small_image = not_image
73
- img.save!
74
- assert_nil img.small_image.width
75
- assert_nil img.small_image.height
76
- end
77
-
78
- it "preserves metadata when reprocessing a specific style" do
79
- img = Image.new
80
- img.big_image = big_image
81
- img.save!
82
- assert_equal 500, img.big_image.width(:large)
83
- img.big_image.reprocess!(:thumb)
84
- assert_equal 500, img.big_image.width(:large)
85
- end
86
-
87
- it "preserves metadata for unprocessed styles" do
88
- img = Image.new
89
- img.big_image = big_image
90
- img.save!
91
-
92
- # set big image meta to fake values for :large & missing :thumb
93
- hash = { large: { height: 1, width: 2, size: 3 } }
94
- img.update_column(:big_image_meta, img.big_image.send(:meta_encode, hash))
95
-
96
- assert_equal 1, img.big_image.height(:large)
97
- assert_equal 2, img.big_image.width(:large)
98
- assert_equal 3, img.big_image.size(:large)
99
- assert_nil img.big_image.height(:thumb)
100
- assert_nil img.big_image.height(:original)
101
- img.big_image.reprocess!(:thumb)
102
- assert_equal 1, img.big_image.height(:large)
103
- assert_equal 2, img.big_image.width(:large)
104
- assert_equal 3, img.big_image.size(:large)
105
- assert_equal 100, img.big_image.height(:thumb)
106
- assert_equal 100, img.big_image.width(:thumb)
107
- assert_equal 277, img.big_image.height(:original) # original is always reprocessed
108
- end
109
-
110
- it "replaces metadata when attachment changes" do
111
- img = Image.new
112
- img.big_image = big_image
113
- img.save!
114
- img.big_image = small_image
115
- img.save!
116
- assert_equal "50x64", img.big_image.image_size
117
- assert_equal "100x100", img.big_image.image_size(:thumb)
118
- assert_equal "500x500", img.big_image.image_size(:large)
119
- end
120
-
121
- private
122
-
123
- def small_path
124
- File.join(File.dirname(__FILE__), 'fixtures', 'small.png')
125
- end
126
-
127
- # 50x64
128
- def small_image
129
- File.open(small_path)
130
- end
131
-
132
- def geometry_for(path)
133
- Paperclip::Geometry.from_file(path)
134
- end
135
-
136
- # 600x277
137
- def big_image
138
- File.open(File.join(File.dirname(__FILE__), 'fixtures', 'big.jpg'))
139
- end
140
-
141
- def not_image
142
- File.open(File.join(File.dirname(__FILE__), 'fixtures', 'big.zip'))
143
- end
144
- end
Binary file
Binary file
Binary file
@@ -1,17 +0,0 @@
1
- source 'https://rubygems.org'
2
-
3
- platforms :jruby do
4
- gem 'activerecord-jdbcsqlite3-adapter'
5
- end
6
-
7
- platforms :rbx do
8
- gem 'json'
9
- gem 'rubysl', '~> 2.0'
10
- end
11
-
12
- # See paperclip-meta.gemspec
13
- gemspec path: '../..'
14
-
15
- gem 'activerecord', '~> 4.0.0'
16
- gem 'minitest', '~> 4.7'
17
- gem 'paperclip', '~> 3.5'
@@ -1,17 +0,0 @@
1
- source 'https://rubygems.org'
2
-
3
- platforms :jruby do
4
- gem 'activerecord-jdbcsqlite3-adapter'
5
- end
6
-
7
- platforms :rbx do
8
- gem 'json'
9
- gem 'rubysl', '~> 2.0'
10
- end
11
-
12
- # See paperclip-meta.gemspec
13
- gemspec path: '../..'
14
-
15
- gem 'activerecord', '~> 4.1'
16
- gem 'minitest', '~> 5.3'
17
- gem 'paperclip', '~> 4.0'
data/spec/schema.rb DELETED
@@ -1,15 +0,0 @@
1
- ActiveRecord::Schema.define do
2
- create_table :images do |t|
3
- t.string :small_image_file_name
4
- t.string :small_image_content_type
5
- t.integer :small_image_updated_at
6
- t.integer :small_image_file_size
7
- t.string :small_image_meta
8
-
9
- t.string :big_image_file_name
10
- t.string :big_image_content_type
11
- t.integer :big_image_updated_at
12
- t.integer :big_image_file_size
13
- t.string :big_image_meta
14
- end
15
- end
data/spec/spec_helper.rb DELETED
@@ -1,53 +0,0 @@
1
- require 'bundler/setup'
2
- Bundler.require(:default)
3
- require 'active_record'
4
- require 'minitest/autorun'
5
- require 'mocha/setup'
6
-
7
- ActiveRecord::Base.establish_connection(
8
- adapter: "sqlite3",
9
- database: ":memory:"
10
- )
11
-
12
- if ENV["VERBOSE"]
13
- ActiveRecord::Base.logger = Logger.new(STDERR)
14
- else
15
- Paperclip.options[:log] = false
16
- end
17
-
18
- load(File.join(File.dirname(__FILE__), 'schema.rb'))
19
-
20
- ActiveRecord::Base.send(:include, Paperclip::Glue)
21
- Paperclip::Meta::Railtie.insert
22
-
23
- I18n.enforce_available_locales = true
24
-
25
- class Image < ActiveRecord::Base
26
- has_attached_file :small_image,
27
- storage: :filesystem,
28
- path: "./spec/tmp/:style/:id.:extension",
29
- url: "./spec/tmp/:style/:id.extension"
30
-
31
- has_attached_file :big_image,
32
- storage: :filesystem,
33
- path: "./spec/tmp/fixtures/tmp/:style/:id.:extension",
34
- url: "./spec/tmp/fixtures/tmp/:style/:id.extension",
35
- styles: { thumb: "100x100#", large: "500x500#" }
36
-
37
- # paperclip 4.0 requires a validator
38
- validates_attachment_content_type :small_image, content_type: /\Aimage/
39
- validates_attachment_content_type :big_image, content_type: /\Aimage/
40
- end
41
-
42
- class ImageWithNoValidation < ActiveRecord::Base
43
- self.table_name = :images
44
-
45
- has_attached_file :small_image,
46
- storage: :filesystem,
47
- path: "./spec/tmp/:style/:id.:extension",
48
- url: "./spec/tmp/:style/:id.extension"
49
-
50
- if Paperclip::VERSION >= "4.0"
51
- do_not_validate_attachment_file_type :small_image
52
- end
53
- end
@@ -1,9 +0,0 @@
1
- require 'paperclip/meta/process_meta_service'
2
-
3
- namespace :paperclip_meta do
4
-
5
- desc 'Regenerate only the paperclip-meta without reprocessing the images themselves'
6
- task :reprocess => :environment do
7
- Paperclip::Meta::ProcessMetaService.process!(Rails.logger)
8
- end
9
- end