rack-showme 0.0.1 → 0.0.2.1

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/.gitignore ADDED
@@ -0,0 +1,4 @@
1
+ rack-showme-*.gem
2
+ *.swp
3
+ .DS_Store
4
+
data/Gemfile CHANGED
@@ -1,4 +1,6 @@
1
1
  source "http://rubygems.org"
2
2
 
3
+ gem 'rake', :group => :development
4
+
3
5
  # Specify your gem's dependencies in rack-showme.gemspec
4
6
  gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,16 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ rack-showme (0.0.2.pre)
5
+
6
+ GEM
7
+ remote: http://rubygems.org/
8
+ specs:
9
+ rake (10.0.4)
10
+
11
+ PLATFORMS
12
+ ruby
13
+
14
+ DEPENDENCIES
15
+ rack-showme!
16
+ rake
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2013 Omar Vargas.
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.markdown CHANGED
@@ -1,7 +1,11 @@
1
- # Rack-Showme
1
+ # Rack::Showme
2
2
 
3
3
  Rack middleware that injects a message into HTML responses.
4
4
 
5
+ > By _message_ I mean a <div> element
6
+
7
+ This give us the ability to, for example, add a message indicating that the server is staging or any other QA environment without have to modify our code base
8
+
5
9
  ## Using with Rails
6
10
 
7
11
  Add the following line to your Gemfile
@@ -10,11 +14,54 @@ Add the following line to your Gemfile
10
14
  gem "rack-showme"
11
15
  ```
12
16
 
13
- Then add the following lines to your application.rb file
17
+ And run `bundle install`
18
+
19
+ Then add the following lines to an enviroment file e.g. `config/environments/development.rb`
14
20
 
15
21
  ```ruby
16
22
  require "rack/showme
23
+
17
24
  config.middleware.use "Rack::Showme"
18
25
  Rack::Showme::Options.message = "Development"
19
26
  ```
20
27
 
28
+ ## Options
29
+
30
+ You can select between three colorschemes `yellow`, `green` and `red`
31
+
32
+ ```ruby
33
+ Rack::Showme::Options.colorscheme= "yellow"
34
+ Rack::Showme::Options.colorscheme= "green"
35
+ Rack::Showme::Options.colorscheme= "red"
36
+ ```
37
+
38
+ This is useful to easily distinguish between diferent enviroments e.g. development and staging
39
+
40
+ ## Information
41
+
42
+ ### Bugs repors
43
+
44
+ If you discover a problem with **Rack::Showme**, please, open a Issue and include the more info you can.
45
+
46
+ ### Contributing
47
+
48
+ Do you have an idea about how do **Rack::Showme** better, don't hesitate in fork the project and send a pull request
49
+
50
+ ## ScreenShots
51
+
52
+ Simple rails app without **Rack::Showme**
53
+
54
+ ![Screenshot](doc/images/normal.png)
55
+
56
+ Default colorscheme (yellow)
57
+
58
+ ![Screenshot](doc/images/default.png)
59
+
60
+ Green colorscheme
61
+
62
+ ![Screenshot](doc/images/green.png)
63
+
64
+ Red colorscheme
65
+
66
+ ![Screenshot](doc/images/red.png)
67
+
data/Rakefile CHANGED
@@ -1,2 +1,12 @@
1
1
  require 'bundler'
2
+ require 'rake'
3
+ require 'rake/testtask'
4
+
2
5
  Bundler::GemHelper.install_tasks
6
+
7
+ # Minitest
8
+ Rake::TestTask.new do |t|
9
+ t.pattern = 'test/**/*_test.rb'
10
+ t.libs << 'test'
11
+ end
12
+
Binary file
Binary file
Binary file
Binary file
@@ -0,0 +1,32 @@
1
+ module Rack
2
+ class Showme
3
+ class MessageBox
4
+ def initialize(options)
5
+ @message = options.message
6
+ @colorscheme = options.colorscheme
7
+ end
8
+
9
+ def html
10
+ "<div id=\"rack-show-me-message-box\" class=\"#{colorscheme_class}\">#{message}</div>"
11
+ end
12
+
13
+ def message
14
+ @message
15
+ end
16
+
17
+ def colorscheme_class
18
+ case @colorscheme
19
+ when "yellow"
20
+ "rack-show-me-colorscheme-yellow"
21
+ when "red"
22
+ "rack-show-me-colorscheme-red"
23
+ when "green"
24
+ "rack-show-me-colorscheme-green"
25
+ else
26
+ "rack-show-me-colorscheme-yellow"
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end
32
+
@@ -2,6 +2,7 @@ module Rack
2
2
  class Showme
3
3
  module Options
4
4
  @@message = "[Add a Message]"
5
+ @@colorscheme = "yellow"
5
6
 
6
7
  class << self
7
8
  def message
@@ -11,6 +12,14 @@ module Rack
11
12
  def message=(value)
12
13
  @@message= value
13
14
  end
15
+
16
+ def colorscheme
17
+ @@colorscheme
18
+ end
19
+
20
+ def colorscheme=(value)
21
+ @@colorscheme= value
22
+ end
14
23
  end
15
24
  end
16
25
  end
@@ -1,12 +1,26 @@
1
- #show-me-message {
1
+ /* ribbon */
2
+ #rack-show-me-message-box {
2
3
  border-bottom: 1px solid #999;
3
4
  border-right: 1px solid #999;
4
5
  position: fixed;
5
6
  top: 0;
6
7
  left: 0;
7
8
  padding: 4px 7px;
8
- background-color: #FFF8C6;
9
- color: #333;
10
9
  cursor: pointer;
11
10
  z-index: 2147483640;
12
11
  }
12
+
13
+ .rack-show-me-colorscheme-yellow {
14
+ background-color: #FFF8C6;
15
+ color: #333333;
16
+ }
17
+
18
+ .rack-show-me-colorscheme-red {
19
+ background-color: #FD0006;
20
+ color: #000000;
21
+ }
22
+
23
+ .rack-show-me-colorscheme-green {
24
+ background-color: #42e73A;
25
+ color: #333333;
26
+ }
@@ -1,5 +1,5 @@
1
1
  module Rack
2
2
  class Showme
3
- VERSION = "0.0.1"
3
+ VERSION = "0.0.2.1"
4
4
  end
5
5
  end
data/lib/rack/showme.rb CHANGED
@@ -1,4 +1,5 @@
1
1
  require "rack/showme/options"
2
+ require "rack/showme/message_box"
2
3
 
3
4
  module Rack
4
5
  class Showme
@@ -30,11 +31,11 @@ module Rack
30
31
 
31
32
  def inject_html
32
33
  css_line = %Q{<style type="text/css">#{read_public_file("showme.css")}</style>\n}
33
- code = "<div id=\"show-me-message\"> #{Options.message}</div>"
34
+ message_box = MessageBox.new(Options).html
34
35
 
35
36
  body = @response.body
36
- body.gsub!("<body>", "<body>#{code}")
37
37
  body.gsub!("</body>", "#{css_line}</body>")
38
+ body.gsub!("<body>", "<body>#{message_box}")
38
39
  @response.body = body
39
40
 
40
41
  @headers["Content-Length"] = @response.body.bytesize.to_s
data/test/test_helper.rb CHANGED
@@ -1 +1 @@
1
- ENV["RAILS_ENV"] = "test"
1
+ require 'minitest/autorun'
@@ -0,0 +1,31 @@
1
+ require 'test_helper'
2
+
3
+ class TestMessageBox < MiniTest::Unit::TestCase
4
+ def test_yellow_colorscheme
5
+ Rack::Showme::Options.colorscheme= "yellow"
6
+ @message_box = Rack::Showme::MessageBox.new(Rack::Showme::Options)
7
+
8
+ assert_equal(@message_box.colorscheme_class, "rack-show-me-colorscheme-yellow")
9
+ end
10
+
11
+ def test_red_colorscheme
12
+ Rack::Showme::Options.colorscheme= "red"
13
+ @message_box = Rack::Showme::MessageBox.new(Rack::Showme::Options)
14
+
15
+ assert_equal(@message_box.colorscheme_class, "rack-show-me-colorscheme-red")
16
+ end
17
+
18
+ def test_green_colorscheme
19
+ Rack::Showme::Options.colorscheme= "green"
20
+ @message_box = Rack::Showme::MessageBox.new(Rack::Showme::Options)
21
+
22
+ assert_equal(@message_box.colorscheme_class, "rack-show-me-colorscheme-green")
23
+ end
24
+ def test_invalid_colorscheme
25
+ Rack::Showme::Options.colorscheme= "apple"
26
+ @message_box = Rack::Showme::MessageBox.new(Rack::Showme::Options)
27
+
28
+ # Yellow is the default colorscheme
29
+ assert_equal(@message_box.colorscheme_class, "rack-show-me-colorscheme-yellow")
30
+ end
31
+ end
@@ -0,0 +1,15 @@
1
+ require 'test_helper'
2
+
3
+ class TestMessageBox < MiniTest::Unit::TestCase
4
+ def setup
5
+ @message_box = Rack::Showme::MessageBox.new(Rack::Showme::Options)
6
+ end
7
+
8
+ def test_html_include_showme_id
9
+ assert_match @message_box.html, /id=\"rack-show-me-message-box\"/
10
+ end
11
+
12
+ def test_html_include_colorscheme_class
13
+ assert_match @message_box.html, /class=\"rack-show-me-colorscheme/
14
+ end
15
+ end
@@ -0,0 +1,12 @@
1
+ require 'test_helper'
2
+
3
+ class TestMessageBox < MiniTest::Unit::TestCase
4
+ def setup
5
+ Rack::Showme::Options.message = "Hello morros"
6
+ @message_box = Rack::Showme::MessageBox.new(Rack::Showme::Options)
7
+ end
8
+
9
+ def test_message
10
+ assert_equal(@message_box.message, "Hello morros")
11
+ end
12
+ end
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.1
4
+ version: 0.0.2.1
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-04-25 00:00:00.000000000 Z
12
+ date: 2013-05-01 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: Rack middleware that injects a message into HTML responses.
15
15
  email:
@@ -18,15 +18,27 @@ executables: []
18
18
  extensions: []
19
19
  extra_rdoc_files: []
20
20
  files:
21
+ - .gitignore
21
22
  - Gemfile
23
+ - Gemfile.lock
24
+ - MIT-LICENSE
22
25
  - README.markdown
23
26
  - Rakefile
27
+ - doc/images/default.png
28
+ - doc/images/green.png
29
+ - doc/images/normal.png
30
+ - doc/images/red.png
24
31
  - lib/rack/showme.rb
32
+ - lib/rack/showme/message_box.rb
25
33
  - lib/rack/showme/options.rb
26
34
  - lib/rack/showme/public/showme.css
27
35
  - lib/rack/showme/version.rb
28
36
  - rack-showme.gemspec
29
37
  - test/test_helper.rb
38
+ - test/unit/showme/message_box/colorschema_class_test.rb
39
+ - test/unit/showme/message_box/html_test.rb
40
+ - test/unit/showme/message_box/message_box_helper.rb
41
+ - test/unit/showme/message_box/message_test.rb
30
42
  homepage: https://github.com/ovargas27/rack-showme
31
43
  licenses: []
32
44
  post_install_message: