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.
@@ -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 command
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
@@ -15,6 +15,7 @@ module Testament
15
15
  String :command, null: false
16
16
  Time :start_time, null: false
17
17
  Fixnum :elapsed_milliseconds, null: false
18
+ Fixnum :exit_status, null: false
18
19
  String :user, null: false
19
20
  String :version, null: false
20
21
  String :category, null: false
@@ -14,19 +14,26 @@ module Testament
14
14
  @default_category = arguments.fetch('default_category')
15
15
  end
16
16
 
17
- def record(command)
17
+ def record(command_words)
18
18
  start_time = Time.now
19
- system command
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
- database.record project: name,
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
@@ -1,3 +1,3 @@
1
1
  module Testament
2
- VERSION = "0.1.0"
2
+ VERSION = "0.2.0"
3
3
  end
@@ -19,6 +19,7 @@ describe Testament::Database do
19
19
  command: 'record',
20
20
  start_time: Time.now,
21
21
  elapsed_milliseconds: 42,
22
+ exit_status: 0,
22
23
  user: 'jack',
23
24
  version: '12345678abcdef',
24
25
  category: 'test'
@@ -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.1.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-18 00:00:00.000000000 Z
12
+ date: 2012-12-21 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport