Permalink
Browse files

Allow parentheses in gemfile gem method calls

  • Loading branch information...
1 parent bc9ae8f commit 44db56a4e406ea4d3a5450dd2853b0fe5d1c3411 @laserlemon laserlemon committed Dec 15, 2011
Showing with 7 additions and 1 deletion.
  1. +1 −1 lib/gemnasium/parser/patterns.rb
  2. +6 −0 spec/gemnasium/parser/gemfile_spec.rb
@@ -20,7 +20,7 @@ module Patterns
PAIR = /(?:(#{KEY})\s*=>\s*(#{VALUE})|(\w+):\s+(#{VALUE}))/
OPTIONS = /#{PAIR}(?:\s*,\s*#{PAIR})*/
- GEM_CALL = /^\s*gem\s+(?<q1>["'])(?<name>#{GEM_NAME})\k<q1>(?:\s*,\s*#{REQUIREMENT_LIST})?(?:\s*,\s*(?<opts>#{OPTIONS}))?\s*$/
+ GEM_CALL = /^\s*gem\s*\(?\s*(?<q1>["'])(?<name>#{GEM_NAME})\k<q1>(?:\s*,\s*#{REQUIREMENT_LIST})?(?:\s*,\s*(?<opts>#{OPTIONS}))?\s*\)?\s*$/
SYMBOLS = /#{SYMBOL}(\s*,\s*#{SYMBOL})*/
GROUP_CALL = /^(?<i1>\s*)group\s+(?<grps>#{SYMBOLS})\s+do\s*?\n(?<blk>.*?)\n^\k<i1>end\s*$/m
@@ -203,4 +203,10 @@ def reset
dependencies[2].type.should == :runtime
dependencies[3].type.should == :development
end
+
+ it "parses parentheses" do
+ content(%(gem("rake", ">= 0.8.7")))
+ dependency.name.should == "rake"
+ dependency.requirement.should == ">= 0.8.7"
+ end
end

0 comments on commit 44db56a

Please sign in to comment.