clock_window 0.0.5 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +32 -4
- data/clock_window.gemspec +2 -1
- data/exe/clock_window +42 -2
- data/lib/clock_window/version.rb +1 -1
- metadata +16 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8f8d46cc95dbc15c89b1f5d1264c0075f31e3328
|
4
|
+
data.tar.gz: 5dfdbcd5c40742cbf87a4a706e6c30dc8990ad5c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b25057158d6bcfc9f1eeebff62792f3fe382a3e2fb607312ca35b51d3ccf6c0cbfd4c618bb1eddd94a119bf066c0fbfbe661206faa6c81457abd44abc6ad2b35
|
7
|
+
data.tar.gz: 80a431c88f389f5c0427d69f9d4a430a2e55fb4c1e68e2d351d3c5018f4950aeb73204ae38624f9fdc2323551f598f657b69b68112f893ce66ba51120dbe46e4
|
data/README.md
CHANGED
@@ -1,12 +1,18 @@
|
|
1
1
|
[![Build Status](https://travis-ci.org/danielpclark/clock_window.svg?branch=master)](https://travis-ci.org/danielpclark/clock_window)
|
2
|
+
[![Gem Version](https://badge.fury.io/rb/clock_window.svg)](https://badge.fury.io/rb/clock_window)
|
2
3
|
[![Code Triagers Badge](http://www.codetriage.com/danielpclark/clock_window/badges/users.svg)](http://www.codetriage.com/danielpclark/clock_window)
|
3
4
|
|
4
5
|
# Clock Window
|
5
|
-
|
6
|
+
[![OS Support](https://github.com/danielpclark/clock_window/blob/master/assets/mac-lin.png)]()
|
6
7
|
|
7
|
-
|
8
|
+
**Mac** & **Linux** compatible.
|
9
|
+
|
10
|
+
A minimalist script to keep track of how long each window is active.
|
11
|
+
Measured in quarter minutes. Hash builds until you kill the script with CTRL-C
|
12
|
+
at which point it writes out the log file. This script <del>adds no extra CPU load</del>
|
13
|
+
will not raise the CPUs temperature indicating minimal CPU usage.
|
8
14
|
|
9
|
-
|
15
|
+
The output will look quite nice in any text editor aligned by the colon separator.
|
10
16
|
|
11
17
|
Output looks like:
|
12
18
|
```
|
@@ -25,7 +31,29 @@ Output looks like:
|
|
25
31
|
gem install clock_window
|
26
32
|
```
|
27
33
|
|
28
|
-
|
34
|
+
# Usage
|
35
|
+
|
36
|
+
The `clock_window` script now accepts command line parameters.
|
37
|
+
|
38
|
+
```
|
39
|
+
usage: clock_window [options]
|
40
|
+
|
41
|
+
-c, --clean Use all known name filters
|
42
|
+
-o, --output File/directory output in strftime
|
43
|
+
-e, --eager Use strftime of time at start of script
|
44
|
+
|
45
|
+
--version Print the version
|
46
|
+
-h, --help This help menu
|
47
|
+
```
|
48
|
+
|
49
|
+
And to save the file in a `year-month/day_of_year.json` format you can execute the script with.
|
50
|
+
|
51
|
+
```
|
52
|
+
clock_window -ceo "%Y-%m/%j.json"
|
53
|
+
```
|
54
|
+
|
55
|
+
For more customizable date formats see the [documentation for strftime](http://apidock.com/ruby/DateTime/strftime).
|
56
|
+
Default file output name is `timelog.json`.
|
29
57
|
|
30
58
|
# Contributing
|
31
59
|
|
data/clock_window.gemspec
CHANGED
@@ -13,12 +13,13 @@ Gem::Specification.new do |spec|
|
|
13
13
|
spec.description = %q{Clock active window. Time tracker by window name.}
|
14
14
|
spec.homepage = "https://github.com/danielpclark/clock_window"
|
15
15
|
spec.license = "MIT"
|
16
|
-
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
16
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(assets|test|spec|features)/}) }
|
17
17
|
spec.bindir = "exe"
|
18
18
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
19
19
|
spec.require_paths = ["lib"]
|
20
20
|
|
21
21
|
spec.add_dependency "neatjson", "~> 0.8"
|
22
|
+
spec.add_dependency "slop", "~> 4.3"
|
22
23
|
spec.add_development_dependency "bundler", "~> 1.12"
|
23
24
|
spec.add_development_dependency "rake", "~> 11.1"
|
24
25
|
spec.add_development_dependency "minitest", "~> 5.8"
|
data/exe/clock_window
CHANGED
@@ -1,17 +1,57 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
+
require 'fileutils'
|
4
|
+
require 'slop'
|
3
5
|
require 'neatjson'
|
4
6
|
require 'clock_window'
|
7
|
+
|
8
|
+
opts = Slop.parse do |o|
|
9
|
+
o.banner = <<-BANNER
|
10
|
+
Clock Window - "Clock your desktop activity!"
|
11
|
+
Copyright (c) 2016 Daniel P. Clark via the MIT License
|
12
|
+
Version: #{ClockWindow::VERSION}
|
13
|
+
|
14
|
+
usage: clock_window [options]
|
15
|
+
BANNER
|
16
|
+
o.bool "-c", "--clean", "Use all known name filters"
|
17
|
+
o.string "-o", "--output", "File/directory output in strftime"
|
18
|
+
o.bool "-e", "--eager", "Use strftime of time at start of script\n"
|
19
|
+
|
20
|
+
o.on "--version", "Print the version" do
|
21
|
+
puts ClockWindow::VERSION
|
22
|
+
exit
|
23
|
+
end
|
24
|
+
o.bool "-h", "--help", "This help menu\n\n"
|
25
|
+
end
|
26
|
+
|
27
|
+
if opts[:help]
|
28
|
+
puts opts
|
29
|
+
exit
|
30
|
+
else
|
31
|
+
puts opts.to_s.partition("\n\n").first
|
32
|
+
puts "\nPress CTRL-C to exit the script."
|
33
|
+
puts "Starting active window tracking!"
|
34
|
+
end
|
35
|
+
|
36
|
+
dir_name, _, file_name = opts[:output].to_s.rpartition(File::SEPARATOR)
|
37
|
+
file_name = "timelog.json" if file_name.empty?
|
38
|
+
|
39
|
+
@time = Time.now if opts[:eager]
|
5
40
|
@hash = {}
|
6
41
|
begin
|
7
42
|
loop do
|
8
|
-
|
43
|
+
filter_opts = opts.clean? ? {filter_opts: {no_notify: true}} : {}
|
44
|
+
x = ClockWindow::ClockIt.new(**filter_opts).active_window
|
9
45
|
@hash[x] = @hash[x].to_f + 0.25
|
10
46
|
sleep 15
|
11
47
|
end
|
12
48
|
ensure
|
13
49
|
@hash = {"*---------- WINDOW NAME ----------*" => "minutes"}.merge(@hash)
|
14
|
-
|
50
|
+
@time ||= Time.now
|
51
|
+
dir = @time.strftime(dir_name)
|
52
|
+
FileUtils.mkdir_p(dir) unless dir.empty?
|
53
|
+
file = @time.strftime(file_name)
|
54
|
+
File.open("#{dir}#{File::SEPARATOR unless dir.empty?}#{file}","w") do |f|
|
15
55
|
f.write(JSON.neat_generate(@hash,aligned:true,around_colon:1))
|
16
56
|
end
|
17
57
|
end
|
data/lib/clock_window/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: clock_window
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Daniel P. Clark
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-05-
|
11
|
+
date: 2016-05-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: neatjson
|
@@ -24,6 +24,20 @@ dependencies:
|
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0.8'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: slop
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '4.3'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '4.3'
|
27
41
|
- !ruby/object:Gem::Dependency
|
28
42
|
name: bundler
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|