Skip to content

Commit

Permalink
Using platform bridge support
Browse files Browse the repository at this point in the history
  • Loading branch information
flbulgarelli committed May 28, 2018
1 parent feaf186 commit 983e9fa
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 32 deletions.
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

0 comments on commit 983e9fa

Please sign in to comment.