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