soar-registry-directory 5.0.0 → 5.0.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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 25375792d34b3062277d3100e6e2dc99e404c75e
|
4
|
+
data.tar.gz: 5fad83bf254ed3fe03b12c3bde8398e25e77609b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c056c7b6e8f10460b0984598c856a3a2035418f663cb4cce11a193c243a22620eb61390e9f5f17a8ae4292856de6efedea52f7614cb17a01d777d6bc3457bf80
|
7
|
+
data.tar.gz: 68d43c936a4b1c5e20b14b1303c2516ffc4b653d3f3f5a2dead51348d703c136c6d437c01343c7ae3104317e4abe1db6c0d503bc154435b2459018d0a1d7696b
|
@@ -24,11 +24,12 @@ module Soar
|
|
24
24
|
# @option configuration [String] :region
|
25
25
|
# @option configuration [String] :endpoint
|
26
26
|
##
|
27
|
-
def initialize(credentials: , table: ,
|
28
|
-
@table_name = table
|
29
|
-
|
30
|
-
@
|
31
|
-
@
|
27
|
+
def initialize(credentials: , table: , configuration: )
|
28
|
+
@table_name = table[:name]
|
29
|
+
index = table[:index]
|
30
|
+
@partition_key = index[:partition_key]
|
31
|
+
@sort_key = index[:sort_key] if index.key?(:sort_key)
|
32
|
+
@global_secondary_indexes = index[:global_secondary_index] if index.key?(:global_secondary_index)
|
32
33
|
@credentials = Hashie.symbolize_keys(credentials)
|
33
34
|
configuration[:credentials] = Aws::Credentials.new(@credentials[:username], @credentials[:password])
|
34
35
|
@client = Aws::DynamoDB::Client.new(Hashie.symbolize_keys(configuration))
|
@@ -40,11 +41,17 @@ module Soar
|
|
40
41
|
# @raise [Soar::Registry::Directory::Error::DuplicateEntryError]
|
41
42
|
##
|
42
43
|
def put(entry)
|
44
|
+
condition_expression = "attribute_not_exists(#{@partition_key})"
|
45
|
+
condition_expression += " AND attribute_not_exists(#{@sort_key})" if @sort_key
|
46
|
+
#@global_secondary_indexes.each { |global_secondary_index|
|
47
|
+
# condition_expression += " AND attribute_not_exists(#{global_secondary_index})"
|
48
|
+
#} if @global_secondary_indexes
|
49
|
+
|
43
50
|
adapt_exceptions do
|
44
51
|
@client.put_item({
|
45
52
|
table_name: @table_name,
|
46
53
|
item: entry,
|
47
|
-
condition_expression:
|
54
|
+
condition_expression: condition_expression
|
48
55
|
})
|
49
56
|
return true
|
50
57
|
end
|
@@ -64,7 +71,7 @@ module Soar
|
|
64
71
|
key: primary_key
|
65
72
|
}
|
66
73
|
identity = @client.get_item(options)
|
67
|
-
raise Soar::Registry::Directory::Error::NoEntriesFoundError, "No entries found for
|
74
|
+
raise Soar::Registry::Directory::Error::NoEntriesFoundError, "No entries found for primary_key = #{primary_key}" if identity.item.nil?
|
68
75
|
identity.item
|
69
76
|
end
|
70
77
|
end
|
@@ -125,7 +132,6 @@ module Soar
|
|
125
132
|
# @return [Boolean]
|
126
133
|
##
|
127
134
|
def recreate_table(name: nil, structure: nil)
|
128
|
-
|
129
135
|
adapt_exceptions do
|
130
136
|
if @client.list_tables.table_names.include?(name)
|
131
137
|
@client.delete_table({
|
@@ -13,21 +13,16 @@ module Soar
|
|
13
13
|
def initialize
|
14
14
|
@retries = 5
|
15
15
|
@configuration = YAML.load_file("config/#{ENV['CONFIG_FILE']}")
|
16
|
-
@table = @configuration['provider']['
|
17
|
-
@index = @
|
16
|
+
@table = @configuration['provider']['config']['table']
|
17
|
+
@index = @table['index']
|
18
18
|
@entries = JSON.parse(File.read("lib/soar/registry/directory/test/fixtures/entries.json"))
|
19
19
|
end
|
20
20
|
|
21
21
|
def given_configured_directory
|
22
|
-
provider = Soar::Registry::Directory::Provider::DynamoDb.new(
|
23
|
-
credentials: @configuration['provider']['credentials'],
|
24
|
-
table: @table,
|
25
|
-
index: @index,
|
26
|
-
configuration: @configuration['provider']['config']
|
27
|
-
})
|
22
|
+
provider = Soar::Registry::Directory::Provider::DynamoDb.new(Hashie.symbolize_keys(@configuration['provider']['config']))
|
28
23
|
@directory = Soar::Registry::Directory.new(provider)
|
29
24
|
@directory.provider.recreate_table({
|
30
|
-
name: @table,
|
25
|
+
name: @table[:name],
|
31
26
|
structure: JSON.parse(File.read("lib/soar/registry/directory/test/fixtures/table_structure.json"))
|
32
27
|
})
|
33
28
|
end
|
@@ -39,9 +34,8 @@ module Soar
|
|
39
34
|
end
|
40
35
|
|
41
36
|
def sabotage_network
|
42
|
-
@configuration['provider']['config'][
|
43
|
-
@configuration['provider']['config']['
|
44
|
-
@directory.provider.client = Aws::DynamoDB::Client.new(Hashie.symbolize_keys(@configuration['provider']['config']))
|
37
|
+
@configuration['provider']['config']['configuration'][:endpoint] = 'http://does-not-exist'
|
38
|
+
@directory.provider.client = Aws::DynamoDB::Client.new(Hashie.symbolize_keys(@configuration['provider']['config']['configuration']))
|
45
39
|
end
|
46
40
|
|
47
41
|
def put_duplicate_entry
|
@@ -102,9 +96,9 @@ module Soar
|
|
102
96
|
|
103
97
|
def index?
|
104
98
|
@index == {
|
105
|
-
|
106
|
-
|
107
|
-
|
99
|
+
partition_key: @index[:partition_key],
|
100
|
+
sort_key: @index[:sort_key],
|
101
|
+
global_secondary_index: @index[:global_secondary_index]
|
108
102
|
}
|
109
103
|
end
|
110
104
|
|
@@ -13,14 +13,18 @@ module Soar
|
|
13
13
|
|
14
14
|
def initialize
|
15
15
|
@configuration = YAML.load_file("config/#{ENV['CONFIG_FILE']}")
|
16
|
-
@index = @configuration['provider']['config']['index']
|
16
|
+
@index = @configuration['provider']['config']['index'].map { |index| index.to_sym }
|
17
17
|
@attributes = @configuration['provider']['config']['attributes']
|
18
18
|
@entries = [{
|
19
19
|
ID: 1,
|
20
20
|
Client_Number: "C123456789",
|
21
|
-
Notifyemail_Invoice: "johnconner@example.com"
|
21
|
+
Notifyemail_Invoice: "johnconner@example.com",
|
22
|
+
First_Name: 'John',
|
23
|
+
Surname: 'Connor'
|
22
24
|
}, {
|
23
25
|
ID: 2,
|
26
|
+
First_Name: 'Sarah',
|
27
|
+
Surname: 'Connor',
|
24
28
|
Client_Number: "C101112134",
|
25
29
|
Notifyemail_Invoice: "sarahconnor@example.com"
|
26
30
|
}]
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: soar-registry-directory
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 5.0.
|
4
|
+
version: 5.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Charles Mulder
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-02-
|
11
|
+
date: 2017-02-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: hashy_db
|
@@ -154,7 +154,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
154
154
|
version: '0'
|
155
155
|
requirements: []
|
156
156
|
rubyforge_project:
|
157
|
-
rubygems_version: 2.5.
|
157
|
+
rubygems_version: 2.5.2
|
158
158
|
signing_key:
|
159
159
|
specification_version: 4
|
160
160
|
summary: Soar Registry Directory
|