Sha256: 590323de053d816aea117c55dcf61e0f856dda4e9d3b35b2c3b25a49d1c9e99a

Contents?: true

Size: 807 Bytes

Versions: 11

Compression:

Stored size: 807 Bytes

Contents

class ListTask
 
  def initialize(format_string = "%s")
    @format_string = format_string
  end
  
  def run(files)
    all_files = files[:all]
    mofified_files = files[:filtered]

    return {
        :state => :success,
        :title => 'List',
        :first => mofified_files.length == 1 ? mofified_files[0] : '%s files.' % mofified_files.length,
        :detail => get_detail(mofified_files)
      }
  end
  
  def get_detail(paths)
    detail = ""
    limit = [paths.length - 1, 14].min
    (0..limit).each do |i|
      path = paths[i]
      detail += (@format_string % path)
      detail += "\n"
    end
    if limit < paths.length - 1
      detail += " - Plus #{(paths.length - 1) - limit} more files."
    end

    return detail
  end
  
  def is_configured?(files)
    return true
  end
  
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
loris-0.5.2 lib/tasks/list_task.rb
loris-0.5.1 lib/tasks/list_task.rb
loris-0.5.0 lib/tasks/list_task.rb
loris-0.4.1 lib/tasks/list_task.rb
loris-0.4.0 lib/tasks/list_task.rb
loris-0.3.2 lib/tasks/list_task.rb
loris-0.3.1 lib/tasks/list_task.rb
loris-0.3.0 lib/tasks/list_task.rb
loris-0.2.3 lib/tasks/list_task.rb
loris-0.2.2 lib/tasks/list_task.rb
loris-0.2.1 lib/tasks/list_task.rb