wlog 1.2.1 → 1.2.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (58) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +14 -0
  3. data/bin/wlog +1 -2
  4. data/lib/wlog/commands/bootstrap_templates.rb +1 -1
  5. data/lib/wlog/commands/concat_description.rb +0 -1
  6. data/lib/wlog/commands/create_issue.rb +1 -1
  7. data/lib/wlog/commands/delete_attachment.rb +0 -1
  8. data/lib/wlog/commands/delete_issue.rb +1 -2
  9. data/lib/wlog/commands/fetch_git_commits.rb +5 -4
  10. data/lib/wlog/commands/fetch_git_commits_standard.rb +0 -1
  11. data/lib/wlog/commands/innit_db.rb +4 -5
  12. data/lib/wlog/commands/make_csv.rb +0 -1
  13. data/lib/wlog/commands/new_entry.rb +2 -2
  14. data/lib/wlog/commands/replace_pattern.rb +0 -1
  15. data/lib/wlog/commands/taint_setup.rb +0 -1
  16. data/lib/wlog/domain.rb +0 -1
  17. data/lib/wlog/domain/attachment.rb +1 -1
  18. data/lib/wlog/domain/git_commit.rb +1 -1
  19. data/lib/wlog/domain/helpers.rb +4 -5
  20. data/lib/wlog/domain/invoice.rb +1 -1
  21. data/lib/wlog/domain/issue.rb +35 -10
  22. data/lib/wlog/domain/key_value.rb +2 -3
  23. data/lib/wlog/domain/log_entry.rb +5 -13
  24. data/lib/wlog/domain/static_configurations.rb +24 -25
  25. data/lib/wlog/domain/sys_config.rb +2 -3
  26. data/lib/wlog/domain/template_helper.rb +2 -2
  27. data/lib/wlog/domain/timelog_helper.rb +1 -1
  28. data/lib/wlog/migrations/make_standard_tables.rb +4 -5
  29. data/lib/wlog/tech/ansi_colors.rb +0 -1
  30. data/lib/wlog/tech/git_commit_parser.rb +14 -14
  31. data/lib/wlog/tech/git_commit_printer.rb +4 -4
  32. data/lib/wlog/tech/text_filters.rb +20 -0
  33. data/lib/wlog/tech/uncolored_string.rb +1 -1
  34. data/lib/wlog/tech/wlog_string.rb +1 -1
  35. data/lib/wlog/ui/bootstrap.rb +1 -2
  36. data/lib/wlog/ui/cli_interface.rb +12 -12
  37. data/lib/wlog/ui/configuration_ui.rb +5 -6
  38. data/lib/wlog/ui/edit_handler.rb +6 -6
  39. data/lib/wlog/ui/git_ui.rb +29 -16
  40. data/lib/wlog/ui/invoice_ui.rb +41 -27
  41. data/lib/wlog/ui/issue_ui.rb +29 -26
  42. data/lib/wlog/ui/setup_wizard.rb +4 -2
  43. data/lib/wlog/ui/template_ui.rb +1 -2
  44. data/lib/wlog/version.rb +1 -1
  45. data/spec/domain/attachment_spec.rb +8 -8
  46. data/spec/domain/commands/concat_desc_spec.rb +2 -2
  47. data/spec/domain/commands/new_entry_spec.rb +2 -2
  48. data/spec/domain/commands/replace_pattern_spec.rb +0 -1
  49. data/spec/domain/git_commits_spec.rb +11 -11
  50. data/spec/domain/invoice_spec.rb +5 -6
  51. data/spec/domain/issue_spec.rb +8 -9
  52. data/spec/domain/key_value_spec.rb +3 -4
  53. data/spec/domain/log_entry_spec.rb +6 -7
  54. data/spec/make_db.rb +1 -2
  55. data/spec/spec_helper.rb +4 -5
  56. data/spec/tech/text_filters_spec.rb +54 -0
  57. data/spec/tech/uncolored_string.rb +1 -1
  58. metadata +6 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3b8af4a4bdef4d942ce3e0da56440ffd9e633c54
4
- data.tar.gz: b3a0dc959da2586fb2b2b511ee729f5b262f61de
3
+ metadata.gz: 4035a8ebc932e0bd3fafca18b8cee1d071370f2d
4
+ data.tar.gz: db684be23ea24718cd088fe9266681e1ba7a5633
5
5
  SHA512:
6
- metadata.gz: d8212057e50030e791c0dddef5a35df96a44f80cefd96cacb095d13de12eba0c7daa3d0697a1f8deae287cc7ddc3844952302e9679d0f244ceb8c2af3474a1f6
7
- data.tar.gz: 589a124eb21948703d5cd9847c2901f2586d38ca4cc627d62f79efd8462f82d98c0f2cefc9c708b6f8e9c74987b251adadab3d5230126347ad4aa01704218749
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
@@ -6,7 +6,7 @@ require 'wlog/ui/bootstrap'
6
6
  require 'wlog/ui/cli_interface'
7
7
 
8
8
  include Wlog
9
-
9
+
10
10
  if ARGV.size > 0
11
11
  case ARGV[0]
12
12
  when "--list"
@@ -29,4 +29,3 @@ else
29
29
  Bootstrap.configure!
30
30
  CliInterface.new.run
31
31
  end
32
-
@@ -22,7 +22,7 @@ class BootstrapTemplates < Commandable
22
22
 
23
23
  private
24
24
 
25
- # Write a default template
25
+ # Write a default template
26
26
  def write_default_template!
27
27
  fh = File.open(TemplateSampleFile, 'w')
28
28
  data = "A list of issues:
@@ -20,4 +20,3 @@ class ConcatDescription < Commandable
20
20
  attr_reader :id, :str
21
21
  end
22
22
  end # end Wlog module
23
-
@@ -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
@@ -14,4 +14,3 @@ class DeleteAttachment < Commandable
14
14
  private
15
15
  end
16
16
  end
17
-
@@ -19,7 +19,7 @@ class DeleteIssue
19
19
  @deleted = true
20
20
  end
21
21
  rescue ActiveRecord::RecordNotFound
22
- @deleted = false
22
+ @deleted = false
23
23
  end
24
24
 
25
25
  def deleted?
@@ -29,4 +29,3 @@ class DeleteIssue
29
29
  attr :deleted
30
30
  end
31
31
  end
32
-
@@ -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=\"#{@from}\" ")
39
- base.concat("--until=\"#{@to}\" ")
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
-
@@ -26,4 +26,3 @@ class FetchGitCommitsStandard < Commandable
26
26
  attr_accessor :commits
27
27
  end
28
28
  end
29
-
@@ -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 = ARGV[0] || DefaultDb
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
-
@@ -23,4 +23,3 @@ class MakeCsv < Commandable
23
23
  attr_accessor :ret
24
24
  end
25
25
  end
26
-
@@ -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
 
@@ -18,4 +18,3 @@ class ReplacePattern < Commandable
18
18
  end
19
19
  end
20
20
  end
21
-
@@ -15,4 +15,3 @@ class TaintSetup
15
15
  end
16
16
  end
17
17
  end
18
-
@@ -10,4 +10,3 @@ require 'wlog/domain/static_configurations.rb'
10
10
  require 'wlog/domain/sys_config.rb'
11
11
  require 'wlog/domain/template_engine.rb'
12
12
  require 'wlog/domain/timelog_helper.rb'
13
-
@@ -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
-
@@ -1,7 +1,7 @@
1
1
  module Wlog
2
2
  # A git commit message
3
3
  # @author Simon Symeonidis
4
- class GitCommit
4
+ class GitCommit
5
5
  def initialize
6
6
  @commit = @author = @shortlog = @message = ""
7
7
  end
@@ -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.database_exits?
30
- File.exists? "#{DataDirectory}#{ARGV[0] || DefaultDb}"
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
-
@@ -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
@@ -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
- str end
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
- # The application name
9
- AppName = "wlog"
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
- # Absolute path to the application directory
15
- AppDirectory = "#{ConfigDirectory}#{AppName}/"
11
+ # Absolute path to the configuration directory
12
+ ConfigDirectory = "#{ENV['HOME']}/.config/"
16
13
 
17
- # Absolute path to the data directory
18
- DataDirectory = "#{AppDirectory}data/"
14
+ # Absolute path to the application directory
15
+ AppDirectory = "#{ConfigDirectory}#{AppName}/"
19
16
 
20
- # Where the template files exist
21
- TemplateDir = "#{AppDirectory}templates/"
17
+ # Absolute path to the data directory
18
+ DataDirectory = "#{AppDirectory}data/"
22
19
 
23
- # Sample file to provide the user with
24
- TemplateSampleFile = "#{TemplateDir}/default.erb"
20
+ # Default database name (when unspecified)
21
+ DefaultDb = "#{ARGV[0] || 'default'}"
25
22
 
26
- # In the future if someone wants to code an alternative, go ahead
27
- TemplateOutputDir = "#{ENV['HOME']}/Documents/wlog/"
23
+ # Where the template files exist
24
+ TemplateDir = "#{AppDirectory}templates/"
28
25
 
29
- # Default database name (when unspecified)
30
- DefaultDb = "default"
26
+ # Sample file to provide the user with
27
+ TemplateSampleFile = "#{TemplateDir}/default.erb"
31
28
 
32
- # This is used to see if it is the first setup or not
33
- TaintFile = "#{AppDirectory}tainted"
29
+ # In the future if someone wants to code an alternative, go ahead
30
+ TemplateOutputDir = "#{ENV['HOME']}/Documents/wlog/#{DefaultDb}/"
34
31
 
35
- # The configuration file
36
- ConfigFile = "#{AppDirectory}config"
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