crossbrowsertesting-gem 0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +1 -0
- data/Gemfile +4 -0
- data/README.md +117 -0
- data/Rakefile +1 -0
- data/cbt.gemspec +19 -0
- data/lib/crossbrowsertesting-gem.rb +63 -0
- metadata +77 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 10a609d074bd06edaf8c7c1730f1610d61ded928
|
4
|
+
data.tar.gz: 6a729c664d48a8cfdecf7dd3b9d8c60acd9c1117
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: d3852c836124b355cd86674aaa07881909253fa98fd5353904d70c3b7f132dfab5250948420589064c33cc13c61b44a37c32dd3381f12a5c7b85804ac6a0c40d
|
7
|
+
data.tar.gz: 7d5d0e11365a6ea7858ef1a2a7df139860ffab87bea3169b06c6170f7167e3a465fb6fbdfa321e260b469e9642e98bb016b29e7f0e5c48d42a5957fff2f86965
|
data/.gitignore
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
lib/.DS_Store
|
data/Gemfile
ADDED
data/README.md
ADDED
@@ -0,0 +1,117 @@
|
|
1
|
+
# CrossBrowserTesting Screenshots
|
2
|
+
|
3
|
+
A ruby gem for [CrossBrowserTesting](http://crossbrowsertesting.com)'s screenshots API.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'crossbrowsertesting-gem'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
gem install crossbrowsertesting-gem
|
18
|
+
|
19
|
+
## Examples of use
|
20
|
+
|
21
|
+
If you are not using Rails, you'll need to require the gem:
|
22
|
+
|
23
|
+
``` ruby
|
24
|
+
require 'CBT'
|
25
|
+
```
|
26
|
+
|
27
|
+
### Create a client
|
28
|
+
Creates a new client instance.
|
29
|
+
|
30
|
+
``` ruby
|
31
|
+
client = CBT.new('username', 'password')
|
32
|
+
```
|
33
|
+
|
34
|
+
###API
|
35
|
+
|
36
|
+
#### Take a screenshot
|
37
|
+
Queues up a request for a screenshot
|
38
|
+
|
39
|
+
``` ruby
|
40
|
+
params = {
|
41
|
+
:url => 'http://darrennix.com',
|
42
|
+
:delay => 5,
|
43
|
+
}
|
44
|
+
request = client.take_screenshot(params)
|
45
|
+
```
|
46
|
+
|
47
|
+
#### Check the status of a screenshot request
|
48
|
+
Returns true or false for completion status
|
49
|
+
|
50
|
+
``` ruby
|
51
|
+
test = request[:test][:id]
|
52
|
+
version = request[:test][:version][:id]
|
53
|
+
completed = client.status(test, version)
|
54
|
+
```
|
55
|
+
|
56
|
+
#### Load the full results of a screenshot request
|
57
|
+
``` ruby
|
58
|
+
results = client.results(test, version)
|
59
|
+
|
60
|
+
results[:test][:version][:results].each do |screenshot|
|
61
|
+
puts screenshot[:images][:fullpage]
|
62
|
+
end
|
63
|
+
```
|
64
|
+
|
65
|
+
#### Get available os and browsers
|
66
|
+
Fetches all available browsers.
|
67
|
+
|
68
|
+
Rather than using this list to construct a set of browsers for testing, I recommend saving a list of
|
69
|
+
browser configurations through the main site and then referencing that list by name in your "take_screenshot" params.
|
70
|
+
|
71
|
+
``` ruby
|
72
|
+
puts client.browsers #returns a hash
|
73
|
+
|
74
|
+
{
|
75
|
+
:error=>0,
|
76
|
+
:message=>"",
|
77
|
+
:oss=>[
|
78
|
+
{
|
79
|
+
:name=>"Android 4.0 Simulator",
|
80
|
+
:api_name=>"Android4.0",
|
81
|
+
:type=>"Android",
|
82
|
+
:version=>"4.0",
|
83
|
+
:device=>"mobile",
|
84
|
+
:icon=>"http://crossbrowsertesting.com/images/software_logos/android15.png",
|
85
|
+
:browsers=>[
|
86
|
+
{
|
87
|
+
:name=>"Android Browser 4.0",
|
88
|
+
:api_name=>"Android4.0",
|
89
|
+
:type=>"Android Browser",
|
90
|
+
:version=>"4.0",
|
91
|
+
:device=>"mobile",
|
92
|
+
:major_browser=>1,
|
93
|
+
:icon=>"http://crossbrowsertesting.com/images/software_logos/android-browser15.png",
|
94
|
+
:default_config=>"Android4.0"
|
95
|
+
}
|
96
|
+
],
|
97
|
+
:other_software=>[
|
98
|
+
{
|
99
|
+
:name=>"Base install - no additional software added",
|
100
|
+
:type=>"None",
|
101
|
+
:version=>"",
|
102
|
+
:icon=>"http://crossbrowsertesting.com/images/software_logos/15.png"
|
103
|
+
}
|
104
|
+
],
|
105
|
+
:resolutions=>[
|
106
|
+
{
|
107
|
+
:name=>"480x800",
|
108
|
+
:width=>480,
|
109
|
+
:height=>800,
|
110
|
+
:default=>1
|
111
|
+
}
|
112
|
+
]
|
113
|
+
},
|
114
|
+
...
|
115
|
+
]
|
116
|
+
}
|
117
|
+
```
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/cbt.gemspec
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |s|
|
5
|
+
s.name = "crossbrowsertesting-gem"
|
6
|
+
s.version = '0.1'
|
7
|
+
s.authors = ["Darren Nix"]
|
8
|
+
s.email = ["low@darrennix.com"]
|
9
|
+
s.homepage = "http://darrennix.com"
|
10
|
+
s.summary = "Ruby helper for crossbrowsertesting.com API"
|
11
|
+
s.description = "Ruby helper for crossbrowsertesting.com API"
|
12
|
+
|
13
|
+
s.files = `git ls-files`.split("\n")
|
14
|
+
s.require_paths = ["lib"]
|
15
|
+
|
16
|
+
s.add_development_dependency "rake"
|
17
|
+
s.add_dependency("yajl-ruby", "1.1.0")
|
18
|
+
|
19
|
+
end
|
@@ -0,0 +1,63 @@
|
|
1
|
+
require "base64"
|
2
|
+
require "net/http"
|
3
|
+
require "yajl"
|
4
|
+
|
5
|
+
class CBT
|
6
|
+
|
7
|
+
API = "http://crossbrowsertesting.com/api/v2/screenshots"
|
8
|
+
|
9
|
+
def initialize(username=nil, password=nil)
|
10
|
+
raise "Expected username and password" unless username && password
|
11
|
+
@username = username
|
12
|
+
@password = password
|
13
|
+
end
|
14
|
+
|
15
|
+
def browsers
|
16
|
+
make_post_request('browsers')
|
17
|
+
end
|
18
|
+
|
19
|
+
def take_screenshot(params)
|
20
|
+
make_post_request('run', params)
|
21
|
+
end
|
22
|
+
|
23
|
+
def status(test, version)
|
24
|
+
response = make_post_request("#{test}/version/#{version}/status")
|
25
|
+
|
26
|
+
puts "-----------status #{test} #{version}"
|
27
|
+
puts response
|
28
|
+
response[:complete] == 1 ? true : false
|
29
|
+
end
|
30
|
+
|
31
|
+
def results(test, version)
|
32
|
+
make_post_request("#{test}/version/#{version}/show")
|
33
|
+
end
|
34
|
+
|
35
|
+
private
|
36
|
+
|
37
|
+
def make_post_request(action, params = {})
|
38
|
+
params[:format] = 'json'
|
39
|
+
uri = URI("#{API}/#{action}")
|
40
|
+
request = Net::HTTP::Post.new(uri)
|
41
|
+
request.set_form_data(params)
|
42
|
+
request.basic_auth(@username, @password)
|
43
|
+
result = Net::HTTP.start(uri.hostname, uri.port) {|http|
|
44
|
+
http.request(request)
|
45
|
+
}
|
46
|
+
|
47
|
+
parser = Yajl::Parser.new(:symbolize_keys => true)
|
48
|
+
begin
|
49
|
+
output = parser.parse(result.body)[:response]
|
50
|
+
if output[:error] != 0
|
51
|
+
raise GeneralError, output[:message]
|
52
|
+
end
|
53
|
+
rescue Yajl::ParseError
|
54
|
+
raise GeneralError, result.body
|
55
|
+
end
|
56
|
+
|
57
|
+
output
|
58
|
+
end
|
59
|
+
|
60
|
+
class GeneralError < StandardError
|
61
|
+
end
|
62
|
+
|
63
|
+
end #Client
|
metadata
ADDED
@@ -0,0 +1,77 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: crossbrowsertesting-gem
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: '0.1'
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Darren Nix
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-06-22 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rake
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - '>='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - '>='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: yajl-ruby
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 1.1.0
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 1.1.0
|
41
|
+
description: Ruby helper for crossbrowsertesting.com API
|
42
|
+
email:
|
43
|
+
- low@darrennix.com
|
44
|
+
executables: []
|
45
|
+
extensions: []
|
46
|
+
extra_rdoc_files: []
|
47
|
+
files:
|
48
|
+
- .gitignore
|
49
|
+
- Gemfile
|
50
|
+
- README.md
|
51
|
+
- Rakefile
|
52
|
+
- cbt.gemspec
|
53
|
+
- lib/crossbrowsertesting-gem.rb
|
54
|
+
homepage: http://darrennix.com
|
55
|
+
licenses: []
|
56
|
+
metadata: {}
|
57
|
+
post_install_message:
|
58
|
+
rdoc_options: []
|
59
|
+
require_paths:
|
60
|
+
- lib
|
61
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
62
|
+
requirements:
|
63
|
+
- - '>='
|
64
|
+
- !ruby/object:Gem::Version
|
65
|
+
version: '0'
|
66
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
67
|
+
requirements:
|
68
|
+
- - '>='
|
69
|
+
- !ruby/object:Gem::Version
|
70
|
+
version: '0'
|
71
|
+
requirements: []
|
72
|
+
rubyforge_project:
|
73
|
+
rubygems_version: 2.0.3
|
74
|
+
signing_key:
|
75
|
+
specification_version: 4
|
76
|
+
summary: Ruby helper for crossbrowsertesting.com API
|
77
|
+
test_files: []
|