Class: Ayadn::PinBoard

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

Instance Method Summary collapse

Constructor Details

#initializePinBoard

Returns a new instance of PinBoard.



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

def initialize
  @status = Status.new
end

Instance Method Details

#ask_credentialsObject



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/ayadn/pinboard.rb', line 13

def ask_credentials
  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)


9
10
11
# File 'lib/ayadn/pinboard.rb', line 9

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

#load_credentialsObject



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

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

#pin(data) ⇒ Object



33
34
35
36
# File 'lib/ayadn/pinboard.rb', line 33

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