wloger 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rspec +2 -0
- data/Gemfile +11 -0
- data/Guardfile +24 -0
- data/README.md +9 -3
- data/lib/wloger/command.rb +17 -17
- data/lib/wloger/error.rb +2 -2
- data/lib/wloger/log_file.rb +16 -0
- data/lib/wloger/past_log_file.rb +10 -0
- data/lib/wloger/today_log_file.rb +30 -0
- data/lib/wloger/version.rb +1 -1
- data/lib/wloger.rb +3 -2
- data/spec/lib/wloger/directory_spec.rb +53 -0
- data/spec/lib/wloger_spec.rb +7 -0
- data/spec/spec_helper.rb +19 -0
- data/wloger.gemspec +1 -0
- metadata +40 -17
- data/lib/wloger/directory.rb +0 -29
- data/lib/wloger/editor.rb +0 -28
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cc6571a6d7d733aa2a9489941b1f49e025c4128f
|
4
|
+
data.tar.gz: f6562c4cf030117b1f5289198e3eaa66d7e8a8cc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: feb4265e6ffbfe804613e6320391d29cb15e0e3fe96268d5da62f40ca6fef885b7b8d9d140f95d1a0407f573394132ac48c4ec090ed4a4fed088aca4f5ffbe64
|
7
|
+
data.tar.gz: d53312dad2c9e2e8b8cd87aba89c5312a65fb1cf7a9c1c34c484de044f23cd4e4064389c7e9fff72718ab2010275b4b4d023c99b6efc9b62be54967d3f080b65
|
data/.rspec
ADDED
data/Gemfile
CHANGED
@@ -1,4 +1,15 @@
|
|
1
1
|
source 'https://rubygems.org'
|
2
2
|
|
3
|
+
gem 'rake', '>= 0.9'
|
4
|
+
gem 'rdoc', '>= 3.9'
|
5
|
+
gem 'thor', '>= 0.19.1'
|
6
|
+
|
7
|
+
group :development do
|
8
|
+
gem 'guard', '>= 2.6.1'
|
9
|
+
gem 'guard-rspec', '>= 4.2.9'
|
10
|
+
gem 'pry', '>= 0.9.12.6'
|
11
|
+
gem 'rspec', '>= 2.14'
|
12
|
+
end
|
13
|
+
|
3
14
|
# Specify your gem's dependencies in wloger.gemspec
|
4
15
|
gemspec
|
data/Guardfile
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
# A sample Guardfile
|
2
|
+
# More info at https://github.com/guard/guard#readme
|
3
|
+
|
4
|
+
guard :rspec do
|
5
|
+
watch(%r{^spec/.+_spec\.rb$})
|
6
|
+
watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
|
7
|
+
watch('spec/spec_helper.rb') { "spec" }
|
8
|
+
|
9
|
+
# Rails example
|
10
|
+
watch(%r{^app/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
|
11
|
+
watch(%r{^app/(.*)(\.erb|\.haml|\.slim)$}) { |m| "spec/#{m[1]}#{m[2]}_spec.rb" }
|
12
|
+
watch(%r{^app/controllers/(.+)_(controller)\.rb$}) { |m| ["spec/routing/#{m[1]}_routing_spec.rb", "spec/#{m[2]}s/#{m[1]}_#{m[2]}_spec.rb", "spec/acceptance/#{m[1]}_spec.rb"] }
|
13
|
+
watch(%r{^spec/support/(.+)\.rb$}) { "spec" }
|
14
|
+
watch('config/routes.rb') { "spec/routing" }
|
15
|
+
watch('app/controllers/application_controller.rb') { "spec/controllers" }
|
16
|
+
|
17
|
+
# Capybara features specs
|
18
|
+
watch(%r{^app/views/(.+)/.*\.(erb|haml|slim)$}) { |m| "spec/features/#{m[1]}_spec.rb" }
|
19
|
+
|
20
|
+
# Turnip features and steps
|
21
|
+
watch(%r{^spec/acceptance/(.+)\.feature$})
|
22
|
+
watch(%r{^spec/acceptance/steps/(.+)_steps\.rb$}) { |m| Dir[File.join("**/#{m[1]}.feature")][0] || 'spec/acceptance' }
|
23
|
+
end
|
24
|
+
|
data/README.md
CHANGED
@@ -1,7 +1,10 @@
|
|
1
1
|
# Wloger
|
2
|
+
[![Gem Version](https://badge.fury.io/rb/wloger.svg)](http://badge.fury.io/rb/wloger)
|
2
3
|
|
3
4
|
Wloger help to manage your daily work-logs.
|
4
5
|
|
6
|
+
![demo](https://raw.github.com/wiki/huyu398/wloger/images/demo.gif)
|
7
|
+
|
5
8
|
## Installation
|
6
9
|
|
7
10
|
Install it yourself as:
|
@@ -26,9 +29,12 @@ Wloger accepts YY/MM/DD, MM/DD, or DD for DATE argument format.
|
|
26
29
|
|
27
30
|
## TODO
|
28
31
|
|
29
|
-
- [ ]
|
30
|
-
- [ ]
|
31
|
-
- [ ]
|
32
|
+
- [ ] add function of grep search in log files
|
33
|
+
- [ ] add configure to select your editor
|
34
|
+
- [ ] add configure to select your log directory
|
35
|
+
- [ ] add configure to become shallow directory nest
|
36
|
+
- [ ] able to select month directory format from name to number
|
37
|
+
- [ ] able to make log file template
|
32
38
|
|
33
39
|
## Contributing
|
34
40
|
|
data/lib/wloger/command.rb
CHANGED
@@ -6,30 +6,30 @@ module Wloger
|
|
6
6
|
class Command < Thor
|
7
7
|
default_command :today_log
|
8
8
|
|
9
|
-
desc 'today_log', 'Edit a today work-log file
|
9
|
+
desc 'today_log', 'Edit a today work-log file'
|
10
10
|
def today_log
|
11
|
-
|
12
|
-
@
|
11
|
+
date = Date.today
|
12
|
+
@today_log = Wloger::TodayLogFile.new(date)
|
13
|
+
@today_log.edit
|
13
14
|
|
14
|
-
@directory.make_today
|
15
|
-
@directory.remove_today unless @editor.edit
|
16
15
|
end
|
17
16
|
|
18
|
-
desc '
|
19
|
-
def
|
20
|
-
|
21
|
-
past_log(date)
|
22
|
-
rescue ArgumentError
|
23
|
-
help
|
17
|
+
desc 'version', 'Show the version of Wloger'
|
18
|
+
def version
|
19
|
+
puts Wloger::VERSION
|
24
20
|
end
|
21
|
+
map %w[-v --version] => :version
|
25
22
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
23
|
+
desc '[DATE]', 'Open the work-log file assigned DATE'
|
24
|
+
def method_missing(method)
|
25
|
+
begin
|
26
|
+
date = Date.parse(method.to_s.rjust(2, '0'))
|
27
|
+
rescue ArgumentError
|
28
|
+
return help
|
29
|
+
end
|
31
30
|
|
32
|
-
Wloger::
|
31
|
+
@past_log = Wloger::PastLogFile.new(date)
|
32
|
+
@past_log.view
|
33
33
|
end
|
34
34
|
end
|
35
35
|
end
|
data/lib/wloger/error.rb
CHANGED
@@ -0,0 +1,16 @@
|
|
1
|
+
module Wloger
|
2
|
+
# base object for today and past logs
|
3
|
+
class LogFile
|
4
|
+
PARENT_DIR_NAME = File.expand_path('~/Documents').freeze
|
5
|
+
DIR_NAME = 'work_log'.freeze
|
6
|
+
LOG_NAME = 'log'.freeze
|
7
|
+
LOG_EXTENTION = 'md'.freeze
|
8
|
+
EDITOR_NAME = 'vim'.freeze
|
9
|
+
|
10
|
+
def initialize(date)
|
11
|
+
@date = date
|
12
|
+
@log_dir = "#{PARENT_DIR_NAME}/#{DIR_NAME}/#{date.strftime('%Y_%m/%d')}"
|
13
|
+
@log_path = "#{@log_dir}/#{LOG_NAME}.#{LOG_EXTENTION}"
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'fileutils'
|
2
|
+
|
3
|
+
module Wloger
|
4
|
+
# today log file class
|
5
|
+
## If don't exist today dir, this class make the dir.
|
6
|
+
class TodayLogFile < LogFile
|
7
|
+
def edit
|
8
|
+
make_dir unless File.exist?(@log_dir)
|
9
|
+
system("#{EDITOR_NAME} #{@log_path}")
|
10
|
+
remove_dir unless File.exist?(@log_path)
|
11
|
+
end
|
12
|
+
|
13
|
+
private
|
14
|
+
|
15
|
+
# recursively make today work-log directory
|
16
|
+
def make_dir
|
17
|
+
FileUtils.mkdir_p(@log_dir)
|
18
|
+
end
|
19
|
+
|
20
|
+
# recursively remove today directory if empty
|
21
|
+
def remove_dir
|
22
|
+
path_tmp = @log_dir
|
23
|
+
while Dir.entries(path_tmp).join == '...'
|
24
|
+
break if File.basename(path_tmp) == DIR_NAME
|
25
|
+
Dir.rmdir(path_tmp)
|
26
|
+
path_tmp = File.dirname(path_tmp)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
data/lib/wloger/version.rb
CHANGED
data/lib/wloger.rb
CHANGED
@@ -0,0 +1,53 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'fileutils'
|
3
|
+
require 'pry'
|
4
|
+
|
5
|
+
describe 'Wloger::Directory' do
|
6
|
+
YEAR = '3050'
|
7
|
+
MONTH = '06'
|
8
|
+
DAY = '08'
|
9
|
+
DATE = [YEAR, MONTH, DAY].join('/')
|
10
|
+
|
11
|
+
context "if today is #{DATE}" do
|
12
|
+
before :all do
|
13
|
+
@logs_saved_dir = File.expand_path("~/#{Wloger::Directory::PARENT_LOG_DIR}/#{Wloger::Directory::LOG_DIR_NAME}")
|
14
|
+
date = Date.parse(DATE)
|
15
|
+
@directory = Wloger::Directory.new(date)
|
16
|
+
end
|
17
|
+
|
18
|
+
it 'has a default log directory name' do
|
19
|
+
expect(Wloger::Directory::LOG_DIR_NAME).not_to eq nil
|
20
|
+
end
|
21
|
+
|
22
|
+
it 'has a default log directory parent' do
|
23
|
+
expect(Wloger::Directory::PARENT_LOG_DIR).not_to eq nil
|
24
|
+
end
|
25
|
+
|
26
|
+
context 'when wloger run to edit today work-log' do
|
27
|
+
it 'has a file path attribute' do
|
28
|
+
expect(@directory.path).not_to eq nil
|
29
|
+
end
|
30
|
+
|
31
|
+
describe '#make_today' do
|
32
|
+
it 'maked today log directory' do
|
33
|
+
expect(Dir.exist?(@directory.path)).to eq false
|
34
|
+
@directory.make_today
|
35
|
+
expect(Dir.exist?(@directory.path)).to eq true
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
describe '#remove_today' do
|
40
|
+
it 'don\'t exist today log directory' do
|
41
|
+
expect(Dir.exist?(@directory.path)).to eq true
|
42
|
+
@directory.remove_today
|
43
|
+
expect(Dir.exist?(@directory.path)).to eq false
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
after :all do
|
48
|
+
log_file_path = "#{@logs_saved_dir}/#{YEAR}_#{MONTH}"
|
49
|
+
FileUtils.rm_rf(log_file_path) if Dir.exist?(log_file_path)
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'wloger'
|
2
|
+
|
3
|
+
# This file was generated by the `rspec --init` command. Conventionally, all
|
4
|
+
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
|
5
|
+
# Require this file using `require "spec_helper"` to ensure that it is only
|
6
|
+
# loaded once.
|
7
|
+
#
|
8
|
+
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
|
9
|
+
RSpec.configure do |config|
|
10
|
+
config.treat_symbols_as_metadata_keys_with_true_values = true
|
11
|
+
config.run_all_when_everything_filtered = true
|
12
|
+
config.filter_run :focus
|
13
|
+
|
14
|
+
# Run specs in random order to surface order dependencies. If you find an
|
15
|
+
# order dependency and want to debug it, you can fix the order by providing
|
16
|
+
# the seed, which is printed after each run.
|
17
|
+
# --seed 1234
|
18
|
+
config.order = 'random'
|
19
|
+
end
|
data/wloger.gemspec
CHANGED
metadata
CHANGED
@@ -1,69 +1,83 @@
|
|
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.4
|
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-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - '>='
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '0'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - '>='
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: bundler
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - ~>
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '1.6'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- -
|
38
|
+
- - ~>
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '1.6'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rake
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- -
|
45
|
+
- - '>='
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: '0'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- -
|
52
|
+
- - '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rspec
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - '>='
|
53
67
|
- !ruby/object:Gem::Version
|
54
68
|
version: '0'
|
55
69
|
- !ruby/object:Gem::Dependency
|
56
70
|
name: pry
|
57
71
|
requirement: !ruby/object:Gem::Requirement
|
58
72
|
requirements:
|
59
|
-
- -
|
73
|
+
- - '>='
|
60
74
|
- !ruby/object:Gem::Version
|
61
75
|
version: '0'
|
62
76
|
type: :development
|
63
77
|
prerelease: false
|
64
78
|
version_requirements: !ruby/object:Gem::Requirement
|
65
79
|
requirements:
|
66
|
-
- -
|
80
|
+
- - '>='
|
67
81
|
- !ruby/object:Gem::Version
|
68
82
|
version: '0'
|
69
83
|
description: Wloger manages the directory control of work-logs and automatically select
|
@@ -75,18 +89,24 @@ executables:
|
|
75
89
|
extensions: []
|
76
90
|
extra_rdoc_files: []
|
77
91
|
files:
|
78
|
-
-
|
92
|
+
- .gitignore
|
93
|
+
- .rspec
|
79
94
|
- Gemfile
|
95
|
+
- Guardfile
|
80
96
|
- LICENSE.txt
|
81
97
|
- README.md
|
82
98
|
- Rakefile
|
83
99
|
- bin/wloger
|
84
100
|
- lib/wloger.rb
|
85
101
|
- lib/wloger/command.rb
|
86
|
-
- lib/wloger/directory.rb
|
87
|
-
- lib/wloger/editor.rb
|
88
102
|
- lib/wloger/error.rb
|
103
|
+
- lib/wloger/log_file.rb
|
104
|
+
- lib/wloger/past_log_file.rb
|
105
|
+
- lib/wloger/today_log_file.rb
|
89
106
|
- lib/wloger/version.rb
|
107
|
+
- spec/lib/wloger/directory_spec.rb
|
108
|
+
- spec/lib/wloger_spec.rb
|
109
|
+
- spec/spec_helper.rb
|
90
110
|
- wloger.gemspec
|
91
111
|
homepage: https://github.com/huyu398/wloger
|
92
112
|
licenses:
|
@@ -98,18 +118,21 @@ require_paths:
|
|
98
118
|
- lib
|
99
119
|
required_ruby_version: !ruby/object:Gem::Requirement
|
100
120
|
requirements:
|
101
|
-
- -
|
121
|
+
- - '>='
|
102
122
|
- !ruby/object:Gem::Version
|
103
123
|
version: '0'
|
104
124
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
105
125
|
requirements:
|
106
|
-
- -
|
126
|
+
- - '>='
|
107
127
|
- !ruby/object:Gem::Version
|
108
128
|
version: '0'
|
109
129
|
requirements: []
|
110
130
|
rubyforge_project:
|
111
|
-
rubygems_version: 2.
|
131
|
+
rubygems_version: 2.0.0
|
112
132
|
signing_key:
|
113
133
|
specification_version: 4
|
114
134
|
summary: Wloger help to manage your daily work-logs.
|
115
|
-
test_files:
|
135
|
+
test_files:
|
136
|
+
- spec/lib/wloger/directory_spec.rb
|
137
|
+
- spec/lib/wloger_spec.rb
|
138
|
+
- spec/spec_helper.rb
|
data/lib/wloger/directory.rb
DELETED
@@ -1,29 +0,0 @@
|
|
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
DELETED
@@ -1,28 +0,0 @@
|
|
1
|
-
module Wloger
|
2
|
-
# using editor for work-log class
|
3
|
-
class Editor
|
4
|
-
EDITOR_NAME = 'vim'.freeze
|
5
|
-
LOG_NAME = 'log'.freeze
|
6
|
-
EXTENTION = 'md'.freeze
|
7
|
-
|
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)
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|