Added v 0.3.1 snapshot.
[twitter4r-core.git] / lib / twitter / console.rb
blob05bde1ea13397d60aedc782fa2fa6006f038a16c
1 # Contains hooks for the twitter console
3 require('optparse')
5 module Twitter
6   class Client
7     class << self
8       # Helper method mostly for irb shell prototyping.
9       # 
10       # Reads in login/password Twitter credentials from YAML file
11       # found at the location given by <tt>config_file</tt> that has 
12       # the following format:
13       #  envname:
14       #    login: mytwitterlogin
15       #    password: mytwitterpassword
16       # 
17       # Where <tt>envname</tt> is the name of the environment like 'test', 
18       # 'dev' or 'prod'.  The <tt>env</tt> argument defaults to 'test'.
19       # 
20       # To use this in the shell you would do something like the following 
21       # examples:
22       #  twitter = Twitter::Client.from_config('config/twitter.yml', 'dev')
23       #  twitter = Twitter::Client.from_config('config/twitter.yml')
24       def from_config(config_file, env = 'test')
25         yaml_hash = YAML.load(File.read(config_file))
26         self.new yaml_hash[env]
27       end
28     end # class << self
29   end
30 end