Class: Ayadn::PinBoard

Inherits:
Object show all
Defined in:
lib/ayadn/pinboard.rb

Instance Method Summary collapse

Instance Method Details

#ask_credentials(status = Status.new) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/ayadn/pinboard.rb', line 9

def ask_credentials status = Status.new
  begin
    status.pin_username
    pin_username = STDIN.gets.chomp()
    status.pin_password
    pin_password = STDIN.noecho(&:gets).chomp()
  rescue Interrupt
    status.canceled
    exit
  rescue => e
    status.wtf
    Errors.global_error({error: e, caller: caller, data: [pin_username]})
  end
  save_credentials(encode(pin_username, pin_password))
end

#has_credentials_file?Boolean

Returns:

  • (Boolean)


5
6
7
# File 'lib/ayadn/pinboard.rb', line 5

def has_credentials_file?
  File.exist?(Ayadn::Settings.config.paths.auth + '/pinboard.data')
end

#load_credentialsObject



25
26
27
# File 'lib/ayadn/pinboard.rb', line 25

def load_credentials
  decode(File.read(Ayadn::Settings.config.paths.auth + '/pinboard.data'))
end

#pin(data) ⇒ Object



29
30
31
32
# File 'lib/ayadn/pinboard.rb', line 29

def pin(data)
  pinboard = Pinboard::Client.new(:username => data.username, :password => data.password)
  pinboard.add(:url => data.url, :tags => data.tags, :extended => data.text, :description => data.description)
end