jar

package
v0.0.0-...-f66789b Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 6, 2015 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package jar has containers for storing data, such as bookmarks and cookies.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewMemoryCookies

func NewMemoryCookies() *cookiejar.Jar

New returns a new cookie jar.

func NewMemoryHeaders

func NewMemoryHeaders() http.Header

NewMemoryHeaders creates and readers a new http.Header slice.

Types

type BookmarksJar

type BookmarksJar interface {
	// Save saves a bookmark with the given name.
	Save(name, url string) error

	// Read returns the URL for the bookmark with the given name.
	Read(name string) (string, error)

	// Remove deletes the bookmark with the given name.
	Remove(name string) bool

	// Has returns a boolean value indicating whether a bookmark exists with the given name.
	Has(name string) bool

	// All returns all of the bookmarks as a BookmarksMap.
	All() BookmarksMap
}

BookmarksJar is a container for storage and retrieval of bookmarks.

type BookmarksMap

type BookmarksMap map[string]string

BookmarksMap stores bookmarks.

type FileBookmarks

type FileBookmarks struct {
	// contains filtered or unexported fields
}

FileBookmarks is an implementation of BookmarksJar that saves to a file.

The bookmarks are saved as a JSON string.

func NewFileBookmarks

func NewFileBookmarks(file string) (*FileBookmarks, error)

NewFileBookmarks creates and returns a new *FileBookmarks type.

func (*FileBookmarks) All

func (b *FileBookmarks) All() BookmarksMap

All returns all of the bookmarks as a BookmarksMap.

func (*FileBookmarks) Has

func (b *FileBookmarks) Has(name string) bool

Has returns a boolean value indicating whether a bookmark exists with the given name.

func (*FileBookmarks) Read

func (b *FileBookmarks) Read(name string) (string, error)

Read returns the URL for the bookmark with the given name.

Returns an error when a bookmark does not exist with the given name. Use the Has() method first to avoid errors.

func (*FileBookmarks) Remove

func (b *FileBookmarks) Remove(name string) bool

Remove deletes the bookmark with the given name.

Returns a boolean value indicating whether a bookmark existed with the given name and was removed. This method may be safely called even when a bookmark with the given name does not exist.

func (*FileBookmarks) Save

func (b *FileBookmarks) Save(name, url string) error

Save saves a bookmark with the given name.

Returns an error when a bookmark with the given name already exists. Use the Has() or Remove() methods first to avoid errors.

type History

type History interface {
	Len() int
	Push(p *State) int
	Pop() *State
	Top() *State
}

History is a type that records browser state.

type MemoryBookmarks

type MemoryBookmarks struct {
	// contains filtered or unexported fields
}

MemoryBookmarks is an in-memory implementation of BookmarksJar.

func NewMemoryBookmarks

func NewMemoryBookmarks() *MemoryBookmarks

NewMemoryBookmarks creates and returns a new *BookmarkMemoryJar type.

func (*MemoryBookmarks) All

func (b *MemoryBookmarks) All() BookmarksMap

All returns all of the bookmarks as a BookmarksMap.

func (*MemoryBookmarks) Has

func (b *MemoryBookmarks) Has(name string) bool

Has returns a boolean value indicating whether a bookmark exists with the given name.

func (*MemoryBookmarks) Read

func (b *MemoryBookmarks) Read(name string) (string, error)

Read returns the URL for the bookmark with the given name.

Returns an error when a bookmark does not exist with the given name. Use the Has() method first to avoid errors.

func (*MemoryBookmarks) Remove

func (b *MemoryBookmarks) Remove(name string) bool

Remove deletes the bookmark with the given name.

Returns a boolean value indicating whether a bookmark existed with the given name and was removed. This method may be safely called even when a bookmark with the given name does not exist.

func (*MemoryBookmarks) Save

func (b *MemoryBookmarks) Save(name, url string) error

Save saves a bookmark with the given name.

Returns an error when a bookmark with the given name already exists. Use the Has() or Remove() methods first to avoid errors.

type MemoryHistory

type MemoryHistory struct {
	// contains filtered or unexported fields
}

MemoryHistory is an in-memory implementation of the History interface.

func NewMemoryHistory

func NewMemoryHistory() *MemoryHistory

NewMemoryHistory creates and returns a new *StateHistory type.

func (*MemoryHistory) Len

func (his *MemoryHistory) Len() int

Len returns the number of states in the history.

func (*MemoryHistory) Pop

func (his *MemoryHistory) Pop() *State

Pop removes and returns the State at the front of the history.

func (*MemoryHistory) Push

func (his *MemoryHistory) Push(p *State) int

Push adds a new State at the front of the history.

func (*MemoryHistory) Top

func (his *MemoryHistory) Top() *State

Top returns the State at the front of the history without removing it.

type Node

type Node struct {
	Value *State
	Next  *Node
}

Node holds stack values and points to the next element.

type State

type State struct {
	Request  *http.Request
	Response *http.Response
	Dom      *goquery.Document
}

State represents a point in time.

func NewHistoryState

func NewHistoryState(req *http.Request, resp *http.Response, dom *goquery.Document) *State

NewHistoryState creates and returns a new *State type.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL