Module: AutoPilot
- Defined in:
- lib/auto_pilot.rb,
lib/auto_pilot/api.rb,
lib/auto_pilot/request.rb,
lib/auto_pilot/util/log.rb,
lib/auto_pilot/configure.rb,
lib/auto_pilot/util/version.rb,
lib/auto_pilot/url_formatter.rb,
lib/auto_pilot/html_converter.rb,
lib/auto_pilot/document_parser.rb,
lib/auto_pilot/template_helper.rb,
lib/auto_pilot/markdown_converter.rb
Defined Under Namespace
Modules: TemplateHelper, URLFormatter Classes: API, Config, DocumentParser, HtmlConverter, Log, MarkdownConverter, Request
Constant Summary collapse
- BASE_URL =
'http://stackoverflow.com/questions'- VERSION =
'0.3.0'
Class Attribute Summary collapse
-
.configuration ⇒ Object
Returns the value of attribute configuration.
Class Method Summary collapse
- .configure {|configuration| ... } ⇒ Object
-
.get_api_answers ⇒ Object
def get_answers(_user = ”, _options = {}) # TODO: id stubs, replace with API question_ids = [19_348_076] answer_ids = [25_536_701] parsed_documents = [] question_ids.each do |id| doc = Request.fetch page_with_my_answer(id) parsed_documents << DocumentParser.new(doc, id, answer_ids.first) end parsed_documents end.
- .page_with_my_answer(id) ⇒ Object
- .write_files(parsed_documents) ⇒ Object
Class Attribute Details
.configuration ⇒ Object
Returns the value of attribute configuration.
3 4 5 |
# File 'lib/auto_pilot/configure.rb', line 3 def configuration @configuration end |
Class Method Details
.configure {|configuration| ... } ⇒ Object
6 7 8 9 10 |
# File 'lib/auto_pilot/configure.rb', line 6 def self.configure self.configuration ||= Config.new yield configuration configuration end |
.get_api_answers ⇒ Object
def get_answers(_user = ”, _options = {})
# TODO: id stubs, replace with API
question_ids = [19_348_076]
answer_ids = [25_536_701]
parsed_documents = []
question_ids.each do |id|
doc = Request.fetch page_with_my_answer(id)
parsed_documents << DocumentParser.new(doc, id, answer_ids.first)
end
parsed_documents
end
25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/auto_pilot.rb', line 25 def get_api_answers parsed_documents = [] answers = AutoPilot::API.new.get_answers answers.each do |answer| question_id = answer[:question_id] answer_id = answer[:answer_id] url = page_with_my_answer(question_id) doc = Request.fetch url # Log.green "question id #{question_id} | answer id #{answer_id}" parsed_documents << DocumentParser.new(doc, question_id, answer_id) end parsed_documents end |
.page_with_my_answer(id) ⇒ Object
39 40 41 |
# File 'lib/auto_pilot.rb', line 39 def page_with_my_answer(id) "#{BASE_URL}/#{id}/" end |
.write_files(parsed_documents) ⇒ Object
43 44 45 46 47 48 |
# File 'lib/auto_pilot.rb', line 43 def write_files(parsed_documents) parsed_documents.each do |doc| HtmlConverter.new doc if AutoPilot.configuration.format.include? :html MarkdownConverter.new doc if AutoPilot.configuration.format.include? :md end end |