Class: AppSendr::Command::Testers
- Defined in:
- lib/appsendr/commands/testers.rb
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
- #add ⇒ Object
- #clear ⇒ Object
-
#index ⇒ Object
output testers.
- #notify ⇒ Object
- #remove ⇒ 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?, #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?
Constructor Details
This class inherits a constructor from AppSendr::Command::Base
Instance Method Details
#add ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/appsendr/commands/testers.rb', line 33 def add if require_project(2,"add testers","an email and name", true) f = testers_file_append return unless f email = args.shift.strip name = args.join(" ").strip f.puts "#{email},#{name}" f.close begin response = appsendr.add_tester(read_app_id,email,name) rescue RestClient::RequestFailed => e display "=== Errors" response = JSON.parse(e.http_body) response['message'].each{|err| display err.join(" ") } end end end |
#clear ⇒ Object
82 83 84 85 86 87 88 89 90 91 |
# File 'lib/appsendr/commands/testers.rb', line 82 def clear if require_project(0,"clear testers",nil) f = testers_file_truncate return unless f f.close appsendr.add_tester(read_app_id) end end |
#index ⇒ Object
output testers
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/appsendr/commands/testers.rb', line 3 def index #output testers if in_project_dir? unless has_project_droppr? require_project_droppr return end testers = appsendr.testers(read_app_id) if testers["message"].size > 0 display "=== Your testers" i = 0 display testers["message"].map {|app, id| "#{i+=1}. #{app['name']} - #{app['email']}" }.join("\n") else display "You have no testers." end # f = testers_file # return unless f # display "=== Testers" # f.each do |line| # tester = line.split(',') # email = tester.first.strip # display "#{email},#{name}" # end # f.close end end |
#notify ⇒ Object
93 94 95 96 97 98 |
# File 'lib/appsendr/commands/testers.rb', line 93 def notify require_project_dir("to notify testers") require_project_droppr appsendr.notify(read_app_id) end |
#remove ⇒ Object
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 |
# File 'lib/appsendr/commands/testers.rb', line 55 def remove if require_project(1,"remove testers","an email") entered_email = args.shift.strip f = testers_file return unless f out = "" found_email = nil f.each do |line| tester = line.split(',') email = tester.first.strip if email == entered_email found_email = email out << "" else out << line end end f.pos = 0 f.print out f.truncate(f.pos) appsendr.remove_tester(read_app_id,entered_email) end end |