stellr 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +4 -0
- data/lib/stellr.rb +1 -1
- data/lib/stellr/collections/searchable_collection.rb +1 -1
- data/lib/stellr/search.rb +1 -0
- data/lib/stellr/search/search_result.rb +8 -0
- data/lib/stellr/search/search_results.rb +9 -0
- data/lib/stellr/server.rb +15 -4
- metadata +2 -2
data/History.txt
CHANGED
data/lib/stellr.rb
CHANGED
@@ -28,7 +28,7 @@ module Stellr
|
|
28
28
|
|
29
29
|
if options[:page]
|
30
30
|
results.current_page = options.delete(:page).to_i
|
31
|
-
options[:limit] = results.per_page = options.delete(:per_page) || 10
|
31
|
+
options[:limit] = results.per_page = (options.delete(:per_page).to_i rescue nil) || 10
|
32
32
|
options[:offset] = (p = results.current_page - 1) <= 0 ? 0 : p * results.per_page
|
33
33
|
end
|
34
34
|
|
data/lib/stellr/search.rb
CHANGED
@@ -9,6 +9,15 @@ module Stellr
|
|
9
9
|
def initialize
|
10
10
|
@results = []
|
11
11
|
end
|
12
|
+
|
13
|
+
def to_json
|
14
|
+
{
|
15
|
+
:results => @results,
|
16
|
+
:total_hits => total_hits,
|
17
|
+
:current_page => current_page,
|
18
|
+
:per_page => per_page
|
19
|
+
}.to_json
|
20
|
+
end
|
12
21
|
|
13
22
|
def method_missing(symbol, *args, &block)
|
14
23
|
@results.send(symbol, *args, &block)
|
data/lib/stellr/server.rb
CHANGED
@@ -68,8 +68,7 @@ module Stellr
|
|
68
68
|
#
|
69
69
|
#
|
70
70
|
def register( name, options = {} )
|
71
|
-
|
72
|
-
name.untaint
|
71
|
+
untaint_collection_name name
|
73
72
|
@collections.synchronize do
|
74
73
|
collection = (@collections[name] ||= create_collection( name, options ))
|
75
74
|
save_collection_config name, options unless options.nil? or options.empty?
|
@@ -138,13 +137,25 @@ module Stellr
|
|
138
137
|
|
139
138
|
def load_collection_config( name )
|
140
139
|
path = collection_config_path name
|
141
|
-
|
140
|
+
@logger.debug "trying to load collection config from #{path}"
|
141
|
+
conf = begin
|
142
|
+
YAML.load( File.read(path) ) if File.readable?(path)
|
143
|
+
rescue
|
144
|
+
@logger.error "error loading config: #{$!}\n#{$!.backtrace.join "\n"}"
|
145
|
+
nil
|
146
|
+
end
|
142
147
|
@logger.info "loaded collection config from #{path}" unless conf.nil?
|
143
148
|
return conf
|
144
149
|
end
|
145
150
|
|
146
151
|
def collection_config_path( name )
|
147
|
-
|
152
|
+
untaint_collection_name name
|
153
|
+
File.join @config.conf_dir, "#{name.untaint}.yml"
|
154
|
+
end
|
155
|
+
|
156
|
+
def untaint_collection_name(name)
|
157
|
+
raise "invalid collection name >#{name}<, may only contain a-zA-Z0-9_-" unless name =~ /^([a-zA-Z0-9_-]+)$/
|
158
|
+
name.untaint
|
148
159
|
end
|
149
160
|
|
150
161
|
# called by shutdown
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: stellr
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Benjamin Krause
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2008-08-
|
13
|
+
date: 2008-08-21 00:00:00 +02:00
|
14
14
|
default_executable:
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|