arc_weld 0.3.1 → 0.3.12

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
  SHA1:
3
- metadata.gz: 930cfc559a14797468e987a6a4575d503e489e75
4
- data.tar.gz: b09b4ced15f5fbe5866f0049de01b1bdf2556196
3
+ metadata.gz: 2277081def68f14e24ea8e16833d31d2e76f0859
4
+ data.tar.gz: 69b941694b14d6177b71a0505b1fccf9dc4cecfa
5
5
  SHA512:
6
- metadata.gz: a0d31f18c19fdefd8c9b6b8b7fb5c8d355e53201722fdc6d4d9a1b11d5edf98bcdbc0d7768a5ef6f087263c888a0b6fc4b2a88e51005fe34afa127530207bc26
7
- data.tar.gz: 8d15eb767e6c467306d08a0417831f8d9ed6270bd75ad84a29391980b8a563519841ab883e28eba2789eb80d3088215e70cddd7d4b3efe396d7a693088e80340
6
+ metadata.gz: 592531f511cffde34bea7c5e44e708f6b41f51f35a67abd12544dfc2552d49ade60f41a00b851b29099b6f1b64823f17856d295a8782ee0bf75234b2f7f71c67
7
+ data.tar.gz: 5ffcaba2a98a99596ec9b65a9583dc4ad68bbf8157e1f79fad3b3eaece44c5f353f7d6c02f35d9d501c69345ace178f508c994f4048158c7370156e0289cbd70
data/.gitignore CHANGED
@@ -1,5 +1,7 @@
1
+ /.idea/
1
2
  /.bundle/
2
3
  /.yardoc
4
+ /Gemfile
3
5
  /Gemfile.lock
4
6
  /_yardoc/
5
7
  /coverage/
data/bin/weld CHANGED
@@ -5,4 +5,4 @@ if Dir.exist?(local_lib=File.join(Dir.pwd,'lib'))
5
5
  Dir[File.join(local_lib,'*.rb')]. each {|local_lib| require local_lib }
6
6
  end
7
7
 
8
- ArcWeld::WeldCli.start(ARGV)
8
+ ArcWeld::Cli.start(ARGV)
@@ -14,19 +14,22 @@ module ArcWeld
14
14
  ArcWeld.const_get(constantize(resource_type))
15
15
  end
16
16
 
17
- def resource_input_path(resource_type)
18
- File.join(self.input_dir, resource_inputs.fetch(resource_type))
17
+ def input_file(filename)
18
+ File.join(self.input_dir, filename)
19
19
  end
20
20
 
21
- def resource_reader(resource_type)
21
+ def resource_reader(resource_type,filename)
22
22
  klass = ArcWeld::Cli::ResourceReaders.const_get(constantize(resource_driver))
23
- klass.new( path: resource_input_path(resource_type),
23
+ klass.new( path: input_file(filename),
24
24
  target_class: resource_class_for(resource_type) )
25
25
  end
26
26
 
27
27
  def reader
28
28
  @readers ||= Hash[
29
- resource_inputs.keys.map { |type| [type, resource_reader(type)]}
29
+ resource_inputs.map do |resource_type,*filenames|
30
+ resource_type_readers = filenames.flatten.map {|filename| resource_reader(resource_type,filename)}
31
+ [resource_type, resource_type_readers]
32
+ end
30
33
  ]
31
34
  end
32
35
 
@@ -43,8 +46,8 @@ module ArcWeld
43
46
  end
44
47
 
45
48
  def load_resources
46
- reader.each do |type, type_reader|
47
- res=type_reader.to_a
49
+ reader.each do |type, type_readers|
50
+ res=type_readers.flat_map &:to_a
48
51
  resources[type].push(*res)
49
52
  end
50
53
  end
@@ -91,21 +94,19 @@ module ArcWeld
91
94
  end
92
95
 
93
96
  def assign_resource_groups
94
- resource_roots['zone'].add_children(*resources['zone'])
95
-
96
- zone_assets
97
-
98
97
  unzoned = resources['asset'].select {|a| a.in_zone.nil?}
99
98
  resource_roots['asset'].add_children(*unzoned)
100
99
 
101
- %w{ network customer location asset_category }.each do |type|
102
- resource_roots[type].add_children(*resources[type])
100
+ %w{ network customer location asset_category zone }.each do |type|
101
+ unrooted = resources[type].select {|instance| instance.parent_ref==instance.class.toplevel }
102
+ resource_roots[type].add_children(*unrooted)
103
103
  end
104
104
  end
105
105
 
106
106
  def generate_archive
107
107
  resource_roots
108
108
  load_resources
109
+ zone_assets
109
110
  assign_resource_groups
110
111
  assign_model_relations
111
112
  archive.add(*resources.values.flatten)
@@ -34,11 +34,14 @@ module ArcWeld
34
34
  src_instance=sources(inputs).find {|s| s.send(src_select) == selected_src }
35
35
  dst_instance=destinations(inputs).find {|s| s.send(dst_select) == selected_dst}
36
36
 
37
- if (src_instance.nil? || dst_instance.nil?)
38
- STDERR.puts format('could not %s %s/%s',
37
+ if src_instance.nil?
38
+ STDERR.puts format('could not %s from %s to %s (source resource not found)',
39
39
  relationship_type,
40
- selected_src,
41
- selected_dst)
40
+ selected_src, selected_dst)
41
+ elsif dst_instance.nil?
42
+ STDERR.puts format('could not %s from %s to %s (destination resource not found)',
43
+ relationship_type,
44
+ selected_src, selected_dst)
42
45
  else
43
46
  src_instance.send(relationship_type,dst_instance)
44
47
  end
@@ -30,13 +30,17 @@ module ArcWeld
30
30
  def relate(inputs)
31
31
  csv.each do |selected_src, category_uri|
32
32
  src_instance=sources(inputs).find {|s| s.send(src_select)==selected_src}
33
-
33
+
34
34
  if (src_instance.nil?)
35
- STDERR.puts format('could not %s %s/%s',
36
- relationship_type,
35
+ STDERR.puts format('could not add category uri %s to %s (resource nil)',
36
+ category_uri,
37
37
  selected_src)
38
+ next
39
+ end
40
+ if ac_resource = inputs['asset_category'].find {|ac| ac.ref_uri==category_uri}
41
+ src_instance.add_category(ac_resource)
38
42
  else
39
- src_instance.send(relationship_type,category_uri)
43
+ src_instance.send(relationship_type,category_uri)
40
44
  end
41
45
  end
42
46
  end
@@ -1,3 +1,3 @@
1
1
  module ArcWeld
2
- VERSION = '0.3.1'
2
+ VERSION = '0.3.12'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: arc_weld
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.3.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Breed
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-10-05 00:00:00.000000000 Z
11
+ date: 2015-12-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: gyoku
@@ -182,7 +182,6 @@ description: Toolkit for building ArcSight resources
182
182
  email:
183
183
  - opensource@breed.org
184
184
  executables:
185
- - setup
186
185
  - weld
187
186
  extensions: []
188
187
  extra_rdoc_files: []
@@ -196,7 +195,6 @@ files:
196
195
  - README.md
197
196
  - Rakefile
198
197
  - arc_weld.gemspec
199
- - bin/setup
200
198
  - bin/weld
201
199
  - lib/arc_weld.rb
202
200
  - lib/arc_weld/archive.rb
@@ -262,7 +260,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
262
260
  version: '0'
263
261
  requirements: []
264
262
  rubyforge_project:
265
- rubygems_version: 2.4.5
263
+ rubygems_version: 2.4.5.1
266
264
  signing_key:
267
265
  specification_version: 4
268
266
  summary: Toolkit for building ArcSight resources
data/bin/setup DELETED
@@ -1,7 +0,0 @@
1
- #!/bin/bash
2
- set -euo pipefail
3
- IFS=$'\n\t'
4
-
5
- bundle install
6
-
7
- # Do any other automated setup that you need to do here