text_injector 0.0.1 → 0.0.2
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 +4 -4
- data/README.md +1 -0
- data/lib/text_injector/version.rb +1 -1
- data/lib/text_injector.rb +2 -9
- data/spec/lib/text_injector_spec.rb +1 -6
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5c48a453ce30ba29eb82b7b9a7ef0293fe6765a1
|
4
|
+
data.tar.gz: cec7a0dc041420d0a3a99890a7f22ed34a7190f8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1482ff8c7ed8f5e8793a220a1247f7d7be0946e8bd447b86785d9ff7bd93c4c0175c14bc60955482655d09da4b579f05c1ec2c1a6995939a99ca05f124cc4e76
|
7
|
+
data.tar.gz: e2325dc0532f9a08108fb6862f4889987f96d199affc671bb9bfc992037ca8998563213d91cffb16a7034a0b2ab95cafd08ff19dd1c6bf886810ed6a64a88b33
|
data/README.md
CHANGED
data/lib/text_injector.rb
CHANGED
@@ -3,6 +3,7 @@ require 'fileutils'
|
|
3
3
|
|
4
4
|
class TextInjector
|
5
5
|
attr_reader :file
|
6
|
+
attr_accessor :content, :identifier
|
6
7
|
def initialize(options={})
|
7
8
|
@options = options
|
8
9
|
@file = @options[:file]
|
@@ -11,14 +12,6 @@ class TextInjector
|
|
11
12
|
@content = @options[:content]
|
12
13
|
end
|
13
14
|
|
14
|
-
# both setter and getter for the dsl
|
15
|
-
def content(text = nil)
|
16
|
-
text.nil? ? @content : @content = text
|
17
|
-
end
|
18
|
-
def identifier(id = nil)
|
19
|
-
id.nil? ? @identifier : @identifier = id
|
20
|
-
end
|
21
|
-
|
22
15
|
def run
|
23
16
|
if File.exists?(@file)
|
24
17
|
write_file(updated_file)
|
@@ -38,7 +31,7 @@ protected
|
|
38
31
|
end
|
39
32
|
|
40
33
|
def marked_content
|
41
|
-
@marked_content
|
34
|
+
@marked_content = [comment_open, @content, comment_close].join("\n")
|
42
35
|
end
|
43
36
|
|
44
37
|
def read_file
|
@@ -35,12 +35,7 @@ describe TextInjector do
|
|
35
35
|
data = IO.read(@file)
|
36
36
|
data.should include('added content')
|
37
37
|
|
38
|
-
injector =
|
39
|
-
:mute => true,
|
40
|
-
:file => @file,
|
41
|
-
:identifier => @identifier,
|
42
|
-
:content => "updated content"
|
43
|
-
)
|
38
|
+
injector.content = "updated content"
|
44
39
|
injector.run
|
45
40
|
data = IO.read(@file)
|
46
41
|
data.should_not include("added content")
|