seiso-import_master 3.0.0.M1 → 3.0.0.M2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- MTk2ZjJlYzk0YTA2YzVhN2IwOWEyZWM3NWM3Y2MwMjc3MjI0ZTNkOA==
4
+ ZWZjNDQ1MTc4NmM3MmQ4M2Q2YTU3YzkyZGVmYTQ5YjU1MTE3OTcyZA==
5
5
  data.tar.gz: !binary |-
6
- ZTM0NDk1MTQ1YmIxM2Y5OTdmMzc4ZTE4MWY5ZmU0NjM4MjcxYmY3Ng==
6
+ MzhmMDM3ODMwMGViYWYwMmRlNjdjMjY0ZGQ4YjFkYjMyMmViODgwYg==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- YTkwNmE2N2E5M2FlMzZkN2FmNGZjOGEyODFjNmNmOTJmMWMxMThiYmJmMTY2
10
- ZGY2YmQwZTIxMjU3MTkwYWJjMGFlYjU0YWI3ZjM3MjRlYmVlYTUyMGVkY2Ux
11
- MDQ0NDUzODhlZmVjYjFkNDJhNGQ5Mjk3N2Q5YjRmNTNjMTc5MDM=
9
+ NDI4NjIxOTA2NmI0NGNiMmI5MzRlZDg1Mzk4YzNlZGQzN2VhOTIzMDFjYTcz
10
+ ODVlY2Y5MzhiY2M3ZDNjMWYwNzg1ZDY1Mzc2NjRmZGZmMDNjMGJlNTA3MTEx
11
+ Y2VkNjE1MzU5YzMzMTBmNGVkZGM3YzNlNTkyNTJjNDVlNDAzMDc=
12
12
  data.tar.gz: !binary |-
13
- MTI5ZGI3Y2E4NmFkMzg4YjlkMGRjNWQwMDcyODMxMWQxZGU0ZTIxNjU2OWQw
14
- OGE5YjM4YTEwNzhlNzM1NjhjMDcyMTdjNGNjNzM3YzA4MDMzNTcxMmM4M2Yx
15
- MmZmMjFmOTk4MDRlMDFlZjllN2I3NTRhOThjMDk3YWNmYzBjNTc=
13
+ OWE3MGExNzY1NjMzMmM2OTBiODRmNTQ2YmNkOGYxMzI0OGJhNDg0ODBhYTFl
14
+ MzAzNDY5ZDJmMTVlOTVkYmJkZjI0MGZiMjA2OGRjNjE1ODBjNzgzYjZmMjBl
15
+ YTE4ZGM3ZmE3NDYwMGRjNWFiMDlmMzg5ODE0N2U0N2EyNjgwZTc=
data/README.md CHANGED
@@ -50,6 +50,10 @@ Build and install the gem using Rake:
50
50
 
51
51
  For local snapshot installations, you may want to clear out existing versions of the gem first.
52
52
 
53
+ To push the gem:
54
+
55
+ $ gem push pkg/[whichever_gem]
56
+
53
57
  ## TODO
54
58
 
55
59
  Figure out whether we want to use dependency injection for this project. There's debate within the Ruby community
@@ -83,7 +83,11 @@ module Seiso
83
83
 
84
84
  # Rescue StandardError here, not Exception, since we want ctrl-c to stop the program.
85
85
  rescue StandardError => e
86
- @log.error "Failed to import file #{file}: #{e.message}"
86
+
87
+ # IMPORTANT: Don't display the message, because Faraday includes the request headers, which include the base64
88
+ # encoded password.
89
+ # @log.error "Failed to import file #{file}: #{e.message}"
90
+ @log.error "Failed to import file #{file}"
87
91
 
88
92
  # FIXME For now, just re-raise the exception, as we want to see where the bugs are.
89
93
  return false
@@ -2,6 +2,8 @@ class Seiso::ImportMaster
2
2
 
3
3
  # Resolves item keys to their URIs.
4
4
  #
5
+ # TODO Rename to UriResolver.
6
+ #
5
7
  # Author:: Willie Wheeler
6
8
  # Copyright:: Copyright (c) 2014-2015 Expedia, Inc.
7
9
  # License:: Apache 2.0
@@ -19,10 +21,15 @@ class Seiso::ImportMaster
19
21
  'machines' => ->(k) { @api.machines.search.findByName(name: k) },
20
22
  'persons' => ->(k) { @api.persons.search.findByUsername(username: k) }
21
23
  }
24
+
25
+ @uri_cache = {}
22
26
  end
23
27
 
24
28
  # Returns the item URI, or nil if either key is nil or the item doesn't exist.
25
29
  def item_uri(type, key)
30
+ cached_uri = get_cached_uri(type, key)
31
+ return cached_uri unless cached_uri.nil?
32
+
26
33
  @log.info "Getting item URI: type=#{type}, key=#{key}"
27
34
  return nil if key.nil?
28
35
  search = @special_searches[type]
@@ -35,7 +42,9 @@ class Seiso::ImportMaster
35
42
 
36
43
  begin
37
44
  # This returns the item's canonical URI, which is what we want.
38
- item.links.self.href
45
+ item_uri = item.links.self.href
46
+ put_cached_uri(type, key, item_uri)
47
+ item_uri
39
48
  rescue HyperResource::ClientError => e
40
49
  status = e.response.status
41
50
  body = e.response.body
@@ -50,5 +59,20 @@ class Seiso::ImportMaster
50
59
  @log.info "Getting item URL: type=#{type}, key=#{key}"
51
60
  # TODO
52
61
  end
62
+
63
+ def get_cached_uri(type, key)
64
+ type_cache = @cache[type]
65
+ return nil if type_cache.nil?
66
+ type_cache[key]
67
+ end
68
+
69
+ def put_cached_uri(type, key, uri)
70
+ type_cache = @cache[type]
71
+ if type_cache.nil?
72
+ type_cache = {}
73
+ @cache[type] = type_cache
74
+ end
75
+ type[key] = uri
76
+ end
53
77
  end
54
78
  end
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
 
5
5
  Gem::Specification.new do |spec|
6
6
  spec.name = 'seiso-import_master'
7
- spec.version = '3.0.0.M1'
7
+ spec.version = '3.0.0.M2'
8
8
  spec.authors = ['Willie Wheeler']
9
9
  spec.email = ['wwheeler@expedia.com']
10
10
  spec.summary = 'Imports Seiso data master files into Seiso.'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: seiso-import_master
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.0.M1
4
+ version: 3.0.0.M2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Willie Wheeler
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-02-15 00:00:00.000000000 Z
11
+ date: 2016-02-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler