big_bro 1.0.0 → 1.1.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.
- checksums.yaml +4 -4
- data/lib/big_brother/counter.rb +1 -1
- data/lib/big_brother/pusher.rb +19 -2
- data/lib/big_brother/reader.rb +8 -0
- data/lib/big_brother/runner.rb +2 -0
- data/lib/big_brother/settings.rb +1 -0
- data/lib/big_brother/version.rb +1 -1
- 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: bfb6753e349d1370ebc2569cf69828523992dba4
|
|
4
|
+
data.tar.gz: 44794e56463db12bcb0b2d0ffbfec167b74a3458
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: f3a86a2552426cf91e6ae8f704f0691fb06b6d9f223605b7c400b6ae80c951e74365ac6f582e6267ad23607c34326f2d7e0a9e7da65ed7e443fbebe22bffb8fa
|
|
7
|
+
data.tar.gz: 3f6d5658bfd96f9a9033c2086b86556f19931a604356a1adfa462aac8b1a566dd7063780ff6ec8bdd9fbb017e39054e8c284a2f2d41242f31180c8c23a84fced
|
data/lib/big_brother/counter.rb
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
require "json"
|
|
2
2
|
|
|
3
3
|
class BigBrother::Counter
|
|
4
|
-
IGNORED_COMMANDS = ["export"]
|
|
4
|
+
IGNORED_COMMANDS = ["export", "cd", "ls", "clear", "ssh", "ftp", "scp"]
|
|
5
5
|
|
|
6
6
|
def self.count_commands_json(file = BigBrother::Settings.get("history_file"), api_key = nil)
|
|
7
7
|
lines = BigBrother::Reader.lines_from_history_file(file)
|
data/lib/big_brother/pusher.rb
CHANGED
|
@@ -1,7 +1,24 @@
|
|
|
1
|
+
require "faraday"
|
|
2
|
+
require "tmpdir"
|
|
3
|
+
|
|
1
4
|
class BigBrother::Pusher
|
|
5
|
+
def self.temp_path
|
|
6
|
+
File.expand_path "big_bro.json", Dir.tmpdir
|
|
7
|
+
end
|
|
8
|
+
|
|
2
9
|
def self.push
|
|
3
10
|
json = BigBrother::Counter.count_commands_json
|
|
4
|
-
|
|
5
|
-
|
|
11
|
+
File.write temp_path, json
|
|
12
|
+
conn = Faraday.new(BigBrother::Settings.get("push_url")) do |f|
|
|
13
|
+
f.request :multipart
|
|
14
|
+
f.request :url_encoded
|
|
15
|
+
f.adapter :net_http
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
payload = { file: Faraday::UploadIO.new(temp_path, "text/plain") }
|
|
19
|
+
|
|
20
|
+
if conn.put("/api/users", payload).status == 200
|
|
21
|
+
BigBrother::Reader.move_history_file
|
|
22
|
+
end
|
|
6
23
|
end
|
|
7
24
|
end
|
data/lib/big_brother/reader.rb
CHANGED
|
@@ -2,4 +2,12 @@ class BigBrother::Reader
|
|
|
2
2
|
def self.lines_from_history_file(filename)
|
|
3
3
|
File.readlines(filename).map(&:strip).reject(&:empty?)
|
|
4
4
|
end
|
|
5
|
+
|
|
6
|
+
def self.move_history_file
|
|
7
|
+
hist_file = BigBrother::Settings.get("history_file")
|
|
8
|
+
old_hist_file = BigBrother::Settings.get("history_file") + ".old"
|
|
9
|
+
history = File.read hist_file
|
|
10
|
+
File.write old_hist_file, history
|
|
11
|
+
File.open(hist_file, "w") {}
|
|
12
|
+
end
|
|
5
13
|
end
|
data/lib/big_brother/runner.rb
CHANGED
data/lib/big_brother/settings.rb
CHANGED
data/lib/big_brother/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: big_bro
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.
|
|
4
|
+
version: 1.1.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- dalexj
|
|
@@ -10,7 +10,7 @@ authors:
|
|
|
10
10
|
autorequire:
|
|
11
11
|
bindir: bin
|
|
12
12
|
cert_chain: []
|
|
13
|
-
date: 2015-03-
|
|
13
|
+
date: 2015-03-19 00:00:00.000000000 Z
|
|
14
14
|
dependencies: []
|
|
15
15
|
description: Pushes data from your terminal history up to the Ministry of Truth
|
|
16
16
|
email: 96dalex@gmail.com
|