Sha256: 7888a93761c661e9d49f8fdb32c1f9aad4c911f826f68d6bc8fa54121b402962

Contents?: true

Size: 834 Bytes

Versions: 4

Compression:

Stored size: 834 Bytes

Contents

namespace :vandal do
  task install: [:environment] do
    cfg = YAML.load_file("#{Rails.root}/.graphiticfg.yml")
    namespace = cfg['namespace']

    vandal_path = VandalUi::Engine.routes.find_script_name({})
    schema_path = "#{vandal_path}/schema.json"

    source = File.join(File.dirname(__FILE__), 'static')
    destination = "#{Rails.root}/public/#{namespace}"
    FileUtils.rm_rf "#{destination}/vandal"
    FileUtils.mkdir_p destination
    FileUtils.copy_entry(source, "#{destination}/vandal")

    path = "#{destination}/vandal/index.html"
    lines = IO.readlines(path).map do |line|
      if line.include?('__SCHEMA_PATH__')
        line.gsub('__SCHEMA_PATH__', ENV.fetch('SCHEMA_PATH', schema_path))
      else
        line
      end
    end

    File.open(path, 'w') do |file|
      file.puts lines
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
vandal_ui-0.4.4 lib/vandal_ui/tasks.rb
vandal_ui-0.4.3 lib/vandal_ui/tasks.rb
vandal_ui-0.4.2 lib/vandal_ui/tasks.rb
vandal_ui-0.4.1 lib/vandal_ui/tasks.rb