class Yoda::Commands::Setup
Attributes
bars[R]
@return [Hash{ Symbol => ProgressBar }]
dir[R]
@return [String]
force_build[R]
@return [true, false]
Public Class Methods
new(dir: nil, force_build: false)
click to toggle source
@param dir [String]
# File lib/yoda/commands/setup.rb, line 16 def initialize(dir: nil, force_build: false) @dir = dir || Dir.pwd @force_build = force_build @bars = {} end
Public Instance Methods
project()
click to toggle source
# File lib/yoda/commands/setup.rb, line 34 def project @project ||= Store::Project.new(dir) end
run()
click to toggle source
# File lib/yoda/commands/setup.rb, line 22 def run build_core_index if File.exist?(File.expand_path('Gemfile.lock', dir)) || force_build Logger.info 'Building index for the current project...' Instrument.instance.hear(initialization_progress: method(:on_progress), registry_dump: method(:on_progress)) do force_build ? project.rebuild_cache : project.build_cache end else Logger.info 'Skipped building project index because Gemfile.lock is not exist for the current dir' end end
Private Instance Methods
build_core_index()
click to toggle source
# File lib/yoda/commands/setup.rb, line 40 def build_core_index Store::Actions::BuildCoreIndex.run unless Store::Actions::BuildCoreIndex.exists? end
on_progress(phase: :save_keys, index: nil, length: nil, **params)
click to toggle source
# File lib/yoda/commands/setup.rb, line 44 def on_progress(phase: :save_keys, index: nil, length: nil, **params) return unless index bar = bars[phase] ||= ProgressBar.create(format: "%t: %c/%C |%w>%i| %e ", title: phase.to_s.gsub('_', ' '), starting_at: index, total: length) bar.progress = index if index <= bar.total end