Skip to content

Commit

Permalink
invoice_ui: fix minor merge conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
psyomn committed Oct 20, 2014
2 parents 66fd14d + 3d69745 commit dbadcd6
Showing 1 changed file with 31 additions and 22 deletions.
53 changes: 31 additions & 22 deletions lib/wlog/ui/invoice_ui.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
require 'readline'
require 'tempfile'
require 'wlog/domain/invoice'
require 'wlog/domain/sys_config'
require 'wlog/domain/static_configurations'
Expand Down Expand Up @@ -33,7 +34,7 @@ def run
when /^commits/ then commits(cmd.split.drop 1)
when 'help' then print_help
when /^end/ then next
else
else
puts "type 'help' for a list of options"
end
end
Expand All @@ -57,7 +58,6 @@ def generate(rest)
@log_entries = @invoice.log_entries_within_dates
@issues = [Issue.find(*(@log_entries.collect(&:issue_id).uniq))].compact.flatten


renderer = ERB.new(TemplateHelper.template_s)
output = renderer.result(binding)

Expand All @@ -72,13 +72,13 @@ def generate(rest)
def delete(rest)
id = rest[0]
cmd = Readline.readline("Are you sure you want to delete invoice ##{id}? [y/n]: ")
return if cmd != 'y'
return if cmd != 'y'
Invoice.delete(id)
end

def ls
Invoice.all.each do |invoice|
print " [#{invoice.id}] "
print " [#{invoice.id}] "
print @strmaker.yellow(invoice.from.strftime("%d-%m-%Y"))
print @strmaker.blue(" -> ")
print @strmaker.yellow(invoice.to.strftime("%d-%m-%Y"))
Expand All @@ -92,7 +92,7 @@ def print_help
'delete', 'delete an invoice (eg: delete 2)',
'generate', 'generate an invoice using set template (eg: generate 2)'
].each_with_index do |cmd,ix|
print ' ' if ix % 2 == 1
print ' ' if ix % 2 == 1
puts cmd
end
end
Expand All @@ -112,27 +112,36 @@ def make_invoice
# TODO: this would have to be factored out at some point. Also I think the
# implementation is crappy. I have to recheck at some point.
def longtext
count = 0
status = nil
str = ""

until status == :end_text do
line = Readline.readline(@strmaker.blue('> ')).strip
count += 1 if line == ""
count = 0 if line != ""

str.concat(line).concat($/)

status = :end_text and next if count == 2
end
str end
if ENV['EDITOR'].nil?
count = 0
status = nil
str = ""

until status == :end_text do
line = Readline.readline(@strmaker.blue('> ')).strip
count += 1 if line == ""
count = 0 if line != ""

str.concat(line).concat($/)

status = :end_text and next if count == 2
end
else
t = Tempfile.new('description')
system(ENV['EDITOR'] + ' ' + t.path)
str = File.open(t.path).read
t.unlink
end

str
end

def commits(invoice_id)
inv = Invoice.find_by_id(invoice_id)
inv = Invoice.find_by_id(invoice_id)
repo = KeyValue.get('git')
author = KeyValue.get('author')

unless repo
unless repo
puts @strmaker.red("You need to set a git repo first")
return
end
Expand All @@ -145,7 +154,7 @@ def commits(invoice_id)
puts "git commits for #{@strmaker.yellow(author)}"
puts
print_git_commits(command.commits)

rescue ActiveRecord::RecordNotFound
puts @strmaker.red("No such invoice")
end
Expand Down

0 comments on commit dbadcd6

Please sign in to comment.