rack-dev-mark 0.4.3 → 0.4.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/.travis.yml +3 -0
- data/README.md +7 -7
- data/gemfiles/rails.3.2.x.gemfile +4 -0
- data/gemfiles/rails.4.0.x.gemfile +4 -0
- data/gemfiles/rails.4.1.x.gemfile +4 -0
- data/lib/generators/rack/dev-mark/install_generator.rb +9 -2
- data/lib/rack/dev-mark/railtie.rb +3 -1
- data/lib/rack/dev-mark/theme/README.md +5 -5
- data/lib/rack/dev-mark/version.rb +1 -1
- data/spec/generators/rack/dev-mark/install_generator_spec.rb +45 -0
- data/spec/rack/dev-mark/railtie_spec.rb +53 -0
- data/spec/spec_helper.rb +23 -1
- data/spec/support/fork_helper.rb +16 -0
- metadata +11 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
NDk1ZDY4YWRhZjU5NDM4Y2Y5MzhlZmY0MmY3N2NkYjE0NGJjOTBjNg==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
YTg2ODY2N2Y4YzkxOGQ5MTQyZWQ2MzA3ZjUwMDNlNWQwZmQ1ZjIzZg==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
YTdmYjNiYzgxZTMwYjU2OTlmZjgwYWVjOTg1YTY0NzM4MTM4ZTRlNzliYWVl
|
10
|
+
NGFlNmRiZDgwZDYxZjc5ZTEyMTViM2FkMDZmZmNhZjdmOTE3YmY0OWE5Y2Nl
|
11
|
+
ZTJlZmIxZDk3YWNlNDA1ZDFmYjNkMjdlMzVmYjAwMmVmZWRmZWE=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
N2NkYzllZTYxMTU2NWRkOWUwNDA3MGRiN2QyNzBiMTI2MGMyMDdlZGUzYTFj
|
14
|
+
YTUyY2I0ODQ3NmY0M2QyNzM0OTFjZDQzZjhmMWIxN2YzYjUxOTA0NzI3YTUx
|
15
|
+
MzdmOTgxOWRmNDIyMzAxZmM3N2VkNGI1MDhiNmM2NGZlNzk3MGM=
|
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -25,7 +25,7 @@ gem "rack-dev-mark"
|
|
25
25
|
|
26
26
|
And run `bundle install`.
|
27
27
|
|
28
|
-
### For
|
28
|
+
### For Rack App
|
29
29
|
|
30
30
|
```ruby
|
31
31
|
require 'rack/dev-mark'
|
@@ -33,7 +33,7 @@ use Rack::DevMark::Middleware
|
|
33
33
|
run MyApp
|
34
34
|
```
|
35
35
|
|
36
|
-
### For
|
36
|
+
### For Rails App
|
37
37
|
|
38
38
|
In `config/environments/development.rb`
|
39
39
|
|
@@ -79,7 +79,7 @@ end
|
|
79
79
|
|
80
80
|
## Custom Theme
|
81
81
|
|
82
|
-
|
82
|
+
Create your own theme class inheriting `Rack::DevMark::Theme::Base`.
|
83
83
|
|
84
84
|
```ruby
|
85
85
|
require 'rack/dev-mark/theme/base'
|
@@ -101,25 +101,25 @@ end
|
|
101
101
|
|
102
102
|
Then, insert them in your app.
|
103
103
|
|
104
|
-
### For
|
104
|
+
### For Rack App
|
105
105
|
|
106
106
|
```ruby
|
107
107
|
use Rack::DevMark::Middleware, [NewTheme.new, AnotherTheme.new]
|
108
108
|
```
|
109
109
|
|
110
|
-
### For
|
110
|
+
### For Rails App
|
111
111
|
|
112
112
|
In `config/application.rb`
|
113
113
|
|
114
114
|
```ruby
|
115
115
|
module MyApp
|
116
116
|
class Application < Rails::Application
|
117
|
-
config.rack_dev_mark.
|
117
|
+
config.rack_dev_mark.theme = [NewTheme.new, AnotherTheme.new]
|
118
118
|
end
|
119
119
|
end
|
120
120
|
```
|
121
121
|
|
122
|
-
You can add any combination of themes.
|
122
|
+
You can add any combination of themes. See more about [themes](lib/rack/dev-mark/theme/README.md).
|
123
123
|
|
124
124
|
## Contributing
|
125
125
|
|
@@ -1,3 +1,4 @@
|
|
1
|
+
require 'rails/generators'
|
1
2
|
require 'rails/generators/base'
|
2
3
|
|
3
4
|
module Rack
|
@@ -7,15 +8,21 @@ module Rack
|
|
7
8
|
|
8
9
|
desc "Install rack-dev-mark."
|
9
10
|
def insert_enable
|
10
|
-
insert_into_file
|
11
|
+
insert_into_file target_path, after: "< Rails::Application\n" do <<-EOS
|
11
12
|
# Enable rack-dev-mark
|
12
13
|
config.rack_dev_mark.enable = !Rails.env.production?
|
13
14
|
# Customize themes if you want to do so
|
14
|
-
# config.rack_dev_mark.
|
15
|
+
# config.rack_dev_mark.theme = [:title, :github_fork_ribbon]
|
15
16
|
|
16
17
|
EOS
|
17
18
|
end
|
18
19
|
end
|
20
|
+
|
21
|
+
private
|
22
|
+
|
23
|
+
def target_path
|
24
|
+
'config/application.rb'
|
25
|
+
end
|
19
26
|
end
|
20
27
|
end
|
21
28
|
end
|
@@ -8,7 +8,9 @@ module Rack
|
|
8
8
|
initializer "rack-dev-mark.configure_rails_initialization" do |app|
|
9
9
|
if app.config.rack_dev_mark.enable
|
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
|
+
racks << theme
|
13
|
+
end
|
12
14
|
app.config.app_middleware.insert_before *racks
|
13
15
|
end
|
14
16
|
end
|
@@ -2,20 +2,20 @@
|
|
2
2
|
|
3
3
|
You can set options when you add the themes into your app. Otherwise, just put the symbol of the theme filename.
|
4
4
|
|
5
|
-
### For
|
5
|
+
### For Rack App
|
6
6
|
|
7
7
|
```ruby
|
8
8
|
use Rack::DevMark::Middleware, [:title, Rack::DevMark::Theme::GithubForkRibbon.new(position: 'right')]
|
9
9
|
```
|
10
10
|
|
11
|
-
### For
|
11
|
+
### For Rails App
|
12
12
|
|
13
13
|
In config/application.rb
|
14
14
|
|
15
15
|
```ruby
|
16
16
|
module MyApp
|
17
17
|
class Application < Rails::Application
|
18
|
-
config.rack_dev_mark.
|
18
|
+
config.rack_dev_mark.theme = [:title, Rack::DevMark::Theme::GithubForkRibbon.new(position: 'right')]
|
19
19
|
end
|
20
20
|
end
|
21
21
|
```
|
@@ -34,11 +34,11 @@ e.g.
|
|
34
34
|
|
35
35
|
`upcase`: `true` or `false` (default)
|
36
36
|
|
37
|
-
##
|
37
|
+
## github_fork_ribbon
|
38
38
|
|
39
39
|
["Fork Me on GitHub" like ribbon](https://github.com/simonwhitaker/github-fork-ribbon-css) originally created by [simonwhitaker](https://github.com/simonwhitaker)
|
40
40
|
|
41
|
-
![
|
41
|
+
![github_fork_ribbon](screenshots/github_fork_ribbon.png)
|
42
42
|
|
43
43
|
### options
|
44
44
|
|
@@ -0,0 +1,45 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
if defined?(::Rails)
|
4
|
+
require 'tempfile'
|
5
|
+
require 'generators/rack/dev-mark/install_generator'
|
6
|
+
describe Rack::DevMark::InstallGenerator do
|
7
|
+
include_context 'forked spec'
|
8
|
+
|
9
|
+
context "config/application.rb" do
|
10
|
+
let(:application_rb) { Tempfile.new('config_application.rb') }
|
11
|
+
before do
|
12
|
+
application_rb.write <<-EOS
|
13
|
+
module MyApp
|
14
|
+
class Application < Rails::Application
|
15
|
+
# ...
|
16
|
+
end
|
17
|
+
end
|
18
|
+
EOS
|
19
|
+
application_rb.rewind
|
20
|
+
allow_any_instance_of(Rack::DevMark::InstallGenerator).to receive(:target_path).and_return(application_rb.path)
|
21
|
+
end
|
22
|
+
after do
|
23
|
+
application_rb.close
|
24
|
+
application_rb.unlink
|
25
|
+
end
|
26
|
+
|
27
|
+
it 'inserts rack-dev-mark settings' do
|
28
|
+
Rails::Generators.invoke("rack:dev-mark:install")
|
29
|
+
application_rb.rewind
|
30
|
+
expect(application_rb.read).to eq <<-EOS
|
31
|
+
module MyApp
|
32
|
+
class Application < Rails::Application
|
33
|
+
# Enable rack-dev-mark
|
34
|
+
config.rack_dev_mark.enable = !Rails.env.production?
|
35
|
+
# Customize themes if you want to do so
|
36
|
+
# config.rack_dev_mark.theme = [:title, :github_fork_ribbon]
|
37
|
+
|
38
|
+
# ...
|
39
|
+
end
|
40
|
+
end
|
41
|
+
EOS
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
if defined?(::Rails)
|
4
|
+
describe Rack::DevMark::Railtie do
|
5
|
+
include_context 'forked spec'
|
6
|
+
|
7
|
+
before do
|
8
|
+
@app = Class.new(::Rails::Application)
|
9
|
+
@app.config.active_support.deprecation = :stderr
|
10
|
+
@app.config.eager_load = false
|
11
|
+
end
|
12
|
+
context "rack_dev_mark enable" do
|
13
|
+
before do
|
14
|
+
@app.config.rack_dev_mark.enable = true
|
15
|
+
@app.initialize!
|
16
|
+
end
|
17
|
+
it 'inserts the middleware' do
|
18
|
+
expect(@app.middleware.middlewares).to include(Rack::DevMark::Middleware)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
context "rack_dev_mark disable" do
|
22
|
+
before do
|
23
|
+
@app.config.rack_dev_mark.enable = false
|
24
|
+
@app.initialize!
|
25
|
+
end
|
26
|
+
it 'does not insert the middleware' do
|
27
|
+
expect(@app.middleware.middlewares).not_to include(Rack::DevMark::Middleware)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
context "rack_dev_mark theme" do
|
31
|
+
let(:theme) { d = double setup: nil; allow(d).to receive(:insert_into){ |b| "#{b} dev-mark" }; d }
|
32
|
+
before do
|
33
|
+
@app.config.rack_dev_mark.enable = true
|
34
|
+
@app.config.rack_dev_mark.theme = [theme]
|
35
|
+
@app.initialize!
|
36
|
+
end
|
37
|
+
it 'inserts the middleware' do
|
38
|
+
expect(theme).to receive(:setup)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
context "rack_dev_mark custom_theme alias" do
|
42
|
+
let(:theme) { d = double setup: nil; allow(d).to receive(:insert_into){ |b| "#{b} dev-mark" }; d }
|
43
|
+
before do
|
44
|
+
@app.config.rack_dev_mark.enable = true
|
45
|
+
@app.config.rack_dev_mark.custom_theme = [theme]
|
46
|
+
@app.initialize!
|
47
|
+
end
|
48
|
+
it 'inserts the middleware' do
|
49
|
+
expect(theme).to receive(:setup)
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,13 +1,35 @@
|
|
1
1
|
require 'rubygems'
|
2
|
+
require 'simplecov'
|
2
3
|
require 'coveralls'
|
3
4
|
Coveralls.wear!
|
4
5
|
|
6
|
+
resultset_path = SimpleCov::ResultMerger.resultset_path
|
7
|
+
FileUtils.rm resultset_path if File.exists? resultset_path
|
8
|
+
SimpleCov.use_merging true
|
9
|
+
SimpleCov.at_exit do
|
10
|
+
SimpleCov.command_name "fork-#{$$}"
|
11
|
+
SimpleCov.result.format!
|
12
|
+
end
|
13
|
+
SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[
|
14
|
+
SimpleCov::Formatter::HTMLFormatter,
|
15
|
+
Coveralls::SimpleCov::Formatter
|
16
|
+
]
|
17
|
+
SimpleCov.start do
|
18
|
+
add_filter 'spec/'
|
19
|
+
end
|
20
|
+
|
21
|
+
ENV['RACK_ENV'] = 'test'
|
22
|
+
|
5
23
|
require 'rack'
|
24
|
+
begin
|
25
|
+
require 'rails'
|
26
|
+
$stdout.write "* Rails has been loaded.\n"
|
27
|
+
rescue LoadError
|
28
|
+
end
|
6
29
|
require 'rack-dev-mark'
|
7
30
|
|
8
31
|
Dir[File.join(File.dirname(__FILE__), "support/**/*.rb")].each {|f| require f }
|
9
32
|
|
10
|
-
ENV['RACK_ENV'] = 'test'
|
11
33
|
RSpec.configure do |config|
|
12
34
|
end
|
13
35
|
|
@@ -0,0 +1,16 @@
|
|
1
|
+
shared_context 'forked spec' do
|
2
|
+
around do |example|
|
3
|
+
read, write = IO.pipe
|
4
|
+
pid = fork do
|
5
|
+
$stdout.sync = true
|
6
|
+
$stderr.sync = true
|
7
|
+
res = example.run
|
8
|
+
Marshal.dump(res, write)
|
9
|
+
write.close
|
10
|
+
end
|
11
|
+
Process.waitpid2 pid
|
12
|
+
res = Marshal.load(read)
|
13
|
+
example.example.send :set_exception, res if res && !res.empty?
|
14
|
+
read.close
|
15
|
+
end
|
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.4.
|
4
|
+
version: 0.4.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-06-
|
11
|
+
date: 2014-06-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rack
|
@@ -84,6 +84,9 @@ files:
|
|
84
84
|
- gemfiles/rack.1.2.x.gemfile
|
85
85
|
- gemfiles/rack.1.3.x.gemfile
|
86
86
|
- gemfiles/rack.1.4.x.gemfile
|
87
|
+
- gemfiles/rails.3.2.x.gemfile
|
88
|
+
- gemfiles/rails.4.0.x.gemfile
|
89
|
+
- gemfiles/rails.4.1.x.gemfile
|
87
90
|
- lib/generators/rack/dev-mark/install_generator.rb
|
88
91
|
- lib/rack-dev-mark.rb
|
89
92
|
- lib/rack/dev-mark.rb
|
@@ -101,13 +104,16 @@ files:
|
|
101
104
|
- rack-dev-mark.gemspec
|
102
105
|
- screenshot-development.png
|
103
106
|
- screenshot-production.png
|
107
|
+
- spec/generators/rack/dev-mark/install_generator_spec.rb
|
104
108
|
- spec/rack/dev-mark/middleware_spec.rb
|
109
|
+
- spec/rack/dev-mark/railtie_spec.rb
|
105
110
|
- spec/rack/dev-mark/theme/base_spec.rb
|
106
111
|
- spec/rack/dev-mark/theme/github_fork_ribbon_spec.rb
|
107
112
|
- spec/rack/dev-mark/theme/title_spec.rb
|
108
113
|
- spec/rack/dev-mark/utils_spec.rb
|
109
114
|
- spec/rack/dev-mark_spec.rb
|
110
115
|
- spec/spec_helper.rb
|
116
|
+
- spec/support/fork_helper.rb
|
111
117
|
- spec/support/theme_helper.rb
|
112
118
|
- vendor/assets/stylesheets/github-fork-ribbon-css/gh-fork-ribbon.css
|
113
119
|
- vendor/assets/stylesheets/github-fork-ribbon-css/gh-fork-ribbon.ie.css
|
@@ -136,11 +142,14 @@ signing_key:
|
|
136
142
|
specification_version: 4
|
137
143
|
summary: Differentiate development environemt from production
|
138
144
|
test_files:
|
145
|
+
- spec/generators/rack/dev-mark/install_generator_spec.rb
|
139
146
|
- spec/rack/dev-mark/middleware_spec.rb
|
147
|
+
- spec/rack/dev-mark/railtie_spec.rb
|
140
148
|
- spec/rack/dev-mark/theme/base_spec.rb
|
141
149
|
- spec/rack/dev-mark/theme/github_fork_ribbon_spec.rb
|
142
150
|
- spec/rack/dev-mark/theme/title_spec.rb
|
143
151
|
- spec/rack/dev-mark/utils_spec.rb
|
144
152
|
- spec/rack/dev-mark_spec.rb
|
145
153
|
- spec/spec_helper.rb
|
154
|
+
- spec/support/fork_helper.rb
|
146
155
|
- spec/support/theme_helper.rb
|