Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

gemify

  • Loading branch information...
commit ab1e165ab8cd9e42f5ed630d5901628ae2b2dc02 1 parent 566fb5a
@grosser authored
View
1  Gemfile
@@ -6,4 +6,5 @@ gem 'fastercsv'
group :dev do
gem 'rake'
gem 'rspec', '~>2'
+ gem 'jeweler'
end
View
6 Gemfile.lock
@@ -3,6 +3,11 @@ GEM
specs:
diff-lcs (1.1.2)
fastercsv (1.5.4)
+ git (1.2.5)
+ jeweler (1.5.2)
+ bundler (~> 1.0.0)
+ git (>= 1.2.5)
+ rake
mechanize (1.0.0)
nokogiri (>= 1.2.1)
nokogiri (1.4.4)
@@ -21,6 +26,7 @@ PLATFORMS
DEPENDENCIES
fastercsv
+ jeweler
mechanize
rake
rspec (~> 2)
View
17 Rakefile
@@ -5,6 +5,21 @@ end
task :headers do
require File.expand_path('lib/webpagetest_grabber')
csv = `curl http://www.webpagetest.org/result/110316_DA_5TFD/110316_DA_5TFD_google.com_page_data.csv`
- data = WebpagetestGrabber.csv_to_array(csv).first.keys
+ data = PagespeedGrabber.csv_to_array(csv).first.keys
puts data.inspect
end
+
+begin
+ require 'jeweler'
+ Jeweler::Tasks.new do |gem|
+ gem.name = 'pagespeed_grabber'
+ gem.summary = "Grab pagespeed results from external services to use them in e.g. munin."
+ gem.email = "michael@grosser.it"
+ gem.homepage = "http://github.com/grosser/#{gem.name}"
+ gem.authors = ["Michael Grosser"]
+ end
+
+ Jeweler::GemcutterTasks.new
+rescue LoadError
+ puts "Jeweler, or one of its dependencies, is not available. Install it with: gem install jeweler"
+end
View
23 Readme.md
@@ -1,4 +1,21 @@
-Grab raw csv results from webpagetest.org
+Grab pagespeed results from external services to use them in e.g. munin.<br/>
+Currently only support webpagetest.org, which is not very reliable and sometimes slow.
- # if the queue is full this will take forever, so be careful !!
- data = WebpagetestGrabber.fetch('google.com', :timeout => 200)
+Not ready for production just a toy project.
+
+ data = PagespeedGrabber.fetch('google.com', :from => 'webpagetest', :timeout => 200)
+
+### Munin
+`munin.rb` can be moved into munin/plugins and renamed to e.g. webpagetest_google.com to aggregate results.
+
+TODO
+====
+ - add other services
+ - make less hacky/use official apis
+ - generate initial AND repeated graph
+
+Authors
+=======
+[Michael Grosser](http://grosser.it)<br/>
+michael@grosser.it<br/>
+Hereby placed under public domain, do what you want, just do not hold me accountable...
View
1  VERSION
@@ -0,0 +1 @@
+0.0.1
View
7 lib/webpagetest_grabber.rb → lib/pagespeed_grabber.rb
@@ -3,10 +3,9 @@
require 'faster_csv'
require 'timeout'
-module WebpagetestGrabber
+module PagespeedGrabber
URL = 'http://www.webpagetest.org'
-
- # page takes ~ 20s to generate
+ VERSION = File.read( File.join(File.dirname(__FILE__),'..','VERSION') ).strip
DEFAULT_TIMEOUT = 100
TIME_BETWEEN_TRIES = 10
CSV_LINK = 'Raw page data'
@@ -14,7 +13,7 @@ module WebpagetestGrabber
def self.fetch(test_url, options={})
Timeout.timeout(options[:timeout]||DEFAULT_TIMEOUT) do
- csv_to_array(download_csv(test_url, options))
+ csv_to_array(download_csv(test_url))
end
end
View
7 munin.rb
@@ -1,6 +1,6 @@
#!/usr/bin/env ruby
require 'rubygems'
-require 'webpagetest_grabber'
+require 'pagespeed_grabber'
test_url = File.dirname(__FILE__).split('_',2).last
@@ -14,13 +14,12 @@ def clean_name(name)
puts "graph_scale no\n";
puts "graph_category other\n";
- WebpagetestGrabber::HEADERS.each do |header|
+ PagespeedGrabber::HEADERS.each do |header|
puts "#{clean_name(header)}.label #{header}\n"
end
else
- initial, repeated = WebpagetestGrabber.fetch(test_url)
+ initial, repeated = PagespeedGrabber.fetch(test_url)
initial.each do |header, value|
puts "#{clean_name(header)}.value #{value}"
end
end
-
View
47 pagespeed_grabber.gemspec
@@ -0,0 +1,47 @@
+# Generated by jeweler
+# DO NOT EDIT THIS FILE DIRECTLY
+# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
+# -*- encoding: utf-8 -*-
+
+Gem::Specification.new do |s|
+ s.name = %q{pagespeed_grabber}
+ s.version = "0.0.1"
+
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
+ s.authors = ["Michael Grosser"]
+ s.date = %q{2011-03-16}
+ s.email = %q{michael@grosser.it}
+ s.files = [
+ "Gemfile",
+ "Gemfile.lock",
+ "Rakefile",
+ "Readme.md",
+ "VERSION",
+ "lib/pagespeed_grabber.rb",
+ "munin.rb",
+ "spec/pagespeed_grabber_spec.rb"
+ ]
+ s.homepage = %q{http://github.com/grosser/pagespeed_grabber}
+ s.require_paths = ["lib"]
+ s.rubygems_version = %q{1.4.2}
+ s.summary = %q{Grab pagespeed results from external services to use them in e.g. munin.}
+ s.test_files = [
+ "spec/pagespeed_grabber_spec.rb"
+ ]
+
+ if s.respond_to? :specification_version then
+ s.specification_version = 3
+
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
+ s.add_runtime_dependency(%q<mechanize>, [">= 0"])
+ s.add_runtime_dependency(%q<fastercsv>, [">= 0"])
+ else
+ s.add_dependency(%q<mechanize>, [">= 0"])
+ s.add_dependency(%q<fastercsv>, [">= 0"])
+ end
+ else
+ s.add_dependency(%q<mechanize>, [">= 0"])
+ s.add_dependency(%q<fastercsv>, [">= 0"])
+ end
+end
+
View
8 spec/pagespeed_grabber_spec.rb
@@ -0,0 +1,8 @@
+require File.expand_path('lib/pagespeed_grabber')
+
+describe PagespeedGrabber do
+ it "can fetch results for an url" do
+ initial, repeated = PagespeedGrabber.fetch('google.com')
+ initial['Load Time (ms)'].to_i.should > repeated['Load Time (ms)'].to_i
+ end
+end
View
8 spec/webpagetest_grabber_spec.rb
@@ -1,8 +0,0 @@
-require File.expand_path('lib/webpagetest_grabber')
-
-describe WebpagetestGrabber do
- it "can fetch results for an url" do
- initial, repeated = WebpagetestGrabber.fetch('google.com')
- initial['Load Time (ms)'].to_i.should > repeated['Load Time (ms)'].to_i
- end
-end
Please sign in to comment.
Something went wrong with that request. Please try again.