bundler_timer 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +1 -0
- data/README.md +32 -0
- data/Rakefile +24 -0
- data/bin/b +3 -0
- data/bundler_timer.gemspec +17 -0
- data/lib/bundler_timer.rb +48 -0
- metadata +85 -0
data/.gitignore
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
*.gem
|
data/README.md
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
Bundler Timer
|
2
|
+
=============
|
3
|
+
Ever find yourself staring at your terminal wondering, "Sweet baby jesus, how many hours of my life do I spend waiting for Bundler?!".
|
4
|
+
Well know you can know just how much of your time has been given to our friend, Bundler.
|
5
|
+
|
6
|
+
Bundler Timer will log those precious seconds and report back a depressing little report each time you run Bundler.
|
7
|
+
|
8
|
+
Installation
|
9
|
+
------------
|
10
|
+
gem install bundler_timer
|
11
|
+
|
12
|
+
# By default, bundler_timer provides a binary named 'b' which you can use
|
13
|
+
# just like bundler. If you'd rather replace the bundler command, do
|
14
|
+
# something like:
|
15
|
+
echo "alias bundle='b'" >> ~/.bash_profile
|
16
|
+
|
17
|
+
# Now you can just run it as usual and keep track of your shortening life!
|
18
|
+
cd ~/code/sweet_project/
|
19
|
+
b install
|
20
|
+
Using activesupport (3.0.3)
|
21
|
+
Using builder (2.1.2)
|
22
|
+
...[snip]...
|
23
|
+
|
24
|
+
Congratulations, you've spent 12 minutes today staring at your screen (5.6 hours overall)
|
25
|
+
|
26
|
+
# To just see the damage:
|
27
|
+
b stats
|
28
|
+
|
29
|
+
|
30
|
+
To Do
|
31
|
+
------
|
32
|
+
* maybe add a daily breakdown in the stats
|
data/Rakefile
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
gemspec = eval(File.read(Dir["*.gemspec"].first))
|
2
|
+
|
3
|
+
|
4
|
+
desc "Validate the gemspec"
|
5
|
+
task :gemspec do
|
6
|
+
gemspec.validate
|
7
|
+
end
|
8
|
+
|
9
|
+
desc "Build gem locally"
|
10
|
+
task :build => :gemspec do
|
11
|
+
system "gem build #{gemspec.name}.gemspec"
|
12
|
+
FileUtils.mkdir_p "pkg"
|
13
|
+
FileUtils.mv "#{gemspec.name}-#{gemspec.version}.gem", "pkg"
|
14
|
+
end
|
15
|
+
|
16
|
+
desc "Install gem locally"
|
17
|
+
task :install => :build do
|
18
|
+
system "gem install pkg/#{gemspec.name}-#{gemspec.version}"
|
19
|
+
end
|
20
|
+
|
21
|
+
desc "Clean automatically generated files"
|
22
|
+
task :clean do
|
23
|
+
FileUtils.rm_rf "pkg"
|
24
|
+
end
|
data/bin/b
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
Gem::Specification.new do |s|
|
4
|
+
s.version = '1.0.1'
|
5
|
+
s.date = '2011-04-04'
|
6
|
+
|
7
|
+
s.name = 'bundler_timer'
|
8
|
+
s.authors = %w[bassnode]
|
9
|
+
s.summary = 'times bundler'
|
10
|
+
s.description = 'times bundler'
|
11
|
+
|
12
|
+
s.default_executable = 'b'
|
13
|
+
s.executables = %w[b]
|
14
|
+
s.files = `git ls-files`.split
|
15
|
+
|
16
|
+
s.add_dependency "sequel", '>= 0'
|
17
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'benchmark'
|
4
|
+
require 'sequel'
|
5
|
+
require 'fileutils'
|
6
|
+
require 'date'
|
7
|
+
|
8
|
+
def smart_time(seconds)
|
9
|
+
if (minutes = seconds/60.0) >= 1
|
10
|
+
if (hours = minutes/60.0) >= 1
|
11
|
+
('%3.1f' % hours) + ' hours'
|
12
|
+
else
|
13
|
+
('%2.1f' % minutes) + ' minutes'
|
14
|
+
end
|
15
|
+
else
|
16
|
+
"#{seconds.round} seconds"
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
storage_dir = File.join(ENV['HOME'], ".bundler_timer")
|
21
|
+
FileUtils.mkdir(storage_dir) unless File.exists?(storage_dir)
|
22
|
+
|
23
|
+
DB = Sequel.sqlite(File.join(storage_dir, 'bundler_timer.db'))
|
24
|
+
DB.create_table? :executions do
|
25
|
+
primary_key :id
|
26
|
+
String :command, :null => false
|
27
|
+
Float :runtime, :null => false
|
28
|
+
Date :run_at, :null => false
|
29
|
+
|
30
|
+
index :run_at
|
31
|
+
end
|
32
|
+
|
33
|
+
# runs bundle install by default
|
34
|
+
command = ARGV[0] || 'install'
|
35
|
+
|
36
|
+
unless command == 'stats'
|
37
|
+
|
38
|
+
time = Benchmark.realtime do
|
39
|
+
system "bundle #{command}"
|
40
|
+
end
|
41
|
+
|
42
|
+
DB[:executions].insert :command => command, :runtime => time, :run_at => Date.today
|
43
|
+
end
|
44
|
+
|
45
|
+
day_total = DB[:executions].where(:run_at => Date.today).sum(:runtime)
|
46
|
+
total = DB[:executions].sum(:runtime)
|
47
|
+
|
48
|
+
puts "\n\tCongratulations, you've spent #{smart_time(day_total)} today staring at your screen (#{smart_time(total)} overall)."
|
metadata
ADDED
@@ -0,0 +1,85 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: bundler_timer
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 21
|
5
|
+
prerelease: false
|
6
|
+
segments:
|
7
|
+
- 1
|
8
|
+
- 0
|
9
|
+
- 1
|
10
|
+
version: 1.0.1
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- bassnode
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2011-04-04 00:00:00 -07:00
|
19
|
+
default_executable: b
|
20
|
+
dependencies:
|
21
|
+
- !ruby/object:Gem::Dependency
|
22
|
+
name: sequel
|
23
|
+
prerelease: false
|
24
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ">="
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
hash: 3
|
30
|
+
segments:
|
31
|
+
- 0
|
32
|
+
version: "0"
|
33
|
+
type: :runtime
|
34
|
+
version_requirements: *id001
|
35
|
+
description: times bundler
|
36
|
+
email:
|
37
|
+
executables:
|
38
|
+
- b
|
39
|
+
extensions: []
|
40
|
+
|
41
|
+
extra_rdoc_files: []
|
42
|
+
|
43
|
+
files:
|
44
|
+
- .gitignore
|
45
|
+
- README.md
|
46
|
+
- Rakefile
|
47
|
+
- bin/b
|
48
|
+
- bundler_timer.gemspec
|
49
|
+
- lib/bundler_timer.rb
|
50
|
+
has_rdoc: true
|
51
|
+
homepage:
|
52
|
+
licenses: []
|
53
|
+
|
54
|
+
post_install_message:
|
55
|
+
rdoc_options: []
|
56
|
+
|
57
|
+
require_paths:
|
58
|
+
- lib
|
59
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
60
|
+
none: false
|
61
|
+
requirements:
|
62
|
+
- - ">="
|
63
|
+
- !ruby/object:Gem::Version
|
64
|
+
hash: 3
|
65
|
+
segments:
|
66
|
+
- 0
|
67
|
+
version: "0"
|
68
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
69
|
+
none: false
|
70
|
+
requirements:
|
71
|
+
- - ">="
|
72
|
+
- !ruby/object:Gem::Version
|
73
|
+
hash: 3
|
74
|
+
segments:
|
75
|
+
- 0
|
76
|
+
version: "0"
|
77
|
+
requirements: []
|
78
|
+
|
79
|
+
rubyforge_project:
|
80
|
+
rubygems_version: 1.3.7
|
81
|
+
signing_key:
|
82
|
+
specification_version: 3
|
83
|
+
summary: times bundler
|
84
|
+
test_files: []
|
85
|
+
|