card-mod-collection 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: 32041fabaee9f9938a11f98238aedbd9aadf50999d72759d4dbcb30c1ba1cc3f
4
- data.tar.gz: 30058d82c17bc5e096de3db930d2195d973864dfcc17c8d890f59014ab12769d
3
+ metadata.gz: 676ab2305586fd9e10fe00cc8fc8cb5efa98a1efd30e99d72a6aa65a91457a4c
4
+ data.tar.gz: 1f887be2fad2ef27879e1080ada1ccbbfb316a39921d2fd055811be8b3b1df0b
5
5
  SHA512:
6
- metadata.gz: e5349352cc0d00e7b3f6109600d94d67c6a0ff70771aef59ccb0a75459472d5f324cde1feade9c1efcbb0d738ff5a05efc6d175408f661f16d4d596c6785c496
7
- data.tar.gz: 55fb1603dd956f1aed3d6dde909c8fd4057e108fe8f1ea22a8a30c6818c60161190b77283650587db6920484027bba2edbdabae343574d29ab4b564c91add267
6
+ metadata.gz: a5a331529bc20615d6afa6422581bbc21ebc95cd80320882f04716de8ae32977463a9e18bbcc77d81f1f09a289e4fb265f8bc31651747c59f69383d7e377f55f
7
+ data.tar.gz: cbe75b23d73de4fe9669ab8c67e4a42dc625f852187cb6a0343f7661a2e07dc01921a0ed683465173cf54cd5156e448aef9c96dc5c621258de64ae3764ba2bfe
@@ -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.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
@@ -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)