fastlane-plugin-patch 0.1.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5a9f0ea20fda14d47e1b04015ebc7048990beca0
4
- data.tar.gz: 9f044357df62f527a53cf2c48451e3050d6faa9a
3
+ metadata.gz: e43a5073e5e6f001a9bac1edc8d5c01269365664
4
+ data.tar.gz: 6a43c19f97495874c41cf06267c9090305e4fe89
5
5
  SHA512:
6
- metadata.gz: dfe86d539223d6a2e65724b1bd1d70566b978abae84f5820e7c0352178a937f1eaf2761402b33bbafc5345b54153315f9bc433720b90d5a9ab1cd50ad9f1e8ce
7
- data.tar.gz: 12c460257e0c22777678fb6e8637d6cf27a5805f1e46241167136fb8af01434b73332d22854b033e20bd56a29a4b020b16e6a950bbd0bce9a348060568276ede
6
+ metadata.gz: d693bb861b0a1d6ccf36acac47d7068a5f6c8093deb6e100fcd5b18c2dd98bb21c055eabc12ad9b5ac28e695ef8b8c533b736a7a2a911351e0904f5835d1cb4b
7
+ data.tar.gz: 006cc262c53603c6c2411e3197354e75792dcb4518474c6b43f245be10b697ea5f5835b0f3fea57964be6c687a0e87c30dfbb6592becdef6299dd8af5ff701db
data/README.md CHANGED
@@ -60,6 +60,19 @@ apply_patch(
60
60
  )
61
61
  ```
62
62
 
63
+ #### Capture groups
64
+
65
+ Capture groups may be used in `:replace` mode.
66
+
67
+ ```Ruby
68
+ apply_patch(
69
+ files: "MyPod.podspec",
70
+ regexp: /(s.name\s*=\s*)"MyPod"/,
71
+ text: '\1"MyOtherPod"',
72
+ mode: :replace
73
+ )
74
+ ```
75
+
63
76
  ### revert_patch action
64
77
 
65
78
  Revert patches by passing the same arguments to the `revert_patch` action:
@@ -28,8 +28,11 @@ module Fastlane
28
28
  UI.user_error! "Must specify :regexp and :text either in a patch or via arguments" if
29
29
  params[:regexp].nil? || params[:text].nil?
30
30
 
31
- helper = Fastlane::Helper::PatchHelper
32
- helper.files_from_params(params).each do |file|
31
+ helper = Helper::PatchHelper
32
+ files = helper.files_from_params params
33
+ UI.user_error! "Must specify at least one file to patch using the :files option" if files.empty?
34
+
35
+ files.each do |file|
33
36
  modified_contents = File.open(file, "r") do |f|
34
37
  helper.apply_patch f.read,
35
38
  params[:regexp],
@@ -55,9 +58,9 @@ module Fastlane
55
58
 
56
59
  def self.details
57
60
  <<-EOF
58
- Append or prepend text to a specified pattern in a list of files or
59
- replace it, once or globally. Patches are specified by arguments or
60
- YAML files. Revert the same patches with the revert_patch action.
61
+ Append or prepend text to a specified pattern in a list of files or
62
+ replace it, once or globally. Patches are specified by arguments or
63
+ YAML files. Revert the same patches with the revert_patch action.
61
64
  EOF
62
65
  end
63
66
 
@@ -28,8 +28,11 @@ module Fastlane
28
28
  UI.user_error! "Must specify :regexp and :text either in a patch or via arguments" if
29
29
  params[:regexp].nil? || params[:text].nil?
30
30
 
31
- helper = Fastlane::Helper::PatchHelper
32
- helper.files_from_params(params).each do |file|
31
+ helper = Helper::PatchHelper
32
+ files = helper.files_from_params params
33
+ UI.user_error! "Must specify at least one file to revert using the :files option" if files.empty?
34
+
35
+ files.each do |file|
33
36
  modified_contents = File.open(file, "r") do |f|
34
37
  helper.revert_patch f.read,
35
38
  params[:regexp],
@@ -55,8 +58,8 @@ module Fastlane
55
58
 
56
59
  def self.details
57
60
  <<-EOF
58
- Revert a patch by specifying the arguments provided to apply_patch
59
- using arguments or the same YAML patch files.
61
+ Revert a patch by specifying the arguments provided to apply_patch
62
+ using arguments or the same YAML patch files.
60
63
  EOF
61
64
  end
62
65
 
@@ -21,7 +21,7 @@ module Fastlane
21
21
  when :prepend
22
22
  "#{text}#{matches[0]}"
23
23
  when :replace
24
- text
24
+ matches[0].sub regexp, text
25
25
  else
26
26
  raise ArgumentError, "Invalid mode argument. Specify :append, :prepend or :replace."
27
27
  end
@@ -1,5 +1,5 @@
1
1
  module Fastlane
2
2
  module Patch
3
- VERSION = "0.1.0"
3
+ VERSION = "0.2.0"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fastlane-plugin-patch
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jimmy Dee
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-07-31 00:00:00.000000000 Z
11
+ date: 2017-08-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pry