Class: Rowr::Prompter
- Inherits:
-
Object
- Object
- Rowr::Prompter
- Defined in:
- lib/rowr/prompter.rb
Instance Attribute Summary collapse
-
#check_external_urls ⇒ Object
Returns the value of attribute check_external_urls.
-
#exts_to_use ⇒ Object
Returns the value of attribute exts_to_use.
-
#new_base_path ⇒ Object
Returns the value of attribute new_base_path.
-
#old_host ⇒ Object
Returns the value of attribute old_host.
-
#source_directory ⇒ Object
Returns the value of attribute source_directory.
Instance Method Summary collapse
- #additional_exts? ⇒ Boolean
- #ask_for_other_source_directory ⇒ Object
- #check_external_urls? ⇒ Boolean
- #dir_select ⇒ Object
- #generate_hash ⇒ Object
-
#initialize ⇒ Prompter
constructor
A new instance of Prompter.
- #new_base_path? ⇒ Boolean
- #old_host? ⇒ Boolean
- #source_directory? ⇒ Boolean
Constructor Details
#initialize ⇒ Prompter
Returns a new instance of Prompter.
13 14 15 |
# File 'lib/rowr/prompter.rb', line 13 def initialize @prompt = TTY::Prompt.new end |
Instance Attribute Details
#check_external_urls ⇒ Object
Returns the value of attribute check_external_urls.
11 12 13 |
# File 'lib/rowr/prompter.rb', line 11 def check_external_urls @check_external_urls end |
#exts_to_use ⇒ Object
Returns the value of attribute exts_to_use.
8 9 10 |
# File 'lib/rowr/prompter.rb', line 8 def exts_to_use @exts_to_use end |
#new_base_path ⇒ Object
Returns the value of attribute new_base_path.
10 11 12 |
# File 'lib/rowr/prompter.rb', line 10 def new_base_path @new_base_path end |
#old_host ⇒ Object
Returns the value of attribute old_host.
9 10 11 |
# File 'lib/rowr/prompter.rb', line 9 def old_host @old_host end |
#source_directory ⇒ Object
Returns the value of attribute source_directory.
7 8 9 |
# File 'lib/rowr/prompter.rb', line 7 def source_directory @source_directory end |
Instance Method Details
#additional_exts? ⇒ Boolean
85 86 87 88 |
# File 'lib/rowr/prompter.rb', line 85 def additional_exts? @prompt.say('By default, I\'ll will scan any .html and .htm files.') self.exts_to_use = @prompt.ask('Please list any other extensions, or hit Enter to skip') end |
#ask_for_other_source_directory ⇒ Object
61 62 63 64 65 66 67 68 69 70 |
# File 'lib/rowr/prompter.rb', line 61 def ask_for_other_source_directory dir = @prompt.ask('Please type in the path to that directory?') do |q| q.required true end unless Dir.exist?(File.(dir)) @prompt.error("Sorry, #{dir} doesn't seem to exist") ask_for_other_source_directory end dir end |
#check_external_urls? ⇒ Boolean
94 95 96 97 98 99 100 101 |
# File 'lib/rowr/prompter.rb', line 94 def check_external_urls? self.check_external_urls = @prompt.select('If I find an link to an external site, what should I do?') do || .default 1 .choice 'Ask me about it', true .choice 'Skip it', false end end |
#dir_select ⇒ Object
52 53 54 55 56 57 58 59 |
# File 'lib/rowr/prompter.rb', line 52 def dir_select @prompt.select('Where is this really old website?') do || .default 1 .choice "#{Dir.pwd} (The current dir)", 1 .choice "Another directory?", 2 end end |
#generate_hash ⇒ Object
103 104 105 106 107 108 109 110 111 |
# File 'lib/rowr/prompter.rb', line 103 def generate_hash { source_directory: source_directory, exts_to_use: exts_to_use, old_host: old_host, new_base_path: new_base_path, check_external_urls: check_external_urls } end |
#new_base_path? ⇒ Boolean
90 91 92 |
# File 'lib/rowr/prompter.rb', line 90 def new_base_path? self.new_base_path = @prompt.ask('What will be the url of the resurrected site?') end |
#old_host? ⇒ Boolean
72 73 74 |
# File 'lib/rowr/prompter.rb', line 72 def old_host? self.old_host = @prompt.ask('What was the old host? (e.g. www.google.com)') end |
#source_directory? ⇒ Boolean
76 77 78 79 80 81 82 83 |
# File 'lib/rowr/prompter.rb', line 76 def source_directory? self.source_directory = case dir_select when 1 Dir.pwd when 2 ask_for_other_source_directory end end |