bundler_timer 1.0.3 → 1.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/.gitignore +2 -1
- data/Gemfile +2 -0
- data/Gemfile.lock +16 -0
- data/Rakefile +2 -24
- data/bin/b +20 -1
- data/bundler_timer.gemspec +13 -10
- data/lib/bundler_timer/cli.rb +19 -0
- data/lib/bundler_timer/statistics.rb +66 -0
- data/lib/bundler_timer/version.rb +3 -0
- data/lib/bundler_timer.rb +0 -48
- metadata +31 -11
data/.gitignore
CHANGED
@@ -1 +1,2 @@
|
|
1
|
-
*.gem
|
1
|
+
*.gem
|
2
|
+
*.swp
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
data/Rakefile
CHANGED
@@ -1,24 +1,2 @@
|
|
1
|
-
|
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
|
1
|
+
require 'bundler'
|
2
|
+
Bundler::GemHelper.install_tasks
|
data/bin/b
CHANGED
@@ -1,3 +1,22 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
-
require '
|
3
|
+
require 'bundler'
|
4
|
+
$:.each do |path|
|
5
|
+
if path =~ %r'/bundler-0.(\d+)' && $1.to_i < 9
|
6
|
+
abort "Please remove older versions of bundler. This can be done by running `gem cleanup bundler`."
|
7
|
+
end
|
8
|
+
end
|
9
|
+
require 'bundler_timer/cli'
|
10
|
+
|
11
|
+
begin
|
12
|
+
BundlerTimer::CLI.start
|
13
|
+
BundlerTimer::Statistics.instance.ugly_output
|
14
|
+
rescue Bundler::BundlerError => e
|
15
|
+
Bundler.ui.error e.message
|
16
|
+
Bundler.ui.debug e.backtrace.join("\n")
|
17
|
+
exit e.status_code
|
18
|
+
rescue Interrupt => e
|
19
|
+
Bundler.ui.error "\nQuitting..."
|
20
|
+
Bundler.ui.debug e.backtrace.join("\n")
|
21
|
+
exit 1
|
22
|
+
end
|
data/bundler_timer.gemspec
CHANGED
@@ -1,20 +1,23 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
s.date = '2011-04-07'
|
3
|
+
$:.push File.expand_path("../lib", __FILE__)
|
4
|
+
require 'bundler_timer/version'
|
6
5
|
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.version = BundlerTimer::VERSION
|
7
8
|
s.name = 'bundler_timer'
|
8
|
-
s.authors = %w[bassnode raggi]
|
9
|
+
s.authors = %w[bassnode raggi eptics]
|
9
10
|
s.email = 'bassnode@gmail.com'
|
10
11
|
s.summary = 'times bundler'
|
11
12
|
s.description = 'Keeps a log of your time waiting on bundler'
|
12
|
-
s.homepage = '
|
13
|
-
s.rubyforge_project = '
|
13
|
+
s.homepage = 'https://github.com/bassnode/bundler_timer'
|
14
|
+
s.rubyforge_project = 'bundler_timer'
|
14
15
|
|
15
|
-
s.
|
16
|
-
s.
|
17
|
-
s.
|
16
|
+
s.files = `git ls-files`.split("\n")
|
17
|
+
s.test_files = `git ls-files -- {test}/*`.split("\n")
|
18
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
19
|
+
s.require_paths = ["lib"]
|
18
20
|
|
19
|
-
s.add_dependency "sequel", '
|
21
|
+
s.add_dependency "sequel", '~> 3'
|
22
|
+
s.add_dependency "bundler", '~> 1'
|
20
23
|
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'bundler/cli'
|
2
|
+
require 'bundler_timer/statistics'
|
3
|
+
|
4
|
+
module BundlerTimer
|
5
|
+
class CLI < Bundler::CLI
|
6
|
+
def initialize(*)
|
7
|
+
@statistics = Statistics.instance
|
8
|
+
super
|
9
|
+
end
|
10
|
+
|
11
|
+
no_tasks do
|
12
|
+
def invoke_task(task, *args)
|
13
|
+
@statistics.record(task.name) do
|
14
|
+
super
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,66 @@
|
|
1
|
+
require 'benchmark'
|
2
|
+
require 'sequel'
|
3
|
+
require 'fileutils'
|
4
|
+
require 'date'
|
5
|
+
require 'singleton'
|
6
|
+
|
7
|
+
module BundlerTimer
|
8
|
+
class Statistics
|
9
|
+
include Singleton
|
10
|
+
|
11
|
+
def initialize
|
12
|
+
create_storage_dir
|
13
|
+
create_database
|
14
|
+
super
|
15
|
+
end
|
16
|
+
|
17
|
+
def record(task, &block)
|
18
|
+
time = Benchmark.realtime do
|
19
|
+
yield
|
20
|
+
end
|
21
|
+
@db[:executions].insert :command => task, :runtime => time, :run_at => Date.today
|
22
|
+
end
|
23
|
+
|
24
|
+
def total
|
25
|
+
@db[:executions].sum(:runtime)
|
26
|
+
end
|
27
|
+
|
28
|
+
def total_for_day(day = Date.today)
|
29
|
+
@db[:executions].where(:run_at => day).sum(:runtime)
|
30
|
+
end
|
31
|
+
|
32
|
+
def ugly_output
|
33
|
+
puts "\n\tCongratulations, you've spent #{smart_time(total_for_day)} today staring at your screen (#{smart_time(total)} overall)."
|
34
|
+
end
|
35
|
+
|
36
|
+
protected
|
37
|
+
def create_storage_dir
|
38
|
+
@storage_dir = File.join(ENV['HOME'], ".bundler_timer")
|
39
|
+
FileUtils.mkdir(@storage_dir) unless File.exists?(@storage_dir)
|
40
|
+
end
|
41
|
+
|
42
|
+
def create_database
|
43
|
+
@db = Sequel.sqlite(File.join(@storage_dir, 'bundler_timer.db'))
|
44
|
+
@db.create_table? :executions do
|
45
|
+
primary_key :id
|
46
|
+
String :command, :null => false
|
47
|
+
Float :runtime, :null => false
|
48
|
+
Date :run_at, :null => false
|
49
|
+
|
50
|
+
index :run_at
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
def smart_time(seconds)
|
55
|
+
if (minutes = seconds/60.0) >= 1
|
56
|
+
if (hours = minutes/60.0) >= 1
|
57
|
+
('%3.1f' % hours) + ' hours'
|
58
|
+
else
|
59
|
+
('%2.1f' % minutes) + ' minutes'
|
60
|
+
end
|
61
|
+
else
|
62
|
+
"#{seconds.round} seconds"
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
data/lib/bundler_timer.rb
CHANGED
@@ -1,48 +0,0 @@
|
|
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.empty? ? 'install' : ARGV.join(' ')
|
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
CHANGED
@@ -1,23 +1,24 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bundler_timer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 19
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 1
|
8
|
+
- 1
|
8
9
|
- 0
|
9
|
-
|
10
|
-
version: 1.0.3
|
10
|
+
version: 1.1.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- bassnode
|
14
14
|
- raggi
|
15
|
+
- eptics
|
15
16
|
autorequire:
|
16
17
|
bindir: bin
|
17
18
|
cert_chain: []
|
18
19
|
|
19
|
-
date: 2011-04-
|
20
|
-
default_executable:
|
20
|
+
date: 2011-04-11 00:00:00 -07:00
|
21
|
+
default_executable:
|
21
22
|
dependencies:
|
22
23
|
- !ruby/object:Gem::Dependency
|
23
24
|
name: sequel
|
@@ -25,14 +26,28 @@ dependencies:
|
|
25
26
|
requirement: &id001 !ruby/object:Gem::Requirement
|
26
27
|
none: false
|
27
28
|
requirements:
|
28
|
-
- -
|
29
|
+
- - ~>
|
29
30
|
- !ruby/object:Gem::Version
|
30
|
-
hash:
|
31
|
+
hash: 5
|
31
32
|
segments:
|
32
|
-
-
|
33
|
-
version: "
|
33
|
+
- 3
|
34
|
+
version: "3"
|
34
35
|
type: :runtime
|
35
36
|
version_requirements: *id001
|
37
|
+
- !ruby/object:Gem::Dependency
|
38
|
+
name: bundler
|
39
|
+
prerelease: false
|
40
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ~>
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
hash: 1
|
46
|
+
segments:
|
47
|
+
- 1
|
48
|
+
version: "1"
|
49
|
+
type: :runtime
|
50
|
+
version_requirements: *id002
|
36
51
|
description: Keeps a log of your time waiting on bundler
|
37
52
|
email: bassnode@gmail.com
|
38
53
|
executables:
|
@@ -43,13 +58,18 @@ extra_rdoc_files: []
|
|
43
58
|
|
44
59
|
files:
|
45
60
|
- .gitignore
|
61
|
+
- Gemfile
|
62
|
+
- Gemfile.lock
|
46
63
|
- README.md
|
47
64
|
- Rakefile
|
48
65
|
- bin/b
|
49
66
|
- bundler_timer.gemspec
|
50
67
|
- lib/bundler_timer.rb
|
68
|
+
- lib/bundler_timer/cli.rb
|
69
|
+
- lib/bundler_timer/statistics.rb
|
70
|
+
- lib/bundler_timer/version.rb
|
51
71
|
has_rdoc: true
|
52
|
-
homepage:
|
72
|
+
homepage: https://github.com/bassnode/bundler_timer
|
53
73
|
licenses: []
|
54
74
|
|
55
75
|
post_install_message:
|
@@ -77,7 +97,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
77
97
|
version: "0"
|
78
98
|
requirements: []
|
79
99
|
|
80
|
-
rubyforge_project:
|
100
|
+
rubyforge_project: bundler_timer
|
81
101
|
rubygems_version: 1.3.7
|
82
102
|
signing_key:
|
83
103
|
specification_version: 3
|