sauce_whisk 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +15 -0
- data/.gitignore +17 -0
- data/Gemfile +7 -0
- data/LICENSE.txt +22 -0
- data/README.md +37 -0
- data/Rakefile +10 -0
- data/lib/sauce_whisk/assets.rb +25 -0
- data/lib/sauce_whisk/jobs.rb +112 -0
- data/lib/sauce_whisk/rest_request_builder.rb +29 -0
- data/lib/sauce_whisk/version.rb +3 -0
- data/lib/sauce_whisk.rb +23 -0
- data/sauce_whisk.gemspec +27 -0
- data/spec/fixtures/vcr_cassettes/assets.yml +161478 -0
- data/spec/fixtures/vcr_cassettes/jobs.yml +256 -0
- data/spec/fixtures/vcr_cassettes/no_jobs.yml +0 -0
- data/spec/fixtures/vcr_cassettes/rest_request.yml +0 -0
- data/spec/lib/sauce_whisk/asset_spec.rb +39 -0
- data/spec/lib/sauce_whisk/assets_spec.rb +27 -0
- data/spec/lib/sauce_whisk/job_spec.rb +113 -0
- data/spec/lib/sauce_whisk/jobs_spec.rb +78 -0
- data/spec/lib/sauce_whisk/rest_request_builder_spec.rb +50 -0
- data/spec/lib/sauce_whisk/sauce_whisk_spec.rb +27 -0
- data/spec/spec_helper.rb +25 -0
- data/vendor/psych/lib/psych/class_loader.rb +101 -0
- data/vendor/psych/lib/psych/coder.rb +94 -0
- data/vendor/psych/lib/psych/core_ext.rb +35 -0
- data/vendor/psych/lib/psych/deprecated.rb +85 -0
- data/vendor/psych/lib/psych/exception.rb +13 -0
- data/vendor/psych/lib/psych/handler.rb +249 -0
- data/vendor/psych/lib/psych/handlers/document_stream.rb +22 -0
- data/vendor/psych/lib/psych/handlers/recorder.rb +39 -0
- data/vendor/psych/lib/psych/json/ruby_events.rb +19 -0
- data/vendor/psych/lib/psych/json/stream.rb +16 -0
- data/vendor/psych/lib/psych/json/tree_builder.rb +12 -0
- data/vendor/psych/lib/psych/json/yaml_events.rb +29 -0
- data/vendor/psych/lib/psych/nodes/alias.rb +18 -0
- data/vendor/psych/lib/psych/nodes/document.rb +60 -0
- data/vendor/psych/lib/psych/nodes/mapping.rb +56 -0
- data/vendor/psych/lib/psych/nodes/node.rb +55 -0
- data/vendor/psych/lib/psych/nodes/scalar.rb +67 -0
- data/vendor/psych/lib/psych/nodes/sequence.rb +81 -0
- data/vendor/psych/lib/psych/nodes/stream.rb +37 -0
- data/vendor/psych/lib/psych/nodes.rb +77 -0
- data/vendor/psych/lib/psych/omap.rb +4 -0
- data/vendor/psych/lib/psych/parser.rb +51 -0
- data/vendor/psych/lib/psych/scalar_scanner.rb +149 -0
- data/vendor/psych/lib/psych/set.rb +4 -0
- data/vendor/psych/lib/psych/stream.rb +37 -0
- data/vendor/psych/lib/psych/streaming.rb +27 -0
- data/vendor/psych/lib/psych/syntax_error.rb +21 -0
- data/vendor/psych/lib/psych/tree_builder.rb +96 -0
- data/vendor/psych/lib/psych/visitors/depth_first.rb +26 -0
- data/vendor/psych/lib/psych/visitors/emitter.rb +51 -0
- data/vendor/psych/lib/psych/visitors/json_tree.rb +24 -0
- data/vendor/psych/lib/psych/visitors/to_ruby.rb +372 -0
- data/vendor/psych/lib/psych/visitors/visitor.rb +19 -0
- data/vendor/psych/lib/psych/visitors/yaml_tree.rb +496 -0
- data/vendor/psych/lib/psych/visitors.rb +6 -0
- data/vendor/psych/lib/psych/y.rb +9 -0
- data/vendor/psych/lib/psych.bundle +0 -0
- data/vendor/psych/lib/psych.rb +497 -0
- data/vendor/psych/tmp/x86_64-darwin12.3.0/psych/1.9.3/Makefile +221 -0
- data/vendor/psych/tmp/x86_64-darwin12.3.0/psych/1.9.3/mkmf.log +50 -0
- data/vendor/psych/tmp/x86_64-darwin12.3.0/psych/1.9.3/psych.bundle +0 -0
- data/vendor/psych/tmp/x86_64-darwin12.3.0/psych/1.9.3/psych.o +0 -0
- data/vendor/psych/tmp/x86_64-darwin12.3.0/psych/1.9.3/psych_emitter.o +0 -0
- data/vendor/psych/tmp/x86_64-darwin12.3.0/psych/1.9.3/psych_parser.o +0 -0
- data/vendor/psych/tmp/x86_64-darwin12.3.0/psych/1.9.3/psych_to_ruby.o +0 -0
- data/vendor/psych/tmp/x86_64-darwin12.3.0/psych/1.9.3/psych_yaml_tree.o +0 -0
- metadata +194 -0
checksums.yaml
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
---
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
NTVhMzg0MGRmMjk3NGZjMjEwMDA4Mzk5M2RiYzQ3N2I3Y2E0ZDQxOA==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
MDBiZDc3M2Q3MDc0OGYzYjlmMzk4YTNmNWZjZjI2ZWRiNmIyZjYyYQ==
|
7
|
+
!binary "U0hBNTEy":
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
Zjk3NDY0MmY2Y2I2NDc4YmYzNzljMGZhNDVhZmQ4Zjc0Yjg5NTQxOTkzZGE5
|
10
|
+
OWMzNGZkYzE4MmU2ZjY0MTIzYTVlYzZiYTU1NjM1ODIxN2Y2OGMxMzJlOWJl
|
11
|
+
YjgxMDQ1OGNmNDI0NTJkNzcyNzMyZTZiNjI4OTI2N2FkY2Y2OGI=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
MmZjMGUwNGM5N2QyNGQxYWQ0NWMzMjgwYmJlZjFlMjFhYTAxMGYzNTQyYWFh
|
14
|
+
MzgwYTRhNWYwODhlOTcyNGRhYTE1YWEwNDE1ODU5YjcwNGVkZDM1NzM1MGIx
|
15
|
+
ZGQzYmU2NzMyYTVkZDYyYmZjZWI1MTVhNDlhODljNTFiMGQwNDc=
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 Dylan Lacey
|
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,37 @@
|
|
1
|
+
# SauceWhisk
|
2
|
+
|
3
|
+
SauceWhisk provides an "ActiveRecord" style client for the [Sauce Labs](http://www.saucelabs.com) RESTful API. If you're not using the [Sauce Gem](https://rubygems.org/gems/sauce) and you want a nice way to interact with our API, give this a try.
|
4
|
+
|
5
|
+
[](https://travis-ci.org/DylanLacey/sauce_whisk)
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
gem 'sauce_whisk'
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install sauce_whisk
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
### Marking a Job as Passed
|
24
|
+
|
25
|
+
SauceWhisk::Jobs.pass_job job_id
|
26
|
+
|
27
|
+
### Marking a Job as Failed
|
28
|
+
|
29
|
+
SauceWhisk::Jobs.fail_job job_id
|
30
|
+
|
31
|
+
## Contributing
|
32
|
+
|
33
|
+
1. Fork it
|
34
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
35
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
36
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
37
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
class Assets
|
2
|
+
extend RestRequestBuilder
|
3
|
+
|
4
|
+
def self.resource
|
5
|
+
"#{SauceWhisk.username}/jobs"
|
6
|
+
end
|
7
|
+
|
8
|
+
def self.fetch(job_id, asset, type=nil)
|
9
|
+
data = get "#{job_id}/assets/#{asset}"
|
10
|
+
Asset.new({:name => asset, :data => data, :job_id => job_id, :type => type})
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
class Asset
|
15
|
+
|
16
|
+
attr_reader :asset_type, :name, :data, :job
|
17
|
+
|
18
|
+
def initialize(parameters={})
|
19
|
+
@asset_type = parameters[:type] || :screenshot
|
20
|
+
@name = parameters[:name]
|
21
|
+
@data = parameters[:data]
|
22
|
+
@job = parameters[:job_id]
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
@@ -0,0 +1,112 @@
|
|
1
|
+
require 'json'
|
2
|
+
|
3
|
+
require 'sauce_whisk/rest_request_builder'
|
4
|
+
|
5
|
+
class Jobs
|
6
|
+
extend RestRequestBuilder
|
7
|
+
|
8
|
+
def self.resource
|
9
|
+
"#{SauceWhisk.username}/jobs"
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.all
|
13
|
+
all_jobs = JSON.parse get
|
14
|
+
all_jobs.map {|job| Job.new(job)}
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.change_status(job_id, status)
|
18
|
+
put job_id, {"passed" => status}.to_json
|
19
|
+
end
|
20
|
+
|
21
|
+
def self.pass_job(job_id)
|
22
|
+
change_status(job_id, true)
|
23
|
+
end
|
24
|
+
|
25
|
+
def self.fail_job(job_id)
|
26
|
+
change_status(job_id, false)
|
27
|
+
end
|
28
|
+
|
29
|
+
def self.save(job)
|
30
|
+
fields_to_save = job.updated_fields.each_with_object(Hash.new) do |field, hsh|
|
31
|
+
hsh[field] = job.send(field.to_s)
|
32
|
+
end
|
33
|
+
put job.id, fields_to_save.to_json
|
34
|
+
end
|
35
|
+
|
36
|
+
def self.fetch(job_id)
|
37
|
+
job_hash = JSON.parse(get job_id)
|
38
|
+
assets = JSON.parse get "#{job_id}/assets"
|
39
|
+
screenshots = assets["screenshots"]
|
40
|
+
|
41
|
+
job_hash.merge!({"screenshot_urls" => screenshots})
|
42
|
+
Job.new(job_hash)
|
43
|
+
end
|
44
|
+
|
45
|
+
def self.fetch_asset(job_id, asset)
|
46
|
+
asset = get "#{job_id}/assets/#{asset}"
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
class Job
|
51
|
+
attr_writer :updated_fields
|
52
|
+
|
53
|
+
def self.tracked_attr_accessor(*methods)
|
54
|
+
methods.each do |method|
|
55
|
+
attr_reader method
|
56
|
+
self.define_method("#{method}=") do |arg|
|
57
|
+
if method != arg
|
58
|
+
updated_fields << method
|
59
|
+
instance_variable_set("@#{method}", arg)
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
attr_reader :id, :owner, :browser, :browser_version, :os, :log_url
|
66
|
+
attr_reader :error, :creation_time, :start_time, :end_time, :video_url
|
67
|
+
attr_reader :screenshot_urls
|
68
|
+
|
69
|
+
tracked_attr_accessor :custom_data, :tags, :name, :visibility, :build, :passed
|
70
|
+
|
71
|
+
def initialize(parameters={})
|
72
|
+
passed = parameters.delete "status"
|
73
|
+
cd = parameters.delete "custom-data"
|
74
|
+
visibility = parameters.delete "public"
|
75
|
+
|
76
|
+
self.passed = passed
|
77
|
+
self.custom_data = cd
|
78
|
+
self.visibility = visibility
|
79
|
+
|
80
|
+
parameters.each do |k,v|
|
81
|
+
self.instance_variable_set("@#{k}".to_sym, v)
|
82
|
+
end
|
83
|
+
|
84
|
+
@updated_fields = []
|
85
|
+
end
|
86
|
+
|
87
|
+
def save
|
88
|
+
Jobs.save(self)
|
89
|
+
end
|
90
|
+
|
91
|
+
def updated_fields
|
92
|
+
@updated_fields ||= []
|
93
|
+
end
|
94
|
+
|
95
|
+
def screenshots
|
96
|
+
unless @screenshots
|
97
|
+
@screenshots = screenshot_urls.map do |screenshot|
|
98
|
+
Assets.fetch id, screenshot
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
@screenshots
|
103
|
+
end
|
104
|
+
|
105
|
+
def video
|
106
|
+
unless @video
|
107
|
+
@video = Assets.fetch id, "video.flv", :video
|
108
|
+
end
|
109
|
+
|
110
|
+
@video
|
111
|
+
end
|
112
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module RestRequestBuilder
|
2
|
+
|
3
|
+
def get(resource_to_fetch=nil)
|
4
|
+
resource_url = fully_qualified_resource
|
5
|
+
resource_url << "/#{resource_to_fetch}" if resource_to_fetch
|
6
|
+
RestClient::Request.execute({:method => :get, :url => resource_url}.merge auth_details)
|
7
|
+
end
|
8
|
+
|
9
|
+
def put(resource_id, body)
|
10
|
+
url = "#{fully_qualified_resource}/#{resource_id}"
|
11
|
+
length = body.length
|
12
|
+
headers = {"Content-Length" => length}
|
13
|
+
req_params = {
|
14
|
+
:method => :put,
|
15
|
+
:url => url,
|
16
|
+
:payload => body,
|
17
|
+
:content_type => "application/json"
|
18
|
+
}
|
19
|
+
RestClient::Request.execute(req_params.merge auth_details)
|
20
|
+
end
|
21
|
+
|
22
|
+
def auth_details
|
23
|
+
{:user => SauceWhisk.username, :password => SauceWhisk.password}
|
24
|
+
end
|
25
|
+
|
26
|
+
def fully_qualified_resource
|
27
|
+
"#{SauceWhisk.base_url}/#{resource}"
|
28
|
+
end
|
29
|
+
end
|
data/lib/sauce_whisk.rb
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
require "sauce_whisk/version"
|
2
|
+
require "sauce_whisk/jobs"
|
3
|
+
require "sauce_whisk/assets"
|
4
|
+
require "sauce_whisk/rest_request_builder"
|
5
|
+
|
6
|
+
module SauceWhisk
|
7
|
+
|
8
|
+
def self.base_url
|
9
|
+
"https://saucelabs.com/rest/v1"
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.username
|
13
|
+
ENV["SAUCE_USERNAME"]
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.password
|
17
|
+
ENV["SAUCE_ACCESS_KEY"]
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.pass_job(job_id)
|
21
|
+
Jobs.pass_job job_id
|
22
|
+
end
|
23
|
+
end
|
data/sauce_whisk.gemspec
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'sauce_whisk/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |gem|
|
7
|
+
gem.name = "sauce_whisk"
|
8
|
+
gem.version = SauceWhisk::VERSION
|
9
|
+
gem.authors = ["Dylan Lacey"]
|
10
|
+
gem.email = ["github@dylanlacey.com"]
|
11
|
+
gem.description = "A Wrapper for the Sauce Labs REST API."
|
12
|
+
gem.summary = "Sauce_Whisk lets you mix extra data into your Sauce test results!\nFetch and update Job details, screenshots, videos and logs."
|
13
|
+
gem.homepage = "http://www.github.com/dylanlacey/sauce_whisk"
|
14
|
+
|
15
|
+
gem.files = `git ls-files`.split($/)
|
16
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
17
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
18
|
+
gem.require_paths = ["lib"]
|
19
|
+
|
20
|
+
gem.license = "MIT"
|
21
|
+
|
22
|
+
gem.add_runtime_dependency "rest-client"
|
23
|
+
gem.add_development_dependency "vcr"
|
24
|
+
gem.add_development_dependency "webmock"
|
25
|
+
gem.add_development_dependency "rspec"
|
26
|
+
gem.add_development_dependency "rake"
|
27
|
+
end
|