Permalink
Browse files

Merge pull request #1 from sferik/parse_parentheses

Correclty parse parentheses in gemspecs
  • Loading branch information...
2 parents b9bf760 + 25dd307 commit 0caea27025ed79b92b7c40abdb908cbd9ea70952 @laserlemon laserlemon committed Dec 15, 2011
Showing with 11 additions and 1 deletion.
  1. +1 −1 lib/gemnasium/parser/patterns.rb
  2. +10 −0 spec/gemnasium/parser/gemspec_spec.rb
@@ -31,7 +31,7 @@ module Patterns
GEMSPEC_CALL = /^\s*gemspec(?:\s+(?<opts>#{OPTIONS}))?\s*$/
- RUNTIME_CALL = /^\s*\w+\.add(?<type>_runtime|_development)?_dependency\s+(?<q1>["'])(?<name>#{GEM_NAME})\k<q1>(?:\s*,\s*#{REQUIREMENTS})?\s*$/
+ RUNTIME_CALL = /^\s*\w+\.add(?<type>_runtime|_development)?_dependency\s*\(?\s*(?<q1>["'])(?<name>#{GEM_NAME})\k<q1>(?:\s*,\s*#{REQUIREMENTS})?\s*\)?\s*$/
def self.options(string)
{}.tap do |hash|
@@ -125,4 +125,14 @@ def reset
dependencies[0].instance_variable_get(:@line).should == 2
dependencies[1].instance_variable_get(:@line).should == 3
end
+
+ it "parses parentheses" do
+ content(<<-EOF)
+ Gem::Specification.new do |gem|
+ gem.add_dependency("rake", ">= 0.8.7")
+ end
+ EOF
+ dependency.name.should == "rake"
+ dependency.requirement.should == ">= 0.8.7"
+ end
end

0 comments on commit 0caea27

Please sign in to comment.