Class: Linguist::Command::Base
- Inherits:
-
Object
- Object
- Linguist::Command::Base
show all
- Includes:
- Helpers
- Defined in:
- lib/linguist_ruby/commands/base.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Methods included from Helpers
#ask, #confirm, #confirm_command, #deprecate, #display, #error, #format_date, #git, #has_git?, #home_directory, #redisplay, #retry_on_exception, #run_command, #running_on_a_mac?, #running_on_windows?, #shell
Constructor Details
#initialize(args, linguist = nil) ⇒ Base
Returns a new instance of Base.
10
11
12
13
14
|
# File 'lib/linguist_ruby/commands/base.rb', line 10
def initialize(args, linguist=nil)
@args = args
@linguist = linguist
@autodetected_project_name = false
end
|
Instance Attribute Details
#args ⇒ Object
Returns the value of attribute args.
7
8
9
|
# File 'lib/linguist_ruby/commands/base.rb', line 7
def args
@args
end
|
#autodetected_app ⇒ Object
Returns the value of attribute autodetected_app.
8
9
10
|
# File 'lib/linguist_ruby/commands/base.rb', line 8
def autodetected_app
@autodetected_app
end
|
Instance Method Details
#app_urls(name) ⇒ Object
97
98
99
|
# File 'lib/linguist_ruby/commands/base.rb', line 97
def app_urls(name)
end
|
#escape(value) ⇒ Object
101
102
103
|
# File 'lib/linguist_ruby/commands/base.rb', line 101
def escape(value)
linguist.escape(value)
end
|
55
56
57
58
|
# File 'lib/linguist_ruby/commands/base.rb', line 55
def
remote = git("config heroku.remote")
remote == "" ? nil : remote
end
|
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
|
# File 'lib/linguist_ruby/commands/base.rb', line 77
def (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
|
30
31
32
33
34
|
# File 'lib/linguist_ruby/commands/base.rb', line 30
def
project_title = ('--project', false)
raise(CommandFailed, "You must specify a project title after --project") if project_title == false
project_title
end
|
36
37
38
39
|
# File 'lib/linguist_ruby/commands/base.rb', line 36
def
dir = Dir.pwd
File.basename(dir)
end
|
41
42
43
44
45
46
47
48
49
50
51
52
53
|
# File 'lib/linguist_ruby/commands/base.rb', line 41
def
dir = Dir.pwd
return unless remotes = git_remotes(dir)
if remote = ('--remote')
remotes[remote]
elsif remote =
remotes[remote]
else
apps = remotes.values.uniq
return apps.first if apps.size == 1
end
end
|
#git_remotes(base_dir = Dir.pwd) ⇒ Object
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
|
# File 'lib/linguist_ruby/commands/base.rb', line 60
def git_remotes(base_dir=Dir.pwd)
remotes = { }
original_dir = Dir.pwd
Dir.chdir(base_dir)
Dir.chdir(original_dir)
remotes
end
|
#git_url(name) ⇒ Object
93
94
95
|
# File 'lib/linguist_ruby/commands/base.rb', line 93
def git_url(name)
"git@#{heroku.host}:#{name}.git"
end
|
#linguist ⇒ Object
16
17
18
|
# File 'lib/linguist_ruby/commands/base.rb', line 16
def linguist
@linguist ||= Linguist::Command.run_internal('auth:client', args)
end
|
#project(title = nil) ⇒ Object
105
106
107
108
|
# File 'lib/linguist_ruby/commands/base.rb', line 105
def project(title=nil)
title ||= project_title
@project ||= linguist.project(title)
end
|
#project_title(force = true) ⇒ Object
20
21
22
23
24
25
26
27
28
|
# File 'lib/linguist_ruby/commands/base.rb', line 20
def project_title(force=true)
project_title =
unless project_title
project_title = || ||
raise(CommandFailed, "No project specified.\nRun this command from project folder or set it adding --project <title>") if force
@autodetected_project_name = true
end
project_title
end
|