Class: ThemeInstaller
- Inherits:
-
Object
- Object
- ThemeInstaller
- Defined in:
- lib/adaptrex/themeinstaller.rb
Constant Summary collapse
- @@touchThemes =
[ ["All Adaptrex Touch Themes", "adaptrex", "adaptrex"], ["All Sencha Touch Default Themes", "default", "default"], #["Custom Theme", "custom", "custom"] ]
- @@extThemes =
[ #["Adaptrex Touch Theme", "adaptrex", "adaptrex-all.css"], ["ExtJS Default Theme", "default", "ext-all.css"], ["ExtJS Gray Theme", "gray", "ext-all-gray.css"], ["ExtJS Access Theme", "access", "ext-all-access.css"], ["ExtJS Neptune Theme", "neptune", "ext-neptune.css"], #["Custom Theme", "custom", "custom"], ]
Instance Attribute Summary collapse
-
#success ⇒ Object
Returns the value of attribute success.
Instance Method Summary collapse
-
#initialize(adaptrexConfig, appConfig, sdkType) ⇒ ThemeInstaller
constructor
A new instance of ThemeInstaller.
- #promptForTheme(sdkType) ⇒ Object
Constructor Details
#initialize(adaptrexConfig, appConfig, sdkType) ⇒ ThemeInstaller
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 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/themeinstaller.rb', line 37 def initialize(adaptrexConfig, appConfig, sdkType) self.success = false isExt = sdkType == "ext" if sdkType == "ext" then sdkName = "ExtJS" else sdkName = "Sencha Touch" end puts((sdkName + " Theme Installer").blue) if sdkType == "touch" then = @@touchThemes else = @@extThemes end if .length == 1 theme = [0] else index = 0 .each {|option| puts " [" + (index + 1).to_s + "] " + [index][0] index += 1 } theme = promptForTheme(sdkType) end puts "Installing " + theme[0] + "..." imgFolder = theme[1] cssFile = theme[2] # Start processing the theme targetFolder = "adaptrex/" + sdkType + "/resources" # Clean out old theme # FileUtils.rm_rf(targetFolder) FileUtils.mkdir_p(targetFolder + "/css") # Add additional touch theme files if sdkType == "touch" if imgFolder == "adaptrex" sdkResourcesFolder = adaptrexConfig.weblibPath + "/" + appConfig.adaptrexVersion + "/touch/resources" Dir.glob(sdkResourcesFolder + "/css/*") {|f| if not File.directory?f FileUtils.cp(File.(f), targetFolder + "/css/") end } else sdkResourcesFolder = adaptrexConfig.weblibPath + "/" + appConfig.touchVersion + "/resources" Dir.glob(sdkResourcesFolder + "/css/*") {|f| if not File.directory?f FileUtils.cp(File.(f), targetFolder + "/css/") end } end # Add additional ext theme files else FileUtils.mkdir_p(targetFolder + "/themes/images") # Adaptrex Theme Not Yet Implemented if imgFolder == "adaptrex" sdkResourcesFolder = adaptrexConfig.weblibPath + "/" + appConfig.adaptrexVersion + "/resources" FileUtils.cp(sdkResourcesFolder + "/css/" + cssFile, targetFolder + "/css/theme.css") FileUtils.cp_r(sdkResourcesFolder + "/themes/images/" + imgFolder, targetFolder + "/themes/images/" + imgFolder) # Custom Themes Not Yet Implemented elsif imgFolder == "custom" # Standard Ext Themes else sdkResourcesFolder = adaptrexConfig.weblibPath + "/" + appConfig.extVersion + "/resources" # Neptune needs some extra files if imgFolder == "neptune" FileUtils.cp_r(sdkResourcesFolder + "/themes/images/default", targetFolder + "/themes/images/neptune") FileUtils.cp(adaptrexConfig.weblibPath + "/" + appConfig.extVersion + "/ext-neptune.js", "adaptrex/" + sdkType + "/ext-neptune.js") elsif imgFolder == "access" FileUtils.cp_r(sdkResourcesFolder + "/themes/images/default", targetFolder + "/themes/images/neptune") end FileUtils.cp(sdkResourcesFolder + "/css/" + cssFile, targetFolder + "/css/" + cssFile) FileUtils.cp_r(sdkResourcesFolder + "/themes/images/" + imgFolder, targetFolder + "/themes/images/" + imgFolder) end end # Success! puts((theme[0] + " Configured").success) self.success = true end |
Instance Attribute Details
#success ⇒ Object
Returns the value of attribute success.
36 37 38 |
# File 'lib/adaptrex/themeinstaller.rb', line 36 def success @success end |
Instance Method Details
#promptForTheme(sdkType) ⇒ Object
120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 |
# File 'lib/adaptrex/themeinstaller.rb', line 120 def promptForTheme(sdkType) print "Which theme do you want to use? [1]: " if sdkType == "touch" then = @@touchThemes else = @@extThemes end selection = STDIN.gets.chomp if selection == "" then selection = "1" end len = .length erm = ("Invalid selection. Enter a number from 1 to " + len.to_s).err if not selection.numeric? puts erm return promptForTheme(sdkType) end selection = Integer(selection) if not (1..len).include?selection puts erm return promptForTheme(sdkType) end return [selection - 1] end |