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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6e07ae3b4f37d0138a36348cb513575790c26f54
4
- data.tar.gz: 141d96855644816733bf92b068186ccd2a3bf811
3
+ metadata.gz: bfb6753e349d1370ebc2569cf69828523992dba4
4
+ data.tar.gz: 44794e56463db12bcb0b2d0ffbfec167b74a3458
5
5
  SHA512:
6
- metadata.gz: 46875404b0821804a3579cac22e4f513dc2a01031fe0eb37ca39311aff381eee5fb6e7d9f821f95d18231652cf24a3537cbd39e8e3e58013874609f5547bf32c
7
- data.tar.gz: 7596e709c5a0b7962d0fdbac12b5b0bed6910ac4d9f61aeb4f698e64cd58409d7123d5c151aad30f764edf02119d23b2c42e4695f2859036e86ebb9f6ddc6775
6
+ metadata.gz: f3a86a2552426cf91e6ae8f704f0691fb06b6d9f223605b7c400b6ae80c951e74365ac6f582e6267ad23607c34326f2d7e0a9e7da65ed7e443fbebe22bffb8fa
7
+ data.tar.gz: 3f6d5658bfd96f9a9033c2086b86556f19931a604356a1adfa462aac8b1a566dd7063780ff6ec8bdd9fbb017e39054e8c284a2f2d41242f31180c8c23a84fced
@@ -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)
@@ -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
- url = "http://localhost:3000/api/users"
5
- `curl -X PUT --data big_bro='#{json}' #{url}`
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
@@ -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
@@ -40,6 +40,8 @@ class BigBrother::Runner
40
40
  stdout.puts BigBrother::Counter.count_commands_json
41
41
  elsif args[0] == "config"
42
42
  config_commands(args)
43
+ elsif args[0] == "push"
44
+ BigBrother::Pusher.push
43
45
  else
44
46
  stdout.puts "Big bro runner template"
45
47
  end
@@ -12,6 +12,7 @@ class BigBrother::Settings
12
12
  def self.defaults
13
13
  {
14
14
  "history_file" => File.expand_path("~/.bash_history"),
15
+ "push_url" => "https://ministry-of-truth.herokuapp.com/",
15
16
  "api_key" => nil
16
17
  }
17
18
  end
@@ -1,3 +1,3 @@
1
1
  class BigBrother
2
- VERSION = "1.0.0"
2
+ VERSION = "1.1.0"
3
3
  end
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.0.0
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-17 00:00:00.000000000 Z
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