Skip to content

Commit

Permalink
Added statistic
Browse files Browse the repository at this point in the history
  • Loading branch information
Bubujka committed Apr 15, 2012
1 parent ccf41d1 commit 1a01d96
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 15 deletions.
1 change: 1 addition & 0 deletions cards
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ require "fileutils.rb"
require "lib/def.rb"
require "lib/bind.rb"
require "lib/flash.rb"
require "lib/statistic.rb"

Dir.glob(File.dirname(__FILE__) + '/commands/*', &method(:require))

Expand Down
9 changes: 9 additions & 0 deletions cards_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ def rc what
cfg[what.to_s]
end

def to_yaml what
what.ya2yaml(:syck_compatible => true)
end

def clear
print `clear`
end
Expand Down Expand Up @@ -202,6 +206,7 @@ def random_file_in dir

def goto_file_mode file
clear
stats "File watch"
show_current_file_line file
default_file_action file
do_what_i_say_in_file file
Expand Down Expand Up @@ -283,3 +288,7 @@ def move_to_home file, dir, save_struct = false
end
rnd_file_in_dir dirname(file)
end

def today_date
Time.new.strftime("%Y-%m-%d")
end
27 changes: 14 additions & 13 deletions commands/file.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@

doc "Удалить файл и перейти к случайному"
file_cmd :rm_file_and_go_rnd do |file|
stats "File deleted"
flash_s "Deleted: #{file.green}"
File::unlink(file)
if !files_in_pth(dir = File.dirname(file)).empty?
Expand All @@ -60,6 +61,7 @@

doc "Отредактировать файл в редакторе"
file_cmd :edit_file do |file|
stats "File editing"
system editor, file
goto_file_mode file
end
Expand All @@ -74,6 +76,7 @@
dir = dirname(file)
clear
if dest = dmenu(dirs_in_pth(dir))
stats "File moving"
mv_to_dir(file, t = fjoin(dir, dest))
flash_s "File #{file.green} moved to #{t.green}"
if rnd = random_file_in(dir)
Expand All @@ -89,6 +92,7 @@
dir = home_dir
clear
if dest = dmenu(dirs_in_pth(dir))
stats "File moving"
mv_to_dir(file, t = fjoin(dir, dest))
flash_s "File #{file.green} moved to #{t.green}"
if rnd = random_file_in(dirname(file))
Expand All @@ -104,6 +108,7 @@
dir = fjoin(dirname(file), '..').ex
clear
if dest = dmenu(dirs_in_pth(dir))
stats "File moving"
mv_to_dir(file, t = fjoin(dir, dest))
flash_s "File #{file.green} moved to #{t.green}"
if rnd = random_file_in(dirname(file))
Expand All @@ -123,23 +128,16 @@
rnd_file_in_dir dir
end


file_cmd :move_to_complete do |file|
move_to file, 'complete'
end

file_cmd :move_to_done do |file|
move_to file, 'done'
end

doc "Перенести файл в папку later"
file_cmd :move_to_later do |file|
stats "File moved to later"
move_to file, 'later'
end

doc "Перенести файл в папку stash
Временное хранилище на период разбора заданий"
file_cmd :stash_task do |file|
stats "File stashed"
move_to file, 'stash'
end

Expand Down Expand Up @@ -172,6 +170,7 @@
print "Write (enter for abort): ".green
txt = gets.chomp
return if txt.empty?
stats "File editing"
w_file file, txt
goto_file_mode file
end
Expand All @@ -195,22 +194,24 @@
Сохраняя структуру каталогов
Добавляя дату переноса"
file_cmd :move_file_to_home_hidden_later do |file|
stats "File moved to later"
file.add_date
move_to_home file, '.later', true
end

doc "Перенести файл в каталог проектов home_dir()/.complete/dir
Сохраняя структуру каталогов
doc "Перенести файл в каталог .complete
Добавляя дату переноса"
file_cmd :move_file_to_home_hidden_complete do |file|
file_cmd :move_file_to_hidden_complete do |file|
stats "File moved to complete"
file.add_date
move_to_home file, '.complete', true
move_to file, '.complete'
end

doc "Перенести файл в каталог проектов home_dir()/_waiting/dir
Сохраняя структуру каталогов
Добавляя дату переноса"
file_cmd :move_file_to_home_waiting do |file|
stats "File moved to waiting"
file.add_date
move_to_home file, '_waiting', true
end
1 change: 1 addition & 0 deletions commands/global.rb
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@
if mode == :file
ext = File.extname(pth)
if(['.mp3', '.MP3', '.wav', '.WAV'].include? ext)
stats "Listening audio file"
play_sound_file pth
end
end
Expand Down
14 changes: 14 additions & 0 deletions lib/statistic.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
def statistic_dir
rc(:statistic_dir).ex
end

def stats what
unless File.exists?(statistic_dir)
FileUtils.mkdir_p statistic_dir
end

file = statistic_dir.fj(what)
File.open(file, 'a+') do |f|
f.write(Time.now.to_f.to_s + "\n")
end
end
4 changes: 2 additions & 2 deletions rc.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
default_dir: ~/gtd
statistic_dir: ~/.buc-statistic
hide_empty_dirs: true
hide_dotted_dirs: true
hide_dotted_files: true
Expand Down Expand Up @@ -57,8 +58,7 @@ bind:
'C-l': move_file_to_home_hidden_later
w: move_to_waiting
'C-w': move_file_to_home_waiting
c: move_to_complete
"C-c": move_file_to_home_hidden_complete
"C-c": move_file_to_hidden_complete
B: run_content_in_browser
s: stash_task
S: unstash_tasks
Expand Down

0 comments on commit 1a01d96

Please sign in to comment.