Module: Mumuki::Laboratory::Seed

Defined in:
lib/mumuki/laboratory/seed.rb

Class Method Summary collapse

Class Method Details

.import_content!(resource) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/mumuki/laboratory/seed.rb', line 5

def import_content!(resource)
  Mumukit::Bridge::Bibliotheca.new(Mumukit::Platform.bibliotheca_api.url).send(resource.to_s.pluralize).each do |r|
    slug = r['slug']
    clazz = resource.to_s.classify.constantize
    puts "Importing #{resource} #{slug}"
    begin
      item = clazz.import!(slug)
    rescue => e
      puts "Ignoring #{slug} because of import error #{e}"
    end
  end
end

.import_contents!Object



18
19
20
# File 'lib/mumuki/laboratory/seed.rb', line 18

def import_contents!
  %w(guide topic book).each { |it| Mumuki::Laboratory::Seed.import_content!(it) }
end

.import_languages!Object



22
23
24
25
26
27
28
29
30
31
32
# File 'lib/mumuki/laboratory/seed.rb', line 22

def import_languages!
  Mumukit::Bridge::Thesaurus.new(Mumukit::Platform.config.thesaurus_url).runners.each do |url|
    puts "Importing Language #{url}"

    begin
      Language.find_or_initialize_by(runner_url: url).import!
    rescue => e
      puts "Ignoring Language #{url} because of import error #{e}"
    end
  end
end