From a73e0e7a0ba9d32bf1be7ad07e5acf5babf50b93 Mon Sep 17 00:00:00 2001 From: Trevor Vallender Date: Sat, 2 Mar 2024 14:50:16 +0000 Subject: [PATCH] Initial commit --- .ruby-version | 1 + Gemfile | 3 +++ Gemfile.lock | 29 +++++++++++++++++++++++++++++ MIT-LICENSE | 20 ++++++++++++++++++++ README.md | 4 ++++ bin/birthdaze | 5 +++++ birthdaze.gemspec | 14 ++++++++++++++ lib/birthdaze.rb | 27 +++++++++++++++++++++++++++ 8 files changed, 103 insertions(+) create mode 100644 .ruby-version create mode 100644 Gemfile create mode 100644 Gemfile.lock create mode 100644 MIT-LICENSE create mode 100644 README.md create mode 100755 bin/birthdaze create mode 100644 birthdaze.gemspec create mode 100644 lib/birthdaze.rb diff --git a/.ruby-version b/.ruby-version new file mode 100644 index 0000000..be94e6f --- /dev/null +++ b/.ruby-version @@ -0,0 +1 @@ +3.2.2 diff --git a/Gemfile b/Gemfile new file mode 100644 index 0000000..b4e2a20 --- /dev/null +++ b/Gemfile @@ -0,0 +1,3 @@ +source "https://rubygems.org" + +gemspec diff --git a/Gemfile.lock b/Gemfile.lock new file mode 100644 index 0000000..5f01b25 --- /dev/null +++ b/Gemfile.lock @@ -0,0 +1,29 @@ +PATH + remote: . + specs: + birthdaze (0.0.1) + carddav + thor + +GEM + remote: https://rubygems.org/ + specs: + carddav (0.1.0) + curb + nokogiri + vcardigan + curb (1.0.5) + nokogiri (1.16.2-x86_64-linux) + racc (~> 1.4) + racc (1.7.3) + thor (1.3.1) + vcardigan (0.0.9) + +PLATFORMS + x86_64-linux + +DEPENDENCIES + birthdaze! + +BUNDLED WITH + 2.4.10 diff --git a/MIT-LICENSE b/MIT-LICENSE new file mode 100644 index 0000000..a306f55 --- /dev/null +++ b/MIT-LICENSE @@ -0,0 +1,20 @@ +Copyright (c) 2023 David Heinemeier Hansson + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..de7a411 --- /dev/null +++ b/README.md @@ -0,0 +1,4 @@ +# Birthdaze + +Birthdaze is a tool to generate a calendar of your contacts’ birthdays +from a CardDAV server account. diff --git a/bin/birthdaze b/bin/birthdaze new file mode 100755 index 0000000..e4ae1d7 --- /dev/null +++ b/bin/birthdaze @@ -0,0 +1,5 @@ +#!/usr/bin/env ruby + +require 'birthdaze' + +Birthdaze.start(ARGV) diff --git a/birthdaze.gemspec b/birthdaze.gemspec new file mode 100644 index 0000000..33c85d7 --- /dev/null +++ b/birthdaze.gemspec @@ -0,0 +1,14 @@ +Gem::Specification.new do |s| + s.name = "birthdaze" + s.version = "0.0.1" + s.summary = "Generate a birthday calendar from CardDAV" + s.authors = ["T S Vallender"] + s.email = "t@tsvallender.co.uk" + s.homepage = "https://git.tsvallender.co.uk/tsv/birthdaze" + s.files = Dir["lib/**/*", "MIT-LICENSE", "README.md"] + s.license = "MIT" + s.executables << "birthdaze" + s.add_dependency "thor" + s.add_dependency "carddav" +end + diff --git a/lib/birthdaze.rb b/lib/birthdaze.rb new file mode 100644 index 0000000..e0f5855 --- /dev/null +++ b/lib/birthdaze.rb @@ -0,0 +1,27 @@ +require "carddav" +require "thor" +require "yaml" + +class Birthdaze < Thor + desc "generate", "Generate calendars" + def generate + puts "Generate calendars" + auth(config["url"], config["username"], config["password"]) + end + + private + + def config + config_file = "#{ENV["HOME"]}/.config/birthdaze.yaml" + unless File.file?(config_file) + puts "Please add a configuration file" + return + end + @config ||= YAML.load_file(config_file) + end + + def auth(url, username, password) + config + client = Carddav::Client.new(url, username, password) + end +end