bs_plus 1.0.1 → 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bs_plus.gemspec +1 -0
- data/lib/bs_plus/browser.rb +25 -12
- data/lib/bs_plus/cli.rb +13 -7
- data/lib/bs_plus/version.rb +1 -1
- metadata +15 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 124bb13715d2c414f2ebe26e067c29e455826393
|
4
|
+
data.tar.gz: 839bc727d4255150d0d9ffcfa16d635c4e9ce22f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 10bcb041e9f19b2f472217ababe9605712f754fe6f7b98105b8cf31704fdea0eb1069f572287c1ac1e172918ab99bbeba026e078f0a93df175b20203b2f9cb17
|
7
|
+
data.tar.gz: b7199022ba7925518e8b4ba690e1f8a465a07bb0eca8ddf9992650021b3f6c8c6a8aeb8a4f0323ce13bcf7d7151bbc127be6e5cdacb48638e8c83ddab1b8228b
|
data/bs_plus.gemspec
CHANGED
@@ -28,6 +28,7 @@ Gem::Specification.new do |spec|
|
|
28
28
|
spec.add_dependency 'hashie', '>3.0.0'
|
29
29
|
spec.add_dependency 'launchy', '>=2.4.0'
|
30
30
|
spec.add_dependency 'selenium-webdriver', '>=2.44.0'
|
31
|
+
spec.add_dependency 'json', '>=1.8.1'
|
31
32
|
|
32
33
|
spec.add_development_dependency 'bundler', '~> 1.6'
|
33
34
|
spec.add_development_dependency 'rake'
|
data/lib/bs_plus/browser.rb
CHANGED
@@ -26,12 +26,21 @@ class Browser < Hashie::Dash
|
|
26
26
|
map {|e| new e}}
|
27
27
|
end
|
28
28
|
|
29
|
-
|
30
|
-
new({browser: 'ie', browser_version: '
|
29
|
+
Desktop = [
|
30
|
+
new({browser: 'ie', browser_version: '8.0', os: 'Windows', os_version: '7'}),
|
31
|
+
new({browser: 'ie', browser_version: '9.0', os: 'Windows', os_version: '7'}),
|
32
|
+
new({browser: 'ie', browser_version: '10.0', os: 'Windows', os_version: '7'}),
|
33
|
+
new({browser: 'ie', browser_version: '11.0', os: 'Windows', os_version: '7'}),
|
34
|
+
new({browser: 'firefox', browser_version: '30.0', os: 'Windows', os_version: '7'}),
|
35
|
+
new({browser: 'chrome', browser_version: '33.0', os: 'Windows', os_version: '7'}),
|
31
36
|
]
|
32
|
-
|
33
|
-
|
34
|
-
|
37
|
+
IEs = all.select {|e| e.browser[/ie/i]}
|
38
|
+
Androids = all.select {|e| e.os[/android/i]}
|
39
|
+
Mobile = [
|
40
|
+
new({browser: 'android', browser_version: '', os: 'android', os_version: '4.4', device: 'Samsung Galaxy S5'}),
|
41
|
+
new({browser: 'iphone', browser_version: '', os: 'ios', os_version: '7.0', device: 'iPhone 5C'}),
|
42
|
+
]
|
43
|
+
Popular = (Desktop + Mobile)
|
35
44
|
|
36
45
|
def snapshot url
|
37
46
|
# Input capabilities
|
@@ -46,13 +55,17 @@ class Browser < Hashie::Dash
|
|
46
55
|
"@hub.browserstack.com/wd/hub",
|
47
56
|
desired_capabilities: caps)
|
48
57
|
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
58
|
+
begin
|
59
|
+
puts "Starting #{self}"
|
60
|
+
driver.navigate.to url
|
61
|
+
puts "Reached #{driver.title} from #{self}, saving screenshot"
|
62
|
+
driver.save_screenshot(file = CGI.escape("#{url}__#{self}.png"))
|
63
|
+
driver.quit
|
64
|
+
puts "Done #{self}"
|
65
|
+
Launchy.open "./#{file}"
|
66
|
+
rescue => e
|
67
|
+
puts "#{e.inspect} from #{self}"
|
68
|
+
end
|
56
69
|
end
|
57
70
|
|
58
71
|
def to_s
|
data/lib/bs_plus/cli.rb
CHANGED
@@ -2,6 +2,7 @@ require 'thor'
|
|
2
2
|
require 'rest-client'
|
3
3
|
require 'json'
|
4
4
|
require 'parallel'
|
5
|
+
require 'bs_plus/browser'
|
5
6
|
|
6
7
|
module BsPlus
|
7
8
|
class Cli < Thor
|
@@ -12,17 +13,22 @@ module BsPlus
|
|
12
13
|
Browser.all.each {|e| puts e }
|
13
14
|
end
|
14
15
|
|
16
|
+
BrowsersOption = {
|
17
|
+
'desktop' => Browser::Desktop,
|
18
|
+
'ies' => Browser::IEs,
|
19
|
+
'androids' => Browser::Androids,
|
20
|
+
'mobile' => Browser::Mobile,
|
21
|
+
'popular' => Browser::Popular,
|
22
|
+
}
|
23
|
+
|
15
24
|
desc 'get WHAT [-b BROWSERS]', 'takes snapshot(s)'
|
16
|
-
method_option :browsers, default: '
|
25
|
+
method_option :browsers, default: 'desktop', aliases: '-b',
|
26
|
+
desc:"#{BrowsersOption.keys.to_sentence} or one from 'bs list'"
|
17
27
|
def get url
|
18
28
|
url = "http://#{url}" unless url[/http/]
|
19
29
|
|
20
|
-
|
21
|
-
|
22
|
-
when 'ies' then Browser::IEs
|
23
|
-
else
|
24
|
-
Browser.parse options[:browsers]
|
25
|
-
end.
|
30
|
+
(BrowsersOption[options[:browsers]] ||
|
31
|
+
Browser.parse(options[:browsers])).
|
26
32
|
tap {|e| puts "Snapshotting with #{e.size} browsers:"}.
|
27
33
|
tap!{|e| Parallel.map(e, in_threads: 5) {|b| b.snapshot url}}
|
28
34
|
end
|
data/lib/bs_plus/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bs_plus
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Leo
|
@@ -136,6 +136,20 @@ dependencies:
|
|
136
136
|
- - ">="
|
137
137
|
- !ruby/object:Gem::Version
|
138
138
|
version: 2.44.0
|
139
|
+
- !ruby/object:Gem::Dependency
|
140
|
+
name: json
|
141
|
+
requirement: !ruby/object:Gem::Requirement
|
142
|
+
requirements:
|
143
|
+
- - ">="
|
144
|
+
- !ruby/object:Gem::Version
|
145
|
+
version: 1.8.1
|
146
|
+
type: :runtime
|
147
|
+
prerelease: false
|
148
|
+
version_requirements: !ruby/object:Gem::Requirement
|
149
|
+
requirements:
|
150
|
+
- - ">="
|
151
|
+
- !ruby/object:Gem::Version
|
152
|
+
version: 1.8.1
|
139
153
|
- !ruby/object:Gem::Dependency
|
140
154
|
name: bundler
|
141
155
|
requirement: !ruby/object:Gem::Requirement
|