Class: SDKInstaller
- Inherits:
-
Object
- Object
- SDKInstaller
- Defined in:
- lib/adaptrex/sdkinstaller.rb
Instance Attribute Summary collapse
-
#success ⇒ Object
Returns the value of attribute success.
Instance Method Summary collapse
-
#initialize(adaptrexConfig, appConfig, sdkType) ⇒ SDKInstaller
constructor
A new instance of SDKInstaller.
- #promptForSDKVersion ⇒ Object
Constructor Details
#initialize(adaptrexConfig, appConfig, sdkType) ⇒ SDKInstaller
Returns a new instance of SDKInstaller.
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 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 |
# File 'lib/adaptrex/sdkinstaller.rb', line 23 def initialize(adaptrexConfig, appConfig, sdkType) self.success = false isExt = sdkType == "ext" if sdkType == "ext" then sdkName = "ExtJS" else sdkName = "Sencha Touch" end puts((sdkName + " SDK Installer").blue) @sdkVersions = nil if isExt @sdkVersions = adaptrexConfig.extVersions else @sdkVersions = adaptrexConfig.touchVersions end if @sdkVersions.length == 0 # # If we don't have any SDKs for this type, warn and return # puts "You don't have any " + sdkName + " SDKs available. Either add".err puts "the correct SDK folder or create a different type of app (page).\n\n" return end if @sdkVersions.length > 1 # # If we have more than one SDK for this type, ask the user for the right one # index = 1 @sdkVersions.each{|version| puts " [" + index.to_s + "] " + version index += 1 } sdkVersion = promptForSDKVersion else # # If we only have one SDK for this type, configure that one # sdkVersion = @sdkVersions[0] end # # Update the AppConfig with the selected SDK Version # if isExt then appConfig.extVersion = sdkVersion else appConfig.touchVersion = sdkVersion end # # Add the SDK folder to our adaptrex folder # FileUtils.mkdir_p("adaptrex/" + sdkType) # # Copy ext.js # sdkFolder = adaptrexConfig.weblibPath + "/" + sdkVersion if isExt FileUtils.cp(sdkFolder + "/ext.js", "adaptrex/ext/ext.js") else FileUtils.cp(sdkFolder + "/sencha-touch.js", "adaptrex/touch/sencha-touch.js") end # # Build the bootstrap file for this Adaptrex/Ext/Sencha combination # bootstrapInstaller = BootstrapInstaller.new(adaptrexConfig, appConfig, sdkType) if not bootstrapInstaller.success then return end # Update appConfig if out sdk installation is successful appConfig.write # Success! puts((sdkName + "Configured (" + sdkVersion + ")").success) self.success = true end |
Instance Attribute Details
#success ⇒ Object
Returns the value of attribute success.
22 23 24 |
# File 'lib/adaptrex/sdkinstaller.rb', line 22 def success @success end |
Instance Method Details
#promptForSDKVersion ⇒ Object
99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 |
# File 'lib/adaptrex/sdkinstaller.rb', line 99 def promptForSDKVersion print "Select the version to use for this webapp: " selection = STDIN.gets.chomp len = @sdkVersions.length erm = ("Invalid Selection. Enter a number from 1 to " + len.to_s).err if not selection.numeric? puts erm return promptForSDKVersion end selection = Integer(selection) if not (1..len).include?selection puts erm return promptForSDKVersion end return @sdkVersions[selection - 1] end |