Module: Writefully::Indices

Defined in:
lib/writefully/indices.rb

Class Method Summary collapse

Class Method Details

.build_from(modified) ⇒ Object



3
4
5
6
7
# File 'lib/writefully/indices.rb', line 3

def self.build_from(modified)
  modified.map do |file_name|
    index_hash_from(index_name_from(remove_content_path(file_name)))       
  end
end

.index_hash_from(array) ⇒ Object



17
18
19
# File 'lib/writefully/indices.rb', line 17

def self.index_hash_from(array)
  Hash[*array]
end

.index_name_from(array) ⇒ Object



13
14
15
# File 'lib/writefully/indices.rb', line 13

def self.index_name_from(array)
  [:site, :resource, :slug].zip(array).flatten
end

.remove_content_path(file_name) ⇒ Object



9
10
11
# File 'lib/writefully/indices.rb', line 9

def self.remove_content_path(file_name)
  file_name.split('/') - Writefully.options[:content].split('/')
end