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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3cf5fcc7baaf382877caaa33709af3466edcac8f76522cd4c961872e07413f19
4
- data.tar.gz: 0dc65eca8caecefab6fd9ac00172d0fc67094d878c1a983e8b9bfec959b7a94d
3
+ metadata.gz: da9b4a6b3d8ecfa150c732ef2bdba888f626b7e51c7230755ee2e93a2e61cde9
4
+ data.tar.gz: cdb0675cb1f3ab97d7df2d1ed8f5cf54f73e00fe16c1302da5cea5881b45938f
5
5
  SHA512:
6
- metadata.gz: f6299b18bded8bf01ee0cfff088ea5ff8bdc188bbe8b99a2cd660c61ad592bd3698bbae95676311839dcbc6754ac34afd8a03f66628d2ba082748963e9c79e2d
7
- data.tar.gz: 8787e26c28145689a3a4d0b378163d34140b514c71a19f1685ca323d12690cc108b1d3fb04884a8eaeca0a6d66a62a93fe412fc82ccde399dd96f0bd2ac38e67
6
+ metadata.gz: 045012fd80276a3ae92bdc2597664cdc7e0116500fd486443375fff0b7cb27c7ec5b4fd9938671ea36479b4df07539cb0597210f771613efcbedfed98c87f610
7
+ data.tar.gz: 1ea808887da019f345fe558c3e611cd21b4018ee19aa6e7bacb893565ae81a141aab70078c66392c34533da6b606a5ed55015f72ac9903732228c78bfbc1c21c
@@ -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
- include ActiveSupport::Configurable
21
+ cattr_accessor :joint, :banned_array, :var_re, :uninflect, :params,
22
+ :session, :stabilize
23
23
 
24
- config_accessor :joint, :banned_array, :var_re, :uninflect, :params,
25
- :session, :stabilize
26
-
27
- Cardname.joint = "+"
28
- Cardname.banned_array = []
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
- @@cache[str]
45
+ cache[str]
47
46
  end
48
47
 
49
48
  def reset_cache str=nil
50
- str ? @@cache.delete(str) : @@cache = {}
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
- @@cache[str] = super str.strip.encode("UTF-8")
99
+ self.class.cache[str] = super str.strip.encode("UTF-8")
101
100
  end
102
101
 
103
102
  def s
@@ -64,7 +64,7 @@ class Cardname
64
64
  end
65
65
  end
66
66
 
67
- def absolute context, args={}
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
- name_proc = self.class.session
104
- name_proc ? name_proc.call : part
103
+ self.class.session || part
105
104
  end
106
105
 
107
106
  def ordinal_part pos, context
@@ -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.9.2
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-02-12 00:00:00.000000000 Z
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.6
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: []