lib/arii/helper.rb in arii-1.2.1 vs lib/arii/helper.rb in arii-1.2.2
- old
+ new
@@ -1,6 +1,5 @@
-
module ARII
##
# = Helper Class
# => Miscellaneous helper methods and utils to deal with data.
@@ -9,11 +8,11 @@
attr_accessor :replacements
@replacements
def initialize
# load each helper function into a map for replacement in the delivery
- @replacements = [ ["%{ARII.date}", self.date], ["%{ARII.datetime}", self.datetime], ["%{ARII.hostname}", self.hostname]]
+ @replacements = [["%{ARII.date}", self.date], ["%{ARII.datetime}", self.datetime], ["%{ARII.hostname}", self.hostname]]
end
public
def hostname
ENV["APP_HOST"]
@@ -53,45 +52,45 @@
#
# + *publisher* - for publisher-specific validations
# + *payload* - content for validation
#
def self.validate_payload publisher, payload
- @database_servers = ["mysql","sqlite","postgresql"]
+ @database_servers = ["mysql", "sqlite", "postgresql"]
valid = true
begin
case publisher
- when 'csv', 'xml', 'json', 'file', 'js'
- # file content URI is mandatory
- if payload[:uri].nil? then
- valid = false
- end
- when 'sql'
+ when 'csv', 'xml', 'json', 'file', 'js'
+ # file content URI is mandatory
+ if payload[:uri].nil? then
+ valid = false
+ end
+ when 'sql'
- # check if database server is available
- unless database_servers.include? payload[:server] then
- valid = false
- end
+ # check if database server is available
+ unless database_servers.include? payload[:server] then
+ valid = false
+ end
- # database username is mandatory
- if payload[:username].nil? then
- valid = false
- end
+ # database username is mandatory
+ if payload[:username].nil? then
+ valid = false
+ end
- # database user password is mandatory
- if payload[:password].nil? then
- valid = false
- end
+ # database user password is mandatory
+ if payload[:password].nil? then
+ valid = false
+ end
- # database name is mandatory
- if payload[:database].nil? then
- valid = false
- end
+ # database name is mandatory
+ if payload[:database].nil? then
+ valid = false
+ end
- # database query is mandatory
- if payload[:query].nil? then
- valid = false
- end
+ # database query is mandatory
+ if payload[:query].nil? then
+ valid = false
+ end
end
rescue Exception => e
end
valid
\ No newline at end of file