Class: DataCatalog::ImporterFramework::Handler

Inherits:
Object
  • Object
show all
Includes:
Shared
Defined in:
lib/handler.rb

Instance Method Summary collapse

Methods included from Shared

#folder

Constructor Details

#initialize(options) ⇒ Handler

Returns a new instance of Handler.



8
9
10
11
12
13
14
15
# File 'lib/handler.rb', line 8

def initialize(options)
  @options = options
  @counter = {}
  [:source, :organization].each do |resource|
    FileUtils.mkdir_p(folder(resource))
    @counter[resource] = 1
  end
end

Instance Method Details

#organization(data) ⇒ Object



21
22
23
# File 'lib/handler.rb', line 21

def organization(data)
  write_data(:organization, data)
end

#source(data) ⇒ Object



17
18
19
# File 'lib/handler.rb', line 17

def source(data)
  write_data(:source, data)
end

#write_data(resource, data) ⇒ Object



25
26
27
28
29
# File 'lib/handler.rb', line 25

def write_data(resource, data)
  file = folder(resource) + ("/%08i.yml" % @counter[resource])
  Utility.write_yaml(file, data)
  @counter[resource] += 1
end