Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Correclty parse parentheses in gemspecs #1

Merged
merged 1 commit into from
Dec 15, 2011
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/gemnasium/parser/patterns.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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|
Expand Down
10 changes: 10 additions & 0 deletions spec/gemnasium/parser/gemspec_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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