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
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/epuber/command/init.rb', line 34 def run super write_gitignore write_bookspec(@book_name) write_sublime_project(@book_name) create_folder('images') create_folder('fonts') create_folder('styles') write_default_style(@book_name) create_folder('text') print_good_bye(@book_name) end |
#validate! ⇒ Object
25 26 27 28 29 30 31 32 |
# File 'lib/epuber/command/init.rb', line 25 def validate! super 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 |