paperclip-dimension 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ ZmMwOTI0YTdlNWJkODUwMDczM2FjMDZlMTUyYzIwMDRlZmMzMTViMA==
5
+ data.tar.gz: !binary |-
6
+ ZWI5ZTc3NGNiNWM0MTRlNjM4MGI0NDYzMGEzNjM0MmU4NTJhZDRmYQ==
7
+ SHA512:
8
+ metadata.gz: !binary |-
9
+ NDYyNDBjY2E4Yzg4OGUyM2RjNGViMmRlZWZkYWRkYWY5NDQ2OGY5OWZlY2Nj
10
+ M2Q3N2M0ZTY0YmQ0M2Q4Njk3ZjdjODA1NjBkY2Q3YzQ0Nzg2ZDg1YTE1Nzgy
11
+ ZmVmMjhjNzUzYjk2ZTcwNDljNmE3OTU2ZDA5NjUxMzAyZTdjYzc=
12
+ data.tar.gz: !binary |-
13
+ ZTAzMDUzZGQ2YjAxZDZjMTkyZjM2OTdjNjEyNTUyYjk3ZjA0NGQ1NTBhMDQ4
14
+ Y2U2ZTIxZDhjZGMxNzUxOTY2MzJlZGVkNTNjMDJiODk2NzVmN2EyY2FjYzZk
15
+ NjcyN2RlNGVkNWQ4N2Q1YjdmYWM1MTYxNDE2M2IwNGRmYmYyZWY=
data/.document CHANGED
@@ -1,5 +1,5 @@
1
- lib/**/*.rb
2
- bin/*
3
- -
4
- features/**/*.feature
5
- LICENSE.txt
1
+ lib/**/*.rb
2
+ bin/*
3
+ -
4
+ features/**/*.feature
5
+ LICENSE.txt
data/.rspec CHANGED
@@ -1 +1 @@
1
- --color
1
+ --color
data/Gemfile CHANGED
@@ -1,14 +1,14 @@
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
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
@@ -1,20 +1,20 @@
1
- Copyright (c) 2011 Aaron Qian
2
-
3
- Permission is hereby granted, free of charge, to any person obtaining
4
- a copy of this software and associated documentation files (the
5
- "Software"), to deal in the Software without restriction, including
6
- without limitation the rights to use, copy, modify, merge, publish,
7
- distribute, sublicense, and/or sell copies of the Software, and to
8
- permit persons to whom the Software is furnished to do so, subject to
9
- the following conditions:
10
-
11
- The above copyright notice and this permission notice shall be
12
- included in all copies or substantial portions of the Software.
13
-
14
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
1
+ Copyright (c) 2011 Aaron Qian
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md CHANGED
@@ -1,131 +1,134 @@
1
- paperclip-dimension
2
- ===================
3
-
4
- This gem is the improved version of `mongoid_paperclip_image_dimension` that is ORM agnostic.
5
-
6
- This is a simple gem to persist image dimensions of originals and thumbnails.
7
- It works for both s3 and filesystem storages.
8
- This lib is based on [this stackoverflow.com article](http://stackoverflow.com/questions/4065295/paperclip-saving-the-images-dimentions-width-height).
9
-
10
- Install
11
- -------
12
-
13
- You can simply install from rubygems:
14
-
15
- ```ruby
16
- gem install paperclip-dimension
17
- require 'paperclip-dimension'
18
- ```
19
-
20
- or in Gemfile:
21
-
22
- ```ruby
23
- gem 'paperclip-dimension'
24
- ```
25
-
26
- Setup
27
- -----
28
-
29
- You need to make sure the following is in place:
30
-
31
- * `Paperclip::Glue` is included in your model.
32
- * `<attachment>_dimensions` attribute is requried to operate.
33
-
34
-
35
- **Rails & ActiveRecord Migration**
36
-
37
- `paperclip` gives you the ability to create migrations with `attachment`.
38
- For example:
39
-
40
- ```ruby
41
- class CreatePosts < ActiveRecord::Migration
42
- def up
43
- create_table :posts do |t|
44
- t.attachment :image
45
- end
46
- end
47
- end
48
- ```
49
-
50
- This creates the following columns:
51
-
52
- * image_file_name
53
- * image_file_size
54
- * image_content_type
55
- * image_updated_at
56
-
57
- `paperclip-dimension` will create an extra field for you: `image_dimensions` when the above migration is run.
58
-
59
- **Mongoid**
60
-
61
- Exmaple Mongoid setup:
62
-
63
- ```ruby
64
- class Post
65
- include Mongoid::Document
66
- include Paperclip::Glue
67
-
68
- # The usual paperclip fields
69
- field :image_file_name, :type => String
70
- field :image_file_size, :type => Integer
71
- field :image_content_type, :type => String
72
- field :image_updated_at, :type => Time
73
-
74
- # The extra paperclip-dimension field
75
- field :image_dimensions, :type => Hash
76
-
77
- # call #has_attached_file like usual
78
- has_attached_file :image, :styles => {
79
- :large => ['350x350>', :jpg],
80
- :medium => ['150x150>', :jpg],
81
- :small => ['30x30>', :jpg]
82
- }
83
- end
84
- ```
85
-
86
- Usage
87
- -----
88
-
89
- This gem gives your model a few extra helpers:
90
-
91
- ```ruby
92
- # suppose we used the example from above
93
- p = Post.first
94
-
95
- # retrieve image dimensions for all sytles
96
- p.image_dimensions
97
- # {
98
- # 'original' => [2048, 1024],
99
- # 'large' => [350, 175],
100
- # 'medium' => [150, 75],
101
- # 'small' => [30, 15]
102
- # }
103
-
104
- # get image dimension as an array
105
- p.image_dimension # [2048, 1024]
106
- p.image_dimension(:original) # [2048, 1024]
107
- p.image_dimension(:large) # [350, 175]
108
-
109
- # get it now as a string
110
- p.image_dimension_str # "2048x1024"
111
- p.image_dimension_str(:original) # "2048x1024"
112
- p.image_dimension_str(:large) # "350x175"
113
- ```
114
-
115
- Contributing to paperclip-dimension
116
- -----------------------------------
117
-
118
- * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
119
- * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
120
- * Fork the project
121
- * Start a feature/bugfix branch
122
- * Commit and push until you are happy with your contribution
123
- * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
124
- * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
125
-
126
- Copyright
127
- ---------
128
-
129
- Copyright (c) 2011 Aaron Qian. See LICENSE.txt for
130
- further details.
131
-
1
+ paperclip-dimension
2
+ ===================
3
+
4
+ This gem used to be called `mongoid_paperclip_image_dimension`, but it has been improved to be ORM agnostic.
5
+ Hence, the name of this gem is now simply `paperclip-dimension`.
6
+ If you were using `mongoid_paperclip_image_dimension` before, you can safely upgrade to this gem.
7
+
8
+
9
+ This is a simple gem to persist image dimensions of originals and thumbnails.
10
+ It works for both s3 and filesystem storages.
11
+ This lib is based on [this stackoverflow.com article](http://stackoverflow.com/questions/4065295/paperclip-saving-the-images-dimentions-width-height).
12
+
13
+ Install
14
+ -------
15
+
16
+ You can simply install from rubygems:
17
+
18
+ ```ruby
19
+ gem install paperclip-dimension
20
+ require 'paperclip-dimension'
21
+ ```
22
+
23
+ or in Gemfile:
24
+
25
+ ```ruby
26
+ gem 'paperclip-dimension'
27
+ ```
28
+
29
+ Setup
30
+ -----
31
+
32
+ You need to make sure the following is in place:
33
+
34
+ * `Paperclip::Glue` is included in your model.
35
+ * `<attachment>_dimensions` attribute is requried to operate.
36
+
37
+
38
+ **Rails & ActiveRecord Migration**
39
+
40
+ `paperclip` gives you the ability to create migrations with `attachment`.
41
+ For example:
42
+
43
+ ```ruby
44
+ class CreatePosts < ActiveRecord::Migration
45
+ def up
46
+ create_table :posts do |t|
47
+ t.attachment :image
48
+ end
49
+ end
50
+ end
51
+ ```
52
+
53
+ This creates the following columns:
54
+
55
+ * image_file_name
56
+ * image_file_size
57
+ * image_content_type
58
+ * image_updated_at
59
+
60
+ `paperclip-dimension` will create an extra field for you: `image_dimensions` when the above migration is run.
61
+
62
+ **Mongoid**
63
+
64
+ Exmaple Mongoid setup:
65
+
66
+ ```ruby
67
+ class Post
68
+ include Mongoid::Document
69
+ include Paperclip::Glue
70
+
71
+ # The usual paperclip fields
72
+ field :image_file_name, :type => String
73
+ field :image_file_size, :type => Integer
74
+ field :image_content_type, :type => String
75
+ field :image_updated_at, :type => Time
76
+
77
+ # The extra paperclip-dimension field
78
+ field :image_dimensions, :type => Hash
79
+
80
+ # call #has_attached_file like usual
81
+ has_attached_file :image, :styles => {
82
+ :large => ['350x350>', :jpg],
83
+ :medium => ['150x150>', :jpg],
84
+ :small => ['30x30>', :jpg]
85
+ }
86
+ end
87
+ ```
88
+
89
+ Usage
90
+ -----
91
+
92
+ This gem gives your model a few extra helpers:
93
+
94
+ ```ruby
95
+ # suppose we used the example from above
96
+ p = Post.first
97
+
98
+ # retrieve image dimensions for all sytles
99
+ p.image_dimensions
100
+ # {
101
+ # 'original' => [2048, 1024],
102
+ # 'large' => [350, 175],
103
+ # 'medium' => [150, 75],
104
+ # 'small' => [30, 15]
105
+ # }
106
+
107
+ # get image dimension as an array
108
+ p.image_dimension # [2048, 1024]
109
+ p.image_dimension(:original) # [2048, 1024]
110
+ p.image_dimension(:large) # [350, 175]
111
+
112
+ # get it now as a string
113
+ p.image_dimension_str # "2048x1024"
114
+ p.image_dimension_str(:original) # "2048x1024"
115
+ p.image_dimension_str(:large) # "350x175"
116
+ ```
117
+
118
+ Contributing to paperclip-dimension
119
+ -----------------------------------
120
+
121
+ * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
122
+ * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
123
+ * Fork the project
124
+ * Start a feature/bugfix branch
125
+ * Commit and push until you are happy with your contribution
126
+ * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
127
+ * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
128
+
129
+ Copyright
130
+ ---------
131
+
132
+ Copyright (c) 2011 Aaron Qian. See LICENSE.txt for
133
+ further details.
134
+
data/Rakefile CHANGED
@@ -1,38 +1,42 @@
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
- require 'jeweler'
13
- Jeweler::Tasks.new do |gem|
14
- gem.name = "paperclip-dimension"
15
- gem.homepage = "http://github.com/aq1018/paperclip-dimension"
16
- gem.license = "MIT"
17
- gem.summary = %Q{A simple plugin to persist image dimensions.}
18
- gem.description = %Q{A simple plugin to persist image dimensions.}
19
- gem.email = "aq1018@gmail.com"
20
- gem.authors = ["Aaron Qian"]
21
-
22
- # this directory is generated by running the test, and should be ignored...
23
- gem.files.exclude 'public'
24
- end
25
-
26
- Jeweler::RubygemsDotOrgTasks.new
27
-
28
- require 'rspec/core'
29
- require 'rspec/core/rake_task'
30
- RSpec::Core::RakeTask.new(:spec) do |spec|
31
- spec.pattern = FileList['spec/**/*_spec.rb']
32
- spec.rspec_opts = "--color --format progress"
33
- end
34
-
35
- task :default => :spec
36
-
37
- require 'yard'
38
- YARD::Rake::YardocTask.new
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
@@ -1,63 +1,70 @@
1
- require 'paperclip'
2
-
3
- module Paperclip
4
- module Dimension
5
- def self.included(klass)
6
- klass.extend Paperclip::Dimension::ClassMethods
7
- end
8
-
9
- module ClassMethods
10
- # override has_attached_file to:
11
- # 1). save dimensions on post process
12
- # 2). create dimension accessors
13
- def has_attached_file name, options={}
14
- super
15
-
16
- class_eval <<-END
17
- # for ActiveRecord
18
- serialize :#{name}_dimensions, Hash if respond_to?(:serialize)
19
-
20
- def #{name}_dimension(style=:original)
21
- self.#{name}_dimensions[style]
22
- end
23
-
24
- def #{name}_dimension_str(style=:original)
25
- dim = #{name}_dimension(style)
26
- dim ? dim.join('x') : nil
27
- end
28
- END
29
-
30
- send "after_#{name}_post_process", lambda { save_dimensions_for(name) }
31
- end
32
- end
33
-
34
- def save_dimensions_for(name)
35
- opts = self.class.attachment_definitions[name]
36
-
37
- styles = opts[:styles].keys + [:original]
38
- dimension_hash = {}
39
- styles.each do |style|
40
- attachment = self.send name
41
- geo = ::Paperclip::Geometry.from_file(attachment.queued_for_write[style])
42
- dimension_hash[style] = [ geo.width.to_i, geo.height.to_i ]
43
- end
44
- self.send "#{name}_dimensions=", dimension_hash
45
- end
46
- end
47
-
48
- module Glue
49
- class << self
50
- def included_with_dimension(klass)
51
- included_without_dimension(klass)
52
- klass.send :include, Paperclip::Dimension
53
- end
54
-
55
- alias :included_without_dimension :included
56
- alias :included :included_with_dimension
57
- end
58
- end
59
-
60
- module Schema
61
- COLUMNS[:dimensions] = :string
62
- end
63
- end
1
+ require 'paperclip'
2
+
3
+ module Paperclip
4
+ module Dimension
5
+ def self.included(klass)
6
+ klass.extend Paperclip::Dimension::ClassMethods
7
+ end
8
+
9
+ module ClassMethods
10
+ # override has_attached_file to:
11
+ # 1). save dimensions on post process
12
+ # 2). create dimension accessors
13
+ def has_attached_file name, options={}
14
+ super
15
+
16
+ class_eval <<-END
17
+ # for ActiveRecord
18
+ serialize :#{name}_dimensions, Hash if respond_to?(:serialize)
19
+
20
+ def #{name}_dimension(style=:original)
21
+ self.#{name}_dimensions[style.to_s]
22
+ end
23
+
24
+ def #{name}_dimension_str(style=:original)
25
+ dim = #{name}_dimension(style.to_s)
26
+ dim ? dim.join('x') : nil
27
+ end
28
+ END
29
+
30
+ send "after_#{name}_post_process", lambda { save_dimensions_for(name) }
31
+ end
32
+ end
33
+
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
+ dimension_hash = {}
46
+ styles.each do |style|
47
+ attachment = self.send name
48
+ geo = ::Paperclip::Geometry.from_file(attachment.queued_for_write[style])
49
+ dimension_hash[style.to_s] = [ geo.width.to_i, geo.height.to_i ]
50
+ end
51
+ self.send "#{name}_dimensions=", dimension_hash
52
+ end
53
+ end
54
+
55
+ module Glue
56
+ class << self
57
+ def included_with_dimension(klass)
58
+ included_without_dimension(klass)
59
+ klass.send :include, Paperclip::Dimension
60
+ end
61
+
62
+ alias :included_without_dimension :included
63
+ alias :included :included_with_dimension
64
+ end
65
+ end
66
+
67
+ module Schema
68
+ COLUMNS[:dimensions] = :string
69
+ end
70
+ end
@@ -0,0 +1,6 @@
1
+
2
+ module Paperclip
3
+ module Dimension
4
+ VERSION = '0.2.1'
5
+ end
6
+ end
@@ -1,69 +1,71 @@
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
-
6
- Gem::Specification.new do |s|
7
- s.name = "paperclip-dimension"
8
- s.version = "0.2.0"
9
-
10
- s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
- s.authors = ["Aaron Qian"]
12
- s.date = "2013-01-10"
13
- s.description = "A simple plugin to persist image dimensions."
14
- s.email = "aq1018@gmail.com"
15
- s.extra_rdoc_files = [
16
- "LICENSE.txt",
17
- "README.md"
18
- ]
19
- s.files = [
20
- ".document",
21
- ".rspec",
22
- "Gemfile",
23
- "LICENSE.txt",
24
- "README.md",
25
- "Rakefile",
26
- "VERSION",
27
- "lib/paperclip-dimension.rb",
28
- "paperclip-dimension.gemspec",
29
- "spec/paperclip-dimension_spec.rb",
30
- "spec/ruby.png",
31
- "spec/spec_helper.rb"
32
- ]
33
- s.homepage = "http://github.com/aq1018/paperclip-dimension"
34
- s.licenses = ["MIT"]
35
- s.require_paths = ["lib"]
36
- s.rubygems_version = "1.8.24"
37
- s.summary = "A simple plugin to persist image dimensions."
38
-
39
- if s.respond_to? :specification_version then
40
- s.specification_version = 3
41
-
42
- if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
43
- s.add_runtime_dependency(%q<paperclip>, [">= 3.0"])
44
- s.add_development_dependency(%q<activerecord>, [">= 0"])
45
- s.add_development_dependency(%q<sqlite3>, [">= 0"])
46
- s.add_development_dependency(%q<rspec>, [">= 0"])
47
- s.add_development_dependency(%q<yard>, [">= 0"])
48
- s.add_development_dependency(%q<bundler>, [">= 0"])
49
- s.add_development_dependency(%q<jeweler>, [">= 0"])
50
- else
51
- s.add_dependency(%q<paperclip>, [">= 3.0"])
52
- s.add_dependency(%q<activerecord>, [">= 0"])
53
- s.add_dependency(%q<sqlite3>, [">= 0"])
54
- s.add_dependency(%q<rspec>, [">= 0"])
55
- s.add_dependency(%q<yard>, [">= 0"])
56
- s.add_dependency(%q<bundler>, [">= 0"])
57
- s.add_dependency(%q<jeweler>, [">= 0"])
58
- end
59
- else
60
- s.add_dependency(%q<paperclip>, [">= 3.0"])
61
- s.add_dependency(%q<activerecord>, [">= 0"])
62
- s.add_dependency(%q<sqlite3>, [">= 0"])
63
- s.add_dependency(%q<rspec>, [">= 0"])
64
- s.add_dependency(%q<yard>, [">= 0"])
65
- s.add_dependency(%q<bundler>, [">= 0"])
66
- s.add_dependency(%q<jeweler>, [">= 0"])
67
- end
68
- end
69
-
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
+
@@ -1,44 +1,52 @@
1
- require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
-
3
- describe Paperclip::Dimension do
4
- before(:each) do
5
- @p = Post.create!({
6
- :image =>File.open(File.dirname(__FILE__) + '/ruby.png'),
7
- :another_image => File.open(File.dirname(__FILE__) + '/ruby.png')
8
- })
9
- @p.reload
10
- end
11
-
12
- it "should save dimensions" do
13
- @p.image_dimensions.should_not be_nil
14
- @p.another_image_dimensions.should_not be_nil
15
- end
16
-
17
- it "should retreive dimensions correctly" do
18
- @p.image_dimension.should == [995, 996]
19
- @p.image_dimension(:original).should == [995, 996]
20
- @p.image_dimension(:large).should == [350, 350]
21
- @p.image_dimension(:medium).should == [150, 150]
22
- @p.image_dimension(:small).should == [30, 30]
23
-
24
- @p.another_image_dimension.should == [995, 996]
25
- @p.another_image_dimension(:original).should == [995, 996]
26
- @p.another_image_dimension(:large).should == [350, 350]
27
- @p.another_image_dimension(:medium).should == [150, 150]
28
- @p.another_image_dimension(:small).should == [30, 30]
29
- end
30
-
31
- it "should retreive dimension strings correctly" do
32
- @p.image_dimension_str.should == "995x996"
33
- @p.image_dimension_str(:original).should == "995x996"
34
- @p.image_dimension_str(:large).should == "350x350"
35
- @p.image_dimension_str(:medium).should == "150x150"
36
- @p.image_dimension_str(:small).should == "30x30"
37
-
38
- @p.another_image_dimension_str.should == "995x996"
39
- @p.another_image_dimension_str(:original).should == "995x996"
40
- @p.another_image_dimension_str(:large).should == "350x350"
41
- @p.another_image_dimension_str(:medium).should == "150x150"
42
- @p.another_image_dimension_str(:small).should == "30x30"
43
- end
44
- end
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+
3
+ describe Paperclip::Dimension do
4
+ before(:each) do
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')
9
+ })
10
+ @p.reload
11
+ end
12
+
13
+ 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
17
+ end
18
+
19
+ 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
23
+ end
24
+
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]
37
+ end
38
+
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"
51
+ end
52
+ end
@@ -1,59 +1,68 @@
1
- $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
2
- $LOAD_PATH.unshift(File.dirname(__FILE__))
3
-
4
- require 'rspec'
5
- require 'active_record'
6
- require 'paperclip'
7
- require 'paperclip-dimension'
8
-
9
- # mocking Rails.root & Rails.env used in Paperclip::Interploration
10
- module Rails
11
- def self.root
12
- File.dirname(__FILE__) + "/.."
13
- end
14
-
15
- def self.env
16
- "test"
17
- end
18
-
19
- def self.logger
20
- nil
21
- end
22
- end
23
-
24
- ActiveRecord::Base.send(:include, Paperclip::Glue)
25
-
26
- # turn off logging
27
- Paperclip.options[:log] = false
28
-
29
- # use sqlite3 memory store
30
- ActiveRecord::Base.establish_connection({
31
- :adapter => 'sqlite3',
32
- :database => ':memory:'
33
- })
34
-
35
- # create tables
36
- ActiveRecord::Schema.define do
37
- create_table :posts do |t|
38
- t.attachment :image
39
- t.attachment :another_image
40
- end
41
- end
42
-
43
- # define model
44
- class Post < ActiveRecord::Base
45
- extend Paperclip::Dimension::ClassMethods
46
- has_attached_file :image, :styles => {
47
- :large => ['350x350>', :jpg],
48
- :medium => ['150x150>', :jpg],
49
- :small => ['30x30>', :jpg]
50
- }
51
-
52
- has_attached_file :another_image, :styles => {
53
- :large => ['350x350>', :jpg],
54
- :medium => ['150x150>', :jpg],
55
- :small => ['30x30>', :jpg]
56
- }
57
- end
58
-
59
-
1
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
2
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
3
+
4
+ require 'rspec'
5
+ require 'active_record'
6
+ require 'paperclip'
7
+ require 'paperclip-dimension'
8
+ require 'rbconfig'
9
+
10
+ # Hack for running Paperclip on Windows
11
+ if RbConfig::CONFIG['host_os'] =~ /mswin|mingw|cygwin/
12
+ Paperclip.options[:command_path] = 'C:\\Program Files\\ImageMagick'
13
+ end
14
+
15
+ # mocking Rails.root & Rails.env used in Paperclip::Interploration
16
+ module Rails
17
+ def self.root
18
+ File.dirname(__FILE__) + "/.."
19
+ end
20
+
21
+ def self.env
22
+ "test"
23
+ end
24
+
25
+ def self.logger
26
+ nil
27
+ end
28
+ end
29
+
30
+ ActiveRecord::Base.send(:include, Paperclip::Glue)
31
+
32
+ # turn off logging
33
+ Paperclip.options[:log] = false
34
+
35
+ # use sqlite3 memory store
36
+ ActiveRecord::Base.establish_connection({
37
+ :adapter => 'sqlite3',
38
+ :database => ':memory:'
39
+ })
40
+
41
+ # create tables
42
+ ActiveRecord::Schema.define do
43
+ create_table :posts do |t|
44
+ t.attachment :image
45
+ t.attachment :another_image
46
+ t.attachment :image_no_styles
47
+ end
48
+ end
49
+
50
+ # define model
51
+ class Post < ActiveRecord::Base
52
+ extend Paperclip::Dimension::ClassMethods
53
+ has_attached_file :image, :styles => {
54
+ :large => ['350x350>', :jpg],
55
+ :medium => ['150x150>', :jpg],
56
+ :small => ['30x30>', :jpg]
57
+ }
58
+
59
+ has_attached_file :another_image, :styles => {
60
+ :large => ['350x350>', :jpg],
61
+ :medium => ['150x150>', :jpg],
62
+ :small => ['30x30>', :jpg]
63
+ }
64
+
65
+ has_attached_file :image_no_styles
66
+ end
67
+
68
+
metadata CHANGED
@@ -1,36 +1,34 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: paperclip-dimension
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
5
- prerelease:
4
+ version: 0.2.1
6
5
  platform: ruby
7
6
  authors:
8
7
  - Aaron Qian
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-01-10 00:00:00.000000000 Z
11
+ date: 2013-10-14 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: paperclip
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
17
  - - ! '>='
20
18
  - !ruby/object:Gem::Version
21
- version: '3.0'
19
+ version: !binary |-
20
+ My4w
22
21
  type: :runtime
23
22
  prerelease: false
24
23
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
24
  requirements:
27
25
  - - ! '>='
28
26
  - !ruby/object:Gem::Version
29
- version: '3.0'
27
+ version: !binary |-
28
+ My4w
30
29
  - !ruby/object:Gem::Dependency
31
30
  name: activerecord
32
31
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
32
  requirements:
35
33
  - - ! '>='
36
34
  - !ruby/object:Gem::Version
@@ -38,7 +36,6 @@ dependencies:
38
36
  type: :development
39
37
  prerelease: false
40
38
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
39
  requirements:
43
40
  - - ! '>='
44
41
  - !ruby/object:Gem::Version
@@ -46,7 +43,6 @@ dependencies:
46
43
  - !ruby/object:Gem::Dependency
47
44
  name: sqlite3
48
45
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
46
  requirements:
51
47
  - - ! '>='
52
48
  - !ruby/object:Gem::Version
@@ -54,7 +50,6 @@ dependencies:
54
50
  type: :development
55
51
  prerelease: false
56
52
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
53
  requirements:
59
54
  - - ! '>='
60
55
  - !ruby/object:Gem::Version
@@ -62,7 +57,6 @@ dependencies:
62
57
  - !ruby/object:Gem::Dependency
63
58
  name: rspec
64
59
  requirement: !ruby/object:Gem::Requirement
65
- none: false
66
60
  requirements:
67
61
  - - ! '>='
68
62
  - !ruby/object:Gem::Version
@@ -70,7 +64,6 @@ dependencies:
70
64
  type: :development
71
65
  prerelease: false
72
66
  version_requirements: !ruby/object:Gem::Requirement
73
- none: false
74
67
  requirements:
75
68
  - - ! '>='
76
69
  - !ruby/object:Gem::Version
@@ -78,7 +71,6 @@ dependencies:
78
71
  - !ruby/object:Gem::Dependency
79
72
  name: yard
80
73
  requirement: !ruby/object:Gem::Requirement
81
- none: false
82
74
  requirements:
83
75
  - - ! '>='
84
76
  - !ruby/object:Gem::Version
@@ -86,7 +78,6 @@ dependencies:
86
78
  type: :development
87
79
  prerelease: false
88
80
  version_requirements: !ruby/object:Gem::Requirement
89
- none: false
90
81
  requirements:
91
82
  - - ! '>='
92
83
  - !ruby/object:Gem::Version
@@ -94,7 +85,6 @@ dependencies:
94
85
  - !ruby/object:Gem::Dependency
95
86
  name: bundler
96
87
  requirement: !ruby/object:Gem::Requirement
97
- none: false
98
88
  requirements:
99
89
  - - ! '>='
100
90
  - !ruby/object:Gem::Version
@@ -102,7 +92,6 @@ dependencies:
102
92
  type: :development
103
93
  prerelease: false
104
94
  version_requirements: !ruby/object:Gem::Requirement
105
- none: false
106
95
  requirements:
107
96
  - - ! '>='
108
97
  - !ruby/object:Gem::Version
@@ -110,7 +99,6 @@ dependencies:
110
99
  - !ruby/object:Gem::Dependency
111
100
  name: jeweler
112
101
  requirement: !ruby/object:Gem::Requirement
113
- none: false
114
102
  requirements:
115
103
  - - ! '>='
116
104
  - !ruby/object:Gem::Version
@@ -118,7 +106,6 @@ dependencies:
118
106
  type: :development
119
107
  prerelease: false
120
108
  version_requirements: !ruby/object:Gem::Requirement
121
- none: false
122
109
  requirements:
123
110
  - - ! '>='
124
111
  - !ruby/object:Gem::Version
@@ -139,6 +126,7 @@ files:
139
126
  - Rakefile
140
127
  - VERSION
141
128
  - lib/paperclip-dimension.rb
129
+ - lib/version.rb
142
130
  - paperclip-dimension.gemspec
143
131
  - spec/paperclip-dimension_spec.rb
144
132
  - spec/ruby.png
@@ -146,29 +134,25 @@ files:
146
134
  homepage: http://github.com/aq1018/paperclip-dimension
147
135
  licenses:
148
136
  - MIT
137
+ metadata: {}
149
138
  post_install_message:
150
139
  rdoc_options: []
151
140
  require_paths:
152
141
  - lib
153
142
  required_ruby_version: !ruby/object:Gem::Requirement
154
- none: false
155
143
  requirements:
156
144
  - - ! '>='
157
145
  - !ruby/object:Gem::Version
158
146
  version: '0'
159
- segments:
160
- - 0
161
- hash: -3262180631021356690
162
147
  required_rubygems_version: !ruby/object:Gem::Requirement
163
- none: false
164
148
  requirements:
165
149
  - - ! '>='
166
150
  - !ruby/object:Gem::Version
167
151
  version: '0'
168
152
  requirements: []
169
153
  rubyforge_project:
170
- rubygems_version: 1.8.24
154
+ rubygems_version: 2.1.8
171
155
  signing_key:
172
- specification_version: 3
156
+ specification_version: 4
173
157
  summary: A simple plugin to persist image dimensions.
174
158
  test_files: []