cardname 0.3.0 → 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/cardname/contextual.rb +8 -6
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: bf908ff88412470eef1eb037b0a90b398e419ad4
4
- data.tar.gz: 791c5cf2d06a2b7d572262fb9f16d56cb647c0b3
3
+ metadata.gz: 3bf83ab1baf1acc98f7083d750adf1ebbb1c13f3
4
+ data.tar.gz: a5a427c2728a53b8065ec4ec20a689c277aa7307
5
5
  SHA512:
6
- metadata.gz: 4298e82e31e1b987bd42a589f52bb13f3ee0e9e611277f64307de182db345ad34436ec4f53310b2901d447f0063338d2e53081132c288b9fa1d0e4b65c9ab985
7
- data.tar.gz: ed7fe969ab7f71ff59ff998640b0d5489d02147501e92aedf1f6e9f30028ed178ef72f38765a5c144ffbeda2fb2f827808d4b47d2d7296e7a8296cd08e30600c
6
+ metadata.gz: a64f1c20ffbba8353d8f735a2d98549538e11e1cd361b0ffb7b6bb25d24164ac6d509c295118c6c3e3280c9bed7af630636aee75fdef1782eaf14b8e1fa5f249
7
+ data.tar.gz: c17c5aa49021512195ce5213e0ac0fb37f5064829b718ffd72eee44d94b96b27c57d702b016fa97197cd6640c81eacf439d49a4e8005f096f455999d70c94a93
@@ -33,18 +33,20 @@ class Cardname
33
33
  name_from(*from).s
34
34
  end
35
35
 
36
- # if possible, relativize name into one beginning with a "+". To do so, it must absolutize back to the correct
36
+ # if possible, relativize name into one beginning with a "+". The new name must absolutize back to the correct
37
37
  # original name in the context of "from"
38
38
  def name_from *from
39
- remaining = parts_excluding *from
40
- return self unless context_relevant?(remaining)
39
+ return self unless (remaining = remove_context *from)
41
40
  compressed = remaining.compact.unshift(nil).to_name # exactly one nil at beginning
42
41
  key == compressed.absolute_name(from).key ? compressed : self
43
42
  end
44
43
 
45
- def context_relevant? remaining
46
- remaining.compact.any? && # not all name parts in context
47
- remaining != parts # some name parts in context (could be faster test!)
44
+ def remove_context *from
45
+ return false unless from.compact.present?
46
+ remaining = parts_excluding *from
47
+ return false if remaining.compact.empty? || # all name parts in context
48
+ remaining == parts # no name parts in context
49
+ remaining
48
50
  end
49
51
 
50
52
  def parts_excluding *string
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cardname
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ethan McCutchen
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2017-10-31 00:00:00.000000000 Z
13
+ date: 2017-11-08 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: activesupport