Class: Yoda::Store::Project::FileFinder

Inherits:
Object
  • Object
show all
Defined in:
lib/yoda/store/project/file_finder.rb

Overview

Find registry file for the current project settings.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(project) ⇒ FileFinder

Returns a new instance of FileFinder.

Parameters:



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

def initialize(project)
  @project = project
end

Instance Attribute Details

#projectProject (readonly)

Returns:



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

def project
  @project
end

Instance Method Details

#cache_dir_pathString?

Returns:

  • (String, nil)


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

def cache_dir_path
  expand_path('.yoda/cache')
end

#clear_dirObject



93
94
95
# File 'lib/yoda/store/project/file_finder.rb', line 93

def clear_dir
  yoda_dir_path && File.exist?(yoda_dir_path) && FileUtils.rm_rf(yoda_dir_path)
end

#config_file_pathString?

Returns:

  • (String, nil)


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

def config_file_path
  expand_path('.yoda.yml')
end

#gemfile_lock_pathString?

Returns:

  • (String, nil)


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

def gemfile_lock_path
  expand_path('Gemfile.lock')
end

#library_local_yardoc_dir_pathString?

Returns:

  • (String, nil)


38
39
40
# File 'lib/yoda/store/project/file_finder.rb', line 38

def library_local_yardoc_dir_path
  expand_path(File.join('.yoda', 'yardoc', RUBY_VERSION))
end

#library_local_yardoc_path(name:, version:) ⇒ String?

Parameters:

  • name (String)
  • version (String)

Returns:

  • (String, nil)


71
72
73
# File 'lib/yoda/store/project/file_finder.rb', line 71

def library_local_yardoc_path(name:, version:)
  expand_path("#{name}-#{version}.yardoc", library_local_yardoc_dir_path)
end

#library_registry_dir_pathString?

Returns:

  • (String, nil)


33
34
35
# File 'lib/yoda/store/project/file_finder.rb', line 33

def library_registry_dir_path
  expand_path(File.join('.yoda', 'library_registry'))
end

#library_registry_path(name:, version:) ⇒ String?

Parameters:

  • name (String)
  • version (String)

Returns:

  • (String, nil)


78
79
80
# File 'lib/yoda/store/project/file_finder.rb', line 78

def library_registry_path(name:, version:)
  expand_path(Registry.registry_name, library_registry_dir_path)
end

#make_dirObject



87
88
89
90
91
# File 'lib/yoda/store/project/file_finder.rb', line 87

def make_dir
  make_dir_at(cache_dir_path)
  make_dir_at(library_local_yardoc_dir_path)
  make_dir_at(library_registry_dir_path)
end

#present?true, false

Returns:

  • (true, false)


18
19
20
# File 'lib/yoda/store/project/file_finder.rb', line 18

def present?
  File.exist?(cache_path)
end

#project_load_pathsArray<String>

Returns:

  • (Array<String>)


58
59
60
# File 'lib/yoda/store/project/file_finder.rb', line 58

def project_load_paths
  ["lib", "app", "ext"].map { |path| expand_path(path) }.compact
end

#project_registry_pathString?

Returns:

  • (String, nil)


83
84
85
# File 'lib/yoda/store/project/file_finder.rb', line 83

def project_registry_path
  expand_path(Registry.registry_name, cache_dir_path)
end

#project_source_pathsArray<String>

Returns:

  • (Array<String>)


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

def project_source_paths
  glob(["{lib,app}/**/*.rb", "ext/**/*.c", ".yoda/*.rb"])
end

#readable_config_file_pathString?

Returns:

  • (String, nil)


63
64
65
66
# File 'lib/yoda/store/project/file_finder.rb', line 63

def readable_config_file_path
  path = config_file_path
  path && File.readable?(config_file_path) ? path : nil
end

#yoda_dir_pathString?

Returns:

  • (String, nil)


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

def yoda_dir_path
  expand_path('.yoda')
end