browserino 2.7.0 → 2.8.0

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: a8e82f74e6c1a1093e2e28dcf7d2f0e9ff74c20a
4
- data.tar.gz: cc1ae8716764953f6d176b8cf140c50907b85045
3
+ metadata.gz: efcc78c534d17dde2bd83b567a4793199e597cab
4
+ data.tar.gz: e679d761460695a698900d35678e8cd3c6222bc7
5
5
  SHA512:
6
- metadata.gz: cec0b5fa777903cf45d0bdd7eed5ccc9fb7bf89378a77c11db2a2e6b1c626b9b0d90acc9313c631c668cfc903380d8f7625713b72c7ea82a0d6110fe9c513425
7
- data.tar.gz: 6dbe5512b40e0026ac52d5e0e41d6cefe81f697e6d75500473254a481a8a1fcf550d490bc1749847d35bba96e5680e0002d8a41277721ffe4d7b80c0cf5e2c13
6
+ metadata.gz: 34072eb40764d52f819b8c75da904e62cf730a56405c4419442d87bde2f4370c66cb403b15eead60de4ffac35400df54c19aa9c62f8c08a18d3e2ac3a4e1a8ec
7
+ data.tar.gz: 7551b0fc05195265a786f40e1aff2f87643be5ecceb723ccede94dadde46a5fd784d90ade154df5f075d9d0654959a7ce97c24dfe0ee2b32b91463024865bdee
data/CHANGELOG.md CHANGED
@@ -1,6 +1,11 @@
1
1
  ## CHANGELOG
2
2
  _dates are in dd-mm-yyyy format_
3
3
 
4
+ #### 20-01-2016 VERSION 2.5.4
5
+
6
+ - formatted / refactored code with rubocop
7
+ - iOS `system_name full: true` returns the version no. of iOS if found
8
+
4
9
  #### 19-01-2016 VERSION 2.5.3
5
10
 
6
11
  - Minor refactoring of code
data/README.md CHANGED
@@ -8,11 +8,27 @@ A UserAgent sniffer with Rails >= 3.2.0 integration
8
8
  [![Build Status](https://travis-ci.org/SidOfc/browserino.svg?branch=master)](https://travis-ci.org/SidOfc/browserino)
9
9
  [![Coverage Status](https://coveralls.io/repos/SidOfc/browserino/badge.svg?branch=master&service=github)](https://coveralls.io/github/SidOfc/browserino?branch=master)
10
10
 
11
+ ---
12
+
13
+ Useragent references:
14
+
15
+ * http://useragentstring.com/
16
+ * http://www.zytrax.com/tech/web/mobile_ids.html
17
+ * http://www.user-agents.org/
18
+
11
19
  ## Changelog
12
20
 
13
21
  _dates are in dd-mm-yyyy format_
14
22
  _older changes can be found in the [CHANGELOG.md](/CHANGELOG.md)_
15
23
 
24
+ #### 26-05-2016 VERSION 2.8.0
25
+
26
+ - Added `search_engine?` method
27
+ - Added `holmes?` method
28
+ - Added `ask?` method
29
+ - Added `duckduckgo?` and alias `ddg?` methods
30
+ - Fixed `respond_to?` method signature
31
+
16
32
  #### 02-03-2016 VERSION 2.7.0
17
33
 
18
34
  - Added `solaris?` method
@@ -39,11 +55,6 @@ _older changes can be found in the [CHANGELOG.md](/CHANGELOG.md)_
39
55
  - Added support for the Brave browser and the `brave?` method
40
56
  - Added `ff?` method
41
57
 
42
- #### 20-01-2016 VERSION 2.5.4
43
-
44
- - formatted / refactored code with rubocop
45
- - iOS `system_name full: true` returns the version no. of iOS if found
46
-
47
58
  ## Installation
48
59
 
49
60
  Add the following to your applications Gemfile:
@@ -85,6 +96,17 @@ Afterwards, the gem is loaded and you can proceed by calling:
85
96
  Browserino.parse '<user agent>'
86
97
  ```
87
98
 
99
+ Browserino is also usable in the command line
100
+
101
+ ```
102
+ ~$ browserino -p <ua>
103
+ ```
104
+
105
+ Output
106
+ ```
107
+ browser_name: chrome, browser_version: 50.0.2661.102, engine_name: webkit, engine_version: 537.36, system_name: macintosh, system_architecture: nil, bot_name: nil
108
+ ```
109
+
88
110
  ### Rails (>= 3.2.0)
89
111
 
90
112
  If you're using Rails (>= 3.2.0) you'll have access to an `agent` object. Browserino will initialize itself using the `request.headers['User-Agent']`
@@ -377,13 +399,13 @@ agent.platform? :android, version: :jelly_bean_16
377
399
  # => true
378
400
  ```
379
401
 
380
- ##### `platform?`, `browser?`, `bot?` and `social_media?` methods
402
+ ##### `platform?`, `browser?`, `bot?` `search_engine?` and `social_media?` methods
381
403
 
382
404
  As you've seen above, the `platform?` function can take two arguments, a symbol with the system name and optionally a hash with a `:version` key to supply a version, the `browser?` method works in exactly the same way.
383
405
 
384
406
  The `bot?` and `social_media?` methods however aren't that complex since you don't need to know a bot / social media version or anything other than it's name so inside these methods, only a name can be passed:
385
407
 
386
- *Every social media match is automatically a bot, but a bot isn't automatically social media*
408
+ *Every social media match is automatically a bot, but a bot isn't automatically social media, __This is also true for the `search_engine?` method__*
387
409
 
388
410
  ```ruby
389
411
  # when a bot UA gets parsed
@@ -409,6 +431,26 @@ agent.bot? :facebook, version: 1.1
409
431
 
410
432
  Every name you see in the below lists can be passed as symbol or string to their respective method
411
433
 
434
+ **search engine**
435
+ * `google`
436
+ * `bing`
437
+ * `yahoo_slurp`
438
+ * `baiduspider`
439
+ * `duckduckgo` or `ddg`
440
+
441
+ Examples:
442
+
443
+ ```ruby
444
+ agent.google?
445
+ agent.baiduspider?
446
+
447
+ # using the search_engine? method
448
+ agent.search_engine? :google
449
+
450
+ # using shorthand
451
+ agent.search_engine? :ddg
452
+ ```
453
+
412
454
  **social media**
413
455
 
414
456
  * `facebook` or `fb`
data/bin/browserino ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'bundler/setup'
4
+ require 'browserino'
5
+
6
+ case ARGV[0]
7
+ when 'parse' then puts Browserino.parse(ARGV[1] || '').to_console_s
8
+ end
data/browserino.gemspec CHANGED
@@ -14,8 +14,8 @@ Gem::Specification.new do |spec|
14
14
  spec.license = "MIT"
15
15
 
16
16
  spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
17
- spec.bindir = "exe"
18
- spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
17
+ spec.bindir = "bin"
18
+ spec.executables = ['browserino']
19
19
  spec.require_paths = ["lib"]
20
20
 
21
21
  spec.add_development_dependency "bundler", "~> 1.10"
@@ -53,11 +53,22 @@ module Browserino
53
53
  @info[:bot_name]
54
54
  end
55
55
 
56
+ def search_engine_name
57
+ @info[:bot_name]
58
+ end
59
+
56
60
  def not
57
61
  @not = true
58
62
  self
59
63
  end
60
64
 
65
+ def to_console_s
66
+ hash_for_to_s.each_with_object('') do |pair, a|
67
+ a << "\e[1;32;49m#{pair[0]}:\e[0m "
68
+ a << "\e[1;95;49m#{(pair[1] == '' ? 'nil' : pair[1])}\e[0m, "
69
+ end[0..-3]
70
+ end
71
+
61
72
  def to_s(sep = '')
62
73
  prev = ''
63
74
  s = hash_for_to_s.each_with_object([]) do |v, a|
@@ -96,7 +107,7 @@ module Browserino
96
107
  end
97
108
  end
98
109
 
99
- def respond_to?(method_sym)
110
+ def respond_to?(method_sym, *args, &block)
100
111
  agent_or_system?(method_sym).nil? ? false : true
101
112
  end
102
113
  end
@@ -83,6 +83,9 @@ module Browserino
83
83
  nutch: { name: /(?<name>nutch)/i },
84
84
  scrapy: { name: /(?<name>scrapy)/i },
85
85
  dataparksearch: { name: /(?<name>dataparksearch)/i },
86
+ holmes: { name: /(?<name>holmes)/i },
87
+ ask: { name: /(?<name>ask)\sjeeves/i },
88
+ duckduckgo: { name: /(?<name>duckduckgo)/i },
86
89
  beslist: { name: /(?<name>beslistbot)/i },
87
90
  facebook: { name: /(?<name>face(?:bookexternalhit|bot))/i },
88
91
  twitter: { name: /(?<name>twitterbot)/i },
@@ -1,15 +1,12 @@
1
1
  module Browserino
2
2
  module Core
3
3
  module Questions
4
- SHORT_SYSTEM_NAMES = {
5
- 'osx' => 'macintosh',
6
- 'win' => 'windows',
7
- 'bb' => 'blackberry'
8
- }.freeze
9
-
10
4
  SOCIAL_MEDIA = [:facebook, :twitter, :linkedin,
11
5
  :instagram, :pinterest, :tumblr].freeze
12
6
 
7
+ SEARCH_ENGINES = [:google, :bing, :yahoo_slurp,
8
+ :baiduspider, :duckduckgo].freeze
9
+
13
10
  def compat?
14
11
  invertable ie? && browser_version != browser_version(compat: true)
15
12
  end
@@ -50,12 +47,24 @@ module Browserino
50
47
  firefox?(*arg)
51
48
  end
52
49
 
50
+ def ddg?(*arg)
51
+ duckduckgo?(*arg)
52
+ end
53
+
53
54
  def bot?(name = nil)
54
55
  is_bot = ua.strip.empty? || !bot_name.nil?
55
56
  is_name = name.nil? || name.to_s.downcase.tr('_', ' ') == bot_name
56
57
  invertable is_bot && is_name
57
58
  end
58
59
 
60
+ def search_engine?(name = nil)
61
+ if name
62
+ invertable send("#{name}?")
63
+ else
64
+ invertable SEARCH_ENGINES.include?(search_engine_name.to_s.to_sym)
65
+ end
66
+ end
67
+
59
68
  def social_media?(name = nil)
60
69
  if name
61
70
  invertable send("#{name}?")
@@ -1,3 +1,3 @@
1
1
  module Browserino
2
- VERSION = '2.7.0'.freeze
2
+ VERSION = '2.8.0'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: browserino
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.7.0
4
+ version: 2.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sidney Liebrand
8
8
  autorequire:
9
- bindir: exe
9
+ bindir: bin
10
10
  cert_chain: []
11
- date: 2016-03-02 00:00:00.000000000 Z
11
+ date: 2016-05-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -111,7 +111,8 @@ dependencies:
111
111
  description:
112
112
  email:
113
113
  - sidneyliebrand@gmail.com
114
- executables: []
114
+ executables:
115
+ - browserino
115
116
  extensions: []
116
117
  extra_rdoc_files: []
117
118
  files:
@@ -127,6 +128,7 @@ files:
127
128
  - LICENSE.txt
128
129
  - README.md
129
130
  - Rakefile
131
+ - bin/browserino
130
132
  - bin/console
131
133
  - bin/setup
132
134
  - browserino.gemspec