Class: AppSendr::Command::Testers

Inherits:
Base
  • Object
show all
Defined in:
lib/appsendr/commands/testers.rb

Instance Attribute Summary

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?, #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 Method Details

#addObject



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/appsendr/commands/testers.rb', line 33

def add
    
    if require_project(2,"add testers","an email and name", true)
        email = args.shift.strip
        name = args.join(" ").strip

        begin 
        response = appsendr.add_tester(read_app_id,email,name)
        message "#{email} added"
        
        rescue RestClient::RequestFailed => e
            message "Errors"
            response = JSON.parse(e.http_body)
            response['message'].each{|err|
                display err.join(" ")
            }
        end
        
    end
end

#clearObject



63
64
65
66
67
68
69
# File 'lib/appsendr/commands/testers.rb', line 63

def clear
    if require_project(0,"clear testers",nil)
        message "Removing all testers"
        appsendr.add_tester(read_app_id)
        
    end
end

#devicesObject



81
82
83
84
85
86
87
88
89
90
91
92
93
94
# File 'lib/appsendr/commands/testers.rb', line 81

def devices
    all = option_exists?('--all', false)
    
    if require_project(0,nil,nil)
        message "Devices"
        app_id = read_app_id unless all
        @remote_devices = appsendr.devices(app_id,false)
        devices = @remote_devices['message']['Device UDIDs']
        devices.each{|device|
            puts device.to_yaml
        }
    end
    
end

#indexObject

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

#notifyObject



71
72
73
74
75
76
77
78
79
# File 'lib/appsendr/commands/testers.rb', line 71

def notify
    if require_project(0,"clear testers",nil)
        require_project_droppr
        message "Notifying testers"
        group = args.join(" ").strip
        
        appsendr.notify(read_app_id,group)
    end          
end

#removeObject



54
55
56
57
58
59
60
61
# File 'lib/appsendr/commands/testers.rb', line 54

def remove
    if require_project(1,"remove testers","an email")
        entered_email = args.shift.strip
        appsendr.remove_tester(read_app_id,entered_email)
        message "Removed tester"
        
    end
end