Code Monkey home page Code Monkey logo

noun-project-api's Introduction

The Noun Project Ruby API Wrapper

A Ruby API wrapper for The Noun Project API's

Gem VersionDependency Status Build Status Circle CI Code Climate Test Coverage

gem "noun-project-api", "~> 1.0.0"

Missing

Current version only wraps the Icon/Icons API's. Feel free to send a pull request with more API's wrapped!

Usage

You need a valid pair of token and secret to use the Gem, you can get these by signing up here

Raises ArgumentError on bad arguments

Configuration

You can use an initializer for example if you're on Rails.

# initializers/noun_project_api.rb
NounProjectApi.configure do |config|
  # Will only show public domain icons when running in dev/test envs
  config.public_domain = ['development', 'test'].include?(ENV['RAILS_ENV'])
end

Find single icon

Initialize

icon_finder = NounProjectApi::IconRetriever.new(token, secret)

Find an Icon by id source

result = icon_finder.find(1) # Returns a hash of the parsed JSON result.

Find an Icon by slug source

result = icon_finder.find_by_slug('globe') # Returns a hash of the parsed JSON result.

Search icons

Initialize

icons_finder = NounProjectApi::IconsRetriever.new(token, secret)

Optional arguments for both methods are limit, offset and page

Find Icons source

result = icons_finder.find('cat') # Returns an array of the parsed JSON results.

Get recent Icons source

result = icons_finder.recent_uploads # Returns an array of the parsed JSON results.

Find a collection of icons

Initialize

collection_finder = NounProjectApi::CollectionRetriever.new(token, secret)

Find a Collection by id source

result = collection_finder.find(1) # Returns a hash of the parsed JSON result.

Find a Collection by slug source

result = collection_finder_finder.find_by_slug('national-park-service') # Returns a hash of the parsed JSON result.

Resulting objects

The resulting object is either a NounObjectApi::Icon or an array of ones.

result.class # NounProjectApi::Icon
result.id # 1
result.public_domain? # true/false
result.svg_url # url/nil
result.preview_url # 200 size preview url
result.preview_url(42) # 42 size preview url

# You can always access the original Hash at
result.original_hash

Disclaimer

This is completely unofficial and is not related to The Noun Project in any way.

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Added some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

About Tailor Brands

Check us out!

noun-project-api's People

Contributors

nadavshatz avatar shepardtone avatar

Watchers

 avatar

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.