Giter Site home page Giter Site logo

logobox's Introduction

Logobox Build Status Code Climate Test Coverage

Logobox is a database of Czech company logos. Currently it contains more than 13 000 logos.

This gem knows how to construct right URLs to those logos. It can also check if logo for company is present on Logobox. All you need is ICO of the company.

Installation

Add this line to your application's Gemfile:

gem 'logobox'

Usage

Logobox has 3 public methods:

Logobox.logo_exists?(ico)

Returns true if logo exists on logobox. If ICO is invalid or logo doesn't exist on logobox returns false. Does actual http request to retrieve this information.

Logobox.logo_exists?(12345678) # Invalid ico
=> false
Logobox.generate_logo_url(ico, size = :medium)

Generates url for logo by given ICO. Logobox provides 3 sizes of logos. You can pick the size by providing second argument. It can be :small/:medium/:big. Default is :medium.

Logobox.generate_logo_url(12345678)
=> "http://www.logobox.cz/getimage.ashx?id=CZ12345678"

Logobox.generate_logo_url(12345678, :small)
=> "http://www.logobox.cz/getimage.ashx?id=CZ12345678&size=small"
Logobox.generate_logo_url!(ico, size = :medium)

Works same as non bang method but if ICO is invalid or logo doesn't exist on Logobox it raises ArgumentError or Logobox::LogoNotFound. Again you can pick size with second optional argument.

Logobox.generate_logo_url!(12345678)
=> ArgumentError: ico is invalid

Logobox.generate_logo_url!(29137420)
=> Logobox::LogoNotFound: logo does not exists

Logobox.generate_logo_url!(27082440)
=> "http://www.logobox.cz/getimage.ashx?id=CZ27082440"

Rails example

class Company < ActiveRecord::Base
  ...
  def logo_url
    Logobox.generate_logo_url(self.ico, :medium)
  end
  ...
end
<%= image_tag(@contact.logo_url) %>

logobox's People

Contributors

boblin avatar

Stargazers

Premysl Donat avatar

Watchers

 avatar James Cloos avatar Andrej Antas avatar Pavel Hronek avatar Ondřej Bína avatar Dmitry Silchenko avatar Patrik Krupar avatar

Forkers

stepnivlk

logobox's Issues

missing runtime ico-validator deps

$ gem install logobox
Fetching: logobox-0.0.3.gem (100%)
Successfully installed logobox-0.0.3
1 gem installed
$ pry
[1] pry(main)> require 'logobox'
LoadError: cannot load such file -- ico-validator/ico_validation
[2] pry(main)> 

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.