Class: Gem::Commands::PatchCommand
- Inherits:
-
Gem::Command
- Object
- Gem::Command
- Gem::Commands::PatchCommand
- Defined in:
- lib/rubygems/commands/patch_command.rb
Instance Method Summary collapse
-
#arguments ⇒ Object
:nodoc:.
-
#description ⇒ Object
:nodoc:.
- #execute ⇒ Object
-
#initialize ⇒ PatchCommand
constructor
A new instance of PatchCommand.
-
#usage ⇒ Object
:nodoc:.
Constructor Details
#initialize ⇒ PatchCommand
Returns a new instance of PatchCommand.
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/rubygems/commands/patch_command.rb', line 5 def initialize super "patch", "Patches the gem with the given patches and generates patched gem.", :output => Dir.pwd, :strip => 0 # Same as 'patch -pNUMBER' on Linux machines add_option('-pNUMBER', '--strip=NUMBER', 'Set the file name strip count to NUMBER.') do |number, | [:strip] = number end # Number of lines to ignore in looking for places to install a hunk add_option('-FNUMBER', '--fuzz=NUMBER', 'Set NUMBER of lines to ignore in looking for places to install a hunk.') do |number, | [:fuzz] = number end # Set output file to FILE instead of overwritting add_option('-oFILE', '--output=FILE', 'Set output FILE.') do |file, | [:outfile] = file end # Dry run only shows expected output from the patching process add_option('--dry-run', 'Print the results from patching, but do not change any files.') do |file, | [:dry_run] = true end end |
Instance Method Details
#arguments ⇒ Object
:nodoc:
30 31 32 33 34 35 36 |
# File 'lib/rubygems/commands/patch_command.rb', line 30 def arguments # :nodoc: args = <<-EOF GEMFILE path to the gem file to patch PATCH [PATCH ...] list of patches to apply EOF return args.gsub(/^\s+/, '') end |
#description ⇒ Object
:nodoc:
38 39 40 41 42 43 44 45 |
# File 'lib/rubygems/commands/patch_command.rb', line 38 def description # :nodoc: desc = <<-EOF `gem-patch` is a RubyGems plugin that helps to patch gems without manually opening and rebuilding them. It opens a given .gem file, extracts it, patches it with system `patch` command, clones its spec, updates the file list and builds the patched gem. EOF return desc.gsub(/^\s+/, '') end |
#execute ⇒ Object
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/rubygems/commands/patch_command.rb', line 51 def execute gemfile = [:args].shift patches = [:args] # No gem unless gemfile raise Gem::CommandLineError, "Please specify a gem file on the command line (e.g. gem patch foo-0.1.0.gem PATCH [PATCH ...])" end # No patches if patches.empty? raise Gem::CommandLineError, "Please specify patches to apply (e.g. gem patch foo-0.1.0.gem foo.patch bar.patch ...)" end patcher = Gem::Patcher.new(gemfile, [:output]) patcher.patch_with(patches, ) patcher.print_results end |
#usage ⇒ Object
:nodoc:
47 48 49 |
# File 'lib/rubygems/commands/patch_command.rb', line 47 def usage # :nodoc: "#{program_name} GEMFILE PATCH [PATCH ...]" end |