text_injector 0.0.2 → 0.0.3

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: 5c48a453ce30ba29eb82b7b9a7ef0293fe6765a1
4
- data.tar.gz: cec7a0dc041420d0a3a99890a7f22ed34a7190f8
3
+ metadata.gz: 9e03b1fb3b239226aba3c34d1f0dd3d33b9a9285
4
+ data.tar.gz: 475f20c84ea53d65ed69466030c134b80fb1735a
5
5
  SHA512:
6
- metadata.gz: 1482ff8c7ed8f5e8793a220a1247f7d7be0946e8bd447b86785d9ff7bd93c4c0175c14bc60955482655d09da4b579f05c1ec2c1a6995939a99ca05f124cc4e76
7
- data.tar.gz: e2325dc0532f9a08108fb6862f4889987f96d199affc671bb9bfc992037ca8998563213d91cffb16a7034a0b2ab95cafd08ff19dd1c6bf886810ed6a64a88b33
6
+ metadata.gz: d405677b2f18a693596861f02ae7a6a50bdabeb3322d504d44f62e5d376847730b9e5da3edcb1ac3e22c020069434fdb2247a28da37bdc1cb2fffc0d673d92a0
7
+ data.tar.gz: 54b095a0f53f63ffa397d715c1f36091bb5e9a69eb03e8e4d51e3d6eb9b88d13d17aaaa67f22ebe0feaa3cba3139b8bda3d8355936ccb24aec4562abc1f0e245
data/.gitignore CHANGED
@@ -14,4 +14,3 @@ rdoc
14
14
  spec/reports
15
15
  test/tmp
16
16
  test/version_tmp
17
- tmp
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}.#{Process.pid}.tmp"
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[:noop]
53
- say "Tmp file written to #{tmp}"
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)
@@ -1,3 +1,3 @@
1
1
  class TextInjector
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
@@ -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.2
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