Module: HWSHelpers

Defined in:
lib/hws_helpers.rb

Overview

These are helper methods that should be common to most modular 'Apps' in Helix Web Services.

Instance Method Summary (collapse)

Instance Method Details

- (Object) p4

[View source]

33
34
35
# File 'lib/hws_helpers.rb', line 33

def p4
  env['p4'] || fail('require_p4 not called')
end

- (Object) require_p4

This will ensure that the environment contains a p4 handle that is configured using our typical hws_settings options.

It should be rare to actually require using this method. This is typically generated by authentication middleware.

The p4 is possibly not connected or logged in.

[View source]

16
17
18
19
20
21
22
# File 'lib/hws_helpers.rb', line 16

def require_p4
  unless !env['p4'].nil?
    p4 = P4Util.open_from_env(env)
    p4.connect
    env['p4'] = p4
  end
end

- (Object) require_p4_with_temp_client

This ensures that the p4 handle has an associated temporary client workspace.

The local temporary directory is saved under 'p4_root'.

[View source]

28
29
30
31
# File 'lib/hws_helpers.rb', line 28

def require_p4_with_temp_client
  require_p4
  env['p4_root'] = P4Util.create_temp_client(env['p4'])
end

- (Object) user

[View source]

37
38
39
# File 'lib/hws_helpers.rb', line 37

def user
  env['AUTH_CREDENTIALS'].first
end