s3_config 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 734b33901f2445ab19eb93ff9b4f0a2d239e7943
4
- data.tar.gz: 02ba0c8af0aa15bc60e6ae6762cea54a20f1c27b
3
+ metadata.gz: 778a5e7ca679476ec5d9e4c753a314899e8684ac
4
+ data.tar.gz: e968f60a39d9eb5f412ae2a2e4b5896e1911d2f6
5
5
  SHA512:
6
- metadata.gz: 2d89be2db1e4c40ad3fedebcf733023d17d62c232f6a6477fc6b269bb96beadeeb9151574d55dc4a096349489efe49f11234c2bef93f8e1aece09c74c08b7152
7
- data.tar.gz: dc2fabcaa2ed139e7f249856e1862bd9619241f46c33d14b0d467824ed862a0fecd250cb18573935810889d62313d0fb1cdc4030b7149c8c5addf1eeb27bba35
6
+ metadata.gz: 859819057c87ff3a9eed95caf7d1d1c1e4b975a78aa27fef3cbb0a843970bbc75364d554418985588113be2d31f2e683e09378a2be43b2d5a96daf3a577e6cf0
7
+ data.tar.gz: cc510e7933bc6858bcb855f544864d3a9a685c28cadb4e52a1c7c006ab57617ae5229a178d446b190a5c70da8a906fd922907f5c4d32ec65833d6854b3cc299e
@@ -51,8 +51,12 @@ module S3Config
51
51
  !client.nil? and !bucket.nil?
52
52
  end
53
53
 
54
+ def versions_count
55
+ bucket.objects({prefix: "#{environment}/"}).count
56
+ end
57
+
54
58
  def latest_version
55
- [(bucket.objects({prefix: "#{environment}/"}).count - 1), 0].max
59
+ [versions_count - 1, 0].max
56
60
  end
57
61
 
58
62
  def read(key)
@@ -61,7 +65,11 @@ module S3Config
61
65
  end
62
66
 
63
67
  def write(key, value)
64
- config = read_configuration
68
+ begin
69
+ config = read_configuration
70
+ rescue ConfigNotDefinedError
71
+ config = {}
72
+ end
65
73
  unless config[key] == value
66
74
  config[key] = value
67
75
  write_configuration config
@@ -110,7 +118,7 @@ module S3Config
110
118
  end
111
119
 
112
120
  def write_configuration(config)
113
- if e = environment and next_version = (latest_version + 1)
121
+ if e = environment and next_version = versions_count
114
122
  serialized_config = YAML.dump(config)
115
123
  bucket.put_object({
116
124
  body: serialized_config,
@@ -1,3 +1,3 @@
1
1
  module S3Config
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: s3_config
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Zane Shannon