gitattributes 2.5.0 → 2.6.0

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: b782ca7bbdcc120c34494e2db3887dcf25d7a9fa
4
- data.tar.gz: 02120c50fa900d5893c20964c6e931b228ef97e3
3
+ metadata.gz: f0a55496d6f14dbe3a2875abf144bb3481abebc5
4
+ data.tar.gz: 2deedb0df3e611e6aa5c5d39cba141c8c37fc88f
5
5
  SHA512:
6
- metadata.gz: 4b441a8a54c939961406cbb9307ce6e00ca9d7124ee003d2428a358a315257c005176f19b4f519296fb74c9875229b2d65628c67cd08c5d21a7078ca8f5cd938
7
- data.tar.gz: ec1bd6314c6296a962fc140f6d0587da069292ba019f9280178aeae8473832e5cc6351c6ceb1d396f8e71ee77926b6151dc3a0d3499c3c7bb6b4aabd72e8fc25
6
+ metadata.gz: e0e84e35f1e99b4147941e3752e639793d60d44a71b1da514bb4bdf9b07dad7e80da14727fdc7d6845c6e76763a399ab7a62a76b9ff76040756420f2042cf82c
7
+ data.tar.gz: 1e3554e0377532cd63ed243973e0ff2d3c9628ad6699d702954e773612905b1f75466960ea6c30292bbd1bb81b11823ebfa3e7768c470556615264a0198b4d96
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{gitattributes}
5
- s.version = '2.5.0'
5
+ s.version = '2.6.0'
6
6
  s.platform = Gem::Platform::RUBY
7
7
 
8
8
  s.authors = ['Peter Donald']
@@ -67,6 +67,11 @@ module Reality #nodoc
67
67
  rule = AttributeRule.new(pattern, attributes)
68
68
  @rules << rule
69
69
  cache_rule(rule)
70
+ rule
71
+ end
72
+
73
+ def remove_rule(rule)
74
+ uncache_rule(rule) if @rules.delete(rule)
70
75
  end
71
76
 
72
77
  # Adds a rule for pattern that sets the text attribute.
@@ -111,6 +116,10 @@ module Reality #nodoc
111
116
  def cache_rule(rule)
112
117
  (@rule_map[rule.pattern] ||= []) << rule
113
118
  end
119
+
120
+ def uncache_rule(rule)
121
+ (@rule_map[rule.pattern] ||= []).delete(rule)
122
+ end
114
123
  end
115
124
  end
116
125
  end
@@ -32,6 +32,23 @@ TEXT
32
32
  assert_equal(false, attributes.rules_by_pattern?('XXX'))
33
33
  end
34
34
 
35
+ def test_remove_rule
36
+ attributes = Reality::Git::Attributes.new("#{working_dir}/#{::SecureRandom.hex}")
37
+
38
+ rule1 = attributes.text_rule('*.md')
39
+ rule2 = attributes.text_rule('*.rake', :eofnl => false)
40
+
41
+ assert_equal(['*.md text', '*.rake text -eofnl'], attributes.rules.collect {|p| p.to_s})
42
+
43
+ attributes.remove_rule(rule1)
44
+
45
+ assert_equal(['*.rake text -eofnl'], attributes.rules.collect {|p| p.to_s})
46
+
47
+ attributes.remove_rule(rule2)
48
+
49
+ assert_equal([], attributes.rules.collect {|p| p.to_s})
50
+ end
51
+
35
52
  def test_multiple_rules_with_same_pattern
36
53
  content = <<TEXT
37
54
  * -text
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gitattributes
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.5.0
4
+ version: 2.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Peter Donald
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-08-16 00:00:00.000000000 Z
11
+ date: 2017-08-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: minitest