chronicle-shell 0.2.1 → 0.2.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: e1f1e5fd44c4e21f27a1f0879096ebedc08dcb866ec62393b5935e348816c9a1
4
- data.tar.gz: d1fee6983b672b691f19bf1efb6fa10629cbc3b112205761da35e7f82e5e59ec
3
+ metadata.gz: 2b88a844a7e429898c8cd9851e9326be1cb1a61cb7fb0598d44456519941d3b9
4
+ data.tar.gz: 51db09766b5dacf94e4cd92ea5531cdb6475e5afa4759d48acb7e3e8f224cc36
5
5
  SHA512:
6
- metadata.gz: 15d51d049d46e24bed446cb8ea03cf2faed69f362a974e828336c5e3449d0037e221c15941cbc417c9585ff0e01160f6fcac5765a494f62f0e3d2d0b7934c0c3
7
- data.tar.gz: ca9f88415679b7aa492a318e48885d1df401b98975c5f735bb36eb310494374d33b4e7cbdac06a06714c5161213ff5472796589bb225a96a40842d036f7dab9f
6
+ metadata.gz: 0a4f39726fe053ad6b5341cc5bece31eafb52bfde210fc7cb601cf388b4f7d131d0828d656946f436c455632d9c4f688e3c933f2069fcd55aef7c3204804d9f1
7
+ data.tar.gz: e4941551b42d16d90ac55345395d7b7bfbd73873a05dde157d129f4add9b0f839a4e55bf90705cd048e3a1c91e261f34aaf346933ebcc948630caf07df179c37
@@ -6,10 +6,10 @@ module Chronicle
6
6
  register_connector do |r|
7
7
  r.provider = 'shell'
8
8
  r.description = 'shell command history'
9
- r.identifier = 'shell-history'
9
+ r.identifier = 'history'
10
10
  end
11
11
 
12
- setting :filename, default: ENV['HISTFILE']
12
+ setting :input
13
13
  setting :shell, default: 'bash'
14
14
 
15
15
  BASH_TIMESTAMP_REGEX = /^\#(?<timestamp>[0-9]{10})/
@@ -37,7 +37,8 @@ module Chronicle
37
37
 
38
38
  # TODO: modularize the shell-specific stuff
39
39
  def history_filename
40
- @config.filename || __send__("history_filename_default_#{@config.shell}")
40
+ # Ideally we coudl just use ENV['HISTFILE] but it's not available outside of Bash
41
+ @config.input&.first || __send__("history_filename_default_#{@config.shell}")
41
42
  end
42
43
 
43
44
  def history_filename_default_bash
@@ -80,13 +81,15 @@ module Chronicle
80
81
  end
81
82
 
82
83
  def load_commands_from_bash
83
- timestamp = nil
84
- File.foreach(history_filename) do |line|
85
- if match = line.scrub.match(BASH_TIMESTAMP_REGEX)
86
- timestamp = Time.at(match[:timestamp].to_i)
87
- elsif timestamp
88
- command = { timestamp: timestamp, command: line.scrub.strip }
84
+ command = nil
85
+ File.readlines(history_filename).reverse_each do |line|
86
+ timestamp_line = line.scrub.match(BASH_TIMESTAMP_REGEX)
87
+ if timestamp_line && command
88
+ timestamp = Time.at(timestamp_line[:timestamp].to_i)
89
+ command = { timestamp: timestamp, command: command }
89
90
  yield command
91
+ else
92
+ command = line.scrub.strip
90
93
  end
91
94
  end
92
95
  end
@@ -6,7 +6,7 @@ module Chronicle
6
6
  register_connector do |r|
7
7
  r.provider = 'shell'
8
8
  r.description = 'a shell command'
9
- r.identifier = 'shell-history'
9
+ r.identifier = 'history'
10
10
  end
11
11
 
12
12
  def transform
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Chronicle
4
4
  module Shell
5
- VERSION = "0.2.1"
5
+ VERSION = "0.2.2"
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: chronicle-shell
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Louis
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-03-14 00:00:00.000000000 Z
11
+ date: 2022-03-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: chronicle-etl
@@ -49,7 +49,7 @@ metadata:
49
49
  homepage_uri: https://github.com/chronicle-app/chronicle-shell
50
50
  source_code_uri: https://github.com/chronicle-app/chronicle-shell
51
51
  changelog_uri: https://github.com/chronicle-app/chronicle-shell/releases
52
- post_install_message:
52
+ post_install_message:
53
53
  rdoc_options: []
54
54
  require_paths:
55
55
  - lib
@@ -64,8 +64,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
64
64
  - !ruby/object:Gem::Version
65
65
  version: '0'
66
66
  requirements: []
67
- rubygems_version: 3.3.9
68
- signing_key:
67
+ rubygems_version: 3.3.3
68
+ signing_key:
69
69
  specification_version: 4
70
70
  summary: Shell connectors for Chronicle-ETL
71
71
  test_files: []