wagn 1.13.0.pre1 → 1.13.0.pre2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (91) hide show
  1. checksums.yaml +4 -4
  2. data/VERSION +1 -1
  3. data/app/controllers/card_controller.rb +3 -3
  4. data/db/migrate_cards/20140307231621_user_data_to_cards.rb +5 -1
  5. data/lib/card.rb +5 -7
  6. data/lib/card/chunk.rb +1 -0
  7. data/lib/card/codename.rb +48 -31
  8. data/lib/card/env.rb +0 -1
  9. data/lib/card/exceptions.rb +3 -3
  10. data/lib/card/format.rb +89 -166
  11. data/lib/card/generators/set/USAGE +1 -1
  12. data/lib/card/loader.rb +1 -1
  13. data/lib/card/set.rb +196 -112
  14. data/lib/card/set_pattern.rb +37 -71
  15. data/lib/wagn/cache.rb +8 -7
  16. data/lib/wagn/commands.rb +1 -1
  17. data/lib/wagn/config/environments/development.rb +1 -1
  18. data/lib/wagn/config/initializers/paperclip.rb +1 -0
  19. data/lib/wagn/generators/wagn/templates/Gemfile +59 -55
  20. data/lib/wagn/location.rb +2 -2
  21. data/mods/core/formats/html_format.rb +2 -6
  22. data/mods/core/formats/text_format.rb +1 -1
  23. data/mods/core/set_patterns/01_all.rb +0 -5
  24. data/mods/core/set_patterns/02_all_plus.rb +1 -3
  25. data/mods/core/set_patterns/07_type_plus_right.rb +0 -1
  26. data/mods/core/sets/all/active_card.rb +1 -1
  27. data/mods/core/sets/all/name.rb +3 -2
  28. data/mods/core/sets/all/pattern.rb +9 -23
  29. data/mods/core/sets/all/phases.rb +27 -13
  30. data/mods/core/sets/all/rules.rb +3 -3
  31. data/mods/core/sets/all/templating.rb +5 -2
  32. data/mods/core/sets/all/tracked_attributes.rb +2 -1
  33. data/mods/core/sets/right/structure.rb +13 -0
  34. data/mods/{standard → core}/sets/type/plain_text.rb +0 -0
  35. data/mods/standard/formats/email_html_format.rb +1 -1
  36. data/mods/standard/lib/card/machine.rb +16 -12
  37. data/mods/standard/lib/card/machine_input.rb +1 -1
  38. data/mods/standard/sets/all/attach.rb +1 -1
  39. data/mods/standard/sets/all/base.rb +92 -94
  40. data/mods/standard/sets/all/follow.rb +1 -1
  41. data/mods/standard/sets/all/rich_html.rb +5 -3
  42. data/mods/standard/sets/all/rss.rb +12 -5
  43. data/mods/standard/sets/right/account.rb +1 -1
  44. data/mods/standard/sets/right/add_help.rb +3 -1
  45. data/mods/standard/sets/right/comment.rb +92 -3
  46. data/mods/standard/sets/right/create.rb +2 -87
  47. data/mods/standard/sets/right/default.rb +3 -2
  48. data/mods/standard/sets/right/delete.rb +2 -5
  49. data/mods/standard/sets/right/help.rb +3 -1
  50. data/mods/standard/sets/right/machine_output.rb +9 -7
  51. data/mods/standard/sets/right/read.rb +2 -5
  52. data/mods/standard/sets/right/style.rb +3 -2
  53. data/mods/standard/sets/right/update.rb +2 -5
  54. data/mods/standard/sets/rstar/rules.rb +0 -2
  55. data/mods/standard/sets/self/head.rb +2 -3
  56. data/mods/standard/sets/self/navbox.rb +0 -7
  57. data/mods/standard/sets/self/recent.rb +2 -2
  58. data/mods/standard/sets/self/search.rb +10 -3
  59. data/mods/standard/sets/self/signin.rb +3 -3
  60. data/mods/standard/sets/type/cardtype.rb +2 -2
  61. data/mods/standard/sets/type/coffee_script.rb +4 -4
  62. data/mods/standard/sets/type/css.rb +12 -4
  63. data/mods/standard/sets/type/image.rb +19 -19
  64. data/mods/standard/sets/type/java_script.rb +1 -1
  65. data/mods/standard/sets/type/layout_type.rb +3 -2
  66. data/mods/standard/sets/type/pointer.rb +3 -2
  67. data/mods/standard/sets/type/scss.rb +6 -34
  68. data/mods/standard/sets/type/search_type.rb +22 -16
  69. data/mods/standard/sets/type/set.rb +2 -2
  70. data/mods/standard/sets/type/setting.rb +2 -2
  71. data/mods/standard/sets/type/skin.rb +4 -18
  72. data/spec/controllers/card_controller_spec.rb +2 -2
  73. data/spec/lib/card/flexmail_spec.rb +1 -0
  74. data/spec/lib/card/format_spec.rb +9 -9
  75. data/spec/lib/card/loader_spec.rb +1 -2
  76. data/spec/lib/card/name_spec.rb +7 -1
  77. data/spec/lib/card/set_pattern_spec.rb +5 -5
  78. data/spec/mods/core/sets/all/pattern_spec.rb +0 -9
  79. data/spec/mods/core/sets/all/phases_spec.rb +2 -1
  80. data/spec/mods/standard/lib/machine_input_spec.rb +20 -4
  81. data/spec/mods/standard/lib/machine_spec.rb +64 -14
  82. data/spec/mods/standard/sets/right/machine_output_spec.rb +2 -17
  83. data/spec/mods/standard/sets/right/script_spec.rb +9 -5
  84. data/spec/mods/standard/sets/right/style_spec.rb +11 -5
  85. data/spec/mods/standard/sets/type/coffeescript_spec.rb +5 -7
  86. data/spec/mods/standard/sets/type/css_spec.rb +3 -4
  87. data/spec/mods/standard/sets/type/javascript_spec.rb +3 -5
  88. data/spec/mods/standard/sets/type/scss_spec.rb +4 -7
  89. data/spec/mods/standard/sets/type/skin_spec.rb +29 -8
  90. metadata +5 -4
  91. data/mods/standard/sets/right/structure.rb +0 -12
data/lib/wagn/cache.rb CHANGED
@@ -59,6 +59,14 @@ module Wagn
59
59
  Card.delete_tmp_files
60
60
  end
61
61
 
62
+ def reset_local
63
+ cache_by_class.each do |cc, cache|
64
+ if Wagn::Cache===cache
65
+ cache.reset_local
66
+ else warn "reset class #{cc}, #{cache.class} #{caller[0..8]*"\n"} ???" end
67
+ end
68
+ end
69
+
62
70
  private
63
71
 
64
72
  def prepopulate
@@ -71,13 +79,6 @@ module Wagn
71
79
  end
72
80
 
73
81
 
74
- def reset_local
75
- cache_by_class.each do |cc, cache|
76
- if Wagn::Cache===cache
77
- cache.reset_local
78
- else warn "reset class #{cc}, #{cache.class} #{caller[0..8]*"\n"} ???" end
79
- end
80
- end
81
82
 
82
83
  end
83
84
 
data/lib/wagn/commands.rb CHANGED
@@ -42,7 +42,7 @@ else
42
42
  end
43
43
  when 'update'
44
44
  load_rake_tasks
45
- Rake::Taske['wagn:update'].invoke
45
+ Rake::Task['wagn:update'].invoke
46
46
  when 'cucumber'
47
47
  system "RAILS_ROOT=. bundle exec cucumber #{ ARGV.join(' ') }"
48
48
  when 'rspec'
@@ -7,7 +7,7 @@ Wagn.application.class.configure do
7
7
  # every request. This slows down response time but is perfect for development
8
8
  # since you don't have to restart the web server when you make code changes.
9
9
  config.cache_classes = false
10
-
10
+
11
11
  # Log error messages when you accidentally call methods on nil.
12
12
  config.whiny_nils = true
13
13
 
@@ -0,0 +1 @@
1
+ Paperclip::Attachment.default_options[:use_timestamp] = false
@@ -5,68 +5,72 @@ gem 'wagn'<%= ", :path=>'#{@wagn_path}'" if @wagn_path.present? %>
5
5
  <%= database_gemfile_entry -%>
6
6
 
7
7
  <% if options['mod-dev'] %>
8
+
9
+ group :test do
8
10
  gem 'rspec-rails', "~> 2.6" # behavior-driven-development suite
9
11
  gem 'spork', '>=0.9'
12
+ end
13
+
10
14
  <% end %>
11
-
12
15
  <% if options['core-dev'] %>
13
- group :assets do
14
- gem 'jquery-rails', '~> 3.1' # main js framework, along with rails-specific unobtrusive lib
15
- gem 'jquery-ui-rails', '~> 4.2' # main js framework, along with rails-specific unobtrusive lib
16
- gem "jquery_mobile_rails", "~> 1.4.1"
17
-
18
- gem 'tinymce-rails', '~> 3.4' # wysiwyg editor
19
-
20
- # execjs is necessary for developing coffeescript. mac users have execjs built-in; don't need this one
21
- gem 'therubyrhino', :platform=>:ruby # :ruby is MRI rubies, so if you use a mac ruby ...
22
- end
23
16
 
17
+ group :assets do
18
+ gem 'jquery-rails', '~> 3.1' # main js framework, along with rails-specific unobtrusive lib
19
+ gem 'jquery-ui-rails', '~> 4.2' # main js framework, along with rails-specific unobtrusive lib
20
+ gem "jquery_mobile_rails", "~> 1.4.1"
24
21
 
25
- group :test do
26
- gem 'simplecov', '~> 0.7.1', :require => false #test coverage
27
-
28
- # SPECS see spec dir
29
- gem 'rspec-rails', "~> 2.6" # behavior-driven-development suite
30
-
31
- gem 'guard-rspec', '~> 4.2' # trigger test runs based on file edits
32
- if RUBY_PLATFORM =~ /darwin/
33
- gem 'terminal-notifier-guard', '~> 1.5' # use growler notifications on macs
34
- end
35
-
36
- # CUKES see features dir
37
- gem 'cucumber-rails', '~> 1.3', :require=>false # feature-driven-development suite
38
- gem 'capybara', '~> 2.2.1' # note, selectors were breaking when we used 2.0.1
39
- gem 'selenium-webdriver', '~> 2.39'
40
- # gem 'capybara-webkit'
41
- gem 'launchy' # lets cucumber launch browser windows
42
-
43
- gem 'timecop', '=0.3.5' # not clear on use/need. referred to in shared_data.rb
44
- # NOTE: had weird errors with timecop 0.4.4. would like to update when possible
45
-
46
- gem 'spork', '>=0.9'
47
-
48
- gem 'rr'#, '=1.0.0'
49
-
50
- gem 'email_spec' #
51
- gem 'database_cleaner', '~> 0.7' # used by cucumber for db transactions
52
-
53
- gem 'turn', "~>0.8.3", :require => false # Pretty printed test output. (version constraint is to avoid minitest requirement)
54
- gem 'minitest', "~>4.0"
55
-
56
-
57
-
58
- #windows stuff
59
- gem 'win32console', '~> 1.3', :platforms => ['mingw', 'mswin']
60
- gem 'win32-process', '~> 0.6', :platforms => ['mingw', 'mswin']
61
- end
22
+ gem 'tinymce-rails', '~> 3.4' # wysiwyg editor
23
+
24
+ # execjs is necessary for developing coffeescript. mac users have execjs built-in; don't need this one
25
+ gem 'therubyrhino', :platform=>:ruby # :ruby is MRI rubies, so if you use a mac ruby ...
26
+ end
27
+
28
+
29
+ group :test do
30
+ gem 'simplecov', '~> 0.7.1', :require => false #test coverage
31
+
32
+ # SPECS see spec dir
33
+ gem 'rspec-rails', "~> 2.6" # behavior-driven-development suite
34
+
35
+ gem 'guard-rspec', '~> 4.2' # trigger test runs based on file edits
36
+ if RUBY_PLATFORM =~ /darwin/
37
+ gem 'terminal-notifier-guard', '~> 1.5' # use growler notifications on macs
38
+ end
39
+
40
+ # CUKES see features dir
41
+ gem 'cucumber-rails', '~> 1.3', :require=>false # feature-driven-development suite
42
+ gem 'capybara', '~> 2.2.1' # note, selectors were breaking when we used 2.0.1
43
+ gem 'selenium-webdriver', '~> 2.39'
44
+ # gem 'capybara-webkit'
45
+ gem 'launchy' # lets cucumber launch browser windows
46
+
47
+ gem 'timecop', '=0.3.5' # not clear on use/need. referred to in shared_data.rb
48
+ # NOTE: had weird errors with timecop 0.4.4. would like to update when possible
49
+
50
+ gem 'spork', '>=0.9'
51
+
52
+ gem 'rr'#, '=1.0.0'
53
+
54
+ gem 'email_spec' #
55
+ gem 'database_cleaner', '~> 0.7' # used by cucumber for db transactions
56
+
57
+ gem 'turn', "~>0.8.3", :require => false # Pretty printed test output. (version constraint is to avoid minitest requirement)
58
+ gem 'minitest', "~>4.0"
59
+
60
+
61
+
62
+ #windows stuff
63
+ gem 'win32console', '~> 1.3', :platforms => ['mingw', 'mswin']
64
+ gem 'win32-process', '~> 0.6', :platforms => ['mingw', 'mswin']
65
+ end
62
66
 
63
- gem 'ruby-prof', '~>0.12.1', :group=>:profile # profiling
67
+ gem 'ruby-prof', '~>0.12.1', :group=>:profile # profiling
64
68
 
65
- group :debug do
66
- if RUBY_VERSION =~ /^2/
67
- gem 'byebug'
68
- else
69
- gem 'debugger'
70
- end
69
+ group :debug do
70
+ if RUBY_VERSION =~ /^2/
71
+ gem 'byebug'
72
+ else
73
+ gem 'debugger'
71
74
  end
75
+ end
72
76
  <% end %>
data/lib/wagn/location.rb CHANGED
@@ -1,6 +1,7 @@
1
1
  # -*- encoding : utf-8 -*-
2
2
  # helper for urls, links, redirects, and other location related things.
3
3
  # note: i'm sure this isn't the optimal name..
4
+
4
5
  module Wagn::Location
5
6
 
6
7
  # we keep a history stack so that in the case of card removal
@@ -17,8 +18,7 @@ module Wagn::Location
17
18
  end
18
19
 
19
20
  def save_location
20
- return if ajax? || !html? || !@card.known?
21
-
21
+ return if ajax? || !html? || !@card.known? || (@card.codename == 'signin')
22
22
  discard_locations_for @card
23
23
  @previous_location = wagn_path @card
24
24
  location_history.push @previous_location
@@ -34,8 +34,8 @@ class Card
34
34
  end
35
35
 
36
36
  def commentable? view, args
37
- self.class.tagged view, :comment and
38
- show_view? :comment_box, args, :hide and #developer or wagneer has overridden default
37
+ self.class.tagged view, :comment and
38
+ show_view? :comment_box, args.merge( :default_visibility=>:hide ) and #developer or wagneer has overridden default
39
39
  ok? :comment
40
40
  end
41
41
 
@@ -211,10 +211,6 @@ class Card
211
211
  }
212
212
  end
213
213
 
214
- def unknown_view view
215
- "<strong>unknown view: <em>#{view}</em></strong>"
216
- end
217
-
218
214
  def unsupported_view view
219
215
  "<strong>view <em>#{view}</em> not supported for <em>#{error_cardname}</em></strong>"
220
216
  end
@@ -5,6 +5,6 @@ class Card
5
5
  Format.register :txt
6
6
 
7
7
  class TextFormat < Format
8
- @@aliases[:txt] = :text
8
+ @@aliases['txt'] = 'text'
9
9
  end
10
10
  end
@@ -1,8 +1,3 @@
1
- @@options = {
2
- :opt_keys => [],
3
- :method_key => ''
4
- }
5
-
6
1
  def label name
7
2
  'All cards'
8
3
  end
@@ -1,6 +1,4 @@
1
- @@options = {
2
- :junction_only => true
3
- }
1
+ @@options = { :junction_only => true }
4
2
 
5
3
  def label name
6
4
  'All "+" cards'
@@ -1,5 +1,4 @@
1
1
  @@options = {
2
- :opt_keys => [:ltype, :right],
3
2
  :junction_only=>true,
4
3
  :assigns_type=>true
5
4
  }
@@ -29,5 +29,5 @@ end
29
29
 
30
30
  #fixme -this needs a better home!
31
31
  def format opts={}
32
- Format.new self, opts
32
+ Card::Format.new self, opts
33
33
  end
@@ -136,9 +136,10 @@ event :validate_unique_codename, :after=>:permit_codename do
136
136
  end
137
137
 
138
138
  event :validate_name, :before=>:approve, :on=>:save do
139
-
140
139
  cdname = name.to_name
141
- if cdname.blank?
140
+ if name.length > 255
141
+ errors.add :name, "is too long (255 character maximum)"
142
+ elsif cdname.blank?
142
143
  errors.add :name, "can't be blank"
143
144
  elsif name_changed?
144
145
  #Rails.logger.debug "valid name #{card.name.inspect} New #{name.inspect}"
@@ -1,21 +1,3 @@
1
- MODULES={}
2
-
3
- module ClassMethods
4
-
5
- def find_set_pattern mark
6
- if mark
7
- class_key = if Card::Name === mark
8
- key_card = Card.fetch mark.to_name.tag_name, :skip_modules=>true
9
- key_card && key_card.codename
10
- else
11
- mark.to_s
12
- end
13
- set_patterns.find { |sub| sub.key == class_key }
14
- end
15
- end
16
-
17
- end
18
-
19
1
 
20
2
  def patterns
21
3
  @patterns ||= set_patterns.map { |sub| sub.new(self) }.compact
@@ -27,7 +9,7 @@ end
27
9
  alias_method_chain :patterns, :new
28
10
 
29
11
  def reset_patterns
30
- @set_mods_loaded = @patterns = @set_modules = @junction_only = @method_keys = @set_names = @template = @rule_set_keys = @virtual = nil
12
+ @set_mods_loaded = @patterns = @set_modules = @junction_only = @set_names = @template = @rule_set_keys = @virtual = nil
31
13
  true
32
14
  end
33
15
 
@@ -49,7 +31,14 @@ def safe_set_keys
49
31
  end
50
32
 
51
33
  def set_modules
52
- @set_modules ||= patterns_without_new[0..-2].reverse.map(&:set_const).compact
34
+ @set_modules ||= patterns_without_new[0..-2].reverse.map(&:module_list).flatten.compact
35
+ end
36
+
37
+ def set_format_modules klass
38
+ @set_format_modules ||= {}
39
+ @set_format_modules[klass] = patterns_without_new[0..-2].reverse.map do |pattern|
40
+ pattern.format_module_list klass
41
+ end.flatten.compact
53
42
  end
54
43
 
55
44
  def set_names
@@ -65,6 +54,3 @@ def rule_set_keys
65
54
  @rule_set_keys ||= patterns.map( &:rule_set_key ).compact
66
55
  end
67
56
 
68
- def method_keys
69
- @method_keys ||= patterns.map(&:get_method_key).compact
70
- end
@@ -1,15 +1,33 @@
1
1
 
2
- def valid_subcard?
3
- abortable { valid? }
2
+ # The Card#abort method is for cleanly exiting an action without continuing to process any further events.
3
+ #
4
+ # Three statuses are supported:
5
+ #
6
+ # failure: adds an error, returns false on save
7
+ # success: no error, returns true on save
8
+ # triumph: similar to success, but if called on a subcard it causes the entire action to abort (not just the subcard)
9
+
10
+ def abort status, msg='action canceled'
11
+ if status == :failure && errors.empty?
12
+ errors.add :abort, msg
13
+ end
14
+ raise Card::Abort.new( status, msg)
4
15
  end
5
16
 
17
+
6
18
  def abortable
7
19
  yield
8
20
  rescue Card::Abort => e
9
- # need mechanism for subcards to abort entire process?
10
- e.status == :success
21
+ if e.status == :triumph
22
+ @supercard ? raise( e ) : true
23
+ else
24
+ e.status == :success
25
+ end
11
26
  end
12
27
 
28
+ def valid_subcard?
29
+ abortable { valid? }
30
+ end
13
31
 
14
32
  # this is an override of standard rails behavior that rescues abortmakes it so that :success abortions do not rollback
15
33
  def with_transaction_returning_status
@@ -22,12 +40,8 @@ def with_transaction_returning_status
22
40
  status
23
41
  end
24
42
 
25
- def abort status=:failure, msg='action canceled'
26
- if status == :failure && errors.empty?
27
- errors.add :abort, msg
28
- end
29
- raise Card::Abort.new( status, msg)
30
- end
43
+ # perhaps above should be in separate module?
44
+ #~~~~~~
31
45
 
32
46
  def approve
33
47
  @action = identify_action
@@ -39,7 +53,7 @@ def approve
39
53
  run_callbacks :approve
40
54
  expire_pieces if errors.any?
41
55
  errors.empty?
42
- rescue Exception=>e
56
+ rescue =>e
43
57
  rescue_event e
44
58
  end
45
59
 
@@ -56,7 +70,7 @@ def store
56
70
  yield
57
71
  @virtual = false
58
72
  end
59
- rescue Exception=>e
73
+ rescue =>e
60
74
  rescue_event e
61
75
  ensure
62
76
  @from_trash = nil
@@ -66,7 +80,7 @@ end
66
80
  def extend
67
81
  # puts "extend called"
68
82
  run_callbacks :extend
69
- rescue Exception=>e
83
+ rescue =>e
70
84
  rescue_event e
71
85
  ensure
72
86
  @action = nil
@@ -44,9 +44,9 @@ def related_sets
44
44
  # refers to sets that users may configure from the current card - NOT to sets to which the current card belongs
45
45
 
46
46
  sets = []
47
- sets << ["#{name}+*type", Card::SetPattern::TypePattern.label( name) ] if known? && type_id==Card::CardtypeID
48
- sets << ["#{name}+*self", Card::SetPattern::SelfPattern.label( name) ]
49
- sets << ["#{name}+*right", Card::SetPattern::RightPattern.label(name) ] if known? && cardname.simple?
47
+ sets << ["#{name}+*type", Card::TypeSet.label( name) ] if known? && type_id==Card::CardtypeID
48
+ sets << ["#{name}+*self", Card::SelfSet.label( name) ]
49
+ sets << ["#{name}+*right", Card::RightSet.label(name) ] if known? && cardname.simple?
50
50
 
51
51
  # Card.search(:type=>'Set',:left=>{:right=>name},:right=>'*type plus right',:return=>'name').each do |set_name|
52
52
  # sets<< set_name
@@ -91,8 +91,11 @@ def assigns_type?
91
91
  # for example, X+*type+*structure governs all cards of type X,
92
92
  # but the content rule does not (in fact cannot) have the type X.
93
93
  if is_structure?
94
- set_class = Card.find_set_pattern cardname.trunk_name
95
- set_class && set_class.assigns_type
94
+ if set_pattern = Card.fetch( cardname.trunk_name.tag_name, :skip_modules=>true )
95
+ pattern_code = set_pattern.codename and
96
+ set_class = Card::SetPattern.find( pattern_code ) and
97
+ set_class.assigns_type
98
+ end
96
99
  end
97
100
  end
98
101
 
@@ -50,6 +50,7 @@ def set_content new_content
50
50
  clear_drafts if current_revision_id
51
51
  new_rev = Card::Revision.create :card_id=>self.id, :content=>new_content, :creator_id =>Auth.current_id
52
52
  self.current_revision_id = new_rev.id
53
+ self.selected_revision_id = nil
53
54
  reset_patterns_if_rule saving=true
54
55
  @name_or_content_changed = true
55
56
  else
@@ -102,7 +103,7 @@ event :update_ruled_cards, :after=>:store do
102
103
  in_set = {}
103
104
  if !(self.trash)
104
105
  if class_id = (set=left and set_class=set.tag and set_class.id)
105
- rule_class_ids = set_patterns.map &:key_id
106
+ rule_class_ids = set_patterns.map &:pattern_id
106
107
  #warn "rule_class_id #{class_id}, #{rule_class_ids.inspect}"
107
108
 
108
109
  #first update all cards in set that aren't governed by narrower rule