Class: Haute::ColorBlock

Inherits:
Object show all
Defined in:
lib/haute/colorblock.rb

Class Method Summary collapse

Class Method Details

.parse(content) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/haute/colorblock.rb', line 5

def parse(content)
  section           = ""
  @styleguide_vars  = {}

  file = StringIO.new(content)
  file.each do |line|
    if line.present?
      if line.split().first(3).first == "//+"
        if section == ""
          section = line.split().first(3).last
        else
          section = ""
        end

      else
        if line.split().first(7).first != "//+ End"
          line_split = line.split(/ : */, 2)
          @styleguide_vars[section] = [] if @styleguide_vars[section].nil?
          val   = line_split.last
          extra = ""
          if val.include? "//+"
            extra = val.split("//+").last()
            val   = val.split("//+").first()
          end
          @styleguide_vars[section].push( {var: line_split.first.strip!, val: val, extra: extra} )
        end
      end
    end
  end
  file.close

  {color_sections: @styleguide_vars}
end