Class: FfiGemHelper

Inherits:
Bundler::GemHelper
  • Object
show all
Defined in:
lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/ffi-1.15.5/rakelib/ffi_gem_helper.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#cross_platformsObject

Returns the value of attribute cross_platforms.



5
6
7
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/ffi-1.15.5/rakelib/ffi_gem_helper.rb', line 5

def cross_platforms
  @cross_platforms
end

Instance Method Details

#headlineObject



23
24
25
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/ffi-1.15.5/rakelib/ffi_gem_helper.rb', line 23

def headline
  '([^\w]*)(\d+\.\d+\.\d+(?:\.\w+)?)([^\w]+)([2Y][0Y][0-9Y][0-9Y]-[0-1M][0-9M]-[0-3D][0-9D])([^\w]*|$)'
end

#hfileObject



19
20
21
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/ffi-1.15.5/rakelib/ffi_gem_helper.rb', line 19

def hfile
  "CHANGELOG.md"
end

#installObject



7
8
9
10
11
12
13
14
15
16
17
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/ffi-1.15.5/rakelib/ffi_gem_helper.rb', line 7

def install
  super

  task "release:guard_clean" => ["release:update_history"]

  task "release:update_history" do
    update_history
  end

  task "release:rubygem_push" => ["gem:native", "gem:java"]
end

#reldateObject



27
28
29
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/ffi-1.15.5/rakelib/ffi_gem_helper.rb', line 27

def reldate
  Time.now.strftime("%Y-%m-%d")
end

#rubygem_push(path) ⇒ Object



58
59
60
61
62
63
64
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/ffi-1.15.5/rakelib/ffi_gem_helper.rb', line 58

def rubygem_push(path)
  cross_platforms.each do |ruby_platform|
    super(path.gsub(/\.gem\z/, "-#{ruby_platform}.gem"))
  end
  super(path.gsub(/\.gem\z/, "-java.gem"))
  super(path)
end

#tag_versionObject



44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/ffi-1.15.5/rakelib/ffi_gem_helper.rb', line 44

def tag_version
  Bundler.ui.confirm "Tag release with annotation:"
  m = File.read(hfile).match(/(?<annotation>#{headline}.*?)#{headline}/m) || raise("Unable to find release notes in #{hfile}")
  Bundler.ui.info(m[:annotation].gsub(/^/, "    "))
  IO.popen(["git", "tag", "--file=-", version_tag], "w") do |fd|
    fd.write m[:annotation]
  end
  yield if block_given?
rescue
  Bundler.ui.error "Untagging #{version_tag} due to error."
  sh_with_code "git tag -d #{version_tag}"
  raise
end

#update_historyObject



31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/rubypitaya/app-template/vendor/bundle/ruby/3.1.0/gems/ffi-1.15.5/rakelib/ffi_gem_helper.rb', line 31

def update_history
  hin = File.read(hfile)
  hout = hin.sub(/#{headline}/) do
    raise "#{hfile} isn't up-to-date for version #{version}" unless $2==version.to_s
    $1 + $2 + $3 + reldate + $5
  end
  if hout != hin
    Bundler.ui.confirm "Updating #{hfile} for release."
    File.write(hfile, hout)
    Rake::FileUtilsExt.sh "git", "commit", hfile, "-m", "Update release date in #{hfile}"
  end
end