Sha256: 4e2650f15d36d61261a4ce7ec432bc5022780a8629ac22139ed1f0e3a715caa7

Contents?: true

Size: 819 Bytes

Versions: 1

Compression:

Stored size: 819 Bytes

Contents

namespace :vandal do
  task :install 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

1 entries across 1 versions & 1 rubygems

Version Path
vandal_ui-0.4.0 lib/vandal_ui/tasks.rb