cardname 0.9.2 → 0.10.0
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 +14 -15
- data/lib/cardname/contextual.rb +2 -3
- data/lib/cardname/manipulate.rb +0 -13
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: da9b4a6b3d8ecfa150c732ef2bdba888f626b7e51c7230755ee2e93a2e61cde9
|
4
|
+
data.tar.gz: cdb0675cb1f3ab97d7df2d1ed8f5cf54f73e00fe16c1302da5cea5881b45938f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 045012fd80276a3ae92bdc2597664cdc7e0116500fd486443375fff0b7cb27c7ec5b4fd9938671ea36479b4df07539cb0597210f771613efcbedfed98c87f610
|
7
|
+
data.tar.gz: 1ea808887da019f345fe558c3e611cd21b4018ee19aa6e7bacb893565ae81a141aab70078c66392c34533da6b606a5ed55015f72ac9903732228c78bfbc1c21c
|
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
|
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.10.0
|
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: 2020-
|
13
|
+
date: 2020-09-11 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: activesupport
|
@@ -61,7 +61,7 @@ licenses:
|
|
61
61
|
- GPL-2.0
|
62
62
|
- GPL-3.0
|
63
63
|
metadata: {}
|
64
|
-
post_install_message:
|
64
|
+
post_install_message:
|
65
65
|
rdoc_options:
|
66
66
|
- "--main"
|
67
67
|
- README.rdoc
|
@@ -80,8 +80,8 @@ 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.
|
84
|
-
signing_key:
|
83
|
+
rubygems_version: 3.0.3
|
84
|
+
signing_key:
|
85
85
|
specification_version: 4
|
86
86
|
summary: Card names without all the cards
|
87
87
|
test_files: []
|