timetrap 1.13.0 → 1.14.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/timetrap/formatters/text.rb +12 -10
- data/lib/timetrap/version.rb +1 -1
- data/spec/timetrap_spec.rb +29 -15
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c45020fe7d345f325987ddc82112fa3b85058e42
|
4
|
+
data.tar.gz: 642e9a4cc1c8add19048cf1b4206c8e4e27217f3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 621d9c3cf5574e3649be2aa3dea174d1501467a49f27dbc24ffc4d9b70011607756e974c3c6c240a0010f3b28bd1723d90f289545e6f60cda982a36174a9efe8
|
7
|
+
data.tar.gz: dd76fc97f00d9ce6b049530bd6686962f0ffbbb1103fee4cf433c23ca9ea868787d83619f23b4fcfe20f603f75c6810d6c9e6ef541da6da123c41b5679d3e6ef
|
@@ -74,20 +74,22 @@ module Timetrap
|
|
74
74
|
end
|
75
75
|
end
|
76
76
|
|
77
|
+
def word_wrap(text, line_width: LONGEST_NOTE_LENGTH, break_sequence: "\n")
|
78
|
+
# https://github.com/rails/rails/blob/df63abe6d31cdbe426ff6dda9bdd878acc602728/actionview/lib/action_view/helpers/text_helper.rb#L258-L262
|
79
|
+
|
80
|
+
text.split("\n").collect! do |line|
|
81
|
+
line.length > line_width ? line.gsub(/(.{1,#{line_width}})(\s+|$)/, "\\1#{break_sequence}").strip : line
|
82
|
+
end * break_sequence
|
83
|
+
end
|
84
|
+
|
77
85
|
def format_note(note)
|
78
86
|
return "" unless note
|
79
|
-
|
87
|
+
wrapped_note = word_wrap(note.gsub("\n"," "))
|
80
88
|
lines = []
|
81
|
-
|
82
|
-
|
83
|
-
while index = line.index(/\s/, LONGEST_NOTE_LENGTH) do
|
84
|
-
shorter_line = line.slice!(0..(index - 1))
|
85
|
-
lines << padded_line(shorter_line.strip, line_number)
|
86
|
-
line_number += 1
|
87
|
-
end
|
88
|
-
lines << padded_line(line.strip, line_number)
|
89
|
-
line_number += 1
|
89
|
+
wrapped_note.lines.each_with_index do |line, index|
|
90
|
+
lines << padded_line(line.strip, index)
|
90
91
|
end
|
92
|
+
|
91
93
|
lines.join("\n")
|
92
94
|
end
|
93
95
|
|
data/lib/timetrap/version.rb
CHANGED
data/spec/timetrap_spec.rb
CHANGED
@@ -454,7 +454,7 @@ The "format" command is deprecated in favor of "display". Sorry for the inconven
|
|
454
454
|
:note => 'entry 4', :start => '2008-10-05 18:00:00'
|
455
455
|
)
|
456
456
|
Timetrap::Entry.create( :sheet => 'LongNoteSheet',
|
457
|
-
:note =>
|
457
|
+
:note => test_long_text, :start => '2008-10-05 16:00:00', :end => '2008-10-05 18:00:00'
|
458
458
|
)
|
459
459
|
Timetrap::Entry.create( :sheet => 'SheetWithLineBreakNote',
|
460
460
|
:note => "first line\nand a second line ", :start => '2008-10-05 16:00:00', :end => '2008-10-05 18:00:00'
|
@@ -515,12 +515,13 @@ Id Day Start End Duration Notes
|
|
515
515
|
@desired_output_for_long_note_sheet = <<-OUTPUT
|
516
516
|
Timesheet: LongNoteSheet
|
517
517
|
Day Start End Duration Notes
|
518
|
-
Sun Oct 05, 2008 16:00:00 - 18:00:00 2:00:00
|
519
|
-
|
520
|
-
|
521
|
-
|
522
|
-
|
523
|
-
|
518
|
+
Sun Oct 05, 2008 16:00:00 - 18:00:00 2:00:00 chatting with bob about upcoming task, district
|
519
|
+
sharing of images, how the user settings currently
|
520
|
+
works etc. Discussing the fingerprinting / cache
|
521
|
+
busting issue with CKEDITOR, suggesting perhaps
|
522
|
+
looking into forking the rubygem and seeing if we
|
523
|
+
can work in our own changes, however hard that
|
524
|
+
might be.
|
524
525
|
2:00:00
|
525
526
|
------------------------------------------------------------------------------------------------------
|
526
527
|
Total 2:00:00
|
@@ -529,12 +530,13 @@ Timesheet: LongNoteSheet
|
|
529
530
|
@desired_output_for_long_note_sheet_with_ids = <<-OUTPUT
|
530
531
|
Timesheet: LongNoteSheet
|
531
532
|
Id Day Start End Duration Notes
|
532
|
-
60000 Sun Oct 05, 2008 16:00:00 - 18:00:00 2:00:00
|
533
|
-
|
534
|
-
|
535
|
-
|
536
|
-
|
537
|
-
|
533
|
+
60000 Sun Oct 05, 2008 16:00:00 - 18:00:00 2:00:00 chatting with bob about upcoming task, district
|
534
|
+
sharing of images, how the user settings currently
|
535
|
+
works etc. Discussing the fingerprinting / cache
|
536
|
+
busting issue with CKEDITOR, suggesting perhaps
|
537
|
+
looking into forking the rubygem and seeing if we
|
538
|
+
can work in our own changes, however hard that
|
539
|
+
might be.
|
538
540
|
2:00:00
|
539
541
|
------------------------------------------------------------------------------------------------------
|
540
542
|
Total 2:00:00
|
@@ -543,8 +545,7 @@ Id Day Start End Duration Notes
|
|
543
545
|
@desired_output_for_note_with_linebreak = <<-OUTPUT
|
544
546
|
Timesheet: SheetWithLineBreakNote
|
545
547
|
Day Start End Duration Notes
|
546
|
-
Sun Oct 05, 2008 16:00:00 - 18:00:00 2:00:00 first line
|
547
|
-
and a second line
|
548
|
+
Sun Oct 05, 2008 16:00:00 - 18:00:00 2:00:00 first line and a second line
|
548
549
|
2:00:00
|
549
550
|
--------------------------------------------------------------------------------
|
550
551
|
Total 2:00:00
|
@@ -1676,4 +1677,17 @@ END:VCALENDAR
|
|
1676
1677
|
t.stat.mode.should == timetrap.stat.mode
|
1677
1678
|
end
|
1678
1679
|
end
|
1680
|
+
|
1681
|
+
|
1682
|
+
private
|
1683
|
+
|
1684
|
+
def test_long_text
|
1685
|
+
<<TEXT
|
1686
|
+
chatting with bob about upcoming task, district sharing of images, how the
|
1687
|
+
user settings currently works etc. Discussing the fingerprinting / cache
|
1688
|
+
busting issue with CKEDITOR, suggesting perhaps looking into forking the
|
1689
|
+
rubygem and seeing if we can work in our own changes, however hard that might
|
1690
|
+
be.
|
1691
|
+
TEXT
|
1692
|
+
end
|
1679
1693
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: timetrap
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.14.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sam Goldstein
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-11-
|
11
|
+
date: 2016-11-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -204,7 +204,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
204
204
|
version: '0'
|
205
205
|
requirements: []
|
206
206
|
rubyforge_project:
|
207
|
-
rubygems_version: 2.
|
207
|
+
rubygems_version: 2.5.1
|
208
208
|
signing_key:
|
209
209
|
specification_version: 4
|
210
210
|
summary: Command line time tracker
|