class Railsbricks

Public Class Methods

annotate() click to toggle source
# File lib/railsbricks.rb, line 49
def self.annotate
  puts
  StringHelpers.wputs "----> Annotating models and routes ...", :info
  puts
  system "bundle exec annotate"
  system "bundle exec annotate --routes"
  puts
  StringHelpers.wputs "----> Models and routes annotated.", :info
  puts
end
display_config() click to toggle source
# File lib/railsbricks.rb, line 75
def self.display_config
  puts
  StringHelpers.wputs "----> Retrieving your app's RailsBricks config values ...", :info
  options = ConfigHelpers.load_config
  puts
  if options.count > 1
    options.each do |k,v|
      StringHelpers.wputs "#{k}: #{v}"
    end
  else
    Errors.display_error "Config values couldn't be found. In most cases, this is because '#{ConfigHelpers::CONFIG_PATH}/config' is not within your app.", true
  end
  puts
  StringHelpers.wputs "----> App config values retrieved.", :info
rescue
  Errors.display_error "Config values couldn't be found. In most cases, this is because '#{ConfigHelpers::CONFIG_PATH}/config' is not within your app.", true
end
display_help() click to toggle source
# File lib/railsbricks.rb, line 93
def self.display_help
  puts
  StringHelpers.wputs "RailsBricks usage:", :info
  StringHelpers.wputs "------------------", :info
  puts
  puts "rbricks --new (or -n) :"
  puts "  --> create a new RailsBricks app."
  puts
  puts "rbricks --recreate-db (or -r) :"
  puts "  --> drop, create, migrate & seed the DB"
  puts
  puts "rbricks --config"
  puts "  --> display your app config"
  puts
  puts "rbricks --version (or -v) :"
  puts "  --> display the RailsBricks version"
  puts
end
display_version() click to toggle source
# File lib/railsbricks.rb, line 67
def self.display_version
  puts
  StringHelpers.wputs "RailsBricks #{Version.current} (#{Version.current_date})", :info
  StringHelpers.wputs "source: https://github.com/nicoschuele/railsbricks", :help
  StringHelpers.wputs "by Nico Schuele (www.nicoschuele.com)", :help
  puts
end
main(args) click to toggle source
# File lib/railsbricks.rb, line 10
def self.main(args)
  # new app
  if args[0] == '-n' || args[0] == '--new'
    new_app
  elsif args[0] == '-r' || args[0] == '--recreate-db'
    recreate_db
  elsif args[0] == '-a' || args[0] == '--annotate'
    annotate
  elsif args[0] == '--robocop'
    prime_directives
  elsif args[0] == '-v' || args[0] == '--version'
    display_version
  elsif args[0] == '--config'
    display_config
  else
    display_help
  end
end
new_app() click to toggle source
# File lib/railsbricks.rb, line 29
def self.new_app
  menu = Menu.new
  @options = menu.new_app_menu
  generator = AppGenerator.new(@options)
  generator.generate_app
end
prime_directives() click to toggle source
# File lib/railsbricks.rb, line 60
def self.prime_directives
  Errors.display_error "1. Serve the public trust"
  Errors.display_error "2. Protect the innocent"
  Errors.display_error "3. Uphold the law"
  Errors.display_error "4. Classified"
end
recreate_db() click to toggle source
# File lib/railsbricks.rb, line 36
def self.recreate_db
  options = ConfigHelpers.load_config
  puts
  StringHelpers.wputs "----> Recreating the database ...", :info
  system "#{options["rake_command"]} db:drop"
  system "#{options["rake_command"]} db:create:all"
  system "#{options["rake_command"]} db:migrate"
  system "#{options["rake_command"]} db:seed"
  puts
  StringHelpers.wputs "----> Database recreated.", :info
  puts
end