Author: Pedro Lucas Porcellis <porcellis@eletrotupi.com>
config: add a configuration file and boot
config/boot.rb | 21 +++++++++++++++++++++ config/config.yml.sample | 3 +++
diff --git a/config/boot.rb b/config/boot.rb new file mode 100644 index 0000000000000000000000000000000000000000..a367bc45e19cda8942a331329f615023a8bec0dd --- /dev/null +++ b/config/boot.rb @@ -0,0 +1,21 @@ +ENV["APP_ENV"] ||= "development" + +def require_local_lib(path) + Dir["#{File.dirname(__FILE__)}/#{path}/**/*.rb"].each {|f| require f } +end + +require 'yaml' + +begin + Configuration = YAML.load_file(File.join(File.dirname(__FILE__), "config.yml")) +rescue Errno::ENOENT => e + abort("Could not load the configuration file. Check if config/config.yml exists") +end + +["rubygems", "sinatra"].each { |lib| require(lib) } +require_local_lib("../lib") + +Sinatra::Base.set environment: ENV["APP_ENV"].to_sym, + raise_errors: true, + dump_errors: true, + app_file: File.join(File.dirname(__FILE__), "..", "main.rb") diff --git a/config/config.yml.sample b/config/config.yml.sample new file mode 100644 index 0000000000000000000000000000000000000000..795b6a22a4f3dbb1eb7da9b947343f4fb93aa980 --- /dev/null +++ b/config/config.yml.sample @@ -0,0 +1,3 @@ +api: + public: foo + private: bar