Class: AppSendr::Command::App
Instance Attribute Summary collapse
-
#app ⇒ Object
Returns the value of attribute app.
-
#app_id ⇒ Object
Returns the value of attribute app_id.
-
#app_name ⇒ Object
Returns the value of attribute app_name.
Attributes inherited from Base
Instance Method Summary collapse
- #create ⇒ Object
- #link ⇒ Object
- #list ⇒ Object
- #list_apps_and_ask ⇒ Object
- #url ⇒ Object
- #versions ⇒ Object
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?, #is_file_to_large?, #message, #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?, #size_of_file
Constructor Details
This class inherits a constructor from AppSendr::Command::Base
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 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 |
# File 'lib/appsendr/commands/app.rb', line 20 def create # username = extract_option('--username') # display username # password = extract_option('--password') # display password # name = args.join(" ").strip error "You must include an app name" if name.empty? require_project_dir("add an app") if has_project_droppr? list = appsendr.list if list["message"].size > 0 list["message"].each{|app| if app['name'] == name remove_appsendr_dir make_appsendr_dir @app = [ app['id'], app['name']] write_app display "Your app has been linked." return end } resp = appsendr.create(name) remove_appsendr_dir make_appsendr_dir if resp['message'] @app = [resp['message']['id'],resp['message']['name']] write_app display "Your app has been created." else error "This app is linked to another account's app" end else 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 |
#link ⇒ Object
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 |
# File 'lib/appsendr/commands/app.rb', line 88 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 "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
109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 |
# File 'lib/appsendr/commands/app.rb', line 109 def list_apps_and_ask apps = [] lines = [] list = appsendr.list if list["message"].size > 0 "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
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
# File 'lib/appsendr/commands/app.rb', line 66 def url if in_project_dir? resp = appsendr.current_version(get_app_id) if resp["message"].size > 0 "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
132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 |
# File 'lib/appsendr/commands/app.rb', line 132 def versions if in_project_dir? groups = appsendr.versions(get_app_id) if groups["message"].size > 0 "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 |