Top Level Namespace

Defined Under Namespace

Modules: Oso, PolarBoolean Classes: FalseClass, Source, TrueClass

Constant Summary collapse

RESET =
''
FG_BLUE =
''
FG_RED =
''

Instance Method Summary collapse

Instance Method Details

#filename_to_source(filename) ⇒ Object



47
48
49
50
51
52
53
54
55
56
57
# File 'lib/oso/polar/polar.rb', line 47

def filename_to_source(filename)
  raise Oso::Polar::PolarFileExtensionError, filename unless File.extname(filename) == '.polar'

  src = File.open(filename, &:read)

  raise Oso::Polar::NullByteInPolarFileError if src.chomp("\0").include?("\0")

  Source.new(src, filename: filename)
rescue Errno::ENOENT
  raise Oso::Polar::PolarFileNotFoundError, filename
end


25
26
27
28
# File 'lib/oso/polar/polar.rb', line 25

def print_error(error)
  warn FG_RED + error.class.name.split('::').last + RESET
  warn error.message
end

#supports_colorObject



11
12
13
# File 'lib/oso/polar/polar.rb', line 11

def supports_color
  $stdout.tty? && $stderr.tty? && ENV['NO_COLOR'].nil?
end