Skip to content

Commit ac56495

Browse files
committed
finally configured texmate to remove trailing white-spaces
1 parent 18a9664 commit ac56495

11 files changed

+418
-418
lines changed

lib/jor/collection.rb

+101-101
Large diffs are not rendered by default.

lib/jor/doc.rb

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
module JOR
33
class Doc
4-
4+
55
def self.paths(path,h)
66
if h.class==Hash
77
v = []
@@ -30,27 +30,27 @@ def self.paths(path,h)
3030
end
3131
end
3232
end
33-
33+
3434
def self.difference(set, set_to_substract)
3535
return set if set_to_substract.nil? || set_to_substract.size==0
36-
36+
3737
to_exclude = []
3838
set_to_substract.each do |item|
3939
raise FieldIdCannotBeExcludedFromIndex.new unless item["path_to"].match(/\/_id/)==nil
4040
to_exclude << Regexp.new("^#{item["path_to"]}")
4141
end
42-
42+
4343
res = []
4444
set.each do |item|
4545
not_found = true
4646
to_exclude.each do |re|
4747
not_found = not_found && re.match(item["path_to"])==nil
4848
end
4949
res << item if not_found
50-
end
50+
end
5151
return res
5252
end
53-
53+
5454
def self.deep_merge(dest, source)
5555
res = Hash.new
5656
dest.merge(source) do |key, old_v, new_v|

lib/jor/errors.rb

+11-11
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,19 @@
22
module JOR
33
class Error < RuntimeError
44
end
5-
5+
66
class NoResults < Error
77
def initialize(doc)
88
super %(no results found for "#{doc}")
99
end
1010
end
11-
11+
1212
class TypeNotSupported < Error
1313
def initialize(class_name)
1414
super %(Type #{class_name} not supported)
1515
end
1616
end
17-
17+
1818
class InvalidFieldName < Error
1919
def initialize(field)
2020
super %(Invalid character in field name "#{field}". Cannot start with '_' or '$')
@@ -32,7 +32,7 @@ def initialize(id, name)
3232
super %(A document with _id #{id} already exists in collection "{name}")
3333
end
3434
end
35-
35+
3636
class DocumentNeedsId < Error
3737
def initialize(name)
3838
super %(The collection #{name} is not auto-incremental. You must define the "_id" of the document")
@@ -50,13 +50,13 @@ def initialize(str)
5050
super %(Incompatible selectors in "#{str}". They must be grouped like this #{Storage::SELECTORS})
5151
end
5252
end
53-
53+
5454
class NotInCollection < Error
5555
def initialize
5656
super %(The current collection is undefined)
5757
end
5858
end
59-
59+
6060
class CollectionDoesNotExist < Error
6161
def initialize(str)
6262
super %(Collection "#{str}" does not exist)
@@ -74,23 +74,23 @@ def initialize(str)
7474
super %(Collection "#{str}" is not a valid name, might be reserved)
7575
end
7676
end
77-
77+
7878
class FieldIdCannotBeExcludedFromIndex < Error
7979
def initialize
8080
super %(Field _id cannot be excluded from the index)
8181
end
8282
end
83-
83+
8484
class CouldNotFindPathToFromIndex < Error
8585
def initialize(str)
8686
super %(Could not find path_to from index #{str})
8787
end
8888
end
89-
89+
9090
class CouldNotFindPathToFromIndex < Error
9191
def initialize(index, id)
9292
super %(Unknown index #{index} in document #{id})
9393
end
9494
end
95-
96-
end
95+
96+
end

lib/jor/server.rb

+15-15
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,46 @@
11

22
module JOR
33
class Server
4-
4+
55
def initialize(redis = nil)
66
## defaults to test db on redis
77
redis ||= Redis.new(:db => 9, :driver => :hiredis)
88
@jor = JOR::Storage.new(redis)
99
end
10-
10+
1111
def call(env)
12-
req = Rack::Request.new(env)
13-
method = req.path
14-
12+
req = Rack::Request.new(env)
13+
method = req.path
14+
1515
if env["REQUEST_METHOD"]!="PUT"
1616
return [422, {"Content-Type" => "application/json"}, [{"error" => "only method accepted is PUT"}.to_json]]
17-
end
18-
17+
end
18+
1919
clean_methods = method.gsub("/","").split(".")
2020
clean_methods.map!(&:to_sym)
2121

2222
args = req.params["args"]
23-
clean_args = []
23+
clean_args = []
2424
body_str = req.body.read
2525
clean_args = JSON::parse(body_str) unless body_str.nil? || body_str.empty?
26-
27-
begin
26+
27+
begin
2828
obj = @jor
2929
res = nil
30-
30+
3131
clean_methods.each_with_index do |meth, i|
3232
if i==clean_methods.size()-1
3333
res = obj.public_send(meth,*clean_args)
3434
else
3535
obj = obj.public_send(meth)
36-
end
37-
end
38-
36+
end
37+
end
38+
3939
if res.class==Hash || res.class==Array
4040
return [200, {"Content-Type" => "application/json"}, [res.to_json]]
4141
else
4242
return [200, {"Content-Type" => "application/json"}, [{"value" => res}.to_json]]
43-
end
43+
end
4444
rescue Exception => e
4545
return [422, {"Content-Type" => "application/json"}, [{"error" => e.message}.to_json]]
4646
end

lib/jor/storage.rb

+6-6
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,14 @@ def initialize(redis_client = nil)
1818
def redis
1919
@redis
2020
end
21-
21+
2222
def collections
2323
redis.smembers("#{Storage::NAMESPACE}/collections")
2424
end
2525

2626
def create_collection(name, options = {:auto_increment => false})
2727
options = {:auto_increment => false}.merge(options.inject({}){|memo,(k,v)| memo[k.to_sym] = v; memo})
28-
raise CollectionNotValid.new(name) if self.respond_to?(name)
28+
raise CollectionNotValid.new(name) if self.respond_to?(name)
2929
is_new = redis.sadd("#{Storage::NAMESPACE}/collections",name)
3030
raise CollectionAlreadyExists.new(name) if (is_new==false or is_new==0)
3131
redis.set("#{Storage::NAMESPACE}/collection/#{name}/auto-increment", options[:auto_increment])
@@ -39,7 +39,7 @@ def destroy_collection(name)
3939
redis.srem("#{Storage::NAMESPACE}/collections",name)
4040
redis.del("#{Storage::NAMESPACE}/collection/#{name}/auto-increment")
4141
end
42-
name
42+
name
4343
end
4444

4545
def destroy_all()
@@ -71,18 +71,18 @@ def info
7171
def method_missing(method)
7272
find_collection(method)
7373
end
74-
74+
7575
def find_collection(method)
7676
redis_auto_incr = redis.get("#{Storage::NAMESPACE}/collection/#{method}/auto-increment")
7777
if (redis_auto_incr=="true")
78-
auto_increment = true
78+
auto_increment = true
7979
elsif (redis_auto_incr=="false")
8080
auto_increment = false
8181
else
8282
raise CollectionDoesNotExist.new(method.to_s)
8383
end
8484
Collection.new(self, method, auto_increment)
85-
end
85+
end
8686

8787
end
8888
end

test/test_helpers/fixtures.rb

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module TestHelpers
22
module Fixtures
3-
3+
44
def create_sample_doc_cs(partial_doc = {})
55
doc = {
66
"_id" => 1,
@@ -64,7 +64,7 @@ def create_sample_doc_restaurant(partial_doc = {})
6464
}
6565
doc.merge(partial_doc)
6666
end
67-
67+
6868
end
6969
end
7070

0 commit comments

Comments
 (0)