Use boolean comparators where it makes sense
This commit is contained in:
parent
dbdc7ae4aa
commit
118886344a
28 changed files with 60 additions and 60 deletions
|
|
@ -23,7 +23,7 @@ namespace :deploy do
|
|||
task :config => ['deploy:set_rails_env'] do
|
||||
require 'securerandom'
|
||||
on roles(:app), in: :groups do
|
||||
db_name = (fetch(:db_user) or fetch(:application))
|
||||
db_name = fetch(:db_user) || fetch(:application)
|
||||
db_passwd = SecureRandom.urlsafe_base64(24).to_s
|
||||
db_yaml = {
|
||||
fetch(:rails_env).to_s => {
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ namespace :enable_plugins do
|
|||
text = capture :cat, shared_path.join('config/plugins.yml'), '||true'
|
||||
if text
|
||||
plugins = YAML.load(text)
|
||||
enable_foodsoft_plugins(plugins['enabled']) if plugins and not plugins['enabled'].nil?
|
||||
enable_foodsoft_plugins(plugins['enabled']) if plugins && !plugins['enabled'].nil?
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ namespace :resque do
|
|||
on roles(:resque), in: :groups do
|
||||
|
||||
SSHKit.config.command_map[:rake_as_run_user] =
|
||||
unless fetch(:run_user).nil? or fetch(:run_user) == fetch(:user)
|
||||
unless fetch(:run_user).nil? || fetch(:run_user) == fetch(:user)
|
||||
"sudo -u '#{fetch(:run_user)}' "
|
||||
else
|
||||
''
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ module DateTimeAttributeValidate
|
|||
if self.instance_variable_get("@#{attribute}_is_set")
|
||||
date = self.instance_variable_get("@#{attribute}_date_value")
|
||||
time = self.instance_variable_get("@#{attribute}_time_value")
|
||||
if date.blank? and time.blank?
|
||||
if date.blank? && time.blank?
|
||||
self.send("#{attribute}=", nil)
|
||||
end
|
||||
end
|
||||
|
|
@ -50,11 +50,11 @@ module DateTimeAttributeValidate
|
|||
# validate date and time
|
||||
define_method("#{attribute}_datetime_value_valid") do
|
||||
date = self.instance_variable_get("@#{attribute}_date_value")
|
||||
unless date.blank? or (Date.parse(date) rescue nil)
|
||||
unless date.blank? || (Date.parse(date) rescue nil)
|
||||
errors.add(attribute, "is not a valid date") # @todo I18n
|
||||
end
|
||||
time = self.instance_variable_get("@#{attribute}_time_value")
|
||||
unless time.blank? or (Time.parse(time) rescue nil)
|
||||
unless time.blank? || (Time.parse(time) rescue nil)
|
||||
errors.add(attribute, "is not a valid time") # @todo I18n
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -94,7 +94,7 @@ class FoodsoftConfig
|
|||
# @param key [String, Symbol]
|
||||
# @return [Object] Value of the key.
|
||||
def [](key)
|
||||
if RailsSettings::CachedSettings.table_exists? and allowed_key?(key)
|
||||
if RailsSettings::CachedSettings.table_exists? && allowed_key?(key)
|
||||
value = RailsSettings::CachedSettings["foodcoop.#{self.scope}.#{key}"]
|
||||
value = config[key] if value.nil?
|
||||
value
|
||||
|
|
@ -113,7 +113,7 @@ class FoodsoftConfig
|
|||
return false unless allowed_key?(key)
|
||||
value = normalize_value value
|
||||
# then update database
|
||||
if config[key] == value or (config[key].nil? and value == false)
|
||||
if config[key] == value || (config[key].nil? && value == false)
|
||||
# delete (ok if it was already deleted)
|
||||
begin
|
||||
RailsSettings::CachedSettings.destroy "foodcoop.#{self.scope}.#{key}"
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ module FoodsoftDateUtil
|
|||
# @todo handle ical parse errors
|
||||
occ = (schedule.next_occurrence(from).to_time rescue nil)
|
||||
end
|
||||
if occ and options[:time]
|
||||
if occ && options[:time]
|
||||
occ = occ.beginning_of_day.advance(seconds: Time.parse(options[:time]).seconds_since_midnight)
|
||||
end
|
||||
occ
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ namespace :foodsoft do
|
|||
if tg.has_next_task?
|
||||
create_until = Date.today + FoodsoftConfig[:tasks_upfront_days].to_i + 1
|
||||
rake_say "creating until #{create_until}"
|
||||
while tg.next_task_date.nil? or tg.next_task_date < create_until
|
||||
while tg.next_task_date.nil? || tg.next_task_date < create_until
|
||||
tg.create_next_task
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -126,7 +126,7 @@ end
|
|||
def ask(question, answers = false)
|
||||
puts question
|
||||
input = STDIN.gets.chomp
|
||||
if input.blank? or (answers and !answers.include?(input))
|
||||
if input.blank? || (answers && !answers.include?(input))
|
||||
puts red "Your Input is not valid. Try again!"
|
||||
input = ask(question, answers)
|
||||
end
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ class TokenVerifier < ActiveSupport::MessageVerifier
|
|||
|
||||
def verify(message)
|
||||
r = super(message)
|
||||
raise InvalidMessage unless r.is_a?(Array) and r.length >= 2 and r.length <= 3
|
||||
raise InvalidMessage unless r.is_a?(Array) && r.length >= 2 && r.length <= 3
|
||||
raise InvalidScope unless r[0] == FoodsoftConfig.scope
|
||||
raise InvalidPrefix unless r[1] == @_prefix
|
||||
# return original message
|
||||
|
|
@ -34,7 +34,7 @@ class TokenVerifier < ActiveSupport::MessageVerifier
|
|||
|
||||
def self.secret
|
||||
# secret_key_base for Rails 4, but Rails 3 initializer may still be used
|
||||
Foodsoft::Application.config.secret_key_base or Foodsoft::Application.config.secret_token
|
||||
Foodsoft::Application.config.secret_key_base || Foodsoft::Application.config.secret_token
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue