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.6.8 lib/flydata/command/login.rb
flydata-0.6.7 lib/flydata/command/login.rb
flydata-0.6.6 lib/flydata/command/login.rb
flydata-0.6.5 lib/flydata/command/login.rb
flydata-0.6.4 lib/flydata/command/login.rb
flydata-0.6.3 lib/flydata/command/login.rb
flydata-0.6.2 lib/flydata/command/login.rb
flydata-0.6.1 lib/flydata/command/login.rb
flydata-0.6.0 lib/flydata/command/login.rb
flydata-0.5.21 lib/flydata/command/login.rb
flydata-0.5.20 lib/flydata/command/login.rb
flydata-0.5.17 lib/flydata/command/login.rb
flydata-0.5.16 lib/flydata/command/login.rb
flydata-0.5.15 lib/flydata/command/login.rb
flydata-0.5.14 lib/flydata/command/login.rb
flydata-0.5.13 lib/flydata/command/login.rb
flydata-0.5.12 lib/flydata/command/login.rb
flydata-0.5.11 lib/flydata/command/login.rb
flydata-0.5.10 lib/flydata/command/login.rb
flydata-0.5.9 lib/flydata/command/login.rb