Sha256: 299b3fbe137d255e97b5a5c3def8183abbba8a002287fc207feade4d6b6cd128

Contents?: true

Size: 1002 Bytes

Versions: 4

Compression:

Stored size: 1002 Bytes

Contents

#!/usr/bin/env ruby
# TODO: Eventually add some flags to support all Ping.fm functionality.

# TODO: Move this into a YAML config?
API_KEY = '5fcb8b7041d5c32c7e1e60dc076989ba'

require File.expand_path(
    File.join(File.dirname(__FILE__), '..', 'lib', 'pingfm'))

keyloader = ::Pingfm::Keyloader.new
unless keyloader.has_keys?
  keyloader.api_key = API_KEY
  print 'Enter your Ping.fm User API key (http://ping.fm/key/): '
  keyloader.app_key = STDIN.gets.chomp
  keyloader.save
end

# post message from ARGV

pingfm = ::Pingfm::Client.new(keyloader.api_key, keyloader.app_key)

s = pingfm.validate
if s['status'] == 'OK'
  status = ARGV.join(' ')

  # Might be a good idea to throw an exception here, instead of just bailing.
  if status.nil? || status.empty?
    puts 'Must provide a message to send.'
    exit
  end

  post_result = pingfm.post(status)

  if post_result['status'] == 'FAIL'
    puts post_result['message']
  else
    puts 'Message sent.'
  end
else
  puts s['message']
end

# EOF

Version data entries

4 entries across 4 versions & 2 rubygems

Version Path
Oshuma-pingfm-1.0.1 bin/pingfm
Oshuma-pingfm-1.0.2 bin/pingfm
pingfm-1.0.1 bin/pingfm
pingfm-1.0.2 bin/pingfm