i18n_debug_page 0.1.0

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.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 2ce8bd98e1e2bdd7e3ec39eb971b5b49ba72083b
4
+ data.tar.gz: 280cb5a9169dd41f6d307a1316f93233bbc22f7d
5
+ SHA512:
6
+ metadata.gz: 7034265d8427489b8e50961dcb4eb0cd93b7947ae9d62a6d44a33e72553a2492875819c33c89751e376e86ae67f217a8f4144c6e30e2b0b831535df61f7f3c66
7
+ data.tar.gz: 15e647e88c30b7caac05baa8e14ab10535015281ac2b226c309f583f2e1b1f774511885dcf60b918a6dd59bb250c412fec4a23654c4a62e403fadf8a174cdd1c
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright 2017 mike
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.md ADDED
@@ -0,0 +1,41 @@
1
+ # I18n Debug Page
2
+ Mountable rails engin for rails app to check i18n translations in page.
3
+
4
+ When we develop a rails app we want to get better debug info. The gem [i18n-debug](https://github.com/fphilipe/i18n-debug) provide a very handy way to present rails translations' lookup.
5
+
6
+ But the log is mixed in rails log and most time the log is really long. It's better if we have seperate place to present such thing, so I18n Debug Page comes.
7
+
8
+ ## Example
9
+ <img src="https://raw.githubusercontent.com/yfractal/i18n_debug_page/master/assets/Screen%20Shot%202017-02-18%20at%209.05.42%20AM.png" />
10
+
11
+ ## Install
12
+
13
+ ```ruby
14
+ # Gemfile
15
+ gem 'i18n_debug_page'
16
+ ```
17
+
18
+ Run:
19
+
20
+ ```bash
21
+ $ bundle install
22
+ ```
23
+
24
+ Mount the engine
25
+ ```ruby
26
+ # config/routes.rb
27
+ mount I18nDebugPage::Engine => "/"
28
+ ```
29
+
30
+ Then you can find i18n debug log in path `/i18n_debug_logs`
31
+
32
+ ## TODO
33
+ - Provide better UI
34
+ - Make the installation more easier
35
+
36
+ ## Additional Information
37
+ This gem was inspired by [status-page](https://github.com/rails-engine/status-page) and [i18n-debug](https://github.com/fphilipe/i18n-debug)
38
+
39
+ ## License
40
+
41
+ The MIT License (MIT)
data/Rakefile ADDED
@@ -0,0 +1,26 @@
1
+ begin
2
+ require 'bundler/setup'
3
+ rescue LoadError
4
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
5
+ end
6
+
7
+ require 'rdoc/task'
8
+
9
+ RDoc::Task.new(:rdoc) do |rdoc|
10
+ rdoc.rdoc_dir = 'rdoc'
11
+ rdoc.title = 'I18nDebugPage'
12
+ rdoc.options << '--line-numbers'
13
+ rdoc.rdoc_files.include('README.md')
14
+ rdoc.rdoc_files.include('lib/**/*.rb')
15
+ end
16
+
17
+ APP_RAKEFILE = File.expand_path("../spec/dummy/Rakefile", __FILE__)
18
+ load 'rails/tasks/engine.rake'
19
+
20
+
21
+ load 'rails/tasks/statistics.rake'
22
+
23
+
24
+
25
+ require 'bundler/gem_tasks'
26
+
@@ -0,0 +1,2 @@
1
+ //= link_directory ../javascripts/i18n_debug_page .js
2
+ //= link_directory ../stylesheets/i18n_debug_page .css
@@ -0,0 +1,13 @@
1
+ // This is a manifest file that'll be compiled into application.js, which will include all the files
2
+ // listed below.
3
+ //
4
+ // Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
5
+ // or any plugin's vendor/assets/javascripts directory can be referenced here using a relative path.
6
+ //
7
+ // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
8
+ // compiled file. JavaScript code in this file should be added after the last require_* statement.
9
+ //
10
+ // Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
11
+ // about supported directives.
12
+ //
13
+ //= require_tree .
@@ -0,0 +1,15 @@
1
+ /*
2
+ * This is a manifest file that'll be compiled into application.css, which will include all the files
3
+ * listed below.
4
+ *
5
+ * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
6
+ * or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path.
7
+ *
8
+ * You're free to add application-wide styles to this file and they'll appear at the bottom of the
9
+ * compiled file so the styles you add here take precedence over styles defined in any other CSS/SCSS
10
+ * files in this directory. Styles in this file should be added after the last require_* statement.
11
+ * It is generally better to create a new file per style scope.
12
+ *
13
+ *= require_tree .
14
+ *= require_self
15
+ */
@@ -0,0 +1,5 @@
1
+ module I18nDebugPage
2
+ class ApplicationController < ActionController::Base
3
+ protect_from_forgery with: :exception
4
+ end
5
+ end
@@ -0,0 +1,9 @@
1
+ require_dependency "i18n_debug_page/application_controller"
2
+
3
+ module I18nDebugPage
4
+ class I18nDebugLogsController < ApplicationController
5
+ def index
6
+ @i18n_debug_logs = I18nDebugPage.i18n_debug_logs
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,4 @@
1
+ module I18nDebugPage
2
+ module ApplicationHelper
3
+ end
4
+ end
@@ -0,0 +1,4 @@
1
+ module I18nDebugPage
2
+ class ApplicationJob < ActiveJob::Base
3
+ end
4
+ end
@@ -0,0 +1,6 @@
1
+ module I18nDebugPage
2
+ class ApplicationMailer < ActionMailer::Base
3
+ default from: 'from@example.com'
4
+ layout 'mailer'
5
+ end
6
+ end
@@ -0,0 +1,5 @@
1
+ module I18nDebugPage
2
+ class ApplicationRecord < ActiveRecord::Base
3
+ self.abstract_class = true
4
+ end
5
+ end
@@ -0,0 +1,97 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>I18n debug page</title>
5
+ <meta charset="utf-8">
6
+ <meta name="viewport" content="width=device-width">
7
+ <style type="text/css" media="screen">
8
+ body {
9
+ line-height: 2rem;
10
+ font-family: sans;
11
+ font-size: 14px;
12
+ background-color: #f0f0f0;
13
+ margin: 0;
14
+ padding: 0;
15
+ color: #000;
16
+ text-align: center;
17
+ }
18
+
19
+ a {
20
+ color: #333;
21
+ }
22
+
23
+ h1 {
24
+ font-weight: normal;
25
+ line-height: 2.8rem;
26
+ font-size: 30px;
27
+ letter-spacing: -1px;
28
+ text-align: center;
29
+ color: #333;
30
+ }
31
+
32
+ .container {
33
+ width: 960px;
34
+ margin: 40px auto;
35
+ text-align: left;
36
+ overflow: hidden;
37
+ }
38
+
39
+ .i18n_debug_logs {
40
+ background: #FFF;
41
+ width: 100%;
42
+ border-radius: 5px;
43
+ }
44
+
45
+ .i18n_debug_logs h1 {
46
+ border-radius: 5px 5px 0 0;
47
+ background: #f9f9f9;
48
+ padding: 10px;
49
+ border-bottom: 1px solid #eee;
50
+ }
51
+
52
+ .i18n_debug_logs .i18n_debug_log {
53
+ font-size: 14px;
54
+ border-bottom: 1px solid #eee;
55
+ padding: 15px;
56
+ }
57
+
58
+ .i18n_debug_logs .i18n_debug_log:last-child {
59
+ border-bottom: 0px;
60
+ }
61
+
62
+ .i18n_debug_logs .name {
63
+ font-size: 20px;
64
+ margin-right: 20px;
65
+ min-width: 100px;
66
+ font-weight: bold;
67
+ color: #555;
68
+ }
69
+ .i18n_debug_logs .result {
70
+ font-size: 14px;
71
+ float: right;
72
+ color: #45b81d;
73
+ }
74
+ .i18n_debug_logs .missing {
75
+ color: red;
76
+ }
77
+ </style>
78
+ </head>
79
+
80
+ <body>
81
+ <div class="container">
82
+ <div class="i18n_debug_logs">
83
+ <h1>I18n Debug Page</h1>
84
+ <% @i18n_debug_logs.each do |i18n_debug_log| %>
85
+ <div class="i18n_debug_log">
86
+ <div class="">
87
+ <span class="name"><%= i18n_debug_log[:key] %></span>
88
+ <span class="result <%= i18n_debug_log[:result] || 'missing' %>">
89
+ <%= i18n_debug_log[:result].inspect %>
90
+ </span>
91
+ </div>
92
+ </div>
93
+ <% end %>
94
+ </div>
95
+ </div>
96
+ </body>
97
+ </html>
@@ -0,0 +1,14 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>I18n debug page</title>
5
+ <%= stylesheet_link_tag "i18n_debug_page/application", media: "all" %>
6
+ <%= javascript_include_tag "i18n_debug_page/application" %>
7
+ <%= csrf_meta_tags %>
8
+ </head>
9
+ <body>
10
+
11
+ <%= yield %>
12
+
13
+ </body>
14
+ </html>
data/config/routes.rb ADDED
@@ -0,0 +1,3 @@
1
+ I18nDebugPage::Engine.routes.draw do
2
+ resources :i18n_debug_logs
3
+ end
@@ -0,0 +1,18 @@
1
+ require "i18n_debug_page/engine"
2
+ require "i18n_debug_page/monitor"
3
+
4
+ module I18nDebugPage
5
+ def recollect_i18n_debug_logs
6
+ I18nDebugPage::Monitor.i18n_debug_logs = []
7
+ end
8
+
9
+ class << self
10
+ def included(base)
11
+ base.send(:before_action, :recollect_i18n_debug_logs)
12
+ end
13
+
14
+ def i18n_debug_logs
15
+ I18nDebugPage::Monitor.i18n_debug_logs
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,5 @@
1
+ module I18nDebugPage
2
+ class Engine < ::Rails::Engine
3
+ isolate_namespace I18nDebugPage
4
+ end
5
+ end
@@ -0,0 +1,16 @@
1
+ require 'i18n/debug'
2
+ module I18nDebugPage
3
+ class Monitor
4
+ class << self
5
+ attr_accessor :i18n_debug_logs
6
+
7
+ I18n::Debug.on_lookup do |key, result|
8
+ Monitor.i18n_debug_logs << { key: key, result: result }
9
+ end
10
+
11
+ def i18n_debug_logs
12
+ @i18n_debug_logs ||= []
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,3 @@
1
+ module I18nDebugPage
2
+ VERSION = '0.1.0'
3
+ end
@@ -0,0 +1,4 @@
1
+ # desc "Explaining what the task does"
2
+ # task :i18n_debug_page do
3
+ # # Task goes here
4
+ # end
metadata ADDED
@@ -0,0 +1,106 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: i18n_debug_page
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - mike
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2017-02-19 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rails
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '5.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '5.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: i18n-debug
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: 1.1.0
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: 1.1.0
41
+ - !ruby/object:Gem::Dependency
42
+ name: sqlite3
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ description: Provide UI for debugging i18n
56
+ email:
57
+ - yfractal@gmail.com
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - MIT-LICENSE
63
+ - README.md
64
+ - Rakefile
65
+ - app/assets/config/i18n_debug_page_manifest.js
66
+ - app/assets/javascripts/i18n_debug_page/application.js
67
+ - app/assets/stylesheets/i18n_debug_page/application.css
68
+ - app/controllers/i18n_debug_page/application_controller.rb
69
+ - app/controllers/i18n_debug_page/i18n_debug_logs_controller.rb
70
+ - app/helpers/i18n_debug_page/application_helper.rb
71
+ - app/jobs/i18n_debug_page/application_job.rb
72
+ - app/mailers/i18n_debug_page/application_mailer.rb
73
+ - app/models/i18n_debug_page/application_record.rb
74
+ - app/views/i18n_debug_page/i18n_debug_logs/index.html.erb
75
+ - app/views/layouts/i18n_debug_page/application.html.erb
76
+ - config/routes.rb
77
+ - lib/i18n_debug_page.rb
78
+ - lib/i18n_debug_page/engine.rb
79
+ - lib/i18n_debug_page/monitor.rb
80
+ - lib/i18n_debug_page/version.rb
81
+ - lib/tasks/i18n_debug_page_tasks.rake
82
+ homepage: ''
83
+ licenses:
84
+ - MIT
85
+ metadata: {}
86
+ post_install_message:
87
+ rdoc_options: []
88
+ require_paths:
89
+ - lib
90
+ required_ruby_version: !ruby/object:Gem::Requirement
91
+ requirements:
92
+ - - ">="
93
+ - !ruby/object:Gem::Version
94
+ version: '0'
95
+ required_rubygems_version: !ruby/object:Gem::Requirement
96
+ requirements:
97
+ - - ">="
98
+ - !ruby/object:Gem::Version
99
+ version: '0'
100
+ requirements: []
101
+ rubyforge_project:
102
+ rubygems_version: 2.5.1
103
+ signing_key:
104
+ specification_version: 4
105
+ summary: i18n debug page
106
+ test_files: []