diff --git a/lib/html2rss/generator/channel_question.rb b/lib/html2rss/generator/channel_question.rb index eaae4fb..05b159b 100644 --- a/lib/html2rss/generator/channel_question.rb +++ b/lib/html2rss/generator/channel_question.rb @@ -2,7 +2,7 @@ require 'faraday' -require_relative './question' +require_relative 'question' module Html2rss module Generator diff --git a/lib/html2rss/generator/collector.rb b/lib/html2rss/generator/collector.rb index 858b37e..e6123c8 100644 --- a/lib/html2rss/generator/collector.rb +++ b/lib/html2rss/generator/collector.rb @@ -1,8 +1,8 @@ # frozen_string_literal: true -require_relative './channel_question' -require_relative './items_selector_question' -require_relative './selector_question' +require_relative 'channel_question' +require_relative 'items_selector_question' +require_relative 'selector_question' module Html2rss module Generator diff --git a/lib/html2rss/generator/file_create_question.rb b/lib/html2rss/generator/file_create_question.rb index f387896..6edac36 100644 --- a/lib/html2rss/generator/file_create_question.rb +++ b/lib/html2rss/generator/file_create_question.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true require 'fileutils' -require_relative './files_and_paths' +require_relative 'files_and_paths' module Html2rss module Generator @@ -19,6 +19,26 @@ class FileCreateQuestion attr_reader :prompt, :feed_config, :channel_url + def self.print_files(relative_yml_path, relative_spec_path) + PrintHelper.markdown <<~MARKDOWN + Created YAML file at: + `#{relative_yml_path}` + + Created spec file at: + `#{relative_spec_path}` + + Use this config to generate RSS with: + `bundle exec html2rss feed #{relative_yml_path}` + MARKDOWN + end + + def self.create_file(file_path, content) + raise 'file exists already' if File.exist? file_path + + FileUtils.mkdir_p File.dirname(file_path) + File.write(file_path, content) + end + def initialize(prompt, state, **_options) @prompt = prompt @state = state @@ -40,26 +60,6 @@ def ask create(fps) end - def self.print_files(relative_yml_path, relative_spec_path) - PrintHelper.markdown <<~MARKDOWN - Created YAML file at: - `#{relative_yml_path}` - - Created spec file at: - `#{relative_spec_path}` - - Use this config to generate RSS with: - `bundle exec html2rss feed #{relative_yml_path}` - MARKDOWN - end - - def self.create_file(file_path, content) - raise 'file exists already' if File.exist? file_path - - FileUtils.mkdir_p File.dirname(file_path) - File.write(file_path, content) - end - private def print_feed_config diff --git a/lib/html2rss/generator/files_and_paths.rb b/lib/html2rss/generator/files_and_paths.rb index f539ef1..6e6b665 100644 --- a/lib/html2rss/generator/files_and_paths.rb +++ b/lib/html2rss/generator/files_and_paths.rb @@ -7,6 +7,12 @@ module Generator class FilesAndPaths attr_reader :config_name, :config_dir + ## + # @return [String] + def self.gem_root + File.expand_path(File.join(__dir__, '../../../..')) + end + def initialize(config_name, config_dir) raise 'config_name is required' if config_name.to_s == '' raise 'config_dir is required' if config_dir.to_s == '' @@ -15,12 +21,6 @@ def initialize(config_name, config_dir) @config_dir = config_dir end - ## - # @return [String] - def self.gem_root - File.expand_path(File.join(__dir__, '../../../..')) - end - ## # @return [String] def yml_dir diff --git a/lib/html2rss/generator/helper.rb b/lib/html2rss/generator/helper.rb index dfd3034..4ef6f14 100644 --- a/lib/html2rss/generator/helper.rb +++ b/lib/html2rss/generator/helper.rb @@ -4,7 +4,7 @@ require 'nokogiri' require 'yaml' -require_relative './print_helper' +require_relative 'print_helper' module Html2rss module Generator diff --git a/lib/html2rss/generator/items_selector_question.rb b/lib/html2rss/generator/items_selector_question.rb index 1cda9cb..78c4604 100644 --- a/lib/html2rss/generator/items_selector_question.rb +++ b/lib/html2rss/generator/items_selector_question.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -require_relative './selector_question' +require_relative 'selector_question' module Html2rss module Generator diff --git a/lib/html2rss/generator/question.rb b/lib/html2rss/generator/question.rb index 9108265..2deff2b 100644 --- a/lib/html2rss/generator/question.rb +++ b/lib/html2rss/generator/question.rb @@ -7,6 +7,10 @@ module Generator class Question attr_reader :state, :prompt_options, :prompt + def self.validate(input:, **_opts) + input.to_s != '' + end + def initialize(prompt, state, **options) @prompt = prompt @state = state @@ -28,10 +32,6 @@ def ask state.store(path, processed_input) if path end - def self.validate(input:, **_opts) - input.to_s != '' - end - private def process(input) diff --git a/lib/html2rss/generator/selector_question.rb b/lib/html2rss/generator/selector_question.rb index 04097ea..a9baaaf 100644 --- a/lib/html2rss/generator/selector_question.rb +++ b/lib/html2rss/generator/selector_question.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true -require_relative './question' -require_relative './item_extractor_question' +require_relative 'question' +require_relative 'item_extractor_question' module Html2rss module Generator