proxy_rb 0.5.0 → 0.6.0

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: 0902f8cb548f1fa6b4180ed66ebf2dcd26edb71a
4
- data.tar.gz: 3e29d77475f07c367318ca19daa7dc5160ba1bb0
3
+ metadata.gz: d9e7207bd7f86b0c2ea177e5806cf5a2588d3cb3
4
+ data.tar.gz: 0162f94083dc363cc0f219b277f72114abfa846c
5
5
  SHA512:
6
- metadata.gz: 14b997bcbfbeb3abffda5dc16e0b04b8313431c4f34b896d3b4cd5f54bddec02c1a05f007ba5ec69d9454c52930d3a309c2ae01a8e157bda5004b77f83e7efa1
7
- data.tar.gz: 06b90ebb03851f17c42ba372f92bb82c033622b341870338897a8c1c2ce599f40dfee891db95cf473887eb5f3ed96e28ce0ad7c12fd04ae6ea6265535010753f
6
+ metadata.gz: 8b934c3f3d8df5727a58341c9293ecff2c6ec6fec6bed89f6d61ad3a3d41bedc1c60d424601693faf7cbe9c90ffc86fbe032837def162845736a348f2e76cd53
7
+ data.tar.gz: 974c031e6bd71d40ce0f16f74bb8da5a877cb9d47092af592588ec92a7ba938aca0fa9f721c4be41660759472f90fb0b7359c63feede795bd7fae63f7963feaf
data/History.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # UNRELEASED
2
2
 
3
+ Empty
4
+
5
+ # RELEASED
6
+
7
+ ## [v0.6.0](https://github.com/cucumber/aruba/compare/v0.5.0...v0.6.0)
8
+
9
+ * Added announcer for response headers
10
+
3
11
  ## [v0.5.0](https://github.com/cucumber/aruba/compare/v0.4.0...v0.5.0)
4
12
 
5
13
  * Added initializer to bootstrap `proxy_prb`
@@ -10,7 +18,6 @@
10
18
  configured user, proxy and resource
11
19
  * Addd new matchers to output better error messages
12
20
 
13
- # RELEASED
14
21
 
15
22
  ## [v0.4.0](https://github.com/cucumber/aruba/compare/v0.1.0...v0.4.0)
16
23
 
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
  require 'shellwords'
3
3
  require 'proxy_rb/colorizer'
4
+ require 'proxy_rb/simple_table'
4
5
 
5
6
  ProxyRb::AnsiColor.coloring = false if !STDOUT.tty? && !ENV.key?('AUTOTEST')
6
7
 
@@ -77,6 +78,7 @@ module ProxyRb
77
78
  output_format :proxy_user, proc { |v| format('Proxy User: %s', v) }
78
79
  output_format :resource_user, proc { |v| format('Resource User: %s', v) }
79
80
  output_format :resource, proc { |v| format('Resource: %s', v) }
81
+ output_format :http_response_headers, proc { |v| format("<<-HTTP_RESPONSE_HEADERS\n%s\nHTTP_RESPONSE_HEADERS", SimpleTable.new(v)) }
80
82
  end
81
83
 
82
84
  def output_format(channel, string = '%s', &block)
@@ -63,6 +63,8 @@ module ProxyRb
63
63
 
64
64
  NonIncludes.register_capybara_driver_for_proxy(proxy)
65
65
 
66
+ proxy_rb.event_bus.notify Events::BeforeResourceFetched.new(page)
67
+
66
68
  begin
67
69
  super(resource.to_s)
68
70
  rescue *ProxyRb.config.driver.timeout_errors
@@ -72,6 +74,8 @@ module ProxyRb
72
74
  rescue => e
73
75
  raise ProxyRb::ResourceNotDownloadableError, "An unexpected error occured while fetching #{resource}: #{e.message}."
74
76
  end
77
+
78
+ proxy_rb.event_bus.notify Events::AfterResourceFetched.new(page)
75
79
  end
76
80
  # rubocop:enable Metrics/AbcSize
77
81
 
@@ -30,5 +30,11 @@ module ProxyRb
30
30
 
31
31
  # The configuration was changed
32
32
  class ChangedConfiguration < BasicEvent; end
33
+
34
+ # Before the resource was fetched
35
+ class BeforeResourceFetched < BasicEvent; end
36
+
37
+ # After the resource was fetched
38
+ class AfterResourceFetched < BasicEvent; end
33
39
  end
34
40
  end
@@ -32,12 +32,14 @@ RSpec.configure do |config|
32
32
  proxy_rb.announcer.activate(:proxy_user) if example.metadata[:announce_proxy_user]
33
33
  proxy_rb.announcer.activate(:resource) if example.metadata[:announce_resource]
34
34
  proxy_rb.announcer.activate(:resource_user) if example.metadata[:announce_resource_user]
35
+ proxy_rb.announcer.activate(:http_response_headers) if example.metadata[:announce_http_response_headers]
35
36
 
36
37
  if example.metadata[:announce]
37
38
  proxy_rb.announcer.activate(:proxy)
38
39
  proxy_rb.announcer.activate(:proxy_user)
39
40
  proxy_rb.announcer.activate(:resource)
40
41
  proxy_rb.announcer.activate(:resource_user)
42
+ proxy_rb.announcer.activate(:http_response_headers)
41
43
  end
42
44
  end
43
45
  end
@@ -54,6 +54,13 @@ module ProxyRb
54
54
  runtime.announcer.announce :resource_user, event.entity
55
55
  end
56
56
  )
57
+
58
+ runtime.event_bus.register(
59
+ :after_resource_fetched,
60
+ proc do |event|
61
+ runtime.announcer.announce :http_response_headers, event.entity.driver.response_headers
62
+ end
63
+ )
57
64
  end
58
65
  # enable Metrics/MethodLength
59
66
  end
@@ -0,0 +1,43 @@
1
+ # Aruba
2
+ module ProxyRb
3
+ # Generate simple table
4
+ class SimpleTable
5
+ private
6
+
7
+ attr_reader :hash, :opts
8
+
9
+ public
10
+
11
+ # Create
12
+ #
13
+ # @param [Hash] hash
14
+ # Input
15
+ def initialize(hash, opts = {})
16
+ @hash = hash
17
+ @opts = {
18
+ :sort => true
19
+ }.merge opts
20
+ end
21
+
22
+ # Generate table
23
+ #
24
+ # @return [String]
25
+ # The table
26
+ def to_s
27
+ longest_key = hash.keys.map(&:to_s).max_by(&:length)
28
+ return '' if longest_key.nil?
29
+
30
+ name_size = longest_key.length
31
+
32
+ rows = hash.each_with_object([]) do |(k,v), a|
33
+ a << format("# %-#{name_size}s => %s", k, v)
34
+ end
35
+
36
+ if opts[:sort] == true
37
+ rows.sort.join("\n")
38
+ else
39
+ rows.join("\n")
40
+ end
41
+ end
42
+ end
43
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
  # Main Module
3
3
  module ProxyRb
4
- VERSION = '0.5.0'
4
+ VERSION = '0.6.0'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: proxy_rb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Max Meyer
@@ -189,6 +189,7 @@ files:
189
189
  - lib/proxy_rb/rspec.rb
190
190
  - lib/proxy_rb/runtime.rb
191
191
  - lib/proxy_rb/setup.rb
192
+ - lib/proxy_rb/simple_table.rb
192
193
  - lib/proxy_rb/user_passwords.rb
193
194
  - lib/proxy_rb/user_passwords/environment_user_password.rb
194
195
  - lib/proxy_rb/user_passwords/vault_user_password.rb