Sha256: 9d49937748c2f04eabceed6b19a159cb701484501e49f66c20f618c7d1b75267

Contents?: true

Size: 768 Bytes

Versions: 92

Compression:

Stored size: 768 Bytes

Contents

require 'flydata/command/base'

module Flydata
  module Command
    class Login < Base
      LOGIN_TRIAL_TIMES=3
      def run
        ret = login(LOGIN_TRIAL_TIMES)
        raise "Login failed #{LOGIN_TRIAL_TIMES} times." unless ret
        ret
      end

      private
      def login(times=3)
        1.upto(times) do |i|
          begin
            return true if login_once
          rescue Exception => e
            puts e
          end
        end
        false
      end
      def login_once
        email = ask("FlyData Email:  ")
        password = ask("FlyData password:  ") {|q| q.echo = false}
        flydata.post('/users/sign_in', {:user => email, :password =>password})
        puts 'Thank you for logging in'
        true
      end
    end
  end
end

Version data entries

92 entries across 92 versions & 1 rubygems

Version Path
flydata-0.8.10.2 lib/flydata/command/login.rb
flydata-0.8.10.1 lib/flydata/command/login.rb
flydata-0.8.9.11 lib/flydata/command/login.rb
flydata-0.8.10 lib/flydata/command/login.rb
flydata-0.8.9 lib/flydata/command/login.rb
flydata-0.8.8 lib/flydata/command/login.rb
flydata-0.8.7 lib/flydata/command/login.rb
flydata-0.8.6 lib/flydata/command/login.rb
flydata-0.8.5 lib/flydata/command/login.rb
flydata-0.8.4 lib/flydata/command/login.rb
flydata-0.8.3 lib/flydata/command/login.rb
flydata-0.8.2 lib/flydata/command/login.rb
flydata-0.8.1 lib/flydata/command/login.rb
flydata-0.8.0 lib/flydata/command/login.rb
flydata-0.7.19 lib/flydata/command/login.rb
flydata-0.7.18 lib/flydata/command/login.rb
flydata-0.7.17 lib/flydata/command/login.rb
flydata-0.7.16 lib/flydata/command/login.rb
flydata-0.7.15 lib/flydata/command/login.rb
flydata-0.7.14 lib/flydata/command/login.rb