Module: Socialcastr

Defined in:
lib/socialcastr.rb,
lib/socialcastr/api.rb,
lib/socialcastr/base.rb,
lib/socialcastr/like.rb,
lib/socialcastr/user.rb,
lib/socialcastr/comment.rb,
lib/socialcastr/message.rb,
lib/socialcastr/version.rb,
lib/socialcastr/exceptions.rb,
lib/socialcastr/sax/active_resource.rb

Defined Under Namespace

Modules: SAX Classes: API, BadRequest, Base, ClientError, Comment, Configuration, ConnectionError, Error, ForbiddenAccess, InvalidAttribute, InvalidMethod, Like, Message, MethodNotAllowed, MissingConfiguration, Redirection, ResourceConflict, ResourceGone, ResourceInvalid, ResourceNotFound, SSLError, ServerError, TimeoutError, UnauthorizedAccess, User

Constant Summary collapse

VERSION =
"0.2.19"

Class Method Summary collapse

Class Method Details

.apiObject



59
60
61
62
63
# File 'lib/socialcastr.rb', line 59

def api
  config = Configuration.instance
  raise MissingConfiguration unless config.ready?
  @api ||= API.new(config.username, config.password, config.domain, config.format, config.debug)
end

.configurationObject



44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/socialcastr.rb', line 44

def configuration
  if block_given?
    yield Configuration.instance
    if Configuration.instance.config_file
      config = YAML::load_file(Configuration.instance.config_file)
      Configuration.instance.domain   = config['domain']
      Configuration.instance.username = config['username']
      Configuration.instance.password = config['password']
      Configuration.instance.format   = config['format']
      Configuration.instance.debug    = config['debug']
    end
  end
  Configuration.instance
end

.const_missing(class_name) ⇒ Object



83
84
85
# File 'lib/socialcastr.rb', line 83

def const_missing(class_name)
  define_element_class(class_name)
end

.define_element_class(class_name) ⇒ Object



87
88
89
# File 'lib/socialcastr.rb', line 87

def define_element_class(class_name)
  Socialcastr.const_set(class_name, Class.new(Socialcastr::Base))
end

.get_element_class(class_name) ⇒ Object



74
75
76
77
78
79
80
81
# File 'lib/socialcastr.rb', line 74

def get_element_class(class_name)
  define_element_class(class_name) unless Socialcastr.const_defined?(class_name)
  if RUBY_VERSION < '1.9'
    Socialcastr.const_get(class_name)
  else 
    Socialcastr.const_get(class_name, false)
  end
end

.resetObject



65
66
67
68
# File 'lib/socialcastr.rb', line 65

def reset
  @api = nil
  configuration.reset
end

.to_class_name(method) ⇒ Object



70
71
72
# File 'lib/socialcastr.rb', line 70

def to_class_name(method)
  method.to_s.gsub(/^[a-z]|-[a-z]/i) { |a| a.sub("-", '').upcase }
end