rails-footnotes 3.7.5.rc4 → 3.7.5
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +7 -5
- data/README.rdoc +2 -2
- data/lib/rails-footnotes/abstract_note.rb +0 -1
- data/lib/rails-footnotes/notes/assigns_note.rb +6 -14
- data/lib/rails-footnotes/version.rb +1 -1
- data/spec/footnotes_spec.rb +13 -10
- data/spec/notes/assigns_note_spec.rb +15 -6
- data/spec/notes/files_note_spec.rb +11 -0
- data/spec/notes/javascripts_note_spec.rb +13 -1
- data/spec/notes/partials_notes_spec.rb +4 -1
- data/spec/notes/stylesheets_note_spec.rb +14 -1
- data/spec/spec_helper.rb +5 -2
- metadata +90 -56
data/Gemfile
CHANGED
@@ -1,12 +1,14 @@
|
|
1
1
|
source "http://rubygems.org"
|
2
2
|
|
3
|
-
# Specify your gem's dependencies in mcutter.gemspec
|
4
3
|
gemspec
|
5
4
|
|
6
5
|
# gem "rails", ">= 3.0.5"
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
gem 'simplecov', '>= 0.4.0', :require => false
|
6
|
+
|
7
|
+
group :test do
|
8
|
+
if RUBY_VERSION > "1.9.0"
|
9
|
+
# gem 'simplecov', '>= 0.4.0', :require => false
|
10
|
+
else
|
11
|
+
# gem "rcov"
|
12
|
+
gem "ruby-debug"
|
11
13
|
end
|
12
14
|
end
|
data/README.rdoc
CHANGED
@@ -17,11 +17,11 @@ Install Rails Footnotes is very easy.
|
|
17
17
|
|
18
18
|
=== Rails 3.x
|
19
19
|
|
20
|
-
gem 'rails-footnotes', '>= 3.7', :group => :development
|
20
|
+
gem 'rails-footnotes', '>= 3.7.5.rc4', :group => :development
|
21
21
|
|
22
22
|
After you install RailsFootnotes and add it to your Gemfile, you need to run the generator:
|
23
23
|
|
24
|
-
rails generate
|
24
|
+
rails generate rails_footnotes:install
|
25
25
|
|
26
26
|
=== Rails 2.x
|
27
27
|
|
@@ -145,7 +145,6 @@ module Footnotes
|
|
145
145
|
return '' if array.empty?
|
146
146
|
|
147
147
|
header = header.collect{|i| escape(i.to_s.humanize) }
|
148
|
-
# array = array.collect { |a| a.collect { |b| c = b.to_s; escape(c) unless c == ""}}
|
149
148
|
rows = array.collect{|i| "<tr><td>#{i.join('</td><td>')}</td></tr>" }
|
150
149
|
|
151
150
|
<<-TABLE
|
@@ -26,28 +26,20 @@ module Footnotes
|
|
26
26
|
end
|
27
27
|
|
28
28
|
def valid?
|
29
|
-
assigns
|
29
|
+
assigns.present?
|
30
30
|
end
|
31
31
|
|
32
32
|
def content
|
33
|
-
|
34
|
-
assigns.each do |key|
|
35
|
-
rows << [ key, escape(assigned_value(key)) ]
|
36
|
-
end
|
37
|
-
mount_table(rows.unshift(['Name', 'Value']), :class => 'name_values', :summary => "Debug information for #{title}")
|
33
|
+
mount_table(to_table, :summary => "Debug information for #{title}")
|
38
34
|
end
|
39
35
|
|
40
36
|
protected
|
37
|
+
def to_table
|
38
|
+
@to_table ||= assigns.inject([]) {|rr, var| rr << [var, escape(assigned_value(var))]}.unshift(['Name', 'Value'])
|
39
|
+
end
|
41
40
|
|
42
41
|
def assigns
|
43
|
-
|
44
|
-
ignored = @@ignored_assigns
|
45
|
-
|
46
|
-
@controller.instance_variables.each {|x| assign << x.intern }
|
47
|
-
@controller.protected_instance_variables.each {|x| ignored << x.intern } if @controller.respond_to? :protected_instance_variables
|
48
|
-
|
49
|
-
assign -= ignored
|
50
|
-
return assign
|
42
|
+
@assigns ||= @controller.instance_variables.map {|v| v.to_sym} - ignored_assigns
|
51
43
|
end
|
52
44
|
|
53
45
|
def assigned_value(key)
|
data/spec/footnotes_spec.rb
CHANGED
@@ -23,7 +23,7 @@ describe "Footnotes" do
|
|
23
23
|
@controller.template = Object.new
|
24
24
|
@controller.request = ActionController::TestRequest.new
|
25
25
|
@controller.response = ActionController::TestResponse.new
|
26
|
-
@controller.response_body =
|
26
|
+
@controller.response_body = HTML.dup
|
27
27
|
@controller.params = {}
|
28
28
|
|
29
29
|
Footnotes::Filter.notes = [ :test ]
|
@@ -36,33 +36,36 @@ describe "Footnotes" do
|
|
36
36
|
index.should eql 334
|
37
37
|
end
|
38
38
|
|
39
|
-
|
40
|
-
|
41
|
-
|
39
|
+
#TODO doe's not pased with 1.8.7
|
40
|
+
if RUBY_VERSION >= '1.9.0'
|
41
|
+
it "foonotes_included" do
|
42
|
+
footnotes_perform!
|
43
|
+
@controller.response_body.should_not == HTML
|
44
|
+
end
|
42
45
|
end
|
43
46
|
|
44
47
|
specify "footnotes_not_included_when_request_is_xhr" do
|
45
48
|
@controller.request.env['HTTP_X_REQUESTED_WITH'] = 'XMLHttpRequest'
|
46
49
|
@controller.request.env['HTTP_ACCEPT'] = 'text/javascript, text/html, application/xml, text/xml, */*'
|
47
50
|
footnotes_perform!
|
48
|
-
@controller.response.body.should eql
|
51
|
+
@controller.response.body.should eql HTML
|
49
52
|
end
|
50
53
|
|
51
54
|
specify "footnotes_not_included_when_content_type_is_javascript" do
|
52
55
|
@controller.response.headers['Content-Type'] = 'text/javascript'
|
53
56
|
footnotes_perform!
|
54
|
-
@controller.response.body.should eql
|
57
|
+
@controller.response.body.should eql HTML
|
55
58
|
end
|
56
59
|
|
57
60
|
specify "footnotes_included_when_content_type_is_html" do
|
58
61
|
@controller.response.headers['Content-Type'] = 'text/html'
|
59
62
|
footnotes_perform!
|
60
|
-
@controller.response.body.should_not eql
|
63
|
+
@controller.response.body.should_not eql HTML
|
61
64
|
end
|
62
65
|
|
63
66
|
specify "footnotes_included_when_content_type_is_nil" do
|
64
67
|
footnotes_perform!
|
65
|
-
@controller.response.body.should_not eql
|
68
|
+
@controller.response.body.should_not eql HTML
|
66
69
|
end
|
67
70
|
|
68
71
|
specify "not_included_when_body_is_not_a_string" do
|
@@ -195,7 +198,7 @@ describe "Footnotes" do
|
|
195
198
|
end
|
196
199
|
end
|
197
200
|
|
198
|
-
|
201
|
+
HTML = <<EOF
|
199
202
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
200
203
|
<html>
|
201
204
|
<head>
|
@@ -210,6 +213,6 @@ $html = <<HTML
|
|
210
213
|
<p>You will be glad to know that no changes need to be made to any of your CSS files.</p>
|
211
214
|
</body>
|
212
215
|
</html>
|
213
|
-
|
216
|
+
EOF
|
214
217
|
|
215
218
|
end
|
@@ -2,23 +2,32 @@ require "spec_helper"
|
|
2
2
|
require 'action_controller'
|
3
3
|
require "rails-footnotes/notes/assigns_note"
|
4
4
|
|
5
|
-
class FootnotesController < ActionController::Base
|
6
|
-
end
|
7
|
-
|
8
5
|
describe Footnotes::Notes::AssignsNote do
|
9
6
|
let(:note) do
|
10
|
-
@controller =
|
7
|
+
@controller = mock
|
8
|
+
@controller.stub(:instance_variables).and_return([:@action_has_layout, :@_status])
|
9
|
+
@controller.instance_variable_set(:@action_has_layout, true)
|
10
|
+
@controller.instance_variable_set(:@_status, 200)
|
11
11
|
Footnotes::Notes::AssignsNote.new(@controller)
|
12
12
|
end
|
13
13
|
subject {note}
|
14
14
|
|
15
15
|
before(:each) {Footnotes::Notes::AssignsNote.ignored_assigns = []}
|
16
|
+
|
16
17
|
it {should be_valid}
|
17
|
-
its(:title) {should eql 'Assigns (
|
18
|
-
|
18
|
+
its(:title) {should eql 'Assigns (2)'}
|
19
|
+
|
20
|
+
specify {note.send(:assigns).should eql [:@action_has_layout, :@_status]}
|
21
|
+
specify {note.send(:to_table).should eql [['Name', 'Value'], [:@action_has_layout, "true"], [:@_status, "200"]]}
|
19
22
|
|
20
23
|
describe "Ignored Assigns" do
|
21
24
|
before(:each) {Footnotes::Notes::AssignsNote.ignored_assigns = [:@_status]}
|
22
25
|
it {note.send(:assigns).should_not include :@_status}
|
23
26
|
end
|
27
|
+
|
28
|
+
it "should call #mount_table method with correct params" do
|
29
|
+
note.should_receive(:mount_table).with(
|
30
|
+
[['Name', 'Value'], [:@action_has_layout, "true"], [:@_status, "200"]], {:summary=>"Debug information for Assigns (2)"})
|
31
|
+
note.content
|
32
|
+
end
|
24
33
|
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'action_controller'
|
3
|
+
require "rails-footnotes/notes/files_note"
|
4
|
+
|
5
|
+
describe Footnotes::Notes::FilesNote do
|
6
|
+
let(:note) {Footnotes::Notes::FilesNote.new(mock('controller', :response => mock('', :body => '')))}
|
7
|
+
subject {note}
|
8
|
+
|
9
|
+
it {should be_valid}
|
10
|
+
its(:row) {should eql :edit}
|
11
|
+
end
|
@@ -2,5 +2,17 @@ require 'spec_helper'
|
|
2
2
|
require "rails-footnotes/notes/javascripts_note"
|
3
3
|
|
4
4
|
describe Footnotes::Notes::JavascriptsNote do
|
5
|
-
|
5
|
+
let(:note) {described_class.new(mock('controller', :response => mock('body', :body => '')))}
|
6
|
+
subject {note}
|
7
|
+
|
8
|
+
it {should be_valid}
|
9
|
+
|
10
|
+
it "should return js links from html after #scan_text mehtod call" do
|
11
|
+
subject.send(:scan_text, HTML_WITH_JS).should eql ['/javascripts/all.js', '/javascripts/jquery.js']
|
12
|
+
end
|
6
13
|
end
|
14
|
+
|
15
|
+
HTML_WITH_JS = <<-EOF
|
16
|
+
<script cache="false" src="/javascripts/all.js?1315913920" type="text/javascript"></script>
|
17
|
+
<script cache="false" src="/javascripts/jquery.js?1315913920" type="text/javascript"></script>
|
18
|
+
EOF
|
@@ -2,5 +2,18 @@ require 'spec_helper'
|
|
2
2
|
require "rails-footnotes/notes/stylesheets_note"
|
3
3
|
|
4
4
|
describe Footnotes::Notes::StylesheetsNote do
|
5
|
-
|
5
|
+
|
6
|
+
let(:note) {described_class.new(mock('controller', :response => mock('body', :body => '')))}
|
7
|
+
subject {note}
|
8
|
+
|
9
|
+
it {should be_valid}
|
10
|
+
|
11
|
+
it "should return css link from html text after #scan_text call" do
|
12
|
+
subject.send(:scan_text, HTML_WITH_CSS).should eql ['/stylesheets/compiled/print.css', '/stylesheets/compiled/print.css']
|
13
|
+
end
|
6
14
|
end
|
15
|
+
|
16
|
+
HTML_WITH_CSS = <<-EOF
|
17
|
+
<link href="/stylesheets/compiled/print.css?1315913920" media="print" rel="stylesheet" type="text/css" />'
|
18
|
+
'<link href="/stylesheets/compiled/print.css?1315913920" media="print" rel="stylesheet" type="text/css" />'
|
19
|
+
EOF
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,68 +1,92 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: rails-footnotes
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
prerelease:
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 17
|
5
|
+
prerelease:
|
6
|
+
segments:
|
7
|
+
- 3
|
8
|
+
- 7
|
9
|
+
- 5
|
10
|
+
version: 3.7.5
|
6
11
|
platform: ruby
|
7
|
-
authors:
|
12
|
+
authors:
|
8
13
|
- Keenan Brock
|
9
14
|
autorequire:
|
10
15
|
bindir: bin
|
11
16
|
cert_chain: []
|
12
|
-
|
13
|
-
|
14
|
-
|
17
|
+
|
18
|
+
date: 2011-09-30 00:00:00 Z
|
19
|
+
dependencies:
|
20
|
+
- !ruby/object:Gem::Dependency
|
15
21
|
name: rails
|
16
|
-
|
22
|
+
prerelease: false
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
17
24
|
none: false
|
18
|
-
requirements:
|
19
|
-
- -
|
20
|
-
- !ruby/object:Gem::Version
|
25
|
+
requirements:
|
26
|
+
- - ">="
|
27
|
+
- !ruby/object:Gem::Version
|
28
|
+
hash: 7
|
29
|
+
segments:
|
30
|
+
- 3
|
31
|
+
- 0
|
32
|
+
- 0
|
21
33
|
version: 3.0.0
|
22
34
|
type: :runtime
|
23
|
-
|
24
|
-
|
25
|
-
- !ruby/object:Gem::Dependency
|
35
|
+
version_requirements: *id001
|
36
|
+
- !ruby/object:Gem::Dependency
|
26
37
|
name: rails
|
27
|
-
|
38
|
+
prerelease: false
|
39
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
28
40
|
none: false
|
29
|
-
requirements:
|
30
|
-
- -
|
31
|
-
- !ruby/object:Gem::Version
|
41
|
+
requirements:
|
42
|
+
- - ">="
|
43
|
+
- !ruby/object:Gem::Version
|
44
|
+
hash: 7
|
45
|
+
segments:
|
46
|
+
- 3
|
47
|
+
- 0
|
48
|
+
- 0
|
32
49
|
version: 3.0.0
|
33
50
|
type: :development
|
34
|
-
|
35
|
-
|
36
|
-
- !ruby/object:Gem::Dependency
|
51
|
+
version_requirements: *id002
|
52
|
+
- !ruby/object:Gem::Dependency
|
37
53
|
name: rspec
|
38
|
-
|
54
|
+
prerelease: false
|
55
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
39
56
|
none: false
|
40
|
-
requirements:
|
41
|
-
- -
|
42
|
-
- !ruby/object:Gem::Version
|
43
|
-
|
57
|
+
requirements:
|
58
|
+
- - ">="
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
hash: 3
|
61
|
+
segments:
|
62
|
+
- 0
|
63
|
+
version: "0"
|
44
64
|
type: :development
|
45
|
-
|
46
|
-
|
47
|
-
- !ruby/object:Gem::Dependency
|
65
|
+
version_requirements: *id003
|
66
|
+
- !ruby/object:Gem::Dependency
|
48
67
|
name: watchr
|
49
|
-
|
68
|
+
prerelease: false
|
69
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
50
70
|
none: false
|
51
|
-
requirements:
|
52
|
-
- -
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
|
71
|
+
requirements:
|
72
|
+
- - ">="
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
hash: 3
|
75
|
+
segments:
|
76
|
+
- 0
|
77
|
+
version: "0"
|
55
78
|
type: :development
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
and links back to your editor.
|
60
|
-
email:
|
79
|
+
version_requirements: *id004
|
80
|
+
description: Every Rails page has footnotes that gives information about your application and links back to your editor.
|
81
|
+
email:
|
61
82
|
- keenan@thebrocks.net
|
62
83
|
executables: []
|
84
|
+
|
63
85
|
extensions: []
|
86
|
+
|
64
87
|
extra_rdoc_files: []
|
65
|
-
|
88
|
+
|
89
|
+
files:
|
66
90
|
- .gitignore
|
67
91
|
- .rspec.example
|
68
92
|
- .watchr.example
|
@@ -102,39 +126,49 @@ files:
|
|
102
126
|
- spec/abstract_note_spec.rb
|
103
127
|
- spec/footnotes_spec.rb
|
104
128
|
- spec/notes/assigns_note_spec.rb
|
129
|
+
- spec/notes/files_note_spec.rb
|
105
130
|
- spec/notes/javascripts_note_spec.rb
|
106
131
|
- spec/notes/partials_notes_spec.rb
|
107
132
|
- spec/notes/stylesheets_note_spec.rb
|
108
133
|
- spec/spec_helper.rb
|
109
134
|
homepage: http://github.com/josevalim/rails-footnotes
|
110
135
|
licenses: []
|
136
|
+
|
111
137
|
post_install_message:
|
112
138
|
rdoc_options: []
|
113
|
-
|
139
|
+
|
140
|
+
require_paths:
|
114
141
|
- lib
|
115
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
142
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
116
143
|
none: false
|
117
|
-
requirements:
|
118
|
-
- -
|
119
|
-
- !ruby/object:Gem::Version
|
120
|
-
|
121
|
-
|
144
|
+
requirements:
|
145
|
+
- - ">="
|
146
|
+
- !ruby/object:Gem::Version
|
147
|
+
hash: 3
|
148
|
+
segments:
|
149
|
+
- 0
|
150
|
+
version: "0"
|
151
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
122
152
|
none: false
|
123
|
-
requirements:
|
124
|
-
- -
|
125
|
-
- !ruby/object:Gem::Version
|
126
|
-
|
153
|
+
requirements:
|
154
|
+
- - ">="
|
155
|
+
- !ruby/object:Gem::Version
|
156
|
+
hash: 3
|
157
|
+
segments:
|
158
|
+
- 0
|
159
|
+
version: "0"
|
127
160
|
requirements: []
|
161
|
+
|
128
162
|
rubyforge_project: rails-footnotes
|
129
|
-
rubygems_version: 1.8.
|
163
|
+
rubygems_version: 1.8.10
|
130
164
|
signing_key:
|
131
165
|
specification_version: 3
|
132
|
-
summary: Every Rails page has footnotes that gives information about your application
|
133
|
-
|
134
|
-
test_files:
|
166
|
+
summary: Every Rails page has footnotes that gives information about your application and links back to your editor.
|
167
|
+
test_files:
|
135
168
|
- spec/abstract_note_spec.rb
|
136
169
|
- spec/footnotes_spec.rb
|
137
170
|
- spec/notes/assigns_note_spec.rb
|
171
|
+
- spec/notes/files_note_spec.rb
|
138
172
|
- spec/notes/javascripts_note_spec.rb
|
139
173
|
- spec/notes/partials_notes_spec.rb
|
140
174
|
- spec/notes/stylesheets_note_spec.rb
|