Sha256: 9c5300c388614ac16437268f4a9026d7233635a845251f5a9788e7bf1fed8c2e

Contents?: true

Size: 754 Bytes

Versions: 17

Compression:

Stored size: 754 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
  
end

Version data entries

17 entries across 17 versions & 2 rubygems

Version Path
karl-loris-0.0.10 lib/tasks/list_task.rb
karl-loris-0.0.11 lib/tasks/list_task.rb
karl-loris-0.0.6 lib/tasks/list_task.rb
karl-loris-0.0.7 lib/tasks/list_task.rb
karl-loris-0.0.9 lib/tasks/list_task.rb
loris-0.2.0 lib/tasks/list_task.rb
loris-0.1.7 lib/tasks/list_task.rb
loris-0.1.5 lib/tasks/list_task.rb
loris-0.1.4 lib/tasks/list_task.rb
loris-0.1.3 lib/tasks/list_task.rb
loris-0.1.2 lib/tasks/list_task.rb
loris-0.1.1 lib/tasks/list_task.rb
loris-0.1.0 lib/tasks/list_task.rb
loris-0.0.16 lib/tasks/list_task.rb
loris-0.0.15 lib/tasks/list_task.rb
loris-0.0.14 lib/tasks/list_task.rb
loris-0.0.12 lib/tasks/list_task.rb