twitterlost 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (5) hide show
  1. data/MIT-LICENSE +22 -0
  2. data/README +59 -0
  3. data/bin/twitterlost +66 -0
  4. data/twitter_sample.yml +3 -0
  5. metadata +67 -0
data/MIT-LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2008 David Brady twitterlost@shinybit.com
2
+
3
+ Permission is hereby granted, free of charge, to any person
4
+ obtaining a copy of this software and associated documentation
5
+ files (the "Software"), to deal in the Software without
6
+ restriction, including without limitation the rights to use,
7
+ copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ copies of the Software, and to permit persons to whom the
9
+ Software is furnished to do so, subject to the following
10
+ conditions:
11
+
12
+ The above copyright notice and this permission notice shall be
13
+ included in all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
17
+ OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
19
+ HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
20
+ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21
+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22
+ OTHER DEALINGS IN THE SOFTWARE.
data/README ADDED
@@ -0,0 +1,59 @@
1
+ README
2
+
3
+ twitterlost is a command-line tool to keep track of your Twitter
4
+ followers. Each time it runs it shows you the new and lost followers
5
+ since the last time it ran.
6
+
7
+ Description
8
+ -----------
9
+
10
+ Keep track of your twitter followers, see who has unfollowed
11
+ you. Sadly it will not tell you why (but it was probably because of
12
+ something you did).
13
+
14
+ Installation
15
+ ------------
16
+
17
+ 1. Install the gem.
18
+
19
+ 2. mkdir ~/.twitterlost (or run twitterlost once and it will be
20
+ created for you)
21
+
22
+ 3. Edit ~/.twitterlost/twitter.yml with the following information:
23
+
24
+ ---
25
+ :login: $USERNAME
26
+ :password: $PASSWORD
27
+
28
+ That's it. The first time you run twitterlost it will see all your
29
+ followers as new; after that it will only report changes.
30
+
31
+ License
32
+ -------
33
+
34
+ Twitterlost is released under the MIT license. Take it, play with it,
35
+ do whatever you want with it, keep this version free.
36
+
37
+ Motivation
38
+ ----------
39
+
40
+ Why did I write Twitterlost? Because I think Twitterless.com is a good
41
+ service wrapped around a brilliant idea, but I didn't want to give
42
+ them my Twitter login and password. If you don't see a problem with
43
+ giving them your login credentials, then by all means use their
44
+ service; it's better than this hack. They'll send you regular email
45
+ updates and such, where twitterlost has to be run by hand.
46
+
47
+ Known Issues
48
+ ------------
49
+
50
+ twitterlost uses the Twitter API to retrieve your list of
51
+ friends. This is returned in chunks of 100. If you have more than 100
52
+ followers, twitterlost must make multiple calls to Twitter. EACH CALL
53
+ counts towards Twitter's 70-calls-per-hour limit. If you have many
54
+ followers and are running a polling Twitter client, Twitter may slap
55
+ you withan "overloaded" message. If this happens to twitterlost, it
56
+ interprets this as the end of your friends list, which means it will
57
+ report all those people as lost friends. They'll come back the next
58
+ time you run twitterlost.
59
+
data/bin/twitterlost ADDED
@@ -0,0 +1,66 @@
1
+ #!/usr/bin/env ruby
2
+ # twitterlost--keep track of unsubscribed followers. Still just a 0.0.1 proof of concept. YMMV.
3
+ # David Brady dbrady@shinybit.com http://twitter.com/chalain
4
+ #
5
+ # TODO: Consider a sqlite database instead of flat files, track new/lost dates
6
+ # TODO: Clean up ugly while loop
7
+
8
+ # !!!IMPORTANT NOTE!!! requires twitter4r >= 0.3.1 and as of
9
+ # 2008-10-11 rubyforge version is 0.3.0. Make sure you have github
10
+ # gem sources, then gem install mbbx6spp-twitter4r
11
+ require 'rubygems'
12
+ require 'twitter'
13
+ require 'yaml'
14
+
15
+ base_dir = File.expand_path("~/.twitterlost/")
16
+ yaml_file = File.join(base_dir, "twitter.yml")
17
+
18
+ # Make sure the dir exists
19
+ FileUtils.mkdir_p(base_dir)
20
+
21
+ # Ensure twitter.yml exists; create default for user if not
22
+ if File.exists?(yaml_file)
23
+ cfg = YAML::load_file( yaml_file )
24
+
25
+ old_followers = IO.readlines(File.join(base_dir, "followers.txt")).map {|line| line.strip }.sort rescue []
26
+
27
+ @client = Twitter::Client.new :login => cfg[:login], :password => cfg[:password]
28
+
29
+ def followers_page(page)
30
+ @client.my :followers, :page => page
31
+ end
32
+
33
+ # Get all your followers. Loop is still kludgy.
34
+ p,f,followers=0,[],[]
35
+ followers += f.map { |u| u.screen_name } while (f=followers_page(p+=1)).any?
36
+ followers.sort!
37
+
38
+ lost_followers = old_followers - followers
39
+ new_followers = followers - old_followers
40
+
41
+ puts "You have #{followers.size} followers. Since the last time this program was run you lost #{lost_followers.size} followers and gained #{new_followers.size} new ones."
42
+
43
+ longest_lost, longest_new = lost_followers.map { |u| u.size }.max, new_followers.map { |u| u.size }.max
44
+
45
+ puts lost_followers.map { |u| "LOST: %-#{longest_lost}s http://twitter.com/#{u}" % u}
46
+ puts new_followers.map { |u| "NEW: %-#{longest_new}s http://twitter.com/#{u}" % u}
47
+
48
+ File.new(File.join(base_dir, "followers.txt"), "w").puts followers.map {|f| "#{f}"}
49
+ File.new(File.join(base_dir, "lost.txt"), "a").puts lost_followers.map {|f| "#{f}"} if lost_followers.any?
50
+ else
51
+ puts <<HELP
52
+ Welcome to Twitterlost! I cannot find your twitter.yml file.
53
+
54
+ I will write out a default file for you, but you will need to
55
+ edit the file to contain your twitter username and password.
56
+
57
+ Writing default file to #{yaml_file}...
58
+ HELP
59
+
60
+ File.open(yaml_file, 'w') do |f|
61
+ f.puts '---'
62
+ f.puts ':login: USERNAME'
63
+ f.puts ':password: PASSWORD'
64
+ end
65
+ end
66
+
@@ -0,0 +1,3 @@
1
+ ---
2
+ :login: ACCOUNT_NAME
3
+ :password: PASSWARD
metadata ADDED
@@ -0,0 +1,67 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: twitterlost
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.5
5
+ platform: ruby
6
+ authors:
7
+ - David Brady
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2009-01-05 00:00:00 -07:00
13
+ default_executable:
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: mbbx6spp-twitter4r
17
+ type: :runtime
18
+ version_requirement:
19
+ version_requirements: !ruby/object:Gem::Requirement
20
+ requirements:
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: 0.3.1
24
+ version:
25
+ description: Twitterlost - keep track of your twitter followers lost and gained
26
+ email: github@shinybit.com
27
+ executables:
28
+ - twitterlost
29
+ extensions: []
30
+
31
+ extra_rdoc_files: []
32
+
33
+ files:
34
+ - twitter_sample.yml
35
+ - bin/twitterlost
36
+ - README
37
+ - MIT-LICENSE
38
+ has_rdoc: true
39
+ homepage: http://github.com/dbrady/twitterlost
40
+ licenses: []
41
+
42
+ post_install_message:
43
+ rdoc_options: []
44
+
45
+ require_paths:
46
+ - lib
47
+ required_ruby_version: !ruby/object:Gem::Requirement
48
+ requirements:
49
+ - - ">="
50
+ - !ruby/object:Gem::Version
51
+ version: "0"
52
+ version:
53
+ required_rubygems_version: !ruby/object:Gem::Requirement
54
+ requirements:
55
+ - - ">="
56
+ - !ruby/object:Gem::Version
57
+ version: "0"
58
+ version:
59
+ requirements: []
60
+
61
+ rubyforge_project:
62
+ rubygems_version: 1.3.5
63
+ signing_key:
64
+ specification_version: 3
65
+ summary: Twitterlost - keep track of your twitter followers lost and gained
66
+ test_files: []
67
+