Class: DaVinciPASTestKit::Generator::IGMetadata

Inherits:
Object
  • Object
show all
Defined in:
lib/davinci_pas_test_kit/generator/ig_metadata.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#ig_versionObject

Returns the value of attribute ig_version.



4
5
6
# File 'lib/davinci_pas_test_kit/generator/ig_metadata.rb', line 4

def ig_version
  @ig_version
end

#profilesObject

Returns the value of attribute profiles.



4
5
6
# File 'lib/davinci_pas_test_kit/generator/ig_metadata.rb', line 4

def profiles
  @profiles
end

#use_case_groupsObject

Returns the value of attribute use_case_groups.



4
5
6
# File 'lib/davinci_pas_test_kit/generator/ig_metadata.rb', line 4

def use_case_groups
  @use_case_groups
end

Instance Method Details

#add_use_case_groups(id, file_name) ⇒ Object



10
11
12
13
# File 'lib/davinci_pas_test_kit/generator/ig_metadata.rb', line 10

def add_use_case_groups(id, file_name)
  @use_case_groups ||= []
  @use_case_groups << { id:, file_name: }
end

#fetch_resources_with_multiple_profilesObject



26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/davinci_pas_test_kit/generator/ig_metadata.rb', line 26

def fetch_resources_with_multiple_profiles
   = YAML.load_file(File.join(__dir__, '..', 'cross_suite', 'generated', 'v2.0.1', 'metadata.yml'),
                            aliases: true)
  resource_supported_profiles = [:profiles].each_with_object({}) do |profile, dict|
    dict[profile[:resource]] ||= []
    dict[profile[:resource]] << profile[:profile_url]
  end

  resources = []
  resource_supported_profiles.each do |resource, profile_list|
    resources << resource.to_s if profile_list.length > 1
  end
  resources
end

#reformatted_versionObject



6
7
8
# File 'lib/davinci_pas_test_kit/generator/ig_metadata.rb', line 6

def reformatted_version
  @reformatted_version ||= ig_version.delete('.-')
end

#request_type_for_bundle_or_claimObject



45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/davinci_pas_test_kit/generator/ig_metadata.rb', line 45

def request_type_for_bundle_or_claim
  {
    'PAS Request Bundle' => 'submit_request',
    'PAS Response Bundle' => 'submit_response',
    'PAS Inquiry Request Bundle' => 'inquire_request',
    'PAS Inquiry Response Bundle' => 'inquire_response',
    'PAS Claim' => 'submit_request',
    'PAS Claim Response' => 'submit_response',
    'PAS Claim Inquiry' => 'inquire_request',
    'PAS Claim Inquiry Response' => 'inquire_response',
    'PAS Claim Update' => 'update_request'
  }
end

#resource_has_multiple_profiles?(resource) ⇒ Boolean

Returns:

  • (Boolean)


41
42
43
# File 'lib/davinci_pas_test_kit/generator/ig_metadata.rb', line 41

def resource_has_multiple_profiles?(resource)
  resources_with_multiple_profiles.include? resource
end

#resources_with_multiple_profilesObject



22
23
24
# File 'lib/davinci_pas_test_kit/generator/ig_metadata.rb', line 22

def resources_with_multiple_profiles
  @resources_with_multiple_profiles ||= fetch_resources_with_multiple_profiles
end

#snake_case_for_profile(profile_metadata) ⇒ Object



59
60
61
62
63
64
65
66
# File 'lib/davinci_pas_test_kit/generator/ig_metadata.rb', line 59

def snake_case_for_profile()
  resource = .resource
  return resource.underscore unless resource_has_multiple_profiles?(resource)

  .name
    .delete_prefix('profile_')
    .underscore
end

#to_hashObject



15
16
17
18
19
20
# File 'lib/davinci_pas_test_kit/generator/ig_metadata.rb', line 15

def to_hash
  {
    ig_version:,
    profiles: profiles.map(&:to_hash)
  }
end

#upper_camel_case_for_profile(profile_metadata) ⇒ Object



68
69
70
# File 'lib/davinci_pas_test_kit/generator/ig_metadata.rb', line 68

def upper_camel_case_for_profile()
  snake_case_for_profile().camelize
end