./lib/lux/config/config.rb in lux-fw-0.1.35 vs ./lib/lux/config/config.rb in lux-fw-0.2.1

- old
+ new

@@ -9,41 +9,22 @@ # if we have errors in module loading, try to load them one more time @module_error = [] # requires all files recrusive in, with spart sort - def require_all(files) + def require_all files files = files.to_s files += '/*' unless files.include?('*') file_errors = [] glob = `echo #{files} #{files}/* #{files}/*/* #{files}/*/*/* #{files}/*/*/*/* |tr ' ' '\n' | grep .rb`.split("\n") - glob.reject! { |file| file =~ /_\d+\.rb$/ } glob.select{ |o| o.index('.rb') }.map{ |o| o.split('.rb')[0]}.each do |ruby_file| - require ruby_file rescue file_errors.push(ruby_file) + require ruby_file end - - file_errors.each { |klass| - @klass = klass - require klass - } - rescue - puts "* double load error: require_all #{files}\n #{@klass}.rb\n #{$!.message}".red - raise $! end - # load specific plugin - def plugin(name) - files = Dir['%s/lib/plugins/%s/*.rb' % [Lux.fw_root, name]] - die('Plugin "%s" load error, no plugin' % name) if files.length == 0 - for file in files - require file - end - # Lux.log "* plugin :#{name}" - end - # preview config in development def show_config for k,v in Lux.config next if v.kind_of?(Hash) puts "* config :#{k} = #{v.kind_of?(Hash) ? '{...}' : v}" @@ -68,17 +49,60 @@ load file end true end - def show_load_speed(load_start) + def ram + `ps -o rss -p #{$$}`.chomp.split("\n").last.to_i / 1000 + end + + def show_load_speed load_start=nil + return @@load_info || 'No lux load info' unless load_start + speed = ((Time.now - load_start)*1000).round.to_s.sub(/(\d)(\d{3})$/,'\1s \2')+'ms' - ram = `ps -o rss -p #{$$}`.chomp.split("\n").last.to_i / 1000 - opts = [] - opts.push Lux.verbose? ? 'verbose'.yellow : 'no-verbose'.green - opts.push Lux.config(:auto_code_reload) ? 'auto-code-reload'.yellow : 'no-code-reload'.green - "* #{'Lux'.white} loaded #{Lux.env('RACK_ENV').green} (#{opts.join(', ')}) mode in #{speed.to_s.white}, uses #{ram.to_s.white} MB RAM with total of #{Gem.loaded_specs.keys.length.to_s.white} gems in spec" + production_mode = true + + production_opts = [ + [:compile_assets, false], + [:auto_code_reload, false], + [:show_server_errors, false], + [:log_to_stdout, false], + ] + + opts = production_opts.map do |key, production_value| + config_test = Lux.config(key) + config_ok = production_value == config_test + production_mode = false unless config_ok + + data = "#{key} (%s)" % [config_test ? :yes : :no] + config_ok ? data : data.yellow + end + + puts @@load_info = '* Config: %s' % opts.join(', ') + + mode = production_mode ? 'production'.green : 'development'.yellow + + "* #{'Lux'.white} loaded #{mode} mode in #{speed.to_s.white}, uses #{ram.to_s.white} MB RAM with total of #{Gem.loaded_specs.keys.length.to_s.white} gems in spec".tap do |it| + @@load_info += "\n#{it}" + end + end + + def set_default_vars + # how long will session last if BROWSER or IP change + Lux.config.session_forced_validity = 5.minutes.to_i + + # name of the session cookie + Lux.config.session_cookie_name = '__luxs' + + # Show server errors to a client + Lux.config.show_server_errors = false + + # Log debug output to stdout + Lux.config.log_to_stdout = false + + # Automatic code reloads in development + Lux.config.auto_code_reload = false end end class Object \ No newline at end of file