card-mod-collection 0.13.2 → 0.14.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/set/abstract/items.rb +10 -7
- data/set/abstract/paging/paging_links.rb +6 -5
- data/set/abstract/paging.rb +5 -11
- data/set/all/extended.rb +2 -2
- data/set/all/item.rb +11 -10
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3d5e60454dce875711bdae859b3e125f98dfeba6168a5f4c4aa5a1cbb0a2557c
|
4
|
+
data.tar.gz: 119712ab680e5e89409a0174c5d2d4afbef2ba8e8e4e131eef02bc88f0b4b0d4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ac0e9901966dfc46137561312733e8aae562de83efc5a96ed53e2cb94b32a53b1ded063040a605bd567bfdb5621fdf5151fa56f93663e6e32522bc52802b9ce8
|
7
|
+
data.tar.gz: 41e672cd8fbf173109cc35a4c34f84e35d549fb89c3c7e521cc74d3390fbf98054f0f39374c1542fcbba7995affc055f80906c10b70c2c4e4c2a47626e6f679d
|
data/set/abstract/items.rb
CHANGED
@@ -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
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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 =
|
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
|
-
|
49
|
-
|
50
|
-
|
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
|
data/set/abstract/paging.rb
CHANGED
@@ -39,20 +39,14 @@ format do
|
|
39
39
|
end
|
40
40
|
|
41
41
|
def env_search_param param
|
42
|
-
|
43
|
-
|
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
|
-
|
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
|
55
|
-
return if Card::Auth.signed_in? ||
|
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?
|
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
|
25
|
-
|
26
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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.
|
4
|
+
version: 0.14.1
|
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:
|
13
|
+
date: 2022-01-04 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.
|
21
|
+
version: 1.104.1
|
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.
|
28
|
+
version: 1.104.1
|
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.
|
67
|
+
rubygems_version: 3.2.15
|
68
68
|
signing_key:
|
69
69
|
specification_version: 4
|
70
70
|
summary: collection (list and search)
|