Class: Adaptrex

Inherits:
Object
  • Object
show all
Defined in:
lib/adaptrex.rb

Overview

Utility to run the various Adaptrex scripts

Instance Method Summary collapse

Constructor Details

#initialize(basePath, args) ⇒ Adaptrex

Returns a new instance of Adaptrex.



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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
# File 'lib/adaptrex.rb', line 26

def initialize(basePath, args)
	puts "-------------------------------------------------------------------------------"
	puts "Adaptrex Tools".bold

	trap("INT") {
		puts "\nQuitting Adaptrex Tools\n\n"
		return
	}

	#   If we don't have a command specificied, just list them
	if (args.length < 1)
		listCommands
		return
	end

	#	Make sure we're running from a webapp folder
	if not File.directory?"WEB-INF"
		if File.directory?"src/main/webapp/WEB-INF"
			Dir.chdir("src/main/webapp")
		else
			puts "Adaptrex Tools needs to be run from a webapp folder\n\n".err
			return
		end
	end

	#   Test for folders with reserved names
	illegal = []
	["ext", "touch"].each do |word|
		if File.directory?word then	illegal.push(word) end
	end
	if illegal.length > 0
		puts "Your project includes reserved folders (" + illegal.join(",") + ")".err
		puts "Please rename or remove those folders before using Adaptrex Tools\n\n".indent
		return
	end

	#   Print out command title
	command = args[0]
	if command == "generate"
		puts "ExtJS/Sencha Touch Application (Page) Generator".bold
	elsif command == "build"
		puts "Webapp Builder".bold
	elsif command == "theme"
		puts "Theme Configurator".bold
	elsif command == "upgrade"
		puts "SDK Upgrader".bold
	elsif command == "delete"
		puts "Application Remover".bold
	else
		puts "Command Not Found (#{args[0]})".err
		listCommands
		return
	end
	puts ""

	#	Get our adaptrex config
	adaptrexConfig = AdaptrexConfig.new
	appConfig = AppConfig.new(adaptrexConfig)
	if not appConfig.valid then return end

	#   Launch our specific adaptrex command
	command = args[0]
	if command == "generate"
		require "adaptrex/generate"
		AdaptrexGenerator.new(adaptrexConfig, appConfig, basePath)

	elsif command == "build"
		require "adaptrex/builder"
		AdaptrexBuilder.new(adaptrexConfig, appConfig)

	elsif command == "theme"
		require "adaptrex/themetool"
		ThemeTool.new(adaptrexConfig, appConfig)

	elsif command == "upgrade"
		require "adaptrex/upgradetool"
		UpgradeTool.new(adaptrexConfig, appConfig)

	elsif command == "delete"
		require "adaptrex/deletetool"
		DeleteTool.new(appConfig)
	end

	if not command == "build" then
		puts "\nHappy Coding!".green
	end
	puts ""
end

Instance Method Details

#listCommandsObject

List our current adaptrex commands



116
117
118
119
120
121
122
123
124
125
# File 'lib/adaptrex.rb', line 116

def listCommands
	puts ""
	puts "  " + "Commands".bold
	puts "  generate  : Generates a new application (page) in your project"
	puts "  build     : Build all javascript for production use"
	puts "  theme     : Install or update an ExtJS or Sencha Touch theme"
	puts "  upgrade   : Upgrade to a new AdaptrexJS, ExtJS or Sencha Touch version"
	puts "  delete    : Delete a page and clean up all configuration settings"
	puts ""
end