cloudbridge 0.9.2 → 0.9.3

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.
Files changed (2) hide show
  1. data/lib/cloudbridge.rb +22 -0
  2. metadata +2 -2
data/lib/cloudbridge.rb CHANGED
@@ -8,4 +8,26 @@ module CloudBridge
8
8
  timestamp = timestamp.to_i
9
9
  SHA1.hexdigest("#{secret_key}:#{timestamp}:#{hostname}") + ":#{timestamp}:#{hostname}"
10
10
  end
11
+
12
+ def self.secret_for_timestamp(secrets_file, for_time)
13
+ last_secret = nil
14
+ for_time = for_time.to_i
15
+ File.open(secrets_file, "r") {|f|
16
+ f.each {|line|
17
+ timestamp, last_secret = line.strip.split(':', 2)
18
+ # go through until we find a timestamp that is lower than the current time. Ignore any further timestamps.
19
+ break if (timestamp.to_i < for_time)
20
+ }
21
+ }
22
+ if (!last_secret)
23
+ raise "Failed to find any secrets in the secrets file."
24
+ end
25
+ return last_secret
26
+ end
27
+
28
+ def self.add_secret(secrets_file, secret)
29
+ File.open(secrets_file, "a") {|f|
30
+ f.puts("#{Time.now.to_i}:#{secret}")
31
+ }
32
+ end
11
33
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cloudbridge
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.2
4
+ version: 0.9.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Graham Batty
@@ -52,7 +52,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
52
52
  requirements: []
53
53
 
54
54
  rubyforge_project: cloudbridge
55
- rubygems_version: 1.2.0
55
+ rubygems_version: 1.3.1
56
56
  signing_key:
57
57
  specification_version: 2
58
58
  summary: CloudBridge is a self-healing minimal-configuration bridge between front-end and backend web servers. This library provides the tools needed to take advantage of it in ruby.