<commit_before># Virsandra [![Build Status](https://travis-ci.org/ottbot/virsandra.png)](https://travis-ci.org/ottbot/virsandra) [![Code Climate](https://codeclimate.com/github/ottbot/virsandra.png)](https://codeclimate.com/github/ottbot/virsandra) [![Dependency Status](https://gemnasium.com/ottbot/virsandra.png)](https://gemnasium.com/ottbot/virsandra) [![Coverage Status](https://coveralls.io/repos/ottbot/virsandra/badge.png?branch=master)](https://coveralls.io/r/ottbot/virsandra)

The Cassandra backed models with Virtus gem with a stupid name.

## Moving target

Virsandra is meant to make it easy to use cassandra for persistence
for models build with virtus.

The feature set will likely remain simple, the idea is to not block
development of other projects while the implentation of CQL changes
quickly.

## Schema yourself

At this stage, you're on your own in terms for schema management. The
gem expects you have maintain table <=> model attribute mappings
youself.

## Example usage

````ruby
require 'virsandra'

Virsandra.configure |c|
  c.servers = "127.0.0.1:9160"
  c.keyspace = "example_keyspace"
end
````

To define a `Company` model backed by a table `companies` using a composite primary key of `name text, founder text`:
````ruby
class Company
  include Virsandra::Model

  attribute :name, String
  attribute :founder, String
  attribute :turnover, Fixnum
  attribute :founded, Date

  table :companies
  key :name, :founder
end
````

Create a company:
````ruby
company = Company.new(name: "Gooble",
                      founder: "<NAME>",
                      turnover: 2000000,
                      founded: 1884)
company.save
````

Find the company by key:
````ruby
company = Company.find(name: "Gooble", founder: "<NAME>")
````

Find or initialize a company. If there is a row with the same primary
key, this will load missing attributes from cassandra and merge new
ones.

````ruby
company = Company.load(name: "Gooble", founder: "<NAME>", foundec: 2012)
company.attributes
#=> {name: "Gooble", founder: "<NAME>", turnover: 2000000, founded: 2012}
````

Seach for companies:
````ruby
companies = Companies.all

googbles = Companies.where(name: 'Gooble')

company_names = Companies.all.map(&:name)
````

## TODO / Missing
1. Support ALLOW FILTERING
2. Create / filter with index
3. Model attributes that are not Cassandra columns
4. Delete models
5. Counters
6. Schema creation / migration


## Contributing

1. Fork it
2. Create your feature branch (`git checkout -b my-new-feature`)
3. Commit your changes (`git commit -am 'Add some feature'`)
4. Push to the branch (`git push origin my-new-feature`)
5. Create new Pull Request<commit_msg>few typos in readme fixed<commit_after># Virsandra [![Build Status](https://travis-ci.org/ottbot/virsandra.png)](https://travis-ci.org/ottbot/virsandra) [![Code Climate](https://codeclimate.com/github/ottbot/virsandra.png)](https://codeclimate.com/github/ottbot/virsandra) [![Dependency Status](https://gemnasium.com/ottbot/virsandra.png)](https://gemnasium.com/ottbot/virsandra) [![Coverage Status](https://coveralls.io/repos/ottbot/virsandra/badge.png?branch=master)](https://coveralls.io/r/ottbot/virsandra)

The Cassandra backed models with Virtus gem with a stupid name.

## Moving target

Virsandra is meant to make it easy to use cassandra for persistence
for models build with virtus.

The feature set will likely remain simple, the idea is to not block
development of other projects while the implantation of CQL changes
quickly.

## Schema yourself

At this stage, you're on your own in terms for schema management. The
gem expects you have maintain table <=> model attribute mappings
yourself.

## Example usage

````ruby
require 'virsandra'

Virsandra.configure |c|
  c.servers = "127.0.0.1:9160"
  c.keyspace = "example_keyspace"
end
````

To define a `Company` model backed by a table `companies` using a composite primary key of `name text, founder text`:
````ruby
class Company
  include Virsandra::Model

  attribute :name, String
  attribute :founder, String
  attribute :turnover, Fixnum
  attribute :founded, Date

  table :companies
  key :name, :founder
end
````

Create a company:
````ruby
company = Company.new(name: "Gooble",
                      founder: "<NAME>",
                      turnover: 2000000,
                      founded: 1884)
company.save
````

Find the company by key:
````ruby
company = Company.find(name: "Gooble", founder: "<NAME>")
````

Find or initialize a company. If there is a row with the same primary
key, this will load missing attributes from cassandra and merge new
ones.

````ruby
company = Company.load(name: "Gooble", founder: "<NAME>", foundec: 2012)
company.attributes
#=> {name: "Gooble", founder: "<NAME>", turnover: 2000000, founded: 2012}
````

Search for companies:
````ruby
companies = Companies.all

googbles = Companies.where(name: 'Gooble')

company_names = Companies.all.map(&:name)
````

## TODO / Missing
1. Support ALLOW FILTERING
2. Create / filter with index
3. Model attributes that are not Cassandra columns
4. Delete models
5. Counters
6. Schema creation / migration


## Contributing

1. Fork it
2. Create your feature branch (`git checkout -b my-new-feature`)
3. Commit your changes (`git commit -am 'Add some feature'`)
4. Push to the branch (`git push origin my-new-feature`)
5. Create new Pull Request
{'fraction_non_alphanumeric': 0.12308839985080194, 'fraction_numerical': 0.0175307720999627, 'mean_word_length': 4.222005842259007, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 15, 'https://': 16, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, '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': '4239494', 'n_tokens_mistral': 1764, 'n_tokens_neox': 1608, 'n_words': 579}