twitter-vanity-suite 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 42ab4b82b6b6e3cf54bfba257c3961231389427a
4
+ data.tar.gz: de06211471303f54130efb945dda771b937fa465
5
+ SHA512:
6
+ metadata.gz: 957e178cd9de7b2e1ac877604106131c1097ba18c9c5a7b7ae83b272c35c0c09d3e44be7bf6a2079de685791263830050da33d3ca4d5ff696f09845c3b25e346
7
+ data.tar.gz: f075f77f9096733acf401fbe41db0f80a6f25134cc1206361663e790e308396dfc70387fa31302919b498767c01d1042908442abbd7952cf19f9325ce0355412
@@ -0,0 +1,29 @@
1
+ #!/usr/bin/env ruby
2
+ require_relative "../lib-internal/common"
3
+
4
+ def usage
5
+ abort "Usage: twitter-intersect (<username>.following|<username>.followers)..."
6
+ end
7
+
8
+ usage if ARGV.empty?
9
+
10
+ def all_ids(method, handle, cursor = -1)
11
+ return [] if cursor == 0
12
+ attrs = $client.send(method, handle, count: 5000, cursor: cursor).attrs
13
+ attrs[:ids] + all_ids(method, handle, attrs[:next_cursor])
14
+ end
15
+
16
+ ids = ARGV.map { |arg| arg.split(".") }.map { |handle, command|
17
+ case command
18
+ when "following"
19
+ all_ids(:friend_ids, handle)
20
+ when "followers"
21
+ all_ids(:follower_ids, handle)
22
+ else
23
+ puts "Unknown command: #{command}"
24
+ puts
25
+ usage
26
+ end
27
+ }
28
+
29
+ puts $client.users(ids.reduce(:&)).map(&:screen_name)
@@ -0,0 +1,24 @@
1
+ #!/usr/bin/env ruby
2
+ require_relative "../lib-internal/common"
3
+
4
+ abort "Usage: twitter-vanity username" if ARGV.empty?
5
+
6
+ def all_followers(username, cursor = -1)
7
+ return [] if cursor.zero?
8
+ attrs = $client.follower_ids(username, count: 5000, cursor: cursor).attrs
9
+ attrs[:ids] + all_followers(username, attrs[:next_cursor])
10
+ end
11
+
12
+ def show_ids_sorted_by_followers(ids)
13
+ users = $client.users(ids)
14
+
15
+ users.sort_by { |user|
16
+ -user.followers_count
17
+ }.each do |user|
18
+ printf "%20s %7d followers\n", user.screen_name, user.followers_count
19
+ end
20
+ end
21
+
22
+ username = ARGV.first
23
+ follower_ids = all_followers(username)
24
+ show_ids_sorted_by_followers(follower_ids)
@@ -0,0 +1,12 @@
1
+ gem "twitter", "~> 5.4"
2
+ require "twitter"
3
+ require "yaml"
4
+
5
+ config = YAML.load_file("#{ENV["HOME"]}/.twitter-api-creds")
6
+
7
+ $client = Twitter::REST::Client.new do |twitter|
8
+ twitter.consumer_key = config["consumer_key"]
9
+ twitter.consumer_secret = config["consumer_secret"]
10
+ twitter.access_token = config["access_token"]
11
+ twitter.access_token_secret = config["access_token_secret"]
12
+ end
metadata ADDED
@@ -0,0 +1,62 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: twitter-vanity-suite
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Charlie Somerville
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-01-01 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: twitter
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '5.4'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '5.4'
27
+ description: 'my personal set of command line twitter tools '
28
+ email: charlie@charliesomerville.com
29
+ executables:
30
+ - twitter-intersect
31
+ - twitter-vanity
32
+ extensions: []
33
+ extra_rdoc_files: []
34
+ files:
35
+ - bin/twitter-intersect
36
+ - bin/twitter-vanity
37
+ - lib-internal/common.rb
38
+ homepage: https://github.com/charliesome/twitter-vanity-tools
39
+ licenses:
40
+ - BSD
41
+ metadata: {}
42
+ post_install_message:
43
+ rdoc_options: []
44
+ require_paths:
45
+ - lib
46
+ required_ruby_version: !ruby/object:Gem::Requirement
47
+ requirements:
48
+ - - ">="
49
+ - !ruby/object:Gem::Version
50
+ version: '0'
51
+ required_rubygems_version: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - ">="
54
+ - !ruby/object:Gem::Version
55
+ version: '0'
56
+ requirements: []
57
+ rubyforge_project:
58
+ rubygems_version: 2.2.0
59
+ signing_key:
60
+ specification_version: 4
61
+ summary: my personal set of command line twitter tools
62
+ test_files: []