defoker 0.0.7 → 0.0.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +22 -0
- data/bin/defoker +58 -11
- data/lib/defoker/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2096e549b7fb1fa21834c21184f2055ffdfc1075
|
4
|
+
data.tar.gz: 0567dfaf47dadde884d5d4758d88f799e8bf3316
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c5d951f24576c64175d00780db60f511fc71b364595c5600a3b9f5ac48963a46dd5f3527ba14cf8e1541c53ed2024ee53486732c7a1f3c57b70a9f4300e7a90d
|
7
|
+
data.tar.gz: acc85b6b64b8b2399f914421358a37fb0ead474a0eea12dba7882a705fe8c27936baffab480bae56126c47278c764124cd4cb6251cea7556f717d226636ca9d1
|
data/README.md
CHANGED
@@ -454,7 +454,29 @@ $ defoker mv_year
|
|
454
454
|
┗ invalid_folder
|
455
455
|
~~~
|
456
456
|
|
457
|
+
### gem_info
|
458
|
+
show gem information.
|
459
|
+
|
460
|
+
~~~bash
|
461
|
+
$ defoker gem_info
|
462
|
+
____ __ _
|
463
|
+
| _ \ ___ / _| ___ | | _____ _ __
|
464
|
+
| | | |/ _ \ |_ / _ \| |/ / _ \ '__|
|
465
|
+
| |_| | __/ _| (_) | < __/ |
|
466
|
+
|____/ \___|_| \___/|_|\_\___|_|
|
467
|
+
|
468
|
+
[gem name]
|
469
|
+
defoker
|
470
|
+
[version]
|
471
|
+
0.0.8
|
472
|
+
[document url]
|
473
|
+
https://github.com/tbpgr/defoker
|
474
|
+
[RubyGems url]
|
475
|
+
http://rubygems.org/gems/defoker
|
476
|
+
~~~
|
477
|
+
|
457
478
|
## History
|
479
|
+
* version 0.0.8 : Add gem_info command. Add debug option.
|
458
480
|
* version 0.0.7 : Add mv_month, mv_year commands.
|
459
481
|
* version 0.0.6 : Add callback in Defokerfile.
|
460
482
|
* version 0.0.5 : Fix typo in Defokerfile Template.
|
data/bin/defoker
CHANGED
@@ -6,15 +6,17 @@ require 'defoker/version'
|
|
6
6
|
require 'thor'
|
7
7
|
require 'fileutils'
|
8
8
|
|
9
|
-
# rubocop:disable ClassLength
|
9
|
+
# rubocop:disable ClassLength, MethodLength
|
10
10
|
module Defoker
|
11
11
|
# = Defoker CLI
|
12
12
|
class CLI < Thor
|
13
13
|
class_option :help, type: :boolean, aliases: '-h', desc: 'help message.'
|
14
14
|
class_option :version, type: :boolean, desc: 'version'
|
15
|
+
class_option :debug, type: :boolean, aliases: '-d', desc: 'debug mode'
|
15
16
|
|
16
17
|
desc 'init', 'generate Defokerfile template'
|
17
18
|
def init
|
19
|
+
setting_debug_mode
|
18
20
|
Defoker::Core.init
|
19
21
|
exit(true)
|
20
22
|
rescue
|
@@ -24,18 +26,21 @@ module Defoker
|
|
24
26
|
option :additional, aliases: 'a'
|
25
27
|
desc 'today', 'create today folder. ex) 20140912, 20140912_hoge'
|
26
28
|
def today
|
29
|
+
setting_debug_mode
|
27
30
|
defoker_core_single_caller(:today)
|
28
31
|
end
|
29
32
|
|
30
33
|
option :additional, aliases: 'a'
|
31
34
|
desc 'tomorrow', 'create tomorrow folder. ex) 20140913, 20140913_hoge'
|
32
35
|
def tomorrow
|
36
|
+
setting_debug_mode
|
33
37
|
defoker_core_single_caller(:tomorrow)
|
34
38
|
end
|
35
39
|
|
36
40
|
option :additional, aliases: 'a'
|
37
41
|
desc 'yesterday', 'create yesterday folder. ex) 20140911, 20140911_hoge'
|
38
42
|
def yesterday
|
43
|
+
setting_debug_mode
|
39
44
|
defoker_core_single_caller(:yesterday)
|
40
45
|
end
|
41
46
|
|
@@ -43,24 +48,28 @@ module Defoker
|
|
43
48
|
option :additional, aliases: 'a'
|
44
49
|
desc 'days', "create day folder list. ex) ['20140909','20140910','20140911','20140912'], ['20140909_hoge','20140910_hoge','20140911_hoge','20140912_hoge']"
|
45
50
|
def days(date)
|
51
|
+
setting_debug_mode
|
46
52
|
defoker_core_multi_caller(date, :days)
|
47
53
|
end
|
48
54
|
|
49
55
|
option :additional, aliases: 'a'
|
50
56
|
desc 'this_month', 'create this_month folder. ex) 201409, 201409_hoge'
|
51
57
|
def this_month
|
58
|
+
setting_debug_mode
|
52
59
|
defoker_core_single_caller(:this_month)
|
53
60
|
end
|
54
61
|
|
55
62
|
option :additional, aliases: 'a'
|
56
63
|
desc 'next_month', 'create next_month folder. ex) 201410, 201410_hoge'
|
57
64
|
def next_month
|
65
|
+
setting_debug_mode
|
58
66
|
defoker_core_single_caller(:next_month)
|
59
67
|
end
|
60
68
|
|
61
69
|
option :additional, aliases: 'a'
|
62
70
|
desc 'previous_month', 'create previous_month folder. ex) 201410, 201410_hoge'
|
63
71
|
def previous_month
|
72
|
+
setting_debug_mode
|
64
73
|
defoker_core_single_caller(:previous_month)
|
65
74
|
end
|
66
75
|
|
@@ -68,24 +77,28 @@ module Defoker
|
|
68
77
|
option :additional, aliases: 'a'
|
69
78
|
desc 'months', "create month folder list. ex) ['201410','201411','201412','201501'], ['201410_hoge','201411_hoge','201412_hoge','201501_hoge']"
|
70
79
|
def months(date)
|
80
|
+
setting_debug_mode
|
71
81
|
defoker_core_multi_caller(date, :months)
|
72
82
|
end
|
73
83
|
|
74
84
|
option :additional, aliases: 'a'
|
75
85
|
desc 'this_year', 'create this_year folder. ex) 2014, 2014_hoge'
|
76
86
|
def this_year
|
87
|
+
setting_debug_mode
|
77
88
|
defoker_core_single_caller(:this_year)
|
78
89
|
end
|
79
90
|
|
80
91
|
option :additional, aliases: 'a'
|
81
92
|
desc 'next_year', 'create next_year folder. ex) 2015, 2015_hoge'
|
82
93
|
def next_year
|
94
|
+
setting_debug_mode
|
83
95
|
defoker_core_single_caller(:next_year)
|
84
96
|
end
|
85
97
|
|
86
98
|
option :additional, aliases: 'a'
|
87
99
|
desc 'previous_year', 'create previous_year folder. ex) 2013, 2013_hoge'
|
88
100
|
def previous_year
|
101
|
+
setting_debug_mode
|
89
102
|
defoker_core_single_caller(:previous_year)
|
90
103
|
end
|
91
104
|
|
@@ -93,43 +106,68 @@ module Defoker
|
|
93
106
|
option :additional, aliases: 'a'
|
94
107
|
desc 'years', "create year folder list. ex) ['2014','2015','2016','2017'], ['2014_hoge','2015_hoge','2016_hoge','2017_hoge']"
|
95
108
|
def years(date)
|
109
|
+
setting_debug_mode
|
96
110
|
defoker_core_multi_caller(date, :years)
|
97
111
|
end
|
98
112
|
|
99
113
|
option :additional, aliases: 'a'
|
100
114
|
desc 'rule', 'create folder by Defokerfile''s rule.'
|
101
115
|
def rule
|
116
|
+
setting_debug_mode
|
102
117
|
additional = options[:additional] ? options[:additional] : ''
|
103
118
|
dir, callback = Defoker::Core.rule(additional: additional)
|
104
|
-
FileUtils.mkdir_p(dir)
|
119
|
+
FileUtils.mkdir_p(dir) unless File.exist?(dir)
|
105
120
|
callback[dir] unless callback.nil?
|
106
121
|
exit(true)
|
107
122
|
rescue => e
|
108
|
-
|
123
|
+
output_error_if_debug_mode(e)
|
109
124
|
exit(false)
|
110
125
|
end
|
111
126
|
|
112
127
|
desc 'mv_month', 'move daily folders to monthly folder'
|
113
128
|
def mv_month
|
129
|
+
setting_debug_mode
|
114
130
|
Defoker::Core.mv_month
|
115
131
|
exit(true)
|
116
132
|
rescue => e
|
117
|
-
|
133
|
+
output_error_if_debug_mode(e)
|
118
134
|
exit(false)
|
119
135
|
end
|
120
136
|
|
121
137
|
desc 'mv_year', 'move monthly folders to yearly folder'
|
122
138
|
def mv_year
|
139
|
+
setting_debug_mode
|
123
140
|
Defoker::Core.mv_year
|
124
141
|
exit(true)
|
125
142
|
rescue => e
|
126
|
-
|
143
|
+
output_error_if_debug_mode(e)
|
127
144
|
exit(false)
|
128
145
|
end
|
129
146
|
|
130
147
|
desc 'version', 'version'
|
131
148
|
def version
|
132
|
-
|
149
|
+
puts Defoker::VERSION
|
150
|
+
end
|
151
|
+
|
152
|
+
desc 'gem_info', 'gem_info'
|
153
|
+
def gem_info
|
154
|
+
print <<-EOS
|
155
|
+
____ __ _
|
156
|
+
| _ \\ ___ / _| ___ | | _____ _ __
|
157
|
+
| | | |/ _ \\ |_ / _ \\| |/ / _ \\ '__|
|
158
|
+
| |_| | __/ _| (_) | < __/ |
|
159
|
+
|____/ \\___|_| \\___/|_|\\_\\___|_|
|
160
|
+
|
161
|
+
[gem name]
|
162
|
+
defoker
|
163
|
+
[version]
|
164
|
+
#{Defoker::VERSION}
|
165
|
+
[document url]
|
166
|
+
https://github.com/tbpgr/defoker
|
167
|
+
[RubyGems url]
|
168
|
+
http://rubygems.org/gems/defoker
|
169
|
+
EOS
|
170
|
+
exit(true)
|
133
171
|
end
|
134
172
|
|
135
173
|
private
|
@@ -137,10 +175,10 @@ module Defoker
|
|
137
175
|
def defoker_core_single_caller(method_name)
|
138
176
|
additional = options[:additional] ? options[:additional] : ''
|
139
177
|
dir = Defoker::Core.send(method_name, additional: additional)
|
140
|
-
FileUtils.mkdir_p(dir)
|
178
|
+
FileUtils.mkdir_p(dir) unless File.exist?(dir)
|
141
179
|
exit(true)
|
142
180
|
rescue => e
|
143
|
-
|
181
|
+
output_error_if_debug_mode(e)
|
144
182
|
exit(false)
|
145
183
|
end
|
146
184
|
|
@@ -148,14 +186,23 @@ module Defoker
|
|
148
186
|
count = options[:count] ? options[:count].to_i : 3
|
149
187
|
additional = options[:additional] ? options[:additional] : ''
|
150
188
|
dirs = Defoker::Core.send(method_name, date, count: count, additional: additional)
|
151
|
-
FileUtils.mkdir_p(
|
189
|
+
dirs.each { |dir|FileUtils.mkdir_p(dir) unless File.exist?(dir) }
|
152
190
|
exit(true)
|
153
191
|
rescue => e
|
154
|
-
|
192
|
+
output_error_if_debug_mode(e)
|
155
193
|
exit(false)
|
156
194
|
end
|
195
|
+
|
196
|
+
def setting_debug_mode
|
197
|
+
$DEBUG = options[:debug]
|
198
|
+
end
|
199
|
+
|
200
|
+
def output_error_if_debug_mode(e)
|
201
|
+
return unless options[:debug]
|
202
|
+
STDERR.puts(e.backtrace)
|
203
|
+
end
|
157
204
|
end
|
158
205
|
end
|
159
206
|
|
160
207
|
Defoker::CLI.start(ARGV)
|
161
|
-
# rubocop:enable ClassLength
|
208
|
+
# rubocop:enable ClassLength, MethodLength
|
data/lib/defoker/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: defoker
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- tbpgr
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-10-
|
11
|
+
date: 2014-10-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|