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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e5144016b9bfc125ed6df81bcb20304bdc0d0e36
4
- data.tar.gz: 256c57dfea9350300f01fd20cce281ffeae0b0a8
3
+ metadata.gz: 27467cc20fda2a5ce14d39c75fa096fd4c673123
4
+ data.tar.gz: 42480399bc32c8f406685725167d075a57bdc654
5
5
  SHA512:
6
- metadata.gz: 8f6f8282f21b20850a2b7e2a1a06fcee52930978740c133d33bedc3928ddb357a79a57501f447a694ec1f271a6ff99b3d93f0a57fa91673f6db1201dfec78e5a
7
- data.tar.gz: 567a4d3ef8302a5a3d9ca8caecb4d27d942ade18fe7a67aa6d36a1059f36189c183df2ab42045740894e7df406d37dec36a5a0fd10fc79b7c1b7a87ec84a9fcc
6
+ metadata.gz: 0f7996653d80341e5d9ad926ba04b64a34c5a0778d7d5f1c1647ba7c3e28852ac473e84fbc84e7106dfa2dcbf7e3bbf85fb7b546947edc2ff333b601c0fe8588
7
+ data.tar.gz: 64772edb624b4fbc99f26b82021fc01599cb3be26fe0bed4f9381c2079596c6bb0a78e1d4d1bf0a88027a4b315bfffb474f1d3374a6c07a667e2c721ef54bc2b
@@ -1,5 +1,3 @@
1
- require "paperclip-meta"
2
-
3
1
  module Paperclip
4
2
  module Meta
5
3
  if defined? ::Rails::Railtie
@@ -1,5 +1,5 @@
1
1
  module Paperclip
2
2
  module Meta
3
- VERSION = "2.0.0"
3
+ VERSION = "2.0.1"
4
4
  end
5
5
  end
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.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: 2015-12-29 00:00:00.000000000 Z
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.5'
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.5'
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: '10.4'
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: '10.4'
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.5.1
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
@@ -1,6 +0,0 @@
1
- .bundle
2
- .ruby-version
3
- Gemfile.lock
4
- pkg/*
5
- spec/gemfiles/*.lock
6
- spec/tmp/*/**
@@ -1,13 +0,0 @@
1
- inherit_from: .rubocop_todo.yml
2
-
3
- Style/AlignParameters:
4
- Enabled: false
5
-
6
- Style/MultilineOperationIndentation:
7
- Enabled: false
8
-
9
- Style/SignalException:
10
- EnforcedStyle: only_raise
11
-
12
- Style/StringLiterals:
13
- EnforcedStyle: double_quotes
@@ -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
-
@@ -1,12 +0,0 @@
1
- language: ruby
2
- cache: bundler
3
- sudo: false
4
- rvm:
5
- - 2.2
6
- - 2.1
7
- - 2.0.0
8
- gemfile:
9
- - spec/gemfiles/Gemfile.paperclip-4
10
- - spec/gemfiles/Gemfile.paperclip-3
11
- install:
12
- - 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,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
@@ -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
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'
@@ -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
@@ -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