Module: Smile

Defined in:
lib/smile/base.rb,
lib/smile.rb,
lib/smile/smug.rb,
lib/smile/json.rb,
lib/smile/common.rb,
lib/smile/session.rb,
lib/smile/version.rb,
lib/smile/exception.rb

Overview

smug.rb

smile

Created by Zac Kleinpeter on 2009-04-28.

Defined Under Namespace

Modules: Common, ParamConverter Classes: Album, Base, Exception, Json, Photo, Session, Smug

Constant Summary

VERSION =
"0.4.4"

Instance Method Summary (collapse)

Instance Method Details

- (Smile::SmugMug.new) auth(email, password)

Login to SmugMug using a specific user account.

Parameters:

  • email (String)

    The username ( e-mail address ) for the SmugMug account

  • password (String)

    The password for the SmugMug account

Returns:

  • (Smile::SmugMug.new)

    An Smug object that has been authenticated



40
41
42
43
44
# File 'lib/smile.rb', line 40

def auth( email, password )
  smug = Smile::Smug.new
  smug.auth( email, password )
  smug
end

- (Smile::SmugMug.new) auth_anonymously

Login to SmugMug using an anonymously account This will allow you to execute many functions, but no user specific functions

Returns:

  • (Smile::SmugMug.new)

    An Smug object that has been authenticated



28
29
30
31
32
# File 'lib/smile.rb', line 28

def auth_anonymously
  smug = Smile::Smug.new
  smug.auth_anonymously
  smug
end

- (Object) search(data, options = {})

Search SmugMug for pics. This search is slower than the others, but returns Smile::Photo objects

pulling more details from every photo.

Parameters:

  • data (String)

    This is the search term that you want to use

  • options (optional, Hash) (defaults to: {})

    Hash of options for the search method

Options Hash (options):

  • :keyword (optional, String)

    override the keyword search

  • :popular (optional, String)

    Use term all or today

  • :popular_category (optional, String)

    Use term category ( e.g. cars )

  • :geo_all (optional, String)

    Geo Stuff

  • :geo_community (optional, String)

    More Geo Stuff

  • :geo_search (optional, String)

    Geo Search

  • :open_search_keyword (optional, String)

    Key word

  • :user_keyword (optional, String)

    Use term nickname

  • :gallery (optional, String)

    Use term albumID_albumKey

  • :nickname (optional, String)

    Use term nickname

  • :nickname_recent (optional, String)

    Use term nickname

  • :nickname_popular (optional, String)

    Use term nickname

  • :user_comments (optional, String)

    Use term nickname

  • :geo_user (optional, String)

    Use term nickname

  • :geo_album (optional, String)

    Use term nickname



83
84
85
86
87
88
89
# File 'lib/smile.rb', line 83

def search( data, options={} )
  auth_anonymously
  search_rss(data,options).items.map do |item|
    image_id, image_key = item.link.split('/').last.split('#').last.split('_')
    Smile::Photo.find( :image_id => image_id, :image_key => image_key )
  end
end

- (RestClientResponse) search_raw(data, options = {})

Raw feed from the SmugMug data feeds

Parameters:

  • data (String)

    This is the search term that you want to use

  • options (optional, Hash) (defaults to: {})

    Hash of options for the search method

Options Hash (options):

  • :keyword (optional, String)

    override the keyword search

  • :popular (optional, String)

    Use term all or today

  • :popular_category (optional, String)

    Use term category ( e.g. cars )

  • :geo_all (optional, String)

    Geo Stuff

  • :geo_community (optional, String)

    More Geo Stuff

  • :geo_search (optional, String)

    Geo Search

  • :open_search_keyword (optional, String)

    Key word

  • :user_keyword (optional, String)

    Use term nickname

  • :gallery (optional, String)

    Use term albumID_albumKey

  • :nickname (optional, String)

    Use term nickname

  • :nickname_recent (optional, String)

    Use term nickname

  • :nickname_popular (optional, String)

    Use term nickname

  • :user_comments (optional, String)

    Use term nickname

  • :geo_user (optional, String)

    Use term nickname

  • :geo_album (optional, String)

    Use term nickname

Returns:

  • (RestClientResponse)

    The response from a RestClient.get request



138
139
140
141
# File 'lib/smile.rb', line 138

def search_raw( data, options={} )
  options.merge!( :type => 'keyword', :data => data )
  base_feed( options )
end

- (Array<Smile::Photo>) search_rss(data, options = {})

Search SmugMug for pics. This search is slower than the others, but returns Smile::Photo objects

Parameters:

  • data (String)

    This is the search term that you want to use

  • options (optional, Hash) (defaults to: {})

    Hash of options for the search method

Options Hash (options):

  • :keyword (optional, String)

    override the keyword search

  • :popular (optional, String)

    Use term all or today

  • :popular_category (optional, String)

    Use term category ( e.g. cars )

  • :geo_all (optional, String)

    Geo Stuff

  • :geo_community (optional, String)

    More Geo Stuff

  • :geo_search (optional, String)

    Geo Search

  • :open_search_keyword (optional, String)

    Key word

  • :user_keyword (optional, String)

    Use term nickname

  • :gallery (optional, String)

    Use term albumID_albumKey

  • :nickname (optional, String)

    Use term nickname

  • :nickname_recent (optional, String)

    Use term nickname

  • :nickname_popular (optional, String)

    Use term nickname

  • :user_comments (optional, String)

    Use term nickname

  • :geo_user (optional, String)

    Use term nickname

  • :geo_album (optional, String)

    Use term nickname

Returns:

  • (Array<Smile::Photo>)

    RSS feed from the RSS::Parser.parse method



112
113
114
115
# File 'lib/smile.rb', line 112

def search_rss( data, options={} )
  raw = search_raw( data, options )
  RSS::Parser.parse( raw, false ) || OpenStruct.new( :items => [] )
end