Skip to content

Commit

Permalink
Merge pull request #1 from sferik/parse_parentheses
Browse files Browse the repository at this point in the history
Correclty parse parentheses in gemspecs
  • Loading branch information
laserlemon committed Dec 15, 2011
2 parents b9bf760 + 25dd307 commit 0caea27
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/gemnasium/parser/patterns.rb
Expand Up @@ -31,7 +31,7 @@ module Patterns


GEMSPEC_CALL = /^\s*gemspec(?:\s+(?<opts>#{OPTIONS}))?\s*$/ 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) def self.options(string)
{}.tap do |hash| {}.tap do |hash|
Expand Down
10 changes: 10 additions & 0 deletions spec/gemnasium/parser/gemspec_spec.rb
Expand Up @@ -125,4 +125,14 @@ def reset
dependencies[0].instance_variable_get(:@line).should == 2 dependencies[0].instance_variable_get(:@line).should == 2
dependencies[1].instance_variable_get(:@line).should == 3 dependencies[1].instance_variable_get(:@line).should == 3
end 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 end

0 comments on commit 0caea27

Please sign in to comment.