Module: HardCider

Defined in:
lib/hard_cider.rb,
lib/hard_cider/cli.rb,
lib/hard_cider/utils.rb,
lib/hard_cider/client.rb,
lib/hard_cider/version.rb

Defined Under Namespace

Modules: Utils Classes: CLI, Client

Constant Summary collapse

DEFAULTS =
{ frequency: 30, timeout: 3600 }.freeze
VERSION =
'0.3.0'

Class Method Summary collapse

Class Method Details

.state(bundle_id:, **options) ⇒ String

Parameters:

  • bundle_id (String)
  • options (Hash)

Returns:

  • (String)


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

def self.state(bundle_id:, **options)
  client = HardCider::Client.new(
    options.slice(*CLIENT_OPTIONS)
  )

  client.latest_build(bundle_id).dig(:attributes, :processing_state)
end

.wait(bundle_id:, **options) ⇒ Boolean

Parameters:

  • bundle_id (String)
  • options (Hash)

Returns:

  • (Boolean)


16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/hard_cider.rb', line 16

def self.wait(bundle_id:, **options)
  options = DEFAULTS.merge(options)
  client = HardCider::Client.new(
    options.slice(*CLIENT_OPTIONS)
  )
  timeout_at = Time.now + options[:timeout]

  loop do
    options[:before_wait]&.call

    return true if client.latest_build_processed?(bundle_id)
    return false if Time.now > timeout_at

    sleep(options[:frequency])
  end
end