rack-simple_user_agent 0.1.1 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.travis.yml +2 -1
- data/README.md +41 -11
- data/Rakefile +1 -1
- data/lib/rack/simple_user_agent/detector.rb +5 -5
- data/lib/rack/simple_user_agent/version.rb +1 -1
- data/rack-simple_user_agent.gemspec +2 -1
- metadata +19 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 26be151d208e1fa3bc6cb600f274def1c876cfc9
|
4
|
+
data.tar.gz: cdeb511a0a0d66071fa9c2b0e3ae3ec9b9c3ac2d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c314d2f3cd9207a35ce535d3fe19883e8fe3ddce5b4452ac067e0aca664cf24abafb841e79c1ed02979afca2d4cf3ad947b8dca1d24348edd6ed4a9c1fdcdc53
|
7
|
+
data.tar.gz: 1b6ebcbc3501af757c4af60a65bcba0a3f2a04911d7254905f456b338a1918a0e5c6a71bad2665927763df0c42105be890bc9267cf3371c58209685834cfb2f6
|
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -1,8 +1,11 @@
|
|
1
1
|
# Rack::SimpleUserAgent
|
2
2
|
|
3
|
-
|
3
|
+
[](https://badge.fury.io/rb/rack-simple_user_agent)
|
4
|
+
[](https://travis-ci.org/toshimaru/rack-simple_user_agent)
|
5
|
+
[](https://coveralls.io/github/toshimaru/rack-simple_user_agent)
|
6
|
+
[](https://codeclimate.com/github/toshimaru/rack-simple_user_agent)
|
4
7
|
|
5
|
-
|
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
|
-
|
18
|
+
## Usage
|
16
19
|
|
17
|
-
|
20
|
+
### on Rails
|
18
21
|
|
19
|
-
|
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
|
-
|
24
|
+
- `request.from_smartphone?`
|
25
|
+
- `request.from_android?`
|
26
|
+
- `request.from_iphone?`
|
27
|
+
- `request.from_windows_phone?`
|
22
28
|
|
23
|
-
|
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
|
-
|
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/
|
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
@@ -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
|
37
|
+
user_agent.to_s.include?("Windows Phone")
|
38
38
|
end
|
39
39
|
|
40
40
|
private
|
@@ -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
|
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.
|
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-
|
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
|
-
|
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: []
|