gitattributes 2.7.0 → 2.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/gitattributes.gemspec +1 -1
- data/lib/reality/git/attributes.rb +10 -2
- data/test/reality/git/test_attributes.rb +34 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b9dbc9ae3068f89180ecfd208254dd413a358d01
|
4
|
+
data.tar.gz: 8557715a83892b0f361ffa162f10e7491074034c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1fd79ddde7dceeded25c2f00eca18afc99559a388c043073a78cede9da31f55cd79c8fb2ac673d1db85bbda1b34f56de4bd5387bed4510388f03687a6933354d
|
7
|
+
data.tar.gz: 793d06a6b3a86d5a03a8f13d844bf8abd3844aecbca5d910cb4599a3eee232297c838a3d43ee2e613160fab8e72105aa47f020dff30f961ec697b43eb44ddbf5
|
data/gitattributes.gemspec
CHANGED
@@ -68,13 +68,21 @@ module Reality #nodoc
|
|
68
68
|
rules
|
69
69
|
end
|
70
70
|
|
71
|
-
def
|
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
|
-
|
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
|