Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature platform bridge #1073

Merged
merged 1 commit into from
Jun 7, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/models/concerns/with_slug.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ module WithSlug
end

def import!
import_from_json! Mumukit::Bridge::Bibliotheca.new(Mumukit::Platform.bibliotheca_api.url).send(self.class.name.underscore, slug)
import_from_json! Mumukit::Platform.bibliotheca_bridge.send(self.class.name.underscore, slug)
end

def slug_parts
Expand Down
38 changes: 9 additions & 29 deletions lib/mumuki/laboratory/seed.rb
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
2 changes: 1 addition & 1 deletion mumuki-laboratory.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Gem::Specification.new do |s|
s.add_dependency 'mumukit-bridge', '~> 3.5'
s.add_dependency 'mumukit-inspection', '~> 3.2'
s.add_dependency 'mumukit-nuntius', '~> 6.1'
s.add_dependency 'mumukit-platform', '~> 1.3'
s.add_dependency 'mumukit-platform', '~> 1.6'
s.add_dependency 'mumukit-login', '~> 5.0'
s.add_dependency 'mumukit-directives', '~> 0.3'

Expand Down
2 changes: 1 addition & 1 deletion spec/models/assistant_spec.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require 'spec_helper'

describe 'adaptive hints' do
describe Mumukit::Assistant do
let(:assistant) { Mumukit::Assistant.parse(rules) }

describe 'content_empty' do
Expand Down