lib/rabbit/slideshare.rb in rabbit-2.1.9 vs lib/rabbit/slideshare.rb in rabbit-2.2.0
- old
+ new
@@ -1,6 +1,6 @@
-# Copyright (C) 2012 Kouhei Sutou <kou@cozmixng.org>
+# Copyright (C) 2012-2016 Kouhei Sutou <kou@cozmixng.org>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
@@ -20,10 +20,11 @@
require "nokogiri"
require "faraday"
require "rabbit/gettext"
require "rabbit/command/rabbit"
+require "rabbit/password-reader"
module Rabbit
module Task
class SlideShare
class Error < StandardError
@@ -136,21 +137,16 @@
def upload_title
@id.gsub(/-/, " ")
end
def password
- @password ||= read_password(_("Enter password on SlideShare"))
+ @password ||= read_password
end
- def read_password(prompt)
- print("%s [%s]: " % [prompt, @user])
- system("/bin/stty -echo") if $stdin.tty?
- $stdin.gets.chomp
- ensure
- if $stdin.tty?
- system("/bin/stty echo")
- puts
- end
+ def read_password
+ prompt = _("Enter password on SlideShare [%{user}]: ") % {:user => @user}
+ reader = PasswordReader.new(prompt)
+ reader.read
end
def common_payload
timestamp = Time.now.to_i.to_s
{