Collage
Rack middleware that packages your JS into a single file.
git clone git://github.com/djanowski/collage.git
GET http://github.com/djanowski/collage
Collage
Rack middleware that packages your JS into a single file.
Usage
This middleware will package all your JavaScript into a single file – very much inspired by Rails’
javascript_include_tag(:all, :cache => true).use Collage, :path => File.dirname(__FILE__) + "/public" use Collage, :path => File.dirname(__FILE__) + "/public", :files => ["jquery*.js", "*.js"]Collage also provides a handy helper for your views. This is useful because it appends the correct timestamp to the
srcattribute, so you won’t have any issues with intermediate caches.<%= Collage.html_tag("./public") %>Installation
$ gem sources -a http://gems.github.com (you only have to do this once) $ sudo gem install djanowski-collageLicense
Copyright (c) 2009 Damian Janowski for Citrusbyte
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Contest
Contexts for Test::Unit.
git clone git://github.com/citrusbyte/contest.git
GET http://github.com/citrusbyte/contest
Contest
Contexts for Test::Unit.
Description
Write declarative tests using nested contexts without performance penalties. Contest is less than 100 lines of code and gets the job done.
Usage
Declare your tests as you would in RSpec or Shoulda:
require 'contest' class SomeTest < Test::Unit::TestCase setup do @value = 1 end teardown do @value = nil end test "sample test" do assert_equal 1, @value end context "a context" do setup do @value += 1 end test "more tests" do assert_equal 2, @value end context "a nested context" do setup do @value += 1 end test "yet more tests" do assert_equal 3, @value end end end endFor your convenience,
contextis aliased asdescribeandtestis aliased asshould, so this is valid:class SomeTest < Test::Unit::TestCase setup do @value = 1 end describe "something" do setup do @value += 1 end should "equal 2" do assert_equal 2, @value end end endYou can run it normally, it’s Test::Unit after all. If you want to run a particular test, say “yet more tests”, try this:
$ testrb my_test.rb -n test_yet_more_testsOr with a regular expression:
$ testrb my_test.rb -n /yet_more_tests/Installation
$ sudo gem install contestIf you want to use it with Rails, add this to config/environment.rb:
config.gem "contest"Then you can vendor the gem:
rake gems:install rake gems:unpackLicense
Copyright (c) 2009 Damian Janowski and Michel Martens for Citrusbyte
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Joe
Release your gems to RubyForge, no pain involved.
git clone git://github.com/djanowski/joe.git
GET http://github.com/djanowski/joe
Joe
Release your gems to RubyForge, no pain involved.
Usage
Joe assumes you have a .gemspec file in the current directory and it will use it to build the gem. Once you have it, try this:
$ thor joe:packageCongratulations, you should have your gem built and an archive copy inside the
pkgdirectory.Now go ahead and release your new gem to RubyForge:
$ thor joe:releaseEasy, right? Wait a few minutes until RubyForge updates its gems index and you will be able to run
sudo gem install foo.Troubleshooting
If you get an error about a missing
group_id, try runningrubyforge config. This hooks up your RubyForge account with the gem and configures where to release it.Maintaining a gemspec file
The easiest way we’ve found to maintain a gemspec file is by creating a
foo.gemspec.erbtemplate (see example). Then you can use a Thor task to produce the real gemspec file:$ thor joe:gemspecInstallation
You need the
rubyforgegem in order to release files. If you don’t have it already:$ sudo gem install rubyforge $ rubyforge setup $ rubyforge configMake sure you have Thor installed:
$ sudo gem install thorAnd then simply:
$ thor install http://dimaion.com/joe/joe.thorThat’s it. Try:
$ thor -TAnd you will get a list of Thor tasks.
Thanks
Thanks to Blake Mizerany for pointing us to the Sinatra Rakefile for reference.
License
Copyright (c) 2009 Damian Janowski and Michel Martens
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
jQuery Form Watermark
Add a watermark to your form elements – the jQuery way
git clone git://github.com/citrusbyte/jquery-watermark.git
GET http://github.com/citrusbyte/jquery-watermark
jQuery Form Watermark
Add a watermark to your form elements – the jQuery way
Description
So you have a text box and you want a default text on it acting as a call to action. When the user focuses on the text box, the default text should go away (and its styling could change, too). What you need is jQuery and this little snippet.
Usage
The only thing you need to add to you form is a
titleattribute:<form id="search"> <input type="text" title="Type to search" /> </form>Now in your JavaScript file:
$(document).ready(function() { $("#search").watermark(); });And if you want to make it look prettier:
input.watermark { color: #888; }Or, clone the repo and try the example.
Installation
You can grab the file directly from http://github.com/citrusbyte/jquery-watermark, or
$ git clone git://github.com/citrusbyte/jquery-watermark.git…and pick it from there. Make sure it’s required after jquery and jquery-ui.
License
Copyright (c) 2009 Damian Janowski for Citrusbyte
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
MicroMachine
Minimal Finite State Machine.
git clone git://github.com/soveran/micromachine.git
GET http://github.com/soveran/micromachine
MicroMachine
Minimal Finite State Machine.
Description
There are many finite state machine implementations for Ruby, and they all provide a nice DSL for declaring events, exceptions, callbacks, and all kinds of niceties in general.
But if all you want is a finite state machine, look no further: this is only 22 lines of code and provides everything a finite state machine must have, and nothing more.
Usage
require 'micromachine' machine = MicroMachine.new(:new) # Initial state. machine.transitions_for[:confirm] = { :new => :confirmed } machine.transitions_for[:ignore] = { :new => :ignored } machine.transitions_for[:reset] = { :confirmed => :new, :ignored => :new } machine.trigger(:confirm) #=> true machine.trigger(:ignore) #=> false machine.trigger(:reset) #=> true machine.trigger(:ignore) #=> trueIt can also have callbacks when entering some state:
machine.on(:confirmed) do puts "Confirmed" endInstallation
$ gem sources -a http://gems.github.com (you only have to do this once) $ sudo gem install soveran-micromachineLicense
Copyright (c) 2009 Michel Martens for Citrusbyte
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Milton
Milton is an upload-handling plugin for Rails that tries to make as few assumptions as possible while providing a lot of functionality.
git clone git://github.com/citrusbyte/milton.git
GET http://github.com/citrusbyte/milton
Milton
Milton is an upload-handling plugin for Rails that tries to make as few assumptions as possible while providing a lot of functionality.
Description
Milton is an upload-handling plugin that assumes little and is highly extensible. Many similar plugins make assumptions about the type of things you’ll be uploading and require some hacking when you want to do something like upload images with thumbnails as well as PDFs with previews. Milton attempts to solve this by assuming nothing about what you’ll be uploading and giving you, at the very least, a plugin for dealing with an underlying file-system.
You can then tack on extra functionality, like handling uploaded files (
is_uploadable), or resizing images (is_resizeable) to certain types of assets.Milton is built to be extensible by keeping pollution of your ActiveRecord model to a minimum, allowing you to extend Milton through a small and simple API rather than dealing with a giant module mixed into your classes.
Handling Uploads
Handling uploads is as simple as calling
is_uploadablein your Asset model (or Attachment model, or whatever else you want to call it) and then setting the file attribute on your model to the uploaded file.Example
Your
Assetmodel:class Asset < ActiveRecord::Base is_uploadable endNote: your underlying table (in this case
assets) must have a string column calledfilename.Your new
Assetform:- form_for Asset.new, :html => { :enctype => 'multipart/form-data' } do |f| = f.file_field :file = f.submit 'Upload'Your
AssetsController:class AssetsController < ApplicationController def create @asset = Asset.create params[:asset] end endResizing Images
Milton creates resized versions of images on demand, as opposed to
attachment_fuandPaperclipwhich create the resized versions when the source file is uploaded. The resized versions are created with a consistent filename and saved to the file system, so they will only be created the first time they are asked for.Currently Milton relies on ImageMagick (but not RMagick!). Once you have ImageMagick installed, just add
is_resizeableto your model in order to allow for image manipulation.class Image < ActiveRecord::Base is_uploadable is_resizeable endNote: there is also a helper
is_imagewhich can be used to specify bothis_uploadableandis_resizeableclass Image < ActiveRecord::Base is_image endOnce your model has
is_resizeableyou can pass an options hash to the#pathmethod to define how you want your resized version. The path to the resized version will be returned (and if no version has been created w/ the given options it will be created).Example
@image.path => .../000/000/000/001/milton.jpg @image.path(:size => '50x50') => .../000/000/000/001/milton.size_50x50.jpg @image.path(:size => '50x50', :crop => true) => .../000/000/000/001/milton.size-50x50_crop-true.jpgResizing Options
Note: currently the only options supported are
:sizeand:crop.
:sizetakes a geometry string similar to other image-manipulation plugins (based off ImageMagick’s geometry strings).
:size => '50x50'will resize the larger dimension down to 50px and maintain aspect ratio (you can use:cropfor forced zoom/cropping).
:size => '50x'will resize the width to 50px and maintain aspect ratio.
:size => 'x50'will resize the height to 50px and maintain aspect ratio.Then you can throw in
:cropto get zoom/cropping functionality:@image.path(:size => '50x50', :crop => true)This will create a 50px x 50px version of the image regardless of the source aspect-ratio. It will not distort the source image, rather it will resize the image as close to fitting as possible without distorting, then crop off the remainder.
By default
:cropuses a North/Center gravity – so the remainder will be cropped from the bottom and equally from both sides.Note: the
:sizeoption is required when resizing.Embedding Images
#pathwill always return the full path to the image, in your views you probably want to refer to the “public” path – the portion of the path from your/publicfolder up for embedding your images. For now there is a helper method that gets attached to your model called#public_paththat simply gives you the path frompublicon.@asset.public_path(:size => '50x50') => '/assets/000/000/001/234/milton.jpg'As opposed to:
@asset.path(:size => '50x50') => '/var/www/site/public/assets/000/000/001/234/milton.jpg'Note: if you use the
:file_system_pathoption to upload your files to somewhere outside of yourpublicfolder this will no longer work. You can pass a different folder topublic_pathto use as an alternate base.@asset.public_path(:size => '50x50', 'uploads')Options
A few options can be passed to the
is_uploadable/is_resizeablecalls in your models.Note: If you’re using Capistrano for deployment remember to put
:file_system_pathpath insharedand link it up on deploy so you don’t lose your uploads between deployments!Example
is_uplodable :chmod => 700, :file_system_path => File.join(Rails.root, 'uploads')Installation
Gem
$ gem install citrusbyte-milton --source http://gems.github.comRuby on Rails gem plugin:
Add to your environment.rb:
config.gem "citrusbyte-milton", :source => "http://gems.github.com", :lib => "milton"Then run:
$ rake gems:installRuby on Rails plugin
script/plugin install git://github.com/citrusbyte/milton.gitYou will also need to install ImageMagick to use image resizing.
Dependencies
- ActiveRecord
- Ruby on Rails (for now?)
- A filesystem (more storage solutions coming soon)
For image manipulation (not required!)
- ImageMagick (more processors coming soon)
Extended Usage Examples
Basic User Avatar
class User < ActiveRecord::Base
has_one :avatar, :dependent => :destroy
end
class Avatar < ActiveRecord::Base
is_image
belongs_to :user
end
Allow user to upload an avatar when creating
class UsersController < ActiveRecord::Base
def create
@user = User.new params[:user]
@user.avatar = Avatar.new(params[:avatar]) if params[:avatar] && params[:avatar][:file]
if @user.save
...
else
...
end
...
end
end
Allow user to upload a new avatar, note that we don’t care about updating files in this has_one case, we’re just gonna set a new relationship (which will destroy the existing one)
class AvatarsController < ActiveRecord::Base
def create
@user = User.find params[:user_id]
# setting a has_one on a saved object saves the new related object
if @user.avatar = Avatar.new(params[:avatar])
...
else
...
end
...
end
end
User’s profile snippet (in Haml)
#profile
= image_tag(@user.avatar.public_path(:size => '100x100', :crop => true))
= @user.name
Contributors
Milton is based on AttachmentPow by Ari Lerner (auser)
License
Copyright (c) 2009 Ben Alavi for Citrusbyte
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
OpenFriends
OpenFriends is about more than just your contacts: it’s about a distributed social layer for the web. Add your friends once, and take them with you, everywhere you go.
git clone git://github.com/citrusbyte/openfriends.git
GET http://github.com/citrusbyte/openfriends
OpenFriends
OpenFriends is about more than just your contacts: it’s about a distributed social layer for the web. Add your friends once, and take them with you, everywhere you go.
About OpenFriends
When you join a social network community site, you have to start adding your list of friends one by one. Either that, or you have to grant them access to your email account. In the end, it is either a real pain or a dangerous privacy violation. Besides, doing the same thing over and over for each new social website has turned the experience into a constant hassle.
OpenFriends solves this problem by providing a way for you to share your list of friends that respects your privacy.
Some solutions
Right now there is one way of easing the pain: microformats. You can have an hCard in some website, along with a list of contacts in XFN format, and point to that URL when signing up to that new social network website. There are many sites that already provide hCards and XFN lists for you, like Twitter and Flickr, and there are also some sites that are ready to consume that information. What is the problem then?
XFN and hCard limitations
Even though both XFN and hCard are standardized, each provider exposes the set of contact data of its preference. Besides, as the profile and the list of contacts are publicly accessible via web, there are a lot of privacy issues at stake. In the end, the XFN list shows only a list of related usernames within that website, and it is usually not enough information for recreating your network of friends somewhere else.
More information
Please refer to the openfriends website for more information about the initiative and what are the ideas behind the implementation.
License
Copyright (c) 2009 Citrusbyte
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Quiki
Quiki is a simple wiki aimed at developers.
git clone git://github.com/citrusbyte/quiki.git
GET http://github.com/citrusbyte/quiki
Quiki
Quiki is a simple wiki aimed at developers.
NAQ (Never Asked Questions)
Q. Why is a tiny app like Quiki written in big bulky Rails and not in something quick like Sinatra/Merb/Raw Machine Code?
A. Because Rails is so easy to extend and add to and can take advantage of all the wonderful plugins! (Quiki is built upon the backs of many previous laborers).
Installation
Quiki is a Ruby on Rails application, so in order to use it just clone this repository and start playing.
git clone git://github.com/citrusbyte/quiki.gitDependencies
It depends on Ultraviolet for code syntax highlighting:
$ gem install ultravioletIf it complains about needed Oniguruma, check http://snippets.aktagon.com/snippets/61-Installing-Ultraviolet-and-Oniguruma
It also depends on Graphviz for diagram generation
http://graphviz.org/License
Copyright (c) 2009 Ben Alavi for Citrusbyte
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Schemer
On-the-fly ActiveRecord schema changes for extremely rapid prototyping.
git clone git://github.com/citrusbyte/schemer.git
GET http://github.com/citrusbyte/schemer
Schemer
On-the-fly ActiveRecord schema changes for extremely rapid prototyping.
Description
Loosely define your schema in your ActiveRecord model and have it created and updated for you without worrying about migrations. Useful for when you want to play around with real data handling during prototyping but you really don’t care about keeping the data or how it’s defined.
WARNING: This will create and delete data definitions on the fly with no warning! Only use this with volatile data! Never attach it to an existing model you care about as it will start adding and dropping columns without your consent!
Usage
class User < ActiveRecord::Base schema :username, :password endCreates a
userstable if it doesn’t exist, complete withusernameandpasswordcolumns the first time you callUser.new.Need another column to play with?
class User < ActiveRecord::Base schema :username, :password, :email endAdds an
User.newis called.Don’t want a column anymore?
class User < ActiveRecord::Base schema :password, :email endRemoves the
usernamecolumn the next timeUser.newis called.Want a relationship?
class Widget < ActiveRecord::Base schema :user_id belongs_to :user endWorks just fine!
NOTE: All columns are created as string columns.
Installation
$ gem sources -a http://gems.github.com (you only have to do this once) $ sudo gem install citrusbyte-schemerLicense
Copyright (c) 2009 Ben Alavi for Citrusbyte
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Spawn
A ridiculously simple fixtures replacement for your web framework of choice.
git clone git://github.com/soveran/spawn.git
GET http://github.com/soveran/spawn
Spawn
A ridiculously simple fixtures replacement for your web framework of choice.
Description
Spawn is a very small library (just 14 lines of code) that can effectively replace fixtures or any other huge library for the same task.
Usage
In the examples below we are using Faker to generate random data, but you can use any method.
With ActiveRecord:
class User < ActiveRecord::Base spawner do |user| user.name = Faker::Name.name user.email = Faker::Internet.email end endWith Sequel:
class User < Sequel::Model extend Spawn spawner do |user| user.name = Faker::Name.name user.email = Faker::Internet.email end endIf you don’t want to pollute your class definition, you can of course use it from outside:
User.spawner do |user| user.name = Faker::Name.name user.email = Faker::Internet.email endThen, in your test or in any other place:
@user = User.spawnOr, if you need something special:
@user = User.spawn :name => "Michel Martens"Installation
$ sudo gem install spawnThanks
Thanks to Foca (http://github.com/foca/) for his suggestions and Pedro (http://github.com/peterpunk/) for the original gemspec.
License
Copyright (c) 2009 Michel Martens for Citrusbyte
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
StoreObserver
Automatically expire cached fragments in Ruby on Rails based on the state of the models involved.
git clone git://github.com/citrusbyte/store_observer.git
GET http://github.com/citrusbyte/store_observer
StoreObserver
Automatically expire cached fragments in Ruby on Rails based on the state of the models involved.
Usage
In any view:
<% store 'fragment_name', :observe => [:users, :coments] do %> cached fragment which does something intensive <% end %>This fragment will be cached until a save or destroy occur in the User and Comment models.
Installation
You can install it as a Rails plugin or as a gem:
$ gem sources -a http://gems.github.com (you only have to do this once) $ sudo gem install citrusbyte-store_observerLicense
Copyright (c) 2008 Michel Martens and Ben Alavi for Citrusbyte
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
git clone git://github.com/citrusbyte/stories.git
GET http://github.com/citrusbyte/stories
Stories
Stories and User Acceptance Tests for the minimalist test framework Contest.
Description
Write user stories and user acceptace tests using Contest, the tiny add on to Test::Unit that provides nested contexts and declarative tests.
Usage
Declare your stories as follows:
require 'stories' class UserStoryTest < Test::Unit::TestCase story "As a user I want to create stories so I can test if they pass" do setup do @user = "valid user" end scenario "A valid user" do assert_equal "valid user", @user end end endIf you are using Rails, you can use stories for your integration tests with Webrat:
class UserStoriesTest < ActionController::IntegrationTest story "As a user I want to log in so that I can access restricted features" do setup do @user = User.spawn end scenario "Using good information" do visit "/" click_link "Log in" fill_in :session_email, :with => user.email fill_in :session_password, :with => user.password click_button "Sign in" assert_not_contain "Log in" assert_not_contain "Sign up" end end endYou can run it normally, it’s Test::Unit after all. If you want to run a particular test, say “yet more tests”, try this:
$ ruby my_test.rb -n test_yet_more_testsOr with a regular expression:
$ ruby my_test.rb -n /yet_more_tests/Awesome output
You can get a nice output with your user stories with the
storiesrunner:$ ruby my_test.rb --runner=storiesNow, if you want to impress everyone around you, try this:
$ ruby my_test.rb --runner=stories-pdfYou will get a nicely formatted PDF with your user stories. It uses Prawn, so you will need to install it first.
Installation
$ sudo gem install storiesIf you want to use it with Rails, add this to config/environment.rb:
config.gem "stories"Then you can vendor the gem:
rake gems:install rake gems:unpackLicense
Copyright (c) 2009 Damian Janowski and Michel Martens for Citrusbyte
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.