which_browser
所属分类:WEB开发
开发工具:Ruby
文件大小:10KB
下载次数:0
上传日期:2013-09-12 06:00:38
上 传 者:
sh-1993
说明: 哪个浏览器向机架请求添加了一些帮助器方法。
(Which Browser adds a few helper methods to a rack request.)
文件列表:
.travis.yml (61, 2013-09-12)
Gemfile (97, 2013-09-12)
LICENSE (1545, 2013-09-12)
Rakefile (190, 2013-09-12)
lib (0, 2013-09-12)
lib\which_browser.rb (3284, 2013-09-12)
lib\which_browser (0, 2013-09-12)
lib\which_browser\version.rb (44, 2013-09-12)
test (0, 2013-09-12)
test\dummy (0, 2013-09-12)
test\dummy\app.rb (775, 2013-09-12)
test\helper.rb (6861, 2013-09-12)
test\test_chrome.rb (540, 2013-09-12)
test\test_firefox.rb (530, 2013-09-12)
test\test_internet_explorer.rb (1875, 2013-09-12)
test\test_mobile.rb (1198, 2013-09-12)
test\test_os.rb (519, 2013-09-12)
test\test_safari.rb (370, 2013-09-12)
which_browser.gemspec (1049, 2013-09-12)
# Which Browser [![Build Status](https://secure.travis-ci.org/citrus/which_browser.png)](http://travis-ci.org/citrus/which_browser)
### Check for user agents like a boss!
Which Browser adds a few helper methods to a rack request so you can write cleaner browser-related logic.
For example, the age old battle against IE 5 & 6 can be handled like so:
stylesheet_link_tag "ie" if request.ie_lt7?
And for a nice browser warning:
- if request.ie6?
IE6 makes the internet suck.
- elsif request.ie5?
You've got to be kidding me.
Or in your rails controller, decide which layout:
render :layout => request.mobile? ? 'mobile' : 'application'
Here's some other popular helpers:
request.ie?
request.ie6?
request.ie_lt6?
request.ie_gte7?
request.mobile?
request.ipad?
request.ipod?
request.iphone?
request.mobile_safari?
request.blackberry?
Installation
------------
As usual, just use the `gem install` command:
(sudo) gem install which_browser
Or add which_browser as a gem in your Gemfile:
gem 'which_browser', '>= 0.2.3'
Then run `bundle install`
Testing
-------
Tests can be run with:
git clone git://github.com/citrus/which_browser.git
cd which_browser
bundle
bundle exec rake
There is also a sinatra app in `test/dummy` for a demo and real-life testing. Install sinatra (`gem install sinatra`) if you don't have it, then run:
cd which_browser
ruby test/dummy/app.rb
Now open your browser to [http://localhost:4567](http://localhost:4567) and fiddle with your user agent.
License
-------
Copyright (c) 2013 Spencer Steffen and Citrus, released under the New BSD License All rights reserved.
近期下载者:
相关文件:
收藏者: