rails_base 0.53.0 → 0.53.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8a9e5642a22977c5cae3b9de0ff97843756c80ae5570ed79c180d1b5f2563c14
4
- data.tar.gz: 8b26fbf0624bc4334b0793872dd2a2ffd73dca21651c5082073e925a92fb7012
3
+ metadata.gz: d20109ef6d422bfe9f2d9ea381e0bae71bfd9cb9a3585554f97fb378baf00d50
4
+ data.tar.gz: '08666f477b07d62d5fffd6505785b12b643bc9164ccd1c038585f7d895fa78c7'
5
5
  SHA512:
6
- metadata.gz: a04d3da65692ffd59dc41961ffae4a7a292043731df480a683d9387997d65812af378a3276401696b7e8f1c8c4568f90caa1118ed1035c89a8be563e0ff3eb25
7
- data.tar.gz: 2ae5996b21c71bf4ac95b5b7ef774b6e0867aa3b08f8128a6ca97dfbc28ecb1846d8d6bba2d9390bc25d422365cb006ce737f4369ee4a817f618a1ae93dfaa0d
6
+ metadata.gz: b67025f0a012ed6c7024671a048f74026f30b9870115f13f5c2ff047f1a5fed7e5b31e61c2074a8f193d5cdd8392465deaa816c6a651d9cfb6f2788de4bcfeb0
7
+ data.tar.gz: 3b44a97ffc9ebd160941fe29b517d1ab114b61250562a6a51d4cf72cb29702233b31b39c6aa550664527b1e78a787600549dba4c06e96c9b9c2feb2b838b30e3
@@ -11,7 +11,6 @@
11
11
  // about supported directives.
12
12
  //
13
13
  // = require rails-ujs
14
- // = require activestorage
15
14
  // = require turbolinks
16
15
  // = require_tree .
17
16
 
@@ -1,6 +1,6 @@
1
1
  module RailsBase::AppearanceHelper
2
- APPEARANCE_MODE_COOKIE = "_#{Rails.application.class.parent_name}_appearance_mode".gsub(' ', '-').downcase
3
- APPEARANCE_MODE_ACTUAL_COOKIE = "_#{Rails.application.class.parent_name}_appearance_actual_mode".gsub(' ', '-').downcase
2
+ APPEARANCE_MODE_COOKIE = "_#{RailsBase.app_name}_appearance_mode".gsub(' ', '-').downcase
3
+ APPEARANCE_MODE_ACTUAL_COOKIE = "_#{RailsBase.app_name}_appearance_actual_mode".gsub(' ', '-').downcase
4
4
  APPEARANCE_TEXT_CLASS = RailsBase::Configuration::Display::Text::APPEARANCE_TEXT_CLASS
5
5
 
6
6
  VIEWPORT_EXTRA_SMALL = 'xs'.freeze
@@ -1,6 +1,6 @@
1
1
  module RailsBase::ApplicationHelper
2
2
 
3
- TIMEZONE_OFFSET_COOKIE = "_#{Rails.application.class.parent_name}_timeoffset"
3
+ TIMEZONE_OFFSET_COOKIE = "_#{RailsBase.app_name}_timeoffset"
4
4
  TIMEZONE_SESSION_NAME = TIMEZONE_THREAD_NAME = :tz_info
5
5
 
6
6
  def browser
@@ -4,19 +4,19 @@ class RailsBase::EmailVerificationMailer < RailsBase::ApplicationMailer
4
4
  def email_verification(user:, url:)
5
5
  @user = user
6
6
  @sso_url_for_user = url
7
- mail(to: @user.email, subject: "Welcome to #{Rails.application.class.parent_name}")
7
+ mail(to: @user.email, subject: "Welcome to #{RailsBase.app_name}")
8
8
  end
9
9
 
10
10
  def forgot_password(user:, url:)
11
11
  @user = user
12
12
  @sso_url_for_user = url
13
- mail(to: @user.email, subject: "#{Rails.application.class.parent_name}: Forgot Password")
13
+ mail(to: @user.email, subject: "#{RailsBase.app_name}: Forgot Password")
14
14
  end
15
15
 
16
16
  def event(user:, event:, msg: nil)
17
17
  @user = user
18
18
  @event = event
19
19
  @msg = msg
20
- mail(to: @user.email, subject: "#{Rails.application.class.parent_name}: #{event}")
20
+ mail(to: @user.email, subject: "#{RailsBase.app_name}: #{event}")
21
21
  end
22
22
  end
@@ -4,13 +4,13 @@ class RailsBase::EventMailer < RailsBase::ApplicationMailer
4
4
  def send_sso(user:, message:)
5
5
  @user = user
6
6
  @message = message
7
- mail(to: user.email, subject: "#{Rails.application.class.parent_name}: SSO login", template_name: 'event')
7
+ mail(to: user.email, subject: "#{RailsBase.app_name}: SSO login", template_name: 'event')
8
8
  # event(user: user, event: 'SSO login', message: message)
9
9
  end
10
10
 
11
11
  def event(user:, event:, message:)
12
12
  @user = user
13
13
  @message = message
14
- mail(to: @user.email, subject: "#{Rails.application.class.parent_name}: #{event}", template_name: 'event')
14
+ mail(to: @user.email, subject: "#{RailsBase.app_name}: #{event}", template_name: 'event')
15
15
  end
16
16
  end
@@ -6,7 +6,7 @@ module RailsBase
6
6
  columns.each do |column|
7
7
  next unless [:datetime].include?(column.type)
8
8
 
9
- # This is actually pretty cool. If you set the thrad corectly, you can
9
+ # This is actually pretty cool. If you set the thread corectly, you can
10
10
  define_method("#{column.name}") do
11
11
  thread_tz = Thread.current[RailsBase::ApplicationController::TIMEZONE_THREAD_NAME]
12
12
  return super() if thread_tz.nil?
@@ -97,7 +97,7 @@ class ShortLivedData < RailsBase::ApplicationRecord
97
97
  # only update if count is valid and we can add things -- save db call
98
98
  return false unless used_count_valid?
99
99
 
100
- update_attributes(exclusive_use_count: exclusive_use_count + 1)
100
+ update(exclusive_use_count: exclusive_use_count + 1)
101
101
  end
102
102
 
103
103
  def invalid_reason
@@ -126,7 +126,7 @@ class ShortLivedData < RailsBase::ApplicationRecord
126
126
  end
127
127
 
128
128
  def user=(u)
129
- update_attributes(user_id: u.id)
129
+ update(user_id: u.id)
130
130
  u.id
131
131
  end
132
132
  end
data/app/models/user.rb CHANGED
@@ -50,7 +50,7 @@ class User < RailsBase::ApplicationRecord
50
50
  end
51
51
 
52
52
  define_method("admin_#{admin_method}!") do
53
- update_attributes!(admin: admin_method)
53
+ update!(admin: admin_method)
54
54
  end
55
55
 
56
56
  #### metods on the class
@@ -109,7 +109,7 @@ class User < RailsBase::ApplicationRecord
109
109
  return if last_known_timezone == tz_name
110
110
 
111
111
  Rails.logger.info { "#{id}: Setting tz_name: #{tz_name}" }
112
- update_attributes(last_known_timezone: tz_name, last_known_timezone_update: Time.now )
112
+ update(last_known_timezone: tz_name, last_known_timezone_update: Time.now )
113
113
  end
114
114
 
115
115
  def timezone
@@ -14,7 +14,7 @@ module RailsBase
14
14
 
15
15
  original_value = model_row.public_send(attribute)
16
16
  begin
17
- model_row.update_attributes!(attribute => sanitized_value)
17
+ model_row.update!(attribute => sanitized_value)
18
18
  rescue ActiveRecord::RecordInvalid => e
19
19
  context.fail!(message: "Failed to update [#{attribute}] with #{sanitized_value} on #{model}##{model_row.id}. #{e.message}")
20
20
  rescue StandardError
@@ -126,6 +126,7 @@
126
126
  </footer>
127
127
  <% end %>
128
128
  </div>
129
+
129
130
  <% if RailsBase.appearance.back_to_top.enable? %>
130
131
  <a id="rails-base-back-to-top" class="btn btn-light btn-lg back-to-top" role="button"><i class="fas fa-chevron-up"></i></a>
131
132
  <script type="text/javascript">
@@ -69,7 +69,7 @@
69
69
  <div class="col-md-10 offset-md-1 text-center">
70
70
  <div class="row">
71
71
  <div class="col-md-9">
72
- <%= f.submit "Sign Up for #{Rails.application.class.parent_name}", class: "btn btn_success btn-block #{submit_klass}" %>
72
+ <%= f.submit "Sign Up for #{RailsBase.app_name}", class: "btn btn_success btn-block #{submit_klass}" %>
73
73
  </div>
74
74
  <div class="col-md-3">
75
75
  <a class="btn btn_primary btn-block" href="<%=RailsBase.url_routes.new_user_session_path%>" role="button">Have an Account? Sign In</a>
@@ -7,7 +7,7 @@
7
7
  </br>
8
8
  </br>
9
9
  Best wishes,</br>
10
- <%= Rails.application.class.parent_name %> team
10
+ <%= RailsBase.app_name %> team
11
11
 
12
12
  </p>
13
13
  </br>
@@ -9,7 +9,7 @@
9
9
  </p>
10
10
  <% end %>
11
11
  <p>
12
- If this is in error please login to your account: <a href=<%= RailsBase::ApplicationMailer::CONTACT_URL %>> Login link for <%= Rails.application.class.parent_name %> </a>
12
+ If this is in error please login to your account: <a href=<%= RailsBase::ApplicationMailer::CONTACT_URL %>> Login link for <%= RailsBase.app_name %> </a>
13
13
  </p>
14
14
 
15
15
  </br>
@@ -8,3 +8,4 @@
8
8
  </div>
9
9
  </div>
10
10
  </div>
11
+
@@ -1,3 +1,4 @@
1
+ require 'singleton'
1
2
  require 'rails_base/configuration/admin'
2
3
  require 'rails_base/configuration/mfa'
3
4
  require 'rails_base/configuration/authentication'
@@ -13,6 +14,8 @@ require 'rails_base/configuration/active_job'
13
14
 
14
15
  module RailsBase
15
16
  class Config
17
+ include Singleton
18
+
16
19
  VARIABLES = {
17
20
  admin: nil,
18
21
  mfa: nil,
@@ -211,8 +211,6 @@ module RailsBase
211
211
  admin_page_filter.flatten!
212
212
  end
213
213
 
214
- private
215
-
216
214
  def convenience_methods
217
215
  # defines instance methods like
218
216
  # user.at_least_super?
@@ -16,27 +16,27 @@ module RailsBase
16
16
  },
17
17
  web_name_logged_in: {
18
18
  type: :string_proc,
19
- default: ->(user) { Rails.application.class.parent_name },
19
+ default: ->(user) { RailsBase.app_name },
20
20
  description: 'Name of the application when authenticated user is present. Name in the tab of the browser. Allows for dynamic tab names'
21
21
  },
22
22
  web_name_logged_out: {
23
23
  type: :string_proc,
24
- default: ->(*) { Rails.application.class.parent_name },
24
+ default: ->(*) { RailsBase.app_name },
25
25
  description: 'Name of the application when no authenticated user. Name in the tab of the browser. Allows for dynamic tab names'
26
26
  },
27
27
  web_title_logged_in: {
28
28
  type: :string_proc,
29
- default: ->(user) { Rails.application.class.parent_name },
29
+ default: ->(user) { RailsBase.app_name },
30
30
  description: 'Title in nav for the web when logged in. String or proc accepted. When proc, current user will be passed in.'
31
31
  },
32
32
  web_title_logged_out: {
33
33
  type: :string_proc,
34
- default: ->(*) { Rails.application.class.parent_name },
34
+ default: ->(*) { RailsBase.app_name },
35
35
  description: 'Title in nav for the web when logged in. String or proc accepted. When proc, current user will be passed in.'
36
36
  },
37
37
  communication_name: {
38
38
  type: :string_proc,
39
- default: ->(*) { Rails.application.class.parent_name },
39
+ default: ->(*) { RailsBase.app_name },
40
40
  description: 'Name used when communicating with users.'
41
41
  },
42
42
  favicon_path: {
@@ -1,18 +1,26 @@
1
1
  module RailsBase
2
2
  class Engine < ::Rails::Engine
3
3
  isolate_namespace RailsBase
4
+ ActiveSupport::Reloader.to_prepare do
5
+ if RailsBase.___execute_initializer___?
6
+ RailsBase.config.admin.convenience_methods
7
+
8
+ RailsBase::ApplicationRecord.descendants.each do |model|
9
+ model._magically_defined_time_objects
10
+ end
11
+ end
12
+ end
4
13
 
5
14
  initializer 'instantiate RailsBase configs' do |_app|
6
- RailsBase.config if ___execute_initializer___?
15
+ RailsBase.config if RailsBase.___execute_initializer___?
7
16
  end
8
17
 
9
18
  initializer 'remove write access to RailsBase config', after: 'after_initialize' do |app|
10
- RailsBase::Configuration::Base._unset_allow_write! if ___execute_initializer___?
19
+ RailsBase::Configuration::Base._unset_allow_write! if RailsBase.___execute_initializer___?
11
20
  end
12
21
 
13
22
  initializer 'define magic convenionce methods for converting team', after: 'active_record.initialize_database' do |app|
14
- if ___execute_initializer___?
15
- raise
23
+ if RailsBase.___execute_initializer___?
16
24
  # need to eager load Models
17
25
  Rails.application.eager_load!
18
26
 
@@ -39,13 +47,6 @@ module RailsBase
39
47
  end
40
48
  end
41
49
 
42
- def ___execute_initializer___?
43
- # Only execute when not doing DB actions
44
- boolean = defined?(ARGV) ? true : false # for when no ARGVs are provided, we know its a railsc or rails s explicit
45
- boolean = false if boolean && ARGV[0]&.include?('db') # when its the DB rake tasks
46
- boolean = false if boolean && ARGV[0]&.include?('asset') # when its an asset
47
- boolean = false if boolean && ARGV[0]&.include?(':') # else this delim should never be included
48
- boolean = false if ENV['SKIP_CUSTOM_INIT']=='true' # explicitly set the variable to skip shit
49
- end
50
+
50
51
  end
51
52
  end
@@ -1,7 +1,7 @@
1
1
  module RailsBase
2
2
  MAJOR = '0'
3
3
  MINOR = '53'
4
- PATCH = '0'
4
+ PATCH = '1'
5
5
  VERSION = "#{MAJOR}.#{MINOR}.#{PATCH}"
6
6
 
7
7
  def self.print_version
data/lib/rails_base.rb CHANGED
@@ -17,10 +17,31 @@ require 'rails_base/admin/action_cache'
17
17
  require 'rails_base/config'
18
18
 
19
19
  module RailsBase
20
+
21
+ # Rails 6 does not play nice with this function -- Find a different work around
22
+ def self.___execute_initializer___?
23
+ # Only execute when not doing DB actions
24
+ boolean = defined?(ARGV) ? true : false # for when no ARGVs are provided, we know its a railsc or rails s explicit
25
+ boolean = false if boolean && ARGV[0]&.include?('db') # when its the DB rake tasks
26
+ boolean = false if boolean && ARGV[0]&.include?('asset') # when its an asset
27
+ boolean = false if boolean && ARGV[0]&.include?(':') # else this delim should never be included
28
+ boolean = false if ENV['SKIP_CUSTOM_INIT']=='true' # explicitly set the variable to skip shit
29
+
30
+ boolean
31
+ end
32
+
20
33
  def self.url_routes
21
34
  Rails.application.routes.url_helpers
22
35
  end
23
36
 
37
+ def self.app_name
38
+ if ::Rails::VERSION::MAJOR >= 6
39
+ ::Rails.application.class.module_parent_name
40
+ else
41
+ ::Rails.application.class.parent_name
42
+ end
43
+ end
44
+
24
45
  def self.route_exist?(path)
25
46
  Rails.application.routes.recognize_path(path)
26
47
  true
@@ -35,7 +56,7 @@ module RailsBase
35
56
  end
36
57
 
37
58
  def self.config
38
- @config ||= RailsBase::Config.new
59
+ @config ||= RailsBase::Config.instance
39
60
  end
40
61
 
41
62
  def self.appearance
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails_base
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.53.0
4
+ version: 0.53.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matt Taylor
@@ -409,7 +409,6 @@ files:
409
409
  - app/assets/images/rails_base/favicon.ico
410
410
  - app/assets/javascripts/rails_base/admin.js
411
411
  - app/assets/javascripts/rails_base/application.js
412
- - app/assets/javascripts/rails_base/cable.js
413
412
  - app/assets/javascripts/rails_base/mfa_auth.coffee
414
413
  - app/assets/javascripts/rails_base/secondary_authentication.coffee
415
414
  - app/assets/javascripts/rails_base/sessions.js
@@ -1,13 +0,0 @@
1
- // Action Cable provides the framework to deal with WebSockets in Rails.
2
- // You can generate new channels where WebSocket features live using the `rails generate channel` command.
3
- //
4
- //= require action_cable
5
- //= require_self
6
- //= require_tree ./channels
7
-
8
- (function() {
9
- this.App || (this.App = {});
10
-
11
- App.cable = ActionCable.createConsumer();
12
-
13
- }).call(this);