Class: SublimeDSL::TextMate::Snippet::PListReader
- Defined in:
- lib/sublime_dsl/textmate/snippet.rb
Overview
TextMate format importer
Instance Attribute Summary
Attributes inherited from Importer
Instance Method Summary collapse
Methods inherited from Importer
Constructor Details
This class inherits a constructor from SublimeDSL::TextMate::Snippet::Importer
Instance Method Details
#load ⇒ Object
195 196 197 198 199 200 201 202 203 204 205 206 207 |
# File 'lib/sublime_dsl/textmate/snippet.rb', line 195 def load snippet.file_format = :textmate p = read_plist(file) snippet.tab_trigger = p.delete('tabTrigger') snippet.name = p.delete('name') snippet.content = p.delete('content') snippet.scope = p.delete('scope') snippet.key_equivalent = p.delete('keyEquivalent') snippet.semantic_class = p.delete('semanticClass') snippet.uuid = p.delete('uuid') snippet.bundle_uuid = p.delete('bundleUUID') p.empty? or warn "unexpected keys in #{file}: #{p.inspect}" end |
#read_plist(file) ⇒ Object
209 210 211 212 213 214 215 216 217 218 219 220 221 222 |
# File 'lib/sublime_dsl/textmate/snippet.rb', line 209 def read_plist(file) text = File.read(file, encoding: 'utf-8') # replace forbidden control characters (given in keyEquivalent) h = {} text.gsub!(Tools::XML::FORBIDDEN_CHARS_RE) do |c| h[c] = Tools::XML::FORBIDDEN_CHARS_MAP[c] end h.each_pair do |c, rep| snippet.warnings << "illegal XML character #{c.inspect} replaced by '#{rep}'" end PList.load(text) end |