<commit_before># Tagalong

[![Build Status](https://secure.travis-ci.org/cyphactor/tagalong.png?branch=master)](http://travis-ci.org/cyphactor/tagalong)

[Tagalong](http://github.com/cyphactor/tagalong) is a Rails tagging plugin that is intended to be clean, efficient, and simple. I have tried hard to keep the API slim and intelligable in terms of Object Oriented Programming. I focused heavily on this as I feel most other Rails tagging plugins seriously neglect OO in their APIs.

The other key differentiation between [Tagalong](http://github.com/cyphactor/tagalong) and other tagging libraries is the relational database structure behind the scenes. This database structure allows [Tagalong](http://github.com/cyphactor/tagalong) to provide not only an Object Oriented API, but also a set of features that help differentiate it from other Rails tagging plugins.

## Feature Overview

* clean Object Oriented API
* does NOT require saving of the model when tagging/untagging
* keeps history of tags Taggers have used
* allows defining multiple Taggers and Taggables
* tracks the number of times tags are used
* returns tag lists in alphabetical order (imporant for UI)

## Installation

Add this line to your application's Gemfile:

    gem 'tagalong'

And then execute:

    $ bundle

Or install it yourself as:

    $ gem install tagalong

## Usage

### Migration Setup

In order to use [Tagalong](http://github.com/cyphactor/tagalong) you have to generate the proper migrations so that the tags can be stored in the database. You can do this with the following command:

    rails generate tagalong:migration

The above will generate the migration and place it appropriately in the db/migrate/ project path so that the next time you `rake db:migrate` it will make the changes to the database.

### Declaring Taggers and Taggables

In addition to generating and running the migrations, you also need to declare at least one Tagger and at least one Taggable. This is done as follows:

    class Contact < ActiveRecord::Base
      tagalong_taggable
    end

    class User < ActiveRecord::Base
      tagalong_tagger
    end

Once you have declared at least one Tagger and Taggable, they can be used in numerous ways as outlined below.

### Tagging

To tag you must call the `tag` method on a Tagger object and hand it a persisted Taggable object with the given tag that you want to apply.

    @user.tag(@contact, "<PASSWORD>")

### Untagging

To untag you must call the `untag` method on a Tagger object and hand it a persisted Taggable object with the given tag that you want to untag.

    @user.untag(@contact, "<PASSWORD>")

### List tags

You can get the list of tags for either a Tagger or a Taggable.

When you get the tags from a Tagger you are getting a list of all tags that Tagger has ever used in ascending alphabetical order.
<commit_msg>Trying to cutdown on word tag in README.<commit_after># Tagalong

[![Build Status](https://secure.travis-ci.org/cyphactor/tagalong.png?branch=master)](http://travis-ci.org/cyphactor/tagalong)

[Tagalong](http://github.com/cyphactor/tagalong) is a Rails tagging plugin that is intended to be clean, efficient, and simple. I have tried hard to keep the API slim and intelligable in terms of Object Oriented Programming. I focused heavily on this as I feel most other Rails tagging plugins seriously neglect OO in their APIs.

The other key differentiation between [Tagalong](http://github.com/cyphactor/tagalong) and other tagging libraries is the relational database structure behind the scenes. This database structure allows [Tagalong](http://github.com/cyphactor/tagalong) to provide not only an Object Oriented API, but also a set of features that help differentiate it from other Rails tagging plugins.

## Feature Overview

* clean Object Oriented API
* does NOT require saving of the model when tagging/untagging
* keeps history of tags Taggers have used
* allows defining multiple Taggers and Taggables
* tracks the number of times tags are used
* returns tag lists in alphabetical order (imporant for UI)

## Installation

Add this line to your application's Gemfile:

    gem 'tagalong'

And then execute:

    $ bundle

Or install it yourself as:

    $ gem install tagalong

## Usage

### Migration Setup

In order to use [Tagalong](http://github.com/cyphactor/tagalong) you have to generate the proper migrations so that the tags can be stored in the database. You can do this with the following command:

    rails generate tagalong:migration

The above will generate the migration and place it appropriately in the db/migrate/ project path so that the next time you `rake db:migrate` it will make the changes to the database.

### Declaring Taggers and Taggables

In addition to generating and running the migrations, you also need to declare at least one Tagger and at least one Taggable. This is done as follows:

    class Contact < ActiveRecord::Base
      tagalong_taggable
    end

    class User < ActiveRecord::Base
      tagalong_tagger
    end

Once you have declared at least one Tagger and Taggable, they can be used in numerous ways as outlined below.

### Tagging

To tag you must call the `tag` method on a Tagger object and hand it a persisted Taggable object with the given label that you want to apply.

    @user.tag(@contact, "<PASSWORD>")

### Untagging

To untag you must call the `untag` method on a Tagger object and hand it a persisted Taggable object with the given label that you want to untag.

    @user.untag(@contact, "<PASSWORD>")

### List tags

You can get the list of tags for either a Tagger or a Taggable.

When you get the tags from a Tagger you are getting a list of all tags that Tagger has ever used in ascending alphabetical order.

{'fraction_non_alphanumeric': 0.05761531766753699, 'fraction_numerical': 0.0, 'mean_word_length': 4.162623539982031, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 7, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, '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': '388269', 'n_tokens_mistral': 1589, 'n_tokens_neox': 1496, 'n_words': 805}