text_injector 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +0 -1
- data/README.md +1 -6
- data/lib/text_injector.rb +3 -3
- data/lib/text_injector/version.rb +1 -1
- data/spec/lib/text_injector_spec.rb +9 -0
- data/tmp/.gitkeep +0 -0
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9e03b1fb3b239226aba3c34d1f0dd3d33b9a9285
|
4
|
+
data.tar.gz: 475f20c84ea53d65ed69466030c134b80fb1735a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d405677b2f18a693596861f02ae7a6a50bdabeb3322d504d44f62e5d376847730b9e5da3edcb1ac3e22c020069434fdb2247a28da37bdc1cb2fffc0d673d92a0
|
7
|
+
data.tar.gz: 54b095a0f53f63ffa397d715c1f36091bb5e9a69eb03e8e4d51e3d6eb9b88d13d17aaaa67f22ebe0feaa3cba3139b8bda3d8355936ccb24aec4562abc1f0e245
|
data/.gitignore
CHANGED
data/README.md
CHANGED
@@ -28,12 +28,7 @@ injector = TextInjector.new(
|
|
28
28
|
:content => "added content"
|
29
29
|
)
|
30
30
|
injector.run # first run
|
31
|
-
|
32
|
-
injector = TextInjector.new(
|
33
|
-
:identifier => "custom-id",
|
34
|
-
:file => "/tmp/test.txt",
|
35
|
-
:content => "updated content"
|
36
|
-
)
|
31
|
+
injector.content = "updated content"
|
37
32
|
injector.run # second run
|
38
33
|
</pre>
|
39
34
|
|
data/lib/text_injector.rb
CHANGED
@@ -42,15 +42,15 @@ protected
|
|
42
42
|
end
|
43
43
|
|
44
44
|
def tmp_path
|
45
|
-
"#{@file}
|
45
|
+
"#{@file}.tmp"
|
46
46
|
end
|
47
47
|
|
48
48
|
def write_file(contents)
|
49
49
|
File.open(tmp_path, 'w') do |file|
|
50
50
|
file.write(contents)
|
51
51
|
end
|
52
|
-
if @options[:
|
53
|
-
say "Tmp file written to #{
|
52
|
+
if @options[:temp_file]
|
53
|
+
say "Tmp file written to #{tmp_path}"
|
54
54
|
else
|
55
55
|
say "Updated #{@file}"
|
56
56
|
FileUtils.mv(tmp_path, @file)
|
@@ -13,6 +13,7 @@ describe TextInjector do
|
|
13
13
|
TextInjector.new(
|
14
14
|
:mute => true,
|
15
15
|
:file => @file,
|
16
|
+
:temp_file => @temp_file,
|
16
17
|
:identifier => @identifier,
|
17
18
|
:content => @content
|
18
19
|
)
|
@@ -64,5 +65,13 @@ added content
|
|
64
65
|
# End TextInjector marker for custom-id
|
65
66
|
EOL
|
66
67
|
end
|
68
|
+
|
69
|
+
it "should create temp file" do
|
70
|
+
@temp_file = true
|
71
|
+
injector.run
|
72
|
+
temp_file = @file + ".tmp"
|
73
|
+
File.exist?(temp_file).should be_true
|
74
|
+
FileUtils.rm_f(temp_file)
|
75
|
+
end
|
67
76
|
end
|
68
77
|
end
|
data/tmp/.gitkeep
ADDED
File without changes
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: text_injector
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tung Nguyen
|
@@ -86,6 +86,7 @@ files:
|
|
86
86
|
- spec/lib/text_injector_spec.rb
|
87
87
|
- spec/spec_helper.rb
|
88
88
|
- text_injector.gemspec
|
89
|
+
- tmp/.gitkeep
|
89
90
|
homepage: http://github.com/tongueroo/text_injector
|
90
91
|
licenses:
|
91
92
|
- MIT
|