module Speculate

Constants

BASE_DIR

Attributes

args[R]

Public Instance Methods

base_dir() click to toggle source
# File lib/speculate.rb, line 10
def base_dir
  @__base_dir__ ||= args.fetch!(:dest, BASE_DIR) 
end
run(args) click to toggle source
# File lib/speculate.rb, line 26
def run args
  @args = Args.new args
  if @args.flag!(:force)
    _force speculations
  end
  speculations
    .filter(&:outdated?)
    .each(&Generator.method(:generate))
end
speculations() click to toggle source
# File lib/speculate.rb, line 14
def speculations
  @__speculations__ ||= _speculations
end
speculations_dir() click to toggle source
# File lib/speculate.rb, line 18
def speculations_dir
  @__speculations_dir__ ||= args.fetch!(:dir, 'spec/speculations')
end
speculations_glob() click to toggle source
# File lib/speculate.rb, line 22
def speculations_glob
  @__speculations_glob__ ||= args.fetch!(:glob, '**/*.md')
end

Private Instance Methods

_force(speculations) click to toggle source
# File lib/speculate.rb, line 39
def _force speculations
  speculations.each do |speculation|
    puts "touching #{speculation.speculation.path} as :force was passed in"
    FileUtils.touch speculation.speculation
  end
end
_speculations() click to toggle source
# File lib/speculate.rb, line 46
def _speculations
  speculations = Dir.glob(File.join(speculations_dir, speculations_glob))
  if speculations.any?
    puts "Speculations found: #{speculations}"
  else
    puts "No Speculations found!!!! :O :O :O"
    return []
  end
  speculations.map{ |speculation| Dirs.speculation_to_dir(speculation, base_dir) }
end