Class: DataspecContent

Inherits:
Object
  • Object
show all
Defined in:
app/helpers/dataspec_content.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config_dir) ⇒ DataspecContent


19
20
21
22
# File 'app/helpers/dataspec_content.rb', line 19

def initialize(config_dir)
  @config_dir = config_dir
  loadDataspec
end

Instance Attribute Details

#attach_attrObject (readonly)

attach_config.json


17
18
19
# File 'app/helpers/dataspec_content.rb', line 17

def attach_attr
  @attach_attr
end

#attach_prefixObject (readonly)

attach_config.json


17
18
19
# File 'app/helpers/dataspec_content.rb', line 17

def attach_prefix
  @attach_prefix
end

#config_dirObject (readonly)

field_details.json


3
4
5
# File 'app/helpers/dataspec_content.rb', line 3

def config_dir
  @config_dir
end

#data_pathObject (readonly)

dataset_details.json


10
11
12
# File 'app/helpers/dataspec_content.rb', line 10

def data_path
  @data_path
end

#data_path_typeObject (readonly)

dataset_details.json


10
11
12
# File 'app/helpers/dataspec_content.rb', line 10

def data_path_type
  @data_path_type
end

#dataset_nameObject (readonly)

dataset_details.json


10
11
12
# File 'app/helpers/dataspec_content.rb', line 10

def dataset_name
  @dataset_name
end

#dedup_ignoreObject (readonly)

import_config.json


13
14
15
# File 'app/helpers/dataspec_content.rb', line 13

def dedup_ignore
  @dedup_ignore
end

#dedup_prioritizeObject (readonly)

import_config.json


13
14
15
# File 'app/helpers/dataspec_content.rb', line 13

def dedup_prioritize
  @dedup_prioritize
end

#default_fields_in_resultsObject (readonly)

display_prefs.json


6
7
8
# File 'app/helpers/dataspec_content.rb', line 6

def default_fields_in_results
  @default_fields_in_results
end

#doc_page_fieldsObject (readonly)

display_prefs.json


6
7
8
# File 'app/helpers/dataspec_content.rb', line 6

def doc_page_fields
  @doc_page_fields
end

#facet_fieldsObject (readonly)

display_prefs.json


6
7
8
# File 'app/helpers/dataspec_content.rb', line 6

def facet_fields
  @facet_fields
end

#field_infoObject (readonly)

field_details.json


3
4
5
# File 'app/helpers/dataspec_content.rb', line 3

def field_info
  @field_info
end

#field_info_sortedObject (readonly)

field_details.json


3
4
5
# File 'app/helpers/dataspec_content.rb', line 3

def field_info_sorted
  @field_info_sorted
end

#fields_in_resultsObject (readonly)

display_prefs.json


6
7
8
# File 'app/helpers/dataspec_content.rb', line 6

def fields_in_results
  @fields_in_results
end

#get_afterObject (readonly)

import_config.json


13
14
15
# File 'app/helpers/dataspec_content.rb', line 13

def get_after
  @get_after
end

#id_fieldObject (readonly)

import_config.json


13
14
15
# File 'app/helpers/dataspec_content.rb', line 13

def id_field
  @id_field
end

#id_secondaryObject (readonly)

import_config.json


13
14
15
# File 'app/helpers/dataspec_content.rb', line 13

def id_secondary
  @id_secondary
end

#ignore_extObject (readonly)

dataset_details.json


10
11
12
# File 'app/helpers/dataspec_content.rb', line 10

def ignore_ext
  @ignore_ext
end

#ignore_listObject (readonly)

import_config.json


13
14
15
# File 'app/helpers/dataspec_content.rb', line 13

def ignore_list
  @ignore_list
end

#image_prefixObject (readonly)

attach_config.json


17
18
19
# File 'app/helpers/dataspec_content.rb', line 17

def image_prefix
  @image_prefix
end

#index_nameObject (readonly)

dataset_details.json


10
11
12
# File 'app/helpers/dataspec_content.rb', line 10

def index_name
  @index_name
end

#item_fieldsObject (readonly)

display_prefs.json


6
7
8
# File 'app/helpers/dataspec_content.rb', line 6

def item_fields
  @item_fields
end

#pdf_tabObject (readonly)

attach_config.json


17
18
19
# File 'app/helpers/dataspec_content.rb', line 17

def pdf_tab
  @pdf_tab
end

#searchable_fieldsObject (readonly)

display_prefs.json


6
7
8
# File 'app/helpers/dataspec_content.rb', line 6

def searchable_fields
  @searchable_fields
end

#show_sort_fieldObject (readonly)

dataset_details.json


10
11
12
# File 'app/helpers/dataspec_content.rb', line 10

def show_sort_field
  @show_sort_field
end

#sort_fieldObject (readonly)

dataset_details.json


10
11
12
# File 'app/helpers/dataspec_content.rb', line 10

def sort_field
  @sort_field
end

#synonym_listObject (readonly)

import_config.json


13
14
15
# File 'app/helpers/dataspec_content.rb', line 13

def synonym_list
  @synonym_list
end

#truncated_fieldsObject (readonly)

display_prefs.json


6
7
8
# File 'app/helpers/dataspec_content.rb', line 6

def truncated_fields
  @truncated_fields
end

#web_tabObject (readonly)

attach_config.json


17
18
19
# File 'app/helpers/dataspec_content.rb', line 17

def web_tab
  @web_tab
end

#web_urlObject (readonly)

attach_config.json


17
18
19
# File 'app/helpers/dataspec_content.rb', line 17

def web_url
  @web_url
end

Instance Method Details

#getAttachConfigObject

Get config settings for attachments (pdfs and images)


76
77
78
79
80
81
82
83
84
# File 'app/helpers/dataspec_content.rb', line 76

def getAttachConfig
  attach_config = JSON.parse(File.read(@config_dir+"attach_config.json"))
  @pdf_tab = attach_config["Show PDF?"]
  @attach_prefix = attach_config["File Path Prefix"]
  @attach_attr = attach_config["File Path Attr"]
  @web_tab = attach_config["Show Webpage?"]
  @web_url = attach_config["Web URL"]
  @image_prefix = attach_config["Image Path Prefix"]
end

#getDatasetDetailsObject

Gets where the dataset is and how it is structured


52
53
54
55
56
57
58
59
60
61
# File 'app/helpers/dataspec_content.rb', line 52

def getDatasetDetails
  dataset_details = JSON.parse(File.read(@config_dir+"dataset_details.json"))
  @index_name = dataset_details["Index Name"]
  @dataset_name = dataset_details["Dataset Name"]
  @data_path_type = dataset_details["Path Type"]
  @data_path = dataset_details["Path"]
  @ignore_ext = dataset_details["Ignore Dir Import Ext"]
  @sort_field = dataset_details["Sort Field"]
  @show_sort_field = dataset_details["Show Sort Field"]
end

#getDisplayPrefsObject

Get where each field should show up


40
41
42
43
44
45
46
47
48
49
# File 'app/helpers/dataspec_content.rb', line 40

def getDisplayPrefs
  display_prefs = JSON.parse(File.read(@config_dir+"display_prefs.json"))
  @facet_fields = display_prefs["Facet"]
  @searchable_fields = display_prefs["Searchable"]
  @fields_in_results = display_prefs["In Search Results"]
  @default_fields_in_results = display_prefs["In Search Results by Default"]
  @doc_page_fields = display_prefs["On Doc Page"]
  @item_fields = display_prefs["Item Field"]
  @truncated_fields = display_prefs["Truncate Text"]
end

#getFieldInfoObject

Gets the details for each field


34
35
36
37
# File 'app/helpers/dataspec_content.rb', line 34

def getFieldInfo
  @field_info = JSON.parse(File.read(@config_dir+"field_details.json"))
  @field_info_sorted = @field_info.sort_by{|field| field["Location"].to_i}
end

#getImportConfigObject

Get import config details


64
65
66
67
68
69
70
71
72
73
# File 'app/helpers/dataspec_content.rb', line 64

def getImportConfig
  dataset_details = JSON.parse(File.read(@config_dir+"import_config.json"))
  @id_field = dataset_details["ID Field"]
  @id_secondary = dataset_details["Secondary ID"]
  @get_after = dataset_details["Get ID After"]
  @synonym_list = dataset_details["Synonym List"]
  @ignore_list = dataset_details["Ignore List"]
  @dedup_ignore = dataset_details["Deduplicate Ignore"]
  @dedup_prioritize = dataset_details["Deduplicate Prioritize"]
end

#loadDataspecObject

Load all dataspec info


25
26
27
28
29
30
31
# File 'app/helpers/dataspec_content.rb', line 25

def loadDataspec
  getFieldInfo
  getDisplayPrefs
  getDatasetDetails
  getImportConfig
  getAttachConfig
end