From 8ba9fb73ad6c784d236dcccecfe022007a7cce18 Mon Sep 17 00:00:00 2001 From: Silvio Rhatto Date: Tue, 1 Feb 2011 11:51:26 -0200 Subject: Removing Keyringer::Checker and adding ls action --- bin/keyringer | 1 - lib/keyring/user_config.rb | 10 +++++++++- lib/keyringer.rb | 2 +- lib/keyringer/actions/ls.rb | 30 ++++++++++++++++++++++++++++++ lib/keyringer/checker.rb | 28 ---------------------------- 5 files changed, 40 insertions(+), 31 deletions(-) create mode 100644 lib/keyringer/actions/ls.rb delete mode 100644 lib/keyringer/checker.rb diff --git a/bin/keyringer b/bin/keyringer index 47e5986..fa569ff 100755 --- a/bin/keyringer +++ b/bin/keyringer @@ -25,7 +25,6 @@ require 'keyringer' begin Keyringer::Parser.new - Keyringer::Checker.new puts "Performing action #{$action.capitalize}" begin action = Keyringer::Actions.const_get($action.capitalize) diff --git a/lib/keyring/user_config.rb b/lib/keyring/user_config.rb index aaf79aa..21a8c33 100644 --- a/lib/keyring/user_config.rb +++ b/lib/keyring/user_config.rb @@ -23,10 +23,14 @@ module Keyring include Singleton def initialize + self.load + self.check + end + + def load @user_config = ENV['HOME'] + '/.keyringer/config' @keyrings = Backend::parse_config(@user_config) @path = @keyrings.get_value($keyring) - raise "No path configuration for #{$keyring} keyring." if @path.nil? end def keyrings @@ -36,5 +40,9 @@ module Keyring def path @path end + + def check + raise "No keydir configured for #{$keyring} keyring." if @path.nil? + end end end diff --git a/lib/keyringer.rb b/lib/keyringer.rb index f271dd1..b8d4595 100644 --- a/lib/keyringer.rb +++ b/lib/keyringer.rb @@ -26,11 +26,11 @@ $:.unshift File.dirname(__FILE__) require 'keyring' require 'keyringer/bash_wrapper' require 'keyringer/parser' -require 'keyringer/checker' require 'keyringer/console' require 'keyringer/actions/decrypt' require 'keyringer/actions/recipients' require 'keyringer/actions/init' +require 'keyringer/actions/ls' module Keyringer VERSION = '2.0-alpha' diff --git a/lib/keyringer/actions/ls.rb b/lib/keyringer/actions/ls.rb new file mode 100644 index 0000000..6f295ad --- /dev/null +++ b/lib/keyringer/actions/ls.rb @@ -0,0 +1,30 @@ +#!/usr/bin/env ruby +# +# Keyringer secret management system. +# +# Copyright (C) 2011 Keyringer Development Team. +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# + +module Keyringer + module Actions + class Ls + def execute + path = Keyring::UserConfig.instance.path + Dir.entries(path + '/keys').join(' ') + end + end + end +end diff --git a/lib/keyringer/checker.rb b/lib/keyringer/checker.rb deleted file mode 100644 index 5369b95..0000000 --- a/lib/keyringer/checker.rb +++ /dev/null @@ -1,28 +0,0 @@ -#!/usr/bin/env ruby -# -# Keyringer secret management system. -# -# Copyright (C) 2011 Keyringer Development Team. -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU Affero General Public License as -# published by the Free Software Foundation, either version 3 of the -# License, or any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public License -# along with this program. If not, see . -# - -module Keyringer - class Checker - def initialize - path = Keyring::UserConfig.instance.path - raise "No path configuration for #{$keyring} keyring." if path.nil? - end - end -end -- cgit v1.2.3