fastlane-plugin-patch 0.4.1 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/lib/fastlane/plugin/patch/actions/apply_patch_action.rb +5 -38
- data/lib/fastlane/plugin/patch/actions/patch_action.rb +13 -48
- data/lib/fastlane/plugin/patch/actions/revert_patch_action.rb +4 -38
- data/lib/fastlane/plugin/patch/version.rb +1 -1
- metadata +21 -8
- data/lib/fastlane/plugin/patch/helper/patch_helper.rb +0 -18
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 14e39ebed238702cd5136356492bcb9edd10ddb31428733aa794344e6e7742b0
|
4
|
+
data.tar.gz: ef915e6994c56ed0e5a64d471e0a00820b5f6abe0046bd93485a7e619451dd93
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 43911789b43ecb17446cea888d1bf6c50c2796fc5befd49e5ffb6aa267896057608360358359800936e42445556d0b37e5ca2879f2a970648c34fa92a9db95f7
|
7
|
+
data.tar.gz: 75afaaf6f325064a7f89a326f9fd22ef28d20f7e1409b71840798d4d667279ef0ca8ffd0b4a4eb18e13a210bf5904343797991b6c22bef792a4ee4381df909db
|
@@ -1,49 +1,16 @@
|
|
1
|
-
require
|
1
|
+
require "pattern_patch"
|
2
2
|
|
3
3
|
module Fastlane
|
4
4
|
module Actions
|
5
5
|
class ApplyPatchAction < Action
|
6
6
|
def self.run(params)
|
7
7
|
if params[:patch]
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
# If the :patch option is present, load these params from the
|
12
|
-
# specified file. Action args override.
|
13
|
-
%w{regexp text mode global}.each do |option|
|
14
|
-
value = patch[option]
|
15
|
-
next if value.nil?
|
16
|
-
|
17
|
-
case option.to_sym
|
18
|
-
when :regexp
|
19
|
-
params[:regexp] = /#{value}/
|
20
|
-
when :mode
|
21
|
-
params[:mode] = value.to_sym
|
22
|
-
else
|
23
|
-
params[option.to_sym] = value
|
24
|
-
end
|
25
|
-
end
|
8
|
+
patch = PatternPatch::Patch.from_yaml params[:patch]
|
9
|
+
else
|
10
|
+
patch = PatternPatch::Patch.new params
|
26
11
|
end
|
27
12
|
|
28
|
-
|
29
|
-
params[:regexp].nil? || params[:text].nil?
|
30
|
-
|
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|
|
36
|
-
modified_contents = File.open(file, "r") do |f|
|
37
|
-
PatternPatch::Utilities.apply_patch f.read,
|
38
|
-
params[:regexp],
|
39
|
-
params[:text],
|
40
|
-
params[:global],
|
41
|
-
params[:mode],
|
42
|
-
params[:offset]
|
43
|
-
end
|
44
|
-
|
45
|
-
File.open(file, "w") { |f| f.write modified_contents }
|
46
|
-
end
|
13
|
+
patch.apply params[:files], offset: params[:offset]
|
47
14
|
rescue => e
|
48
15
|
UI.user_error! "Error in ApplyPatchAction: #{e.message}\n#{e.backtrace}"
|
49
16
|
end
|
@@ -1,58 +1,19 @@
|
|
1
1
|
require 'pattern_patch'
|
2
|
-
require 'yaml'
|
3
2
|
|
4
3
|
module Fastlane
|
5
4
|
module Actions
|
6
5
|
class PatchAction < Action
|
7
6
|
def self.run(params)
|
8
7
|
if params[:patch]
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
# If the :patch option is present, load these params from the
|
13
|
-
# specified file. Action args override.
|
14
|
-
%w{regexp text mode global}.each do |option|
|
15
|
-
value = patch[option]
|
16
|
-
next if value.nil?
|
17
|
-
|
18
|
-
case option.to_sym
|
19
|
-
when :regexp
|
20
|
-
params[:regexp] = /#{value}/
|
21
|
-
when :mode
|
22
|
-
params[:mode] = value.to_sym
|
23
|
-
else
|
24
|
-
params[option.to_sym] = value
|
25
|
-
end
|
26
|
-
end
|
8
|
+
patch = PatternPatch::Patch.from_yaml params[:patch]
|
9
|
+
else
|
10
|
+
patch = PatternPatch::Patch.new params
|
27
11
|
end
|
28
12
|
|
29
|
-
|
30
|
-
params[:
|
31
|
-
|
32
|
-
|
33
|
-
files = helper.files_from_params params
|
34
|
-
UI.user_error! "Must specify at least one file to patch using the :files option" if files.empty?
|
35
|
-
|
36
|
-
files.each do |file|
|
37
|
-
modified_contents = File.open(file, "r") do |f|
|
38
|
-
if params[:revert]
|
39
|
-
PatternPatch::Utilities.revert_patch f.read,
|
40
|
-
params[:regexp],
|
41
|
-
params[:text],
|
42
|
-
params[:global],
|
43
|
-
params[:mode],
|
44
|
-
params[:offset]
|
45
|
-
else
|
46
|
-
PatternPatch::Utilities.apply_patch f.read,
|
47
|
-
params[:regexp],
|
48
|
-
params[:text],
|
49
|
-
params[:global],
|
50
|
-
params[:mode],
|
51
|
-
params[:offset]
|
52
|
-
end
|
53
|
-
end
|
54
|
-
|
55
|
-
File.open(file, "w") { |f| f.write modified_contents }
|
13
|
+
if params[:revert]
|
14
|
+
patch.revert params[:files], offset: params[:offset]
|
15
|
+
else
|
16
|
+
patch.apply params[:files], offset: params[:offset]
|
56
17
|
end
|
57
18
|
rescue => e
|
58
19
|
UI.user_error! "Error in PatchAction: #{e.message}\n#{e.backtrace}"
|
@@ -105,8 +66,8 @@ YAML files. Revert the same patches with the revert option.
|
|
105
66
|
[
|
106
67
|
FastlaneCore::ConfigItem.new(key: :files,
|
107
68
|
description: "Absolute or relative path(s) to one or more files to patch",
|
108
|
-
|
109
|
-
|
69
|
+
type: Array,
|
70
|
+
optional: false),
|
110
71
|
FastlaneCore::ConfigItem.new(key: :regexp,
|
111
72
|
description: "A regular expression to match",
|
112
73
|
optional: true,
|
@@ -115,6 +76,10 @@ YAML files. Revert the same patches with the revert option.
|
|
115
76
|
description: "Text used to modify to the match",
|
116
77
|
optional: true,
|
117
78
|
type: String),
|
79
|
+
FastlaneCore::ConfigItem.new(key: :text_file,
|
80
|
+
description: "Text file for patch text",
|
81
|
+
optional: true,
|
82
|
+
type: String),
|
118
83
|
FastlaneCore::ConfigItem.new(key: :global,
|
119
84
|
description: "If true, patch all occurrences of the pattern",
|
120
85
|
optional: true,
|
@@ -1,50 +1,16 @@
|
|
1
1
|
require 'pattern_patch'
|
2
|
-
require 'yaml'
|
3
2
|
|
4
3
|
module Fastlane
|
5
4
|
module Actions
|
6
5
|
class RevertPatchAction < Action
|
7
6
|
def self.run(params)
|
8
7
|
if params[:patch]
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
# If the :patch option is present, load these params from the
|
13
|
-
# specified file. Action args override.
|
14
|
-
%w{regexp text mode global}.each do |option|
|
15
|
-
value = patch[option]
|
16
|
-
next if value.nil?
|
17
|
-
|
18
|
-
case option.to_sym
|
19
|
-
when :regexp
|
20
|
-
params[:regexp] = /#{value}/
|
21
|
-
when :mode
|
22
|
-
params[:mode] = value.to_sym
|
23
|
-
else
|
24
|
-
params[option.to_sym] = value
|
25
|
-
end
|
26
|
-
end
|
8
|
+
patch = PatternPatch::Patch.from_yaml params[:patch]
|
9
|
+
else
|
10
|
+
patch = PatternPatch::Patch.new params
|
27
11
|
end
|
28
12
|
|
29
|
-
|
30
|
-
params[:regexp].nil? || params[:text].nil?
|
31
|
-
|
32
|
-
helper = Helper::PatchHelper
|
33
|
-
files = helper.files_from_params params
|
34
|
-
UI.user_error! "Must specify at least one file to revert using the :files option" if files.empty?
|
35
|
-
|
36
|
-
files.each do |file|
|
37
|
-
modified_contents = File.open(file, "r") do |f|
|
38
|
-
PatternPatch::Utilities.revert_patch f.read,
|
39
|
-
params[:regexp],
|
40
|
-
params[:text],
|
41
|
-
params[:global],
|
42
|
-
params[:mode],
|
43
|
-
params[:offset]
|
44
|
-
end
|
45
|
-
|
46
|
-
File.open(file, "w") { |f| f.write modified_contents }
|
47
|
-
end
|
13
|
+
patch.revert params[:files], offset: params[:offset]
|
48
14
|
rescue => e
|
49
15
|
UI.user_error! "Error in RevertPatchAction: #{e.message}\n#{e.backtrace}"
|
50
16
|
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.
|
4
|
+
version: 0.5.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-
|
11
|
+
date: 2017-11-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: pattern_patch
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: 0.5.1
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
26
|
+
version: 0.5.1
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: pry
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -81,7 +81,7 @@ dependencies:
|
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '0'
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
|
-
name:
|
84
|
+
name: rspec_junit_formatter
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
87
|
- - ">="
|
@@ -95,7 +95,7 @@ dependencies:
|
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: '0'
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
|
-
name:
|
98
|
+
name: rspec-simplecov
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
100
100
|
requirements:
|
101
101
|
- - ">="
|
@@ -108,6 +108,20 @@ dependencies:
|
|
108
108
|
- - ">="
|
109
109
|
- !ruby/object:Gem::Version
|
110
110
|
version: '0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: rubocop
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - "~>"
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: 0.49.0
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - "~>"
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: 0.49.0
|
111
125
|
- !ruby/object:Gem::Dependency
|
112
126
|
name: simplecov
|
113
127
|
requirement: !ruby/object:Gem::Requirement
|
@@ -148,7 +162,6 @@ files:
|
|
148
162
|
- lib/fastlane/plugin/patch/actions/apply_patch_action.rb
|
149
163
|
- lib/fastlane/plugin/patch/actions/patch_action.rb
|
150
164
|
- lib/fastlane/plugin/patch/actions/revert_patch_action.rb
|
151
|
-
- lib/fastlane/plugin/patch/helper/patch_helper.rb
|
152
165
|
- lib/fastlane/plugin/patch/version.rb
|
153
166
|
homepage: https://github.com/jdee/fastlane-plugin-patch
|
154
167
|
licenses:
|
@@ -170,7 +183,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
170
183
|
version: '0'
|
171
184
|
requirements: []
|
172
185
|
rubyforge_project:
|
173
|
-
rubygems_version: 2.
|
186
|
+
rubygems_version: 2.7.1
|
174
187
|
signing_key:
|
175
188
|
specification_version: 4
|
176
189
|
summary: Apply and revert pattern-based patches to any text file.
|
@@ -1,18 +0,0 @@
|
|
1
|
-
module Fastlane
|
2
|
-
module Helper
|
3
|
-
class PatchHelper
|
4
|
-
class << self
|
5
|
-
def files_from_params(params)
|
6
|
-
case params[:files]
|
7
|
-
when Array
|
8
|
-
params[:files].map(&:to_s)
|
9
|
-
when String
|
10
|
-
params[:files].split(",")
|
11
|
-
else
|
12
|
-
raise ArgumentError, "Invalid type #{params[:files].class} for :files option. Specify an Array or a String."
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|