rails_db 2.4.5 → 2.5.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.
Files changed (31) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +1 -9
  3. data/app/assets/javascripts/rails_db/application.js +1 -84
  4. data/app/assets/javascripts/rails_db/shared.js +83 -0
  5. data/app/helpers/rails_db/application_helper.rb +48 -0
  6. data/app/views/layouts/rails_db/application.html.erb +6 -2
  7. data/app/views/rails_db/shared/_assets.html.erb +26 -0
  8. data/lib/rails_db/engine.rb +16 -13
  9. data/lib/rails_db/version.rb +1 -1
  10. data/lib/rails_db.rb +7 -1
  11. data/rails_db.gemspec +0 -1
  12. data/test/dummy/log/test.log +523 -0
  13. data/test/dummy/tmp/cache/assets/sprockets/v4.0.0/-d/-dFmyu9De77yM2skayCjxg-b5DDLMjzHiO-HZ8eqcA4.cache +1 -0
  14. data/test/dummy/tmp/cache/assets/sprockets/v4.0.0/-x/-xjvXK67vrqZQIInyRlIL5XDOq-nEcTo5f0bpUEGueA.cache +0 -0
  15. data/test/dummy/tmp/cache/assets/sprockets/v4.0.0/3h/3h2FhtpMLTvVDRuUigIcwhsadyODfurqo4yFcfcQHYk.cache +1 -0
  16. data/test/dummy/tmp/cache/assets/sprockets/v4.0.0/8Q/8QEGHBv08YdoHFAv7cwhkO4Mmb0GXY8fr-0ALvC5R0o.cache +1 -0
  17. data/test/dummy/tmp/cache/assets/sprockets/v4.0.0/9G/9GA6fWc8ECFuVECVlNlIElC9tHcWOiWuPC6vXDEPhxw.cache +0 -0
  18. data/test/dummy/tmp/cache/assets/sprockets/v4.0.0/Bu/Bum5YkwvLquRTZsFNaSTShYyctIox2zQso28ySz7_wU.cache +1 -0
  19. data/test/dummy/tmp/cache/assets/sprockets/v4.0.0/QM/QM4PExN1xJfM3Qce8ccenrNJhulC6nhwy6iIsTW-Lt8.cache +0 -0
  20. data/test/dummy/tmp/cache/assets/sprockets/v4.0.0/Sj/SjgiVHAJsC5T6Q8KtQ8a7W1yUO7Q58FKOVqq2fLnPW8.cache +0 -0
  21. data/test/dummy/tmp/cache/assets/sprockets/v4.0.0/Wg/Wg-rem_R8qCAX43KPkLItyYIjR7WexyBgKW6fWZem64.cache +1 -0
  22. data/test/dummy/tmp/cache/assets/sprockets/v4.0.0/eq/eq3s9WWfQaspG8gCeucF1EFBYR-VN_U6yJpn0qWfjPk.cache +0 -0
  23. data/test/dummy/tmp/cache/assets/sprockets/v4.0.0/gp/gpB6SVB3O9McHcR4mBtFHFl26DX0qBrEr26XAMKOVTo.cache +1 -0
  24. data/test/dummy/tmp/cache/assets/sprockets/v4.0.0/gu/gu4qNYOYvNdgjiGV-ndb-YqJNfPbrqtZrlX7NlOy5ac.cache +1 -0
  25. data/test/dummy/tmp/cache/assets/sprockets/v4.0.0/hI/hiMgoFMwQ5Kh4p_b6HiBz8vtsIDs60RfM74O-XEWxgo.cache +3 -0
  26. data/test/dummy/tmp/cache/assets/sprockets/v4.0.0/iU/iUbBboX6KYOCn8Meioi9ifDmpvz9Q5PYFKLQtC1npU0.cache +0 -0
  27. data/test/dummy/tmp/cache/assets/sprockets/v4.0.0/ir/irfkiK0kq4WQxp8tWJBRsprajlb3CVAgz4rMPmJ-jrw.cache +0 -0
  28. data/test/dummy/tmp/cache/assets/sprockets/v4.0.0/mj/MjiV6c1ad6f2cEDfj8XoKSV4N31B42lSbg1OH9MmZzs.cache +1 -0
  29. data/test/dummy/tmp/cache/assets/sprockets/v4.0.0/qh/qhOgFIHFHttn-VV0Uu2W-4p0Cu5_MklXvqYkwKFsbKs.cache +8 -0
  30. data/test/dummy/tmp/cache/assets/sprockets/v4.0.0/uw/uwZKoJUdAwBfBb11hg52km8ZD_lyZf6WFKcYDM_7aSM.cache +0 -0
  31. metadata +36 -16
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 97bf5db2b70dddcf1da63c417b4e860bd41323397ac8a6d7a1a95476269bcb96
4
- data.tar.gz: 72012771a62f581e8674521b2d909ae28e971bbf8f84e3885c8b6809adc445f0
3
+ metadata.gz: 853f483c3bdb85c1ac0d7886b9918bc19a54a101f12c6f62d862ce08a1bea6fb
4
+ data.tar.gz: 0fbf7b0d28e81571b406a900254a07795777d883dfc6af19bb5402442dd7c459
5
5
  SHA512:
6
- metadata.gz: aebba26da9947061cc1a68237edfdb196b5ed90b4b3de029f876da29f8e6511be2d9ef7681efaa26b637bbf8b1c3c656498c3dc075894785acfaa0ea0798fee7
7
- data.tar.gz: a97ecc0e26123d658bef30094643d599dcc95bca9419773ea815d3ad65cbeef4f5e0a84ae3e8862c61ce34ab819f23f0d04e21368d784350da7efb756bbfddd3
6
+ metadata.gz: 8dc44b938aff470f1a0a831532316a747ece19afff8e65e6ccaba3e01fa4cc833a06d05792b0694391d03fdc69ab967ed2fd66445d5907a37fe24e2cf60d2cd7
7
+ data.tar.gz: d15fcce18076e079ed73e07bb8c9fc6ad20f884dcc20a55a6fdda34ae7f05f6e9ab782aa792aaebd0b0fb3e806fd450d8a59a702aeb55b022a0fd8f0f1d0f16a
data/Gemfile.lock CHANGED
@@ -1,14 +1,13 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rails_db (2.4.5)
4
+ rails_db (2.5.0)
5
5
  activerecord
6
6
  csv
7
7
  kaminari
8
8
  rails (>= 5.0.0)
9
9
  ransack (>= 2.3.2)
10
10
  simple_form (>= 5.0.1)
11
- sprockets-rails
12
11
  terminal-table
13
12
 
14
13
  GEM
@@ -228,13 +227,6 @@ GEM
228
227
  simple_form (5.1.0)
229
228
  actionpack (>= 5.2)
230
229
  activemodel (>= 5.2)
231
- sprockets (4.2.1)
232
- concurrent-ruby (~> 1.0)
233
- rack (>= 2.2.4, < 4)
234
- sprockets-rails (3.5.0)
235
- actionpack (>= 6.1)
236
- activesupport (>= 6.1)
237
- sprockets (>= 3.0.0)
238
230
  sqlite3 (1.7.3)
239
231
  mini_portile2 (~> 2.8.0)
240
232
  stringio (3.1.0)
@@ -10,87 +10,4 @@
10
10
  //= require rails_db/sticky
11
11
  //= require rails_db/show_hide_columns.js
12
12
  //= require rails_db/search.js
13
-
14
- $(function(){
15
- $(document).foundation();
16
-
17
- jQuery.expr[":"].icontains = jQuery.expr.createPseudo(function (arg) {
18
- return function (elem) {
19
- return jQuery(elem).text().toUpperCase().indexOf(arg.toUpperCase()) >= 0;
20
- };
21
- });
22
-
23
- $('body').on('change', '.per_page_pagination_select', function() {
24
- $(this).parents('form').submit();
25
- });
26
-
27
- $('body').on('keyup', '#rails_db_tables_input', function() {
28
- value = $(this).val();
29
- $("#rails_db_tables a").show();
30
- $("#rails_db_tables a:not(:icontains('" + value + "'))").hide();
31
- });
32
-
33
- $('body').on('click', '.expand, .collapse', function() {
34
- expand_collapse();
35
- save_expand_collapse();
36
- return false;
37
- });
38
- });
39
-
40
- function expand_collapse() {
41
- $('#main_content').toggleClass('push-3')
42
- $('#main_content').toggleClass('large-9')
43
- $('#main_content').toggleClass('large-12')
44
- $('#sidebar').toggle();
45
- $('.collapse').toggle();
46
- $('.expand').toggle();
47
- };
48
-
49
- function save_expand_collapse() {
50
- $.removeCookie('sidebar_hidden');
51
- $.cookie('sidebar_hidden', !$('.expand').is(':visible'), { expires: 30, path: '/' });
52
- };
53
-
54
- // https://github.com/codemirror/CodeMirror/blob/master/mode/sql/index.html
55
- function init_sql_editor(mime, tables) {
56
- var editor = CodeMirror.fromTextArea($('#sql').get(0), {
57
- mime: mime,
58
- hint: CodeMirror.hint.sql,
59
- matchBrackets: true,
60
- smartIndent: true,
61
- autofocus: true,
62
- "theme": 'pastel-on-dark',
63
- "lineNumbers": true,
64
- "mode": "text/x-sql",
65
- "tabSize": 4,
66
- height: 'auto',
67
- extraKeys: {
68
- "Esc": 'autocomplete',
69
- "Ctrl": 'autocomplete',
70
- "Ctrl-Space": 'autocomplete',
71
- "Ctrl-Enter": function() {
72
- $(editor.getInputField()).parents('form').submit();
73
- }
74
- },
75
- hintOptions: {
76
- tables: tables
77
- }
78
- });
79
- editor.setSize('100%', '300');
80
- editor.focus();
81
- };
82
-
83
- function set_browser_url(url) {
84
- if (typeof (history.pushState) != "undefined") {
85
- window.history.pushState({"path": url}, '', url);
86
- }
87
- }
88
-
89
- $(window).bind('popstate', function(event) {
90
- if (typeof (history.pushState) != "undefined") {
91
- var state = event.originalEvent.state;
92
- if (state) {
93
- window.location = state.path;
94
- }
95
- }
96
- });
13
+ //= require rails_db/shared.js
@@ -0,0 +1,83 @@
1
+ $(function(){
2
+ $(document).foundation();
3
+
4
+ jQuery.expr[":"].icontains = jQuery.expr.createPseudo(function (arg) {
5
+ return function (elem) {
6
+ return jQuery(elem).text().toUpperCase().indexOf(arg.toUpperCase()) >= 0;
7
+ };
8
+ });
9
+
10
+ $('body').on('change', '.per_page_pagination_select', function() {
11
+ $(this).parents('form').submit();
12
+ });
13
+
14
+ $('body').on('keyup', '#rails_db_tables_input', function() {
15
+ value = $(this).val();
16
+ $("#rails_db_tables a").show();
17
+ $("#rails_db_tables a:not(:icontains('" + value + "'))").hide();
18
+ });
19
+
20
+ $('body').on('click', '.expand, .collapse', function() {
21
+ expand_collapse();
22
+ save_expand_collapse();
23
+ return false;
24
+ });
25
+ });
26
+
27
+ function expand_collapse() {
28
+ $('#main_content').toggleClass('push-3')
29
+ $('#main_content').toggleClass('large-9')
30
+ $('#main_content').toggleClass('large-12')
31
+ $('#sidebar').toggle();
32
+ $('.collapse').toggle();
33
+ $('.expand').toggle();
34
+ };
35
+
36
+ function save_expand_collapse() {
37
+ $.removeCookie('sidebar_hidden');
38
+ $.cookie('sidebar_hidden', !$('.expand').is(':visible'), { expires: 30, path: '/' });
39
+ };
40
+
41
+ // https://github.com/codemirror/CodeMirror/blob/master/mode/sql/index.html
42
+ function init_sql_editor(mime, tables) {
43
+ var editor = CodeMirror.fromTextArea($('#sql').get(0), {
44
+ mime: mime,
45
+ hint: CodeMirror.hint.sql,
46
+ matchBrackets: true,
47
+ smartIndent: true,
48
+ autofocus: true,
49
+ "theme": 'pastel-on-dark',
50
+ "lineNumbers": true,
51
+ "mode": "text/x-sql",
52
+ "tabSize": 4,
53
+ height: 'auto',
54
+ extraKeys: {
55
+ "Esc": 'autocomplete',
56
+ "Ctrl": 'autocomplete',
57
+ "Ctrl-Space": 'autocomplete',
58
+ "Ctrl-Enter": function() {
59
+ $(editor.getInputField()).parents('form').submit();
60
+ }
61
+ },
62
+ hintOptions: {
63
+ tables: tables
64
+ }
65
+ });
66
+ editor.setSize('100%', '300');
67
+ editor.focus();
68
+ };
69
+
70
+ function set_browser_url(url) {
71
+ if (typeof (history.pushState) != "undefined") {
72
+ window.history.pushState({"path": url}, '', url);
73
+ }
74
+ }
75
+
76
+ $(window).bind('popstate', function(event) {
77
+ if (typeof (history.pushState) != "undefined") {
78
+ var state = event.originalEvent.state;
79
+ if (state) {
80
+ window.location = state.path;
81
+ }
82
+ }
83
+ });
@@ -78,5 +78,53 @@ module RailsDb
78
78
  p
79
79
  end
80
80
  end
81
+
82
+ def insert_css_file(file)
83
+ if using_sprockets?
84
+ # For Sprockets, use the asset pipeline
85
+ # Remove .css extension and use the file path as-is for asset pipeline
86
+ asset_name = file.gsub('.css', '')
87
+ stylesheet_link_tag asset_name, media: "all"
88
+ else
89
+ # For Propshaft/Rails 8 compatibility - inline the CSS
90
+ css_path = File.expand_path(File.dirname(__FILE__) + "/../../assets/stylesheets/#{file}")
91
+ if File.exist?(css_path)
92
+ raw "<style>#{File.read(css_path)}</style>"
93
+ else
94
+ ""
95
+ end
96
+ end
97
+ end
98
+
99
+ def insert_js_file(file)
100
+ if using_sprockets?
101
+ # For Sprockets, use the asset pipeline
102
+ # Remove .js extension and use the file path as-is for asset pipeline
103
+ asset_name = file.gsub('.js', '')
104
+ javascript_include_tag asset_name
105
+ else
106
+ # For Propshaft/Rails 8 compatibility - inline the JavaScript
107
+ js_path = File.expand_path(File.dirname(__FILE__) + "/../../assets/javascripts/#{file}")
108
+ if File.exist?(js_path)
109
+ raw "<script>#{File.read(js_path)}</script>"
110
+ else
111
+ ""
112
+ end
113
+ end
114
+ end
115
+
116
+ private
117
+
118
+ def using_sprockets?
119
+ # Check if sprockets-rails is available and being used
120
+ return false unless defined?(Sprockets)
121
+
122
+ # Check if Rails.application.assets is a Sprockets environment
123
+ Rails.application.assets.is_a?(Sprockets::Environment) ||
124
+ Rails.application.assets.is_a?(Sprockets::Index)
125
+ rescue
126
+ # If anything fails, assume we're not using Sprockets
127
+ false
128
+ end
81
129
  end
82
130
  end
@@ -3,8 +3,12 @@
3
3
  <head>
4
4
  <title><%= [yield(:title), 'Rails DB'].reject(&:blank?).join(' - ') %></title>
5
5
  <%= stylesheet_link_tag "https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.5.0/css/font-awesome.min.css" %>
6
- <%= stylesheet_link_tag "rails_db/application", media: "all" %>
7
- <%= javascript_include_tag "rails_db/application" %>
6
+ <% if using_sprockets? %>
7
+ <%= stylesheet_link_tag "rails_db/application", media: "all" %>
8
+ <%= javascript_include_tag "rails_db/application" %>
9
+ <% else %>
10
+ <%= render 'rails_db/shared/assets' %>
11
+ <% end %>
8
12
  <%= csrf_meta_tags %>
9
13
 
10
14
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
@@ -0,0 +1,26 @@
1
+ <!-- CSS Assets -->
2
+ <%= insert_css_file 'rails_db/foundation.min.css' %>
3
+ <%= insert_css_file 'rails_db/foundation_and_overrides.css' %>
4
+ <%= insert_css_file 'codemirror/codemirror.css' %>
5
+ <%= insert_css_file 'codemirror/codemirror/themes/pastel-on-dark.css' %>
6
+ <%= insert_css_file 'codemirror/codemirror/addons/hint/show-hint.css' %>
7
+ <%= insert_css_file 'rails_db/app.css' %>
8
+ <%= insert_css_file 'rails_db/sidebar.css' %>
9
+ <%= insert_css_file 'rails_db/pagination.css' %>
10
+ <%= insert_css_file 'rails_db/table.css' %>
11
+ <%= insert_css_file 'rails_db/forms.css' %>
12
+ <%= insert_css_file 'rails_db/search.css' %>
13
+
14
+ <!-- JavaScript Assets -->
15
+ <%= insert_js_file 'codemirror/codemirror.js' %>
16
+ <%= insert_js_file 'codemirror/codemirror/modes/sql.js' %>
17
+ <%= insert_js_file 'codemirror/codemirror/addons/hint/show-hint.js' %>
18
+ <%= insert_js_file 'codemirror/codemirror/addons/hint/sql-hint.js' %>
19
+ <%= insert_js_file 'rails_db/jquery.js' %>
20
+ <%= insert_js_file 'rails_db/jquery.cookie.js' %>
21
+ <%= insert_js_file 'rails_db/rails-ujs.js' %>
22
+ <%= insert_js_file 'rails_db/foundation.min.js' %>
23
+ <%= insert_js_file 'rails_db/sticky.js' %>
24
+ <%= insert_js_file 'rails_db/show_hide_columns.js' %>
25
+ <%= insert_js_file 'rails_db/search.js' %>
26
+ <%= insert_js_file 'rails_db/shared.js' %>
@@ -4,19 +4,22 @@ module RailsDb
4
4
  config.autoload_paths += Dir["#{config.root}/lib"]
5
5
 
6
6
  initializer 'rails_db.assets_precompile', :group => :all do |app|
7
- app.config.assets.precompile += [
8
- 'rails_db/application.js',
9
- 'rails_db/application.css',
10
- 'rails_db/logo.png',
11
- 'rails_db/logo_mini.png',
12
- 'rails_db/data_table_code.png',
13
- 'rails_db/data_table.png',
14
- 'rails_db/railsdb.png',
15
- 'rails_db/runsql.png',
16
- 'rails_db/*.png',
17
- 'codemirror/*',
18
- 'codemirror/**/*'
19
- ]
7
+ # Only configure asset precompilation if Sprockets is available
8
+ if defined?(Sprockets) && app.config.respond_to?(:assets)
9
+ app.config.assets.precompile += [
10
+ 'rails_db/application.js',
11
+ 'rails_db/application.css',
12
+ 'rails_db/logo.png',
13
+ 'rails_db/logo_mini.png',
14
+ 'rails_db/data_table_code.png',
15
+ 'rails_db/data_table.png',
16
+ 'rails_db/railsdb.png',
17
+ 'rails_db/runsql.png',
18
+ 'rails_db/*.png',
19
+ 'codemirror/*',
20
+ 'codemirror/**/*'
21
+ ]
22
+ end
20
23
  end
21
24
 
22
25
  initializer 'rails_db.helpers' do
@@ -1,3 +1,3 @@
1
1
  module RailsDb
2
- VERSION = "2.4.5"
2
+ VERSION = "2.5.0"
3
3
  end
data/lib/rails_db.rb CHANGED
@@ -5,7 +5,13 @@ require 'simple_form'
5
5
  require 'active_record'
6
6
  require 'ransack'
7
7
  require 'kaminari'
8
- require 'sprockets/rails'
8
+
9
+ # Only require sprockets/rails if it's available
10
+ begin
11
+ require 'sprockets/rails'
12
+ rescue LoadError
13
+ # sprockets-rails is not available, continue without it
14
+ end
9
15
 
10
16
  module RailsDb
11
17
  # Custom require relative that work with older rubies also
data/rails_db.gemspec CHANGED
@@ -23,7 +23,6 @@ Gem::Specification.new do |s|
23
23
  s.add_dependency 'activerecord'
24
24
  s.add_dependency 'ransack', '>= 2.3.2'
25
25
  s.add_dependency 'kaminari'
26
- s.add_dependency 'sprockets-rails'
27
26
  s.add_dependency 'csv'
28
27
 
29
28
  s.add_development_dependency "launchy"