browserstack-screenshot 0.0.1 → 0.0.2

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 CHANGED
@@ -1,15 +1,7 @@
1
- ---
2
- !binary "U0hBMQ==":
3
- metadata.gz: !binary |-
4
- ZTUyYmVmYzE5MDJmZDA5YjY4MGRhOGVkNzBlZmEyMWZmYTcyNmU2MQ==
5
- data.tar.gz: !binary |-
6
- N2E2YzM4YzM3Yjk3ODg5NWJiYjY0YzdkYWYxNzk5YTNlZTRhZjk3YQ==
7
- !binary "U0hBNTEy":
8
- metadata.gz: !binary |-
9
- MTRkODZlN2UwZmFmZjA4ZDRlMjIzN2U2NWU2ZTYwOTQwMzkzMDBmMTY4NzQy
10
- MGJlMTU0ZWM3Yzg1MzgyM2IzOGNjYTM4ZTFiMzk0N2RkNWQwNDU0Y2U3Nzcw
11
- NmU5M2NkMmVmOGExNzA0OGY5MjdkMzBjZmRkZmI4MzQ5MWVjNDE=
12
- data.tar.gz: !binary |-
13
- ZWQyMzBiMTY3YjNhYzY0N2M0NWNjZWMwNzc0ODMxMGZmYTc4OWEwZWZkZWMx
14
- NDZmODRmOGUxMjIzYzU0NjdkZjI1OGUwMTI2NDQwYzk4OWMxY2Q0MWJmYjk1
15
- YWFjNTljNWI3NGU3MWJiMjc3MTNlYzk1N2JhNWE5YThkODgzMmU=
1
+ ---
2
+ SHA512:
3
+ data.tar.gz: b979c9234f0b4c1739ea153638a169cad12663691f8948062b6dfc5197224ed24837f66e736844af4b84551113c141c7647e60acddbcfa4598095e0c4f202c2b
4
+ metadata.gz: 9de316bf428c0d53aa15c81b1e355912209710175208f06a30b7da32ebbd5acc6971e5f513599c878d455c4f60682f8d50da27635d4f4e4eeccd92ab162da071
5
+ SHA1:
6
+ data.tar.gz: 26ef50dce12fdfd09a12c27fdacb876c5844bc2e
7
+ metadata.gz: 02467616ef664eda6a1ae99febd06de47dc0dd2c
data/.gitignore CHANGED
@@ -15,3 +15,4 @@ spec/reports
15
15
  test/tmp
16
16
  test/version_tmp
17
17
  tmp
18
+ .DS_Store
data/README.md CHANGED
@@ -39,14 +39,14 @@ client = Screenshot::Client.new(settings)
39
39
  ###API
40
40
 
41
41
  ####Getting available os and browsers
42
- Fetches all available browsers. [API info](http://www.browserstack.com/screenshots/api#browser-list)
42
+ Fetches all available browsers. [API info](http://www.browserstack.com/screenshots/api#list-os-browsers)
43
43
 
44
44
  ``` ruby
45
45
  client.get_os_and_browsers #returns a hash
46
46
  ```
47
47
 
48
48
  ####Generating Screenshots
49
- Frame the config object according to the format given. [Format info](http://www.browserstack.com/screenshots/api#job-ids)
49
+ Frame the config object according to the format given. [Format info](http://www.browserstack.com/screenshots/api#generate-screenshots)
50
50
 
51
51
  Eg settings object:
52
52
  ``` ruby
@@ -56,6 +56,8 @@ params = {
56
56
  :win_res => "1024x768", #Options : "1024x768", "1280x1024"
57
57
  :mac_res => "1920x1080", #Options : "1024x768", "1280x960", "1280x1024", "1600x1200", "1920x1080"
58
58
  :quality => "compressed", #Options : "compressed", "original"
59
+ :wait_time => 5, #Options: 2, 5, 10, 15, 20, 60
60
+ :orientation => "portrait", #Options: "portrait", "landscape"
59
61
  :tunnel => false,
60
62
  :browsers => [
61
63
  {:os=>"Windows",:os_version=>"7",:browser=>"ie",:browser_version=>"8.0"},
@@ -63,7 +65,7 @@ params = {
63
65
  ]
64
66
  }
65
67
  ```
66
- `callback_url`, `win_res`, `mac_res`, `quality` and `tunnel` being optional parameters.
68
+ `callback_url`, `win_res`, `mac_res`, `quality`, `wait_time`, `orientation` and `tunnel` being optional parameters.
67
69
 
68
70
  #####For testing Local/Internal Server setup
69
71
  * First setup local tunnel using the command line method as mentioned [here](http://www.browserstack.com/local-testing#setup)
@@ -100,4 +102,4 @@ client.screenshots request_id
100
102
  2. Create your feature branch (`git checkout -b my-new-feature`)
101
103
  3. Commit your changes (`git commit -am 'Add some feature'`)
102
104
  4. Push to the branch (`git push origin my-new-feature`)
103
- 5. Create new Pull Request
105
+ 5. Create new Pull Request
@@ -6,8 +6,8 @@ require 'screenshot/version'
6
6
  Gem::Specification.new do |spec|
7
7
  spec.name = "browserstack-screenshot"
8
8
  spec.version = Screenshot::VERSION
9
- spec.authors = ["ahmed1490"]
10
- spec.email = ["ahmed1490@gmail.com"]
9
+ spec.authors = ["ahmed1490", "utsavkesharwani"]
10
+ spec.email = ["ahmed1490@gmail.com", "utsav.kesharwani@gmail.com"]
11
11
  spec.description = %q{Ruby wrapper for Browserstack screenshots API}
12
12
  spec.summary = %q{Get screenshots from live browsers using this gem}
13
13
  spec.homepage = "https://github.com/browserstack/ruby-screenshots"
@@ -1,5 +1,6 @@
1
1
  require "base64"
2
- require "net/http"
2
+ require "net/https"
3
+ require "openssl"
3
4
  require "yajl"
4
5
  require "screenshot/client"
5
6
  require "screenshot/version"
@@ -1,7 +1,7 @@
1
1
  module Screenshot
2
2
  class Client
3
3
 
4
- API = "http://www.browserstack.com/screenshots"
4
+ API = "https://www.browserstack.com/screenshots"
5
5
 
6
6
  def initialize(options={})
7
7
  options = symbolize_keys options
@@ -61,6 +61,10 @@ module Screenshot
61
61
 
62
62
  def make_request req, options={}, uri=API
63
63
  conn = Net::HTTP.new uri.host, uri.port
64
+ conn.use_ssl = uri.scheme == 'https'
65
+ conn.verify_mode = OpenSSL::SSL::VERIFY_PEER
66
+ conn.cert_store = OpenSSL::X509::Store.new
67
+ conn.cert_store.set_default_paths
64
68
  add_authentication options, req
65
69
  res = conn.request req
66
70
  http_response_code_check res
@@ -77,11 +81,13 @@ module Screenshot
77
81
  when 200
78
82
  res
79
83
  when 401
80
- raise "401 Unauthorized : Authentication Failed!"
84
+ raise AuthenticationError, encode({:code => res.code, :body => res.body})
85
+ when 403
86
+ raise ScreenshotNotAllowedError, encode({:code => res.code, :body => res.body})
81
87
  when 422
82
- raise "Unprocessable entity."+"\n Response Body: "+res.body
88
+ raise InvalidRequestError, encode({:code => res.code, :body => res.body})
83
89
  else
84
- raise "Unexpected Response Code : "+res.code+"\n Response Body: "+res.body
90
+ raise UnexpectedError, encode({:code => res.code, :body => res.body})
85
91
  end
86
92
  end
87
93
 
@@ -90,9 +96,26 @@ module Screenshot
90
96
  parser.parse(response.body)
91
97
  end
92
98
 
99
+ def encode(hash)
100
+ Yajl::Encoder.encode(hash)
101
+ end
102
+
93
103
  def symbolize_keys hash
94
104
  hash.inject({}){|memo,(k,v)| memo[k.to_sym] = v; memo}
95
105
  end
96
106
 
97
107
  end #Client
108
+
109
+ class AuthenticationError < StandardError
110
+ end
111
+
112
+ class InvalidRequestError < StandardError
113
+ end
114
+
115
+ class ScreenshotNotAllowedError < StandardError
116
+ end
117
+
118
+ class UnexpectedError < StandardError
119
+ end
120
+
98
121
  end #Screenshots
@@ -1,3 +1,3 @@
1
1
  module Screenshot
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
metadata CHANGED
@@ -1,96 +1,82 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: browserstack-screenshot
3
- version: !ruby/object:Gem::Version
4
- version: 0.0.1
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.2
5
5
  platform: ruby
6
- authors:
6
+ authors:
7
7
  - ahmed1490
8
+ - utsavkesharwani
8
9
  autorequire:
9
10
  bindir: bin
10
11
  cert_chain: []
11
- date: 2013-04-17 00:00:00.000000000 Z
12
- dependencies:
13
- - !ruby/object:Gem::Dependency
12
+
13
+ date: 2015-06-02 00:00:00 Z
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
14
16
  name: rake
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - ! '>='
18
- - !ruby/object:Gem::Version
19
- version: '0'
20
- type: :development
21
17
  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
18
+ requirement: &id001 !ruby/object:Gem::Requirement
19
+ requirements:
20
+ - &id003
21
+ - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: "0"
24
+ type: :development
25
+ version_requirements: *id001
26
+ - !ruby/object:Gem::Dependency
28
27
  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
28
  prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - '='
39
- - !ruby/object:Gem::Version
29
+ requirement: &id002 !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "="
32
+ - !ruby/object:Gem::Version
40
33
  version: 1.1.0
34
+ type: :runtime
35
+ version_requirements: *id002
41
36
  description: Ruby wrapper for Browserstack screenshots API
42
- email:
37
+ email:
43
38
  - ahmed1490@gmail.com
39
+ - utsav.kesharwani@gmail.com
44
40
  executables: []
41
+
45
42
  extensions: []
43
+
46
44
  extra_rdoc_files: []
47
- files:
48
- - !binary |-
49
- LkRTX1N0b3Jl
50
- - !binary |-
51
- LmdpdGlnbm9yZQ==
52
- - !binary |-
53
- LnJ1YnktZ2Vtc2V0
54
- - !binary |-
55
- LnJ1YnktdmVyc2lvbg==
56
- - !binary |-
57
- R2VtZmlsZQ==
58
- - !binary |-
59
- TElDRU5TRS50eHQ=
60
- - !binary |-
61
- UkVBRE1FLm1k
62
- - !binary |-
63
- UmFrZWZpbGU=
64
- - !binary |-
65
- YnJvd3NlcnN0YWNrLXNjcmVlbnNob3QuZ2Vtc3BlYw==
66
- - !binary |-
67
- bGliL3NjcmVlbnNob3QucmI=
68
- - !binary |-
69
- bGliL3NjcmVlbnNob3QvY2xpZW50LnJi
70
- - !binary |-
71
- bGliL3NjcmVlbnNob3QvdmVyc2lvbi5yYg==
45
+
46
+ files:
47
+ - .gitignore
48
+ - .ruby-gemset
49
+ - .ruby-version
50
+ - Gemfile
51
+ - LICENSE.txt
52
+ - README.md
53
+ - Rakefile
54
+ - browserstack-screenshot.gemspec
55
+ - lib/screenshot.rb
56
+ - lib/screenshot/client.rb
57
+ - lib/screenshot/version.rb
72
58
  homepage: https://github.com/browserstack/ruby-screenshots
73
- licenses:
74
- - ''
59
+ licenses:
60
+ - ""
75
61
  metadata: {}
62
+
76
63
  post_install_message:
77
64
  rdoc_options: []
78
- require_paths:
65
+
66
+ require_paths:
79
67
  - lib
80
- required_ruby_version: !ruby/object:Gem::Requirement
81
- requirements:
82
- - - ! '>='
83
- - !ruby/object:Gem::Version
84
- version: '0'
85
- required_rubygems_version: !ruby/object:Gem::Requirement
86
- requirements:
87
- - - ! '>='
88
- - !ruby/object:Gem::Version
89
- version: '0'
68
+ required_ruby_version: !ruby/object:Gem::Requirement
69
+ requirements:
70
+ - *id003
71
+ required_rubygems_version: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - *id003
90
74
  requirements: []
75
+
91
76
  rubyforge_project:
92
- rubygems_version: 2.0.3
77
+ rubygems_version: 2.0.15
93
78
  signing_key:
94
79
  specification_version: 4
95
80
  summary: Get screenshots from live browsers using this gem
96
81
  test_files: []
82
+
data/.DS_Store DELETED
Binary file