rack-simple_user_agent 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3309a48be2e5b525ef4c973d4e869a68eef979f0
4
- data.tar.gz: 337689d03919bf637f7aa9656096008740154ac4
3
+ metadata.gz: 26be151d208e1fa3bc6cb600f274def1c876cfc9
4
+ data.tar.gz: cdeb511a0a0d66071fa9c2b0e3ae3ec9b9c3ac2d
5
5
  SHA512:
6
- metadata.gz: 80142413c71166bee2d37b6fd6309a3fb6d87e7afb986240841332be4eb7173d8907bd1833f2f63b2d75314698b35d98410596b3cf262fcdfa7791d1ef291048
7
- data.tar.gz: 9622528fbe51c5e03f03ab82123ebde1d2da8fe4f3bc92b71d0f9425068f62ca82ba6400968bb5c2dbaff6f4fa74f59775927decb4fb10dba1597379a7808cc1
6
+ metadata.gz: c314d2f3cd9207a35ce535d3fe19883e8fe3ddce5b4452ac067e0aca664cf24abafb841e79c1ed02979afca2d4cf3ad947b8dca1d24348edd6ed4a9c1fdcdc53
7
+ data.tar.gz: 1b6ebcbc3501af757c4af60a65bcba0a3f2a04911d7254905f456b338a1918a0e5c6a71bad2665927763df0c42105be890bc9267cf3371c58209685834cfb2f6
data/.travis.yml CHANGED
@@ -1,4 +1,5 @@
1
1
  language: ruby
2
2
  rvm:
3
- - 2.2.4
3
+ - 2.2
4
+ - 2.3.0
4
5
  before_install: gem install bundler -v 1.11.2
data/README.md CHANGED
@@ -1,8 +1,11 @@
1
1
  # Rack::SimpleUserAgent
2
2
 
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/rack/simple_user_agent`. To experiment with that code, run `bin/console` for an interactive prompt.
3
+ [![Gem Version](https://badge.fury.io/rb/rack-simple_user_agent.svg)](https://badge.fury.io/rb/rack-simple_user_agent)
4
+ [![Build Status](https://travis-ci.org/toshimaru/rack-simple_user_agent.svg)](https://travis-ci.org/toshimaru/rack-simple_user_agent)
5
+ [![Coverage Status](https://coveralls.io/repos/github/toshimaru/rack-simple_user_agent/badge.svg)](https://coveralls.io/github/toshimaru/rack-simple_user_agent)
6
+ [![Code Climate](https://codeclimate.com/github/toshimaru/rack-simple_user_agent/badges/gpa.svg)](https://codeclimate.com/github/toshimaru/rack-simple_user_agent)
4
7
 
5
- TODO: Delete this and the text above, and describe your gem
8
+ Rack::SimpleUserAgent is Rack::Request extension which detects smartphone from user-agent string. There is no complicated logic for the detection, it simply checks if user-agent includes particular string.
6
9
 
7
10
  ## Installation
8
11
 
@@ -12,17 +15,46 @@ Add this line to your application's Gemfile:
12
15
  gem 'rack-simple_user_agent'
13
16
  ```
14
17
 
15
- And then execute:
18
+ ## Usage
16
19
 
17
- $ bundle
20
+ ### on Rails
18
21
 
19
- Or install it yourself as:
22
+ Bundling 'rack-simple_user_agent' automatically makes Rack::SimpleUserAgent methods available. It's convenient when you use the feature [Action Pack Variants](http://guides.rubyonrails.org/4_1_release_notes.html#action-pack-variants) (as of Rails4.1).
20
23
 
21
- $ gem install rack-simple_user_agent
24
+ - `request.from_smartphone?`
25
+ - `request.from_android?`
26
+ - `request.from_iphone?`
27
+ - `request.from_windows_phone?`
22
28
 
23
- ## Usage
29
+ ### on Sinatra
30
+
31
+ ```rb
32
+ require "sinatra"
33
+ require "rack/simple_user_agent"
34
+
35
+ configure do
36
+ use Rack::SimpleUserAgent
37
+ end
38
+
39
+ get "/" do
40
+ request.from_smartphone?
41
+ "Hello World!"
42
+ end
43
+ ```
24
44
 
25
- TODO: Write usage instructions here
45
+ ## Available Detection Methods
46
+
47
+ ```
48
+ request ── from_smartphone?
49
+ ├── from_android?
50
+ │   ├── from_android_mobile?
51
+ │   └── from_android_tablet?
52
+ ├── from_iphone?
53
+ │   ├── from_ipad?
54
+ │   ├── from_iphone?
55
+ │   └── from_ipod?
56
+ └── from_windows_phone?
57
+ ```
26
58
 
27
59
  ## Development
28
60
 
@@ -32,10 +64,8 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
32
64
 
33
65
  ## Contributing
34
66
 
35
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/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.
36
-
67
+ Bug 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.
37
68
 
38
69
  ## License
39
70
 
40
71
  The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
41
-
data/Rakefile CHANGED
@@ -7,4 +7,4 @@ Rake::TestTask.new(:test) do |t|
7
7
  t.test_files = FileList['test/**/*_test.rb']
8
8
  end
9
9
 
10
- task :default => :spec
10
+ task :default => :test
@@ -5,6 +5,10 @@ module Rack
5
5
  from_ios? || from_android? || from_windows_phone?
6
6
  end
7
7
 
8
+ def from_ios?
9
+ from_iphone? || from_ipad? || from_ipod?
10
+ end
11
+
8
12
  def from_iphone?
9
13
  user_agent.to_s.include?("iPhone")
10
14
  end
@@ -17,10 +21,6 @@ module Rack
17
21
  user_agent.to_s.include?("iPod")
18
22
  end
19
23
 
20
- def from_ios?
21
- from_iphone? || from_ipad? || from_ipod?
22
- end
23
-
24
24
  def from_android?
25
25
  user_agent.to_s.include?("Android")
26
26
  end
@@ -34,7 +34,7 @@ module Rack
34
34
  end
35
35
 
36
36
  def from_windows_phone?
37
- user_agent.to_s.include?("Windows Phone OS")
37
+ user_agent.to_s.include?("Windows Phone")
38
38
  end
39
39
 
40
40
  private
@@ -1,5 +1,5 @@
1
1
  module Rack
2
2
  class SimpleUserAgent
3
- VERSION = "0.1.1"
3
+ VERSION = "0.1.2"
4
4
  end
5
5
  end
@@ -9,7 +9,7 @@ Gem::Specification.new do |spec|
9
9
  spec.email = ["me@toshimaru.net"]
10
10
 
11
11
  spec.summary = %q{Rack::SimpleUserAgent is stupidly simple UA detector}
12
- spec.description = %q{Rack::SimpleUserAgent is stupidly simple UA detector mainly for smartphones.}
12
+ spec.description = %q{Rack::SimpleUserAgent is Rack::Request extension which detects smartphone from user-agent string. There is no complicated logic for the detection, it simply checks if user-agent includes particular string.}
13
13
  spec.homepage = "https://github.com/toshimaru/rack-simple_user_agent"
14
14
  spec.license = "MIT"
15
15
 
@@ -23,4 +23,5 @@ Gem::Specification.new do |spec|
23
23
  spec.add_development_dependency "minitest", "~> 5.0"
24
24
  spec.add_development_dependency "pry"
25
25
  spec.add_development_dependency "rack-test"
26
+ spec.add_development_dependency "coveralls"
26
27
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rack-simple_user_agent
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - toshimaru
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-04-20 00:00:00.000000000 Z
11
+ date: 2016-04-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -80,7 +80,23 @@ dependencies:
80
80
  - - ">="
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
- description: Rack::SimpleUserAgent is stupidly simple UA detector mainly for smartphones.
83
+ - !ruby/object:Gem::Dependency
84
+ name: coveralls
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ description: Rack::SimpleUserAgent is Rack::Request extension which detects smartphone
98
+ from user-agent string. There is no complicated logic for the detection, it simply
99
+ checks if user-agent includes particular string.
84
100
  email:
85
101
  - me@toshimaru.net
86
102
  executables: []