dummy_magick 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 5be0ae0005f921f076b960f53e54cd7ba245da07
4
+ data.tar.gz: 7898bb74835f5bfacf94b4451369c428e7a74972
5
+ SHA512:
6
+ metadata.gz: 25e97b1c21b0bc0d7205ec8943e37144a97a2ce47f1593d59f3049ff5e47cde33b332e2d78ab876d7b04808a7a26442843064a3b0c0e45827e9a0aa16fa45438
7
+ data.tar.gz: 2710670a0db6d7429218e7d0d27d64711a39325b78ab3b6f9d501f3734b8046e2aae6d143e27dbdb5e2f315ad8a50c5ac2aa0316c12e2deae5694e4f374c208d
@@ -0,0 +1,14 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ *.bundle
11
+ *.so
12
+ *.o
13
+ *.a
14
+ mkmf.log
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
@@ -0,0 +1,13 @@
1
+ inherit_from: .rubocop_todo.yml
2
+
3
+ Metrics/LineLength:
4
+ Max: 120
5
+
6
+ Style/RegexpLiteral:
7
+ MaxSlashes: 0
8
+
9
+ Style/Documentation:
10
+ Enabled: false
11
+
12
+ Style/AsciiComments:
13
+ Enabled: false
@@ -0,0 +1,6 @@
1
+ # This configuration was generated by `rubocop --auto-gen-config`
2
+ # on 2015-02-03 00:00:01 +0900 using RuboCop version 0.28.0.
3
+ # The point is for the user to remove these configuration records
4
+ # one by one as the offenses are removed from the code base.
5
+ # Note that changes in the inspected code, or installation of new
6
+ # versions of RuboCop, may require this file to be generated again.
@@ -0,0 +1,16 @@
1
+ language: ruby
2
+ cache: bundler
3
+ rvm:
4
+ - 1.9.3
5
+ - 2.0
6
+ - 2.1
7
+ - 2.2
8
+ - rbx
9
+ - jruby
10
+ - ruby-head
11
+ matrix:
12
+ allow_failures:
13
+ - rvm: ruby-head
14
+ before_install:
15
+ - sudo apt-get install imagemagick libmagickcore-dev libmagickwand-dev
16
+ - sudo apt-get install -qq graphicsmagick
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in dummy_magick.gemspec
4
+ gemspec
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2015 unosk
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.
@@ -0,0 +1,65 @@
1
+ # DummyMagick
2
+
3
+ Generate a dummy image file for development
4
+
5
+ [![Build Status](https://travis-ci.org/unosk/dummy_magick.svg?branch=master)](https://travis-ci.org/unosk/dummy_magick)
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ group :development, :test do
13
+ gem 'dummy_magick'
14
+ end
15
+ ```
16
+
17
+ And then execute:
18
+
19
+ ```
20
+ $ bundle
21
+ ```
22
+
23
+ ## Usage
24
+
25
+ ```ruby
26
+ ##
27
+ # Generate a dummy image file
28
+ #
29
+ # @param width [Integer] The width of the image.
30
+ # @param height [Integer] The height of the image.
31
+ # @param format [String] The file extension of the image format. Like 'jpg', 'png', 'gif' etc.
32
+ # @return [File]
33
+ DummyMagick.dummy_image_file(100, 100, :png)
34
+ ```
35
+
36
+ ### with CarrierWave
37
+ ```ruby
38
+ class User < ActiveRecord::Base
39
+ mount_uploader :avatar, AvatarUploader
40
+ end
41
+
42
+ User.new
43
+ User.avator = DummyMagick.dummy_image_file(100, 100, :png)
44
+ User.save!
45
+ ```
46
+
47
+ ### on RSpec Controller Test
48
+ ```ruby
49
+ image_file = DummyMagick.dummy_image_file(100, 100, :png)
50
+ post :create, avatar: fixture_file_upload(image_file.path, 'image/png')
51
+ ```
52
+
53
+ ### on Capybara
54
+ ```ruby
55
+ image_file = DummyMagick.dummy_image_file(100, 100, :png)
56
+ attach_file 'Upload file', image_file.path
57
+ ```
58
+
59
+ ## Contributing
60
+
61
+ 1. Fork it ( https://github.com/unosk/dummy_magick/fork )
62
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
63
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
64
+ 4. Push to the branch (`git push origin my-new-feature`)
65
+ 5. Create a new Pull Request
@@ -0,0 +1,6 @@
1
+ require 'bundler/gem_tasks'
2
+ require 'rspec/core/rake_task'
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task default: :spec
@@ -0,0 +1,28 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'dummy_magick/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'dummy_magick'
8
+ spec.version = DummyMagick::VERSION
9
+ spec.authors = ['unosk']
10
+ spec.email = ['unosk.s@gmail.com']
11
+ spec.summary = 'Generate a dummy image file for development'
12
+ spec.description = 'Generate a dummy image file for development'
13
+ spec.homepage = 'https://github.com/unosk/dummy_magick'
14
+ spec.license = 'MIT'
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ['lib']
20
+
21
+ spec.add_dependency 'mini_magick'
22
+
23
+ spec.add_development_dependency 'bundler', '~> 1.7'
24
+ spec.add_development_dependency 'rake', '~> 10.0'
25
+ spec.add_development_dependency 'rspec'
26
+ spec.add_development_dependency 'rubocop'
27
+ spec.add_development_dependency 'yard'
28
+ end
@@ -0,0 +1,21 @@
1
+ require 'dummy_magick/version'
2
+ require 'base64'
3
+ require 'mini_magick'
4
+
5
+ module DummyMagick
6
+ IMAGE_1X1 = Base64.decode64('R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==').freeze
7
+
8
+ ##
9
+ # Generate a dummy image file
10
+ #
11
+ # @param width [Integer] The width of the image.
12
+ # @param height [Integer] The height of the image.
13
+ # @param format [String] The file extension of the image format. Like 'jpg', 'png', 'gif' etc.
14
+ # @return [File]
15
+ def self.dummy_image_file(width, height, format = :jpg)
16
+ img = ::MiniMagick::Image.create('gif') { |f| f.write IMAGE_1X1 }
17
+ img.resize("#{width}x#{height}!")
18
+ img.format(format)
19
+ File.new(img.path)
20
+ end
21
+ end
@@ -0,0 +1,3 @@
1
+ module DummyMagick
2
+ VERSION = '0.0.1'
3
+ end
@@ -0,0 +1,25 @@
1
+ require 'spec_helper'
2
+
3
+ describe DummyMagick do
4
+ it 'has a version number' do
5
+ expect(DummyMagick::VERSION).not_to be nil
6
+ end
7
+
8
+ describe '.dummy_image_file' do
9
+ subject { DummyMagick.dummy_image_file(10, 20, :png) }
10
+ let(:image) { MiniMagick::Image.new(subject.path) }
11
+
12
+ it 'returns an instance of File' do
13
+ expect(subject).to be_an_instance_of(File)
14
+ end
15
+
16
+ it 'generates an image with given size' do
17
+ expect(image.dimensions).to eq [10, 20]
18
+ end
19
+
20
+ it 'generates an image with given format' do
21
+ expect(File.extname(subject.path)).to eq '.png'
22
+ expect(image.mime_type).to eq 'image/png'
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,2 @@
1
+ $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
2
+ require 'dummy_magick'
metadata ADDED
@@ -0,0 +1,145 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: dummy_magick
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - unosk
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-02-02 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: mini_magick
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.7'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.7'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '10.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '10.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rubocop
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: yard
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ description: Generate a dummy image file for development
98
+ email:
99
+ - unosk.s@gmail.com
100
+ executables: []
101
+ extensions: []
102
+ extra_rdoc_files: []
103
+ files:
104
+ - ".gitignore"
105
+ - ".rspec"
106
+ - ".rubocop.yml"
107
+ - ".rubocop_todo.yml"
108
+ - ".travis.yml"
109
+ - Gemfile
110
+ - LICENSE.txt
111
+ - README.md
112
+ - Rakefile
113
+ - dummy_magick.gemspec
114
+ - lib/dummy_magick.rb
115
+ - lib/dummy_magick/version.rb
116
+ - spec/dummy_magick_spec.rb
117
+ - spec/spec_helper.rb
118
+ homepage: https://github.com/unosk/dummy_magick
119
+ licenses:
120
+ - MIT
121
+ metadata: {}
122
+ post_install_message:
123
+ rdoc_options: []
124
+ require_paths:
125
+ - lib
126
+ required_ruby_version: !ruby/object:Gem::Requirement
127
+ requirements:
128
+ - - ">="
129
+ - !ruby/object:Gem::Version
130
+ version: '0'
131
+ required_rubygems_version: !ruby/object:Gem::Requirement
132
+ requirements:
133
+ - - ">="
134
+ - !ruby/object:Gem::Version
135
+ version: '0'
136
+ requirements: []
137
+ rubyforge_project:
138
+ rubygems_version: 2.4.5
139
+ signing_key:
140
+ specification_version: 4
141
+ summary: Generate a dummy image file for development
142
+ test_files:
143
+ - spec/dummy_magick_spec.rb
144
+ - spec/spec_helper.rb
145
+ has_rdoc: