gitattributes 2.7.0 → 2.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3391db6ba85e5c53796a1089ca85c426c3a069cd
4
- data.tar.gz: 4114507b6e91022921434bb96d0568e634986a83
3
+ metadata.gz: b9dbc9ae3068f89180ecfd208254dd413a358d01
4
+ data.tar.gz: 8557715a83892b0f361ffa162f10e7491074034c
5
5
  SHA512:
6
- metadata.gz: aeda2224f7496f96aa8573c0fc931b913a25b0dba4f906f717b9cdcdac74154862a6947f815e5504a27062ad1880d70f6caee84acedc0e427391a5c881d36d3f
7
- data.tar.gz: 8033820c58275d628962a675d0423ea6413642419b3c03abc13ab771de752682da8b8ef4d3e4b3aa204432de9c70d75ad9975277596975437a6b1063f2e7a21b
6
+ metadata.gz: 1fd79ddde7dceeded25c2f00eca18afc99559a388c043073a78cede9da31f55cd79c8fb2ac673d1db85bbda1b34f56de4bd5387bed4510388f03687a6933354d
7
+ data.tar.gz: 793d06a6b3a86d5a03a8f13d844bf8abd3844aecbca5d910cb4599a3eee232297c838a3d43ee2e613160fab8e72105aa47f020dff30f961ec697b43eb44ddbf5
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{gitattributes}
5
- s.version = '2.7.0'
5
+ s.version = '2.8.0'
6
6
  s.platform = Gem::Platform::RUBY
7
7
 
8
8
  s.authors = ['Peter Donald']
@@ -68,13 +68,21 @@ module Reality #nodoc
68
68
  rules
69
69
  end
70
70
 
71
- def write_to(filename, options = {})
71
+ def as_file_contents(options = {})
72
72
  prefix = options[:prefix].nil? ? '' : "#{options[:prefix]}\n"
73
73
  rules = self.rules
74
74
  rules = rules.dup.sort.uniq if options[:normalize]
75
75
  content = rules.collect {|r| r.to_s}.join("\n")
76
76
  content += "\n" unless content.empty?
77
- IO.write(filename, prefix + content)
77
+ prefix + content
78
+ end
79
+
80
+ def write_to(filename, options = {})
81
+ IO.write(filename, as_file_contents(options))
82
+ end
83
+
84
+ def write(options = {})
85
+ write_to(@attributes_file, options)
78
86
  end
79
87
 
80
88
  def rule(pattern, attributes)
@@ -215,6 +215,40 @@ TEXT
215
215
  assert_equal({ 'text' => false }, attributes.attributes('foo/docs/README.md'))
216
216
  end
217
217
 
218
+ def test_write
219
+ content = <<TEXT
220
+ * -text
221
+ TEXT
222
+ dir = "#{working_dir}/#{::SecureRandom.hex}"
223
+ write_standard_file(dir, content)
224
+
225
+ attributes = Reality::Git::Attributes.parse(dir)
226
+ assert_equal("#{dir}/.gitattributes", attributes.attributes_file)
227
+ assert_equal(['* -text'], attributes.rules.collect {|p| p.to_s})
228
+
229
+ attributes.write
230
+
231
+ assert_equal(<<TEXT, IO.read("#{dir}/.gitattributes"))
232
+ * -text
233
+ TEXT
234
+ end
235
+
236
+ def test_as_file_contents
237
+ content = <<TEXT
238
+ * -text
239
+ TEXT
240
+ dir = "#{working_dir}/#{::SecureRandom.hex}"
241
+ write_standard_file(dir, content)
242
+
243
+ attributes = Reality::Git::Attributes.parse(dir)
244
+ assert_equal("#{dir}/.gitattributes", attributes.attributes_file)
245
+ assert_equal(['* -text'], attributes.rules.collect {|p| p.to_s})
246
+
247
+ assert_equal(<<TEXT, attributes.as_file_contents)
248
+ * -text
249
+ TEXT
250
+ end
251
+
218
252
  def test_write_to
219
253
  content = <<TEXT
220
254
  * -text
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gitattributes
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.7.0
4
+ version: 2.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Peter Donald