class SublimeDSL::TextMate::Theme::DSLReader
Public Class Methods
new(file = nil)
click to toggle source
# File lib/sublime_dsl/textmate/theme/dsl_reader.rb, line 9 def initialize(file = nil) @themes = [] @current_theme = nil instance_eval File.read(file, encoding: 'utf-8'), file if file end
Public Instance Methods
_themes()
click to toggle source
# File lib/sublime_dsl/textmate/theme/dsl_reader.rb, line 15 def _themes @themes end
base_colors(options = {})
click to toggle source
# File lib/sublime_dsl/textmate/theme/dsl_reader.rb, line 51 def base_colors(options = {}) ensure_context __method__ @current_theme.base_colors.merge! options end
bold()
click to toggle source
# File lib/sublime_dsl/textmate/theme/dsl_reader.rb, line 23 def bold; 'bold' end
ensure_context(name)
click to toggle source
# File lib/sublime_dsl/textmate/theme/dsl_reader.rb, line 79 def ensure_context(name) @current_theme or raise Error, "#{name} is invalid outside a 'theme' block" end
italic()
click to toggle source
# File lib/sublime_dsl/textmate/theme/dsl_reader.rb, line 24 def italic; 'italic' end
item(name, scope, *attributes)
click to toggle source
# File lib/sublime_dsl/textmate/theme/dsl_reader.rb, line 56 def item(name, scope, *attributes) ensure_context __method__ item = Item.new(name, scope) attributes.each do |a| if a.is_a? Hash a.each_pair do |k, v| if k == :back item.background = v else raise Error, "invalid item option: #{k.inspect} => #{v.inspect}" end end elsif %w(bold italic underline).include?(a) item.send "#{a}=", true elsif a.start_with? '#' item.foreground = a else raise Error, "invalid item attribute: #{a.inspect}" end end @current_theme.add_item item end
license(text)
click to toggle source
# File lib/sublime_dsl/textmate/theme/dsl_reader.rb, line 47 def license(text) @current_theme.license = text end
method_missing(sym, *args, &block)
click to toggle source
# File lib/sublime_dsl/textmate/theme/dsl_reader.rb, line 19 def method_missing(sym, *args, &block) raise Error, "'#{sym}' is not a valid Theme DSL statement" end
theme(name, options={}, &block)
click to toggle source
# File lib/sublime_dsl/textmate/theme/dsl_reader.rb, line 27 def theme(name, options={}, &block) @current_theme and raise Error, "'theme' blocks cannot be nested" @current_theme = Theme.new(name) @current_theme.basename = options.delete(:file) options.empty? or warn "invalid options: #{options.inspect}" instance_eval(&block) @themes << @current_theme @current_theme = nil end
underline()
click to toggle source
# File lib/sublime_dsl/textmate/theme/dsl_reader.rb, line 25 def underline; 'underline' end
uuid(value)
click to toggle source
# File lib/sublime_dsl/textmate/theme/dsl_reader.rb, line 42 def uuid(value) ensure_context __method__ @current_theme.uuid = value end