rack-simple_user_agent 0.4.0 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/FUNDING.yml +1 -0
- data/.github/workflows/rubocop.yml +14 -0
- data/.rubocop.yml +9 -0
- data/.rubocop_todo.yml +20 -0
- data/.travis.yml +2 -1
- data/CHANGELOG.md +1 -0
- data/Gemfile +10 -0
- data/Rakefile +7 -5
- data/bin/console +3 -6
- data/lib/rack/simple_user_agent/detectors/android.rb +3 -1
- data/lib/rack/simple_user_agent/detectors/bot.rb +6 -4
- data/lib/rack/simple_user_agent/detectors/ios.rb +5 -3
- data/lib/rack/simple_user_agent/detectors/windows_phone.rb +3 -1
- data/lib/rack/simple_user_agent/detectors.rb +6 -4
- data/lib/rack/simple_user_agent/railtie.rb +3 -1
- data/lib/rack/simple_user_agent/version.rb +3 -1
- data/lib/rack/simple_user_agent.rb +4 -2
- data/rack-simple_user_agent.gemspec +13 -19
- metadata +10 -104
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e5095cb34b40a6038ba15a5d77f7038d89193d7aa5f15b16202b13b54a484cac
|
4
|
+
data.tar.gz: cf962764c650b73ab17b821c3c3b51e07b0fb86cecc4150b99c1c464a1ece0be
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2e01b736edfdefa5d47feed11abad62cedf5fa50ce7d40376b5d47911b93d4342ffc0610316e48eb4c1689f5af4ff2ed0052b83a9e5bb490729f8fe809ef662c
|
7
|
+
data.tar.gz: 4edfc9e7a3f8f0861b84a78d8eee809749c4fcbcfee4a19ad0c7559dc9e155a43ca5de6b0c0844b85949534e44a53d0bd15891f7670bcda15096eded048c626e
|
data/.github/FUNDING.yml
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
github: toshimaru
|
@@ -0,0 +1,14 @@
|
|
1
|
+
name: RuboCop
|
2
|
+
on: [pull_request]
|
3
|
+
jobs:
|
4
|
+
build:
|
5
|
+
runs-on: ubuntu-latest
|
6
|
+
name: rubocop
|
7
|
+
steps:
|
8
|
+
- uses: actions/checkout@v2
|
9
|
+
- name: Set up Ruby
|
10
|
+
uses: actions/setup-ruby@v1
|
11
|
+
with:
|
12
|
+
ruby-version: 2.6
|
13
|
+
- run: bundle install
|
14
|
+
- run: bundle exec rubocop
|
data/.rubocop.yml
ADDED
data/.rubocop_todo.yml
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
# This configuration was generated by
|
2
|
+
# `rubocop --auto-gen-config`
|
3
|
+
# on 2020-03-13 18:11:21 +0900 using RuboCop version 0.80.1.
|
4
|
+
# The point is for the user to remove these configuration records
|
5
|
+
# one by one as the offenses are removed from the code base.
|
6
|
+
# Note that changes in the inspected code, or installation of new
|
7
|
+
# versions of RuboCop, may require this file to be generated again.
|
8
|
+
|
9
|
+
# Offense count: 8
|
10
|
+
Style/Documentation:
|
11
|
+
Exclude:
|
12
|
+
- 'spec/**/*'
|
13
|
+
- 'test/**/*'
|
14
|
+
- 'lib/rack/simple_user_agent.rb'
|
15
|
+
- 'lib/rack/simple_user_agent/detectors.rb'
|
16
|
+
- 'lib/rack/simple_user_agent/detectors/android.rb'
|
17
|
+
- 'lib/rack/simple_user_agent/detectors/bot.rb'
|
18
|
+
- 'lib/rack/simple_user_agent/detectors/ios.rb'
|
19
|
+
- 'lib/rack/simple_user_agent/detectors/windows_phone.rb'
|
20
|
+
- 'lib/rack/simple_user_agent/railtie.rb'
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
Changelog is maintained under [Github Releases](https://github.com/toshimaru/rack-simple_user_agent/releases).
|
data/Gemfile
CHANGED
@@ -1,4 +1,14 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
source 'https://rubygems.org'
|
2
4
|
|
3
5
|
# Specify your gem's dependencies in rack-simple_user_agent.gemspec
|
4
6
|
gemspec
|
7
|
+
|
8
|
+
gem 'coveralls'
|
9
|
+
gem 'minitest', '~> 5.0'
|
10
|
+
gem 'minitest-reporters'
|
11
|
+
gem 'rack-test'
|
12
|
+
gem 'rake'
|
13
|
+
gem 'rubocop'
|
14
|
+
gem 'rubocop-minitest'
|
data/Rakefile
CHANGED
@@ -1,10 +1,12 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'bundler/gem_tasks'
|
4
|
+
require 'rake/testtask'
|
3
5
|
|
4
6
|
Rake::TestTask.new(:test) do |t|
|
5
|
-
t.libs <<
|
6
|
-
t.libs <<
|
7
|
+
t.libs << 'test'
|
8
|
+
t.libs << 'lib'
|
7
9
|
t.test_files = FileList['test/**/*_test.rb']
|
8
10
|
end
|
9
11
|
|
10
|
-
task :
|
12
|
+
task default: :test
|
data/bin/console
CHANGED
@@ -1,11 +1,8 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
2
3
|
|
3
|
-
require
|
4
|
-
require
|
4
|
+
require 'bundler/setup'
|
5
|
+
require 'rack/simple_user_agent'
|
5
6
|
|
6
7
|
# You can add fixtures and/or initialization code here to make experimenting
|
7
8
|
# with your gem easier. You can also use a different console, if you like.
|
8
|
-
|
9
|
-
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
-
require "pry"
|
11
|
-
Pry.start
|
@@ -1,21 +1,23 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Rack
|
2
4
|
class SimpleUserAgent
|
3
5
|
module Detectors
|
4
6
|
module Bot
|
5
7
|
def from_googlebot?
|
6
|
-
user_agent_string.include?(
|
8
|
+
user_agent_string.include?('Googlebot')
|
7
9
|
end
|
8
10
|
|
9
11
|
def from_googlebot_news?
|
10
|
-
user_agent_string.include?(
|
12
|
+
user_agent_string.include?('Googlebot-News')
|
11
13
|
end
|
12
14
|
|
13
15
|
def from_googlebot_images?
|
14
|
-
user_agent_string.include?(
|
16
|
+
user_agent_string.include?('Googlebot-Image')
|
15
17
|
end
|
16
18
|
|
17
19
|
def from_googlebot_video?
|
18
|
-
user_agent_string.include?(
|
20
|
+
user_agent_string.include?('Googlebot-Video')
|
19
21
|
end
|
20
22
|
end
|
21
23
|
end
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Rack
|
2
4
|
class SimpleUserAgent
|
3
5
|
module Detectors
|
@@ -7,15 +9,15 @@ module Rack
|
|
7
9
|
end
|
8
10
|
|
9
11
|
def from_iphone?
|
10
|
-
user_agent_string.include?(
|
12
|
+
user_agent_string.include?('iPhone;')
|
11
13
|
end
|
12
14
|
|
13
15
|
def from_ipad?
|
14
|
-
user_agent_string.include?(
|
16
|
+
user_agent_string.include?('iPad;')
|
15
17
|
end
|
16
18
|
|
17
19
|
def from_ipod?
|
18
|
-
user_agent_string.include?(
|
20
|
+
user_agent_string.include?('iPod touch;')
|
19
21
|
end
|
20
22
|
end
|
21
23
|
end
|
@@ -1,7 +1,9 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
require
|
4
|
-
require
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'rack/simple_user_agent/detectors/android'
|
4
|
+
require 'rack/simple_user_agent/detectors/bot'
|
5
|
+
require 'rack/simple_user_agent/detectors/ios'
|
6
|
+
require 'rack/simple_user_agent/detectors/windows_phone'
|
5
7
|
|
6
8
|
module Rack
|
7
9
|
class SimpleUserAgent
|
@@ -1,7 +1,9 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Rack
|
2
4
|
class SimpleUserAgent
|
3
5
|
class Railtie < ::Rails::Railtie
|
4
|
-
initializer
|
6
|
+
initializer 'rack-simple_user_agent.configure_rails_initialization' do |app|
|
5
7
|
app.config.middleware.use Rack::SimpleUserAgent
|
6
8
|
|
7
9
|
ActiveSupport.on_load(:action_controller) do
|
@@ -1,5 +1,7 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'rack/simple_user_agent/version'
|
4
|
+
require 'rack/simple_user_agent/detectors'
|
3
5
|
require 'rack/simple_user_agent/railtie' if defined?(Rails)
|
4
6
|
|
5
7
|
module Rack
|
@@ -1,30 +1,24 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
lib = File.expand_path('lib', __dir__)
|
2
4
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
5
|
require 'rack/simple_user_agent/version'
|
4
6
|
|
5
7
|
Gem::Specification.new do |spec|
|
6
|
-
spec.name =
|
8
|
+
spec.name = 'rack-simple_user_agent'
|
7
9
|
spec.version = Rack::SimpleUserAgent::VERSION
|
8
|
-
spec.authors = [
|
9
|
-
spec.email = [
|
10
|
+
spec.authors = ['toshimaru']
|
11
|
+
spec.email = ['me@toshimaru.net']
|
10
12
|
|
11
|
-
spec.summary =
|
12
|
-
spec.description =
|
13
|
-
spec.homepage =
|
14
|
-
spec.license =
|
13
|
+
spec.summary = 'Rack::SimpleUserAgent is stupidly simple UA detector'
|
14
|
+
spec.description = '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.'
|
15
|
+
spec.homepage = 'https://github.com/toshimaru/rack-simple_user_agent'
|
16
|
+
spec.license = 'MIT'
|
15
17
|
|
16
18
|
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features|sample)/}) }
|
17
|
-
spec.bindir =
|
19
|
+
spec.bindir = 'exe'
|
18
20
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
19
|
-
spec.require_paths = [
|
20
|
-
|
21
|
-
spec.required_ruby_version = ">= 2.2.2"
|
21
|
+
spec.require_paths = ['lib']
|
22
22
|
|
23
|
-
spec.
|
24
|
-
spec.add_development_dependency "rake", "~> 11.0"
|
25
|
-
spec.add_development_dependency "minitest", "~> 5.0"
|
26
|
-
spec.add_development_dependency "minitest-reporters"
|
27
|
-
spec.add_development_dependency "pry"
|
28
|
-
spec.add_development_dependency "rack-test"
|
29
|
-
spec.add_development_dependency "coveralls"
|
23
|
+
spec.required_ruby_version = '>= 2.3'
|
30
24
|
end
|
metadata
CHANGED
@@ -1,113 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rack-simple_user_agent
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- toshimaru
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
12
|
-
dependencies:
|
13
|
-
- !ruby/object:Gem::Dependency
|
14
|
-
name: bundler
|
15
|
-
requirement: !ruby/object:Gem::Requirement
|
16
|
-
requirements:
|
17
|
-
- - "~>"
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: '1.11'
|
20
|
-
type: :development
|
21
|
-
prerelease: false
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
23
|
-
requirements:
|
24
|
-
- - "~>"
|
25
|
-
- !ruby/object:Gem::Version
|
26
|
-
version: '1.11'
|
27
|
-
- !ruby/object:Gem::Dependency
|
28
|
-
name: rake
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
30
|
-
requirements:
|
31
|
-
- - "~>"
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: '11.0'
|
34
|
-
type: :development
|
35
|
-
prerelease: false
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
37
|
-
requirements:
|
38
|
-
- - "~>"
|
39
|
-
- !ruby/object:Gem::Version
|
40
|
-
version: '11.0'
|
41
|
-
- !ruby/object:Gem::Dependency
|
42
|
-
name: minitest
|
43
|
-
requirement: !ruby/object:Gem::Requirement
|
44
|
-
requirements:
|
45
|
-
- - "~>"
|
46
|
-
- !ruby/object:Gem::Version
|
47
|
-
version: '5.0'
|
48
|
-
type: :development
|
49
|
-
prerelease: false
|
50
|
-
version_requirements: !ruby/object:Gem::Requirement
|
51
|
-
requirements:
|
52
|
-
- - "~>"
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
version: '5.0'
|
55
|
-
- !ruby/object:Gem::Dependency
|
56
|
-
name: minitest-reporters
|
57
|
-
requirement: !ruby/object:Gem::Requirement
|
58
|
-
requirements:
|
59
|
-
- - ">="
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: '0'
|
62
|
-
type: :development
|
63
|
-
prerelease: false
|
64
|
-
version_requirements: !ruby/object:Gem::Requirement
|
65
|
-
requirements:
|
66
|
-
- - ">="
|
67
|
-
- !ruby/object:Gem::Version
|
68
|
-
version: '0'
|
69
|
-
- !ruby/object:Gem::Dependency
|
70
|
-
name: pry
|
71
|
-
requirement: !ruby/object:Gem::Requirement
|
72
|
-
requirements:
|
73
|
-
- - ">="
|
74
|
-
- !ruby/object:Gem::Version
|
75
|
-
version: '0'
|
76
|
-
type: :development
|
77
|
-
prerelease: false
|
78
|
-
version_requirements: !ruby/object:Gem::Requirement
|
79
|
-
requirements:
|
80
|
-
- - ">="
|
81
|
-
- !ruby/object:Gem::Version
|
82
|
-
version: '0'
|
83
|
-
- !ruby/object:Gem::Dependency
|
84
|
-
name: rack-test
|
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
|
-
- !ruby/object:Gem::Dependency
|
98
|
-
name: coveralls
|
99
|
-
requirement: !ruby/object:Gem::Requirement
|
100
|
-
requirements:
|
101
|
-
- - ">="
|
102
|
-
- !ruby/object:Gem::Version
|
103
|
-
version: '0'
|
104
|
-
type: :development
|
105
|
-
prerelease: false
|
106
|
-
version_requirements: !ruby/object:Gem::Requirement
|
107
|
-
requirements:
|
108
|
-
- - ">="
|
109
|
-
- !ruby/object:Gem::Version
|
110
|
-
version: '0'
|
11
|
+
date: 2020-03-13 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
111
13
|
description: Rack::SimpleUserAgent is Rack::Request extension which detects user-agent
|
112
14
|
from user-agent string. No complicated logic for the detection, it simply(stupidly)
|
113
15
|
checks if user-agent includes particular string or not.
|
@@ -117,8 +19,13 @@ executables: []
|
|
117
19
|
extensions: []
|
118
20
|
extra_rdoc_files: []
|
119
21
|
files:
|
22
|
+
- ".github/FUNDING.yml"
|
23
|
+
- ".github/workflows/rubocop.yml"
|
120
24
|
- ".gitignore"
|
25
|
+
- ".rubocop.yml"
|
26
|
+
- ".rubocop_todo.yml"
|
121
27
|
- ".travis.yml"
|
28
|
+
- CHANGELOG.md
|
122
29
|
- CODE_OF_CONDUCT.md
|
123
30
|
- Gemfile
|
124
31
|
- LICENSE.txt
|
@@ -147,15 +54,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
147
54
|
requirements:
|
148
55
|
- - ">="
|
149
56
|
- !ruby/object:Gem::Version
|
150
|
-
version: 2.
|
57
|
+
version: '2.3'
|
151
58
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
152
59
|
requirements:
|
153
60
|
- - ">="
|
154
61
|
- !ruby/object:Gem::Version
|
155
62
|
version: '0'
|
156
63
|
requirements: []
|
157
|
-
|
158
|
-
rubygems_version: 2.7.6
|
64
|
+
rubygems_version: 3.1.2
|
159
65
|
signing_key:
|
160
66
|
specification_version: 4
|
161
67
|
summary: Rack::SimpleUserAgent is stupidly simple UA detector
|