lib/generators/blacklight/user_generator.rb in blacklight-6.0.2 vs lib/generators/blacklight/user_generator.rb in blacklight-6.1.0

- old
+ new

@@ -8,15 +8,15 @@ source_root File.expand_path('../templates', __FILE__) argument :model_name, :type => :string , :default => "user" class_option :devise , :type => :boolean, :default => false, :aliases => "-d", :desc => "Use Devise as authentication logic (this is default)." - desc """ -This generator makes the following changes to your application: - 1. Creates a devise-based user model - 2. Injects blacklight-specific behavior into your user model -""" + desc <<-EOS + This generator makes the following changes to your application: + 1. Creates a devise-based user model + 2. Injects blacklight-specific behavior into your user model + EOS # Install Devise? def generate_devise_assets if options[:devise] if ENV['RAILS_VERSION'] =~ /^5\.0/ || ENV['RAILS_VERSION'] == 'edge' gem 'devise', github: 'plataformatec/devise' # Need > 3.5.3 @@ -47,19 +47,25 @@ end # Add Blacklight to the user model def inject_blacklight_user_behavior file_path = "app/models/#{model_name.underscore}.rb" - if File.exists?(file_path) + if File.exist?(file_path) inject_into_class file_path, model_name.classify do - "\n if Blacklight::Utils.needs_attr_accessible?\n" + - "\n attr_accessible :email, :password, :password_confirmation" + - "\n end\n" + - "# Connects this user object to Blacklights Bookmarks. " + - "\n include Blacklight::User\n" + "\n if Blacklight::Utils.needs_attr_accessible?" \ + "\n attr_accessible :email, :password, :password_confirmation" \ + "\n end" \ + "\n # Connects this user object to Blacklights Bookmarks." \ + "\n include Blacklight::User\n" end else - say_status("warning", "Blacklight authenticated user functionality not installed, as a user model could not be found at /app/models/user.rb. If you used a different name, please re-run the migration and provide that name as an argument. Such as `rails -g blacklight:user client`", :yellow) + say_status "warning", <<-EOS.strip_heredocs, :yellow + Blacklight authenticated user functionality not installed, as a user model + could not be found at /app/models/user.rb. If you used a different name, + please re-run the migration and provide that name as an argument. E.g.: + + `rails -g blacklight:user client` + EOS end end end end