Skip to content

Commit

Permalink
Support multiple parser paths
Browse files Browse the repository at this point in the history
  • Loading branch information
josh committed Jul 13, 2012
1 parent 4c80c18 commit f155a5e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
14 changes: 8 additions & 6 deletions lib/kss/parser.rb
Expand Up @@ -10,14 +10,16 @@ class Parser
# within the directory recursively for any comment blocks that look like # within the directory recursively for any comment blocks that look like
# KSS. # KSS.
# #
# base_path - The path String where style files are located. # paths - Each path String where style files are located.
def initialize(base_path) def initialize(*paths)
@sections = {} @sections = {}


Dir["#{base_path}/**/*.*"].each do |filename| paths.each do |path|
parser = CommentParser.new(filename) Dir["#{path}/**/*.*"].each do |filename|
parser.blocks.each do |comment_block| parser = CommentParser.new(filename)
add_section comment_block, filename if self.class.kss_block?(comment_block) parser.blocks.each do |comment_block|
add_section comment_block, filename if self.class.kss_block?(comment_block)
end
end end
end end
end end
Expand Down
5 changes: 5 additions & 0 deletions test/parser_test.rb
Expand Up @@ -7,6 +7,7 @@ def setup
@sass_parsed = Kss::Parser.new('test/fixtures/sass') @sass_parsed = Kss::Parser.new('test/fixtures/sass')
@css_parsed = Kss::Parser.new('test/fixtures/css') @css_parsed = Kss::Parser.new('test/fixtures/css')
@less_parsed = Kss::Parser.new('test/fixtures/less') @less_parsed = Kss::Parser.new('test/fixtures/less')
@multiple_parsed = Kss::Parser.new('test/fixtures/scss', 'test/fixtures/less')


@css_comment = <<comment @css_comment = <<comment
/* /*
Expand Down Expand Up @@ -104,4 +105,8 @@ def setup
assert_equal 2, @css_parsed.sections.count assert_equal 2, @css_parsed.sections.count
end end


test "parse multiple paths" do
assert_equal 6, @multiple_parsed.sections.count
end

end end

0 comments on commit f155a5e

Please sign in to comment.