md_inc 0.2.1 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +2 -0
- data/Gemfile.lock +24 -0
- data/README.md +4 -4
- data/bin/md_inc +33 -0
- data/lib/md_inc/version.rb +1 -1
- data/lib/md_inc.rb +8 -0
- metadata +6 -3
data/Gemfile
CHANGED
data/Gemfile.lock
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
md_inc (0.2.2)
|
5
|
+
|
6
|
+
GEM
|
7
|
+
remote: https://rubygems.org/
|
8
|
+
specs:
|
9
|
+
diff-lcs (1.1.3)
|
10
|
+
rspec (2.12.0)
|
11
|
+
rspec-core (~> 2.12.0)
|
12
|
+
rspec-expectations (~> 2.12.0)
|
13
|
+
rspec-mocks (~> 2.12.0)
|
14
|
+
rspec-core (2.12.2)
|
15
|
+
rspec-expectations (2.12.1)
|
16
|
+
diff-lcs (~> 1.1.3)
|
17
|
+
rspec-mocks (2.12.2)
|
18
|
+
|
19
|
+
PLATFORMS
|
20
|
+
ruby
|
21
|
+
|
22
|
+
DEPENDENCIES
|
23
|
+
md_inc!
|
24
|
+
rspec
|
data/README.md
CHANGED
@@ -21,7 +21,7 @@ Or install it yourself as:
|
|
21
21
|
MdInc is a simple text inclusion filter intended for use
|
22
22
|
with markdown and similar text formatting utilities.
|
23
23
|
MdInc provides simple 'include this other file' kind
|
24
|
-
of processing. Using
|
24
|
+
of processing. Using MdInc is straight forwark: Just require
|
25
25
|
it in and use the process method:
|
26
26
|
|
27
27
|
require 'md_inc'
|
@@ -29,9 +29,9 @@ it in and use the process method:
|
|
29
29
|
v = MdInc::TextProcessor.new
|
30
30
|
output = v.process 'The quick brown fox'
|
31
31
|
|
32
|
-
In the simple case like the one above,
|
32
|
+
In the simple case like the one above, MdInc simply
|
33
33
|
returns the text unchanged. The interesting bit is
|
34
|
-
when your input text includes commands that
|
34
|
+
when your input text includes commands that MdInc
|
35
35
|
recognizes. MdInc commands all start with a . in
|
36
36
|
the first column of a line. The most basic is
|
37
37
|
`.inc`. Here is some input that includes an `.inc`
|
@@ -42,7 +42,7 @@ command:
|
|
42
42
|
.inc 'some_other_file.md'
|
43
43
|
And the last line.
|
44
44
|
|
45
|
-
Run the file above through
|
45
|
+
Run the file above through MdInc and the output
|
46
46
|
will include the contents of `some_other_file.md`
|
47
47
|
embedded in it.
|
48
48
|
|
data/bin/md_inc
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'optparse'
|
3
|
+
require "md_inc"
|
4
|
+
|
5
|
+
base_dir = nil
|
6
|
+
|
7
|
+
op = OptionParser.new do |op|
|
8
|
+
on "-h", "--help", "Print help string" do
|
9
|
+
puts op
|
10
|
+
exit 0
|
11
|
+
end
|
12
|
+
|
13
|
+
on "-i dir", "--include dir", "Add this directory to the Ruby path" do |dir|
|
14
|
+
$: << dir
|
15
|
+
end
|
16
|
+
|
17
|
+
on '-d dir', '--dir dir', "Set the default dir for pulling incldue files" do |dir|
|
18
|
+
base_dir = dir
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
op.parse!
|
23
|
+
|
24
|
+
tp = MdInc::TextProcessor.new
|
25
|
+
tp.base_dir = base_dir if base_dir
|
26
|
+
|
27
|
+
if ARGV.empty?
|
28
|
+
tp.process_stream(STDIN)
|
29
|
+
else
|
30
|
+
ARGV.each do |path|
|
31
|
+
tp.process_file(path)
|
32
|
+
end
|
33
|
+
end
|
data/lib/md_inc/version.rb
CHANGED
data/lib/md_inc.rb
CHANGED
@@ -3,6 +3,14 @@ require 'md_inc/md_inc_commands'
|
|
3
3
|
|
4
4
|
module MdInc
|
5
5
|
class TextProcessor
|
6
|
+
def process_stream(s)
|
7
|
+
process(s.read)
|
8
|
+
end
|
9
|
+
|
10
|
+
def process_file(path)
|
11
|
+
process(File.read(path))
|
12
|
+
end
|
13
|
+
|
6
14
|
def process(content)
|
7
15
|
output = []
|
8
16
|
content.split("\n").each do |line|
|
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.2.
|
4
|
+
version: 0.2.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,21 +9,24 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-02-12 00:00:00.
|
12
|
+
date: 2013-02-12 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: MdInc is a simple text inclusion utility (it sucks in files) intended
|
15
15
|
for use with markdown and similar utilities.
|
16
16
|
email:
|
17
17
|
- russ@russolsen.com
|
18
|
-
executables:
|
18
|
+
executables:
|
19
|
+
- md_inc
|
19
20
|
extensions: []
|
20
21
|
extra_rdoc_files: []
|
21
22
|
files:
|
22
23
|
- .gitignore
|
23
24
|
- Gemfile
|
25
|
+
- Gemfile.lock
|
24
26
|
- LICENSE
|
25
27
|
- README.md
|
26
28
|
- Rakefile
|
29
|
+
- bin/md_inc
|
27
30
|
- lib/md_inc.rb
|
28
31
|
- lib/md_inc/md_inc_commands.rb
|
29
32
|
- lib/md_inc/version.rb
|