grayscale_paperclip_processor 0.0.1

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.
data/.gitignore ADDED
@@ -0,0 +1,18 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ coverage
6
+ InstalledFiles
7
+ lib/bundler/man
8
+ pkg
9
+ rdoc
10
+ spec/reports
11
+ test/tmp
12
+ test/version_tmp
13
+ tmp
14
+
15
+ # YARD artifacts
16
+ .yardoc
17
+ _yardoc
18
+ doc/
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in grayscale_paperclip_processor.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Андрей [ws70]
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,22 @@
1
+ grayscale_paperclip_processor
2
+ =============================
3
+
4
+ Grayscale processor for Paperclip gem
5
+
6
+ Usage:
7
+
8
+ Gemfile:
9
+
10
+ gem "grayscale_paperclip_processor"
11
+
12
+ Model:
13
+
14
+ has_attached_file :data,
15
+ :processors => [:watermark],
16
+ :styles => {
17
+ :grayscale => {
18
+ :processors => [:grayscale],
19
+ :geometry => "361x226!"
20
+ }
21
+ :normal => "361x226#",
22
+ ...
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,21 @@
1
+ # -*- encoding: utf-8 -*-
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'grayscale_paperclip_processor/version'
5
+
6
+ Gem::Specification.new do |gem|
7
+ gem.name = "grayscale_paperclip_processor"
8
+ gem.version = GrayscalePaperclipProcessor::VERSION
9
+ gem.authors = ["Андрей [ws70]"]
10
+ gem.email = ["railscode@gmail.com"]
11
+ gem.description = "Grayscale processor for Paperclip gem"
12
+ gem.summary = "Grayscale processor for Paperclip gem"
13
+ gem.homepage = "https://github.com/vav/grayscale_paperclip_processor"
14
+
15
+ gem.files = `git ls-files`.split($/)
16
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
17
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
18
+ gem.require_paths = ["lib"]
19
+
20
+ gem.add_dependency "paperclip", ">= 2.8.0"
21
+ end
@@ -0,0 +1,3 @@
1
+ require "grayscale_paperclip_processor/engine"
2
+ require "grayscale_paperclip_processor/grayscale"
3
+ require "grayscale_paperclip_processor/version"
@@ -0,0 +1,6 @@
1
+ module GrayscalePaperclipProcessor
2
+ module Rails
3
+ class Engine < ::Rails::Engine
4
+ end
5
+ end
6
+ end
@@ -0,0 +1,24 @@
1
+ # coding: utf-8
2
+ module Paperclip
3
+ class Grayscale < Processor
4
+ def initialize file, options = {}, attachment = nil
5
+ super
6
+ @file = file
7
+ @geometry = options[:geometry]
8
+ @current_format = File.extname(@file.path)
9
+ @basename = File.basename(@file.path, @current_format)
10
+ end
11
+
12
+ def make
13
+ dst = Tempfile.new(@basename)
14
+ dst.binmode
15
+ command = "#{File.expand_path(@file.path)} -resize #{@geometry} -colorspace Gray #{File.expand_path(dst.path)}"
16
+ begin
17
+ success = Paperclip.run("convert", command)
18
+ rescue PaperclipCommandLineError
19
+ raise PaperclipError, "There was an error converting the image to grayscale for #{@basename}"
20
+ end
21
+ dst
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,3 @@
1
+ module GrayscalePaperclipProcessor
2
+ VERSION = "0.0.1"
3
+ end
metadata ADDED
@@ -0,0 +1,71 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: grayscale_paperclip_processor
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Андрей [ws70]
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-03-28 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: paperclip
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: 2.8.0
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: 2.8.0
30
+ description: Grayscale processor for Paperclip gem
31
+ email:
32
+ - railscode@gmail.com
33
+ executables: []
34
+ extensions: []
35
+ extra_rdoc_files: []
36
+ files:
37
+ - .gitignore
38
+ - Gemfile
39
+ - LICENSE.txt
40
+ - README.md
41
+ - Rakefile
42
+ - grayscale_paperclip_processor.gemspec
43
+ - lib/grayscale_paperclip_processor.rb
44
+ - lib/grayscale_paperclip_processor/engine.rb
45
+ - lib/grayscale_paperclip_processor/grayscale.rb
46
+ - lib/grayscale_paperclip_processor/version.rb
47
+ homepage: https://github.com/vav/grayscale_paperclip_processor
48
+ licenses: []
49
+ post_install_message:
50
+ rdoc_options: []
51
+ require_paths:
52
+ - lib
53
+ required_ruby_version: !ruby/object:Gem::Requirement
54
+ none: false
55
+ requirements:
56
+ - - ! '>='
57
+ - !ruby/object:Gem::Version
58
+ version: '0'
59
+ required_rubygems_version: !ruby/object:Gem::Requirement
60
+ none: false
61
+ requirements:
62
+ - - ! '>='
63
+ - !ruby/object:Gem::Version
64
+ version: '0'
65
+ requirements: []
66
+ rubyforge_project:
67
+ rubygems_version: 1.8.23
68
+ signing_key:
69
+ specification_version: 3
70
+ summary: Grayscale processor for Paperclip gem
71
+ test_files: []