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 +4 -4
- data/CHANGELOG.md +4 -0
- data/lib/kitchen_blame/version.rb +1 -1
- data/lib/kitchen_blame.rb +15 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 49d7e3e2a1216fb99003b1ae0ecc917f14217a5e
|
4
|
+
data.tar.gz: a95032a8972ab0df665e7f63a0f2dd62689a7d9b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
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.
|
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-
|
11
|
+
date: 2017-07-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|