rumx 0.0.6 → 0.0.7
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/History.md +5 -0
- data/README.md +4 -1
- data/examples/timer/my_bean.rb +1 -1
- data/lib/rumx/server.rb +33 -13
- metadata +2 -2
data/History.md
CHANGED
@@ -1,12 +1,17 @@
|
|
1
1
|
Rumx Changelog
|
2
2
|
=====================
|
3
3
|
|
4
|
+
0.0.7
|
5
|
+
|
6
|
+
- Add .properties format for brain-dead hyperic. Might as well allow extending while we're at it.
|
7
|
+
|
4
8
|
0.0.6
|
5
9
|
|
6
10
|
- Separate out error tracking from Timer bean. TimerAndError bean now includes what Timer bean used to bean.
|
7
11
|
Timer and Error beans can be used to track time and errors individually.
|
8
12
|
Apologies for the somewhat incompatible change if anyone is already using Rumx::Beans::Timer. Just rename
|
9
13
|
to Rumx::Beans::TimerAndError if you want both.
|
14
|
+
- Fix bug where Rack mounted apps don't have the correct url.
|
10
15
|
|
11
16
|
0.0.5
|
12
17
|
|
data/README.md
CHANGED
@@ -87,6 +87,9 @@ Refer to the timer example for more information.
|
|
87
87
|
|
88
88
|
## TODO
|
89
89
|
|
90
|
+
Figure out the "NameError - uninitialized constant Rack::File:" error that occurs frequently on startup and seems related
|
91
|
+
to the tree not displaying correctly. Works okay with refresh.
|
92
|
+
|
90
93
|
Api doc non-existent.
|
91
94
|
|
92
95
|
Really needs some html/css love. Right now the sinatra pages are so ugly they'll make your eyes hurt but I don't do this stuff
|
@@ -102,7 +105,7 @@ New types :date and :datetime?
|
|
102
105
|
|
103
106
|
Build in optional authentication or just let user extend Rumx::Server?
|
104
107
|
|
105
|
-
Railtie it
|
108
|
+
Railtie it?
|
106
109
|
|
107
110
|
## Author
|
108
111
|
|
data/examples/timer/my_bean.rb
CHANGED
@@ -14,10 +14,10 @@ class MyBean
|
|
14
14
|
while true
|
15
15
|
begin
|
16
16
|
@timer.measure do
|
17
|
+
sleep @sleep_time
|
17
18
|
if rand(100) < @percent_failure
|
18
19
|
raise "Failure occurred with sleep_time=#{@sleep_time} and percent failure=#{@percent_failure}"
|
19
20
|
end
|
20
|
-
sleep @sleep_time
|
21
21
|
end
|
22
22
|
rescue Exception => e
|
23
23
|
# Error handling...
|
data/lib/rumx/server.rb
CHANGED
@@ -8,6 +8,7 @@ module Rumx
|
|
8
8
|
configure do
|
9
9
|
enable :logging
|
10
10
|
mime_type :json, 'application/json'
|
11
|
+
mime_type :properties, 'text/plain'
|
11
12
|
end
|
12
13
|
|
13
14
|
set :root, File.join(File.dirname(__FILE__), 'server')
|
@@ -92,17 +93,36 @@ module Rumx
|
|
92
93
|
partial :attribute_value_tag, :locals => {:attribute => attribute, :param_name => param_name, :value => value}
|
93
94
|
end
|
94
95
|
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
96
|
+
# Brain-dead hyperic doesn't know about json?
|
97
|
+
def to_properties(val, prefix=nil)
|
98
|
+
str = ''
|
99
|
+
new_prefix = (prefix + '.') if prefix
|
100
|
+
new_prefix = new_prefix || ''
|
101
|
+
if val.kind_of?(Hash)
|
102
|
+
val.each do |key, value|
|
103
|
+
str += to_properties(value, new_prefix + key.to_s)
|
103
104
|
end
|
105
|
+
elsif val.kind_of?(Array)
|
106
|
+
val.each_with_index do |value, i|
|
107
|
+
str += to_properties(value, new_prefix + i.to_s)
|
108
|
+
end
|
109
|
+
else
|
110
|
+
str += "#{prefix}=#{val}\n"
|
104
111
|
end
|
105
|
-
|
112
|
+
return str
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
116
|
+
def handle_attributes(attribute_hash, format)
|
117
|
+
case format
|
118
|
+
when 'json'
|
119
|
+
content_type :json
|
120
|
+
attribute_hash.to_json
|
121
|
+
when 'properties'
|
122
|
+
content_type :properties
|
123
|
+
to_properties(attribute_hash)
|
124
|
+
else
|
125
|
+
404
|
106
126
|
end
|
107
127
|
end
|
108
128
|
|
@@ -115,8 +135,8 @@ module Rumx
|
|
115
135
|
bean = Bean.find(path.split('/'))
|
116
136
|
return 404 unless bean
|
117
137
|
# For get we read, then write. post is the other way around.
|
118
|
-
if params[:format]
|
119
|
-
bean.bean_get_and_set_attributes(params)
|
138
|
+
if params[:format]
|
139
|
+
handle_attributes(bean.bean_get_and_set_attributes(params), params[:format])
|
120
140
|
else
|
121
141
|
haml_for_ajax :content_attributes, :locals => {:get_set_method => :bean_get_and_set_attributes, :params => params, :path => path, :bean => bean}
|
122
142
|
end
|
@@ -128,8 +148,8 @@ module Rumx
|
|
128
148
|
return 404 unless bean
|
129
149
|
#puts "params=#{params.inspect}"
|
130
150
|
# For post we write, then read. get is the other way around.
|
131
|
-
if params[:format]
|
132
|
-
bean.bean_set_and_get_attributes(params)
|
151
|
+
if params[:format]
|
152
|
+
handle_attributes(bean.bean_set_and_get_attributes(params), params[:format])
|
133
153
|
else
|
134
154
|
haml_for_ajax :content_attributes, :locals => {:get_set_method => :bean_set_and_get_attributes, :params => params, :path => path, :bean => bean}
|
135
155
|
end
|
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.7
|
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-14 00:00:00 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: sinatra
|