I have a Ruby script that I have developed that searches through an internal system we use through it's API.
When I run the script in the terminal by calling:
ruby search.rb "TEST"
it runs just fine and I get the list of results I would expect, in the XML format to be passed to Alfred.
However when I call the script from Alfred:
ruby search.rb "{query}"
I type the keyword "S" and it shows the proper placeholder Title (so I know the keyword worked). However, as soon as I start to type the query text it just goes to the default search items (e.g. Search Google for....). It never shows the "Please Wait Subtext...."
Has anyone encountered this issue or am I missing something critical? Any help would be greatly appreciated.
Also as an aside I'm not sure I understand the purpose of the two steps in the sample "Script Filter To Notification" workflow. What is the "Script Filter" step doing different form the "Run Script" step?
Thanks in advance for any help...
Here's a picture of my workflow:
I have pasted as much of the script below as I can (it has some proprietary info in it so I can't share the full script), but I don't think i have omitted any critical information. If there are any specific questions about certain parts of the missing scripts, I'll share what I can.
$logger = Yell.new "Alfred Logger", :level => :error
$search = ARGV[0].to_s.gsub("\\","")
.......
$logger.info "#{$search} was passed in as search paramater"
def xmlPackage(items)
resultXML = Builder::XmlMarkup.new(:target => $output,:indent => 2)
resultXML.instruct!
resultXML.items do
items.each do |item|
resultXML.item(:uid=>"suggest {query}",:arg=>item.arg) {
resultXML.title item.title
resultXML.subtitle item.subtitle
resultXML.icon item.icon
resultXML.valid item.valid
}
end
end
end
Login = Struct.new( :url, :user, :password)
sessions = ...login paramateres......
items = []
newSessions = []
sessions.each_with_index do |session,index|
$logger.info "checking session to #{session.url}: #{$sessions[index]}"
$url = "https://#{session.url}/api"
qUrl = $url + "&search=#{$search}&returnlimits=20"
results = JSON.parse(RestClient.get qUrl,:authorization=>$sessions[index],:content_type => :json, :accept => :json)
if results["responseStatus"].eql? "FAILURE"
....address common failure cause....
end
$logger.info "Creating XML for session #{session.url} #{$session}"
results["documents"].each_with_index do |result,index|
icon = getIcon(result["document"]["format__v"].to_s)
arg = .......
title = ....Title....
subtitle = arg.to_s
$logger.info "Found item: #{title}"
items << Item.new(arg,title,subtitle,icon,"yes")
end
$logger.info "XML created for session #{session.url}"
newSessions << $session
end
...cycles through multiple sessions....
puts xmlPackage(items)