Class: Smurf::TypographyParser

Inherits:
Object
  • Object
show all
Defined in:
lib/smurf/typography_parser.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(typography_sass_file = Smurf.typography_sass_file) ⇒ TypographyParser

Returns a new instance of TypographyParser.



7
8
9
10
# File 'lib/smurf/typography_parser.rb', line 7

def initialize(typography_sass_file = Smurf.typography_sass_file)
  @typographies = {}
  @typography_sass_file = typography_sass_file
end

Instance Attribute Details

#typographiesObject

Returns the value of attribute typographies.



5
6
7
# File 'lib/smurf/typography_parser.rb', line 5

def typographies
  @typographies
end

#typography_sass_fileObject

Returns the value of attribute typography_sass_file.



5
6
7
# File 'lib/smurf/typography_parser.rb', line 5

def typography_sass_file
  @typography_sass_file
end

Instance Method Details

#parse(options = {}) ⇒ Object



12
13
14
15
16
17
18
19
20
# File 'lib/smurf/typography_parser.rb', line 12

def parse(options = {})
  sass_tree = Sass::Engine.for_file(self.typography_sass_file, options).to_tree
  sass_tree.children.each do | node |
    if node.kind_of?(Sass::Tree::CommentNode) && is_typography_comment?(node)
      parsed_comment = YAML.load node.value.join.gsub!("// ", "")
      self.typographies[parsed_comment["styleguide_typography"]["mixin"]] = parsed_comment["styleguide_typography"]["params"]
    end
  end
end