Sha256: 9e1c1bc7b478707fdb8b8b056a380964f91401103089c1fe77eb95d19641bbaa
Contents?: true
Size: 1.96 KB
Versions: 2
Compression:
Stored size: 1.96 KB
Contents
class Mona::Project::Factory include Mona::Mixins sig do params( root_path: String, init_proc: T.proc.params(args: T.anything).returns(T.anything) ) .returns(Mona::Project) end def call(root_path, init_proc:) @tasks = [] @root_path = root_path instance_exec(&init_proc) project = Mona::Project.new( root_path: root_path, env: @env, configs_dir: @configs_dir, package_dirname: @package_dirname, packages_lookup_subdir: @packages_lookup_subdir, loader: @loader, tasks: @tasks ) end private sig do params( block: T.proc.params(args: T.anything).returns(T.anything) ) .void end def setup(&block) instance_exec(@project, &block) nil end sig do params( value: T.any(Symbol, String, T.proc.returns(T.any(String, Symbol))) ) .void end def set_env(value) @env = (value.is_a?(Proc) ? value.call : value).to_sym raise Mona::Error.new("block or value should be provided") if @env.nil? nil end sig do params(value: String).void end def set_configs_dir(value) @configs_dir = value nil end sig do params(value: String).void end def set_package_dirname(value) @package_dirname = value nil end sig do params( name: Symbol, block: T.proc.params(args: T.anything).returns(T.anything) ) .void end def set_loader(name, &block) @loader = Mona::Loaders::Base.registry.fetch(name).new(@root_path, &block) nil end sig do params(value: String).void end def set_packages_lookup_subdir(value) @packages_lookup_subdir = value nil end sig do params( name: Symbol, on: Symbol, block: T.proc.params(args: T.anything).returns(T.anything), ) .void end def register_task(name, on:, &block) @tasks.push( Mona::Task.new( name: name, on: on, block: block ) ) nil end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
mona-0.2.3 | lib/mona/project/factory.rb |
mona-0.2.2 | lib/mona/project/factory.rb |