Class: LIBUSB::GemHelper
- Inherits:
-
Bundler::GemHelper
- Object
- Bundler::GemHelper
- LIBUSB::GemHelper
- Defined in:
- lib/libusb/gem_helper.rb
Instance Attribute Summary collapse
-
#cross_platforms ⇒ Object
Returns the value of attribute cross_platforms.
Instance Method Summary collapse
- #headline ⇒ Object
- #hfile ⇒ Object
- #install ⇒ Object
- #reldate ⇒ Object
- #rubygem_push(path) ⇒ Object
- #tag_version ⇒ Object
- #update_history ⇒ Object
Instance Attribute Details
#cross_platforms ⇒ Object
Returns the value of attribute cross_platforms.
20 21 22 |
# File 'lib/libusb/gem_helper.rb', line 20 def cross_platforms @cross_platforms end |
Instance Method Details
#headline ⇒ Object
38 39 40 |
# File 'lib/libusb/gem_helper.rb', line 38 def headline '([^\w]*)(\d+\.\d+\.\d+)([^\w]+)([2Y][0Y][0-9Y][0-9Y]-[0-1M][0-9M]-[0-3D][0-9D])([^\w]*|$)' end |
#hfile ⇒ Object
34 35 36 |
# File 'lib/libusb/gem_helper.rb', line 34 def hfile "History.md" end |
#install ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/libusb/gem_helper.rb', line 22 def install super task "release:guard_clean" => ["release:update_history"] task "release:update_history" do update_history end task "release:rubygem_push" => ["gem:native"] end |
#reldate ⇒ Object
42 43 44 |
# File 'lib/libusb/gem_helper.rb', line 42 def reldate Time.now.strftime("%Y-%m-%d") end |
#rubygem_push(path) ⇒ Object
73 74 75 76 77 78 |
# File 'lib/libusb/gem_helper.rb', line 73 def rubygem_push(path) cross_platforms.each do |ruby_platform| super(path.gsub(/\.gem\z/, "-#{ruby_platform}.gem")) end super(path) end |
#tag_version ⇒ Object
59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/libusb/gem_helper.rb', line 59 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_status %W[git tag -d #{version_tag}] raise end |
#update_history ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/libusb/gem_helper.rb', line 46 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 |