blank_image 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: ffd53f9c4cced7e596235c5cdbb85466fc6354cc
4
+ data.tar.gz: 04794932cfe89e0a93c8ecbfe7071725e004af94
5
+ SHA512:
6
+ metadata.gz: 1d631b413cba0677d71ec9654d6f817192143b3ebb5022dde1d8623eec5a52b1bd9756acc82c8cbe249f2fb51824d5cad4644142b22bf74ffb350583f325eb93
7
+ data.tar.gz: bb6867d2889d35b1920f14a74b6efe90c6263aaaec7660c51be244f58bc06cae99e26003dcb6eab8d7f1ef845c5c25d8e446896384792a7826cce8bbdbd6aa61
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright 2016 Shinnosuke Takeda
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.rdoc ADDED
@@ -0,0 +1,3 @@
1
+ = BlankImage
2
+
3
+ This project rocks and uses MIT-LICENSE.
data/Rakefile ADDED
@@ -0,0 +1,34 @@
1
+ begin
2
+ require 'bundler/setup'
3
+ rescue LoadError
4
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
5
+ end
6
+
7
+ require 'rdoc/task'
8
+
9
+ RDoc::Task.new(:rdoc) do |rdoc|
10
+ rdoc.rdoc_dir = 'rdoc'
11
+ rdoc.title = 'BlankImage'
12
+ rdoc.options << '--line-numbers'
13
+ rdoc.rdoc_files.include('README.rdoc')
14
+ rdoc.rdoc_files.include('lib/**/*.rb')
15
+ end
16
+
17
+
18
+
19
+
20
+
21
+
22
+ Bundler::GemHelper.install_tasks
23
+
24
+ require 'rake/testtask'
25
+
26
+ Rake::TestTask.new(:test) do |t|
27
+ t.libs << 'lib'
28
+ t.libs << 'test'
29
+ t.pattern = 'test/**/*_test.rb'
30
+ t.verbose = false
31
+ end
32
+
33
+
34
+ task default: :test
@@ -0,0 +1,12 @@
1
+ require 'blank_image/helper'
2
+
3
+ module BlankImage
4
+ class Engine < ::Rails::Engine
5
+ isolate_namespace BlankImage
6
+ initializer 'blank_image.action_controller_helpers' do
7
+ ActiveSupport.on_load :action_controller do
8
+ include BlankImage::Helper
9
+ end
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,20 @@
1
+ module BlankImage
2
+ module Helper
3
+ def render_blank_image(format: :gif)
4
+ case format.to_sym
5
+ when :gif
6
+ render(
7
+ text: BlankImage::Image::Gif.to_s,
8
+ content_type: BlankImage::Image::Gif.content_type,
9
+ )
10
+ when :png
11
+ render(
12
+ text: BlankImage::Image::Png.to_s,
13
+ content_type: BlankImage::Image::Png.content_type,
14
+ )
15
+ else
16
+ raise ArgumentError, "Unsupported format `#{format}`. `png` or `gif` are available."
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,27 @@
1
+ module BlankImage
2
+ module Image
3
+ class Gif
4
+ DATA = [
5
+ 0x47, 0x49, 0x46, 0x38, 0x39, 0x61, 0x01, 0x00, 0x01, 0x00,
6
+ 0x80, 0x00, 0x00, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x21,
7
+ 0xf9, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2c, 0x00, 0x00,
8
+ 0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00, 0x02, 0x02, 0x44,
9
+ 0x01, 0x00, 0x3b,
10
+ ].freeze
11
+
12
+ class << self
13
+ def data
14
+ DATA
15
+ end
16
+
17
+ def to_s
18
+ @to_s ||= data.pack('c*')
19
+ end
20
+
21
+ def content_type
22
+ 'image/gif'.freeze
23
+ end
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,32 @@
1
+ module BlankImage
2
+ module Image
3
+ class Png
4
+ DATA = [
5
+ 0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a, 0x00, 0x00,
6
+ 0x00, 0x0d, 0x49, 0x48, 0x44, 0x52, 0x00, 0x00, 0x00, 0x01,
7
+ 0x00, 0x00, 0x00, 0x01, 0x01, 0x03, 0x00, 0x00, 0x00, 0x25,
8
+ 0xdb, 0x56, 0xca, 0x00, 0x00, 0x00, 0x03, 0x50, 0x4c, 0x54,
9
+ 0x45, 0xff, 0x4d, 0x00, 0x5c, 0x35, 0x38, 0x7f, 0x00, 0x00,
10
+ 0x00, 0x01, 0x74, 0x52, 0x4e, 0x53, 0x00, 0x40, 0xe6, 0xd8,
11
+ 0x66, 0x00, 0x00, 0x00, 0x0a, 0x49, 0x44, 0x41, 0x54, 0x78,
12
+ 0x9c, 0x63, 0x62, 0x00, 0x00, 0x00, 0x06, 0x00, 0x03, 0x36,
13
+ 0x37, 0x7c, 0xa8, 0x00, 0x00, 0x00, 0x00, 0x49, 0x45, 0x4e,
14
+ 0x44, 0xae, 0x42, 0x60, 0x82,
15
+ ].freeze
16
+
17
+ class << self
18
+ def data
19
+ DATA
20
+ end
21
+
22
+ def to_s
23
+ @to_s ||= data.pack('c*')
24
+ end
25
+
26
+ def content_type
27
+ 'image/png'.freeze
28
+ end
29
+ end
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,3 @@
1
+ module BlankImage
2
+ VERSION = "1.0.0"
3
+ end
@@ -0,0 +1,5 @@
1
+ require 'blank_image/version'
2
+ require 'blank_image/image/png'
3
+ require 'blank_image/image/gif'
4
+ require 'blank_image/helper'
5
+ require 'blank_image/engine'
@@ -0,0 +1,4 @@
1
+ # desc "Explaining what the task does"
2
+ # task :blank_image do
3
+ # # Task goes here
4
+ # end
metadata ADDED
@@ -0,0 +1,68 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: blank_image
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - cnosuke
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-02-28 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rails
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '4.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '4.0'
27
+ description:
28
+ email:
29
+ - shinnosuke@gmail.com
30
+ executables: []
31
+ extensions: []
32
+ extra_rdoc_files: []
33
+ files:
34
+ - MIT-LICENSE
35
+ - README.rdoc
36
+ - Rakefile
37
+ - lib/blank_image.rb
38
+ - lib/blank_image/engine.rb
39
+ - lib/blank_image/helper.rb
40
+ - lib/blank_image/image/gif.rb
41
+ - lib/blank_image/image/png.rb
42
+ - lib/blank_image/version.rb
43
+ - lib/tasks/blank_image_tasks.rake
44
+ homepage: https://github.com/cnosuke/blank_image
45
+ licenses:
46
+ - MIT
47
+ metadata: {}
48
+ post_install_message:
49
+ rdoc_options: []
50
+ require_paths:
51
+ - lib
52
+ required_ruby_version: !ruby/object:Gem::Requirement
53
+ requirements:
54
+ - - ">="
55
+ - !ruby/object:Gem::Version
56
+ version: '0'
57
+ required_rubygems_version: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ requirements: []
63
+ rubyforge_project:
64
+ rubygems_version: 2.5.1
65
+ signing_key:
66
+ specification_version: 4
67
+ summary: Rails plugin to send blank image file (e.g. 1x1 GIF)
68
+ test_files: []