Skip to content

Commit

Permalink
Allow parentheses in gemfile gem method calls
Browse files Browse the repository at this point in the history
  • Loading branch information
laserlemon committed Dec 15, 2011
1 parent bc9ae8f commit 44db56a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/gemnasium/parser/patterns.rb
Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions spec/gemnasium/parser/gemfile_spec.rb
Expand Up @@ -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.