Module: Mwc

Defined in:
lib/mwc.rb,
lib/mwc/tasks.rb,
lib/mwc/config.rb,
lib/mwc/server.rb,
lib/mwc/command.rb,
lib/mwc/version.rb,
lib/mwc/environment.rb,
lib/mwc/utils/option.rb,
lib/mwc/commands/init.rb,
lib/mwc/options/mruby.rb,
lib/mwc/utils/command.rb,
lib/mwc/commands/watch.rb,
lib/mwc/commands/server.rb,
lib/mwc/compile_options.rb,
lib/mwc/options/project.rb,
lib/mwc/commands/compile.rb,
lib/mwc/utils/hash_accessor.rb,
lib/mwc/utils/command_registry.rb

Overview

WebAssembly compile tool for mruby

Defined Under Namespace

Modules: Commands, Options, Utils Classes: Command, CompileOptions, Config, Environment, Server, Tasks

Constant Summary collapse

LOCK =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

Since:

  • 0.3.0

Mutex.new
VERSION =
'0.4.0'

Class Method Summary collapse

Class Method Details

.configMwc::Config

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

The mwc config

Returns:

Since:

  • 0.1.0



44
45
46
# File 'lib/mwc.rb', line 44

def self.config
  @config ||= Config.new
end

.config=(path) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Set config

Parameters:

  • path (Pathname)

    the config path

Since:

  • 0.3.0



54
55
56
# File 'lib/mwc.rb', line 54

def self.config=(path)
  @config = Config.new(path)
end

.environmentMwc::Environment

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Current environment

Returns:

See Also:

Since:

  • 0.3.0



94
95
96
97
98
# File 'lib/mwc.rb', line 94

def self.environment
  return config.default if @env.nil?

  config.environments[@env] || config.default
end

.mrubyMwc::Options::MRuby

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Current mruby preferences

Returns:

Since:

  • 0.3.0



106
107
108
# File 'lib/mwc.rb', line 106

def self.mruby
  environment.mruby
end

.projectMwc::Options::Project

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Current project preferences

Returns:

Since:

  • 0.3.0



116
117
118
# File 'lib/mwc.rb', line 116

def self.project
  environment.project
end

.rootPathname

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

The project root

Returns:

  • (Pathname)

    the root

Since:

  • 0.1.0



20
21
22
23
24
25
26
# File 'lib/mwc.rb', line 20

def self.root
  return @root unless @root.nil?

  @root ||= Pathname.pwd
  @root ||= Bundler.root if defined?(::Bundler)
  @root
end

.root=(path) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Set project root

Parameters:

  • path (String|Pathname)

    the root path

Since:

  • 0.1.0



34
35
36
# File 'lib/mwc.rb', line 34

def self.root=(path)
  @root = Pathname.new(path)
end

.source_rootString

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

The thor template source root

Returns:

  • (String)

    the source root path

Since:

  • 0.1.0



64
65
66
67
68
69
# File 'lib/mwc.rb', line 64

def self.source_root
  Pathname
    .new(File.dirname(__FILE__))
    .join('mwc', 'templates')
    .to_s
end

.use(env, &_block) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Use prefer environment

Parameters:

  • name (String)

    prefer environment

  • block (Proc)

    the block execute under this environment

Since:

  • 0.3.0



78
79
80
81
82
83
84
# File 'lib/mwc.rb', line 78

def self.use(env, &_block)
  LOCK.synchronize do
    @env = env&.to_sym
    yield
    @env = nil
  end
end