cardname 0.9.4 → 0.11.1
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/README.md +7 -0
- data/lib/cardname.rb +14 -15
- data/lib/cardname/contextual.rb +9 -8
- data/lib/cardname/manipulate.rb +0 -13
- metadata +11 -16
- 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: bf803bf5912ae399a82c94a44bcc353a75f3d21894f292db0aacce5b40fde00c
|
4
|
+
data.tar.gz: d069f7f3d0a329d01fa67d7f20720e32d30ed3ca52d9e2ec360a9537d05152dc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fe7f9d7f7c0d16e9100da7689ec8a26d250a27d87c6445bdc1e62aa359c299760478f5c35a740cc50c7d190b43dd9788963cdf6190c9d098388e287decc26dc7
|
7
|
+
data.tar.gz: 91cabf13b19181f1b967830cad3fbcfd0c7faae4bbc5e6a4bde6d7a2bf7bd88ec4f31a65dac27902ffa8f771480c7d9a9728ac9b7d662bd83c0595b7fdd8d474
|
data/README.md
ADDED
data/lib/cardname.rb
CHANGED
@@ -1,6 +1,5 @@
|
|
1
1
|
# -*- encoding : utf-8 -*-
|
2
2
|
|
3
|
-
require "active_support/configurable"
|
4
3
|
require "active_support/inflector"
|
5
4
|
require "htmlentities"
|
6
5
|
|
@@ -19,22 +18,22 @@ class Cardname < String
|
|
19
18
|
|
20
19
|
OK4KEY_RE = '\p{Word}\*'
|
21
20
|
|
22
|
-
|
21
|
+
cattr_accessor :joint, :banned_array, :var_re, :uninflect, :params,
|
22
|
+
:session, :stabilize
|
23
23
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
Cardname.var_re = /\{([^\}]*\})\}/
|
30
|
-
Cardname.uninflect = :singularize
|
31
|
-
Cardname.stabilize = false
|
24
|
+
self.joint = "+"
|
25
|
+
self.banned_array = []
|
26
|
+
self.var_re = /\{([^\}]*\})\}/
|
27
|
+
self.uninflect = :singularize
|
28
|
+
self.stabilize = false
|
32
29
|
|
33
30
|
JOINT_RE = Regexp.escape joint
|
34
31
|
|
35
|
-
@@cache = {}
|
36
|
-
|
37
32
|
class << self
|
33
|
+
def cache
|
34
|
+
@cache ||= {}
|
35
|
+
end
|
36
|
+
|
38
37
|
def new obj
|
39
38
|
return obj if obj.is_a? self.class
|
40
39
|
|
@@ -43,11 +42,11 @@ class Cardname < String
|
|
43
42
|
end
|
44
43
|
|
45
44
|
def cached_name str
|
46
|
-
|
45
|
+
cache[str]
|
47
46
|
end
|
48
47
|
|
49
48
|
def reset_cache str=nil
|
50
|
-
str ?
|
49
|
+
str ? cache.delete(str) : @cache = {}
|
51
50
|
end
|
52
51
|
|
53
52
|
def stringify obj
|
@@ -97,7 +96,7 @@ class Cardname < String
|
|
97
96
|
attr_reader :key
|
98
97
|
|
99
98
|
def initialize str
|
100
|
-
|
99
|
+
self.class.cache[str] = super str.strip.encode("UTF-8")
|
101
100
|
end
|
102
101
|
|
103
102
|
def s
|
data/lib/cardname/contextual.rb
CHANGED
@@ -64,7 +64,7 @@ class Cardname
|
|
64
64
|
end
|
65
65
|
end
|
66
66
|
|
67
|
-
def absolute context
|
67
|
+
def absolute context
|
68
68
|
context = (context || "").to_name
|
69
69
|
new_parts = absolutize_contextual_parts context
|
70
70
|
return "" if new_parts.empty?
|
@@ -100,8 +100,7 @@ class Cardname
|
|
100
100
|
end
|
101
101
|
|
102
102
|
def user_part part
|
103
|
-
|
104
|
-
name_proc ? name_proc.call : part
|
103
|
+
self.class.session || part
|
105
104
|
end
|
106
105
|
|
107
106
|
def ordinal_part pos, context
|
@@ -117,13 +116,15 @@ class Cardname
|
|
117
116
|
|
118
117
|
def absolutize_extremes new_parts, context
|
119
118
|
[0, -1].each do |i|
|
120
|
-
|
121
|
-
# following avoids recontextualizing with relative contexts.
|
122
|
-
# Eg, `+A+B+.absolute('+A')` should be +A+B, not +A+A+B.
|
123
|
-
next if new_parts.to_name.send "#{[ :start, :end ][i]}s_with_parts?", context
|
124
|
-
new_parts[i] = context
|
119
|
+
new_parts[i] = context if absolutize_extreme? new_parts, context, i
|
125
120
|
end
|
126
121
|
end
|
127
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
|
128
129
|
end
|
129
130
|
end
|
data/lib/cardname/manipulate.rb
CHANGED
@@ -75,17 +75,4 @@ class Cardname
|
|
75
75
|
raise StandardError, "'#{part}' has to be simple. #{msg}"
|
76
76
|
end
|
77
77
|
end
|
78
|
-
|
79
|
-
# ~~~~~~~~~~~~~~~~~~~~ MISC ~~~~~~~~~~~~~~~~~~~~
|
80
|
-
|
81
|
-
# HACK. This doesn't belong here.
|
82
|
-
# shouldn't it use inclusions???
|
83
|
-
def self.substitute! str, hash
|
84
|
-
hash.keys.each do |var|
|
85
|
-
str.gsub! var_re do |x|
|
86
|
-
hash[var.to_sym]
|
87
|
-
end
|
88
|
-
end
|
89
|
-
str
|
90
|
-
end
|
91
78
|
end
|
metadata
CHANGED
@@ -1,16 +1,16 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cardname
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.11.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ethan McCutchen
|
8
8
|
- Philipp Kühl
|
9
9
|
- Gerry Gleason
|
10
|
-
autorequire:
|
10
|
+
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date:
|
13
|
+
date: 2021-03-02 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
|
@@ -58,15 +58,10 @@ files:
|
|
58
58
|
- lib/core_ext.rb
|
59
59
|
homepage: http://decko.org
|
60
60
|
licenses:
|
61
|
-
- GPL-2.0
|
62
61
|
- GPL-3.0
|
63
62
|
metadata: {}
|
64
|
-
post_install_message:
|
65
|
-
rdoc_options:
|
66
|
-
- "--main"
|
67
|
-
- README.rdoc
|
68
|
-
- "--inline-source"
|
69
|
-
- "--line-numbers"
|
63
|
+
post_install_message:
|
64
|
+
rdoc_options: []
|
70
65
|
require_paths:
|
71
66
|
- lib
|
72
67
|
required_ruby_version: !ruby/object:Gem::Requirement
|
@@ -80,8 +75,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
80
75
|
- !ruby/object:Gem::Version
|
81
76
|
version: '0'
|
82
77
|
requirements: []
|
83
|
-
rubygems_version: 3.0.
|
84
|
-
signing_key:
|
78
|
+
rubygems_version: 3.0.3
|
79
|
+
signing_key:
|
85
80
|
specification_version: 4
|
86
81
|
summary: Card names without all the cards
|
87
82
|
test_files: []
|