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
@@ -84,10 +84,10 @@ class SysConfig
|
|
84
84
|
terms.each do |term_tuple| # [term, value]
|
85
85
|
values[term_tuple[0]] = term_tuple[1]
|
86
86
|
end
|
87
|
-
values
|
87
|
+
values
|
88
88
|
rescue Errno::ENOENT
|
89
89
|
$stderr.puts "#{self.class.name}: Problem opening file #{ConfigFile}"
|
90
|
-
# Minimum guarantee: disable ansi colors
|
90
|
+
# Minimum guarantee: disable ansi colors
|
91
91
|
{'ansi' => 'no'}
|
92
92
|
end
|
93
93
|
|
@@ -96,4 +96,3 @@ class SysConfig
|
|
96
96
|
|
97
97
|
end
|
98
98
|
end # module Wlog
|
99
|
-
|
@@ -3,9 +3,9 @@ require 'wlog/domain/static_configurations'
|
|
3
3
|
|
4
4
|
module Wlog
|
5
5
|
# Bunlde helper functions for templates here
|
6
|
-
# @author Simon Symeonidis
|
6
|
+
# @author Simon Symeonidis
|
7
7
|
class TemplateHelper
|
8
|
-
include StaticConfigurations
|
8
|
+
include StaticConfigurations
|
9
9
|
# @return absolute path to the template the user has set
|
10
10
|
def self.template_file
|
11
11
|
num = KeyValue.get('template') || 1
|
@@ -1,10 +1,10 @@
|
|
1
|
-
require 'active_record'
|
1
|
+
require 'active_record'
|
2
2
|
|
3
3
|
module Wlog
|
4
4
|
# Migrations to replace the raw sql from turntables
|
5
5
|
# @author Simon Symeonidis
|
6
6
|
class MakeStandardTables < ActiveRecord::Migration
|
7
|
-
def change
|
7
|
+
def change
|
8
8
|
create_table :issues do |t|
|
9
9
|
t.text :description
|
10
10
|
t.datetime :due_date
|
@@ -23,7 +23,7 @@ class MakeStandardTables < ActiveRecord::Migration
|
|
23
23
|
end
|
24
24
|
|
25
25
|
create_table :attachments do |t|
|
26
|
-
t.text :filename
|
26
|
+
t.text :filename
|
27
27
|
t.text :given_name
|
28
28
|
t.text :data
|
29
29
|
t.datetime :created_at
|
@@ -42,5 +42,4 @@ class MakeStandardTables < ActiveRecord::Migration
|
|
42
42
|
end
|
43
43
|
end
|
44
44
|
end
|
45
|
-
end
|
46
|
-
|
45
|
+
end
|
@@ -6,39 +6,39 @@ class GitCommitParser
|
|
6
6
|
# @param log_s is the string obtained from running a `git log` command
|
7
7
|
# @return a list of GitCommit objects
|
8
8
|
def self.parse(log_s)
|
9
|
-
cur = nil
|
10
|
-
inmessage = false
|
11
|
-
gitlogs = []
|
12
|
-
|
13
|
-
log_s.lines.each do |line|
|
9
|
+
cur = nil
|
10
|
+
inmessage = false
|
11
|
+
gitlogs = []
|
12
|
+
|
13
|
+
log_s.lines.each do |line|
|
14
14
|
case line
|
15
15
|
when /^commit/i
|
16
|
-
inmessage = false
|
16
|
+
inmessage = false
|
17
17
|
gitlogs.push cur if cur
|
18
18
|
cur = GitCommit.new
|
19
19
|
cur.commit = line.split[1].strip
|
20
|
-
|
20
|
+
|
21
21
|
when /^author/i
|
22
22
|
next unless cur
|
23
23
|
cur.author = line.split[1].strip
|
24
|
-
|
24
|
+
|
25
25
|
when /^date/i, /^\n$/
|
26
26
|
next
|
27
|
-
|
28
|
-
else
|
27
|
+
|
28
|
+
else
|
29
29
|
next unless cur
|
30
30
|
if inmessage
|
31
31
|
cur.message.concat(line)
|
32
32
|
cur.message.strip!
|
33
33
|
else
|
34
34
|
cur.shortlog = line
|
35
|
-
cur.shortlog.strip!
|
35
|
+
cur.shortlog.strip!
|
36
36
|
inmessage = true
|
37
|
-
end
|
37
|
+
end
|
38
38
|
end
|
39
|
-
|
39
|
+
|
40
40
|
end
|
41
|
-
|
41
|
+
|
42
42
|
# if commits have no hash, discard them
|
43
43
|
gitlogs.reject! { |e| e.commit == "" }
|
44
44
|
gitlogs.push cur if cur
|
@@ -5,12 +5,12 @@ module Wlog
|
|
5
5
|
module GitCommitPrinter
|
6
6
|
|
7
7
|
def print_git_commits(commit_a)
|
8
|
-
sm = SysConfig.string_decorator
|
9
|
-
|
10
|
-
commit_a.each do |commit|
|
8
|
+
sm = SysConfig.string_decorator
|
9
|
+
|
10
|
+
commit_a.each do |commit|
|
11
11
|
print ' '
|
12
12
|
print sm.blue(commit.commit)
|
13
|
-
print ' '
|
13
|
+
print ' '
|
14
14
|
puts sm.green(commit.shortlog[0..50] + ' ...')
|
15
15
|
end
|
16
16
|
nil end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'wlog/domain/sys_config'
|
2
|
+
module Wlog
|
3
|
+
# Group text filters here, for any text processing you want to do
|
4
|
+
# @author Simon Symeonidis
|
5
|
+
module TextFilters
|
6
|
+
# Use strmakers in order to color hyperlinks. This will look for a regex
|
7
|
+
# pattern of a http(s) link, and color it.
|
8
|
+
# @param string is the string we want to look into and color
|
9
|
+
# @return the string with ansi colored links if ansi is set.
|
10
|
+
def highlight_hyperlink_s(string)
|
11
|
+
@strmaker = SysConfig.string_decorator
|
12
|
+
regex = /http(s)?:\S*|www.\S*/
|
13
|
+
s = string.dup
|
14
|
+
tmp = nil
|
15
|
+
s.gsub!(regex) { @strmaker.blue($&) }
|
16
|
+
s
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
data/lib/wlog/ui/bootstrap.rb
CHANGED
@@ -10,10 +10,9 @@ class Bootstrap
|
|
10
10
|
# make $HOME/.config/wlog standard dirs, and pull up database
|
11
11
|
def self.configure!
|
12
12
|
Helpers.make_dirs!
|
13
|
-
InnitDb.new.execute
|
13
|
+
InnitDb.new.execute
|
14
14
|
# Initial setup if first time running
|
15
15
|
SetupWizard.new.run if Helpers.first_setup?
|
16
16
|
end
|
17
17
|
end
|
18
18
|
end
|
19
|
-
|
@@ -32,7 +32,7 @@ class CliInterface
|
|
32
32
|
def run
|
33
33
|
cmd = "default"
|
34
34
|
label = @strmaker.white('wlog')
|
35
|
-
until cmd == "end" do
|
35
|
+
until cmd == "end" do
|
36
36
|
cmd = Readline.readline("[#{label}] ") || "end"
|
37
37
|
cmd.chomp!
|
38
38
|
|
@@ -52,7 +52,7 @@ class CliInterface
|
|
52
52
|
end
|
53
53
|
end
|
54
54
|
end
|
55
|
-
|
55
|
+
|
56
56
|
# TODO this might need to be factored out elsewhere
|
57
57
|
def self.list_databases
|
58
58
|
puts "Available Worklog databases: "
|
@@ -61,8 +61,8 @@ class CliInterface
|
|
61
61
|
end
|
62
62
|
end
|
63
63
|
|
64
|
-
private
|
65
|
-
|
64
|
+
private
|
65
|
+
|
66
66
|
# Create a new issue
|
67
67
|
def new_issue; CreateIssue.new.execute end
|
68
68
|
|
@@ -74,7 +74,7 @@ private
|
|
74
74
|
puts 'usage:'
|
75
75
|
puts ' delete <id>'
|
76
76
|
return
|
77
|
-
else
|
77
|
+
else
|
78
78
|
issue_id = issue_id.to_i
|
79
79
|
end
|
80
80
|
|
@@ -83,8 +83,8 @@ private
|
|
83
83
|
choice = Readline.readline("Delete issue #{issue_id}? [y/n]").strip
|
84
84
|
if choice == "y"
|
85
85
|
dcmd.execute
|
86
|
-
else
|
87
|
-
puts "Did nothing"
|
86
|
+
else
|
87
|
+
puts "Did nothing"
|
88
88
|
return
|
89
89
|
end
|
90
90
|
end
|
@@ -95,7 +95,7 @@ private
|
|
95
95
|
def archive(cmd)
|
96
96
|
args = cmd.split[1..-1]
|
97
97
|
|
98
|
-
if args.length > 0
|
98
|
+
if args.length > 0
|
99
99
|
if args[0] == 'finished'
|
100
100
|
puts "Archiving finished issues."
|
101
101
|
ArchiveFinishedIssues.new.execute
|
@@ -140,7 +140,7 @@ private
|
|
140
140
|
# FIXME (update the command stuff)
|
141
141
|
# Print the help of the cli app
|
142
142
|
def print_help
|
143
|
-
['new', 'Create a new log entry',
|
143
|
+
['new', 'Create a new log entry',
|
144
144
|
'outcsv', 'Export everything to CSV',
|
145
145
|
'help', 'print this dialog',
|
146
146
|
'end', 'Exit the progam',
|
@@ -148,12 +148,13 @@ private
|
|
148
148
|
'archive', 'Archive a file into a specific issue',
|
149
149
|
'invoices', 'Go to invoices interface',
|
150
150
|
'templates', 'Go to template interface, and set templates',
|
151
|
+
'git', 'Go git interface for setting git options',
|
151
152
|
'focus', 'Focus on a particular ',
|
152
153
|
'show', 'List all the issues',
|
153
154
|
'help', 'Show this information',
|
154
155
|
'search', 'Search for a specific text',
|
155
156
|
'config', 'Set differeing configuration parameters'
|
156
|
-
].each_with_index do |el,ix|
|
157
|
+
].each_with_index do |el,ix|
|
157
158
|
print ' ' if 1 == ix % 2
|
158
159
|
puts el
|
159
160
|
end
|
@@ -193,7 +194,7 @@ private
|
|
193
194
|
# Search for an issue
|
194
195
|
def search
|
195
196
|
term = Readline.readline("search issues for term : ")
|
196
|
-
issues = Issue.where(["description like ?", "%#{term}%"])
|
197
|
+
issues = Issue.where(["description like ?", "%#{term}%"])
|
197
198
|
print_list(issues)
|
198
199
|
end
|
199
200
|
|
@@ -202,4 +203,3 @@ private
|
|
202
203
|
|
203
204
|
end
|
204
205
|
end # module Wlog
|
205
|
-
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'readline'
|
2
2
|
require 'wlog/domain/sys_config'
|
3
3
|
|
4
|
-
module Wlog
|
4
|
+
module Wlog
|
5
5
|
# Ui to manage configuration settings
|
6
6
|
# @author Simon Symeonidis
|
7
7
|
class ConfigurationUi
|
@@ -19,7 +19,7 @@ class ConfigurationUi
|
|
19
19
|
cmd = Readline.readline("[#{label}] ") || "end"
|
20
20
|
cmd.chomp!
|
21
21
|
|
22
|
-
case cmd
|
22
|
+
case cmd
|
23
23
|
when /^show/ then show_configurations
|
24
24
|
when /^set/ then set(cmd)
|
25
25
|
when /^help/ then help
|
@@ -27,11 +27,11 @@ class ConfigurationUi
|
|
27
27
|
end
|
28
28
|
end
|
29
29
|
|
30
|
-
private
|
30
|
+
private
|
31
31
|
|
32
32
|
# This should show the configurations
|
33
33
|
def show_configurations
|
34
|
-
SysConfig.read_attributes.each do |name, value|
|
34
|
+
SysConfig.read_attributes.each do |name, value|
|
35
35
|
puts "%s %s" % [@strmaker.green(name), value]
|
36
36
|
end
|
37
37
|
end
|
@@ -47,7 +47,7 @@ private
|
|
47
47
|
# Set a value to something else
|
48
48
|
def set(cmd)
|
49
49
|
arr = cmd.split
|
50
|
-
if arr.size != 3
|
50
|
+
if arr.size != 3
|
51
51
|
puts "Wrong number of arguments"
|
52
52
|
return
|
53
53
|
end
|
@@ -60,4 +60,3 @@ private
|
|
60
60
|
'set <key> <value>' => 'set the configuration pair'}
|
61
61
|
end
|
62
62
|
end # module wlog
|
63
|
-
|
data/lib/wlog/ui/edit_handler.rb
CHANGED
@@ -7,7 +7,7 @@ module Wlog
|
|
7
7
|
class EditHandler
|
8
8
|
|
9
9
|
def initialize(issue)
|
10
|
-
@issue = issue
|
10
|
+
@issue = issue
|
11
11
|
@strmaker = SysConfig.string_decorator
|
12
12
|
end
|
13
13
|
|
@@ -29,7 +29,7 @@ class EditHandler
|
|
29
29
|
when /^reported/
|
30
30
|
edit_reported_time(param)
|
31
31
|
|
32
|
-
else
|
32
|
+
else
|
33
33
|
$stdout.puts "Usage: "
|
34
34
|
$stdout.puts " edit title - to edit the title"
|
35
35
|
$stdout.puts " edit desc - to edit the long description"
|
@@ -37,7 +37,7 @@ class EditHandler
|
|
37
37
|
$stdout.puts " edit time - to edit the time"
|
38
38
|
end
|
39
39
|
end
|
40
|
-
|
40
|
+
|
41
41
|
# Small helper to parse the due date when editing the dates of issues.
|
42
42
|
# @param time is the date-time in string format (eg Oct 28)
|
43
43
|
# @return nothing - we're just setting if the data format is ok
|
@@ -63,9 +63,9 @@ class EditHandler
|
|
63
63
|
"Invalid date/time format. Try format like 'Oct 28'"
|
64
64
|
end
|
65
65
|
|
66
|
-
# TODO fix me
|
66
|
+
# TODO fix me
|
67
67
|
# @param time_str The time that we want to kind of sanitize
|
68
|
-
# @return a Time object which is set to 9am on that day if no time
|
68
|
+
# @return a Time object which is set to 9am on that day if no time
|
69
69
|
# is provided
|
70
70
|
def time_handle(time_str)
|
71
71
|
date_time = DateTime.parse(time_str)
|
@@ -76,4 +76,4 @@ class EditHandler
|
|
76
76
|
attr :issue
|
77
77
|
|
78
78
|
end
|
79
|
-
end # wlog
|
79
|
+
end # wlog
|
data/lib/wlog/ui/git_ui.rb
CHANGED
@@ -3,45 +3,58 @@ module Wlog
|
|
3
3
|
# Interface to setup git stuff.
|
4
4
|
# @author Simon Symeonidis
|
5
5
|
class GitUi
|
6
|
-
|
6
|
+
|
7
7
|
def initialize
|
8
8
|
@strmaker = SysConfig.string_decorator
|
9
9
|
end
|
10
10
|
|
11
|
-
def run
|
12
|
-
cmd = "default"
|
11
|
+
def run
|
12
|
+
cmd = "default"
|
13
13
|
|
14
|
-
until cmd == "end" do
|
14
|
+
until cmd == "end" do
|
15
15
|
cmd = Readline.readline("[#{@strmaker.blue('git')}] ")
|
16
16
|
|
17
|
-
case cmd
|
17
|
+
case cmd
|
18
18
|
when /^set/
|
19
19
|
path = Readline.readline("Path to git repo (eg: project/.git/): ")
|
20
|
-
|
20
|
+
|
21
21
|
unless File.directory? path
|
22
22
|
puts @strmaker.red("That doesn't look like a git repo. Nothing done")
|
23
23
|
next
|
24
24
|
end
|
25
25
|
|
26
26
|
author = Readline.readline("git author: ")
|
27
|
-
|
27
|
+
|
28
28
|
# Set the git repo in the db (so one git repo per db)
|
29
29
|
KeyValue.put!("git", path)
|
30
30
|
KeyValue.put!("author", author)
|
31
31
|
|
32
|
-
|
33
|
-
|
32
|
+
when /^unset/
|
33
|
+
KeyValue.put!("git", "")
|
34
34
|
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
35
|
+
when /^(ls|show)/
|
36
|
+
print ' repo: '
|
37
|
+
puts @strmaker.green(KeyValue.get("git"))
|
38
|
+
print ' auth: '
|
39
|
+
puts @strmaker.yellow(KeyValue.get("author"))
|
40
|
+
|
41
|
+
when /^help/
|
42
|
+
print_help
|
40
43
|
|
41
44
|
end
|
42
45
|
end
|
43
|
-
end
|
44
46
|
|
47
|
+
private
|
48
|
+
|
49
|
+
def print_help
|
50
|
+
['ls, show', 'list the current git repository settings',
|
51
|
+
'set', 'set repo and author for currnet git repository',
|
52
|
+
'unset', 'unsets git repository settings',
|
53
|
+
'help', 'print this menu'].each_with_index do |cmd,ix|
|
54
|
+
print " " if ix % 2 == 1
|
55
|
+
puts cmd
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
45
59
|
end
|
46
60
|
end
|
47
|
-
|