rack-dev-mark 0.3.0 → 0.4.0

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
- MDZhYWU3YWUzMjdiM2MxMDc2ZmY3ODdjZDA2NTlmZDBjNDMwYzY0ZQ==
4
+ MzNjZGU4ODkxOWUxNzNkNThkZjgxY2Y0ZmFmN2M5Yjc3MjNhZjNkNA==
5
5
  data.tar.gz: !binary |-
6
- ZWIwMDliNmZmZmQ5NTg2NTNjNWNiODVlNGI3NDQ0YjM1MDQ5N2E4OA==
6
+ MjE2MTQ1MzZiNGFmNzYyNDk5ZjQzNzQ4ZGE1N2UxMGExY2NhN2U0OQ==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- OTFjY2RiMDIzMmY2MGQwNjEzZjk4ZDZmNmFhNjI5NTJlYWZmMWFjYjg0YmU0
10
- ZTYzNjhjZDkwYTA0ZTA5OWFkZTRiMDlmMjA3NTdiZjQ3ZGZkNWEwZjI3ZDQ4
11
- MGYyZmMxYTZiMWZjNTk3ZGNmNzhjZmJmZmQ5ZjRiZTlkNWMxMmU=
9
+ ZGFiYmVlMGE2ZTg3ZDQwMWNhZGZkYzQ4NWM3NDBkMGY3ZDA5ZmQzNjExNjUy
10
+ ZTIzNWE4NzlmYjRmN2YzMjU0ZTY2N2IxNTM0ZDYyZWJhMmM5OGI1Yzk0ZTdm
11
+ YzM0ZWEyMDUzYTY1NGM4MjNiM2E0NDJmNzY3ZmJmYzc4NjE1NzA=
12
12
  data.tar.gz: !binary |-
13
- YzliN2QzODAzMmM2OTdkZWFmNTY5YWQzNDVmYTFhN2RjYjFhY2ZlYjI3YjAw
14
- Njg1MDJlYzc1N2IxZmE0MjM1Mzk3MzAyMGZmN2RmNzljYTMyOTJkZTY2OTAy
15
- OWY5ZDc1MmMzMDQ3YmUwMzM0MjkyYjY5YmRjMzc2ZDA0NzBmNmI=
13
+ ZTQ2Y2M1ZGVjMjAwZDlhNTgwNzVjMmU5N2VlN2M1ZDJkNzQ4MWQxMTI3OGQx
14
+ ODVhMDY2YTQxYmY0OGM0YzE4NDJmNWFhNWI3NTJkNDU2YWU4ZjExNTc0NTc4
15
+ ZWJhYmMwNjkxNWU4MWQzMzA4ZGZiYjc4OWQ2MmU0ODQ3YjMzNjA=
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # rack-dev-mark
2
2
 
3
- [![Gem Version](https://badge.fury.io/rb/rack-dev-mark.svg)](http://badge.fury.io/rb/rack-dev-mark) [![Build Status](https://secure.travis-ci.org/dtaniwaki/rack-dev-mark.png?branch=master)](http://travis-ci.org/dtaniwaki/rack-dev-mark) [![Coverage Status](https://coveralls.io/repos/dtaniwaki/rack-dev-mark/badge.png?branch=master)](https://coveralls.io/r/dtaniwaki/rack-dev-mark?branch=master)
3
+ [![Gem Version](https://badge.fury.io/rb/rack-dev-mark.svg)](http://badge.fury.io/rb/rack-dev-mark) [![Build Status](https://secure.travis-ci.org/dtaniwaki/rack-dev-mark.png?branch=master)](http://travis-ci.org/dtaniwaki/rack-dev-mark) [![Coverage Status](https://coveralls.io/repos/dtaniwaki/rack-dev-mark/badge.png?branch=master)](https://coveralls.io/r/dtaniwaki/rack-dev-mark?branch=master) [![Code Climate](https://codeclimate.com/github/dtaniwaki/rack-dev-mark.png)](https://codeclimate.com/github/dtaniwaki/rack-dev-mark)
4
4
 
5
5
  Differentiate development environment from production.
6
6
  You can choose [themes](lib/rack/dev-mark/theme/README.md) to differentiate the page.
@@ -35,14 +35,21 @@ run MyApp
35
35
 
36
36
  ### For your Rails app
37
37
 
38
+ In `config/environments/development.rb`
39
+
40
+ ```ruby
41
+ MyApp::Application.configure do
42
+ config.rack_dev_mark.enable = true
43
+ end
44
+ ```
45
+
46
+ Or
38
47
  In `config/application.rb`
39
48
 
40
49
  ```ruby
41
50
  module MyApp
42
51
  class Application < Rails::Application
43
- if Rails.env != 'production'
44
- config.middleware.insert_before ActionDispatch::ShowExceptions, Rack::DevMark::Middleware
45
- end
52
+ config.rack_dev_mark.enable = !Rails.env.production?
46
53
  end
47
54
  end
48
55
  ```
@@ -58,9 +65,7 @@ In `config/application.rb`
58
65
  ```ruby
59
66
  module MyApp
60
67
  class Application < Rails::Application
61
- if !%w(env1 env2 env3).include?(Rails.env)
62
- config.middleware.insert_before ActionDispatch::ShowExceptions, Rack::DevMark::Middleware
63
- end
68
+ config.rack_dev_mark.enable = !%w(env1 env2 env3).include?(Rails.env)
64
69
  end
65
70
  end
66
71
  ```
@@ -73,14 +78,14 @@ Define a sub class of `Rack::DevMark::Theme::Base` somewhere in your app.
73
78
  require 'rack/dev-mark/theme/base'
74
79
 
75
80
  class NewTheme < Rack::DevMark::Theme::Base
76
- def insert_into(html, env, revision)
81
+ def insert_into(html)
77
82
  # Do something for your theme
78
83
  html
79
84
  end
80
85
  end
81
86
 
82
87
  class AnotherTheme < Rack::DevMark::Theme::Base
83
- def insert_into(html, env, revision)
88
+ def insert_into(html)
84
89
  # Do something for your theme
85
90
  html
86
91
  end
@@ -102,9 +107,7 @@ In `config/application.rb`
102
107
  ```ruby
103
108
  module MyApp
104
109
  class Application < Rails::Application
105
- if Rails.env != 'production'
106
- config.middleware.insert_before ActionDispatch::ShowExceptions, Rack::DevMark::Middleware, [NewTheme.new, AnotherTheme.new]
107
- end
110
+ config.rack_dev_mark.custom_theme = [NewTheme.new, AnotherTheme.new]
108
111
  end
109
112
  end
110
113
  ```
@@ -25,7 +25,7 @@ module Rack
25
25
  response.each do |b|
26
26
  begin
27
27
  new_body << insert_dev_marks(b)
28
- rescue Rack::DevMark::Exception => e
28
+ rescue => e
29
29
  $stderr.write "Failed to insert dev marks: #{e.message}\n"
30
30
  end
31
31
  end
@@ -0,0 +1,17 @@
1
+ require 'rails'
2
+
3
+ module Rack
4
+ module DevMark
5
+ class Railtie < Rails::Railtie
6
+ config.rack_dev_mark = ActiveSupport::OrderedOptions.new
7
+
8
+ initializer "rack-dev-mark.configure_rails_initialization" do |app|
9
+ if app.config.rack_dev_mark.enable
10
+ racks = [ActionDispatch::ShowExceptions, Rack::DevMark::Middleware]
11
+ racks << app.config.rack_dev_mark.custom_theme if app.config.rack_dev_mark.custom_theme
12
+ app.config.app_middleware.insert_before *racks
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
@@ -1,3 +1,5 @@
1
+ require 'rack/dev-mark/theme/base'
2
+
1
3
  module Rack
2
4
  module DevMark
3
5
  module Theme
@@ -1,5 +1,5 @@
1
1
  module Rack
2
2
  module DevMark
3
- VERSION = '0.3.0'
3
+ VERSION = '0.4.0'
4
4
  end
5
5
  end
data/lib/rack/dev-mark.rb CHANGED
@@ -16,3 +16,5 @@ module Rack
16
16
  end
17
17
  end
18
18
  end
19
+
20
+ require 'rack/dev-mark/railties' if defined?(Rails)
@@ -57,4 +57,13 @@ describe Rack::DevMark::Middleware do
57
57
  expect(body).to eq(['{}'])
58
58
  end
59
59
  end
60
+ context "themes raise exceptions" do
61
+ before do
62
+ allow(theme).to receive(:insert_into).and_raise('something happened')
63
+ end
64
+ it "does not raise an exception but write it down in $stderr" do
65
+ expect($stderr).to receive(:write).with(/something happened/)
66
+ subject.call({})
67
+ end
68
+ end
60
69
  end
@@ -0,0 +1,11 @@
1
+ require 'spec_helper'
2
+
3
+ describe Rack::DevMark::Utils do
4
+ subject { Class.new{ include Rack::DevMark::Utils }.new }
5
+
6
+ describe "#camelize" do
7
+ it "camelizes" do
8
+ expect(subject.camelize("test_test_test")).to eq("TestTestTest")
9
+ end
10
+ end
11
+ 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.3.0
4
+ version: 0.4.0
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-15 00:00:00.000000000 Z
11
+ date: 2014-06-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rack
@@ -88,6 +88,7 @@ files:
88
88
  - lib/rack/dev-mark.rb
89
89
  - lib/rack/dev-mark/error.rb
90
90
  - lib/rack/dev-mark/middleware.rb
91
+ - lib/rack/dev-mark/railties.rb
91
92
  - lib/rack/dev-mark/theme.rb
92
93
  - lib/rack/dev-mark/theme/README.md
93
94
  - lib/rack/dev-mark/theme/base.rb
@@ -103,6 +104,7 @@ files:
103
104
  - spec/rack/dev-mark/theme/base_spec.rb
104
105
  - spec/rack/dev-mark/theme/github_fork_ribbon_spec.rb
105
106
  - spec/rack/dev-mark/theme/title_spec.rb
107
+ - spec/rack/dev-mark/utils_spec.rb
106
108
  - spec/rack/dev-mark_spec.rb
107
109
  - spec/spec_helper.rb
108
110
  - spec/support/theme_helper.rb
@@ -137,6 +139,7 @@ test_files:
137
139
  - spec/rack/dev-mark/theme/base_spec.rb
138
140
  - spec/rack/dev-mark/theme/github_fork_ribbon_spec.rb
139
141
  - spec/rack/dev-mark/theme/title_spec.rb
142
+ - spec/rack/dev-mark/utils_spec.rb
140
143
  - spec/rack/dev-mark_spec.rb
141
144
  - spec/spec_helper.rb
142
145
  - spec/support/theme_helper.rb