Sha256: 5b82507eb7e50c15193a6d3481708d49d62636552156784e700cd60745399bc7

Contents?: true

Size: 1.52 KB

Versions: 20

Compression:

Stored size: 1.52 KB

Contents

namespace :sync do
  task :all, [:host] => :environment do |t, args|
    require 'iqvoc'
    require 'iqvoc/rdf_sync'

    if Iqvoc.config["triplestore.url"] == Iqvoc.config.defaults["triplestore.url"] # XXX: duplicates controller
      puts I18n.t("txt.controllers.triplestore_sync.config_warning")
      fail
    end

    ROOT = args[:host]
    raise(ArgumentError, "host not specified") unless ROOT

    include Rails.application.routes.url_helpers
    default_url_options[:host] = ROOT

    class FakeController
      include Iqvoc::RDFSync::Helper
      delegate :url_helpers, :to => "Rails.application.routes"

      def root_url(*args)
        ROOT
      end

      def view_context(*args)
        default_url_options[:host] = root_url
        view = FakeView.new(Rails.root.join("app", "views"))
        view.controller = self
        return view
      end

      # delegate URL helpers
      def method_missing(name, *args, &block)
        url_helpers.send(name, *args, &block)
      end
    end

    class FakeView < ActionView::Base
      include ApplicationHelper

      attr_accessor :controller

      # delegate URL helpers
      def method_missing(name, *args, &block)
        @controller.send(name, *args, &block)
      end
    end

    puts I18n.t("txt.controllers.triplestore_sync.config_info",
        :target_info => Iqvoc.config["triplestore.url"]) + " (host: #{ROOT})"
    success = FakeController.new.triplestore_syncer.all
    unless success
      puts I18n.t("txt.controllers.triplestore_sync.error")
      fail
    end
  end
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
iqvoc-4.3.3 lib/tasks/sync.rake
iqvoc-4.7.0 lib/tasks/sync.rake
iqvoc-4.6.1 lib/tasks/sync.rake
iqvoc-4.5.2 lib/tasks/sync.rake
iqvoc-4.6.0 lib/tasks/sync.rake
iqvoc-4.5.1 lib/tasks/sync.rake
iqvoc-4.5.0 lib/tasks/sync.rake
iqvoc-4.4.0 lib/tasks/sync.rake
iqvoc-4.3.2 lib/tasks/sync.rake
iqvoc-4.3.1 lib/tasks/sync.rake
iqvoc-4.3.0 lib/tasks/sync.rake
iqvoc-4.2.0 lib/tasks/sync.rake
iqvoc-4.1.3 lib/tasks/sync.rake
iqvoc-4.1.2 lib/tasks/sync.rake
iqvoc-4.1.1 lib/tasks/sync.rake
iqvoc-4.1.0 lib/tasks/sync.rake
iqvoc-4.0.9 lib/tasks/sync.rake
iqvoc-4.0.8 lib/tasks/sync.rake
iqvoc-4.0.7 lib/tasks/sync.rake
iqvoc-4.0.6 lib/tasks/sync.rake