Module: IosAnalytics::Translate
- Included in:
- CLI
- Defined in:
- lib/ios_analytics/translate.rb
Class Method Summary collapse
Instance Method Summary collapse
- #create_element(checkstyle_dom, file_path, diagnostics) ⇒ Object
- #trans(derived_data, app_name) ⇒ Object
- #trans_file(checkstyle_dom, plist_file) ⇒ Object
Class Method Details
.add_dummy(checkstyle) ⇒ Object
56 57 58 59 60 61 62 |
# File 'lib/ios_analytics/translate.rb', line 56 def self.add_dummy(checkstyle) checkstyle.add_element('file', 'name' => '' ) checkstyle end |
Instance Method Details
#create_element(checkstyle_dom, file_path, diagnostics) ⇒ Object
45 46 47 48 49 50 51 52 53 54 |
# File 'lib/ios_analytics/translate.rb', line 45 def create_element(checkstyle_dom, file_path, diagnostics) file = checkstyle_dom.add_element('file', 'name' => file_path ) file.add_element('error', 'line' => diagnostics['location']['line'], 'severity' => 'error', 'message' => "#{diagnostics['category']}\n#{diagnostics['description']}" ) end |
#trans(derived_data, app_name) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/ios_analytics/translate.rb', line 6 def trans(derived_data, app_name) doc = REXML::Document.new doc << REXML::XMLDecl.new('1.0', 'UTF-8') checkstyle = doc.add_element('checkstyle') path = Pathname.new(derived_data) .join( 'Build', 'Intermediates', "#{app_name}.build", '**', 'StaticAnalyzer', '**', '*.plist' ) Dir.glob(path).each do |plist_file| trans_file(checkstyle, plist_file) end unless checkstyle.has_elements? IosAnalytics::Translate.add_dummy(checkstyle) end doc end |
#trans_file(checkstyle_dom, plist_file) ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/ios_analytics/translate.rb', line 33 def trans_file(checkstyle_dom, plist_file) result = Plist::parse_xml(plist_file) return checkstyle_dom if result['files'].empty? file_path = result['files'][0] result['diagnostics'].each do |diagnostics| create_element(checkstyle_dom, file_path, diagnostics) end checkstyle_dom end |