consult 0.8.0 → 0.8.1

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 371b66af8be47b598b8ee428856c17d35864b5ba93b3bff8ad0852c4d403d2fe
4
- data.tar.gz: ce70cfa1f22a21d6255ae2fd1a867b2950765ca5c3b8b3c4f8090aab8f0c28d1
3
+ metadata.gz: 8b95340130b792146eeee73303c8a617ef7ce1a9d4748a124e3d8b46658280a5
4
+ data.tar.gz: 9103d4414a1d933a82a49f917143fb3d6d2d2f0ecd6b11f79089f0d0477c6a75
5
5
  SHA512:
6
- metadata.gz: f72c7410f792f22c1bdc4d095b9f2fb122943625f2be6876461f692acd378fbd4bce6ce14797fe387d59d8ffaaf827612b3a7fb908d880a07b2933dddf294d03
7
- data.tar.gz: f19a08e8ec11f404c82c6344885c36cc9346d04fbdaa7de8fdb9ddb3fe7059d1cc4c7d4c472a2a2ad41a642a87e338b5aa49a4eff36b0a19cd795dc29b48ee9f
6
+ metadata.gz: 9047b28026836b804685e285839d58e29bd3b4cfc53ba9e29d207e27d26afe217a15d21d8b74557a17503fe958287e2b35cb3171cfa02382a93ae8846bbe761e
7
+ data.tar.gz: fbeacae84e7a885817ad3bc9e058ed6c83d1d27e0825466bd0dc334690a8beca29a9bc7a38e85f2136933102e3b425ff5aa70000abcd347adfb9732dfe221d0c
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ #### 0.8.1
2
+
3
+ * Obey template location order as specified in consult's config
4
+
1
5
  #### 0.8.0
2
6
 
3
7
  * Add support for multiple sources for a single template ([#14](https://github.com/veracross/consult/pull/14))
@@ -7,6 +7,8 @@ module Consult
7
7
  include Utilities
8
8
  include TemplateFunctions
9
9
 
10
+ LOCATIONS = %i[path paths consul_key consul_keys]
11
+
10
12
  attr_reader :name, :config
11
13
 
12
14
  def initialize(name, config)
@@ -53,23 +55,27 @@ module Consult
53
55
  dest.mtime < (Time.now - @config[:ttl].to_i)
54
56
  end
55
57
 
58
+ def ordered_locations
59
+ @config.keys & LOCATIONS
60
+ end
61
+
56
62
  private
57
63
 
58
64
  # Concatenate all the source templates together, in the order provided
59
- # Disk contents go first
60
65
  def contents
61
- disk_contents + consul_contents
66
+ ordered_locations.map do |location|
67
+ location.to_s.start_with?('consul') ? consul_contents(location) : disk_contents(location)
68
+ end.join
62
69
  end
63
70
 
64
- def consul_contents
65
- [@config[:consul_key], @config[:consul_keys]].compact.flatten.map do |key|
71
+ def consul_contents(location)
72
+ [@config[location]].compact.flatten.map do |key|
66
73
  Diplomat::Kv.get(key, options: nil, not_found: :return, found: :return)
67
74
  end.join
68
75
  end
69
76
 
70
- # Concatenate all the source templates together, in the order provided
71
- def disk_contents
72
- [path, paths].compact.flatten.map do |file_path|
77
+ def disk_contents(location)
78
+ [public_send(location)].compact.flatten.map do |file_path|
73
79
  File.read file_path, encoding: 'utf-8'
74
80
  end.join
75
81
  end
@@ -1,3 +1,3 @@
1
1
  module Consult
2
- VERSION = '0.8.0'
2
+ VERSION = '0.8.1'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: consult
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.0
4
+ version: 0.8.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeff Fraser
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-10-10 00:00:00.000000000 Z
11
+ date: 2018-10-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport