noir 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/noir.rb +0 -1
- data/lib/noir/base/command.rb +4 -1
- data/lib/noir/base/terminal_command.rb +4 -0
- data/lib/noir/command/completion.rb +0 -4
- data/lib/noir/command/edit/weekly_report/friday.rb +1 -1
- data/lib/noir/command/edit/weekly_report/monday.rb +1 -1
- data/lib/noir/command/edit/weekly_report/saturday.rb +1 -1
- data/lib/noir/command/edit/weekly_report/sunday.rb +1 -1
- data/lib/noir/command/edit/weekly_report/thursday.rb +1 -1
- data/lib/noir/command/edit/weekly_report/tuesday.rb +1 -1
- data/lib/noir/command/edit/weekly_report/wednesday.rb +1 -1
- data/lib/noir/command/new.rb +9 -0
- data/lib/noir/command/new/gitignore.rb +13 -0
- data/lib/noir/command/new/gitignore/tex.rb +19 -0
- data/lib/noir/command/new/gitignore/vim.rb +13 -0
- data/lib/noir/command/new/makefile.rb +11 -0
- data/lib/noir/command/new/makefile/tex.rb +34 -0
- data/lib/noir/command/new/note.rb +2 -2
- data/lib/noir/executer.rb +7 -8
- data/lib/noir/version.rb +1 -1
- data/noir.gemspec +2 -0
- data/spec/noir/command/new/gitignore/tex_spec.rb +8 -0
- data/spec/noir/command/new/gitignore/vim_spec.rb +10 -0
- data/spec/noir/command/new/gitignore_spec.rb +9 -0
- data/spec/noir/command/new/makefile/tex_spec.rb +9 -0
- data/spec/noir/command/new/makefile_spec.rb +10 -0
- data/spec/noir/executer_spec.rb +26 -0
- data/spec/noir/noir/base/command_spec.rb +5 -0
- metadata +18 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 87a92fb27d6501f841713ec7f5972152c1df2b02
|
4
|
+
data.tar.gz: 3b4585476354ecdee659faf9c14f00f8fc89ff71
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 730faf4b77365e52fa48aac8cd44b5de86678ebac29cbadabc4ce158c66232d7c4caef1ba26cda40479b09b5a08033a6fd714775a1a87e49ab62d6e9d514009b
|
7
|
+
data.tar.gz: c4dd7f89a0f889d030737bfba74ccb43bc6f1ef11a74eeb7ec5bf792a951851af5b2e0bd8536ac06b829c5f4c59565adc4cc772a43c964b94a65d383746a9b83
|
data/lib/noir.rb
CHANGED
data/lib/noir/base/command.rb
CHANGED
@@ -27,7 +27,10 @@ module Noir::Base
|
|
27
27
|
|
28
28
|
def sub_commands
|
29
29
|
consts = constants - superclass.constants
|
30
|
-
consts = consts.select
|
30
|
+
consts = consts.select do |const|
|
31
|
+
const_get(const).class == Class &&
|
32
|
+
const_get(const).ancestors.include?(Noir::Base::Command)
|
33
|
+
end
|
31
34
|
end
|
32
35
|
|
33
36
|
def check_command_not_found command=nil, *args
|
data/lib/noir/command/new.rb
CHANGED
@@ -1,5 +1,14 @@
|
|
1
1
|
class Noir::Command::New < Noir::Base::Command
|
2
2
|
@description = 'Create new files'
|
3
|
+
|
4
|
+
def self.createFile filename, text=''
|
5
|
+
File.open(filename, 'w') do |file|
|
6
|
+
file.write(text.sub(/^\n/, ''))
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
3
10
|
end
|
4
11
|
|
5
12
|
require 'noir/command/new/note'
|
13
|
+
require 'noir/command/new/gitignore'
|
14
|
+
require 'noir/command/new/makefile'
|
@@ -0,0 +1,13 @@
|
|
1
|
+
class Noir::Command::New::GitIgnore < Noir::Base::Command
|
2
|
+
@description = 'Create new .gitignore'
|
3
|
+
|
4
|
+
GitIgnoreName = '.gitignore'
|
5
|
+
|
6
|
+
def self.createGitIgnore text
|
7
|
+
Noir::Command::New.createFile(GitIgnoreName, text)
|
8
|
+
end
|
9
|
+
|
10
|
+
end
|
11
|
+
|
12
|
+
require 'noir/command/new/gitignore/vim'
|
13
|
+
require 'noir/command/new/gitignore/tex'
|
@@ -0,0 +1,19 @@
|
|
1
|
+
class Noir::Command::New::GitIgnore::Tex < Noir::Base::TerminalCommand
|
2
|
+
@description = 'Create new .gitignore for TeX'
|
3
|
+
|
4
|
+
GitIgnoreText = %q(
|
5
|
+
*.swp
|
6
|
+
|
7
|
+
*.log
|
8
|
+
*.aux
|
9
|
+
*.dvi
|
10
|
+
*.pdf
|
11
|
+
*.toc
|
12
|
+
)
|
13
|
+
|
14
|
+
def self.execute *args
|
15
|
+
Noir::Command::New::GitIgnore.createGitIgnore GitIgnoreText
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
19
|
+
|
@@ -0,0 +1,13 @@
|
|
1
|
+
class Noir::Command::New::GitIgnore::Vim < Noir::Base::TerminalCommand
|
2
|
+
@description = 'Create new .gitignore for vim'
|
3
|
+
|
4
|
+
GitIgnoreText = %q(
|
5
|
+
*.swp
|
6
|
+
)
|
7
|
+
|
8
|
+
def self.execute *args
|
9
|
+
Noir::Command::New::GitIgnore.createGitIgnore GitIgnoreText
|
10
|
+
end
|
11
|
+
|
12
|
+
end
|
13
|
+
|
@@ -0,0 +1,11 @@
|
|
1
|
+
class Noir::Command::New::Makefile < Noir::Base::Command
|
2
|
+
@description = 'Create new Makefile'
|
3
|
+
|
4
|
+
MakefileName = 'Makefile'
|
5
|
+
|
6
|
+
def self.createMakefile text
|
7
|
+
Noir::Command::New.createFile(MakefileName, text)
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
require 'noir/command/new/makefile/tex'
|
@@ -0,0 +1,34 @@
|
|
1
|
+
class Noir::Command::New::Makefile::Tex < Noir::Base::TerminalCommand
|
2
|
+
@description = 'Create new Makefile for TeX'
|
3
|
+
|
4
|
+
MakefileText = %q(
|
5
|
+
# target name
|
6
|
+
TARGET=<tex_file_name_without_extension>
|
7
|
+
|
8
|
+
# dependencies
|
9
|
+
$(TARGET).pdf : $(TARGET).dvi
|
10
|
+
dvipdfmx $<
|
11
|
+
|
12
|
+
$(TARGET).dvi : $(wildcard **/*.tex) $(TARGET).tex
|
13
|
+
platex $(TARGET).tex
|
14
|
+
platex $(TARGET).tex
|
15
|
+
platex $(TARGET).tex
|
16
|
+
|
17
|
+
# commands
|
18
|
+
.PHONY : all open clean
|
19
|
+
|
20
|
+
all : $(TARGET).pdf
|
21
|
+
|
22
|
+
open : $(TARGET).pdf
|
23
|
+
open $(TARGET).pdf
|
24
|
+
|
25
|
+
clean:
|
26
|
+
rm -f *.dvi *.aux *.log *.pdf *.ps *.gz *.bbl *.blg *.toc *~ *.core
|
27
|
+
)
|
28
|
+
|
29
|
+
def self.execute *args
|
30
|
+
Noir::Command::New::Makefile.createMakefile MakefileText
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
34
|
+
|
@@ -1,5 +1,4 @@
|
|
1
1
|
require 'date'
|
2
|
-
require 'fileutils'
|
3
2
|
|
4
3
|
class Noir::Command::New::Note < Noir::Base::TerminalCommand
|
5
4
|
@description = 'create empty txt. filename format is <serial-no>_<date>.txt'
|
@@ -9,7 +8,8 @@ class Noir::Command::New::Note < Noir::Base::TerminalCommand
|
|
9
8
|
def execute *args
|
10
9
|
note_num = Dir.glob('[0-9]*_????????.txt').size + 1
|
11
10
|
note_name = format("%02d", note_num) + '_' + Time.now.strftime('%Y%m%d') + '.txt'
|
12
|
-
|
11
|
+
Noir::Command::New.createFile note_name
|
12
|
+
puts note_name
|
13
13
|
end
|
14
14
|
|
15
15
|
end
|
data/lib/noir/executer.rb
CHANGED
@@ -6,19 +6,12 @@ module Noir
|
|
6
6
|
def self.find_command command_arr, search_str
|
7
7
|
command = eval(command_arr.join('::'))
|
8
8
|
|
9
|
-
|
10
|
-
return nil if command.superclass == Noir::Base::TerminalCommand
|
11
|
-
|
12
|
-
commands = command.constants(true).map(&:to_s)
|
9
|
+
commands = command.sub_commands.map(&:to_s)
|
13
10
|
matched_str = commands.find{|c| c.downcase == search_str.downcase}
|
14
11
|
matched_str = find_abbr_command(commands, search_str) if matched_str.nil?
|
15
12
|
|
16
13
|
return nil if matched_str.nil?
|
17
14
|
matched_arr = command_arr + [matched_str]
|
18
|
-
unless eval(matched_arr.join('::')).ancestors.include?(Noir::Base::Command)
|
19
|
-
# matched. but matched class is not inherited commmand
|
20
|
-
return nil
|
21
|
-
end
|
22
15
|
|
23
16
|
return matched_str
|
24
17
|
end
|
@@ -60,6 +53,12 @@ module Noir
|
|
60
53
|
# inherited methods
|
61
54
|
|
62
55
|
def self.execute
|
56
|
+
Noir::Options.parse_options_from_argv!
|
57
|
+
|
58
|
+
if Noir::Options.exist? Noir::Options::Help
|
59
|
+
return command_from_argv.description
|
60
|
+
end
|
61
|
+
|
63
62
|
command_from_argv.execute *args_from_argv
|
64
63
|
end
|
65
64
|
|
data/lib/noir/version.rb
CHANGED
data/noir.gemspec
CHANGED
@@ -18,6 +18,8 @@ Gem::Specification.new do |spec|
|
|
18
18
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
19
|
spec.require_paths = ["lib"]
|
20
20
|
|
21
|
+
spec.required_ruby_version = '>= 1.9.2'
|
22
|
+
|
21
23
|
spec.add_development_dependency "bundler", "~> 1.5"
|
22
24
|
spec.add_development_dependency "rake", "10.1.1"
|
23
25
|
spec.add_development_dependency "rspec", "3.0.0.beta2"
|
data/spec/noir/executer_spec.rb
CHANGED
@@ -204,4 +204,30 @@ describe 'Noir::Executer' do
|
|
204
204
|
end # in defined argv
|
205
205
|
|
206
206
|
end # args_from_argv
|
207
|
+
|
208
|
+
describe 'execute' do
|
209
|
+
let(:mock_command) { double('Noir::Base::Command') }
|
210
|
+
|
211
|
+
before do
|
212
|
+
stub_const 'Noir::Executer', Noir::Executer
|
213
|
+
allow(Noir::Executer).to receive(:command_from_argv).and_return(mock_command)
|
214
|
+
|
215
|
+
allow(mock_command).to receive(:execute).and_return(:call_execute)
|
216
|
+
allow(mock_command).to receive(:description).and_return(:call_description)
|
217
|
+
end
|
218
|
+
|
219
|
+
it 'not has help flag. execute command.execute' do
|
220
|
+
expect(Noir::Executer.execute).to eq(:call_execute)
|
221
|
+
end
|
222
|
+
|
223
|
+
it 'has help option. execute command.describe' do
|
224
|
+
stub_const 'ARGV', ['-h']
|
225
|
+
expect(Noir::Executer.execute).to eq(:call_description)
|
226
|
+
end
|
227
|
+
|
228
|
+
it 'has log help option. execute command.describe' do
|
229
|
+
stub_const 'ARGV', ['--help']
|
230
|
+
expect(Noir::Executer.execute).to eq(:call_description)
|
231
|
+
end
|
232
|
+
end # execute
|
207
233
|
end
|
@@ -54,6 +54,7 @@ describe 'Noir::Base::Command' do
|
|
54
54
|
stub_const('Hoge::SubCommand' , Class.new(Noir::Base::Command))
|
55
55
|
stub_const('Hoge::SubCommand::SubSubCommand' , Class.new(Noir::Base::Command))
|
56
56
|
stub_const('Hoge::SubCommand::SubSubNonCommand' , Class.new)
|
57
|
+
stub_const('Hoge::SubCommand::NotCommand' , :not_command)
|
57
58
|
stub_const('Hoge::SubCommandTwo' , Class.new(Noir::Base::Command))
|
58
59
|
stub_const('Hoge::SubNonCommand' , Class.new)
|
59
60
|
|
@@ -112,6 +113,10 @@ describe 'Noir::Base::Command' do
|
|
112
113
|
expect(@commands).not_to include(:SubCommand)
|
113
114
|
end
|
114
115
|
|
116
|
+
it 'not include non class const' do
|
117
|
+
expect(@commands).not_to include(:not_command)
|
118
|
+
end
|
119
|
+
|
115
120
|
end
|
116
121
|
end
|
117
122
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: noir
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- atton
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-04-
|
11
|
+
date: 2014-04-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -85,6 +85,11 @@ files:
|
|
85
85
|
- lib/noir/command/init.rb
|
86
86
|
- lib/noir/command/init/zsh.rb
|
87
87
|
- lib/noir/command/new.rb
|
88
|
+
- lib/noir/command/new/gitignore.rb
|
89
|
+
- lib/noir/command/new/gitignore/tex.rb
|
90
|
+
- lib/noir/command/new/gitignore/vim.rb
|
91
|
+
- lib/noir/command/new/makefile.rb
|
92
|
+
- lib/noir/command/new/makefile/tex.rb
|
88
93
|
- lib/noir/command/new/note.rb
|
89
94
|
- lib/noir/executer.rb
|
90
95
|
- lib/noir/options.rb
|
@@ -103,6 +108,11 @@ files:
|
|
103
108
|
- spec/noir/command/help_spec.rb
|
104
109
|
- spec/noir/command/init/zsh_spec.rb
|
105
110
|
- spec/noir/command/init_spec.rb
|
111
|
+
- spec/noir/command/new/gitignore/tex_spec.rb
|
112
|
+
- spec/noir/command/new/gitignore/vim_spec.rb
|
113
|
+
- spec/noir/command/new/gitignore_spec.rb
|
114
|
+
- spec/noir/command/new/makefile/tex_spec.rb
|
115
|
+
- spec/noir/command/new/makefile_spec.rb
|
106
116
|
- spec/noir/command/new/note_spec.rb
|
107
117
|
- spec/noir/command/new_spec.rb
|
108
118
|
- spec/noir/command_spec.rb
|
@@ -125,7 +135,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
125
135
|
requirements:
|
126
136
|
- - ">="
|
127
137
|
- !ruby/object:Gem::Version
|
128
|
-
version:
|
138
|
+
version: 1.9.2
|
129
139
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
130
140
|
requirements:
|
131
141
|
- - ">="
|
@@ -151,6 +161,11 @@ test_files:
|
|
151
161
|
- spec/noir/command/help_spec.rb
|
152
162
|
- spec/noir/command/init/zsh_spec.rb
|
153
163
|
- spec/noir/command/init_spec.rb
|
164
|
+
- spec/noir/command/new/gitignore/tex_spec.rb
|
165
|
+
- spec/noir/command/new/gitignore/vim_spec.rb
|
166
|
+
- spec/noir/command/new/gitignore_spec.rb
|
167
|
+
- spec/noir/command/new/makefile/tex_spec.rb
|
168
|
+
- spec/noir/command/new/makefile_spec.rb
|
154
169
|
- spec/noir/command/new/note_spec.rb
|
155
170
|
- spec/noir/command/new_spec.rb
|
156
171
|
- spec/noir/command_spec.rb
|