testament 0.1.0 → 0.2.0
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.
- data/lib/testament/cli.rb +3 -3
- data/lib/testament/database.rb +1 -0
- data/lib/testament/project.rb +11 -4
- data/lib/testament/version.rb +1 -1
- data/spec/testament/database_spec.rb +1 -0
- data/spec/testament_spec.rb +5 -0
- metadata +2 -2
data/lib/testament/cli.rb
CHANGED
@@ -23,9 +23,9 @@ class CLI < Thor
|
|
23
23
|
|
24
24
|
desc "record COMMAND", "record and execute COMMAND"
|
25
25
|
def record(*command_words)
|
26
|
-
command = command_words.join(' ')
|
27
26
|
project = Testament::Project.load
|
28
|
-
project.record
|
27
|
+
record = project.record command_words
|
28
|
+
exit record[:exit_status]
|
29
29
|
end
|
30
30
|
|
31
31
|
desc "log", "print logs"
|
@@ -48,4 +48,4 @@ END_TXT
|
|
48
48
|
table = Terminal::Table.new :headings => report.headers, :rows => report.rows
|
49
49
|
puts table
|
50
50
|
end
|
51
|
-
end
|
51
|
+
end
|
data/lib/testament/database.rb
CHANGED
data/lib/testament/project.rb
CHANGED
@@ -14,19 +14,26 @@ module Testament
|
|
14
14
|
@default_category = arguments.fetch('default_category')
|
15
15
|
end
|
16
16
|
|
17
|
-
def record(
|
17
|
+
def record(command_words)
|
18
18
|
start_time = Time.now
|
19
|
-
system
|
19
|
+
system *command_words
|
20
20
|
end_time = Time.now
|
21
21
|
elapsed_milliseconds = ((end_time - start_time) * 1000).round
|
22
|
+
command = command_words.join(' ')
|
22
23
|
|
23
|
-
|
24
|
+
memento = {
|
25
|
+
project: name,
|
24
26
|
command: command,
|
25
27
|
start_time: start_time,
|
26
28
|
elapsed_milliseconds: elapsed_milliseconds,
|
29
|
+
exit_status: $?.exitstatus,
|
27
30
|
user: user,
|
28
31
|
version: version,
|
29
32
|
category: default_category
|
33
|
+
}
|
34
|
+
|
35
|
+
database.record memento
|
36
|
+
memento
|
30
37
|
end
|
31
38
|
|
32
39
|
def log
|
@@ -48,4 +55,4 @@ module Testament
|
|
48
55
|
|
49
56
|
attr_reader :database
|
50
57
|
end
|
51
|
-
end
|
58
|
+
end
|
data/lib/testament/version.rb
CHANGED
data/spec/testament_spec.rb
CHANGED
@@ -49,6 +49,11 @@ describe 'testament' do
|
|
49
49
|
output = testament 'log'
|
50
50
|
expect(output).to match(/echo foo/)
|
51
51
|
end
|
52
|
+
|
53
|
+
it 'returns the return code of the executed commnd' do
|
54
|
+
testament "record ruby -e 'exit 1'"
|
55
|
+
expect($?.exitstatus).to eq(1)
|
56
|
+
end
|
52
57
|
end
|
53
58
|
|
54
59
|
context 'log' do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: testament
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-12-
|
12
|
+
date: 2012-12-21 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activesupport
|