rack-env-notifier 0.0.2 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGELOG.md +6 -0
- data/README.md +29 -15
- data/lib/rack/env_notifier.rb +22 -6
- data/lib/rack-env-notifier.rb +1 -2
- data/rack-env-notifier.gemspec +1 -1
- data/spec/rack/env_notifier_spec.rb +21 -4
- metadata +29 -18
- checksums.yaml +0 -7
- data/lib/env_notifier_rails/railtie.rb +0 -11
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -1,30 +1,28 @@
|
|
1
1
|
# Rack::EnvNotifier [](http://travis-ci.org/ducknorris/rack-env-notifier)
|
2
2
|
|
3
|
-
[](https://codeclimate.com/github/ducknorris/rack-env-notifier) [](https://gemnasium.com/ducknorris/rack-env-notifier)[](http://badge.fury.io/rb/rack-env-notifier)
|
3
|
+
[](https://codeclimate.com/github/ducknorris/rack-env-notifier) [](https://gemnasium.com/ducknorris/rack-env-notifier) [](http://badge.fury.io/rb/rack-env-notifier)
|
4
4
|
|
5
|
-
|
5
|
+
Middleware that displays the custom notification for every html page. Designed to work both in production and in development.
|
6
6
|
|
7
|
-
|
7
|
+

|
8
8
|
|
9
|
-

|
10
10
|
|
11
|
-

|
12
12
|
|
13
|
-

|
14
14
|
|
15
|
-

|
16
16
|
|
17
|
-

|
18
18
|
|
19
|
-

|
19
|
+

|
22
20
|
|
23
21
|
## Installation
|
24
22
|
|
25
23
|
Add this line to your application's Gemfile:
|
26
24
|
|
27
|
-
gem '
|
25
|
+
gem 'rack-env-notifier'
|
28
26
|
|
29
27
|
And then execute:
|
30
28
|
|
@@ -32,11 +30,11 @@ And then execute:
|
|
32
30
|
|
33
31
|
Or install it yourself as:
|
34
32
|
|
35
|
-
$ gem install
|
33
|
+
$ gem install rack-env-notifier
|
36
34
|
|
37
35
|
## Usage
|
38
36
|
|
39
|
-
This Gem
|
37
|
+
This Gem can display a custom notification on every html page. This can be configured like this:
|
40
38
|
|
41
39
|
Rack::EnvNotifier.notify = Rails.env.production?
|
42
40
|
|
@@ -48,7 +46,13 @@ or
|
|
48
46
|
|
49
47
|
#### Position on screen
|
50
48
|
|
51
|
-
|
49
|
+
The notification uses ``#env-notifer`` CSS ID. This can be customized, using custom CSS.
|
50
|
+
|
51
|
+
To disable default CSS and use custom configure the initializer:
|
52
|
+
|
53
|
+
Rack::EnvNotifier.custom_css = true
|
54
|
+
|
55
|
+
And define custom CSS:
|
52
56
|
|
53
57
|
#env-notifier {
|
54
58
|
font-size: 16px;
|
@@ -85,6 +89,16 @@ For Ruby on Rails, by default the message it will be the name of the current env
|
|
85
89
|
Rack::EnvNotifier.message = "hot environment"
|
86
90
|
end
|
87
91
|
|
92
|
+
|
93
|
+
### Rails
|
94
|
+
|
95
|
+
Here is a sample initializer:
|
96
|
+
|
97
|
+
if Rails.env.development?
|
98
|
+
Rack::EnvNotifier.notify = true
|
99
|
+
Rack::EnvNotifier.message = 'Dev'
|
100
|
+
end
|
101
|
+
|
88
102
|
## Contributing
|
89
103
|
|
90
104
|
Thanks to our [contributors](https://github.com/ducknorris/env_notifier/graphs/contributors).
|
data/lib/rack/env_notifier.rb
CHANGED
@@ -3,28 +3,44 @@ require 'rack/env_notifier/body_injector'
|
|
3
3
|
module Rack
|
4
4
|
class EnvNotifier
|
5
5
|
class << self
|
6
|
+
def custom_css
|
7
|
+
@custom_css
|
8
|
+
end
|
9
|
+
|
10
|
+
def custom_css=(css)
|
11
|
+
@custom_css = css
|
12
|
+
end
|
13
|
+
|
6
14
|
def message
|
7
15
|
@message
|
8
16
|
end
|
9
17
|
|
10
|
-
def message=(
|
11
|
-
@message =
|
18
|
+
def message=(msg)
|
19
|
+
@message = msg
|
12
20
|
end
|
13
21
|
|
14
22
|
def notification
|
15
|
-
|
23
|
+
if @custom_css == true
|
24
|
+
<<-EOF
|
25
|
+
<!-- Notify Start -->
|
26
|
+
<div id="env-notifier" class="#{@message.gsub(/[^a-z]/i, '-').gsub(/--*/, '-').gsub(/-$/, '')}">#{@message}</div>
|
27
|
+
<!-- Notify End -->
|
28
|
+
EOF
|
29
|
+
else
|
30
|
+
<<-EOF
|
16
31
|
<!-- Notify Start -->
|
17
32
|
<div id="env-notifier" class="#{@message.gsub(/[^a-z]/i, '-').gsub(/--*/, '-').gsub(/-$/, '')}" style="position: fixed; top: 0; right: 0; left: 0; background: rgba(150, 50, 50, .7); color: #fff; text-align: center; font-size: 16px; font-weight: bold; padding: 2px; z-index: 999999">#{@message}</div>
|
18
33
|
<!-- Notify End -->
|
19
|
-
|
34
|
+
EOF
|
35
|
+
end
|
20
36
|
end
|
21
37
|
|
22
38
|
def notify?
|
23
39
|
@notify
|
24
40
|
end
|
25
41
|
|
26
|
-
def notify=(
|
27
|
-
@notify =
|
42
|
+
def notify=(ntf)
|
43
|
+
@notify = ntf
|
28
44
|
end
|
29
45
|
end
|
30
46
|
|
data/lib/rack-env-notifier.rb
CHANGED
data/rack-env-notifier.gemspec
CHANGED
@@ -8,7 +8,7 @@ Gem::Specification.new do |spec|
|
|
8
8
|
spec.version = Rack::EnvNotifier::VERSION
|
9
9
|
spec.authors = ["Catalin Ilinca"]
|
10
10
|
spec.email = ["c@talin.ro"]
|
11
|
-
spec.description = %q{Middleware that displays the custom
|
11
|
+
spec.description = %q{Middleware that displays the custom notification for every html page. Designed to work both in production and in development.}
|
12
12
|
spec.summary = %q{Know your ground!}
|
13
13
|
spec.homepage = "https://github.com/ducknorris/rack-env-notifier"
|
14
14
|
spec.license = "MIT"
|
@@ -77,13 +77,30 @@ describe Rack::EnvNotifier do
|
|
77
77
|
get '/some/path'
|
78
78
|
end
|
79
79
|
|
80
|
-
|
81
|
-
|
80
|
+
describe "with default CSS" do
|
81
|
+
it "does format the Notification" do
|
82
|
+
Rack::EnvNotifier.notification.should eq(<<-EOF
|
82
83
|
<!-- Notify Start -->
|
83
84
|
<div id="env-notifier" class="notification" style="position: fixed; top: 0; right: 0; left: 0; background: rgba(150, 50, 50, .7); color: #fff; text-align: center; font-size: 16px; font-weight: bold; padding: 2px; z-index: 999999">notification</div>
|
84
85
|
<!-- Notify End -->
|
85
|
-
|
86
|
-
|
86
|
+
EOF
|
87
|
+
)
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
context "with custom CSS" do
|
92
|
+
before do
|
93
|
+
Rack::EnvNotifier.custom_css = true
|
94
|
+
end
|
95
|
+
|
96
|
+
it "does format the Notification" do
|
97
|
+
Rack::EnvNotifier.notification.should eq(<<-EOF
|
98
|
+
<!-- Notify Start -->
|
99
|
+
<div id="env-notifier" class="notification">notification</div>
|
100
|
+
<!-- Notify End -->
|
101
|
+
EOF
|
102
|
+
)
|
103
|
+
end
|
87
104
|
end
|
88
105
|
end
|
89
106
|
end
|
metadata
CHANGED
@@ -1,18 +1,20 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rack-env-notifier
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
|
+
prerelease:
|
5
6
|
platform: ruby
|
6
7
|
authors:
|
7
8
|
- Catalin Ilinca
|
8
9
|
autorequire:
|
9
10
|
bindir: bin
|
10
11
|
cert_chain: []
|
11
|
-
date: 2013-11-
|
12
|
+
date: 2013-11-15 00:00:00.000000000 Z
|
12
13
|
dependencies:
|
13
14
|
- !ruby/object:Gem::Dependency
|
14
15
|
name: bundler
|
15
16
|
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
16
18
|
requirements:
|
17
19
|
- - ~>
|
18
20
|
- !ruby/object:Gem::Version
|
@@ -20,6 +22,7 @@ dependencies:
|
|
20
22
|
type: :development
|
21
23
|
prerelease: false
|
22
24
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
23
26
|
requirements:
|
24
27
|
- - ~>
|
25
28
|
- !ruby/object:Gem::Version
|
@@ -27,61 +30,69 @@ dependencies:
|
|
27
30
|
- !ruby/object:Gem::Dependency
|
28
31
|
name: rake
|
29
32
|
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
30
34
|
requirements:
|
31
|
-
- - '>='
|
35
|
+
- - ! '>='
|
32
36
|
- !ruby/object:Gem::Version
|
33
37
|
version: '0'
|
34
38
|
type: :development
|
35
39
|
prerelease: false
|
36
40
|
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
37
42
|
requirements:
|
38
|
-
- - '>='
|
43
|
+
- - ! '>='
|
39
44
|
- !ruby/object:Gem::Version
|
40
45
|
version: '0'
|
41
46
|
- !ruby/object:Gem::Dependency
|
42
47
|
name: rspec
|
43
48
|
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
44
50
|
requirements:
|
45
|
-
- - '>='
|
51
|
+
- - ! '>='
|
46
52
|
- !ruby/object:Gem::Version
|
47
53
|
version: '0'
|
48
54
|
type: :development
|
49
55
|
prerelease: false
|
50
56
|
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
51
58
|
requirements:
|
52
|
-
- - '>='
|
59
|
+
- - ! '>='
|
53
60
|
- !ruby/object:Gem::Version
|
54
61
|
version: '0'
|
55
62
|
- !ruby/object:Gem::Dependency
|
56
63
|
name: rack-test
|
57
64
|
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
58
66
|
requirements:
|
59
|
-
- - '>='
|
67
|
+
- - ! '>='
|
60
68
|
- !ruby/object:Gem::Version
|
61
69
|
version: '0'
|
62
70
|
type: :development
|
63
71
|
prerelease: false
|
64
72
|
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
65
74
|
requirements:
|
66
|
-
- - '>='
|
75
|
+
- - ! '>='
|
67
76
|
- !ruby/object:Gem::Version
|
68
77
|
version: '0'
|
69
78
|
- !ruby/object:Gem::Dependency
|
70
79
|
name: rack
|
71
80
|
requirement: !ruby/object:Gem::Requirement
|
81
|
+
none: false
|
72
82
|
requirements:
|
73
|
-
- - '>='
|
83
|
+
- - ! '>='
|
74
84
|
- !ruby/object:Gem::Version
|
75
85
|
version: 1.1.3
|
76
86
|
type: :runtime
|
77
87
|
prerelease: false
|
78
88
|
version_requirements: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
79
90
|
requirements:
|
80
|
-
- - '>='
|
91
|
+
- - ! '>='
|
81
92
|
- !ruby/object:Gem::Version
|
82
93
|
version: 1.1.3
|
83
|
-
description: Middleware that displays the custom
|
84
|
-
|
94
|
+
description: Middleware that displays the custom notification for every html page.
|
95
|
+
Designed to work both in production and in development.
|
85
96
|
email:
|
86
97
|
- c@talin.ro
|
87
98
|
executables: []
|
@@ -105,7 +116,6 @@ files:
|
|
105
116
|
- assets/preview5.png
|
106
117
|
- assets/preview6.png
|
107
118
|
- assets/preview7.png
|
108
|
-
- lib/env_notifier_rails/railtie.rb
|
109
119
|
- lib/rack-env-notifier.rb
|
110
120
|
- lib/rack/env_notifier.rb
|
111
121
|
- lib/rack/env_notifier/body_injector.rb
|
@@ -116,26 +126,27 @@ files:
|
|
116
126
|
homepage: https://github.com/ducknorris/rack-env-notifier
|
117
127
|
licenses:
|
118
128
|
- MIT
|
119
|
-
metadata: {}
|
120
129
|
post_install_message:
|
121
130
|
rdoc_options: []
|
122
131
|
require_paths:
|
123
132
|
- lib
|
124
133
|
required_ruby_version: !ruby/object:Gem::Requirement
|
134
|
+
none: false
|
125
135
|
requirements:
|
126
|
-
- - '>='
|
136
|
+
- - ! '>='
|
127
137
|
- !ruby/object:Gem::Version
|
128
138
|
version: '0'
|
129
139
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
140
|
+
none: false
|
130
141
|
requirements:
|
131
|
-
- - '>='
|
142
|
+
- - ! '>='
|
132
143
|
- !ruby/object:Gem::Version
|
133
144
|
version: '0'
|
134
145
|
requirements: []
|
135
146
|
rubyforge_project:
|
136
|
-
rubygems_version:
|
147
|
+
rubygems_version: 1.8.23
|
137
148
|
signing_key:
|
138
|
-
specification_version:
|
149
|
+
specification_version: 3
|
139
150
|
summary: Know your ground!
|
140
151
|
test_files:
|
141
152
|
- spec/rack/body_injector_spec.rb
|
checksums.yaml
DELETED
@@ -1,7 +0,0 @@
|
|
1
|
-
---
|
2
|
-
SHA1:
|
3
|
-
metadata.gz: ccd26b3423d911ae9ddfd1f0e07b3dfe5a64fb86
|
4
|
-
data.tar.gz: 2e18052ba84fa618d67cc92d0838b7ee24f40d63
|
5
|
-
SHA512:
|
6
|
-
metadata.gz: fa00b51945c47c64ee954c20d79e52e9dbfde5d64e8f7c99ebb61f70b8e37939328086f9f1821474b958d141c05e84f269328aa4fe42ab2da841c6d9a99dad7e
|
7
|
-
data.tar.gz: 245e94e5c6ca117bf51de25434eafd7d83f9a1986df1c0012e36f53e9a44d7e978558950159201e77a5fb6faacd364696f168e1e33b950f6f35907ca0aac1e73
|
@@ -1,11 +0,0 @@
|
|
1
|
-
module EnvNotifierRails
|
2
|
-
class Railtie < ::Rails::Railtie
|
3
|
-
initializer 'rack_env_notifier.initialize' do |app|
|
4
|
-
Rack::EnvNotifier.message = 'development'
|
5
|
-
Rack::EnvNotifier.notify = Rails.env.development?
|
6
|
-
|
7
|
-
# Install the Middleware
|
8
|
-
app.config.middleware.use Rack::EnvNotifier
|
9
|
-
end
|
10
|
-
end
|
11
|
-
end
|