punched 1.3.2 → 1.3.3
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
- data/.github/workflows/specs.yml +23 -0
- data/.gitignore +1 -0
- data/README.md +21 -1
- data/lib/punchcard.rb +13 -7
- data/spec/punchcard_spec.rb +7 -7
- metadata +7 -7
- data/.travis.yml +0 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 332d10b07688d8df737329d65083cdee12e2f2a7fd2cc7d84a503fe8948688a0
|
4
|
+
data.tar.gz: 36a9ee38a2ad8187ba685982d01b0ae7422c077ec7107a1756706c9a675d15f7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c79f2403337f89533eaa77695786d33c41c6003d47e49f0eee1a62b66305eb9ee74fcf579a8efc44f1dfea2439de159aeef7f58c3d66a77567adce2daa7883db
|
7
|
+
data.tar.gz: 9337844f5458db7fc43ee924e31f71567a5f97b12ac30d4fa34bd422b90d7e3ecb444264c87ec738b4f61a873d964ce43f8dabee527f547dcf2b085176ce1f60
|
@@ -0,0 +1,23 @@
|
|
1
|
+
name: Specs
|
2
|
+
|
3
|
+
on: [push]
|
4
|
+
|
5
|
+
jobs:
|
6
|
+
build:
|
7
|
+
|
8
|
+
runs-on: ubuntu-latest
|
9
|
+
|
10
|
+
strategy:
|
11
|
+
matrix:
|
12
|
+
ruby-version: ['2.7', '3.0', '3.1', '3.2']
|
13
|
+
|
14
|
+
steps:
|
15
|
+
- uses: actions/checkout@v3
|
16
|
+
- name: Set up Ruby
|
17
|
+
uses: ruby/setup-ruby@ec02537da5712d66d4d50a0f33b7eb52773b5ed1
|
18
|
+
with:
|
19
|
+
ruby-version: ${{ matrix.ruby-version }}
|
20
|
+
- name: Install dependencies
|
21
|
+
run: bundle install
|
22
|
+
- name: Run tests
|
23
|
+
run: bundle exec rspec
|
data/.gitignore
CHANGED
data/README.md
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# Punchcard
|
2
2
|
## Minimal time tracking tool for cli
|
3
3
|
|
4
|
-
|
4
|
+

|
5
5
|
|
6
6
|
[](https://asciinema.org/a/222572)
|
7
7
|
|
@@ -150,6 +150,26 @@ By default, PunchCard will store the data in `~/.punchcard/`. Define your custom
|
|
150
150
|
export PUNCHCARD_DIR=~/Nextcloud/punchcard
|
151
151
|
```
|
152
152
|
|
153
|
+
### Bash auto complete
|
154
|
+
|
155
|
+
It is possible to add an auto completion for punchcard to your bash (tested on zsh so far). Add the following to your `.zshrc` / `.bashrc`:
|
156
|
+
|
157
|
+
```bash
|
158
|
+
PUNCHCARD_EXEC_PATH=$(which punched)
|
159
|
+
|
160
|
+
punchcard_projects () {
|
161
|
+
ls $PUNCHCARD_DIR
|
162
|
+
return 0
|
163
|
+
}
|
164
|
+
|
165
|
+
[ -f $PUNCHCARD_EXEC_PATH ] && complete -F punchcard_projects $PUNCHCARD_EXEC_PATH
|
166
|
+
```
|
167
|
+
|
168
|
+
Ensure that the `$PUNCHCARD_DIR` environment variable is also set (see `Store projects files in a custom folder and sync them between computers`).
|
169
|
+
|
170
|
+
Now you get a list of your existing projects everytime hitting a tab-key while using `punched`.
|
171
|
+
|
172
|
+
In `rvm` the return value of `which punched` will be empty; use rvm to get the absolute path and / or set the path manually.
|
153
173
|
|
154
174
|
### Tests
|
155
175
|
|
data/lib/punchcard.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
# (c) 2017-
|
3
|
+
# (c) 2017-2023 by Philipp Staender
|
4
4
|
|
5
5
|
require 'date'
|
6
6
|
require 'time'
|
@@ -13,7 +13,7 @@ class PunchCard
|
|
13
13
|
HOURLY_RATE_PATTERN = /^\s*(\d+)([^\d]+)*\s*/i.freeze
|
14
14
|
TIME_POINT_PATTERN = /^((\d+|.+?\s[\+\-]\d{4}?\s*)(\-)*(\d+|\s.+\d?)*)$/.freeze
|
15
15
|
META_KEY_PATTERN = /^([a-zA-Z0-9]+)\:\s*(.*)$/.freeze
|
16
|
-
VERSION = '1.3.
|
16
|
+
VERSION = '1.3.3'
|
17
17
|
|
18
18
|
attr_accessor :title
|
19
19
|
|
@@ -108,7 +108,7 @@ class PunchCard
|
|
108
108
|
find_or_make_file
|
109
109
|
durations = []
|
110
110
|
last_activity = nil
|
111
|
-
|
111
|
+
project_data_without_comments.map do |line|
|
112
112
|
points = line_to_time_points(line)
|
113
113
|
next unless points
|
114
114
|
|
@@ -179,7 +179,7 @@ class PunchCard
|
|
179
179
|
|
180
180
|
def total(start_at: nil, end_at: nil)
|
181
181
|
total = 0
|
182
|
-
|
182
|
+
project_data_without_comments.map do |line|
|
183
183
|
points = line_to_time_points(line)
|
184
184
|
next unless points
|
185
185
|
|
@@ -297,7 +297,7 @@ class PunchCard
|
|
297
297
|
end
|
298
298
|
|
299
299
|
def last_entry
|
300
|
-
|
300
|
+
project_data_without_comments.last
|
301
301
|
end
|
302
302
|
|
303
303
|
def timestamp
|
@@ -309,12 +309,14 @@ class PunchCard
|
|
309
309
|
end
|
310
310
|
|
311
311
|
def read_project_data
|
312
|
-
title =
|
312
|
+
title = File.basename(project_file)
|
313
313
|
timestamps = []
|
314
314
|
i = 0
|
315
315
|
File.open(project_file, 'r').each_line do |line|
|
316
316
|
line.strip!
|
317
|
-
if
|
317
|
+
next if line.start_with?('#')
|
318
|
+
|
319
|
+
if i.zero? && !line.match(TIME_POINT_PATTERN)
|
318
320
|
title = line
|
319
321
|
elsif line.match(META_KEY_PATTERN)
|
320
322
|
set line.match(META_KEY_PATTERN)[1], line.match(META_KEY_PATTERN)[2]
|
@@ -332,6 +334,10 @@ class PunchCard
|
|
332
334
|
File.open(project_file).each_line.map(&:strip)
|
333
335
|
end
|
334
336
|
|
337
|
+
def project_data_without_comments
|
338
|
+
project_data.filter { |l| !l.start_with?('#')}
|
339
|
+
end
|
340
|
+
|
335
341
|
def write_string_to_project_file!(string)
|
336
342
|
File.open(project_file, 'w') { |f| f.write(string) }
|
337
343
|
end
|
data/spec/punchcard_spec.rb
CHANGED
@@ -84,18 +84,18 @@ describe PunchCard do
|
|
84
84
|
expect(my_project_file.lines[-2]).to match(/^\d+/)
|
85
85
|
end
|
86
86
|
|
87
|
-
it '
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
expect(
|
87
|
+
it 'ignores lines starting with #' do
|
88
|
+
start_and_stop
|
89
|
+
File.write("#{example_settings_dir}/my_project", my_project_file + "\n# A comment line")
|
90
|
+
start_and_stop
|
91
|
+
expect(my_project_file).to match("\n# A comment line")
|
92
92
|
end
|
93
93
|
|
94
|
-
|
94
|
+
it 'should convert names to underscore with special characters' do
|
95
95
|
PunchCard.new 'Playing Motörhead'
|
96
96
|
expect(my_project_file('playing_mot_rhead').strip).to eq('Playing Motörhead')
|
97
97
|
project = PunchCard.new 'Playing*'
|
98
|
-
expect(project.project).to eq('
|
98
|
+
expect(project.project).to eq('playing_mot_rhead')
|
99
99
|
end
|
100
100
|
|
101
101
|
it 'should set hourlyRate' do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: punched
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.3.
|
4
|
+
version: 1.3.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Philipp Staender
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-09-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: markdown-tables
|
@@ -32,8 +32,8 @@ executables:
|
|
32
32
|
extensions: []
|
33
33
|
extra_rdoc_files: []
|
34
34
|
files:
|
35
|
+
- ".github/workflows/specs.yml"
|
35
36
|
- ".gitignore"
|
36
|
-
- ".travis.yml"
|
37
37
|
- Gemfile
|
38
38
|
- LICENSE
|
39
39
|
- README.md
|
@@ -45,7 +45,7 @@ homepage: https://github.com/pstaender/punchcard
|
|
45
45
|
licenses:
|
46
46
|
- GPL-3.0
|
47
47
|
metadata: {}
|
48
|
-
post_install_message:
|
48
|
+
post_install_message:
|
49
49
|
rdoc_options: []
|
50
50
|
require_paths:
|
51
51
|
- lib
|
@@ -60,8 +60,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: '0'
|
62
62
|
requirements: []
|
63
|
-
rubygems_version: 3.
|
64
|
-
signing_key:
|
63
|
+
rubygems_version: 3.2.3
|
64
|
+
signing_key:
|
65
65
|
specification_version: 4
|
66
66
|
summary: Punchcard Timetracker
|
67
67
|
test_files: []
|