Class: Vivlio::Starter::CLI::DeleteCommands::ChapterDeletion
- Inherits:
-
Object
- Object
- Vivlio::Starter::CLI::DeleteCommands::ChapterDeletion
- Defined in:
- lib/vivlio/starter/cli/delete.rb
Overview
章ファイルと関連リソースの削除処理を担う
削除対象:
- contents/XX-slug.md(章 Markdown)
- images/XX-slug/(章画像ディレクトリ)
- config/catalog.yml 内の該当エントリ
Instance Method Summary collapse
-
#initialize(options) ⇒ ChapterDeletion
constructor
A new instance of ChapterDeletion.
-
#preview(basename) ⇒ void
dry-run モード用: 削除予定を表示する(実際の削除は行わない).
-
#remove(basename) ⇒ void
章ファイルと関連リソースを削除する.
Constructor Details
#initialize(options) ⇒ ChapterDeletion
Returns a new instance of ChapterDeletion.
194 195 196 |
# File 'lib/vivlio/starter/cli/delete.rb', line 194 def initialize() @options = end |
Instance Method Details
#preview(basename) ⇒ void
This method returns an undefined value.
dry-run モード用: 削除予定を表示する(実際の削除は行わない)
202 203 204 205 206 207 208 209 |
# File 'lib/vivlio/starter/cli/delete.rb', line 202 def preview(basename) base = basename.sub(/\.md\z/, '') md_file = File.join(Common::CONTENTS_DIR, basename) img_dir = File.join(Common::IMAGES_DIR, base) Common.log_always "[DRY-RUN] #{base} の削除予定:" Common.log_always " - 文書: #{md_file} #{File.exist?(md_file) ? '(exists)' : '(not found)'}" Common.log_always " - 画像Dir: #{img_dir} #{Dir.exist?(img_dir) ? '(exists)' : '(not found)'}" end |
#remove(basename) ⇒ void
This method returns an undefined value.
章ファイルと関連リソースを削除する
副作用:
- contents/XX-slug.md を削除
- images/XX-slug/ ディレクトリを削除
- config/catalog.yml から該当エントリを削除
220 221 222 223 224 225 226 227 |
# File 'lib/vivlio/starter/cli/delete.rb', line 220 def remove(basename) delete_markdown_file(basename) delete_image_directory(basename) # catalog.yml からも削除することで build 時に含まれなくなる base = basename.sub(/\.md\z/, '') Build::CatalogUpdater.remove_chapter(base) end |