card-mod-collection 0.13.3 → 0.14.2

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: d25d5cc2046eb52c82cc76da483084c60d4049ccb4e57d93ad23c6418e4ccf5f
4
- data.tar.gz: f242af51ce605508d5448e104e12b4abb34f8a599f8e47454c8842b04d368a19
3
+ metadata.gz: 24b0a4b03b7c0b961f921db2be11daed010b3965ff1822e5cd4eb26e0639cb25
4
+ data.tar.gz: 00fed392559e8c1c576454406afab9325a9b12638e30741ba4f64e3bd32ba705
5
5
  SHA512:
6
- metadata.gz: 0466f45f83d16fd0aab344a2a7402c98c2a54a24194a72cd4ca166090cfd522a4405a5f1090863cea05226d59c0191e89e0f38327b0e2bf2ec86b3d4d867226c
7
- data.tar.gz: 07a5efb540ef038c4bae665796993eb8be7a5fa42f2b1dcf7c491e4794d486c62dca9b92ab7dafaae0c86ba1edd497418249eb93b91b4e7335a175a62b6c5aab
6
+ metadata.gz: ab9ed226b6098e53b8acdf1b9f9655a95f0fdb5c0b4ed57345bae7165becd341d3a2a884921d8eb27fdc6bde1ab2d2474d191961f3eaa1cf0302c361f8bcc134
7
+ data.tar.gz: 7c1105a83e423a1168c020f42367fcf3fe59cf42ee3b93796cb11bfa0ea39255ec6bd28490b754c6b2bf31ceaec57085dae8c470b2fea596fa6f6fe247ce138d
@@ -76,7 +76,7 @@ end
76
76
  # set card content based on array and save card
77
77
  # @param array [Array] list of strings/names (Cardish)
78
78
  def items= array
79
- items_to_content array
79
+ self.content = array
80
80
  save!
81
81
  end
82
82
 
@@ -92,8 +92,7 @@ end
92
92
  def add_item cardish, allow_duplicates=false
93
93
  return if !allow_duplicates && include_item?(cardish)
94
94
 
95
- items = item_strings << cardish
96
- items_to_content items
95
+ self.content = (item_strings << cardish)
97
96
  end
98
97
 
99
98
  # append item to list and save card
@@ -106,7 +105,7 @@ end
106
105
  # @param cardish [String, Card::Name] item to drop
107
106
  def drop_item cardish
108
107
  drop_item_name = Card::Name[cardish]
109
- items_to_content(item_names.reject { |item_name| item_name == drop_item_name })
108
+ self.content = (item_names.reject { |item_name| item_name == drop_item_name })
110
109
  end
111
110
 
112
111
  # remove item from list and save card
@@ -123,7 +122,7 @@ def insert_item index, name
123
122
  new_names = item_names
124
123
  new_names.delete name
125
124
  new_names.insert index, name
126
- items_to_content new_names
125
+ self.content = new_names
127
126
  end
128
127
 
129
128
  # insert item into list at specified location and save
@@ -156,7 +155,7 @@ end
156
155
  # TODO: support type_code and type_id. (currently type)
157
156
  # uses name, because its most common use is from CQL
158
157
  def item_type
159
- opt = options_rule_card
158
+ opt = options_card
160
159
  # FIXME: need better recursion prevention
161
160
  return if !opt || opt == self
162
161
 
@@ -2,6 +2,8 @@
2
2
 
3
3
  # render paging links
4
4
  class PagingLinks
5
+ MAX_PAGES = 100
6
+
5
7
  def initialize total_pages, current_page
6
8
  @total = total_pages
7
9
  @current = current_page
@@ -44,11 +46,10 @@ class PagingLinks
44
46
  end
45
47
 
46
48
  def right_part
47
- [
48
- (ellipse if @total > @window_end + 1),
49
- (direct_page_link @total if @total > @window_end),
50
- next_page_link
51
- ].compact
49
+ parts = [next_page_link]
50
+ parts.unshift direct_page_link(@total) if @total <= MAX_PAGES && @total > @window_end
51
+ parts.unshift ellipse if @total > @window_end + 1
52
+ parts
52
53
  end
53
54
 
54
55
  def previous_page_link
@@ -39,20 +39,14 @@ format do
39
39
  end
40
40
 
41
41
  def env_search_param param
42
- enforcing_legal_limit param do
43
- val = Env.params[param]
44
- val.to_i if focal? && val.present?
45
- end
46
- end
42
+ val = Env.params[param]
43
+ return unless focal? && val.present?
47
44
 
48
- def enforcing_legal_limit param
49
- yield.tap do |val|
50
- enforce_legal_limit! val if param == :limit
51
- end
45
+ legal_search_param val.to_i
52
46
  end
53
47
 
54
- def enforce_legal_limit! val
55
- return if Card::Auth.signed_in? || !val || val <= MAX_ANONYMOUS_SEARCH_PARAM
48
+ def legal_search_param val
49
+ return val if Card::Auth.signed_in? || val <= MAX_ANONYMOUS_SEARCH_PARAM
56
50
 
57
51
  raise Card::Error::PermissionDenied,
58
52
  "limit parameter exceeds maximum for anonymous users " \
data/set/all/extended.rb CHANGED
@@ -18,11 +18,11 @@ private
18
18
 
19
19
  def extend_item_list items, list, book
20
20
  item = items.shift
21
- return if already_extended? item, book
21
+ return if already_extended?(item, book)
22
22
 
23
23
  if item.collection?
24
24
  # keep items in order
25
- items.unshift(*item.item_cards)
25
+ items.unshift(*item.item_cards.compact)
26
26
  else # no further level of items
27
27
  list << item
28
28
  end
data/set/all/item.rb CHANGED
@@ -21,13 +21,18 @@ def item_count args={}
21
21
  item_names(args).size
22
22
  end
23
23
 
24
- def items_to_content array
25
- items = array.map { |i| standardize_item i }.reject(&:blank?)
26
- self.content = items.to_pointer_content
24
+ def items_content array
25
+ standardized_items(array).to_pointer_content
26
+ end
27
+
28
+ def standardized_items array
29
+ array.map { |i| standardize_item i }.reject(&:blank?)
27
30
  end
28
31
 
29
32
  def standardize_item item
30
33
  Card::Name[item]
34
+ rescue Card::Error::NotFound
35
+ item
31
36
  end
32
37
 
33
38
  def include_item? item
@@ -35,23 +40,19 @@ def include_item? item
35
40
  end
36
41
 
37
42
  def add_item item
38
- return if include_item? item
39
-
40
- items_to_content(items_strings << item)
43
+ self.content = (item_strings << item) unless include_item? item
41
44
  end
42
45
 
43
46
  def drop_item item
44
47
  item = Card::Name[item]
45
- return unless include_item? item
46
-
47
- items_to_content(item_names.reject { |i| i == item })
48
+ self.content = (item_names.reject { |i| i == item }) if include_item? item
48
49
  end
49
50
 
50
51
  def insert_item index, name
51
52
  new_names = item_names
52
53
  new_names.delete name
53
54
  new_names.insert index, name
54
- items_to_content new_names
55
+ self.content = new_names
55
56
  end
56
57
 
57
58
  def replace_item old, new
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: card-mod-collection
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.13.3
4
+ version: 0.14.2
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: 2022-01-08 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.3
21
+ version: 1.104.2
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.3
28
+ version: 1.104.2
29
29
  description: ''
30
30
  email:
31
31
  - info@decko.org
@@ -64,7 +64,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
64
64
  - !ruby/object:Gem::Version
65
65
  version: '0'
66
66
  requirements: []
67
- rubygems_version: 3.1.6
67
+ rubygems_version: 3.2.15
68
68
  signing_key:
69
69
  specification_version: 4
70
70
  summary: collection (list and search)