calderin 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/bin/calderin +23 -1
  3. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 01a6a91d91c5711d836c4a0f589cb26f1843fbac
4
- data.tar.gz: 43c74bd3469984f537321f8530999e5490723919
3
+ metadata.gz: 25d3aa9f13961e7a53b7d2aba3e8ee11e4c4d75f
4
+ data.tar.gz: 0bc7c90e90fb4ba990c83a8d7208e17e7e082013
5
5
  SHA512:
6
- metadata.gz: a9fbdb494e352efddf2805c4335936a2dae2597e2693e305679ea10d56e50d4a4da6c8e3bb49692ea8d36b68f882154acd65288680cfddc054ca7c6180c3e1ea
7
- data.tar.gz: 0ba557a2f68dd1517c7c09d2fc07494b3cbede49058be089a666437355d3c35120de236bc2375a69c6e3a198fcbce87142414f9e6c670f60f0172aa1f48f8759
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
- `echo #{ message } | gpg --decrypt --output #{File.join(pond_directory, Time.now.strftime('%Y-%m-%d') + '_' + SecureRandom.hex) } && echo >> New Message`
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 }"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: calderin
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - PoTe