Module: Cubicle

Defined in:
lib/cubicle/mongo_environment.rb,
lib/cubicle.rb,
lib/cubicle/data.rb,
lib/cubicle/query.rb,
lib/cubicle/ratio.rb,
lib/cubicle/member.rb,
lib/cubicle/measure.rb,
lib/cubicle/version.rb,
lib/cubicle/duration.rb,
lib/cubicle/date_time.rb,
lib/cubicle/dimension.rb,
lib/cubicle/expansion.rb,
lib/cubicle/query/dsl.rb,
lib/cubicle/data/level.rb,
lib/cubicle/data/table.rb,
lib/cubicle/difference.rb,
lib/cubicle/aggregation.rb,
lib/cubicle/data/member.rb,
lib/cubicle/member_list.rb,
lib/cubicle/data/hierarchy.rb,
lib/cubicle/aggregation/dsl.rb,
lib/cubicle/aggregation/ad_hoc.rb,
lib/cubicle/calculated_measure.rb,
lib/cubicle/aggregation/profiler.rb,
lib/cubicle/bucketized_dimension.rb,
lib/cubicle/query/dsl/time_intelligence.rb,
lib/cubicle/aggregation/aggregation_view.rb,
lib/cubicle/aggregation/cubicle_metadata.rb,
lib/cubicle/aggregation/map_reduce_helper.rb,
lib/cubicle/mongo_mapper/aggregate_plugin.rb,
lib/cubicle/aggregation/aggregation_manager.rb,
lib/cubicle/aggregation/aggregation_metadata.rb

Overview

This class represents MongoDB. It is lifted line for line from MongoMapper github.com/jnunemaker/mongomapper/blob/master/lib/mongo_mapper.rb Actually, if the MongoMapper gem is loaded, Cubicle will simply use it for providing the MongoEnvironment. However, if MongoMapper isn’t loaded, this stuff is still required, so why reinvent the wheel?

Defined Under Namespace

Modules: Aggregation, Data, DateTime, MongoMapper Classes: BucketizedDimension, CalculatedMeasure, Difference, Dimension, Duration, Expansion, Measure, Member, MemberList, MongoEnvironment, Query, Ratio

Constant Summary collapse

VERSION =
'0.5.2'

Class Method Summary collapse

Class Method Details

.clear_temp_tablesObject



74
75
76
# File 'lib/cubicle.rb', line 74

def self.clear_temp_tables
  self.mongo.database.collection_names.each{|cn|self.mongo.database[cn].drop if cn =~ /tmp.mr.mapreduce/i}
end

.loggerObject



70
71
72
# File 'lib/cubicle.rb', line 70

def self.logger
  @logger ||= (Cubicle.mongo.logger || Logger.new("cubicle.log"))
end

.mongoObject



62
63
64
# File 'lib/cubicle.rb', line 62

def self.mongo
  @mongo ||= defined?(::MongoMapper::Document) ? ::MongoMapper : MongoEnvironment
end

.mongo=(mongo_env) ⇒ Object



66
67
68
# File 'lib/cubicle.rb', line 66

def self.mongo=(mongo_env)
  @mongo = mongo_env
end

.register_cubicle_directory(directory_path, recursive = true) ⇒ Object



46
47
48
49
# File 'lib/cubicle.rb', line 46

def self.register_cubicle_directory(directory_path, recursive=true)
  searcher = "#{recursive ? "*" : "**/*"}.rb"
  Dir[File.join(directory_path,searcher)].each {|cubicle| require cubicle}
end

.setup(config, environment, options) ⇒ Object

Offer an easy way to set cubicle up with configuration independent of mongo mapper even if mongo mapper has been included. This is useful in a scenario where you want your map reduce activity to happen on a different server, such as a slave, so that your transactional systems aren’t constantly irritated by all the loud crunching sounds that cubicle makes. Maybe someday map reduce will learn to chew with its mouth shut. Until then, it may be prudent to let cubicle run on a slave, and mongo mapper on your master.



57
58
59
60
# File 'lib/cubicle.rb', line 57

def self.setup(config,environment,options)
  @mongo = MongoEnvironment
  @mongo.setup(config,environment,options)
end