Class: Devserver::CLI
- Inherits:
-
Thor
- Object
- Thor
- Devserver::CLI
- Includes:
- Thor::Actions
- Defined in:
- lib/devserver/cli.rb
Constant Summary collapse
- @@default_settings =
defaults
{}
- @@default_settings_source =
{}
- @@is_rails_dir =
true
Class Method Summary collapse
-
.determine_app_root ⇒ String
Pretend that we are checking for rails by checking for config/boot.rb we’ll even do something smart for ourselves by chdir ..
-
.load_defaults_from_yaml ⇒ Object
Load defaults from a devserver.yaml file located in config/.
-
.set_defaults ⇒ Object
sets defaults for the class.
Instance Method Summary collapse
Class Method Details
.determine_app_root ⇒ String
Pretend that we are checking for rails by checking for config/boot.rb we’ll even do something smart for ourselves by chdir .. if ../config/boot.rb exists. “smart for ourselves” is the operative phrase
47 48 49 50 51 52 53 54 55 56 |
# File 'lib/devserver/cli.rb', line 47 def self.determine_app_root if(File.exist?('config/boot.rb')) return Dir.pwd elsif(File.exist?('../config/boot.rb')) Dir.chdir('..') return Dir.pwd else return nil end end |
.load_defaults_from_yaml ⇒ Object
Load defaults from a devserver.yaml file located in config/
59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/devserver/cli.rb', line 59 def self.load_defaults_from_yaml configfile ="#{@@app_root}/config/devserver.yml" if File.exists?(configfile) then @@default_settings[:configfile] = configfile temp = YAML.load_file(configfile) if temp.class == Hash temp.each do |key,value| @@default_settings[key.to_sym] = value @@default_settings_source[key.to_sym] = configfile end end end end |
.set_defaults ⇒ Object
sets defaults for the class
28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/devserver/cli.rb', line 28 def self.set_defaults if(!(@@app_root = self.determine_app_root)) @@is_rails_dir = false @@app_root = '.' end @@default_settings[:port] = 3000 @@default_settings[:environment] = 'development' @@default_settings[:log_file] = "#{@@app_root}/log/devserver.log" @@default_settings[:pid_file] = "#{@@app_root}/tmp/pids/devserver.pid" @@default_settings[:mode] = 'start' @@default_settings[:server] = 'thin' self.load_defaults_from_yaml end |
Instance Method Details
#about ⇒ Object
121 122 123 124 |
# File 'lib/devserver/cli.rb', line 121 def about rails_warning puts "Devserver Version #{VERSION}: Provides a wrapper around passenger, thin or mongrel for local ruby on rails development." end |
#command ⇒ Object
187 188 189 190 191 192 193 194 195 196 197 198 199 200 |
# File 'lib/devserver/cli.rb', line 187 def command rails_warning the_server = Devserver::CommandManager.new() gem_warning(the_server) if([:start]) puts "start command: #{the_server.command('start')}" end if([:stop]) puts "stop command: #{the_server.command('stop')}" end if([:debug]) puts "debug command: #{the_server.command('debug')}" end end |
#debug ⇒ Object
156 157 158 159 160 161 162 163 164 165 166 |
# File 'lib/devserver/cli.rb', line 156 def debug rails_error the_server = Devserver::CommandManager.new() gem_error(the_server) if(the_server.is_port_open?) puts "Another process is running on Port: #{the_server.port}" puts "Running stop command: #{the_server.command(stop)}" the_server.stop_devserver end the_server.start_devserver('debug') end |
#defaults ⇒ Object
127 128 129 130 |
# File 'lib/devserver/cli.rb', line 127 def defaults rails_warning print_defaults end |
#start ⇒ Object
138 139 140 141 142 143 144 145 146 147 148 |
# File 'lib/devserver/cli.rb', line 138 def start rails_error the_server = Devserver::CommandManager.new() gem_error(the_server) if(the_server.is_port_open?) puts "Another process is running on Port: #{the_server.port}" puts "Running stop command: #{the_server.command('stop')}" the_server.stop_devserver end the_server.start_devserver end |
#stop ⇒ Object
170 171 172 173 174 175 176 |
# File 'lib/devserver/cli.rb', line 170 def stop rails_error gem_error(the_server) the_server = Devserver::CommandManager.new() gem_error(the_server) the_server.stop_devserver end |