Class: Objc2swiftAssistant::Assistant
- Inherits:
-
Object
- Object
- Objc2swiftAssistant::Assistant
- Defined in:
- lib/assistant.rb
Instance Attribute Summary collapse
-
#config ⇒ Object
Returns the value of attribute config.
-
#config_file_path ⇒ Object
Returns the value of attribute config_file_path.
-
#configuration ⇒ Object
Returns the value of attribute configuration.
-
#dest_root ⇒ Object
Returns the value of attribute dest_root.
-
#log_level_name ⇒ Object
Returns the value of attribute log_level_name.
-
#recognizers ⇒ Object
Returns the value of attribute recognizers.
-
#source_root ⇒ Object
Returns the value of attribute source_root.
-
#structure_option ⇒ Object
Returns the value of attribute structure_option.
Instance Method Summary collapse
- #generate(dry_run) ⇒ Object
-
#initialize(source, dest, config_file, log_level_name, structure_option) ⇒ Assistant
constructor
A new instance of Assistant.
- #log_stage_start(text) ⇒ Object
- #read_config_file ⇒ Object
- #update ⇒ Object
Constructor Details
#initialize(source, dest, config_file, log_level_name, structure_option) ⇒ Assistant
Returns a new instance of Assistant.
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/assistant.rb', line 29 def initialize( source, dest, config_file, log_level_name, structure_option) @source_root = source @dest_root = dest @config_file_path = config_file.nil? ? nil : Pathname.new( config_file ) @log_level_name = log_level_name @structure_option = structure_option @recognizers = [ CategoryDeclarationRecognizer.new(), CategoryImplRecognizer.new(), ProtocolRecognizer.new(), #EnumRecognizer.new(), ImplementationRecognizer.new(), InterfaceRecognizer.new(), MethodRecognizer.new(), PropertyDeclarationRecognizer.new(), AtDirectiveRecognizer.new() #PragmaMarkRecognizer.new() ] end |
Instance Attribute Details
#config ⇒ Object
Returns the value of attribute config.
24 25 26 |
# File 'lib/assistant.rb', line 24 def config @config end |
#config_file_path ⇒ Object
Returns the value of attribute config_file_path.
23 24 25 |
# File 'lib/assistant.rb', line 23 def config_file_path @config_file_path end |
#configuration ⇒ Object
Returns the value of attribute configuration.
26 27 28 |
# File 'lib/assistant.rb', line 26 def configuration @configuration end |
#dest_root ⇒ Object
Returns the value of attribute dest_root.
21 22 23 |
# File 'lib/assistant.rb', line 21 def dest_root @dest_root end |
#log_level_name ⇒ Object
Returns the value of attribute log_level_name.
25 26 27 |
# File 'lib/assistant.rb', line 25 def log_level_name @log_level_name end |
#recognizers ⇒ Object
Returns the value of attribute recognizers.
22 23 24 |
# File 'lib/assistant.rb', line 22 def recognizers @recognizers end |
#source_root ⇒ Object
Returns the value of attribute source_root.
20 21 22 |
# File 'lib/assistant.rb', line 20 def source_root @source_root end |
#structure_option ⇒ Object
Returns the value of attribute structure_option.
27 28 29 |
# File 'lib/assistant.rb', line 27 def structure_option @structure_option end |
Instance Method Details
#generate(dry_run) ⇒ Object
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 |
# File 'lib/assistant.rb', line 55 def generate( dry_run ) unless @config_file_path.nil? log_stage_start( 'Reading Configuration File' ) end @recognizers.each do | recognizer | recognizer.configuration = @configuration end source_file_set = ObjCFileSet.new( @source_root, @recognizers, configuration:@configuration) log_stage_start( 'Scanning Objective-C Source Files' ) source_file_set.scan log_stage_start( 'Recognizing code fragmants' ) source_file_set.recognize_code_fragments log_stage_start( 'Converting to Swift' ) source_file_set.prepare_conversion source_file_set.generate_swift_file_set( @dest_root, dry_run ) source_file_set.dump( '', ' ', @configuration.dump_only_errors ) if @configuration.dump_source # TODO # source_file_set.generate_swift_files(dry_run) # # generator = SwiftFileGenerator( @dest_root, source_file_set ) # generator.map_sources_to_destinations # if writeCode # # else # generator.concat_source_files() end |
#log_stage_start(text) ⇒ Object
104 105 106 107 |
# File 'lib/assistant.rb', line 104 def log_stage_start( text ) return unless @verbose @configuration.log_verbose( "\n---------------------------------------- #{text} ----------------------------------------\n\n" ) end |
#read_config_file ⇒ Object
92 93 94 95 96 97 98 99 100 101 102 |
# File 'lib/assistant.rb', line 92 def read_config_file if @config_file_path.nil? @configuration = ObjC2SwiftConfiguration.new( {}, @log_level_name, @structure_option ) else file_data = @config_file_path.read config_hash = JSON.parse(file_data) @configuration = ObjC2SwiftConfiguration.new( config_hash, @log_level_name, @structure_option ) end @configuration.load_configuration end |
#update ⇒ Object
49 50 51 52 53 |
# File 'lib/assistant.rb', line 49 def update source_file_set = ObjCFileSet.new( @source_root, @config_hash ) source_file_set.scan end |