1
0
Fork 0
mirror of https://github.com/nishiki/manage-password.git synced 2025-02-21 10:20:05 +00:00

fix syntax for options in method

This commit is contained in:
Adrien Waksberg 2017-03-30 19:40:04 +02:00
parent 002ec2175b
commit 3c787371b3
3 changed files with 8 additions and 8 deletions

View file

@ -218,7 +218,7 @@ class Cli
# Display the query's result # Display the query's result
# @args: options -> the option to search # @args: options -> the option to search
def list(options = {}) def list(**options)
result = @mpw.list(options) result = @mpw.list(options)
if result.empty? if result.empty?
@ -406,7 +406,7 @@ class Cli
# Update an item # Update an item
# @args: password -> generate a random password # @args: password -> generate a random password
# options -> the option to search # options -> the option to search
def update(password = false, options = {}) def update(password = false, **options)
items = @mpw.list(options) items = @mpw.list(options)
if items.empty? if items.empty?
@ -431,7 +431,7 @@ class Cli
# Remove an item # Remove an item
# @args: options -> the option to search # @args: options -> the option to search
def delete(options = {}) def delete(**options)
items = @mpw.list(options) items = @mpw.list(options)
if items.empty? if items.empty?
@ -456,7 +456,7 @@ class Cli
# Copy a password, otp, login # Copy a password, otp, login
# @args: clipboard -> enable clipboard # @args: clipboard -> enable clipboard
# options -> the option to search # options -> the option to search
def copy(clipboard = true, options = {}) def copy(clipboard = true, **options)
items = @mpw.list(options) items = @mpw.list(options)
if items.empty? if items.empty?

View file

@ -35,7 +35,7 @@ class Item
# Create a new item # Create a new item
# @args: options -> a hash of parameter # @args: options -> a hash of parameter
# raise an error if the hash hasn't the key name # raise an error if the hash hasn't the key name
def initialize(options = {}) def initialize(**options)
if !options.key?(:host) || options[:host].to_s.empty? if !options.key?(:host) || options[:host].to_s.empty?
raise I18n.t('error.update.host_empty') raise I18n.t('error.update.host_empty')
end end
@ -55,7 +55,7 @@ class Item
# Update the item # Update the item
# @args: options -> a hash of parameter # @args: options -> a hash of parameter
def update(options = {}) def update(**options)
if options.key?(:host) && options[:host].to_s.empty? if options.key?(:host) && options[:host].to_s.empty?
raise I18n.t('error.update.host_empty') raise I18n.t('error.update.host_empty')
end end

View file

@ -223,7 +223,7 @@ class MPW
# Set config # Set config
# args: config -> a hash with config options # args: config -> a hash with config options
def set_config(options = {}) def set_config(**options)
@config = {} if @config.nil? @config = {} if @config.nil?
@config['protocol'] = options[:protocol] if options.key?(:protocol) @config['protocol'] = options[:protocol] if options.key?(:protocol)
@ -246,7 +246,7 @@ class MPW
# Search in some csv data # Search in some csv data
# @args: options -> a hash with paramaters # @args: options -> a hash with paramaters
# @rtrn: a list with the resultat of the search # @rtrn: a list with the resultat of the search
def list(options = {}) def list(**options)
result = [] result = []
search = options[:pattern].to_s.downcase search = options[:pattern].to_s.downcase