cubicle 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.rdoc +2 -0
- data/LICENSE.txt +22 -0
- data/README.rdoc +173 -0
- data/Rakefile +49 -0
- data/cubicle.gemspec +91 -0
- data/examples/cubicles/poker_hand_cubicle.rb +16 -0
- data/examples/models/poker_hand.rb +3 -0
- data/lib/cubicle.rb +389 -0
- data/lib/cubicle/aggregation.rb +10 -0
- data/lib/cubicle/calculated_measure.rb +18 -0
- data/lib/cubicle/data.rb +84 -0
- data/lib/cubicle/data_level.rb +60 -0
- data/lib/cubicle/date_time.rb +33 -0
- data/lib/cubicle/dimension.rb +4 -0
- data/lib/cubicle/measure.rb +16 -0
- data/lib/cubicle/member.rb +53 -0
- data/lib/cubicle/member_list.rb +11 -0
- data/lib/cubicle/mongo_environment.rb +102 -0
- data/lib/cubicle/mongo_mapper/aggregate_plugin.rb +17 -0
- data/lib/cubicle/query.rb +315 -0
- data/lib/cubicle/ratio.rb +12 -0
- data/lib/cubicle/support.rb +46 -0
- data/lib/cubicle/version.rb +3 -0
- data/test/config/database.yml +15 -0
- data/test/cubicle/cubicle_aggregation_test.rb +21 -0
- data/test/cubicle/cubicle_data_level_test.rb +58 -0
- data/test/cubicle/cubicle_data_test.rb +51 -0
- data/test/cubicle/cubicle_query_test.rb +326 -0
- data/test/cubicle/cubicle_test.rb +85 -0
- data/test/cubicle/mongo_mapper/aggregate_plugin_test.rb +39 -0
- data/test/cubicles/defect_cubicle.rb +26 -0
- data/test/log/test.log +6813 -0
- data/test/models/defect.rb +73 -0
- data/test/test_helper.rb +62 -0
- metadata +144 -0
@@ -0,0 +1,73 @@
|
|
1
|
+
class Defect
|
2
|
+
#include MongoMapper::Document
|
3
|
+
|
4
|
+
#key :defect_id, String
|
5
|
+
#key :manufacture_date, String
|
6
|
+
#key :manufacture_time, Time
|
7
|
+
#key :product, Product
|
8
|
+
#key :plant, Plant
|
9
|
+
#key :operator, String
|
10
|
+
#key :outcome, String
|
11
|
+
#key :cost, Float
|
12
|
+
#key :root_cause, String
|
13
|
+
|
14
|
+
def self.collection
|
15
|
+
Cubicle.mongo.database["defects"]
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.create(attributes)
|
19
|
+
self.collection.insert(attributes)
|
20
|
+
end
|
21
|
+
|
22
|
+
def self.create_test_data
|
23
|
+
Defect.create :defect_id=>"1",
|
24
|
+
:manufacture_date=>"2010-01-01",
|
25
|
+
:manufacture_time=>"2010-01-01".to_time,
|
26
|
+
:product=>{:name=>"Sad Day Moonshine",:category=>"Alcohol"},
|
27
|
+
:plant=>{:name=>"Plant1",:address=>{:region=>"West",:location=>"San Francisco, Ca"}},
|
28
|
+
:operator=>"Franny",
|
29
|
+
:outcome=>"Repaired",
|
30
|
+
:cost=>0.78,
|
31
|
+
:root_cause=>:act_of_god
|
32
|
+
|
33
|
+
Defect.create :defect_id=>"2",
|
34
|
+
:manufacture_date=>"2010-01-05",
|
35
|
+
:manufacture_time=>"2010-01-05".to_time,
|
36
|
+
:product=>{:name=>"Evil's Pickling Spice",:category=>"Baking"},
|
37
|
+
:plant=>{:name=>"Plant2",:address=>{:region=>"Midwest",:location=>"Des Moines, Ia"}},
|
38
|
+
:operator=>"Seymour",
|
39
|
+
:outcome=>"Discarded",
|
40
|
+
:cost=>0.02,
|
41
|
+
:root_cause=>:operator_error
|
42
|
+
|
43
|
+
Defect.create :defect_id=>"3",
|
44
|
+
:manufacture_date=>"2010-02-01",
|
45
|
+
:manufacture_time=>"2010-02-01".to_time,
|
46
|
+
:product=>{:name=>"Sad Day Moonshine",:category=>"Alcohol"},
|
47
|
+
:plant=>{:name=>"Plant1",:address=>{:region=>"West",:location=>"San Francisco, Ca"}},
|
48
|
+
:operator=>"Zooey",
|
49
|
+
:outcome=>"Consumed",
|
50
|
+
:cost=>2.94,
|
51
|
+
:root_cause=>:poor_judgment
|
52
|
+
|
53
|
+
Defect.create :defect_id=>"4",
|
54
|
+
:manufacture_date=>"2009-12-09",
|
55
|
+
:manufacture_time=>"2009-12-09".to_time,
|
56
|
+
:product=>{:name=>"Brush Fire Bottle Rockets",:category=>"Fireworks"},
|
57
|
+
:plant=>{:name=>"Plant19",:address=>{:region=>"South",:location=>"Burmingham, Al"}},
|
58
|
+
:operator=>"Buddy",
|
59
|
+
:outcome=>"Repaired",
|
60
|
+
:cost=>0.43,
|
61
|
+
:root_cause=>:act_of_god
|
62
|
+
|
63
|
+
Defect.create :defect_id=>"5",
|
64
|
+
:manufacture_date=>"2010-01-01",
|
65
|
+
:manufacture_time=>"2010-01-01".to_time,
|
66
|
+
:product=>{:name=>"Sad Day Moonshine",:category=>"Alcohol"},
|
67
|
+
:plant=>{:name=>"Plant3",:address=>{:region=>"West",:location=>"Oakland, Ca"}},
|
68
|
+
:operator=>"Franny",
|
69
|
+
:outcome=>"Repaired",
|
70
|
+
:cost=>12.19,
|
71
|
+
:root_cause=>:defective_materials
|
72
|
+
end
|
73
|
+
end
|
data/test/test_helper.rb
ADDED
@@ -0,0 +1,62 @@
|
|
1
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
2
|
+
|
3
|
+
dir = File.dirname(__FILE__)
|
4
|
+
require File.join(dir,"..","lib","cubicle")
|
5
|
+
require 'active_support/test_case'
|
6
|
+
require "shoulda"
|
7
|
+
require "logger"
|
8
|
+
require File.join(dir,"models","defect")
|
9
|
+
Cubicle.register_cubicle_directory(File.join(dir,"cubicles"))
|
10
|
+
|
11
|
+
|
12
|
+
module ActiveSupport
|
13
|
+
class TestCase
|
14
|
+
def setup
|
15
|
+
dir = File.expand_path(File.dirname(__FILE__))
|
16
|
+
logdir = File.join(dir,'log')
|
17
|
+
Dir.mkdir(logdir) unless File.directory?(logdir)
|
18
|
+
Cubicle.mongo.setup(YAML.load_file(File.join(dir,'config', 'database.yml')), "test", {
|
19
|
+
:logger => Logger.new(File.join(logdir,'test.log')),
|
20
|
+
:passenger => false
|
21
|
+
})
|
22
|
+
end
|
23
|
+
def teardown
|
24
|
+
Cubicle.mongo.database.collections.each do |coll|
|
25
|
+
coll.drop
|
26
|
+
end
|
27
|
+
Time.reset #Return Time.now to its original state
|
28
|
+
end
|
29
|
+
|
30
|
+
# Make sure that each test case has a teardown
|
31
|
+
# method to clear the db after each test.
|
32
|
+
def inherited(base)
|
33
|
+
base.define_method teardown do
|
34
|
+
super
|
35
|
+
end
|
36
|
+
base.define_method setup do
|
37
|
+
super
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
#This seems like an odd approach - why not just alias now, you ask
|
43
|
+
#well, I did, and for whatever reason, got stack overflows
|
44
|
+
#whenever I'd try to run the test suite. So...um...this doesn't
|
45
|
+
#overflow the stack, so it will do.
|
46
|
+
class Time
|
47
|
+
@@old_now = method(:now)
|
48
|
+
class << self
|
49
|
+
def now=(new_now)
|
50
|
+
@@new_now = new_now.to_time
|
51
|
+
def Time.now
|
52
|
+
@@new_now
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
def reset
|
57
|
+
def Time.now
|
58
|
+
@@old_now.call
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
metadata
ADDED
@@ -0,0 +1,144 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: cubicle
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 1
|
8
|
+
- 0
|
9
|
+
version: 0.1.0
|
10
|
+
platform: ruby
|
11
|
+
authors:
|
12
|
+
- Nathan Stults
|
13
|
+
autorequire:
|
14
|
+
bindir: bin
|
15
|
+
cert_chain: []
|
16
|
+
|
17
|
+
date: 2010-03-13 00:00:00 -08:00
|
18
|
+
default_executable:
|
19
|
+
dependencies:
|
20
|
+
- !ruby/object:Gem::Dependency
|
21
|
+
name: activesupport
|
22
|
+
prerelease: false
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - ">="
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
segments:
|
28
|
+
- 2
|
29
|
+
- 3
|
30
|
+
version: "2.3"
|
31
|
+
type: :runtime
|
32
|
+
version_requirements: *id001
|
33
|
+
- !ruby/object:Gem::Dependency
|
34
|
+
name: mongo
|
35
|
+
prerelease: false
|
36
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
segments:
|
41
|
+
- 0
|
42
|
+
- 18
|
43
|
+
- 3
|
44
|
+
version: 0.18.3
|
45
|
+
type: :runtime
|
46
|
+
version_requirements: *id002
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: shoulda
|
49
|
+
prerelease: false
|
50
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
segments:
|
55
|
+
- 2
|
56
|
+
- 10
|
57
|
+
- 3
|
58
|
+
version: 2.10.3
|
59
|
+
type: :development
|
60
|
+
version_requirements: *id003
|
61
|
+
description: Cubicle provides a dsl and aggregation caching framework for automating the generation, execution and caching of map reduce queries when using MongoDB in Ruby. Cubicle also includes a MongoMapper plugin for quickly performing ad-hoc, multi-level group-by queries against a MongoMapper model.
|
62
|
+
email: hereiam@sonic.net
|
63
|
+
executables: []
|
64
|
+
|
65
|
+
extensions: []
|
66
|
+
|
67
|
+
extra_rdoc_files:
|
68
|
+
- LICENSE.txt
|
69
|
+
- README.rdoc
|
70
|
+
files:
|
71
|
+
- CHANGELOG.rdoc
|
72
|
+
- LICENSE.txt
|
73
|
+
- README.rdoc
|
74
|
+
- Rakefile
|
75
|
+
- cubicle.gemspec
|
76
|
+
- lib/cubicle.rb
|
77
|
+
- lib/cubicle/aggregation.rb
|
78
|
+
- lib/cubicle/calculated_measure.rb
|
79
|
+
- lib/cubicle/data.rb
|
80
|
+
- lib/cubicle/data_level.rb
|
81
|
+
- lib/cubicle/date_time.rb
|
82
|
+
- lib/cubicle/dimension.rb
|
83
|
+
- lib/cubicle/measure.rb
|
84
|
+
- lib/cubicle/member.rb
|
85
|
+
- lib/cubicle/member_list.rb
|
86
|
+
- lib/cubicle/mongo_environment.rb
|
87
|
+
- lib/cubicle/mongo_mapper/aggregate_plugin.rb
|
88
|
+
- lib/cubicle/query.rb
|
89
|
+
- lib/cubicle/ratio.rb
|
90
|
+
- lib/cubicle/support.rb
|
91
|
+
- lib/cubicle/version.rb
|
92
|
+
- test/config/database.yml
|
93
|
+
- test/cubicle/cubicle_aggregation_test.rb
|
94
|
+
- test/cubicle/cubicle_data_level_test.rb
|
95
|
+
- test/cubicle/cubicle_data_test.rb
|
96
|
+
- test/cubicle/cubicle_query_test.rb
|
97
|
+
- test/cubicle/cubicle_test.rb
|
98
|
+
- test/cubicle/mongo_mapper/aggregate_plugin_test.rb
|
99
|
+
- test/cubicles/defect_cubicle.rb
|
100
|
+
- test/log/test.log
|
101
|
+
- test/models/defect.rb
|
102
|
+
- test/test_helper.rb
|
103
|
+
has_rdoc: true
|
104
|
+
homepage: http://github.com/PlasticLizard/cubicle
|
105
|
+
licenses: []
|
106
|
+
|
107
|
+
post_install_message:
|
108
|
+
rdoc_options:
|
109
|
+
- --charset=UTF-8
|
110
|
+
require_paths:
|
111
|
+
- lib
|
112
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
113
|
+
requirements:
|
114
|
+
- - ">="
|
115
|
+
- !ruby/object:Gem::Version
|
116
|
+
segments:
|
117
|
+
- 0
|
118
|
+
version: "0"
|
119
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
120
|
+
requirements:
|
121
|
+
- - ">="
|
122
|
+
- !ruby/object:Gem::Version
|
123
|
+
segments:
|
124
|
+
- 0
|
125
|
+
version: "0"
|
126
|
+
requirements: []
|
127
|
+
|
128
|
+
rubyforge_project:
|
129
|
+
rubygems_version: 1.3.6
|
130
|
+
signing_key:
|
131
|
+
specification_version: 3
|
132
|
+
summary: Pseudo-Multi Dimensional analysis / simplified aggregation for MongoDB in Ruby (NOLAP ;))
|
133
|
+
test_files:
|
134
|
+
- test/cubicle/cubicle_aggregation_test.rb
|
135
|
+
- test/cubicle/cubicle_data_level_test.rb
|
136
|
+
- test/cubicle/cubicle_data_test.rb
|
137
|
+
- test/cubicle/cubicle_query_test.rb
|
138
|
+
- test/cubicle/cubicle_test.rb
|
139
|
+
- test/cubicle/mongo_mapper/aggregate_plugin_test.rb
|
140
|
+
- test/cubicles/defect_cubicle.rb
|
141
|
+
- test/models/defect.rb
|
142
|
+
- test/test_helper.rb
|
143
|
+
- examples/cubicles/poker_hand_cubicle.rb
|
144
|
+
- examples/models/poker_hand.rb
|