Class: WsdlMapper::Generation::Base Abstract

Inherits:
Object
  • Object
show all
Defined in:
lib/wsdl_mapper/generation/base.rb

Overview

This class is abstract.

Instance Method Summary collapse

Constructor Details

#initialize(context) ⇒ Base

Returns a new instance of Base.



10
11
12
13
# File 'lib/wsdl_mapper/generation/base.rb', line 10

def initialize(context)
  @context = context
  @logger = Logging.logger[self]
end

Instance Method Details

#append_file_for(type_name, result, &block) ⇒ Object



40
41
42
43
# File 'lib/wsdl_mapper/generation/base.rb', line 40

def append_file_for(type_name, result, &block)
  file_name = @context.path_for type_name
  file file_name, result, mode: 'a', &block
end

#file(file_name, result, mode: 'w') ⇒ Object



51
52
53
54
55
56
57
58
# File 'lib/wsdl_mapper/generation/base.rb', line 51

def file(file_name, result, mode: 'w')
  File.open file_name, mode do |io|
    f = get_formatter io
    yield f
  end

  result.files << file_name
end

#file_for(type_name, result, &block) ⇒ Object



35
36
37
38
# File 'lib/wsdl_mapper/generation/base.rb', line 35

def file_for(type_name, result, &block)
  file_name = @context.path_for type_name
  file file_name, result, &block
end

#generate_name(name, suffix = '') ⇒ Object



15
16
17
18
19
20
21
22
23
# File 'lib/wsdl_mapper/generation/base.rb', line 15

def generate_name(name, suffix = '')
  return 'nil' if name.nil?

  ns = name.ns.inspect
  local_name = (name.name + suffix).inspect


  "[#{ns}, #{local_name}]"
end

#get_formatter(io) ⇒ Object



60
61
62
# File 'lib/wsdl_mapper/generation/base.rb', line 60

def get_formatter(io)
  @formatter_factory.new io
end

#get_module_names(type) ⇒ Object



64
65
66
# File 'lib/wsdl_mapper/generation/base.rb', line 64

def get_module_names(type)
  type.parents.reverse.map(&:module_name)
end

#get_type_name(type) ⇒ Object



25
26
27
28
29
30
31
32
33
# File 'lib/wsdl_mapper/generation/base.rb', line 25

def get_type_name(type)
  if type.name
    type
  elsif type.containing_element
    @namer.get_inline_type type.containing_element
  elsif type.containing_property
    @namer.get_inline_type type.containing_property
  end
end

#type_file_for(type_name, result) {|| ... } ⇒ Object



46
47
48
49
# File 'lib/wsdl_mapper/generation/base.rb', line 46

def type_file_for(type_name, result, &block)
  file_for type_name, result, &block
  result.add_type type_name
end