Module: ELA::Utils
- Included in:
- ELA
- Defined in:
- lib/ela/utils.rb
Instance Method Summary collapse
- #labels ⇒ Object
- #page_title ⇒ Object
- #settings ⇒ Object
- #write_labels_yml(path) ⇒ Object
- #write_settings_yml(path) ⇒ Object
- #write_yml(name, path) ⇒ Object
- #yml_config(name) ⇒ Object
Instance Method Details
#labels ⇒ Object
72 73 74 75 76 77 78 79 80 81 82 83 84 85 |
# File 'lib/ela/utils.rb', line 72 def labels preamble = " # PLEASE DO NOT CHANGE THIS FILE, YOUR CHANGES WILL BE LOST AFTER THE NEXT APP UPDATE\n # Create a file `labels.overwrite.yml.txt` and place particular changes there. Example:\n #\n # airplaneInternalLoads:\n # fuselage:\n # shortTitle: FLL\n # mohrsCircle:\n # shortTitle: Mohr's Circus\n\n" preamble + yml_config(:labels) end |
#page_title ⇒ Object
122 123 124 125 126 127 128 129 |
# File 'lib/ela/utils.rb', line 122 def page_title global_settings_path = File.join(Dir.pwd, 'settings.yml') if File.exists?(global_settings_path) yml = YAML.load(File.read(global_settings_path)) yml_title = yml['page'].andand['title'] end yml_title or 'E-Learning Apps' end |
#settings ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/ela/utils.rb', line 21 def settings preamble = " # PLEASE DO NOT CHANGE THIS FILE, YOUR CHANGES WILL BE LOST AFTER THE NEXT UPDATE\n # Create a file `settings.overwrite.yml.txt` and place particular changes there. Example:\n #\n # directOperatingCosts:\n # airplanes:\n # A 300 B4-200:\n # speed: 855\n # ILR Super Aircraft:\n # maxTakeOffMass: 165000\n # maxFuelMass: 59646\n # operationEmptyMass: 80640\n # maxPayload: 45360\n # maxRange: 8412\n # speed: 2300\n # engineCount: 6\n # slst: 233\n # engine: 6 x 233kN CF6-50C2\n # reference: ILR12345\n # beamSectionProperties:\n # zProfile:\n # defaults:\n # h: 12.5\n #\n # Structure:\n #\n # {appName}:\n # curves:\n # {curveName}:\n # group: {groupName} # Translation in labels.yml.txt file at {appName} -> listAnchors -> {groupName} -> label\n # selected: (true|false)\n # defaults:\n # {parameterName}: {parameterDefaultValue}\n # formFields:\n # {fieldName}:\n # range: [{fieldFrom}, {fieldTo}] # including boundary values\n # stepSize: {fieldStepSize}\n # group: {fieldGroupName} # Translated to \"Field Group Name\"\n # precision: {fieldPrecision} # Decimal places for computed fields\n # {subappPath}: # subapp settings are more specific and therfore supercede settings from parent layers\n # curves:\n # {curveName}:\n # selected: (true|false)\n #\n # In this file, all curves, parameters and formFields are present even if they have no dedicated settings.\n\n" preamble + yml_config(:settings) end |
#write_labels_yml(path) ⇒ Object
10 11 12 |
# File 'lib/ela/utils.rb', line 10 def write_labels_yml(path) File.write(path, labels) end |
#write_settings_yml(path) ⇒ Object
6 7 8 |
# File 'lib/ela/utils.rb', line 6 def write_settings_yml(path) File.write(path, settings) end |
#write_yml(name, path) ⇒ Object
14 15 16 17 18 19 |
# File 'lib/ela/utils.rb', line 14 def write_yml(name, path) case name when :settings then write_settings_yml(path) when :labels then write_labels_yml(path) end end |
#yml_config(name) ⇒ Object
87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 |
# File 'lib/ela/utils.rb', line 87 def yml_config(name) global_yml_path = File.join(Dir.pwd, "#{name}.yml") s = '' if File.exists?(global_yml_path) s += File.read(global_yml_path) end apps = '' app_settings = '' apps_path = File.join(Dir.pwd, 'apps') Dir.new(apps_path).each do |entry| next if ['.', '..'].include?(entry) entry_path = File.join(apps_path, entry) next unless File.directory?(entry_path) apps += " - #{entry}\n" app_settings += "#{entry}:\n" app_yml_path = File.join(entry_path, "#{name}.yml") if File.exists?(app_yml_path) File.readlines(app_yml_path).each do |line| app_settings += " #{line}" end end end if name == :settings s += "apps:\n#{apps}" end s + app_settings end |