cssquirt 0.0.1.pre.1

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: 189fe8598ad2da9cfafbc99352fda8b14c1da8bb
4
+ data.tar.gz: 249ff1354f027eb4af8b061f800b4de300177d0e
5
+ SHA512:
6
+ metadata.gz: 87e09b3a07ae0f854263bb9f261c2853a36987b88e3d56093f453bcdd49b60ddf405140c40b9f800a3e8ff3bfaf1e60b56e0c1770e878cdb8b7160f6f48757cb
7
+ data.tar.gz: 72ae4ba583147126a8474ef52b493e27912668913973121736cfe8b1c2e79d7d48263da6d1c0a9d2044ae6a9d28aa70db688d1c6ad6d0b19b5e4d501be42cc27
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/.travis.yml ADDED
@@ -0,0 +1,6 @@
1
+ language: ruby
2
+ rvm:
3
+ - 1.8.7
4
+ - 1.9.3
5
+ - 2.0.0
6
+
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in cssquirt.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Matthew Rothenberg
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,94 @@
1
+ # CSSquirt
2
+
3
+ [![Gem Version](https://badge.fury.io/rb/cssquirt.png)](http://badge.fury.io/rb/cssquirt)
4
+ [![Build Status](https://travis-ci.org/mroth/cssquirt.png?branch=master)](https://travis-ci.org/mroth/cssquirt)
5
+
6
+ Embeds images (or directories of images) directly into CSS via the Data URI scheme.
7
+
8
+ This technique is commonly used to reduce HTTP requests as an easier alternative to CSS sprite sheets.
9
+
10
+ Some notes/caveats for using this technique:
11
+ - Be sure your web server is configured to gzip your HTML/CSS content, and any size overhead should disapear.
12
+ - The maximum size supported is 32KB per image.
13
+
14
+ For more information see [this article](#).
15
+
16
+ ## Installation
17
+
18
+ Add this line to your application's Gemfile:
19
+
20
+ gem 'cssquirt'
21
+
22
+ And then execute:
23
+
24
+ $ bundle
25
+
26
+ Or install it yourself as:
27
+
28
+ $ gem install cssquirt
29
+
30
+ ## Usage
31
+
32
+ ### As a library
33
+ Just `require 'cssquirt'` and you should be good to go.
34
+
35
+ #### Working on individual files
36
+ Example from an IRB session:
37
+
38
+ >> myImg = CSSquirt::ImageFile.new 'spec/samples/example.gif'
39
+ => #<CSSquirt::ImageFile:0x007fbffb3af580 @file_path="spec/samples/example.gif">
40
+
41
+ >> myImg.as_img_tag
42
+ => "<img src='data:image/gif;base64,R0lGODlhNQAmAKL/AP///wC1/wghSsDAwAAAAAAAAAAAAAAAACH5BAEAAAMALAAAAAA1ACYAAAP4OLrc/jDKSau9lRDMOwlbJ1IfOJ6QFphoqwgl657wumozg1vxre2tDzDSs4F8QVuIaFQah50aaOlQNa3K3e8ikE6rxduVAPgBztRJNwbEjp/kcxmdVnun4edVXo5DKXdNgmJPfBpydSSDi4RZhj8CHoyLYYd9BF2RHGx5V4M/QpginJ1OkzcDfxMlmDClU5SgrBhCmWuTlbJXF7Uvt43AP7g8IJoLv0WkjBrGq60Oa26wR8vPFZkQv57UgpDNdhKBpt3MXTkLnbmt5ucKpLKytu06N7Zstuzz6MX4tfL69Kz5YgaQSL5jBwsywPYgocJjDyNKnEiRQQIAO3x6ChocsO0CwoUUFEKcSLGiRQ8RAAA7' />"
43
+
44
+ >> myImg.as_css_background
45
+ => "background: url(data:image/gif;base64,R0lGODlhNQAmAKL/AP///wC1/wghSsDAwAAAAAAAAAAAAAAAACH5BAEAAAMALAAAAAA1ACYAAAP4OLrc/jDKSau9lRDMOwlbJ1IfOJ6QFphoqwgl657wumozg1vxre2tDzDSs4F8QVuIaFQah50aaOlQNa3K3e8ikE6rxduVAPgBztRJNwbEjp/kcxmdVnun4edVXo5DKXdNgmJPfBpydSSDi4RZhj8CHoyLYYd9BF2RHGx5V4M/QpginJ1OkzcDfxMlmDClU5SgrBhCmWuTlbJXF7Uvt43AP7g8IJoLv0WkjBrGq60Oa26wR8vPFZkQv57UgpDNdhKBpt3MXTkLnbmt5ucKpLKytu06N7Zstuzz6MX4tfL69Kz5YgaQSL5jBwsywPYgocJjDyNKnEiRQQIAO3x6ChocsO0CwoUUFEKcSLGiRQ8RAAA7) no-repeat;"
46
+
47
+ >> puts myImg.as_css_background_with_class
48
+ .example_gif {
49
+ background: url(data:image/gif;base64,R0lGODlhNQAmAKL/AP///wC1/wghSsDAwAAAAAAAAAAAAAAAACH5BAEAAAMALAAAAAA1ACYAAAP4OLrc/jDKSau9lRDMOwlbJ1IfOJ6QFphoqwgl657wumozg1vxre2tDzDSs4F8QVuIaFQah50aaOlQNa3K3e8ikE6rxduVAPgBztRJNwbEjp/kcxmdVnun4edVXo5DKXdNgmJPfBpydSSDi4RZhj8CHoyLYYd9BF2RHGx5V4M/QpginJ1OkzcDfxMlmDClU5SgrBhCmWuTlbJXF7Uvt43AP7g8IJoLv0WkjBrGq60Oa26wR8vPFZkQv57UgpDNdhKBpt3MXTkLnbmt5ucKpLKytu06N7Zstuzz6MX4tfL69Kz5YgaQSL5jBwsywPYgocJjDyNKnEiRQQIAO3x6ChocsO0CwoUUFEKcSLGiRQ8RAAA7) no-repeat;
50
+ }
51
+ => nil
52
+
53
+ >> puts myImg.as_css_background_with_class('funkytown')
54
+ .funkytown {
55
+ background: url(data:image/gif;base64,R0lGODlhNQAmAKL/AP///wC1/wghSsDAwAAAAAAAAAAAAAAAACH5BAEAAAMALAAAAAA1ACYAAAP4OLrc/jDKSau9lRDMOwlbJ1IfOJ6QFphoqwgl657wumozg1vxre2tDzDSs4F8QVuIaFQah50aaOlQNa3K3e8ikE6rxduVAPgBztRJNwbEjp/kcxmdVnun4edVXo5DKXdNgmJPfBpydSSDi4RZhj8CHoyLYYd9BF2RHGx5V4M/QpginJ1OkzcDfxMlmDClU5SgrBhCmWuTlbJXF7Uvt43AP7g8IJoLv0WkjBrGq60Oa26wR8vPFZkQv57UgpDNdhKBpt3MXTkLnbmt5ucKpLKytu06N7Zstuzz6MX4tfL69Kz5YgaQSL5jBwsywPYgocJjDyNKnEiRQQIAO3x6ChocsO0CwoUUFEKcSLGiRQ8RAAA7) no-repeat;
56
+ }
57
+ => nil
58
+
59
+ #### Working on groups of files
60
+ Use `CSSquirt::ImageFileList` which just extends the goodness of a [`Rake::FileList`](http://rake.rubyforge.org/classes/Rake/FileList.html) and adds some batch processing. The batch processing is smart enough to report errors to you on specific files via `STDERR` but will just omit those files from the final output.
61
+
62
+ >> filez=CSSquirt::ImageFileList.new('samples/*')
63
+ => ["samples/16px_rocket.png", "samples/64px_bomb.png", "samples/example.gif", "samples/example.jpg", "samples/example.mp3", "samples/example.svg", "samples/toobig.gif"]
64
+
65
+ >> filez.exclude('samples/*.png')
66
+ => ["samples/example.gif", "samples/example.jpg", "samples/example.mp3", "samples/example.svg", "samples/toobig.gif"]
67
+
68
+ >> doc = filez.to_css
69
+ WARNING: skipped file - File samples/example.mp3 reports type application/octet-stream which is not a supported image format.
70
+ WARNING: skipped file - File samples/toobig.gif is too big - 104710 greater than 32768.
71
+
72
+ >> puts doc
73
+ /* Generated with CSSquirt! (http://github.com/mroth/cssquirt/) */
74
+ .example_gif {
75
+ background: url(data:image/gif;base64,R0lGODlhN[snip...]) no-repeat;
76
+ }
77
+ .example_jpg {
78
+ background: url(data:image/jpeg;base64,/9j/4AAQS[snip...]) no-repeat;
79
+ }
80
+ .example_svg {
81
+ background: url(data:image/svg+xml;base64,PD94bWwgdmV[snip...]) no-repeat;
82
+ }
83
+ => nil
84
+
85
+ ### From the command line
86
+ Coming soon!
87
+
88
+ ## Contributing
89
+
90
+ 1. Fork it
91
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
92
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
93
+ 4. Push to the branch (`git push origin my-new-feature`)
94
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,5 @@
1
+ require "bundler/gem_tasks"
2
+
3
+ require 'rspec/core/rake_task'
4
+ RSpec::Core::RakeTask.new(:spec)
5
+ task :default => :spec
data/cssquirt.gemspec ADDED
@@ -0,0 +1,24 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'cssquirt/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "cssquirt"
8
+ spec.version = CSSquirt::VERSION
9
+ spec.authors = ["Matthew Rothenberg"]
10
+ spec.email = ["mrothenberg@gmail.com"]
11
+ spec.description = %q{Embeds images (or directories of images) directly into CSS via the Data URI scheme.}
12
+ spec.summary = %q{Embeds images (or directories of images) directly into CSS via the Data URI scheme.}
13
+ spec.homepage = "http://github.com/mroth/cssquirt"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files`.split($/)
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_development_dependency "bundler", "~> 1.3"
22
+ spec.add_development_dependency "rspec"
23
+ spec.add_dependency "rake"
24
+ end
@@ -0,0 +1,41 @@
1
+ require 'rake'
2
+ module CSSquirt
3
+ class ImageFileList < Rake::FileList
4
+
5
+ # Public: return a CSS document of all images
6
+ #
7
+ # prefix - an optional String to automatically prefix all class names with, useful
8
+ # for namespacing, etc. Default: nil.
9
+ # header - a optional Boolean value representing whether or not to include the
10
+ # "generated by" credit in the header of the CSS document. Default: true.
11
+ #
12
+ # Returns a CSS document as a String.
13
+ def to_css(prefix=nil, header=true)
14
+ css_classes = self.zip(self.to_images).map do |item|
15
+ item_filelist,item_imagefile = item[0],item[1]
16
+ item_imagefile.as_css_background_with_class( prefix + "-#{item_filelist.pathmap('%n')}" )
17
+ end
18
+
19
+ header_msg = "/* Generated with CSSquirt! (http://github.com/mroth/cssquirt/) */\n"
20
+ header_msg = '' if header == false
21
+ header_msg + css_classes.join("\n")
22
+ end
23
+
24
+ # Public: map the filelist to ImageFiles, handling any errors.
25
+ # For now, this just reports errors to STDERR so they can be noted.
26
+ #
27
+ # Returns an Array of ImageFiles.
28
+ def to_images
29
+ image_map = []
30
+ self.each do |file|
31
+ begin
32
+ image_map << ImageFile.new(file)
33
+ rescue Exception => e
34
+ $stderr.puts "WARNING: skipped file - #{e.message}"
35
+ end
36
+ end
37
+ image_map
38
+ end
39
+
40
+ end
41
+ end
@@ -0,0 +1,93 @@
1
+ module CSSquirt
2
+ class ImageFile
3
+ require "base64"
4
+
5
+ MAX_FILE_SIZE = 32768
6
+ VALID_FILE_MIMETYPES = ['image/png', 'image/jpeg', 'image/gif', 'image/svg+xml']
7
+
8
+ # Public: Intialize a new ImageFile object.
9
+ #
10
+ # file_path - A String representing the relative path to an image file.
11
+ #
12
+ # Raises IOError if the file cannot be found.
13
+ # Raises TypeError if the file is not a valid image file.
14
+ # Raises RangeError if the file is larger than the maximum size that can be
15
+ # encoded as a Data URI (default: 32 kilobytes).
16
+ def initialize(file_path)
17
+ @file_path = file_path
18
+ raise IOError, "No file found at #{file_path}!" unless File.exist? file_path
19
+
20
+ unless self.valid_image_format?
21
+ raise TypeError, "File #{file_path} reports type #{self.filetype} which is not a supported image format."
22
+ end
23
+
24
+ file_size = File.size(@file_path)
25
+ if file_size > MAX_FILE_SIZE
26
+ raise RangeError, "File #{file_path} is too big - #{file_size} greater than #{MAX_FILE_SIZE}."
27
+ end
28
+ end
29
+
30
+ # Public: Returns the MIME type for the file.
31
+ #
32
+ # Examples
33
+ #
34
+ # ImageFile.new('example.png')
35
+ # # => 'image/png'
36
+ # ImageFile.new('example.svg')
37
+ # # => 'image/svg+xml'
38
+ #
39
+ # Returns a String representation of the MIME type.
40
+ def filetype
41
+ `file --mime-type -b #{@file_path}`.chomp
42
+ end
43
+
44
+ # Public: Formats a data-uri based HTML IMG tag for the file.
45
+ #
46
+ # Returns the entire IMG tag as a String.
47
+ def as_img_tag()
48
+ "<img src='#{self.encode}' />"
49
+ end
50
+
51
+ # Public: Formats a CSS background image rule for the file, and wraps
52
+ # it in a class definition.
53
+ #
54
+ # klass - The name of the class to use for the CSS rule. Optional. If
55
+ # ommitted, the default will the basename of the file path.
56
+ #
57
+ # Returns the class wrapped CSS background rule as a String.
58
+ def as_css_background_with_class(klass=nil)
59
+ klass=File.basename(@file_path).tr('.','_') unless klass
60
+ ".#{klass} {\n #{self.as_css_background}\n}"
61
+ end
62
+
63
+ # Public: Formats a CSS background image rule for the file.
64
+ #
65
+ # Returns the CSS background rule as a String.
66
+ def as_css_background()
67
+ "background: url(#{self.encode}) no-repeat;"
68
+ end
69
+
70
+ # Public: Encodes file into a CSS string representation.
71
+ #
72
+ # Returns the Base64 encoded String with filetype information embedded.
73
+ def encode()
74
+ "data:#{self.filetype};base64," + self.raw_encode
75
+ end
76
+
77
+ # Public: file into its raw Base64 string representation.
78
+ #
79
+ # Returns the Base64 encoded String.
80
+ def raw_encode()
81
+ return Base64.encode64(File.read @file_path).delete("\n") if RUBY_VERSION < "1.9.0"
82
+ Base64.strict_encode64(File.read @file_path)
83
+ end
84
+
85
+ protected
86
+ # Protected: is the file of an image format we support?
87
+ #
88
+ # Returns a Boolean representing image format validity.
89
+ def valid_image_format?
90
+ VALID_FILE_MIMETYPES.include? self.filetype
91
+ end
92
+ end
93
+ end
@@ -0,0 +1,3 @@
1
+ module CSSquirt
2
+ VERSION = "0.0.1.pre.1"
3
+ end
data/lib/cssquirt.rb ADDED
@@ -0,0 +1,6 @@
1
+ require "cssquirt/version"
2
+ require "cssquirt/image_file"
3
+ require "cssquirt/file_list"
4
+
5
+ module CSSquirt
6
+ end
@@ -0,0 +1,5 @@
1
+ require "spec_helper"
2
+
3
+ describe CSSquirt do
4
+
5
+ end
@@ -0,0 +1,26 @@
1
+ require "spec_helper"
2
+
3
+ describe ImageFileList do
4
+ describe "#to_css" do
5
+ it "should handle mapping a prefix to autogenerated CSS classes" do
6
+ ImageFileList.new('spec/samples/example.gif').to_css('premium', false).should match(/\.premium-example \{/)
7
+ end
8
+ it "should add a generator message to the top of files by default" do
9
+ ImageFileList.new().to_css().split('\n').first.should eq("/* Generated with CSSquirt! (http://github.com/mroth/cssquirt/) */\n")
10
+ end
11
+ it "should allow the generator message to be disabled" do
12
+ ImageFileList.new().to_css(nil, false).split('\n').first.should_not eq("/* Generated with CSSquirt! (http://github.com/mroth/cssquirt/) */\n")
13
+ end
14
+ end
15
+
16
+ describe "#to_images" do
17
+ it "should return an array of all ImageFiles" do
18
+ fl = ImageFileList.new('spec/samples/*.png', 'spec/samples/*.gif').to_images
19
+ fl.each { |file| file.should be_kind_of(ImageFile) }
20
+ end
21
+ it "should eat Exceptions and output errors to STDERR instead" do
22
+ bad_eggs = 'spec/samples/*.mp3', 'spec/samples/toobig.gif'
23
+ lambda { ImageFileList.new(bad_eggs).to_images }.should_not raise_error
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,85 @@
1
+ require "spec_helper"
2
+
3
+ describe ImageFile do
4
+
5
+ describe ".new" do
6
+ it "should return an ImageFile object" do
7
+ ImageFile.new('spec/samples/example.gif').should be_kind_of(ImageFile)
8
+ end
9
+ it "should raise an error if filepath is not valid" do
10
+ lambda { ImageFile.new('spec/samples/doesnt_exist.lol') }.should raise_error(IOError)
11
+ end
12
+ it "should raise an error if filepath does not represent a valid image file" do
13
+ lambda { ImageFile.new('spec/samples/example.mp3') }.should raise_error(TypeError)
14
+ end
15
+ it "should raise an error if file is above 32KB" do
16
+ lambda { ImageFile.new('spec/samples/toobig.gif') }.should raise_error(RangeError)
17
+ end
18
+ end
19
+
20
+ context "instance methods" do
21
+ before(:all) do
22
+ @img_png = ImageFile.new 'spec/samples/16px_rocket.png'
23
+ @img_png2 = ImageFile.new 'spec/samples/64px_bomb.png'
24
+ @img_gif = ImageFile.new 'spec/samples/example.gif'
25
+ @img_jpg = ImageFile.new 'spec/samples/example.jpg'
26
+ @img_svg = ImageFile.new 'spec/samples/example.svg'
27
+ end
28
+
29
+ describe "#filetype" do
30
+ it "should return image/png for PNG files" do
31
+ @img_png.filetype.should eq('image/png')
32
+ end
33
+ it "should return image/gif for GIF files" do
34
+ @img_gif.filetype.should eq('image/gif')
35
+ end
36
+ it "should return image/jpeg for JPG files" do
37
+ @img_jpg.filetype.should eq('image/jpeg')
38
+ end
39
+ it "should return image/svg+xml for SVG files" do
40
+ @img_svg.filetype.should eq('image/svg+xml')
41
+ end
42
+ end
43
+
44
+ describe "#as_img_tag" do
45
+ it "should return the encoded image as an image tag" do
46
+ @img_png.as_img_tag.should eq("<img src='#{@img_png.encode}' />")
47
+ end
48
+ end
49
+
50
+ describe "#as_css_background_with_class" do
51
+ it "should return the encoded image as a full CSS rule" do
52
+ @img_gif.as_css_background_with_class().should match(/^\.\w+ \{\n(.*)\n\}/)
53
+ end
54
+ it "should use the filename base as the default class name" do
55
+ @img_gif.as_css_background_with_class().should match(/^\.example_gif \{/)
56
+ end
57
+ it "should use an optional class name if passed one" do
58
+ @img_gif.as_css_background_with_class('funkytown').should match(/^\.funkytown \{/)
59
+ end
60
+ it "should modify invalid filenames to be valid CSS class names"
61
+ it "should raise an error if sent an invalid CSS class name"
62
+ end
63
+
64
+ describe "#as_css_background" do
65
+ it "should return the encoded image as a CSS background rule" do
66
+ @img_png.as_css_background.should eq("background: url(#{@img_png.encode}) no-repeat;")
67
+ end
68
+ end
69
+
70
+ describe "#encode" do
71
+ it "should return the base64 string wrapped in proper CSS format" do
72
+ png_prefix = "data:image/png;base64,"
73
+ @img_png.encode.should eq(png_prefix + @img_png.raw_encode)
74
+ svg_prefix = "data:image/svg+xml;base64,"
75
+ @img_svg.encode.should eq(svg_prefix + @img_svg.raw_encode)
76
+ end
77
+ end
78
+
79
+ describe "#raw_encode" do
80
+ it "should properly encode the file" do
81
+ @img_png.raw_encode.should eq("iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAMAAAAoLQ9TAAACIlBMVEUAAAASERMUExQXFhYmJSgnJilhYGZ9AABCQEWLAAAuLC87OT3D2voeHR4mIiOdRQAmISLnYgBgAgKDAACAAACMAAB7AQCBAAAFBAU2NTk/PkI3NToAAAAzMTVVU1h1dHyMjJVqaXA+PEEAAAAwLjFQTlN9e4OpqbJ/fYY8Oj8aGRs5NztlZGpraXAaGRs8Oj50c3qOi5VTUVd8AAB8AABeAAA8LzJ0dHxubHM6ODyHAACUAACPAABQT1R+AACVAACnAABgZG4zMTSAAACOAACTAABqdII9PkV+AAByAABuBwBWNTRqdYRAREsUDAiRQwC3SAGSSzlANjsUEhCxZwDYaQFdAACJTgDGlQBiMR1PKypjEBGPAACjagDUsQCxaQC7SQFwCgB5AACfZwC/lgDSsQDGlgC0ZwCVQQByAACOAACWAACVXQCfZwCMTgCAAACAAADJydPFxM+fnqe/v8na2uXa2eSwrbm0tb9zdHhWVliKiY/CwMzDxdKrrbhRUVFlZWRNTU6al6FbEBFnYmi4usbJzNm7u8hoaGtKSkpcW1+BgYyGAQFZPUGipK/Dw9DItMDGws+trLeNi5OMjptiEBF2dHy4tcHXbXS+MTWwo66qqLOXmqeXipPcVFm8Bwd0OT2cmqSSlKLVMTbAAgJnIyZzcXmFiJRjZHDpHQi+AABdEhVUUFVlYmlaP0RbERLvWwB1GQOGAgLjmwCiWgCnAABpx48CAAAAcXRSTlMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAADFTATAh9cnc7SMQEnh9n7zRYIZNudCYT2+1sVYGmU9tgfFKH9hxqk/toocbvY9mULBzLZ+IUICoTylAlc9msNtfHZ/vwt4faFMhRG5OK1WwoIuqQaRQ1yG1EyGzIAAACzSURBVBgZRcExSgNhEIbh752d2d+NBxCsrARBBAuvkIhYCtp7Km8gAYONqawUscwBgqZPCkURxMrZzUKeB22wQ1LPdllTp9ojnTHF1fJ9GJHiw5XiAE5JD7F0lUPSkFbBvDmGEb14HvgJnNO7i+0fD2hYG9cvJouIaencl2Lfstd64+lLcgsu6PjjpyQfcvVXbuFy/I6S1XU1mJSyrBZHKHFNbzZfKVnT/G7dTBYRbyu1/gH1JiFHBs2I5wAAAABJRU5ErkJggg==")
82
+ end
83
+ end
84
+ end
85
+ end
Binary file
Binary file
Binary file
Binary file
Binary file
@@ -0,0 +1,69 @@
1
+ <?xml version="1.0" encoding="UTF-8" standalone="no"?>
2
+ <svg
3
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
4
+ xmlns:cc="http://web.resource.org/cc/"
5
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
6
+ xmlns:svg="http://www.w3.org/2000/svg"
7
+ xmlns="http://www.w3.org/2000/svg"
8
+ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
9
+ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
10
+ width="600"
11
+ height="600"
12
+ id="svg2"
13
+ sodipodi:version="0.32"
14
+ inkscape:version="0.45.1"
15
+ sodipodi:docname="Example.svg"
16
+ inkscape:output_extension="org.inkscape.output.svg.inkscape"
17
+ sodipodi:docbase="/home/gmaxwell"
18
+ version="1.0">
19
+ <metadata
20
+ id="metadata9">
21
+ <rdf:RDF>
22
+ <cc:Work
23
+ rdf:about="">
24
+ <dc:format>image/svg+xml</dc:format>
25
+ <dc:type
26
+ rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
27
+ </cc:Work>
28
+ </rdf:RDF>
29
+ </metadata>
30
+ <sodipodi:namedview
31
+ inkscape:window-height="620"
32
+ inkscape:window-width="814"
33
+ inkscape:pageshadow="2"
34
+ inkscape:pageopacity="0.0"
35
+ guidetolerance="10.0"
36
+ gridtolerance="10.0"
37
+ objecttolerance="10.0"
38
+ borderopacity="1.0"
39
+ bordercolor="#666666"
40
+ pagecolor="#ffffff"
41
+ id="base"
42
+ width="600px"
43
+ height="600px"
44
+ inkscape:zoom="0.35974058"
45
+ inkscape:cx="50"
46
+ inkscape:cy="519.04966"
47
+ inkscape:window-x="483"
48
+ inkscape:window-y="101"
49
+ inkscape:current-layer="svg2" />
50
+ <defs
51
+ id="defs16" />
52
+ <g
53
+ id="g2161"
54
+ transform="matrix(6.3951354,0,0,6.3951354,-22.626246,-7.1082509)">
55
+ <path
56
+ nodetypes="ccccccccccccccccccccccccccccccccccccccc"
57
+ id="flowRoot1882"
58
+ d="M 36.009766,9.2505083 C 37.739295,9.4211273 38.305879,11.470697 38.052581,12.935049 C 37.346266,16.153899 36.316821,19.51466 35.445405,22.717701 C 36.091666,24.812224 31.712284,24.008877 33.219932,22.315459 C 34.817041,18.411202 36.011404,13.498336 36.009766,9.2505083 z M 36.009766,2.9926958 C 38.210311,1.2242088 40.996268,9.172757 33.911571,6.1534847 C 33.884619,5.7603019 36.096289,3.3869447 36.009766,2.9926958 z M 41.371094,15.871601 C 41.371094,13.66457 41.371094,11.457539 41.371094,9.250508 C 43.180621,9.4257387 43.963014,11.704559 43.286137,13.215517 C 42.859084,15.059792 42.939241,17.3996 44.601487,18.625335 C 46.710544,19.683477 49.38774,17.353112 48.803268,15.118437 C 48.93196,13.406538 48.236292,11.613848 48.968862,9.9690415 C 51.055097,9.6500357 51.500677,12.487155 50.544985,13.844747 C 50.070023,15.309708 50.857452,16.781898 50.672344,18.239432 C 50.279615,19.94056 48.418404,20.00023 47.0225,20.071868 C 45.478489,20.38194 43.516835,20.791368 42.361947,19.38874 C 41.522514,18.444089 41.211274,17.107671 41.371094,15.871601 z M 61.224609,9.5727739 C 60.41978,11.557552 58.100804,10.235616 56.62767,10.571551 C 53.836862,14.393611 60.920038,13.513667 61.8085,17.011648 C 61.85613,18.933747 60.028359,20.587389 58.129091,20.443312 C 56.904487,20.607229 54.609204,20.982393 54.417879,19.267622 C 55.280609,17.508269 57.336359,19.528803 58.633111,18.8463 C 60.403141,17.99081 59.402232,15.555325 57.728781,15.321475 C 56.550115,14.98135 55.091813,15.225439 54.254747,14.112764 C 53.017669,12.881167 53.392132,10.733148 54.736719,9.7413252 C 56.619172,8.3307396 59.170326,8.9535067 61.224609,9.5727739 z M 66.458984,6.1450396 C 65.368126,7.6333334 67.348936,9.9531574 68.987229,9.0948979 C 69.978133,11.042503 66.524641,10.777931 66.473495,12.430992 C 64.443605,16.101814 68.48273,18.623426 67.571657,20.417528 C 65.440858,20.26155 64.324307,17.844452 64.577433,15.919357 C 64.70847,14.408586 65.055107,12.79361 64.322961,11.373941 C 63.786422,9.5475192 64.150419,7.1452655 65.954233,6.1552477 L 66.206043,6.1203323 L 66.458984,6.1450396 L 66.458984,6.1450396 z " />
59
+ <path
60
+ nodetypes="ccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc"
61
+ id="flowRoot1890"
62
+ d="M 10.867188,44.877953 C 6.2812618,42.124849 5.2205914,52.366268 10.409215,49.892431 C 12.389385,49.295568 14.988045,43.912658 10.867188,44.877953 z M 15.167969,43.987328 C 14.919826,46.33724 16.617756,52.554202 12.298734,50.536918 C 9.8041142,52.312916 6.0580855,52.958674 4.5023123,49.583386 C 2.6350454,45.257322 7.3033103,42.298712 11.046443,43.361059 C 15.247185,41.320786 9.4930286,38.338264 7.1068792,40.322138 C 3.4374421,40.01388 7.406407,37.201407 9.3495087,37.962912 C 12.44212,37.877788 15.556534,40.380131 15.171751,43.648912 L 15.169638,43.83797 L 15.167969,43.987328 z M 30.53125,43.553734 C 29.638794,45.911558 32.49467,50.463872 28.779999,51.070944 C 26.888088,47.702306 30.931621,41.190257 25.58365,40.046147 C 20.73931,40.312798 21.252194,45.910871 22.001439,49.154066 C 21.84253,51.828309 18.790577,51.39256 19.585585,48.673738 C 19.851829,45.693864 18.285332,39.630301 20.986983,38.702911 C 23.508461,40.80889 25.761847,35.731906 28.452459,38.686226 C 29.921454,39.793194 30.827618,41.709992 30.53125,43.553734 z M 38.807,49.770223 C 42.369034,50.768974 44.523344,46.328688 43.700521,43.358983 C 40.402775,35.546453 32.491199,44.344131 38.807,49.770223 z M 39.941406,38.034203 C 52.085872,39.705642 43.204854,59.098342 34.688722,48.642968 C 32.591886,44.778031 34.383109,38.440132 39.291369,38.051827 L 39.941406,38.034203 L 39.941406,38.034203 z M 51.660156,34.624046 C 49.815978,37.850583 54.789459,38.666222 55.83437,39.23566 C 54.140746,40.715733 50.093061,40.12158 51.562461,43.76212 C 51.004096,46.980523 52.486847,50.037723 55.670614,50.54595 C 53.547788,53.782616 48.41793,50.035495 49.349973,46.519692 C 50.339877,43.686471 48.78131,40.671166 48.467256,38.48357 C 51.099926,37.413599 47.886512,33.32283 51.660156,34.624046 z M 69.859375,43.553734 C 68.966918,45.911557 71.822794,50.463872 68.108124,51.070944 C 66.216214,47.702306 70.259746,41.190256 64.911775,40.046145 C 60.222418,40.285904 60.439194,45.757728 61.367942,48.953683 C 60.705448,53.064855 57.788626,49.900134 58.838379,47.289738 C 58.969709,43.381174 59.006437,39.455087 58.607404,35.565714 C 59.356025,31.632413 62.368269,34.68013 61.01352,37.194316 C 60.38417,39.302538 61.469087,40.653476 62.996248,38.474829 C 66.202089,36.826154 70.863269,39.826451 69.859375,43.553734 z M 85.410156,44.374046 C 83.244849,47.905533 76.447085,42.456344 75.976013,47.444052 C 76.913541,51.724548 83.275324,48.726196 84.393639,50.133773 C 82.109855,53.525123 76.421339,51.860111 74.285335,49.01336 C 71.258247,44.729984 74.614013,37.166516 80.254289,37.96756 C 83.286958,38.284495 85.833914,41.310745 85.410156,44.374046 z M 83.253906,43.741234 C 84.431319,39.039614 74.594812,38.687325 76.291886,43.335226 C 78.284783,44.796048 81.032856,43.090943 83.253906,43.741234 z M 96.554688,40.366234 C 93.290612,38.6882 90.622217,42.519635 90.728522,45.492665 C 90.881925,47.333676 92.330286,52.144465 89.028751,50.905988 C 88.95673,46.763963 88.353312,42.447207 89.31721,38.336643 C 91.040471,38.503437 92.207514,40.668181 93.421468,38.208298 C 94.902478,37.44973 97.690944,38.263668 96.554688,40.366234 z " />
63
+ <path
64
+ style="fill:#ff0000"
65
+ nodetypes="ccccccccccccccccccccccccccccccccccccccccccccccccccccc"
66
+ id="flowRoot1898"
67
+ d="M 17.026327,63.789847 C 0.7506376,64.058469 13.88279,66.387154 13.113883,69.323258 C 8.0472417,70.287093 3.5936285,63.565714 6.8090451,59.370548 C 8.7591553,55.717791 15.269922,55.198361 16.902068,59.393261 C 17.532581,60.758947 17.628237,62.396589 17.026327,63.789847 z M 15.306463,62.656109 C 18.852566,58.713773 7.6543584,56.609143 10.765803,61.304742 C 12.124789,62.217715 13.961359,61.705342 15.306463,62.656109 z M 31.307931,62.391383 C 27.130518,63.524026 24.669863,68.663004 27.470717,72.229472 C 25.946657,74.052316 24.253697,71.076237 24.857281,69.636909 C 23.737444,67.038428 17.399862,72.254246 19.386636,68.888657 C 23.159719,67.551193 22.398496,63.711301 22.06067,60.848671 C 24.064085,60.375294 24.370376,65.772689 27.167918,63.326048 C 28.350126,62.546369 29.927362,61.067531 31.307931,62.391383 z M 37.66875,70.598623 C 33.467314,66.62264 32.517064,77.972723 37.30626,74.466636 C 38.742523,73.853608 40.55904,70.38932 37.66875,70.598623 z M 41.677321,70.973131 C 42.340669,75.308182 36.926157,78.361257 33.331921,76.223155 C 29.43435,74.893988 30.618698,67.677232 35.003806,68.567885 C 37.137393,70.592854 42.140265,67.002221 37.656192,66.290007 C 35.242233,65.914214 35.166503,62.640757 38.036954,63.926404 C 40.847923,64.744926 43.227838,68.124735 41.677321,70.973131 z M 62.379099,76.647079 C 62.007404,78.560417 61.161437,84.034535 58.890565,82.010019 C 59.769679,79.039958 62.536382,72.229115 56.947899,72.765789 C 53.790416,73.570863 54.908257,80.968388 51.529286,79.496859 C 51.707831,76.559817 55.858125,71.896837 50.8321,70.678504 C 45.898113,69.907818 47.485944,75.735824 45.286883,78.034703 C 42.916393,76.333396 45.470823,71.647155 46.624124,69.414735 C 50.919507,67.906486 63.618534,70.878704 62.379099,76.647079 z M 66.426447,83.84905 C 67.616398,85.777591 62.114624,94.492698 62.351124,90.31711 C 63.791684,86.581961 65.730376,78.000636 67.391891,74.85575 C 71.027815,73.781175 76.383067,75.350289 76.591972,79.751898 C 77.048545,83.793048 73.066803,88.429945 68.842187,86.765936 C 67.624386,86.282034 66.56741,85.195132 66.426447,83.84905 z M 74.086569,81.803435 C 76.851893,78.050524 69.264402,74.310256 67.560734,78.378191 C 65.893402,80.594099 67.255719,83.775746 69.700555,84.718558 C 72.028708,85.902224 73.688639,83.888662 74.086569,81.803435 z M 82.318799,73.124577 C 84.30523,75.487059 81.655015,88.448086 78.247183,87.275736 C 78.991935,82.387828 81.291029,77.949394 82.318799,73.124577 z M 95.001985,87.684695 C 78.726298,87.953319 91.858449,90.281999 91.089542,93.218107 C 86.0229,94.18194 81.569287,87.460562 84.784701,83.265394 C 86.734814,79.612637 93.245582,79.09321 94.877729,83.28811 C 95.508245,84.653796 95.603892,86.291438 95.001985,87.684695 z M 93.282122,86.550957 C 96.828223,82.608621 85.630017,80.503993 88.741461,85.199592 C 90.100447,86.112565 91.937018,85.600192 93.282122,86.550957 z " />
68
+ </g>
69
+ </svg>
Binary file
@@ -0,0 +1,28 @@
1
+ require 'rspec'
2
+ require 'cssquirt'
3
+ include CSSquirt
4
+
5
+ RSpec.configure do |config|
6
+ config.color_enabled = true
7
+ config.formatter = 'documentation'
8
+
9
+ config.before(:all) { silence_output }
10
+ config.after(:all) { enable_output }
11
+ end
12
+
13
+
14
+ # Redirects stderr and stdout to /dev/null.
15
+ # Helpers from https://gist.github.com/adamstegman/926858
16
+ def silence_output
17
+ @orig_stderr = $stderr
18
+ @orig_stdout = $stdout
19
+ $stderr = File.new('/dev/null', 'w')
20
+ $stdout = File.new('/dev/null', 'w')
21
+ end
22
+
23
+ def enable_output
24
+ $stderr = @orig_stderr
25
+ $stdout = @orig_stdout
26
+ @orig_stderr = nil
27
+ @orig_stdout = nil
28
+ end
metadata ADDED
@@ -0,0 +1,121 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: cssquirt
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1.pre.1
5
+ platform: ruby
6
+ authors:
7
+ - Matthew Rothenberg
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-06-10 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: '1.3'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '1.3'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rspec
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ description: Embeds images (or directories of images) directly into CSS via the Data
56
+ URI scheme.
57
+ email:
58
+ - mrothenberg@gmail.com
59
+ executables: []
60
+ extensions: []
61
+ extra_rdoc_files: []
62
+ files:
63
+ - .gitignore
64
+ - .travis.yml
65
+ - Gemfile
66
+ - LICENSE.txt
67
+ - README.md
68
+ - Rakefile
69
+ - cssquirt.gemspec
70
+ - lib/cssquirt.rb
71
+ - lib/cssquirt/file_list.rb
72
+ - lib/cssquirt/image_file.rb
73
+ - lib/cssquirt/version.rb
74
+ - spec/cssquirt_spec.rb
75
+ - spec/file_list_spec.rb
76
+ - spec/image_file_spec.rb
77
+ - spec/samples/16px_rocket.png
78
+ - spec/samples/64px_bomb.png
79
+ - spec/samples/example.gif
80
+ - spec/samples/example.jpg
81
+ - spec/samples/example.mp3
82
+ - spec/samples/example.svg
83
+ - spec/samples/toobig.gif
84
+ - spec/spec_helper.rb
85
+ homepage: http://github.com/mroth/cssquirt
86
+ licenses:
87
+ - MIT
88
+ metadata: {}
89
+ post_install_message:
90
+ rdoc_options: []
91
+ require_paths:
92
+ - lib
93
+ required_ruby_version: !ruby/object:Gem::Requirement
94
+ requirements:
95
+ - - '>='
96
+ - !ruby/object:Gem::Version
97
+ version: '0'
98
+ required_rubygems_version: !ruby/object:Gem::Requirement
99
+ requirements:
100
+ - - '>'
101
+ - !ruby/object:Gem::Version
102
+ version: 1.3.1
103
+ requirements: []
104
+ rubyforge_project:
105
+ rubygems_version: 2.0.2
106
+ signing_key:
107
+ specification_version: 4
108
+ summary: Embeds images (or directories of images) directly into CSS via the Data URI
109
+ scheme.
110
+ test_files:
111
+ - spec/cssquirt_spec.rb
112
+ - spec/file_list_spec.rb
113
+ - spec/image_file_spec.rb
114
+ - spec/samples/16px_rocket.png
115
+ - spec/samples/64px_bomb.png
116
+ - spec/samples/example.gif
117
+ - spec/samples/example.jpg
118
+ - spec/samples/example.mp3
119
+ - spec/samples/example.svg
120
+ - spec/samples/toobig.gif
121
+ - spec/spec_helper.rb