dynobattery 0.1.0
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/Manifest +4 -0
- data/README.rdoc +3 -0
- data/Rakefile +16 -0
- data/dynobattery.gemspec +30 -0
- data/lib/dynobattery.rb +32 -0
- metadata +73 -0
data/Manifest
ADDED
data/README.rdoc
ADDED
data/Rakefile
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake'
|
3
|
+
require 'echoe'
|
4
|
+
require 'net/http'
|
5
|
+
require 'heroku'
|
6
|
+
|
7
|
+
Echoe.new('dynobattery', '0.1.0') do |p|
|
8
|
+
p.description = "Submit request operations for dyno calculations on Heroku"
|
9
|
+
p.url = "http://github.com/fedesoria/dynobattery"
|
10
|
+
p.author = "Federico Soria"
|
11
|
+
p.email = "federico@dospuntocero.com.mx"
|
12
|
+
p.ignore_pattern = ["tmp/*", "script/*"]
|
13
|
+
p.development_dependencies = []
|
14
|
+
end
|
15
|
+
|
16
|
+
Dir["#{File.dirname(__FILE__)}/tasks/*.rake"].sort.each { |ext| load ext }
|
data/dynobattery.gemspec
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
Gem::Specification.new do |s|
|
4
|
+
s.name = %q{dynobattery}
|
5
|
+
s.version = "0.1.0"
|
6
|
+
|
7
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
|
8
|
+
s.authors = ["Federico Soria"]
|
9
|
+
s.date = %q{2010-06-28}
|
10
|
+
s.description = %q{Submit request operations for dyno calculations on Heroku}
|
11
|
+
s.email = %q{federico@dospuntocero.com.mx}
|
12
|
+
s.extra_rdoc_files = ["README.rdoc", "lib/dynobattery.rb"]
|
13
|
+
s.files = ["Manifest", "README.rdoc", "Rakefile", "lib/dynobattery.rb", "dynobattery.gemspec"]
|
14
|
+
s.homepage = %q{http://github.com/fedesoria/dynobattery}
|
15
|
+
s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Dynobattery", "--main", "README.rdoc"]
|
16
|
+
s.require_paths = ["lib"]
|
17
|
+
s.rubyforge_project = %q{dynobattery}
|
18
|
+
s.rubygems_version = %q{1.3.6}
|
19
|
+
s.summary = %q{Submit request operations for dyno calculations on Heroku}
|
20
|
+
|
21
|
+
if s.respond_to? :specification_version then
|
22
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
23
|
+
s.specification_version = 3
|
24
|
+
|
25
|
+
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
26
|
+
else
|
27
|
+
end
|
28
|
+
else
|
29
|
+
end
|
30
|
+
end
|
data/lib/dynobattery.rb
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
class DynoBattery
|
2
|
+
def initialize(app)
|
3
|
+
@app = app
|
4
|
+
end
|
5
|
+
|
6
|
+
def call(env)
|
7
|
+
uri = URI.parse("http://dyno-battery.heroku.com/")
|
8
|
+
http = Net::HTTP.new(uri.host, uri.port)
|
9
|
+
http.open_timeout = 3
|
10
|
+
http.read_timeout = 3
|
11
|
+
start = Time.now
|
12
|
+
status, headers, response = @app.call(env)
|
13
|
+
stop = Time.now
|
14
|
+
if stop.min == 40
|
15
|
+
get_dynos
|
16
|
+
http.post("/heroku","name=#{DYNO_DOMAIN}&date=#{start.to_s}&time=#{"%10.6f" % (stop - start)}&dyno=#{@dynos}")
|
17
|
+
else
|
18
|
+
http.post("/heroku","name=#{DYNO_DOMAIN}&date=#{start.to_s}&time=#{"%10.6f" % (stop - start)}")
|
19
|
+
end
|
20
|
+
[status, headers, response]
|
21
|
+
end
|
22
|
+
|
23
|
+
|
24
|
+
def get_dynos
|
25
|
+
heroku = Heroku::Client.new(DYNO_USER, DYNO_PASSWORD)
|
26
|
+
@dynos = heroku.info(DYNO_DOMAIN)[:dynos]
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
30
|
+
|
31
|
+
|
32
|
+
|
metadata
ADDED
@@ -0,0 +1,73 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: dynobattery
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 1
|
8
|
+
- 0
|
9
|
+
version: 0.1.0
|
10
|
+
platform: ruby
|
11
|
+
authors:
|
12
|
+
- Federico Soria
|
13
|
+
autorequire:
|
14
|
+
bindir: bin
|
15
|
+
cert_chain: []
|
16
|
+
|
17
|
+
date: 2010-06-28 00:00:00 -05:00
|
18
|
+
default_executable:
|
19
|
+
dependencies: []
|
20
|
+
|
21
|
+
description: Submit request operations for dyno calculations on Heroku
|
22
|
+
email: federico@dospuntocero.com.mx
|
23
|
+
executables: []
|
24
|
+
|
25
|
+
extensions: []
|
26
|
+
|
27
|
+
extra_rdoc_files:
|
28
|
+
- README.rdoc
|
29
|
+
- lib/dynobattery.rb
|
30
|
+
files:
|
31
|
+
- Manifest
|
32
|
+
- README.rdoc
|
33
|
+
- Rakefile
|
34
|
+
- lib/dynobattery.rb
|
35
|
+
- dynobattery.gemspec
|
36
|
+
has_rdoc: true
|
37
|
+
homepage: http://github.com/fedesoria/dynobattery
|
38
|
+
licenses: []
|
39
|
+
|
40
|
+
post_install_message:
|
41
|
+
rdoc_options:
|
42
|
+
- --line-numbers
|
43
|
+
- --inline-source
|
44
|
+
- --title
|
45
|
+
- Dynobattery
|
46
|
+
- --main
|
47
|
+
- README.rdoc
|
48
|
+
require_paths:
|
49
|
+
- lib
|
50
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
segments:
|
55
|
+
- 0
|
56
|
+
version: "0"
|
57
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
segments:
|
62
|
+
- 1
|
63
|
+
- 2
|
64
|
+
version: "1.2"
|
65
|
+
requirements: []
|
66
|
+
|
67
|
+
rubyforge_project: dynobattery
|
68
|
+
rubygems_version: 1.3.6
|
69
|
+
signing_key:
|
70
|
+
specification_version: 3
|
71
|
+
summary: Submit request operations for dyno calculations on Heroku
|
72
|
+
test_files: []
|
73
|
+
|