gitattributes 2.6.0 → 2.7.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 +14 -0
- data/test/reality/git/test_attributes.rb +11 -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: 3391db6ba85e5c53796a1089ca85c426c3a069cd
|
4
|
+
data.tar.gz: 4114507b6e91022921434bb96d0568e634986a83
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: aeda2224f7496f96aa8573c0fc931b913a25b0dba4f906f717b9cdcdac74154862a6947f815e5504a27062ad1880d70f6caee84acedc0e427391a5c881d36d3f
|
7
|
+
data.tar.gz: 8033820c58275d628962a675d0423ea6413642419b3c03abc13ab771de752682da8b8ef4d3e4b3aa204432de9c70d75ad9975277596975437a6b1063f2e7a21b
|
data/gitattributes.gemspec
CHANGED
@@ -54,6 +54,20 @@ module Reality #nodoc
|
|
54
54
|
{}
|
55
55
|
end
|
56
56
|
|
57
|
+
# Returns the rules for the specified path.
|
58
|
+
def rules_for_path(path)
|
59
|
+
full_path = File.join(@path, path)
|
60
|
+
|
61
|
+
rules = []
|
62
|
+
|
63
|
+
self.rules.each do |rule|
|
64
|
+
full_pattern = rule.pattern[0] == '/' ? "#{@relative_path}#{rule.pattern}" : "#{@relative_path}/**/#{rule.pattern}"
|
65
|
+
rules << rule if File.fnmatch?(full_pattern, full_path, File::FNM_PATHNAME | File::FNM_DOTMATCH)
|
66
|
+
end
|
67
|
+
|
68
|
+
rules
|
69
|
+
end
|
70
|
+
|
57
71
|
def write_to(filename, options = {})
|
58
72
|
prefix = options[:prefix].nil? ? '' : "#{options[:prefix]}\n"
|
59
73
|
rules = self.rules
|
@@ -49,6 +49,17 @@ TEXT
|
|
49
49
|
assert_equal([], attributes.rules.collect {|p| p.to_s})
|
50
50
|
end
|
51
51
|
|
52
|
+
def test_rules_for_path
|
53
|
+
attributes = Reality::Git::Attributes.new("#{working_dir}/#{::SecureRandom.hex}")
|
54
|
+
|
55
|
+
attributes.text_rule('*.md')
|
56
|
+
attributes.text_rule('*.rake')
|
57
|
+
|
58
|
+
assert_equal([], attributes.rules_for_path('Foo.txt').collect {|p| p.to_s})
|
59
|
+
assert_equal(['*.md text'], attributes.rules_for_path('Foo.md').collect {|p| p.to_s})
|
60
|
+
assert_equal(['*.md text'], attributes.rules_for_path('doc/MyDoc.md').collect {|p| p.to_s})
|
61
|
+
end
|
62
|
+
|
52
63
|
def test_multiple_rules_with_same_pattern
|
53
64
|
content = <<TEXT
|
54
65
|
* -text
|