rumx 0.0.5 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- data/History.md +7 -0
- data/examples/timer/my_bean.rb +1 -1
- data/lib/rumx/beans.rb +2 -0
- data/lib/rumx/beans/error.rb +36 -0
- data/lib/rumx/beans/timer.rb +2 -14
- data/lib/rumx/beans/timer_and_error.rb +37 -0
- data/lib/rumx/server.rb +4 -4
- data/lib/rumx/server/views/content_attributes.haml.error_attempt +51 -0
- metadata +5 -2
data/History.md
CHANGED
@@ -1,6 +1,13 @@
|
|
1
1
|
Rumx Changelog
|
2
2
|
=====================
|
3
3
|
|
4
|
+
0.0.6
|
5
|
+
|
6
|
+
- Separate out error tracking from Timer bean. TimerAndError bean now includes what Timer bean used to bean.
|
7
|
+
Timer and Error beans can be used to track time and errors individually.
|
8
|
+
Apologies for the somewhat incompatible change if anyone is already using Rumx::Beans::Timer. Just rename
|
9
|
+
to Rumx::Beans::TimerAndError if you want both.
|
10
|
+
|
4
11
|
0.0.5
|
5
12
|
|
6
13
|
- Allow default values for operation arguments.
|
data/examples/timer/my_bean.rb
CHANGED
data/lib/rumx/beans.rb
CHANGED
@@ -0,0 +1,36 @@
|
|
1
|
+
module Rumx
|
2
|
+
module Beans
|
3
|
+
class Error
|
4
|
+
include Bean
|
5
|
+
|
6
|
+
bean_attr_reader :error_count, :integer, 'Number of times the measured block has raised an exception'
|
7
|
+
bean_attr_embed_list :errors, 'List of the last occurring errors'
|
8
|
+
|
9
|
+
def initialize(opts={})
|
10
|
+
@errors = []
|
11
|
+
@max_errors = (opts[:max_errors] || 1).to_i
|
12
|
+
end
|
13
|
+
|
14
|
+
def reset=(val)
|
15
|
+
if val
|
16
|
+
@error_count = 0
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def perform(prefix='')
|
21
|
+
yield
|
22
|
+
rescue Exception => e
|
23
|
+
bean_synchronize do
|
24
|
+
@error_count += 1
|
25
|
+
@errors << Message.new(e.message)
|
26
|
+
@errors.shift while @errors.size > @max_errors
|
27
|
+
end
|
28
|
+
raise
|
29
|
+
end
|
30
|
+
|
31
|
+
def to_s
|
32
|
+
"error_count=#{@error_count} last_error=#{@errors.last}"
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
data/lib/rumx/beans/timer.rb
CHANGED
@@ -4,35 +4,30 @@ module Rumx
|
|
4
4
|
include Bean
|
5
5
|
|
6
6
|
bean_attr_reader :total_count, :integer, 'Number of times the measured block has run'
|
7
|
-
bean_attr_reader :error_count, :integer, 'Number of times the measured block has raised an exception'
|
8
7
|
bean_attr_reader :total_time, :float, 'Total time (msec) for all the runs of the timed instruction'
|
9
8
|
bean_attr_reader :max_time, :float, 'The maximum time (msec) for all the runs of the timed instruction'
|
10
9
|
bean_attr_reader :min_time, :float, 'The minimum time (msec) for all the runs of the timed instruction'
|
11
10
|
bean_attr_reader :last_time, :float, 'The time (msec) for the last run of the timed instruction'
|
12
11
|
bean_reader :avg_time, :float, 'The average time (msec) for all runs of the timed instruction'
|
13
|
-
bean_writer :reset, :boolean, 'Reset the times and counts to zero (Note that last_time
|
14
|
-
bean_attr_embed_list :errors, 'List of the last occurring errors'
|
12
|
+
bean_writer :reset, :boolean, 'Reset the times and counts to zero (Note that last_time is not reset)'
|
15
13
|
|
16
14
|
def initialize(opts={})
|
17
15
|
# Force initialization of Bean#bean_mutex to avoid race condition (See bean.rb)
|
18
16
|
bean_mutex
|
19
17
|
@last_time = 0.0
|
20
18
|
self.reset = true
|
21
|
-
@errors = []
|
22
|
-
@max_errors = (opts[:max_errors] || 1).to_i
|
23
19
|
end
|
24
20
|
|
25
21
|
def reset=(val)
|
26
22
|
if val
|
27
23
|
@total_count = 0
|
28
|
-
@error_count = 0
|
29
24
|
@min_time = nil
|
30
25
|
@max_time = 0.0
|
31
26
|
@total_time = 0.0
|
32
27
|
end
|
33
28
|
end
|
34
29
|
|
35
|
-
def measure
|
30
|
+
def measure
|
36
31
|
start_time = Time.now
|
37
32
|
begin
|
38
33
|
yield
|
@@ -47,13 +42,6 @@ module Rumx
|
|
47
42
|
end
|
48
43
|
end
|
49
44
|
return current_time
|
50
|
-
rescue Exception => e
|
51
|
-
bean_synchronize do
|
52
|
-
@error_count += 1
|
53
|
-
@errors << Message.new(e.message)
|
54
|
-
@errors.shift while @errors.size > @max_errors
|
55
|
-
end
|
56
|
-
raise
|
57
45
|
end
|
58
46
|
|
59
47
|
def min_time
|
@@ -0,0 +1,37 @@
|
|
1
|
+
module Rumx
|
2
|
+
module Beans
|
3
|
+
class TimerAndError < Timer
|
4
|
+
|
5
|
+
bean_attr_reader :error_count, :integer, 'Number of times the measured block has raised an exception'
|
6
|
+
bean_attr_embed_list :errors, 'List of the last occurring errors'
|
7
|
+
|
8
|
+
def initialize(opts={})
|
9
|
+
super
|
10
|
+
@errors = []
|
11
|
+
@max_errors = (opts[:max_errors] || 1).to_i
|
12
|
+
end
|
13
|
+
|
14
|
+
def reset=(val)
|
15
|
+
super
|
16
|
+
if val
|
17
|
+
@error_count = 0
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def measure
|
22
|
+
super
|
23
|
+
rescue Exception => e
|
24
|
+
bean_synchronize do
|
25
|
+
@error_count += 1
|
26
|
+
@errors << Message.new(e.message)
|
27
|
+
@errors.shift while @errors.size > @max_errors
|
28
|
+
end
|
29
|
+
raise
|
30
|
+
end
|
31
|
+
|
32
|
+
def to_s
|
33
|
+
"error_count=#{@error_count}" + super
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
data/lib/rumx/server.rb
CHANGED
@@ -34,19 +34,19 @@ module Rumx
|
|
34
34
|
end
|
35
35
|
|
36
36
|
def attributes_path(path)
|
37
|
-
URI.escape(path + '/attributes')
|
37
|
+
url URI.escape(path + '/attributes')
|
38
38
|
end
|
39
39
|
|
40
40
|
def attribute_path(path)
|
41
|
-
URI.escape(path + '/attribute')
|
41
|
+
url URI.escape(path + '/attribute')
|
42
42
|
end
|
43
43
|
|
44
44
|
def operations_path(path)
|
45
|
-
URI.escape(path + '/operations')
|
45
|
+
url URI.escape(path + '/operations')
|
46
46
|
end
|
47
47
|
|
48
48
|
def operation_path(path)
|
49
|
-
URI.escape(path + '/operation')
|
49
|
+
url URI.escape(path + '/operation')
|
50
50
|
end
|
51
51
|
|
52
52
|
# http://sinatra-book.gittr.com/#implementation_of_rails_style_partials but extract_options! part of ActiveSupport
|
@@ -0,0 +1,51 @@
|
|
1
|
+
%h3= path
|
2
|
+
%h4 Attributes
|
3
|
+
%form#form{ :method =>'POST' }
|
4
|
+
%table{:width => '100%'}
|
5
|
+
%thead
|
6
|
+
%tr
|
7
|
+
%td Name
|
8
|
+
%td Description
|
9
|
+
%td Allow Read
|
10
|
+
%td Allow Write
|
11
|
+
%td Type
|
12
|
+
%td Value
|
13
|
+
%tbody
|
14
|
+
- bean.send(get_set_method, params) do |attribute, value, rel_path, param_name|
|
15
|
+
%tr
|
16
|
+
- #puts "path=#{path} type=#{path.class.name} rel_path=#{rel_path} class=#{rel_path.class.name}"
|
17
|
+
%td= link_to_attribute(path, rel_path)
|
18
|
+
%td= attribute.description
|
19
|
+
%td= attribute.allow_read
|
20
|
+
%td= attribute.allow_write
|
21
|
+
%td= attribute.type.to_s
|
22
|
+
%td= attribute_value_tag(attribute, param_name, value)
|
23
|
+
%input{ :type => 'submit', :value => 'Update' }
|
24
|
+
|
25
|
+
:javascript
|
26
|
+
$("#form").submit(function() {
|
27
|
+
$.post("#{attributes_path(path)}", $("#form").serialize(), function(result) {
|
28
|
+
$("#content").html(result);
|
29
|
+
})
|
30
|
+
.error(function(xhr, ajaxOptions, thrownError) { alert("error"); });
|
31
|
+
return false;
|
32
|
+
});
|
33
|
+
-#$().ready(function(){
|
34
|
+
-#$.ajaxSetup({
|
35
|
+
-# error:function(x,e){
|
36
|
+
-# if(x.status==0){
|
37
|
+
-# alert('You are offline!!\n Please Check Your Network.');
|
38
|
+
-# }else if(x.status==404){
|
39
|
+
-# alert('Requested URL not found.');
|
40
|
+
-# }else if(x.status==500){
|
41
|
+
-# alert('Internel Server Error.');
|
42
|
+
-# }else if(e=='parsererror'){
|
43
|
+
-# alert('Error.\nParsing JSON Request failed.');
|
44
|
+
-# }else if(e=='timeout'){
|
45
|
+
-# alert('Request Time out.');
|
46
|
+
-# }else {
|
47
|
+
-# alert('Unknow Error.\n'+x.responseText);
|
48
|
+
-# }
|
49
|
+
-# }
|
50
|
+
-#});
|
51
|
+
-#});
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: rumx
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.0.
|
5
|
+
version: 0.0.6
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Brad Pardee
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2011-12-
|
13
|
+
date: 2011-12-12 00:00:00 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: sinatra
|
@@ -79,9 +79,11 @@ files:
|
|
79
79
|
- lib/rumx/operation.rb
|
80
80
|
- lib/rumx/server.rb
|
81
81
|
- lib/rumx/type.rb
|
82
|
+
- lib/rumx/beans/error.rb
|
82
83
|
- lib/rumx/beans/folder.rb
|
83
84
|
- lib/rumx/beans/message.rb
|
84
85
|
- lib/rumx/beans/timer.rb
|
86
|
+
- lib/rumx/beans/timer_and_error.rb
|
85
87
|
- lib/rumx/server/public/attribute_test.html
|
86
88
|
- lib/rumx/server/public/jquery-ui-1.8.16.custom.min.js
|
87
89
|
- lib/rumx/server/public/jquery.jstree.js
|
@@ -111,6 +113,7 @@ files:
|
|
111
113
|
- lib/rumx/server/views/attribute_value_tag.haml
|
112
114
|
- lib/rumx/server/views/content_attribute.haml
|
113
115
|
- lib/rumx/server/views/content_attributes.haml
|
116
|
+
- lib/rumx/server/views/content_attributes.haml.error_attempt
|
114
117
|
- lib/rumx/server/views/content_operation.haml
|
115
118
|
- lib/rumx/server/views/content_operations.haml
|
116
119
|
- lib/rumx/server/views/index.haml
|