dummy_image 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/README.md ADDED
@@ -0,0 +1,46 @@
1
+ # DummyImage
2
+
3
+ A tiny rack app to generate dummy images on the fly for development, or fall back to a url in other environments.
4
+
5
+ ## Requirements
6
+
7
+ * imagemagick (with 'convert' command line tool)
8
+
9
+ ## Installation
10
+
11
+ Add this line to your application's Gemfile:
12
+
13
+ gem 'dummy_image'
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install dummy_image
22
+
23
+ ## Usage
24
+
25
+ This is a rack app that responds to the following URLS:
26
+
27
+ /width.(format)
28
+ /width/height.(format)
29
+ /width/height/foreground.(format)
30
+ /width/height/foreground/background.(format)
31
+
32
+ Where *mount* is the location where the app is mounted
33
+
34
+ ## Rails Usage
35
+
36
+ In your config/routes.rb add:
37
+
38
+ mount DummyImage::Middleware, at: '/dummy'
39
+
40
+ ## Contributing
41
+
42
+ 1. Fork it
43
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
44
+ 3. Commit your changes (`git commit -am 'Added some feature'`)
45
+ 4. Push to the branch (`git push origin my-new-feature`)
46
+ 5. Create new Pull Request
@@ -0,0 +1,7 @@
1
+ require "dummy_image/version"
2
+
3
+ module DummyImage
4
+ autoload :Image, 'dummy_image/image'
5
+ autoload :Middleware, 'dummy_image/middleware'
6
+ autoload :RequestParser, 'dummy_image/request_parser'
7
+ end
@@ -0,0 +1,33 @@
1
+ require 'spec_helper'
2
+
3
+ describe DummyImage::Image do
4
+ let(:arguments) { stub( height: "200",
5
+ width: "200",
6
+ fgcolor: "333333",
7
+ bgcolor: "CCCCCC",
8
+ format: "png"
9
+ ) }
10
+ describe "#image_name" do
11
+ subject { described_class.new(arguments) }
12
+ it { subject.image_name.should == "200_200_333333_CCCCCC.png" }
13
+ end
14
+
15
+ describe ".find" do
16
+ let(:file_name) { "200_200_333333_CCCCCC.png" }
17
+ subject { described_class.find(arguments) }
18
+ context "when file exists" do
19
+ before do
20
+ File.stub(:exists?, "tmp/200_200_333333_CCCCCC.png").and_return(true)
21
+ end
22
+ it { subject.should == file_name }
23
+ end
24
+
25
+ context "when file does not exist" do
26
+ before do
27
+ File.stub(:exists?, "tmp/200_200_333333_CCCCCC.png").and_return(false)
28
+ DummyImage::Image::ImageBuilder.stub(:build, ["200", "200", "333333", "CCCCCC", "200 x 200", "tmp/200_200_333333_CCCCCC.png"]).and_return(true)
29
+ end
30
+ it { subject.should == file_name }
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,63 @@
1
+ require 'spec_helper'
2
+
3
+ describe DummyImage::RequestParser do
4
+ subject { described_class.new(path) }
5
+
6
+ context "with nothing specified" do
7
+ let(:path) { "/" }
8
+ its(:height) { should == "300" }
9
+ its(:width) { should == "300" }
10
+ its(:fgcolor) { should == "333333" }
11
+ its(:bgcolor) { should == "CCCCCC" }
12
+ end
13
+
14
+ context "with only height specified" do
15
+ let(:path) { "/200" }
16
+ its(:height) { should == "200" }
17
+ its(:width) { should == "200" }
18
+ its(:fgcolor) { should == "333333" }
19
+ its(:bgcolor) { should == "CCCCCC" }
20
+ end
21
+
22
+ context "with height, width specified" do
23
+ let(:path) { "/200/400" }
24
+ its(:height) { should == "200" }
25
+ its(:width) { should == "400" }
26
+ its(:fgcolor) { should == "333333" }
27
+ its(:bgcolor) { should == "CCCCCC" }
28
+ end
29
+
30
+ context "with height, width, foreground color specified" do
31
+ let(:path) { "/200/400/434343" }
32
+ its(:height) { should == "200" }
33
+ its(:width) { should == "400" }
34
+ its(:fgcolor) { should == "434343" }
35
+ its(:bgcolor) { should == "CCCCCC" }
36
+ end
37
+
38
+ context "with height, width, foreground color, background color specified" do
39
+ let(:path) { "/200/400/434343/505050" }
40
+ its(:height) { should == "200" }
41
+ its(:width) { should == "400" }
42
+ its(:fgcolor) { should == "434343" }
43
+ its(:bgcolor) { should == "505050" }
44
+ end
45
+
46
+ context "with image format specified" do
47
+ let(:path) { "/200/400/434343/505050.png" }
48
+ its(:height) { should == "200" }
49
+ its(:width) { should == "400" }
50
+ its(:fgcolor) { should == "434343" }
51
+ its(:bgcolor) { should == "505050" }
52
+ its(:format) { should == "png" }
53
+ end
54
+
55
+ context "with invalid image format specified" do
56
+ let(:path) { "/200/400/434343/505050.swf" }
57
+ its(:height) { should == "200" }
58
+ its(:width) { should == "400" }
59
+ its(:fgcolor) { should == "434343" }
60
+ its(:bgcolor) { should == "505050" }
61
+ its(:format) { should == "png" }
62
+ end
63
+ end
metadata ADDED
@@ -0,0 +1,78 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: dummy_image
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Dave Lyon
9
+ - Joshua Davey
10
+ autorequire:
11
+ bindir: bin
12
+ cert_chain: []
13
+ date: 2012-02-13 00:00:00.000000000 -06:00
14
+ default_executable:
15
+ dependencies:
16
+ - !ruby/object:Gem::Dependency
17
+ name: rspec
18
+ requirement: &2152732500 !ruby/object:Gem::Requirement
19
+ none: false
20
+ requirements:
21
+ - - ~>
22
+ - !ruby/object:Gem::Version
23
+ version: '2.8'
24
+ type: :development
25
+ prerelease: false
26
+ version_requirements: *2152732500
27
+ - !ruby/object:Gem::Dependency
28
+ name: rack-test
29
+ requirement: &2152748380 !ruby/object:Gem::Requirement
30
+ none: false
31
+ requirements:
32
+ - - =
33
+ - !ruby/object:Gem::Version
34
+ version: 0.6.1
35
+ type: :development
36
+ prerelease: false
37
+ version_requirements: *2152748380
38
+ description: Generate dummy images via Rack
39
+ email:
40
+ - dave@davelyon.net
41
+ - josh@joshuadavey.com
42
+ executables: []
43
+ extensions: []
44
+ extra_rdoc_files: []
45
+ files:
46
+ - lib/dummy_image.rb
47
+ - README.md
48
+ - spec/dummy_image/image_spec.rb
49
+ - spec/dummy_image/request_parser_spec.rb
50
+ has_rdoc: true
51
+ homepage: http://davelyon.net
52
+ licenses: []
53
+ post_install_message: Requires imagemagick with the 'convert' command
54
+ rdoc_options: []
55
+ require_paths:
56
+ - lib
57
+ required_ruby_version: !ruby/object:Gem::Requirement
58
+ none: false
59
+ requirements:
60
+ - - ! '>='
61
+ - !ruby/object:Gem::Version
62
+ version: '0'
63
+ required_rubygems_version: !ruby/object:Gem::Requirement
64
+ none: false
65
+ requirements:
66
+ - - ! '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ requirements:
70
+ - imagemagick (convert)
71
+ rubyforge_project:
72
+ rubygems_version: 1.6.2
73
+ signing_key:
74
+ specification_version: 3
75
+ summary: A tiny rack app to generate dummy images on the fly for development.
76
+ test_files:
77
+ - spec/dummy_image/image_spec.rb
78
+ - spec/dummy_image/request_parser_spec.rb