calderin 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/calderin +23 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 25d3aa9f13961e7a53b7d2aba3e8ee11e4c4d75f
|
4
|
+
data.tar.gz: 0bc7c90e90fb4ba990c83a8d7208e17e7e082013
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bc415e20f4ed69a5fb429ba42a71aca94128e6d4ec8f55bf0ffe85c9e497256cdbe7a05c78a32bc058a2826df926db6f13e87f5358bd25b8a470440eec53d60b
|
7
|
+
data.tar.gz: 17b590cb0415399d213807558052a6cf6829642c826539497047673f930579ef0f5f39a3de4c8543a9726e123a94be79ca158d26f70890bf4860ccb58037fe0d
|
data/bin/calderin
CHANGED
@@ -4,6 +4,7 @@ require 'clap'
|
|
4
4
|
require 'toml'
|
5
5
|
require 'securerandom'
|
6
6
|
require 'rest-client'
|
7
|
+
require 'digest/md5'
|
7
8
|
require 'time'
|
8
9
|
|
9
10
|
config_file = File.join(Dir.home, '.pondrc')
|
@@ -46,7 +47,28 @@ when 'get'
|
|
46
47
|
messages = JSON.parse(RestClient.get(pond_url))
|
47
48
|
|
48
49
|
messages.each do |message|
|
49
|
-
|
50
|
+
tmp_file = File.join(pond_directory, '.' + SecureRandom.hex)
|
51
|
+
|
52
|
+
# Attempt to decrypt message into temporary file
|
53
|
+
`echo #{ message } | gpg --decrypt --output #{ tmp_file }`
|
54
|
+
|
55
|
+
# If file exists it means the message is intended for us.
|
56
|
+
if File.exists?(tmp_file)
|
57
|
+
identifier = Digest::MD5.hexdigest(File.read(tmp_file))
|
58
|
+
|
59
|
+
# The message might be old or new, check for the hash to see if we have
|
60
|
+
# it in store
|
61
|
+
if Dir.glob("*#{ identifier }*").any?
|
62
|
+
# Old message, just delete it
|
63
|
+
File.delete(tmp_file)
|
64
|
+
else
|
65
|
+
# New message! :D
|
66
|
+
file_name = File.join(pond_directory, Time.now.strftime('%Y-%m-%d_') + identifier)
|
67
|
+
File.rename(tmp_file, file_name)
|
68
|
+
|
69
|
+
puts "New message:\n#{file_name}"
|
70
|
+
end
|
71
|
+
end
|
50
72
|
end
|
51
73
|
when 'inbox'
|
52
74
|
system "#{ ENV['EDITOR'] || 'vi' } #{ pond_directory }"
|