card-mod-content 0.13.4 → 0.14.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: 5ac708ca2b275e22da91e4563a6689a0e782541ce230338abc4d4ce173f050ad
4
- data.tar.gz: 965a796f3fb24906039c36a3f99b1235edfe4b58f45e3607dc25906a5e8ee8c3
3
+ metadata.gz: 787c9c826bc3774c5768367aa580523fa4c9761bd5666f1e5f0f20bd63e232a1
4
+ data.tar.gz: 1502d97db6bf3f12eff75e092d709bfa182739cf26bb1e8407e60c1b835e0beb
5
5
  SHA512:
6
- metadata.gz: a2746333bde208a73d5cf3e7d58b3dd739d563bb667cdb39e0e78a824eecdef9533481f85016ab68f8c3b5c79d2f432c76974180f29a7916b54009163265f060
7
- data.tar.gz: 5243c7317d0ab6f4a34d223a5027fc440ee89b3af8f5bcd31d31325b699a4aaf73d45065ed6faa5e8561f699fbd22cf4beed5ff2eb7abfc4997331058f762a03
6
+ metadata.gz: 1dbc01b4028df133a64ecaaa11f623f39478fb0de84717c9935bd678f1a4ba21aee46dd50f2602481a976a74f8965a77a0bdddeec58f2c585e9645b56d5226ec
7
+ data.tar.gz: 3dbee3c56ee6c25477c2aa5f1d6d43f1030f8dff43c081b0621707f42b85145348532fb5fa6fc9313becfbc09a50a7a4232db76c6a0ba3767eae4cff676620e7
@@ -32,7 +32,7 @@ class Card
32
32
  link_text ? { title: link_text } : {}
33
33
  end
34
34
 
35
- def replace_reference old_name, new_name
35
+ def swap_name old_name, new_name
36
36
  replace_name_reference old_name, new_name
37
37
  replace_link_text old_name, new_name
38
38
  link_text_syntax = "|#{@link_text}" if @link_text.present?
@@ -122,11 +122,7 @@ class Card
122
122
  end
123
123
 
124
124
  def replace_link_text old_name, new_name
125
- if @link_text.is_a?(Content)
126
- @link_text.find_chunks(:Reference).each do |chunk|
127
- chunk.replace_reference old_name, new_name
128
- end
129
- elsif @link_text.present?
125
+ replacing_content_object @link_text, old_name, new_name do
130
126
  @link_text = old_name.to_name.sub_in(@link_text, with: new_name)
131
127
  end
132
128
  end
@@ -76,7 +76,7 @@ class Card
76
76
  # this is not necessarily text, sometimes objects for json
77
77
  end
78
78
 
79
- def replace_reference old_name, new_name
79
+ def swap_name old_name, new_name
80
80
  replace_name_reference old_name, new_name
81
81
  nest_body = [@name.to_s, @opt_lists].compact * "|"
82
82
  @text = "{{#{nest_body}}}"
@@ -81,7 +81,7 @@ class Card
81
81
  "<##{self.class}:n[#{@name}] p[#{@process_chunk}] txt:#{@text}>"
82
82
  end
83
83
 
84
- def replace_reference old_name, new_name
84
+ def swap_name old_name, new_name
85
85
  replace_name_reference old_name, new_name
86
86
  @text = "\"#{@name}\""
87
87
  end
@@ -27,17 +27,22 @@ class Card
27
27
  private
28
28
 
29
29
  def replace_name_reference old_name, new_name
30
- @referee_card = nil
31
- @referee_name = nil
32
- if name.is_a? Content
33
- name.find_chunks(:Reference).each do |chunk|
34
- chunk.replace_reference old_name, new_name
35
- end
36
- else
30
+ @referee_card = @referee_name = nil
31
+ replacing_content_object name, old_name, new_name do
37
32
  @name = name.to_name.swap old_name, new_name
38
33
  end
39
34
  end
40
35
 
36
+ def replacing_content_object obj, old_name, new_name
37
+ if obj.is_a? Content
38
+ obj.find_chunks(:Reference).each do |chunk|
39
+ chunk.swap_name old_name, new_name
40
+ end
41
+ elsif obj.present?
42
+ yield
43
+ end
44
+ end
45
+
41
46
  def render_obj raw
42
47
  return raw unless format && raw.is_a?(Content)
43
48
 
@@ -58,6 +58,7 @@ end
58
58
 
59
59
  format :html do
60
60
  view :input do
61
+ # Localize
61
62
  "Content is stored in file and can't be edited."
62
63
  end
63
64
 
data/set/abstract/lock.rb CHANGED
@@ -2,7 +2,7 @@ def lock
2
2
  was_already_locked = locked?
3
3
  return if was_already_locked
4
4
 
5
- Auth.as_bot do
5
+ Card::Auth.as_bot do
6
6
  lock!
7
7
  yield
8
8
  end
@@ -1,13 +1,13 @@
1
1
  def is_template?
2
2
  return @is_template unless @is_template.nil?
3
3
 
4
- @is_template = name.trait_name? :structure, :default
4
+ @is_template = name.right_name&.codename&.in? %i[structure default]
5
5
  end
6
6
 
7
7
  def is_structure?
8
8
  return @is_structure unless @is_structure.nil?
9
9
 
10
- @is_structure = name.trait_name? :structure
10
+ @is_structure = name.right_name&.codename == :structure
11
11
  end
12
12
 
13
13
  def template
@@ -24,31 +24,6 @@ def template
24
24
  end
25
25
  end
26
26
 
27
- def default_type_id
28
- Card.default_type_id
29
- end
30
-
31
- def new_card_template
32
- default = rule_card :default, skip_modules: true
33
- return default unless (structure = dup_structure default&.type_id)
34
-
35
- @virtual = true if compound?
36
- self.type_id = structure.type_id if assign_type_to?(structure)
37
- structure
38
- end
39
-
40
- def dup_structure type_id
41
- dup_card = dup
42
- dup_card.type_id = type_id || default_type_id
43
- dup_card.structure_rule_card
44
- end
45
-
46
- def assign_type_to? structure
47
- return if type_id == structure.type_id
48
-
49
- structure.assigns_type?
50
- end
51
-
52
27
  def assigns_type?
53
28
  # needed because not all *structure templates govern the type of set members
54
29
  # for example, X+*type+*structure governs all cards of type X,
@@ -68,3 +43,24 @@ def structure_rule_card
68
43
 
69
44
  card.db_content&.strip == "_self" ? nil : card
70
45
  end
46
+
47
+ private
48
+
49
+ def new_card_template
50
+ default = rule_card :default, skip_modules: true
51
+ return default unless (structure = dup_structure default&.type_id)
52
+
53
+ @virtual = true if compound?
54
+ self.type_id = structure.type_id if assign_type_to?(structure)
55
+ structure
56
+ end
57
+
58
+ def dup_structure type_id
59
+ dup_card = dup
60
+ dup_card.type_id = type_id || Card.default_type_id
61
+ dup_card.structure_rule_card
62
+ end
63
+
64
+ def assign_type_to? structure
65
+ type_id == structure.type_id && structure.assigns_type?
66
+ end
data/set/right/default.rb CHANGED
@@ -23,7 +23,7 @@ format :html do
23
23
  end
24
24
 
25
25
  def visible_cardtype_groups
26
- hash = ::Card::Set::Self::Cardtype::GROUP.slice("Text", "Data", "Upload")
26
+ hash = All::CardtypeGroups::GROUP.slice("Text", "Data", "Upload")
27
27
  hash["Organize"] = ["List", "Pointer", "Link list", "Nest list"]
28
28
  hash
29
29
  end
@@ -16,7 +16,7 @@ format :html do
16
16
  end
17
17
 
18
18
  def visible_cardtype_groups
19
- hash = ::Card::Set::Self::Cardtype::GROUP.slice("Text")
19
+ hash = All::CardtypeGroups::GROUP.slice("Text")
20
20
  hash["Organize"] = ["Search", "Nest list"]
21
21
  hash
22
22
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: card-mod-content
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.13.4
4
+ version: 0.14.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: 2021-09-24 00:00:00.000000000 Z
13
+ date: 2021-12-22 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: card
@@ -18,14 +18,14 @@ dependencies:
18
18
  requirements:
19
19
  - - '='
20
20
  - !ruby/object:Gem::Version
21
- version: 1.103.4
21
+ version: 1.104.0
22
22
  type: :runtime
23
23
  prerelease: false
24
24
  version_requirements: !ruby/object:Gem::Requirement
25
25
  requirements:
26
26
  - - '='
27
27
  - !ruby/object:Gem::Version
28
- version: 1.103.4
28
+ version: 1.104.0
29
29
  description: ''
30
30
  email:
31
31
  - info@decko.org
@@ -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.1.6
83
+ rubygems_version: 3.2.15
84
84
  signing_key:
85
85
  specification_version: 4
86
86
  summary: card content handling