Sha256: 392d68f38e22dc77b771ba1e4725ffa5dedd4f13eef824cd3f0e8b6db8e29930
Contents?: true
Size: 1.75 KB
Versions: 1
Compression:
Stored size: 1.75 KB
Contents
require 't/core_ext/enumerable' require 't/core_ext/string' require 't/rcfile' require 'thor' require 'twitter' module T class CLI class Unfollow < Thor DEFAULT_HOST = 'api.twitter.com' DEFAULT_PROTOCOL = 'https' check_unknown_options! def initialize(*) super @rcfile = RCFile.instance end desc "users SCREEN_NAME [SCREEN_NAME...]", "Allows you to stop following users." def users(screen_name, *screen_names) screen_names.unshift(screen_name) screen_names.threaded_map do |screen_name| screen_name = screen_name.strip_at client.unfollow(screen_name, :include_entities => false) end number = screen_names.length say "@#{@rcfile.default_profile[0]} is no longer following #{number} #{number == 1 ? 'user' : 'users'}." say say "Run `#{$0} follow users #{screen_names.join(' ')}` to follow again." end desc "all SUBCOMMAND ...ARGS", "Follow all users." require 't/cli/unfollow/all' subcommand 'all', CLI::Unfollow::All private def base_url "#{protocol}://#{host}" end def client return @client if @client @rcfile.path = parent_options['profile'] if parent_options['profile'] @client = Twitter::Client.new( :endpoint => base_url, :consumer_key => @rcfile.default_consumer_key, :consumer_secret => @rcfile.default_consumer_secret, :oauth_token => @rcfile.default_token, :oauth_token_secret => @rcfile.default_secret ) end def host parent_options['host'] || DEFAULT_HOST end def protocol parent_options['no_ssl'] ? 'http' : DEFAULT_PROTOCOL end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
t-0.2.1 | lib/t/cli/unfollow.rb |