Skip to content

Commit

Permalink
Merge pull request #454 from librariesio/fixing-line-endings
Browse files Browse the repository at this point in the history
Rubygems parser Gemfile.lock chomp nonprinting newline chars
  • Loading branch information
tyrelsouza authored May 29, 2019
2 parents 22e47f9 + d574ee2 commit 28ecfb6
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/bibliothecary/parsers/rubygems.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def self.mapping
end

def self.parse_gemfile_lock(manifest)
manifest.split("\n").map do |line|
manifest.lines(chomp: true).map do |line|
match = line.match(NAME_VERSION_4)
next unless match
name = match[1]
Expand Down
2 changes: 1 addition & 1 deletion lib/bibliothecary/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module Bibliothecary
VERSION = "6.7.0"
VERSION = "6.7.1"
end
4 changes: 4 additions & 0 deletions spec/fixtures/GemfileLineEndings.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
GEM
remote: https://rubygems.org/
specs:
rails (5.2.3)
18 changes: 18 additions & 0 deletions spec/parsers/rubygems_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,24 @@
})
end

it 'parses dependencies from Gemfile.lock with windows line endings' do
fixture = load_fixture("GemfileLineEndings.lock")
# If this fails, the line endings changed, on this file.
# to fix it, run `vim spec/fixtures/GemfileLineEndings.lock +"set ff=dos" +wq`
expect(fixture).to include("\r\n")

expect(
described_class.analyse_contents("Gemfile.lock", fixture)).to eq({
:platform=>"rubygems",
:path=>"Gemfile.lock",
:dependencies=>[
{:name=>"rails", :requirement=>"5.2.3", :type=>"runtime"},
],
kind: 'lockfile',
success: true
})
end

it 'matches valid manifest filepaths' do
expect(described_class.match?('devise.gemspec')).to be_truthy
expect(described_class.match?('Gemfile')).to be_truthy
Expand Down

0 comments on commit 28ecfb6

Please sign in to comment.