Class: AppSendr::Command::App
- Inherits:
-
Base
- Object
- Base
- AppSendr::Command::App
show all
- Defined in:
- lib/appsendr/commands/app.rb
Instance Attribute Summary collapse
Attributes inherited from Base
#args, #autodetected_app
Instance Method Summary
collapse
Methods inherited from Base
#appsendr, #ask, #confirm, #extract_app, #extract_option, #format_date, #initialize, #option_exists?
Methods included from Helpers
#credentials_file, #credentials_setup?, #display, #error, #has_project_droppr?, #home_directory, #in_project_dir?, #project_appsendr, #project_appsendr_app, #read_app, #read_app_id, #require_in_project_and_no_droppr, #require_project, #require_project_dir, #require_project_droppr, #running_on_a_mac?, #running_on_windows?
Instance Attribute Details
#app ⇒ Object
Returns the value of attribute app.
5
6
7
|
# File 'lib/appsendr/commands/app.rb', line 5
def app
@app
end
|
#app_id ⇒ Object
Returns the value of attribute app_id.
5
6
7
|
# File 'lib/appsendr/commands/app.rb', line 5
def app_id
@app_id
end
|
#app_name ⇒ Object
Returns the value of attribute app_name.
5
6
7
|
# File 'lib/appsendr/commands/app.rb', line 5
def app_name
@app_name
end
|
Instance Method Details
#create ⇒ Object
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
# File 'lib/appsendr/commands/app.rb', line 20
def create
if require_in_project_and_no_droppr(1,"an app name","a name to create an app on appsendr",true)
name = args.join(" ").strip
resp = appsendr.create(name)
make_appsendr_dir if resp['message']
@app = [resp['message']['id'],resp['message']['name']]
write_app
display "Your app has been created."
end
end
|
#groups ⇒ Object
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
|
# File 'lib/appsendr/commands/app.rb', line 104
def groups
if in_project_dir?
groups = appsendr.groups(get_app_id)
if groups["message"].size > 0
display "=== Your groups"
i = 0
display groups["message"].map {|app, id|
"#{i+=1}. #{app['name'].ljust(35)}"
}.join("\n")
else
display "You have no groups."
end
else
error("You are not in a project directory")
end
end
|
#link ⇒ Object
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
|
# File 'lib/appsendr/commands/app.rb', line 60
def link
if in_project_dir?
error "This app is already linked to an appsendr." unless !has_project_droppr?
app = list_apps_and_ask
return unless app
link = appsendr.link(app['id'])
make_appsendr_dir if link
name = link['message']['name'] || app['name']
aid = link['message']['id'] || app['id']
@app = [aid,name]
write_app
display "Your app has been linked."
else
error("You are not in a project directory")
end
end
|
#list ⇒ Object
7
8
9
10
11
12
13
14
15
16
17
18
|
# File 'lib/appsendr/commands/app.rb', line 7
def list
list = appsendr.list
if list["message"].size > 0
display "=== Your apps"
i = 0
display list["message"].map {|app, id|
"#{i+=1}. #{app['name'].ljust(35)}"
}.join("\n")
else
display "You have no apps."
end
end
|
#list_apps_and_ask ⇒ Object
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
|
# File 'lib/appsendr/commands/app.rb', line 81
def list_apps_and_ask
apps = []
lines = []
list = appsendr.list
if list["message"].size > 0
display "=== Your apps"
i = 0
list["message"].each{|app|
apps.push({"name"=>app['name'], "id"=>app['id']})
lines.push("#{i+=1}. #{app['name'].ljust(35)}")
}
display lines.join("\n")
print "\n"
print "Enter the # for the app you wish to link to: "
app_number = ask
return apps[app_number.to_i-1]
else
display "You have no apps."
end
end
|
#url ⇒ Object
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
# File 'lib/appsendr/commands/app.rb', line 38
def url
if in_project_dir?
resp = appsendr.current_version(get_app_id)
if resp["message"].size > 0
display "=== Your last install url is:"
url = resp["message"][0]['install_url']
display url
do_copy = option_exists?('--copy', false)
if do_copy
display "Copied URL"
IO.popen('pbcopy', 'w') { |clipboard| clipboard.write url }
end
else
display "No versions available"
end
else
error("You are not in a project directory")
end
end
|
#versions ⇒ Object
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
|
# File 'lib/appsendr/commands/app.rb', line 123
def versions
if in_project_dir?
groups = appsendr.versions(get_app_id)
if groups["message"].size > 0
display "=== Your versions"
i = 0
display groups["message"].map {|app, id|
"#{i+=1}. #{app['notes']} #{app['install_url']}"
}.join("\n")
else
display "You have no version."
end
else
error("You are not in a project directory")
end
end
|