dboard 0.0.5 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/dboard.gemspec +0 -4
- data/lib/collector.rb +15 -8
- data/lib/version.rb +1 -1
- data/spec/collector_spec.rb +3 -3
- metadata +4 -69
- data/Guardfile +0 -8
data/dboard.gemspec
CHANGED
@@ -23,8 +23,4 @@ Gem::Specification.new do |s|
|
|
23
23
|
s.add_dependency "dalli", "~> 1.0.5"
|
24
24
|
s.add_dependency "sinatra", "~> 1.2"
|
25
25
|
s.add_development_dependency "rspec", "2.6.0"
|
26
|
-
s.add_development_dependency "guard", "0.5.1"
|
27
|
-
s.add_development_dependency "guard-rspec", "0.4.3"
|
28
|
-
s.add_development_dependency "guard-bundler", "0.1.3"
|
29
|
-
s.add_development_dependency "rb-fsevent", "0.4.1"
|
30
26
|
end
|
data/lib/collector.rb
CHANGED
@@ -28,20 +28,27 @@ module Dboard
|
|
28
28
|
@sources.each do |source, instance|
|
29
29
|
Thread.new do
|
30
30
|
loop do
|
31
|
-
|
32
|
-
puts "#{source} updating..."
|
33
|
-
update_source(source, instance)
|
34
|
-
elapsed_time = Time.now - time
|
35
|
-
time_until_next_update = instance.update_interval - elapsed_time
|
36
|
-
time_until_next_update = 0 if time_until_next_update < 0
|
37
|
-
puts "#{source} done in #{elapsed_time} seconds, will update again in #{time_until_next_update} seconds (interval: #{instance.update_interval})."
|
38
|
-
sleep time_until_next_update
|
31
|
+
update_in_thread
|
39
32
|
end
|
40
33
|
end
|
41
34
|
end
|
42
35
|
loop { sleep 1 }
|
43
36
|
end
|
44
37
|
|
38
|
+
def update_in_thread
|
39
|
+
time = Time.now
|
40
|
+
puts "#{source} updating..."
|
41
|
+
update_source(source, instance)
|
42
|
+
elapsed_time = Time.now - time
|
43
|
+
time_until_next_update = instance.update_interval - elapsed_time
|
44
|
+
time_until_next_update = 0 if time_until_next_update < 0
|
45
|
+
puts "#{source} done in #{elapsed_time} seconds, will update again in #{time_until_next_update} seconds (interval: #{instance.update_interval})."
|
46
|
+
sleep time_until_next_update
|
47
|
+
rescue Exception => ex
|
48
|
+
puts "Something failed outside the update_source method. #{ex.message}"
|
49
|
+
puts ex.backtrace
|
50
|
+
end
|
51
|
+
|
45
52
|
def update_source(source, instance)
|
46
53
|
begin
|
47
54
|
data = instance.fetch
|
data/lib/version.rb
CHANGED
data/spec/collector_spec.rb
CHANGED
@@ -9,7 +9,7 @@ describe Dboard::Collector, "register_source" do
|
|
9
9
|
it "can register a source" do
|
10
10
|
new_relic = mock
|
11
11
|
new_relic.stub!(:update_interval).and_return(5)
|
12
|
-
Dboard::Collector.
|
12
|
+
Dboard::Collector.register_source :new_relic, new_relic
|
13
13
|
Dboard::Collector.instance.sources.should == { :new_relic => new_relic }
|
14
14
|
end
|
15
15
|
|
@@ -17,14 +17,14 @@ describe Dboard::Collector, "register_source" do
|
|
17
17
|
new_relic = mock
|
18
18
|
new_relic.stub!(:fetch).and_return({ :db => "100%" })
|
19
19
|
callback = mock
|
20
|
-
Dboard::Collector.
|
20
|
+
Dboard::Collector.register_after_update_callback callback
|
21
21
|
|
22
22
|
callback.should_receive(:call)
|
23
23
|
Dboard::Publisher.stub!(:publish)
|
24
24
|
Dboard::Collector.instance.update_source(:new_relic, new_relic)
|
25
25
|
|
26
26
|
# since it is a singleton, and this callbacks leaks into the other tests
|
27
|
-
Dboard::Collector.
|
27
|
+
Dboard::Collector.register_after_update_callback(lambda {})
|
28
28
|
end
|
29
29
|
|
30
30
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dboard
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 23
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
|
+
- 1
|
7
8
|
- 0
|
8
9
|
- 0
|
9
|
-
|
10
|
-
version: 0.0.5
|
10
|
+
version: 1.0.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- "Joakim Kolsj\xC3\xB6"
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date:
|
18
|
+
date: 2013-07-22 00:00:00 +02:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -113,70 +113,6 @@ dependencies:
|
|
113
113
|
version: 2.6.0
|
114
114
|
type: :development
|
115
115
|
version_requirements: *id006
|
116
|
-
- !ruby/object:Gem::Dependency
|
117
|
-
name: guard
|
118
|
-
prerelease: false
|
119
|
-
requirement: &id007 !ruby/object:Gem::Requirement
|
120
|
-
none: false
|
121
|
-
requirements:
|
122
|
-
- - "="
|
123
|
-
- !ruby/object:Gem::Version
|
124
|
-
hash: 9
|
125
|
-
segments:
|
126
|
-
- 0
|
127
|
-
- 5
|
128
|
-
- 1
|
129
|
-
version: 0.5.1
|
130
|
-
type: :development
|
131
|
-
version_requirements: *id007
|
132
|
-
- !ruby/object:Gem::Dependency
|
133
|
-
name: guard-rspec
|
134
|
-
prerelease: false
|
135
|
-
requirement: &id008 !ruby/object:Gem::Requirement
|
136
|
-
none: false
|
137
|
-
requirements:
|
138
|
-
- - "="
|
139
|
-
- !ruby/object:Gem::Version
|
140
|
-
hash: 9
|
141
|
-
segments:
|
142
|
-
- 0
|
143
|
-
- 4
|
144
|
-
- 3
|
145
|
-
version: 0.4.3
|
146
|
-
type: :development
|
147
|
-
version_requirements: *id008
|
148
|
-
- !ruby/object:Gem::Dependency
|
149
|
-
name: guard-bundler
|
150
|
-
prerelease: false
|
151
|
-
requirement: &id009 !ruby/object:Gem::Requirement
|
152
|
-
none: false
|
153
|
-
requirements:
|
154
|
-
- - "="
|
155
|
-
- !ruby/object:Gem::Version
|
156
|
-
hash: 29
|
157
|
-
segments:
|
158
|
-
- 0
|
159
|
-
- 1
|
160
|
-
- 3
|
161
|
-
version: 0.1.3
|
162
|
-
type: :development
|
163
|
-
version_requirements: *id009
|
164
|
-
- !ruby/object:Gem::Dependency
|
165
|
-
name: rb-fsevent
|
166
|
-
prerelease: false
|
167
|
-
requirement: &id010 !ruby/object:Gem::Requirement
|
168
|
-
none: false
|
169
|
-
requirements:
|
170
|
-
- - "="
|
171
|
-
- !ruby/object:Gem::Version
|
172
|
-
hash: 13
|
173
|
-
segments:
|
174
|
-
- 0
|
175
|
-
- 4
|
176
|
-
- 1
|
177
|
-
version: 0.4.1
|
178
|
-
type: :development
|
179
|
-
version_requirements: *id010
|
180
116
|
description: Dashboard framework
|
181
117
|
email:
|
182
118
|
- joakim.kolsjo@gmail.com
|
@@ -190,7 +126,6 @@ files:
|
|
190
126
|
- .gitignore
|
191
127
|
- .rvmrc
|
192
128
|
- Gemfile
|
193
|
-
- Guardfile
|
194
129
|
- LICENCE
|
195
130
|
- README.md
|
196
131
|
- Rakefile
|
data/Guardfile
DELETED
@@ -1,8 +0,0 @@
|
|
1
|
-
guard 'rspec', :version => 2, :all_on_start => false, :all_after_pass => true, :bundler => false, :keep_failed => false do
|
2
|
-
watch(%r{^spec/.+_spec\.rb$})
|
3
|
-
watch(%r{^lib/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
|
4
|
-
end
|
5
|
-
|
6
|
-
guard 'bundler' do
|
7
|
-
watch('Gemfile')
|
8
|
-
end
|