🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
DemoInstallSign in
Socket

yandex_detector

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

yandex_detector

0.0.2
Rubygems
Version published
Maintainers
1
Created
Source

Introduction

yandex_detector is a Ruby 1.9.2 wrapper for Yandex.Detector API (http://api.yandex.ru/detector/) wich allows to detect mobile device's properties by it's request headers.

This document describes installation and usage of yandex_detector.

Please report issues on Github.

For feedback, suggestions, etc. write to aishek@gmail.com.

Build Status

Installation

To install:

gem install yandex_detector

or with a Gemfile:

gem 'yandex_detector'
bundle install

Usage

Usage in Rails:

require 'yandex_detector'

# API call timeout in seconds (default is 2 seconds)
timeout = 2

result = YandexDetector.detect request.headers, timeout

Usage in Ruby program:

require 'yandex_detector'

# HTTP headers, you need at least one to perform detect
headers = Hash.new[
  'user-agent',           'value1'
  'profile',              'value2',
  'wap-profile',          'value3',
  'x-wap-profile',        'value4',
  'x-operamini-phone-ua', 'value1'
]
# API call timeout in seconds (default is 2 seconds)
timeout = 2

result = YandexDetector.detect headers, timeout

Result object have following helpers:

result.error?
result.error_message

result.success?
result.iphone?
result.android?
result.blackberry?

Please, see complete list of available helpers.

Documentation

The RubyDoc documentation is available online.

How it works

yandex_detector perform Yandex's API service call via network if there are at least one of needed headers provided. Please, consider right timeout value and fallback on timeout for your application to prevent slow execution.

Author

Idea & implementation — Alexandr Borisov (aishek@gmail.com)

Licence

yandex_detector is licensed under MIT

FAQs

Package last updated on 15 Oct 2011

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts