Permalink
Browse files

Support multiple parser paths

  • Loading branch information...
1 parent 4c80c18 commit f155a5e42b3cef95b58f89a4635320b53bd3ded1 @josh josh committed Jul 13, 2012
Showing with 13 additions and 6 deletions.
  1. +8 −6 lib/kss/parser.rb
  2. +5 −0 test/parser_test.rb
View
@@ -10,14 +10,16 @@ class Parser
# within the directory recursively for any comment blocks that look like
# KSS.
#
- # base_path - The path String where style files are located.
- def initialize(base_path)
+ # paths - Each path String where style files are located.
+ def initialize(*paths)
@sections = {}
- Dir["#{base_path}/**/*.*"].each do |filename|
- parser = CommentParser.new(filename)
- parser.blocks.each do |comment_block|
- add_section comment_block, filename if self.class.kss_block?(comment_block)
+ paths.each do |path|
+ Dir["#{path}/**/*.*"].each do |filename|
+ parser = CommentParser.new(filename)
+ parser.blocks.each do |comment_block|
+ add_section comment_block, filename if self.class.kss_block?(comment_block)
+ end
end
end
end
View
@@ -7,6 +7,7 @@ def setup
@sass_parsed = Kss::Parser.new('test/fixtures/sass')
@css_parsed = Kss::Parser.new('test/fixtures/css')
@less_parsed = Kss::Parser.new('test/fixtures/less')
+ @multiple_parsed = Kss::Parser.new('test/fixtures/scss', 'test/fixtures/less')
@css_comment = <<comment
/*
@@ -104,4 +105,8 @@ def setup
assert_equal 2, @css_parsed.sections.count
end
+ test "parse multiple paths" do
+ assert_equal 6, @multiple_parsed.sections.count
+ end
+
end

0 comments on commit f155a5e

Please sign in to comment.