Class: Chocomint::Tools::MakeDir
- Defined in:
- lib/chocomint/tools/make_dir.rb
Overview
許可ディレクトリ内にディレクトリを作成する (親も含め mkdir_p)。
Instance Method Summary collapse
- #call(args) ⇒ Object
- #description ⇒ Object
-
#initialize(path_guard:) ⇒ MakeDir
constructor
A new instance of MakeDir.
- #name ⇒ Object
- #schema ⇒ Object
Methods inherited from Base
Constructor Details
#initialize(path_guard:) ⇒ MakeDir
Returns a new instance of MakeDir.
9 10 11 |
# File 'lib/chocomint/tools/make_dir.rb', line 9 def initialize(path_guard:) @path_guard = path_guard end |
Instance Method Details
#call(args) ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/chocomint/tools/make_dir.rb', line 30 def call(args) measure do abs = @path_guard.resolve(args["path"]) if File.file?(abs) next fail(stderr: "a file already exists at #{args['path']}") end require "fileutils" FileUtils.mkdir_p(abs) ok(stdout: "created directory #{args['path']}") end end |
#description ⇒ Object
15 16 17 |
# File 'lib/chocomint/tools/make_dir.rb', line 15 def description "指定パスにディレクトリを作成する (親ディレクトリも作成)。path は許可ディレクトリ内であること。" end |
#name ⇒ Object
13 |
# File 'lib/chocomint/tools/make_dir.rb', line 13 def name = "make_dir" |
#schema ⇒ Object
19 20 21 22 23 24 25 26 27 28 |
# File 'lib/chocomint/tools/make_dir.rb', line 19 def schema { "type" => "object", "properties" => { "path" => { "type" => "string" } }, "required" => %w[path], "additionalProperties" => false } end |