From b6eec80060bb80c2bcda1c22c890baad06831c64 Mon Sep 17 00:00:00 2001 From: David Vargas Date: Thu, 1 Dec 2022 15:24:01 +0000 Subject: [PATCH] [U] . --- .../{02-nextcloud.rb => 02-nextcloud-test-conn.rb} | 2 -- bin/nextcloud/{04-user-info.rb => 03-show-user-info.rb} | 3 ++- bin/nextcloud/06-webdav.rb | 5 +++++ bin/nextcloud/lib.rb | 7 ++++++- 4 files changed, 13 insertions(+), 4 deletions(-) rename bin/nextcloud/{02-nextcloud.rb => 02-nextcloud-test-conn.rb} (81%) rename bin/nextcloud/{04-user-info.rb => 03-show-user-info.rb} (88%) diff --git a/bin/nextcloud/02-nextcloud.rb b/bin/nextcloud/02-nextcloud-test-conn.rb similarity index 81% rename from bin/nextcloud/02-nextcloud.rb rename to bin/nextcloud/02-nextcloud-test-conn.rb index e53d0aa..19e39bb 100755 --- a/bin/nextcloud/02-nextcloud.rb +++ b/bin/nextcloud/02-nextcloud-test-conn.rb @@ -11,7 +11,5 @@ nextcloud = Nextcloud.new( password: settings["PASSWORD"] ) -ocs = nextcloud.ocs -puts "* ocs.webdav.directory: #{ocs.webdav.directory}" webdav = nextcloud.webdav puts "* webdav.directory(@path): #{webdav.directory.instance_variable_get(:@path)}" diff --git a/bin/nextcloud/04-user-info.rb b/bin/nextcloud/03-show-user-info.rb similarity index 88% rename from bin/nextcloud/04-user-info.rb rename to bin/nextcloud/03-show-user-info.rb index 28dfca0..19d46d1 100755 --- a/bin/nextcloud/04-user-info.rb +++ b/bin/nextcloud/03-show-user-info.rb @@ -1,9 +1,10 @@ #!/usr/bin/env ruby require_relative "lib" +settings = get_settings() nextcloud = get_nextcloud_object() ocs = nextcloud.ocs -user = ocs.user.find("dvarrui") +user = ocs.user.find(settings["USERNAME"]) tags = %i(enabled id quota email displayname phone address website twitter groups language meta) diff --git a/bin/nextcloud/06-webdav.rb b/bin/nextcloud/06-webdav.rb index 0b3dc2d..90e0086 100755 --- a/bin/nextcloud/06-webdav.rb +++ b/bin/nextcloud/06-webdav.rb @@ -10,9 +10,14 @@ webdav = nextcloud.webdav path = webdav.directory.instance_variable_get(:@path) puts "* webdav.directory(@path): #{path}" + dir = "files_from_git" +binding.break result = webdav.directory.create(dir) puts result +result = webdav.directory.put("lib.rb", File.join(dir, "lib.rb")) +puts result + dir = webdav.directory.find puts dir.contents diff --git a/bin/nextcloud/lib.rb b/bin/nextcloud/lib.rb index 09bf4dc..4cc2f13 100644 --- a/bin/nextcloud/lib.rb +++ b/bin/nextcloud/lib.rb @@ -1,8 +1,13 @@ require "dotenv" require "nextcloud" +require "debug" + +def get_settings() + Dotenv.load +end def get_nextcloud_object - settings = Dotenv.load + settings = get_settings nextcloud = Nextcloud.new( url: settings["URL"], username: settings["USERNAME"],