rails-bootstrap-sass-grid_size_display 0.0.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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: adda83231d0d9768e2d5fbd1bd1bebb2cac7b0cc
4
+ data.tar.gz: 046e3d722358d96e65fac247e2b28ea44f22252a
5
+ SHA512:
6
+ metadata.gz: 6c217dfdb927c16cf46d0d4501dab99f5ba54289e7352eec47f58b09a43f5548698853c86d06dcf5cb5334d3d39c08bd496cf7a017f3fe63150dce01b16df4b7
7
+ data.tar.gz: b6900d999404a7a6d1fa69794b4df36654e726ab511f77d9d4adf43e05e0cca2edc678dc6306e60d1a9ec09213c2098e16e5a8931093e3577c5e3430deb833db
@@ -0,0 +1,23 @@
1
+ .bundle/
2
+ log/*.log
3
+ pkg/
4
+ test/dummy/db/*.sqlite3
5
+ test/dummy/db/*.sqlite3-journal
6
+ test/dummy/log/*.log
7
+ test/dummy/tmp/
8
+ test/dummy/.sass-cache
9
+
10
+ /*.gem
11
+ /.yardoc
12
+ /Gemfile.lock
13
+ /_yardoc/
14
+ /coverage/
15
+ /doc/
16
+ /pkg/
17
+ /spec/reports/
18
+ /tmp/
19
+ /.DS_Store
20
+
21
+ /.gems
22
+ /.byebug_history
23
+ /.rspec
data/Gemfile ADDED
@@ -0,0 +1,15 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Declare your gem's dependencies in grid_size_display.gemspec.
4
+ # Bundler will treat runtime dependencies like base dependencies, and
5
+ # development dependencies will be added by default to the :development group.
6
+ gemspec
7
+
8
+ # Declare any dependencies that are still in development here instead of in
9
+ # your gemspec. These might include edge Rails or gems from your path or
10
+ # Git. Remember to move these dependencies to your gemspec before releasing
11
+ # your gem to rubygems.org.
12
+
13
+ # To use a debugger
14
+ # gem 'byebug', group: [:development, :test]
15
+
@@ -0,0 +1,20 @@
1
+ Copyright 2016 jgdreyes
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.
@@ -0,0 +1,56 @@
1
+ = GridSizeDisplay
2
+
3
+ If you are using Rails and the bootstrap-sass gem, display a visual indicator to let
4
+ you know what bootstrap grid size you are using. This gem uses the default
5
+ bootstrap variables names to determine grid sizes. The gem works even if you've overwritten
6
+ the default values of the variables.
7
+
8
+
9
+ From the Bootstrap3 documentation:
10
+ ```
11
+ @media (max-width: @screen-xs-max) { ... }
12
+ @media (min-width: @screen-sm-min) and (max-width: @screen-sm-max) { ... }
13
+ @media (min-width: @screen-md-min) and (max-width: @screen-md-max) { ... }
14
+ @media (min-width: @screen-lg-min) { ... }
15
+ ```
16
+
17
+ - `col-xs-*` = Red
18
+ - `col-sm-*` = Orange
19
+ - `col-md-*` = Yellow
20
+ - `col-lg-*` = Green
21
+
22
+
23
+
24
+
25
+
26
+ ## Installation
27
+
28
+ Add this line to your applications Rails + bootstrap-sass enabled application Gemfile:
29
+
30
+ ```ruby
31
+ group :development do
32
+ gem 'gem_size_display'
33
+ end
34
+ ```
35
+
36
+ And then execute:
37
+
38
+ ```
39
+ $ bundle
40
+ ```
41
+
42
+ Include the Sass partial to your application.scss file. Be sure to include it after bootstrap.
43
+
44
+ ```sass
45
+ // app/assets/stylesheets/application.scss
46
+ ...
47
+ @import "bootstrap-sprockets";
48
+ @import "bootstrap";
49
+ @import "grid_size_display/media_sizes";
50
+ ```
51
+
52
+ ## Special query strings
53
+
54
+ By default the visual indicator will be displayed on every request. If you include
55
+ the query string `grid_size_display=disable` at the end of your request you will disable
56
+ the display for your session. To re-enable just add the query string `grid_size_display=enable`.
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+
@@ -0,0 +1,28 @@
1
+ #grid-size-display-container {
2
+ position: absolute;
3
+ top: 0;
4
+ width: 100%;
5
+ height: 10px;
6
+ z-index: 10000;
7
+ }
8
+
9
+ @media (max-width: $screen-xs-max) {
10
+ #grid-size-display-container {
11
+ background-color: red;
12
+ }
13
+ }
14
+ @media (min-width: $screen-sm-min) and (max-width: $screen-sm-max) {
15
+ #grid-size-display-container {
16
+ background-color: orange;
17
+ }
18
+ }
19
+ @media (min-width: $screen-md-min) and (max-width: $screen-md-max) {
20
+ #grid-size-display-container {
21
+ background-color: yellow;
22
+ }
23
+ }
24
+ @media (min-width: $screen-lg-min) {
25
+ #grid-size-display-container {
26
+ background-color: green;
27
+ }
28
+ }
@@ -0,0 +1,4 @@
1
+ module GridSizeDisplay
2
+ class ApplicationController < ActionController::Base
3
+ end
4
+ end
@@ -0,0 +1,63 @@
1
+ module GridSizeDisplay
2
+ class Engine < ::Rails::Engine
3
+
4
+ isolate_namespace GridSizeDisplay
5
+
6
+ initializer "rails-bootstrap-sass_grid_size_display.add_middleware" do |app|
7
+ app.middleware.use GridSizeDisplay::Rack
8
+ end
9
+ end
10
+
11
+ class Rack
12
+ DEFAULT_INSERTION_POINT = '</body>'.freeze
13
+ HTML_CONTENT_TYPE = 'text/html'.freeze
14
+
15
+ def initialize(app, options = {})
16
+ @app, @options = app, options
17
+ @options[:insertion_point] ||= DEFAULT_INSERTION_POINT
18
+ end
19
+
20
+ def call(env)
21
+ status, headers, response = @app.call(env)
22
+
23
+ req = process_display_param(env)
24
+
25
+ if headers['Content-Type'].to_s.include?(HTML_CONTENT_TYPE) && display_grid?(req)
26
+ new_response = []
27
+ response.each do |body|
28
+ # find the last matching insertion point in the body and insert the content
29
+ partition = body.rpartition(@options[:insertion_point])
30
+ partition[0] += %q{<div id="grid-size-display-container"></div>}
31
+ new_response << partition.join
32
+ end
33
+
34
+ # Update the content-length
35
+ headers['Content-Length'] = new_response.inject(0) do |len, body|
36
+ len += body.bytesize
37
+ end.to_s
38
+
39
+ [status, headers, new_response]
40
+ else
41
+ [status, headers, response]
42
+ end
43
+ end
44
+
45
+ def display_grid?(req)
46
+ req.session['grid_size_display']
47
+ end
48
+
49
+
50
+ def process_display_param(env)
51
+ req = ::Rack::Request.new(env)
52
+
53
+ case req.params['grid_size_display']
54
+ when 'enable' then req.session['grid_size_display'] = true
55
+ when 'disable' then req.session['grid_size_display'] = false
56
+ end
57
+
58
+ req.session['grid_size_display'] = true if req.session['grid_size_display'].nil?
59
+ req
60
+ end
61
+
62
+ end
63
+ end
@@ -0,0 +1,3 @@
1
+ module GridSizeDisplay
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,4 @@
1
+ require "grid_size_display/engine"
2
+
3
+ module GridSizeDisplay
4
+ end
@@ -0,0 +1,31 @@
1
+ $:.push File.expand_path("../lib", __FILE__)
2
+
3
+ # Maintain your gem's version:
4
+ require "grid_size_display/version"
5
+
6
+ # Describe your gem and declare its dependencies:
7
+ Gem::Specification.new do |spec|
8
+ spec.name = "rails-bootstrap-sass-grid_size_display"
9
+ spec.version = GridSizeDisplay::VERSION
10
+
11
+ spec.authors = ["Jennifer Reyes"]
12
+ spec.email = ["jgdreyes@gmail.com"]
13
+
14
+ spec.summary = %q{Display a colored grid size indicator when using bootstrap-sass with Rails.}
15
+ spec.description = %q{Display a colored grid size indicator when using bootstrap-sass with Rails. Display a colored grid size indicator at the top of the page. The colors correspond to the bootstrap breakpoints.}
16
+ spec.homepage = "https://github.com/jgdreyes/rails-bootstrap-sass-grid_size_display"
17
+ spec.license = "MIT"
18
+
19
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
20
+ spec.bindir = "exe"
21
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
22
+ spec.require_paths = ["lib"]
23
+
24
+ spec.add_development_dependency "bundler", "~> 1.11"
25
+ spec.add_development_dependency "rake", "~> 10.0"
26
+ spec.add_development_dependency "rspec", "~> 3.0"
27
+
28
+ spec.add_dependency "rails", "~> 4.2"
29
+ spec.add_dependency "bootstrap-sass", "~> 3.3"
30
+ spec.add_dependency "byebug", "~> 8.2"
31
+ end
metadata ADDED
@@ -0,0 +1,141 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rails-bootstrap-sass-grid_size_display
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Jennifer Reyes
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2016-04-21 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.11'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.11'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '3.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '3.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rails
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '4.2'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '4.2'
69
+ - !ruby/object:Gem::Dependency
70
+ name: bootstrap-sass
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '3.3'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '3.3'
83
+ - !ruby/object:Gem::Dependency
84
+ name: byebug
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '8.2'
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '8.2'
97
+ description: Display a colored grid size indicator when using bootstrap-sass with
98
+ Rails. Display a colored grid size indicator at the top of the page. The colors
99
+ correspond to the bootstrap breakpoints.
100
+ email:
101
+ - jgdreyes@gmail.com
102
+ executables: []
103
+ extensions: []
104
+ extra_rdoc_files: []
105
+ files:
106
+ - ".gitignore"
107
+ - Gemfile
108
+ - MIT-LICENSE
109
+ - README.rdoc
110
+ - Rakefile
111
+ - app/assets/stylesheets/grid_size_display/_media_sizes.scss
112
+ - app/controllers/grid_size_display/application_controller.rb
113
+ - lib/grid_size_display/engine.rb
114
+ - lib/grid_size_display/version.rb
115
+ - lib/rails-bootstrap-sass-grid_size_display.rb
116
+ - rails-bootstrap-sass-grid_size_display.gemspec
117
+ homepage: https://github.com/jgdreyes/rails-bootstrap-sass-grid_size_display
118
+ licenses:
119
+ - MIT
120
+ metadata: {}
121
+ post_install_message:
122
+ rdoc_options: []
123
+ require_paths:
124
+ - lib
125
+ required_ruby_version: !ruby/object:Gem::Requirement
126
+ requirements:
127
+ - - ">="
128
+ - !ruby/object:Gem::Version
129
+ version: '0'
130
+ required_rubygems_version: !ruby/object:Gem::Requirement
131
+ requirements:
132
+ - - ">="
133
+ - !ruby/object:Gem::Version
134
+ version: '0'
135
+ requirements: []
136
+ rubyforge_project:
137
+ rubygems_version: 2.4.5.1
138
+ signing_key:
139
+ specification_version: 4
140
+ summary: Display a colored grid size indicator when using bootstrap-sass with Rails.
141
+ test_files: []