card 1.20.3 → 1.20.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/VERSION +1 -1
- data/config/initializers/01_core_extensions/kernel.rb +11 -0
- data/config/initializers/core_extensions.rb +2 -1
- data/config/initializers/patches.rb +1 -1
- data/lib/card/act_manager.rb +3 -1
- data/lib/card/act_manager/stage_director.rb +2 -3
- data/lib/card/auth/proxy.rb +1 -1
- data/mod/basic_formats/set/all/all_csv.rb +7 -22
- data/mod/carrierwave/set/abstract/attachment/paths.rb +5 -3
- data/mod/core/set/all/collection.rb +59 -1
- data/mod/core/set/all/name.rb +1 -1
- data/mod/machines/set/abstract/machine.rb +5 -0
- data/mod/settings/lib/card/setting.rb +1 -1
- data/mod/standard/set/abstract/search.rb +6 -4
- data/mod/standard/set/all/rich_html/content.rb +8 -2
- data/mod/standard/set/all/rich_html/editing.rb +1 -1
- data/mod/standard/spec/set/type/search_type_spec.rb +42 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bc831339e2819ac6a6ea6e2d4b4a2213c5c683ad
|
4
|
+
data.tar.gz: 433407d4dd89299309079c2be3483b5185a8d93b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f6ed5a62f46acd1188f4cb77f408d59ebaed043634616ec68d3060ea812f063daa948c4c4e224bf9039900afc1029a9e8a2ffbb93d98fe3f2c27dd7f3b774fdb
|
7
|
+
data.tar.gz: 0d51251838f7fd2fde52471b2c91b025f08f71b690af62665fbe5f85e2d8df4697390d1e53aa9276bbb3a2985630bc727e75444e4b252fa7b958539c9a4225e1
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.20.
|
1
|
+
1.20.4
|
@@ -2,13 +2,14 @@
|
|
2
2
|
|
3
3
|
# extend core Ruby object classes
|
4
4
|
|
5
|
-
class
|
5
|
+
class Module
|
6
6
|
def include_extension extension
|
7
7
|
include extension
|
8
8
|
end
|
9
9
|
end
|
10
10
|
|
11
11
|
module CoreExtensions
|
12
|
+
::Kernel.include_extension Kernel
|
12
13
|
::Object.include_extension Object
|
13
14
|
::Module.include_extension Module
|
14
15
|
::Array.include_extension Array
|
data/lib/card/act_manager.rb
CHANGED
@@ -114,6 +114,7 @@ class Card
|
|
114
114
|
end
|
115
115
|
|
116
116
|
def add director
|
117
|
+
# Rails.logger.debug "added: #{director.card.name}".green
|
117
118
|
directors[director.card] = director
|
118
119
|
end
|
119
120
|
|
@@ -140,7 +141,8 @@ class Card
|
|
140
141
|
end
|
141
142
|
|
142
143
|
def to_s
|
143
|
-
|
144
|
+
act_director.to_s
|
145
|
+
#directors.values.map(&:to_s).join "\n"
|
144
146
|
end
|
145
147
|
end
|
146
148
|
end
|
@@ -163,11 +163,10 @@ class Card
|
|
163
163
|
end
|
164
164
|
end
|
165
165
|
|
166
|
-
def to_s
|
166
|
+
def to_s level=1
|
167
167
|
str = @card.name.to_s.clone
|
168
168
|
if @subdirectors
|
169
|
-
subs = subdirectors.map(
|
170
|
-
.map { |card| " #{card.name}" }.join "\n"
|
169
|
+
subs = subdirectors.map { |d| " " * level + d.to_s(level + 1) }.join "\n"
|
171
170
|
str << "\n#{subs}"
|
172
171
|
end
|
173
172
|
str
|
data/lib/card/auth/proxy.rb
CHANGED
@@ -9,7 +9,7 @@ format :csv do
|
|
9
9
|
@depth.zero? ? :csv_row : :name
|
10
10
|
end
|
11
11
|
|
12
|
-
view :csv_row do
|
12
|
+
view :csv_row do
|
13
13
|
array = _render_raw.scan(/\{\{[^\}]*\}\}/).map do |inc|
|
14
14
|
process_content(inc).strip
|
15
15
|
end
|
@@ -22,28 +22,13 @@ format :csv do
|
|
22
22
|
""
|
23
23
|
end
|
24
24
|
|
25
|
-
view :
|
26
|
-
|
27
|
-
|
28
|
-
card1 = search_with_params.first
|
25
|
+
view :name_with_fields do
|
26
|
+
CSV.generate_line name_with_fields_row
|
27
|
+
end
|
29
28
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
else
|
34
|
-
titles = parsed_content.map do |chunk|
|
35
|
-
next if chunk.class != Card::Content::Chunk::Nest
|
36
|
-
opts = chunk.options
|
37
|
-
if %w(name link).member? opts[:view]
|
38
|
-
opts[:view]
|
39
|
-
else
|
40
|
-
opts[:nest_name].to_name.tag
|
41
|
-
end
|
42
|
-
end.compact
|
43
|
-
CSV.generate_line titles.map { |title| title.to_s.upcase }
|
44
|
-
end
|
45
|
-
rescue
|
46
|
-
""
|
29
|
+
def name_with_fields_row
|
30
|
+
nested_fields.each_with_object([card.name]) do |(field_name, options), row|
|
31
|
+
row << nest(field_name)
|
47
32
|
end
|
48
33
|
end
|
49
34
|
end
|
@@ -21,9 +21,11 @@ def coded_dir new_mod=nil
|
|
21
21
|
end
|
22
22
|
|
23
23
|
def mod_dir new_mod=nil
|
24
|
-
|
25
|
-
Card::Mod::Loader.mod_dirs.path(
|
26
|
-
|
24
|
+
mod_name = new_mod || mod
|
25
|
+
dir = Card::Mod::Loader.mod_dirs.path(mod_name) || (mod_name == :test && "test")
|
26
|
+
|
27
|
+
raise Error, "can't find mod \"#{mod_name}\"" unless dir
|
28
|
+
dir
|
27
29
|
end
|
28
30
|
|
29
31
|
def files_base_dir
|
@@ -191,7 +191,7 @@ format do
|
|
191
191
|
end
|
192
192
|
|
193
193
|
def implicit_item_view
|
194
|
-
view = voo_items_view || default_item_view
|
194
|
+
view = params[:item] || voo_items_view || default_item_view
|
195
195
|
Card::View.canonicalize view
|
196
196
|
end
|
197
197
|
|
@@ -344,3 +344,61 @@ format :html do
|
|
344
344
|
static_tabs tabs, tab_type
|
345
345
|
end
|
346
346
|
end
|
347
|
+
|
348
|
+
format :csv do
|
349
|
+
view :core do
|
350
|
+
if (item_view_options[:view] == :name_with_fields) && focal?
|
351
|
+
title_row("item name") + name_with_field_rows
|
352
|
+
else
|
353
|
+
super()
|
354
|
+
end
|
355
|
+
end
|
356
|
+
|
357
|
+
def name_with_field_rows
|
358
|
+
list = card.item_names
|
359
|
+
columns = columns_from_referees list.first
|
360
|
+
|
361
|
+
list.map do |item_name|
|
362
|
+
CSV.generate_line row_from_field_names(item_name, columns)
|
363
|
+
end.join
|
364
|
+
end
|
365
|
+
|
366
|
+
def columns_from_referees referer
|
367
|
+
columns = []
|
368
|
+
Card.fetch(referer).format.each_nested_field do |chunk|
|
369
|
+
columns << chunk.referee_name.tag
|
370
|
+
end
|
371
|
+
columns
|
372
|
+
end
|
373
|
+
|
374
|
+
def row_from_field_names parent_name, field_names, view=:core
|
375
|
+
field_names.each_with_object([parent_name]) do |field, row|
|
376
|
+
row << nest([parent_name, field], view: view)
|
377
|
+
end
|
378
|
+
end
|
379
|
+
|
380
|
+
def title_row extra_titles=nil
|
381
|
+
titles = column_titles extra_titles
|
382
|
+
return "" unless titles.present?
|
383
|
+
CSV.generate_line titles.map { |title| title.to_s.upcase }
|
384
|
+
rescue
|
385
|
+
""
|
386
|
+
end
|
387
|
+
|
388
|
+
def column_titles extra_titles=nil
|
389
|
+
res = Array extra_titles
|
390
|
+
card1 = Card.fetch card.item_names(limit: 1).first
|
391
|
+
card1.each_nested_chunk do |chunk|
|
392
|
+
res << column_title(chunk.options)
|
393
|
+
end
|
394
|
+
res.compact
|
395
|
+
end
|
396
|
+
|
397
|
+
def column_title opts
|
398
|
+
if %w(name link).member? opts[:view]
|
399
|
+
opts[:view]
|
400
|
+
else
|
401
|
+
opts[:nest_name].to_name.tag
|
402
|
+
end
|
403
|
+
end
|
404
|
+
end
|
data/mod/core/set/all/name.rb
CHANGED
@@ -173,6 +173,11 @@ end
|
|
173
173
|
|
174
174
|
def cache_output_part input_card, output
|
175
175
|
Auth.as_bot do
|
176
|
+
# save virtual cards first
|
177
|
+
# otherwise the cache card will save it to get the left_id
|
178
|
+
# and trigger the cache update again
|
179
|
+
input_card.save! if input_card.new_card?
|
180
|
+
|
176
181
|
cache_card = fetch_cache_card(input_card, true)
|
177
182
|
cache_card.update_attributes! content: output
|
178
183
|
end
|
@@ -20,7 +20,7 @@ def item_cards args={}
|
|
20
20
|
end
|
21
21
|
|
22
22
|
def item_names args={}
|
23
|
-
args[:limit]
|
23
|
+
args[:limit] ||= 0
|
24
24
|
returning(:name, args) { search args }
|
25
25
|
end
|
26
26
|
|
@@ -92,10 +92,12 @@ format :data do
|
|
92
92
|
end
|
93
93
|
|
94
94
|
format :csv do
|
95
|
-
view :
|
96
|
-
|
95
|
+
view :core, mod: All::Collection::CsvFormat
|
96
|
+
|
97
|
+
view :card_list do
|
98
|
+
items = super()
|
97
99
|
if @depth.zero?
|
98
|
-
|
100
|
+
title_row + items
|
99
101
|
else
|
100
102
|
items
|
101
103
|
end
|
@@ -161,8 +161,7 @@ format :html do
|
|
161
161
|
end
|
162
162
|
|
163
163
|
def related_card_and_options args
|
164
|
-
options = (args
|
165
|
-
return unless options
|
164
|
+
return unless (options = related_options(args))
|
166
165
|
related_card = related_card_from_options options
|
167
166
|
options[:view] ||= :open
|
168
167
|
options[:show] ||= []
|
@@ -170,6 +169,13 @@ format :html do
|
|
170
169
|
[related_card, options]
|
171
170
|
end
|
172
171
|
|
172
|
+
def related_options args
|
173
|
+
options = (args[:related] || params[:related])
|
174
|
+
options = { name: options } if options.is_a? String
|
175
|
+
return unless options.is_a? Hash
|
176
|
+
options.symbolize_keys
|
177
|
+
end
|
178
|
+
|
173
179
|
def related_card_from_options options
|
174
180
|
related_card = options.delete :card
|
175
181
|
return related_card if related_card
|
@@ -56,7 +56,7 @@ describe Card::Set::Type::SearchType do
|
|
56
56
|
expect(subject.content).to eq '{"name":"YYY"}'
|
57
57
|
end
|
58
58
|
end
|
59
|
-
|
59
|
+
describe "rss format" do
|
60
60
|
it "render rss without errors" do
|
61
61
|
search_card = Card.create type: "Search", name: "Asearch",
|
62
62
|
content: %({"id":"1"})
|
@@ -64,4 +64,45 @@ describe Card::Set::Type::SearchType do
|
|
64
64
|
expect(rss).to have_tag("title", text: "Wagn Bot")
|
65
65
|
end
|
66
66
|
end
|
67
|
+
|
68
|
+
describe "csv format" do
|
69
|
+
describe "view :content" do
|
70
|
+
subject do
|
71
|
+
render_view :content, { name: "Book+*type+by name" },
|
72
|
+
format: :csv
|
73
|
+
end
|
74
|
+
|
75
|
+
it "has title row with nest names" do
|
76
|
+
is_expected.to include "AUTHOR,ILLUSTRATOR"
|
77
|
+
end
|
78
|
+
|
79
|
+
it "has nests contents" do
|
80
|
+
create "Guide",
|
81
|
+
type: "Book",
|
82
|
+
subfields: { "author" => "Hitchhiker",
|
83
|
+
"illustrator" => "Galaxy" }
|
84
|
+
is_expected.to include "Hitchhiker,Galaxy"
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
describe "view :nested_fields" do
|
89
|
+
subject do
|
90
|
+
Card::Env.params[:item] = :name_with_fields
|
91
|
+
render_card_with_args :core, { name: "Book+*type+by name" },
|
92
|
+
{ format: :csv }, items: { view: :name_with_fields }
|
93
|
+
end
|
94
|
+
|
95
|
+
it "has title row item name and field names" do
|
96
|
+
is_expected.to include "ITEM NAME,AUTHOR,ILLUSTRATOR"
|
97
|
+
end
|
98
|
+
|
99
|
+
it "has field contents" do
|
100
|
+
create "Guide",
|
101
|
+
type: "Book",
|
102
|
+
subfields: { "author" => "Hitchhiker",
|
103
|
+
"illustrator" => "Galaxy" }
|
104
|
+
is_expected.to include "Guide,Hitchhiker,Galaxy"
|
105
|
+
end
|
106
|
+
end
|
107
|
+
end
|
67
108
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: card
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.20.
|
4
|
+
version: 1.20.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ethan McCutchen
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date: 2017-04-
|
14
|
+
date: 2017-04-15 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: smartname
|
@@ -283,6 +283,7 @@ files:
|
|
283
283
|
- config/i18n-tasks.yml
|
284
284
|
- config/initializers/01_core_extensions/array.rb
|
285
285
|
- config/initializers/01_core_extensions/hash.rb
|
286
|
+
- config/initializers/01_core_extensions/kernel.rb
|
286
287
|
- config/initializers/01_core_extensions/module.rb
|
287
288
|
- config/initializers/01_core_extensions/object.rb
|
288
289
|
- config/initializers/01_core_extensions/persistent_identifiers.rb
|