Sha256: 9e67fcb830e3211b3423d00ec95333100f72078c4372ff5846565488874128a6

Contents?: true

Size: 1.45 KB

Versions: 10

Compression:

Stored size: 1.45 KB

Contents

require "fileutils"
require "bundler/gem_tasks"

desc "Syncronize Swagger UI"
task :sync_swagger_ui do

  source      = File.join File.dirname(__FILE__), "swagger-ui-src", "dist"
  destination = File.join File.dirname(__FILE__), "app", "assets"

  js_destination = File.join destination, "javascripts", "swagger-ui"

  idx = File.join js_destination, "index.js"

  File.read(idx).each_line do | line |
    if line =~ /require (.*)/
      file = "#{source}/#{$1.strip}"
      # hack to make throbber.gif available on asset pipeline
      if $1.strip =~ /swagger-ui\.js/
        contents = File.read file
        File.open "#{file.gsub(source, js_destination)}.erb", "w" do | f |
          f << contents.gsub("src='images/throbber.gif'", "src='<%= asset_path(\"throbber.gif\") %>'")
        end
      else
        FileUtils.cp_r file, file.gsub(source, js_destination), verbose: true
      end
    end
  end

  oauth_source = File.join source, "lib", "swagger-oauth.js"
  oauth_dest   = js_destination.gsub "swagger-ui-src", "swagger-oauth.js"

  FileUtils.cp_r oauth_source, oauth_dest, verbose: true

  css_destination = File.join destination, "stylesheets", "swagger-ui"
  css_source      = File.join source, "css"

  idx = File.join css_destination, "index.css"

  File.read(idx).each_line do | line |
    if line =~ /require (.*)\.css/
      file = "#{css_source}/#{$1.strip}.css"
      FileUtils.cp_r file, file.gsub(css_source, css_destination), verbose: true
    end
  end

end

Version data entries

10 entries across 10 versions & 3 rubygems

Version Path
swagger-ui_rails5-2.2.8.2 Rakefile
swagger-ui_rails5-2.2.8.1 Rakefile
swagger-ui_rails5-2.2.8 Rakefile
swagger-ui_rails_audionerd-2.3.2 Rakefile
swagger-ui_rails_audionerd-2.3.1 Rakefile
swagger-ui_rails_audionerd-2.3.0 Rakefile
swagger-ui_rails_audionerd-2.1.1 Rakefile
swagger-ui_rails-2.1.0.alpha.7.1 Rakefile
swagger-ui_rails-2.1.0.pre.alpha.7.1 Rakefile
swagger-ui_rails-2.1.0.pre.alpha.7 Rakefile