calderin 0.0.3 → 0.0.4

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 +18 -15
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 25d3aa9f13961e7a53b7d2aba3e8ee11e4c4d75f
4
- data.tar.gz: 0bc7c90e90fb4ba990c83a8d7208e17e7e082013
3
+ metadata.gz: e23b4f4464323f9f56e1d76c3bdd7019d43293e0
4
+ data.tar.gz: 530fde6559157174f5fb267493daf9fae4c5bb11
5
5
  SHA512:
6
- metadata.gz: bc415e20f4ed69a5fb429ba42a71aca94128e6d4ec8f55bf0ffe85c9e497256cdbe7a05c78a32bc058a2826df926db6f13e87f5358bd25b8a470440eec53d60b
7
- data.tar.gz: 17b590cb0415399d213807558052a6cf6829642c826539497047673f930579ef0f5f39a3de4c8543a9726e123a94be79ca158d26f70890bf4860ccb58037fe0d
6
+ metadata.gz: 2af8cb37a04809f9f0ab27a5a1b7e9500664e88db90df8059e9fe5b45e654f93233b19cb14c34d06488fd8e086ff2d54e877437045bc3665ed3453cb08e34515
7
+ data.tar.gz: b52ce621d2b0fc56bb28ea9bf7022d3fd056a92a0320782e49bbf6aea45c43366fee1951ed496c7892fc026e938a30c65bfad8db7d8b09c0f8a762b33283144f
data/bin/calderin CHANGED
@@ -46,28 +46,31 @@ when 'message'
46
46
  when 'get'
47
47
  messages = JSON.parse(RestClient.get(pond_url))
48
48
 
49
+ new_messages = []
49
50
  messages.each do |message|
50
51
  tmp_file = File.join(pond_directory, '.' + SecureRandom.hex)
52
+ identifier = Digest::MD5.hexdigest(message)
53
+
54
+ # Check if message is already known
55
+ next if Dir.glob(File.join(pond_directory, "*#{ identifier }*")).any?
51
56
 
52
57
  # Attempt to decrypt message into temporary file
53
58
  `echo #{ message } | gpg --decrypt --output #{ tmp_file }`
54
59
 
55
- # If file exists it means the message is intended for us.
60
+ # If file exists it means the message is intended for us, since
61
+ # we are checking for identifiers it also means the message is
62
+ # new if we reached this point in the code.
56
63
  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
64
+ file_name = File.join(pond_directory, Time.now.strftime('%Y-%m-%d_') + identifier)
65
+ File.rename(tmp_file, file_name)
66
+ new_messages << file_name
67
+ end
68
+ end
69
+
70
+ unless new_messages.empty?
71
+ puts "New Messages: \n"
72
+ new_messages.each do |m|
73
+ puts m
71
74
  end
72
75
  end
73
76
  when 'inbox'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: calderin
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - PoTe
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-11-04 00:00:00.000000000 Z
11
+ date: 2013-11-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: clap