text_injector 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1aa2b51a9f81a902aec4e3914387d9e351d757ca
4
- data.tar.gz: 1c214c373b2260f81abf253eed5d7c3270ee8108
3
+ metadata.gz: 5c48a453ce30ba29eb82b7b9a7ef0293fe6765a1
4
+ data.tar.gz: cec7a0dc041420d0a3a99890a7f22ed34a7190f8
5
5
  SHA512:
6
- metadata.gz: 6421c6a051ec465d4fd3d0f9bbe7dea4a1fb503d93002ea1a6288d9dc045e9dfc034ed39d675ed7a883f8ab7817c18258a57c64204de2664fa6036a5d7349910
7
- data.tar.gz: 161018abf57233c00b4ff4a24b8f663125609aa3b918e7c3e3d30d974233fd159f8279704b669f972a094e9026cb55d3e7dfe8694ad000c13df0e5f650c90aa9
6
+ metadata.gz: 1482ff8c7ed8f5e8793a220a1247f7d7be0946e8bd447b86785d9ff7bd93c4c0175c14bc60955482655d09da4b579f05c1ec2c1a6995939a99ca05f124cc4e76
7
+ data.tar.gz: e2325dc0532f9a08108fb6862f4889987f96d199affc671bb9bfc992037ca8998563213d91cffb16a7034a0b2ab95cafd08ff19dd1c6bf886810ed6a64a88b33
data/README.md CHANGED
@@ -21,6 +21,7 @@ Or install it yourself as:
21
21
  ## Usage
22
22
 
23
23
  <pre>
24
+ require 'text_injector'
24
25
  injector = TextInjector.new(
25
26
  :identifier => "custom-id",
26
27
  :file => "/tmp/test.txt",
@@ -1,3 +1,3 @@
1
1
  class TextInjector
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
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 ||= [comment_open, @content, comment_close].join("\n")
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 = TextInjector.new(
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")
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.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tung Nguyen