rails-footnotes 3.7.8 → 3.7.9

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.
@@ -59,17 +59,36 @@ this code temporarily disables notes for all controllers
59
59
  controller.action_name == 'edit' }
60
60
  end
61
61
 
62
- If you are not using Textmate as text editor, in your environment.rb or
63
- in an initializer do:
62
+ If you are not using Textmate as text editor, MacVim and Sublime Text 2 are also compatible.
64
63
 
65
- Footnotes::Filter.prefix = 'mvim://open?url=file://%s&line=%d&column=%d'
64
+ *MacVim*
65
+
66
+ In your environment.rb or in an initializer do:
66
67
 
67
- for MacVim
68
+ Footnotes::Filter.prefix = 'mvim://open?url=file://%s&line=%d&column=%d'
68
69
 
69
70
  Where you are going to choose a prefix compatible with your text editor. The %s is
70
71
  replaced by the name of the file, the first %d is replaced by the line number and
71
72
  the second %d is replaced by the column.
72
73
 
74
+ Take note that the order in which the file name (%s), line number (%d) and column number (%d) appears is important.
75
+ We assume that they appear in that order. "foo://line=%d&file=%s" (%d precedes %s) would throw out an error.
76
+
77
+ *Sublime* *Text* *2*
78
+
79
+ 1. Keep the Textmate prefix, Footnotes::Filter.prefix = 'txmt://open?url=file://%s&line=%d&column=%d'
80
+
81
+ 2. Install {subl-hanlder}[https://github.com/asuth/subl-handler]
82
+
83
+ 3. Open subl-handler. Go to preferences (SublHandler > Preferences), and point "Path to subl" to your installed instance. (EG, /Applications/Sublime Text 2.app/Contents/SharedSupport/bin/subl). Note: do not escape the whitespaces, subl-handler accounts for those.
84
+
85
+ 4. Install {RCDefault}[http://www.rubicode.com/Software/RCDefaultApp]. It's OSX 10.2, but it works.
86
+
87
+ 5. Go to RCDefaultApp (OS System Preferences > DefaultApps). Go to URL section, select "tmxt" extension, and set default applicaiton to "SublHandler".
88
+
89
+
90
+ *Footnotes* *Display* *Options*
91
+
73
92
  By default, footnotes are appended at the end of the page with default stylesheet. If you want
74
93
  to change their position, you can define a div with id "footnotes_holder" or define your own stylesheet
75
94
  by turning footnotes stylesheet off:
@@ -13,16 +13,7 @@ module Footnotes
13
13
  @@after_hooks << block
14
14
  end
15
15
 
16
- # The footnotes are applied by default to all actions. You can change this
17
- # behavior commenting the after_filter line below and putting it in Your
18
- # application. Then you can cherrypick in which actions it will appear.
19
- #
20
- module RailsFootnotesExtension
21
- def self.included(base)
22
- base.prepend_before_filter Footnotes::BeforeFilter
23
- base.after_filter Footnotes::AfterFilter
24
- end
25
- end
16
+ autoload :RailsFootnotesExtension, 'rails-footnotes/extension'
26
17
 
27
18
  def self.run!
28
19
  require 'rails-footnotes/footnotes'
@@ -0,0 +1,8 @@
1
+ module Footnotes
2
+ module RailsFootnotesExtension
3
+ def self.included(base)
4
+ base.prepend_before_filter Footnotes::BeforeFilter
5
+ base.after_filter Footnotes::AfterFilter
6
+ end
7
+ end
8
+ end
@@ -52,8 +52,11 @@ module Footnotes
52
52
  def initialize(controller)
53
53
  @controller = controller
54
54
  @template = controller.instance_variable_get(:@template)
55
- @body = controller.response.body
56
55
  @notes = []
56
+
57
+ revert_pos(controller.response_body) do
58
+ @body = controller.response.body
59
+ end
57
60
  end
58
61
 
59
62
  def add_footnotes!
@@ -91,6 +94,13 @@ module Footnotes
91
94
  end
92
95
  end
93
96
 
97
+ def revert_pos(file)
98
+ return yield unless file.respond_to?(:pos) && file.respond_to?(:pos=)
99
+ original = file.pos
100
+ yield
101
+ file.pos = original
102
+ end
103
+
94
104
  def performed_render?
95
105
  @controller.instance_variable_get(:@performed_render) || # rails 2.x
96
106
  (@controller.respond_to?(:performed?) && @controller.performed?) # rails3, will break on redirect??
@@ -1,3 +1,3 @@
1
1
  module Footnotes
2
- VERSION = "3.7.8"
2
+ VERSION = "3.7.9"
3
3
  end
@@ -1,6 +1,7 @@
1
1
  require "spec_helper"
2
2
  require 'action_controller'
3
3
  require 'action_controller/test_case'
4
+ require "tempfile"
4
5
 
5
6
  class FootnotesController < ActionController::Base
6
7
  attr_accessor :template, :performed_render
@@ -36,6 +37,25 @@ describe "Footnotes" do
36
37
  index.should eql 334
37
38
  end
38
39
 
40
+ context "response_body is file" do
41
+ before do
42
+ @file = Tempfile.new("test")
43
+ @file.write "foobarbaz"
44
+ @file.rewind
45
+ end
46
+
47
+ after do
48
+ @file.close!
49
+ end
50
+
51
+ it "should not change file position" do
52
+ @controller.response_body = @file
53
+ expect {
54
+ @footnotes = Footnotes::Filter.new(@controller)
55
+ }.not_to change{ @controller.response_body.pos }
56
+ end
57
+ end
58
+
39
59
  #TODO doe's not pased with 1.8.7
40
60
  if RUBY_VERSION >= '1.9.0'
41
61
  it "foonotes_included" do
metadata CHANGED
@@ -1,83 +1,75 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: rails-footnotes
3
- version: !ruby/object:Gem::Version
4
- hash: 11
3
+ version: !ruby/object:Gem::Version
4
+ version: 3.7.9
5
5
  prerelease:
6
- segments:
7
- - 3
8
- - 7
9
- - 8
10
- version: 3.7.8
11
6
  platform: ruby
12
- authors:
7
+ authors:
13
8
  - Roman V. Babenko
14
- - "Jos\xC3\xA9 Valim"
9
+ - José Valim
15
10
  - Keenan Brock
16
11
  - Duane Johnson
17
12
  autorequire:
18
13
  bindir: bin
19
14
  cert_chain: []
20
-
21
- date: 2012-04-19 00:00:00 Z
22
- dependencies:
23
- - !ruby/object:Gem::Dependency
15
+ date: 2012-10-27 00:00:00.000000000 Z
16
+ dependencies:
17
+ - !ruby/object:Gem::Dependency
24
18
  name: rails
25
- prerelease: false
26
- requirement: &id001 !ruby/object:Gem::Requirement
19
+ requirement: !ruby/object:Gem::Requirement
27
20
  none: false
28
- requirements:
29
- - - ">="
30
- - !ruby/object:Gem::Version
31
- hash: 7
32
- segments:
33
- - 3
34
- - 0
35
- - 0
21
+ requirements:
22
+ - - ! '>='
23
+ - !ruby/object:Gem::Version
36
24
  version: 3.0.0
37
25
  type: :runtime
38
- version_requirements: *id001
39
- - !ruby/object:Gem::Dependency
40
- name: rails
41
26
  prerelease: false
42
- requirement: &id002 !ruby/object:Gem::Requirement
27
+ version_requirements: !ruby/object:Gem::Requirement
43
28
  none: false
44
- requirements:
45
- - - ">="
46
- - !ruby/object:Gem::Version
47
- hash: 7
48
- segments:
49
- - 3
50
- - 0
51
- - 0
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
32
+ version: 3.0.0
33
+ - !ruby/object:Gem::Dependency
34
+ name: rails
35
+ requirement: !ruby/object:Gem::Requirement
36
+ none: false
37
+ requirements:
38
+ - - ! '>='
39
+ - !ruby/object:Gem::Version
52
40
  version: 3.0.0
53
41
  type: :development
54
- version_requirements: *id002
55
- - !ruby/object:Gem::Dependency
56
- name: rspec
57
42
  prerelease: false
58
- requirement: &id003 !ruby/object:Gem::Requirement
43
+ version_requirements: !ruby/object:Gem::Requirement
59
44
  none: false
60
- requirements:
45
+ requirements:
46
+ - - ! '>='
47
+ - !ruby/object:Gem::Version
48
+ version: 3.0.0
49
+ - !ruby/object:Gem::Dependency
50
+ name: rspec
51
+ requirement: !ruby/object:Gem::Requirement
52
+ none: false
53
+ requirements:
61
54
  - - ~>
62
- - !ruby/object:Gem::Version
63
- hash: 43
64
- segments:
65
- - 2
66
- - 9
67
- - 0
55
+ - !ruby/object:Gem::Version
68
56
  version: 2.9.0
69
57
  type: :development
70
- version_requirements: *id003
71
- description: Every Rails page has footnotes that gives information about your application and links back to your editor.
72
- email:
58
+ prerelease: false
59
+ version_requirements: !ruby/object:Gem::Requirement
60
+ none: false
61
+ requirements:
62
+ - - ~>
63
+ - !ruby/object:Gem::Version
64
+ version: 2.9.0
65
+ description: Every Rails page has footnotes that gives information about your application
66
+ and links back to your editor.
67
+ email:
73
68
  - romanvbabenko@gmail.com
74
69
  executables: []
75
-
76
70
  extensions: []
77
-
78
71
  extra_rdoc_files: []
79
-
80
- files:
72
+ files:
81
73
  - .gitignore
82
74
  - .rspec.example
83
75
  - .travis.yml
@@ -97,6 +89,7 @@ files:
97
89
  - lib/rails-footnotes/backtracer.rb
98
90
  - lib/rails-footnotes/before_filter.rb
99
91
  - lib/rails-footnotes/each_with_rescue.rb
92
+ - lib/rails-footnotes/extension.rb
100
93
  - lib/rails-footnotes/filter.rb
101
94
  - lib/rails-footnotes/footnotes.rb
102
95
  - lib/rails-footnotes/notes/all.rb
@@ -130,38 +123,30 @@ files:
130
123
  - spec/spec_helper.rb
131
124
  homepage: http://github.com/josevalim/rails-footnotes
132
125
  licenses: []
133
-
134
126
  post_install_message:
135
127
  rdoc_options: []
136
-
137
- require_paths:
128
+ require_paths:
138
129
  - lib
139
- required_ruby_version: !ruby/object:Gem::Requirement
130
+ required_ruby_version: !ruby/object:Gem::Requirement
140
131
  none: false
141
- requirements:
142
- - - ">="
143
- - !ruby/object:Gem::Version
144
- hash: 3
145
- segments:
146
- - 0
147
- version: "0"
148
- required_rubygems_version: !ruby/object:Gem::Requirement
132
+ requirements:
133
+ - - ! '>='
134
+ - !ruby/object:Gem::Version
135
+ version: '0'
136
+ required_rubygems_version: !ruby/object:Gem::Requirement
149
137
  none: false
150
- requirements:
151
- - - ">="
152
- - !ruby/object:Gem::Version
153
- hash: 3
154
- segments:
155
- - 0
156
- version: "0"
138
+ requirements:
139
+ - - ! '>='
140
+ - !ruby/object:Gem::Version
141
+ version: '0'
157
142
  requirements: []
158
-
159
143
  rubyforge_project: rails-footnotes
160
- rubygems_version: 1.8.17
144
+ rubygems_version: 1.8.24
161
145
  signing_key:
162
146
  specification_version: 3
163
- summary: Every Rails page has footnotes that gives information about your application and links back to your editor.
164
- test_files:
147
+ summary: Every Rails page has footnotes that gives information about your application
148
+ and links back to your editor.
149
+ test_files:
165
150
  - spec/abstract_note_spec.rb
166
151
  - spec/footnotes_spec.rb
167
152
  - spec/notes/assigns_note_spec.rb