puffing-billy 3.0.1 → 3.0.2

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
  SHA256:
3
- metadata.gz: ec02ea3b7f01e33d68df684db911886bacb0b9c92f1fbe3d9931df42218dd78f
4
- data.tar.gz: 9ea280821375f4ba83429c33aa2d17035a3269e580fbb52c6a26e5db968eed25
3
+ metadata.gz: 3d2331e867abf32f326b7c70cd9b40604bc865a122b4ae86fa2e80d937f34659
4
+ data.tar.gz: 7641cae1895a3922ea7c799cfa8274fbcc119571336428649f869614df58d759
5
5
  SHA512:
6
- metadata.gz: 9b1680023f9b58ee65995bc91471d11f4d1a9fd96dbee00a9635edb23775bbe2824b3234414c5d87aa33709a10b8c71729079bb0bd885db7023958aa4da77859
7
- data.tar.gz: f42c4227325d9dcab48a50eed2f5470db36c90e5fc8aff2618cfd37531fe15e23345b7bff92080053a130b0e9755a8f43c46cdf958d45ece795e8cd4ac7e7c51
6
+ metadata.gz: 2b95020cc16529fc786eb38341c4bc0ab97fa150fd8aa9b1ffae30e6a28905c54f04b80c55eda8c817f057a43937f3e1b089a18d13ef1ceda8a9e2dedbb737c9
7
+ data.tar.gz: e474b6370e0f648bfda03afdd7fc2b0ad6354517d55fbc283c449e8e46609daf9cc977fa11a4c709dd2993b8abd9ca9f6c79924c30f43de39b41751d8a326b7f
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ v3.0.2, 2022-02-16
2
+ -------------------
3
+ * Add rake tasks inside files DSL in gemspec [#321](https://github.com/oesmith/puffing-billy/pull/321)
4
+
1
5
  v3.0.1, 2022-02-15
2
6
  -------------------
3
7
  * Adapt to newer versions selenium webdriver [#314](https://github.com/oesmith/puffing-billy/pull/314)
data/lib/billy/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Billy
2
- VERSION = '3.0.1'
2
+ VERSION = '3.0.2'
3
3
  end
@@ -0,0 +1,87 @@
1
+ require 'addressable/uri'
2
+
3
+ namespace :cache do
4
+ desc 'Print out all cache file information'
5
+ task :print_all do
6
+ cache_array = load_cache
7
+
8
+ sort_cache(cache_array).each do |cache|
9
+ print_cache_details(cache)
10
+ end
11
+ end
12
+
13
+ desc 'Print out specific cache file information'
14
+ task :print_details, :sha do |_t, args|
15
+ fail "Missing sha; usage: rake cache:print_details['<sha>']" unless args[:sha]
16
+ cache_array = load_cache(Billy.config.cache_path, '*' + args[:sha] + '*.yml')
17
+
18
+ sort_cache(cache_array).each do |cache|
19
+ print_cache_details(cache)
20
+ end
21
+ end
22
+
23
+ desc 'Find specific cache files by URL'
24
+ task :find_by_url, :api_path do |_t, args|
25
+ fail "Missing api path; usage: rake cache:find_by_url['<api_path>']" unless args[:api_path]
26
+ cache_array = load_cache
27
+ filtered_cache_array = cache_array.select { |f| f[:url_path].include?(args[:api_path]) }
28
+
29
+ sort_cache(filtered_cache_array).each do |cache|
30
+ print_cache_details(cache)
31
+ end
32
+ end
33
+
34
+ desc 'Find specific cache files by scope'
35
+ task :find_by_scope, :scope do |_t, args|
36
+ fail "Missing scope; usage: rake cache:find_by_scope['<scope>']" unless args[:scope]
37
+ cache_array = load_cache
38
+ filtered_cache_array = cache_array.select { |f| f[:scope] && f[:scope].include?(args[:scope]) }
39
+
40
+ sort_cache(filtered_cache_array).each do |cache|
41
+ print_cache_details(cache)
42
+ end
43
+ end
44
+
45
+ desc 'Find cache files with non-successful status codes'
46
+ task :find_non_successful do
47
+ cache_array = load_cache
48
+ filtered_cache_array = cache_array.select { |f| !(200..299).include?(f[:status]) }
49
+
50
+ sort_cache(filtered_cache_array).each do |cache|
51
+ print_cache_details(cache)
52
+ end
53
+ end
54
+
55
+ def load_cache(cache_directory = Billy.config.cache_path, file_pattern = '*.yml')
56
+ cache_path = Rails.root.join(cache_directory)
57
+ cache_array = []
58
+
59
+ Dir.glob(cache_path + file_pattern) do |filename|
60
+ data = load_cache_file(filename)
61
+ url = Addressable::URI.parse(data[:url])
62
+ data[:url_path] = "#{url.path}#{url.query ? '?' + url.query : ''}#{url.fragment ? '#' + url.fragment : ''}"
63
+ data[:filename] = filename.gsub(Rails.root.to_s + '/', '')
64
+ cache_array << data
65
+ end
66
+ cache_array
67
+ end
68
+
69
+ def load_cache_file(filename)
70
+ YAML.load_file(filename)
71
+ rescue ArgumentError => e
72
+ puts "Could not parse YAML: #{e.message}"
73
+ end
74
+
75
+ def print_cache_details(cache)
76
+ puts " Scope: #{cache[:scope]}" if cache[:scope]
77
+ puts " URL: #{cache[:url]}"
78
+ puts " Body: #{cache[:body]}" if Billy.config.cache_request_body_methods.include?(cache[:method])
79
+ puts " Details: Request method '#{cache[:method]}' returned response status code: '#{cache[:status]}'"
80
+ puts "Filename: #{cache[:filename]}"
81
+ puts "\n\n"
82
+ end
83
+
84
+ def sort_cache(cache, key = :url_path)
85
+ cache.sort_by { |hsh| hsh[key] }
86
+ end
87
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: puffing-billy
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.1
4
+ version: 3.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Olly Smith
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-02-15 00:00:00.000000000 Z
11
+ date: 2022-02-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec
@@ -366,6 +366,7 @@ files:
366
366
  - lib/billy/watir/rspec.rb
367
367
  - lib/puffing-billy.rb
368
368
  - lib/puffing-billy/rspec.rb
369
+ - lib/tasks/billy.rake
369
370
  homepage: https://github.com/oesmith/puffing-billy
370
371
  licenses:
371
372
  - MIT