bs_plus 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: ad55a051a257d37a473405bcaae18fcac093130b
4
+ data.tar.gz: 57b707fbd2fb5e64c914294d9a06e29cd78c0d05
5
+ SHA512:
6
+ metadata.gz: e51febaa2835869f01adc7d1ae787df82db2bd1ce86c986ba7e79ffb5d4beac9e68274c35f319637d83e693e44f279cea4ba9c65f05f70b513800845f8659e0f
7
+ data.tar.gz: f2d8971d4f3a0450225e108ae859f224e8c5d35488ca674c8dbb5eb8959aac7ac93b91d7c7b4806af53c7d0f3a55376ec3c4eb28528070fc1a37595422ab09b5
data/.gitignore ADDED
@@ -0,0 +1,24 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ *.bundle
19
+ *.so
20
+ *.o
21
+ *.a
22
+ mkmf.log
23
+ .DS_Store
24
+ /*.png
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in bs_plus.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2015 Leo 'altV'
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,29 @@
1
+ # BsPlus
2
+
3
+ CLI for browserstack to use automate plan from command line.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'bs_plus'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install bs_plus
18
+
19
+ ## Usage
20
+
21
+ Currently there's a binary named bs, it prints its usage.
22
+
23
+ ## Contributing
24
+
25
+ 1. Fork it ( https://github.com/[my-github-username]/bs_plus/fork )
26
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
27
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
28
+ 4. Push to the branch (`git push origin my-new-feature`)
29
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+
data/bin/bs ADDED
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'bs_plus'
4
+
5
+ BsPlus::Cli.start ARGV
data/bs_plus.gemspec ADDED
@@ -0,0 +1,36 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'bs_plus/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'bs_plus'
8
+ spec.version = BsPlus::VERSION
9
+ spec.authors = ['Leo']
10
+ spec.email = ['leonid.inbox@gmail.com']
11
+ spec.summary = %q{This should use your automate plan of browserstack and do screenshots}
12
+ spec.description = %q{This should use your automate plan of browserstack and do screenshots}
13
+ spec.homepage = ''
14
+ spec.license = 'MIT'
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ['lib']
20
+
21
+
22
+ spec.add_dependency 'highline', '>=1.6.21'
23
+ spec.add_dependency 'activesupport', '>=4.0.4'
24
+ spec.add_dependency 'retryable', '>=1.3.5'
25
+ spec.add_dependency 'parallel', '>=1.3.0'
26
+ spec.add_dependency 'thor', '>=0.19.1'
27
+ spec.add_dependency 'rest-client', '>=1.7.2'
28
+ spec.add_dependency 'hashie', '>3.0.0'
29
+ spec.add_dependency 'launchy', '>=2.4.0'
30
+ spec.add_dependency 'selenium-webdriver', '>=2.44.0'
31
+
32
+ spec.add_development_dependency 'bundler', '~> 1.6'
33
+ spec.add_development_dependency 'rake'
34
+ spec.add_development_dependency 'pry-rescue'
35
+ spec.add_development_dependency 'pry'
36
+ end
@@ -0,0 +1,63 @@
1
+ require 'active_support'
2
+ require 'active_support/cache'
3
+ require 'active_support/core_ext/numeric'
4
+ require 'active_support/core_ext/string'
5
+ require 'selenium-webdriver'
6
+ require 'launchy'
7
+ require 'hashie'
8
+ require 'cgi'
9
+
10
+ module BsPlus
11
+ class Browser < Hashie::Dash
12
+ include Hashie::Extensions::Dash::IndifferentAccess
13
+ property :browser
14
+ property :browser_version
15
+ property :os
16
+ property :os_version
17
+ property :device
18
+
19
+ FileCache = ActiveSupport::Cache::FileStore.new "#{Dir.home}/.browserstack_plus/cache"
20
+
21
+ def self.all
22
+ FileCache.fetch('browser.list', expires_in: 24.hours) {
23
+ @list ||= RestClient.get("https://#{Config.fetch(:username)}:#{Config.fetch(:password)}"\
24
+ "@www.browserstack.com/automate/browsers.json").
25
+ tap! {|e| JSON.parse e}.
26
+ map {|e| new e}}
27
+ end
28
+
29
+ Popular = [
30
+ new({browser: 'ie', browser_version: '7.0', os: 'Windows', os_version: 'XP'}),
31
+ ]
32
+
33
+ IEs = all.select {|e| e.browser[/ie/i]}
34
+
35
+
36
+ def snapshot url
37
+ # Input capabilities
38
+ caps = Selenium::WebDriver::Remote::Capabilities.new.tap {|c|
39
+ self.stringify_keys.select{|k,v| v}.each {|k,v| c[k] = v}
40
+ c["browserstack.debug"] = "true"
41
+ c["name"] = "Running BrowserStack from command line"
42
+ }
43
+
44
+ driver = Selenium::WebDriver.for(:remote,
45
+ url: "https://#{Config.fetch(:username)}:#{Config.fetch(:password)}"\
46
+ "@hub.browserstack.com/wd/hub",
47
+ desired_capabilities: caps)
48
+
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}"
56
+ end
57
+
58
+ def to_s
59
+ "#{browser}#{browser_version}"\
60
+ "(#{os}-#{os_version}#{':' + device if device})"
61
+ end
62
+ end
63
+ end
@@ -0,0 +1,30 @@
1
+ require 'thor'
2
+ require 'rest-client'
3
+ require 'json'
4
+ require 'parallel'
5
+
6
+ module BsPlus
7
+ class Cli < Thor
8
+ desc 'list', 'List currently available browsers'
9
+ def list
10
+ puts 'browser browser_version os os_version device'
11
+ puts '--------------------------------------------'
12
+ Browser.all.each {|e| puts e }
13
+ end
14
+
15
+ desc 'get WHAT [-b BROWSERS]', 'takes snapshot(s)'
16
+ method_option :browsers, default: 'popular', aliases: '-b'
17
+ def get url
18
+ url = "http://#{url}" unless url[/http/]
19
+
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.
26
+ tap {|e| puts "Snapshotting with #{e.size} browsers:"}.
27
+ tap!{|e| Parallel.map(e, in_threads: 5) {|b| b.snapshot url}}
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,55 @@
1
+ require 'yaml'
2
+ require 'highline'
3
+ require 'active_support/core_ext/hash'
4
+
5
+ class BsPlus::Config
6
+ HomePath = File.expand_path '~/.browserstack-cred'
7
+ LocalPath = File.expand_path './.browserstack-cred'
8
+
9
+ class <<self
10
+ def init
11
+ fetch(:username) {HighLine.new.ask('Please enter your browserstack username')}
12
+
13
+ fetch(:password) {HighLine.new.ask('Please enter your password') {|h|
14
+ h.echo = false }}
15
+ end
16
+
17
+ OtherDefaults =
18
+ { }
19
+
20
+
21
+ def home_config
22
+ YAML.load_file(HomePath ).deep_symbolize_keys rescue {} end
23
+
24
+ def local_config
25
+ YAML.load_file(LocalPath).deep_symbolize_keys rescue {} end
26
+
27
+ def all
28
+ OtherDefaults.merge(home_config).merge(local_config) end
29
+
30
+ def fetch key, &blk
31
+ unless block_given?
32
+ all.fetch key
33
+ else
34
+ all.fetch key do
35
+ value = yield
36
+ write key, value
37
+ value
38
+ end
39
+ end
40
+ end
41
+
42
+ def write key, value
43
+ FileUtils.touch(HomePath) unless File.exists? HomePath
44
+ write_config_file HomePath, home_config.merge({key => value})
45
+ end
46
+
47
+ def write_config_file path, hash
48
+ File.open(HomePath, 'r+') { |f| YAML.dump hash.deep_stringify_keys, f }
49
+ end
50
+
51
+ def method_missing key
52
+ fetch key
53
+ end
54
+ end
55
+ end
@@ -0,0 +1,5 @@
1
+ class Object
2
+ def tap!
3
+ yield self
4
+ end
5
+ end
@@ -0,0 +1,3 @@
1
+ module BsPlus
2
+ VERSION = "1.0.1"
3
+ end
data/lib/bs_plus.rb ADDED
@@ -0,0 +1,10 @@
1
+ require 'bs_plus/version'
2
+ require 'bs_plus/cli'
3
+ require 'bs_plus/core_ext'
4
+ require 'bs_plus/config'
5
+
6
+ require 'bs_plus/browser'
7
+
8
+ module BsPlus
9
+ Config.init # will ask for username/password if not present
10
+ end
metadata ADDED
@@ -0,0 +1,240 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: bs_plus
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Leo
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-01-20 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: highline
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: 1.6.21
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: 1.6.21
27
+ - !ruby/object:Gem::Dependency
28
+ name: activesupport
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: 4.0.4
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: 4.0.4
41
+ - !ruby/object:Gem::Dependency
42
+ name: retryable
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: 1.3.5
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: 1.3.5
55
+ - !ruby/object:Gem::Dependency
56
+ name: parallel
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: 1.3.0
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: 1.3.0
69
+ - !ruby/object:Gem::Dependency
70
+ name: thor
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: 0.19.1
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: 0.19.1
83
+ - !ruby/object:Gem::Dependency
84
+ name: rest-client
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: 1.7.2
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: 1.7.2
97
+ - !ruby/object:Gem::Dependency
98
+ name: hashie
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">"
102
+ - !ruby/object:Gem::Version
103
+ version: 3.0.0
104
+ type: :runtime
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">"
109
+ - !ruby/object:Gem::Version
110
+ version: 3.0.0
111
+ - !ruby/object:Gem::Dependency
112
+ name: launchy
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: 2.4.0
118
+ type: :runtime
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: 2.4.0
125
+ - !ruby/object:Gem::Dependency
126
+ name: selenium-webdriver
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ">="
130
+ - !ruby/object:Gem::Version
131
+ version: 2.44.0
132
+ type: :runtime
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ">="
137
+ - !ruby/object:Gem::Version
138
+ version: 2.44.0
139
+ - !ruby/object:Gem::Dependency
140
+ name: bundler
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - "~>"
144
+ - !ruby/object:Gem::Version
145
+ version: '1.6'
146
+ type: :development
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - "~>"
151
+ - !ruby/object:Gem::Version
152
+ version: '1.6'
153
+ - !ruby/object:Gem::Dependency
154
+ name: rake
155
+ requirement: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - ">="
158
+ - !ruby/object:Gem::Version
159
+ version: '0'
160
+ type: :development
161
+ prerelease: false
162
+ version_requirements: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - ">="
165
+ - !ruby/object:Gem::Version
166
+ version: '0'
167
+ - !ruby/object:Gem::Dependency
168
+ name: pry-rescue
169
+ requirement: !ruby/object:Gem::Requirement
170
+ requirements:
171
+ - - ">="
172
+ - !ruby/object:Gem::Version
173
+ version: '0'
174
+ type: :development
175
+ prerelease: false
176
+ version_requirements: !ruby/object:Gem::Requirement
177
+ requirements:
178
+ - - ">="
179
+ - !ruby/object:Gem::Version
180
+ version: '0'
181
+ - !ruby/object:Gem::Dependency
182
+ name: pry
183
+ requirement: !ruby/object:Gem::Requirement
184
+ requirements:
185
+ - - ">="
186
+ - !ruby/object:Gem::Version
187
+ version: '0'
188
+ type: :development
189
+ prerelease: false
190
+ version_requirements: !ruby/object:Gem::Requirement
191
+ requirements:
192
+ - - ">="
193
+ - !ruby/object:Gem::Version
194
+ version: '0'
195
+ description: This should use your automate plan of browserstack and do screenshots
196
+ email:
197
+ - leonid.inbox@gmail.com
198
+ executables:
199
+ - bs
200
+ extensions: []
201
+ extra_rdoc_files: []
202
+ files:
203
+ - ".gitignore"
204
+ - Gemfile
205
+ - LICENSE.txt
206
+ - README.md
207
+ - Rakefile
208
+ - bin/bs
209
+ - bs_plus.gemspec
210
+ - lib/bs_plus.rb
211
+ - lib/bs_plus/browser.rb
212
+ - lib/bs_plus/cli.rb
213
+ - lib/bs_plus/config.rb
214
+ - lib/bs_plus/core_ext.rb
215
+ - lib/bs_plus/version.rb
216
+ homepage: ''
217
+ licenses:
218
+ - MIT
219
+ metadata: {}
220
+ post_install_message:
221
+ rdoc_options: []
222
+ require_paths:
223
+ - lib
224
+ required_ruby_version: !ruby/object:Gem::Requirement
225
+ requirements:
226
+ - - ">="
227
+ - !ruby/object:Gem::Version
228
+ version: '0'
229
+ required_rubygems_version: !ruby/object:Gem::Requirement
230
+ requirements:
231
+ - - ">="
232
+ - !ruby/object:Gem::Version
233
+ version: '0'
234
+ requirements: []
235
+ rubyforge_project:
236
+ rubygems_version: 2.2.2
237
+ signing_key:
238
+ specification_version: 4
239
+ summary: This should use your automate plan of browserstack and do screenshots
240
+ test_files: []