Module: Mona

Defined in:
lib/mona.rb,
lib/mona/version.rb

Defined Under Namespace

Modules: Mixins Classes: Config, Container, Error, Package, Project, Task

Constant Summary collapse

PROJECT_FILENAME =
'Monafile.rb'
PACKAGE_FILENAME =
'Package.rb'
Deps =
Container.injector
VERSION =
"0.2.3"

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.current_projectObject

Returns the value of attribute current_project.



46
47
48
# File 'lib/mona.rb', line 46

def current_project
  @current_project
end

Class Method Details

.configs(from = caller_locations.first.path) ⇒ Object



75
76
77
78
79
# File 'lib/mona.rb', line 75

def configs(from = caller_locations.first.path)
  sync_current_project!(from) do
    Container["config.manager"]
  end
end

.init_package(package_name = nil, from: caller_locations.first.path, env: nil, prevent_eager_load: false) ⇒ Object



48
49
50
51
52
53
54
55
# File 'lib/mona.rb', line 48

def init_package(package_name = nil, from: caller_locations.first.path, env: nil, prevent_eager_load: false)
  sync_current_project!(from) do
    package_name ||= Container["package.builder"].call(from, current_project.root_path, current_project.package_dirname).name
    env ||= current_project.env

    Container["package.initializer"].call(package_name, env: env, prevent_eager_load: prevent_eager_load)
  end
end

.loader(from = caller_locations.first.path) ⇒ Object



69
70
71
72
73
# File 'lib/mona.rb', line 69

def loader(from = caller_locations.first.path)
  sync_current_project!(from) do
    current_project.loader
  end
end

.packages(from = caller_locations.first.path) ⇒ Object



81
82
83
84
85
# File 'lib/mona.rb', line 81

def packages(from = caller_locations.first.path)
  sync_current_project!(from) do
    Container["package.repo"]
  end
end

.root(from = caller_locations.first.path) ⇒ Object



57
58
59
60
61
# File 'lib/mona.rb', line 57

def root(from = caller_locations.first.path)
  sync_current_project!(from) do
    current_project.root_path
  end
end

.sync_current_project!(path, &block) ⇒ Object



87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
# File 'lib/mona.rb', line 87

def sync_current_project!(path, &block)
  path = File.expand_path(path)
  path = File.dirname(path) unless File.directory?(path)

  root = Container['project.find_root'].call(path)

  if @current_project && @current_project.root_path == root
    return block.call
  end

  synchronize do
    @current_project = Container["project.initializer"].call(path)

    block.call
  end
end

.synchronize(&block) ⇒ Object



104
105
106
107
108
# File 'lib/mona.rb', line 104

def synchronize(&block)
  @mutex ||= Mutex.new

  @mutex.synchronize(&block)
end

.tasks(from = caller_locations.first.path) ⇒ Object



63
64
65
66
67
# File 'lib/mona.rb', line 63

def tasks(from = caller_locations.first.path)
  sync_current_project!(from) do
    Container["task.manager"]
  end
end