Module: Rabbit::ThemeBrowser::Tag
- Defined in:
- lib/rabbit/theme-browser/tag.rb
Constant Summary collapse
- INFOS =
{}
Class Method Summary collapse
- .infos_pangoize(infos) ⇒ Object
- .reload_tag_infos ⇒ Object
- .update_info_by_yaml_file(filename, *args) ⇒ Object
Class Method Details
.infos_pangoize(infos) ⇒ Object
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 53 |
# File 'lib/rabbit/theme-browser/tag.rb', line 28 def infos_pangoize(infos) result = {} infos.each_key do |name| props = {} result[name] = props (infos[name] || {}).each do |key, value| case key when "size" prop_value = value * Pango::SCALE when "weight" weight = "WEIGHT_#{value.upcase}" prop_value = Pango::FontDescription.const_get(weight) when "style" style = "STYLE_#{value.upcase}" prop_value = Pango::FontDescription.const_get(style) when "underline" underline = value.upcase prop_value = Pango::AttrUnderline.const_get(underline) else prop_value = value end props[key] = prop_value end end result end |
.reload_tag_infos ⇒ Object
55 56 57 58 59 60 61 62 |
# File 'lib/rabbit/theme-browser/tag.rb', line 55 def reload_tag_infos INFOS.clear update_info_by_yaml_file("rabbit", "theme-browser", "default-tag.yaml") begin update_info_by_yaml_file("rabbit", "theme-browser", "tag.yaml") rescue NotExistError end end |
.update_info_by_yaml_file(filename, *args) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/rabbit/theme-browser/tag.rb', line 14 def update_info_by_yaml_file(filename, *args) filename = File.join(filename, *args) if File.exist?(filename) target = filename else target = Utils.find_path_in_load_path(filename) end raise NotExistError.new(filename) if target.nil? result = File.open(target) do |f| YAML.load(f.read) end INFOS.update(infos_pangoize(result)) end |