Module: Robodash

Defined in:
lib/robodash.rb,
lib/robodash/version.rb

Constant Summary collapse

DEFAULT_HOST =

Defaults

"https://robodash.app"
OPEN_TIMEOUT =
2
READ_TIMEOUT =
5
SCHEDULE_REGEX =

Parse flexible format like “every 30 minutes”, “3 days”, “2 hours”

/^(?:every\s+)?(\d+)\s*(minute|hour|day|week|month|year)s?$/
VERSION =
"0.3.0"

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.api_tokenObject

Returns the value of attribute api_token.



18
19
20
# File 'lib/robodash.rb', line 18

def api_token
  @api_token
end

.enabledObject

Returns the value of attribute enabled.



18
19
20
# File 'lib/robodash.rb', line 18

def enabled
  @enabled
end

.host=(value) ⇒ Object

Sets the attribute host

Parameters:

  • value

    the value to set the attribute host to.



18
19
20
# File 'lib/robodash.rb', line 18

def host=(value)
  @host = value
end

Class Method Details

.count(name, count, range = nil) ⇒ Object

Count should always be an integer



45
46
47
# File 'lib/robodash.rb', line 45

def count(name, count, range = nil)
  fire_and_forget("count", {name: name, count: count.to_i})
end

.enabled?Boolean

Returns:

  • (Boolean)


20
21
22
23
# File 'lib/robodash.rb', line 20

def enabled?
  return true if @enabled.nil?
  @enabled
end

.ping(name, schedule = nil, grace_period: nil) ⇒ Object

Possible schedules:

  • minutely

  • hourly

  • daily

  • weekly

  • monthly

  • yearly

Examples: Robodash.ping(“Some task”, :daily, grace_period: 10.minutes) Robodash.ping(“Some task”, “every 10 minutes”, grace_period: 10.minutes)



36
37
38
39
40
41
42
# File 'lib/robodash.rb', line 36

def ping(name, schedule = nil, grace_period: nil)
  params = {name: name}
  params.merge!({grace_period: grace_period.to_i}) if grace_period.present?
  params.merge!(parse_schedule(schedule)) if schedule.present?

  fire_and_forget("ping", params)
end