Sha256: 568f07347884a304e8af642f594459fb27e6841c55cbced0a861d3f56d935216

Contents?: true

Size: 1.28 KB

Versions: 1

Compression:

Stored size: 1.28 KB

Contents

#!/usr/bin/env ruby

require 'turtlelinks'

current_path = Dir.pwd
puts "Current path: #{current_path}"

# Remove turbolinks from app/layouts/application.html.erb
layout_file = File.join(current_path, 'app/views/layouts/application.html.erb')
layout_with_turbolinks = File.read(layout_file)
layout_without_turbolinks = layout_with_turbolinks.gsub(/, 'data-turbolinks-track' => true/, '')
File.open(layout_file, 'w') { |file| file << layout_without_turbolinks }

# Remove turbolinks from the Gemfile
gemfile_file = File.join(current_path, 'Gemfile')
gemfile_with_turbolinks = File.read(gemfile_file)

gemfile_regexes = [
  '# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks',
  /gem 'turbolinks'\n/
]

gemfile_without_turbolinks = gemfile_regexes.inject(gemfile_with_turbolinks) do |content, regex|
  content.gsub!(regex, '')
end

File.open(gemfile_file, 'w') { |file| file << gemfile_without_turbolinks }

# Remove from app/assets/javascripts/application.js
app_js_file = File.join(current_path, 'app/assets/javascripts/application.js')
app_js_with_turbolinks = File.read(app_js_file)
app_js_without_turbolinks = app_js_with_turbolinks.gsub(/\/\/= require turbolinks\n/, '')
File.open(app_js_file, 'w') { |file| file << app_js_without_turbolinks }

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
turtlelinks-0.0.1 bin/turtlelinks