includer 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +37 -0
- data/bin/includer +6 -0
- data/lib/includer/cli.rb +29 -0
- data/lib/includer/includer.rb +9 -0
- data/lib/includer.rb +2 -0
- metadata +68 -0
data/README.md
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
# The Includer
|
2
|
+
|
3
|
+
The Includer is an easy way to include files into another files, like we are used to do when programming (every language has its own variation of `load`, `require`, `import`, etc.) or in the web (Apache's [SSI](http://httpd.apache.org/docs/2.2/howto/ssi.html), PHP's [`include`](http://php.net/manual/en/function.include.php), Rails' [`render :partial`](http://api.rubyonrails.org/classes/ActionController/Base.html#M000658), etc.) but with any kind of file, under any circunstance.
|
4
|
+
|
5
|
+
I use it to split large markdown files, but there are many potential uses (large CSV datasets, or configuration files, for instance). If you do something cool that's worth to be noted in this README, let me know ;-)
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
sudo gem sources -a http://gemcutter.org # [if you haven't done it already]
|
10
|
+
sudo gem install includer
|
11
|
+
|
12
|
+
## Usage
|
13
|
+
|
14
|
+
For a file to include another, you just have to write the following:
|
15
|
+
|
16
|
+
{{path/to/file.ext}}
|
17
|
+
|
18
|
+
For example, this could be the markdown source for this README.md file (it really isn't ;-) ):
|
19
|
+
|
20
|
+
# The Includer
|
21
|
+
|
22
|
+
{{intro.md}}
|
23
|
+
{{install.md}}
|
24
|
+
{{usage.md}}
|
25
|
+
{{copyright.md}}
|
26
|
+
|
27
|
+
This can be done recursively: included files can include more files. Try infinite loops at your own risk. I mean, don't try them ;-)
|
28
|
+
|
29
|
+
Then, just run The Includer:
|
30
|
+
|
31
|
+
$ includer input.txt output.txt
|
32
|
+
|
33
|
+
If you omit the output file, it will write to the standard output.
|
34
|
+
|
35
|
+
## Copyright & Licensing
|
36
|
+
|
37
|
+
Copyright (c) 2010 Sergio Gil. MIT license, see LICENSE for details.
|
data/bin/includer
ADDED
data/lib/includer/cli.rb
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
class Includer
|
2
|
+
|
3
|
+
class CLI
|
4
|
+
|
5
|
+
def initialize(*argv)
|
6
|
+
@input_file, @output_file = argv.first(2)
|
7
|
+
fail("includer <input_file> [<output_file>]") if @input_file.nil?
|
8
|
+
fail("File not found: #{@input_file}") unless File.exists?(@input_file)
|
9
|
+
end
|
10
|
+
|
11
|
+
def run
|
12
|
+
output = Includer.read(@input_file)
|
13
|
+
if @output_file
|
14
|
+
File.open(@output_file, "w") { |f| f.write output }
|
15
|
+
else
|
16
|
+
STDOUT.puts output
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
private
|
21
|
+
|
22
|
+
def fail(message)
|
23
|
+
STDOUT.puts(message)
|
24
|
+
exit(-1)
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
data/lib/includer.rb
ADDED
metadata
ADDED
@@ -0,0 +1,68 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: includer
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- "Sergio Gil P\xC3\xA9rez de la Manga"
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2010-02-15 00:00:00 +01:00
|
13
|
+
default_executable:
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: rspec
|
17
|
+
type: :development
|
18
|
+
version_requirement:
|
19
|
+
version_requirements: !ruby/object:Gem::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ">="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: "0"
|
24
|
+
version:
|
25
|
+
description:
|
26
|
+
email: sgilperez@gmail.com
|
27
|
+
executables:
|
28
|
+
- includer
|
29
|
+
extensions: []
|
30
|
+
|
31
|
+
extra_rdoc_files:
|
32
|
+
- README.md
|
33
|
+
files:
|
34
|
+
- lib/includer/cli.rb
|
35
|
+
- lib/includer/includer.rb
|
36
|
+
- lib/includer.rb
|
37
|
+
- README.md
|
38
|
+
has_rdoc: true
|
39
|
+
homepage: http://github.com/porras/includer
|
40
|
+
licenses: []
|
41
|
+
|
42
|
+
post_install_message:
|
43
|
+
rdoc_options:
|
44
|
+
- --main
|
45
|
+
- README.md
|
46
|
+
require_paths:
|
47
|
+
- lib
|
48
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
49
|
+
requirements:
|
50
|
+
- - ">="
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
version: "0"
|
53
|
+
version:
|
54
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
55
|
+
requirements:
|
56
|
+
- - ">="
|
57
|
+
- !ruby/object:Gem::Version
|
58
|
+
version: "0"
|
59
|
+
version:
|
60
|
+
requirements: []
|
61
|
+
|
62
|
+
rubyforge_project:
|
63
|
+
rubygems_version: 1.3.5
|
64
|
+
signing_key:
|
65
|
+
specification_version: 3
|
66
|
+
summary: Includes files into another files
|
67
|
+
test_files: []
|
68
|
+
|