rack-dev-mark 0.5.1 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/README.md +22 -3
- data/{lib/rack/dev-mark/theme/README.md → THEME.md} +23 -7
- data/lib/rack/dev-mark.rb +8 -0
- data/lib/rack/dev-mark/middleware.rb +1 -1
- data/lib/rack/dev-mark/theme/base.rb +3 -2
- data/lib/rack/dev-mark/theme/github_fork_ribbon.rb +6 -1
- data/lib/rack/dev-mark/theme/tag.rb +1 -0
- data/lib/rack/dev-mark/version.rb +1 -1
- data/{lib/rack/dev-mark/theme/screenshots → misc/theme}/github_fork_ribbon.png +0 -0
- data/misc/theme/github_fork_ribbon_tooltip.png +0 -0
- data/misc/theme/title.png +0 -0
- data/spec/rack/dev-mark/theme/base_spec.rb +8 -1
- data/spec/rack/dev-mark/theme/github_fork_ribbon_spec.rb +4 -4
- data/spec/support/theme_helper.rb +1 -1
- metadata +6 -4
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
MzFjOWI5ZjJlNDdiODE0ZWY3NDM3NzE2NjdkODk2OGI3MWNiZDBiOQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
YmZkNjY3MjZlMmRiZTk3NTU4N2Q5YzMyYWNlNWIwM2U4ZTg1MzQ1NQ==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
YjM4ZDUzM2Y1N2FmMDJlYjBkNzQ3MjkyY2U3NzVlZDZiOWJiZTQzOTU1ZjIy
|
10
|
+
ZTgwNjgxNmVkYmU2ZTI3ZTZhMmZhY2FjYzE0ZWM1Nzc2M2NiYTlmZjUyNTI1
|
11
|
+
NDE4OTVhZWQwMDdhOWY3YWJhZGQ3ODE5MmU5NzYyZDNhNGRmMTc=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
ZWI3Mzc0NTk3M2VlNzhjNmM1MDJjNTA5NzJhZjEzYzI2ZDBkNjYzMzkyMzI2
|
14
|
+
NDg2MjlkZDNmMzY3NzYyMWM3YjEzYjcwOGRjZTZlNDEzNzU4YTk2ZmVjYzU4
|
15
|
+
MjhlNTg2YTc2NGM2YzYzMTgyMjM3MDg0YjNhODNkMmM4MTgxYjA=
|
data/README.md
CHANGED
@@ -1,9 +1,13 @@
|
|
1
1
|
# rack-dev-mark
|
2
2
|
|
3
|
-
[![Gem Version]
|
3
|
+
[![Gem Version][gem-image]][gem-link]
|
4
|
+
[![Dependency Status][deps-image]][deps-link]
|
5
|
+
[![Build Status][build-image]][build-link]
|
6
|
+
[![Coverage Status][cov-image]][cov-link]
|
7
|
+
[![Code Climate][gpa-image]][gpa-link]
|
4
8
|
|
5
9
|
Differentiate development environment from production.
|
6
|
-
You can choose [themes](
|
10
|
+
You can choose [themes](THEME.md) to differentiate the page.
|
7
11
|
|
8
12
|
## Screenshot
|
9
13
|
|
@@ -140,7 +144,7 @@ module MyApp
|
|
140
144
|
end
|
141
145
|
```
|
142
146
|
|
143
|
-
You can add any combination of themes. See more about [themes](
|
147
|
+
You can add any combination of themes. See more about [themes](THEME.md).
|
144
148
|
|
145
149
|
## Contributing
|
146
150
|
|
@@ -153,3 +157,18 @@ You can add any combination of themes. See more about [themes](lib/rack/dev-mark
|
|
153
157
|
## Copyright
|
154
158
|
|
155
159
|
Copyright (c) 2014 Daisuke Taniwaki. See [LICENSE](LICENSE) for details.
|
160
|
+
|
161
|
+
|
162
|
+
|
163
|
+
|
164
|
+
[gem-image]: https://badge.fury.io/rb/rack-dev-mark.svg
|
165
|
+
[gem-link]: http://badge.fury.io/rb/rack-dev-mark
|
166
|
+
[build-image]: https://secure.travis-ci.org/dtaniwaki/rack-dev-mark.png
|
167
|
+
[build-link]: http://travis-ci.org/dtaniwaki/rack-dev-mark
|
168
|
+
[deps-image]: https://gemnasium.com/dtaniwaki/rack-dev-mark.svg
|
169
|
+
[deps-link]: https://gemnasium.com/dtaniwaki/rack-dev-mark
|
170
|
+
[cov-image]: https://coveralls.io/repos/dtaniwaki/rack-dev-mark/badge.png
|
171
|
+
[cov-link]: https://coveralls.io/r/dtaniwaki/rack-dev-mark
|
172
|
+
[gpa-image]: https://codeclimate.com/github/dtaniwaki/rack-dev-mark.png
|
173
|
+
[gpa-link]: https://codeclimate.com/github/dtaniwaki/rack-dev-mark
|
174
|
+
|
@@ -24,9 +24,19 @@ end
|
|
24
24
|
|
25
25
|
Insert the environment string into tags or attributes.
|
26
26
|
|
27
|
-
e.g.
|
27
|
+
### e.g.
|
28
28
|
|
29
|
-
|
29
|
+
#### by tag name
|
30
|
+
|
31
|
+
`Rack::DevMark::Theme::Tag.new(attribute: 'data-title')`
|
32
|
+
|
33
|
+
`<div data-title="foo">foo</div>` will be `<div data-title="(env) foo">foo</div>`
|
34
|
+
|
35
|
+
#### by attribute
|
36
|
+
|
37
|
+
`Rack::DevMark::Theme::Tag.new(name: 'h1')`
|
38
|
+
|
39
|
+
`<h1>foo</h1>` will be `<h1="foo">(env) foo</h1>`
|
30
40
|
|
31
41
|
### options
|
32
42
|
|
@@ -40,13 +50,11 @@ e.g.
|
|
40
50
|
|
41
51
|
## title
|
42
52
|
|
43
|
-
|
44
|
-
|
45
|
-
e.g.
|
53
|
+
Subclass of tag theme specifically made for title tag. It just adds the environment string into the page title.
|
46
54
|
|
47
55
|
`My Homepage` on development env will be `(development) My Homepage`
|
48
56
|
|
49
|
-
|
57
|
+
![title](misc/theme/title.png)
|
50
58
|
|
51
59
|
### options
|
52
60
|
|
@@ -58,7 +66,15 @@ options are the same as tag theme.
|
|
58
66
|
|
59
67
|
["Fork Me on GitHub" like ribbon](https://github.com/simonwhitaker/github-fork-ribbon-css) originally created by [simonwhitaker](https://github.com/simonwhitaker)
|
60
68
|
|
61
|
-
|
69
|
+
It shows a banner of the environment on the ribbon.
|
70
|
+
|
71
|
+
![github_fork_ribbon](misc/theme/github_fork_ribbon.png)
|
72
|
+
|
73
|
+
It also shows deployment revision and timestamp on the tooltip if available.
|
74
|
+
|
75
|
+
![github_fork_ribbon tooltip](misc/theme/github_fork_ribbon_tooltip.png)
|
76
|
+
|
77
|
+
Click the banner to remove it temporarily.
|
62
78
|
|
63
79
|
### options
|
64
80
|
|
data/lib/rack/dev-mark.rb
CHANGED
@@ -22,6 +22,14 @@ module Rack
|
|
22
22
|
def self.revision=(revision)
|
23
23
|
@revision = revision
|
24
24
|
end
|
25
|
+
|
26
|
+
def self.timestamp
|
27
|
+
@timestamp ||= (::File.open('REVISION') { |f| f.ctime } rescue nil)
|
28
|
+
end
|
29
|
+
|
30
|
+
def self.timestamp=(timestamp)
|
31
|
+
@timestamp = timestamp
|
32
|
+
end
|
25
33
|
end
|
26
34
|
end
|
27
35
|
|
@@ -8,7 +8,7 @@ module Rack
|
|
8
8
|
@app = app
|
9
9
|
@themes = [themes].flatten.map do |theme|
|
10
10
|
theme = theme.is_a?(Symbol) ? Rack::DevMark::Theme.const_get(camelize(theme.to_s)).new : theme
|
11
|
-
theme.setup Rack::DevMark.env, Rack::DevMark.revision
|
11
|
+
theme.setup Rack::DevMark.env, Rack::DevMark.revision, Rack::DevMark.timestamp
|
12
12
|
theme
|
13
13
|
end
|
14
14
|
end
|
@@ -2,15 +2,16 @@ module Rack
|
|
2
2
|
module DevMark
|
3
3
|
module Theme
|
4
4
|
class Base
|
5
|
-
attr_reader :env, :revision
|
5
|
+
attr_reader :env, :revision, :timestamp
|
6
6
|
|
7
7
|
def initialize(*args)
|
8
8
|
raise RuntimeError, 'Abstract class can not be instantiated' if self.class == Rack::DevMark::Theme::Base
|
9
9
|
end
|
10
10
|
|
11
|
-
def setup(env, revision)
|
11
|
+
def setup(env, revision, timestamp)
|
12
12
|
@env = env
|
13
13
|
@revision = revision
|
14
|
+
@timestamp = timestamp
|
14
15
|
end
|
15
16
|
|
16
17
|
def insert_into(html)
|
@@ -7,18 +7,23 @@ module Rack
|
|
7
7
|
class GithubForkRibbon < Base
|
8
8
|
def initialize(options = {})
|
9
9
|
@options = options
|
10
|
+
super
|
10
11
|
end
|
11
12
|
|
12
13
|
def insert_into(html)
|
13
14
|
position = @options[:position] || 'left'
|
14
15
|
color = @options[:color] || 'red'
|
15
16
|
fixed = @options[:fixed] ? ' fixed' : ''
|
17
|
+
title = []
|
18
|
+
title << revision if revision.to_s != ''
|
19
|
+
title << timestamp if timestamp.to_s != ''
|
20
|
+
title = title.join(" ")
|
16
21
|
s = <<-EOS
|
17
22
|
#{stylesheet_link_tag "github-fork-ribbon-css/gh-fork-ribbon.css"}
|
18
23
|
<!--[if lt IE 9]>
|
19
24
|
#{stylesheet_link_tag "github-fork-ribbon-css/gh-fork-ribbon.ie.css"}
|
20
25
|
<![endif]-->
|
21
|
-
<div class="github-fork-ribbon-wrapper #{position}#{fixed}" onClick="this.style.display='none'" title="#{
|
26
|
+
<div class="github-fork-ribbon-wrapper #{position}#{fixed}" onClick="this.style.display='none'" title="#{title}"><div class="github-fork-ribbon #{color}"><span class="github-fork-ribbon-text">#{env}</span></div></div>
|
22
27
|
EOS
|
23
28
|
html.sub %r{(<body[^>]*>)}i, "\\1#{s.strip}"
|
24
29
|
end
|
File without changes
|
Binary file
|
Binary file
|
@@ -9,7 +9,7 @@ describe Rack::DevMark::Theme::Base do
|
|
9
9
|
describe "subclass" do
|
10
10
|
subject { Class.new(Rack::DevMark::Theme::Base).new }
|
11
11
|
it "sets up" do
|
12
|
-
subject.setup 'env', 'rev'
|
12
|
+
subject.setup 'env', 'rev', 'time'
|
13
13
|
expect(subject.env).to eq('env')
|
14
14
|
expect(subject.revision).to eq('rev')
|
15
15
|
end
|
@@ -26,6 +26,13 @@ describe Rack::DevMark::Theme::Base do
|
|
26
26
|
expect(subject.send(:gsub_tag_content, input, 'a', &lambda{ |v| 'replaced' })).to eq(output)
|
27
27
|
end
|
28
28
|
end
|
29
|
+
context "for nested tags" do
|
30
|
+
let(:input) { %Q|<body><h1>head</h1><a href="something"><span>x</span></a><span>y</span></div>| }
|
31
|
+
let(:output) { %Q|<body><h1>head</h1><a href="something"><span>x</span></a><span>y</span></div>| }
|
32
|
+
it "does not replace a string" do
|
33
|
+
expect(subject.send(:gsub_tag_content, input, 'a', &lambda{ |v| 'replaced' })).to eq(output)
|
34
|
+
end
|
35
|
+
end
|
29
36
|
end
|
30
37
|
describe "#gsub_tag_attribute" do
|
31
38
|
let(:input) { %Q|<body><h1>head</h1><a href="something" data-title="x" data-body="x">x</a><span data-title="y">y</span></div>| }
|
@@ -9,7 +9,7 @@ describe Rack::DevMark::Theme::GithubForkRibbon do
|
|
9
9
|
<!--[if lt IE 9]>
|
10
10
|
<style>#{read_stylesheet "github-fork-ribbon-css/gh-fork-ribbon.ie.css"}</style>
|
11
11
|
<![endif]-->
|
12
|
-
<div class="github-fork-ribbon-wrapper left" onClick="this.style.display='none'" title="rev"><div class="github-fork-ribbon red"><span class="github-fork-ribbon-text">env</span></div></div>body</body></html>
|
12
|
+
<div class="github-fork-ribbon-wrapper left" onClick="this.style.display='none'" title="rev time"><div class="github-fork-ribbon red"><span class="github-fork-ribbon-text">env</span></div></div>body</body></html>
|
13
13
|
EOS
|
14
14
|
s.strip
|
15
15
|
end
|
@@ -24,7 +24,7 @@ describe Rack::DevMark::Theme::GithubForkRibbon do
|
|
24
24
|
<!--[if lt IE 9]>
|
25
25
|
<style>#{read_stylesheet "github-fork-ribbon-css/gh-fork-ribbon.ie.css"}</style>
|
26
26
|
<![endif]-->
|
27
|
-
<div class="github-fork-ribbon-wrapper right" onClick="this.style.display='none'" title="rev"><div class="github-fork-ribbon red"><span class="github-fork-ribbon-text">env</span></div></div>body</body></html>
|
27
|
+
<div class="github-fork-ribbon-wrapper right" onClick="this.style.display='none'" title="rev time"><div class="github-fork-ribbon red"><span class="github-fork-ribbon-text">env</span></div></div>body</body></html>
|
28
28
|
EOS
|
29
29
|
s.strip
|
30
30
|
end
|
@@ -40,7 +40,7 @@ describe Rack::DevMark::Theme::GithubForkRibbon do
|
|
40
40
|
<!--[if lt IE 9]>
|
41
41
|
<style>#{read_stylesheet "github-fork-ribbon-css/gh-fork-ribbon.ie.css"}</style>
|
42
42
|
<![endif]-->
|
43
|
-
<div class="github-fork-ribbon-wrapper left" onClick="this.style.display='none'" title="rev"><div class="github-fork-ribbon orange"><span class="github-fork-ribbon-text">env</span></div></div>body</body></html>
|
43
|
+
<div class="github-fork-ribbon-wrapper left" onClick="this.style.display='none'" title="rev time"><div class="github-fork-ribbon orange"><span class="github-fork-ribbon-text">env</span></div></div>body</body></html>
|
44
44
|
EOS
|
45
45
|
s.strip
|
46
46
|
end
|
@@ -56,7 +56,7 @@ describe Rack::DevMark::Theme::GithubForkRibbon do
|
|
56
56
|
<!--[if lt IE 9]>
|
57
57
|
<style>#{read_stylesheet "github-fork-ribbon-css/gh-fork-ribbon.ie.css"}</style>
|
58
58
|
<![endif]-->
|
59
|
-
<div class="github-fork-ribbon-wrapper left fixed" onClick="this.style.display='none'" title="rev"><div class="github-fork-ribbon red"><span class="github-fork-ribbon-text">env</span></div></div>body</body></html>
|
59
|
+
<div class="github-fork-ribbon-wrapper left fixed" onClick="this.style.display='none'" title="rev time"><div class="github-fork-ribbon red"><span class="github-fork-ribbon-text">env</span></div></div>body</body></html>
|
60
60
|
EOS
|
61
61
|
s.strip
|
62
62
|
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
|
+
version: 0.6.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-07-
|
11
|
+
date: 2014-07-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rack
|
@@ -79,6 +79,7 @@ files:
|
|
79
79
|
- LICENSE
|
80
80
|
- README.md
|
81
81
|
- Rakefile
|
82
|
+
- THEME.md
|
82
83
|
- gemfiles/gemfile
|
83
84
|
- gemfiles/rack.1.1.x.gemfile
|
84
85
|
- gemfiles/rack.1.2.x.gemfile
|
@@ -94,10 +95,8 @@ files:
|
|
94
95
|
- lib/rack/dev-mark/middleware.rb
|
95
96
|
- lib/rack/dev-mark/railtie.rb
|
96
97
|
- lib/rack/dev-mark/theme.rb
|
97
|
-
- lib/rack/dev-mark/theme/README.md
|
98
98
|
- lib/rack/dev-mark/theme/base.rb
|
99
99
|
- lib/rack/dev-mark/theme/github_fork_ribbon.rb
|
100
|
-
- lib/rack/dev-mark/theme/screenshots/github_fork_ribbon.png
|
101
100
|
- lib/rack/dev-mark/theme/tag.rb
|
102
101
|
- lib/rack/dev-mark/theme/title.rb
|
103
102
|
- lib/rack/dev-mark/utils.rb
|
@@ -105,6 +104,9 @@ files:
|
|
105
104
|
- misc/screenshot-development.png
|
106
105
|
- misc/screenshot-production.png
|
107
106
|
- misc/screenshot.gif
|
107
|
+
- misc/theme/github_fork_ribbon.png
|
108
|
+
- misc/theme/github_fork_ribbon_tooltip.png
|
109
|
+
- misc/theme/title.png
|
108
110
|
- rack-dev-mark.gemspec
|
109
111
|
- spec/generators/rack/dev-mark/install_generator_spec.rb
|
110
112
|
- spec/rack/dev-mark/middleware_spec.rb
|