high_voltage 2.2.0 → 3.0.0

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 (86) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +2 -4
  3. data/.travis.yml +15 -5
  4. data/Appraisals +7 -10
  5. data/CONTRIBUTING.md +4 -1
  6. data/Gemfile +4 -1
  7. data/Gemfile.lock +65 -43
  8. data/MIT-LICENSE +1 -1
  9. data/NEWS.md +18 -0
  10. data/README.md +86 -18
  11. data/Rakefile +9 -4
  12. data/app/controllers/concerns/high_voltage/static_page.rb +8 -11
  13. data/gemfiles/rails4.0.gemfile +9 -0
  14. data/gemfiles/rails4.1.gemfile +9 -0
  15. data/gemfiles/rails4.2.gemfile +9 -0
  16. data/gemfiles/rails50.gemfile +10 -0
  17. data/high_voltage.gemspec +0 -2
  18. data/lib/high_voltage/configuration.rb +4 -22
  19. data/lib/high_voltage/constraints/root_route.rb +17 -10
  20. data/lib/high_voltage/engine.rb +10 -3
  21. data/lib/high_voltage/page.rb +44 -0
  22. data/lib/high_voltage/page_collector.rb +23 -0
  23. data/lib/high_voltage/page_finder.rb +16 -2
  24. data/lib/high_voltage/version.rb +1 -1
  25. data/lib/high_voltage.rb +2 -0
  26. data/spec/constraints/root_route_spec.rb +23 -8
  27. data/spec/controllers/pages_controller_spec.rb +57 -52
  28. data/spec/fake_app.rb +15 -0
  29. data/spec/fixtures/app/views/pages/_partial.html.erb +1 -0
  30. data/spec/fixtures/app/views/pages/text.txt.erb +1 -0
  31. data/spec/fixtures/config/database.yml +3 -0
  32. data/spec/high_voltage/configuration_spec.rb +0 -57
  33. data/spec/high_voltage/page_collector_spec.rb +36 -0
  34. data/spec/high_voltage/page_finder_spec.rb +34 -14
  35. data/spec/high_voltage/page_spec.rb +65 -0
  36. data/spec/spec_helper.rb +21 -8
  37. data/spec/support/http_method_shim.rb +15 -0
  38. metadata +57 -127
  39. data/spec/controllers/action_caching_controller_spec.rb +0 -38
  40. data/spec/controllers/page_caching_controller_spec.rb +0 -37
  41. data/spec/dummy/Rakefile +0 -7
  42. data/spec/dummy/app/controllers/application_controller.rb +0 -3
  43. data/spec/dummy/app/helpers/application_helper.rb +0 -2
  44. data/spec/dummy/config/application.rb +0 -43
  45. data/spec/dummy/config/boot.rb +0 -10
  46. data/spec/dummy/config/environment.rb +0 -5
  47. data/spec/dummy/config/environments/development.rb +0 -25
  48. data/spec/dummy/config/environments/production.rb +0 -49
  49. data/spec/dummy/config/environments/test.rb +0 -30
  50. data/spec/dummy/config/initializers/backtrace_silencers.rb +0 -7
  51. data/spec/dummy/config/initializers/inflections.rb +0 -10
  52. data/spec/dummy/config/initializers/mime_types.rb +0 -5
  53. data/spec/dummy/config/initializers/secret_key_base.rb +0 -1
  54. data/spec/dummy/config/initializers/secret_token.rb +0 -7
  55. data/spec/dummy/config/initializers/session_store.rb +0 -8
  56. data/spec/dummy/config/locales/en.yml +0 -5
  57. data/spec/dummy/config.ru +0 -4
  58. data/spec/dummy/public/404.html +0 -26
  59. data/spec/dummy/public/422.html +0 -26
  60. data/spec/dummy/public/500.html +0 -26
  61. data/spec/dummy/public/favicon.ico +0 -0
  62. data/spec/dummy/public/javascripts/application.js +0 -2
  63. data/spec/dummy/public/javascripts/controls.js +0 -965
  64. data/spec/dummy/public/javascripts/dragdrop.js +0 -974
  65. data/spec/dummy/public/javascripts/effects.js +0 -1123
  66. data/spec/dummy/public/javascripts/prototype.js +0 -6001
  67. data/spec/dummy/public/javascripts/rails.js +0 -191
  68. data/spec/dummy/public/stylesheets/.gitkeep +0 -0
  69. data/spec/dummy/script/rails +0 -6
  70. /data/spec/{dummy → fixtures}/app/views/layouts/alternate.html.erb +0 -0
  71. /data/spec/{dummy → fixtures}/app/views/layouts/application.html.erb +0 -0
  72. /data/spec/{dummy → fixtures}/app/views/other/wrong.html.erb +0 -0
  73. /data/spec/{dummy → fixtures}/app/views/other_pages/also_dir/also_nested.html.erb +0 -0
  74. /data/spec/{dummy → fixtures}/app/views/other_pages/also_exists.html.erb +0 -0
  75. /data/spec/{dummy → fixtures}/app/views/other_pages/also_exists_but_references_nonexistent_partial.html.erb +0 -0
  76. /data/spec/{dummy → fixtures}/app/views/pages/also_dir/also_nested.html.erb +0 -0
  77. /data/spec/{dummy → fixtures}/app/views/pages/also_exists.html.erb +0 -0
  78. /data/spec/{dummy → fixtures}/app/views/pages/also_exists_but_references_nonexistent_partial.html.erb +0 -0
  79. /data/spec/{dummy → fixtures}/app/views/pages/dir/nested.html.erb +0 -0
  80. /data/spec/{dummy → fixtures}/app/views/pages/exists.html.erb +0 -0
  81. /data/spec/{dummy → fixtures}/app/views/pages/exists_but_references_nonexistent_partial.html.erb +0 -0
  82. /data/spec/{dummy → fixtures}/app/views/pages/rot13.html.erb +0 -0
  83. /data/spec/{dummy → fixtures}/config/routes.rb +0 -0
  84. /data/spec/{dummy → fixtures}/public/pages/exists.html +0 -0
  85. /data/spec/{dummy → support}/app/controllers/alternative_finder_controller.rb +0 -0
  86. /data/spec/{dummy → support}/app/controllers/subclassed_pages_controller.rb +0 -0
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7f93b914b6966f7141851a562ce82ffe1e218e01
4
- data.tar.gz: d6456e304488fec82214e584d9dbd8f261151d69
3
+ metadata.gz: f6fe8331cf7311ae941daea7a313a66e350a5565
4
+ data.tar.gz: d1f5bb5ec3984ce97f167a7e4b56c9936ff1a788
5
5
  SHA512:
6
- metadata.gz: eabead4dde04710b58c97047ca3d0b18af4694696b0e800af9ad0618d08d37c358071999f2fb4a56455857c501d1204a1df73c91c85f58e1fe4d9c71a915d93d
7
- data.tar.gz: 8a0b9a4dabe052d01a1b2f4edc91cc7bd15a36eff75ab49d7db3e4c18fe9509203edc214fc2a5d2767022cdfac32c384b94af8023583a5e39944fd94830be8ba
6
+ metadata.gz: 7b5f88d3c1b88243befa89c0e1c8e1640b9b1556ea070dcbb7eff8bfeab51c88d6907e6746730d9318c4a276f026f45695eefc800e9aba078bc4ee48714860a8
7
+ data.tar.gz: 949ae450736d58557bc15ecdcd6f33098ae2ada670563b9440e8b65e7883d12154ddc170d3f42d1147133d4452ccabe7d771707eef320779113e32bdccc636a7
data/.gitignore CHANGED
@@ -1,9 +1,7 @@
1
1
  .bundle/
2
2
  log/*.log
3
3
  pkg/
4
- spec/dummy/db/*.sqlite3
5
- spec/dummy/log/*.log
6
- spec/dummy/tmp/
7
4
  *.swp
8
- gemfiles/
9
5
  *.gem
6
+ gemfiles/*.lock
7
+ spec/fixtures/log/*.log
data/.travis.yml CHANGED
@@ -1,8 +1,18 @@
1
- language:
2
- - ruby
1
+ gemfile:
2
+ - gemfiles/rails4.0.gemfile
3
+ - gemfiles/rails4.1.gemfile
4
+ - gemfiles/rails4.2.gemfile
3
5
  install:
4
6
  - 'travis_retry bundle install'
7
+ language:
8
+ - ruby
5
9
  rvm:
6
- - 1.9.3
7
- - 2.0.0
8
- - 2.1.2
10
+ - 2.0.0-p648
11
+ - 2.1.8
12
+ - 2.2.4
13
+ - 2.3.0
14
+ script: 'bundle exec rake spec'
15
+ notifications:
16
+ email: false
17
+ sudo: false
18
+ cache: bundler
data/Appraisals CHANGED
@@ -1,16 +1,13 @@
1
- if RUBY_VERSION >= '2.0'
2
- rails_versions = ['~> 3.2.13', '~> 4.0.0', '~> 4.1.0']
3
- else
4
- rails_versions = ['~> 3.1.12', '~> 3.2.13']
5
- end
1
+ rails_versions = ['~> 4.0.0', '~> 4.1.0', '~> 4.2.0']
6
2
 
7
3
  rails_versions.each do |rails_version|
8
4
  appraise "rails#{rails_version.slice(/\d+\.\d+/)}" do
9
5
  gem 'rails', rails_version
10
-
11
- if ['~> 4.0.0', '~> 4.1.0'].include? rails_version
12
- gem 'actionpack-action_caching'
13
- gem 'actionpack-page_caching'
14
- end
15
6
  end
16
7
  end
8
+
9
+ appraise "rails50" do
10
+ gem "rails", "~> 5.0.0.beta3"
11
+ gem "rspec-rails", "3.5.0.beta1"
12
+ gem "rails-controller-testing"
13
+ end
data/CONTRIBUTING.md CHANGED
@@ -1,4 +1,7 @@
1
- We love pull requests. Here's a quick guide:
1
+ We love pull requests from everyone. By participating in this project, you
2
+ agree to abide by the thoughtbot [code of conduct].
3
+
4
+ [code of conduct]: https://thoughtbot.com/open-source-code-of-conduct
2
5
 
3
6
  1. Fork the repo.
4
7
 
data/Gemfile CHANGED
@@ -1,3 +1,6 @@
1
- source "http://rubygems.org"
1
+ source "https://rubygems.org"
2
2
 
3
3
  gemspec
4
+
5
+ gem "appraisal"
6
+ gem "rspec-rails", "~> 3.2"
data/Gemfile.lock CHANGED
@@ -1,30 +1,31 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- high_voltage (2.2.0)
4
+ high_voltage (3.0.0)
5
5
 
6
6
  GEM
7
- remote: http://rubygems.org/
7
+ remote: https://rubygems.org/
8
8
  specs:
9
- actionpack (4.1.1)
10
- actionview (= 4.1.1)
11
- activesupport (= 4.1.1)
12
- rack (~> 1.5.2)
9
+ actionpack (4.2.5.2)
10
+ actionview (= 4.2.5.2)
11
+ activesupport (= 4.2.5.2)
12
+ rack (~> 1.6)
13
13
  rack-test (~> 0.6.2)
14
- actionview (4.1.1)
15
- activesupport (= 4.1.1)
14
+ rails-dom-testing (~> 1.0, >= 1.0.5)
15
+ rails-html-sanitizer (~> 1.0, >= 1.0.2)
16
+ actionview (4.2.5.2)
17
+ activesupport (= 4.2.5.2)
16
18
  builder (~> 3.1)
17
19
  erubis (~> 2.7.0)
18
- activemodel (4.1.1)
19
- activesupport (= 4.1.1)
20
- builder (~> 3.1)
21
- activesupport (4.1.1)
22
- i18n (~> 0.6, >= 0.6.9)
20
+ rails-dom-testing (~> 1.0, >= 1.0.5)
21
+ rails-html-sanitizer (~> 1.0, >= 1.0.2)
22
+ activesupport (4.2.5.2)
23
+ i18n (~> 0.7)
23
24
  json (~> 1.7, >= 1.7.7)
24
25
  minitest (~> 5.1)
25
- thread_safe (~> 0.1)
26
+ thread_safe (~> 0.3, >= 0.3.4)
26
27
  tzinfo (~> 1.1)
27
- appraisal (1.0.0)
28
+ appraisal (1.0.2)
28
29
  bundler
29
30
  rake
30
31
  thor (>= 0.14.0)
@@ -32,39 +33,57 @@ GEM
32
33
  coderay (1.1.0)
33
34
  diff-lcs (1.2.5)
34
35
  erubis (2.7.0)
35
- i18n (0.6.9)
36
- json (1.8.1)
36
+ i18n (0.7.0)
37
+ json (1.8.3)
38
+ loofah (2.0.3)
39
+ nokogiri (>= 1.5.9)
37
40
  method_source (0.8.2)
38
- minitest (5.3.3)
39
- pry (0.9.12.6)
40
- coderay (~> 1.0)
41
- method_source (~> 0.8)
41
+ mini_portile2 (2.0.0)
42
+ minitest (5.8.4)
43
+ nokogiri (1.6.7.2)
44
+ mini_portile2 (~> 2.0.0.rc2)
45
+ pry (0.10.1)
46
+ coderay (~> 1.1.0)
47
+ method_source (~> 0.8.1)
42
48
  slop (~> 3.4)
43
- rack (1.5.2)
44
- rack-test (0.6.2)
49
+ rack (1.6.4)
50
+ rack-test (0.6.3)
45
51
  rack (>= 1.0)
46
- railties (4.1.1)
47
- actionpack (= 4.1.1)
48
- activesupport (= 4.1.1)
52
+ rails-deprecated_sanitizer (1.0.3)
53
+ activesupport (>= 4.2.0.alpha)
54
+ rails-dom-testing (1.0.7)
55
+ activesupport (>= 4.2.0.beta, < 5.0)
56
+ nokogiri (~> 1.6.0)
57
+ rails-deprecated_sanitizer (>= 1.0.1)
58
+ rails-html-sanitizer (1.0.3)
59
+ loofah (~> 2.0)
60
+ railties (4.2.5.2)
61
+ actionpack (= 4.2.5.2)
62
+ activesupport (= 4.2.5.2)
49
63
  rake (>= 0.8.7)
50
64
  thor (>= 0.18.1, < 2.0)
51
- rake (10.3.1)
52
- rspec-core (2.14.8)
53
- rspec-expectations (2.14.5)
54
- diff-lcs (>= 1.1.3, < 2.0)
55
- rspec-mocks (2.14.6)
56
- rspec-rails (2.14.2)
57
- actionpack (>= 3.0)
58
- activemodel (>= 3.0)
59
- activesupport (>= 3.0)
60
- railties (>= 3.0)
61
- rspec-core (~> 2.14.0)
62
- rspec-expectations (~> 2.14.0)
63
- rspec-mocks (~> 2.14.0)
64
- slop (3.5.0)
65
+ rake (10.5.0)
66
+ rspec-core (3.4.3)
67
+ rspec-support (~> 3.4.0)
68
+ rspec-expectations (3.4.0)
69
+ diff-lcs (>= 1.2.0, < 2.0)
70
+ rspec-support (~> 3.4.0)
71
+ rspec-mocks (3.4.1)
72
+ diff-lcs (>= 1.2.0, < 2.0)
73
+ rspec-support (~> 3.4.0)
74
+ rspec-rails (3.4.2)
75
+ actionpack (>= 3.0, < 4.3)
76
+ activesupport (>= 3.0, < 4.3)
77
+ railties (>= 3.0, < 4.3)
78
+ rspec-core (~> 3.4.0)
79
+ rspec-expectations (~> 3.4.0)
80
+ rspec-mocks (~> 3.4.0)
81
+ rspec-support (~> 3.4.0)
82
+ rspec-support (3.4.1)
83
+ slop (3.6.0)
65
84
  thor (0.19.1)
66
- thread_safe (0.3.3)
67
- tzinfo (1.1.0)
85
+ thread_safe (0.3.5)
86
+ tzinfo (1.2.2)
68
87
  thread_safe (~> 0.1)
69
88
 
70
89
  PLATFORMS
@@ -75,4 +94,7 @@ DEPENDENCIES
75
94
  appraisal
76
95
  high_voltage!
77
96
  pry
78
- rspec-rails
97
+ rspec-rails (~> 3.2)
98
+
99
+ BUNDLED WITH
100
+ 1.11.2
data/MIT-LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright 2010-2014 thoughtbot, inc.
1
+ Copyright 2010-2015 thoughtbot, inc.
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
data/NEWS.md CHANGED
@@ -1,3 +1,21 @@
1
+ New for 3.0.0
2
+ + HighVoltage now supports Rails 5.0.0.beta3 and up.
3
+ + Properly handle extensions in root route constraint requests.
4
+ + Removes caching in preparation for Rails 5.
5
+
6
+ New for 2.4.0
7
+ + Retrieve a list of available static pages via `HighVoltage.page_ids`.
8
+ + Properly handle page ids which are blank when being sanitized.
9
+ + Only provide deprecation warnings around caching when caching is enabled.
10
+
11
+ New for 2.3.0:
12
+ + Ruby 2.2 and Rails 4.2 testing
13
+ + Raise InvalidPageIdError when visiting a page with invalid characters
14
+ + Code of Conduct added to Contributing guide
15
+
16
+ New for 2.2.1:
17
+ + Resolve issue with require statements for Rails 3.x projects
18
+
1
19
  New for 2.2.0:
2
20
  + Deprecate caching because page and action caching was removed in Rails 4
3
21
  + Refactor test suite to use rspec `expect` syntax consistently.
data/README.md CHANGED
@@ -15,13 +15,9 @@ Yeah, like "About us", "Directions", marketing pages, etc.
15
15
  Include in your Gemfile:
16
16
 
17
17
  ```ruby
18
- gem 'high_voltage', '~> 2.2.0'
18
+ gem 'high_voltage', '~> 3.0.0'
19
19
  ```
20
20
 
21
- For Rails versions prior to 3.0, use the 0.9.2 tag of high_voltage:
22
-
23
- https://github.com/thoughtbot/high_voltage/tree/v0.9.2
24
-
25
21
  ## Usage
26
22
 
27
23
  Write your static pages and put them in the RAILS_ROOT/app/views/pages directory.
@@ -32,17 +28,28 @@ Write your static pages and put them in the RAILS_ROOT/app/views/pages directory
32
28
  After putting something interesting there, you can link to it from anywhere in your app with:
33
29
 
34
30
  ```ruby
35
- link_to 'About', page_path('about')
31
+ <%= link_to 'About', page_path('about') %>
36
32
  ```
37
33
 
38
34
  You can nest pages in a directory structure, if that makes sense from a URL perspective for you:
39
35
 
40
36
  ```ruby
41
- link_to 'Q4 Reports', page_path('about/corporate/policies/HR/en_US/biz/sales/Quarter-Four')
37
+ <%= link_to 'Q4 Reports', page_path('about/corporate/policies/HR/en_US/biz/sales/Quarter-Four') %>
42
38
  ```
43
39
 
44
40
  Bam.
45
41
 
42
+ You can also get a list of your static pages by calling `HighVoltage.page_ids`
43
+ This might be useful if you need to build a sitemap. For example, if you are
44
+ using the [sitemap_generator](https://github.com/kjvarga/sitemap_generator) gem,
45
+ you could add something like this to your sitemap config file:
46
+
47
+ ```ruby
48
+ HighVoltage.page_ids.each do |page|
49
+ add page, changefreq: 'monthly'
50
+ end
51
+ ```
52
+
46
53
  ## Configuration
47
54
 
48
55
  #### Routing overview
@@ -157,7 +164,7 @@ end
157
164
 
158
165
  #### Caching
159
166
 
160
- Caching has been deprecated and will be removed in the next release.
167
+ Built in caching support has been removed in HighVoltage. See [PR 221](https://github.com/thoughtbot/high_voltage/pull/221).
161
168
 
162
169
  Page caching and action caching can be done via Rails. Visit the [Caching with
163
170
  Rails: An overview](http://guides.rubyonrails.org/caching_with_rails.html) guide
@@ -263,6 +270,58 @@ end
263
270
  Use this to create a custom file mapping, clean filenames for your file
264
271
  system, A/B test, and so on.
265
272
 
273
+ ## Localization
274
+
275
+ [Rails I18n guides](http://guides.rubyonrails.org/i18n.html).
276
+
277
+ Add a before filter to the Application controller
278
+
279
+ ```ruby
280
+ # app/controllers/application_controller.rb
281
+ before_action :set_locale
282
+
283
+ def set_locale
284
+ I18n.locale = params[:locale] || I18n.default_locale
285
+ end
286
+ ```
287
+
288
+ Disable the default High Voltage routes
289
+
290
+ ```ruby
291
+ # config/initializers/high_voltage.rb
292
+ HighVoltage.configure do |config|
293
+ config.routes = false
294
+ end
295
+ ```
296
+
297
+ ```ruby
298
+ # config/routes.rb
299
+ scope "/:locale", locale: /en|bn|hi/ do
300
+ get "/pages/:id" => "high_voltage/pages#show", :as => :page, :format => false
301
+ end
302
+ ```
303
+
304
+ Add a static page to the project
305
+
306
+ ```
307
+ # app/views/pages/about.html.erb
308
+ <%= t "hello" %>
309
+ ```
310
+
311
+ Make sure that there are corresponding locale files
312
+
313
+ ```
314
+ /config/locale/bn.yml
315
+ /config/locale/en.yml
316
+ /config/locale/hi.yml
317
+ ```
318
+
319
+ One last note is there is a [know
320
+ issue](https://github.com/thoughtbot/high_voltage/issues/59) with High Voltage.
321
+
322
+ You'll need to specify routes like this `<%= link_to "About Us", page_path(id:
323
+ "about") %>`
324
+
266
325
  ## Testing
267
326
 
268
327
  You can test your static pages using [RSpec](https://github.com/rspec/rspec-rails)
@@ -272,7 +331,7 @@ and [shoulda-matchers](https://github.com/thoughtbot/shoulda-matchers):
272
331
  # spec/controllers/pages_controller_spec.rb
273
332
  describe PagesController, '#show' do
274
333
  %w(earn_money screencast about contact).each do |page|
275
- context 'on GET to /pages/#{page}' do
334
+ context "on GET to /pages/#{page}" do
276
335
  before do
277
336
  get :show, id: page
278
337
  end
@@ -291,20 +350,29 @@ Enjoy!
291
350
 
292
351
  ## Contributing
293
352
 
294
- Please see [CONTRIBUTING.md](https://github.com/thoughtbot/high_voltage/blob/master/CONTRIBUTING.md)
295
- for details.
353
+ Please see [CONTRIBUTING.md].
354
+ Thank you, [contributors]!
355
+
356
+ [CONTRIBUTING.md]: /CONTRIBUTING.md
357
+ [contributors]: https://github.com/thoughtbot/high_voltage/graphs/contributors
296
358
 
297
- ## Credits
359
+ ## License
298
360
 
299
- ![thoughtbot](http://thoughtbot.com/images/tm/logo.png)
361
+ High Voltage is copyright © 2009-2016 thoughtbot. It is free software, and may
362
+ be redistributed under the terms specified in the [`LICENSE`] file.
300
363
 
301
- High Voltage is maintained and funded by [thoughtbot, inc](http://thoughtbot.com/community)
364
+ [`LICENSE`]: /MIT-LICENSE
302
365
 
303
- Thank you to all [the contributors](https://github.com/thoughtbot/high_voltage/contributors)!
366
+ ## About thoughtbot
304
367
 
368
+ ![thoughtbot](https://thoughtbot.com/logo.png)
369
+
370
+ High Voltage is maintained and funded by thoughtbot, inc.
305
371
  The names and logos for thoughtbot are trademarks of thoughtbot, inc.
306
372
 
307
- ## License
373
+ We love open source software!
374
+ See [our other projects][community].
375
+ We are [available for hire][hire].
308
376
 
309
- High Voltage is Copyright © 2009-2014 thoughtbot. It is free software, and may
310
- be redistributed under the terms specified in the MIT-LICENSE file.
377
+ [community]: https://thoughtbot.com/community?utm_source=github
378
+ [hire]: https://thoughtbot.com/hire-us?utm_source=github
data/Rakefile CHANGED
@@ -11,9 +11,14 @@ require 'appraisal'
11
11
  RSpec::Core::RakeTask.new(:spec)
12
12
 
13
13
  desc 'Default'
14
- task :default => [:all]
14
+ task :default do
15
+ if ENV['BUNDLE_GEMFILE'] =~ /gemfiles/
16
+ Rake::Task['spec'].invoke
17
+ else
18
+ Rake::Task['appraise'].invoke
19
+ end
20
+ end
15
21
 
16
- desc 'Test the engine under all supported Rails versions'
17
- task all: ['appraisal:install'] do |t|
18
- exec 'rake appraisal spec'
22
+ task :appraise do
23
+ exec 'appraisal install && appraisal rake'
19
24
  end
@@ -6,28 +6,25 @@ module HighVoltage::StaticPage
6
6
 
7
7
  rescue_from ActionView::MissingTemplate do |exception|
8
8
  if exception.message =~ %r{Missing template #{page_finder.content_path}}
9
- raise ActionController::RoutingError, "No such page: #{params[:id]}"
9
+ invalid_page
10
10
  else
11
11
  raise exception
12
12
  end
13
13
  end
14
14
 
15
- if respond_to?(:caches_action)
16
- caches_action :show, layout: HighVoltage.action_caching_layout,
17
- if: -> { HighVoltage.action_caching }
18
- end
19
-
20
- if respond_to?(:caches_page)
21
- caches_page :show, if: -> { HighVoltage.page_caching }
22
- end
23
-
24
- hide_action :current_page, :page_finder, :page_finder_factory
15
+ rescue_from HighVoltage::InvalidPageIdError, with: :invalid_page
25
16
  end
26
17
 
27
18
  def show
28
19
  render template: current_page
29
20
  end
30
21
 
22
+ def invalid_page
23
+ raise ActionController::RoutingError, "No such page: #{params[:id]}"
24
+ end
25
+
26
+ private
27
+
31
28
  def current_page
32
29
  page_finder.find
33
30
  end
@@ -0,0 +1,9 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "appraisal"
6
+ gem "rspec-rails", "~> 3.2"
7
+ gem "rails", "~> 4.0.0"
8
+
9
+ gemspec :path => "../"
@@ -0,0 +1,9 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "appraisal"
6
+ gem "rspec-rails", "~> 3.2"
7
+ gem "rails", "~> 4.1.0"
8
+
9
+ gemspec :path => "../"
@@ -0,0 +1,9 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "appraisal"
6
+ gem "rspec-rails", "~> 3.2"
7
+ gem "rails", "~> 4.2.0"
8
+
9
+ gemspec :path => "../"
@@ -0,0 +1,10 @@
1
+ # This file was generated by Appraisal
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gem "appraisal"
6
+ gem "rspec-rails", "3.5.0.beta1"
7
+ gem "rails", "~> 5.0.0.beta3"
8
+ gem "rails-controller-testing"
9
+
10
+ gemspec :path => "../"
data/high_voltage.gemspec CHANGED
@@ -17,7 +17,5 @@ Gem::Specification.new do |s|
17
17
  s.require_paths = ["lib"]
18
18
 
19
19
  s.add_development_dependency("activesupport", ">= 3.1.0")
20
- s.add_development_dependency("appraisal")
21
20
  s.add_development_dependency("pry")
22
- s.add_development_dependency("rspec-rails")
23
21
  end
@@ -1,10 +1,5 @@
1
1
  module HighVoltage
2
2
  module Configuration
3
- CACHING_DEPRECATION_WARNING = <<-WARNING.strip_heredoc.squish
4
- Caching support has been deprecated and will be removed
5
- in the next release.
6
- WARNING
7
-
8
3
  attr_accessor(
9
4
  :content_path,
10
5
  :home_page,
@@ -14,8 +9,6 @@ module HighVoltage
14
9
  :routes,
15
10
  )
16
11
 
17
- attr_reader :action_caching, :action_caching_layout, :page_caching
18
-
19
12
  def configure
20
13
  yield self
21
14
  end
@@ -24,26 +17,15 @@ module HighVoltage
24
17
  base.set_default_configuration
25
18
  end
26
19
 
27
- def action_caching=(value)
28
- ActiveSupport::Deprecation.warn(CACHING_DEPRECATION_WARNING)
29
- @action_caching = value
20
+ def page_ids
21
+ HighVoltage::PageCollector.new(HighVoltage.full_path).page_ids
30
22
  end
31
23
 
32
- def action_caching_layout=(value)
33
- ActiveSupport::Deprecation.warn(CACHING_DEPRECATION_WARNING)
34
- @action_caching_layout = value
35
- end
36
-
37
- def page_caching=(value)
38
- ActiveSupport::Deprecation.warn(CACHING_DEPRECATION_WARNING)
39
- @page_caching = value
24
+ def full_path
25
+ Rails.root.join("app", "views", HighVoltage.content_path)
40
26
  end
41
27
 
42
28
  def set_default_configuration
43
- @action_caching = false
44
- @action_caching_layout = true
45
- @page_caching = false
46
-
47
29
  self.content_path = 'pages/'
48
30
  self.home_page = nil
49
31
  self.layout = 'application'
@@ -2,20 +2,27 @@ module HighVoltage
2
2
  module Constraints
3
3
  # Routing constraint to validate request.path has a corresponding view
4
4
  class RootRoute
5
- def self.matches?(request)
6
- pattern = file_pattern(request.path)
5
+ class << self
6
+ def matches?(request)
7
+ page_id = clean_page_path(request.path)
8
+ pattern = file_pattern(page_id)
7
9
 
8
- Dir.glob(pattern).any?
9
- end
10
+ Dir.glob(pattern).any?
11
+ end
10
12
 
11
- private
13
+ private
12
14
 
13
- def self.file_pattern(page_id)
14
- "#{content_path}#{page_id}.html*"
15
- end
15
+ def clean_page_path(request_path)
16
+ request_path.sub(/\.html$/, "")
17
+ end
18
+
19
+ def file_pattern(page_id)
20
+ "#{content_path}#{page_id}.html*"
21
+ end
16
22
 
17
- def self.content_path
18
- Rails.root.join('app', 'views', HighVoltage.content_path).to_s
23
+ def content_path
24
+ Rails.root.join("app", "views", HighVoltage.content_path).to_s
25
+ end
19
26
  end
20
27
  end
21
28
  end
@@ -1,15 +1,22 @@
1
1
  module HighVoltage
2
2
  class Engine < Rails::Engine
3
- initializer 'Set up default parent engine' do |app|
3
+ initializer "Set up default parent engine" do |app|
4
4
  HighVoltage.parent_engine ||= Rails.application
5
5
  end
6
6
 
7
- initializer 'Require concerns path' do |app|
8
- concerns_path = 'app/controllers/concerns'
7
+ initializer "Require concerns path" do |app|
8
+ concerns_path = "app/controllers/concerns"
9
9
 
10
10
  unless app.paths.keys.include?(concerns_path)
11
11
  app.paths.add(concerns_path)
12
12
  end
13
13
  end
14
+
15
+ initializer "Require for Rails 3" do |app|
16
+ if defined?(Rails) && Rails::VERSION::MAJOR == 3
17
+ require "concerns/high_voltage/static_page"
18
+ require "high_voltage/pages_controller"
19
+ end
20
+ end
14
21
  end
15
22
  end