Module: CrystalRuby

Extended by:
Config
Defined in:
lib/crystalruby.rb,
lib/crystalruby/types.rb,
lib/crystalruby/config.rb,
lib/crystalruby/adapter.rb,
lib/crystalruby/library.rb,
lib/crystalruby/reactor.rb,
lib/crystalruby/version.rb,
lib/crystalruby/function.rb,
lib/crystalruby/template.rb,
lib/crystalruby/typemaps.rb,
lib/crystalruby/arc_mutex.rb,
lib/crystalruby/types/type.rb,
lib/crystalruby/compilation.rb,
lib/crystalruby/typebuilder.rb,
lib/crystalruby/source_reader.rb,
lib/crystalruby/types/primitive.rb,
lib/crystalruby/types/fixed_width.rb,
lib/crystalruby/types/variable_width.rb,
lib/crystalruby/types/concerns/allocator.rb

Defined Under Namespace

Modules: Adapter, Compilation, Config, LibC, Reactor, SourceReader, Template, TypeBuilder, Typemaps, Types Classes: ArcMutex, Configuration, Function, Library

Constant Summary collapse

VERSION =
"0.3.0"
InvalidCastError =
Class.new(StandardError)

Class Method Summary collapse

Methods included from Config

config

Class Method Details

.check_config!Object



51
52
53
54
55
56
# File 'lib/crystalruby.rb', line 51

def check_config!
  return if config.crystal_src_dir

  raise "Missing config option `crystal_src_dir`. \nProvide this inside crystalruby.yaml " \
    "(run `bundle exec crystalruby init` to generate this file with detaults)"
end

.check_crystal_ruby!Object



38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/crystalruby.rb', line 38

def check_crystal_ruby!
  return if system("which crystal > /dev/null 2>&1")

  msg = "Crystal executable not found. Please ensure Crystal is installed and in your PATH. " \
    "See https://crystal-lang.org/install/."

  if config.crystal_missing_ignore
    config.logger.error msg
  else
    raise msg
  end
end

.compile!Object



66
67
68
# File 'lib/crystalruby.rb', line 66

def compile!
  CrystalRuby::Library.all.each(&:build!)
end

.configure {|config| ... } ⇒ Object

Yields:



81
82
83
84
# File 'lib/crystalruby/config.rb', line 81

def self.configure
  yield(config)
  @paths_cache = {}
end

.initialize_crystal_ruby!Object



30
31
32
33
34
35
36
# File 'lib/crystalruby.rb', line 30

def initialize_crystal_ruby!
  return if initialized?

  check_crystal_ruby!
  check_config!
  @initialized = true
end

.initialized?Boolean

Returns:

  • (Boolean)


26
27
28
# File 'lib/crystalruby.rb', line 26

def initialized?
  !!@initialized
end