Class Magnolia
In: lib/magnolia/magnolia.rb
Parent: Object

Methods

add   delete   get   new   search   set_api_key   tags_add   tags_delete   tags_find   tags_replace   update  

Classes and Modules

Class Magnolia::Mark
Class Magnolia::Tag

External Aliases

get -> find
add -> create
delete -> destroy
update -> edit
tags_add -> add_tags
tags_delete -> delete_tags
tags_replace -> replace_tags
tags_replace -> rename_tags
tags_replace -> tags_rename
tags_find -> find_tags

Public Class methods

Examples

  Magnolia.add(:title        => 'Addicted To New',
              :description  => 'A great site!',
              :url          => 'http://addictedtonew.com/',
              :private      => 'false',
              :tags         => 'cool dude, lame tag, addicting',
              :rating       => 5)

Options

  :url          - A URL string. Must be valid (required)
  :title        - A title string (optional)
  :description  - A description string (optional)
  :private      - The bookmark’s privacy status; either 'true' or 'false' (optional)
  :tags         - A list of tags. This will completely replace any existing tags for each specified bookmark (optional)
  :rating       - An integer representing a star rating; 1-5 (optional)

Return Value

Returns an array containing the added mark

Examples

  delone      = Magnolia.delete(:id => 'java')
  delmultiple = Magnolia.delete(:id => 'java,perl,someotherid')
  deldiff     = Magnolia.destroy(:id => 'someid')

Options

  :id - The short name for one or more bookmarks; seperate multiples with commas (required)

Return Value

Nuttin

This method is basically like a Ruby on Rails find method. Pass it a short name (which is basically an id) or comma-seperated short names and it will return each mark that is found. Because it is similar to rails find method, I have aliased it.

Examples

  getone      = Magnolia.get(:id => 'rubyonrails')
  getmultiple = Magnolia.get(:id => 'rubyonrails,ruby,someotherid')

If you like Ruby on Rails and think find is a more appropriate name for the method, feel free to use it.

  getdiff     = Magnolia.find(:id => 'id1')

Options

  :id - The short name for one or more bookmarks; seperate multiples with commas (required)

Return Value

Returns an array of Marks.

This must be called before any of the other methods can be used. It sets a class variable named api_key which all the other class methods use when making requests.

Example

  Magnolia.new('yourgreatsuperapikey')

This method searches for bookmarks that match certain criteria provided by you. Ma.gnolia named this method bookmarks_find but I thought it was more appropriately named search.

Examples

  latest  = Magnolia.find(:person => 'jnunemaker') # will find my last ten bookmarks
  recent  = Magnolia.find(:person => 'jnunemaker', :limit => 20) # will find my last 20 bookmarks
  nice    = Magnolia.find(:person => 'jnunemaker', :tags => 'nice', :limit => 5) # will find my last 5 bookmarks tagged 'nice'

Let‘s get a bit trickier. Below will rescue from a request error such as not enough information or person not found, etc.

  begin
    marks = Magnolia.search(:person => 'jnunemaker')
    marks.each do |mark|
      puts mark.title, " #{mark.id}"
    end
  rescue Magnolia::RequestError => msg
    puts msg
  end

Options

  :tags   - Multiple tags are treated as an AND search; seperate multiples with commas
  :person - Multiple screen names are treated as an ‘OR’ search; seperate multiples with commas
  :group  - Multiple groups are treated as an ‘OR’ search; seperate multiples with commas
  :rating - Only bookmarks rated this value or higher will be returned
  :from   - Only bookmarks created after this date time will be returned
  :to     - Only bookmarks created before this date time will be returned
  :url    - Only return bookmarks with this url
  :limit  - A maximum number of bookmarks to return from search

Return Value

Returns an array of Marks.

Sets the api key for all requests

Examples

  Magnolia.tags_add(:id => 'rubyonrails', :tags => 'fast,simple')

You can also use add_tags if tags_add seems backwards.

  Magnolia.add_tags(:id => 'rubyonrails', :tags => 'fast,simple')

Options

  :id     - One or more bookmark short names to which the specified tags should be added
  :tags   - Tags to be added to the specified bookmarks

Return Value

Nuttin

Examples

  Magnolia.tags_delete(:id => 'java', :tags => 'cool,fun')

You can also use add_tags if tags_add seems backwards.

  Magnolia.add_tags(:id => 'id1', :tags => 'newtag1,newtag2')

Options

  :id     - One or more bookmark short names to which the specified tags should be added
  :tags   - Tags to be added to the specified bookmarks

Return Value

Nuttin

Examples

  tags = Magnolia.tags_find(:person => 'jnunemaker')
  tags.each do |tag|
    puts tag.name
  end

You can also use the alias of find_tags if it makes more sense to you

  tags = Magnolia.find_tags(:person => 'jnunemaker')

Options

  :person - The person whose tags you would like to find

Return Value

An array of Tag objects

Examples

  Magnolia.tags_replace(:id => 'languages', :old => 'java', :new => 'rubyonrails')

You can also use any of these below if you don‘t like tags_delete

  Magnolia.replace_tags(:id => 'languages', :old => 'java', :new => 'rubyonrails')
  Magnolia.rename_tags(:id => 'languages', :old => 'java', :new => 'rubyonrails')
  Magnolia.tags_rename(:id => 'languages', :old => 'java', :new => 'rubyonrails')

Options

  :id     - One or more bookmark short names to which the specified tags should be added
  :old    - Existing tag to be replaced
  :new    - New tag to replace existing tag

Return Value

Nuttin

Examples

  Magnolia.update(:id           => 'someid',
                :title        => 'Addicted To New',
                :description  => 'A great site!',
                :url          => 'http://addictedtonew.com/',
                :private      => 'false',
                :tags         => 'cool dude, lame tag, addicting',
                :rating       => 5)

Options

  :id           - The short name for one bookmark (required)
  :url          - A URL string. Must be valid (optional)
  :title        - A title string (optional)
  :description  - A description string (optional)
  :private      - The bookmark’s privacy status; either 'true' or 'false' (optional)
  :tags         - A list of tags. This will completely replace any existing tags for each specified bookmark (optional)
  :rating       - An integer representing a star rating; 1-5 (optional)

Return Value

Returns an array containing the updated mark.

[Validate]