wagn 1.14.6 → 1.14.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (56) hide show
  1. checksums.yaml +4 -4
  2. data/VERSION +1 -1
  3. data/app/controllers/card_controller.rb +15 -25
  4. data/lib/card/format.rb +30 -20
  5. data/lib/card/generators/set/USAGE +10 -3
  6. data/lib/card/generators/set/set_generator.rb +14 -6
  7. data/lib/card/generators/set/templates/set_spec_template.erb +1 -1
  8. data/lib/card/set.rb +3 -2
  9. data/lib/wagn.rb +7 -8
  10. data/lib/wagn/config/environments/development.rb +8 -0
  11. data/lib/wagn/generators/wagn/templates/Gemfile +1 -0
  12. data/lib/wagn/log.rb +224 -55
  13. data/mod/01_core/set/all/collection.rb +1 -1
  14. data/mod/01_core/set/all/fetch.rb +1 -1
  15. data/mod/01_core/set/all/notify.rb +3 -3
  16. data/mod/01_core/spec/format/html_format_spec.rb +0 -25
  17. data/mod/{05_standard → 02_basic_types}/format/css_format.rb +0 -0
  18. data/mod/{05_standard → 02_basic_types}/format/csv_format.rb +0 -0
  19. data/mod/{05_standard → 02_basic_types}/format/file_format.rb +0 -0
  20. data/mod/{05_standard → 02_basic_types}/format/js_format.rb +0 -0
  21. data/mod/{05_standard → 02_basic_types}/format/json_format.rb +0 -0
  22. data/mod/{05_standard → 02_basic_types}/format/rss_format.rb +0 -0
  23. data/mod/{05_standard → 02_basic_types}/format/xml_format.rb +0 -0
  24. data/mod/{05_standard → 02_basic_types}/set/all/all_css.rb +0 -0
  25. data/mod/{05_standard → 02_basic_types}/set/all/all_csv.rb +0 -0
  26. data/mod/{05_standard → 02_basic_types}/set/all/all_js.rb +0 -0
  27. data/mod/{05_standard → 02_basic_types}/set/all/base.rb +26 -20
  28. data/mod/{05_standard → 02_basic_types}/set/all/file.rb +0 -0
  29. data/mod/{05_standard → 02_basic_types}/set/all/json.rb +0 -0
  30. data/mod/{05_standard → 02_basic_types}/set/all/rss.rb +0 -0
  31. data/mod/{05_standard → 02_basic_types}/set/all/text.rb +0 -0
  32. data/mod/02_basic_types/set/type/pointer.rb +0 -1
  33. data/mod/{05_standard → 02_basic_types}/spec/set/all/all_css_spec.rb +0 -0
  34. data/mod/{05_standard → 02_basic_types}/spec/set/all/all_csv_spec.rb +0 -0
  35. data/mod/{05_standard → 02_basic_types}/spec/set/all/base_spec.rb +0 -0
  36. data/mod/{05_standard → 02_basic_types}/spec/set/all/file_spec.rb +0 -0
  37. data/mod/{05_standard → 02_basic_types}/spec/set/all/json_spec.rb +0 -0
  38. data/mod/{05_standard → 02_basic_types}/spec/set/all/rss_spec.rb +0 -0
  39. data/mod/{05_standard → 02_basic_types}/spec/set/all/text_spec.rb +0 -0
  40. data/mod/02_basic_types/spec/set/{plain_text_spec.rb → type/plain_text_spec.rb} +0 -0
  41. data/mod/02_basic_types/spec/set/{pointer_spec.rb → type/pointer_spec.rb} +0 -0
  42. data/mod/03_machines/lib/javascript/jquery-ui.js +11264 -12933
  43. data/mod/03_machines/lib/stylesheets/jquery-ui-smoothness.css +1 -1
  44. data/mod/03_machines/set/self/script_jquery_helper.rb +2 -1
  45. data/mod/05_standard/set/all/account.rb +1 -1
  46. data/mod/05_standard/set/all/error.rb +11 -4
  47. data/mod/05_standard/set/all/{rich_html.rb → rich_html/content.rb} +0 -0
  48. data/mod/05_standard/set/all/{editing.rb → rich_html/editing.rb} +0 -0
  49. data/mod/05_standard/set/all/{form.rb → rich_html/form.rb} +0 -0
  50. data/mod/05_standard/set/all/{header.rb → rich_html/header.rb} +4 -6
  51. data/mod/05_standard/set/all/{wrapper.rb → rich_html/wrapper.rb} +0 -0
  52. data/mod/05_standard/spec/set/all/error_spec.rb +7 -0
  53. data/mod/05_standard/spec/set/all/{rich_html_spec.rb → rich_html/form_spec.rb} +2 -10
  54. data/mod/05_standard/spec/set/all/rich_html/wrapper_spec.rb +26 -0
  55. data/spec/lib/wagn/log_spec.rb +101 -0
  56. metadata +36 -32
@@ -1175,4 +1175,4 @@ body .ui-tooltip {
1175
1175
  opacity: .3;
1176
1176
  filter: Alpha(Opacity=30);
1177
1177
  border-radius: 8px;
1178
- }
1178
+ }
@@ -2,7 +2,8 @@
2
2
  view :raw do |args|
3
3
  # jquery.ui.all must be after jquery.mobile to override dialog weirdness *
4
4
  # jquery.ui.autocomplete must be after jquery.ui stuff
5
- js_files = %w( jquerymobile.js jquery-ui.js jquery.ui.autocomplete.html.js jquery.autosize.js jquery.fileupload.js jquery.iframe-transport.js jquery_ujs.js )
5
+ # FIXME removed jquerymobile.js. Doesn't work with the new jquery version
6
+ js_files = %w( jquery-ui.js jquery.ui.autocomplete.html.js jquery.autosize.js jquery.fileupload.js jquery.iframe-transport.js jquery_ujs.js )
6
7
  js_files.map do |filename|
7
8
  File.read "#{Wagn.gem_root}/mod/03_machines/lib/javascript/#{filename}"
8
9
  end.join("\n")
@@ -57,7 +57,7 @@ end
57
57
 
58
58
 
59
59
  event :generate_token do
60
- Digest::SHA1.hexdigest "--#{Time.now.to_s}--#{rand 10}--"
60
+ Digest::SHA1.hexdigest "--#{Time.now.to_f}--#{rand 10}--"
61
61
  end
62
62
 
63
63
  event :set_stamper, :before=>:approve do
@@ -1,6 +1,13 @@
1
+
2
+
1
3
  format do
2
- view :closed_missing, :perms=>:none do |args| '' end
3
- view :missing, :perms=>:none do |args| '' end
4
+ view :closed_missing, :perms=>:none, :closed=>true do |args|
5
+ ''
6
+ end
7
+
8
+ view :missing, :perms=>:none do |args|
9
+ ''
10
+ end
4
11
 
5
12
  view :not_found, :perms=>:none, :error_code=>404 do |args|
6
13
  %{ Could not find #{card.name.present? ? %{"#{card.name}"} : 'the card requested'}. }
@@ -19,11 +26,11 @@ format do
19
26
  %{ 404: Bad Address }
20
27
  end
21
28
 
22
- view :too_deep, :perms=>:none do |args|
29
+ view :too_deep, :perms=>:none, :closed=>true do |args|
23
30
  %{ Man, you're too deep. (Too many levels of inclusions at a time) }
24
31
  end
25
32
 
26
- view :too_slow, :perms=>:none do |args|
33
+ view :too_slow, :perms=>:none, :closed=>true do |args|
27
34
  %{ Timed out! #{ showname } took too long to load. }
28
35
  end
29
36
  end
@@ -1,6 +1,6 @@
1
1
  format :html do
2
2
 
3
- view :toggle do |args|
3
+ view :toggle, :perms=>:none, :closed=>true do |args|
4
4
  verb, adjective, direction = ( args[:toggle_mode] == :close ? %w{ open open e } : %w{ close closed s } )
5
5
 
6
6
  view_link '', adjective, :title => "#{verb} #{card.name}",
@@ -18,7 +18,7 @@ format :html do
18
18
  }
19
19
  end
20
20
 
21
- view :menu, :tags=>:unknown_ok do |args|
21
+ view :menu, :tags=>:unknown_ok, :perms=>:none, :closed=>true do |args|
22
22
  return _render_template_closer if args[:menu_hack] == :template_closer
23
23
  disc_tagname = Card.fetch(:discussion, :skip_modules=>true).cardname
24
24
  disc_card = unless card.new_card? or card.junction? && card.cardname.tag_name.key == disc_tagname.key
@@ -51,10 +51,8 @@ format :html do
51
51
  %{<span class="card-menu-link" data-menu-vars='#{json}'>#{_render_menu_link}</span>}
52
52
  end
53
53
 
54
- view :menu_link do |args|
54
+ view :menu_link, :closed=>true, :perms=>:none do |args|
55
55
  '<a class="ui-icon ui-icon-gear"></a>'
56
56
  end
57
57
 
58
-
59
-
60
- end
58
+ end
@@ -0,0 +1,7 @@
1
+ describe Card::Set::All::Error do
2
+ describe 'missing view' do
3
+ it "should prompt to add" do
4
+ expect(render_content('{{+cardipoo|open}}').match(/Add \<span/ )).not_to be_nil
5
+ end
6
+ end
7
+ end
@@ -1,12 +1,4 @@
1
- # -*- encoding : utf-8 -*-
2
-
3
- describe Card::Set::All::RichHtml do
4
- describe 'missing view' do
5
- it "should prompt to add" do
6
- expect(render_content('{{+cardipoo|open}}').match(/Add \<span/ )).not_to be_nil
7
- end
8
- end
9
-
1
+ describe Card::Set::All::RichHtml::Form do
10
2
  describe "type_list" do
11
3
  before do
12
4
  @card = Card['UserForm'] # no cards with this type
@@ -46,4 +38,4 @@ describe Card::Set::All::RichHtml do
46
38
  expect(no_edit_card.format.render_type).to match(/<a[^>]* class="([^"]*)?\bno-edit\b[^"]*"/)
47
39
  end
48
40
  end
49
- end
41
+ end
@@ -0,0 +1,26 @@
1
+ describe Card::Set::All::RichHtml::Wrapper do
2
+ context "full wrapping" do
3
+ before do
4
+ @ocslot = Card['A'].format
5
+ end
6
+
7
+ it "should have the appropriate attributes on open" do
8
+ assert_view_select @ocslot.render(:open), 'div[class="card-slot open-view card-frame ALL TYPE-basic SELF-a"]' do
9
+ assert_select 'h1[class="card-header"]' do
10
+ assert_select 'span[class="card-title"]'
11
+ end
12
+ assert_select 'div[class~="card-body"]'
13
+ end
14
+ end
15
+
16
+ it "should have the appropriate attributes on closed" do
17
+ v = @ocslot.render(:closed)
18
+ assert_view_select v, 'div[class="card-slot closed-view card-frame ALL TYPE-basic SELF-a"]' do
19
+ assert_select 'h1[class="card-header"]' do
20
+ assert_select 'span[class="card-title"]'
21
+ end
22
+ assert_select 'div[class~="closed-content card-content"]'
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,101 @@
1
+ describe Wagn::Log::Request do
2
+ before do
3
+ controller = double()
4
+ allow(controller).to receive(:env) do
5
+ hash = {}
6
+ %w( REMOTE_ADDR REQUEST_METHOD REQUEST_URI HTTP_ACCEPT_LANGUAGE HTTP_REFERER).each do |key|
7
+ hash[key] = key
8
+ end
9
+ hash
10
+ end
11
+ card = double()
12
+ allow(card).to receive(:name) { 'cardname' }
13
+ allow(controller).to receive(:card) { card }
14
+ allow(controller).to receive(:action_name) { 'action_name' }
15
+ allow(controller).to receive(:params) { {'view' => 'view'} }
16
+ allow(controller).to receive(:status) { 'status' }
17
+ Wagn::Log::Request.write_log_entry controller
18
+ end
19
+ it 'creates csv file' do
20
+ expect(File.exist? Wagn::Log::Request.path).to be_truthy
21
+ end
22
+
23
+ describe 'log file' do
24
+ subject { File.read Wagn::Log::Request.path }
25
+
26
+ it { is_expected.to include 'REMOTE_ADDR' }
27
+ it { is_expected.to include 'REQUEST_METHOD' }
28
+ it { is_expected.to include 'view' }
29
+ it { is_expected.to include 'status' }
30
+ it { is_expected.to include 'cardname' }
31
+ end
32
+ end
33
+
34
+
35
+ describe Wagn::Log::Performance do
36
+ def test_log
37
+ Wagn::Log::Performance.start :method=>'test'
38
+ yield
39
+ Wagn::Log::Performance.stop
40
+ end
41
+
42
+ it 'logs searches if enabled' do
43
+ Wagn.config.performance_logger = { :methods=>[:search]}
44
+ expect(Rails.logger).to receive(:wagn).with(/test/).once
45
+ expect(Rails.logger).to receive(:wagn).with(/search\:/).at_least(1)
46
+ test_log do
47
+ Card.search :name=>'all'
48
+ end
49
+ end
50
+
51
+ it 'logs fetches if enabled' do
52
+ Wagn.config.performance_logger = { :methods=>[:fetch] }
53
+ expect(Rails.logger).to receive(:wagn).with(/test/).once
54
+ expect(Rails.logger).to receive(:wagn).with(/fetch/).at_least(1)
55
+ test_log do
56
+ Card.fetch 'all'
57
+ end
58
+ end
59
+
60
+ it 'logs views if enabled' do
61
+ Wagn.config.performance_logger = { :methods=>[:view]}
62
+ expect(Rails.logger).to receive(:wagn).with(/test/).once
63
+ expect(Rails.logger).to receive(:wagn).with(/process: \*all/)
64
+ expect(Rails.logger).to receive(:wagn).with(/view\:/)
65
+ test_log do
66
+ Card[:all].format.render_raw
67
+ end
68
+ end
69
+
70
+ it 'logs events if enabled' do
71
+ Wagn.config.performance_logger = { :methods=>[:event]}
72
+ expect(Rails.logger).to receive(:wagn).with(/test/).once
73
+ expect(Rails.logger).to receive(:wagn).with(/process: c1/).once
74
+ expect(Rails.logger).to receive(:wagn).at_least(1).with(/ \|--\([\d.]+ms\) event\:/)
75
+ test_log do
76
+ Card::Auth.as_bot { Card.fetch('c1').update_attributes!(:content=>'c1') }
77
+ end
78
+ end
79
+
80
+ it "doesn't log methods if disabled" do
81
+ Wagn.config.performance_logger = { :methods=>[]}
82
+ expect(Rails.logger).to receive(:wagn).with(/test/).once
83
+ test_log do
84
+ Card::Auth.as_bot { Card.fetch('c1').update_attributes!(:content=>'c1') }
85
+ Card.search :name=>'all'
86
+ Card.fetch 'all'
87
+ Card[:all].format.render_raw
88
+ end
89
+ end
90
+
91
+ it 'creates tree for nested method calls' do
92
+ Wagn.config.performance_logger = { :methods=>[:view]}
93
+ expect(Rails.logger).to receive(:wagn).with(/test/).once
94
+ expect(Rails.logger).to receive(:wagn).with(/ \|--\([\d.]+ms\) process: c1/)
95
+ expect(Rails.logger).to receive(:wagn).with(/ \|--\([\d.]+ms\) view\: core/)
96
+ expect(Rails.logger).to receive(:wagn).with(/ \|--\([\d.]+ms\) view\: raw/)
97
+ test_log do
98
+ Card['c1'].format.render_core
99
+ end
100
+ end
101
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wagn
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.14.6
4
+ version: 1.14.7
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: 2015-01-20 00:00:00.000000000 Z
13
+ date: 2015-01-26 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rails
@@ -531,10 +531,32 @@ files:
531
531
  - mod/01_core/spec/set/all/trash_spec.rb
532
532
  - mod/01_core/spec/set/all/type_spec.rb
533
533
  - mod/01_core/spec/set/all/utils_spec.rb
534
+ - mod/02_basic_types/format/css_format.rb
535
+ - mod/02_basic_types/format/csv_format.rb
536
+ - mod/02_basic_types/format/file_format.rb
537
+ - mod/02_basic_types/format/js_format.rb
538
+ - mod/02_basic_types/format/json_format.rb
539
+ - mod/02_basic_types/format/rss_format.rb
540
+ - mod/02_basic_types/format/xml_format.rb
541
+ - mod/02_basic_types/set/all/all_css.rb
542
+ - mod/02_basic_types/set/all/all_csv.rb
543
+ - mod/02_basic_types/set/all/all_js.rb
544
+ - mod/02_basic_types/set/all/base.rb
545
+ - mod/02_basic_types/set/all/file.rb
546
+ - mod/02_basic_types/set/all/json.rb
547
+ - mod/02_basic_types/set/all/rss.rb
548
+ - mod/02_basic_types/set/all/text.rb
534
549
  - mod/02_basic_types/set/type/plain_text.rb
535
550
  - mod/02_basic_types/set/type/pointer.rb
536
- - mod/02_basic_types/spec/set/plain_text_spec.rb
537
- - mod/02_basic_types/spec/set/pointer_spec.rb
551
+ - mod/02_basic_types/spec/set/all/all_css_spec.rb
552
+ - mod/02_basic_types/spec/set/all/all_csv_spec.rb
553
+ - mod/02_basic_types/spec/set/all/base_spec.rb
554
+ - mod/02_basic_types/spec/set/all/file_spec.rb
555
+ - mod/02_basic_types/spec/set/all/json_spec.rb
556
+ - mod/02_basic_types/spec/set/all/rss_spec.rb
557
+ - mod/02_basic_types/spec/set/all/text_spec.rb
558
+ - mod/02_basic_types/spec/set/type/plain_text_spec.rb
559
+ - mod/02_basic_types/spec/set/type/pointer_spec.rb
538
560
  - mod/03_machines/lib/card/machine.rb
539
561
  - mod/03_machines/lib/card/machine_input.rb
540
562
  - mod/03_machines/lib/javascript/ace.js
@@ -655,35 +677,20 @@ files:
655
677
  - mod/05_standard/file/790/medium-6419.png
656
678
  - mod/05_standard/file/790/original-6419.png
657
679
  - mod/05_standard/file/790/small-6419.png
658
- - mod/05_standard/format/css_format.rb
659
- - mod/05_standard/format/csv_format.rb
660
- - mod/05_standard/format/file_format.rb
661
- - mod/05_standard/format/js_format.rb
662
- - mod/05_standard/format/json_format.rb
663
- - mod/05_standard/format/rss_format.rb
664
- - mod/05_standard/format/xml_format.rb
665
680
  - mod/05_standard/set/all/account.rb
666
- - mod/05_standard/set/all/all_css.rb
667
- - mod/05_standard/set/all/all_csv.rb
668
- - mod/05_standard/set/all/all_js.rb
669
681
  - mod/05_standard/set/all/attach.rb
670
- - mod/05_standard/set/all/base.rb
671
682
  - mod/05_standard/set/all/comment.rb
672
- - mod/05_standard/set/all/editing.rb
673
683
  - mod/05_standard/set/all/error.rb
674
684
  - mod/05_standard/set/all/event_viz.rb
675
- - mod/05_standard/set/all/file.rb
676
685
  - mod/05_standard/set/all/follow.rb
677
- - mod/05_standard/set/all/form.rb
678
- - mod/05_standard/set/all/header.rb
679
686
  - mod/05_standard/set/all/history.rb
680
- - mod/05_standard/set/all/json.rb
681
687
  - mod/05_standard/set/all/links.rb
682
688
  - mod/05_standard/set/all/observer.rb
683
- - mod/05_standard/set/all/rich_html.rb
684
- - mod/05_standard/set/all/rss.rb
685
- - mod/05_standard/set/all/text.rb
686
- - mod/05_standard/set/all/wrapper.rb
689
+ - mod/05_standard/set/all/rich_html/content.rb
690
+ - mod/05_standard/set/all/rich_html/editing.rb
691
+ - mod/05_standard/set/all/rich_html/form.rb
692
+ - mod/05_standard/set/all/rich_html/header.rb
693
+ - mod/05_standard/set/all/rich_html/wrapper.rb
687
694
  - mod/05_standard/set/right/account.rb
688
695
  - mod/05_standard/set/right/email.rb
689
696
  - mod/05_standard/set/right/password.rb
@@ -732,21 +739,16 @@ files:
732
739
  - mod/05_standard/spec/format/rss_format_spec.rb
733
740
  - mod/05_standard/spec/format/xml_format_spec.rb
734
741
  - mod/05_standard/spec/set/all/account_spec.rb
735
- - mod/05_standard/spec/set/all/all_css_spec.rb
736
- - mod/05_standard/spec/set/all/all_csv_spec.rb
737
742
  - mod/05_standard/spec/set/all/attach_spec.rb
738
- - mod/05_standard/spec/set/all/base_spec.rb
739
743
  - mod/05_standard/spec/set/all/comment_spec.rb
740
744
  - mod/05_standard/spec/set/all/email_html_spec.rb
745
+ - mod/05_standard/spec/set/all/error_spec.rb
741
746
  - mod/05_standard/spec/set/all/event_viz_spec.rb
742
- - mod/05_standard/spec/set/all/file_spec.rb
743
747
  - mod/05_standard/spec/set/all/follow_spec.rb
744
748
  - mod/05_standard/spec/set/all/history_spec.rb
745
- - mod/05_standard/spec/set/all/json_spec.rb
746
749
  - mod/05_standard/spec/set/all/observer_spec.rb
747
- - mod/05_standard/spec/set/all/rich_html_spec.rb
748
- - mod/05_standard/spec/set/all/rss_spec.rb
749
- - mod/05_standard/spec/set/all/text_spec.rb
750
+ - mod/05_standard/spec/set/all/rich_html/form_spec.rb
751
+ - mod/05_standard/spec/set/all/rich_html/wrapper_spec.rb
750
752
  - mod/05_standard/spec/set/right/account_spec.rb
751
753
  - mod/05_standard/spec/set/right/email_spec.rb
752
754
  - mod/05_standard/spec/set/right/password_spec.rb
@@ -1353,6 +1355,7 @@ files:
1353
1355
  - spec/lib/card/set_pattern_spec.rb
1354
1356
  - spec/lib/card/set_spec.rb
1355
1357
  - spec/lib/wagn/cache_spec.rb
1358
+ - spec/lib/wagn/log_spec.rb
1356
1359
  - spec/mailers/mailer_spec.rb
1357
1360
  - spec/models/card/cardtype_spec.rb
1358
1361
  - spec/models/card/create_spec.rb
@@ -1450,6 +1453,7 @@ test_files:
1450
1453
  - spec/lib/card/set_pattern_spec.rb
1451
1454
  - spec/lib/card/set_spec.rb
1452
1455
  - spec/lib/wagn/cache_spec.rb
1456
+ - spec/lib/wagn/log_spec.rb
1453
1457
  - spec/mailers/mailer_spec.rb
1454
1458
  - spec/models/card/cardtype_spec.rb
1455
1459
  - spec/models/card/create_spec.rb