Class: Epuber::Command::Init
- Inherits:
-
Epuber::Command
- Object
- CLAide::Command
- Epuber::Command
- Epuber::Command::Init
- Defined in:
- lib/epuber/command/init.rb
Instance Method Summary collapse
-
#initialize(argv) ⇒ Init
constructor
A new instance of Init.
- #run ⇒ Object
- #validate! ⇒ Object
Methods inherited from Epuber::Command
Constructor Details
#initialize(argv) ⇒ Init
Returns a new instance of Init.
19 20 21 22 23 |
# File 'lib/epuber/command/init.rb', line 19 def initialize(argv) @book_name = argv.arguments!.first super(argv) end |
Instance Method Details
#run ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/epuber/command/init.rb', line 32 def run super write_gitignore write_bookspec(@book_name) write_sublime_project(@book_name) FileUtils.mkdir_p('images') FileUtils.mkdir_p('fonts') FileUtils.mkdir_p('styles') write_default_style(@book_name) FileUtils.mkdir_p('text') print_good_bye(@book_name) end |
#validate! ⇒ Object
25 26 27 28 29 30 |
# File 'lib/epuber/command/init.rb', line 25 def validate! help! 'You must specify identifier-like name of the book as first argument' if @book_name.nil? existing = Dir.glob('*.bookspec') help! "Can't reinit this folder, #{existing.first} already exists." unless existing.empty? end |