Skip to content
This repository has been archived by the owner on Jun 16, 2020. It is now read-only.

Commit

Permalink
Created docs
Browse files Browse the repository at this point in the history
  • Loading branch information
joelmoss committed Nov 23, 2011
1 parent 6c29dc4 commit 3abb0b8
Show file tree
Hide file tree
Showing 37 changed files with 4,605 additions and 31 deletions.
Empty file added CHANGELOG.rdoc
Empty file.
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ if RUBY_VERSION < '1.9'
gem "ruby-debug", ">= 0.10.3"
end

gem 'sdoc'
gem 'rake'
gem 'shoulda'
gem 'sqlite3', '>=1.3.4'
Expand Down
7 changes: 7 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,14 @@ GEM
arel (2.2.1)
builder (3.0.0)
i18n (0.6.0)
json (1.6.1)
multi_json (1.0.3)
rake (0.9.2.2)
rdoc (3.11)
json (~> 1.4)
sdoc (0.3.16)
json (>= 1.1.3)
rdoc (~> 3.10)
shoulda (2.11.3)
sqlite3 (1.3.4)
turn (0.8.3)
Expand All @@ -36,6 +42,7 @@ PLATFORMS
DEPENDENCIES
bitmask_attributes!
rake
sdoc
shoulda
sqlite3 (>= 1.3.4)
turn
55 changes: 27 additions & 28 deletions README.md → README.rdoc
Original file line number Diff line number Diff line change
@@ -1,46 +1,45 @@
BitmaskAttributes
=================
== BitmaskAttributes

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
------------

=== 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
-------

=== Example

Simply declare an existing integer column as a bitmask with its possible
values.

class User < ActiveRecord::Base
bitmask :roles, :as => [:writer, :publisher, :editor, :proofreader]
bitmask :roles, :as => [:writer, :publisher, :editor, :proofreader]
end

You can then modify the column using the declared values without resorting
to manual bitmasks.

user = User.create(:name => "Bruce", :roles => [:publisher, :editor])
user.roles
# => [:publisher, :editor]
user.roles << :writer
user.roles
# => [:publisher, :editor, :writer]

It's easy to find out if a record has a given value:

user.roles?(:editor)
# => true

You can check for multiple values (uses an `and` boolean):

user.roles?(:editor, :publisher)
Expand All @@ -58,8 +57,8 @@ You can get the list of values for any given attribute:
User.values_for_roles
# => [:writer, :publisher, :editor, :proofreader]

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

=== Named Scopes

A couple useful named scopes are also generated when you use
`bitmask`:
Expand Down Expand Up @@ -87,8 +86,8 @@ Find records without a specific attribute.

Note that "without_" only supports a single attribute argument, and the "no_" method does not support arguments.

Adding Methods
--------------

=== Adding Methods

You can add your own methods to the bitmasked attributes (similar to
named scopes):
Expand All @@ -104,35 +103,35 @@ named scopes):
# => true


Warning: Modifying possible values
----------------------------------
=== Warning: Modifying possible values

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
------------

=== Contributing

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.
7. Create a {pull request}[http://help.github.com/send-pull-requests/] from your branch.
8. Promote it. Get others to drop in and +1 it.

Credits
-------

Thanks to [Bruce Williams](https://github.com/bruce) and the following contributors
=== Credits

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)
* {Jason L Perry}[http://github.com/ambethia]
* {Nicolas Fouché}[http://github.com/nfo]
* {Ivan Buiko}[http://github.com/IvanBuiko]


Copyright
---------
=== Copyright

Copyright (c) 2007-2009 Bruce Williams & 2011 Joel Moss. See LICENSE for details.
19 changes: 16 additions & 3 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,20 @@ def gem_file
"#{name}-#{version}.gem"
end

require 'rdoc/task'
require 'sdoc'
Rake::RDocTask.new do |rdoc|
rdoc.rdoc_dir = 'doc'
rdoc.title = "#{name} #{version}"
rdoc.options << '-f' << 'sdoc'
rdoc.options << '-a'
rdoc.options << '--markup' << 'tomdoc'
rdoc.options << '-m' << 'README.rdoc'
rdoc.rdoc_files.include('CHANGELOG*')
rdoc.rdoc_files.include('README*')
rdoc.rdoc_files.include('lib/**/*.rb')
end


#############################################################################
#
Expand Down Expand Up @@ -98,7 +112,6 @@ EOF
load "lib/#{name}/version.rb"
file = "CHANGELOG.rdoc"
old = File.read(file)
version = Deals::VERSION
message = "Bumping to version #{version}"

File.open(file, "w") do |f|
Expand All @@ -110,9 +123,9 @@ EOF
EOF
end

exec "#{ENV["EDITOR"]} #{file}"
Rake::Task['build'].invoke
exec ["git commit -aqm '#{message}'",
exec ["#{ENV["EDITOR"]} #{file}",
"git commit -aqm '#{message}'",
"git tag -a -m '#{message}' v#{version}",
"git push origin master",
"git push origin $(git tag | tail -1)",
Expand Down
Binary file added doc/apple-touch-icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
114 changes: 114 additions & 0 deletions doc/classes/BitmaskAttributes.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>BitmaskAttributes</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link rel="stylesheet" href="../css/reset.css" type="text/css" media="screen" />
<link rel="stylesheet" href="../css/main.css" type="text/css" media="screen" />
<link rel="stylesheet" href="../css/github.css" type="text/css" media="screen" />
<script src="../js/jquery-1.3.2.min.js" type="text/javascript" charset="utf-8"></script>
<script src="../js/jquery-effect.js" type="text/javascript" charset="utf-8"></script>
<script src="../js/main.js" type="text/javascript" charset="utf-8"></script>
<script src="../js/highlight.pack.js" type="text/javascript" charset="utf-8"></script>

</head>

<body>
<div class="banner">

<h1>
<span class="type">Module</span>
BitmaskAttributes

</h1>
<ul class="files">

<li><a href="../files/lib/bitmask_attributes/definition_rb.html">lib/bitmask_attributes/definition.rb</a></li>

<li><a href="../files/lib/bitmask_attributes/value_proxy_rb.html">lib/bitmask_attributes/value_proxy.rb</a></li>

<li><a href="../files/lib/bitmask_attributes/version_rb.html">lib/bitmask_attributes/version.rb</a></li>

<li><a href="../files/lib/bitmask_attributes_rb.html">lib/bitmask_attributes.rb</a></li>

</ul>
</div>
<div id="bodyContent">
<div id="content">











<!-- Namespace -->
<div class="sectiontitle">Namespace</div>
<ul>

<li>
<span class="type">MODULE</span>
<a href="BitmaskAttributes/ClassMethods.html">BitmaskAttributes::ClassMethods</a>
</li>

<li>
<span class="type">CLASS</span>
<a href="BitmaskAttributes/Definition.html">BitmaskAttributes::Definition</a>
</li>

<li>
<span class="type">CLASS</span>
<a href="BitmaskAttributes/ValueProxy.html">BitmaskAttributes::ValueProxy</a>
</li>

</ul>
















<!-- Section constants -->
<div class="sectiontitle">Constants</div>
<table border='0' cellpadding='5'>

<tr valign='top'>
<td class="attr-name">VERSION</td>
<td>=</td>
<td class="attr-value">&quot;0.2.3&quot;.freeze</td>
</tr>

<tr valign='top'>
<td>&nbsp;</td>
<td colspan="2" class="attr-desc"></td>
</tr>


</table>






<!-- Methods -->
</div>
</div>
</body>
</html>
Loading

0 comments on commit 3abb0b8

Please sign in to comment.