class Crosby::Tasks

Public Instance Methods

install_tasks() click to toggle source
# File lib/crosby/tasks.rb, line 7
def install_tasks
  namespace :crosby do
    desc "displays all diffs in the configured folder " +
         "(#{Crosby.config[:export_path]})"
    task :diff do
      each_uuid do |uuid|
        puts "============================================================"
        puts "UUID: #{uuid}"
        puts "============================================================"
        Crosby::Diff.compare(uuid) { |diff| puts diff }
      end
    end
  end
end

Private Instance Methods

each_uuid(&block) click to toggle source
# File lib/crosby/tasks.rb, line 24
def each_uuid(&block)
  [].tap { |uuids|
    Dir.new(Crosby.config[:export_path]).each { |filename|
      uuids << extract_uuid(filename) if filename =~ /\.crosby$/
    }

    uuids.compact!
    uuids.uniq!
    uuids.sort!

    uuids.each { |uuid| block.call(uuid) } if block_given?
  }
end
extract_uuid(filename) click to toggle source
# File lib/crosby/tasks.rb, line 38
def extract_uuid(filename)
  filename.gsub(/^.+\..+\..+\.(\S+)\.crosby$/, '\1')
end