Sha256: ba1f9dcc1edc9dbf4b45e4219bb8a16a75f641a057c4d1452f7b919b613bdd05

Contents?: true

Size: 1.13 KB

Versions: 3

Compression:

Stored size: 1.13 KB

Contents

#!/usr/bin/env ruby

require 'softwear/library'

if ARGV.length > 0 && ARGV[0] == 'update'
  old_gemfile = File.open('Gemfile').read.gsub(/\r\n?/, "\n")
  gemfile = []

  handler = nil
  append_line = nil

  injected_gems = false

  ignore_line = lambda do |line|
    if line.include? Softwear::Lib::GEMFILE_CLOSER
      gemfile << line
      handler = append_line
    end
  end

  append_line = lambda do |line|
    gemfile << line
    if line.include? Softwear::Lib::GEMFILE_OPENER
      puts "Updating common gems"
      gemfile << Softwear::Lib::COMMON_GEMS
      injected_gems = true
      handler = ignore_line
    end
  end

  handler = append_line
  old_gemfile.each_line do |line|
    handler.call(line)
  end

  unless injected_gems
    puts "Adding common gems - check for duplicates!"
    gemfile << "\n" + Softwear::Lib::GEMFILE_OPENER + "\n"
    gemfile << Softwear::Lib::COMMON_GEMS
    gemfile << Softwear::Lib::GEMFILE_CLOSER + "\n"
  end

  File.open('Gemfile', 'w') do |file|
    gemfile.each do |line|
      file.write(line)
    end
  end
  puts "Done!"
else
  puts "Run `softwear update` to update your gemfile's common dependencies"
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
softwear-2.0.7 bin/softwear
softwear-2.0.6 bin/softwear
softwear-2.0.5 bin/softwear