rack-showme 0.0.3 → 0.0.4

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/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rack-showme (0.0.2.1)
4
+ rack-showme (0.0.4)
5
5
 
6
6
  GEM
7
7
  remote: http://rubygems.org/
@@ -0,0 +1,13 @@
1
+ module Rack
2
+ class Showme
3
+ class BreakpointsBox < MessageBox
4
+ def initialize(options)
5
+ @colorscheme = options.colorscheme
6
+ end
7
+
8
+ def html
9
+ "<div id=\"rack-show-me-breakpoints\" class=\"#{colorscheme_class}\"></div>"
10
+ end
11
+ end
12
+ end
13
+ end
@@ -21,7 +21,6 @@ module Rack
21
21
  COLORS.include?(@colorscheme) ? custom_class_name : default_class_name
22
22
  end
23
23
 
24
- private
25
24
  def default_class_name
26
25
  "#{PREFIX}-#{COLORS.first}"
27
26
  end
@@ -3,6 +3,7 @@ module Rack
3
3
  module Options
4
4
  @@message = "[Add a Message]"
5
5
  @@colorscheme = "yellow"
6
+ @@show_breakpoints = nil
6
7
 
7
8
  class << self
8
9
  def message
@@ -20,6 +21,14 @@ module Rack
20
21
  def colorscheme=(value)
21
22
  @@colorscheme= value
22
23
  end
24
+
25
+ def show_breakpoints=(value)
26
+ @show_breakpoints = value
27
+ end
28
+
29
+ def show_breakpoints
30
+ @show_breakpoints
31
+ end
23
32
  end
24
33
  end
25
34
  end
@@ -0,0 +1,29 @@
1
+ /* Default breakpoints
2
+ * aka jonathandean's breakpoints
3
+ * http://jonathandean.com/2013/01/showing-the-current-breakpoint-name-when-testing-responsive-designs-using-only-css/
4
+ */
5
+
6
+ @media screen and (min-width: 960px){
7
+ #rack-show-me-breakpoints:before{
8
+ content: ' at desktop';
9
+ }
10
+ }
11
+
12
+ @media screen and (min-width: 768px) and (max-width:959px){
13
+ #rack-show-me-breakpoints:before{
14
+ content: ' at tablet';
15
+ }
16
+ }
17
+
18
+ @media screen and (max-width: 767px){
19
+ #rack-show-me-breakpoints:before{
20
+ content: ' at mobile-portrait';
21
+ }
22
+ }
23
+
24
+ @media screen and (min-width: 480px) and (max-width:767px){
25
+ #rack-show-me-breakpoints:before{
26
+ content: ' at mobile-landscape';
27
+ }
28
+ }
29
+
@@ -1,26 +1,40 @@
1
1
  /* ribbon */
2
2
  #rack-show-me-message-box {
3
- border-bottom: 1px solid #999;
4
- border-right: 1px solid #999;
3
+ color: #333333;
4
+ border-bottom: 1px solid #999;
5
+ border-right: 1px solid #999;
5
6
  position: fixed;
6
7
  top: 0;
7
8
  left: 0;
8
- padding: 4px 7px;
9
- cursor: pointer;
10
- z-index: 2147483640;
9
+ padding: 4px 7px;
10
+ cursor: pointer;
11
+ z-index: 2147483640;
12
+ }
13
+
14
+ #rack-show-me-breakpoints {
15
+ color: #333333;
16
+ border-bottom: 1px solid #999;
17
+ border-right: 1px solid #999;
18
+ position: fixed;
19
+ top: 29px;
20
+ left: 0;
21
+ padding: 4px 7px;
22
+ cursor: pointer;
23
+ z-index: 2147483640;
11
24
  }
12
25
 
13
26
  .rack-show-me-colorscheme-yellow {
14
- background-color: #FFF8C6;
15
- color: #333333;
27
+ background-color: #FFF8C6;
28
+ color: #333333;
16
29
  }
17
30
 
18
31
  .rack-show-me-colorscheme-red {
19
- background-color: #FD0006;
20
- color: #000000;
32
+ background-color: #FD0006;
33
+ color: #000000;
21
34
  }
22
35
 
23
36
  .rack-show-me-colorscheme-green {
24
- background-color: #42e73A;
25
- color: #333333;
37
+ background-color: #42e73A;
38
+ color: #333333;
26
39
  }
40
+
@@ -1,5 +1,5 @@
1
1
  module Rack
2
2
  class Showme
3
- VERSION = "0.0.3"
3
+ VERSION = "0.0.4"
4
4
  end
5
5
  end
data/lib/rack/showme.rb CHANGED
@@ -1,5 +1,6 @@
1
1
  require "rack/showme/options"
2
2
  require "rack/showme/message_box"
3
+ require "rack/showme/breakpoints_box"
3
4
 
4
5
  module Rack
5
6
  class Showme
@@ -33,18 +34,30 @@ module Rack
33
34
  @headers && @headers["Content-Type"] && @headers["Content-Type"].include?("text/html")
34
35
  end
35
36
 
36
- def inject_html
37
- css_line = %Q{<style type="text/css">#{read_public_file("showme.css")}</style>\n}
38
- message_box = MessageBox.new(Options).html
37
+ def display_breakpoints?
38
+ @display_breakpoints ||= Options.show_breakpoints
39
+ end
39
40
 
41
+ def inject_html
40
42
  body = @response.body
41
43
  body.gsub!("</body>", "#{css_line}</body>")
42
- body.gsub!("<body>", "<body>#{message_box}")
44
+ body.gsub!("<body>", "<body>#{show_boxes}")
43
45
  @response.body = body
44
46
 
45
47
  @headers["Content-Length"] = @response.body.bytesize.to_s
46
48
  end
47
49
 
50
+ def css_line
51
+ files = ["showme.css"]
52
+ files << "showme.breakpoints.css" if display_breakpoints?
53
+ %Q{<style type="text/css">#{files.map{|file| read_public_file(file) }.join()}</style>\n}
54
+ end
55
+
56
+ def show_boxes
57
+ html_string = MessageBox.new(Options).html
58
+ html_string + BreakpointsBox.new(Options).html if display_breakpoints?
59
+ end
60
+
48
61
  def read_public_file(filename)
49
62
  output = ::File.open(::File.join(::File.dirname(__FILE__), "showme", "public", filename), "r:UTF-8") do |f|
50
63
  f.read
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rack-showme
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-07-05 00:00:00.000000000 Z
12
+ date: 2013-08-24 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: Rack middleware that injects a message into HTML responses.
15
15
  email:
@@ -33,8 +33,10 @@ files:
33
33
  - doc/images/staging_red.png
34
34
  - doc/images/staging_yellow.png
35
35
  - lib/rack/showme.rb
36
+ - lib/rack/showme/breakpoints_box.rb
36
37
  - lib/rack/showme/message_box.rb
37
38
  - lib/rack/showme/options.rb
39
+ - lib/rack/showme/public/showme.breakpoints.css
38
40
  - lib/rack/showme/public/showme.css
39
41
  - lib/rack/showme/version.rb
40
42
  - rack-showme.gemspec