card-mod-collection 0.13.1 → 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: 7c59d763c599f7e9b51ebcb2b5ae32408c88c46e6832684fa31918dcdd1aed20
4
- data.tar.gz: 8b399b450fa43ad145660185f1e1a9b64d7d05dff050d70dc7392a8dec8b4b03
3
+ metadata.gz: 676ab2305586fd9e10fe00cc8fc8cb5efa98a1efd30e99d72a6aa65a91457a4c
4
+ data.tar.gz: 1f887be2fad2ef27879e1080ada1ccbbfb316a39921d2fd055811be8b3b1df0b
5
5
  SHA512:
6
- metadata.gz: da5238514f9ea637bd4e228b9cfa8e93d888a0929819407495da8a78291a5fe8fcd79a7f37eaf3dc597aea8df6baabd2838083e3aee782128a11380563770924
7
- data.tar.gz: 88d63f2279e2d2d082d3eae7390bade21525f45a9044827be4877b4c5148272900e2b6d4b9c6f8d069a3fc678057097afe6c8dd9e12c25b539ca6a15133e8d33
6
+ metadata.gz: a5a331529bc20615d6afa6422581bbc21ebc95cd80320882f04716de8ae32977463a9e18bbcc77d81f1f09a289e4fb265f8bc31651747c59f69383d7e377f55f
7
+ data.tar.gz: cbe75b23d73de4fe9669ab8c67e4a42dc625f852187cb6a0343f7661a2e07dc01921a0ed683465173cf54cd5156e448aef9c96dc5c621258de64ae3764ba2bfe
@@ -43,12 +43,16 @@ def item_ids args={}
43
43
  item_names(args).map(&:card_id).compact
44
44
  end
45
45
 
46
+ def item_cards args={}
47
+ standard_item_cards args
48
+ end
49
+
46
50
  # @return [Array] list of Card objects
47
51
  # @param args [Hash] see #item_names for additional options
48
52
  # @option args [String] :complete keyword to use in searching among items
49
53
  # @option args [True/False] :known_only if true, return only known cards
50
54
  # @option args [String] :type name of type to be used for unknown cards
51
- def item_cards args={}
55
+ def standard_item_cards args={}
52
56
  return item_cards_search(args) if args[:complete]
53
57
  return known_item_cards(args) if args[:known_only]
54
58
 
@@ -72,7 +76,7 @@ end
72
76
  # set card content based on array and save card
73
77
  # @param array [Array] list of strings/names (Cardish)
74
78
  def items= array
75
- items_to_content array
79
+ self.content = array
76
80
  save!
77
81
  end
78
82
 
@@ -88,8 +92,7 @@ end
88
92
  def add_item cardish, allow_duplicates=false
89
93
  return if !allow_duplicates && include_item?(cardish)
90
94
 
91
- items = item_strings << cardish
92
- items_to_content items
95
+ self.content = (item_strings << cardish)
93
96
  end
94
97
 
95
98
  # append item to list and save card
@@ -102,7 +105,7 @@ end
102
105
  # @param cardish [String, Card::Name] item to drop
103
106
  def drop_item cardish
104
107
  drop_item_name = Card::Name[cardish]
105
- 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 })
106
109
  end
107
110
 
108
111
  # remove item from list and save card
@@ -119,7 +122,7 @@ def insert_item index, name
119
122
  new_names = item_names
120
123
  new_names.delete name
121
124
  new_names.insert index, name
122
- items_to_content new_names
125
+ self.content = new_names
123
126
  end
124
127
 
125
128
  # insert item into list at specified location and save
@@ -152,7 +155,7 @@ end
152
155
  # TODO: support type_code and type_id. (currently type)
153
156
  # uses name, because its most common use is from CQL
154
157
  def item_type
155
- opt = options_rule_card
158
+ opt = options_card
156
159
  # FIXME: need better recursion prevention
157
160
  return if !opt || opt == self
158
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.1
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-08-06 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.1
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.1
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)