Coder Social home page Coder Social logo

yandex-api's Introduction

Yandex::API

Gem Version

Allow you work with any Yandex.APIs

Modules:

Installation

Add this line to your application's Gemfile:

gem 'yandex-api'

And then execute:

$ bundle

Or install it yourself as:

$ gem install yandex-api

Direct

Ruby:

Create configuration file yandex_direct.yml

token: token
login: login
locale: ru
verbose: true
sandbox: true

Ruby On Rails:

Create configuration file yandex_direct.yml

development:
    token: token
    login: login
    locale: ru
    verbose: true
    sandbox: true

Create yandex_direct.rb in config/initializers

Yandex::API::Direct.load File.join(Rails.root,"config","yandex_direct.yml"), Rails.env

Simple example:

require 'yandex-api'
Yandex::API::Direct.load "yandex_direct.yml"

campaign = Yandex::API::Direct::CampaignInfo.list.first
puts campaign.inspect
puts campaign.banners.first.inspect

Translate

Ruby:

Create configuration file yandex_translate.yml

token: "token"
ui: true
verbose: true

Ruby On Rails:

Create configuration file yandex_translate.yml

development:
    token: "token"
    ui: "ru"
    verbose: true

Create yandex_translate.rb in config/initializers

Yandex::API::Translate.load File.join(Rails.root,"config","yandex_translate.yml"), Rails.env

Simple example

require 'yandex-api'
Yandex::API::Translate.load "yandex.yml", "production"

puts Yandex::API::Translate.languages.inspect
puts Yandex::API::Translate.detect('test').inspect
puts Yandex::API::Translate.do('Hello GitHub', 'ru').inspect

Disk

Create configuration file yandex_disk.yml

token: "token"
verbose: true

Ruby On Rails:

Create configuration file yandex_disk.yml

development:
    token: "token"
    verbose: true

Simple example

require 'yandex-api'
Yandex::API::Disk.load "yandex_disk.yml", "production"

include Yandex::API::Disk

storage = Storage.new
puts "Storage:\n\ttrash: #{storage.trash_size} bytes\n\ttotal: #{storage.total_space} bytes\n\tused: #{storage.used_space} bytes"
Storage.upload(File.open('foo'), 'disk:/bar')
Storage.move('disk:/bar', 'disk:/foo')
Storage.rm('disk:/foo')
Storage.clean('disk:/foo')

Storage class has methods

Storage.rm(path)            # remove directory
Storage.write(file, path)   # upload file to path
Storage.move(from, to)      # move file from -> to
Storage.copy(from, to)      # copy file form -> to
Storage.clean(path)         # clean trash (if path nil, clena all)
Storage.mkdir(path)         # create directory
Storage.exists?(path)       # existing path or not?

Contributing

  1. Fork it ( https://github.com/jpascal/yandex-api/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

yandex-api's People

Contributors

arrowcircle avatar jpascal avatar lloydpick avatar

Watchers

 avatar  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.