From e8a2b9fba1b08b1a6f25129a648cd8aa2545b68c Mon Sep 17 00:00:00 2001 From: Tatsuki Sugiura Date: Wed, 16 Mar 2016 19:55:31 +0900 Subject: [PATCH] Move digest calc to base class. --- lib/osdn/cli.rb | 12 ++++++++++++ lib/osdn/cli/command/frs_upload.rb | 11 ----------- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/lib/osdn/cli.rb b/lib/osdn/cli.rb index 66b8c64..631a07d 100644 --- a/lib/osdn/cli.rb +++ b/lib/osdn/cli.rb @@ -167,6 +167,18 @@ module OSDN def update_variables(dir, vars) write_variables(load_variables(dir, false).merge(vars), dir) end + + private + def hexdigest(klass, file) + fio = file.open + dig = klass.new + while buf = fio.read(1024*1024) and buf.length > 0 + dig << buf + end + fio.close + dig.hexdigest + end + end class Ping < Base diff --git a/lib/osdn/cli/command/frs_upload.rb b/lib/osdn/cli/command/frs_upload.rb index f28fd80..3832c96 100644 --- a/lib/osdn/cli/command/frs_upload.rb +++ b/lib/osdn/cli/command/frs_upload.rb @@ -149,16 +149,5 @@ module OSDN; module CLI; module Command def api OSDNClient::ProjectApi.new end - - def hexdigest(klass, file) - fio = file.open - dig = klass.new - while buf = fio.read(1024*1024) and buf.length > 0 - dig << buf - end - fio.close - dig.hexdigest - end - end end; end; end -- 2.11.0