Skip to content

Commit

Permalink
fix whitespace
Browse files Browse the repository at this point in the history
  • Loading branch information
daveray committed Oct 19, 2011
1 parent e07b7f6 commit d9a2a0e
Showing 1 changed file with 20 additions and 20 deletions.
40 changes: 20 additions & 20 deletions lib/familiar.rb
Expand Up @@ -2,7 +2,7 @@

# The use and distribution terms for this software are covered by the
# Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)
# which can be found in the file epl-v10.html at the root of this
# which can be found in the file epl-v10.html at the root of this
# distribution.
# By using this software in any fashion, you are agreeing to be bound by
# the terms of this license.
Expand Down Expand Up @@ -71,7 +71,7 @@ def method_missing(meth, *args, &block)

# Returns a Clojure NS by name. When given no argument, returns clojure.core.
#
# This is generally useful because it provides access to Clojure vars
# This is generally useful because it provides access to Clojure vars
# for when you need to use a Clojure var without invoking it. Combine
# with NS.[] for this effect.
#
Expand Down Expand Up @@ -105,9 +105,9 @@ def self.ns (ns)
#
# [var] => #'clojure.core/var
#
# This is useful if you need to pass an existing Clojure function to a
# This is useful if you need to pass an existing Clojure function to a
# higher-order function.
#
#
# Note that there's significant overlap with Familiar.ns().
#
# Examples:
Expand Down Expand Up @@ -143,7 +143,7 @@ def self.[] (ns_name, var = nil)
end
ns(ns_name)[var]
end

def self.method_missing(meth, *args, &block)
ns(nil).send(meth, *args, &block)
end
Expand Down Expand Up @@ -185,7 +185,7 @@ def inspect!
# Run a block of code without having to qualify everything in this module:
#
# Examples:
#
#
# # Here, reduce, fn, range are all from Clojure
# Familiar.with do
# reduce fn {|acc, x| acc + x}, range(100)
Expand All @@ -199,7 +199,7 @@ def self.with(&block)
# Functions

# Wrap a Proc in a Java Callable
class Callable
class Callable
include Java::java.util.concurrent.Callable
def initialize(callable)
@callable = callable
Expand All @@ -224,7 +224,7 @@ def invoke(*args)
# Create a Clojure fn from a block
#
# Example:
#
#
# (fn [x] (+ x 1))
#
# is the same as:
Expand All @@ -236,7 +236,7 @@ def self.fn(p = nil, &code)
Fn.new &code
else
Fn.new &p
end
end
end

#############################################################################
Expand All @@ -255,8 +255,8 @@ def self.atom?(v)
end

class Java::ClojureLang::Atom
# Like clojure.core/swap! except block is used as update function

# Like clojure.core/swap! except block is used as update function
def swap!(&code)
swap(Familiar.fn(code))
end
Expand All @@ -280,17 +280,17 @@ class Java::ClojureLang::Ref

# Like clojure.core/alter except block is used as update function
def alter(&code)
java_send :alter,
[Java::clojure.lang.IFn.java_class,
java_send :alter,
[Java::clojure.lang.IFn.java_class,
Java::clojure.lang.ISeq.java_class],
Familiar.fn(code),
nil
end

# Like clojure.core/commute except block is used as update function
def commute(&code)
java_send :commute,
[Java::clojure.lang.IFn.java_class,
java_send :commute,
[Java::clojure.lang.IFn.java_class,
Java::clojure.lang.ISeq.java_class],
Familiar.fn(code),
nil
Expand All @@ -312,7 +312,7 @@ def send_off(&code)
Familiar.send_off(self, Familiar.fn(code))
end
end

#############################################################################
# Misc

Expand All @@ -323,7 +323,7 @@ def self.future(&code)

#############################################################################
# Type conversions

def self.to_clojure(v)
v.respond_to?(:to_clojure) ? v.to_clojure : v
end
Expand All @@ -342,10 +342,10 @@ def to_clojure
class ::Hash
def to_clojure
f = Familiar
f.into f.hash_map, map {|k,v| f.vector(f.to_clojure(k), f.to_clojure(v))}
f.into f.hash_map, map {|k,v| f.vector(f.to_clojure(k), f.to_clojure(v))}
end
end

class ::Set
def to_clojure
r = Familiar.hash_set()
Expand Down Expand Up @@ -390,7 +390,7 @@ class Java::ClojureLang::LazySeq
include ListToRuby
end

module MapToRuby
module MapToRuby
def to_ruby
r = {}
each do |k,v|
Expand Down

0 comments on commit d9a2a0e

Please sign in to comment.