defoker 0.0.3 → 0.0.4
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/Gemfile +5 -8
- data/README.md +69 -1
- data/bin/defoker +131 -117
- data/defoker.gemspec +25 -25
- data/images/defoker.gif +0 -0
- data/lib/date_base_name.rb +160 -165
- data/lib/defoker/version.rb +3 -3
- data/lib/defoker_core.rb +45 -0
- data/lib/defoker_dsl.rb +22 -0
- data/lib/defoker_dsl_model.rb +11 -0
- data/spec/defoker_core_spec.rb +752 -609
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ca9c983a5ecae049e87562fde03ae9069924d36f
|
4
|
+
data.tar.gz: 2cec660df681c77d30518cecce73565058af772f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9d4d2d1a1c78a9c0b4a8b2bfa2e0ca578218bc6ddb41d6e5f51cce2672a600af51d376f7c1346928357780dc594426e4e28d30b61fef27e2e092a9ad758100d4
|
7
|
+
data.tar.gz: c317466dd4413d0a80a877778fb9cf81ca0a7dedff229151e2596fc4910b3814f4d53f7b9eed68cdd67481e711d8f6a98f9c4c5c1c2c0b3c783dc7e66d170bde
|
data/Gemfile
CHANGED
@@ -1,18 +1,15 @@
|
|
1
1
|
source 'https://rubygems.org'
|
2
2
|
|
3
3
|
gemspec
|
4
|
-
gem
|
5
|
-
gem
|
6
|
-
gem
|
7
|
-
gem "activesupport", "~> 4.0.1"
|
8
|
-
gem "activemodel", "~> 4.0.2"
|
9
|
-
gem "tudu", "~> 0.0.4"
|
4
|
+
gem 'rspec', '~> 2.14.1'
|
5
|
+
gem 'thor', '~> 0.18.1'
|
6
|
+
gem 'simplecov', '~> 0.8.2'
|
10
7
|
|
11
8
|
group :doc do
|
12
|
-
gem
|
9
|
+
gem 'yard'
|
13
10
|
end
|
14
11
|
|
15
12
|
group :test do
|
16
13
|
gem 'coveralls', require: false
|
17
|
-
gem
|
14
|
+
gem 'timecop'
|
18
15
|
end
|
data/README.md
CHANGED
@@ -273,13 +273,81 @@ $ ls -F | grep /
|
|
273
273
|
2017_hoge/
|
274
274
|
~~~
|
275
275
|
|
276
|
+
### rule-output
|
277
|
+
* generate Defokerfile template
|
278
|
+
|
279
|
+
~~~bash
|
280
|
+
$ defoker init
|
281
|
+
$ cat Defokerfile
|
282
|
+
# type is required.
|
283
|
+
# you can choose type form...
|
284
|
+
# [:today | :tomorrow | :yesterday | :this_month | :next_month | :previous_month | :this_year | :previous_year | :next_month]
|
285
|
+
# example
|
286
|
+
# type :this_month
|
287
|
+
type :today
|
288
|
+
# base is optional.
|
289
|
+
# example
|
290
|
+
# base 'ruby'
|
291
|
+
base ''
|
292
|
+
~~~
|
293
|
+
|
294
|
+
* execute by default Defokerfile
|
295
|
+
|
296
|
+
~~~bash
|
297
|
+
# execute at 2014/10/01
|
298
|
+
$ defoker rule
|
299
|
+
$ ls -F | grep /
|
300
|
+
20141001/
|
301
|
+
$ defoker rule -a hoge
|
302
|
+
$ ls -F | grep /
|
303
|
+
20141001_hoge/
|
304
|
+
|
305
|
+
# execute at 2014/10/02
|
306
|
+
$ defoker rule
|
307
|
+
$ ls -F | grep /
|
308
|
+
20141002/
|
309
|
+
$ defoker rule -a hoge
|
310
|
+
$ ls -F | grep /
|
311
|
+
20141002_hoge/
|
312
|
+
~~~
|
313
|
+
|
314
|
+
* edit Defokerfile.(type = previous_month, base = monthly_report)
|
315
|
+
|
316
|
+
~~~bash
|
317
|
+
$ cat Defokerfile
|
318
|
+
type :previous_month
|
319
|
+
base 'monthly_report'
|
320
|
+
~~~
|
321
|
+
|
322
|
+
* execute by edited Defokerfile.
|
323
|
+
|
324
|
+
~~~bash
|
325
|
+
# execute at 2014/10
|
326
|
+
$ defoker rule
|
327
|
+
$ ls -F | grep /
|
328
|
+
201409_monthly_report/
|
329
|
+
$ defoker rule -a hoge
|
330
|
+
$ ls -F | grep /
|
331
|
+
201409_monthly_report_hoge/
|
332
|
+
|
333
|
+
# execute at 2014/11
|
334
|
+
$ defoker rule
|
335
|
+
$ ls -F | grep /
|
336
|
+
201410_monthly_report/
|
337
|
+
$ defoker rule -a hoge
|
338
|
+
$ ls -F | grep /
|
339
|
+
201410_monthly_report_hoge/
|
340
|
+
~~~
|
341
|
+
|
276
342
|
## History
|
343
|
+
* version 0.0.4 : Add init/rule command for rule-output.
|
344
|
+
* version 0.0.3 : Fix typo in gemspec.
|
277
345
|
* version 0.0.2 : Fix typo and change public interface tommorow to tomorrow.
|
278
346
|
* version 0.0.1 : First release.
|
279
347
|
|
280
348
|
## Contributing
|
281
349
|
|
282
|
-
1. Fork it ( https://github.com/
|
350
|
+
1. Fork it ( https://github.com/tbpgr/defoker/fork )
|
283
351
|
2. Create your feature branch (`git checkout -b my-new-feature`)
|
284
352
|
3. Commit your changes (`git commit -am 'Add some feature'`)
|
285
353
|
4. Push to the branch (`git push origin my-new-feature`)
|
data/bin/defoker
CHANGED
@@ -1,117 +1,131 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
# encoding: utf-8
|
3
|
-
|
4
|
-
require 'defoker_core'
|
5
|
-
require 'defoker/version'
|
6
|
-
require 'thor'
|
7
|
-
require 'fileutils'
|
8
|
-
|
9
|
-
module Defoker
|
10
|
-
# = Defoker CLI
|
11
|
-
class CLI < Thor
|
12
|
-
class_option :help, type: :boolean, aliases: '-h', desc: 'help message.'
|
13
|
-
class_option :version, type: :boolean, desc: 'version'
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
def
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# encoding: utf-8
|
3
|
+
|
4
|
+
require 'defoker_core'
|
5
|
+
require 'defoker/version'
|
6
|
+
require 'thor'
|
7
|
+
require 'fileutils'
|
8
|
+
|
9
|
+
module Defoker
|
10
|
+
# = Defoker CLI
|
11
|
+
class CLI < Thor
|
12
|
+
class_option :help, type: :boolean, aliases: '-h', desc: 'help message.'
|
13
|
+
class_option :version, type: :boolean, desc: 'version'
|
14
|
+
|
15
|
+
desc 'init', 'generate Defokerfile template'
|
16
|
+
def init
|
17
|
+
Defoker::Core.new.init
|
18
|
+
exit(true)
|
19
|
+
rescue
|
20
|
+
exit(false)
|
21
|
+
end
|
22
|
+
|
23
|
+
option :additional, aliases: 'a'
|
24
|
+
desc 'today', 'create today folder. ex) 20140912, 20140912_hoge'
|
25
|
+
def today
|
26
|
+
defoker_core_single_caller(:today)
|
27
|
+
end
|
28
|
+
|
29
|
+
option :additional, aliases: 'a'
|
30
|
+
desc 'tomorrow', 'create tomorrow folder. ex) 20140913, 20140913_hoge'
|
31
|
+
def tomorrow
|
32
|
+
defoker_core_single_caller(:tomorrow)
|
33
|
+
end
|
34
|
+
|
35
|
+
option :additional, aliases: 'a'
|
36
|
+
desc 'yesterday', 'create yesterday folder. ex) 20140911, 20140911_hoge'
|
37
|
+
def yesterday
|
38
|
+
defoker_core_single_caller(:yesterday)
|
39
|
+
end
|
40
|
+
|
41
|
+
option :count, aliases: 'c'
|
42
|
+
option :additional, aliases: 'a'
|
43
|
+
desc 'days', "create day folder list. ex) ['20140909','20140910','20140911','20140912'], ['20140909_hoge','20140910_hoge','20140911_hoge','20140912_hoge']"
|
44
|
+
def days(date)
|
45
|
+
defoker_core_multi_caller(date, :days)
|
46
|
+
end
|
47
|
+
|
48
|
+
option :additional, aliases: 'a'
|
49
|
+
desc 'this_month', 'create this_month folder. ex) 201409, 201409_hoge'
|
50
|
+
def this_month
|
51
|
+
defoker_core_single_caller(:this_month)
|
52
|
+
end
|
53
|
+
|
54
|
+
option :additional, aliases: 'a'
|
55
|
+
desc 'next_month', 'create next_month folder. ex) 201410, 201410_hoge'
|
56
|
+
def next_month
|
57
|
+
defoker_core_single_caller(:next_month)
|
58
|
+
end
|
59
|
+
|
60
|
+
option :additional, aliases: 'a'
|
61
|
+
desc 'previous_month', 'create previous_month folder. ex) 201410, 201410_hoge'
|
62
|
+
def previous_month
|
63
|
+
defoker_core_single_caller(:previous_month)
|
64
|
+
end
|
65
|
+
|
66
|
+
option :count, aliases: 'c'
|
67
|
+
option :additional, aliases: 'a'
|
68
|
+
desc 'months', "create month folder list. ex) ['201410','201411','201412','201501'], ['201410_hoge','201411_hoge','201412_hoge','201501_hoge']"
|
69
|
+
def months(date)
|
70
|
+
defoker_core_multi_caller(date, :months)
|
71
|
+
end
|
72
|
+
|
73
|
+
option :additional, aliases: 'a'
|
74
|
+
desc 'this_year', 'create this_year folder. ex) 2014, 2014_hoge'
|
75
|
+
def this_year
|
76
|
+
defoker_core_single_caller(:this_year)
|
77
|
+
end
|
78
|
+
|
79
|
+
option :additional, aliases: 'a'
|
80
|
+
desc 'next_year', 'create next_year folder. ex) 2015, 2015_hoge'
|
81
|
+
def next_year
|
82
|
+
defoker_core_single_caller(:next_year)
|
83
|
+
end
|
84
|
+
|
85
|
+
option :additional, aliases: 'a'
|
86
|
+
desc 'previous_year', 'create previous_year folder. ex) 2013, 2013_hoge'
|
87
|
+
def previous_year
|
88
|
+
defoker_core_single_caller(:previous_year)
|
89
|
+
end
|
90
|
+
|
91
|
+
option :count, aliases: 'c'
|
92
|
+
option :additional, aliases: 'a'
|
93
|
+
desc 'years', "create year folder list. ex) ['2014','2015','2016','2017'], ['2014_hoge','2015_hoge','2016_hoge','2017_hoge']"
|
94
|
+
def years(date)
|
95
|
+
defoker_core_multi_caller(date, :years)
|
96
|
+
end
|
97
|
+
|
98
|
+
option :additional, aliases: 'a'
|
99
|
+
desc 'rule', 'create folder by Defokerfile''s rule.'
|
100
|
+
def rule
|
101
|
+
defoker_core_single_caller(:rule)
|
102
|
+
end
|
103
|
+
|
104
|
+
desc 'version', 'version'
|
105
|
+
def version
|
106
|
+
p Defoker::VERSION
|
107
|
+
end
|
108
|
+
|
109
|
+
private
|
110
|
+
def defoker_core_single_caller(method_name)
|
111
|
+
additional = options[:additional] ? options[:additional] : ''
|
112
|
+
dir = Defoker::Core.new.send(method_name, additional: additional)
|
113
|
+
FileUtils.mkdir_p(dir)
|
114
|
+
exit(true)
|
115
|
+
rescue
|
116
|
+
exit(false)
|
117
|
+
end
|
118
|
+
|
119
|
+
def defoker_core_multi_caller(date, method_name)
|
120
|
+
count = options[:count] ? options[:count].to_i : 3
|
121
|
+
additional = options[:additional] ? options[:additional] : ''
|
122
|
+
dirs = Defoker::Core.new.send(method_name, date, count: count, additional: additional)
|
123
|
+
FileUtils.mkdir_p(dirs)
|
124
|
+
exit(true)
|
125
|
+
rescue
|
126
|
+
exit(false)
|
127
|
+
end
|
128
|
+
end
|
129
|
+
end
|
130
|
+
|
131
|
+
Defoker::CLI.start(ARGV)
|
data/defoker.gemspec
CHANGED
@@ -1,25 +1,25 @@
|
|
1
|
-
# coding: utf-8
|
2
|
-
lib = File.expand_path('../lib', __FILE__)
|
3
|
-
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
-
require 'defoker/version'
|
5
|
-
|
6
|
-
Gem::Specification.new do |spec|
|
7
|
-
spec.name = 'defoker'
|
8
|
-
spec.version = Defoker::VERSION
|
9
|
-
spec.authors = ['tbpgr']
|
10
|
-
spec.email = ['tbpgr@tbpgr.jp']
|
11
|
-
spec.summary =
|
12
|
-
spec.description =
|
13
|
-
spec.homepage = 'https://github.com/tbpgr/defoker'
|
14
|
-
spec.license = 'MIT'
|
15
|
-
|
16
|
-
spec.files = `git ls-files -z`.split("\x0")
|
17
|
-
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
-
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
-
spec.require_paths = ['lib']
|
20
|
-
|
21
|
-
spec.add_development_dependency 'bundler', '~> 1.6'
|
22
|
-
spec.add_development_dependency 'rake', '~> 10.0'
|
23
|
-
spec.add_development_dependency 'yard'
|
24
|
-
spec.add_development_dependency 'timecop'
|
25
|
-
end
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'defoker/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = 'defoker'
|
8
|
+
spec.version = Defoker::VERSION
|
9
|
+
spec.authors = ['tbpgr']
|
10
|
+
spec.email = ['tbpgr@tbpgr.jp']
|
11
|
+
spec.summary = 'Create various kind of date-base format named folders.'
|
12
|
+
spec.description = 'Create various kind of date-base format named folders.'
|
13
|
+
spec.homepage = 'https://github.com/tbpgr/defoker'
|
14
|
+
spec.license = 'MIT'
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ['lib']
|
20
|
+
|
21
|
+
spec.add_development_dependency 'bundler', '~> 1.6'
|
22
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
23
|
+
spec.add_development_dependency 'yard'
|
24
|
+
spec.add_development_dependency 'timecop'
|
25
|
+
end
|
data/images/defoker.gif
CHANGED
Binary file
|