favicon_maker 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/.gitignore +5 -0
- data/favicon_maker.gemspec +23 -0
- data/lib/favicon_maker.rb +63 -0
- data/lib/version.rb +3 -0
- metadata +77 -0
| @@ -0,0 +1,23 @@ | |
| 1 | 
            +
            # -*- encoding: utf-8 -*-
         | 
| 2 | 
            +
            $:.push File.expand_path("../lib", __FILE__)
         | 
| 3 | 
            +
            require "version"
         | 
| 4 | 
            +
             | 
| 5 | 
            +
            Gem::Specification.new do |s|
         | 
| 6 | 
            +
              s.name        = "favicon_maker"
         | 
| 7 | 
            +
              s.version     = FaviconMaker::VERSION
         | 
| 8 | 
            +
              s.platform    = Gem::Platform::RUBY
         | 
| 9 | 
            +
              s.authors     = ["Andreas Follmann"]
         | 
| 10 | 
            +
              #s.email       = [""]
         | 
| 11 | 
            +
              #s.homepage    = "https://github.com/tdreyno/middleman-smusher"
         | 
| 12 | 
            +
              s.summary     = %q{Create favicon files in various sizes from a base image}
         | 
| 13 | 
            +
              s.description = %q{Create favicon files in various sizes from a base image}
         | 
| 14 | 
            +
             | 
| 15 | 
            +
              s.rubyforge_project = "favicon_maker"
         | 
| 16 | 
            +
             | 
| 17 | 
            +
              s.files         = `git ls-files`.split("\n")
         | 
| 18 | 
            +
              s.test_files    = `git ls-files -- {test,spec,features}/*`.split("\n")
         | 
| 19 | 
            +
              s.executables   = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
         | 
| 20 | 
            +
              s.require_paths = ["lib"]
         | 
| 21 | 
            +
              
         | 
| 22 | 
            +
              s.add_runtime_dependency("mini_magick", ["~> 3.0"])
         | 
| 23 | 
            +
            end
         | 
| @@ -0,0 +1,63 @@ | |
| 1 | 
            +
            module FaviconMaker
         | 
| 2 | 
            +
              require "mini_magick"
         | 
| 3 | 
            +
              require 'fileutils'
         | 
| 4 | 
            +
              
         | 
| 5 | 
            +
              class Generator
         | 
| 6 | 
            +
                VERSION = "0.0.1"
         | 
| 7 | 
            +
                
         | 
| 8 | 
            +
                ICON_VERSIONS = {
         | 
| 9 | 
            +
                  :apple_114 => ["apple-touch-icon-114x114-precomposed.png", "114x114", "png"],
         | 
| 10 | 
            +
                  :apple_72 => ["apple-touch-icon-72x72-precomposed.png", "72x72", "png"],
         | 
| 11 | 
            +
                  :apple_57 => ["apple-touch-icon-57x57-precomposed.png", "57x57", "png"],
         | 
| 12 | 
            +
                  :apple_pre => ["apple-touch-icon-precomposed.png", "57x57", "png"],
         | 
| 13 | 
            +
                  :apple => ["apple-touch-icon.png", "57x57", "png"],
         | 
| 14 | 
            +
                  :fav_png => ["favicon.png", "16x16", "png"],
         | 
| 15 | 
            +
                  :fav_ico => ["favicon.ico", "16x16", "ico"]
         | 
| 16 | 
            +
                }
         | 
| 17 | 
            +
                
         | 
| 18 | 
            +
                class << self
         | 
| 19 | 
            +
                
         | 
| 20 | 
            +
                  def create_versions(options={}, &block)
         | 
| 21 | 
            +
                    options = {
         | 
| 22 | 
            +
                      :versions => ICON_VERSIONS.keys,
         | 
| 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 | 
            +
                    options[:versions].each do |version|
         | 
| 35 | 
            +
                      version = ICON_VERSIONS[version]
         | 
| 36 | 
            +
                      filename = version[0]
         | 
| 37 | 
            +
                      composed_path = File.join(base_path, filename)
         | 
| 38 | 
            +
                      output_path = File.join(options[:root_dir], options[:output_dir], 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[1]
         | 
| 50 | 
            +
                        image.format version[2]
         | 
| 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
         | 
    
        data/lib/version.rb
    ADDED
    
    
    
        metadata
    ADDED
    
    | @@ -0,0 +1,77 @@ | |
| 1 | 
            +
            --- !ruby/object:Gem::Specification 
         | 
| 2 | 
            +
            name: favicon_maker
         | 
| 3 | 
            +
            version: !ruby/object:Gem::Version 
         | 
| 4 | 
            +
              prerelease: false
         | 
| 5 | 
            +
              segments: 
         | 
| 6 | 
            +
              - 0
         | 
| 7 | 
            +
              - 0
         | 
| 8 | 
            +
              - 1
         | 
| 9 | 
            +
              version: 0.0.1
         | 
| 10 | 
            +
            platform: ruby
         | 
| 11 | 
            +
            authors: 
         | 
| 12 | 
            +
            - Andreas Follmann
         | 
| 13 | 
            +
            autorequire: 
         | 
| 14 | 
            +
            bindir: bin
         | 
| 15 | 
            +
            cert_chain: []
         | 
| 16 | 
            +
             | 
| 17 | 
            +
            date: 2011-10-31 00:00:00 +01:00
         | 
| 18 | 
            +
            default_executable: 
         | 
| 19 | 
            +
            dependencies: 
         | 
| 20 | 
            +
            - !ruby/object:Gem::Dependency 
         | 
| 21 | 
            +
              name: mini_magick
         | 
| 22 | 
            +
              prerelease: false
         | 
| 23 | 
            +
              requirement: &id001 !ruby/object:Gem::Requirement 
         | 
| 24 | 
            +
                requirements: 
         | 
| 25 | 
            +
                - - ~>
         | 
| 26 | 
            +
                  - !ruby/object:Gem::Version 
         | 
| 27 | 
            +
                    segments: 
         | 
| 28 | 
            +
                    - 3
         | 
| 29 | 
            +
                    - 0
         | 
| 30 | 
            +
                    version: "3.0"
         | 
| 31 | 
            +
              type: :runtime
         | 
| 32 | 
            +
              version_requirements: *id001
         | 
| 33 | 
            +
            description: Create favicon files in various sizes from a base image
         | 
| 34 | 
            +
            email: 
         | 
| 35 | 
            +
            executables: []
         | 
| 36 | 
            +
             | 
| 37 | 
            +
            extensions: []
         | 
| 38 | 
            +
             | 
| 39 | 
            +
            extra_rdoc_files: []
         | 
| 40 | 
            +
             | 
| 41 | 
            +
            files: 
         | 
| 42 | 
            +
            - .gitignore
         | 
| 43 | 
            +
            - favicon_maker.gemspec
         | 
| 44 | 
            +
            - lib/favicon_maker.rb
         | 
| 45 | 
            +
            - lib/version.rb
         | 
| 46 | 
            +
            has_rdoc: true
         | 
| 47 | 
            +
            homepage: 
         | 
| 48 | 
            +
            licenses: []
         | 
| 49 | 
            +
             | 
| 50 | 
            +
            post_install_message: 
         | 
| 51 | 
            +
            rdoc_options: []
         | 
| 52 | 
            +
             | 
| 53 | 
            +
            require_paths: 
         | 
| 54 | 
            +
            - lib
         | 
| 55 | 
            +
            required_ruby_version: !ruby/object:Gem::Requirement 
         | 
| 56 | 
            +
              requirements: 
         | 
| 57 | 
            +
              - - ">="
         | 
| 58 | 
            +
                - !ruby/object:Gem::Version 
         | 
| 59 | 
            +
                  segments: 
         | 
| 60 | 
            +
                  - 0
         | 
| 61 | 
            +
                  version: "0"
         | 
| 62 | 
            +
            required_rubygems_version: !ruby/object:Gem::Requirement 
         | 
| 63 | 
            +
              requirements: 
         | 
| 64 | 
            +
              - - ">="
         | 
| 65 | 
            +
                - !ruby/object:Gem::Version 
         | 
| 66 | 
            +
                  segments: 
         | 
| 67 | 
            +
                  - 0
         | 
| 68 | 
            +
                  version: "0"
         | 
| 69 | 
            +
            requirements: []
         | 
| 70 | 
            +
             | 
| 71 | 
            +
            rubyforge_project: favicon_maker
         | 
| 72 | 
            +
            rubygems_version: 1.3.6
         | 
| 73 | 
            +
            signing_key: 
         | 
| 74 | 
            +
            specification_version: 3
         | 
| 75 | 
            +
            summary: Create favicon files in various sizes from a base image
         | 
| 76 | 
            +
            test_files: []
         | 
| 77 | 
            +
             |