ribbonit 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 92cd42e89e6bc423c4cb348864a63d84e6391756
4
+ data.tar.gz: 86fcc204946e0b49b779fc26551de84476568af1
5
+ SHA512:
6
+ metadata.gz: b3d7e825e6930c5fb50f53b6b30456da2a2522873f6c9db9e2b57e46c034f36699d5fddd216d94f95d94862c3e6e0fad3a958cc2a264d46f061c3a2c987ee920
7
+ data.tar.gz: 025e6c3130034094c042b3725f67673703ddf28c01e12820c05afb1f9133a288c22b2d39d06d03f9c17f045e0b21f535b0af7e3de1d537fc0547a8b00891a8a7
@@ -0,0 +1,12 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+
11
+ .rubocop-http*
12
+ !bin
@@ -0,0 +1,4 @@
1
+ inherit_from: https://raw.githubusercontent.com/anthony-robin/rubocop-rules/master/.rubocop.yml
2
+
3
+ AllCops:
4
+ TargetRubyVersion: 2.4
@@ -0,0 +1,16 @@
1
+ sudo: false
2
+ language: ruby
3
+ rvm:
4
+ - 2.4.0
5
+
6
+ cache:
7
+ bundler: true
8
+
9
+ before_install:
10
+ - gem install bundler -v 1.14.6
11
+
12
+ script:
13
+ - bin/rubocop
14
+
15
+ notifications:
16
+ email: false
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in ribbonit.gemspec
4
+ gemspec
@@ -0,0 +1,134 @@
1
+ # Ribbonit
2
+
3
+ **Ribbonit** displays an elegant ribbon to the corner of the page displaying useful information about the application: **Rails environment**, **Rails version**, **Ruby version**.
4
+
5
+ It is completely inspired from the Github 'fork me' ribbon.
6
+
7
+ ![Travis CI](https://travis-ci.org/anthony-robin/Ribbonit.svg?branch=master)
8
+
9
+ ## Installation
10
+
11
+ Add this line to your application's Gemfile:
12
+
13
+ ```ruby
14
+ # Gemfile
15
+ gem 'ribbonit'
16
+ ```
17
+
18
+ And then execute:
19
+
20
+ ```shell
21
+ $ bundle
22
+ ```
23
+
24
+ Or install it yourself as:
25
+ ```shell
26
+ $ gem install ribbonit
27
+ ```
28
+
29
+ ## Usage
30
+
31
+ 1) Run initializer
32
+ ```shell
33
+ $ bin/rails g ribbonit:install
34
+ ```
35
+ This will create a `ribbonit.rb` file in `config/initializers`
36
+
37
+ 2) Import assets
38
+ ```sass
39
+ // application.sass
40
+ @import ribbon
41
+ ```
42
+
43
+ 3) Call ribbon in layout
44
+ ```slim
45
+ / application.slim
46
+ ...
47
+ body
48
+ = ribbonit
49
+ ```
50
+
51
+ ## Options
52
+ You can customize some options through the initializer. Here are the defaults options:
53
+
54
+ ```ruby
55
+ # config/initializers/ribbonit.rb
56
+
57
+ display_rails_version = true
58
+ display_ruby_version = true
59
+
60
+ hide_for_small = true # Display ribbon in small devices ?
61
+ position = 'top-left' # top-right, bottom-left, bottom-right
62
+
63
+ # Available colors:
64
+ # orange, blue, green, red, purple, black, white
65
+ themes = {
66
+ development: 'black',
67
+ staging: 'blue'
68
+ }
69
+
70
+ # Sometimes, people use another name for this environment
71
+ staging_name = 'staging'
72
+ ```
73
+
74
+ ## Screenshots
75
+ ### Colors
76
+ <table>
77
+ <tr>
78
+ <td><img src="vendor/assets/images/colors/orange.png" width="100"></td>
79
+ <td><img src="vendor/assets/images/colors/blue.png" width="100"></td>
80
+ <td><img src="vendor/assets/images/colors/green.png" width="100"></td>
81
+ <td><img src="vendor/assets/images/colors/red.png" width="100"></td>
82
+ </tr>
83
+ <tr>
84
+ <td>Orange</td>
85
+ <td>Blue</td>
86
+ <td>Green</td>
87
+ <td>Red</td>
88
+ </tr>
89
+ <tr>
90
+ <td><img src="vendor/assets/images/colors/purple.png" width="100"></td>
91
+ <td><img src="vendor/assets/images/colors/black.png" width="100"></td>
92
+ <td><img src="vendor/assets/images/colors/white.png" width="100"></td>
93
+ </tr>
94
+ <tr>
95
+ <td>Purple</td>
96
+ <td>Black</td>
97
+ <td>White</td>
98
+ </tr>
99
+ </table>
100
+
101
+ ### Positions
102
+ <table>
103
+ <tr>
104
+ <td><img src="vendor/assets/images/colors/blue.png" width="100"></td>
105
+ <td><img src="vendor/assets/images/positions/top-right.png" width="100"></td>
106
+ <td><img src="vendor/assets/images/positions/bottom-right.png" width="100"></td>
107
+ <td><img src="vendor/assets/images/positions/bottom-left.png" width="100"></td>
108
+ </tr>
109
+ <tr>
110
+ <td>Top/Left</td>
111
+ <td>Top/Right</td>
112
+ <td>Bottom/Right</td>
113
+ <td>Bottom/Left</td>
114
+ </tr>
115
+ </table>
116
+
117
+ ### Environments
118
+ <table>
119
+ <tr>
120
+ <td><img src="vendor/assets/images/colors/purple.png" width="100"></td>
121
+ <td><img src="vendor/assets/images/environments/staging.png" width="100"></td>
122
+ </tr>
123
+ <tr>
124
+ <td>Development</td>
125
+ <td>Staging</td>
126
+ </tr>
127
+ </table>
128
+
129
+ ## Contributing
130
+ 1. Fork it
131
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
132
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
133
+ 4. Push to the branch (`git push origin my-new-feature`)
134
+ 5. Create new Pull Request
@@ -0,0 +1,10 @@
1
+ require 'bundler/gem_tasks'
2
+ require 'rake/testtask'
3
+
4
+ Rake::TestTask.new(:test) do |t|
5
+ t.libs << 'test'
6
+ t.libs << 'lib'
7
+ t.test_files = FileList['test/**/*_test.rb']
8
+ end
9
+
10
+ task default: :test
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'bundler/setup'
4
+ require 'ribbonit'
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require 'irb'
14
+ IRB.start
@@ -0,0 +1,9 @@
1
+ #!/usr/bin/env ruby
2
+ require 'pathname'
3
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile',
4
+ Pathname.new(__FILE__).realpath)
5
+
6
+ require 'rubygems'
7
+ require 'bundler/setup'
8
+
9
+ load Gem.bin_path('rubocop', 'rubocop')
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,21 @@
1
+ <% config = Ribbonit.configuration %>
2
+
3
+ <% if Rails.env.development? || Rails.env.send("#{config.staging_name}?") %>
4
+
5
+ <div id="ribbon" class="ribbon <%= config.position %> <%= config.hide_for_small ? 'hide-for-small' : '' %>">
6
+ <div class="ribbon-container <%= config.themes[Rails.env.to_sym] %>">
7
+ <span class="env"><%= Rails.env.capitalize %></span>
8
+
9
+ <span class="version">
10
+ <% if config.display_rails_version %>
11
+ Rails: <strong><%= Rails.version %></strong>
12
+ <% end %>
13
+
14
+ <% if config.display_ruby_version %>
15
+ Ruby: <strong><%= RUBY_VERSION %></strong>
16
+ <% end %>
17
+ </span>
18
+ </div>
19
+ </div>
20
+
21
+ <% end %>
@@ -0,0 +1,13 @@
1
+ # rubocop:disable ClassAndModuleChildren
2
+ module Ribbonit
3
+ module Generators
4
+ class InstallGenerator < ::Rails::Generators::Base
5
+ desc 'Copy Ribbonit initializer configuration'
6
+ source_root File.expand_path('../templates', __FILE__)
7
+
8
+ def copy_initializer
9
+ template 'ribbonit.rb', 'config/initializers/ribbonit.rb'
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,32 @@
1
+ Ribbonit.configure do |config|
2
+ ###
3
+ # Displayed informations
4
+ #
5
+ config.display_rails_version = true
6
+ config.display_ruby_version = true
7
+
8
+ ###
9
+ # Display on small devices ?
10
+ #
11
+ config.hide_for_small = true
12
+
13
+ ###
14
+ # Position - available positions are:
15
+ # 'top-left', 'top-right', 'bottom-left', 'bottom-right'
16
+ #
17
+ config.position = 'top-left'
18
+
19
+ ###
20
+ # Themes - available options are:
21
+ # 'orange', 'blue', 'green', 'red', 'purple', 'black', 'white'
22
+ #
23
+ config.themes = {
24
+ development: 'black',
25
+ staging: 'blue'
26
+ }
27
+
28
+ ###
29
+ # Environment name
30
+ #
31
+ config.staging_name = 'staging'
32
+ end
@@ -0,0 +1,3 @@
1
+ require 'ribbonit/version'
2
+ require 'ribbonit/configuration'
3
+ require 'ribbonit/rails/engine' if defined?(Rails)
@@ -0,0 +1,27 @@
1
+ require 'active_support/configurable'
2
+
3
+ module Ribbonit
4
+ def self.configuration
5
+ @configuration ||= Ribbonit::Configuration.new
6
+ end
7
+
8
+ def self.configure
9
+ yield configuration
10
+ end
11
+ end
12
+
13
+ class Ribbonit::Configuration
14
+ include ActiveSupport::Configurable
15
+
16
+ config_accessor(:display_rails_version) { true }
17
+ config_accessor(:display_ruby_version) { true }
18
+ config_accessor(:hide_for_small) { true }
19
+ config_accessor(:position) { 'top-left' }
20
+ config_accessor(:themes) do
21
+ {
22
+ development: 'orange',
23
+ staging: 'blue'
24
+ }
25
+ end
26
+ config_accessor(:staging_name) { 'staging' }
27
+ end
@@ -0,0 +1,15 @@
1
+ require 'ribbonit/view_helpers'
2
+
3
+ # rubocop:disable ClassAndModuleChildren
4
+ module Ribbonit
5
+ module Rails
6
+ class Engine < ::Rails::Engine
7
+ initializer 'ribbonit.view_helpers' do |app|
8
+ ActionView::Base.send :include, ViewHelpers
9
+ ActiveSupport.on_load(:action_controller) do
10
+ append_view_path "#{Gem.loaded_specs['ribbonit'].full_gem_path}/lib/app/views/partials"
11
+ end
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,3 @@
1
+ module Ribbonit
2
+ VERSION = '0.1.0'.freeze
3
+ end
@@ -0,0 +1,5 @@
1
+ module Ribbonit::ViewHelpers
2
+ def ribbonit
3
+ render '/ribbon'
4
+ end
5
+ end
@@ -0,0 +1,29 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'ribbonit/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'ribbonit'
8
+ spec.version = Ribbonit::VERSION
9
+ spec.authors = ['Anthony Robin']
10
+ spec.email = ['contact@anthony-robin.fr']
11
+
12
+ spec.summary = 'Display Ribbon with Rails env'
13
+ spec.description = 'Display an elegant Github like ribbon to your Rails application showing environment informations (Rails environment, Ruby version, Rails version, ...)'
14
+ spec.homepage = 'https://github.com/anthony-robin'
15
+
16
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
17
+ spec.bindir = 'exe'
18
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
19
+ spec.require_paths = ['lib']
20
+
21
+ spec.add_development_dependency 'bundler', '~> 1.12'
22
+ spec.add_development_dependency 'rake', '~> 10.0'
23
+ spec.add_development_dependency 'minitest', '~> 5.0'
24
+ spec.add_development_dependency 'byebug'
25
+ spec.add_development_dependency 'rubocop'
26
+
27
+ spec.add_dependency 'rails'
28
+ spec.add_dependency 'sassc-rails'
29
+ end
@@ -0,0 +1,106 @@
1
+ $ribbon_width: 165px
2
+ $ribbon_height: 165px
3
+
4
+ $top: 36px
5
+ $left: -60px
6
+
7
+ .ribbon
8
+ position: fixed
9
+ top: 0
10
+ left: 0
11
+ z-index: 1001
12
+ display: block
13
+ overflow: hidden
14
+ width: $ribbon_width
15
+ height: $ribbon_height
16
+ font-size: 16px
17
+ font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif
18
+ line-height: 1rem
19
+
20
+ // Position
21
+ &.top-right
22
+ right: 0
23
+ left: inherit
24
+ .ribbon-container
25
+ right: $left
26
+ left: inherit
27
+ transform: rotate(45deg)
28
+
29
+ &.bottom-left
30
+ top: inherit
31
+ bottom: 0
32
+ .ribbon-container
33
+ top: inherit
34
+ bottom: $top
35
+ transform: rotate(45deg)
36
+
37
+ &.bottom-right
38
+ top: inherit
39
+ right: 0
40
+ bottom: 0
41
+ left: inherit
42
+ .ribbon-container
43
+ top: inherit
44
+ right: $left
45
+ bottom: $top
46
+ left: inherit
47
+ transform: rotate(-45deg)
48
+
49
+ // Container
50
+ .ribbon-container
51
+ position: absolute
52
+ top: $top
53
+ left: $left
54
+ padding: 7px 40px
55
+ width: 100%
56
+ background: #333
57
+ box-shadow: 1px 1px 3px rgba(#000, .8)
58
+ color: #FFF
59
+ text-align: center
60
+ text-decoration: none
61
+ font-size: 1rem
62
+ transform: rotate(-45deg)
63
+
64
+ &::before, &::after
65
+ position: absolute
66
+ top: 1px
67
+ left: 0
68
+ display: block
69
+ width: 100%
70
+ height: 1px
71
+ background: #FFF
72
+ content: ''
73
+
74
+ &::after
75
+ top: auto
76
+ bottom: 1px
77
+
78
+ // Colors
79
+ &.orange
80
+ background: #f80
81
+ &.blue
82
+ background: #49a
83
+ &.green
84
+ background: #090
85
+ &.red
86
+ background: #a00
87
+ &.purple
88
+ background: #551a8b
89
+ &.black
90
+ background: #333
91
+ &.white
92
+ background: #fff
93
+ color: #333
94
+
95
+ // Displayed informations
96
+ .env
97
+ margin-bottom: 0
98
+ text-transform: uppercase
99
+
100
+ .version
101
+ display: block
102
+ font-size: 11px
103
+
104
+ @media only screen and (max-width: 40em)
105
+ .ribbon.hide-for-small
106
+ display: none
metadata ADDED
@@ -0,0 +1,172 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ribbonit
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Anthony Robin
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2017-05-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.12'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.12'
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: minitest
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '5.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '5.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: byebug
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rubocop
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rails
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: sassc-rails
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :runtime
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ description: Display an elegant Github like ribbon to your Rails application showing
112
+ environment informations (Rails environment, Ruby version, Rails version, ...)
113
+ email:
114
+ - contact@anthony-robin.fr
115
+ executables: []
116
+ extensions: []
117
+ extra_rdoc_files: []
118
+ files:
119
+ - ".gitignore"
120
+ - ".rubocop.yml"
121
+ - ".travis.yml"
122
+ - Gemfile
123
+ - README.md
124
+ - Rakefile
125
+ - bin/console
126
+ - bin/rubocop
127
+ - bin/setup
128
+ - lib/app/views/partials/_ribbon.html.erb
129
+ - lib/generators/ribbonit/install_generator.rb
130
+ - lib/generators/ribbonit/templates/ribbonit.rb
131
+ - lib/ribbonit.rb
132
+ - lib/ribbonit/configuration.rb
133
+ - lib/ribbonit/rails/engine.rb
134
+ - lib/ribbonit/version.rb
135
+ - lib/ribbonit/view_helpers.rb
136
+ - ribbonit.gemspec
137
+ - vendor/assets/images/colors/black.png
138
+ - vendor/assets/images/colors/blue.png
139
+ - vendor/assets/images/colors/green.png
140
+ - vendor/assets/images/colors/orange.png
141
+ - vendor/assets/images/colors/purple.png
142
+ - vendor/assets/images/colors/red.png
143
+ - vendor/assets/images/colors/white.png
144
+ - vendor/assets/images/environments/staging.png
145
+ - vendor/assets/images/positions/bottom-left.png
146
+ - vendor/assets/images/positions/bottom-right.png
147
+ - vendor/assets/images/positions/top-right.png
148
+ - vendor/assets/stylesheets/_ribbon.sass
149
+ homepage: https://github.com/anthony-robin
150
+ licenses: []
151
+ metadata: {}
152
+ post_install_message:
153
+ rdoc_options: []
154
+ require_paths:
155
+ - lib
156
+ required_ruby_version: !ruby/object:Gem::Requirement
157
+ requirements:
158
+ - - ">="
159
+ - !ruby/object:Gem::Version
160
+ version: '0'
161
+ required_rubygems_version: !ruby/object:Gem::Requirement
162
+ requirements:
163
+ - - ">="
164
+ - !ruby/object:Gem::Version
165
+ version: '0'
166
+ requirements: []
167
+ rubyforge_project:
168
+ rubygems_version: 2.6.12
169
+ signing_key:
170
+ specification_version: 4
171
+ summary: Display Ribbon with Rails env
172
+ test_files: []