Permalink
Browse files

Initial release

  • Loading branch information...
0 parents commit 3746499906339a3f8af692eaa719268dbc03d2df @fnando committed Jul 16, 2010
Showing with 777 additions and 0 deletions.
  1. +3 −0 .gitignore
  2. +69 −0 README.rdoc
  3. +48 −0 Rakefile
  4. +41 −0 browser.gemspec
  5. +319 −0 lib/browser.rb
  6. +17 −0 lib/browser/action_controller.rb
  7. +8 −0 lib/browser/version.rb
  8. +272 −0 test/browser_test.rb
@@ -0,0 +1,3 @@
+pkg
+coverage
+doc
@@ -0,0 +1,69 @@
+= Browser
+
+Do some browser detection with Ruby. Includes ActionController integration.
+
+== Installation
+
+ gem install browser
+
+== Usage
+
+ require "rubygems"
+ require "browser"
+
+ browser = Browser.new(:ua => "some string", :accept_language => "en-us")
+ browser.safari?
+ browser.opera?
+ browser.mobile?
+ browser.firefox?
+ browser.ie?
+ browser.ie6? # this goes up to 9
+ browser.capable? # supports some CSS 3
+ browser.platform # return :mac, :windows, :linux or :other
+ browser.mac?
+ browser.windows?
+ browser.linux?
+ browser.meta # an array with several attributes
+ browser.to_s # the meta info joined by space
+
+See the tests for more examples.
+
+=== Rails integration
+
+Just add it to the Gemfile or `environment.rb`, depending of your Rails version.
+
+ gem "browser" #=> Rails 3
+ config.gem "browser" #=> Rails 2
+
+This adds a helper method called `browser`, that inspects your current user agent.
+
+ <% if browser.ie6? %>
+ <p class="disclaimer">Your're running an older IE version. Please update it!</p>
+ <% end %>
+
+== Maintainer
+
+* Nando Vieira - http://nandovieira.com.br
+
+== License
+
+(The MIT License)
+
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of this software and associated documentation files (the
+'Software'), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,48 @@
+require "rcov/rcovtask"
+require "rake/testtask"
+require "rake/rdoctask"
+require "lib/browser/version"
+
+Rcov::RcovTask.new do |t|
+ t.test_files = FileList["test/**/*_test.rb"]
+ t.rcov_opts = ["--sort coverage", "--exclude .gem"]
+
+ t.output_dir = "coverage"
+ t.libs << "test"
+ t.verbose = true
+end
+
+Rake::TestTask.new do |t|
+ t.libs << "lib"
+ t.libs << "test"
+ t.test_files = FileList["test/**/*_test.rb"]
+ t.verbose = true
+ t.ruby_opts = %w[-rubygems]
+end
+
+Rake::RDocTask.new do |rdoc|
+ rdoc.main = "README.rdoc"
+ rdoc.rdoc_dir = "doc"
+ rdoc.title = "Browser API"
+ rdoc.options += %w[ --line-numbers --inline-source --charset utf-8 ]
+ rdoc.rdoc_files.include("README.rdoc")
+ rdoc.rdoc_files.include("lib/**/*.rb")
+end
+
+begin
+ require "jeweler"
+
+ Jeweler::Tasks.new do |gem|
+ gem.name = "browser"
+ gem.email = "fnando.vieira@gmail.com"
+ gem.homepage = "http://github.com/fnando/browser"
+ gem.authors = ["Nando Vieira"]
+ gem.version = Browser::Version::STRING
+ gem.summary = "Do some browser detection with Ruby."
+ gem.files = FileList["README.rdoc", "{lib,test}/**/*", "Rakefile"]
+ end
+
+ Jeweler::GemcutterTasks.new
+rescue LoadError => e
+ puts "You need to install jeweler to build this gem."
+end
@@ -0,0 +1,41 @@
+# Generated by jeweler
+# DO NOT EDIT THIS FILE DIRECTLY
+# Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
+# -*- encoding: utf-8 -*-
+
+Gem::Specification.new do |s|
+ s.name = %q{browser}
+ s.version = "0.1.0"
+
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
+ s.authors = ["Nando Vieira"]
+ s.date = %q{2010-07-16}
+ s.email = %q{fnando.vieira@gmail.com}
+ s.extra_rdoc_files = [
+ "README.rdoc"
+ ]
+ s.files = [
+ "README.rdoc",
+ "Rakefile",
+ "lib/browser.rb",
+ "lib/browser/action_controller.rb",
+ "lib/browser/version.rb",
+ "test/browser_test.rb"
+ ]
+ s.homepage = %q{http://github.com/fnando/browser}
+ s.rdoc_options = ["--charset=UTF-8"]
+ s.require_paths = ["lib"]
+ s.rubygems_version = %q{1.3.7}
+ s.summary = %q{Do some browser detection with Ruby.}
+
+ if s.respond_to? :specification_version then
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
+ s.specification_version = 3
+
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
+ else
+ end
+ else
+ end
+end
+
Oops, something went wrong.

0 comments on commit 3746499

Please sign in to comment.