diff --git a/lib/passwordstate.rb b/lib/passwordstate.rb index d9e0ea224a1693f595b6221fdaece4a2e66ae036..f1954213741c81de6b4199ab977ad2a87abeb6e0 100644 --- a/lib/passwordstate.rb +++ b/lib/passwordstate.rb @@ -1,7 +1,6 @@ # frozen_string_literal: true require 'logging' -require 'pp' require 'passwordstate/version' require 'passwordstate/client' require 'passwordstate/errors' diff --git a/lib/passwordstate/errors.rb b/lib/passwordstate/errors.rb index 2f4fd0208b2bc1419ea5550b9a8880936af6a1c2..8ebf62ea91fb2f4e1cd31773aaf535c5ee463367 100644 --- a/lib/passwordstate/errors.rb +++ b/lib/passwordstate/errors.rb @@ -15,7 +15,7 @@ module Passwordstate @errors = errors errorstr = errors.map { |err| err['message'] || err['phrase'] || err['error'] }.join('; ') - super "Passwordstate responded with an error to the request:\n#{errorstr}" + super("Passwordstate responded with an error to the request:\n#{errorstr}") end def self.new_by_code(code, req, res, errors = []) diff --git a/lib/passwordstate/resource.rb b/lib/passwordstate/resource.rb index 77a546735bc1af5f9824497e0017208321689c8a..2955714cf4f59259a715a739f32fa36398dcfebe 100644 --- a/lib/passwordstate/resource.rb +++ b/lib/passwordstate/resource.rb @@ -126,7 +126,7 @@ module Passwordstate nil_as_string = opts.fetch(:nil_as_string, self.class.nil_as_string) (self.class.send(:accessor_field_names) + self.class.send(:read_field_names) + self.class.send(:write_field_names)).to_h do |field| redact = self.class.send(:field_options)[field]&.fetch(:redact, false) && !ignore_redact - at_field = "@#{field}".to_sym + at_field = :"@#{field}" field = at_field if atify value = instance_variable_get(at_field) unless redact value = '[ REDACTED ]' if redact @@ -190,7 +190,7 @@ module Passwordstate parsed_value = convert.call(value, direction: :from) end - instance_variable_set "@#{field}".to_sym, parsed_value || value + instance_variable_set :"@#{field}", parsed_value || value end self end diff --git a/lib/passwordstate/resource_list.rb b/lib/passwordstate/resource_list.rb index 0a027222d4d2bb756e4eb794d96c6513057d6506..240826f6c95d5692bff6e51d176dafbebfcea78c 100644 --- a/lib/passwordstate/resource_list.rb +++ b/lib/passwordstate/resource_list.rb @@ -62,11 +62,11 @@ module Passwordstate end def operation_supported?(operation) - return nil unless %i[search all get post put delete].include?(operation) + return false unless %i[search all get post put delete].include?(operation) return false if options.key?(:only) && !options[:only].include?(operation) return false if options.key?(:except) && options[:except].include?(operation) - !options.fetch("#{operation}_path".to_sym, '').nil? + !options.fetch(:"#{operation}_path", '').nil? end def new(data) diff --git a/lib/passwordstate/resources/document.rb b/lib/passwordstate/resources/document.rb index 26deccabff1e807c19ac199a47a9c45a9b20fa0e..678cae3e2f670ed5d071adfdb2522a8f4cf69055 100644 --- a/lib/passwordstate/resources/document.rb +++ b/lib/passwordstate/resources/document.rb @@ -13,7 +13,7 @@ module Passwordstate alias title document_name def self.all(client, store, **query) - super client, query.merge(_api_path: "#{api_path}/#{validate_store! store}") + super(client, query.merge(_api_path: "#{api_path}/#{validate_store! store}")) end def self.search(client, store, **options) @@ -21,19 +21,19 @@ module Passwordstate end def self.get(client, store, object) - super client, object, _api_path: "#{api_path}/#{validate_store! store}" + super(client, object, _api_path: "#{api_path}/#{validate_store! store}") end def self.post(client, store, data, **query) - super client, data, query.merge(_api_path: "#{api_path}/#{validate_store! store}") + super(client, data, query.merge(_api_path: "#{api_path}/#{validate_store! store}")) end def self.put(client, store, data, **query) - super client, data, query.merge(_api_path: "#{api_path}/#{validate_store! store}") + super(client, data, query.merge(_api_path: "#{api_path}/#{validate_store! store}")) end def self.delete(client, store, object, **query) - super client, object, query.merge(_api_path: "#{api_path}/#{validate_store! store}") + super(client, object, query.merge(_api_path: "#{api_path}/#{validate_store! store}")) end class << self diff --git a/lib/passwordstate/resources/password.rb b/lib/passwordstate/resources/password.rb index 69b88fdbd69417631a2ba5532a3717f6b35f95ef..d5f58c275f41d262857a43d8670122fcf9451e2e 100644 --- a/lib/passwordstate/resources/password.rb +++ b/lib/passwordstate/resources/password.rb @@ -112,11 +112,13 @@ module Passwordstate end def self.all(client, **query) - super client, **{ query_all: true }.merge(query) + query = { query_all: true }.merge(query) + super(client, **query) end def self.search(client, **query) - super client, **{ _api_path: 'searchpasswords' }.merge(query) + query = { _api_path: 'searchpasswords' }.merge(query) + super(client, **query) end def self.generate(client, **options) diff --git a/lib/passwordstate/resources/password_list.rb b/lib/passwordstate/resources/password_list.rb index 39f0e9b6dc53324e447117c92ce2278eeac7ec8a..3160d41e0eb1dc648388ddde40823dc040a91fec 100644 --- a/lib/passwordstate/resources/password_list.rb +++ b/lib/passwordstate/resources/password_list.rb @@ -70,7 +70,7 @@ module Passwordstate alias title password_list def self.search(client, **query) - super client, **query.merge(_api_path: 'searchpasswordlists') + super(client, **query.merge(_api_path: 'searchpasswordlists')) end def passwords