Class: BuntoImport::Importers::Drupal7

Inherits:
BuntoImport::Importer show all
Extended by:
BuntoImport::Importers::DrupalCommon::ClassMethods
Includes:
DrupalCommon
Defined in:
lib/bunto-import/importers/drupal7.rb

Constant Summary

Constants included from BuntoImport::Importers::DrupalCommon::ClassMethods

BuntoImport::Importers::DrupalCommon::ClassMethods::DEFAULTS

Class Method Summary collapse

Methods included from BuntoImport::Importers::DrupalCommon::ClassMethods

process, require_deps, specify_options

Methods included from DrupalCommon

#aliases_query, #build_query, #post_data, #validate

Methods inherited from BuntoImport::Importer

inherited, run, stringify_keys, subclasses

Class Method Details

.aliases_query(prefix) ⇒ Object



35
36
37
# File 'lib/bunto-import/importers/drupal7.rb', line 35

def self.aliases_query(prefix)
  "SELECT source, alias FROM #{prefix}url_alias WHERE source = ?"
end

.build_query(prefix, types) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/bunto-import/importers/drupal7.rb', line 9

def self.build_query(prefix, types)
  types = types.join("' OR n.type = '")
  types = "n.type = '#{types}'"

  query = "          SELECT n.nid,\n                 n.title,\n                 fdb.body_value,\n                 fdb.body_summary,\n                 n.created,\n                 n.status,\n                 n.type,\n                 GROUP_CONCAT( td.name SEPARATOR '|' ) AS 'tags'\n          FROM \#{prefix}field_data_body AS fdb,\n               \#{prefix}node AS n\n               LEFT OUTER JOIN \#{prefix}taxonomy_index AS ti ON ti.nid = n.nid\n               LEFT OUTER JOIN \#{prefix}taxonomy_term_data AS td ON ti.tid = td.tid\n          WHERE (\#{types})\n            AND n.nid = fdb.entity_id\n            AND n.vid = fdb.revision_id\n          GROUP BY n.nid\"\n"

  return query
end

.post_data(sql_post_data) ⇒ Object



39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/bunto-import/importers/drupal7.rb', line 39

def self.post_data(sql_post_data)
  content = sql_post_data[:body_value].to_s
  summary = sql_post_data[:body_summary].to_s
  tags = (sql_post_data[:tags] || '').downcase.strip

  data = {
    'excerpt' => summary,
    'categories' => tags.split('|')
  }

  return data, content
end