kitchen_blame 0.2.0 → 0.3.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: 186f2029646cb8aa537f69f02a085cd6b68cda5d
4
- data.tar.gz: 2a6d6dde0a425c33c5806a05b4790a9d7a457df6
3
+ metadata.gz: 49d7e3e2a1216fb99003b1ae0ecc917f14217a5e
4
+ data.tar.gz: a95032a8972ab0df665e7f63a0f2dd62689a7d9b
5
5
  SHA512:
6
- metadata.gz: 42c193a5f13a2850cdde11b241a70469f0d9b265a3c14d6443635fd378714daeda813ca45acbb937ae1adca846dd28ed399dc8c5908340b1fd324d7bf730e6ed
7
- data.tar.gz: 12a47ab2e5c96823be027a8749d84687b997e64e0786d27adbbf40c7a33240f10a06811c05f126931e85c026c8e36818d9a8599ba171d02cd3411025416cfe94
6
+ metadata.gz: 9ec4b4030315ede1ea630e9a36b1b04bd81d71e21a4a564b2a857fb81568093baf63d19bdd13eb8612ebbd1fc9c39ce2f4c340cc9a8b37435d2acfad1da60c35
7
+ data.tar.gz: 308de4af7c1ccd2555ee2cfb1ae53f620359b9c863dbc5b3808e3f98d2f1a22dfaf59370d72b7055fca2b83cde8da693efe326df52d6effe059c186aaf04f424
data/CHANGELOG.md CHANGED
@@ -6,6 +6,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
6
6
 
7
7
  ## [Unreleased]
8
8
 
9
+ ## [0.3.0] - 2017-07-06
10
+ ### Added
11
+ - Join log path with default kitchen log path when necessary
12
+
9
13
  ## [0.2.0] - 2017-07-05
10
14
  ### Added
11
15
  - version subcommand
@@ -14,5 +14,5 @@
14
14
  # limitations under the License.
15
15
 
16
16
  module KitchenBlame
17
- VERSION = '0.2.0'.freeze
17
+ VERSION = '0.3.0'.freeze
18
18
  end
data/lib/kitchen_blame.rb CHANGED
@@ -16,10 +16,13 @@
16
16
  require 'kitchen_blame/version'
17
17
  require 'date'
18
18
  require 'json'
19
+ require 'pathname'
19
20
 
20
21
  module KitchenBlame
21
22
  # Main class
22
23
  class Blame
24
+ LOG_DIR = (Pathname.getwd + Pathname.new('.kitchen/logs')).freeze
25
+
23
26
  # Return the DateTime object from a regex match with a named capture of 'time'
24
27
  def self.extract_time(match)
25
28
  time = match[:time]
@@ -44,7 +47,17 @@ module KitchenBlame
44
47
  ((pair.last[:time] - pair.first[:time]) * 24 * 60 * 60).to_i
45
48
  end
46
49
 
50
+ # Determine the appropriate log file or raise an error
51
+ def self.resolve_log(log)
52
+ log_path = Pathname.new(log)
53
+ return log_path.to_path if log_path.exist? && log_path.file?
54
+ log_path = LOG_DIR + log_path
55
+ fail "Unable to fully qualify or find test kitchen log #{log}" unless log_path.exist? && log_path.file?
56
+ log_path.to_path
57
+ end
58
+
47
59
  def self.analyze_create(key_path, log)
60
+ log = resolve_log(log)
48
61
  server_log_entries = server_log_entries(key_path, log)
49
62
  create_duration = image_create(log, server_log_entries)
50
63
  startup_finished_entry = server_log_entries.find { |entry| entry['MESSAGE'].include?('Startup finished') }
@@ -72,6 +85,7 @@ module KitchenBlame
72
85
 
73
86
  # rubocop:disable MethodLength
74
87
  def self.analyze_recipe(log)
88
+ log = resolve_log(log)
75
89
  recipe_lines = IO.readlines(log).grep(/Recipe:/).map do |line|
76
90
  match_data = /\[(?<time>.*)\].*Recipe:\s(?<recipe>.*)$/.match(line)
77
91
  next unless match_data
@@ -89,6 +103,7 @@ module KitchenBlame
89
103
 
90
104
  # rubocop:disable MethodLength
91
105
  def self.analyze_duration(log)
106
+ log = resolve_log(log)
92
107
  log_lines = IO.readlines(log).map do |line|
93
108
  match_data = /.,\s\[(?<time>.*)\]\s+[^:]+:(?<log>.*)$/.match(line)
94
109
  next unless match_data
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kitchen_blame
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brian O'Connell
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-07-05 00:00:00.000000000 Z
11
+ date: 2017-07-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler