Sha256: 470a40ae4bd560a625efbff46015e862a06d518491578c24934bce0e9903ddcd

Contents?: true

Size: 907 Bytes

Versions: 1

Compression:

Stored size: 907 Bytes

Contents

require 'ostruct'
require_relative "store"
require_relative "api"
require_relative "pad"

module Hackpad
  module Cli
    module Padlist
      extend self

      def get_list(refresh=false)
        all = []
        if refresh or !Store.exists? "padlist"
          print "Refreshing "
          list = Api.list
          list.each do |a|
            print "."
            pad = Pad.new a
            pad.load 'txt', refresh
            all << OpenStruct.new( id: a, title: pad.title )
          end
          puts " all done."
          Store.save_list all
        else
          all = Store.read_list
        end
        all
      end

      def check_list
        all = []
        list = Api.list
        list.each do |a|
          pad = Pad.new a
          if !pad.is_cached?
            all << OpenStruct.new( id: a, title: pad.title )
          end
        end
        all
      end

    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
hackpad-cli-0.0.7 lib/hackpad/cli/padlist.rb