Class: Coloration::Converters::AbstractConverter

Inherits:
Object
  • Object
show all
Defined in:
lib/coloration/abstract_converter.rb

Class Attribute Summary collapse

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Class Attribute Details

.in_theme_typeObject (readonly)

Returns the value of attribute in_theme_type.



5
6
7
# File 'lib/coloration/abstract_converter.rb', line 5

def in_theme_type
  @in_theme_type
end

Instance Attribute Details

#inputObject

Returns the value of attribute input.



4
5
6
# File 'lib/coloration/abstract_converter.rb', line 4

def input
  @input
end

#itemsObject

Returns the value of attribute items.



4
5
6
# File 'lib/coloration/abstract_converter.rb', line 4

def items
  @items
end

#nameObject

Returns the value of attribute name.



4
5
6
# File 'lib/coloration/abstract_converter.rb', line 4

def name
  @name
end

#resultObject

Returns the value of attribute result.



4
5
6
# File 'lib/coloration/abstract_converter.rb', line 4

def result
  @result
end

#uiObject

Returns the value of attribute ui.



4
5
6
# File 'lib/coloration/abstract_converter.rb', line 4

def ui
  @ui
end

Class Method Details

.process_cmd_lineObject



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/coloration/abstract_converter.rb', line 7

def self.process_cmd_line
  if ARGV.size > 0
    begin
      converter = self.new
      converter.feed(File.read(ARGV[0]))
      out_filename = ARGV[1] || ARGV[0].gsub(/\.#{@in_theme_ext}$/, ".#{@out_theme_ext}")
      converter.convert!
      File.open(out_filename, "w") { |f| f.write(converter.result) }
    rescue Coloration::Readers::TextMateThemeReader::InvalidThemeError
      STDERR.puts "Err: given file doesn't look like xml plist file containing Textmate theme"
    end
  else
    puts "#{File.basename($0)} <in #{@in_theme_type} theme> [out #{@out_theme_type} theme]"
  end
end

Instance Method Details

#convert!Object



27
28
29
30
# File 'lib/coloration/abstract_converter.rb', line 27

def convert!
  parse_input
  build_result
end

#feed(data) ⇒ Object



23
24
25
# File 'lib/coloration/abstract_converter.rb', line 23

def feed(data)
  self.input = data
end