class RailsFixPermissions

Public Class Methods

new() click to toggle source
# File lib/rails-fix-permissions.rb, line 2
def initialize
  # Relational path of the current folder (app folder).
  @app_path = '../' + File.basename(Dir.getwd)
  if File.exist?(@app_path+'/bin/rails')
    set_permissions
  else
    puts "It's not a Rails application."
    puts "Exiting..."
  end
end

Public Instance Methods

set_permissions() click to toggle source

Shell scripts to recursively set the Rails defaults permissions.

# File lib/rails-fix-permissions.rb, line 14
def set_permissions
  if File.directory?(@app_path)
    puts "Running shell scripts into '"+@app_path+"' to set permissions..."
    directories = `chmod 755 $(find #{@app_path} -type d)`
    files = `chmod 644 $(find #{@app_path} -type f)`
    bundle = `chmod 755 #{@app_path+'/bin/bundle'}`
    rails = `chmod 755 #{@app_path+'/bin/rails'}`
    rake = `chmod 755 #{@app_path+'/bin/rake'}`
    spring = `chmod 755 #{@app_path+'/bin/spring'}`
    puts 'Done!'
  else
    puts "Something went wrong, rails-fix-permissions can't find the current working path: '"+@app_path+"'"
  end
end