card 1.16.4 → 1.16.5
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/db/migrate_core_cards/20150429090551_search_card_context.rb +34 -0
- data/db/migrate_core_cards/20150824135418_update_file_history.rb +10 -5
- data/db/migrate_core_cards/20150910085603_remove_performance_log_card.rb +10 -0
- data/db/seed/new/card_actions.yml +358 -366
- data/db/seed/new/card_acts.yml +1 -1
- data/db/seed/new/card_changes.yml +1379 -1399
- data/db/seed/new/card_references.yml +1109 -710
- data/db/seed/new/cards.yml +1436 -1454
- data/db/seed/test/fixtures/card_actions.yml +1031 -1039
- data/db/seed/test/fixtures/card_acts.yml +155 -155
- data/db/seed/test/fixtures/card_changes.yml +4148 -4168
- data/db/seed/test/fixtures/card_references.yml +1577 -1178
- data/db/seed/test/fixtures/cards.yml +2259 -2277
- data/db/version_core_cards.txt +1 -1
- data/lib/card.rb +3 -2
- data/lib/card/env.rb +66 -0
- data/lib/card/format.rb +3 -38
- data/lib/card/loader.rb +0 -4
- data/lib/card/location.rb +38 -0
- data/lib/card/set.rb +1 -3
- data/lib/card/success.rb +2 -3
- data/mod/01_core/format/html_format.rb +0 -48
- data/mod/01_core/set/all/collection.rb +9 -7
- data/mod/01_core/set/all/initialize.rb +5 -0
- data/mod/01_core/set/all/location_history.rb +10 -0
- data/mod/01_core/set/all/phases.rb +2 -1
- data/mod/01_core/set/all/rules.rb +0 -2
- data/mod/01_core/set/all/trash.rb +3 -2
- data/mod/01_core/set/all/utils.rb +12 -0
- data/mod/01_core/spec/set/all/permissions_spec.rb +8 -8
- data/mod/01_core/spec/set/all/type_spec.rb +14 -14
- data/mod/01_history/set/all/content_history.rb +7 -3
- data/mod/01_history/set/all/history.rb +3 -3
- data/mod/02_basic_types/set/type/pointer.rb +8 -1
- data/mod/03_machines/lib/javascript/wagn_mod.js.coffee +39 -0
- data/mod/03_machines/lib/stylesheets/style_cards.scss +12 -2
- data/mod/03_machines/set/right/machine_output.rb +4 -0
- data/mod/03_machines/set/type/css.rb +1 -1
- data/mod/04_settings/spec/set/right/structure_spec.rb +1 -1
- data/mod/05_email/set/all/observer.rb +5 -5
- data/mod/05_email/set/type_plus_right/user/follow.rb +1 -1
- data/mod/05_standard/file/favicon/image-icon.png +0 -0
- data/mod/05_standard/file/favicon/image-large.png +0 -0
- data/mod/05_standard/file/favicon/image-medium.png +0 -0
- data/mod/05_standard/file/favicon/image-original.png +0 -0
- data/mod/05_standard/file/favicon/image-small.png +0 -0
- data/mod/05_standard/lib/carrier_wave/cardmount.rb +8 -2
- data/mod/05_standard/lib/file_uploader.rb +47 -35
- data/mod/05_standard/set/abstract/attachment.rb +87 -35
- data/mod/05_standard/set/all/error.rb +1 -1
- data/mod/05_standard/set/all/links.rb +1 -0
- data/mod/05_standard/set/self/signin.rb +1 -1
- data/mod/05_standard/set/type/file.rb +16 -1
- data/mod/05_standard/set/type/image.rb +2 -0
- data/mod/05_standard/set/type/search_type.rb +2 -2
- data/mod/05_standard/spec/chunk/link_spec.rb +42 -32
- data/mod/05_standard/spec/set/all/links_spec.rb +15 -0
- data/mod/05_standard/spec/set/self/head_spec.rb +3 -3
- data/mod/05_standard/spec/set/type/email_template_spec.rb +39 -39
- data/mod/05_standard/spec/set/type/file_spec.rb +0 -12
- data/mod/05_standard/spec/set/type/image_spec.rb +26 -2
- data/spec/lib/card/content_spec.rb +169 -154
- data/spec/lib/card/format_spec.rb +7 -7
- data/spec/lib/card/success_spec.rb +1 -1
- metadata +7 -6
- data/lib/card/log.rb +0 -545
- data/mod/05_standard/set/self/performance_log.rb +0 -92
- data/spec/lib/card/log_spec.rb +0 -270
@@ -1,92 +0,0 @@
|
|
1
|
-
def log_dir
|
2
|
-
dir = File.join File.dirname(Wagn.paths['log'].existent.first), 'performance'
|
3
|
-
Dir.mkdir dir unless Dir.exists? dir
|
4
|
-
dir
|
5
|
-
end
|
6
|
-
|
7
|
-
def log_path item
|
8
|
-
File.join log_dir, "#{item.gsub('/','_').gsub(/[^0-9A-Za-z.\-]/, '_')}.log"
|
9
|
-
end
|
10
|
-
|
11
|
-
def csv_path
|
12
|
-
File.join log_dir, "#{Card[:performance_log].codename}.csv"
|
13
|
-
end
|
14
|
-
|
15
|
-
def add_log_entry request, html_log
|
16
|
-
time = DateTime.now.utc.strftime "%Y%m%d%H%M%S"
|
17
|
-
name = "%s+%s %s" % [Card[:performance_log].name, time, request.gsub('/','/') ]
|
18
|
-
if Card.fetch name
|
19
|
-
name += 'a'
|
20
|
-
while Card.fetch name
|
21
|
-
name.next!
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
Card::Auth.as_bot do
|
26
|
-
File.open(Card[:performance_log].log_path(name), 'w') {|f| f.puts html_log}
|
27
|
-
Card[:performance_log].add_item! name
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
def add_csv_entry page, wbench_data, runs
|
32
|
-
if !File.exists? csv_path
|
33
|
-
File.open(csv_path, 'w') { |f| f.puts "page,render time, dom loading time, connection time"}
|
34
|
-
end
|
35
|
-
browser = wbench_data.browser
|
36
|
-
runs.times do |i|
|
37
|
-
csv_data = [
|
38
|
-
page,
|
39
|
-
browser['responseEnd'][i] - browser['requestStart'][i],
|
40
|
-
browser['domComplete'][i] - browser['domLoading'][i], # domLoadingTime
|
41
|
-
browser['requestStart'][i], # domLoadingStart
|
42
|
-
]
|
43
|
-
csv_line = CSV.generate_line(csv_data)
|
44
|
-
File.open(csv_path, 'a') { |f| f.puts csv_line }
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
format :html do
|
49
|
-
view :core do |args|
|
50
|
-
wagn_data =
|
51
|
-
card.item_names.map do |item|
|
52
|
-
path = card.log_path item
|
53
|
-
if File.exists? path
|
54
|
-
File.read(path)
|
55
|
-
end
|
56
|
-
end.compact.join "\n"
|
57
|
-
browser_data = CSV.parse(File.read(card.csv_path))
|
58
|
-
output [
|
59
|
-
table(browser_data, true),
|
60
|
-
wagn_data
|
61
|
-
]
|
62
|
-
end
|
63
|
-
|
64
|
-
def table data, with_header=false
|
65
|
-
thead = if with_header
|
66
|
-
content_tag :thead do
|
67
|
-
content_tag :tr do
|
68
|
-
data.shift.map do |item|
|
69
|
-
content_tag :th, item
|
70
|
-
end.join "\n"
|
71
|
-
end
|
72
|
-
end
|
73
|
-
end
|
74
|
-
tbody = content_tag :tbody do
|
75
|
-
data.map do |row|
|
76
|
-
content_tag :tr do
|
77
|
-
row.map do |item|
|
78
|
-
content_tag :td, item
|
79
|
-
end.join "\n"
|
80
|
-
end
|
81
|
-
end.join "\n"
|
82
|
-
end
|
83
|
-
|
84
|
-
%{
|
85
|
-
<table class="table">
|
86
|
-
#{thead}
|
87
|
-
#{tbody}
|
88
|
-
</table>
|
89
|
-
}
|
90
|
-
end
|
91
|
-
end
|
92
|
-
|
data/spec/lib/card/log_spec.rb
DELETED
@@ -1,270 +0,0 @@
|
|
1
|
-
# -*- encoding : utf-8 -*-
|
2
|
-
|
3
|
-
describe Card::Log::Request do
|
4
|
-
before do
|
5
|
-
controller = double()
|
6
|
-
allow(controller).to receive(:env) do
|
7
|
-
hash = {}
|
8
|
-
%w( REMOTE_ADDR REQUEST_METHOD REQUEST_URI HTTP_ACCEPT_LANGUAGE HTTP_REFERER).each do |key|
|
9
|
-
hash[key] = key
|
10
|
-
end
|
11
|
-
hash
|
12
|
-
end
|
13
|
-
card = double()
|
14
|
-
allow(card).to receive(:name) { 'cardname' }
|
15
|
-
allow(controller).to receive(:card) { card }
|
16
|
-
allow(controller).to receive(:action_name) { 'action_name' }
|
17
|
-
allow(controller).to receive(:params) { {'view' => 'view'} }
|
18
|
-
allow(controller).to receive(:status) { 'status' }
|
19
|
-
Card::Log::Request.write_log_entry controller
|
20
|
-
end
|
21
|
-
it 'creates csv file' do
|
22
|
-
expect(File.exist? Card::Log::Request.path).to be_truthy
|
23
|
-
end
|
24
|
-
|
25
|
-
describe 'log file' do
|
26
|
-
subject { File.read Card::Log::Request.path }
|
27
|
-
|
28
|
-
it { is_expected.to include 'REMOTE_ADDR' }
|
29
|
-
it { is_expected.to include 'REQUEST_METHOD' }
|
30
|
-
it { is_expected.to include 'view' }
|
31
|
-
it { is_expected.to include 'status' }
|
32
|
-
it { is_expected.to include 'cardname' }
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
|
37
|
-
describe Card::Log::Performance do
|
38
|
-
def log_method opts
|
39
|
-
Card::Log::Performance.load_config(:methods=>opts)
|
40
|
-
end
|
41
|
-
|
42
|
-
def expect_logger_to_receive_once message
|
43
|
-
allow(Rails.logger).to receive(:info).with(/((?!#{message}).)*/ )
|
44
|
-
expect(Rails.logger).to receive(:info).once.with(message)
|
45
|
-
with_logging { yield }
|
46
|
-
end
|
47
|
-
|
48
|
-
|
49
|
-
def expect_logger_to_receive message
|
50
|
-
allow(Rails.logger).to receive(:info)
|
51
|
-
Array.wrap(message).each do |msg|
|
52
|
-
expect(Rails.logger).to receive(:info).with(msg)
|
53
|
-
end
|
54
|
-
with_logging { yield }
|
55
|
-
end
|
56
|
-
|
57
|
-
def expect_logger_not_to_receive message
|
58
|
-
allow(Rails.logger).to receive(:info)
|
59
|
-
Array.wrap(message).each do |msg|
|
60
|
-
expect(Rails.logger).not_to receive(:info).with(msg)
|
61
|
-
end
|
62
|
-
with_logging { yield }
|
63
|
-
end
|
64
|
-
|
65
|
-
def with_logging
|
66
|
-
Card::Log::Performance.start :method=>'test'
|
67
|
-
yield
|
68
|
-
Card::Log::Performance.stop
|
69
|
-
end
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
it 'creates tree for nested method calls' do
|
74
|
-
log_method [:view]
|
75
|
-
expect_logger_to_receive([
|
76
|
-
/ \|--\([\d.]+ms\) process: c1/,
|
77
|
-
/ \|--\([\d.]+ms\) view\: core/,
|
78
|
-
/ \|--\([\d.]+ms\) view\: raw/,
|
79
|
-
]) do
|
80
|
-
Card['c1'].format.render_core
|
81
|
-
end
|
82
|
-
end
|
83
|
-
|
84
|
-
|
85
|
-
describe 'logger configuration' do
|
86
|
-
|
87
|
-
it 'handles array with method name' do # log arbitrary card method
|
88
|
-
log_method( [:content] )
|
89
|
-
expect_logger_to_receive(/content/) do
|
90
|
-
Card[:all].content
|
91
|
-
end
|
92
|
-
end
|
93
|
-
|
94
|
-
it 'handles instance method type' do
|
95
|
-
class Card
|
96
|
-
def test a, b
|
97
|
-
Rails.logger.info("orignal method is still alive")
|
98
|
-
end
|
99
|
-
def self.test a, b; end
|
100
|
-
end
|
101
|
-
log_method( { Card => { :instance => { :test=> { :title=>:name, :message=>2 }}}} )
|
102
|
-
|
103
|
-
expect_logger_to_receive([/still alive/,/all: magic/]) do
|
104
|
-
Card[:all].test "ignore this argument", "magic"
|
105
|
-
Card.test "you won't", "get this one"
|
106
|
-
end
|
107
|
-
end
|
108
|
-
|
109
|
-
it 'handles classes and singleton method type' do
|
110
|
-
log_method( { Card => { :singleton=>[:fetch] } } )
|
111
|
-
expect_logger_to_receive(/fetch/) do
|
112
|
-
Card.fetch 'A'
|
113
|
-
end
|
114
|
-
end
|
115
|
-
|
116
|
-
it 'handles different class and singleton method type' do
|
117
|
-
log_method( { Cardio => { :singleton=>[:gem_root] } } )
|
118
|
-
expect_logger_to_receive(/gem_root/) do
|
119
|
-
Cardio.gem_root
|
120
|
-
end
|
121
|
-
end
|
122
|
-
|
123
|
-
it 'handles method log options' do
|
124
|
-
log_method( {Card::Set::Type::Skin => {:item_names => {:message=>:raw_content, :title=>"skin item names"}}} )
|
125
|
-
expect_logger_to_receive(/skin item names/) do
|
126
|
-
Card['classic bootstrap skin'].item_names
|
127
|
-
Card['*all+*read'].item_names
|
128
|
-
end
|
129
|
-
end
|
130
|
-
|
131
|
-
# it 'uses default method log options' do
|
132
|
-
# log_method [:fetch]
|
133
|
-
# expect_logger_to_receive( /fetch: all/ ) do
|
134
|
-
# Card.fetch 'all'
|
135
|
-
# end
|
136
|
-
# end
|
137
|
-
|
138
|
-
it 'handles procs and integers for method log options' do # use method arguments and procs to customize log messages
|
139
|
-
log_method( :instance => { :name= => { :title => proc { |method_context| "change name '#{method_context.name}' to"}, :message=>1 } } )
|
140
|
-
expect_logger_to_receive_once(/change name 'c1' to: Alfred/) do
|
141
|
-
Card['c1'].name = 'Alfred'
|
142
|
-
end
|
143
|
-
end
|
144
|
-
|
145
|
-
|
146
|
-
describe 'special methods' do
|
147
|
-
# FIXME: this test fails because of the logging stuff above. Need a way to reset the Card class or use test classes in all tests
|
148
|
-
# it "doesn't log special methods if disabled" do
|
149
|
-
# log_method []
|
150
|
-
# expect(Rails.logger).to receive(:wagn).with(/test/).once
|
151
|
-
# with_logging do
|
152
|
-
# Card::Auth.as_bot { Card.fetch('c1').update_attributes!(:content=>'c1') }
|
153
|
-
# Card.search :name=>'all'
|
154
|
-
# Card[:all].format.render_raw
|
155
|
-
# end
|
156
|
-
# end
|
157
|
-
|
158
|
-
it 'logs searches if enabled' do
|
159
|
-
log_method [:search]
|
160
|
-
expect_logger_to_receive( /search:/ ) do
|
161
|
-
Card.search :name=>'all'
|
162
|
-
end
|
163
|
-
end
|
164
|
-
|
165
|
-
it 'logs views if enabled' do
|
166
|
-
log_method [:view]
|
167
|
-
expect_logger_to_receive([/process: \*all/, /view:/ ] ) do
|
168
|
-
Card[:all].format.render_raw
|
169
|
-
end
|
170
|
-
end
|
171
|
-
|
172
|
-
it 'logs events if enabled' do
|
173
|
-
log_method [:event]
|
174
|
-
expect_logger_to_receive([/process: c1/, / \|--\([\d.]+ms\) event:/] ) do
|
175
|
-
Card::Auth.as_bot { Card.fetch('c1').update_attributes!(:content=>'c1') }
|
176
|
-
end
|
177
|
-
end
|
178
|
-
|
179
|
-
|
180
|
-
end
|
181
|
-
|
182
|
-
end
|
183
|
-
|
184
|
-
describe Card::Log::Performance::BigBrother do
|
185
|
-
before do
|
186
|
-
class TestClass
|
187
|
-
extend Card::Log::Performance::BigBrother
|
188
|
-
def inst_m; end
|
189
|
-
def self.sing_m; end
|
190
|
-
end
|
191
|
-
end
|
192
|
-
|
193
|
-
|
194
|
-
describe '#watch_singleton_method' do
|
195
|
-
before do
|
196
|
-
TestClass.watch_singleton_method :sing_m
|
197
|
-
end
|
198
|
-
|
199
|
-
it 'logs singleton method' do
|
200
|
-
expect_logger_to_receive_once(/sing_m/) do
|
201
|
-
TestClass.sing_m
|
202
|
-
end
|
203
|
-
end
|
204
|
-
|
205
|
-
it 'does not log instance method' do
|
206
|
-
expect_logger_not_to_receive(/inst_,/) do
|
207
|
-
TestClass.new.inst_m
|
208
|
-
end
|
209
|
-
end
|
210
|
-
end
|
211
|
-
|
212
|
-
describe '#watch_instance_method' do
|
213
|
-
before do
|
214
|
-
TestClass.watch_instance_method :inst_m
|
215
|
-
end
|
216
|
-
|
217
|
-
it 'logs instance method' do
|
218
|
-
expect_logger_to_receive_once(/inst_m/) do
|
219
|
-
TestClass.new.inst_m
|
220
|
-
end
|
221
|
-
end
|
222
|
-
|
223
|
-
it 'does not log singleton method' do
|
224
|
-
expect_logger_not_to_receive(/sing_m/) do
|
225
|
-
TestClass.sing_m
|
226
|
-
end
|
227
|
-
end
|
228
|
-
end
|
229
|
-
|
230
|
-
|
231
|
-
describe '#watch_all_singleton_methods' do
|
232
|
-
before do
|
233
|
-
TestClass.watch_all_singleton_methods
|
234
|
-
end
|
235
|
-
it 'logs singleton method' do
|
236
|
-
expect_logger_to_receive(/sing_m/) do
|
237
|
-
TestClass.sing_m
|
238
|
-
end
|
239
|
-
end
|
240
|
-
end
|
241
|
-
|
242
|
-
describe 'watch_all_instance_methods' do
|
243
|
-
before do
|
244
|
-
TestClass.watch_all_instance_methods
|
245
|
-
end
|
246
|
-
|
247
|
-
it 'logs instance method' do
|
248
|
-
expect_logger_to_receive(/inst_m/) do
|
249
|
-
TestClass.new.inst_m
|
250
|
-
end
|
251
|
-
end
|
252
|
-
end
|
253
|
-
|
254
|
-
describe '#watch_all_methods' do
|
255
|
-
before do
|
256
|
-
TestClass.watch_all_methods
|
257
|
-
end
|
258
|
-
|
259
|
-
it 'logs instance and singleton methods' do
|
260
|
-
expect_logger_to_receive([/inst_m/,/sing_m/]) do
|
261
|
-
TestClass.new.inst_m
|
262
|
-
TestClass.sing_m
|
263
|
-
end
|
264
|
-
end
|
265
|
-
end
|
266
|
-
|
267
|
-
end
|
268
|
-
|
269
|
-
|
270
|
-
end
|