<commit_before>
Discover Oembeds
================

Discover Oembeds parses your model, finds the the links, gets the data from the provider and saves that data to the database. Supports three providers: [Flickr](http://www.flickr.com), [Vimeo](http://www.vimeo.com), [YouTube](http://www.youtube.com).

Installation
============

	script/plugin install git://github.com/emrekutlu/discover_oembeds.git

Requires [HTTparty](http://github.com/jnunemaker/httparty).

	sudo gem install httparty

Usage
=====

Create a migration.

	script/generate migration create_oembeds

Copy this migration.

	class CreateOembeds < ActiveRecord::Migration

		def self.up
			create_table :oembeds do |t|
				t.string			:kind
				t.string			:version
				t.string			:title
				t.string			:author_name
				t.string			:author_url
				t.string			:provider_name
				t.string			:provider_url
				t.integer			:cache_age
				t.string			:thumbnail_url
				t.string			:thumbnail_width
				t.string			:thumbnail_height
				t.string			:url
				t.text				:html
				t.integer			:width
				t.integer			:height
				t.string			:field
				t.string			:href
				t.references	:resource, :polymorphic => true
				t.timestamps
			end

			add_index :oembeds, :resource_type
			add_index :oembeds, :resource_id
		end

		def self.down
			drop_table :oembeds
		end

	end


Just add <code>discover_oembeds</code> method to your model.

	class Post < ActiveRecord::Base
		discover_oembeds :body
	end

This code will check the <code>body</code> attribute of the <code>Post</code> model for available oembeds.

Getting the oembeds of a <code>Post</code> model:

	Post.last.oembeds

Examples
--------

	discover_oembeds #if no parameter given, checks the :content attribute
	discover_oembeds :body #checks the :body attribute
	discover_oembeds :body, :title #checks multiple attributes, to get just :body attributes' oembeds Post.last.oembeds.body<commit_msg>README edited<commit_after>
Discover Oembeds
================

Discover Oembeds parses your model, finds the the links, gets the data from the provider and saves that data to the database. Supports three providers: [Flickr](http://www.flickr.com), [Vimeo](http://www.vimeo.com), [YouTube](http://www.youtube.com).

Installation
============

	script/plugin install git://github.com/emrekutlu/discover_oembeds.git

Requires [HTTparty](http://github.com/jnunemaker/httparty).

	sudo gem install httparty

Create a migration.

	script/generate migration create_oembeds

Copy this migration.

	class CreateOembeds < ActiveRecord::Migration

		def self.up
			create_table :oembeds do |t|
				t.string			:kind
				t.string			:version
				t.string			:title
				t.string			:author_name
				t.string			:author_url
				t.string			:provider_name
				t.string			:provider_url
				t.integer			:cache_age
				t.string			:thumbnail_url
				t.string			:thumbnail_width
				t.string			:thumbnail_height
				t.string			:url
				t.text				:html
				t.integer			:width
				t.integer			:height
				t.string			:field
				t.string			:href
				t.references	:resource, :polymorphic => true
				t.timestamps
			end

			add_index :oembeds, :resource_type
			add_index :oembeds, :resource_id
		end

		def self.down
			drop_table :oembeds
		end

	end

Usage
=====

Just add <code>discover_oembeds</code> method to your model.

	class Post < ActiveRecord::Base
		discover_oembeds :body
	end

This code will check the <code>body</code> attribute of the <code>Post</code> model for available oembeds.

Getting the oembeds of a <code>Post</code> model:

	Post.last.oembeds

Examples
--------

	discover_oembeds #if no parameter given, checks the :content attribute
	discover_oembeds :body #checks the :body attribute
	discover_oembeds :body, :title #checks multiple attributes, to get just :body attributes' oembeds Post.last.oembeds.body
{'fraction_non_alphanumeric': 0.10548412490160063, 'fraction_numerical': 0.0, 'mean_word_length': 3.5112426035502957, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 6, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4176586', 'n_tokens_mistral': 1506, 'n_tokens_neox': 1282, 'n_words': 354}