believer 0.2.1 → 0.2.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/README.md +6 -3
- data/lib/believer.rb +2 -1
- data/lib/believer/base.rb +1 -0
- data/lib/believer/batch_delete.rb +1 -1
- data/lib/believer/command.rb +2 -2
- data/lib/believer/ddl.rb +10 -0
- data/lib/believer/delete.rb +1 -1
- data/lib/believer/empty_result.rb +3 -1
- data/lib/believer/{scoped_command.rb → filter_command.rb} +1 -1
- data/lib/believer/finder_methods.rb +23 -0
- data/lib/believer/query.rb +24 -21
- data/lib/believer/querying.rb +1 -1
- data/lib/believer/relation.rb +40 -3
- data/lib/believer/test/test_run_life_cycle.rb +11 -18
- data/lib/believer/version.rb +1 -1
- data/spec/believer/base_spec.rb +5 -1
- data/spec/believer/callback_spec.rb +1 -0
- data/spec/believer/environment_spec.rb +2 -6
- data/spec/believer/finder_methods_spec.rb +39 -0
- data/spec/believer/querying_spec.rb +16 -0
- data/spec/believer/relation_spec.rb +28 -13
- data/spec/believer/test_run_life_cycle_spec.rb +53 -0
- data/spec/believer/time_series_spec.rb +8 -3
- data/spec/support/test_classes.rb +6 -1
- metadata +122 -100
data/README.md
CHANGED
@@ -131,11 +131,11 @@ Song.where(:artist => 'Pink Floyd').where(:album => 'Meddle').order(:track_numbe
|
|
131
131
|
```
|
132
132
|
|
133
133
|
### Configuration
|
134
|
-
If using Rails, place a believer.yml file in the configuration directory of your application.
|
134
|
+
If using Rails or Merb, place a believer.yml file in the configuration directory of your application.
|
135
135
|
The file structure starts with the the environment name, followed by the connection configuration.
|
136
136
|
This is the client connection configuration passed to the cql-rb gem.
|
137
137
|
|
138
|
-
```
|
138
|
+
``` yml
|
139
139
|
development:
|
140
140
|
host: 127.0.0.1
|
141
141
|
port: 9042
|
@@ -244,4 +244,7 @@ causing you to 'manually' delete all the garbage.
|
|
244
244
|
|
245
245
|
To make this a little less labor intensive, you can include the module Believer::Test::TestRunLifeCycle in your test.
|
246
246
|
This module will implement an after(:each) hook, which deletes all Believer::Base instance/records created in the span
|
247
|
-
of the test.
|
247
|
+
of the test.
|
248
|
+
|
249
|
+
## Class documentation
|
250
|
+
For API go [here](http://rubydoc.info/gems/believer/frames).
|
data/lib/believer.rb
CHANGED
@@ -29,7 +29,7 @@ require 'believer/where_clause'
|
|
29
29
|
require 'believer/empty_result'
|
30
30
|
require 'believer/limit'
|
31
31
|
require 'believer/order_by'
|
32
|
-
require 'believer/
|
32
|
+
require 'believer/filter_command'
|
33
33
|
require 'believer/query'
|
34
34
|
require 'believer/delete'
|
35
35
|
require 'believer/insert'
|
@@ -37,6 +37,7 @@ require 'believer/scoping'
|
|
37
37
|
require 'believer/batch'
|
38
38
|
require 'believer/batch_delete'
|
39
39
|
require 'believer/callbacks'
|
40
|
+
require 'believer/finder_methods'
|
40
41
|
|
41
42
|
require 'believer/observer'
|
42
43
|
require 'believer/relation'
|
data/lib/believer/base.rb
CHANGED
data/lib/believer/command.rb
CHANGED
@@ -23,9 +23,9 @@ module Believer
|
|
23
23
|
cql = to_cql
|
24
24
|
begin
|
25
25
|
start = Time.now
|
26
|
-
puts "Executing #{cql}"
|
26
|
+
#puts "Executing #{cql}"
|
27
27
|
res = connection.execute(cql)
|
28
|
-
|
28
|
+
puts "#{name} #{sprintf "%.3f", (Time.now - start)*1000.0} ms: #{cql}"
|
29
29
|
return res
|
30
30
|
rescue Cql::Protocol::DecodingError => e
|
31
31
|
# Decoding errors tend to #$%# up the connection, resulting in no more activity, so a reconnect is performed here.
|
data/lib/believer/ddl.rb
CHANGED
@@ -4,6 +4,16 @@ module Believer
|
|
4
4
|
extend ActiveSupport::Concern
|
5
5
|
|
6
6
|
module ClassMethods
|
7
|
+
|
8
|
+
def drop_table
|
9
|
+
connection_pool.with do |connection|
|
10
|
+
cql = "CREATE TABLE #{table_name}"
|
11
|
+
puts "Dropping table #{table_name} using CQL:\n#{cql}"
|
12
|
+
connection.execute(cql)
|
13
|
+
puts "Dropped table #{table_name}"
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
7
17
|
def create_table
|
8
18
|
connection_pool.with do |connection|
|
9
19
|
cql = create_table_cql
|
data/lib/believer/delete.rb
CHANGED
@@ -0,0 +1,23 @@
|
|
1
|
+
module Believer
|
2
|
+
module FinderMethods
|
3
|
+
|
4
|
+
# Tests if there are any records present which conform to the argument filter(s)
|
5
|
+
# @param args [Object] a filter condition. This argument has the same usage as the where method
|
6
|
+
#def exists?(*args)
|
7
|
+
# super if defined?(super) && args.size == 0
|
8
|
+
# where(*args).exists?
|
9
|
+
#end
|
10
|
+
|
11
|
+
def find(*args)
|
12
|
+
return where(args[0]).first if args[0].is_a?(Hash)
|
13
|
+
|
14
|
+
if primary_key_columns.size == 1
|
15
|
+
return where(primary_key_columns[0] => args).to_a if args.is_a?(Array) && args.size > 1
|
16
|
+
return where(primary_key_columns[0] => args[0]).first
|
17
|
+
end
|
18
|
+
|
19
|
+
nil
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
23
|
+
end
|
data/lib/believer/query.rb
CHANGED
@@ -1,9 +1,11 @@
|
|
1
1
|
module Believer
|
2
|
-
class Query <
|
2
|
+
class Query < FilterCommand
|
3
3
|
|
4
4
|
attr_accessor :record_class, :selects, :order_by, :limit_to
|
5
5
|
|
6
6
|
delegate *(Enumerable.instance_methods(false).map {|enum_method| enum_method.to_sym}), :to => :to_a
|
7
|
+
delegate :each, :size, :[], :to => :to_a
|
8
|
+
delegate :primary_key_columns, :to => :record_class
|
7
9
|
|
8
10
|
def initialize(attrs)
|
9
11
|
super
|
@@ -85,23 +87,21 @@ module Believer
|
|
85
87
|
end
|
86
88
|
|
87
89
|
def to_a
|
88
|
-
|
90
|
+
if @loaded_objects.nil?
|
89
91
|
result = execute
|
90
|
-
@
|
92
|
+
@loaded_objects = []
|
91
93
|
start = Time.now
|
92
94
|
result.each do |row|
|
93
|
-
@
|
95
|
+
@loaded_objects << @record_class.instantiate_from_result_rows(row)
|
94
96
|
end
|
95
|
-
puts "Took #{sprintf "%.3f", (Time.now - start)*1000.0} ms to deserialize #{@
|
97
|
+
puts "Took #{sprintf "%.3f", (Time.now - start)*1000.0} ms to deserialize #{@loaded_objects.size} object(s)"
|
96
98
|
end
|
97
|
-
@
|
98
|
-
end
|
99
|
-
|
100
|
-
def size
|
101
|
-
to_a.size
|
99
|
+
@loaded_objects
|
102
100
|
end
|
103
101
|
|
104
102
|
def count
|
103
|
+
return @loaded_objects.size unless @loaded_objects.nil?
|
104
|
+
|
105
105
|
count_q = clone
|
106
106
|
count_q.selects = ['COUNT(*)']
|
107
107
|
result = count_q.execute
|
@@ -113,28 +113,31 @@ module Believer
|
|
113
113
|
cnt
|
114
114
|
end
|
115
115
|
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
def [](index)
|
123
|
-
to_a[index]
|
116
|
+
# Tests if there are any records present which conform to the argument filter(s)
|
117
|
+
# @param args [Object] a filter condition. This argument has the same usage as the where method
|
118
|
+
def exists?(*args)
|
119
|
+
return count > 0 if args.nil? || args.size == 0
|
120
|
+
where(*args).exists?
|
124
121
|
end
|
125
122
|
|
126
123
|
def first
|
127
|
-
return @
|
124
|
+
return @loaded_objects.first unless @loaded_objects.nil?
|
128
125
|
clone.limit(1)[0]
|
129
126
|
end
|
130
127
|
|
131
128
|
def last
|
132
|
-
return @
|
133
|
-
raise "Cannot retrieve last
|
129
|
+
return @loaded_objects.last unless @loaded_objects.nil?
|
130
|
+
raise "Cannot retrieve last if no order column is set" if @order_by.nil?
|
134
131
|
lq = clone.limit(1)
|
135
132
|
lq.order_by = @order_by.inverse
|
136
133
|
lq[0]
|
137
134
|
end
|
135
|
+
|
136
|
+
protected
|
137
|
+
def loaded_objects
|
138
|
+
@loaded_objects
|
139
|
+
end
|
140
|
+
|
138
141
|
end
|
139
142
|
|
140
143
|
end
|
data/lib/believer/querying.rb
CHANGED
data/lib/believer/relation.rb
CHANGED
@@ -65,7 +65,7 @@ module Believer
|
|
65
65
|
|
66
66
|
raise "key and foreign_key must have same number of items" if opts[:key].size != opts[:foreign_key].size
|
67
67
|
|
68
|
-
self.redefine_method(name) do
|
68
|
+
self.redefine_method(name) do |reload = false|
|
69
69
|
relation_class = get_relation_class.call
|
70
70
|
|
71
71
|
q = relation_class.scoped
|
@@ -75,16 +75,53 @@ module Believer
|
|
75
75
|
end
|
76
76
|
if options[:filter]
|
77
77
|
q = self.instance_exec(q, &(options[:filter]))
|
78
|
-
|
78
|
+
unless q
|
79
|
+
er = EmptyResult.new
|
80
|
+
er.extend(CollectionMethods)
|
81
|
+
er.extend(::Believer::FinderMethods)
|
82
|
+
return er
|
83
|
+
end
|
79
84
|
end
|
80
85
|
return q.first if options[:type] == :one_2_one
|
81
|
-
|
86
|
+
|
87
|
+
col = Collection.new(q.query_attributes)
|
88
|
+
col.to_a if reload
|
89
|
+
col
|
90
|
+
end
|
91
|
+
|
92
|
+
end
|
93
|
+
|
94
|
+
end
|
95
|
+
|
96
|
+
module CollectionMethods
|
97
|
+
|
98
|
+
def clear
|
99
|
+
destroy(*(to_a.dup))
|
100
|
+
end
|
101
|
+
|
102
|
+
def destroy(*objects)
|
103
|
+
return if loaded_objects.nil? || loaded_objects.empty?
|
104
|
+
objects.each do |obj|
|
105
|
+
if loaded_objects.include?(obj)
|
106
|
+
obj.destroy
|
107
|
+
loaded_objects.delete(obj)
|
108
|
+
end
|
82
109
|
end
|
110
|
+
end
|
83
111
|
|
112
|
+
def create(attrs = {})
|
113
|
+
obj = record_class.create(attrs)
|
114
|
+
loaded_objects << obj
|
84
115
|
end
|
85
116
|
|
86
117
|
end
|
87
118
|
|
119
|
+
class Collection < Believer::Query
|
120
|
+
include CollectionMethods
|
121
|
+
include FinderMethods
|
122
|
+
|
123
|
+
end
|
124
|
+
|
88
125
|
end
|
89
126
|
|
90
127
|
end
|
@@ -12,34 +12,27 @@ module Believer
|
|
12
12
|
end
|
13
13
|
end
|
14
14
|
|
15
|
-
def saved_models
|
16
|
-
@saved_models ||= []
|
17
|
-
end
|
18
|
-
|
19
|
-
def after_save(model)
|
20
|
-
saved_models << model
|
21
|
-
end
|
22
|
-
|
23
15
|
# Detroys all CqlRecord::Base instances created
|
24
16
|
class Destructor < Believer::Observer
|
25
17
|
observe Believer::Base
|
26
18
|
|
27
19
|
def cleanup
|
28
|
-
saved_models.
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
20
|
+
unless @saved_models.nil? || @saved_models.empty?
|
21
|
+
puts "Cleaning up #{@saved_models.size} objects"
|
22
|
+
@saved_models.each do |model|
|
23
|
+
begin
|
24
|
+
model.destroy
|
25
|
+
rescue Exception => e
|
26
|
+
puts "Could not destroy model #{model}: #{e}\n#{e.backtrace.join("\n")}"
|
27
|
+
end
|
33
28
|
end
|
29
|
+
@saved_models = nil
|
34
30
|
end
|
35
31
|
end
|
36
32
|
|
37
|
-
def saved_models
|
38
|
-
@saved_models ||= []
|
39
|
-
end
|
40
|
-
|
41
33
|
def after_save(model)
|
42
|
-
saved_models
|
34
|
+
@saved_models ||= []
|
35
|
+
@saved_models << model
|
43
36
|
end
|
44
37
|
|
45
38
|
end
|
data/lib/believer/version.rb
CHANGED
data/spec/believer/base_spec.rb
CHANGED
@@ -12,18 +12,14 @@ describe Believer::Environment do
|
|
12
12
|
end
|
13
13
|
|
14
14
|
it 'load the Merb configuration' do
|
15
|
-
|
16
|
-
|
17
|
-
Merb = Env.new(File.join(RSpec.configuration.test_files_dir, 'merb'), :development, nil)
|
15
|
+
Merb = Struct.new(:root, :environment, :logger).new(File.join(RSpec.configuration.test_files_dir, 'merb'), :development, nil)
|
18
16
|
env = Believer::Base.environment
|
19
17
|
env.class.should == Believer::Environment::MerbEnv
|
20
18
|
env.configuration[:host].should == 'merb.local'
|
21
19
|
end
|
22
20
|
|
23
21
|
it 'load the rails configuration' do
|
24
|
-
|
25
|
-
|
26
|
-
Rails = Env.new(File.join(RSpec.configuration.test_files_dir, 'rails'), :development, nil)
|
22
|
+
Rails = Struct.new(:root, :env, :logger).new(File.join(RSpec.configuration.test_files_dir, 'rails'), :development, nil)
|
27
23
|
env = Believer::Base.environment
|
28
24
|
env.class.should == Believer::Environment::RailsEnv
|
29
25
|
env.configuration[:host].should == '123.456.789.0'
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Believer::FinderMethods do
|
4
|
+
|
5
|
+
before :each do
|
6
|
+
@level_42 = Test::Artist.create(:name => 'Level 42')
|
7
|
+
@u2 = Test::Artist.create(:name => 'U2')
|
8
|
+
@ub_40 = Test::Artist.create(:name => 'UB 40')
|
9
|
+
@artists = [@level_42, @u2, @ub_40]
|
10
|
+
end
|
11
|
+
|
12
|
+
it 'exists? should return true for an existing object' do
|
13
|
+
# Test all variants
|
14
|
+
Test::Artist.exists?(:name => 'U2').should == true
|
15
|
+
Test::Artist.exists?('name = ?', 'U2').should == true
|
16
|
+
end
|
17
|
+
|
18
|
+
it 'exists? should return false for an non-existing object' do
|
19
|
+
# Test all variants
|
20
|
+
Test::Artist.exists?(:name => 'Genesis').should == false
|
21
|
+
Test::Artist.exists?('name = ?', 'Genesis').should == false
|
22
|
+
end
|
23
|
+
|
24
|
+
it 'find using a hash' do
|
25
|
+
Test::Artist.find(:name => 'U2').should == @u2
|
26
|
+
end
|
27
|
+
|
28
|
+
it 'find using an array' do
|
29
|
+
res = Test::Artist.find('U2', 'UB 40')
|
30
|
+
res.size.should == 2
|
31
|
+
res.include?(@u2).should == true
|
32
|
+
res.include?(@ub_40).should == true
|
33
|
+
end
|
34
|
+
|
35
|
+
it 'find using single primary key value' do
|
36
|
+
Test::Artist.find('U2').should == @u2
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Believer::Querying do
|
4
|
+
|
5
|
+
[
|
6
|
+
{:method => :select, :args => [:name]},
|
7
|
+
{:method => :where, :args => {:name => 'Beatles'}},
|
8
|
+
{:method => :order, :args => :name},
|
9
|
+
{:method => :limit, :args => 10},
|
10
|
+
].each do |scenario|
|
11
|
+
it "#{scenario[:method]} call should return a query object" do
|
12
|
+
Test::Artist.send(scenario[:method], scenario[:args]).class.should == Believer::Query
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
@@ -1,23 +1,21 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Believer::Relation do
|
4
|
+
include Believer::Test::TestRunLifeCycle
|
4
5
|
|
5
6
|
before :each do
|
6
|
-
@
|
7
|
-
@
|
8
|
-
@
|
9
|
-
@artists << Test::Artist.create(:name => 'Pink Floyd', :label => 'Epic')
|
7
|
+
@beatles = Test::Artist.create(:name => 'Beatles', :label => 'Apple')
|
8
|
+
@jethro_tull = Test::Artist.create(:name => 'Jethro Tull', :label => 'Crysalis')
|
9
|
+
@pink_floyd = Test::Artist.create(:name => 'Pink Floyd', :label => 'Epic')
|
10
10
|
|
11
|
-
@
|
12
|
-
@
|
13
|
-
@
|
14
|
-
@albums << Test::Album.create(:artist_name => 'Beatles', :name => 'Abbey Road', :release_date => Time.utc(1969))
|
11
|
+
@help = Test::Album.create(:artist_name => 'Beatles', :name => 'Help', :release_date => Time.utc(1965))
|
12
|
+
@revolver = Test::Album.create(:artist_name => 'Beatles', :name => 'Revolver', :release_date => Time.utc(1966))
|
13
|
+
@abbey_road = Test::Album.create(:artist_name => 'Beatles', :name => 'Abbey Road', :release_date => Time.utc(1969))
|
15
14
|
|
16
|
-
@
|
17
|
-
@
|
15
|
+
@dark_side_of_the_moon = Test::Album.create(:artist_name => 'Pink Floyd', :name => 'Dark side of the moon', :release_date => Time.utc(1973))
|
16
|
+
@wish_you_were_here = Test::Album.create(:artist_name => 'Pink Floyd', :name => 'Wish you were here', :release_date => Time.utc(1975))
|
18
17
|
|
19
|
-
@
|
20
|
-
@songs << Test::Song.create(:artist_name => 'Pink Floyd', :album_name => 'Wish you were here', :name => 'Have a cigar')
|
18
|
+
@have_a_cigar = Test::Song.create(:artist_name => 'Pink Floyd', :album_name => 'Wish you were here', :name => 'Have a cigar')
|
21
19
|
|
22
20
|
end
|
23
21
|
|
@@ -26,8 +24,25 @@ describe Believer::Relation do
|
|
26
24
|
a.albums.size.should == 3
|
27
25
|
end
|
28
26
|
|
27
|
+
it "one to many relation collection should support exists? method" do
|
28
|
+
a = Test::Artist.where(:name => 'Beatles').first
|
29
|
+
a.albums.exists?(:name => 'Help').should == true
|
30
|
+
end
|
31
|
+
|
32
|
+
it "one to many relation collection should support clear method" do
|
33
|
+
a = Test::Artist.where(:name => 'Beatles').first
|
34
|
+
a.albums.size.should == 3
|
35
|
+
a.albums.clear
|
36
|
+
a.albums.size.should == 0
|
37
|
+
end
|
38
|
+
|
39
|
+
it "one to many relation collection should support find method" do
|
40
|
+
a = Test::Artist.where(:name => 'Beatles').first
|
41
|
+
a.albums.find(:name => 'Help').should == @help
|
42
|
+
end
|
43
|
+
|
29
44
|
it "one to one relation" do
|
30
|
-
@
|
45
|
+
@have_a_cigar.album.should == Test::Album.where(:artist_name => 'Pink Floyd', :name => 'Wish you were here').first
|
31
46
|
end
|
32
47
|
|
33
48
|
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
#TODO: this is a crappy test!
|
4
|
+
describe Believer::Test::TestRunLifeCycle do
|
5
|
+
include Believer::Test::TestRunLifeCycle
|
6
|
+
|
7
|
+
before :all do
|
8
|
+
@destroyed_count = 0
|
9
|
+
@destroy_monitor = lambda do |obj|
|
10
|
+
@destroyed_count += 1
|
11
|
+
puts "Destroyed"
|
12
|
+
end
|
13
|
+
|
14
|
+
begin
|
15
|
+
XXX.drop_table
|
16
|
+
XXX.create_table
|
17
|
+
rescue
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
21
|
+
|
22
|
+
after :all do
|
23
|
+
puts "Checking"
|
24
|
+
@destroyed_count.should == @created.size
|
25
|
+
XXX.drop_table
|
26
|
+
end
|
27
|
+
|
28
|
+
before :each do
|
29
|
+
|
30
|
+
@created = []
|
31
|
+
10.times do |i|
|
32
|
+
@created << XXX.create(:name => "artist_#{i}", :destroy_monitor => @destroy_monitor)
|
33
|
+
puts "Created"
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
it "should clean all created objects" do
|
38
|
+
|
39
|
+
end
|
40
|
+
|
41
|
+
class XXX < Believer::Base
|
42
|
+
column :name, :type => :string
|
43
|
+
primary_key :name
|
44
|
+
cattr_accessor :destroyed_count
|
45
|
+
|
46
|
+
attr_accessor :destroy_monitor
|
47
|
+
|
48
|
+
before_destroy do
|
49
|
+
@destroy_monitor.call(self)
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
end
|
@@ -1,18 +1,23 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe 'Time series' do
|
4
|
+
include Believer::Test::TestRunLifeCycle
|
4
5
|
|
5
6
|
before :each do
|
6
7
|
@interval = 1.minute
|
7
8
|
@start = Time.utc(2012)
|
8
|
-
@count =
|
9
|
+
@count = 10
|
9
10
|
@count.times do |i|
|
10
|
-
|
11
|
+
attrs = {:computer_id => 'ABC', :event_type => 1, :time => @start + (@interval * i)}
|
12
|
+
Test::Event::PARAMETER_NAMES.each do |param|
|
13
|
+
attrs[param] = rand(1000) * rand(1000)
|
14
|
+
end
|
15
|
+
Test::Event.create(attrs)
|
11
16
|
end
|
12
17
|
end
|
13
18
|
|
14
19
|
it 'load all' do
|
15
|
-
Test::Event.where(:computer_id =>
|
20
|
+
Test::Event.where(:computer_id => 'ABC', :event_type => 1).size.should == @count
|
16
21
|
end
|
17
22
|
|
18
23
|
end
|
@@ -45,11 +45,16 @@ module Test
|
|
45
45
|
end
|
46
46
|
|
47
47
|
class Event < Believer::Base
|
48
|
-
column :computer_id, :type => :
|
48
|
+
column :computer_id, :type => :string
|
49
49
|
column :event_type, :type => :integer
|
50
50
|
column :time, :type => :integer, :key => true
|
51
51
|
column :description, :type => :string
|
52
52
|
|
53
|
+
PARAMETER_NAMES = (1..50).map { |index| "parameter_#{index}".to_sym }
|
54
|
+
PARAMETER_NAMES.each do |param|
|
55
|
+
column param, :type => :float
|
56
|
+
end
|
57
|
+
|
53
58
|
primary_key [:computer_id, :event_type], :time
|
54
59
|
|
55
60
|
end
|
metadata
CHANGED
@@ -1,119 +1,124 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: believer
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 19
|
5
5
|
prerelease:
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 2
|
9
|
+
- 2
|
10
|
+
version: 0.2.2
|
6
11
|
platform: ruby
|
7
|
-
authors:
|
12
|
+
authors:
|
8
13
|
- Jerphaes van Blijenburgh
|
9
14
|
autorequire:
|
10
15
|
bindir: bin
|
11
16
|
cert_chain: []
|
12
|
-
|
13
|
-
|
14
|
-
|
17
|
+
|
18
|
+
date: 2013-10-23 00:00:00 Z
|
19
|
+
dependencies:
|
20
|
+
- !ruby/object:Gem::Dependency
|
15
21
|
name: activemodel
|
16
|
-
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
|
-
requirements:
|
19
|
-
- - ! '>='
|
20
|
-
- !ruby/object:Gem::Version
|
21
|
-
version: '0'
|
22
|
-
type: :runtime
|
23
22
|
prerelease: false
|
24
|
-
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
25
24
|
none: false
|
26
|
-
requirements:
|
27
|
-
- -
|
28
|
-
- !ruby/object:Gem::Version
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
- - ! '>='
|
36
|
-
- !ruby/object:Gem::Version
|
37
|
-
version: '0'
|
25
|
+
requirements:
|
26
|
+
- - ">="
|
27
|
+
- !ruby/object:Gem::Version
|
28
|
+
hash: 21
|
29
|
+
segments:
|
30
|
+
- 3
|
31
|
+
- 2
|
32
|
+
- 13
|
33
|
+
version: 3.2.13
|
38
34
|
type: :runtime
|
35
|
+
version_requirements: *id001
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: cql-rb
|
39
38
|
prerelease: false
|
40
|
-
|
39
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
41
40
|
none: false
|
42
|
-
requirements:
|
43
|
-
- -
|
44
|
-
- !ruby/object:Gem::Version
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
version: '0'
|
41
|
+
requirements:
|
42
|
+
- - ">="
|
43
|
+
- !ruby/object:Gem::Version
|
44
|
+
hash: -1897861864
|
45
|
+
segments:
|
46
|
+
- 1
|
47
|
+
- 1
|
48
|
+
- 0
|
49
|
+
- pre
|
50
|
+
- 6
|
51
|
+
version: 1.1.0.pre6
|
54
52
|
type: :runtime
|
53
|
+
version_requirements: *id002
|
54
|
+
- !ruby/object:Gem::Dependency
|
55
|
+
name: connection_pool
|
55
56
|
prerelease: false
|
56
|
-
|
57
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
57
58
|
none: false
|
58
|
-
requirements:
|
59
|
-
- -
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
|
62
|
-
|
59
|
+
requirements:
|
60
|
+
- - ">="
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
hash: 3
|
63
|
+
segments:
|
64
|
+
- 0
|
65
|
+
version: "0"
|
66
|
+
type: :runtime
|
67
|
+
version_requirements: *id003
|
68
|
+
- !ruby/object:Gem::Dependency
|
63
69
|
name: rake
|
64
|
-
requirement: !ruby/object:Gem::Requirement
|
65
|
-
none: false
|
66
|
-
requirements:
|
67
|
-
- - ! '>='
|
68
|
-
- !ruby/object:Gem::Version
|
69
|
-
version: '0'
|
70
|
-
type: :development
|
71
70
|
prerelease: false
|
72
|
-
|
71
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
73
72
|
none: false
|
74
|
-
requirements:
|
75
|
-
- -
|
76
|
-
- !ruby/object:Gem::Version
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
none: false
|
82
|
-
requirements:
|
83
|
-
- - ! '>='
|
84
|
-
- !ruby/object:Gem::Version
|
85
|
-
version: '0'
|
73
|
+
requirements:
|
74
|
+
- - ">="
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
hash: 3
|
77
|
+
segments:
|
78
|
+
- 0
|
79
|
+
version: "0"
|
86
80
|
type: :development
|
81
|
+
version_requirements: *id004
|
82
|
+
- !ruby/object:Gem::Dependency
|
83
|
+
name: rspec
|
87
84
|
prerelease: false
|
88
|
-
|
85
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
89
86
|
none: false
|
90
|
-
requirements:
|
91
|
-
- -
|
92
|
-
- !ruby/object:Gem::Version
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
none: false
|
98
|
-
requirements:
|
99
|
-
- - ! '>='
|
100
|
-
- !ruby/object:Gem::Version
|
101
|
-
version: '0'
|
87
|
+
requirements:
|
88
|
+
- - ">="
|
89
|
+
- !ruby/object:Gem::Version
|
90
|
+
hash: 3
|
91
|
+
segments:
|
92
|
+
- 0
|
93
|
+
version: "0"
|
102
94
|
type: :development
|
95
|
+
version_requirements: *id005
|
96
|
+
- !ruby/object:Gem::Dependency
|
97
|
+
name: simplecov
|
103
98
|
prerelease: false
|
104
|
-
|
99
|
+
requirement: &id006 !ruby/object:Gem::Requirement
|
105
100
|
none: false
|
106
|
-
requirements:
|
107
|
-
- -
|
108
|
-
- !ruby/object:Gem::Version
|
109
|
-
|
110
|
-
|
111
|
-
|
101
|
+
requirements:
|
102
|
+
- - "="
|
103
|
+
- !ruby/object:Gem::Version
|
104
|
+
hash: 1
|
105
|
+
segments:
|
106
|
+
- 0
|
107
|
+
- 7
|
108
|
+
- 1
|
109
|
+
version: 0.7.1
|
110
|
+
type: :development
|
111
|
+
version_requirements: *id006
|
112
|
+
description: "An Objeect Relational Mapping library for CQL3 "
|
113
|
+
email:
|
112
114
|
- jerphaes@gmail.com
|
113
115
|
executables: []
|
116
|
+
|
114
117
|
extensions: []
|
118
|
+
|
115
119
|
extra_rdoc_files: []
|
116
|
-
|
120
|
+
|
121
|
+
files:
|
117
122
|
- lib/believer/base.rb
|
118
123
|
- lib/believer/batch.rb
|
119
124
|
- lib/believer/batch_delete.rb
|
@@ -129,6 +134,8 @@ files:
|
|
129
134
|
- lib/believer/environment/merb_env.rb
|
130
135
|
- lib/believer/environment/rails_env.rb
|
131
136
|
- lib/believer/environment.rb
|
137
|
+
- lib/believer/filter_command.rb
|
138
|
+
- lib/believer/finder_methods.rb
|
132
139
|
- lib/believer/insert.rb
|
133
140
|
- lib/believer/limit.rb
|
134
141
|
- lib/believer/model_schema.rb
|
@@ -138,7 +145,6 @@ files:
|
|
138
145
|
- lib/believer/query.rb
|
139
146
|
- lib/believer/querying.rb
|
140
147
|
- lib/believer/relation.rb
|
141
|
-
- lib/believer/scoped_command.rb
|
142
148
|
- lib/believer/scoping.rb
|
143
149
|
- lib/believer/test/test_run_life_cycle.rb
|
144
150
|
- lib/believer/values.rb
|
@@ -150,51 +156,67 @@ files:
|
|
150
156
|
- spec/believer/callback_spec.rb
|
151
157
|
- spec/believer/delete_spec.rb
|
152
158
|
- spec/believer/environment_spec.rb
|
159
|
+
- spec/believer/finder_methods_spec.rb
|
153
160
|
- spec/believer/insert_spec.rb
|
154
161
|
- spec/believer/limit_spec.rb
|
155
162
|
- spec/believer/order_by_spec.rb
|
156
163
|
- spec/believer/query_spec.rb
|
164
|
+
- spec/believer/querying_spec.rb
|
157
165
|
- spec/believer/relation_spec.rb
|
166
|
+
- spec/believer/test_run_life_cycle_spec.rb
|
158
167
|
- spec/believer/time_series_spec.rb
|
159
168
|
- spec/believer/where_spec.rb
|
160
169
|
- spec/spec_helper.rb
|
161
170
|
- spec/support/setup_database.rb
|
162
171
|
- spec/support/test_classes.rb
|
163
172
|
homepage: http://github.com/jerphaes/believer
|
164
|
-
licenses:
|
173
|
+
licenses:
|
165
174
|
- Apache License 2.0
|
166
175
|
post_install_message:
|
167
176
|
rdoc_options: []
|
168
|
-
|
177
|
+
|
178
|
+
require_paths:
|
169
179
|
- lib
|
170
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
180
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
171
181
|
none: false
|
172
|
-
requirements:
|
173
|
-
- -
|
174
|
-
- !ruby/object:Gem::Version
|
182
|
+
requirements:
|
183
|
+
- - ">="
|
184
|
+
- !ruby/object:Gem::Version
|
185
|
+
hash: 55
|
186
|
+
segments:
|
187
|
+
- 1
|
188
|
+
- 9
|
189
|
+
- 2
|
175
190
|
version: 1.9.2
|
176
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
191
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
177
192
|
none: false
|
178
|
-
requirements:
|
179
|
-
- -
|
180
|
-
- !ruby/object:Gem::Version
|
181
|
-
|
193
|
+
requirements:
|
194
|
+
- - ">="
|
195
|
+
- !ruby/object:Gem::Version
|
196
|
+
hash: 3
|
197
|
+
segments:
|
198
|
+
- 0
|
199
|
+
version: "0"
|
182
200
|
requirements: []
|
201
|
+
|
183
202
|
rubyforge_project:
|
184
203
|
rubygems_version: 1.8.25
|
185
204
|
signing_key:
|
186
205
|
specification_version: 3
|
187
206
|
summary: CQL3 ORM
|
188
|
-
test_files:
|
207
|
+
test_files:
|
189
208
|
- spec/believer/base_spec.rb
|
190
209
|
- spec/believer/callback_spec.rb
|
191
210
|
- spec/believer/delete_spec.rb
|
192
211
|
- spec/believer/environment_spec.rb
|
212
|
+
- spec/believer/finder_methods_spec.rb
|
193
213
|
- spec/believer/insert_spec.rb
|
194
214
|
- spec/believer/limit_spec.rb
|
195
215
|
- spec/believer/order_by_spec.rb
|
196
216
|
- spec/believer/query_spec.rb
|
217
|
+
- spec/believer/querying_spec.rb
|
197
218
|
- spec/believer/relation_spec.rb
|
219
|
+
- spec/believer/test_run_life_cycle_spec.rb
|
198
220
|
- spec/believer/time_series_spec.rb
|
199
221
|
- spec/believer/where_spec.rb
|
200
222
|
- spec/spec_helper.rb
|