rails-footnotes 3.7.0 → 3.7.1.pre

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore CHANGED
@@ -1 +1,8 @@
1
+ .*
2
+ !.gitignore
3
+ !.gitmodules
4
+ *.gem
5
+ .bundle
6
+ Gemfile.lock
7
+ pkg/*
1
8
  tags
data/README CHANGED
@@ -50,6 +50,16 @@ add something like this to config/initializers/footnotes.rb:
50
50
  # ... other init code
51
51
  end
52
52
 
53
+ Hooks
54
+ -------------
55
+
56
+ Footnotes.setup do |config|
57
+ config.before {|controller, filter| filter.notes = controller.class.name =~ /Message/ && \
58
+ controller.action_name == 'index' ? [:assigns] : []}
59
+ config.before {|controller, filter| filter.notes |= [:params] if controller.class.name =~ /Profile/ && \
60
+ controller.action_name == 'edit' }
61
+ end
62
+
53
63
  If you are not using Textmate as text editor, in your environment.rb or
54
64
  in an initializer do:
55
65
 
@@ -48,9 +48,10 @@ module Footnotes
48
48
  # This method allows this kind of setup
49
49
  #
50
50
  def start!(controller)
51
- @@klasses = []
51
+ self.each_with_rescue(Footnotes.before_hooks) {|hook| hook.call(controller, self)}
52
52
 
53
- each_with_rescue(@@notes.flatten) do |note|
53
+ @@klasses = []
54
+ self.each_with_rescue(@@notes.flatten) do |note|
54
55
  klass = "Footnotes::Notes::#{note.to_s.camelize}Note".constantize
55
56
  klass.start!(controller) if klass.respond_to?(:start!)
56
57
  @@klasses << klass
@@ -59,22 +60,22 @@ module Footnotes
59
60
 
60
61
  # Process notes, discarding only the note if any problem occurs
61
62
  #
62
- def each_with_rescue(notes)
63
+ def each_with_rescue(collection)
63
64
  delete_me = []
64
65
 
65
- notes.each do |note|
66
+ collection.each do |item|
66
67
  begin
67
- yield note
68
+ yield item
68
69
  rescue Exception => e
69
- # Discard note if it has a problem
70
- log_error("Footnotes #{note.to_s.camelize}Note Exception", e)
71
- delete_me << note
70
+ # Discard item if it has a problem
71
+ log_error("Footnotes #{item.to_s.camelize} Exception", e)
72
+ delete_me << item
72
73
  next
73
74
  end
74
75
  end
75
76
 
76
- delete_me.each{ |note| notes.delete(note) }
77
- return notes
77
+ delete_me.each { |item| collection.delete(item) }
78
+ return collection
78
79
  end
79
80
 
80
81
  # Logs the error using specified title and format
@@ -115,9 +116,8 @@ module Footnotes
115
116
  # This method allows this kind of work
116
117
  #
117
118
  def close!(controller)
118
- each_with_rescue(@@klasses) do |klass|
119
- klass.close!(controller)
120
- end
119
+ self.each_with_rescue(@@klasses) {|klass| klass.close!(controller)}
120
+ self.each_with_rescue(Footnotes.after_hooks) {|hook| hook.call(controller, self)}
121
121
  end
122
122
 
123
123
  protected
@@ -219,14 +219,14 @@ module Footnotes
219
219
  function hideAll(){
220
220
  #{close unless @@multiple_notes}
221
221
  }
222
-
222
+
223
223
  function hideAllAndToggle(id) {
224
224
  hideAll();
225
225
  toggle(id)
226
226
 
227
227
  location.href = '#footnotes_debug';
228
- }
229
-
228
+ }
229
+
230
230
  function toggle(id){
231
231
  var el = document.getElementById(id);
232
232
  if (el.style.display == 'none') {
@@ -235,11 +235,11 @@ module Footnotes
235
235
  Footnotes.hide(el);
236
236
  }
237
237
  }
238
-
238
+
239
239
  function show(element) {
240
240
  element.style.display = 'block'
241
241
  }
242
-
242
+
243
243
  function hide(element) {
244
244
  element.style.display = 'none'
245
245
  }
@@ -356,7 +356,7 @@ module Footnotes
356
356
  end
357
357
 
358
358
  # Instance each_with_rescue method
359
- #
359
+ #
360
360
  def each_with_rescue(*args, &block)
361
361
  self.class.each_with_rescue(*args, &block)
362
362
  end
@@ -1,3 +1,3 @@
1
1
  module Footnotes
2
- VERSION = "3.7.0"
2
+ VERSION = "3.7.1.pre"
3
3
  end
@@ -1,5 +1,18 @@
1
1
  module Footnotes
2
-
2
+ mattr_accessor :before_hooks
3
+ @@before_hooks = []
4
+
5
+ mattr_accessor :after_hooks
6
+ @@after_hooks = []
7
+
8
+ def self.before(&block)
9
+ @@before_hooks << block
10
+ end
11
+
12
+ def self.after(&block)
13
+ @@after_hooks << block
14
+ end
15
+
3
16
  # The footnotes are applied by default to all actions. You can change this
4
17
  # behavior commenting the after_filter line below and putting it in Your
5
18
  # application. Then you can cherrypick in which actions it will appear.
@@ -10,13 +23,17 @@ module Footnotes
10
23
  base.after_filter Footnotes::AfterFilter
11
24
  end
12
25
  end
13
-
26
+
14
27
  def self.run!
15
28
  require 'rails-footnotes/footnotes'
16
29
  require 'rails-footnotes/backtracer'
17
-
30
+
18
31
  Dir[File.join(File.dirname(__FILE__), 'rails-footnotes', 'notes', '*.rb')].each { |note| require note }
19
-
20
- ActionController::Base.send(:include, RailsFootnotesExtension)
32
+
33
+ ActionController::Base.send(:include, RailsFootnotesExtension)
34
+ end
35
+
36
+ def self.setup
37
+ yield self
21
38
  end
22
39
  end
metadata CHANGED
@@ -1,8 +1,8 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails-footnotes
3
3
  version: !ruby/object:Gem::Version
4
- prerelease:
5
- version: 3.7.0
4
+ prerelease: 6
5
+ version: 3.7.1.pre
6
6
  platform: ruby
7
7
  authors:
8
8
  - Keenan Brock
@@ -10,8 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2011-03-19 00:00:00 +02:00
14
- default_executable:
13
+ date: 2011-04-23 00:00:00 Z
15
14
  dependencies:
16
15
  - !ruby/object:Gem::Dependency
17
16
  name: rails
@@ -112,7 +111,6 @@ files:
112
111
  - test/footnotes_test.rb
113
112
  - test/notes/abstract_note_test.rb
114
113
  - test/test_helper.rb
115
- has_rdoc: true
116
114
  homepage: http://github.com/josevalim/rails-footnotes
117
115
  licenses: []
118
116
 
@@ -130,13 +128,13 @@ required_ruby_version: !ruby/object:Gem::Requirement
130
128
  required_rubygems_version: !ruby/object:Gem::Requirement
131
129
  none: false
132
130
  requirements:
133
- - - ">="
131
+ - - ">"
134
132
  - !ruby/object:Gem::Version
135
- version: "0"
133
+ version: 1.3.1
136
134
  requirements: []
137
135
 
138
136
  rubyforge_project: rails-footnotes
139
- rubygems_version: 1.5.0
137
+ rubygems_version: 1.7.2
140
138
  signing_key:
141
139
  specification_version: 3
142
140
  summary: Every Rails page has footnotes that gives information about your application and links back to your editor.
@@ -144,3 +142,4 @@ test_files:
144
142
  - test/footnotes_test.rb
145
143
  - test/notes/abstract_note_test.rb
146
144
  - test/test_helper.rb
145
+ has_rdoc: