Module: Rubymisc

Included in:
Rbm, Rbm
Defined in:
lib/rubymisc.rb,
lib/rubymisc/self.rb,
lib/rubymisc/regex.rb,
lib/rubymisc/version.rb,
lib/rubymisc/ext/float.rb,
lib/rubymisc/ext/object.rb,
lib/rubymisc/ext/string.rb,
lib/rubymisc/exceptional.rb,
lib/rubymisc/ext/integer.rb,
lib/rubymisc/regex/manual.rb,
lib/rubymisc/ext/active_record.rb

Overview

This module encapsulates top level class methods.

Defined Under Namespace

Modules: ArValidates, Exceptional, Float, Integer, Object, Regex, String

Constant Summary collapse

VERSION =
'0.2.0'

Class Method Summary collapse

Class Method Details

.dump_error_to_file(file) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/rubymisc/self.rb', line 10

def dump_error_to_file(file)
  if $!
    File.open(file, 'a:utf-8:utf-8') do |log|
      error = { timestamp: Time.now,
                message:   $!.message,
                backtrace: $!.backtrace,
                gems:      Gem.loaded_specs.inject({}) { |m, (n, s)| m.merge(n => s.version.to_s) } }
      require 'yaml'
      YAML.dump(error, log)
    end
  end
end

.log_at_exit_error(log_to) ⇒ Object



6
7
8
# File 'lib/rubymisc/self.rb', line 6

def log_at_exit_error(log_to)
  at_exit { dump_error_to_file(log_to) }
end

.rbm_ext_load(ext_prefix = '') ⇒ Object

:nodoc:



10
11
12
# File 'lib/rubymisc.rb', line 10

def rbm_ext_load(ext_prefix = '') #:nodoc:
  ->(ext_file) { require ext_prefix + ext_file }
end