Class: ExtJS::XTheme::Command::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/extjs-xtheme/commands/base.rb

Direct Known Subclasses

Config, Effects, Help, Theme

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args, config) ⇒ Base

Returns a new instance of Base.



10
11
12
13
# File 'lib/extjs-xtheme/commands/base.rb', line 10

def initialize(args, config)
	@args = args
	@config = config
end

Instance Attribute Details

#argsObject

include Heroku::Helpers



7
8
9
# File 'lib/extjs-xtheme/commands/base.rb', line 7

def args
  @args
end

#configObject (readonly)

Returns the value of attribute config.



8
9
10
# File 'lib/extjs-xtheme/commands/base.rb', line 8

def config
  @config
end

Instance Method Details

#askObject



28
29
30
# File 'lib/extjs-xtheme/commands/base.rb', line 28

def ask
	gets.strip
end

#display(msg, newline = true) ⇒ Object



15
16
17
18
19
20
21
22
# File 'lib/extjs-xtheme/commands/base.rb', line 15

def display(msg, newline=true)
	if newline
		puts(msg)
	else
		print(msg)
		STDOUT.flush
	end
end

#error(msg) ⇒ Object



24
25
26
# File 'lib/extjs-xtheme/commands/base.rb', line 24

def error(msg)
	ExtJS::XTheme::Command.error(msg)
end

#escape(value) ⇒ Object



70
71
72
# File 'lib/extjs-xtheme/commands/base.rb', line 70

def escape(value)
	heroku.escape(value)
end

#extract_app(force = true) ⇒ Object



40
41
42
43
44
45
46
47
48
# File 'lib/extjs-xtheme/commands/base.rb', line 40

def extract_app(force=true)
	app = extract_option('--app')
	unless app
		app = extract_app_in_dir(Dir.pwd) ||
		raise(CommandFailed, "No app specified.\nRun this command from app folder or set it adding --app <app name>") if force
		@autodetected_app = true
	end
	app
end

#extract_app_in_dir(dir) ⇒ Object



50
51
52
# File 'lib/extjs-xtheme/commands/base.rb', line 50

def extract_app_in_dir(dir)
	
end

#extract_option(options, default = true) ⇒ Object



54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# File 'lib/extjs-xtheme/commands/base.rb', line 54

def extract_option(options, default=true)
	values = options.is_a?(Array) ? options : [options]
	return unless opt_index = args.select { |a| values.include? a }.first
	opt_position = args.index(opt_index) + 1
	if args.size > opt_position && opt_value = args[opt_position]
		if opt_value.include?('--')
			opt_value = nil
		else
			args.delete_at(opt_position)
		end
	end
	opt_value ||= default
	args.delete(opt_index)
	block_given? ? yield(opt_value) : opt_value
end

#herokuObject



36
37
38
# File 'lib/extjs-xtheme/commands/base.rb', line 36

def heroku
	#@heroku ||= Heroku::Command.run_internal('auth:client', args)
end

#shell(cmd) ⇒ Object



32
33
34
# File 'lib/extjs-xtheme/commands/base.rb', line 32

def shell(cmd)
	FileUtils.cd(Dir.pwd) {|d| return `#{cmd}`}
end