-
-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1073 from mumuki/feature-platform-bridge
Feature platform bridge
- Loading branch information
Showing
4 changed files
with
12 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,15 @@ | ||
require 'mumukit/bridge' | ||
|
||
module Mumuki::Laboratory::Seed | ||
class << self | ||
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 | ||
|
||
def import_contents! | ||
%w(guide topic book).each { |it| Mumuki::Laboratory::Seed.import_content!(it) } | ||
end | ||
|
||
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 | ||
def self.import_contents! | ||
Mumukit::Platform.bibliotheca_bridge.import_contents! do |resource_type, slug| | ||
resource_type.classify.constantize.import!(slug) | ||
end | ||
end | ||
|
||
def self.import_languages! | ||
Mumukit::Platform.thesaurus_bridge.import_languages! do |runner_url| | ||
Language.find_or_initialize_by(runner_url: runner_url).import! | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters