rack-dev-mark 0.7.1 → 0.7.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -13
- data/README.md +26 -1
- data/VERSION +1 -1
- data/lib/rack/dev-mark.rb +8 -0
- data/lib/rack/dev-mark/action_controller_helpers.rb +25 -0
- data/lib/rack/dev-mark/middleware.rb +3 -1
- data/lib/rack/dev-mark/railtie.rb +7 -0
- data/spec/rack/dev-mark/action_controller_helpers_spec.rb +51 -0
- data/spec/rack/dev-mark/middleware_spec.rb +11 -0
- data/spec/rack/dev-mark_spec.rb +16 -0
- data/spec/spec_helper.rb +1 -0
- metadata +17 -14
checksums.yaml
CHANGED
@@ -1,15 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
|
5
|
-
data.tar.gz: !binary |-
|
6
|
-
OTkwYThlNzUzODY2MzQzYjFhY2MzMzc0MTBlNGQxZDQwZGVmY2IyYw==
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: e536e84497366fccf4c91419da55af604cce73e8
|
4
|
+
data.tar.gz: 99358d2e3e4cf7723501ec7040199f8be07bdbe0
|
7
5
|
SHA512:
|
8
|
-
metadata.gz:
|
9
|
-
|
10
|
-
NTkyMGM4ZjEzODE4ZjNkNDE1NGE1NmJkNTVkMGM4YjNiMTM1OGY5ODg4MmQ4
|
11
|
-
OTM2M2MwY2E3NjJiOTMzN2MzNDBiY2IwM2JlOGM0YTJmNDJhMjY=
|
12
|
-
data.tar.gz: !binary |-
|
13
|
-
YzVlZDgwOTVkMzBjNDY0ZGNmOGJhNzEyMzZjMDE0MmZjOTM3ZGVkNzkxYjNk
|
14
|
-
MjMwNWU1MGQxNWI5NDAxMzlmODg2NWZlNzYxODE4MzAyOTA1ODJhMGRiNjFl
|
15
|
-
MjZmNTBlZjU0NjI2MThjOTYwY2FkMDYzMzNiNDk5MTMyN2M2NDk=
|
6
|
+
metadata.gz: 82eb7b6a40748a4a7accceb112e790d272542ecb476131f70d5a1c4b79a11da7c9d4dc58fd37180e44311d4f507dcafc6279ec7612bd4e00f833679125cedd6e
|
7
|
+
data.tar.gz: 93ab4550f6eb4b7233ecfc6d382cbb547cdd3335c2d98d6f6eb720cb701cf48fa472e84e02b107341bef156892b33d294544e277f67bd43ecf29a089383b7afd
|
data/README.md
CHANGED
@@ -8,7 +8,11 @@
|
|
8
8
|
|
9
9
|
Differentiate development environment from production. You can choose [themes](THEME.md) to differentiate the page.
|
10
10
|
|
11
|
-
The running sample
|
11
|
+
[The running sample](http://rack-dev-mark.dtaniwaki.com/) is available.
|
12
|
+
|
13
|
+
You can also try this gem on Heroku.
|
14
|
+
|
15
|
+
[![Deploy](https://www.herokucdn.com/deploy/button.png)](https://heroku.com/deploy?template=https://github.com/dtaniwaki/rack-dev-mark-sample-app)
|
12
16
|
|
13
17
|
## Screenshot
|
14
18
|
|
@@ -120,6 +124,27 @@ module MyApp
|
|
120
124
|
config.rack_dev_mark.env = 'foo'
|
121
125
|
end
|
122
126
|
end
|
127
|
+
```
|
128
|
+
|
129
|
+
#### Temporarily disable the dev mark
|
130
|
+
|
131
|
+
`skip_rack_dev_mark` controller helper works like `around_filter`.
|
132
|
+
|
133
|
+
```ruby
|
134
|
+
class FooController < ApplicationController
|
135
|
+
skip_rack_dev_mark except: [:iframe]
|
136
|
+
|
137
|
+
def index
|
138
|
+
# Do something
|
139
|
+
end
|
140
|
+
|
141
|
+
def iframe
|
142
|
+
# Do something
|
143
|
+
end
|
144
|
+
end
|
145
|
+
```
|
146
|
+
|
147
|
+
In this case, only `index` action will insert the dev mark.
|
123
148
|
|
124
149
|
## I18n Support
|
125
150
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.7.
|
1
|
+
0.7.3
|
data/lib/rack/dev-mark.rb
CHANGED
@@ -32,6 +32,14 @@ module Rack
|
|
32
32
|
@timestamp = timestamp.is_a?(Time) ? timestamp : Time.parse(timestamp)
|
33
33
|
end
|
34
34
|
|
35
|
+
def tmp_disabled
|
36
|
+
@tmp_disabled ||= false
|
37
|
+
end
|
38
|
+
|
39
|
+
def tmp_disabled=(v)
|
40
|
+
@tmp_disabled = !!v
|
41
|
+
end
|
42
|
+
|
35
43
|
def rack_dev_mark_env
|
36
44
|
s = ENV['RACK_DEV_MARK_ENV']
|
37
45
|
s.to_s == '' ? nil : s
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module Rack
|
2
|
+
module DevMark
|
3
|
+
module ActionControllerHelpers
|
4
|
+
module ClassMethods
|
5
|
+
def skip_rack_dev_mark(options = {})
|
6
|
+
before_filter options do
|
7
|
+
disable_rack_dev_mark
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.included(base)
|
13
|
+
base.extend ClassMethods
|
14
|
+
end
|
15
|
+
|
16
|
+
def disable_rack_dev_mark
|
17
|
+
Rack::DevMark.tmp_disabled = true
|
18
|
+
end
|
19
|
+
|
20
|
+
def enable_rack_dev_mark
|
21
|
+
Rack::DevMark.tmp_disabled = false
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -14,13 +14,15 @@ module Rack
|
|
14
14
|
end
|
15
15
|
|
16
16
|
def call(env)
|
17
|
+
Rack::DevMark.tmp_disabled = false
|
18
|
+
|
17
19
|
status, headers, response = @app.call(env)
|
18
20
|
|
19
21
|
headers = HeaderHash.new(headers)
|
20
22
|
|
21
23
|
headers['X-Rack-Dev-Mark-Env'] = CGI.escape Rack::DevMark.env
|
22
24
|
|
23
|
-
if headers['Content-Type'].to_s =~ %r{\btext/html\b}i
|
25
|
+
if !Rack::DevMark.tmp_disabled && headers['Content-Type'].to_s =~ %r{\btext/html\b}i
|
24
26
|
new_body = ''
|
25
27
|
response.each do |b|
|
26
28
|
begin
|
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'rails'
|
2
2
|
require_relative 'rails_options'
|
3
|
+
require_relative 'action_controller_helpers'
|
3
4
|
|
4
5
|
module Rack
|
5
6
|
module DevMark
|
@@ -28,6 +29,12 @@ module Rack
|
|
28
29
|
Rack::DevMark.env = app.config.rack_dev_mark.env
|
29
30
|
end
|
30
31
|
end
|
32
|
+
|
33
|
+
initializer "rack-dev-mark.load_controller_helpers", after: "rack-dev-mark.insert_middleware" do |app|
|
34
|
+
ActiveSupport.on_load :action_controller do
|
35
|
+
include Rack::DevMark::ActionControllerHelpers
|
36
|
+
end
|
37
|
+
end
|
31
38
|
end
|
32
39
|
end
|
33
40
|
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
if defined?(::Rails)
|
4
|
+
require 'action_controller'
|
5
|
+
describe Rack::DevMark::ActionControllerHelpers do
|
6
|
+
let(:controller_klass) do
|
7
|
+
Class.new(ActionController::Base) do
|
8
|
+
skip_rack_dev_mark
|
9
|
+
|
10
|
+
def disabled_action
|
11
|
+
puts 'test'
|
12
|
+
render inline: '<html><head></head><body></body></html>'
|
13
|
+
end
|
14
|
+
|
15
|
+
def enabled_action
|
16
|
+
render inline: '<html><head></head><body></body></html>'
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
let(:controller) { controller_klass.new }
|
21
|
+
|
22
|
+
include_context 'forked spec'
|
23
|
+
|
24
|
+
before do
|
25
|
+
@app = Class.new(::Rails::Application)
|
26
|
+
@app.config.active_support.deprecation = :stderr
|
27
|
+
@app.config.eager_load = false
|
28
|
+
@app.config.rack_dev_mark.enable = true
|
29
|
+
@app.initialize!
|
30
|
+
end
|
31
|
+
|
32
|
+
describe "#disable_rack_dev_mark" do
|
33
|
+
it "sets Rack::DevMark.tmp_disabled true" do
|
34
|
+
expect(Rack::DevMark).to receive(:tmp_disabled=).with(true)
|
35
|
+
controller.disable_rack_dev_mark
|
36
|
+
end
|
37
|
+
end
|
38
|
+
describe "#enable_rack_dev_mark" do
|
39
|
+
it "sets Rack::DevMark.tmp_disabled false" do
|
40
|
+
expect(Rack::DevMark).to receive(:tmp_disabled=).with(false)
|
41
|
+
controller.enable_rack_dev_mark
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
describe "::skip_rack_dev_mark" do
|
46
|
+
it "does not add dev mark" do
|
47
|
+
skip "need a spec test"
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
@@ -80,4 +80,15 @@ describe Rack::DevMark::Middleware do
|
|
80
80
|
subject.call({})
|
81
81
|
end
|
82
82
|
end
|
83
|
+
context "tmp_disabled flag" do
|
84
|
+
before do
|
85
|
+
allow(Rack::DevMark).to receive(:tmp_disabled).and_return(true)
|
86
|
+
end
|
87
|
+
it "does not raise an exception but write it down in $stderr" do
|
88
|
+
status, headers, body = subject.call({})
|
89
|
+
expect(status).to eq(200)
|
90
|
+
expect(headers).to include('Content-Type' => 'text/html; charset=utf-8')
|
91
|
+
expect(body).to eq(["response"])
|
92
|
+
end
|
93
|
+
end
|
83
94
|
end
|
data/spec/rack/dev-mark_spec.rb
CHANGED
@@ -77,6 +77,22 @@ describe Rack::DevMark do
|
|
77
77
|
expect(subject.timestamp).to eq(Time.new(2014, 4, 1))
|
78
78
|
end
|
79
79
|
end
|
80
|
+
describe "::tmp_disabled" do
|
81
|
+
it "returns false as default" do
|
82
|
+
expect(subject.tmp_disabled).to be false
|
83
|
+
end
|
84
|
+
end
|
85
|
+
describe "::tmp_disabled=" do
|
86
|
+
it "sets true" do
|
87
|
+
subject.tmp_disabled = true
|
88
|
+
expect(subject.tmp_disabled).to be true
|
89
|
+
end
|
90
|
+
|
91
|
+
it "sets other value as true" do
|
92
|
+
subject.tmp_disabled = 1
|
93
|
+
expect(subject.tmp_disabled).to be true
|
94
|
+
end
|
95
|
+
end
|
80
96
|
describe "::rack_dev_mark_env" do
|
81
97
|
it "returns nil" do
|
82
98
|
ENV['RACK_DEV_MARK_ENV'] = nil
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,69 +1,69 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rack-dev-mark
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.7.
|
4
|
+
version: 0.7.3
|
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-
|
11
|
+
date: 2014-08-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rack
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '1.1'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '1.1'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '0'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- -
|
38
|
+
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rspec
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- -
|
45
|
+
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: '3.0'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- -
|
52
|
+
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '3.0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: coveralls
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- -
|
59
|
+
- - ">="
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: '0'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- -
|
66
|
+
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
69
|
description: Differentiate development environment from production
|
@@ -73,8 +73,8 @@ executables: []
|
|
73
73
|
extensions: []
|
74
74
|
extra_rdoc_files: []
|
75
75
|
files:
|
76
|
-
- .gitignore
|
77
|
-
- .travis.yml
|
76
|
+
- ".gitignore"
|
77
|
+
- ".travis.yml"
|
78
78
|
- COMPATIBILITY.md
|
79
79
|
- Gemfile
|
80
80
|
- LICENSE
|
@@ -85,6 +85,7 @@ files:
|
|
85
85
|
- lib/generators/rack/dev-mark/install_generator.rb
|
86
86
|
- lib/rack-dev-mark.rb
|
87
87
|
- lib/rack/dev-mark.rb
|
88
|
+
- lib/rack/dev-mark/action_controller_helpers.rb
|
88
89
|
- lib/rack/dev-mark/error.rb
|
89
90
|
- lib/rack/dev-mark/i18n_helper.rb
|
90
91
|
- lib/rack/dev-mark/middleware.rb
|
@@ -105,6 +106,7 @@ files:
|
|
105
106
|
- misc/theme/title.png
|
106
107
|
- rack-dev-mark.gemspec
|
107
108
|
- spec/generators/rack/dev-mark/install_generator_spec.rb
|
109
|
+
- spec/rack/dev-mark/action_controller_helpers_spec.rb
|
108
110
|
- spec/rack/dev-mark/i18n_helper_spec.rb
|
109
111
|
- spec/rack/dev-mark/middleware_spec.rb
|
110
112
|
- spec/rack/dev-mark/rails_options_spec.rb
|
@@ -130,12 +132,12 @@ require_paths:
|
|
130
132
|
- lib
|
131
133
|
required_ruby_version: !ruby/object:Gem::Requirement
|
132
134
|
requirements:
|
133
|
-
- -
|
135
|
+
- - ">="
|
134
136
|
- !ruby/object:Gem::Version
|
135
137
|
version: '0'
|
136
138
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
137
139
|
requirements:
|
138
|
-
- -
|
140
|
+
- - ">="
|
139
141
|
- !ruby/object:Gem::Version
|
140
142
|
version: '0'
|
141
143
|
requirements: []
|
@@ -146,6 +148,7 @@ specification_version: 4
|
|
146
148
|
summary: Differentiate development environment from production
|
147
149
|
test_files:
|
148
150
|
- spec/generators/rack/dev-mark/install_generator_spec.rb
|
151
|
+
- spec/rack/dev-mark/action_controller_helpers_spec.rb
|
149
152
|
- spec/rack/dev-mark/i18n_helper_spec.rb
|
150
153
|
- spec/rack/dev-mark/middleware_spec.rb
|
151
154
|
- spec/rack/dev-mark/rails_options_spec.rb
|