Sha256: 2cc2f1962d599e2217f9ac9b7f967ff4a71c466460573669e518e768ddd11c20

Contents?: true

Size: 968 Bytes

Versions: 3

Compression:

Stored size: 968 Bytes

Contents

require 'env-conf'

module Jersey
  #require bundler and the proper gems for the ENV
  def self.require
    Kernel.require 'bundler'
    Config.dotenv!
    $stderr.puts "Loading #{Config.app_env} environment..."
    Bundler.require(:default, Config.app_env)
  end

  # adds ./lib dir to the load path
  def self.load_path
    $stderr.puts "Adding './lib' to path..."
    $LOAD_PATH.unshift(File.expand_path('./lib'))
  end

  # sets TZ to UTC and Sequel timezone to :utc
  def self.set_timezones
    $stderr.puts "Setting timezones to UTC..."
    Sequel.default_timezone = :utc if defined? Sequel
    ENV['TZ'] = 'UTC'
  end

  def self.hack_time_class
    $stderr.puts "Modifying Time#to_s to use #iso8601..." if ENV['DEBUG']
    # use send to call private method
    Time.send(:define_method, :to_s) do
      self.iso8601
    end
  end

  # all in one go
  def self.setup
    self.require
    self.load_path
    self.set_timezones
    self.hack_time_class
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
jersey-0.2.0 lib/jersey/setup.rb
jersey-0.1.0 lib/jersey/setup.rb
jersey-0.0.3 lib/jersey/setup.rb