Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ rdoc
pkg
\#*
.#*
*.gem
1 change: 1 addition & 0 deletions .rvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
rvm use 1.9.2@bitmask_attributes --create --install
11 changes: 11 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
source "http://rubygems.org"

gemspec

if RUBY_VERSION < '1.9'
gem "ruby-debug", ">= 0.10.3"
end

gem 'shoulda'
gem 'sqlite3'
gem 'turn'
37 changes: 37 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
PATH
remote: .
specs:
bitmask_attributes (0.2.1)
activerecord (~> 3.0)

GEM
remote: http://rubygems.org/
specs:
activemodel (3.0.9)
activesupport (= 3.0.9)
builder (~> 2.1.2)
i18n (~> 0.5.0)
activerecord (3.0.9)
activemodel (= 3.0.9)
activesupport (= 3.0.9)
arel (~> 2.0.10)
tzinfo (~> 0.3.23)
activesupport (3.0.9)
ansi (1.3.0)
arel (2.0.10)
builder (2.1.2)
i18n (0.5.0)
shoulda (2.11.3)
sqlite3 (1.3.3)
turn (0.8.2)
ansi (>= 1.2.2)
tzinfo (0.3.29)

PLATFORMS
ruby

DEPENDENCIES
bitmask_attributes!
shoulda
sqlite3
turn
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright (c) 2007-2009 Bruce Williams
Copyright (c) 2007-2009 Bruce Williams & 2011 Joel Moss

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
Expand Down
52 changes: 35 additions & 17 deletions README.markdown → README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,20 @@
bitmask-attribute
BitmaskAttributes
=================

Transparent manipulation of bitmask attributes.
Transparent manipulation of bitmask attributes for ActiveRecord, based on
the bitmask-attribute gem, which has been dormant since 2009. This updated
gem work with Rails 3 and up (including Rails 3.1).

Installation
------------

The best way to install is with RubyGems:

$ [sudo] gem install bitmask_attributes

Or better still, just add it to your Gemfile:

gem 'bitmask_attributes'

Example
-------
Expand Down Expand Up @@ -40,6 +53,11 @@ Or, just check if any values are present:
user.roles?
# => true

You can get the list of values for any given attribute:

User.values_for_roles
# => [:writer, :publisher, :editor, :proofreader]

Named Scopes
------------

Expand All @@ -52,11 +70,8 @@ A couple useful named scopes are also generated when you use
# => (all editors)
User.with_roles(:editor, :writer)
# => (all users who are BOTH editors and writers)

Later we'll support an `or` boolean; for now, do something like:

User.with_roles(:editor) + User.with_roles(:writer)
# => (all users who are EITHER editors and writers)
User.with_any_roles(:editor, :writer)
# => (all users who are editors OR writers)

Find records without any bitmask set:

Expand Down Expand Up @@ -89,25 +104,28 @@ IMPORTANT: Once you have data using a bitmask, don't change the order
of the values, remove any values, or insert any new values in the `:as`
array anywhere except at the end. You won't like the results.

Contributing and reporting issues
---------------------------------

Please feel free to fork & contribute fixes via GitHub pull requests.
The official repository for this project is
http://github.com/bruce/bitmask-attribute
Contributing
------------

Issues can be reported at
http://github.com/bruce/bitmask-attribute/issues
1. Fork it.
2. Create a branch (`git checkout -b new-feature`)
3. Make your changes
4. Run the tests (`bundle install` then `bundle exec rake`)
5. Commit your changes (`git commit -am "Created new feature"`)
6. Push to the branch (`git push origin new-feature`)
7. Create a [Pull Request](http://help.github.com/pull-requests/) from your branch.
8. Promote it. Get others to drop in and +1 it.

Credits
-------

Thanks to the following contributors:
Thanks to [Bruce Williams](https://github.com/bruce) and the following contributors
of the bitmask-attribute plugin:

* [Jason L Perry](http://github.com/ambethia)
* [Nicolas Fouché](http://github.com/nfo)

Copyright
---------

Copyright (c) 2007-2009 Bruce Williams. See LICENSE for details.
Copyright (c) 2007-2009 Bruce Williams & 2011 Joel Moss. See LICENSE for details.
61 changes: 10 additions & 51 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -1,57 +1,16 @@
require 'rubygems'
require 'rake'
# encoding: UTF-8

begin
require 'jeweler'
Jeweler::Tasks.new do |gem|
gem.name = "bitmask-attribute"
gem.summary = %Q{Simple bitmask attribute support for ActiveRecord}
gem.email = "bruce@codefluency.com"
gem.homepage = "http://github.com/bruce/bitmask-attribute"
gem.authors = ["Bruce Williams"]
gem.add_dependency 'activerecord'
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
end
Jeweler::GemcutterTasks.new
rescue LoadError
puts "Jeweler not available. Install it with: sudo gem install technicalpickles-jeweler -s http://gems.github.com"
end
require "bundler"
Bundler::GemHelper.install_tasks

require 'rake/testtask'
Rake::TestTask.new(:test) do |test|
test.libs << 'lib' << 'test'
test.pattern = 'test/**/*_test.rb'
test.verbose = true
end

begin
require 'rcov/rcovtask'
Rcov::RcovTask.new do |test|
test.libs << 'test'
test.pattern = 'test/**/*_test.rb'
test.verbose = true
end
rescue LoadError
task :rcov do
abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
end
end


desc 'Default: run unit tests.'
task :default => :test

require 'rake/rdoctask'
Rake::RDocTask.new do |rdoc|
if File.exist?('VERSION.yml')
config = YAML.load(File.read('VERSION.yml'))
version = "#{config[:major]}.#{config[:minor]}.#{config[:patch]}"
else
version = ""
end

rdoc.rdoc_dir = 'rdoc'
rdoc.title = "bitmask-attribute #{version}"
rdoc.rdoc_files.include('README*')
rdoc.rdoc_files.include('lib/**/*.rb')
end

Rake::TestTask.new(:test) do |t|
t.libs << 'lib'
t.libs << 'test'
t.pattern = 'test/**/*_test.rb'
t.verbose = true
end
1 change: 0 additions & 1 deletion VERSION

This file was deleted.

20 changes: 20 additions & 0 deletions bitmask_attributes.gemspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# -*- encoding: utf-8 -*-
$:.push File.expand_path("../lib", __FILE__)
require "bitmask_attributes/version"

Gem::Specification.new do |gem|
gem.name = "bitmask_attributes"
gem.summary = %Q{Simple bitmask attribute support for ActiveRecord}
gem.description = %Q{Simple bitmask attribute support for ActiveRecord}
gem.email = "joel@developwithstyle.com"
gem.homepage = "http://github.com/joelmoss/bitmask_attributes"
gem.authors = ['Joel Moss']

gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
gem.files = `git ls-files`.split("\n")
gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
gem.require_paths = ['lib']
gem.version = BitmaskAttributes::VERSION

gem.add_dependency 'activerecord', '~> 3.0'
end
2 changes: 0 additions & 2 deletions lib/bitmask-attribute.rb

This file was deleted.

Loading