Skip to content

Commit

Permalink
fix pattern to allow gem's name with a period
Browse files Browse the repository at this point in the history
  • Loading branch information
gonzoyumo committed Oct 17, 2012
1 parent 63a200e commit c9b3e43
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/gemnasium/parser/patterns.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
module Gemnasium
module Parser
module Patterns
GEM_NAME = /[a-zA-Z0-9\-_]+/
GEM_NAME = /[a-zA-Z0-9\-_\.]+/
QUOTED_GEM_NAME = /(?:(?<gq>["'])(?<name>#{GEM_NAME})\k<gq>|%q<(?<name>#{GEM_NAME})>)/

MATCHER = /(?:=|!=|>|<|>=|<=|~>)/
Expand Down
6 changes: 6 additions & 0 deletions spec/gemnasium/parser/gemfile_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,12 @@ def reset
dependencies.size.should == 0
end

it "parses gems with a period in the name" do
content(%(gem "pygment.rb", ">= 0.8.7"))
dependency.name.should == "pygment.rb"
dependency.requirement.should == ">= 0.8.7"
end

it "parses non-requirement gems" do
content(%(gem "rake"))
dependency.name.should == "rake"
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 @@ -55,6 +55,16 @@ def reset
dependencies.size.should == 0
end

it "parses gems with a period in the name" do
content(<<-EOF)
Gem::Specification.new do |gem|
gem.add_dependency "pygment.rb", ">= 0.8.7"
end
EOF
dependency.name.should == "pygment.rb"
dependency.requirement.should == ">= 0.8.7"
end

it "parses non-requirement gems" do
content(<<-EOF)
Gem::Specification.new do |gem|
Expand Down

5 comments on commit c9b3e43

@laserlemon
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤘

@gonzoyumo
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I should have mentioned credits:
as pointed out by laserlemon

:)

@laserlemon
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ha, no credit-seeking here. Thanks for the well-written/tested fix! 👏

@gonzoyumo
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure but still, you've done most of the job :)

@laserlemon
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😊

Please sign in to comment.