Class: Railsbricks
- Inherits:
-
Object
- Object
- Railsbricks
- Defined in:
- lib/railsbricks.rb
Class Method Summary collapse
- .annotate ⇒ Object
- .display_config ⇒ Object
- .display_help ⇒ Object
- .display_version ⇒ Object
- .main(args) ⇒ Object
- .new_app ⇒ Object
- .prime_directives ⇒ Object
- .recreate_db ⇒ Object
Class Method Details
.annotate ⇒ Object
49 50 51 52 53 54 55 56 57 58 |
# 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 ⇒ Object
75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 |
# File 'lib/railsbricks.rb', line 75 def self.display_config puts StringHelpers.wputs "----> Retrieving your app's RailsBricks config values ...", :info = ConfigHelpers.load_config puts if .count > 1 .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 ⇒ Object
93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 |
# 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 ⇒ Object
67 68 69 70 71 72 73 |
# 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) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# 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 ⇒ Object
29 30 31 32 33 34 |
# File 'lib/railsbricks.rb', line 29 def self.new_app = Menu.new = . generator = AppGenerator.new() generator.generate_app end |
.prime_directives ⇒ Object
60 61 62 63 64 65 |
# 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 ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/railsbricks.rb', line 36 def self.recreate_db = 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 |