cardname 0.10.0 → 0.11.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +7 -0
- data/lib/cardname.rb +3 -3
- data/lib/cardname/contextual.rb +7 -5
- data/lib/cardname/parts.rb +0 -31
- data/lib/cardname/predicates.rb +11 -0
- metadata +15 -15
- data/README.rdoc +0 -7
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/README.md
ADDED
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/contextual.rb
CHANGED
@@ -116,13 +116,15 @@ class Cardname
|
|
116
116
|
|
117
117
|
def absolutize_extremes new_parts, context
|
118
118
|
[0, -1].each do |i|
|
119
|
-
|
120
|
-
# following avoids recontextualizing with relative contexts.
|
121
|
-
# Eg, `+A+B+.absolute('+A')` should be +A+B, not +A+A+B.
|
122
|
-
next if new_parts.to_name.send "#{[ :start, :end ][i]}s_with_parts?", context
|
123
|
-
new_parts[i] = context
|
119
|
+
new_parts[i] = context if absolutize_extreme? new_parts, context, i
|
124
120
|
end
|
125
121
|
end
|
126
122
|
|
123
|
+
def absolutize_extreme? new_parts, context, index
|
124
|
+
return false if new_parts[index].present?
|
125
|
+
# following avoids recontextualizing with relative contexts.
|
126
|
+
# Eg, `+A+B+.absolute('+A')` should be +A+B, not +A+A+B.
|
127
|
+
!new_parts.to_name.send "#{[ :start, :end ][index]}s_with_parts?", context
|
128
|
+
end
|
127
129
|
end
|
128
130
|
end
|
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.
|
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:
|
13
|
+
date: 2021-05-05 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: activesupport
|
@@ -41,13 +41,13 @@ dependencies:
|
|
41
41
|
- !ruby/object:Gem::Version
|
42
42
|
version: '4.3'
|
43
43
|
description: Naming patterns abstracted from Decko cards
|
44
|
-
email:
|
44
|
+
email:
|
45
|
+
- info@decko.org
|
45
46
|
executables: []
|
46
47
|
extensions: []
|
47
|
-
extra_rdoc_files:
|
48
|
-
- README.rdoc
|
48
|
+
extra_rdoc_files: []
|
49
49
|
files:
|
50
|
-
- README.
|
50
|
+
- README.md
|
51
51
|
- Rakefile
|
52
52
|
- lib/cardname.rb
|
53
53
|
- lib/cardname/contextual.rb
|
@@ -56,17 +56,17 @@ files:
|
|
56
56
|
- lib/cardname/predicates.rb
|
57
57
|
- lib/cardname/variants.rb
|
58
58
|
- lib/core_ext.rb
|
59
|
-
homepage:
|
59
|
+
homepage: https://decko.org
|
60
60
|
licenses:
|
61
|
-
- GPL-2.0
|
62
61
|
- GPL-3.0
|
63
|
-
metadata:
|
62
|
+
metadata:
|
63
|
+
source_code_uri: https://github.com/decko-commons/decko
|
64
|
+
homepage_uri: https://decko.org
|
65
|
+
bug_tracker_uri: https://github.com/decko-commons/decko/issues
|
66
|
+
wiki_uri: https://decko.org
|
67
|
+
documentation_url: http://docs.decko.org/
|
64
68
|
post_install_message:
|
65
|
-
rdoc_options:
|
66
|
-
- "--main"
|
67
|
-
- README.rdoc
|
68
|
-
- "--inline-source"
|
69
|
-
- "--line-numbers"
|
69
|
+
rdoc_options: []
|
70
70
|
require_paths:
|
71
71
|
- lib
|
72
72
|
required_ruby_version: !ruby/object:Gem::Requirement
|
@@ -80,7 +80,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
80
80
|
- !ruby/object:Gem::Version
|
81
81
|
version: '0'
|
82
82
|
requirements: []
|
83
|
-
rubygems_version: 3.
|
83
|
+
rubygems_version: 3.1.4
|
84
84
|
signing_key:
|
85
85
|
specification_version: 4
|
86
86
|
summary: Card names without all the cards
|