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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ad55a051a257d37a473405bcaae18fcac093130b
4
- data.tar.gz: 57b707fbd2fb5e64c914294d9a06e29cd78c0d05
3
+ metadata.gz: 124bb13715d2c414f2ebe26e067c29e455826393
4
+ data.tar.gz: 839bc727d4255150d0d9ffcfa16d635c4e9ce22f
5
5
  SHA512:
6
- metadata.gz: e51febaa2835869f01adc7d1ae787df82db2bd1ce86c986ba7e79ffb5d4beac9e68274c35f319637d83e693e44f279cea4ba9c65f05f70b513800845f8659e0f
7
- data.tar.gz: f2d8971d4f3a0450225e108ae859f224e8c5d35488ca674c8dbb5eb8959aac7ac93b91d7c7b4806af53c7d0f3a55376ec3c4eb28528070fc1a37595422ab09b5
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'
@@ -26,12 +26,21 @@ class Browser < Hashie::Dash
26
26
  map {|e| new e}}
27
27
  end
28
28
 
29
- Popular = [
30
- new({browser: 'ie', browser_version: '7.0', os: 'Windows', os_version: 'XP'}),
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
- IEs = all.select {|e| e.browser[/ie/i]}
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
- puts "Starting #{self}"
50
- driver.navigate.to url
51
- puts "Reached #{driver.title} from #{self}, saving screenshot"
52
- driver.save_screenshot(file = CGI.escape("#{url}__#{self}.png"))
53
- driver.quit
54
- puts "Done #{self}"
55
- Launchy.open "./#{file}"
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: 'popular', aliases: '-b'
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
- case options[:browsers]
21
- when 'popular' then Browser::Popular
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
@@ -1,3 +1,3 @@
1
1
  module BsPlus
2
- VERSION = "1.0.1"
2
+ VERSION = "1.0.2"
3
3
  end
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.1
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