From 44db56a4e406ea4d3a5450dd2853b0fe5d1c3411 Mon Sep 17 00:00:00 2001 From: Steve Richert Date: Thu, 15 Dec 2011 12:08:41 -0500 Subject: [PATCH] Allow parentheses in gemfile gem method calls --- lib/gemnasium/parser/patterns.rb | 2 +- spec/gemnasium/parser/gemfile_spec.rb | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/gemnasium/parser/patterns.rb b/lib/gemnasium/parser/patterns.rb index 9fa4660..c622bb8 100644 --- a/lib/gemnasium/parser/patterns.rb +++ b/lib/gemnasium/parser/patterns.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+(?["'])(?#{GEM_NAME})\k(?:\s*,\s*#{REQUIREMENT_LIST})?(?:\s*,\s*(?#{OPTIONS}))?\s*$/ + GEM_CALL = /^\s*gem\s*\(?\s*(?["'])(?#{GEM_NAME})\k(?:\s*,\s*#{REQUIREMENT_LIST})?(?:\s*,\s*(?#{OPTIONS}))?\s*\)?\s*$/ SYMBOLS = /#{SYMBOL}(\s*,\s*#{SYMBOL})*/ GROUP_CALL = /^(?\s*)group\s+(?#{SYMBOLS})\s+do\s*?\n(?.*?)\n^\kend\s*$/m diff --git a/spec/gemnasium/parser/gemfile_spec.rb b/spec/gemnasium/parser/gemfile_spec.rb index 1c27c96..ced64ec 100644 --- a/spec/gemnasium/parser/gemfile_spec.rb +++ b/spec/gemnasium/parser/gemfile_spec.rb @@ -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