defoker 0.0.1
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 +7 -0
- data/.coveralls.yml +1 -0
- data/.gitignore +14 -0
- data/.rspec +2 -0
- data/.rubocop.yml +1 -0
- data/.travis.yml +7 -0
- data/Gemfile +18 -0
- data/LICENSE.txt +22 -0
- data/README.md +284 -0
- data/Rakefile +8 -0
- data/bin/defoker +117 -0
- data/defoker.gemspec +25 -0
- data/images/defoker.gif +0 -0
- data/lib/date_base_name.rb +165 -0
- data/lib/defoker/version.rb +3 -0
- data/lib/defoker_core.rb +113 -0
- data/rubocop-todo.yml +26 -0
- data/spec/date_base_name_spec.rb +482 -0
- data/spec/defoker_core_spec.rb +609 -0
- data/spec/spec_helper.rb +16 -0
- metadata +123 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 566abb39743a690c37d78d0d84803aa41d6b94c3
|
4
|
+
data.tar.gz: 22935a2803580506ed809b539c96fa2ef0d1c7d8
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 55d634319f4a080eb26d7c8c837134d14d7f59ce84c05415a085ee4d5c70caeead112b91b368ea6b6fed9bd2123e60ecc1750336cccd85a599821bc79ca08938
|
7
|
+
data.tar.gz: bacaa8a01b56b9a4172b651cab594208ba5f73958963b7742e26339a771ff02db84dd7d5c5d8b3dbc7919a36e69655898d2ab1a800a01dde4163bdc6bc977125
|
data/.coveralls.yml
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
service_name: travis-ci
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.rubocop.yml
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
inherit_from: rubocop-todo.yml
|
data/.travis.yml
ADDED
data/Gemfile
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
source 'https://rubygems.org'
|
2
|
+
|
3
|
+
gemspec
|
4
|
+
gem "rspec", "~> 2.14.1"
|
5
|
+
gem "thor", "~> 0.18.1"
|
6
|
+
gem "simplecov", "~> 0.8.2"
|
7
|
+
gem "activesupport", "~> 4.0.1"
|
8
|
+
gem "activemodel", "~> 4.0.2"
|
9
|
+
gem "tudu", "~> 0.0.4"
|
10
|
+
|
11
|
+
group :doc do
|
12
|
+
gem "yard"
|
13
|
+
end
|
14
|
+
|
15
|
+
group :test do
|
16
|
+
gem 'coveralls', require: false
|
17
|
+
gem "timecop"
|
18
|
+
end
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 tbpgr
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,284 @@
|
|
1
|
+
# Defoker
|
2
|
+
|
3
|
+
[](https://travis-ci.org/tbpgr/defoker)
|
4
|
+
[](https://coveralls.io/r/tbpgr/defoker)
|
5
|
+
|
6
|
+
Defoker is date/month/year base format named folder generator.
|
7
|
+
Defoker = DatE format FOlder maKER.
|
8
|
+
|
9
|
+
## Demo
|
10
|
+

|
11
|
+
|
12
|
+
## Target Versions
|
13
|
+
* Ruby 2.0
|
14
|
+
* Ruby 2.1
|
15
|
+
|
16
|
+
## Installation
|
17
|
+
|
18
|
+
Add this line to your application's Gemfile:
|
19
|
+
|
20
|
+
```ruby
|
21
|
+
gem 'defoker'
|
22
|
+
```
|
23
|
+
|
24
|
+
And then execute:
|
25
|
+
|
26
|
+
$ bundle
|
27
|
+
|
28
|
+
Or install it yourself as:
|
29
|
+
|
30
|
+
$ gem install defoker
|
31
|
+
|
32
|
+
## Usage
|
33
|
+
### help
|
34
|
+
~~~bash
|
35
|
+
$ defoker help
|
36
|
+
~~~
|
37
|
+
|
38
|
+
### today
|
39
|
+
* no additional text
|
40
|
+
|
41
|
+
~~~bash
|
42
|
+
# execute at 2014/10/01
|
43
|
+
$ defoker today
|
44
|
+
$ ls -F | grep /
|
45
|
+
20141001/
|
46
|
+
~~~
|
47
|
+
|
48
|
+
* with additional text
|
49
|
+
|
50
|
+
~~~bash
|
51
|
+
# execute at 2014/10/01
|
52
|
+
$ defoker today -a hoge
|
53
|
+
$ ls -F | grep /
|
54
|
+
20141001_hoge/
|
55
|
+
~~~
|
56
|
+
|
57
|
+
### tommorow
|
58
|
+
* no additional text
|
59
|
+
|
60
|
+
~~~bash
|
61
|
+
# execute at 2014/10/01
|
62
|
+
$ defoker tommorow
|
63
|
+
$ ls -F | grep /
|
64
|
+
20141002/
|
65
|
+
~~~
|
66
|
+
|
67
|
+
* with additional text
|
68
|
+
|
69
|
+
~~~bash
|
70
|
+
# execute at 2014/10/01
|
71
|
+
$ defoker tommorow -a hoge
|
72
|
+
$ ls -F | grep /
|
73
|
+
20141002_hoge/
|
74
|
+
~~~
|
75
|
+
|
76
|
+
### yesterday
|
77
|
+
* no additional text
|
78
|
+
|
79
|
+
~~~bash
|
80
|
+
# execute at 2014/10/01
|
81
|
+
$ defoker yesterday
|
82
|
+
$ ls -F | grep /
|
83
|
+
2014930/
|
84
|
+
~~~
|
85
|
+
|
86
|
+
* with additional text
|
87
|
+
|
88
|
+
~~~bash
|
89
|
+
# execute at 2014/10/01
|
90
|
+
$ defoker yesterday -a hoge
|
91
|
+
$ ls -F | grep /
|
92
|
+
2014930_hoge/
|
93
|
+
~~~
|
94
|
+
|
95
|
+
### days
|
96
|
+
* no count, additional text
|
97
|
+
|
98
|
+
~~~bash
|
99
|
+
# default = 3 directories
|
100
|
+
$ defoker days 20140920
|
101
|
+
$ ls -F | grep /
|
102
|
+
20140920/
|
103
|
+
20140921/
|
104
|
+
20140922/
|
105
|
+
~~~
|
106
|
+
|
107
|
+
* with repeat count, additional text
|
108
|
+
|
109
|
+
~~~bash
|
110
|
+
$ defoker days 20140920 -c 4 -a hoge
|
111
|
+
$ ls -F | grep /
|
112
|
+
20140920_hoge/
|
113
|
+
20140921_hoge/
|
114
|
+
20140922_hoge/
|
115
|
+
20140923_hoge/
|
116
|
+
~~~
|
117
|
+
|
118
|
+
### this_month
|
119
|
+
* no additional text
|
120
|
+
|
121
|
+
~~~bash
|
122
|
+
# execute at 2014/10/01
|
123
|
+
$ defoker this_month
|
124
|
+
$ ls -F | grep /
|
125
|
+
201410/
|
126
|
+
~~~
|
127
|
+
|
128
|
+
* with additional text
|
129
|
+
|
130
|
+
~~~bash
|
131
|
+
# execute at 2014/10/01
|
132
|
+
$ defoker this_month -a hoge
|
133
|
+
$ ls -F | grep /
|
134
|
+
201410_hoge/
|
135
|
+
~~~
|
136
|
+
|
137
|
+
### next_month
|
138
|
+
* no additional text
|
139
|
+
|
140
|
+
~~~bash
|
141
|
+
# execute at 2014/10/01
|
142
|
+
$ defoker next_month
|
143
|
+
$ ls -F | grep /
|
144
|
+
201411/
|
145
|
+
~~~
|
146
|
+
|
147
|
+
* with additional text
|
148
|
+
|
149
|
+
~~~bash
|
150
|
+
# execute at 2014/10/01
|
151
|
+
$ defoker next_month -a hoge
|
152
|
+
$ ls -F | grep /
|
153
|
+
201411_hoge/
|
154
|
+
~~~
|
155
|
+
|
156
|
+
### previous_month
|
157
|
+
* no additional text
|
158
|
+
|
159
|
+
~~~bash
|
160
|
+
# execute at 2014/10/01
|
161
|
+
$ defoker previous_month
|
162
|
+
$ ls -F | grep /
|
163
|
+
201409/
|
164
|
+
~~~
|
165
|
+
|
166
|
+
* with additional text
|
167
|
+
|
168
|
+
~~~bash
|
169
|
+
# execute at 2014/10/01
|
170
|
+
$ defoker previous_month -a hoge
|
171
|
+
$ ls -F | grep /
|
172
|
+
201409_hoge/
|
173
|
+
~~~
|
174
|
+
|
175
|
+
### months
|
176
|
+
* no count, additional text
|
177
|
+
|
178
|
+
~~~bash
|
179
|
+
$ defoker months 201410
|
180
|
+
$ ls -F | grep /
|
181
|
+
201410/
|
182
|
+
201411/
|
183
|
+
201412/
|
184
|
+
~~~
|
185
|
+
|
186
|
+
* with count, additional text
|
187
|
+
|
188
|
+
~~~bash
|
189
|
+
$ defoker months 201410 -c 4 -a hoge
|
190
|
+
$ ls -F | grep /
|
191
|
+
201410_hoge/
|
192
|
+
201411_hoge/
|
193
|
+
201412_hoge/
|
194
|
+
201501_hoge/
|
195
|
+
~~~
|
196
|
+
|
197
|
+
### this_year
|
198
|
+
* no additional text
|
199
|
+
|
200
|
+
~~~bash
|
201
|
+
# execute at 2014/10/01
|
202
|
+
$ defoker this_year
|
203
|
+
$ ls -F | grep /
|
204
|
+
2014/
|
205
|
+
~~~
|
206
|
+
|
207
|
+
* with additional text
|
208
|
+
|
209
|
+
~~~bash
|
210
|
+
# execute at 2014/10/01
|
211
|
+
$ defoker this_year -a hoge
|
212
|
+
$ ls -F | grep /
|
213
|
+
2014_hoge/
|
214
|
+
~~~
|
215
|
+
|
216
|
+
### next_year
|
217
|
+
* no additional text
|
218
|
+
|
219
|
+
~~~bash
|
220
|
+
# execute at 2014/10/01
|
221
|
+
$ defoker next_year
|
222
|
+
$ ls -F | grep /
|
223
|
+
2015/
|
224
|
+
~~~
|
225
|
+
|
226
|
+
* with additional text
|
227
|
+
|
228
|
+
~~~bash
|
229
|
+
# execute at 2014/10/01
|
230
|
+
$ defoker next_year -a hoge
|
231
|
+
$ ls -F | grep /
|
232
|
+
2015_hoge/
|
233
|
+
~~~
|
234
|
+
|
235
|
+
### previous_year
|
236
|
+
* no additional text
|
237
|
+
|
238
|
+
~~~bash
|
239
|
+
# execute at 2014/10/01
|
240
|
+
$ defoker previous_year
|
241
|
+
$ ls -F | grep /
|
242
|
+
2013/
|
243
|
+
~~~
|
244
|
+
|
245
|
+
* with additional text
|
246
|
+
|
247
|
+
~~~bash
|
248
|
+
# execute at 2014/10/01
|
249
|
+
$ defoker previous_year -a hoge
|
250
|
+
$ ls -F | grep /
|
251
|
+
2013_hoge/
|
252
|
+
~~~
|
253
|
+
|
254
|
+
### years
|
255
|
+
* no count, additional text
|
256
|
+
|
257
|
+
~~~bash
|
258
|
+
$ ls -F | grep /
|
259
|
+
2014/
|
260
|
+
2015/
|
261
|
+
2016/
|
262
|
+
~~~
|
263
|
+
|
264
|
+
* with count, additional text
|
265
|
+
|
266
|
+
~~~bash
|
267
|
+
$ defoker years 2014 -c 4 -a hoge
|
268
|
+
$ ls -F | grep /
|
269
|
+
2014_hoge/
|
270
|
+
2015_hoge/
|
271
|
+
2016_hoge/
|
272
|
+
2017_hoge/
|
273
|
+
~~~
|
274
|
+
|
275
|
+
## History
|
276
|
+
* version 0.0.1 : First release.
|
277
|
+
|
278
|
+
## Contributing
|
279
|
+
|
280
|
+
1. Fork it ( https://github.com/[my-github-username]/defoker/fork )
|
281
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
282
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
283
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
284
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
data/bin/defoker
ADDED
@@ -0,0 +1,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
|
+
option :additional, aliases: 'a'
|
16
|
+
desc 'today', 'create today folder. ex) 20140912, 20140912_hoge'
|
17
|
+
def today
|
18
|
+
defoker_core_single_caller(:today)
|
19
|
+
end
|
20
|
+
|
21
|
+
option :additional, aliases: 'a'
|
22
|
+
desc 'tommorow', 'create tommorow folder. ex) 20140913, 20140913_hoge'
|
23
|
+
def tommorow
|
24
|
+
defoker_core_single_caller(:tommorow)
|
25
|
+
end
|
26
|
+
|
27
|
+
option :additional, aliases: 'a'
|
28
|
+
desc 'yesterday', 'create yesterday folder. ex) 20140911, 20140911_hoge'
|
29
|
+
def yesterday
|
30
|
+
defoker_core_single_caller(:yesterday)
|
31
|
+
end
|
32
|
+
|
33
|
+
option :count, aliases: 'c'
|
34
|
+
option :additional, aliases: 'a'
|
35
|
+
desc 'days', "create day folder list. ex) ['20140909','20140910','20140911','20140912'], ['20140909_hoge','20140910_hoge','20140911_hoge','20140912_hoge']"
|
36
|
+
def days(date)
|
37
|
+
defoker_core_multi_caller(date, :days)
|
38
|
+
end
|
39
|
+
|
40
|
+
option :additional, aliases: 'a'
|
41
|
+
desc 'this_month', 'create this_month folder. ex) 201409, 201409_hoge'
|
42
|
+
def this_month
|
43
|
+
defoker_core_single_caller(:this_month)
|
44
|
+
end
|
45
|
+
|
46
|
+
option :additional, aliases: 'a'
|
47
|
+
desc 'next_month', 'create next_month folder. ex) 201410, 201410_hoge'
|
48
|
+
def next_month
|
49
|
+
defoker_core_single_caller(:next_month)
|
50
|
+
end
|
51
|
+
|
52
|
+
option :additional, aliases: 'a'
|
53
|
+
desc 'previous_month', 'create previous_month folder. ex) 201410, 201410_hoge'
|
54
|
+
def previous_month
|
55
|
+
defoker_core_single_caller(:previous_month)
|
56
|
+
end
|
57
|
+
|
58
|
+
option :count, aliases: 'c'
|
59
|
+
option :additional, aliases: 'a'
|
60
|
+
desc 'months', "create month folder list. ex) ['201410','201411','201412','201501'], ['201410_hoge','201411_hoge','201412_hoge','201501_hoge']"
|
61
|
+
def months(date)
|
62
|
+
defoker_core_multi_caller(date, :months)
|
63
|
+
end
|
64
|
+
|
65
|
+
option :additional, aliases: 'a'
|
66
|
+
desc 'this_year', 'create this_year folder. ex) 2014, 2014_hoge'
|
67
|
+
def this_year
|
68
|
+
defoker_core_single_caller(:this_year)
|
69
|
+
end
|
70
|
+
|
71
|
+
option :additional, aliases: 'a'
|
72
|
+
desc 'next_year', 'create next_year folder. ex) 2015, 2015_hoge'
|
73
|
+
def next_year
|
74
|
+
defoker_core_single_caller(:next_year)
|
75
|
+
end
|
76
|
+
|
77
|
+
option :additional, aliases: 'a'
|
78
|
+
desc 'previous_year', 'create previous_year folder. ex) 2013, 2013_hoge'
|
79
|
+
def previous_year
|
80
|
+
defoker_core_single_caller(:previous_year)
|
81
|
+
end
|
82
|
+
|
83
|
+
option :count, aliases: 'c'
|
84
|
+
option :additional, aliases: 'a'
|
85
|
+
desc 'years', "create year folder list. ex) ['2014','2015','2016','2017'], ['2014_hoge','2015_hoge','2016_hoge','2017_hoge']"
|
86
|
+
def years(date)
|
87
|
+
defoker_core_multi_caller(date, :years)
|
88
|
+
end
|
89
|
+
|
90
|
+
desc 'version', 'version'
|
91
|
+
def version
|
92
|
+
p Defoker::VERSION
|
93
|
+
end
|
94
|
+
|
95
|
+
private
|
96
|
+
def defoker_core_single_caller(method_name)
|
97
|
+
additional = options[:additional] ? options[:additional] : ''
|
98
|
+
dir = Defoker::Core.new.send(method_name, additional: additional)
|
99
|
+
FileUtils.mkdir_p(dir)
|
100
|
+
exit(true)
|
101
|
+
rescue
|
102
|
+
exit(false)
|
103
|
+
end
|
104
|
+
|
105
|
+
def defoker_core_multi_caller(date, method_name)
|
106
|
+
count = options[:count] ? options[:count].to_i : 3
|
107
|
+
additional = options[:additional] ? options[:additional] : ''
|
108
|
+
dirs = Defoker::Core.new.send(method_name, date, count: count, additional: additional)
|
109
|
+
FileUtils.mkdir_p(dirs)
|
110
|
+
exit(true)
|
111
|
+
rescue
|
112
|
+
exit(false)
|
113
|
+
end
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
117
|
+
Defoker::CLI.start(ARGV)
|