cardname 0.3.0 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/cardname/contextual.rb +8 -6
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3bf83ab1baf1acc98f7083d750adf1ebbb1c13f3
|
4
|
+
data.tar.gz: a5a427c2728a53b8065ec4ec20a689c277aa7307
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a64f1c20ffbba8353d8f735a2d98549538e11e1cd361b0ffb7b6bb25d24164ac6d509c295118c6c3e3280c9bed7af630636aee75fdef1782eaf14b8e1fa5f249
|
7
|
+
data.tar.gz: c17c5aa49021512195ce5213e0ac0fb37f5064829b718ffd72eee44d94b96b27c57d702b016fa97197cd6640c81eacf439d49a4e8005f096f455999d70c94a93
|
data/lib/cardname/contextual.rb
CHANGED
@@ -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 "+".
|
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 =
|
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
|
46
|
-
|
47
|
-
|
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.
|
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-
|
13
|
+
date: 2017-11-08 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: activesupport
|