time-sheet 0.10.0 → 0.12.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/time_sheet/time/cmd.rb +2 -1
- data/lib/time_sheet/time/entry.rb +22 -2
- data/lib/time_sheet/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5ca95455a7df9dfb1262804ff2c325b25cea1336b75320b86881ebb9f96a9f8d
|
4
|
+
data.tar.gz: a85d3aa69e2d335b37e54bf210fe28a6f83ae1f78aa178ebe08aa4822542ce8d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e7eb8b409573f45e1098b262b207bf09b6557fb8372ee31a75514ee77320526fb1f46ef9e8e55927f218bcf7142697e768d3f15e345466eded9163beaa92fb67
|
7
|
+
data.tar.gz: 7b78b9d314aa531c452d677fd725b07ea7471c62a3b1999af5cfd577f8a5644416d5173000f380dd7620fd9660d9bb2e300ca6c12f8e034d49def97c2e2c69c6
|
data/lib/time_sheet/time/cmd.rb
CHANGED
@@ -117,6 +117,7 @@ class TimeSheet::Time::Cmd
|
|
117
117
|
o.string '-t', '--to', 'ignore entries more recent than the date given'
|
118
118
|
o.string '-p', '--project', 'take only entries of this project into account'
|
119
119
|
o.string '-a', '--activity', 'take only entries of this activity into account'
|
120
|
+
o.string '--tags', 'filter by tag (comma separated, not case sensitive, prefix tag with ! to exclude)'
|
120
121
|
o.string '-d', '--description', 'consider only entries matching this description'
|
121
122
|
o.string '-e', '--employee', 'consider only entries for this employee'
|
122
123
|
o.float '-r', '--rate', 'use an alternative hourly rate (default: 80.0)', default: 80.00
|
@@ -155,7 +156,7 @@ class TimeSheet::Time::Cmd
|
|
155
156
|
end
|
156
157
|
|
157
158
|
if options[:package]
|
158
|
-
package = data.last.map{|entry| entry[1]}.sum
|
159
|
+
package = (data.last.nil? ? 0 : data.last.map{|entry| entry[1]}.sum)
|
159
160
|
total = options[:package] * 60
|
160
161
|
percent = (package / total.to_f * 100)
|
161
162
|
|
@@ -78,7 +78,7 @@ class TimeSheet::Time::Entry
|
|
78
78
|
end
|
79
79
|
|
80
80
|
def tags
|
81
|
-
(@data['tags']
|
81
|
+
self.class.parse_tags(@data['tags'])
|
82
82
|
end
|
83
83
|
|
84
84
|
def working_day?
|
@@ -90,7 +90,9 @@ class TimeSheet::Time::Entry
|
|
90
90
|
from = from.to_time if from.is_a?(Date)
|
91
91
|
to = (filters[:to] ? filters[:to] : nil)
|
92
92
|
to = (to + 1).to_time if to.is_a?(Date)
|
93
|
+
tags = self.class.parse_tags(filters[:tags])
|
93
94
|
|
95
|
+
has_tags?(tags) &&
|
94
96
|
self.class.attrib_matches_any?(employee, filters[:employee]) &&
|
95
97
|
self.class.attrib_matches_any?(description, filters[:description]) &&
|
96
98
|
self.class.attrib_matches_any?(project, filters[:project]) &&
|
@@ -99,6 +101,19 @@ class TimeSheet::Time::Entry
|
|
99
101
|
(!to || to >= self.end)
|
100
102
|
end
|
101
103
|
|
104
|
+
def has_tags?(tags)
|
105
|
+
return true if tags.empty?
|
106
|
+
|
107
|
+
tags.all? do |tag|
|
108
|
+
if tag.match?(/^\!/)
|
109
|
+
t = tag.gsub(/\!/, '')
|
110
|
+
!self.tags.include?(t)
|
111
|
+
else
|
112
|
+
self.tags.include?(tag)
|
113
|
+
end
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
102
117
|
def valid?
|
103
118
|
valid!
|
104
119
|
true
|
@@ -157,7 +172,8 @@ class TimeSheet::Time::Entry
|
|
157
172
|
'duration' => duration,
|
158
173
|
'project' => project,
|
159
174
|
'activity' => activity,
|
160
|
-
'description' => description
|
175
|
+
'description' => description,
|
176
|
+
'tags' => tags
|
161
177
|
}
|
162
178
|
end
|
163
179
|
|
@@ -173,4 +189,8 @@ class TimeSheet::Time::Entry
|
|
173
189
|
end
|
174
190
|
end
|
175
191
|
|
192
|
+
def self.parse_tags(string)
|
193
|
+
(string || '').to_s.downcase.split(/\s*,\s*/).map{|t| t.strip}
|
194
|
+
end
|
195
|
+
|
176
196
|
end
|
data/lib/time_sheet/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: time-sheet
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.12.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Moritz Schepp
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-09-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: spreadsheet
|