rack-dev-mark 0.6.0 → 0.6.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/.travis.yml +11 -10
- data/Gemfile +3 -0
- data/README.md +6 -15
- data/VERSION +1 -0
- data/lib/rack/dev-mark.rb +24 -17
- data/lib/rack/dev-mark/railtie.rb +1 -1
- data/lib/rack/dev-mark/theme.rb +1 -1
- data/lib/rack/dev-mark/version.rb +1 -1
- data/rack-dev-mark.gemspec +2 -2
- data/spec/rack/dev-mark/railtie_spec.rb +13 -4
- data/spec/rack/dev-mark_spec.rb +45 -0
- metadata +5 -12
- data/gemfiles/gemfile +0 -3
- data/gemfiles/rack.1.1.x.gemfile +0 -4
- data/gemfiles/rack.1.2.x.gemfile +0 -4
- data/gemfiles/rack.1.3.x.gemfile +0 -4
- data/gemfiles/rack.1.4.x.gemfile +0 -4
- data/gemfiles/rails.3.2.x.gemfile +0 -4
- data/gemfiles/rails.4.0.x.gemfile +0 -4
- data/gemfiles/rails.4.1.x.gemfile +0 -4
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
M2VlN2RhM2Y4NWFiNmUyM2IwMDEwY2IxOWQ1YjUxNDk0NGFlNzc2NA==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
YjFkMTc4YzY4ZTRhMTk4MTc1MDY1MmQ4YjMyYjVlNWViY2JiMDRkMA==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
YjA4ZjQ2N2Q0ZDUxNTg2MWQ4NGZjYzA4ZDM3ZTRjYmIwOWY1ODJjNmU0MjMw
|
10
|
+
MDYyZjhlYWZmZjQwOGQyYzQ0YTE1ZWYwODIzNTg2YzcxYzU5OWZjMGMwMjBl
|
11
|
+
NmI4N2I3YWExMTg3NTVhYWZkNDBhYjE0Mzk1MTczODE1YzUxNzI=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
YzBkZTFhYWQzYmVkNjRlY2RkNzExNDNiOWQyYzk5NGYxYWVkOWJhNmQzNWJm
|
14
|
+
M2Q3NTc2Y2MyMzEwMGRkMGY1NmI0ZjUzZGNjOTFiNzRlMTdiYjIyYmFjMmM1
|
15
|
+
MmM4ZWU0ZjFkMDMxNTAxZWVkODU2ZWZhNDk3YjcyODg4MTEzNTA=
|
data/.travis.yml
CHANGED
@@ -3,16 +3,17 @@ language: ruby
|
|
3
3
|
rvm:
|
4
4
|
- 1.9.3
|
5
5
|
- 2.0.0
|
6
|
-
- 2.1
|
7
|
-
|
8
|
-
|
9
|
-
-
|
10
|
-
-
|
11
|
-
-
|
12
|
-
-
|
13
|
-
-
|
14
|
-
-
|
15
|
-
-
|
6
|
+
- 2.1
|
7
|
+
|
8
|
+
env:
|
9
|
+
-
|
10
|
+
- RACK_VERSION=1.1.0
|
11
|
+
- RACK_VERSION=1.2.0
|
12
|
+
- RACK_VERSION=1.3.0
|
13
|
+
- RACK_VERSION=1.4.0
|
14
|
+
- RAILS_VERSION=3.2.0
|
15
|
+
- RAILS_VERSION=4.0.0
|
16
|
+
- RAILS_VERSION=4.1.0
|
16
17
|
|
17
18
|
script: "bundle exec rake spec"
|
18
19
|
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -44,7 +44,7 @@ run MyApp
|
|
44
44
|
In `config/environments/development.rb`
|
45
45
|
|
46
46
|
```ruby
|
47
|
-
|
47
|
+
Rails.application.configure do
|
48
48
|
config.rack_dev_mark.enable = true
|
49
49
|
end
|
50
50
|
```
|
@@ -83,25 +83,16 @@ module MyApp
|
|
83
83
|
end
|
84
84
|
```
|
85
85
|
|
86
|
-
#### Heroku
|
86
|
+
#### Rails on Heroku
|
87
87
|
|
88
|
-
Since Heroku [uses production env for staging](https://devcenter.heroku.com/articles/multiple-environments). You can use
|
89
|
-
|
90
|
-
```ruby
|
91
|
-
module MyApp
|
92
|
-
class Application < Rails::Application
|
93
|
-
Rack::DevMark.env = ENV['RACK_DEV_MARK']
|
94
|
-
config.rack_dev_mark.enable = !Rails.env.production? || ENV['RACK_DEV_MARK']
|
95
|
-
end
|
96
|
-
end
|
97
|
-
```
|
98
|
-
|
99
|
-
And set the environment variable.
|
88
|
+
Since Heroku [uses production env for staging](https://devcenter.heroku.com/articles/multiple-environments). You can't use the settings above. However, the gem provide an easier way to set it up on Heroku. Just set the environment variable on the environment in which you want to show the mark.
|
100
89
|
|
101
90
|
```bash
|
102
|
-
heroku config:set
|
91
|
+
heroku config:set RACK_DEV_MARK_ENV=staging
|
103
92
|
```
|
104
93
|
|
94
|
+
That's it!
|
95
|
+
|
105
96
|
## Custom Theme
|
106
97
|
|
107
98
|
Although the default themes are `title` and `github_fork_ribbon`, you can create your own themes inheriting `Rack::DevMark::Theme::Base`.
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.6.2
|
data/lib/rack/dev-mark.rb
CHANGED
@@ -7,28 +7,35 @@ require 'rack/dev-mark/version'
|
|
7
7
|
|
8
8
|
module Rack
|
9
9
|
module DevMark
|
10
|
-
|
11
|
-
|
12
|
-
|
10
|
+
class << self
|
11
|
+
def env
|
12
|
+
@env ||= rack_dev_mark_env || ENV['RAILS_ENV'] || ENV['RACK_ENV'] || 'development'
|
13
|
+
end
|
13
14
|
|
14
|
-
|
15
|
-
|
16
|
-
|
15
|
+
def env=(env)
|
16
|
+
@env = env
|
17
|
+
end
|
17
18
|
|
18
|
-
|
19
|
-
|
20
|
-
|
19
|
+
def revision
|
20
|
+
@revision ||= (::File.open('REVISION') { |f| f.read.strip } rescue nil)
|
21
|
+
end
|
21
22
|
|
22
|
-
|
23
|
-
|
24
|
-
|
23
|
+
def revision=(revision)
|
24
|
+
@revision = revision
|
25
|
+
end
|
25
26
|
|
26
|
-
|
27
|
-
|
28
|
-
|
27
|
+
def timestamp
|
28
|
+
@timestamp ||= (::File.open('REVISION') { |f| f.mtime } rescue nil)
|
29
|
+
end
|
30
|
+
|
31
|
+
def timestamp=(timestamp)
|
32
|
+
@timestamp = timestamp.is_a?(Time) ? timestamp : Time.parse(timestamp)
|
33
|
+
end
|
29
34
|
|
30
|
-
|
31
|
-
|
35
|
+
def rack_dev_mark_env
|
36
|
+
s = ENV['RACK_DEV_MARK_ENV']
|
37
|
+
s.to_s == '' ? nil : s
|
38
|
+
end
|
32
39
|
end
|
33
40
|
end
|
34
41
|
end
|
@@ -6,7 +6,7 @@ module Rack
|
|
6
6
|
config.rack_dev_mark = ActiveSupport::OrderedOptions.new
|
7
7
|
|
8
8
|
initializer "rack-dev-mark.configure_rails_initialization" do |app|
|
9
|
-
if app.config.rack_dev_mark.enable
|
9
|
+
if app.config.rack_dev_mark.enable || Rack::DevMark.rack_dev_mark_env
|
10
10
|
racks = [ActionDispatch::ShowExceptions, Rack::DevMark::Middleware]
|
11
11
|
if theme = app.config.rack_dev_mark.theme || app.config.rack_dev_mark.custom_theme
|
12
12
|
racks << theme
|
data/lib/rack/dev-mark/theme.rb
CHANGED
data/rack-dev-mark.gemspec
CHANGED
@@ -7,8 +7,8 @@ Gem::Specification.new do |gem|
|
|
7
7
|
gem.authors = ["Daisuke Taniwaki"]
|
8
8
|
gem.email = ["daisuketaniwaki@gmail.com"]
|
9
9
|
gem.homepage = "https://github.com/dtaniwaki/rack-dev-mark"
|
10
|
-
gem.summary = "Differentiate development
|
11
|
-
gem.description = "Differentiate development
|
10
|
+
gem.summary = "Differentiate development environment from production"
|
11
|
+
gem.description = "Differentiate development environment from production"
|
12
12
|
gem.license = "MIT"
|
13
13
|
|
14
14
|
gem.files = `git ls-files`.split("\n")
|
@@ -12,29 +12,38 @@ describe Rack::DevMark::Railtie do
|
|
12
12
|
context "rack_dev_mark enable" do
|
13
13
|
before do
|
14
14
|
@app.config.rack_dev_mark.enable = true
|
15
|
-
@app.initialize!
|
16
15
|
end
|
17
16
|
it 'inserts the middleware' do
|
17
|
+
@app.initialize!
|
18
18
|
expect(@app.middleware.middlewares).to include(Rack::DevMark::Middleware)
|
19
19
|
end
|
20
20
|
end
|
21
21
|
context "rack_dev_mark disable" do
|
22
22
|
before do
|
23
23
|
@app.config.rack_dev_mark.enable = false
|
24
|
-
@app.initialize!
|
25
24
|
end
|
26
25
|
it 'does not insert the middleware' do
|
26
|
+
@app.initialize!
|
27
27
|
expect(@app.middleware.middlewares).not_to include(Rack::DevMark::Middleware)
|
28
28
|
end
|
29
|
+
context "with rack_dev_mark_env" do
|
30
|
+
before do
|
31
|
+
ENV['RACK_DEV_MARK_ENV'] = 'test'
|
32
|
+
end
|
33
|
+
it 'inserts the middleware' do
|
34
|
+
@app.initialize!
|
35
|
+
expect(@app.middleware.middlewares).to include(Rack::DevMark::Middleware)
|
36
|
+
end
|
37
|
+
end
|
29
38
|
end
|
30
39
|
context "rack_dev_mark theme" do
|
31
40
|
let(:theme) { d = double setup: nil; allow(d).to receive(:insert_into){ |b| "#{b} dev-mark" }; d }
|
32
41
|
before do
|
33
42
|
@app.config.rack_dev_mark.enable = true
|
34
43
|
@app.config.rack_dev_mark.theme = [theme]
|
35
|
-
@app.initialize!
|
36
44
|
end
|
37
45
|
it 'inserts the middleware' do
|
46
|
+
@app.initialize!
|
38
47
|
expect(theme).to receive(:setup)
|
39
48
|
end
|
40
49
|
end
|
@@ -43,9 +52,9 @@ describe Rack::DevMark::Railtie do
|
|
43
52
|
before do
|
44
53
|
@app.config.rack_dev_mark.enable = true
|
45
54
|
@app.config.rack_dev_mark.custom_theme = [theme]
|
46
|
-
@app.initialize!
|
47
55
|
end
|
48
56
|
it 'inserts the middleware' do
|
57
|
+
@app.initialize!
|
49
58
|
expect(theme).to receive(:setup)
|
50
59
|
end
|
51
60
|
end
|
data/spec/rack/dev-mark_spec.rb
CHANGED
@@ -27,6 +27,12 @@ describe Rack::DevMark do
|
|
27
27
|
ENV['RAILS_ENV'] = 'def'
|
28
28
|
expect(subject.env).to eq('def')
|
29
29
|
end
|
30
|
+
it "returns rack_dev_mark_env instead of rails_env" do
|
31
|
+
ENV['RACK_ENV'] = 'abc'
|
32
|
+
ENV['RAILS_ENV'] = 'def'
|
33
|
+
ENV['RACK_DEV_MARK_ENV'] = 'ghi'
|
34
|
+
expect(subject.env).to eq('ghi')
|
35
|
+
end
|
30
36
|
end
|
31
37
|
describe "::env=" do
|
32
38
|
it "sets custom env" do
|
@@ -55,4 +61,43 @@ describe Rack::DevMark do
|
|
55
61
|
expect(subject.revision).to eq('custom')
|
56
62
|
end
|
57
63
|
end
|
64
|
+
describe "::timestamp" do
|
65
|
+
let(:time) { Time.new(2000, 1, 2) }
|
66
|
+
after do
|
67
|
+
::File.delete('REVISION') if ::File.exists?('REVISION')
|
68
|
+
subject.instance_variable_set("@timestamp", nil)
|
69
|
+
end
|
70
|
+
it "returns timestamp" do
|
71
|
+
::FileUtils.touch 'REVISION', mtime: time
|
72
|
+
expect(subject.timestamp).to eq(time)
|
73
|
+
end
|
74
|
+
it "returns nil if REVISION does not exist" do
|
75
|
+
expect(subject.timestamp).to eq(nil)
|
76
|
+
end
|
77
|
+
end
|
78
|
+
describe "::timestamp=" do
|
79
|
+
it "sets custom timestamp by string" do
|
80
|
+
subject.timestamp = '2014/3/1'
|
81
|
+
expect(subject.timestamp).to eq(Time.new(2014, 3, 1))
|
82
|
+
end
|
83
|
+
|
84
|
+
it "sets custom timestamp by time object" do
|
85
|
+
subject.timestamp = Time.new(2014, 4, 1)
|
86
|
+
expect(subject.timestamp).to eq(Time.new(2014, 4, 1))
|
87
|
+
end
|
88
|
+
end
|
89
|
+
describe "::rack_dev_mark_env" do
|
90
|
+
it "returns nil" do
|
91
|
+
ENV['RACK_DEV_MARK_ENV'] = nil
|
92
|
+
expect(subject.rack_dev_mark_env).to eq(nil)
|
93
|
+
end
|
94
|
+
it "returns nil" do
|
95
|
+
ENV['RACK_DEV_MARK_ENV'] = ''
|
96
|
+
expect(subject.rack_dev_mark_env).to eq(nil)
|
97
|
+
end
|
98
|
+
it "returns custom value" do
|
99
|
+
ENV['RACK_DEV_MARK_ENV'] = 'abc'
|
100
|
+
expect(subject.env).to eq('abc')
|
101
|
+
end
|
102
|
+
end
|
58
103
|
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.
|
4
|
+
version: 0.6.2
|
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
|
+
date: 2014-07-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rack
|
@@ -66,7 +66,7 @@ dependencies:
|
|
66
66
|
- - ! '>='
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
|
-
description: Differentiate development
|
69
|
+
description: Differentiate development environment from production
|
70
70
|
email:
|
71
71
|
- daisuketaniwaki@gmail.com
|
72
72
|
executables: []
|
@@ -80,14 +80,7 @@ files:
|
|
80
80
|
- README.md
|
81
81
|
- Rakefile
|
82
82
|
- THEME.md
|
83
|
-
-
|
84
|
-
- gemfiles/rack.1.1.x.gemfile
|
85
|
-
- gemfiles/rack.1.2.x.gemfile
|
86
|
-
- gemfiles/rack.1.3.x.gemfile
|
87
|
-
- gemfiles/rack.1.4.x.gemfile
|
88
|
-
- gemfiles/rails.3.2.x.gemfile
|
89
|
-
- gemfiles/rails.4.0.x.gemfile
|
90
|
-
- gemfiles/rails.4.1.x.gemfile
|
83
|
+
- VERSION
|
91
84
|
- lib/generators/rack/dev-mark/install_generator.rb
|
92
85
|
- lib/rack-dev-mark.rb
|
93
86
|
- lib/rack/dev-mark.rb
|
@@ -145,7 +138,7 @@ rubyforge_project:
|
|
145
138
|
rubygems_version: 2.2.2
|
146
139
|
signing_key:
|
147
140
|
specification_version: 4
|
148
|
-
summary: Differentiate development
|
141
|
+
summary: Differentiate development environment from production
|
149
142
|
test_files:
|
150
143
|
- spec/generators/rack/dev-mark/install_generator_spec.rb
|
151
144
|
- spec/rack/dev-mark/middleware_spec.rb
|
data/gemfiles/gemfile
DELETED
data/gemfiles/rack.1.1.x.gemfile
DELETED
data/gemfiles/rack.1.2.x.gemfile
DELETED
data/gemfiles/rack.1.3.x.gemfile
DELETED
data/gemfiles/rack.1.4.x.gemfile
DELETED