favicon_maker 0.0.6 → 0.0.7

Sign up to get free protection for your applications and to get access to all the features.
data/.travis.yml ADDED
@@ -0,0 +1,4 @@
1
+ rvm:
2
+ - 1.8.7
3
+ - 1.9.2
4
+ script: "bundle exec rspec spec"
data/Gemfile CHANGED
@@ -1,4 +1,3 @@
1
1
  source "http://rubygems.org"
2
2
 
3
- gemspec
4
- gem 'rspec'
3
+ gemspec
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- FaviconMaker
1
+ FaviconMaker [![Build Status](https://secure.travis-ci.org/follmann/favicon_maker.png)](http://travis-ci.org/[follmann]/[favicon_maker])
2
2
  ============
3
3
 
4
4
  Tired of creating a gazillion different favicons to satisfy all kinds of devices and resolutions in different file formats?
@@ -19,8 +19,29 @@ The basic idea is to have one image file as source for all the different sizes a
19
19
  ## Integration
20
20
  ### Middleman
21
21
  In order to integrate the FaviconMaker effortless into your [Middleman](https://github.com/tdreyno/middleman) project use the following gem: [middleman-favicon-maker](https://github.com/follmann/middleman-favicon-maker)
22
- ### Rails
23
- Soon to come... Have a look on the basic usage for now.
22
+ ### Capistrano
23
+ 1. Edit your Capfile and add the following line
24
+
25
+ require "favicon_maker"
26
+
27
+ 2. Add the following snippet to your deploy.rb
28
+
29
+ namespace :favicon do
30
+ task :create_versions do
31
+ options = {
32
+ :root_dir => release_path,
33
+ :input_dir => File.join("app", "assets", "public"),
34
+ :output_dir => "public"
35
+ }
36
+ FaviconMaker::Generator.create_versions(options) do |filepath|
37
+ puts "Created favicon: #{filepath}"
38
+ end
39
+ end
40
+ end
41
+
42
+ after "deploy:update_code", "favicon:create_versions"
43
+
44
+ **Note: This snippet is untested but should work**
24
45
 
25
46
  ## Basic Usage
26
47
  ### Simple
@@ -46,16 +67,18 @@ Uses the following defaults:
46
67
 
47
68
  options = {
48
69
  :versions => [:apple_114, :apple_57, :apple, :fav_png, :fav_ico],
49
- :custom_versions => {:apple_extreme_retina => {:filename => "apple-touch-icon-228x228-precomposed.png", :dimensions => "228x228", :format => "png"}}
70
+ :custom_versions => {:apple_extreme_retina => {:filename => "apple-touch-icon-228x228-precomposed.png", :dimensions => "228x228", :format => "png"}},
50
71
  :root_dir => Rails.root,
51
- :input_dir => File.join(Rails.root, "app", "assets", "public"),
72
+ :input_dir => File.join("app", "assets", "public"),
52
73
  :base_image => "favico.png",
53
74
  :output_dir => "public",
54
75
  :copy => true
55
76
  }
77
+
56
78
  FaviconMaker::Generator.create_versions(options) do |filepath|
57
- Rails.logger.info "Created favicon: #{filepath}"
79
+ puts "Created favicon: #{filepath}"
58
80
  end
81
+
59
82
  ## Base Image Guideline
60
83
  Choose the version with the biggest dimension as your base image. Currently the size 114x114 for newer iOS devices marks the upper limit. So just create a PNG with 24 or 32 Bit color depth and 114x114 document size. Downscaling of images always works better than upscaling.
61
84
 
@@ -1,6 +1,7 @@
1
1
  # -*- encoding: utf-8 -*-
2
+
2
3
  $:.push File.expand_path("../lib", __FILE__)
3
- require "version"
4
+ require "favicon_maker/version"
4
5
 
5
6
  Gem::Specification.new do |s|
6
7
  s.name = "favicon_maker"
@@ -12,12 +13,12 @@ Gem::Specification.new do |s|
12
13
  s.summary = %q{Create favicon files in various sizes from a base image}
13
14
  s.description = %q{Create favicon files in various sizes from a base image}
14
15
 
15
- s.rubyforge_project = "favicon_maker"
16
-
17
16
  s.files = `git ls-files`.split("\n")
18
17
  s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
19
18
  s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
20
19
  s.require_paths = ["lib"]
21
20
 
22
21
  s.add_runtime_dependency("mini_magick", ["~> 3.0"])
22
+
23
+ s.add_development_dependency("rspec", ["~> 2.6.0"])
23
24
  end
data/lib/favicon_maker.rb CHANGED
@@ -1,64 +1,9 @@
1
1
  module FaviconMaker
2
- require "mini_magick"
3
- require 'fileutils'
4
2
 
5
- class Generator
6
- VERSION = "0.0.1"
7
-
8
- ICON_VERSIONS = {
9
- :apple_114 => {:filename => "apple-touch-icon-114x114-precomposed.png", :dimensions => "114x114", :format => "png"},
10
- :apple_72 => {:filename => "apple-touch-icon-72x72-precomposed.png", :dimensions => "72x72", :format => "png"},
11
- :apple_57 => {:filename => "apple-touch-icon-57x57-precomposed.png", :dimensions => "57x57", :format => "png"},
12
- :apple_pre => {:filename => "apple-touch-icon-precomposed.png", :dimensions => "57x57", :format => "png"},
13
- :apple => {:filename => "apple-touch-icon.png", :dimensions => "57x57", :format => "png"},
14
- :fav_png => {:filename => "favicon.png", :dimensions => "16x16", :format => "png"},
15
- :fav_ico => {:filename => "favicon.ico", :dimensions => "16x16", :format => "ico"}
16
- }
17
-
18
- class << self
19
-
20
- def create_versions(options={}, &block)
21
- options = {
22
- :versions => ICON_VERSIONS.keys,
23
- :custom_versions => {},
24
- :root_dir => File.dirname(__FILE__),
25
- :input_dir => "favicons",
26
- :base_image => "favicon_base.png",
27
- :output_dir => "favicons_output",
28
- :copy => false
29
- }.merge(options)
30
-
31
- raise ArgumentError unless options[:versions].is_a? Array
32
- base_path = File.join(options[:root_dir], options[:input_dir])
33
- input_path = File.join(base_path, options[:base_image])
34
-
35
- icon_versions = ICON_VERSIONS.merge(options[:custom_versions])
36
- (options[:versions] + options[:custom_versions].keys).uniq.each do |version|
37
- version = icon_versions[version]
38
- composed_path = File.join(base_path, version[:filename])
39
- output_path = File.join(options[:root_dir], options[:output_dir], version[:filename])
40
-
41
- created = false
42
- # check for self composed icon file
43
- if File.exist?(composed_path)
44
- if options[:copy]
45
- FileUtils.cp composed_path, output_path
46
- created = true
47
- end
48
- else
49
- image = MiniMagick::Image.open(input_path)
50
- image.resize version[:dimensions]
51
- image.format version[:format]
52
- image.write output_path
53
- created = true
54
- end
55
-
56
- if block_given? && created
57
- yield output_path
58
- end
59
- end
60
- end
61
-
62
- end
63
- end
3
+ libdir = File.dirname(__FILE__)
4
+ $LOAD_PATH.unshift(libdir) unless $LOAD_PATH.include?(libdir)
5
+
6
+ # Auto-load modules on-demand
7
+ autoload :Generator, "favicon_maker/generator"
8
+
64
9
  end
@@ -0,0 +1,63 @@
1
+ module FaviconMaker
2
+ require "mini_magick"
3
+ require 'fileutils'
4
+
5
+ class Generator
6
+
7
+ ICON_VERSIONS = {
8
+ :apple_114 => {:filename => "apple-touch-icon-114x114-precomposed.png", :dimensions => "114x114", :format => "png"},
9
+ :apple_72 => {:filename => "apple-touch-icon-72x72-precomposed.png", :dimensions => "72x72", :format => "png"},
10
+ :apple_57 => {:filename => "apple-touch-icon-57x57-precomposed.png", :dimensions => "57x57", :format => "png"},
11
+ :apple_pre => {:filename => "apple-touch-icon-precomposed.png", :dimensions => "57x57", :format => "png"},
12
+ :apple => {:filename => "apple-touch-icon.png", :dimensions => "57x57", :format => "png"},
13
+ :fav_png => {:filename => "favicon.png", :dimensions => "16x16", :format => "png"},
14
+ :fav_ico => {:filename => "favicon.ico", :dimensions => "16x16", :format => "ico"}
15
+ }
16
+
17
+ class << self
18
+
19
+ def create_versions(options={}, &block)
20
+ options = {
21
+ :versions => ICON_VERSIONS.keys,
22
+ :custom_versions => {},
23
+ :root_dir => File.dirname(__FILE__),
24
+ :input_dir => "favicons",
25
+ :base_image => "favicon_base.png",
26
+ :output_dir => "favicons_output",
27
+ :copy => false
28
+ }.merge(options)
29
+
30
+ raise ArgumentError unless options[:versions].is_a? Array
31
+ base_path = File.join(options[:root_dir], options[:input_dir])
32
+ input_path = File.join(base_path, options[:base_image])
33
+
34
+ icon_versions = ICON_VERSIONS.merge(options[:custom_versions])
35
+ (options[:versions] + options[:custom_versions].keys).uniq.each do |version|
36
+ version = icon_versions[version]
37
+ composed_path = File.join(base_path, version[:filename])
38
+ output_path = File.join(options[:root_dir], options[:output_dir], version[:filename])
39
+
40
+ created = false
41
+ # check for self composed icon file
42
+ if File.exist?(composed_path)
43
+ if options[:copy]
44
+ FileUtils.cp composed_path, output_path
45
+ created = true
46
+ end
47
+ else
48
+ image = MiniMagick::Image.open(input_path)
49
+ image.resize version[:dimensions]
50
+ image.format version[:format]
51
+ image.write output_path
52
+ created = true
53
+ end
54
+
55
+ if block_given? && created
56
+ yield output_path
57
+ end
58
+ end
59
+ end
60
+
61
+ end
62
+ end
63
+ end
@@ -0,0 +1,3 @@
1
+ module FaviconMaker
2
+ VERSION = "0.0.7"
3
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: favicon_maker
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.0.7
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-11-01 00:00:00.000000000Z
12
+ date: 2011-11-12 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: mini_magick
16
- requirement: &70131795630020 !ruby/object:Gem::Requirement
16
+ requirement: &70320442867780 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,7 +21,18 @@ dependencies:
21
21
  version: '3.0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70131795630020
24
+ version_requirements: *70320442867780
25
+ - !ruby/object:Gem::Dependency
26
+ name: rspec
27
+ requirement: &70320442865600 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ~>
31
+ - !ruby/object:Gem::Version
32
+ version: 2.6.0
33
+ type: :development
34
+ prerelease: false
35
+ version_requirements: *70320442865600
25
36
  description: Create favicon files in various sizes from a base image
26
37
  email:
27
38
  executables: []
@@ -30,12 +41,14 @@ extra_rdoc_files: []
30
41
  files:
31
42
  - .gitignore
32
43
  - .rspec
44
+ - .travis.yml
33
45
  - Gemfile
34
46
  - LICENSE
35
47
  - README.md
36
48
  - favicon_maker.gemspec
37
49
  - lib/favicon_maker.rb
38
- - lib/version.rb
50
+ - lib/favicon_maker/generator.rb
51
+ - lib/favicon_maker/version.rb
39
52
  - spec/favicon_maker_spec.rb
40
53
  - spec/spec_helper.rb
41
54
  - spec/support/favicon_base.png
@@ -58,7 +71,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
58
71
  - !ruby/object:Gem::Version
59
72
  version: '0'
60
73
  requirements: []
61
- rubyforge_project: favicon_maker
74
+ rubyforge_project:
62
75
  rubygems_version: 1.8.10
63
76
  signing_key:
64
77
  specification_version: 3
data/lib/version.rb DELETED
@@ -1,3 +0,0 @@
1
- module FaviconMaker
2
- VERSION = "0.0.6"
3
- end