cardname 0.10.0 → 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: da9b4a6b3d8ecfa150c732ef2bdba888f626b7e51c7230755ee2e93a2e61cde9
4
- data.tar.gz: cdb0675cb1f3ab97d7df2d1ed8f5cf54f73e00fe16c1302da5cea5881b45938f
3
+ metadata.gz: e8f8b91a34b888b1e298d4ec50d7a6d2c12207e1449ece845751bf8ad7f325b1
4
+ data.tar.gz: 6deab4dff00266b7e180557e3bf0b7577ad393f76bd560ee2adfa766d56a5f23
5
5
  SHA512:
6
- metadata.gz: 045012fd80276a3ae92bdc2597664cdc7e0116500fd486443375fff0b7cb27c7ec5b4fd9938671ea36479b4df07539cb0597210f771613efcbedfed98c87f610
7
- data.tar.gz: 1ea808887da019f345fe558c3e611cd21b4018ee19aa6e7bacb893565ae81a141aab70078c66392c34533da6b606a5ed55015f72ac9903732228c78bfbc1c21c
6
+ metadata.gz: 204bad77b0157b0e472c92a6a2d861ea336da50744c4fc572e72c82b6fa9a0be6eb04591205c1441d8e51b050ca3f9242f26c18691b38d10a935dad267570ead
7
+ data.tar.gz: e1a36c3294f34dd18e56588eec50262177ae94a6d35eb18ba8e8702b553c3dde82608d75147fa493cfa464a7f200291d6e60bc85160a57d124bd0a512385a72a
data/README.md ADDED
@@ -0,0 +1,7 @@
1
+ <!--
2
+ # @title README - Cardname
3
+ -->
4
+ # Cardname
5
+
6
+ Wiki Segmented Name Logic
7
+
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
@@ -116,13 +116,15 @@ class Cardname
116
116
 
117
117
  def absolutize_extremes new_parts, context
118
118
  [0, -1].each do |i|
119
- next if new_parts[i].present?
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
@@ -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
@@ -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.10.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: 2020-09-11 00:00:00.000000000 Z
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: info@decko.org
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.rdoc
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: http://decko.org
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.0.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
data/README.rdoc DELETED
@@ -1,7 +0,0 @@
1
-
2
- == Cardname
3
-
4
- Wiki Segmented Name Logic
5
-
6
- == Abstract
7
-