Module: Contacts

Defined in:
lib/contacts.rb,
lib/contacts/util.rb,
lib/contacts/yahoo.rb,
lib/contacts/google.rb,
lib/contacts/version.rb,
lib/contacts/consumer.rb,
lib/contacts/windows_live.rb,
lib/contacts/oauth_consumer.rb

Defined Under Namespace

Modules: Util, VERSION Classes: Consumer, Contact, Error, Google, OAuthConsumer, TooManyRedirects, WindowsLive, Yahoo

Constant Summary collapse

Identifier =
'Ruby Contacts v' + VERSION::STRING

Class Method Summary collapse

Class Method Details

.configure(configuration) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/contacts.rb', line 8

def self.configure(configuration)
  configuration.each do |key, value|
    klass =
      case key.to_s
      when 'google'
        Google
      when 'yahoo'
        Yahoo
      when 'windows_live'
        WindowsLive
      else
        raise ArgumentError, "unknown consumer: #{key}"
      end
    klass.configure(value)
  end
end

.consumer_class_for(name) ⇒ Object



49
50
51
52
53
54
55
56
57
58
59
# File 'lib/contacts.rb', line 49

def self.consumer_class_for(name)
  class_name = name.to_s.gsub(/(?:\A|_)(.)/){|s| $1.upcase}
  class_name.sub!(/Oauth/, 'OAuth')
  class_name.sub!(/Bbauth/, 'BBAuth')
  begin
    klass = const_get(class_name)
  rescue NameError
    return nil
  end
  klass < Consumer ? klass : nil
end

.deserialize_consumer(name, serialized_data) ⇒ Object



39
40
41
42
# File 'lib/contacts.rb', line 39

def self.deserialize_consumer(name, serialized_data)
  klass = consumer_class_for(name) and
    klass.deserialize(serialized_data)
end

.new(name, *args, &block) ⇒ Object



44
45
46
47
# File 'lib/contacts.rb', line 44

def self.new(name, *args, &block)
  klass = consumer_class_for(name) and
    klass.new(*args, &block)
end

.verbose?Boolean

Returns:

  • (Boolean)


61
62
63
# File 'lib/contacts.rb', line 61

def self.verbose?
  'irb' == $0
end