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: f7534aad40030456e9a4b9fc88d8a58d52e2817a
4
- data.tar.gz: 1afbcb2d7d1a1441eb2e0e5067399c237e3fb19f
3
+ metadata.gz: 25375792d34b3062277d3100e6e2dc99e404c75e
4
+ data.tar.gz: 5fad83bf254ed3fe03b12c3bde8398e25e77609b
5
5
  SHA512:
6
- metadata.gz: 4ba850d7503dffb59cf24d74eff42a43acdb1b145d4920b7e2b053bfcbbf449d8c7ddc76986575b6b4725251b1fe867b3201c54275bd9729bfb9de6ff9337d7d
7
- data.tar.gz: f567f1b47129a1a61997af5b08f29e19c12671dead9e6d8a38974847fa282d6701c4df17fe1709661c3d7f13f7e304953c9ad05a31513c8ab326f64fa017c1eb
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: , index: , configuration: )
28
- @table_name = table
29
- @partition_key = index['partition_key']
30
- @sort_key = index['sort_key'] if index.key?('sort_key')
31
- @global_secondary_indexes = index['global_secondary_index'] if index.key?('global_secondary_index')
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: "attribute_not_exists(#{@partition_key})"
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 #{@primary_key} = #{primary_key}" if identity.item.nil?
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({
@@ -104,7 +104,7 @@ module Soar
104
104
  adapt_exceptions do
105
105
  index = []
106
106
  @client.query("SHOW INDEX FROM Client").each_hash { |entry|
107
- index << entry['Column_name']
107
+ index << entry['Column_name'].to_sym
108
108
  }
109
109
  index
110
110
  end
@@ -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']['table']['name']
17
- @index = @configuration['provider']['table']['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'][:credentials] = Aws::Credentials.new(@configuration['provider']['credentials']['username'], @configuration['provider']['credentials']['password'])
43
- @configuration['provider']['config']['endpoint'] = 'http://does-not-exist'
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
- 'partition_key' => @index['partition_key'],
106
- 'sort_key' => @index['sort_key'],
107
- 'global_secondary_index' => @index['global_secondary_index']
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.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-16 00:00:00.000000000 Z
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.1
157
+ rubygems_version: 2.5.2
158
158
  signing_key:
159
159
  specification_version: 4
160
160
  summary: Soar Registry Directory