twix 0.0.1 → 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. data/lib/twix.rb +32 -1
  2. metadata +5 -2
@@ -1,8 +1,9 @@
1
1
  require 'twitter'
2
+ require 'yaml'
2
3
 
3
4
  module Twix
4
5
  def self.init
5
- config_file = File.expand("~") + "/.twixrc"
6
+ config_file = File.expand_path("~") + "/.twixrc"
6
7
  twix_config = YAML.load_file(config_file)
7
8
  Twitter.configure do |config|
8
9
  config.consumer_key = twix_config['twitter']['consumer_key']
@@ -11,4 +12,34 @@ module Twix
11
12
  config.oauth_token_secret = twix_config['twitter']['oauth_token_secret']
12
13
  end
13
14
  end
15
+
16
+ def self.run(args)
17
+ handle_switches
18
+ usernames = args.select {|arg| arg.match(/\A@/)}
19
+ user = usernames.first
20
+ show_user_tweets(user) if user
21
+ end
22
+
23
+ def self.handle_switches
24
+ true
25
+ end
26
+
27
+ def self.show_user_tweets(user)
28
+ timeline = Twitter.user_timeline(user.gsub(/\A@/, ''))
29
+ puts "Tweets for #{user}:"
30
+ timeline.each_with_index do |tweet, index|
31
+ display_tweet(tweet, index)
32
+ end
33
+ print "\nWhich Tweet do you want to execute? "
34
+ tweet_index = $stdin.gets.chomp
35
+ if tweet_index.match(/\A(1|)[0-9]\Z/).nil?
36
+ puts "\n\nYour input must be between 0 and 19"
37
+ show_user_tweets(user)
38
+ end
39
+ eval timeline[tweet_index.to_i].text
40
+ end
41
+
42
+ def self.display_tweet(tweet, index)
43
+ puts "\t#{index} - #{tweet.text}"
44
+ end
14
45
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: twix
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-10-09 00:00:00.000000000 Z
12
+ date: 2012-11-01 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: twitter
@@ -96,6 +96,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
96
96
  - - ! '>='
97
97
  - !ruby/object:Gem::Version
98
98
  version: '0'
99
+ segments:
100
+ - 0
101
+ hash: 4532826585065384912
99
102
  required_rubygems_version: !ruby/object:Gem::Requirement
100
103
  none: false
101
104
  requirements: