xcop 0.5.2 → 0.5.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d76b2ac9a770f9fed2c3104af130c575fcb6feb9
4
- data.tar.gz: ef4750fcdc6b1378ad560a67d252b33e161bf8c6
3
+ metadata.gz: d0587f8d49aed88e6e268948e67eea7c8ec6557e
4
+ data.tar.gz: 834e3b41d80ecdaa50d0b1a4357d69009eaeee5a
5
5
  SHA512:
6
- metadata.gz: 1751468ef75335d74e76ecd203369b88b8ca49358a8b848d778f5e499325b7c5c66189958bc8a7f1ff260075556add064fca80844ec1ee2ac5fdaab7b32aa05d
7
- data.tar.gz: c027812f78ebea034525e47240145dfab07e032145193ffefed90d4753a71774a9ffb65feaa57f767f0afebc0e8cfb40fca99f83d5a69f628ed31dc2b28bf306
6
+ metadata.gz: d906e4dee068262203da8a251e7d4f1c225a53793f88f306efe671edc0a142351dc4a5c9d4f6601e994dd60c1064ff7cce9cd6980da857a54e6ecd07304dbee4
7
+ data.tar.gz: 8b8f1c85855c25586c2d0d41a10e7941f551e560bc987bbb895597f3acdc7cc7c30d7912cc7e29570c344a5366845281faad99fa177e104f99fa5274550b0719
data/lib/xcop.rb CHANGED
@@ -98,6 +98,7 @@ module Xcop
98
98
  def fix(license = '')
99
99
  xml = Nokogiri::XML(File.open(@path), &:noblanks)
100
100
  unless license.empty?
101
+ xml.xpath('/comment()').remove
101
102
  xml.children.before(
102
103
  Nokogiri::XML::Comment.new(xml, "\n#{license.strip}\n")
103
104
  )
data/lib/xcop/version.rb CHANGED
@@ -25,5 +25,5 @@
25
25
  # Copyright:: Copyright (c) 2017 Yegor Bugayenko
26
26
  # License:: MIT
27
27
  module Xcop
28
- VERSION = '0.5.2'.freeze
28
+ VERSION = '0.5.3'.freeze
29
29
  end
data/test/test_xcop.rb CHANGED
@@ -69,4 +69,15 @@ class TestXcop < Minitest::Test
69
69
  assert_equal(Xcop::Document.new(f).ldiff(license), '')
70
70
  end
71
71
  end
72
+
73
+ def test_removes_previous_license
74
+ Dir.mktmpdir 'test4' do |dir|
75
+ f = File.join(dir, 'bad.xml')
76
+ license = "the license to add\n\n\nhey"
77
+ File.write(f, '<hello>how do you do?</hello>')
78
+ Xcop::Document.new(f).fix(license)
79
+ Xcop::Document.new(f).fix(license)
80
+ assert_equal(Nokogiri::XML(File.read(f)).xpath('/comment()').length, 1)
81
+ end
82
+ end
72
83
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: xcop
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.2
4
+ version: 0.5.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yegor Bugayenko