class GrapeSwaggerRailsThemes::InstallGenerator
Public Instance Methods
copy_grape_swagger_rails_templates()
click to toggle source
# File lib/generators/grape_swagger_rails_themes/install_generator.rb, line 16 def copy_grape_swagger_rails_templates download = open('https://raw.githubusercontent.com/ruby-grape/grape-swagger-rails/master/app/views/grape_swagger_rails/application/index.html.erb') create_file "app/views/grape_swagger_rails/application/index.html.erb", download.read insert_into_file "app/views/grape_swagger_rails/application/index.html.erb", '<%= stylesheet_link_tag "swagger-ui-themes/themes/#{GrapeSwaggerRails.options.theme_version}/theme-#{::GrapeSwaggerRails.options.theme}.css" unless ::GrapeSwaggerRails.options.theme == "default" %>', after: "<%= stylesheet_link_tag 'grape_swagger_rails/application.css' %>" insert_into_file "config/initializers/assets.rb", "\nRails.application.config.assets.precompile += %w( swagger-ui-themes/themes/2.x/*.css swagger-ui-themes/themes/3.x/*.css )", after: "Rails.application.config.assets.paths << Rails.root.join('node_modules')" end
copy_initializer()
click to toggle source
# File lib/generators/grape_swagger_rails_themes/install_generator.rb, line 8 def copy_initializer template "grape_swagger_rails_themes.rb", "config/initializers/grape_swagger_rails_themes.rb" end
install_dependencies()
click to toggle source
# File lib/generators/grape_swagger_rails_themes/install_generator.rb, line 12 def install_dependencies run 'yarn add swagger-ui-themes' end