pattern_patch 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/pattern_patch/patch.rb +20 -1
- data/lib/pattern_patch/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e6f3d56a8e098394dcb99213f11b443e2f9594f170c18e42bc7b542c66a5ce05
|
4
|
+
data.tar.gz: 74ef513114b65d8dc6920d7780abfbbbb0f44434bf904315a5486a662302e944
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9d1965026da862449372668c4c3b835203700d30d93e6baf84c2d5a8eccb674d4badb8ed74fbc3bca2f812d1b489668f2b6dcb1a79fab84f323b04afe1c534c5
|
7
|
+
data.tar.gz: 043d8424830d6c8cd5ca3893c00c396bf49dafa2f4e425df222d046d04d7d2fa9a75862afd586580998cc4455b57b2495435a8f5060b4d9244e7574a7206168f
|
data/lib/pattern_patch/patch.rb
CHANGED
@@ -7,6 +7,7 @@ module PatternPatch
|
|
7
7
|
attr_accessor :text
|
8
8
|
attr_accessor :mode
|
9
9
|
attr_accessor :global
|
10
|
+
attr_reader :text_file
|
10
11
|
|
11
12
|
class << self
|
12
13
|
def from_yaml(path)
|
@@ -22,17 +23,35 @@ module PatternPatch
|
|
22
23
|
hash[:mode] = hash[:mode].to_sym
|
23
24
|
end
|
24
25
|
|
26
|
+
if hash[:text_file]
|
27
|
+
hash[:text_file] = File.expand_path hash[:text_file], File.dirname(path)
|
28
|
+
end
|
29
|
+
|
25
30
|
new hash
|
26
31
|
end
|
27
32
|
end
|
28
33
|
|
29
34
|
def initialize(options = {})
|
35
|
+
raise ArgumentError, "text and text_file are mutually exclusive" if options[:text] && options[:text_file]
|
36
|
+
|
30
37
|
@regexp = options[:regexp]
|
31
|
-
@
|
38
|
+
@text_file = options[:text_file]
|
39
|
+
|
40
|
+
if @text_file
|
41
|
+
@text = File.read @text_file
|
42
|
+
else
|
43
|
+
@text = options[:text]
|
44
|
+
end
|
45
|
+
|
32
46
|
@mode = options[:mode] || :append
|
33
47
|
@global = options[:global].nil? ? false : options[:global]
|
34
48
|
end
|
35
49
|
|
50
|
+
def text_file=(path)
|
51
|
+
@text_file = path
|
52
|
+
@text = File.read path if path
|
53
|
+
end
|
54
|
+
|
36
55
|
def apply(files, options = {})
|
37
56
|
offset = options[:offset] || 0
|
38
57
|
files = [files] if files.kind_of? String
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pattern_patch
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.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-
|
11
|
+
date: 2017-11-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|