h1. Sugar high!

Inspired by the 'zucker' project.

!secure.travis-ci.org/kristianmandrup/sugar-high.png(Build Status)!:travis-ci.org/kristianmandrup/sugar-high

h2. Install

gem install sugar-high

h2. Usage

See specs for example use

h2. Update Aug 21, 2011

Extracted file_mutate and sweetloader gems.

Only tested for Ruby 1.9.2 and 1.9.3. Using *Travis CI*.

h2. Sugar packs

h3. Alias

h3. Arguments

h3. Array

h3. Blank

h3. Class Extension

Makes it easy to autoload multiple modules by standard folder-to-module mapping convention

Note: This pack has recently been extracted into its own gem called sweet_loader

h3. Delegate

Extracted from Active Support core extensions:

See “Delegate”:apidock.com/rails/Module/delegate

@activesupport/lib/active_support/core_ext/module/delegation.rb@

h3. DSL

by @stanislaw

Useful as a building block for DSLs!

<pre> with(Hash.new) do

merge!(:a => 1)
merge!(:b => 2)

end.should == {:a => 1, :b => 2}

with(Hash.new, :ready => true) do |options|

...

end

with(Hash.new, 1,2,3) do |*args|

...

end </pre>

h3. Enumerable

h3. File

h3. Hash

h3. Includes

h3. Kind of

h3. Metaclass

h3. Methods

h3. Module

Create empty namespaces

h3. Not

Adds the #not method to Object, so you can say fx: if x.not.empty?

h3. Numeric

module NumericCheckExt

module NumberDslExt added to all numeric classes (Float and Numeric)

<pre>3.thousand + 2.hundred

=> 3200

</pre>

h3. Path

module PathString

<pre> “a/b/c”.to_dir “a/b/c/d.rb”.to_file </pre>

File type existance

Navigate dirs

<pre> “a/b/c/d”.up(2).should == “a/b” “a/b/”.post_up(2).should == “a/b/../../”

“a/b/../”.post_down(1).should == “a/b/”

</pre>

h3. Properties

<pre> class CruiseShip

extend Properties

property :direction
property :speed, is(0..300)

end

ship = CruiseShip.new ship.add_direction_listener(lambda {|x| puts “Oy… someone changed the direction to #{x}”})

ship.speed = 200 ship.speed = 301 # outside valid range! </pre>

h3. RegExp

String, RegExp

<pre>“a, b /c”.to_regexp # escapes it for reg exp!</pre>

MatchData

h3. RSpec 2 Matchers

<pre>

require 'sugar-high/rspec'

have_aliases :original, :alias_1, :alias2

</pre>

h3. Rails

Currently the following Rails packs are included:

More to follow in the future…

h4. Concerns

@require 'rails/concerns'@

Useful concern pattern in order to include concern modules into Rails models (or even controllers etc.)

h3. String

Class methods

Instance methods

If not already defined

h2. Note on Patches/Pull Requests

h2. Copyright

Copyright © 2010 Kristian Mandrup. See LICENSE for details.