bs_plus 1.0.8 → 1.0.9

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: 58ef79f517a0f5960f59b7f423f7e789ef78d9cf
4
- data.tar.gz: 7e378be96c8e21a63b93e595ca691300b36f502f
3
+ metadata.gz: 31c9318207264588a4c9f051e500cf5eece9bc10
4
+ data.tar.gz: 1db8198c21da3785d102d3ec5c636dce741054e6
5
5
  SHA512:
6
- metadata.gz: 45b208d72ba84aba6a27973fd5581ace78aeb9e258c06154f0197e2ec6403eb3c246ad5ab37c21a0ddf6fe0837a4b8a12f26f1a59270bfb41a8655cb1a8c3e1b
7
- data.tar.gz: 0d5aac37a115b93e5991dbd76b54d3cf46bf8d0abe708c94cba8dd28caec802d23193193e96b0de35ec70716a8f4d02cdc8719671e234c978e5cd103a0b78353
6
+ metadata.gz: 518a9294bf768795f36ceb728e72837575e7cbeae979f0aa3c9221b30b6f226ae83a203cb4e3de4cfcdf3ab6b1570ebb1e963b0a042c68598c1174400899ab0a
7
+ data.tar.gz: 9410299b2ead437cb5572697de8435c0dbef8075890e9a1770be0690421bc5f0f49f31be629cd2f5ba63892c183751391ca0e92f7d3b1f036d38c70be03d38f4
data/README.md CHANGED
@@ -27,3 +27,7 @@ Currently there's a binary named bs, it prints its usage.
27
27
  3. Commit your changes (`git commit -am 'Add some feature'`)
28
28
  4. Push to the branch (`git push origin my-new-feature`)
29
29
  5. Create a new Pull Request
30
+
31
+ Launch with
32
+ RUBYLIB=lib bundle exec rescue bin/bs get google.com -b "ie8"
33
+ or RUBYLIB pry -rbs_plus
Binary file
@@ -20,17 +20,22 @@ Gem::Specification.new do |spec|
20
20
 
21
21
 
22
22
  spec.add_dependency 'highline', '>=1.6.21'
23
- spec.add_dependency 'activesupport', '>=3.0.0'
23
+ spec.add_dependency 'activesupport', '>=4.2.0'
24
24
  spec.add_dependency 'retryable', '>=1.3.5'
25
25
  spec.add_dependency 'parallel', '>=1.3.0'
26
26
  spec.add_dependency 'thor', '>=0.19.1'
27
27
  spec.add_dependency 'rest-client', '>=1.7.2'
28
- spec.add_dependency 'hashie', '>3.0.0'
28
+ spec.add_dependency 'hashie', '>3.1.0'
29
29
  spec.add_dependency 'launchy', '>=2.4.0'
30
30
  spec.add_dependency 'selenium-webdriver', '>=2.44.0'
31
+ spec.add_dependency 'capybara', '>=2.2.1'
32
+ spec.add_dependency 'os', '>=0.9.4'
33
+ spec.add_dependency 'childprocess', '>=0.5.5'
31
34
 
32
35
  spec.add_development_dependency 'bundler', '~> 1.6'
33
36
  spec.add_development_dependency 'rake'
34
37
  spec.add_development_dependency 'pry-rescue'
38
+ spec.add_development_dependency 'pry-doc'
39
+ # spec.add_development_dependency 'pry-stack_explorer'
35
40
  spec.add_development_dependency 'pry'
36
41
  end
@@ -1,9 +1,23 @@
1
1
  require 'bs_plus/core_ext'
2
2
  require 'bs_plus/version'
3
3
  require 'bs_plus/config'
4
+ require 'childprocess'
5
+ require 'os'
4
6
  BsPlus::Config.init # will ask for username/password if not present, hehe
5
7
 
6
8
  require 'bs_plus/cli'
7
9
 
8
10
  module BsPlus
11
+ def self.with_tunnel
12
+ p = ChildProcess.build File.expand_path(File.join(Kernel.__dir__, '../bin', "BrowserStackLocal#{case
13
+ when OS.windows? then 'Windows'; when OS.linux? then 'Linux'; when OS.mac? then 'Mac'; end}")),
14
+ '-force', '-forcelocal', Config.fetch(:password)
15
+ p.io.inherit!
16
+ p.start
17
+ sleep 4.5
18
+ raise "Problem with tunnel" unless p.alive?
19
+ yield
20
+ ensure
21
+ p.stop# unless p.alive?
22
+ end
9
23
  end
@@ -6,6 +6,7 @@ require 'selenium-webdriver'
6
6
  require 'launchy'
7
7
  require 'hashie'
8
8
  require 'cgi'
9
+ require 'capybara'
9
10
  require 'bs_plus/config'
10
11
 
11
12
  module BsPlus
@@ -43,35 +44,88 @@ class Browser < Hashie::Dash
43
44
  ]
44
45
  Popular = (Desktop + Mobile)
45
46
 
46
- def snapshot url
47
- # Input capabilities
47
+
48
+ def new_session options={}
49
+ options.reverse_merge! local: true
48
50
  caps = Selenium::WebDriver::Remote::Capabilities.new.tap {|c|
49
51
  self.stringify_keys.select{|k,v| v}.each {|k,v| c[k] = v}
50
- c["browserstack.debug"] = "true"
51
- c["name"] = "Running BrowserStack from command line"
52
+ c["browserstack.debug"] = 'true'
53
+ c['browserstack.local'] = (!!options[:local]).to_s
54
+ c['acceptSslCerts'] = 'true'
55
+ c["name"] = 'Running bs_plus from command line'
52
56
  }
53
57
 
54
- driver = Selenium::WebDriver.for(:remote,
55
- url: "https://#{Config.fetch(:username)}:#{Config.fetch(:password)}"\
56
- "@hub.browserstack.com/wd/hub",
57
- desired_capabilities: caps)
58
+ Capybara.register_driver(:"#{to_s}") { |app|
59
+ Capybara::Selenium::Driver.new(app, browser: :remote,
60
+ url: "https://#{Config.fetch(:username)}:#{Config.fetch(:password)}"\
61
+ "@hub-eu.browserstack.com/wd/hub",
62
+ desired_capabilities: caps) }
63
+
64
+ yield (s = Capybara::Session.new(:"#{to_s}"))
65
+ ensure
66
+ s.driver.quit
67
+ end
58
68
 
59
- begin
69
+ def snapshot url
70
+ new_session do |browser|
60
71
  puts "Starting #{self}"
61
- driver.navigate.to url
62
- puts "Reached #{driver.title} from #{self}, saving screenshot"
63
- driver.save_screenshot(file = CGI.escape("#{url}__#{self}.png"))
64
- driver.quit
72
+ browser.visit url
73
+ puts "Reached #{browser.title} from #{self}, saving screenshot"
74
+ browser.save_screenshot file = CGI.escape("#{url}__#{self}.png")
65
75
  puts "Done #{self}"
66
76
  Launchy.open "./#{file}"
67
- rescue => e
68
- puts "#{e.inspect} from #{self}"
69
77
  end
78
+ rescue => e
79
+ puts "#{e.inspect} from #{self}"
70
80
  end
71
81
 
72
82
  def to_s
73
83
  "#{browser}#{browser_version}"\
74
84
  "(#{os}-#{os_version}#{':' + device if device})"
75
85
  end
86
+
87
+ def self.parse browser_string
88
+ all.select {|b| b.to_s[Regexp.new browser_string, 'i']}
89
+ end
90
+
91
+ def self.logins
92
+ @logins ||= begin
93
+ File.expand_path('~/.loginfile.rb').tap! {|home_path| load home_path if File.exists? home_path }
94
+ File.expand_path('./.loginfile.rb').tap! {|local_path| load local_path if File.exists? local_path }
95
+
96
+ (defined?(LoginsGlobal) ? LoginsGlobal : {}).merge(defined?(LoginsLocal) ? LoginsLocal : {})
97
+ end
98
+ end
99
+
100
+ def self.actions
101
+ @actions ||= begin
102
+ File.expand_path('~/.loginfile.rb').tap! {|home_path| load home_path if File.exists? home_path }
103
+ File.expand_path('./.loginfile.rb').tap! {|local_path| load local_path if File.exists? local_path }
104
+
105
+ (defined?(ActionsGlobal) ? ActionsGlobal : {}).merge(defined?(ActionsLocal) ? ActionsLocal : {})
106
+ end
107
+ end
108
+
109
+
110
+
111
+
112
+
113
+
114
+ def raw_selenium_session options={}
115
+ options.reverse_merge! local: true
116
+ caps = Selenium::WebDriver::Remote::Capabilities.new.tap {|c|
117
+ self.stringify_keys.select{|k,v| v}.each {|k,v| c[k] = v}
118
+ c["browserstack.debug"] = 'true'
119
+ c['browserstack.local'] = (!!options[:local]).to_s
120
+ c['acceptSslCerts'] = 'true'
121
+ c["name"] = 'Running bs_plus from command line'
122
+ }
123
+
124
+ driver = Selenium::WebDriver.for(:remote,
125
+ url: "https://#{Config.fetch(:username)}:#{Config.fetch(:password)}"\
126
+ "@hub.browserstack.com/wd/hub",
127
+ desired_capabilities: caps)
128
+ end
129
+
76
130
  end
77
131
  end
@@ -3,6 +3,8 @@ require 'rest-client'
3
3
  require 'json' unless defined? JSON # wtf is can't activate json-1.8.0, already activated json-1.8.1 (Gem::LoadError)
4
4
  require 'parallel'
5
5
  require 'bs_plus/browser'
6
+ require 'bs_plus/config'
7
+ require 'os'
6
8
 
7
9
  module BsPlus
8
10
  class Cli < Thor
@@ -21,16 +23,40 @@ module BsPlus
21
23
  'popular' => Browser::Popular,
22
24
  }
23
25
 
24
- desc 'get WHAT [-b BROWSERS]', 'takes snapshot(s)'
26
+ desc 'get WHAT [-b BROWSERS]', "takes snapshot(s). Browsers: #{BrowsersOption.keys.to_sentence} or one from 'bs list'"
25
27
  method_option :browsers, default: 'desktop', aliases: '-b',
26
28
  desc:"#{BrowsersOption.keys.to_sentence} or one from 'bs list'"
27
29
  def get url
28
30
  url = "http://#{url}" unless url[/http/]
29
31
 
30
- (BrowsersOption[options[:browsers]] ||
31
- Browser.parse(options[:browsers])).
32
- tap {|e| puts "Snapshotting with #{e.size} browsers:"}.
33
- tap!{|e| Parallel.map(e, in_threads: 5) {|b| b.snapshot url}}
32
+ BsPlus.with_tunnel {
33
+ (BrowsersOption[options[:browsers]] ||
34
+ Browser.parse(options[:browsers]).take(1)).
35
+ tap {|e| puts "Snapshotting with #{e.size} browsers:"}.
36
+ tap!{|e| Parallel.map(e, in_threads: 5) {|b| b.snapshot url}} }
37
+ end
38
+
39
+ desc 'live URL -b BROWSER', "Opens browser on browserstack. Browser one from 'bs list' by regex"
40
+ method_option :browser, required: true, aliases: '-b', desc:"Browser one from 'bs list' by regex"
41
+ def live url
42
+ url = "http://#{url}" unless url[/http/]
43
+
44
+ BsPlus.with_tunnel {
45
+ (Browser.parse(options[:browser]).first || (raise %Q[#{Browser.all.map(&:to_s).join("\n")}]+"\nCouldn't find browser in the list." )).
46
+ tap {|e| puts "Opening with #{e}. Please log in to BrowserStack"}.
47
+ tap!{|b| Launchy.open "https://www.browserstack.com/automate"
48
+ b.new_session do |browser|
49
+ browser.visit url
50
+ loop { browser.has_title?('.'); sleep 30 }
51
+ end } }
52
+ end
53
+
54
+ desc 'tunnel', 'Runs BrowserStackLocal binary with your key and --automate flag'
55
+ def tunnel detach = false
56
+ #Process.detach
57
+ system File.join Kernel.__dir__, '../../bin', "BrowserStackLocal#{case
58
+ when OS.windows? then 'Windows'; when OS.linux? then 'Linux'; when OS.mac? then 'Mac'; end
59
+ } -force -onlyAutomate -forcelocal #{Config.fetch(:password)}"
34
60
  end
35
61
  end
36
62
  end
@@ -3,15 +3,15 @@ require 'highline'
3
3
  require 'active_support/core_ext/hash'
4
4
 
5
5
  class BsPlus::Config
6
- HomePath = File.expand_path '~/.browserstack-cred'
7
- LocalPath = File.expand_path './.browserstack-cred'
6
+ HomePath = File.expand_path '~/.browserstack-plus'
7
+ LocalPath = File.expand_path './.browserstack-plus'
8
8
 
9
9
  class <<self
10
10
  def init
11
- fetch(:username) {HighLine.new.ask('Please enter your browserstack username')}
11
+ fetch(:username) {HighLine.new.ask('Please enter your browserstack username').to_s}
12
12
 
13
13
  fetch(:password) {HighLine.new.ask('Please enter your password') {|h|
14
- h.echo = false }}
14
+ h.echo = false }.to_s}
15
15
  end
16
16
 
17
17
  OtherDefaults =
@@ -1,3 +1,3 @@
1
1
  module BsPlus
2
- VERSION = "1.0.8"
2
+ VERSION = "1.0.9"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bs_plus
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.8
4
+ version: 1.0.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Leo
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-01-20 00:00:00.000000000 Z
11
+ date: 2015-01-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: highline
@@ -30,14 +30,14 @@ dependencies:
30
30
  requirements:
31
31
  - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: 3.0.0
33
+ version: 4.2.0
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
- version: 3.0.0
40
+ version: 4.2.0
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: retryable
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -100,14 +100,14 @@ dependencies:
100
100
  requirements:
101
101
  - - ">"
102
102
  - !ruby/object:Gem::Version
103
- version: 3.0.0
103
+ version: 3.1.0
104
104
  type: :runtime
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
108
  - - ">"
109
109
  - !ruby/object:Gem::Version
110
- version: 3.0.0
110
+ version: 3.1.0
111
111
  - !ruby/object:Gem::Dependency
112
112
  name: launchy
113
113
  requirement: !ruby/object:Gem::Requirement
@@ -136,6 +136,48 @@ dependencies:
136
136
  - - ">="
137
137
  - !ruby/object:Gem::Version
138
138
  version: 2.44.0
139
+ - !ruby/object:Gem::Dependency
140
+ name: capybara
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - ">="
144
+ - !ruby/object:Gem::Version
145
+ version: 2.2.1
146
+ type: :runtime
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - ">="
151
+ - !ruby/object:Gem::Version
152
+ version: 2.2.1
153
+ - !ruby/object:Gem::Dependency
154
+ name: os
155
+ requirement: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - ">="
158
+ - !ruby/object:Gem::Version
159
+ version: 0.9.4
160
+ type: :runtime
161
+ prerelease: false
162
+ version_requirements: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - ">="
165
+ - !ruby/object:Gem::Version
166
+ version: 0.9.4
167
+ - !ruby/object:Gem::Dependency
168
+ name: childprocess
169
+ requirement: !ruby/object:Gem::Requirement
170
+ requirements:
171
+ - - ">="
172
+ - !ruby/object:Gem::Version
173
+ version: 0.5.5
174
+ type: :runtime
175
+ prerelease: false
176
+ version_requirements: !ruby/object:Gem::Requirement
177
+ requirements:
178
+ - - ">="
179
+ - !ruby/object:Gem::Version
180
+ version: 0.5.5
139
181
  - !ruby/object:Gem::Dependency
140
182
  name: bundler
141
183
  requirement: !ruby/object:Gem::Requirement
@@ -178,6 +220,20 @@ dependencies:
178
220
  - - ">="
179
221
  - !ruby/object:Gem::Version
180
222
  version: '0'
223
+ - !ruby/object:Gem::Dependency
224
+ name: pry-doc
225
+ requirement: !ruby/object:Gem::Requirement
226
+ requirements:
227
+ - - ">="
228
+ - !ruby/object:Gem::Version
229
+ version: '0'
230
+ type: :development
231
+ prerelease: false
232
+ version_requirements: !ruby/object:Gem::Requirement
233
+ requirements:
234
+ - - ">="
235
+ - !ruby/object:Gem::Version
236
+ version: '0'
181
237
  - !ruby/object:Gem::Dependency
182
238
  name: pry
183
239
  requirement: !ruby/object:Gem::Requirement
@@ -196,6 +252,9 @@ description: This should use your automate plan of browserstack and do screensho
196
252
  email:
197
253
  - leonid.inbox@gmail.com
198
254
  executables:
255
+ - BrowserStackLocalLinux
256
+ - BrowserStackLocalMac
257
+ - BrowserStackLocalWindows.exe
199
258
  - bs
200
259
  extensions: []
201
260
  extra_rdoc_files: []
@@ -205,6 +264,9 @@ files:
205
264
  - LICENSE.txt
206
265
  - README.md
207
266
  - Rakefile
267
+ - bin/BrowserStackLocalLinux
268
+ - bin/BrowserStackLocalMac
269
+ - bin/BrowserStackLocalWindows.exe
208
270
  - bin/bs
209
271
  - bs_plus.gemspec
210
272
  - lib/bs_plus.rb
@@ -238,3 +300,4 @@ signing_key:
238
300
  specification_version: 4
239
301
  summary: This should use your automate plan of browserstack and do screenshots
240
302
  test_files: []
303
+ has_rdoc: