Class: Objc2swiftAssistant::ObjC2SwiftConfiguration

Inherits:
FileHierarchicalConfig show all
Defined in:
lib/objc2swift_assistant/objc_2_swift_configuration.rb

Instance Attribute Summary collapse

Attributes inherited from FileHierarchicalConfig

#all_valid_keys, #config_hash, #configs_by_path, #failure_reason, #node_class

Instance Method Summary collapse

Methods inherited from FileHierarchicalConfig

#add_config_node, #config_value, #config_value_defaulted, #load_configuration

Constructor Details

#initialize(config_hash, log_level_name, structure_option) ⇒ ObjC2SwiftConfiguration

Returns a new instance of ObjC2SwiftConfiguration.



45
46
47
48
49
50
51
52
# File 'lib/objc2swift_assistant/objc_2_swift_configuration.rb', line 45

def initialize( config_hash, log_level_name, structure_option )
  super( config_hash, ALL_CONFIG_KEYS )
  @node_class = ObjC2SwiftConfigNode
  @type_mapper = Objc2SwiftTypeMapper.new()
  @block_converter = Objc2SwiftBlockConverter.new( @type_mapper )
  @log_level = LOG_LEVELS_BY_NAME[ log_level_name ]
  @structure_option = structure_option
end

Instance Attribute Details

#block_converterObject

Returns the value of attribute block_converter.



39
40
41
# File 'lib/objc2swift_assistant/objc_2_swift_configuration.rb', line 39

def block_converter
  @block_converter
end

#log_levelObject

Returns the value of attribute log_level.



42
43
44
# File 'lib/objc2swift_assistant/objc_2_swift_configuration.rb', line 42

def log_level
  @log_level
end

#structure_optionObject

Returns the value of attribute structure_option.



40
41
42
# File 'lib/objc2swift_assistant/objc_2_swift_configuration.rb', line 40

def structure_option
  @structure_option
end

#type_mapperObject

Returns the value of attribute type_mapper.



38
39
40
# File 'lib/objc2swift_assistant/objc_2_swift_configuration.rb', line 38

def type_mapper
  @type_mapper
end

Instance Method Details

#company_name(file_path) ⇒ Object



61
62
63
# File 'lib/objc2swift_assistant/objc_2_swift_configuration.rb', line 61

def company_name( file_path )
  config_value( file_path, COMPANY_NAME_KEY )
end

#dump_only_errorsObject



90
91
92
# File 'lib/objc2swift_assistant/objc_2_swift_configuration.rb', line 90

def dump_only_errors
  @structure_option == 'errors'
end

#dump_sourceObject



86
87
88
# File 'lib/objc2swift_assistant/objc_2_swift_configuration.rb', line 86

def dump_source
  [ 'all', 'errors' ].include?( @structure_option )
end

#emit_original_bodies(file_path) ⇒ Object



69
70
71
# File 'lib/objc2swift_assistant/objc_2_swift_configuration.rb', line 69

def emit_original_bodies( file_path )
  config_value_defaulted( file_path, EMIT_ORIGINAL_BODIES_KEY, true )
end

#emit_original_signatures(file_path) ⇒ Object



65
66
67
# File 'lib/objc2swift_assistant/objc_2_swift_configuration.rb', line 65

def emit_original_signatures( file_path )
  config_value_defaulted( file_path, EMIT_ORIGINAL_SIGNATURES_KEY, true )
end

#emit_unconverted_content(file_path) ⇒ Object



73
74
75
# File 'lib/objc2swift_assistant/objc_2_swift_configuration.rb', line 73

def emit_unconverted_content( file_path )
  config_value_defaulted( file_path, EMIT_UNCONVERTED_CONTENT_KEY, true )
end

#log_verbose(str) ⇒ Object

Logging



78
79
80
# File 'lib/objc2swift_assistant/objc_2_swift_configuration.rb', line 78

def log_verbose( str )
  puts( str ) if @log_level >= LOG_LEVEL_VERBOSE
end

#log_warning(str) ⇒ Object



82
83
84
# File 'lib/objc2swift_assistant/objc_2_swift_configuration.rb', line 82

def log_warning( str )
  puts( "WARNING: " + str ) if @log_level >= LOG_LEVEL_WARNINGS
end

#omit_file(file_path) ⇒ Object



54
55
56
57
58
59
# File 'lib/objc2swift_assistant/objc_2_swift_configuration.rb', line 54

def omit_file( file_path )
  # val = config_value(file_path, OMIT_FILE_KEY)
  # puts( "Omit File: #{file_path} #{val ? 'true' : 'false' }" )  # nil will evaluate to false
  config_value( file_path, OMIT_FILE_KEY )

end