tweetskim 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,4 @@
1
+ *.gem
2
+ .bundle
3
+ Gemfile.lock
4
+ pkg/*
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in tweetskim.gemspec
4
+ gemspec
data/README.rdoc ADDED
@@ -0,0 +1,77 @@
1
+
2
+ == DESCRIPTION:
3
+
4
+ A stripped down, command line-centered way to read tweets efficiently.
5
+
6
+ == USAGE:
7
+
8
+ TODO
9
+
10
+ == INSTALL:
11
+
12
+ TODO
13
+
14
+
15
+ == FEATURES/PROBLEMS:
16
+
17
+ TODO
18
+
19
+ == TODO
20
+
21
+ two column presentation: add mentions
22
+
23
+ usage
24
+ tweet-skim [usernames...]
25
+ -m, --mark-all-read
26
+ -a, --show-all
27
+ -i --inverse-order
28
+ -h --html-output
29
+
30
+ configure
31
+ dotfile
32
+ config accounts, set tokens per account
33
+ option: hide timeline, hide mentions
34
+
35
+ generate nicely formatted html version in ~/.<APP>/last-generated
36
+ point browser to that
37
+ "mark all as read, go straight to browser
38
+ for multiple accounts: show them tabbed, concated or something else
39
+ super readable, greyscale, only gfx=avatars
40
+ Links to actual tweets to enable interaction using regular twitter web gui
41
+ make the design beautiful
42
+ CSS3 workthrough
43
+ Design & typography books workthrough
44
+
45
+ mobile version
46
+ move timeline last read values to central location
47
+ mobile app
48
+
49
+ web version
50
+ figure out way to post "mark as read"
51
+
52
+
53
+
54
+ == LICENSE:
55
+
56
+ (The MIT License)
57
+
58
+ Copyright (c) 2012 tweetskim
59
+
60
+ Permission is hereby granted, free of charge, to any person obtaining
61
+ a copy of this software and associated documentation files (the
62
+ 'Software'), to deal in the Software without restriction, including
63
+ without limitation the rights to use, copy, modify, merge, publish,
64
+ distribute, sublicense, and/or sell copies of the Software, and to
65
+ permit persons to whom the Software is furnished to do so, subject to
66
+ the following conditions:
67
+
68
+ The above copyright notice and this permission notice shall be
69
+ included in all copies or substantial portions of the Software.
70
+
71
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
72
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
73
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
74
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
75
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
76
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
77
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/Rakefile ADDED
@@ -0,0 +1,7 @@
1
+ require "bundler/gem_tasks"
2
+ require 'rake/testtask'
3
+
4
+ Rake::TestTask.new do |i|
5
+ i.test_files = FileList['test/test_*.rb']
6
+ #i.verbose = true
7
+ end
data/bin/tweetskim ADDED
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "tweetskim"
4
+
5
+ tweet_adapter = Tweetskim::TwitterAdapter.new
6
+ puts tweet_adapter.tweet_column(tweet_adapter.timeline(:count => 100), 40)
@@ -0,0 +1,102 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ module Tweetskim
4
+ require 'rubygems'
5
+ require 'twitter'
6
+ require 'oauth'
7
+
8
+ class TwitterAdapter
9
+
10
+ def trial
11
+ 4
12
+ end
13
+
14
+
15
+
16
+ # TODO call for each user in config
17
+ # implicit for the user authenticated in client. Different user =
18
+ # different client
19
+ def mentions(options = {})
20
+ client = authenticated_client #
21
+ mentions = client.mentions(options)
22
+ end
23
+
24
+ def timeline(options = {})
25
+ client = authenticated_client
26
+ timeline = client.home_timeline(options)
27
+ end
28
+
29
+
30
+ def tweet_column(tweets, column_width)
31
+ tweet_texts = tweets.reverse.map {|tweet| "--#{tweet.user.name}-- #{tweet.text}"}
32
+ reflowed_tweets = tweet_texts.map {|tweet| `echo "#{tweet}" | fmt -w #{column_width}` }
33
+ reflowed_tweets.join "\n\n"
34
+ end
35
+
36
+ CONSUMER_KEY = "3oUZhYLZcaqqQePajIjnBg"
37
+ CONSUMER_SECRET = "mAYecEGPwy7BlkibFGHCACtY5x1Mm0YOvczxsll4OY"
38
+
39
+ # TODO call for specific user
40
+ def authenticated_client
41
+ if user_tokens_stored?
42
+ user_token, user_secret = load_user_tokens
43
+ else
44
+ user_token, user_secret = oauth_pin_dance_for_token_and_secret
45
+ store_user_tokens(user_token, user_secret)
46
+ end
47
+
48
+ Twitter.configure do |config|
49
+ config.consumer_key = CONSUMER_KEY
50
+ config.consumer_secret = CONSUMER_SECRET
51
+ config.oauth_token = user_token
52
+ config.oauth_token_secret = user_secret
53
+ end
54
+
55
+ client = Twitter::Client.new
56
+ client.verify_credentials
57
+ return client
58
+ end
59
+
60
+ def oauth_pin_dance_for_token_and_secret
61
+ oauth_consumer = OAuth::Consumer.new(CONSUMER_KEY, CONSUMER_SECRET,
62
+ :site => 'http://api.twitter.com',
63
+ :request_token_path => '/oauth/request_token',
64
+ :access_token_path => '/oauth/access_token',
65
+ :authorize_path => '/oauth/authorize')
66
+
67
+ request_token = oauth_consumer.get_request_token
68
+ rtoken = request_token.token
69
+ rsecret = request_token.secret
70
+
71
+ puts "You have to set up Twitter authentication the first time you use tweetskim."
72
+ puts "Please authenticate by following this URL:"
73
+ puts request_token.authorize_url
74
+
75
+ print "What was the PIN Twitter gave you? "
76
+ pin = gets.chomp
77
+
78
+ OAuth::RequestToken.new(oauth_consumer, rtoken, rsecret)
79
+ access_token = request_token.get_access_token(:oauth_verifier => pin)
80
+
81
+ return access_token.token, access_token.secret
82
+ end
83
+
84
+ #TODO store tokens for each user
85
+ TOKEN_FILE_PATH = File.expand_path "~/.tweetskim/tokens"
86
+
87
+ def user_tokens_stored?
88
+ File.exists? TOKEN_FILE_PATH
89
+ end
90
+
91
+ def store_user_tokens(token, secret)
92
+ `mkdir ~/.tweetskim/`
93
+ `echo "#{token}___#{secret}" > #{TOKEN_FILE_PATH}`
94
+ end
95
+
96
+ def load_user_tokens
97
+ token, secret = `cat #{TOKEN_FILE_PATH}`.split "___"
98
+ return token.chomp, secret.chomp
99
+ end
100
+
101
+ end
102
+ end
@@ -0,0 +1,3 @@
1
+ module Tweetskim
2
+ VERSION = "0.0.1"
3
+ end
data/lib/tweetskim.rb ADDED
@@ -0,0 +1,6 @@
1
+ require "tweetskim/version"
2
+ require "tweetskim/core"
3
+
4
+ module Tweetskim
5
+
6
+ end
@@ -0,0 +1,3 @@
1
+ require 'stringio'
2
+ require 'test/unit'
3
+ require File.dirname(__FILE__) + '/../lib/tweetskim'
@@ -0,0 +1,31 @@
1
+ require File.dirname(__FILE__) + '/test_helper.rb'
2
+
3
+ class TestTweetskim < Test::Unit::TestCase
4
+
5
+ def setup
6
+ @t = Tweetskim::TwitterAdapter.new
7
+ end
8
+
9
+ def test_something
10
+ assert_equal 4, @t.trial
11
+ end
12
+
13
+ def test_twitter_integration_get_mentions
14
+ assert_equal 10, @t.mentions[0...10].count
15
+ end
16
+
17
+ def test_twitter_integration_get_timeline
18
+ assert_equal 10, @t.timeline[0...10].count
19
+ end
20
+
21
+
22
+ def test_column_creation
23
+ tweet_str = ["Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. ", "Ut enimad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.", "Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. ", "Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."]
24
+
25
+ # tweets = tweet_str.map { |str| Twitter::Status.new :text => str }
26
+
27
+ puts @t.tweet_column( @t.timeline, 40)
28
+ end
29
+
30
+ end
31
+
data/test.txt ADDED
@@ -0,0 +1 @@
1
+ hepp
data/tweetskim.gemspec ADDED
@@ -0,0 +1,24 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "tweetskim/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "tweetskim"
7
+ s.version = Tweetskim::VERSION
8
+ s.authors = ["Thomas Kjeldahl Nilsson"]
9
+ s.email = ["thomas@kjeldahlnilsson.net"]
10
+ s.homepage = ""
11
+ s.summary = %q{A stripped down CLI utility for reading tweets}
12
+ s.description = %q{Usage: tweetskim [username]}
13
+
14
+ s.rubyforge_project = "tweetskim"
15
+
16
+ s.files = `git ls-files`.split("\n")
17
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
18
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
19
+ s.require_paths = ["lib"]
20
+
21
+ # specify any dependencies here; for example:
22
+ # s.add_development_dependency "rspec"
23
+ # s.add_runtime_dependency "rest-client"
24
+ end
metadata ADDED
@@ -0,0 +1,79 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: tweetskim
3
+ version: !ruby/object:Gem::Version
4
+ hash: 29
5
+ prerelease:
6
+ segments:
7
+ - 0
8
+ - 0
9
+ - 1
10
+ version: 0.0.1
11
+ platform: ruby
12
+ authors:
13
+ - Thomas Kjeldahl Nilsson
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2012-03-03 00:00:00 +01:00
19
+ default_executable:
20
+ dependencies: []
21
+
22
+ description: "Usage: tweetskim [username]"
23
+ email:
24
+ - thomas@kjeldahlnilsson.net
25
+ executables:
26
+ - tweetskim
27
+ extensions: []
28
+
29
+ extra_rdoc_files: []
30
+
31
+ files:
32
+ - .gitignore
33
+ - Gemfile
34
+ - README.rdoc
35
+ - Rakefile
36
+ - bin/tweetskim
37
+ - lib/tweetskim.rb
38
+ - lib/tweetskim/core.rb
39
+ - lib/tweetskim/version.rb
40
+ - test.txt
41
+ - test/test_helper.rb
42
+ - test/test_tweetskim.rb
43
+ - tweetskim.gemspec
44
+ has_rdoc: true
45
+ homepage: ""
46
+ licenses: []
47
+
48
+ post_install_message:
49
+ rdoc_options: []
50
+
51
+ require_paths:
52
+ - lib
53
+ required_ruby_version: !ruby/object:Gem::Requirement
54
+ none: false
55
+ requirements:
56
+ - - ">="
57
+ - !ruby/object:Gem::Version
58
+ hash: 3
59
+ segments:
60
+ - 0
61
+ version: "0"
62
+ required_rubygems_version: !ruby/object:Gem::Requirement
63
+ none: false
64
+ requirements:
65
+ - - ">="
66
+ - !ruby/object:Gem::Version
67
+ hash: 3
68
+ segments:
69
+ - 0
70
+ version: "0"
71
+ requirements: []
72
+
73
+ rubyforge_project: tweetskim
74
+ rubygems_version: 1.4.2
75
+ signing_key:
76
+ specification_version: 3
77
+ summary: A stripped down CLI utility for reading tweets
78
+ test_files: []
79
+