Class: GitSleep::Communicator

Inherits:
Object
  • Object
show all
Includes:
Singleton
Defined in:
lib/git-sleep/communicator.rb

Instance Method Summary collapse

Instance Method Details

#can_commit?Boolean

Returns:

  • (Boolean)


30
31
32
# File 'lib/git-sleep/communicator.rb', line 30

def can_commit?
  data['can_commit']
end

#can_connect?Boolean

Returns:

  • (Boolean)


8
9
10
11
12
13
14
15
# File 'lib/git-sleep/communicator.rb', line 8

def can_connect?
  reset_data!
  true
# TODO: be more specific
# only rescue httparty error related to inability to connect
rescue StandardError
  false
end

#happy_response?Boolean

Returns:

  • (Boolean)


17
18
19
# File 'lib/git-sleep/communicator.rb', line 17

def happy_response?
  response.code == 200
end

#hours_of_sleepObject



34
35
36
# File 'lib/git-sleep/communicator.rb', line 34

def hours_of_sleep
  data['sleep24']
end

#not_signed_up_messageObject



25
26
27
28
# File 'lib/git-sleep/communicator.rb', line 25

def not_signed_up_message
  "Must first authorize at #{GitSleep::OUR_SITE}\n" \
    'Then run `git sleep authorize`'
end

#not_signed_up_response?Boolean

Returns:

  • (Boolean)


21
22
23
# File 'lib/git-sleep/communicator.rb', line 21

def not_signed_up_response?
  response.code == 401
end

#usernameObject



38
39
40
# File 'lib/git-sleep/communicator.rb', line 38

def username
  ENV['USER']
end