Sha256: bf9a61669558b17cee2c19127792dc0ad80c5372628ae893d5c3ae7b15535964

Contents?: true

Size: 1.44 KB

Versions: 750

Compression:

Stored size: 1.44 KB

Contents

#!/usr/bin/env ruby
# frozen_string_literal: true

require 'pwn'

old_rev = PWN::VERSION
readme_md_path = './README.md'
current_ruby = './.ruby-version'
placeholder_arr = old_rev.split('.')
major = placeholder_arr[0].to_i
minor = placeholder_arr[1].to_i
hotfix = placeholder_arr[2].to_i

if hotfix < 999
  hotfix += 1
  placeholder_arr[2] = hotfix.to_s
else
  placeholder_arr[2] = '0'
  if minor < 9
    minor += 1
    placeholder_arr[1] = minor.to_s
  else
    placeholder_arr[1] = '0'
    major += 1
    placeholder_arr[0] = major.to_s
  end
end

new_rev = placeholder_arr.join('.')

puts "Upgrading to #{new_rev}..."
File.open('./lib/pwn/version.rb', 'w') do |f|
  f.puts '# frozen_string_literal: true'
  f.puts "\n"
  f.puts 'module PWN'
  f.puts "  VERSION = '#{new_rev}'"
  f.puts 'end'
end

# Update README.md
current_ruby_version = "ruby-#{File.read(current_ruby).chomp}"
old_readme_md = File.read(readme_md_path, encoding: 'utf-8')
pwn_regex = 'pwn\[v.+\..+\..+\]'
rb_regex = 'ruby-.+'
File.open(readme_md_path, 'w') do |file|
  old_readme_md.each_line do |line|
    if line.to_s.scrub.match?(/#{pwn_regex}/) ||
       line.to_s.scrub.match?(/#{rb_regex}/)

      new_line = line.to_s.gsub(/pwn\[v#{old_rev}\]/, "pwn\[v#{new_rev}\]") if line.to_s.scrub.match?(/#{pwn_regex}/)
      new_line = line.to_s.gsub(/ruby-.+(?=(@))/, current_ruby_version) if line.to_s.scrub.match?(/#{rb_regex}/)

      file.puts new_line
    else
      file.puts line
    end
  end
end

Version data entries

750 entries across 750 versions & 1 rubygems

Version Path
pwn-0.4.438 bin/pwn_autoinc_version
pwn-0.4.437 bin/pwn_autoinc_version
pwn-0.4.436 bin/pwn_autoinc_version
pwn-0.4.435 bin/pwn_autoinc_version
pwn-0.4.434 bin/pwn_autoinc_version
pwn-0.4.433 bin/pwn_autoinc_version
pwn-0.4.432 bin/pwn_autoinc_version
pwn-0.4.431 bin/pwn_autoinc_version
pwn-0.4.430 bin/pwn_autoinc_version
pwn-0.4.429 bin/pwn_autoinc_version
pwn-0.4.428 bin/pwn_autoinc_version
pwn-0.4.427 bin/pwn_autoinc_version
pwn-0.4.426 bin/pwn_autoinc_version
pwn-0.4.425 bin/pwn_autoinc_version
pwn-0.4.424 bin/pwn_autoinc_version
pwn-0.4.423 bin/pwn_autoinc_version
pwn-0.4.422 bin/pwn_autoinc_version
pwn-0.4.421 bin/pwn_autoinc_version
pwn-0.4.419 bin/pwn_autoinc_version
pwn-0.4.418 bin/pwn_autoinc_version