Class: SearchTerms

Inherits:
Object
  • Object
show all
Defined in:
lib/nexmo_developer/app/services/search_terms.rb

Class Method Summary collapse

Class Method Details

.generate(locale = I18n.default_locale) ⇒ Object



2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/nexmo_developer/app/services/search_terms.rb', line 2

def self.generate(locale = I18n.default_locale)
  document_paths = {
    documentation: {
      documents: Dir.glob("#{Rails.configuration.docs_base_path}/_documentation/#{locale}/**/*.md"),
      origin: Pathname.new("#{Rails.configuration.docs_base_path}/_documentation/#{locale}"),
      base_url_path: '',
    },
    api: {
      documents: Dir.glob("#{Rails.configuration.docs_base_path}/_api/**/*.md"),
      origin: Pathname.new("#{Rails.configuration.docs_base_path}/_api"),
      base_url_path: '/api',
    },
    use_cases: {
      documents: Dir.glob("#{Rails.configuration.docs_base_path}/_use_cases/#{locale}/**/*.md"),
      origin: Pathname.new("#{Rails.configuration.docs_base_path}/_use_cases/#{locale}"),
      base_url_path: '/use-cases',
    },
  }

  document_paths.map do |document_class, config|
    config[:documents].map do |document_path|
      Search::Document.new(document_class, config, document_path).articles.map(&:to_h)
    end
  end.flatten
end