paperclip-meta 2.0.0 → 2.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/paperclip-meta/railtie.rb +0 -2
- data/lib/paperclip-meta/version.rb +1 -1
- metadata +8 -31
- data/.gitignore +0 -6
- data/.rubocop.yml +0 -13
- data/.rubocop_todo.yml +0 -41
- data/.travis.yml +0 -12
- data/Gemfile +0 -10
- data/Rakefile +0 -10
- data/paperclip-meta.gemspec +0 -29
- data/spec/attachment_spec.rb +0 -148
- data/spec/fixtures/big.jpg +0 -0
- data/spec/fixtures/big.zip +0 -0
- data/spec/fixtures/small.png +0 -0
- data/spec/gemfiles/Gemfile.paperclip-3 +0 -17
- data/spec/gemfiles/Gemfile.paperclip-4 +0 -17
- data/spec/schema.rb +0 -15
- data/spec/spec_helper.rb +0 -58
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 27467cc20fda2a5ce14d39c75fa096fd4c673123
|
4
|
+
data.tar.gz: 42480399bc32c8f406685725167d075a57bdc654
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0f7996653d80341e5d9ad926ba04b64a34c5a0778d7d5f1c1647ba7c3e28852ac473e84fbc84e7106dfa2dcbf7e3bbf85fb7b546947edc2ff333b601c0fe8588
|
7
|
+
data.tar.gz: 64772edb624b4fbc99f26b82021fc01599cb3be26fe0bed4f9381c2079596c6bb0a78e1d4d1bf0a88027a4b315bfffb474f1d3374a6c07a667e2c721ef54bc2b
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: paperclip-meta
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alexey Bondar
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2016-04-22 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: paperclip
|
@@ -37,28 +37,28 @@ dependencies:
|
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '1.
|
40
|
+
version: '1.10'
|
41
41
|
type: :development
|
42
42
|
prerelease: false
|
43
43
|
version_requirements: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '1.
|
47
|
+
version: '1.10'
|
48
48
|
- !ruby/object:Gem::Dependency
|
49
49
|
name: rake
|
50
50
|
requirement: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: '
|
54
|
+
version: '11.0'
|
55
55
|
type: :development
|
56
56
|
prerelease: false
|
57
57
|
version_requirements: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
59
|
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: '
|
61
|
+
version: '11.0'
|
62
62
|
- !ruby/object:Gem::Dependency
|
63
63
|
name: mocha
|
64
64
|
requirement: !ruby/object:Gem::Requirement
|
@@ -109,27 +109,12 @@ executables: []
|
|
109
109
|
extensions: []
|
110
110
|
extra_rdoc_files: []
|
111
111
|
files:
|
112
|
-
- ".gitignore"
|
113
|
-
- ".rubocop.yml"
|
114
|
-
- ".rubocop_todo.yml"
|
115
|
-
- ".travis.yml"
|
116
|
-
- Gemfile
|
117
112
|
- LICENSE.txt
|
118
113
|
- README.md
|
119
|
-
- Rakefile
|
120
114
|
- lib/paperclip-meta.rb
|
121
115
|
- lib/paperclip-meta/attachment.rb
|
122
116
|
- lib/paperclip-meta/railtie.rb
|
123
117
|
- lib/paperclip-meta/version.rb
|
124
|
-
- paperclip-meta.gemspec
|
125
|
-
- spec/attachment_spec.rb
|
126
|
-
- spec/fixtures/big.jpg
|
127
|
-
- spec/fixtures/big.zip
|
128
|
-
- spec/fixtures/small.png
|
129
|
-
- spec/gemfiles/Gemfile.paperclip-3
|
130
|
-
- spec/gemfiles/Gemfile.paperclip-4
|
131
|
-
- spec/schema.rb
|
132
|
-
- spec/spec_helper.rb
|
133
118
|
homepage: http://github.com/teeparham/paperclip-meta
|
134
119
|
licenses:
|
135
120
|
- MIT
|
@@ -150,17 +135,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
150
135
|
version: '0'
|
151
136
|
requirements: []
|
152
137
|
rubyforge_project:
|
153
|
-
rubygems_version: 2.
|
138
|
+
rubygems_version: 2.6.2
|
154
139
|
signing_key:
|
155
140
|
specification_version: 4
|
156
141
|
summary: Add width, height, and size to paperclip images
|
157
|
-
test_files:
|
158
|
-
- spec/attachment_spec.rb
|
159
|
-
- spec/fixtures/big.jpg
|
160
|
-
- spec/fixtures/big.zip
|
161
|
-
- spec/fixtures/small.png
|
162
|
-
- spec/gemfiles/Gemfile.paperclip-3
|
163
|
-
- spec/gemfiles/Gemfile.paperclip-4
|
164
|
-
- spec/schema.rb
|
165
|
-
- spec/spec_helper.rb
|
142
|
+
test_files: []
|
166
143
|
has_rdoc:
|
data/.gitignore
DELETED
data/.rubocop.yml
DELETED
data/.rubocop_todo.yml
DELETED
@@ -1,41 +0,0 @@
|
|
1
|
-
# This configuration was generated by
|
2
|
-
# `rubocop --auto-gen-config`
|
3
|
-
# on 2015-12-29 14:24:38 -0700 using RuboCop version 0.35.1.
|
4
|
-
# The point is for the user to remove these configuration records
|
5
|
-
# one by one as the offenses are removed from the code base.
|
6
|
-
# Note that changes in the inspected code, or installation of new
|
7
|
-
# versions of RuboCop, may require this file to be generated again.
|
8
|
-
|
9
|
-
# Offense count: 4
|
10
|
-
# Configuration parameters: AllowURI, URISchemes.
|
11
|
-
Metrics/LineLength:
|
12
|
-
Max: 95
|
13
|
-
|
14
|
-
# Offense count: 6
|
15
|
-
# Configuration parameters: Exclude.
|
16
|
-
Style/Documentation:
|
17
|
-
Exclude:
|
18
|
-
- 'spec/**/*'
|
19
|
-
- 'test/**/*'
|
20
|
-
- 'lib/paperclip-meta/attachment.rb'
|
21
|
-
- 'lib/paperclip-meta/railtie.rb'
|
22
|
-
- 'lib/paperclip-meta/version.rb'
|
23
|
-
|
24
|
-
# Offense count: 1
|
25
|
-
# Configuration parameters: Exclude.
|
26
|
-
Style/FileName:
|
27
|
-
Exclude:
|
28
|
-
- 'lib/paperclip-meta.rb'
|
29
|
-
|
30
|
-
# Offense count: 1
|
31
|
-
# Configuration parameters: MinBodyLength.
|
32
|
-
Style/GuardClause:
|
33
|
-
Exclude:
|
34
|
-
- 'lib/paperclip-meta/attachment.rb'
|
35
|
-
|
36
|
-
# Offense count: 1
|
37
|
-
# Cop supports --auto-correct.
|
38
|
-
Style/SpecialGlobalVars:
|
39
|
-
Exclude:
|
40
|
-
- 'paperclip-meta.gemspec'
|
41
|
-
|
data/.travis.yml
DELETED
data/Gemfile
DELETED
data/Rakefile
DELETED
data/paperclip-meta.gemspec
DELETED
@@ -1,29 +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 = "paperclip-meta"
|
7
|
-
s.version = Paperclip::Meta::VERSION
|
8
|
-
s.authors = ["Alexey Bondar", "Tee Parham"]
|
9
|
-
s.email = ["y8@ya.ru", "tee@neighborland.com"]
|
10
|
-
s.homepage = "http://github.com/teeparham/paperclip-meta"
|
11
|
-
s.summary = "Add width, height, and size to paperclip images"
|
12
|
-
s.description = "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 = ">= 2.0.0"
|
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.4"
|
26
|
-
s.add_development_dependency "mocha", "~> 1.0"
|
27
|
-
s.add_development_dependency "activerecord", ">= 4.0"
|
28
|
-
s.add_development_dependency "sqlite3", ">= 1.3.10"
|
29
|
-
end
|
data/spec/attachment_spec.rb
DELETED
@@ -1,148 +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
|
-
assert_equal((50.0 / 64.0), img.small_image.aspect_ratio)
|
12
|
-
end
|
13
|
-
|
14
|
-
it "saves geometry for styles" do
|
15
|
-
img = Image.create(small_image: small_image, big_image: big_image)
|
16
|
-
assert_equal 100, img.big_image.width(:thumb)
|
17
|
-
assert_equal 100, img.big_image.height(:thumb)
|
18
|
-
end
|
19
|
-
|
20
|
-
it "saves original style geometry" do
|
21
|
-
img = Image.create(small_image: small_image)
|
22
|
-
assert_equal 50, img.small_image.width(:original)
|
23
|
-
assert_equal 64, img.small_image.height(:original)
|
24
|
-
end
|
25
|
-
|
26
|
-
it "sets geometry on update" do
|
27
|
-
img = Image.create!
|
28
|
-
img.small_image = small_image
|
29
|
-
img.save
|
30
|
-
geometry = geometry_for(small_path)
|
31
|
-
assert_equal geometry.width, img.small_image.width
|
32
|
-
assert_equal geometry.height, img.small_image.height
|
33
|
-
end
|
34
|
-
|
35
|
-
describe '#size' do
|
36
|
-
before do
|
37
|
-
@image = Image.create(big_image: big_image)
|
38
|
-
end
|
39
|
-
|
40
|
-
it "should save file size with meta data " do
|
41
|
-
path = File.join(File.dirname(__FILE__), "tmp/fixtures/tmp/thumb/#{@image.id}.jpg")
|
42
|
-
size = File.stat(path).size
|
43
|
-
assert_equal size, @image.big_image.size(:thumb)
|
44
|
-
end
|
45
|
-
|
46
|
-
it "should access normal paperclip method when no style passed" do
|
47
|
-
@image.big_image.expects size_without_meta_data: 1234
|
48
|
-
assert_equal 1234, @image.big_image.size
|
49
|
-
end
|
50
|
-
|
51
|
-
it "should have access to original file size" do
|
52
|
-
assert_equal 37_042, @image.big_image.size
|
53
|
-
end
|
54
|
-
end
|
55
|
-
|
56
|
-
it "clears geometry fields when image is destroyed" do
|
57
|
-
img = Image.create(small_image: small_image, big_image: big_image)
|
58
|
-
assert_equal 100, img.big_image.width(:thumb)
|
59
|
-
img.big_image = nil
|
60
|
-
img.save!
|
61
|
-
assert_nil img.big_image.width(:thumb)
|
62
|
-
end
|
63
|
-
|
64
|
-
it "does not save when file is not an image" do
|
65
|
-
img = Image.new
|
66
|
-
img.small_image = not_image
|
67
|
-
refute img.save
|
68
|
-
assert_nil img.small_image.width
|
69
|
-
end
|
70
|
-
|
71
|
-
it "returns nil attributes when file is not an image" do
|
72
|
-
img = ImageWithNoValidation.new
|
73
|
-
img.small_image = not_image
|
74
|
-
img.save!
|
75
|
-
assert_nil img.small_image.width
|
76
|
-
assert_nil img.small_image.height
|
77
|
-
end
|
78
|
-
|
79
|
-
it "preserves metadata when reprocessing a specific style" do
|
80
|
-
img = Image.new
|
81
|
-
img.big_image = big_image
|
82
|
-
img.save!
|
83
|
-
assert_equal 500, img.big_image.width(:large)
|
84
|
-
img.big_image.reprocess!(:thumb)
|
85
|
-
assert_equal 500, img.big_image.width(:large)
|
86
|
-
end
|
87
|
-
|
88
|
-
it "preserves metadata for unprocessed styles" do
|
89
|
-
img = Image.new
|
90
|
-
img.big_image = big_image
|
91
|
-
img.save!
|
92
|
-
|
93
|
-
# set big image meta to fake values for :large & missing :thumb
|
94
|
-
hash = { large: { height: 1, width: 2, size: 3 } }
|
95
|
-
img.update_column(:big_image_meta, img.big_image.send(:meta_encode, hash))
|
96
|
-
|
97
|
-
assert_equal 1, img.big_image.height(:large)
|
98
|
-
assert_equal 2, img.big_image.width(:large)
|
99
|
-
assert_equal 3, img.big_image.size(:large)
|
100
|
-
assert_nil img.big_image.height(:thumb)
|
101
|
-
assert_nil img.big_image.height(:original)
|
102
|
-
img.big_image.reprocess!(:thumb)
|
103
|
-
assert_equal 1, img.big_image.height(:large)
|
104
|
-
assert_equal 2, img.big_image.width(:large)
|
105
|
-
assert_equal 3, img.big_image.size(:large)
|
106
|
-
assert_equal 100, img.big_image.height(:thumb)
|
107
|
-
assert_equal 100, img.big_image.width(:thumb)
|
108
|
-
assert_equal 277, img.big_image.height(:original) # original is always reprocessed
|
109
|
-
end
|
110
|
-
|
111
|
-
it "replaces metadata when attachment changes" do
|
112
|
-
img = Image.new
|
113
|
-
img.big_image = big_image
|
114
|
-
img.save!
|
115
|
-
img.big_image = small_image
|
116
|
-
img.save!
|
117
|
-
assert_equal "50x64", img.big_image.image_size
|
118
|
-
assert_equal "100x100", img.big_image.image_size(:thumb)
|
119
|
-
assert_equal "500x500", img.big_image.image_size(:large)
|
120
|
-
assert_equal((50.0 / 64.0), img.big_image.aspect_ratio)
|
121
|
-
assert_equal((100.0 / 100.0), img.big_image.aspect_ratio(:thumb))
|
122
|
-
assert_equal((500.0 / 500.0), img.big_image.aspect_ratio(:large))
|
123
|
-
end
|
124
|
-
|
125
|
-
private
|
126
|
-
|
127
|
-
def small_path
|
128
|
-
File.join(File.dirname(__FILE__), "fixtures", "small.png")
|
129
|
-
end
|
130
|
-
|
131
|
-
# 50x64
|
132
|
-
def small_image
|
133
|
-
File.open(small_path)
|
134
|
-
end
|
135
|
-
|
136
|
-
def geometry_for(path)
|
137
|
-
Paperclip::Geometry.from_file(path)
|
138
|
-
end
|
139
|
-
|
140
|
-
# 600x277
|
141
|
-
def big_image
|
142
|
-
File.open(File.join(File.dirname(__FILE__), "fixtures", "big.jpg"))
|
143
|
-
end
|
144
|
-
|
145
|
-
def not_image
|
146
|
-
File.open(File.join(File.dirname(__FILE__), "fixtures", "big.zip"))
|
147
|
-
end
|
148
|
-
end
|
data/spec/fixtures/big.jpg
DELETED
Binary file
|
data/spec/fixtures/big.zip
DELETED
Binary file
|
data/spec/fixtures/small.png
DELETED
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,58 +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
|
-
# suppress AR 4.2 warnings
|
26
|
-
if ActiveRecord::Base.respond_to?(:raise_in_transactional_callbacks)
|
27
|
-
ActiveRecord::Base.raise_in_transactional_callbacks = true
|
28
|
-
end
|
29
|
-
|
30
|
-
class Image < ActiveRecord::Base
|
31
|
-
has_attached_file :small_image,
|
32
|
-
storage: :filesystem,
|
33
|
-
path: "./spec/tmp/:style/:id.:extension",
|
34
|
-
url: "./spec/tmp/:style/:id.extension"
|
35
|
-
|
36
|
-
has_attached_file :big_image,
|
37
|
-
storage: :filesystem,
|
38
|
-
path: "./spec/tmp/fixtures/tmp/:style/:id.:extension",
|
39
|
-
url: "./spec/tmp/fixtures/tmp/:style/:id.extension",
|
40
|
-
styles: { thumb: "100x100#", large: "500x500#" }
|
41
|
-
|
42
|
-
# paperclip 4.0 requires a validator
|
43
|
-
validates_attachment_content_type :small_image, content_type: /\Aimage/
|
44
|
-
validates_attachment_content_type :big_image, content_type: /\Aimage/
|
45
|
-
end
|
46
|
-
|
47
|
-
class ImageWithNoValidation < ActiveRecord::Base
|
48
|
-
self.table_name = :images
|
49
|
-
|
50
|
-
has_attached_file :small_image,
|
51
|
-
storage: :filesystem,
|
52
|
-
path: "./spec/tmp/:style/:id.:extension",
|
53
|
-
url: "./spec/tmp/:style/:id.extension"
|
54
|
-
|
55
|
-
if Paperclip::VERSION >= "4.0"
|
56
|
-
do_not_validate_attachment_file_type :small_image
|
57
|
-
end
|
58
|
-
end
|