Sha256: ba316d1c6427697cbb43d4b83ae19a2b14ad4f6e3f4026f26a8c2a50054cfd7d

Contents?: true

Size: 1.98 KB

Versions: 4

Compression:

Stored size: 1.98 KB

Contents

#!/usr/bin/env ruby
$:.unshift File.join File.dirname(__FILE__), '..', 'lib'
require 'rubygems'
require 'tumblr_client'
require 'oauth'
require 'yaml'
require 'irb'
require 'irb/completion'

path = File.join ENV['HOME'], '.tumblr'

if File.exist?(path)

  # Load configuration from data
  configuration = YAML.load_file path
  Tumblr.configure do |config|
    Tumblr::Config::VALID_OPTIONS_KEYS.each do |key|
      config.send(:"#{key}=", configuration[key.to_s])
    end
  end

else

  Tumblr.configure do |config|

    puts "Register an application at: http://www.tumblr.com/oauth/apps"
    print 'OAuth Consumer key: '
    config.consumer_key = gets.chomp

    print 'OAuth Consumer secret: '
    config.consumer_secret = gets.chomp

    site = 'http://www.tumblr.com'
    consumer = OAuth::Consumer.new(config.consumer_key, config.consumer_secret, :site => site)
    request_token = consumer.get_request_token

    puts

    puts request_token.authorize_url
    puts "Post-redirect, copy the oauth_verifier"
    print 'OAuth Verifier: '
    verifier = gets.chomp

    access_token = request_token.get_access_token :oauth_verifier => verifier
    config.oauth_token = access_token.token
    config.oauth_token_secret = access_token.secret

  end

  # Save credentials
  File.open(path, 'w') do |f|
    configuration = {}
    Tumblr::Config::VALID_OPTIONS_KEYS.each do |key|
      configuration[key.to_s] = Tumblr.send(key)
    end
    f.write YAML.dump configuration
  end

end


ENV['IRBRC'] = '.irbrc' if File.exists? '.irbrc'

puts %q[
        .                                 .o8       oooo
      .o8                                "888       `888
    .o888oo oooo  oooo  ooo. .oo.  .oo.   888oooo.   888  oooo d8b
      888   `888  `888  `888P"Y88bP"Y88b  d88' `88b  888  `888""8P
      888    888   888   888   888   888  888   888  888   888
      888 .  888   888   888   888   888  888   888  888   888    .o.
      "888"  `V88V"V8P' o888o o888o o888o `Y8bod8P' o888o d888b   Y8P

]

ARGV.clear
IRB.start
exit!

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
tumblr_client-0.7.1 bin/tumblr
tumblr_client-0.7.0 bin/tumblr
tumblr_client-0.6.11 bin/tumblr
tumblr_client-0.6.9 bin/tumblr