Class: AppConfig
- Inherits:
-
Object
- Object
- AppConfig
- Defined in:
- lib/adaptrex/appconfig.rb
Instance Attribute Summary collapse
-
#adaptrexVersion ⇒ Object
Returns the value of attribute adaptrexVersion.
-
#extVersion ⇒ Object
Returns the value of attribute extVersion.
-
#lastSDK ⇒ Object
Returns the value of attribute lastSDK.
-
#pages ⇒ Object
Returns the value of attribute pages.
-
#touchVersion ⇒ Object
Returns the value of attribute touchVersion.
-
#valid ⇒ Object
Returns the value of attribute valid.
Instance Method Summary collapse
-
#initialize(adaptrexConfig) ⇒ AppConfig
constructor
A new instance of AppConfig.
- #read ⇒ Object
- #write ⇒ Object
Constructor Details
#initialize(adaptrexConfig) ⇒ AppConfig
Returns a new instance of AppConfig.
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/adaptrex/appconfig.rb', line 22 def initialize(adaptrexConfig) @adaptrexConfig = adaptrexConfig self.valid = false self.pages = Hash.new if not File.directory?"adaptrex" then Dir.mkdir("adaptrex") end if not File.exist?"adaptrex/.app.settings" then write end read # # Make sure we've got an AdaptrexJS version configured for this webapp # adaptrex = self.adaptrexVersion if adaptrex.nil? adaptrexInstaller = AdaptrexInstaller.new(adaptrexConfig) self.adaptrexVersion = adaptrexInstaller.version write puts "" end # # Make sure adapterx config contains the frameworks configured in this app # missingSDKs = [] ext = self.extVersion touch = self.touchVersion if not adaptrex.nil? and adaptrexConfig.adaptrexVersions.index(adaptrex).nil? missingSDKs.push(adaptrex) end if not ext.nil? and adaptrexConfig.extVersions.index(ext).nil? missingSDKs.push(ext) end if not touch.nil? and adaptrexConfig.touchVersions.index(touch).nil? missingSDKs.push(touch) end if missingSDKs.length > 0 puts "Your weblib folder is missing SDKs used by this webapp".err puts "Check your weblib folder at: ".indent + adaptrexConfig.weblibPath puts "Missing the following:".indent for sdk in missingSDKs puts " - #{sdk}".indent end puts "" return end self.valid = true end |
Instance Attribute Details
#adaptrexVersion ⇒ Object
Returns the value of attribute adaptrexVersion.
21 22 23 |
# File 'lib/adaptrex/appconfig.rb', line 21 def adaptrexVersion @adaptrexVersion end |
#extVersion ⇒ Object
Returns the value of attribute extVersion.
21 22 23 |
# File 'lib/adaptrex/appconfig.rb', line 21 def extVersion @extVersion end |
#lastSDK ⇒ Object
Returns the value of attribute lastSDK.
21 22 23 |
# File 'lib/adaptrex/appconfig.rb', line 21 def lastSDK @lastSDK end |
#pages ⇒ Object
Returns the value of attribute pages.
21 22 23 |
# File 'lib/adaptrex/appconfig.rb', line 21 def pages @pages end |
#touchVersion ⇒ Object
Returns the value of attribute touchVersion.
21 22 23 |
# File 'lib/adaptrex/appconfig.rb', line 21 def touchVersion @touchVersion end |
#valid ⇒ Object
Returns the value of attribute valid.
21 22 23 |
# File 'lib/adaptrex/appconfig.rb', line 21 def valid @valid end |
Instance Method Details
#read ⇒ Object
72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 |
# File 'lib/adaptrex/appconfig.rb', line 72 def read settings = File.new("adaptrex/.app.settings", "r") while (line = settings.gets) line.strip! if (line[0] != ?# and line[0] != ?=) eq = line.index("=") if (eq) key = line[0..eq - 1].strip value = line[eq + 1..-1].strip if key == "adaptrex.version" then self.adaptrexVersion = value elsif key == "ext.version" then self.extVersion = value elsif key == "touch.version" then self.touchVersion = value elsif key == "last.sdk" then self.lastSDK = value else self.pages[key] = value end end end end settings.close end |
#write ⇒ Object
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 |
# File 'lib/adaptrex/appconfig.rb', line 94 def write settings = File.open("adaptrex/.app.settings", "w") settings.puts "# Adaptrex Application Configuration" settings.puts "# ----------------------------------" settings.puts "#" settings.puts "# This folder is automatically generated and maintained by Adaptrex Tools." settings.puts "# You may modify this file directly to add or remove apps (pages) that" settings.puts "# you have modified outside of the Adaptrex Tools." settings.puts "\n\n" settings.puts "# Frameworks" settings.puts "# ----------" if not self.adaptrexVersion.nil? then settings.puts "adaptrex.version = " + self.adaptrexVersion end if not self.extVersion.nil? then settings.puts "ext.version = " + self.extVersion end if not self.touchVersion.nil? then settings.puts "touch.version = " + self.touchVersion end if not self.lastSDK.nil? then settings.puts "last.sdk = " + self.lastSDK end settings.puts "\n\n" settings.puts "# Applications" settings.puts "# ------------" self.pages.each do|key,val| settings.puts key + " = " + val end settings.close end |