This document outlines the dependencies between Ruby files and functions within the project. Understanding these dependencies is crucial for maintaining and updating the codebase, especially when migrating to a new Ruby version or making changes to the base files. Full usage documentation is contained in README.md
'json'gem'spreadsheet'gem
- Description Contains the top-level functions regularly accessed by the user.
-
- Dependencies:
- Calls
stripInfofromkmlParser.rbto process the input KML file. - Calls
writeToXlsWithClassfromkmlParser.rbto write the processed data to an XLS file.
- Calls
- Description: Converts a KML file into an XLS file. The function can operate in different modes, such as "CatNum" for categorized numbers or "straight" for direct transcription.
- Dependencies:
-
- Dependencies:
- Calls
readXLScolumnfrombIndexOps.rbto read data from an Excel file. - Calls
generateSortingNumbersfromautoMethods.rbto create sorting numbers based on the input data. - Calls
writeXLSfromArrayfrombIndexOps.rbto write the sorting numbers and indexes to an Excel file.
- Calls
- Description: Reads data from an Excel file, generates sorting numbers, and writes the results to another Excel file.
- Dependencies:
-
- Dependencies:
- Calls
parseNestedEndpointsfromautoMethods.rbto parse nested endpoints from MetaFields. - Calls
readIndexDatafrombIndexOps.rbto read data from an index file. - Calls
writeJSONfrombIndexOps.rbto write JSON data. - Calls
generateUniqueFilenamefromprettyCommonFunctions.rbto create a unique filename. - Calls
writeXLSfromRowArrayfrombIndexOps.rbto write data to an Excel file.
- Calls
- Description: Processes index data, adds JSON information, and writes the updated data to an Excel file.
- Dependencies:
-
- Dependencies:
- Calls
readIndexDatafrombIndexOps.rbto read data from an index file. - Calls
writeImageNotesfrombIndexOps.rbto generate image notes based on input data. - Calls
generateUniqueFilenamefromautoMethods.rbto create a unique filename. - Calls
writeXLSfromRowArrayfrombIndexOps.rbto write data to an Excel file.
- Calls
- Description: Processes index data to add image notes and writes the updated data to an Excel file.
- Dependencies:
- Description Defines a class that generates JSON files that mirror the output of the Digital Kenyon api. This can be used to generate mock json directly from the spreadsheet data, which can then be moved to balyInterface/methodTesting and simulate updates.
'json'
RequiredJSONThis hash contains all the JSON data that is provided by Digital Kenyon that is not supplied from the spreadsheet. This includes mostly fixed info, but some variables that are not predictable. Everything in the hash is passed as fixed data to all JSON output.OptAPIfieldsThis hash connects the fields on Digital Kenyon to the column header identifiers. In other words, it defines the structure of the variable JSON data and tells the program where to find each field in the spreadsheet.
All of the following functions are methods for the JsonSample class.
-
- Dependencies
- Calls
parseNestedEndpoints(link) to generate a list of the fields inOptAPIfieldsthat need to be accessed from the spreadsheet. - Calls
readIndexData(link) to generate an array of row hashes containing the spreadsheet data. - Calls
generateOptHash(link) to insert the rowhash data into the structure defined inOptAPIfields. - Calls
fixApiDiscrepancies(link) to adjust the JSON to match specific formats produced by Digital Kenyon
- Calls
- Description This function is the main one for creating the JSON data, and from an input xls file creates a JSON object that mirrors a query result from the Digital Kenyon api.
- Dependencies
-
- Dependencies
- Calls
generateUniqueFilename(link) frombIndexOps.rb
- Calls
- Dependencies
- Description Contains operations to be used on the Baly Index. An input file for these functions must be an Excel 97-2003 Worksheet (.xls) and must include the header row of the Baly Slide Index Google Sheet. Then the full rows of the Index to be processed can be pasted below.
'json'
-
DefaultFieldsAn array containing unique identifiers of each of the header rows in the Baly Slide Index Google Sheet. It need only include the ones used by functions in this file, but we must ensure that these strings are not found in any other header cells. -
MetaFields A nested hash showing the desired structure of generated JSON data. The bottom level contains a hash showing the header row identifiers from DefaultFields where specific data can be found.
-
SampleRowHash A sample of the hashes produced for each row of the input spreadsheet. These are typically created by the readIndexData function, but a sample allows us to test methods reliably.
-
RequiredJSON A hash containing all the JSON data from digital kenyon that cannot be
-
The following methods are defined for multiple classes, allowing them to be used at all levels of nested Arrays and Hashes containing strings.
- Method for Hashes, Arrays, and Strings. Tests whether the object is the last level of nesting, ie. when it contains only strings. For strings it always returns false.
- Method for Arrays and Hashes to add a value/key-value to the object provided that the value has length greater than 0.
-
-
Inserts a key-value pair into the hash unless the value passed has length equal to zero.
-
Returns a boolean of whether both the keys and values of the hash are fillable using the
Array#fillable?command defined below.
-
-
- Tests whether the array is entirely composed of strings (ie. there are no nested objects inside)
- Pushes an element to the array if the elements length is greater than 0.
-
Removes a
'-'element from the start of the array. Used to empty arrays that come from dashed cells in the Baly Slide Index Google Sheet. -
Uses the
String#fullstripmethod defined inbalyClasses.rbto clean leading and trailing whitespace from each element of the array. Includes an option to remove elements that are empty after whitespace removal (default removes them).
-
- Always returns false. It is defined for the String class to keep polymorphism when iterating through nested objects.
- Tests whether the string matches the format for a viable hyperlink.
-
- Dependencies
- Calls
readIndexDatato read the "References" column of the input spreadsheet. - Calls
hyperlink?string method on each word of the reference to identify links. - Calls
generateUniqueFilenamefromprettyCommonFunctions.rbto make the output file name. - Calls
writeXLSfromRowArrayjump to to create a new spreadsheet with the generated data
- Calls
- Description
Reads an input spreadsheet and formats the references into html. This includes placing each reference in a
element and formatting links appropriately.
- Dependencies
-
- Dependencies
- Description
Writes JSON for a single row of the spreadsheet. Uses a rowhash object produced by
readIndexData.
-
- Dependencies
- Description
Iterates through the MetaFields hash to fill it with data from the rowhash object produced by
readIndexData. Returns a nested object that matches the structure of MetaFields.
-
- Dependencies
- Calls
fullstrip?method on strings frombalyClasses.rbto detect dashed data inside the rowhash object
- Calls
- Description Uses conventions to read a bottom-level hash inside MetaFields and supply the necessary fixed and variable data. Variable data comes from the rowhash object produced by ReadIndexData
- Dependencies
-
Mirrors the
fillHashFromRowfunction to fill an end level array in the MetaFields hash. -
- Dependencies
- Calls
parseWrittenDates(link)to format a string date into an array of day, month, and year. - Calls
parsePrintedDates(link) to format a stamped date into an array containing the month and year. - Calls
addUnlessEmpty(link) to assemble data into a larger structure. - Calls the
cleanWhitespace(link) array method to remove extra whitespace from arrays derived from rowhash items. - Calls the
cleanDash(link) array method to remove dashes marking missing data from the arrays derived from rowhash objects. - Calls
parseSlideRange(link) fromprettyCommonFunctions.rbto properly format a comma separated list of old IDs - Calls
is_integer?(link) andfullstripstring methods frombalyClasses.rbto process strings from the rowhash object.
- Calls
- Description Generates a nested hash containing data that cannot be pulled straight from the rowhash object (dates, links, keywords, etc.).
- Dependencies
-
- Description
This standalone function reads the nested hash MetaFields and locates the items that need to be collected by the readIndexData function. It returns a custom error function (passed as a parameter) when it detects that the given nested hash is improper. This raises an error early before other functions like
generateReqHashprocess it.
- Description
This standalone function reads the nested hash MetaFields and locates the items that need to be collected by the readIndexData function. It returns a custom error function (passed as a parameter) when it detects that the given nested hash is improper. This raises an error early before other functions like
-
- Dependencies
- Description
This currently unused function compiles a list/hash of the keywords passed, depending on the
includeOriginsboolean parameter. IfincludeOrigins = true, it returns a hash pointing each keyword to the ids containing it, if not, it returns a simple array of keywords.
-
- Dependencies
- Calls
'spreadsheet'gem to open and read the input spreadsheet. - Calls
getFieldLocs(link) to know which spreadsheet columns contain which data
- Calls
- Description Simplifies the process of reading input spreadsheets by taking an input file, worksheet number and a string array of the column header identifiers (aka, fields) and outputting an array of rows, where each row is either a hash connecting the fields to the data, or an array just containing the data in the same order as the fields were passed.
- Dependencies
-
- Dependencies
- Description Takes the header row of an input spreadsheet and an array of field identifiers to look for and produces a hash connecting each field to the column that contains that data.
-
- Dependencies
- Calls the
geocodergem to automatically get city, region, and country info from geocoordinates.
- Calls the
- Description This function automatically generates geographic data from geocoordinates. However, the geocoder gem has been plagued with errors and has not worked for a while. As such it has been removed from other functions. Note that even when working properly, the data it produces still needs to be checked, and regions probably will not correspond to the custom regions we have defined for the project.
- Dependencies
-
- Dependencies
- Calls
parseWrittenDatesandparsePrintedDatesto format date information into arrays. - Calls the
Classificationclass frombalyClasses.rbfor formatting the old ids. - Calls the
fullstripstring method frombalyClasses.rbto clean string data.
- Calls
- Description This function takes slide data and combines them into a formulaic paragraph, the slide's Image Notes field.
- Dependencies
-
- Dependencies
- Description Parses formulaic written dates into presentable strings or arrays that make data easier to read. The formula necessary is: "January 1, 1970, January 1970, 1970" to accomodate various levels of precision. For an input of "January 1, 1970" it can return either a string: "January 1st, 1970", an array: [1,"January",1970].
-
- Dependencies
- Calls the
fullstrip(link) string method frombalyClasses.rb
- Calls the
- Description Reads a stamped date of the format that appears on the physical slides and formats it into a presentable date string or array of date info. The stamp dates have three letter month shorthands (JAN, JUL, etc) and two digit years.
- Dependencies
-
- Dependencies
- Calls the
'spreadsheet'gem to open a blank spreadsheet - Calls
generateUniqueFilenamefromprettyCommonFunctions.rbto generate a filename based of the given title of the new spreadsheet.
- Calls the
- Description
This function simplifies the process of writing new spreadsheets by acting as a sort of inverse to
readIndexData. It takes an array of row arrays and writes them into a new spreadsheet, with options to supply custom headers.
- Dependencies
-
- Dependencies
Uses the
geocodergem for geographic data - Description Adds basic city,region, and country info from the geocoder gem.
- Dependencies
Uses the
-
- Description Detects whether a string has directional information keywords.
-
- Description Takes a KML file and represents the data as a series of placemarks, where each placemark is either a point or a directional line. No dependencies.
- Accessor functions for basic data
- Makes a hash of string classifications to angle measurements from lines
-
- Generic class for map items, stores universal data like title, description, and coordinates, all available via accessor functions
- Specific class for point objects, which inherit all their qualities from Placemark.
- Specific class for line objects, which inherit all the qualities from Placemark, and add a function to compute the angle between its coordinates.
-
- Dependencies
Uses the
spreadsheetgem, and the KML, Slide, and Classification classes. Uses functionsswapSlideIdentifier,addLocationToSlide,formatspreadsheet,formatSlideData,formatCoordsfrom kmlParser.rb,parseSlideRangeandgenerateUniqueFilenamefromprettyCommonFunctions.rb, andindexConverterfromindexConverter.rb. - Description Large function that converts geospatial data from the KML class object to the spreadsheet object.
- Settings
mode: string option either "straight" (default) or "catnum". "Straight gives a simple placemark-by placemark representation, while catnum groups by slide and groups the data of multiple placemarks.filename: string option for custom named files. Default setting is "blank" for a randomized filename.fillBlanks: boolean option to include all slides between the ones mentioned in the KML file. True includes blank spaces for slides that had no info added.
- Dependencies
Uses the
-
- Dependecies
Depends only on the
fullstripstring method frombalyClasses.rb - Description To allow for slide identifiers to be in descriptions and titles, this function removes an identifier from the title and adds it to the description so that it can be read.
- Dependecies
Depends only on the
-
- Dependencies
hasDirection?andis_integer?string methods - Description Parses angle data or notes from a point's description.
- Dependencies
-
- Dependencies
spreadsheetgem. - Description Adds proper headings to the first row of a spreadsheet object.
- Dependencies
-
- Dependencies Slide class
- Description Reads a slide and produces an array of all the relevant info in spreadsheet order.
-
- Description Reads an array of coordinates and returns the proper string representation
-
- Dependencies
spreadsheetgem. - Description Takes a spreadsheet, worksheet number, and column number, and collects the information in that column into an array.
- Dependencies
-
- Dependencies
spreadsheetgem, andgenerateUniqueFilename. - Description Takes a nested array of columns and writes the data to a spreadsheet file.
- Dependencies
-
- Description Tests whether a string is convertible to a valid integer.
-
- Description Tests whether a string is convertible to a valid floating point number.
-
- Dependencies
- Calls
cleanSpaces(link) to remove any nonstandard characters
- Calls
- Description Removes whitespace and non-standard space characters from left side of string
- Dependencies
-
- Dependencies
- Calls
cleanSpaces(link) to remove any nonstandard characters
- Calls
- Description Removes whitespace and non-standard space characters from right side of string
- Dependencies
-
- Description Converts alphabetic string to numeric value based on position in alphabet
-
- Description A regex method to substitute all non-standard spaces with regular ones.
-
- Description A method to find all the indices of a given string inside an array. Returns an array of integers of each index place.
-
- Description
A mirror of the
includesAtIndexmethod, but case-sensitive.
- Description
A mirror of the
-
- Description Creates new slide object from a given classification number.
-
- Dependencies
Calls the
groupmethod on the slide's Classification object.
- Dependencies
Calls the
Description Returns Baly group identifier
Dependencies
- Calls the
groupmethod on the slide's Classification object.
Description Returns VRC group identifier
Description Returns requested indexing system identifier
Dependencies
- Calls
sortingNumber
Description Returns sorting number for Baly system
Description Returns slide coordinates from either general or specific location
Description Adds alternative identification to slide
Description Adds location data to slide with validation checks
Description Creates new classification from string or array input with validation
Dependencies
- Calls
alphValue
Description Calculates sorting number for Baly system
Description Checks if classification is within given range
Description Parses location array input into components
Dependencies
- Calls
parseLocationArray
Description Creates new general location with optional range
Description Applies location to specified range
Dependencies
- Calls
parseLocationArray - Calls
getAttributesFromString
Description Creates new specific location with parsed attributes
Description Parses location attributes from string input
Description Creates new angle object with validation
Dependencies
- Calls
meetsformat?
Description Creates new subcollection with validation
Description Validates input format for subcollection
Dependencies
- Calls
isVRC?
Description Increments subcollection number with system-specific logic
Description Checks if collection is VRC type based on identifier format