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
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4035a8ebc932e0bd3fafca18b8cee1d071370f2d
|
4
|
+
data.tar.gz: db684be23ea24718cd088fe9266681e1ba7a5633
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9a057291af53d32cfe182105462f80910daad2eed5e479479af62c1a42cae4fe230edc627b2007b8909f3a9b36a2ac1711b3f4c34f534899ec4cd042f9c32c68
|
7
|
+
data.tar.gz: 6563cd1a3b160452e76cc620232876e8b8143aa9b32baf10e72cc3cd1a216b29dc931258b4858cc6afc4906b7c4b0faa9a24f04b72e761e7f6ff4cb4f16014c1
|
data/README.md
CHANGED
@@ -310,6 +310,20 @@ will be printed on screen.
|
|
310
310
|
22d760f881e613a30d3b722dd9b26f4f46c1cf4c domain/log_entry: add belongs_to issue ...
|
311
311
|
79d1e3393587b02c328a454d5cfe301d3f80aee8 invoices: select date range for log entries ...
|
312
312
|
|
313
|
+
## Config
|
314
|
+
|
315
|
+
If you want to unset colors you can do so by going to the config menu
|
316
|
+
|
317
|
+
[wlog] config
|
318
|
+
[config]
|
319
|
+
|
320
|
+
and then typing in
|
321
|
+
|
322
|
+
[config] set ansi no
|
323
|
+
|
324
|
+
When you restart wlog, the colors will be set off. To set colors back on just
|
325
|
+
use `yes`.
|
326
|
+
|
313
327
|
## Contributing
|
314
328
|
|
315
329
|
1. Fork it
|
data/bin/wlog
CHANGED
@@ -12,7 +12,7 @@ class CreateIssue < Commandable
|
|
12
12
|
desc = Readline.readline("Small issue description :") || "None."
|
13
13
|
ldesc = Readline.readline("Long issue description :") || "None."
|
14
14
|
@ret = Issue.create(:description =>desc.chomp, :long_description => ldesc,
|
15
|
-
:status => 0, :created_at => Time.now, :updated_at => Time.now,
|
15
|
+
:status => 0, :created_at => Time.now, :updated_at => Time.now,
|
16
16
|
:due_date => Time.now, :timelog => 0)
|
17
17
|
end
|
18
18
|
attr_accessor :ret
|
@@ -13,7 +13,7 @@ class FetchGitCommits < Commandable
|
|
13
13
|
# @param repo location to the git repo
|
14
14
|
# @param author only show logs of that author. If none is given, fetch all
|
15
15
|
# authors
|
16
|
-
# @example
|
16
|
+
# @example
|
17
17
|
# from_date = DateTime.now - 15
|
18
18
|
# to_date = DateTime.now + 5
|
19
19
|
# repo = '/home/jon/wlog/.git/'
|
@@ -34,12 +34,13 @@ private
|
|
34
34
|
|
35
35
|
# git --git-dir <thedir> log --since=... --until=... --author=...
|
36
36
|
def run_git_cmd
|
37
|
+
from_s = @from.strftime("%b %d %Y")
|
38
|
+
to_s = @to.strftime("%b %d %Y")
|
37
39
|
base = "git --git-dir #{@repo} log "
|
38
|
-
base.concat("--since=\"#{
|
39
|
-
base.concat("--until=\"#{
|
40
|
+
base.concat("--since=\"#{from_s}\" ")
|
41
|
+
base.concat("--until=\"#{to_s}\" ")
|
40
42
|
base.concat("--author=\"#{@author}\"") if @author
|
41
43
|
base end
|
42
44
|
|
43
45
|
end
|
44
46
|
end
|
45
|
-
|
@@ -41,7 +41,7 @@ class InnitDb < Commandable
|
|
41
41
|
|
42
42
|
migrations.reject!{ |e| existing.include? e.to_s}
|
43
43
|
|
44
|
-
migrations.each do |migration|
|
44
|
+
migrations.each do |migration|
|
45
45
|
ActiveRecord::Migration.run(migration)
|
46
46
|
SchemaMigration.create(:version => migration.name)
|
47
47
|
end
|
@@ -51,8 +51,8 @@ class InnitDb < Commandable
|
|
51
51
|
private
|
52
52
|
|
53
53
|
# Checks to see if versioning table is there. Create if not.
|
54
|
-
def make_schema_migrations!
|
55
|
-
ActiveRecord::Migration.verbose = false
|
54
|
+
def make_schema_migrations!
|
55
|
+
ActiveRecord::Migration.verbose = false
|
56
56
|
ActiveRecord::Base.configurations = dbconfig
|
57
57
|
ActiveRecord::Base.establish_connection(:development)
|
58
58
|
ActiveRecord::Base.default_timezone = :local
|
@@ -64,7 +64,7 @@ private
|
|
64
64
|
|
65
65
|
# TODO this should probably be moved
|
66
66
|
def dbconfig
|
67
|
-
dbname =
|
67
|
+
dbname = DefaultDb
|
68
68
|
{'development' => {
|
69
69
|
:adapter => 'sqlite3',
|
70
70
|
:pool => 5,
|
@@ -74,4 +74,3 @@ private
|
|
74
74
|
|
75
75
|
end
|
76
76
|
end
|
77
|
-
|
@@ -8,13 +8,13 @@ module Wlog
|
|
8
8
|
# @author Simon Symeonidis
|
9
9
|
class NewEntry < Commandable
|
10
10
|
|
11
|
-
def initialize(desc, issue)
|
11
|
+
def initialize(desc, issue)
|
12
12
|
@desc, @issue = desc, issue
|
13
13
|
end
|
14
14
|
|
15
15
|
def execute
|
16
16
|
log_entry = LogEntry.new(
|
17
|
-
:description => @desc,
|
17
|
+
:description => @desc,
|
18
18
|
:created_at => DateTime.now,
|
19
19
|
:updated_at => DateTime.now)
|
20
20
|
|
data/lib/wlog/domain.rb
CHANGED
@@ -19,6 +19,7 @@ class Attachment < ActiveRecord::Base
|
|
19
19
|
|
20
20
|
private
|
21
21
|
|
22
|
+
# TODO need to check if there is a better way to check for this
|
22
23
|
def compress_string
|
23
24
|
self.data = Zlib::Deflate.deflate self.data
|
24
25
|
end
|
@@ -32,4 +33,3 @@ private
|
|
32
33
|
|
33
34
|
end
|
34
35
|
end # module Wlog
|
35
|
-
|
data/lib/wlog/domain/helpers.rb
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
require 'wlog/domain/static_configurations'
|
2
2
|
|
3
3
|
module Wlog
|
4
|
-
# This contains a few helper methods that may be used by any part in the
|
4
|
+
# This contains a few helper methods that may be used by any part in the
|
5
5
|
# application.
|
6
6
|
# @author Simon Symeonidis
|
7
7
|
class Helpers
|
8
8
|
include StaticConfigurations
|
9
|
-
# Break the string to a different line
|
9
|
+
# Break the string to a different line
|
10
10
|
# @param string is the string that we want processed.
|
11
11
|
# @param numchars is the amount of characters max per line.
|
12
12
|
def self.break_string(string,numchars)
|
@@ -26,8 +26,8 @@ class Helpers
|
|
26
26
|
|
27
27
|
# Check to see if the database exists in the DataDirectory
|
28
28
|
# @return true if exists, otherwise false
|
29
|
-
def self.
|
30
|
-
File.exists? "#{DataDirectory}#{
|
29
|
+
def self.database_exists?
|
30
|
+
File.exists? "#{DataDirectory}#{DefaultDb}"
|
31
31
|
end
|
32
32
|
|
33
33
|
# Check to see if DataDirectory exists
|
@@ -44,4 +44,3 @@ class Helpers
|
|
44
44
|
def self.first_setup?; !File.exists? TaintFile end
|
45
45
|
end
|
46
46
|
end # module Wlog
|
47
|
-
|
data/lib/wlog/domain/invoice.rb
CHANGED
@@ -2,7 +2,7 @@ require 'active_record'
|
|
2
2
|
require 'wlog/domain/log_entry'
|
3
3
|
|
4
4
|
module Wlog
|
5
|
-
# The invoice domain object - use this to manipulate invoice recordings, or
|
5
|
+
# The invoice domain object - use this to manipulate invoice recordings, or
|
6
6
|
# this along with some renderer and templates in order to create said invoices.
|
7
7
|
# @author Simon Symeonidis
|
8
8
|
class Invoice < ActiveRecord::Base
|
data/lib/wlog/domain/issue.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
require 'active_record'
|
1
|
+
require 'active_record'
|
2
2
|
|
3
3
|
require 'wlog/domain/log_entry'
|
4
4
|
require 'wlog/domain/timelog_helper'
|
@@ -8,7 +8,7 @@ require 'wlog/domain/helpers'
|
|
8
8
|
module Wlog
|
9
9
|
# This aggregates log entries. The total time spent on this issue is
|
10
10
|
# calculated from checking out said log entries.
|
11
|
-
# @author Simon Symeonidis
|
11
|
+
# @author Simon Symeonidis
|
12
12
|
class Issue < ActiveRecord::Base
|
13
13
|
|
14
14
|
has_many :log_entries, dependent: :delete_all
|
@@ -33,7 +33,7 @@ class Issue < ActiveRecord::Base
|
|
33
33
|
@strmaker = SysConfig.string_decorator
|
34
34
|
"#{@strmaker.yellow('Issue')} ##{id}#{$/}"\
|
35
35
|
" #{@strmaker.blue('Reported')} : #{created_at.asctime}#{$/}"\
|
36
|
-
" #{@strmaker.blue('Due')} : #{due_date.asctime}#{$/}"\
|
36
|
+
" #{@strmaker.blue('Due')} : #{due_date.asctime} #{make_remaining_days_s}#{$/}"\
|
37
37
|
" #{@strmaker.blue('Entries')} : #{le_count} #{$/}"\
|
38
38
|
" #{@strmaker.blue('Status')} : #{Statuses[status]}#{$/}"\
|
39
39
|
" #{@strmaker.blue('Time')} : #{TimelogHelper.time_to_s(timelog)}#{$/}"\
|
@@ -48,10 +48,10 @@ class Issue < ActiveRecord::Base
|
|
48
48
|
|
49
49
|
# Mark issue as started
|
50
50
|
def mark_started!; self.status = 0 end
|
51
|
-
|
51
|
+
|
52
52
|
# Mark the issue as working
|
53
53
|
def mark_working!; self.status = 1 end
|
54
|
-
|
54
|
+
|
55
55
|
# Mark the issue as finished
|
56
56
|
def mark_finished!; self.status = 2 end
|
57
57
|
|
@@ -63,23 +63,48 @@ class Issue < ActiveRecord::Base
|
|
63
63
|
|
64
64
|
private
|
65
65
|
Statuses = {
|
66
|
-
StatusNew => "new",
|
67
|
-
StatusStarted => "started work",
|
68
|
-
StatusFinished => "finished",
|
66
|
+
StatusNew => "new",
|
67
|
+
StatusStarted => "started work",
|
68
|
+
StatusFinished => "finished",
|
69
69
|
StatusArchived => "archived"}
|
70
70
|
|
71
71
|
# Stringify attachments for terminal output
|
72
72
|
def attachments_s
|
73
73
|
str = ''
|
74
|
-
self.attachments.each do |att|
|
74
|
+
self.attachments.each do |att|
|
75
75
|
str.concat(att.to_s)
|
76
76
|
end
|
77
77
|
str = @strmaker.red(" N/A#{$/}") if str == '' # no attachments
|
78
78
|
str.concat($/)
|
79
79
|
str end
|
80
80
|
|
81
|
+
# TODO might need factoring out
|
82
|
+
# Will make a string of the due date, and append the days that remain. On
|
83
|
+
# dates before the due date, you get things like '+5 days'. Past due dates will
|
84
|
+
# render '-5 days'
|
85
|
+
# @return a string containing the number of days that remain
|
86
|
+
def make_remaining_days_s
|
87
|
+
days = (due_date.to_date - Time.now.to_date).to_i
|
88
|
+
days_s = "[#{days} day#{days == 1 ? '' : 's'}]"
|
89
|
+
make_colored_num_s(days, days_s)
|
90
|
+
end
|
91
|
+
|
92
|
+
# TODO might need factoring out
|
93
|
+
# Depending on the number range we color things. Uses the strmaker, so
|
94
|
+
# terminals with no ansi support will not see anything funky :(
|
95
|
+
# @return yellow stringified number if 1 <= x <= 3, green for more, red for
|
96
|
+
# less
|
97
|
+
def make_colored_num_s(num, num_s)
|
98
|
+
if num >= 1 && num <= 3
|
99
|
+
@strmaker.yellow(num_s)
|
100
|
+
elsif num < 1
|
101
|
+
@strmaker.red(num_s)
|
102
|
+
else
|
103
|
+
@strmaker.green(num_s)
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
81
107
|
private_class_method
|
82
108
|
|
83
109
|
end # class Issue
|
84
110
|
end # module Wlog
|
85
|
-
|
@@ -15,7 +15,7 @@ class KeyValue < ActiveRecord::Base
|
|
15
15
|
def self.put!(key, value)
|
16
16
|
if ret = KeyValue.find_by_key(key)
|
17
17
|
ret.value = value
|
18
|
-
else
|
18
|
+
else
|
19
19
|
ret = KeyValue.new(:key => key, :value => value)
|
20
20
|
end
|
21
21
|
ret.save
|
@@ -29,6 +29,5 @@ class KeyValue < ActiveRecord::Base
|
|
29
29
|
end
|
30
30
|
|
31
31
|
private
|
32
|
-
end
|
32
|
+
end
|
33
33
|
end # module Wlog
|
34
|
-
|
@@ -2,24 +2,16 @@ require 'active_record'
|
|
2
2
|
|
3
3
|
require 'wlog/domain/helpers'
|
4
4
|
require 'wlog/domain/attachment'
|
5
|
+
require 'wlog/tech/text_filters'
|
5
6
|
|
6
7
|
module Wlog
|
7
|
-
# Author :: Simon Symeonidis
|
8
|
+
# Author :: Simon Symeonidis
|
8
9
|
# Active Record Domain object for a log entry
|
9
10
|
class LogEntry < ActiveRecord::Base
|
11
|
+
include TextFilters
|
10
12
|
|
11
13
|
belongs_to :issue
|
12
14
|
|
13
|
-
# Search by string to find a matching description with 'LIKE'.
|
14
|
-
# def self.search_descriptions(db, term)
|
15
|
-
# all = Array.new
|
16
|
-
# db.execute(SelectDescriptionLike,"%#{term}%").each do |row|
|
17
|
-
# le = LogEntry.new
|
18
|
-
# le.quick_assign!(row[0], row[1], Time.at(row[2]))
|
19
|
-
# all.push le
|
20
|
-
# end
|
21
|
-
# all end
|
22
|
-
|
23
15
|
# Print things nicely formmated no more than 80 cars (well, unless you stick
|
24
16
|
# the time in the end which is not counted for).
|
25
17
|
def to_s
|
@@ -29,9 +21,9 @@ class LogEntry < ActiveRecord::Base
|
|
29
21
|
indent = " " * (id.to_s.split('').count + 5)
|
30
22
|
desc.gsub!(/#{$/}/, "#{$/}#{indent}")
|
31
23
|
str.concat(desc)
|
32
|
-
|
24
|
+
highlight_hyperlink_s(str)
|
25
|
+
end
|
33
26
|
|
34
27
|
private
|
35
28
|
end
|
36
29
|
end # module Wlog
|
37
|
-
|
@@ -3,37 +3,36 @@ module Wlog
|
|
3
3
|
#
|
4
4
|
# Please follow the convention that if vars are dirs, then they end with '/'
|
5
5
|
#
|
6
|
-
# @author Simon Symeonidis
|
7
|
-
module StaticConfigurations
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
# Absolute path to the configuration directory
|
12
|
-
ConfigDirectory = "#{ENV['HOME']}/.config/"
|
6
|
+
# @author Simon Symeonidis
|
7
|
+
module StaticConfigurations
|
8
|
+
# The application name
|
9
|
+
AppName = "wlog"
|
13
10
|
|
14
|
-
|
15
|
-
|
11
|
+
# Absolute path to the configuration directory
|
12
|
+
ConfigDirectory = "#{ENV['HOME']}/.config/"
|
16
13
|
|
17
|
-
|
18
|
-
|
14
|
+
# Absolute path to the application directory
|
15
|
+
AppDirectory = "#{ConfigDirectory}#{AppName}/"
|
19
16
|
|
20
|
-
|
21
|
-
|
17
|
+
# Absolute path to the data directory
|
18
|
+
DataDirectory = "#{AppDirectory}data/"
|
22
19
|
|
23
|
-
|
24
|
-
|
20
|
+
# Default database name (when unspecified)
|
21
|
+
DefaultDb = "#{ARGV[0] || 'default'}"
|
25
22
|
|
26
|
-
|
27
|
-
|
23
|
+
# Where the template files exist
|
24
|
+
TemplateDir = "#{AppDirectory}templates/"
|
28
25
|
|
29
|
-
|
30
|
-
|
26
|
+
# Sample file to provide the user with
|
27
|
+
TemplateSampleFile = "#{TemplateDir}/default.erb"
|
31
28
|
|
32
|
-
|
33
|
-
|
29
|
+
# In the future if someone wants to code an alternative, go ahead
|
30
|
+
TemplateOutputDir = "#{ENV['HOME']}/Documents/wlog/#{DefaultDb}/"
|
34
31
|
|
35
|
-
|
36
|
-
|
37
|
-
end
|
38
|
-
end # module Wlog
|
32
|
+
# This is used to see if it is the first setup or not
|
33
|
+
TaintFile = "#{AppDirectory}tainted"
|
39
34
|
|
35
|
+
# The configuration file
|
36
|
+
ConfigFile = "#{AppDirectory}config"
|
37
|
+
end
|
38
|
+
end # module Wlog
|