Module: Atlantis::Portal::Helpers

Defined in:
lib/Atlantis/portal/helpers.rb

Instance Method Summary collapse

Instance Method Details

#agentObject



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/Atlantis/portal/helpers.rb', line 19

def agent
  unless @agent
    @agent = Atlantis::Portal::Agent.new

    @agent.instance_eval do
      def username
        @username ||= ask "Username:"
      end

      def password
        @password ||= pw "Password:"
      end
    end
  end

  @agent
end

#pluralize(n, singular, plural = nil) ⇒ Object



37
38
39
# File 'lib/Atlantis/portal/helpers.rb', line 37

def pluralize(n, singular, plural = nil)
  n.to_i == 1 ? "1 #{singular}" : "#{n} #{plural || singular + 's'}"
end

#tryObject



41
42
43
44
45
46
47
48
49
# File 'lib/Atlantis/portal/helpers.rb', line 41

def try
  return unless block_given?

  begin
    yield
  rescue UnsuccessfulAuthenticationError
    say_error "Could not authenticate with TestFlight. Check that your username & password are correct, and that your membership is valid and all pending Terms of Service & agreements are accepted. If this problem continues, try logging into https://testflightapp.com/ from a browser to see what's going on." and abort
  end
end