wlog 1.2.1 → 1.2.2
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/README.md +14 -0
- data/bin/wlog +1 -2
- data/lib/wlog/commands/bootstrap_templates.rb +1 -1
- data/lib/wlog/commands/concat_description.rb +0 -1
- data/lib/wlog/commands/create_issue.rb +1 -1
- data/lib/wlog/commands/delete_attachment.rb +0 -1
- data/lib/wlog/commands/delete_issue.rb +1 -2
- data/lib/wlog/commands/fetch_git_commits.rb +5 -4
- data/lib/wlog/commands/fetch_git_commits_standard.rb +0 -1
- data/lib/wlog/commands/innit_db.rb +4 -5
- data/lib/wlog/commands/make_csv.rb +0 -1
- data/lib/wlog/commands/new_entry.rb +2 -2
- data/lib/wlog/commands/replace_pattern.rb +0 -1
- data/lib/wlog/commands/taint_setup.rb +0 -1
- data/lib/wlog/domain.rb +0 -1
- data/lib/wlog/domain/attachment.rb +1 -1
- data/lib/wlog/domain/git_commit.rb +1 -1
- data/lib/wlog/domain/helpers.rb +4 -5
- data/lib/wlog/domain/invoice.rb +1 -1
- data/lib/wlog/domain/issue.rb +35 -10
- data/lib/wlog/domain/key_value.rb +2 -3
- data/lib/wlog/domain/log_entry.rb +5 -13
- data/lib/wlog/domain/static_configurations.rb +24 -25
- data/lib/wlog/domain/sys_config.rb +2 -3
- data/lib/wlog/domain/template_helper.rb +2 -2
- data/lib/wlog/domain/timelog_helper.rb +1 -1
- data/lib/wlog/migrations/make_standard_tables.rb +4 -5
- data/lib/wlog/tech/ansi_colors.rb +0 -1
- data/lib/wlog/tech/git_commit_parser.rb +14 -14
- data/lib/wlog/tech/git_commit_printer.rb +4 -4
- data/lib/wlog/tech/text_filters.rb +20 -0
- data/lib/wlog/tech/uncolored_string.rb +1 -1
- data/lib/wlog/tech/wlog_string.rb +1 -1
- data/lib/wlog/ui/bootstrap.rb +1 -2
- data/lib/wlog/ui/cli_interface.rb +12 -12
- data/lib/wlog/ui/configuration_ui.rb +5 -6
- data/lib/wlog/ui/edit_handler.rb +6 -6
- data/lib/wlog/ui/git_ui.rb +29 -16
- data/lib/wlog/ui/invoice_ui.rb +41 -27
- data/lib/wlog/ui/issue_ui.rb +29 -26
- data/lib/wlog/ui/setup_wizard.rb +4 -2
- data/lib/wlog/ui/template_ui.rb +1 -2
- data/lib/wlog/version.rb +1 -1
- data/spec/domain/attachment_spec.rb +8 -8
- data/spec/domain/commands/concat_desc_spec.rb +2 -2
- data/spec/domain/commands/new_entry_spec.rb +2 -2
- data/spec/domain/commands/replace_pattern_spec.rb +0 -1
- data/spec/domain/git_commits_spec.rb +11 -11
- data/spec/domain/invoice_spec.rb +5 -6
- data/spec/domain/issue_spec.rb +8 -9
- data/spec/domain/key_value_spec.rb +3 -4
- data/spec/domain/log_entry_spec.rb +6 -7
- data/spec/make_db.rb +1 -2
- data/spec/spec_helper.rb +4 -5
- data/spec/tech/text_filters_spec.rb +54 -0
- data/spec/tech/uncolored_string.rb +1 -1
- metadata +6 -3
data/lib/wlog/ui/invoice_ui.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'readline'
|
2
|
+
require 'tempfile'
|
2
3
|
require 'wlog/domain/invoice'
|
3
4
|
require 'wlog/domain/sys_config'
|
4
5
|
require 'wlog/domain/static_configurations'
|
@@ -33,7 +34,7 @@ class InvoiceUi
|
|
33
34
|
when /^commits/ then commits(cmd.split.drop 1)
|
34
35
|
when 'help' then print_help
|
35
36
|
when /^end/ then next
|
36
|
-
else
|
37
|
+
else
|
37
38
|
puts "type 'help' for a list of options"
|
38
39
|
end
|
39
40
|
end
|
@@ -46,13 +47,17 @@ private
|
|
46
47
|
num = rest.first || 1
|
47
48
|
|
48
49
|
@invoice = Invoice.find(num.to_i)
|
49
|
-
|
50
|
-
|
50
|
+
|
51
|
+
if KeyValue.get('git')
|
52
|
+
# Only attempt to fetch commits if user has set git repo
|
53
|
+
cmd = FetchGitCommitsStandard.new(@invoice.from, @invoice.to)
|
54
|
+
cmd.execute
|
55
|
+
@commits = cmd.commits
|
56
|
+
end
|
51
57
|
|
52
58
|
@log_entries = @invoice.log_entries_within_dates
|
53
59
|
@issues = [Issue.find(*(@log_entries.collect(&:issue_id).uniq))].compact.flatten
|
54
|
-
|
55
|
-
|
60
|
+
|
56
61
|
renderer = ERB.new(TemplateHelper.template_s)
|
57
62
|
output = renderer.result(binding)
|
58
63
|
|
@@ -67,13 +72,13 @@ private
|
|
67
72
|
def delete(rest)
|
68
73
|
id = rest[0]
|
69
74
|
cmd = Readline.readline("Are you sure you want to delete invoice ##{id}? [y/n]: ")
|
70
|
-
return if cmd != 'y'
|
75
|
+
return if cmd != 'y'
|
71
76
|
Invoice.delete(id)
|
72
77
|
end
|
73
78
|
|
74
79
|
def ls
|
75
80
|
Invoice.all.each do |invoice|
|
76
|
-
print " [#{invoice.id}] "
|
81
|
+
print " [#{invoice.id}] "
|
77
82
|
print @strmaker.yellow(invoice.from.strftime("%d-%m-%Y"))
|
78
83
|
print @strmaker.blue(" -> ")
|
79
84
|
print @strmaker.yellow(invoice.to.strftime("%d-%m-%Y"))
|
@@ -85,9 +90,10 @@ private
|
|
85
90
|
['new', 'make a new invoice',
|
86
91
|
'ls,show', 'list the current invoice templates',
|
87
92
|
'delete', 'delete an invoice (eg: delete 2)',
|
88
|
-
'generate', 'generate an invoice using set template (eg: generate 2)'
|
93
|
+
'generate', 'generate an invoice using set template (eg: generate 2)',
|
94
|
+
'commits', 'list out the commits valid for the duration of the invoice'
|
89
95
|
].each_with_index do |cmd,ix|
|
90
|
-
print ' ' if ix % 2 == 1
|
96
|
+
print ' ' if ix % 2 == 1
|
91
97
|
puts cmd
|
92
98
|
end
|
93
99
|
end
|
@@ -107,27 +113,36 @@ private
|
|
107
113
|
# TODO: this would have to be factored out at some point. Also I think the
|
108
114
|
# implementation is crappy. I have to recheck at some point.
|
109
115
|
def longtext
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
116
|
+
if ENV['EDITOR'].nil?
|
117
|
+
count = 0
|
118
|
+
status = nil
|
119
|
+
str = ""
|
120
|
+
|
121
|
+
until status == :end_text do
|
122
|
+
line = Readline.readline(@strmaker.blue('> ')).strip
|
123
|
+
count += 1 if line == ""
|
124
|
+
count = 0 if line != ""
|
125
|
+
|
126
|
+
str.concat(line).concat($/)
|
127
|
+
|
128
|
+
status = :end_text and next if count == 2
|
129
|
+
end
|
130
|
+
else
|
131
|
+
t = Tempfile.new('description')
|
132
|
+
system(ENV['EDITOR'] + ' ' + t.path)
|
133
|
+
str = File.open(t.path).read
|
134
|
+
t.unlink
|
135
|
+
end
|
136
|
+
|
137
|
+
str
|
138
|
+
end
|
124
139
|
|
125
140
|
def commits(invoice_id)
|
126
|
-
inv = Invoice.find_by_id(invoice_id)
|
141
|
+
inv = Invoice.find_by_id(invoice_id)
|
127
142
|
repo = KeyValue.get('git')
|
128
143
|
author = KeyValue.get('author')
|
129
144
|
|
130
|
-
unless repo
|
145
|
+
unless repo
|
131
146
|
puts @strmaker.red("You need to set a git repo first")
|
132
147
|
return
|
133
148
|
end
|
@@ -140,11 +155,10 @@ private
|
|
140
155
|
puts "git commits for #{@strmaker.yellow(author)}"
|
141
156
|
puts
|
142
157
|
print_git_commits(command.commits)
|
143
|
-
|
158
|
+
|
144
159
|
rescue ActiveRecord::RecordNotFound
|
145
160
|
puts @strmaker.red("No such invoice")
|
146
161
|
end
|
147
162
|
|
148
163
|
end
|
149
164
|
end
|
150
|
-
|
data/lib/wlog/ui/issue_ui.rb
CHANGED
@@ -52,15 +52,35 @@ class IssueUi
|
|
52
52
|
# Focusing on the current issue
|
53
53
|
attr_accessor :issue
|
54
54
|
|
55
|
-
private
|
56
|
-
|
55
|
+
private
|
56
|
+
# This needs updating
|
57
|
+
def print_help
|
58
|
+
["new", "Create a new log entry",
|
59
|
+
'ls', "list issues",
|
60
|
+
'desc', "describe an issue",
|
61
|
+
'edit', "edit fields of an issue",
|
62
|
+
'concat', "append information to an issue",
|
63
|
+
'replace', 'replace text within an issue',
|
64
|
+
'lt', 'log time on an issue',
|
65
|
+
"outcsv", "Export everything to CSV",
|
66
|
+
'attach', 'Attach a file to the current issue',
|
67
|
+
'attachls', 'Show what files have been attached to an issue',
|
68
|
+
'attachout', 'Extract a file from the database',
|
69
|
+
"help", "print this dialog",
|
70
|
+
"end", "Exit the progam (alias: forget, finish)",
|
71
|
+
"search", "Search for a string in the log description text",
|
72
|
+
"delete", "Remove the task with a given id"].each_with_index do |el,ix|
|
73
|
+
print " " if 1 == ix % 2
|
74
|
+
puts el
|
75
|
+
end
|
76
|
+
end
|
57
77
|
# Wriet out the data contained in the database of the attachment
|
58
78
|
def output_attach
|
59
79
|
att_id = Readline.readline('Which attachment to output? : ').to_i
|
60
80
|
loc = Readline.readline('Output where (abs dir) ? : ')
|
61
81
|
loc.chomp!
|
62
82
|
att = Attachment.find(att_id)
|
63
|
-
|
83
|
+
|
64
84
|
fh = File.open("#{loc}/#{att.filename}", 'w')
|
65
85
|
fh.write(att.data)
|
66
86
|
fh.close
|
@@ -68,7 +88,7 @@ private
|
|
68
88
|
|
69
89
|
def show_attach
|
70
90
|
atts = @issue.attachments
|
71
|
-
atts.each do |att|
|
91
|
+
atts.each do |att|
|
72
92
|
printf "[%d] - %s (alias: %s)\n", att.id, att.filename, att.given_name
|
73
93
|
end
|
74
94
|
end
|
@@ -78,7 +98,7 @@ private
|
|
78
98
|
loc.strip!
|
79
99
|
name_alias = Readline.readline('Alias name for file (optional): ')
|
80
100
|
name_alias.strip!
|
81
|
-
|
101
|
+
|
82
102
|
fh = File.open(loc, "r")
|
83
103
|
data = fh.read
|
84
104
|
fh.close
|
@@ -99,30 +119,14 @@ private
|
|
99
119
|
|
100
120
|
# Time logging command
|
101
121
|
def time(rest)
|
102
|
-
time = TimelogHelper.parse(rest.join)
|
122
|
+
time = TimelogHelper.parse(rest.join)
|
103
123
|
@issue.log_time(time)
|
104
124
|
puts @strmaker.green('logged time!')
|
105
125
|
end
|
106
126
|
|
107
127
|
# Print the description of the issue
|
108
|
-
def describe_issue;
|
109
|
-
puts @issue
|
110
|
-
end
|
111
|
-
|
112
|
-
# This needs updating
|
113
|
-
def print_help
|
114
|
-
["new", "Create a new log entry",
|
115
|
-
"outcsv", "Export everything to CSV",
|
116
|
-
'attach', 'Attach a file to the current issue',
|
117
|
-
'attachls', 'Show what files have been attached to an issue',
|
118
|
-
'attachout', 'Extract a file from the database',
|
119
|
-
"help", "print this dialog",
|
120
|
-
"end", "Exit the progam",
|
121
|
-
"search", "Search for a string in the log description text",
|
122
|
-
"delete", "Remove the task with a given id"].each_with_index do |el,ix|
|
123
|
-
print " " if 1 == ix % 2
|
124
|
-
puts el
|
125
|
-
end
|
128
|
+
def describe_issue;
|
129
|
+
puts @issue
|
126
130
|
end
|
127
131
|
|
128
132
|
# Exit the issue, mark as finished
|
@@ -133,7 +137,7 @@ private
|
|
133
137
|
@issue.save
|
134
138
|
end
|
135
139
|
ret end
|
136
|
-
|
140
|
+
|
137
141
|
# new entry command
|
138
142
|
def new_entry
|
139
143
|
description = Readline.readline("Enter new issue:#{$/} ")
|
@@ -195,4 +199,3 @@ private
|
|
195
199
|
end
|
196
200
|
end
|
197
201
|
end # end module
|
198
|
-
|
data/lib/wlog/ui/setup_wizard.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
require 'readline'
|
2
2
|
require 'wlog/domain/sys_config'
|
3
3
|
require 'wlog/commands/taint_setup'
|
4
|
+
require 'wlog/tech/wlog_string'
|
4
5
|
|
5
6
|
module Wlog
|
6
7
|
# This is the ui that is displayed whenever we detect that it is the first
|
@@ -18,10 +19,11 @@ class SetupWizard
|
|
18
19
|
TaintSetup.new.execute
|
19
20
|
end
|
20
21
|
|
21
|
-
private
|
22
|
+
private
|
22
23
|
|
23
24
|
def get_setting
|
24
|
-
|
25
|
+
puts WlogString.green('ABCD')
|
26
|
+
question = "Is the previous line a green 'ABCD'? [yes/no] :"
|
25
27
|
until ['yes', 'no'].include? input
|
26
28
|
@input = Readline.readline(question)
|
27
29
|
@input.chomp!
|
data/lib/wlog/ui/template_ui.rb
CHANGED
@@ -33,7 +33,7 @@ class TemplateUi
|
|
33
33
|
private
|
34
34
|
|
35
35
|
def print_help
|
36
|
-
['ls, show', 'list the current templates you can use',
|
36
|
+
['ls, show', 'list the current templates you can use',
|
37
37
|
'set <num>', 'set the template you want to use',
|
38
38
|
'help', 'print this menu'].each_with_index do |cmd,ix|
|
39
39
|
print " " if ix % 2 == 1
|
@@ -63,4 +63,3 @@ private
|
|
63
63
|
|
64
64
|
end
|
65
65
|
end
|
66
|
-
|
data/lib/wlog/version.rb
CHANGED
@@ -9,24 +9,24 @@ require 'zlib'
|
|
9
9
|
|
10
10
|
include Wlog
|
11
11
|
|
12
|
-
describe Attachment do
|
13
|
-
|
12
|
+
describe Attachment do
|
13
|
+
|
14
14
|
db_name = 'default'
|
15
15
|
db_path = standard_db_path(db_name)
|
16
|
-
|
16
|
+
|
17
17
|
before(:all) do
|
18
18
|
make_testing_db(db_name)
|
19
19
|
end
|
20
|
-
|
20
|
+
|
21
21
|
after(:all) do
|
22
22
|
close_testing_db
|
23
23
|
FileUtils.rm db_path
|
24
24
|
end
|
25
|
-
|
25
|
+
|
26
26
|
it 'should attach a mock file to an issue' do
|
27
27
|
@issue = Issue.create(:description => 'mydesc',
|
28
28
|
:long_description => 'potato')
|
29
|
-
|
29
|
+
|
30
30
|
# You're kind of forced to do this because I've hacked a shitty
|
31
31
|
# implementation of compressing - uncompressing strings automatically when
|
32
32
|
# attaching files.
|
@@ -48,5 +48,5 @@ describe Attachment do
|
|
48
48
|
it "should return nil if something is not found" do
|
49
49
|
expect(Attachment.find_by_id(123123123)).to eq(nil)
|
50
50
|
end
|
51
|
-
end
|
52
|
-
#
|
51
|
+
end
|
52
|
+
#
|
@@ -9,7 +9,7 @@ require 'wlog/commands/concat_description'
|
|
9
9
|
|
10
10
|
include Wlog
|
11
11
|
|
12
|
-
describe ConcatDescription do
|
12
|
+
describe ConcatDescription do
|
13
13
|
|
14
14
|
db_name = 'default'
|
15
15
|
db_path = standard_db_path(db_name)
|
@@ -30,7 +30,7 @@ describe ConcatDescription do
|
|
30
30
|
after(:all) do
|
31
31
|
FileUtils.rm db_path
|
32
32
|
end
|
33
|
-
|
33
|
+
|
34
34
|
# I know, tests should not really look for implementation details, but things
|
35
35
|
# in our case *should* really inherit the command interface.
|
36
36
|
it "should inherit from commandable" do
|
@@ -7,7 +7,7 @@ require 'wlog/commands/new_entry'
|
|
7
7
|
|
8
8
|
include Wlog
|
9
9
|
|
10
|
-
describe NewEntry do
|
10
|
+
describe NewEntry do
|
11
11
|
|
12
12
|
db_name = 'default'
|
13
13
|
db_path = standard_db_path(db_name)
|
@@ -23,7 +23,7 @@ describe NewEntry do
|
|
23
23
|
FileUtils.rm db_path
|
24
24
|
end
|
25
25
|
|
26
|
-
it "should insert a new entry on execution" do
|
26
|
+
it "should insert a new entry on execution" do
|
27
27
|
command = NewEntry.new("my desc", @issue)
|
28
28
|
command.execute
|
29
29
|
expect(LogEntry.count).to eq(1)
|
@@ -2,7 +2,7 @@ require_relative '../spec_helper'
|
|
2
2
|
|
3
3
|
include Wlog
|
4
4
|
|
5
|
-
describe GitCommitParser do
|
5
|
+
describe GitCommitParser do
|
6
6
|
|
7
7
|
GitLogSample = <<GITDATA
|
8
8
|
commit 19b5dd496ba2e4125c681b3c505f7631053a2fab
|
@@ -10,7 +10,7 @@ Author: psyomn <lethaljellybean@gmail.com>
|
|
10
10
|
Date: Wed Oct 23 23:00:56 2013 -0400
|
11
11
|
|
12
12
|
Tiny setup wizard for checking if ansi or not
|
13
|
-
|
13
|
+
|
14
14
|
Need to provide a system configuration service that takes into account things
|
15
15
|
that are the same for any running instance of the application (because others
|
16
16
|
might just be specific to project databases).
|
@@ -30,14 +30,14 @@ Date: Wed Oct 23 22:46:27 2013 -0400
|
|
30
30
|
GITDATA
|
31
31
|
|
32
32
|
Malformed = <<BADGIT
|
33
|
-
potato potato potato potato potato potato potato potato potato potato potato
|
34
|
-
potato potato potato potato potato potato potato potato potato potato potato potato
|
35
|
-
potato potato potato potato potato potato potato potato potato potato potato potato
|
36
|
-
potato potato potato potato potato potato potato potato potato potato potato potato
|
37
|
-
potato potato potato potato potato potato potato potato potato potato potato potato
|
33
|
+
potato potato potato potato potato potato potato potato potato potato potato
|
34
|
+
potato potato potato potato potato potato potato potato potato potato potato potato
|
35
|
+
potato potato potato potato potato potato potato potato potato potato potato potato
|
36
|
+
potato potato potato potato potato potato potato potato potato potato potato potato
|
37
|
+
potato potato potato potato potato potato potato potato potato potato potato potato
|
38
38
|
BADGIT
|
39
39
|
|
40
|
-
it 'should return [] on null string' do
|
40
|
+
it 'should return [] on null string' do
|
41
41
|
expect(GitCommitParser.parse('')).to eq([])
|
42
42
|
end
|
43
43
|
|
@@ -49,7 +49,7 @@ BADGIT
|
|
49
49
|
expect(GitCommitParser.parse(GitLogSample).count).to eq(3)
|
50
50
|
end
|
51
51
|
|
52
|
-
it 'should retrieve hashes' do
|
52
|
+
it 'should retrieve hashes' do
|
53
53
|
commits = GitCommitParser.parse(GitLogSample)
|
54
54
|
hashes = commits.collect &:commit
|
55
55
|
expected_hashes = [
|
@@ -60,13 +60,13 @@ BADGIT
|
|
60
60
|
expect((hashes & expected_hashes).count).to eq(3)
|
61
61
|
end
|
62
62
|
|
63
|
-
it 'should retrieve authors' do
|
63
|
+
it 'should retrieve authors' do
|
64
64
|
commits = GitCommitParser.parse(GitLogSample)
|
65
65
|
authors = commits.collect &:author
|
66
66
|
expect(authors.count).to eq(3)
|
67
67
|
end
|
68
68
|
|
69
|
-
it 'should retrieve shortlogs' do
|
69
|
+
it 'should retrieve shortlogs' do
|
70
70
|
commits = GitCommitParser.parse(GitLogSample)
|
71
71
|
shortlogs = commits.collect &:shortlog
|
72
72
|
expect(shortlogs.count).to eq(3)
|
data/spec/domain/invoice_spec.rb
CHANGED
@@ -3,24 +3,24 @@ require_relative '../make_db'
|
|
3
3
|
|
4
4
|
include Wlog
|
5
5
|
|
6
|
-
describe Invoice do
|
6
|
+
describe Invoice do
|
7
7
|
include DomainHelpers
|
8
8
|
|
9
9
|
db_name = 'default'
|
10
10
|
db_path = standard_db_path(db_name)
|
11
11
|
|
12
|
-
before :all do
|
12
|
+
before :all do
|
13
13
|
make_testing_db(db_name)
|
14
14
|
end
|
15
15
|
|
16
|
-
after :all do
|
16
|
+
after :all do
|
17
17
|
FileUtils.rm db_path
|
18
18
|
end
|
19
19
|
|
20
|
-
it 'should fetch all relevant log entries between two dates' do
|
20
|
+
it 'should fetch all relevant log entries between two dates' do
|
21
21
|
invoice = Invoice.create(:from => (DateTime.now - 5), :to => (DateTime.now + 5))
|
22
22
|
issue = make_issue
|
23
|
-
|
23
|
+
|
24
24
|
10.times do
|
25
25
|
le = make_log_entry
|
26
26
|
le.created_at = DateTime.now - 2
|
@@ -32,4 +32,3 @@ describe Invoice do
|
|
32
32
|
end
|
33
33
|
|
34
34
|
end
|
35
|
-
|