rhosync 2.0.9 → 2.1.0.beta.1

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.
Files changed (52) hide show
  1. data/CHANGELOG +9 -0
  2. data/Rakefile +1 -1
  3. data/bench/benchapp/sources/mock_adapter.rb +2 -2
  4. data/bench/benchapp/tmp/restart.txt +0 -0
  5. data/bench/spec/mock_adapter_spec.rb +1 -1
  6. data/lib/rhosync/api/stats.rb +21 -0
  7. data/lib/rhosync/bulk_data/bulk_data.rb +1 -1
  8. data/lib/rhosync/client.rb +10 -0
  9. data/lib/rhosync/console/app/public/home.css +9 -4
  10. data/lib/rhosync/console/app/public/images/foot_logo_rhosync.png +0 -0
  11. data/lib/rhosync/console/app/public/images/landing_header.jpg +0 -0
  12. data/lib/rhosync/console/app/public/jqplot/excanvas.min.js +35 -0
  13. data/lib/rhosync/console/app/public/jqplot/jqplot.barRenderer.min.js +34 -0
  14. data/lib/rhosync/console/app/public/jqplot/jqplot.canvasAxisLabelRenderer.js +187 -0
  15. data/lib/rhosync/console/app/public/jqplot/jqplot.canvasAxisTickRenderer.js +226 -0
  16. data/lib/rhosync/console/app/public/jqplot/jqplot.canvasTextRenderer.js +408 -0
  17. data/lib/rhosync/console/app/public/jqplot/jqplot.categoryAxisRenderer.min.js +34 -0
  18. data/lib/rhosync/console/app/public/jqplot/jqplot.cursor.js +952 -0
  19. data/lib/rhosync/console/app/public/jqplot/jqplot.dateAxisRenderer.js +313 -0
  20. data/lib/rhosync/console/app/public/jqplot/jqplot.dateAxisRenderer.min.js +34 -0
  21. data/lib/rhosync/console/app/public/jqplot/jqplot.pointLabels.min.js +34 -0
  22. data/lib/rhosync/console/app/public/jqplot/jquery-1.4.2.min.js +154 -0
  23. data/lib/rhosync/console/app/public/jqplot/jquery.jqplot.min.css +1 -0
  24. data/lib/rhosync/console/app/public/jqplot/jquery.jqplot.min.js +34 -0
  25. data/lib/rhosync/console/app/routes/timing.rb +223 -7
  26. data/lib/rhosync/console/app/views/content.erb +1 -1
  27. data/lib/rhosync/console/app/views/headermenu.erb +4 -4
  28. data/lib/rhosync/console/app/views/jqplot.erb +52 -0
  29. data/lib/rhosync/console/app/views/layout.erb +86 -11
  30. data/lib/rhosync/console/rhosync_api.rb +19 -0
  31. data/lib/rhosync/jobs/bulk_data_job.rb +2 -2
  32. data/lib/rhosync/stats/middleware.rb +4 -6
  33. data/lib/rhosync/stats/record.rb +51 -26
  34. data/lib/rhosync/store.rb +12 -1
  35. data/lib/rhosync/tasks.rb +4 -2
  36. data/lib/rhosync/user.rb +11 -1
  37. data/lib/rhosync/version.rb +2 -2
  38. data/lib/rhosync.rb +3 -3
  39. data/spec/api/rhosync_api_spec.rb +26 -0
  40. data/spec/api/stats_spec.rb +66 -0
  41. data/spec/client_spec.rb +40 -0
  42. data/spec/client_sync_spec.rb +14 -0
  43. data/spec/stats/middleware_spec.rb +11 -5
  44. data/spec/stats/record_spec.rb +30 -11
  45. data/spec/store_spec.rb +15 -1
  46. data/spec/user_spec.rb +44 -0
  47. metadata +32 -14
  48. data/doc/protocol.html +0 -2291
  49. data/doc/public/css/print.css +0 -29
  50. data/doc/public/css/screen.css +0 -257
  51. data/doc/public/css/style.css +0 -20
  52. data/lib/rhosync/console/app/public/images/header_halo copy.jpg +0 -0
@@ -1,6 +1,6 @@
1
1
  require 'rhosync'
2
- FOO_RECORD_RESOLUTION = 2
3
- FOO_RECORD_SIZE = 8
2
+ STATS_RECORD_RESOLUTION = 2 unless defined? STATS_RECORD_RESOLUTION
3
+ STATS_RECORD_SIZE = 8 unless defined? STATS_RECORD_SIZE
4
4
 
5
5
  include Rhosync
6
6
  include Rhosync::Stats
@@ -10,12 +10,13 @@ describe "Record" do
10
10
  before(:each) do
11
11
  @now = 9
12
12
  Store.db.flushdb
13
+ Store.stub!(:lock).and_yield
13
14
  end
14
15
 
15
16
  it "should add metric to the record and trim record size" do
16
17
  Time.stub!(:now).and_return { @now += 1; @now }
17
18
  10.times { Record.add('foo') }
18
- Store.db.zrange('stat:foo', 0, -1).should == ["2:13", "2:15", "2:17", "2:19"]
19
+ Store.db.zrange('stat:foo', 0, -1).should == ["2:12", "2:14", "2:16", "2:18"]
19
20
  end
20
21
 
21
22
  it "should add single record" do
@@ -24,16 +25,35 @@ describe "Record" do
24
25
  Store.db.zrange('stat:foo', 0, -1).should == ["1:10"]
25
26
  end
26
27
 
28
+ it "should return type of metric" do
29
+ Record.add('foo')
30
+ Record.rtype('foo').should == 'zset'
31
+ end
32
+
33
+ it "should set string metric" do
34
+ Record.set_value('foo', 'bar')
35
+ Store.db.get('stat:foo').should == 'bar'
36
+ end
37
+
38
+ it "should get string metric" do
39
+ Store.db.set('stat:foo', 'bar')
40
+ Record.get_value('foo').should == 'bar'
41
+ end
42
+
43
+ it "should get keys" do
44
+ Record.add('foo')
45
+ Record.add('bar')
46
+ Record.keys.sort.should == ['bar','foo']
47
+ end
48
+
27
49
  it "should add absolute metric value" do
28
50
  Time.stub!(:now).and_return { @now += 1; @now }
29
51
  time = 0
30
52
  4.times do
31
- Record.add('foo',time) do |current,value|
32
- Record.save_average(current, value)
33
- end
53
+ Record.save_average('foo',time)
34
54
  time += 1
35
55
  end
36
- Store.db.zrange('stat:foo', 0, -1).should == ["2.0,1.0:11", "2.0,5.0:13"]
56
+ Store.db.zrange('stat:foo', 0, -1).should == ["2.0,1.0:10", "2.0,5.0:12"]
37
57
  end
38
58
 
39
59
  it "should update metric" do
@@ -44,20 +64,19 @@ describe "Record" do
44
64
  # something interesting
45
65
  end
46
66
  end
47
- Store.db.zrange('stat:foo', 0, -1).should == ["1,1.0:15", "1,1.0:18", "1,1.0:21"]
48
- Rhosync.stats = nil
67
+ Store.db.zrange('stat:foo', 0, -1).should == ["1,1.0:14", "1,1.0:18", "1,1.0:20"]
49
68
  end
50
69
 
51
70
  it "should get range of metric values" do
52
71
  Time.stub!(:now).and_return { @now += 1; @now }
53
72
  10.times { Record.add('foo') }
54
- Record.range('foo', 0, 1).should == ["2:13", "2:15"]
73
+ Record.range('foo', 0, 1).should == ["2:12", "2:14"]
55
74
  end
56
75
 
57
76
  it "should reset metric" do
58
77
  Time.stub!(:now).and_return { @now += 1; @now }
59
78
  10.times { Record.add('foo') }
60
- Store.db.zrange('stat:foo', 0, -1).should == ["2:13", "2:15", "2:17", "2:19"]
79
+ Store.db.zrange('stat:foo', 0, -1).should == ["2:12", "2:14", "2:16", "2:18"]
61
80
  Record.reset('foo')
62
81
  Store.db.zrange('stat:foo', 0, -1).should == []
63
82
  end
data/spec/store_spec.rb CHANGED
@@ -40,6 +40,11 @@ describe "Store" do
40
40
  Store.get_data(@s.docname(:md)).should == @data
41
41
  end
42
42
 
43
+ it "should set_data and get_data" do
44
+ Store.set_data('foo', @data)
45
+ Store.get_data('foo').should == @data
46
+ end
47
+
43
48
  it "should add simple array data to new set" do
44
49
  @data = ['1','2','3']
45
50
  Store.put_data(@s.docname(:md),@data).should == true
@@ -58,6 +63,15 @@ describe "Store" do
58
63
  Store.get_value('foo').should == 'bar'
59
64
  end
60
65
 
66
+ it "should incr a key" do
67
+ Store.incr('foo').should == 1
68
+ end
69
+
70
+ it "should decr a key" do
71
+ Store.set_value('foo', 10)
72
+ Store.decr('foo').should == 9
73
+ end
74
+
61
75
  it "should return true/false if element ismember of a set" do
62
76
  Store.put_data('foo',['a'])
63
77
  Store.ismember?('foo','a').should == true
@@ -139,7 +153,7 @@ describe "Store" do
139
153
 
140
154
  it "should lock key for timeout" do
141
155
  doc = "locked_data"
142
- Store.db.set "#{doc}:lock", Time.now.to_i+3
156
+ Store.db.set "lock:#{doc}", Time.now.to_i+3
143
157
  Store.should_receive(:sleep).at_least(:once).with(1).and_return { sleep 1 }
144
158
  m_lock = Store.get_lock(doc,2)
145
159
  end
data/spec/user_spec.rb CHANGED
@@ -1,5 +1,8 @@
1
1
  require File.join(File.dirname(__FILE__),'spec_helper')
2
2
 
3
+ STATS_RECORD_RESOLUTION = 2 unless defined? STATS_RECORD_RESOLUTION
4
+ STATS_RECORD_SIZE = 8 unless defined? STATS_RECORD_SIZE
5
+
3
6
  describe "User" do
4
7
  it_should_behave_like "SpecBootstrapHelper"
5
8
  it_should_behave_like "SourceAdapterHelper"
@@ -10,6 +13,7 @@ describe "User" do
10
13
  @u1.id.should == @u.id
11
14
  @u1.login.should == @u_fields[:login]
12
15
  @u1.email.should == @u_fields[:email]
16
+ Store.get_value('user:count').should == "1"
13
17
  end
14
18
 
15
19
  it "should delete seats for user's clients" do
@@ -66,6 +70,7 @@ describe "User" do
66
70
  @c.put_data(:cd,@data)
67
71
  cid = @c.id
68
72
  @u.delete
73
+ Store.get_value('user:count').should == "0"
69
74
  User.is_exist?(@u_fields[:login]).should == false
70
75
  Client.is_exist?(cid).should == false
71
76
  @c.get_data(:cd).should == {}
@@ -76,4 +81,43 @@ describe "User" do
76
81
  @u.delete
77
82
  ApiToken.is_exist?(token).should == false
78
83
  end
84
+
85
+ describe "User Stats" do
86
+
87
+ before(:all) do
88
+ Store.stub!(:lock).and_yield
89
+ end
90
+
91
+ before(:each) do
92
+ Rhosync::Stats::Record.reset('users')
93
+ end
94
+
95
+ after(:each) do
96
+ Rhosync::Stats::Record.reset('users')
97
+ end
98
+
99
+ after(:all) do
100
+ Store.flash_data('stat:users*')
101
+ end
102
+
103
+ it "should increment user stats on create" do
104
+ Time.stub!(:now).and_return(10)
105
+ Rhosync.stats = true
106
+ User.create({:login => 'testuser2'})
107
+ Rhosync::Stats::Record.range('users',0,-1).should == ["2:10"]
108
+ Store.get_value('user:count').should == "2"
109
+ Rhosync.stats = false
110
+ end
111
+
112
+ it "should decrement user stats on delete" do
113
+ Time.stub!(:now).and_return(10)
114
+ Rhosync.stats = true
115
+ u = User.create({:login => 'testuser1'})
116
+ Rhosync::Stats::Record.range('users',0,-1).should == ["2:10"]
117
+ u.delete
118
+ Rhosync::Stats::Record.range('users',0,-1).should == ["1:10"]
119
+ Store.get_value('user:count').should == "1"
120
+ Rhosync.stats = false
121
+ end
122
+ end
79
123
  end
metadata CHANGED
@@ -1,13 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rhosync
3
3
  version: !ruby/object:Gem::Version
4
- hash: 29
5
- prerelease: false
4
+ hash: 62196465
5
+ prerelease: true
6
6
  segments:
7
7
  - 2
8
+ - 1
8
9
  - 0
9
- - 9
10
- version: 2.0.9
10
+ - beta
11
+ - 1
12
+ version: 2.1.0.beta.1
11
13
  platform: ruby
12
14
  authors:
13
15
  - Rhomobile
@@ -15,7 +17,7 @@ autorequire:
15
17
  bindir: bin
16
18
  cert_chain: []
17
19
 
18
- date: 2010-10-14 00:00:00 -07:00
20
+ date: 2010-11-07 00:00:00 -07:00
19
21
  default_executable: rhosync
20
22
  dependencies:
21
23
  - !ruby/object:Gem::Dependency
@@ -311,6 +313,7 @@ files:
311
313
  - bench/benchapp/settings/settings.yml
312
314
  - bench/benchapp/sources/mock_adapter.rb
313
315
  - bench/benchapp/sources/queue_mock_adapter.rb
316
+ - bench/benchapp/tmp/restart.txt
314
317
  - bench/lib/bench.rb
315
318
  - bench/lib/bench/cli.rb
316
319
  - bench/lib/bench/logging.rb
@@ -336,10 +339,6 @@ files:
336
339
  - bench/spec/result_spec.rb
337
340
  - bench/spec/utils_spec.rb
338
341
  - bin/rhosync
339
- - doc/protocol.html
340
- - doc/public/css/print.css
341
- - doc/public/css/screen.css
342
- - doc/public/css/style.css
343
342
  - generators/rhosync.rb
344
343
  - generators/templates/application/Rakefile
345
344
  - generators/templates/application/application.rb
@@ -370,6 +369,7 @@ files:
370
369
  - lib/rhosync/api/reset.rb
371
370
  - lib/rhosync/api/set_db_doc.rb
372
371
  - lib/rhosync/api/set_refresh_time.rb
372
+ - lib/rhosync/api/stats.rb
373
373
  - lib/rhosync/api/update_user.rb
374
374
  - lib/rhosync/api/upload_file.rb
375
375
  - lib/rhosync/api_token.rb
@@ -385,13 +385,26 @@ files:
385
385
  - lib/rhosync/console/app/helpers/helpers.rb
386
386
  - lib/rhosync/console/app/public/ThickBox.css
387
387
  - lib/rhosync/console/app/public/home.css
388
- - lib/rhosync/console/app/public/images/header_halo copy.jpg
388
+ - lib/rhosync/console/app/public/images/foot_logo_rhosync.png
389
389
  - lib/rhosync/console/app/public/images/header_halo.jpg
390
390
  - lib/rhosync/console/app/public/images/land_separator.gif
391
391
  - lib/rhosync/console/app/public/images/landing_header.jpg
392
392
  - lib/rhosync/console/app/public/images/logo_rhosync.png
393
393
  - lib/rhosync/console/app/public/images/rhomobile_rhohub_logo.png
394
394
  - lib/rhosync/console/app/public/images/tabs_separator.png
395
+ - lib/rhosync/console/app/public/jqplot/excanvas.min.js
396
+ - lib/rhosync/console/app/public/jqplot/jqplot.barRenderer.min.js
397
+ - lib/rhosync/console/app/public/jqplot/jqplot.canvasAxisLabelRenderer.js
398
+ - lib/rhosync/console/app/public/jqplot/jqplot.canvasAxisTickRenderer.js
399
+ - lib/rhosync/console/app/public/jqplot/jqplot.canvasTextRenderer.js
400
+ - lib/rhosync/console/app/public/jqplot/jqplot.categoryAxisRenderer.min.js
401
+ - lib/rhosync/console/app/public/jqplot/jqplot.cursor.js
402
+ - lib/rhosync/console/app/public/jqplot/jqplot.dateAxisRenderer.js
403
+ - lib/rhosync/console/app/public/jqplot/jqplot.dateAxisRenderer.min.js
404
+ - lib/rhosync/console/app/public/jqplot/jqplot.pointLabels.min.js
405
+ - lib/rhosync/console/app/public/jqplot/jquery-1.4.2.min.js
406
+ - lib/rhosync/console/app/public/jqplot/jquery.jqplot.min.css
407
+ - lib/rhosync/console/app/public/jqplot/jquery.jqplot.min.js
395
408
  - lib/rhosync/console/app/public/main.css
396
409
  - lib/rhosync/console/app/public/reset.css
397
410
  - lib/rhosync/console/app/public/style.css
@@ -410,6 +423,7 @@ files:
410
423
  - lib/rhosync/console/app/views/headermenu.erb
411
424
  - lib/rhosync/console/app/views/home.erb
412
425
  - lib/rhosync/console/app/views/index.erb
426
+ - lib/rhosync/console/app/views/jqplot.erb
413
427
  - lib/rhosync/console/app/views/layout.erb
414
428
  - lib/rhosync/console/app/views/login.erb
415
429
  - lib/rhosync/console/app/views/newuser.erb
@@ -471,6 +485,7 @@ files:
471
485
  - spec/api/rhosync_api_spec.rb
472
486
  - spec/api/set_db_doc_spec.rb
473
487
  - spec/api/set_refresh_time_spec.rb
488
+ - spec/api/stats_spec.rb
474
489
  - spec/api/update_user_spec.rb
475
490
  - spec/api/upload_file_spec.rb
476
491
  - spec/api_token_spec.rb
@@ -552,12 +567,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
552
567
  required_rubygems_version: !ruby/object:Gem::Requirement
553
568
  none: false
554
569
  requirements:
555
- - - ">="
570
+ - - ">"
556
571
  - !ruby/object:Gem::Version
557
- hash: 3
572
+ hash: 25
558
573
  segments:
559
- - 0
560
- version: "0"
574
+ - 1
575
+ - 3
576
+ - 1
577
+ version: 1.3.1
561
578
  requirements: []
562
579
 
563
580
  rubyforge_project:
@@ -588,6 +605,7 @@ test_files:
588
605
  - spec/api/rhosync_api_spec.rb
589
606
  - spec/api/set_db_doc_spec.rb
590
607
  - spec/api/set_refresh_time_spec.rb
608
+ - spec/api/stats_spec.rb
591
609
  - spec/api/update_user_spec.rb
592
610
  - spec/api/upload_file_spec.rb
593
611
  - spec/api_token_spec.rb