rails-footnotes 4.1.8 → 5.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 21fa093ff6eaf5b53695cfaed61637fa8e4c8187
4
- data.tar.gz: 79e79b4486adcd087d948cc6d2d9f4959b6ac2bd
2
+ SHA256:
3
+ metadata.gz: c46e88fcf583fff51677ec9c3d049017bc3154f17c38aa9c872f14b5ab5184db
4
+ data.tar.gz: 16f25b1769f5bd07bbc68c5e598d9a247669fa8249bc08ebcadd0f62427ad085
5
5
  SHA512:
6
- metadata.gz: 0873a5dbe0233b3f87b43748bfe402227116892233b09fb964c2ab692c35dc0a09e6f02f348ba5696b5bb9922b08490afabb04805be9af994a72856420581826
7
- data.tar.gz: 1b88bc094b480f831319fa08b8c56fe0ac43356b5ca31ad1d492eee4cbe1bdadd438b05fc46bb22a5232fa1447398dd2a7d64e776177238e24c8f59f2f23c2cc
6
+ metadata.gz: 207f2170eed40c410ab90f923ecddc199abe7fdcf341f1e047d9ceda03be2f6135ac049c821249645929123a719cd78812bcfffda8b4aa25340788851f264ec6
7
+ data.tar.gz: faec60331eb700897e1013e1e3df6b158ba57f3682ab61e479612da878666dd2c34a5f47f76b9fc4162e9bbfeb85f7b7cf28b282ff9ddfa847c81592477cb326
@@ -0,0 +1,25 @@
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ branches: [ main ]
6
+ pull_request:
7
+ branches: [ main ]
8
+
9
+ jobs:
10
+ test:
11
+
12
+ runs-on: ubuntu-latest
13
+ strategy:
14
+ matrix:
15
+ ruby-version: ['3.0']
16
+
17
+ steps:
18
+ - uses: actions/checkout@v2
19
+ - name: Set up Ruby
20
+ uses: ruby/setup-ruby@v1
21
+ with:
22
+ ruby-version: ${{ matrix.ruby-version }}
23
+ bundler-cache: true # runs 'bundle install' and caches installed gems automatically
24
+ - name: Run tests
25
+ run: bin/rspec
data/.gitignore CHANGED
@@ -1,13 +1,12 @@
1
1
  .*
2
+ !.github
2
3
  !.gitignore
3
4
  !.gitmodules
4
- !.travis.yml
5
5
  !*.example
6
6
  *.gem
7
7
  .bundle
8
- Gemfile.lock
8
+ .rspec_results
9
9
  pkg/*
10
- /bin
11
10
  /coverage
12
11
  tags
13
12
  /doc
data/Gemfile CHANGED
@@ -1,3 +1,10 @@
1
1
  source "https://rubygems.org"
2
2
 
3
3
  gemspec
4
+
5
+ gem "capybara", "~> 3.35"
6
+ gem "nokogiri", "~> 1.12"
7
+ gem "pry", "~> 0.14.1"
8
+ gem "rake", "~> 13.0"
9
+ gem "rspec-rails", "~> 5.0"
10
+ gem "sprockets-rails", "~> 3.2"
data/Gemfile.lock ADDED
@@ -0,0 +1,187 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ rails-footnotes (5.0.0)
5
+ rails (~> 6.0)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ actioncable (6.1.4)
11
+ actionpack (= 6.1.4)
12
+ activesupport (= 6.1.4)
13
+ nio4r (~> 2.0)
14
+ websocket-driver (>= 0.6.1)
15
+ actionmailbox (6.1.4)
16
+ actionpack (= 6.1.4)
17
+ activejob (= 6.1.4)
18
+ activerecord (= 6.1.4)
19
+ activestorage (= 6.1.4)
20
+ activesupport (= 6.1.4)
21
+ mail (>= 2.7.1)
22
+ actionmailer (6.1.4)
23
+ actionpack (= 6.1.4)
24
+ actionview (= 6.1.4)
25
+ activejob (= 6.1.4)
26
+ activesupport (= 6.1.4)
27
+ mail (~> 2.5, >= 2.5.4)
28
+ rails-dom-testing (~> 2.0)
29
+ actionpack (6.1.4)
30
+ actionview (= 6.1.4)
31
+ activesupport (= 6.1.4)
32
+ rack (~> 2.0, >= 2.0.9)
33
+ rack-test (>= 0.6.3)
34
+ rails-dom-testing (~> 2.0)
35
+ rails-html-sanitizer (~> 1.0, >= 1.2.0)
36
+ actiontext (6.1.4)
37
+ actionpack (= 6.1.4)
38
+ activerecord (= 6.1.4)
39
+ activestorage (= 6.1.4)
40
+ activesupport (= 6.1.4)
41
+ nokogiri (>= 1.8.5)
42
+ actionview (6.1.4)
43
+ activesupport (= 6.1.4)
44
+ builder (~> 3.1)
45
+ erubi (~> 1.4)
46
+ rails-dom-testing (~> 2.0)
47
+ rails-html-sanitizer (~> 1.1, >= 1.2.0)
48
+ activejob (6.1.4)
49
+ activesupport (= 6.1.4)
50
+ globalid (>= 0.3.6)
51
+ activemodel (6.1.4)
52
+ activesupport (= 6.1.4)
53
+ activerecord (6.1.4)
54
+ activemodel (= 6.1.4)
55
+ activesupport (= 6.1.4)
56
+ activestorage (6.1.4)
57
+ actionpack (= 6.1.4)
58
+ activejob (= 6.1.4)
59
+ activerecord (= 6.1.4)
60
+ activesupport (= 6.1.4)
61
+ marcel (~> 1.0.0)
62
+ mini_mime (>= 1.1.0)
63
+ activesupport (6.1.4)
64
+ concurrent-ruby (~> 1.0, >= 1.0.2)
65
+ i18n (>= 1.6, < 2)
66
+ minitest (>= 5.1)
67
+ tzinfo (~> 2.0)
68
+ zeitwerk (~> 2.3)
69
+ addressable (2.8.0)
70
+ public_suffix (>= 2.0.2, < 5.0)
71
+ builder (3.2.4)
72
+ capybara (3.35.3)
73
+ addressable
74
+ mini_mime (>= 0.1.3)
75
+ nokogiri (~> 1.8)
76
+ rack (>= 1.6.0)
77
+ rack-test (>= 0.6.3)
78
+ regexp_parser (>= 1.5, < 3.0)
79
+ xpath (~> 3.2)
80
+ coderay (1.1.3)
81
+ concurrent-ruby (1.1.9)
82
+ crass (1.0.6)
83
+ diff-lcs (1.4.4)
84
+ erubi (1.10.0)
85
+ globalid (0.5.2)
86
+ activesupport (>= 5.0)
87
+ i18n (1.8.10)
88
+ concurrent-ruby (~> 1.0)
89
+ loofah (2.12.0)
90
+ crass (~> 1.0.2)
91
+ nokogiri (>= 1.5.9)
92
+ mail (2.7.1)
93
+ mini_mime (>= 0.1.1)
94
+ marcel (1.0.1)
95
+ method_source (1.0.0)
96
+ mini_mime (1.1.0)
97
+ minitest (5.14.4)
98
+ nio4r (2.5.8)
99
+ nokogiri (1.12.3-arm64-darwin)
100
+ racc (~> 1.4)
101
+ nokogiri (1.12.3-x86_64-linux)
102
+ racc (~> 1.4)
103
+ pry (0.14.1)
104
+ coderay (~> 1.1)
105
+ method_source (~> 1.0)
106
+ public_suffix (4.0.6)
107
+ racc (1.5.2)
108
+ rack (2.2.3)
109
+ rack-test (1.1.0)
110
+ rack (>= 1.0, < 3)
111
+ rails (6.1.4)
112
+ actioncable (= 6.1.4)
113
+ actionmailbox (= 6.1.4)
114
+ actionmailer (= 6.1.4)
115
+ actionpack (= 6.1.4)
116
+ actiontext (= 6.1.4)
117
+ actionview (= 6.1.4)
118
+ activejob (= 6.1.4)
119
+ activemodel (= 6.1.4)
120
+ activerecord (= 6.1.4)
121
+ activestorage (= 6.1.4)
122
+ activesupport (= 6.1.4)
123
+ bundler (>= 1.15.0)
124
+ railties (= 6.1.4)
125
+ sprockets-rails (>= 2.0.0)
126
+ rails-dom-testing (2.0.3)
127
+ activesupport (>= 4.2.0)
128
+ nokogiri (>= 1.6)
129
+ rails-html-sanitizer (1.4.1)
130
+ loofah (~> 2.3)
131
+ railties (6.1.4)
132
+ actionpack (= 6.1.4)
133
+ activesupport (= 6.1.4)
134
+ method_source
135
+ rake (>= 0.13)
136
+ thor (~> 1.0)
137
+ rake (13.0.6)
138
+ regexp_parser (2.1.1)
139
+ rspec-core (3.10.1)
140
+ rspec-support (~> 3.10.0)
141
+ rspec-expectations (3.10.1)
142
+ diff-lcs (>= 1.2.0, < 2.0)
143
+ rspec-support (~> 3.10.0)
144
+ rspec-mocks (3.10.2)
145
+ diff-lcs (>= 1.2.0, < 2.0)
146
+ rspec-support (~> 3.10.0)
147
+ rspec-rails (5.0.2)
148
+ actionpack (>= 5.2)
149
+ activesupport (>= 5.2)
150
+ railties (>= 5.2)
151
+ rspec-core (~> 3.10)
152
+ rspec-expectations (~> 3.10)
153
+ rspec-mocks (~> 3.10)
154
+ rspec-support (~> 3.10)
155
+ rspec-support (3.10.2)
156
+ sprockets (4.0.2)
157
+ concurrent-ruby (~> 1.0)
158
+ rack (> 1, < 3)
159
+ sprockets-rails (3.2.2)
160
+ actionpack (>= 4.0)
161
+ activesupport (>= 4.0)
162
+ sprockets (>= 3.0.0)
163
+ thor (1.1.0)
164
+ tzinfo (2.0.4)
165
+ concurrent-ruby (~> 1.0)
166
+ websocket-driver (0.7.5)
167
+ websocket-extensions (>= 0.1.0)
168
+ websocket-extensions (0.1.5)
169
+ xpath (3.2.0)
170
+ nokogiri (~> 1.8)
171
+ zeitwerk (2.4.2)
172
+
173
+ PLATFORMS
174
+ arm64-darwin-20
175
+ x86_64-linux
176
+
177
+ DEPENDENCIES
178
+ capybara (~> 3.35)
179
+ nokogiri (~> 1.12)
180
+ pry (~> 0.14.1)
181
+ rails-footnotes!
182
+ rake (~> 13.0)
183
+ rspec-rails (~> 5.0)
184
+ sprockets-rails (~> 3.2)
185
+
186
+ BUNDLED WITH
187
+ 2.2.23
data/README.rdoc CHANGED
@@ -1,6 +1,4 @@
1
- = Rails Footnotes
2
-
3
- {<img src="https://travis-ci.org/josevalim/rails-footnotes.png" />}[https://travis-ci.org/josevalim/rails-footnotes]
1
+ = Rails 6 Footnotes
4
2
 
5
3
  Rails footnotes displays footnotes in your application for easy debugging, such as sessions,
6
4
  request parameters, cookies, filter chain, routes, queries, etc.
@@ -10,17 +8,11 @@ your backtrace lines.
10
8
 
11
9
  == Installation
12
10
 
13
- NOTE: Since this branch aims for Rails 3.2+ support, if you want to use footnotes with Rails 2.3 you should use this branch:
14
-
15
- https://github.com/josevalim/rails-footnotes/tree/rails2
16
-
17
- Installing Rails Footnotes is very easy.
11
+ Add to your `Gemfile`:
18
12
 
19
- === Rails 3.2.x/4.x
13
+ gem "rails-footnotes", "~> 5.0"
20
14
 
21
- gem 'rails-footnotes', '~> 4.0'
22
-
23
- After you install RailsFootnotes and add it to your Gemfile, you need to run the generator:
15
+ Run `bundle install`, then the generator:
24
16
 
25
17
  rails generate rails_footnotes:install
26
18
 
@@ -37,7 +29,7 @@ This will create an initializer with default config and some examples.
37
29
 
38
30
  === Editor links
39
31
 
40
- Textmate, MacVim and Sublime Text 2 are compatible.
32
+ Textmate, MacVim and Sublime Text 3 are compatible.
41
33
 
42
34
  *MacVim*
43
35
 
@@ -52,17 +44,11 @@ the second %d is replaced by the column number.
52
44
  Take note that the order in which the file name (%s), line number (%d) and column number (%d) appears is important.
53
45
  We assume that they appear in that order. "foo://line=%d&file=%s" (%d precedes %s) would throw out an error.
54
46
 
55
- *Sublime* *Text* *2*
56
-
57
- 1. Keep the Textmate prefix, <tt>f.prefix = 'txmt://open?url=file://%s&line=%d&column=%d'</tt>
47
+ *Sublime* *Text* *3*
58
48
 
59
- 2. Install {subl-handler}[https://github.com/asuth/subl-handler]
49
+ Install {subl}[https://github.com/dhoulb/subl], then use:
60
50
 
61
- 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.
62
-
63
- 4. Install {RCDefault}[http://www.rubicode.com/Software/RCDefaultApp]. It's OSX 10.2, but it works.
64
-
65
- 5. Go to RCDefaultApp (OS System Preferences > DefaultApps). Go to URL section, select "tmxt" extension, and set default applicaiton to "SublHandler".
51
+ f.prefix = 'subl://open?url=file://%s&line=%d&column=%d'
66
52
 
67
53
  *Use* *with* *Vagrant* (*and* *other* *virtual* *machines*)
68
54
 
@@ -156,39 +142,7 @@ If you'd like the footnote, to be at a different place (perhaps for aesthetical
156
142
  <div id="footnotes_holder"></div>
157
143
  at an appropriate place, your notes will now appear inside div#footnotes_holder
158
144
 
159
- == Collaborators
160
-
161
- * Leon Li - http://github.com/scorpio
162
- * Keenan Brock - http://github.com/kbrock
163
- * Ivan Storck - http://github.com/ivanoats
164
- * Kris Chamber - http://github.com/kristopher
165
- * Roman V. Babenko - http://github.com/romanvbabenko
166
- * Adrien Siami - http://github.com/intrepidd
167
-
168
145
  == Bugs and Feedback
169
146
 
170
147
  If you discover any bugs, please open an issue.
171
148
  If you just want to give some positive feedback or drop a line, that's fine too!
172
-
173
- === Version 4.x
174
-
175
- Starting from version 4.0, Adren Siami is the maintainer of this plugin.
176
-
177
- === Version 3.x
178
-
179
- This plugin was maintained until version 4.0 by Roman V. Babenko
180
-
181
- Copyright (c) 2010-2014 Roman V. Babenko (romanvbabenko@gmail.com)
182
- http://romanvbabenko.com
183
-
184
- This plugin was maintained until version 3.6 by José Valim
185
-
186
- Copyright (c) 2009 José Valim (jose@plataformatec.com.br)
187
- http://blog.plataformatec.com.br
188
-
189
- === Version 2.0
190
-
191
- This plugin was created and maintained until version 2.0 by Duane Johnson:
192
-
193
- Copyright (c) 2006 InquiryLabs, Inc.
194
- http://blog.inquirylabs.com
data/bin/rake ADDED
@@ -0,0 +1,29 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ #
5
+ # This file was generated by Bundler.
6
+ #
7
+ # The application 'rake' is installed as part of a gem, and
8
+ # this file is here to facilitate running it.
9
+ #
10
+
11
+ require "pathname"
12
+ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
13
+ Pathname.new(__FILE__).realpath)
14
+
15
+ bundle_binstub = File.expand_path("../bundle", __FILE__)
16
+
17
+ if File.file?(bundle_binstub)
18
+ if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
19
+ load(bundle_binstub)
20
+ else
21
+ abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
22
+ Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
23
+ end
24
+ end
25
+
26
+ require "rubygems"
27
+ require "bundler/setup"
28
+
29
+ load Gem.bin_path("rake", "rake")
data/bin/rspec ADDED
@@ -0,0 +1,29 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ #
5
+ # This file was generated by Bundler.
6
+ #
7
+ # The application 'rspec' is installed as part of a gem, and
8
+ # this file is here to facilitate running it.
9
+ #
10
+
11
+ require "pathname"
12
+ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
13
+ Pathname.new(__FILE__).realpath)
14
+
15
+ bundle_binstub = File.expand_path("../bundle", __FILE__)
16
+
17
+ if File.file?(bundle_binstub)
18
+ if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
19
+ load(bundle_binstub)
20
+ else
21
+ abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
22
+ Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
23
+ end
24
+ end
25
+
26
+ require "rubygems"
27
+ require "bundler/setup"
28
+
29
+ load Gem.bin_path("rspec-core", "rspec")
@@ -1,11 +1,10 @@
1
- defined?(Footnotes) && Footnotes.setup do |f|
1
+ Footnotes.setup do |f|
2
2
  # Whether or not to enable footnotes
3
3
  f.enabled = Rails.env.development?
4
- # You can also use a lambda / proc to conditionally toggle footnotes
5
- # Example :
4
+ # You can also use a lambda / proc to conditionally toggle footnotes, like
6
5
  # f.enabled = -> { User.current.admin? }
7
6
  # Beware of thread-safety though, Footnotes.enabled is NOT thread safe
8
- # and should not be modified anywhere else.
7
+ # and should not be modified outside this initializer.
9
8
 
10
9
  # Only toggle some notes :
11
10
  # f.notes = [:session, :cookies, :params, :filters, :routes, :env, :queries, :log]
@@ -24,4 +23,4 @@ defined?(Footnotes) && Footnotes.setup do |f|
24
23
 
25
24
  # Allow to open multiple notes :
26
25
  # f.multiple_notes = true
27
- end
26
+ end if defined?(Footnotes) && Footnotes.respond_to?(:setup)
@@ -5,7 +5,6 @@ require 'rails-footnotes/each_with_rescue'
5
5
  require 'rails-footnotes/filter'
6
6
  require 'rails-footnotes/notes/all'
7
7
  require 'rails-footnotes/extension'
8
- require 'active_support/deprecation'
9
8
 
10
9
  module Footnotes
11
10
  mattr_accessor :before_hooks
@@ -37,11 +36,6 @@ module Footnotes
37
36
  delegate :font_size=, :to => Filter
38
37
  end
39
38
 
40
- def self.run!
41
- ActiveSupport::Deprecation.warn "run! is deprecated and will be removed from future releases, use Footnotes.setup or Footnotes.enabled instead.", caller
42
- Footnotes.enabled = true
43
- end
44
-
45
39
  def self.before(&block)
46
40
  @@before_hooks << block
47
41
  end
@@ -67,6 +61,8 @@ module Footnotes
67
61
  end
68
62
  end
69
63
 
70
- ActionController::Base.send(:include, Footnotes::RailsFootnotesExtension)
64
+ ActiveSupport.on_load(:action_controller) do
65
+ ActionController::Base.send(:include, Footnotes::RailsFootnotesExtension)
66
+ end
71
67
 
72
68
  load Rails.root.join('.rails_footnotes') if Rails.root && Rails.root.join('.rails_footnotes').exist?
@@ -2,31 +2,23 @@ require 'active_support/concern'
2
2
 
3
3
  module Footnotes
4
4
  module RailsFootnotesExtension
5
-
6
5
  extend ActiveSupport::Concern
7
6
 
8
7
  included do
9
- if Rails::VERSION::MAJOR >= 5
10
- prepend_before_action :rails_footnotes_before_filter
11
- after_action :rails_footnotes_after_filter
12
- else
13
- prepend_before_filter :rails_footnotes_before_filter
14
- after_filter :rails_footnotes_after_filter
15
- end
8
+ prepend_before_action :rails_footnotes_before_filter
9
+ after_action :rails_footnotes_after_filter
16
10
  end
17
11
 
18
12
  def rails_footnotes_before_filter
19
- if Footnotes.enabled?(self)
20
- Footnotes::Filter.start!(self)
21
- end
13
+ Footnotes::Filter.start!(self) if Footnotes.enabled?(self)
22
14
  end
23
15
 
24
16
  def rails_footnotes_after_filter
25
- if Footnotes.enabled?(self)
26
- filter = Footnotes::Filter.new(self)
27
- filter.add_footnotes!
28
- filter.close!(self)
29
- end
17
+ return unless Footnotes.enabled?(self)
18
+
19
+ filter = Footnotes::Filter.new(self)
20
+ filter.add_footnotes!
21
+ filter.close!(self)
30
22
  end
31
23
  end
32
24
  end
@@ -47,7 +47,7 @@ module Footnotes
47
47
  if args.empty?
48
48
  @@prefix
49
49
  else
50
- args.map! { |arg| URI.escape(arg.to_s) }
50
+ args.map! { |arg| arg.to_s.split("/").map{|s| ERB::Util.url_encode(s) }.join("/") }
51
51
 
52
52
  if @@prefix.respond_to? :call
53
53
  @@prefix.call *args
@@ -116,7 +116,8 @@ module Footnotes
116
116
  end
117
117
 
118
118
  def valid_format?
119
- ['text/html', nil].include? @controller.response.content_type
119
+ format = @controller.response.content_type
120
+ format.nil? || format.include?("text/html")
120
121
  end
121
122
 
122
123
  def valid_content_type?
@@ -169,7 +170,7 @@ module Footnotes
169
170
  #footnotes_debug table td {padding: 5px; border-bottom: 1px solid #ccc;}
170
171
  #footnotes_debug table td strong {color: #9b1b1b;}
171
172
  #footnotes_debug table th {padding: 5px; border-bottom: 1px solid #ccc;}
172
- #footnotes_debug table tr:nth-child(2n) td {background: #eee;}
173
+ #footnotes_debug table tr:nth-child(2n) td {background: #f5f5f5;}
173
174
  #footnotes_debug table tr:nth-child(2n + 1) td {background: #fff;}
174
175
  #footnotes_debug tbody {text-align: left;}
175
176
  #footnotes_debug .name_values td {vertical-align: top;}
@@ -16,9 +16,9 @@ module Footnotes
16
16
  :@view_runtime,
17
17
  :@marked_for_same_origin_verification
18
18
  ]
19
- cattr_accessor :ignored_assigns, :instance_writter => false
19
+ cattr_accessor :ignored_assigns, :instance_writer => false
20
20
  @@ignored_assigns_pattern = /^@_/
21
- cattr_accessor :ignored_assigns_pattern, :instance_writter => false
21
+ cattr_accessor :ignored_assigns_pattern, :instance_writer => false
22
22
 
23
23
  def initialize(controller)
24
24
  @controller = controller
@@ -24,14 +24,15 @@ module Footnotes
24
24
 
25
25
  protected
26
26
  def scan_text(text)
27
- []
27
+ raise NotImplementedError, "implement this in your subclass"
28
28
  end
29
29
 
30
30
  def parse_files!
31
- asset_paths = Rails.application.config.assets.paths
31
+ asset_paths = Rails.application.config.try(:assets).try(:paths) || []
32
32
  linked_files = []
33
33
 
34
34
  @files.collect do |file|
35
+ file.gsub!(/-[a-f0-9]{64}\./, '.')
35
36
  base_name = File.basename(file)
36
37
  asset_paths.each do |asset_path|
37
38
  results = Dir[File.expand_path(base_name, asset_path) + '*']
@@ -1,7 +1,7 @@
1
1
  module Footnotes
2
2
  module Notes
3
3
  class QueriesNote < AbstractNote
4
- cattr_accessor :alert_db_time, :alert_sql_number, :orm, :ignored_regexps, :instance_writter => false
4
+ cattr_accessor :alert_db_time, :alert_sql_number, :orm, :ignored_regexps, :instance_writer => false
5
5
  @@alert_db_time = 16.0
6
6
  @@alert_sql_number = 8
7
7
  @@query_subscriber = nil
@@ -23,8 +23,8 @@ module Footnotes
23
23
  def title
24
24
  queries = self.events.count
25
25
  total_time = self.events.map(&:duration).sum
26
- query_color = generate_red_color(self.events.count, alert_sql_number)
27
- db_color = generate_red_color(total_time, alert_db_time)
26
+ query_color = alert_color(self.events.count, alert_sql_number)
27
+ db_color = alert_color(total_time, alert_db_time)
28
28
 
29
29
  <<-TITLE
30
30
  <span style="background-color:#{query_color}">Queries (#{queries})</span>
@@ -57,17 +57,16 @@ module Footnotes
57
57
 
58
58
  protected
59
59
  def print_name_and_time(name, time)
60
- "<span style='background-color:#{generate_red_color(time, alert_ratio)}'>#{escape(name || 'SQL')} (#{'%.3fms' % time})</span>"
60
+ "<span style='background-color:#{alert_color(time, alert_ratio)}'>#{escape(name || 'SQL')} (#{'%.3fms' % time})</span>"
61
61
  end
62
62
 
63
63
  def print_query(query)
64
64
  escape(query.to_s.gsub(/(\s)+/, ' ').gsub('`', ''))
65
65
  end
66
66
 
67
- def generate_red_color(value, alert)
68
- c = ((value.to_f/alert).to_i - 1) * 16
69
- c = 0 if c < 0; c = 15 if c > 15; c = (15-c).to_s(16)
70
- "#ff#{c*4}"
67
+ def alert_color(value, threshold)
68
+ return 'transparent' if value < threshold
69
+ '#ffff00'
71
70
  end
72
71
 
73
72
  def alert_ratio
@@ -103,7 +102,7 @@ module Footnotes
103
102
  attr_accessor :events, :ignore_regexps
104
103
 
105
104
  def initialize(orm)
106
- super()
105
+ super()
107
106
  @events = []
108
107
  orm.each {|adapter| ActiveSupport::LogSubscriber.attach_to adapter, self}
109
108
  end
@@ -33,7 +33,8 @@ module Footnotes
33
33
  protected
34
34
 
35
35
  def filename
36
- @filename ||= self.class.template[:file]
36
+ return @filename if defined?(@filename)
37
+ @filename = self.class.template.try(:[], :file)
37
38
  end
38
39
 
39
40
  end
@@ -1,3 +1,3 @@
1
1
  module Footnotes
2
- VERSION = "4.1.8"
2
+ VERSION = "5.0.0"
3
3
  end
@@ -0,0 +1 @@
1
+ require_relative "./rails-footnotes"
@@ -6,22 +6,16 @@ Gem::Specification.new do |s|
6
6
  s.name = "rails-footnotes"
7
7
  s.version = Footnotes::VERSION
8
8
  s.platform = Gem::Platform::RUBY
9
- s.authors = ["Roman V. Babenko", "José Valim", "Keenan Brock", "Duane Johnson", "Adrien Siami"]
10
- s.email = ["romanvbabenko@gmail.com"]
11
- s.homepage = "http://github.com/josevalim/rails-footnotes"
9
+ s.authors = ["Roman V. Babenko", "José Valim", "Keenan Brock", "Duane Johnson", "Adrien Siami", "André Arko"]
10
+ s.email = ["andre@arko.net"]
11
+ s.homepage = "http://github.com/indirect/rails-footnotes"
12
12
  s.summary = %q{Every Rails page has footnotes that gives information about your application and links back to your editor.}
13
13
  s.description = %q{Every Rails page has footnotes that gives information about your application and links back to your editor.}
14
14
 
15
- s.rubyforge_project = "rails-footnotes"
16
-
17
- s.add_dependency "rails", ">= 3.2"
18
-
19
- s.add_development_dependency "rspec-rails", '~> 3.3.2'
20
- s.add_development_dependency "sprockets-rails", '~> 2.0'
21
- s.add_development_dependency "capybara"
15
+ s.add_dependency "rails", "~> 6.0"
16
+ s.required_ruby_version = "~> 3.0"
22
17
 
23
18
  s.files = `git ls-files`.split("\n")
24
19
  s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
25
- s.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
26
20
  s.require_paths = ["lib"]
27
21
  end
@@ -0,0 +1,2 @@
1
+ //= link_directory ../javascripts .js
2
+ //= link_directory ../stylesheets .css
@@ -0,0 +1 @@
1
+ FILES INDEX
@@ -1,10 +1,9 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  class FilesController < ApplicationController
4
-
5
- def index
6
- end
4
+ def index
7
5
  end
6
+ end
8
7
 
9
8
  describe FilesController, type: :controller do
10
9
  render_views
@@ -19,6 +18,7 @@ describe FilesController, type: :controller do
19
18
 
20
19
  it 'includes stylesheets assets in the response' do
21
20
  get :index
21
+ expect(response.body).to include("FILES INDEX")
22
22
  js_debug = first('fieldset#javascripts_debug_info div', visible: false)
23
23
  expect(js_debug).to have_selector('li a', visible: false, count: 1)
24
24
  expect(js_debug).to have_selector('li a', text: /foobar\.js/, visible: false)
@@ -3,15 +3,15 @@ require 'spec_helper'
3
3
  class FootnotesController < ActionController::Base
4
4
 
5
5
  def foo
6
- render :text => HTML_DOCUMENT, :content_type => 'text/html'
6
+ render inline: HTML_DOCUMENT, content_type: 'text/html'
7
7
  end
8
8
 
9
9
  def foo_holder
10
- render :text => '<html><body><div id="footnotes_holder"></div></body></html>'
10
+ render inline: '<html><body><div id="footnotes_holder"></div></body></html>'
11
11
  end
12
12
 
13
13
  def foo_js
14
- render :text => '<script></script>', :content_type => 'text/javascript'
14
+ render inline: '<script></script>', content_type: 'text/javascript'
15
15
  end
16
16
 
17
17
  def foo_download
@@ -75,7 +75,7 @@ describe FootnotesController, type: :controller do
75
75
  describe 'when request is xhr' do
76
76
  include_context 'has_no_footnotes'
77
77
  before do
78
- xhr :get, :foo
78
+ get :foo, xhr: true
79
79
  end
80
80
  end
81
81
 
@@ -10,7 +10,7 @@ describe 'log note', type: :controller do
10
10
  def index
11
11
  Rails.logger.error 'foo'
12
12
  Rails.logger.warn 'bar'
13
- render :text => '<html><head></head><body></body></html>', :content_type => 'text/html'
13
+ render inline: '<html><head></head><body></body></html>', content_type: 'text/html'
14
14
  end
15
15
  end
16
16
 
@@ -9,11 +9,11 @@ end
9
9
  describe Footnotes::Notes::EnvNote do
10
10
  let(:controller) {
11
11
  FootnotesEnvController.new.tap { |c|
12
- c.template = Object.new
13
- c.request = ActionController::TestRequest.new
14
- c.response = ActionController::TestResponse.new
12
+ c.template = Object.new
13
+ c.request = ActionDispatch::TestRequest.create
14
+ c.response = ActionDispatch::TestResponse.new
15
15
  c.response_body = %Q(<html><body></body></html>)
16
- c.params = {}
16
+ c.params = {}
17
17
  }
18
18
  }
19
19
 
@@ -30,8 +30,8 @@ describe "Footnotes" do
30
30
  before do
31
31
  @controller = FootnotesController.new
32
32
  @controller.template = Object.new
33
- @controller.request = ActionController::TestRequest.new
34
- @controller.response = ActionController::TestResponse.new
33
+ @controller.request = ActionDispatch::TestRequest.create
34
+ @controller.response = ActionDispatch::TestResponse.new
35
35
  @controller.response_body = HTML_DOCUMENT.dup
36
36
  @controller.params = {}
37
37
 
@@ -48,6 +48,7 @@ describe "Footnotes" do
48
48
  context "response_body is file" do
49
49
  before do
50
50
  @file = Tempfile.new("test")
51
+ def @file.body; read; end
51
52
  @file.write "foobarbaz"
52
53
  @file.rewind
53
54
  end
@@ -89,7 +90,7 @@ describe "Footnotes" do
89
90
  end
90
91
 
91
92
  specify "footnotes_included_when_content_type_is_html" do
92
- @controller.response.content_type = 'text/html'
93
+ @controller.response.content_type = 'text/html; charset=utf-8'
93
94
  footnotes_perform!
94
95
  expect(@controller.response.body).not_to eql HTML_DOCUMENT
95
96
  end
@@ -25,7 +25,7 @@ describe Footnotes::Notes::AssignsNote do
25
25
  specify {expect(note.send(:to_table)).to eql [
26
26
  ["Name", "Value"],
27
27
  ["<strong>@action_has_layout</strong><br /><em>TrueClass</em>", "true"],
28
- ["<strong>@status</strong><br /><em>Fixnum</em>", "200"]
28
+ ["<strong>@status</strong><br /><em>Integer</em>", "200"]
29
29
  ]}
30
30
 
31
31
  describe "Ignored Assigns" do
@@ -43,7 +43,7 @@ describe Footnotes::Notes::AssignsNote do
43
43
  [
44
44
  ["Name", "Value"],
45
45
  ["<strong>@action_has_layout</strong><br /><em>TrueClass</em>", "true"],
46
- ["<strong>@status</strong><br /><em>Fixnum</em>", "200"]
46
+ ["<strong>@status</strong><br /><em>Integer</em>", "200"]
47
47
  ], {:summary=>"Debug information for Assigns (2)"})
48
48
  note.content
49
49
  end
@@ -2,10 +2,16 @@ require 'spec_helper'
2
2
  require 'action_controller'
3
3
  require "rails-footnotes/notes/files_note"
4
4
 
5
+ class ConcreteFilesNote < Footnotes::Notes::FilesNote
6
+ def scan_text(text)
7
+ []
8
+ end
9
+ end
10
+
5
11
  describe Footnotes::Notes::FilesNote do
6
12
 
7
13
  let(:note) do
8
- Footnotes::Notes::FilesNote.new(double('controller', :response => double('', :body => '')))
14
+ ConcreteFilesNote.new(double('controller', :response => double('', :body => '')))
9
15
  end
10
16
 
11
17
  subject { note }
@@ -2,11 +2,17 @@ require "spec_helper"
2
2
  require "rails-footnotes/notes/view_note"
3
3
 
4
4
  describe Footnotes::Notes::ViewNote do
5
-
6
5
  it "should not be valid if view file not exist" do
7
6
  note = Footnotes::Notes::ViewNote.new(double)
8
7
  allow(note).to receive(:filename).and_return(nil)
9
8
 
10
9
  expect(note).not_to be_valid
11
10
  end
11
+
12
+ it "should not explode if template is nil" do
13
+ Footnotes::Notes::ViewNote.template = nil
14
+
15
+ note = Footnotes::Notes::ViewNote.new(double)
16
+ expect(note).to_not be_valid
17
+ end
12
18
  end
data/spec/spec_helper.rb CHANGED
@@ -35,6 +35,7 @@ RSpec.configure do |config|
35
35
 
36
36
  config.include Capybara::DSL
37
37
  config.include Helpers
38
+ config.example_status_persistence_file_path = ".rspec_results"
38
39
 
39
40
  Rails.application.routes.draw do
40
41
  get 'footnotes/foo'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails-footnotes
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.1.8
4
+ version: 5.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Roman V. Babenko
@@ -9,83 +9,45 @@ authors:
9
9
  - Keenan Brock
10
10
  - Duane Johnson
11
11
  - Adrien Siami
12
- autorequire:
12
+ - André Arko
13
+ autorequire:
13
14
  bindir: bin
14
15
  cert_chain: []
15
- date: 2016-01-15 00:00:00.000000000 Z
16
+ date: 2021-08-23 00:00:00.000000000 Z
16
17
  dependencies:
17
18
  - !ruby/object:Gem::Dependency
18
19
  name: rails
19
- requirement: !ruby/object:Gem::Requirement
20
- requirements:
21
- - - ">="
22
- - !ruby/object:Gem::Version
23
- version: '3.2'
24
- type: :runtime
25
- prerelease: false
26
- version_requirements: !ruby/object:Gem::Requirement
27
- requirements:
28
- - - ">="
29
- - !ruby/object:Gem::Version
30
- version: '3.2'
31
- - !ruby/object:Gem::Dependency
32
- name: rspec-rails
33
- requirement: !ruby/object:Gem::Requirement
34
- requirements:
35
- - - "~>"
36
- - !ruby/object:Gem::Version
37
- version: 3.3.2
38
- type: :development
39
- prerelease: false
40
- version_requirements: !ruby/object:Gem::Requirement
41
- requirements:
42
- - - "~>"
43
- - !ruby/object:Gem::Version
44
- version: 3.3.2
45
- - !ruby/object:Gem::Dependency
46
- name: sprockets-rails
47
20
  requirement: !ruby/object:Gem::Requirement
48
21
  requirements:
49
22
  - - "~>"
50
23
  - !ruby/object:Gem::Version
51
- version: '2.0'
52
- type: :development
24
+ version: '6.0'
25
+ type: :runtime
53
26
  prerelease: false
54
27
  version_requirements: !ruby/object:Gem::Requirement
55
28
  requirements:
56
29
  - - "~>"
57
30
  - !ruby/object:Gem::Version
58
- version: '2.0'
59
- - !ruby/object:Gem::Dependency
60
- name: capybara
61
- requirement: !ruby/object:Gem::Requirement
62
- requirements:
63
- - - ">="
64
- - !ruby/object:Gem::Version
65
- version: '0'
66
- type: :development
67
- prerelease: false
68
- version_requirements: !ruby/object:Gem::Requirement
69
- requirements:
70
- - - ">="
71
- - !ruby/object:Gem::Version
72
- version: '0'
31
+ version: '6.0'
73
32
  description: Every Rails page has footnotes that gives information about your application
74
33
  and links back to your editor.
75
34
  email:
76
- - romanvbabenko@gmail.com
35
+ - andre@arko.net
77
36
  executables: []
78
37
  extensions: []
79
38
  extra_rdoc_files: []
80
39
  files:
40
+ - ".github/workflows/ci.yml"
81
41
  - ".gitignore"
82
42
  - ".rspec.example"
83
- - ".travis.yml"
84
43
  - CHANGELOG
85
44
  - Gemfile
45
+ - Gemfile.lock
86
46
  - MIT-LICENSE
87
47
  - README.rdoc
88
48
  - Rakefile
49
+ - bin/rake
50
+ - bin/rspec
89
51
  - gemfiles/Gemfile.rails-3.2.22
90
52
  - gemfiles/Gemfile.rails-4.0.x
91
53
  - gemfiles/Gemfile.rails-4.1.x
@@ -117,8 +79,10 @@ files:
117
79
  - lib/rails-footnotes/notes/stylesheets_note.rb
118
80
  - lib/rails-footnotes/notes/view_note.rb
119
81
  - lib/rails-footnotes/version.rb
82
+ - lib/rails6-footnotes.rb
120
83
  - rails-footnotes.gemspec
121
84
  - spec/abstract_note_spec.rb
85
+ - spec/app/assets/config/manifest.js
122
86
  - spec/app/assets/javascripts/foobar.js
123
87
  - spec/app/assets/stylesheets/foobar.css
124
88
  - spec/app/views/files/index.html.erb
@@ -139,32 +103,32 @@ files:
139
103
  - spec/notes/stylesheets_note_spec.rb
140
104
  - spec/notes/view_note_spec.rb
141
105
  - spec/spec_helper.rb
142
- homepage: http://github.com/josevalim/rails-footnotes
106
+ homepage: http://github.com/indirect/rails-footnotes
143
107
  licenses: []
144
108
  metadata: {}
145
- post_install_message:
109
+ post_install_message:
146
110
  rdoc_options: []
147
111
  require_paths:
148
112
  - lib
149
113
  required_ruby_version: !ruby/object:Gem::Requirement
150
114
  requirements:
151
- - - ">="
115
+ - - "~>"
152
116
  - !ruby/object:Gem::Version
153
- version: '0'
117
+ version: '3.0'
154
118
  required_rubygems_version: !ruby/object:Gem::Requirement
155
119
  requirements:
156
120
  - - ">="
157
121
  - !ruby/object:Gem::Version
158
122
  version: '0'
159
123
  requirements: []
160
- rubyforge_project: rails-footnotes
161
- rubygems_version: 2.5.0
162
- signing_key:
124
+ rubygems_version: 3.2.23
125
+ signing_key:
163
126
  specification_version: 4
164
127
  summary: Every Rails page has footnotes that gives information about your application
165
128
  and links back to your editor.
166
129
  test_files:
167
130
  - spec/abstract_note_spec.rb
131
+ - spec/app/assets/config/manifest.js
168
132
  - spec/app/assets/javascripts/foobar.js
169
133
  - spec/app/assets/stylesheets/foobar.css
170
134
  - spec/app/views/files/index.html.erb
data/.travis.yml DELETED
@@ -1,25 +0,0 @@
1
- cache: bundler
2
- sudo: false
3
- script: "bundle exec rake"
4
- rvm:
5
- - 1.9.3
6
- - 2.0.0
7
- - 2.1.7
8
- - 2.2.3
9
- gemfile:
10
- - gemfiles/Gemfile.rails-3.2.22
11
- - gemfiles/Gemfile.rails-4.0.x
12
- - gemfiles/Gemfile.rails-4.1.x
13
- - gemfiles/Gemfile.rails-4.2.x
14
- - gemfiles/Gemfile.rails-edge
15
- matrix:
16
- allow_failures:
17
- - gemfile: gemfiles/Gemfile.rails-edge
18
- - gemfile: gemfiles/Gemfile.rails-3.2.22
19
- exclude:
20
- - rvm: 1.9.3
21
- gemfile: gemfiles/Gemfile.rails-edge
22
- - rvm: 2.0.0
23
- gemfile: gemfiles/Gemfile.rails-edge
24
- - rvm: 2.1.7
25
- gemfile: gemfiles/Gemfile.rails-edge