cardname 0.14.2 → 0.15.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8b664681f0f0dc208ca0df6f8f108aafe07ab9b083488b380e05638bc664e37e
4
- data.tar.gz: dbdb5f28e8a201f7a5c9712a9f9b79e6e4ac976b27836acf4e4c94fb5d584cd0
3
+ metadata.gz: '09f8f18762c861c7f86ba80f9b3f880c4eed7b44b469d01db78433fbe50db63f'
4
+ data.tar.gz: 32b9b34f0b2bf444ce301876703f7cb0a45822e64cbf7142731828b09d282f98
5
5
  SHA512:
6
- metadata.gz: 4ed00423be8d365f55c9ea565778ec2d1f68f0b09665a533686e95f5567c9f422f58b0b6073245ac71b5f88e2343baf79d06a90a9d2b3d819b2882751212fe9b
7
- data.tar.gz: c57d9036b2ea1b62791f3ee7fca9b9b2173576c8851c36cb7005f5a81d0a55ec8e76fc387aa992b01cebd2830bb48765637bd00100fac283323ab60ce1bdbafb
6
+ metadata.gz: e9dbdb672ab542bdbf618cd72ed6819f72d469a0a1a0f0ba1d1799977dd66ef21b46e0034b9846948585696ecdca7abbe94811ad18cd9e9d69fe106840c6e6ea
7
+ data.tar.gz: 840efe97c1f02b061445c9ed8b82b01f04be25c95fe3cdd90da46d3acf5d111be9090ba24d8cc499808d17f762c87a5c3100ee4440e4bb94e7f2f3fb7f094184
@@ -0,0 +1,37 @@
1
+ class Cardname
2
+ # Name-based "Fields" are compound names in which the right name is treated
3
+ # as an attribute of the left. (Eg MyName+address is a field of MyName)
4
+ module Fields
5
+ # @return [String]
6
+ def field tag_name
7
+ field_name(tag_name).s
8
+ end
9
+
10
+ # @return [Card::Name]
11
+ def field_name tag
12
+ tag = tag.to_s[1..-1] if !tag.is_a?(Symbol) && tag.to_s[0] == "+"
13
+ [self, tag].to_name
14
+ end
15
+
16
+ # @return [True/False]
17
+ def field_of? context
18
+ return false unless compound?
19
+
20
+ if context.present?
21
+ absolute_name(context).left_name.key == context.to_name.key
22
+ else
23
+ s.match?(/^\s*\+[^+]+$/)
24
+ end
25
+ end
26
+
27
+ # name is relative name containing only the rightmost part
28
+ # @return [True/False]
29
+ def field_only?
30
+ relative? && stripped.to_name.parts.reject(&:blank?).first == parts.last
31
+ end
32
+
33
+ def relative_field_name tag_name
34
+ field_name(tag_name).name_from self
35
+ end
36
+ end
37
+ end
data/lib/cardname.rb CHANGED
@@ -10,6 +10,7 @@ class Cardname < String
10
10
  require "cardname/contextual"
11
11
  require "cardname/predicates"
12
12
  require "cardname/manipulate"
13
+ require "cardname/fields"
13
14
 
14
15
  include Parts
15
16
  include Pieces
@@ -17,6 +18,7 @@ class Cardname < String
17
18
  include Contextual
18
19
  include Predicates
19
20
  include Manipulate
21
+ include Fields
20
22
 
21
23
  OK4KEY_RE = '\p{Word}\*'
22
24
 
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.14.2
4
+ version: 0.15.0
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: 2022-01-08 00:00:00.000000000 Z
13
+ date: 2023-01-04 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: activesupport
@@ -51,6 +51,7 @@ files:
51
51
  - Rakefile
52
52
  - lib/cardname.rb
53
53
  - lib/cardname/contextual.rb
54
+ - lib/cardname/fields.rb
54
55
  - lib/cardname/manipulate.rb
55
56
  - lib/cardname/parts.rb
56
57
  - lib/cardname/pieces.rb
@@ -81,7 +82,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
81
82
  - !ruby/object:Gem::Version
82
83
  version: '0'
83
84
  requirements: []
84
- rubygems_version: 3.2.15
85
+ rubygems_version: 3.3.11
85
86
  signing_key:
86
87
  specification_version: 4
87
88
  summary: Card names without all the cards