wloger 0.0.1 → 0.0.3
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 +9 -1
- data/bin/wloger +1 -1
- data/lib/wloger/command.rb +26 -11
- data/lib/wloger/directory.rb +29 -0
- data/lib/wloger/editor.rb +19 -2
- data/lib/wloger/error.rb +11 -0
- data/lib/wloger/version.rb +1 -1
- data/lib/wloger.rb +2 -1
- data/wloger.gemspec +2 -0
- metadata +18 -3
- data/lib/wloger/directory_controller.rb +0 -22
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a9e55339d9a3945f46dd637ac5c513f602f4a637
|
4
|
+
data.tar.gz: ef2873cf6fb6e8f3892f4dde4a5dcb95bf9ac612
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 72b5cf7ca409766925c83a2ac8648bca896b8686ac1a853ff283467a2ba4f6366fd10980836a0578c652d0c94786fef4c4174ba4e19e67847aff8b43cbf69531
|
7
|
+
data.tar.gz: 17c643dd68ae5c6426466c41a06f4de41be1112cdf287699cf02132dcd741f654c59be9abac9fdbbb37836fc031f9a96a43e7fd87635c1d4d4b3cd11f408bede
|
data/README.md
CHANGED
@@ -13,8 +13,16 @@ Install it yourself as:
|
|
13
13
|
If you log today, execute following command.
|
14
14
|
|
15
15
|
$ wloger
|
16
|
+
# Wloger will execute "vim ~/Documents/work_log/{THIS_YEAR}_{THIS_MONTH}/{TODAY}/log.md"
|
16
17
|
|
17
|
-
Wloger make log directory
|
18
|
+
Wloger make today log directory, and execute editor!!
|
19
|
+
|
20
|
+
If you want to view past log, execute following command.
|
21
|
+
|
22
|
+
$ wloger {DATE}
|
23
|
+
# Wloger will execute "vim ~/Documents/work_log/{THE_YEAR}_{THE_MONTH}/{THE_DAY}/log.md"
|
24
|
+
|
25
|
+
Wloger accepts YY/MM/DD, MM/DD, or DD for DATE argument format.
|
18
26
|
|
19
27
|
## TODO
|
20
28
|
|
data/bin/wloger
CHANGED
data/lib/wloger/command.rb
CHANGED
@@ -1,20 +1,35 @@
|
|
1
1
|
require 'date'
|
2
|
+
require 'thor'
|
2
3
|
|
3
4
|
module Wloger
|
4
5
|
# Command line parse class
|
5
|
-
class Command
|
6
|
-
|
7
|
-
def execute(*args)
|
8
|
-
# argument parse
|
9
|
-
date = Date.parse(args.first) unless args.first.nil?
|
10
|
-
date ||= Date.today
|
6
|
+
class Command < Thor
|
7
|
+
default_command :today_log
|
11
8
|
|
12
|
-
|
13
|
-
|
9
|
+
desc 'today_log', 'Edit a today work-log file.'
|
10
|
+
def today_log
|
11
|
+
@directory = Wloger::Directory.new(Date.today)
|
12
|
+
@editor = Wloger::Editor.new(@directory.path)
|
14
13
|
|
15
|
-
|
16
|
-
|
17
|
-
|
14
|
+
@directory.make_today
|
15
|
+
@directory.remove_today unless @editor.edit
|
16
|
+
end
|
17
|
+
|
18
|
+
desc '[DATE]', 'Open the work-log file assigned DATE.'
|
19
|
+
def method_missing(method)
|
20
|
+
date = Date.parse(method.to_s.rjust(2, '0'))
|
21
|
+
past_log(date)
|
22
|
+
rescue ArgumentError
|
23
|
+
help
|
24
|
+
end
|
25
|
+
|
26
|
+
private
|
27
|
+
|
28
|
+
def past_log(date)
|
29
|
+
@directory = Wloger::Directory.new(date)
|
30
|
+
@editor = Wloger::Editor.new(@directory.path)
|
31
|
+
|
32
|
+
Wloger::Error.no_log_file unless @editor.view
|
18
33
|
end
|
19
34
|
end
|
20
35
|
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'fileutils'
|
2
|
+
|
3
|
+
module Wloger
|
4
|
+
# control work-log directories and current directory class
|
5
|
+
class Directory
|
6
|
+
LOG_DIR_NAME = 'work_log'.freeze
|
7
|
+
PARENT_LOG_DIR = 'Documents'.freeze
|
8
|
+
|
9
|
+
attr_accessor :path
|
10
|
+
|
11
|
+
def initialize(date)
|
12
|
+
@path = File.expand_path("~/#{PARENT_LOG_DIR}/#{LOG_DIR_NAME}/#{date.strftime('%Y_%b/%d')}")
|
13
|
+
end
|
14
|
+
|
15
|
+
# recursively make today work-log directory
|
16
|
+
def make_today
|
17
|
+
FileUtils.mkdir_p(@path) unless Dir.exist?(@path)
|
18
|
+
end
|
19
|
+
|
20
|
+
# recursively remove today directory if empty
|
21
|
+
def remove_today
|
22
|
+
while Dir.entries(@path).join == '...'
|
23
|
+
break if File.basename(@path) == LOG_DIR_NAME
|
24
|
+
Dir.rmdir(@path)
|
25
|
+
@path = File.dirname(@path)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
data/lib/wloger/editor.rb
CHANGED
@@ -2,10 +2,27 @@ module Wloger
|
|
2
2
|
# using editor for work-log class
|
3
3
|
class Editor
|
4
4
|
EDITOR_NAME = 'vim'.freeze
|
5
|
+
LOG_NAME = 'log'.freeze
|
5
6
|
EXTENTION = 'md'.freeze
|
6
7
|
|
7
|
-
def
|
8
|
-
|
8
|
+
def initialize(log_path)
|
9
|
+
@file_path = "#{log_path}/#{LOG_NAME}.#{EXTENTION}"
|
10
|
+
end
|
11
|
+
|
12
|
+
def edit
|
13
|
+
system("#{EDITOR_NAME} #{@file_path}")
|
14
|
+
log_exist?
|
15
|
+
end
|
16
|
+
|
17
|
+
def view
|
18
|
+
return unless log_exist?
|
19
|
+
system("#{EDITOR_NAME} #{@file_path}")
|
20
|
+
end
|
21
|
+
|
22
|
+
private
|
23
|
+
|
24
|
+
def log_exist?
|
25
|
+
File.exist?(@file_path)
|
9
26
|
end
|
10
27
|
end
|
11
28
|
end
|
data/lib/wloger/error.rb
ADDED
data/lib/wloger/version.rb
CHANGED
data/lib/wloger.rb
CHANGED
data/wloger.gemspec
CHANGED
@@ -18,6 +18,8 @@ Gem::Specification.new do |spec|
|
|
18
18
|
spec.test_files = spec.files.grep(/^(test|spec|features)\//)
|
19
19
|
spec.require_paths = ['lib']
|
20
20
|
|
21
|
+
spec.add_dependency 'thor'
|
22
|
+
|
21
23
|
spec.add_development_dependency 'bundler', '~> 1.6'
|
22
24
|
spec.add_development_dependency 'rake'
|
23
25
|
spec.add_development_dependency 'pry'
|
metadata
CHANGED
@@ -1,15 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: wloger
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- huyu398
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-05-
|
11
|
+
date: 2014-05-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: thor
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
13
27
|
- !ruby/object:Gem::Dependency
|
14
28
|
name: bundler
|
15
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -69,8 +83,9 @@ files:
|
|
69
83
|
- bin/wloger
|
70
84
|
- lib/wloger.rb
|
71
85
|
- lib/wloger/command.rb
|
72
|
-
- lib/wloger/
|
86
|
+
- lib/wloger/directory.rb
|
73
87
|
- lib/wloger/editor.rb
|
88
|
+
- lib/wloger/error.rb
|
74
89
|
- lib/wloger/version.rb
|
75
90
|
- wloger.gemspec
|
76
91
|
homepage: https://github.com/huyu398/wloger
|
@@ -1,22 +0,0 @@
|
|
1
|
-
require 'fileutils'
|
2
|
-
|
3
|
-
module Wloger
|
4
|
-
# control work-log directories and current directory class
|
5
|
-
class DirectoryController
|
6
|
-
LOG_DIR_NAME = 'work_log'.freeze
|
7
|
-
PARENT_LOG_DIR = 'Documents'.freeze
|
8
|
-
|
9
|
-
attr_accessor :log_dir
|
10
|
-
attr_accessor :log_name
|
11
|
-
|
12
|
-
def initialize(date)
|
13
|
-
@log_dir = File.expand_path("~/#{PARENT_LOG_DIR}/#{LOG_DIR_NAME}/#{date.strftime('%Y_%b/%d')}")
|
14
|
-
@log_name = date.strftime('%d')
|
15
|
-
end
|
16
|
-
|
17
|
-
# recursively make work-log directory of today
|
18
|
-
def make_today_directory
|
19
|
-
FileUtils.mkdir_p(@log_dir) unless Dir.exist?(@log_dir)
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|