map_reduced 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/map_reduced/config.rb +3 -1
- data/lib/map_reduced/document.rb +7 -10
- data/lib/map_reduced.rb +1 -2
- metadata +4 -4
data/lib/map_reduced/config.rb
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
module MapReduced
|
2
2
|
class Config
|
3
3
|
class << self
|
4
|
-
|
4
|
+
|
5
|
+
attr_writer :template_path
|
5
6
|
attr_reader :db
|
6
7
|
|
7
8
|
def database(string)
|
@@ -9,6 +10,7 @@ module MapReduced
|
|
9
10
|
end
|
10
11
|
|
11
12
|
def template_path
|
13
|
+
return @template_path if defined?(@template_path)
|
12
14
|
defined?(Rails) ? Rails.root + "app/functions" : Pathname.new(File.expand_path("./functions"))
|
13
15
|
end
|
14
16
|
|
data/lib/map_reduced/document.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
module MapReduced
|
2
2
|
module Document
|
3
3
|
module ClassMethods
|
4
|
-
|
4
|
+
@@added_functions = []
|
5
5
|
def map_reduce(*names)
|
6
6
|
names.each do |name|
|
7
7
|
self.class_eval %Q{
|
@@ -25,6 +25,10 @@ module MapReduced
|
|
25
25
|
db.collection(collection_name)
|
26
26
|
end
|
27
27
|
|
28
|
+
def use_functions(*names)
|
29
|
+
@@added_functions = names
|
30
|
+
end
|
31
|
+
|
28
32
|
private
|
29
33
|
|
30
34
|
def collection_name
|
@@ -43,18 +47,14 @@ module MapReduced
|
|
43
47
|
function_string("#{function}_reduce")
|
44
48
|
end
|
45
49
|
|
46
|
-
def functions(*names)
|
47
|
-
@@functions = names
|
48
|
-
end
|
49
|
-
|
50
50
|
def setup_functions
|
51
|
-
@@
|
51
|
+
@@added_functions.each do |function_name|
|
52
52
|
db.add_stored_function(function_name.to_s, function_string(function_name))
|
53
53
|
end
|
54
54
|
end
|
55
55
|
|
56
56
|
def teardown_functions
|
57
|
-
@@
|
57
|
+
@@added_functions.each {|name| db.remove_stored_function(name.to_s)}
|
58
58
|
end
|
59
59
|
|
60
60
|
def function_string(name)
|
@@ -72,9 +72,6 @@ module MapReduced
|
|
72
72
|
end
|
73
73
|
|
74
74
|
def self.included(receiver)
|
75
|
-
receiver.class_eval %Q{
|
76
|
-
@@functions = []
|
77
|
-
}
|
78
75
|
receiver.extend ClassMethods
|
79
76
|
receiver.send :include, InstanceMethods
|
80
77
|
end
|
data/lib/map_reduced.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: map_reduced
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 27
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 2
|
10
|
+
version: 0.0.2
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Scott Burton
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2010-08-
|
18
|
+
date: 2010-08-29 00:00:00 -07:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|