Module: Apstrings

Defined in:
lib/apstrings.rb,
lib/apstrings/line.rb,
lib/apstrings/logger.rb,
lib/apstrings/reader.rb,
lib/apstrings/kv_pair.rb,
lib/apstrings/version.rb,
lib/apstrings/strings_parser.rb,
lib/apstrings/dot_string_file.rb,
lib/apstrings/strings_validator.rb

Defined Under Namespace

Classes: DotStringFile, KVPair, Line, Log, Reader, StringsParser, ValidateResult, Validator

Constant Summary collapse

VERSION =
"0.4.1"

Class Method Summary collapse

Class Method Details

.log_error(message) ⇒ Object



62
63
64
# File 'lib/apstrings.rb', line 62

def self.log_error(message)
  Log::error(message)
end

.log_info(message) ⇒ Object



54
55
56
# File 'lib/apstrings.rb', line 54

def self.log_info(message)
  Log::info(message)
end

.log_warning(message) ⇒ Object



58
59
60
# File 'lib/apstrings.rb', line 58

def self.log_warning(message)
  Log::warn(message)
end

.parse(file) ⇒ Object

Public



11
12
13
14
# File 'lib/apstrings.rb', line 11

def self.parse(file)
 	file = Apstrings::read(file)
		StringsParser.new(file).parse_file
end

.read(file) ⇒ Object



16
17
18
# File 'lib/apstrings.rb', line 16

def self.read(file)
	Reader.read(file)
end

.validate(file, masterFile = nil) ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/apstrings.rb', line 20

def self.validate(file,masterFile = nil)
 
   valid_strings , valid_master = false, true
   Open3.popen3("plutil",  "-lint" ,"#{file}") {|i, o, e, t| 
       if t.value.exitstatus == 0
         valid_strings = true
       else
         valid_strings = false
         error =  e.gets
         output = o.gets
         message = (error != nil  ? error : output)
         Apstrings::log_error(" Format error in #{file}: #{message}")
       end
   }

   if masterFile != nil
       Open3.popen3("plutil",  "-lint" ,"#{masterFile}") {|i, o, e, t| 
       if t.value.exitstatus == 0
         valid_master = true
       else
         valid_master = false
         error =  e.gets
         output = o.gets
         message = (error != nil  ? error : output)
         Apstrings::log_error(" Format error in #{file}: #{message}")
       end
     }
   end

   if valid_strings && valid_master
     Validator::validate(file,masterFile)
   end
end