md_inc 0.3.0 → 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -16,10 +16,22 @@ Or install it yourself as:
16
16
 
17
17
  $ gem install md_inc
18
18
 
19
- **Note that with version 0.3.0 the API for adding
20
- new commands has changed. You command methodss
19
+ ## API Changes
20
+
21
+ The MdInc API has changed somewhat with the
22
+ 0.3.x releases:
23
+ * With version 0.3.0 the API for adding
24
+ new commands has changed. You command methods
21
25
  should be ordinary methods, not module methods
22
- as before.**
26
+ as before.
27
+ * Version 0.3.1 fixes and at the same time changes
28
+ the way that the base directory for the included files
29
+ works. In pre-0.3 versions you would use the `root`
30
+ method to set the base directory. In newer versions
31
+ you can set the base directory by passing an options
32
+ tag to the constructor:
33
+
34
+ processor = MdInc::TextProcessor.new(:base_dir => '/etc')
23
35
 
24
36
  ## Usage
25
37
 
@@ -1,11 +1,11 @@
1
1
  module MdInc
2
2
  module Commands
3
- def root(path)
4
- @root = path
5
- end
6
-
7
3
  def full_path(path)
8
- @root ? File.join(@root, path) : path
4
+ if options[:base_dir]
5
+ File.join(options[:base_dir], path)
6
+ else
7
+ path
8
+ end
9
9
  end
10
10
 
11
11
  def content
@@ -1,3 +1,3 @@
1
1
  module MdInc
2
- VERSION = "0.3.0"
2
+ VERSION = "0.3.1"
3
3
  end
data/spec/md_inc_spec.rb CHANGED
@@ -132,6 +132,15 @@ describe MdInc::TextProcessor do
132
132
  output.should == "first\naaa\nbbb\nlast"
133
133
  end
134
134
 
135
+ it 'can pull in a file from a different direc using the :base_dir option' do
136
+ processor = MdInc::TextProcessor.new(:base_dir => '/etc')
137
+ text = "first\n.inc 'passwd'\nlast"
138
+ output = processor.process(text)
139
+ output.should match(/root/)
140
+ output.should match(/bin/)
141
+
142
+ end
143
+
135
144
  it 'can do include just the lines between two matching lines' do
136
145
  text = "first\n.between(/line 4/, /line 7/, inc('temp2') )\nlast"
137
146
  output = mdi.process(text)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: md_inc
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: