paperclip-dimension 0.2.1 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,15 +1,7 @@
1
1
  ---
2
- !binary "U0hBMQ==":
3
- metadata.gz: !binary |-
4
- ZmMwOTI0YTdlNWJkODUwMDczM2FjMDZlMTUyYzIwMDRlZmMzMTViMA==
5
- data.tar.gz: !binary |-
6
- ZWI5ZTc3NGNiNWM0MTRlNjM4MGI0NDYzMGEzNjM0MmU4NTJhZDRmYQ==
2
+ SHA1:
3
+ metadata.gz: 7121833dd0fe9f1b3db0c6ff4022a16d9456bd2c
4
+ data.tar.gz: 479db6c06ebb406319523c948245112767cfae10
7
5
  SHA512:
8
- metadata.gz: !binary |-
9
- NDYyNDBjY2E4Yzg4OGUyM2RjNGViMmRlZWZkYWRkYWY5NDQ2OGY5OWZlY2Nj
10
- M2Q3N2M0ZTY0YmQ0M2Q4Njk3ZjdjODA1NjBkY2Q3YzQ0Nzg2ZDg1YTE1Nzgy
11
- ZmVmMjhjNzUzYjk2ZTcwNDljNmE3OTU2ZDA5NjUxMzAyZTdjYzc=
12
- data.tar.gz: !binary |-
13
- ZTAzMDUzZGQ2YjAxZDZjMTkyZjM2OTdjNjEyNTUyYjk3ZjA0NGQ1NTBhMDQ4
14
- Y2U2ZTIxZDhjZGMxNzUxOTY2MzJlZGVkNTNjMDJiODk2NzVmN2EyY2FjYzZk
15
- NjcyN2RlNGVkNWQ4N2Q1YjdmYWM1MTYxNDE2M2IwNGRmYmYyZWY=
6
+ metadata.gz: 7ea2c5a35ded79db2784da8a8d405802418858c9b4638f76bfc9838dba6bba6d2e17b0f4b3d102b1d7e9693b1a7fe0a6a93b24a5cfe87ead081559fe3a965170
7
+ data.tar.gz: a4c980107021aeb1cb2224a96ab8ceda12126491265612c84c8473558f87993f5ca7a5580f2f45cd19d9ee9a54c9709c100159a21808408f3d3801efd021f70c
File without changes
@@ -32,19 +32,11 @@ module Paperclip
32
32
  end
33
33
 
34
34
  def save_dimensions_for(name)
35
- if self.class.respond_to?(:attachment_definitions)
36
- # for Paperclip version <= 3.4.2 and >= 3.5.1
37
- opts = self.class.attachment_definitions[name]
38
- else
39
- # for Paperclip version 3.5.0
40
- opts = ::Paperclip::Tasks::Attachments.definitions_for(self.class)[name]
41
- end
42
-
43
- styles = [:original]
44
- styles += opts[:styles].keys if opts[:styles]
45
35
  dimension_hash = {}
36
+ attachment = self.send(name)
37
+ styles = [:original]
38
+ styles += attachment.styles.keys if attachment.styles
46
39
  styles.each do |style|
47
- attachment = self.send name
48
40
  geo = ::Paperclip::Geometry.from_file(attachment.queued_for_write[style])
49
41
  dimension_hash[style.to_s] = [ geo.width.to_i, geo.height.to_i ]
50
42
  end
@@ -1,6 +1,6 @@
1
1
 
2
2
  module Paperclip
3
3
  module Dimension
4
- VERSION = '0.2.1'
4
+ VERSION = '0.3.0'.freeze
5
5
  end
6
6
  end
@@ -3,50 +3,64 @@ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
3
3
  describe Paperclip::Dimension do
4
4
  before(:each) do
5
5
  @p = Post.create!({
6
- :image =>File.open(File.dirname(__FILE__) + '/ruby.png'),
7
- :another_image => File.open(File.dirname(__FILE__) + '/ruby.png'),
8
- :image_no_styles => File.open(File.dirname(__FILE__) + '/ruby.png')
6
+ :image => File.open(File.dirname(__FILE__) + '/ruby.png'),
7
+ :another_image => File.open(File.dirname(__FILE__) + '/ruby.png'),
8
+ :image_with_proc => File.open(File.dirname(__FILE__) + '/ruby.png'),
9
+ :image_no_styles => File.open(File.dirname(__FILE__) + '/ruby.png')
9
10
  })
10
11
  @p.reload
11
12
  end
12
13
 
13
14
  it "should save dimensions" do
14
- @p.image_dimensions.should_not be_nil
15
- @p.another_image_dimensions.should_not be_nil
16
- @p.image_no_styles_dimensions.should_not be_nil
15
+ expect(@p.image_dimensions).to_not eq nil
16
+ expect(@p.another_image_dimensions).to_not eq nil
17
+ expect(@p.image_with_proc).to_not eq nil
18
+ expect(@p.image_no_styles_dimensions).to_not eq nil
17
19
  end
18
20
 
19
21
  it "should accept empty styles hash" do
20
- @p.image_no_styles_dimension.should == [995, 996]
21
- @p.image_no_styles_dimension(:original).should == [995, 996]
22
- @p.image_no_styles_dimension(:large).should be_nil
22
+ expect(@p.image_no_styles_dimension).to eq [995, 996]
23
+ expect(@p.image_no_styles_dimension(:original)).to eq [995, 996]
24
+ expect(@p.image_no_styles_dimension(:large)).to eq nil
23
25
  end
24
26
 
25
- it "should retreive dimensions correctly" do
26
- @p.image_dimension.should == [995, 996]
27
- @p.image_dimension(:original).should == [995, 996]
28
- @p.image_dimension(:large).should == [350, 350]
29
- @p.image_dimension(:medium).should == [150, 150]
30
- @p.image_dimension(:small).should == [30, 30]
31
-
32
- @p.another_image_dimension.should == [995, 996]
33
- @p.another_image_dimension(:original).should == [995, 996]
34
- @p.another_image_dimension(:large).should == [350, 350]
35
- @p.another_image_dimension(:medium).should == [150, 150]
36
- @p.another_image_dimension(:small).should == [30, 30]
27
+ it "should retrieve dimensions correctly" do
28
+ expect(@p.image_dimension).to eq [995, 996]
29
+ expect(@p.image_dimension(:original)).to eq [995, 996]
30
+ expect(@p.image_dimension(:large)).to eq [350, 350]
31
+ expect(@p.image_dimension(:medium)).to eq [150, 150]
32
+ expect(@p.image_dimension(:small)).to eq [30, 30]
33
+
34
+ expect(@p.another_image_dimension).to eq [995, 996]
35
+ expect(@p.another_image_dimension(:original)).to eq [995, 996]
36
+ expect(@p.another_image_dimension(:large)).to eq [350, 350]
37
+ expect(@p.another_image_dimension(:medium)).to eq [150, 150]
38
+ expect(@p.another_image_dimension(:small)).to eq [30, 30]
39
+
40
+ expect(@p.image_with_proc_dimension).to eq [995, 996]
41
+ expect(@p.image_with_proc_dimension(:original)).to eq [995, 996]
42
+ expect(@p.image_with_proc_dimension(:large)).to eq [350, 350]
43
+ expect(@p.image_with_proc_dimension(:medium)).to eq [150, 150]
44
+ expect(@p.image_with_proc_dimension(:small)).to eq [30, 30]
37
45
  end
38
46
 
39
- it "should retreive dimension strings correctly" do
40
- @p.image_dimension_str.should == "995x996"
41
- @p.image_dimension_str(:original).should == "995x996"
42
- @p.image_dimension_str(:large).should == "350x350"
43
- @p.image_dimension_str(:medium).should == "150x150"
44
- @p.image_dimension_str(:small).should == "30x30"
45
-
46
- @p.another_image_dimension_str.should == "995x996"
47
- @p.another_image_dimension_str(:original).should == "995x996"
48
- @p.another_image_dimension_str(:large).should == "350x350"
49
- @p.another_image_dimension_str(:medium).should == "150x150"
50
- @p.another_image_dimension_str(:small).should == "30x30"
47
+ it "should retrieve dimension strings correctly" do
48
+ expect(@p.image_dimension_str).to eq "995x996"
49
+ expect(@p.image_dimension_str(:original)).to eq "995x996"
50
+ expect(@p.image_dimension_str(:large)).to eq "350x350"
51
+ expect(@p.image_dimension_str(:medium)).to eq "150x150"
52
+ expect(@p.image_dimension_str(:small)).to eq "30x30"
53
+
54
+ expect(@p.another_image_dimension_str).to eq "995x996"
55
+ expect(@p.another_image_dimension_str(:original)).to eq "995x996"
56
+ expect(@p.another_image_dimension_str(:large)).to eq "350x350"
57
+ expect(@p.another_image_dimension_str(:medium)).to eq "150x150"
58
+ expect(@p.another_image_dimension_str(:small)).to eq "30x30"
59
+
60
+ expect(@p.image_with_proc_dimension_str).to eq "995x996"
61
+ expect(@p.image_with_proc_dimension_str(:original)).to eq "995x996"
62
+ expect(@p.image_with_proc_dimension_str(:large)).to eq "350x350"
63
+ expect(@p.image_with_proc_dimension_str(:medium)).to eq "150x150"
64
+ expect(@p.image_with_proc_dimension_str(:small)).to eq "30x30"
51
65
  end
52
66
  end
@@ -43,6 +43,7 @@ ActiveRecord::Schema.define do
43
43
  create_table :posts do |t|
44
44
  t.attachment :image
45
45
  t.attachment :another_image
46
+ t.attachment :image_with_proc
46
47
  t.attachment :image_no_styles
47
48
  end
48
49
  end
@@ -50,19 +51,30 @@ end
50
51
  # define model
51
52
  class Post < ActiveRecord::Base
52
53
  extend Paperclip::Dimension::ClassMethods
54
+
53
55
  has_attached_file :image, :styles => {
54
- :large => ['350x350>', :jpg],
55
- :medium => ['150x150>', :jpg],
56
- :small => ['30x30>', :jpg]
56
+ :large => ['350x350>', :jpg],
57
+ :medium => ['150x150>', :jpg],
58
+ :small => ['30x30>', :jpg]
57
59
  }
58
60
 
59
61
  has_attached_file :another_image, :styles => {
60
- :large => ['350x350>', :jpg],
61
- :medium => ['150x150>', :jpg],
62
- :small => ['30x30>', :jpg]
62
+ :large => ['350x350>', :jpg],
63
+ :medium => ['150x150>', :jpg],
64
+ :small => ['30x30>', :jpg]
63
65
  }
64
66
 
65
- has_attached_file :image_no_styles
66
- end
67
+ has_attached_file :image_with_proc, :styles => Proc.new { |obj|
68
+ {
69
+ :large => ['350x350>', :jpg],
70
+ :medium => ['150x150>', :jpg],
71
+ :small => ['30x30>', :jpg]
72
+ }
73
+ }
67
74
 
75
+ has_attached_file :image_no_styles
68
76
 
77
+ %i(image another_image image_with_proc image_no_styles).each do |field|
78
+ validates_attachment_content_type field, :content_type => ['image/png']
79
+ end
80
+ end
metadata CHANGED
@@ -1,133 +1,110 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: paperclip-dimension
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Aaron Qian
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-10-14 00:00:00.000000000 Z
11
+ date: 2016-08-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: paperclip
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ! '>='
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: !binary |-
20
- My4w
19
+ version: '3.0'
21
20
  type: :runtime
22
21
  prerelease: false
23
22
  version_requirements: !ruby/object:Gem::Requirement
24
23
  requirements:
25
- - - ! '>='
24
+ - - ">="
26
25
  - !ruby/object:Gem::Version
27
- version: !binary |-
28
- My4w
26
+ version: '3.0'
29
27
  - !ruby/object:Gem::Dependency
30
28
  name: activerecord
31
29
  requirement: !ruby/object:Gem::Requirement
32
30
  requirements:
33
- - - ! '>='
31
+ - - ">="
34
32
  - !ruby/object:Gem::Version
35
33
  version: '0'
36
34
  type: :development
37
35
  prerelease: false
38
36
  version_requirements: !ruby/object:Gem::Requirement
39
37
  requirements:
40
- - - ! '>='
38
+ - - ">="
41
39
  - !ruby/object:Gem::Version
42
40
  version: '0'
43
41
  - !ruby/object:Gem::Dependency
44
42
  name: sqlite3
45
43
  requirement: !ruby/object:Gem::Requirement
46
44
  requirements:
47
- - - ! '>='
45
+ - - ">="
48
46
  - !ruby/object:Gem::Version
49
47
  version: '0'
50
48
  type: :development
51
49
  prerelease: false
52
50
  version_requirements: !ruby/object:Gem::Requirement
53
51
  requirements:
54
- - - ! '>='
52
+ - - ">="
55
53
  - !ruby/object:Gem::Version
56
54
  version: '0'
57
55
  - !ruby/object:Gem::Dependency
58
56
  name: rspec
59
57
  requirement: !ruby/object:Gem::Requirement
60
58
  requirements:
61
- - - ! '>='
59
+ - - ">="
62
60
  - !ruby/object:Gem::Version
63
61
  version: '0'
64
62
  type: :development
65
63
  prerelease: false
66
64
  version_requirements: !ruby/object:Gem::Requirement
67
65
  requirements:
68
- - - ! '>='
66
+ - - ">="
69
67
  - !ruby/object:Gem::Version
70
68
  version: '0'
71
69
  - !ruby/object:Gem::Dependency
72
- name: yard
70
+ name: rake
73
71
  requirement: !ruby/object:Gem::Requirement
74
72
  requirements:
75
- - - ! '>='
73
+ - - ">="
76
74
  - !ruby/object:Gem::Version
77
75
  version: '0'
78
76
  type: :development
79
77
  prerelease: false
80
78
  version_requirements: !ruby/object:Gem::Requirement
81
79
  requirements:
82
- - - ! '>='
80
+ - - ">="
83
81
  - !ruby/object:Gem::Version
84
82
  version: '0'
85
83
  - !ruby/object:Gem::Dependency
86
- name: bundler
84
+ name: gem-release
87
85
  requirement: !ruby/object:Gem::Requirement
88
86
  requirements:
89
- - - ! '>='
87
+ - - ">="
90
88
  - !ruby/object:Gem::Version
91
89
  version: '0'
92
90
  type: :development
93
91
  prerelease: false
94
92
  version_requirements: !ruby/object:Gem::Requirement
95
93
  requirements:
96
- - - ! '>='
97
- - !ruby/object:Gem::Version
98
- version: '0'
99
- - !ruby/object:Gem::Dependency
100
- name: jeweler
101
- requirement: !ruby/object:Gem::Requirement
102
- requirements:
103
- - - ! '>='
104
- - !ruby/object:Gem::Version
105
- version: '0'
106
- type: :development
107
- prerelease: false
108
- version_requirements: !ruby/object:Gem::Requirement
109
- requirements:
110
- - - ! '>='
94
+ - - ">="
111
95
  - !ruby/object:Gem::Version
112
96
  version: '0'
113
97
  description: A simple plugin to persist image dimensions.
114
- email: aq1018@gmail.com
98
+ email:
99
+ - aq1018@gmail.com
115
100
  executables: []
116
101
  extensions: []
117
- extra_rdoc_files:
118
- - LICENSE.txt
119
- - README.md
102
+ extra_rdoc_files: []
120
103
  files:
121
- - .document
122
- - .rspec
123
- - Gemfile
124
- - LICENSE.txt
104
+ - LICENSE
125
105
  - README.md
126
- - Rakefile
127
- - VERSION
128
106
  - lib/paperclip-dimension.rb
129
107
  - lib/version.rb
130
- - paperclip-dimension.gemspec
131
108
  - spec/paperclip-dimension_spec.rb
132
109
  - spec/ruby.png
133
110
  - spec/spec_helper.rb
@@ -141,18 +118,21 @@ require_paths:
141
118
  - lib
142
119
  required_ruby_version: !ruby/object:Gem::Requirement
143
120
  requirements:
144
- - - ! '>='
121
+ - - ">="
145
122
  - !ruby/object:Gem::Version
146
123
  version: '0'
147
124
  required_rubygems_version: !ruby/object:Gem::Requirement
148
125
  requirements:
149
- - - ! '>='
126
+ - - ">="
150
127
  - !ruby/object:Gem::Version
151
128
  version: '0'
152
129
  requirements: []
153
130
  rubyforge_project:
154
- rubygems_version: 2.1.8
131
+ rubygems_version: 2.4.7
155
132
  signing_key:
156
133
  specification_version: 4
157
134
  summary: A simple plugin to persist image dimensions.
158
- test_files: []
135
+ test_files:
136
+ - spec/paperclip-dimension_spec.rb
137
+ - spec/ruby.png
138
+ - spec/spec_helper.rb
data/.document DELETED
@@ -1,5 +0,0 @@
1
- lib/**/*.rb
2
- bin/*
3
- -
4
- features/**/*.feature
5
- LICENSE.txt
data/.rspec DELETED
@@ -1 +0,0 @@
1
- --color
data/Gemfile DELETED
@@ -1,14 +0,0 @@
1
- source 'http://rubygems.org'
2
-
3
- gem "paperclip", '>= 3.0'
4
-
5
- # Add dependencies to develop your gem here.
6
- # Include everything needed to run rake, tests, features, etc.
7
- group :development do
8
- gem 'activerecord'
9
- gem 'sqlite3'
10
- gem 'rspec'
11
- gem 'yard'
12
- gem 'bundler'
13
- gem 'jeweler'
14
- end
data/Rakefile DELETED
@@ -1,42 +0,0 @@
1
- require 'rubygems'
2
- require 'bundler'
3
- begin
4
- Bundler.setup(:default, :development)
5
- rescue Bundler::BundlerError => e
6
- $stderr.puts e.message
7
- $stderr.puts "Run `bundle install` to install missing gems"
8
- exit e.status_code
9
- end
10
- require 'rake'
11
-
12
- $LOAD_PATH.unshift File.expand_path('../lib', __FILE__)
13
- require 'version'
14
-
15
- require 'jeweler'
16
- Jeweler::Tasks.new do |gem|
17
- gem.name = "paperclip-dimension"
18
- gem.homepage = "http://github.com/aq1018/paperclip-dimension"
19
- gem.license = "MIT"
20
- gem.summary = %Q{A simple plugin to persist image dimensions.}
21
- gem.description = %Q{A simple plugin to persist image dimensions.}
22
- gem.email = "aq1018@gmail.com"
23
- gem.authors = ["Aaron Qian"]
24
- gem.version = Paperclip::Dimension::VERSION
25
-
26
- # this directory is generated by running the test, and should be ignored...
27
- gem.files.exclude 'public'
28
- end
29
-
30
- Jeweler::RubygemsDotOrgTasks.new
31
-
32
- require 'rspec/core'
33
- require 'rspec/core/rake_task'
34
- RSpec::Core::RakeTask.new(:spec) do |spec|
35
- spec.pattern = FileList['spec/**/*_spec.rb']
36
- spec.rspec_opts = "--color --format progress"
37
- end
38
-
39
- task :default => :spec
40
-
41
- require 'yard'
42
- YARD::Rake::YardocTask.new
data/VERSION DELETED
@@ -1 +0,0 @@
1
- 0.2.0
@@ -1,71 +0,0 @@
1
- # Generated by jeweler
2
- # DO NOT EDIT THIS FILE DIRECTLY
3
- # Instead, edit Jeweler::Tasks in rakefile, and run 'rake gemspec'
4
- # -*- encoding: utf-8 -*-
5
- # stub: paperclip-dimension 0.2.1 ruby lib
6
-
7
- Gem::Specification.new do |s|
8
- s.name = "paperclip-dimension"
9
- s.version = "0.2.1"
10
-
11
- s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
12
- s.authors = ["Aaron Qian"]
13
- s.date = "2013-10-14"
14
- s.description = "A simple plugin to persist image dimensions."
15
- s.email = "aq1018@gmail.com"
16
- s.extra_rdoc_files = [
17
- "LICENSE.txt",
18
- "README.md"
19
- ]
20
- s.files = [
21
- ".document",
22
- ".rspec",
23
- "Gemfile",
24
- "LICENSE.txt",
25
- "README.md",
26
- "Rakefile",
27
- "VERSION",
28
- "lib/paperclip-dimension.rb",
29
- "lib/version.rb",
30
- "paperclip-dimension.gemspec",
31
- "spec/paperclip-dimension_spec.rb",
32
- "spec/ruby.png",
33
- "spec/spec_helper.rb"
34
- ]
35
- s.homepage = "http://github.com/aq1018/paperclip-dimension"
36
- s.licenses = ["MIT"]
37
- s.require_paths = ["lib"]
38
- s.rubygems_version = "2.1.8"
39
- s.summary = "A simple plugin to persist image dimensions."
40
-
41
- if s.respond_to? :specification_version then
42
- s.specification_version = 4
43
-
44
- if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
45
- s.add_runtime_dependency(%q<paperclip>, [">= 3.0"])
46
- s.add_development_dependency(%q<activerecord>, [">= 0"])
47
- s.add_development_dependency(%q<sqlite3>, [">= 0"])
48
- s.add_development_dependency(%q<rspec>, [">= 0"])
49
- s.add_development_dependency(%q<yard>, [">= 0"])
50
- s.add_development_dependency(%q<bundler>, [">= 0"])
51
- s.add_development_dependency(%q<jeweler>, [">= 0"])
52
- else
53
- s.add_dependency(%q<paperclip>, [">= 3.0"])
54
- s.add_dependency(%q<activerecord>, [">= 0"])
55
- s.add_dependency(%q<sqlite3>, [">= 0"])
56
- s.add_dependency(%q<rspec>, [">= 0"])
57
- s.add_dependency(%q<yard>, [">= 0"])
58
- s.add_dependency(%q<bundler>, [">= 0"])
59
- s.add_dependency(%q<jeweler>, [">= 0"])
60
- end
61
- else
62
- s.add_dependency(%q<paperclip>, [">= 3.0"])
63
- s.add_dependency(%q<activerecord>, [">= 0"])
64
- s.add_dependency(%q<sqlite3>, [">= 0"])
65
- s.add_dependency(%q<rspec>, [">= 0"])
66
- s.add_dependency(%q<yard>, [">= 0"])
67
- s.add_dependency(%q<bundler>, [">= 0"])
68
- s.add_dependency(%q<jeweler>, [">= 0"])
69
- end
70
- end
71
-