cardname 0.11.3 → 0.11.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/cardname.rb +3 -3
- data/lib/cardname/parts.rb +0 -31
- data/lib/cardname/predicates.rb +11 -0
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: e8f8b91a34b888b1e298d4ec50d7a6d2c12207e1449ece845751bf8ad7f325b1
|
|
4
|
+
data.tar.gz: 6deab4dff00266b7e180557e3bf0b7577ad393f76bd560ee2adfa766d56a5f23
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 204bad77b0157b0e472c92a6a2d861ea336da50744c4fc572e72c82b6fa9a0be6eb04591205c1441d8e51b050ca3f9242f26c18691b38d10a935dad267570ead
|
|
7
|
+
data.tar.gz: e1a36c3294f34dd18e56588eec50262177ae94a6d35eb18ba8e8702b553c3dde82608d75147fa493cfa464a7f200291d6e60bc85160a57d124bd0a512385a72a
|
data/lib/cardname.rb
CHANGED
|
@@ -5,12 +5,14 @@ require "htmlentities"
|
|
|
5
5
|
|
|
6
6
|
class Cardname < String
|
|
7
7
|
require_relative "cardname/parts"
|
|
8
|
+
require_relative "cardname/pieces"
|
|
8
9
|
require_relative "cardname/variants"
|
|
9
10
|
require_relative "cardname/contextual"
|
|
10
11
|
require_relative "cardname/predicates"
|
|
11
12
|
require_relative "cardname/manipulate"
|
|
12
13
|
|
|
13
14
|
include Parts
|
|
15
|
+
include Pieces
|
|
14
16
|
include Variants
|
|
15
17
|
include Contextual
|
|
16
18
|
include Predicates
|
|
@@ -18,8 +20,7 @@ class Cardname < String
|
|
|
18
20
|
|
|
19
21
|
OK4KEY_RE = '\p{Word}\*'
|
|
20
22
|
|
|
21
|
-
cattr_accessor :joint, :banned_array, :var_re, :uninflect, :params,
|
|
22
|
-
:session, :stabilize
|
|
23
|
+
cattr_accessor :joint, :banned_array, :var_re, :uninflect, :params, :session, :stabilize
|
|
23
24
|
|
|
24
25
|
self.joint = "+"
|
|
25
26
|
self.banned_array = []
|
|
@@ -116,7 +117,6 @@ class Cardname < String
|
|
|
116
117
|
end
|
|
117
118
|
end
|
|
118
119
|
|
|
119
|
-
# dangerous, too
|
|
120
120
|
def []= index, val
|
|
121
121
|
p = parts
|
|
122
122
|
p[index] = val
|
data/lib/cardname/parts.rb
CHANGED
|
@@ -4,24 +4,12 @@ class Cardname
|
|
|
4
4
|
# the same methods without _name return strings
|
|
5
5
|
module Parts
|
|
6
6
|
attr_reader :parts, :part_keys, :simple
|
|
7
|
-
|
|
8
7
|
alias_method :to_a, :parts
|
|
9
8
|
|
|
10
9
|
def parts
|
|
11
10
|
@parts = Cardname.split_parts s
|
|
12
11
|
end
|
|
13
12
|
|
|
14
|
-
def simple
|
|
15
|
-
@simple = parts.size <= 1
|
|
16
|
-
end
|
|
17
|
-
alias simple? simple
|
|
18
|
-
|
|
19
|
-
# @return true if name has more than one part
|
|
20
|
-
def compound?
|
|
21
|
-
!simple?
|
|
22
|
-
end
|
|
23
|
-
alias junction? compound?
|
|
24
|
-
|
|
25
13
|
def part_keys
|
|
26
14
|
@part_keys ||= simple ? [simple_key] : parts.map { |p| p.to_name.simple_key }
|
|
27
15
|
end
|
|
@@ -89,25 +77,6 @@ class Cardname
|
|
|
89
77
|
@piece_names ||= pieces.map(&:to_name)
|
|
90
78
|
end
|
|
91
79
|
|
|
92
|
-
# self and all ancestors (= parts and recursive lefts)
|
|
93
|
-
# @example
|
|
94
|
-
# "A+B+C+D".to_name.pieces
|
|
95
|
-
# # => ["A", "B", "C", "D", "A+B", "A+B+C", "A+B+C+D"]
|
|
96
|
-
def pieces
|
|
97
|
-
@pieces ||=
|
|
98
|
-
if simple?
|
|
99
|
-
[self]
|
|
100
|
-
else
|
|
101
|
-
junction_pieces = []
|
|
102
|
-
parts[1..-1].inject parts[0] do |left, right|
|
|
103
|
-
piece = [left, right] * self.class.joint
|
|
104
|
-
junction_pieces << piece
|
|
105
|
-
piece
|
|
106
|
-
end
|
|
107
|
-
parts + junction_pieces
|
|
108
|
-
end
|
|
109
|
-
end
|
|
110
|
-
|
|
111
80
|
def ancestors
|
|
112
81
|
@ancestors ||= pieces.reject { |p| p == self}
|
|
113
82
|
end
|
data/lib/cardname/predicates.rb
CHANGED
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
class Cardname
|
|
2
2
|
module Predicates
|
|
3
|
+
def simple
|
|
4
|
+
@simple.nil? ? (@simple = parts.size <= 1) : @simple
|
|
5
|
+
end
|
|
6
|
+
alias_method :simple?, :simple
|
|
7
|
+
|
|
8
|
+
# @return true if name has more than one part
|
|
9
|
+
def compound?
|
|
10
|
+
!simple?
|
|
11
|
+
end
|
|
12
|
+
alias_method :junction?, :compound?
|
|
13
|
+
|
|
3
14
|
def valid?
|
|
4
15
|
return true if self.class.nothing_banned?
|
|
5
16
|
!parts.find do |pt|
|
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.11.
|
|
4
|
+
version: 0.11.4
|
|
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: 2021-
|
|
13
|
+
date: 2021-05-05 00:00:00.000000000 Z
|
|
14
14
|
dependencies:
|
|
15
15
|
- !ruby/object:Gem::Dependency
|
|
16
16
|
name: activesupport
|