#!/usr/bin/env ruby
#
# NOTE: Make sure the selected Feed in Feeder is the one you want to add to
#
# --file needs to be full path to file
# --shortVersion is the human readable / marketing version - aka 1.0, 2.0, etc
# --longVersion is what sparkle checks... aka 1.0_123
#
# www.nickbrawn.com // Nick Brawn
require 'optparse'
require 'osx/cocoa'
options = {}
def feeder(filename, shortVersion, longVersion)
include OSX
OSX.require_framework 'ScriptingBridge'
feeder = SBApplication.applicationWithBundleIdentifier_("com.reinvented.Feeder")
print "#{feeder.selectedFeed.name}\n"
selectedFeed = feeder.selectedFeed
print "#{filename}, #{shortVersion}\n\n\n"
p = {}
p["itemTitle"] = "New Build Available (#{longVersion})"
p['enclosureUploadFile'] = filename
p['feed'] = selectedFeed
p['sparkleVersion'] = longVersion
p['sparkleShortVersion'] = shortVersion
newItem = feeder.classForScriptingClass_("feed item").alloc.initWithProperties_(p)
print "#{newItem}\n"
feeder.selectedFeed.feedItems.addObject_(newItem)
#print newItem.activate
feeder.activate # use this if you want to edit prior to publishing
#feeder.selectedFeed.publish # use this for automatic publishing
end
opts = OptionParser.new
opts.on("--file=ARG", String) do |v|
options[:file] = v
end
opts.on("--shortVersion=ARG", String) do |v|
options[:short] = v
end
opts.on("--longVersion=ARG", String) do |v|
options[:long] = v
end
rest = opts.parse(ARGV)
#read_args
print "#{options}\n"
feeder(options[:file],options[:short],options[:long])
# Based on the following applescript
#
#tell application "Feeder"
#set theFeed to selected feed
#set episodeTitle to "This Episode's Title"
#set episodeLink to "http://example.com/epsiodelink.html"
#set enclosureFile to "Users:yourname:Desktop:Episode1.mp3"
#make new feed item at theFeed with properties {feed:theFeed, item title:episodeTitle, item link:episodeLink, enclosure upload file:enclosureFile}
#publish theFeed
#end tell