noir 0.1.11 → 0.1.12

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: '08cf16499d9bd42ed7c3167d5fc969d56b8a99a7c5275bc129045792de1a4492'
4
- data.tar.gz: 28adf26d590ba3632242c64847cfb40cf649f913c256cb67fd014b84f9eb6d80
3
+ metadata.gz: 1344b645923c638c0e9485530afdcd8ef2c632b2ff1f4a3b8c28e44f60534b0f
4
+ data.tar.gz: 5ffc5a08a587f99df13c7afdedbda2dce7a76a44515b4fe51d3279e1e1a1040e
5
5
  SHA512:
6
- metadata.gz: e788d6c3693d8eb361d6d7efa5cea2104d7bcaf74fec931e5c33b223140ae231c2fa3f9b35a27a857f2664b3424762b38986585eb8c459494b44aa69d8b994c5
7
- data.tar.gz: 5f05aab4771ba667af938c89b4c1c0d66843b3ee23511d1cd47771560d2128bb402c57a98e10158f44eb475a686407a51cb9931fd977773c1236c9f77af1dd5b
6
+ metadata.gz: 673cafea79abc0a967566e674923feb0a7bc5a6fe37b6c234222fbfdf9b336d9870c285fb706c147adace84ce5e2903daaa772f975f83ca4d586298801d8e901
7
+ data.tar.gz: a9d4ea04e57a6cab8bd3b26aac60388a58443d032fc8e7b8c2b06948e4f52f45b88d72c1e4cc1abc20e8ad53dda114fa6c313f39cafc324bd0599b6238ad926e
@@ -1 +1 @@
1
- 2.5.1
1
+ 2.6.5
@@ -1,17 +1,32 @@
1
1
  language: ruby
2
2
  rvm:
3
+ - 2.6.4
4
+ - 2.6.3
5
+ - 2.6.2
6
+ - 2.6.1
7
+ - 2.6.0
8
+ - 2.5.6
9
+ - 2.5.5
10
+ - 2.5.4
11
+ - 2.5.3
12
+ - 2.5.2
3
13
  - 2.5.1
4
14
  - 2.5.0
15
+ - 2.4.6
16
+ - 2.4.5
5
17
  - 2.4.4
6
18
  - 2.4.3
7
19
  - 2.4.2
8
20
  - 2.4.1
9
21
  - 2.4.0
22
+ - 2.3.8
23
+ - 2.3.7
10
24
  - 2.3.6
11
25
  - 2.3.5
12
26
  - 2.3.4
13
27
  - 2.3.3
14
28
  - 2.3.2
29
+ - 2.2.10
15
30
  - 2.2.9
16
31
  - 2.2.8
17
32
  - 2.2.7
@@ -22,18 +37,14 @@ rvm:
22
37
  - 2.2.2
23
38
  - 2.2.1
24
39
  - 2.2.0
40
+ - 2.1.10
25
41
  - 2.1.9
26
42
  - 2.1.8
27
43
  - 2.1.7
28
44
  - 2.1.6
29
45
  - 2.1.5
30
- - 2.1.4
31
- - 2.1.3
32
- - 2.1.2
33
- - 2.1.1
34
- - 2.0.0
35
- before_install:
36
- - gem update bundler
46
+ - 2.1.0
47
+ - 2.0.0-p648
37
48
  notifications:
38
49
  email: false
39
50
  slack:
@@ -16,4 +16,3 @@ require 'noir/command/edit'
16
16
  require 'noir/command/format'
17
17
  require 'noir/command/help'
18
18
  require 'noir/command/new'
19
- require 'noir/command/summarize'
@@ -3,12 +3,26 @@ class Noir::Command::New::Note < Noir::Base::TerminalCommand
3
3
 
4
4
  TimeFormat = '%Y%m%d'
5
5
  FileNameGlob = '[0-9]*_????????.txt'
6
+ SerialDigitRange = 1..3
6
7
 
7
8
  class << self
8
9
 
10
+ def serial_format number
11
+ digit_from_env = ENV['NOIR_NOTE_SERIAL_DIGIT']
12
+
13
+ # default digit is 2
14
+ digit = digit_from_env.nil? ? 2 : digit_from_env.to_i
15
+ if SerialDigitRange.cover?(digit)
16
+ return format("%0#{digit}d", number)
17
+ else
18
+ raise ["Invalid NOIR_NOTE_SERIAL_DIGIT=#{digit_from_env}.",
19
+ "supported digits are [#{SerialDigitRange.to_a.join(', ')}]."].join("\n")
20
+ end
21
+ end
22
+
9
23
  def create_new_note
10
24
  note_num = Dir.glob(FileNameGlob).size + 1
11
- note_name = format("%02d", note_num) + '_' + Time.now.strftime(TimeFormat) + '.txt'
25
+ note_name = serial_format(note_num) + '_' + Time.now.strftime(TimeFormat) + '.txt'
12
26
  Noir::Command::New.createFile note_name
13
27
  return note_name
14
28
  end
@@ -1,3 +1,3 @@
1
1
  module Noir
2
- VERSION = '0.1.11'
2
+ VERSION = '0.1.12'
3
3
  end
@@ -20,9 +20,9 @@ Gem::Specification.new do |spec|
20
20
 
21
21
  spec.required_ruby_version = '>= 2.0.0'
22
22
 
23
- spec.add_development_dependency 'bundler', '~> 1.6'
24
- spec.add_development_dependency 'rake', '12.3.1'
25
- spec.add_development_dependency 'rspec', '3.8.0'
26
- spec.add_development_dependency 'rspec-temp_dir', '1.0.0'
27
- spec.add_development_dependency 'pry', '0.11.3'
23
+ spec.add_development_dependency 'bundler'
24
+ spec.add_development_dependency 'rake'
25
+ spec.add_development_dependency 'rspec'
26
+ spec.add_development_dependency 'rspec-temp_dir'
27
+ spec.add_development_dependency 'pry'
28
28
  end
@@ -12,21 +12,79 @@ describe 'Noir::Command::New::Note' do
12
12
  expect{Noir::Command::New::Note.execute}.to output.to_stdout
13
13
  end
14
14
 
15
- it 'is support empty directory' do
16
- allow(Dir).to receive(:glob).with(anything).and_return([])
17
- expect(Noir::Command::New).to receive(:createFile)
18
- expect{Noir::Command::New::Note.execute}.to output(/^01_.*txt$/).to_stdout
15
+ describe 'supports empty directory' do
16
+ it 'default digit = 2' do
17
+ allow(Dir).to receive(:glob).with(anything).and_return([])
18
+ expect(Noir::Command::New).to receive(:createFile)
19
+ expect{Noir::Command::New::Note.execute}.to output(/^01_.*txt$/).to_stdout
20
+ end
21
+
22
+ it 'can set digit(1) using ENV' do
23
+ allow(ENV).to receive(:[]).with('NOIR_NOTE_SERIAL_DIGIT').and_return('1')
24
+ allow(Dir).to receive(:glob).with(anything).and_return([])
25
+ expect(Noir::Command::New).to receive(:createFile)
26
+ expect{Noir::Command::New::Note.execute}.to output(/^1_.*txt$/).to_stdout
27
+ end
28
+
29
+ it 'can set digit(3) using ENV' do
30
+ allow(ENV).to receive(:[]).with('NOIR_NOTE_SERIAL_DIGIT').and_return('3')
31
+ allow(Dir).to receive(:glob).with(anything).and_return([])
32
+ expect(Noir::Command::New).to receive(:createFile)
33
+ expect{Noir::Command::New::Note.execute}.to output(/^001_.*txt$/).to_stdout
34
+ end
19
35
  end
20
36
 
21
- it 'is support directory include few files' do
22
- allow(Dir).to receive(:glob).with(anything).and_return(10.times.to_a)
23
- expect(Noir::Command::New).to receive(:createFile)
24
- expect{Noir::Command::New::Note.execute}.to output(/^11_.*txt$/).to_stdout
37
+ describe 'supports directory has' do
38
+ it 'few files' do
39
+ allow(Dir).to receive(:glob).with(anything).and_return(10.times.to_a)
40
+ expect(Noir::Command::New).to receive(:createFile)
41
+ expect{Noir::Command::New::Note.execute}.to output(/^11_.*txt$/).to_stdout
42
+ end
43
+
44
+ it 'few files with digit config' do
45
+ allow(ENV).to receive(:[]).with('NOIR_NOTE_SERIAL_DIGIT').and_return('3')
46
+ allow(Dir).to receive(:glob).with(anything).and_return(15.times.to_a)
47
+ expect(Noir::Command::New).to receive(:createFile)
48
+ expect{Noir::Command::New::Note.execute}.to output(/^016_.*txt$/).to_stdout
49
+ end
50
+
51
+ it 'over 100 files' do
52
+ allow(Dir).to receive(:glob).with(anything).and_return(120.times.to_a)
53
+ expect(Noir::Command::New).to receive(:createFile)
54
+ expect{Noir::Command::New::Note.execute}.to output(/^121_.*txt$/).to_stdout
55
+ end
25
56
  end
26
57
 
27
- it 'is support directory include over 100 files' do
28
- allow(Dir).to receive(:glob).with(anything).and_return(120.times.to_a)
29
- expect(Noir::Command::New).to receive(:createFile)
30
- expect{Noir::Command::New::Note.execute}.to output(/^121_.*txt$/).to_stdout
58
+ describe 'has validation for NOIR_NOTE_SERIAL_DIGIT' do
59
+ it 'if set 0, raise error' do
60
+ allow(ENV).to receive(:[]).with('NOIR_NOTE_SERIAL_DIGIT').and_return('0')
61
+ allow(Dir).to receive(:glob).with(anything).and_return([])
62
+ expect{Noir::Command::New::Note.execute}.to raise_error(RuntimeError, /DIGIT.*0.*/)
63
+ end
64
+
65
+ it 'if set -1, raise error' do
66
+ allow(ENV).to receive(:[]).with('NOIR_NOTE_SERIAL_DIGIT').and_return('-1')
67
+ allow(Dir).to receive(:glob).with(anything).and_return([])
68
+ expect{Noir::Command::New::Note.execute}.to raise_error(RuntimeError, /DIGIT.*-1.*/)
69
+ end
70
+
71
+ it 'if set 4, raise error' do
72
+ allow(ENV).to receive(:[]).with('NOIR_NOTE_SERIAL_DIGIT').and_return('4')
73
+ allow(Dir).to receive(:glob).with(anything).and_return([])
74
+ expect{Noir::Command::New::Note.execute}.to raise_error(RuntimeError, /DIGIT.*4.*/)
75
+ end
76
+
77
+ it 'if set string, raise error' do
78
+ allow(ENV).to receive(:[]).with('NOIR_NOTE_SERIAL_DIGIT').and_return('abc')
79
+ allow(Dir).to receive(:glob).with(anything).and_return([])
80
+ expect{Noir::Command::New::Note.execute}.to raise_error(RuntimeError, /DIGIT.*abc.*/)
81
+ end
82
+
83
+ it 'if raise error, not create file' do
84
+ allow(ENV).to receive(:[]).with('NOIR_NOTE_SERIAL_DIGIT').and_return('hogehoge')
85
+ allow(Dir).to receive(:glob).with(anything).and_return([])
86
+ expect(Noir::Command::New).to_not receive(:createFile)
87
+ expect{Noir::Command::New::Note.execute}.to raise_error(RuntimeError, /DIGIT.*hoge.*/)
88
+ end
31
89
  end
32
90
  end
metadata CHANGED
@@ -1,85 +1,85 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: noir
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.11
4
+ version: 0.1.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - atton
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-08-08 00:00:00.000000000 Z
11
+ date: 2019-12-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '1.6'
19
+ version: '0'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - "~>"
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: '1.6'
26
+ version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - '='
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: 12.3.1
33
+ version: '0'
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
- version: 12.3.1
40
+ version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rspec
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - '='
45
+ - - ">="
46
46
  - !ruby/object:Gem::Version
47
- version: 3.8.0
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
53
  - !ruby/object:Gem::Version
54
- version: 3.8.0
54
+ version: '0'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: rspec-temp_dir
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - '='
59
+ - - ">="
60
60
  - !ruby/object:Gem::Version
61
- version: 1.0.0
61
+ version: '0'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - '='
66
+ - - ">="
67
67
  - !ruby/object:Gem::Version
68
- version: 1.0.0
68
+ version: '0'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: pry
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - '='
73
+ - - ">="
74
74
  - !ruby/object:Gem::Version
75
- version: 0.11.3
75
+ version: '0'
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - '='
80
+ - - ">="
81
81
  - !ruby/object:Gem::Version
82
- version: 0.11.3
82
+ version: '0'
83
83
  description: Untility commands with completion for atton.
84
84
  email:
85
85
  - e115763@gmail.com
@@ -119,9 +119,6 @@ files:
119
119
  - lib/noir/command/new/makefile.rb
120
120
  - lib/noir/command/new/makefile/tex.rb
121
121
  - lib/noir/command/new/note.rb
122
- - lib/noir/command/summarize.rb
123
- - lib/noir/command/summarize/note.rb
124
- - lib/noir/command/summarize/note/weekly.rb
125
122
  - lib/noir/executer.rb
126
123
  - lib/noir/options.rb
127
124
  - lib/noir/util.rb
@@ -153,9 +150,6 @@ files:
153
150
  - spec/noir/command/new/makefile_spec.rb
154
151
  - spec/noir/command/new/note_spec.rb
155
152
  - spec/noir/command/new_spec.rb
156
- - spec/noir/command/summarize/note/weekly_spec.rb
157
- - spec/noir/command/summarize/note_spec.rb
158
- - spec/noir/command/summarize_spec.rb
159
153
  - spec/noir/command_spec.rb
160
154
  - spec/noir/executer_spec.rb
161
155
  - spec/noir/noir/base/command_spec.rb
@@ -183,8 +177,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
183
177
  - !ruby/object:Gem::Version
184
178
  version: '0'
185
179
  requirements: []
186
- rubyforge_project:
187
- rubygems_version: 2.7.6
180
+ rubygems_version: 3.0.6
188
181
  signing_key:
189
182
  specification_version: 4
190
183
  summary: Utilities for atton.
@@ -214,9 +207,6 @@ test_files:
214
207
  - spec/noir/command/new/makefile_spec.rb
215
208
  - spec/noir/command/new/note_spec.rb
216
209
  - spec/noir/command/new_spec.rb
217
- - spec/noir/command/summarize/note/weekly_spec.rb
218
- - spec/noir/command/summarize/note_spec.rb
219
- - spec/noir/command/summarize_spec.rb
220
210
  - spec/noir/command_spec.rb
221
211
  - spec/noir/executer_spec.rb
222
212
  - spec/noir/noir/base/command_spec.rb
@@ -1,5 +0,0 @@
1
- class Noir::Command::Summarize < Noir::Base::Command
2
- @description = 'summarize utilities'
3
- end
4
-
5
- require 'noir/command/summarize/note'
@@ -1,5 +0,0 @@
1
- class Noir::Command::Summarize::Note < Noir::Base::Command
2
- @description = 'summarize notes'
3
- end
4
-
5
- require 'noir/command/summarize/note/weekly'
@@ -1,30 +0,0 @@
1
- class Noir::Command::Summarize::Note::Weekly < Noir::Base::Command
2
- @description = 'summarize notes weekly'
3
-
4
- extend Noir::Util::Weekly
5
- TimeFormat = '%Y%m%d'
6
-
7
- def self.summarize_by_week separator_day_of_week, week_diff=0
8
- begin_note = begin_of_week_separeted(separator_day_of_week, week_diff).strftime(TimeFormat)
9
- end_note = end_of_week_separeted(separator_day_of_week, week_diff).strftime(TimeFormat)
10
-
11
- note_names = (begin_note..end_note).map{|n| Dir.glob("*#{n}*").first}.compact
12
- puts note_names.flat_map {|name| ['-----' + name + '-----', File.read(name) ]}.join("\n")
13
- end
14
- end
15
-
16
- # Sub commands: specific day of week
17
- [:monday, :tuesday, :wednesday, :thursday, :friday, :saturday, :sunday].each do |day|
18
- clazz = Class.new(Noir::Base::TerminalCommand)
19
- clazz.class_eval do
20
- @description = "summarize notes weekly separated by #{day}"
21
- @day_of_week = day
22
- end
23
- clazz.class_eval do
24
- def self.execute *args
25
- week_diff = args.first.to_i || 0
26
- Noir::Command::Summarize::Note::Weekly.summarize_by_week @day_of_week, week_diff
27
- end
28
- end
29
- Noir::Command::Summarize::Note::Weekly.const_set(day.capitalize, clazz)
30
- end
@@ -1,44 +0,0 @@
1
- require 'noir'
2
- require 'spec_helper'
3
-
4
- describe 'Noir::Command::Summarize::Note::Weekly' do
5
- include_context :dependencie_on_current_directory
6
- dependent_time_now
7
-
8
- it 'is inherited Noir::Base::Command' do
9
- expect(Noir::Command::Summarize::Note::Weekly.superclass).to eq(Noir::Base::Command)
10
- end
11
-
12
- describe '.summarize_by_week' do
13
- before do
14
- File.write('01_20140401.txt', 'hoge') # 2014/04/01(Tue)
15
- File.write('02_20140402.txt', 'fuga') # 2014/04/02(Wed)
16
- File.write('03_20140403.txt', 'piyo') # 2014/04/03(Thu)
17
- end
18
-
19
- it 'include texts in .txt file' do
20
- expect{Noir::Command::Summarize::Note::Weekly.summarize_by_week(:tuesday)}.to output(/hoge/).to_stdout
21
- end
22
-
23
- it 'include all texts in weekly range' do
24
- expect{Noir::Command::Summarize::Note::Weekly.summarize_by_week(:monday)}.to output(/hoge/).to_stdout
25
- expect{Noir::Command::Summarize::Note::Weekly.summarize_by_week(:monday)}.to output(/fuga/).to_stdout
26
- expect{Noir::Command::Summarize::Note::Weekly.summarize_by_week(:monday)}.to output(/piyo/).to_stdout
27
- end
28
-
29
- it 'not include texts without weekly range' do
30
- expect{Noir::Command::Summarize::Note::Weekly.summarize_by_week(:wednesday)}.to output(/hoge/).to_stdout
31
- expect{Noir::Command::Summarize::Note::Weekly.summarize_by_week(:wednesday)}.not_to output(/fuga/).to_stdout
32
- expect{Noir::Command::Summarize::Note::Weekly.summarize_by_week(:wednesday)}.not_to output(/piyo/).to_stdout
33
- end
34
- end
35
-
36
- describe 'sub commands' do
37
- [:monday, :tuesday, :wednesday, :thursday, :friday, :saturday, :sunday].each do |day|
38
- it 'is inherited Noir::Base::TerminalCommand' do
39
- sub_command = Noir::Command::Summarize::Note::Weekly.const_get day.capitalize
40
- expect(sub_command.superclass).to eq(Noir::Base::TerminalCommand)
41
- end
42
- end
43
- end
44
- end
@@ -1,9 +0,0 @@
1
- require 'noir'
2
- require 'spec_helper'
3
-
4
- describe 'Noir::Command::Summarize::Note' do
5
- it 'is inherited Noir::Base::Command' do
6
- expect(Noir::Command::Summarize::Note.superclass).to eq(Noir::Base::Command)
7
- end
8
- end
9
-
@@ -1,10 +0,0 @@
1
- require 'noir'
2
- require 'spec_helper'
3
-
4
- describe 'Noir::Command::Summarize' do
5
- it 'is inherited Noir::Base::Command' do
6
- expect(Noir::Command::Summarize.superclass).to eq(Noir::Base::Command)
7
- end
8
- end
9
-
10
-