rack-dev-mark 0.6.3 → 0.6.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- ZTIwYWU4ODJlNDk4YTRmOWYwNzlmMDU2YjcwN2UwNTEwYzA5YmU2Ng==
4
+ ZGQ4OTM0MjZiOGJkMDAxYTNhOTNmNGMzYTQwYjVjNGZlOTYzMTMzOQ==
5
5
  data.tar.gz: !binary |-
6
- YzU3OGZhNTFkNjdjNTdjNGVhZjk4NzNkMjYxODQ2NGI5NzdlMDVkZg==
6
+ ZTMxN2EyYjhhZDE0YWRhYTkxYjJhNDc3MjlkMzhmMGY0YjM1ODE1YQ==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- Mjk4NTVkMDk3ZDc4MThkMzNiYjNjMDFlNzliM2U2ZWI0ZDNlZjhmYmQ0NWI3
10
- MWQxMjQ0ZWVlZDEwOGVlZGNjMWM0YTY4ZWM3ZTE4NDE1NTNlOGU3ZTFkYmQ4
11
- NTM0ZjUxYjg0OGI1ODIwZjlmNmM2MzJiNGE1ZDUyZWYyYzYzMzQ=
9
+ NjJiMmI5N2M3Nzc1ZjhiNWZjNWY0MDZlOWJkMzkyZGIwMjNmNTU4YmY5MTYz
10
+ YmUyZmY1ZTY1ZDZmMTFiZTY4ZDMxZjk0MGFhNzUwNzY5YjI1YmRjMWY0YzNk
11
+ NmU4YWFjZTRmYTA5ODg5NzQ1YTFiOTVjY2E5YTUzZmYxZGU0NjA=
12
12
  data.tar.gz: !binary |-
13
- YjYxMmEyZjFjMjdlODc0ZmIxNmI3ZWUyMTY3MzcwNDdlNTA0ZTY2MmM5NzAx
14
- ODMwNTVjZWNiNGQ1MTJmNmM1MmI3ZDM0YTNhYThhOGM2Y2Y2ZDYzYjA2OWYy
15
- YjFjNGU1YmE5OGMwMzZlNjJhN2M1ODk5ZWY3MmFlMDhiMzcyMTU=
13
+ NjUwOTM0ZThmYmY2ZTQ1ZTUzMGI0OGVlOWFhMjM2YjEyNmU1YThmYzJjMzY4
14
+ ZTA3ZjA4MjkzMjQzMDM4NGYwYWU3ODI0YjdlMzkwOWI0MzUwODA4YWJkYTFm
15
+ ZjA5ODQxMjUzYTVlYWQzOTQ5ZDBkYTgzNTRiMjdjNTUzMTc5MDE=
@@ -0,0 +1,32 @@
1
+ # Compatibility with Other Middlewares
2
+
3
+ ## Rack::Deflater
4
+
5
+ Some people ask rack-dev-mark does not work with `Rack::Delfater`. Those who ask this question typically insert `Rack::Deflater` by `config.middleware.use Rack::Deflater`. To deflate all the response including the error pages, you need to put the middleware before `ActionDispatch::ShowExceptions`. So the order of those 3 middlewares including `rack-dev-mark` looks like below.
6
+
7
+ ```ruby
8
+ use Rack::Deflater
9
+ use Rack::DevMark::Middleware
10
+ use ActionDispatch::ShowExceptions
11
+ ```
12
+
13
+ To make the order above, you can have the following settings for `Rack::Deflater`.
14
+
15
+ ```ruby
16
+ module MyApp
17
+ class Application < Rails::Application
18
+ config.middleware.insert_before ActionDispatch::ShowExceptions, Rack::Deflater
19
+ end
20
+ end
21
+ ```
22
+
23
+ Of course, you can stick the `config.middleware.use Rack::Deflater` by the following settings for `rack-dev-mark`.
24
+
25
+ ```ruby
26
+ module MyApp
27
+ class Application < Rails::Application
28
+ config.rack_dev_mark.insert_after Rack::Deflater
29
+ end
30
+ end
31
+ ```
32
+
data/README.md CHANGED
@@ -93,6 +93,22 @@ heroku config:set RACK_DEV_MARK_ENV=staging
93
93
 
94
94
  That's it!
95
95
 
96
+ #### Custom Rack Middleware Order
97
+
98
+ `rack-dev-mark` should be inserted before `ActionDispatch::ShowExceptions` becase we want to show the dev mark on the error pages as well. However, it does not work well if it's inserted by incorrect order with some other rack middlewares. So, it provides the setting of inserted place.
99
+
100
+ ```ruby
101
+ module MyApp
102
+ class Application < Rails::Application
103
+ config.rack_dev_mark.insert_before SomeOtherMiddleware
104
+ end
105
+ end
106
+ ```
107
+
108
+ `config.rack_dev_mark.insert_after` is also available to insert `rack-dev-mark` after a middleware.
109
+
110
+ [Here](COMPATIBILITY.md) is the compatibility list which many people often ask.
111
+
96
112
  ## Custom Theme
97
113
 
98
114
  Although the default themes are `title` and `github_fork_ribbon`, you can create your own themes inheriting `Rack::DevMark::Theme::Base`.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.6.3
1
+ 0.6.4
@@ -13,6 +13,10 @@ module Rack
13
13
  config.rack_dev_mark.enable = !Rails.env.production?
14
14
  # Customize themes if you want to do so
15
15
  # config.rack_dev_mark.theme = [:title, :github_fork_ribbon]
16
+ # Customize inserted place of the middleware if necessary.
17
+ # You can use either `insert_before` or `insert_after`
18
+ # config.rack_dev_mark.insert_before SomeOtherMiddleware
19
+ # config.rack_dev_mark.insert_after SomeOtherMiddleware
16
20
 
17
21
  EOS
18
22
  end
@@ -0,0 +1,21 @@
1
+ module Rack
2
+ module DevMark
3
+ class RailsOptions
4
+ attr_accessor :enable, :theme
5
+
6
+ alias_method :custom_theme, :theme
7
+ alias_method :custom_theme=, :theme=
8
+
9
+ %w(before after).each do |type|
10
+ method_name = "insert_#{type}"
11
+ define_method method_name do |middleware|
12
+ @insert_type = [method_name, middleware]
13
+ end
14
+ end
15
+
16
+ def insert_type
17
+ @insert_type ||= []
18
+ end
19
+ end
20
+ end
21
+ end
@@ -1,17 +1,25 @@
1
1
  require 'rails'
2
+ require_relative 'rails_options'
2
3
 
3
4
  module Rack
4
5
  module DevMark
5
6
  class Railtie < Rails::Railtie
6
- config.rack_dev_mark = ActiveSupport::OrderedOptions.new
7
+ config.rack_dev_mark = RailsOptions.new
7
8
 
8
9
  initializer "rack-dev-mark.configure_rails_initialization" do |app|
9
10
  if app.config.rack_dev_mark.enable || Rack::DevMark.rack_dev_mark_env
10
- racks = [ActionDispatch::ShowExceptions, Rack::DevMark::Middleware]
11
+ racks = []
12
+
13
+ insert_type = app.config.rack_dev_mark.insert_type
14
+ insert_method = insert_type[0] || 'insert_before'
15
+ racks << (insert_type[1] || ActionDispatch::ShowExceptions)
16
+
17
+ racks << Rack::DevMark::Middleware
11
18
  if theme = app.config.rack_dev_mark.theme || app.config.rack_dev_mark.custom_theme
12
19
  racks << theme
13
20
  end
14
- app.config.app_middleware.insert_before *racks
21
+
22
+ app.config.app_middleware.send(insert_method, *racks)
15
23
  end
16
24
  end
17
25
  end
@@ -34,6 +34,10 @@ module MyApp
34
34
  config.rack_dev_mark.enable = !Rails.env.production?
35
35
  # Customize themes if you want to do so
36
36
  # config.rack_dev_mark.theme = [:title, :github_fork_ribbon]
37
+ # Customize inserted place of the middleware if necessary.
38
+ # You can use either `insert_before` or `insert_after`
39
+ # config.rack_dev_mark.insert_before SomeOtherMiddleware
40
+ # config.rack_dev_mark.insert_after SomeOtherMiddleware
37
41
 
38
42
  # ...
39
43
  end
@@ -41,5 +45,12 @@ end
41
45
  EOS
42
46
  end
43
47
  end
48
+
49
+ describe "#target_path (private)" do
50
+ subject { Rack::DevMark::InstallGenerator.new }
51
+ it "returns 'config/application.rb'" do
52
+ expect(subject.__send__(:target_path)).to eq('config/application.rb')
53
+ end
54
+ end
44
55
  end
45
56
  end
@@ -0,0 +1,31 @@
1
+ require 'spec_helper'
2
+
3
+ if defined?(::Rails)
4
+ describe Rack::DevMark::RailsOptions do
5
+ subject { Rack::DevMark::RailsOptions.new }
6
+ it do
7
+ is_expected.to respond_to(:enable)
8
+ is_expected.to respond_to(:enable=)
9
+ is_expected.to respond_to(:theme)
10
+ is_expected.to respond_to(:theme=)
11
+ is_expected.to respond_to(:insert_type)
12
+ is_expected.not_to respond_to(:insert_type=)
13
+ end
14
+ it "has aliases of theme methods" do
15
+ expect(subject.method(:theme)).to eq(subject.method(:custom_theme))
16
+ expect(subject.method(:theme=)).to eq(subject.method(:custom_theme=))
17
+ end
18
+ describe "#insert_before" do
19
+ it "has the implicit setter of insert_type" do
20
+ subject.insert_before 'something'
21
+ expect(subject.insert_type).to eq(['insert_before', 'something'])
22
+ end
23
+ end
24
+ describe "#insert_after" do
25
+ it "has the implicit setter of insert_type" do
26
+ subject.insert_after 'something'
27
+ expect(subject.insert_type).to eq(['insert_after', 'something'])
28
+ end
29
+ end
30
+ end
31
+ end
@@ -15,7 +15,9 @@ describe Rack::DevMark::Railtie do
15
15
  end
16
16
  it 'inserts the middleware' do
17
17
  @app.initialize!
18
- expect(@app.middleware.middlewares).to include(Rack::DevMark::Middleware)
18
+ middlewares = @app.middleware.middlewares
19
+ expect(middlewares).to include(Rack::DevMark::Middleware)
20
+ expect(middlewares.index(Rack::DevMark::Middleware)).to eq(middlewares.index(ActionDispatch::ShowExceptions) - 1)
19
21
  end
20
22
  end
21
23
  context "rack_dev_mark disable" do
@@ -58,5 +60,35 @@ describe Rack::DevMark::Railtie do
58
60
  expect(theme).to receive(:setup)
59
61
  end
60
62
  end
63
+ context "rack_dev_mark insert_before" do
64
+ let(:dummy_middleware) { Class.new{ define_method(:initialize) { |_| }; define_method(:to_s) { 'Dummy' } } }
65
+ before do
66
+ @app.config.middleware.use dummy_middleware
67
+ @app.config.rack_dev_mark.enable = true
68
+ @app.config.rack_dev_mark.insert_before dummy_middleware
69
+ end
70
+ it 'inserts the middleware before the other middleware' do
71
+ @app.initialize!
72
+ middlewares = @app.middleware.middlewares
73
+ expect(middlewares).to include(Rack::DevMark::Middleware)
74
+ expect(middlewares).to include(dummy_middleware)
75
+ expect(middlewares.index(Rack::DevMark::Middleware)).to eq(middlewares.index(dummy_middleware) - 1)
76
+ end
77
+ end
78
+ context "rack_dev_mark insert_after" do
79
+ let(:dummy_middleware) { Class.new{ define_method(:initialize) { |_| }; define_method(:to_s) { 'Dummy' } } }
80
+ before do
81
+ @app.config.middleware.use dummy_middleware
82
+ @app.config.rack_dev_mark.enable = true
83
+ @app.config.rack_dev_mark.insert_after dummy_middleware
84
+ end
85
+ it 'inserts the middleware before the other middleware' do
86
+ @app.initialize!
87
+ middlewares = @app.middleware.middlewares
88
+ expect(middlewares).to include(Rack::DevMark::Middleware)
89
+ expect(middlewares).to include(dummy_middleware)
90
+ expect(middlewares.index(Rack::DevMark::Middleware)).to eq(middlewares.index(dummy_middleware) + 1)
91
+ end
92
+ end
61
93
  end
62
94
  end
@@ -10,7 +10,7 @@ shared_context 'forked spec' do
10
10
  end
11
11
  Process.waitpid2 pid
12
12
  res = Marshal.load(read)
13
- example.example.send :set_exception, res if res && !res.empty?
13
+ example.example.send :set_exception, res if res && res.to_s != ''
14
14
  read.close
15
15
  end
16
16
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rack-dev-mark
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.3
4
+ version: 0.6.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daisuke Taniwaki
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-07-11 00:00:00.000000000 Z
11
+ date: 2014-07-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rack
@@ -75,6 +75,7 @@ extra_rdoc_files: []
75
75
  files:
76
76
  - .gitignore
77
77
  - .travis.yml
78
+ - COMPATIBILITY.md
78
79
  - Gemfile
79
80
  - LICENSE
80
81
  - README.md
@@ -86,6 +87,7 @@ files:
86
87
  - lib/rack/dev-mark.rb
87
88
  - lib/rack/dev-mark/error.rb
88
89
  - lib/rack/dev-mark/middleware.rb
90
+ - lib/rack/dev-mark/rails_options.rb
89
91
  - lib/rack/dev-mark/railtie.rb
90
92
  - lib/rack/dev-mark/theme.rb
91
93
  - lib/rack/dev-mark/theme/base.rb
@@ -103,6 +105,7 @@ files:
103
105
  - rack-dev-mark.gemspec
104
106
  - spec/generators/rack/dev-mark/install_generator_spec.rb
105
107
  - spec/rack/dev-mark/middleware_spec.rb
108
+ - spec/rack/dev-mark/rails_options_spec.rb
106
109
  - spec/rack/dev-mark/railtie_spec.rb
107
110
  - spec/rack/dev-mark/theme/base_spec.rb
108
111
  - spec/rack/dev-mark/theme/github_fork_ribbon_spec.rb
@@ -142,6 +145,7 @@ summary: Differentiate development environment from production
142
145
  test_files:
143
146
  - spec/generators/rack/dev-mark/install_generator_spec.rb
144
147
  - spec/rack/dev-mark/middleware_spec.rb
148
+ - spec/rack/dev-mark/rails_options_spec.rb
145
149
  - spec/rack/dev-mark/railtie_spec.rb
146
150
  - spec/rack/dev-mark/theme/base_spec.rb
147
151
  - spec/rack/dev-mark/theme/github_fork_ribbon_spec.rb