{"id":15792873,"url":"https://github.com/toshimaru/rack-simple_user_agent","last_synced_at":"2025-04-15T06:53:16.609Z","repository":{"id":7787503,"uuid":"56515600","full_name":"toshimaru/rack-simple_user_agent","owner":"toshimaru","description":"Rack::SimpleUserAgent is stupidly simple UA detector","archived":false,"fork":false,"pushed_at":"2025-03-04T18:34:38.000Z","size":85,"stargazers_count":13,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-15T06:53:11.130Z","etag":null,"topics":["gem","rack","rails","sinatra"],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/toshimaru.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE.txt","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"toshimaru"}},"created_at":"2016-04-18T14:39:29.000Z","updated_at":"2025-03-04T18:34:21.000Z","dependencies_parsed_at":"2024-02-16T22:25:11.528Z","dependency_job_id":"96c4811e-16b8-4d9a-946a-bb8040396ae3","html_url":"https://github.com/toshimaru/rack-simple_user_agent","commit_stats":{"total_commits":74,"total_committers":2,"mean_commits":37.0,"dds":"0.28378378378378377","last_synced_commit":"148393ec8c28d223a88f3d5ab7b9bafd7d059fd6"},"previous_names":[],"tags_count":14,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/toshimaru%2Frack-simple_user_agent","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/toshimaru%2Frack-simple_user_agent/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/toshimaru%2Frack-simple_user_agent/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/toshimaru%2Frack-simple_user_agent/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/toshimaru","download_url":"https://codeload.github.com/toshimaru/rack-simple_user_agent/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249023711,"owners_count":21199958,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["gem","rack","rails","sinatra"],"created_at":"2024-10-04T23:06:16.097Z","updated_at":"2025-04-15T06:53:16.600Z","avatar_url":"https://github.com/toshimaru.png","language":"Ruby","funding_links":["https://github.com/sponsors/toshimaru"],"categories":[],"sub_categories":[],"readme":"# Rack::SimpleUserAgent\n\n[![Gem Version](https://badge.fury.io/rb/rack-simple_user_agent.svg)](https://badge.fury.io/rb/rack-simple_user_agent)\n![Test](https://github.com/toshimaru/rack-simple_user_agent/workflows/Test/badge.svg)\n![RuboCop](https://github.com/toshimaru/rack-simple_user_agent/workflows/RuboCop/badge.svg)\n[![Test Coverage](https://api.codeclimate.com/v1/badges/576b6f673fc00d07da0d/test_coverage)](https://codeclimate.com/github/toshimaru/rack-simple_user_agent/test_coverage)\n[![Code Climate](https://codeclimate.com/github/toshimaru/rack-simple_user_agent/badges/gpa.svg)](https://codeclimate.com/github/toshimaru/rack-simple_user_agent)\n\n`Rack::SimpleUserAgent` is `Rack::Request` extension which detects user-agent from user-agent string. No complicated logic for the detection, it simply(stupidly) checks if user-agent includes particular string or not.\n\n## Installation\n\nAdd this line to your application's `Gemfile`:\n\n```ruby\ngem 'rack-simple_user_agent'\n```\n\n## Available Detection Methods\n\n```\nrequest ─ from_smartdevice?\n        │ ├─ from_ios?\n        │ ├─ from_android?\n        │ └─ from_windows_phone?\n        │\n        ├ from_smartphone?\n        │ ├─ from_android_mobile?\n        │ ├─ from_iphone?\n        │ ├─ from_ipod?\n        │ └─ from_windows_phone?\n        │\n        ├ from_tablet?\n        │ ├─ from_ipad?\n        │ └─ from_android_tablet?\n        │\n        └ from_googlebot?\n          ├─ from_googlebot_news?\n          ├─ from_googlebot_images?\n          └─ from_googlebot_video?\n```\n\n## Usage\n\n### on Rails\n\nInstalling `rack-simple_user_agent` automatically makes all detection methods available.\n\n#### Action Pack Variants Usage\n\nThese methods are useful when you use the Rails' [Action Pack Variants](http://guides.rubyonrails.org/4_1_release_notes.html#action-pack-variants) (as of Rails4.1).\n\n```rb\nclass ApplicationController \u003c ActionController::Base\n  before_action :set_request_variant\n\n  def set_request_variant\n    request.variant = :smartphone if request.from_smartphone?\n  end\nend\n```\n\nThen, you can use two types of view. For example:\n\n```\napp/views/projects/show.html.erb\napp/views/projects/show.html+smartphone.erb\n```\n\n### on Sinatra\n\n```rb\nrequire \"sinatra\"\nrequire \"rack/simple_user_agent\"\n\nconfigure do\n  use Rack::SimpleUserAgent\nend\n\nget \"/\" do\n  if request.from_smartphone?\n    \"Hello World from smartphone\"\n  elsif request.from_tablet?\n    \"Hello World from tablet\"\n  else\n    \"Hello World\"\n  end\nend\n```\n\n## Testing\n\n```bash\nbundle exec rake test\n```\n\n## Development\n\nAfter checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.\n\nTo install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).\n\n## Contributing\n\nBug reports and pull requests are welcome on GitHub at https://github.com/toshimaru/rack-simple_user_agent. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.\n\n## License\n\nThe gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).\n\n## Code of Conduct\n\nEveryone interacting in the BundledGem project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](./CODE_OF_CONDUCT.md).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftoshimaru%2Frack-simple_user_agent","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftoshimaru%2Frack-simple_user_agent","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftoshimaru%2Frack-simple_user_agent/lists"}