Class: Yoda::Store::Project

Inherits:
Object
  • Object
show all
Defined in:
lib/yoda/store/project.rb,
lib/yoda/store/project/cache.rb,
lib/yoda/store/project/library_doc_loader.rb

Defined Under Namespace

Classes: Cache, LibraryDocLoader

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(root_path) ⇒ Project

Returns a new instance of Project.

Parameters:

  • root_path (String)


16
17
18
19
20
21
# File 'lib/yoda/store/project.rb', line 16

def initialize(root_path)
  fail ArgumentError, root_path unless root_path.is_a?(String)

  @root_path = File.absolute_path(root_path)
  @registry = Registry.new
end

Instance Attribute Details

#registryObject (readonly)

Returns the value of attribute registry.



13
14
15
# File 'lib/yoda/store/project.rb', line 13

def registry
  @registry
end

#root_pathObject (readonly)

Returns the value of attribute root_path.



10
11
12
# File 'lib/yoda/store/project.rb', line 10

def root_path
  @root_path
end

Instance Method Details

#build_cacheArray<BaseError>

Returns:



34
35
36
37
38
39
40
# File 'lib/yoda/store/project.rb', line 34

def build_cache
  setup
  loader = LibraryDocLoader.build_for(self)
  loader.run
  load_project_files
  loader.errors
end

#clearObject



28
29
30
31
# File 'lib/yoda/store/project.rb', line 28

def clear
  setup
  registry.adapter.clear
end

#read_source(source_path) ⇒ Object

Parameters:

  • source_path (String)


52
53
54
# File 'lib/yoda/store/project.rb', line 52

def read_source(source_path)
  Actions::ReadFile.run(registry, source_path)
end

#rebuild_cacheObject



42
43
44
45
# File 'lib/yoda/store/project.rb', line 42

def rebuild_cache
  clear
  build_cache
end

#setupObject



23
24
25
26
# File 'lib/yoda/store/project.rb', line 23

def setup
  make_dir
  cache.register_adapter(registry)
end

#yoda_dirObject



47
48
49
# File 'lib/yoda/store/project.rb', line 47

def yoda_dir
  File.expand_path('.yoda', root_path)
end