logtime 0.2.0 → 0.2.1
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.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/Gemfile +2 -2
- data/Gemfile.lock +10 -10
- data/UPDATES.md +11 -1
- data/VERSION +1 -1
- data/config/schema.rb +20 -20
- data/lib/commands/add.rb +12 -4
- data/lib/commands/list.rb +12 -9
- data/lib/commands/rm.rb +13 -4
- data/lib/commands/start.rb +12 -5
- data/lib/commands/stop.rb +18 -10
- data/lib/helpers/output.rb +17 -0
- data/lib/subcommands/series.rb +19 -11
- data/lib/subcommands/tags.rb +26 -9
- data/logtime.gemspec +1 -1
- data/makefile +29 -0
- metadata +4 -2
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3129507c9ca507033f03a09c38d1e6dd7ac2b3d5
|
4
|
+
data.tar.gz: 4a81907eaf2942548b182ab3cfcb9470c9c674e0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 70e85f85ae1c29229182a2526e3684e87b2d93d90bd89dd72f0d38202190241020979fea2f81f58e30948e44c795322c9f825ed45a2e66ac469e5510d7e02746
|
7
|
+
data.tar.gz: 026cdef8e50e28daf4bdefa3348da8b18e5e03097f9af141acefeee921838f298f89c668940f44b129a02c72072d74fe97f797937ac19d1944340a391deb2d11
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
GEM
|
2
2
|
remote: http://rubygems.org/
|
3
3
|
specs:
|
4
|
-
activemodel (4.2.
|
5
|
-
activesupport (= 4.2.
|
4
|
+
activemodel (4.2.2)
|
5
|
+
activesupport (= 4.2.2)
|
6
6
|
builder (~> 3.1)
|
7
|
-
activerecord (4.2.
|
8
|
-
activemodel (= 4.2.
|
9
|
-
activesupport (= 4.2.
|
7
|
+
activerecord (4.2.2)
|
8
|
+
activemodel (= 4.2.2)
|
9
|
+
activesupport (= 4.2.2)
|
10
10
|
arel (~> 6.0)
|
11
|
-
activesupport (4.2.
|
11
|
+
activesupport (4.2.2)
|
12
12
|
i18n (~> 0.7)
|
13
13
|
json (~> 1.7, >= 1.7.7)
|
14
14
|
minitest (~> 5.1)
|
@@ -32,7 +32,7 @@ PLATFORMS
|
|
32
32
|
ruby
|
33
33
|
|
34
34
|
DEPENDENCIES
|
35
|
-
activerecord
|
36
|
-
chronic_duration
|
37
|
-
sqlite3
|
38
|
-
thor
|
35
|
+
activerecord (~> 4.2.2)
|
36
|
+
chronic_duration (= 0.10.6)
|
37
|
+
sqlite3 (~> 1.3.9)
|
38
|
+
thor (~> 0.19.1)
|
data/UPDATES.md
CHANGED
@@ -1,9 +1,19 @@
|
|
1
1
|
Releases
|
2
2
|
=======
|
3
3
|
|
4
|
+
## 0.2.1 (23rd June 2015)
|
5
|
+
|
6
|
+
* Fixed deprecation warning on schema create
|
7
|
+
* Normalised output space before and after output
|
8
|
+
* Added error if no tags exist on `tags ls`
|
9
|
+
* Added error if unable to destroy a record
|
10
|
+
* Updated activerecord to 4.2.2
|
11
|
+
* Added makefile with gem build and temporary test script
|
12
|
+
|
13
|
+
|
4
14
|
## 0.2.0 (15th June 2015)
|
5
15
|
|
6
|
-
* Renamed --active option to --all for `
|
16
|
+
* Renamed --active option to --all for `ls`
|
7
17
|
* Added ability to search series by log name, e,g; `series ls logname`
|
8
18
|
* Fixed debug output in `series ls`
|
9
19
|
* Fixed log name not displaying in `series ls`
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.2.
|
1
|
+
0.2.1
|
data/config/schema.rb
CHANGED
@@ -1,41 +1,41 @@
|
|
1
1
|
ActiveRecord::Schema.define do
|
2
|
-
|
3
2
|
#
|
4
3
|
# Logs
|
5
4
|
#
|
6
|
-
create_table :logs do |table|
|
7
|
-
table.column :name, :string
|
8
|
-
table.column :active, :string, default: false
|
9
|
-
table.column :estimation, :decimal
|
10
|
-
table.timestamps
|
11
|
-
end unless ActiveRecord::Base.connection.table_exists? 'logs'
|
12
5
|
|
6
|
+
create_table :logs do |t|
|
7
|
+
t.string :name
|
8
|
+
t.string :active, default: false
|
9
|
+
t.decimal :estimation
|
10
|
+
t.timestamps null: false
|
11
|
+
end unless ActiveRecord::Base.connection.table_exists? 'logs'
|
13
12
|
|
14
13
|
#
|
15
14
|
# Logs Tags
|
16
15
|
#
|
17
|
-
create_table :logs_tags do |table|
|
18
|
-
table.column :log_id, :integer
|
19
|
-
table.column :tag_id, :integer
|
20
|
-
end unless ActiveRecord::Base.connection.table_exists? 'logs_tags'
|
21
16
|
|
17
|
+
create_table :logs_tags do |t|
|
18
|
+
t.integer :log_id
|
19
|
+
t.integer :tag_id
|
20
|
+
end unless ActiveRecord::Base.connection.table_exists? 'logs_tags'
|
22
21
|
|
23
22
|
#
|
24
23
|
# Tags
|
25
24
|
#
|
26
|
-
|
27
|
-
|
28
|
-
|
25
|
+
|
26
|
+
create_table :tags do |t|
|
27
|
+
t.string :tag
|
28
|
+
t.timestamps null: false
|
29
29
|
end unless ActiveRecord::Base.connection.table_exists? 'tags'
|
30
30
|
|
31
31
|
#
|
32
32
|
# Series
|
33
33
|
#
|
34
|
-
create_table :series do |table|
|
35
|
-
table.column :log_id, :integer
|
36
|
-
table.column :start, :timestamp, null: true
|
37
|
-
table.column :end, :timestamp, null: true
|
38
|
-
table.timestamps
|
39
|
-
end unless ActiveRecord::Base.connection.table_exists? 'series'
|
40
34
|
|
35
|
+
create_table :series do |t|
|
36
|
+
t.integer :log_id
|
37
|
+
t.timestamp :start, null: true
|
38
|
+
t.timestamp :end, null: true
|
39
|
+
t.timestamps null: false
|
40
|
+
end unless ActiveRecord::Base.connection.table_exists? 'series'
|
41
41
|
end unless File.exists?(File.join($logtime_path, 'database.db'))
|
data/lib/commands/add.rb
CHANGED
@@ -13,7 +13,9 @@ module Commands
|
|
13
13
|
if options[:estimate]
|
14
14
|
estimation = ChronicDuration.parse(options[:estimate]) if !estimation
|
15
15
|
if !estimation
|
16
|
-
|
16
|
+
output do
|
17
|
+
say "could not parse estimation time: " + options[:estimate], :red
|
18
|
+
end
|
17
19
|
exit
|
18
20
|
end
|
19
21
|
log.estimation = estimation
|
@@ -22,16 +24,22 @@ module Commands
|
|
22
24
|
# save log
|
23
25
|
if !log.save
|
24
26
|
log.errors.full_messages.each do |error|
|
25
|
-
|
27
|
+
output do
|
28
|
+
say error, :red
|
29
|
+
end
|
26
30
|
end
|
27
31
|
exit
|
28
32
|
end
|
29
33
|
|
30
34
|
# start option
|
31
35
|
if options[:start] and log.start!
|
32
|
-
|
36
|
+
output do
|
37
|
+
say name.to_s + " added and started", :green
|
38
|
+
end
|
33
39
|
else
|
34
|
-
|
40
|
+
output do
|
41
|
+
say name.to_s + " added", :green
|
42
|
+
end
|
35
43
|
end
|
36
44
|
end
|
37
45
|
end
|
data/lib/commands/list.rb
CHANGED
@@ -60,17 +60,20 @@ module Commands
|
|
60
60
|
end
|
61
61
|
|
62
62
|
if logs.count == 0
|
63
|
-
|
64
|
-
|
65
|
-
|
63
|
+
output do
|
64
|
+
say "No logs found", :red
|
65
|
+
end
|
66
66
|
exit
|
67
67
|
else
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
68
|
+
output do
|
69
|
+
print_table table
|
70
|
+
|
71
|
+
output_spacer
|
72
|
+
|
73
|
+
say [logs.count.to_s, "logs out of", Log.count.to_s].join(' '), :cyan
|
74
|
+
say [creep_stats.count, "estimations"].join(' '), :cyan
|
75
|
+
say [creep_stats.mean.round(2), "percent mean creep"].join(' '), :cyan
|
76
|
+
end
|
74
77
|
end
|
75
78
|
end
|
76
79
|
end
|
data/lib/commands/rm.rb
CHANGED
@@ -9,13 +9,17 @@ module Commands
|
|
9
9
|
|
10
10
|
# log exists?
|
11
11
|
if !log
|
12
|
-
|
12
|
+
output do
|
13
|
+
say "#{name} log not found", :red
|
14
|
+
end
|
13
15
|
exit
|
14
16
|
end
|
15
17
|
|
16
18
|
# make sure user confirmed
|
17
19
|
if !options[:confirm]
|
18
|
-
|
20
|
+
output do
|
21
|
+
say "You must --confirm before removing #{name} log", :red
|
22
|
+
end
|
19
23
|
exit
|
20
24
|
end
|
21
25
|
|
@@ -25,8 +29,13 @@ module Commands
|
|
25
29
|
end
|
26
30
|
|
27
31
|
# destroy log!
|
28
|
-
|
29
|
-
|
32
|
+
output do
|
33
|
+
if log.destroy
|
34
|
+
say "#{name} has been destroyed", :green
|
35
|
+
else
|
36
|
+
say "#{name} could not be destroyed", :red
|
37
|
+
end
|
38
|
+
end
|
30
39
|
end
|
31
40
|
end
|
32
41
|
end
|
data/lib/commands/start.rb
CHANGED
@@ -8,23 +8,30 @@ module Commands
|
|
8
8
|
|
9
9
|
# not found
|
10
10
|
if !log
|
11
|
-
|
11
|
+
output do
|
12
|
+
say "#{name} not found", :red
|
13
|
+
end
|
12
14
|
exit
|
13
15
|
end
|
14
16
|
|
15
17
|
# already active?
|
16
18
|
if log.active?
|
17
|
-
|
19
|
+
output do
|
20
|
+
say "#{name} already active", :red
|
21
|
+
end
|
18
22
|
exit
|
19
23
|
end
|
20
24
|
|
21
25
|
# begin new series, activate log
|
22
|
-
# Series.start!(log_id: log.id)
|
23
26
|
if log.start!
|
24
27
|
started_at = time_display(Time.now)
|
25
|
-
|
28
|
+
output do
|
29
|
+
say "#{name} started at #{started_at}", :green
|
30
|
+
end
|
26
31
|
else
|
27
|
-
|
32
|
+
output do
|
33
|
+
say "#{name} failed to start", :red
|
34
|
+
end
|
28
35
|
end
|
29
36
|
end
|
30
37
|
end
|
data/lib/commands/stop.rb
CHANGED
@@ -8,28 +8,36 @@ module Commands
|
|
8
8
|
|
9
9
|
# not found
|
10
10
|
if !log
|
11
|
-
|
11
|
+
output do
|
12
|
+
say name.to_s + " not found", :red
|
13
|
+
end
|
12
14
|
exit
|
13
15
|
end
|
14
16
|
|
15
17
|
# log not active
|
16
18
|
if log.inactive?
|
17
|
-
|
19
|
+
output do
|
20
|
+
say "#{name} not active", :red
|
21
|
+
end
|
18
22
|
exit
|
19
23
|
end
|
20
24
|
|
21
25
|
# stop log
|
22
26
|
if log.stop!
|
23
|
-
|
27
|
+
output do
|
28
|
+
say "#{name} stopped!", :green
|
24
29
|
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
30
|
+
time_total = log.total_time/3600
|
31
|
+
time_total = time_total.round(2)
|
32
|
+
time_last = Series.find(log.series.last.id).total_time/3600
|
33
|
+
time_last = time_last.round(2)
|
34
|
+
# time_start =
|
35
|
+
say "#{time_last} hours out of #{time_total}", :cyan
|
36
|
+
end
|
31
37
|
else
|
32
|
-
|
38
|
+
output do
|
39
|
+
say "#{name} failed to stop", :red
|
40
|
+
end
|
33
41
|
end
|
34
42
|
end
|
35
43
|
end
|
data/lib/subcommands/series.rb
CHANGED
@@ -12,9 +12,9 @@ module SubCommands
|
|
12
12
|
if log
|
13
13
|
series = ::Series.where(log: log).order(options[:order].to_sym => :desc)
|
14
14
|
else
|
15
|
-
|
16
|
-
|
17
|
-
|
15
|
+
output do
|
16
|
+
say "Could not find #{search}!", :red
|
17
|
+
end
|
18
18
|
exit
|
19
19
|
end
|
20
20
|
end
|
@@ -45,12 +45,14 @@ module SubCommands
|
|
45
45
|
(timer/3600).round(2).to_s] # row
|
46
46
|
end
|
47
47
|
|
48
|
-
|
49
|
-
|
50
|
-
puts ''
|
48
|
+
output do
|
49
|
+
print_table table
|
51
50
|
|
52
|
-
|
53
|
-
|
51
|
+
output_spacer
|
52
|
+
|
53
|
+
say [series.count.to_s, "series out of", ::Series.count].join(' '), :cyan
|
54
|
+
say [(series_stats.mean/3600).round(2), "hours avg"].join(' '), :cyan
|
55
|
+
end
|
54
56
|
end
|
55
57
|
|
56
58
|
desc "rm [ID]", "Destroy series"
|
@@ -59,12 +61,16 @@ module SubCommands
|
|
59
61
|
series = ::Series.find(id)
|
60
62
|
|
61
63
|
if !series
|
62
|
-
|
64
|
+
output do
|
65
|
+
say "Series ##{id} not found", :red
|
66
|
+
end
|
63
67
|
exit
|
64
68
|
end
|
65
69
|
|
66
70
|
if !options[:confirm]
|
67
|
-
|
71
|
+
output do
|
72
|
+
say "You must --confirm before removing series", :red
|
73
|
+
end
|
68
74
|
exit
|
69
75
|
end
|
70
76
|
|
@@ -73,7 +79,9 @@ module SubCommands
|
|
73
79
|
end
|
74
80
|
|
75
81
|
destroyed = series.destroy
|
76
|
-
|
82
|
+
output do
|
83
|
+
say "Series ##{id} has been destroyed", :green
|
84
|
+
end
|
77
85
|
end
|
78
86
|
end
|
79
87
|
end
|
data/lib/subcommands/tags.rb
CHANGED
@@ -5,21 +5,31 @@ module SubCommands
|
|
5
5
|
tag = ::Tag.new(tag: tag.strip)
|
6
6
|
|
7
7
|
if !tag.save
|
8
|
-
|
9
|
-
|
8
|
+
output do
|
9
|
+
tag.errors.full_messages.each do |error|
|
10
|
+
say error, :red
|
11
|
+
end
|
10
12
|
end
|
11
|
-
exit
|
13
|
+
exit
|
12
14
|
end
|
13
15
|
|
14
|
-
|
16
|
+
output do
|
17
|
+
say tag.tag + " added!", :green
|
18
|
+
end
|
15
19
|
end
|
16
20
|
|
17
21
|
desc "rm", "Destroy tag"
|
18
22
|
# option :prune, :type => :boolean, :alias => '-p', :default => false not implemented yet
|
19
23
|
def rm(tag)
|
20
24
|
tag = ::Tag.find_by!(tag: tag)
|
21
|
-
|
22
|
-
|
25
|
+
|
26
|
+
output do
|
27
|
+
if tag.destroy
|
28
|
+
say "Tag #{tag.tag} destroyed forever", :green
|
29
|
+
else
|
30
|
+
say "Tag #{tag.tag} could not be destroyed", :red
|
31
|
+
end
|
32
|
+
end
|
23
33
|
end
|
24
34
|
|
25
35
|
desc "ls", "List all tags"
|
@@ -27,13 +37,20 @@ module SubCommands
|
|
27
37
|
def ls
|
28
38
|
tags = ::Tag.order(options[:order].to_sym => :desc)
|
29
39
|
|
40
|
+
if tags.size == 0
|
41
|
+
output do
|
42
|
+
say "No tags found", :red
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
30
46
|
table = [['#', 'name', 'logs']] # header
|
31
47
|
tags.each do |tag|
|
32
48
|
table << [tag.id, tag.tag, tag.logs.count] # row
|
33
49
|
end
|
34
|
-
|
35
|
-
|
36
|
-
|
50
|
+
|
51
|
+
output do
|
52
|
+
print_table table
|
53
|
+
end
|
37
54
|
end
|
38
55
|
end
|
39
56
|
end
|
data/logtime.gemspec
CHANGED
data/makefile
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
build:
|
2
|
+
gem uninstall logtime && \
|
3
|
+
gem build logtime.gemspec && \
|
4
|
+
gem install logtime && \
|
5
|
+
which logtime && \
|
6
|
+
logtime version
|
7
|
+
|
8
|
+
test:
|
9
|
+
-rm -r ${HOME}/.logtime
|
10
|
+
logtime ls
|
11
|
+
logtime ls --all
|
12
|
+
logtime add test --estimate '5 hours 5 minutes and 5 seconds' --tag woah,wow && sleep 1
|
13
|
+
logtime add test && sleep 1
|
14
|
+
logtime stop test && sleep 1
|
15
|
+
logtime start test && sleep 1
|
16
|
+
logtime rm test && sleep 1
|
17
|
+
logtime add test2 && sleep 1
|
18
|
+
logtime stop test2 && sleep 1
|
19
|
+
logtime start test2 && sleep 1
|
20
|
+
logtime rm test2 --confirm && sleep 1
|
21
|
+
logtime tags ls
|
22
|
+
logtime tags rm wow
|
23
|
+
logtime tags ls
|
24
|
+
logtime series ls
|
25
|
+
lt ls
|
26
|
+
lt ls --all
|
27
|
+
|
28
|
+
backup:
|
29
|
+
-cp ${HOME}/.logtime/* ${HOME}/.logtime-backup
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: logtime
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Paperback
|
@@ -30,7 +30,7 @@ cert_chain:
|
|
30
30
|
2/luIWFCIDih/t3xy/BezkXJLXfRZF2Xd6/Ax9+zEVss6iUJ6kcxwaZ/J5r28EDI
|
31
31
|
KS3vMuAGgck=
|
32
32
|
-----END CERTIFICATE-----
|
33
|
-
date: 2015-06-
|
33
|
+
date: 2015-06-23 00:00:00.000000000 Z
|
34
34
|
dependencies:
|
35
35
|
- !ruby/object:Gem::Dependency
|
36
36
|
name: thor
|
@@ -118,6 +118,7 @@ files:
|
|
118
118
|
- lib/commands/start.rb
|
119
119
|
- lib/commands/stop.rb
|
120
120
|
- lib/commands/version.rb
|
121
|
+
- lib/helpers/output.rb
|
121
122
|
- lib/helpers/statistics.rb
|
122
123
|
- lib/helpers/time_difference.rb
|
123
124
|
- lib/helpers/time_display.rb
|
@@ -129,6 +130,7 @@ files:
|
|
129
130
|
- lib/subcommands/series.rb
|
130
131
|
- lib/subcommands/tags.rb
|
131
132
|
- logtime.gemspec
|
133
|
+
- makefile
|
132
134
|
homepage: https://github.com/Paperback/Logtime.git
|
133
135
|
licenses:
|
134
136
|
- MIT
|
metadata.gz.sig
CHANGED
Binary file
|