detroit-erbside 0.2.0 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/LICENSE.txt +676 -0
- data/README.md +46 -0
- data/lib/detroit-erbside.rb +56 -38
- data/man/detroit-erbside.5 +100 -0
- data/man/detroit-erbside.5.html +151 -0
- data/man/detroit-erbside.5.ronn +7 -7
- metadata +44 -24
- data/.ruby +0 -35
- data/COPYING.rdoc +0 -705
- data/README.rdoc +0 -31
data/README.md
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
# Detroit Erbside Tool
|
2
|
+
|
3
|
+
[Website](http://rubyworks.github.com/detroit-erbside) /
|
4
|
+
[Report Issue](http://github.com/rubyworks/detroit-erbside/issues) /
|
5
|
+
[Development](http://github.com/rubyworks/detroit-erbside)
|
6
|
+
|
7
|
+
[![Build Status](https://secure.travis-ci.org/rubyworks/detroit-erbside.png)](http://travis-ci.org/rubyworks/detroit-erbside)
|
8
|
+
[![Gem Version](https://badge.fury.io/rb/detroit-erbside.png)](http://badge.fury.io/rb/detroit-erbside)
|
9
|
+
[![Flattr Me](http://api.flattr.com/button/flattr-badge-large.png)](http://flattr.com/thing/324911/Rubyworks-Ruby-Development-Fund)
|
10
|
+
|
11
|
+
|
12
|
+
## About
|
13
|
+
|
14
|
+
The Erbside tool provide inline source code templating during
|
15
|
+
the standard `generate` phase.
|
16
|
+
|
17
|
+
See http://rubyworks.github.com/erbside for more information.
|
18
|
+
|
19
|
+
|
20
|
+
## Installation
|
21
|
+
|
22
|
+
### Using RubyGems
|
23
|
+
|
24
|
+
$ gem install detroit-erbside
|
25
|
+
|
26
|
+
|
27
|
+
## Copyrights
|
28
|
+
|
29
|
+
Detroit Erbside
|
30
|
+
|
31
|
+
Copyright (c) 2011 Rubyworks
|
32
|
+
|
33
|
+
(GPL-3.0 License)
|
34
|
+
|
35
|
+
This program is free software: you can redistribute it and/or modify
|
36
|
+
it under the terms of the GNU General Public License as published by
|
37
|
+
the Free Software Foundation, either version 3 of the License, or
|
38
|
+
(at your option) any later version.
|
39
|
+
|
40
|
+
This program is distributed in the hope that it will be useful,
|
41
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
42
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
43
|
+
GNU General Public License for more details.
|
44
|
+
|
45
|
+
See LICENSE.txt file for full details.
|
46
|
+
|
data/lib/detroit-erbside.rb
CHANGED
@@ -1,11 +1,39 @@
|
|
1
|
-
require 'detroit
|
1
|
+
require 'detroit-standard'
|
2
2
|
|
3
3
|
module Detroit
|
4
4
|
|
5
|
+
##
|
6
|
+
# Erbside tool is an inline templating tool for source code.
|
7
|
+
# It can be useful for keeping information uptodate that is
|
8
|
+
# static in code, but dynamic to the project itself. A good
|
9
|
+
# example a `VERSION` constant.
|
10
|
+
#
|
11
|
+
# module MyApp
|
12
|
+
# VERSION = "1.2.0" #:erb: VERSION = "<%= version %>"
|
13
|
+
# ...
|
5
14
|
#
|
6
15
|
class Erbside < Tool
|
7
16
|
|
8
|
-
#
|
17
|
+
# Designed to work with the standard assembly. This tool
|
18
|
+
# attaches to `generate` station.
|
19
|
+
#
|
20
|
+
# @!parse
|
21
|
+
# include Standard
|
22
|
+
#
|
23
|
+
assembly Standard
|
24
|
+
|
25
|
+
# Loction of manpage for tool.
|
26
|
+
MANPAGE = File.dirname(__FILE__) + '/../man/detroit-erbside.5'
|
27
|
+
|
28
|
+
# Load requirements and set attribute defaults.
|
29
|
+
#
|
30
|
+
# @return [void]
|
31
|
+
def prerequisite
|
32
|
+
require 'erbside'
|
33
|
+
require 'shellwords'
|
34
|
+
|
35
|
+
@path = 'lib'
|
36
|
+
end
|
9
37
|
|
10
38
|
# Paths of lifes to render.
|
11
39
|
attr_accessor :path
|
@@ -22,58 +50,48 @@ module Detroit
|
|
22
50
|
# Prompt on each write.
|
23
51
|
attr_accessor :prompt
|
24
52
|
|
53
|
+
# Metadata resources, default is project metadata.
|
54
|
+
attr_accessor :resources
|
25
55
|
|
26
|
-
#
|
27
|
-
|
28
|
-
def assemble?(station, options={})
|
29
|
-
case station
|
30
|
-
when :generate then true
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
# Attach to `generate` station.
|
35
|
-
def assemble(station, options={})
|
36
|
-
case station
|
37
|
-
when :generate then generate
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
# S E R V I C E M E T H O D S
|
56
|
+
# Alias for resources.
|
57
|
+
alias_accessor :resource, :resources
|
42
58
|
|
43
59
|
# Render templates.
|
44
60
|
def generate
|
45
61
|
options = {}
|
46
|
-
options[:prompt]
|
47
|
-
options[:exclude]
|
48
|
-
options[:ignore]
|
62
|
+
options[:prompt] = prompt
|
63
|
+
options[:exclude] = exclude
|
64
|
+
options[:ignore] = ignore
|
65
|
+
options[:resources] = resources || metadata
|
49
66
|
|
50
67
|
::Erbside::Runner.new(path, options).render
|
51
68
|
end
|
52
69
|
|
70
|
+
# This tool ties into the `generate` station of the standard
|
71
|
+
# assembly.
|
72
|
+
#
|
73
|
+
# @return [Boolean]
|
74
|
+
def assemble?(station, options={})
|
75
|
+
return true if station == :generate
|
76
|
+
end
|
77
|
+
|
53
78
|
private
|
54
79
|
|
80
|
+
# If project metadata responds to `#to_h` then we can us it.
|
81
|
+
def metadata
|
82
|
+
data = super
|
83
|
+
if data.respond_to?(:to_h)
|
84
|
+
data.to_h
|
85
|
+
else
|
86
|
+
nil
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
55
90
|
#
|
56
91
|
#def files
|
57
92
|
# amass(path, exclude, ignore)
|
58
93
|
#end
|
59
94
|
|
60
|
-
#
|
61
|
-
def initialize_requires
|
62
|
-
require 'erbside'
|
63
|
-
require 'shellwords'
|
64
|
-
end
|
65
|
-
|
66
|
-
#
|
67
|
-
def initialize_defaults
|
68
|
-
@path = 'lib'
|
69
|
-
end
|
70
|
-
|
71
|
-
public
|
72
|
-
|
73
|
-
def self.man_page
|
74
|
-
File.dirname(__FILE__)+'/../man/detroit-erbside.5'
|
75
|
-
end
|
76
|
-
|
77
95
|
end
|
78
96
|
|
79
97
|
end
|
@@ -0,0 +1,100 @@
|
|
1
|
+
.\" generated with Ronn/v0.7.3
|
2
|
+
.\" http://github.com/rtomayko/ronn/tree/0.7.3
|
3
|
+
.
|
4
|
+
.TH "DETROIT\-ERBSIDE" "5" "January 2014" "" ""
|
5
|
+
.
|
6
|
+
.SH "NAME"
|
7
|
+
\fBdetroit\-erbside\fR \- render inline source code templates
|
8
|
+
.
|
9
|
+
.SH "DESCRIPTION"
|
10
|
+
The DNote plug\-in for Detroit utilize the Erbside command line tool to render inline templates in source code files\.
|
11
|
+
.
|
12
|
+
.SH "OPTIONS"
|
13
|
+
The following options can be used in the Detroit toolchain file for defining an Erbside tool\.
|
14
|
+
.
|
15
|
+
.IP "\(bu" 4
|
16
|
+
\fBpath\fR \- File paths to render\. Default is \fBlib\fR\.
|
17
|
+
.
|
18
|
+
.IP "\(bu" 4
|
19
|
+
\fBexclude\fR \- Exclude subpaths of \fBpath\fR\.
|
20
|
+
.
|
21
|
+
.IP "\(bu" 4
|
22
|
+
\fBignore\fR \- Ignore subpaths of \fBpath\fR based on basename of path\.
|
23
|
+
.
|
24
|
+
.IP "\(bu" 4
|
25
|
+
\fBresource\fR \- Resource file(s) to gather metadata from\.
|
26
|
+
.
|
27
|
+
.IP "\(bu" 4
|
28
|
+
\fBprompt\fR \- Prompt before writing each file\.
|
29
|
+
.
|
30
|
+
.IP "" 0
|
31
|
+
.
|
32
|
+
.SH "EXAMPLES"
|
33
|
+
A common use by the author of this plugin is for insertion of version number into source code\. Say we have the file, \fBlib/myapp/version\.rb\fR\.
|
34
|
+
.
|
35
|
+
.IP "" 4
|
36
|
+
.
|
37
|
+
.nf
|
38
|
+
|
39
|
+
module MyApp
|
40
|
+
VERSION = "1\.0\.0" #:erb: VERSION = "<%= version %>"
|
41
|
+
end
|
42
|
+
.
|
43
|
+
.fi
|
44
|
+
.
|
45
|
+
.IP "" 0
|
46
|
+
.
|
47
|
+
.P
|
48
|
+
Then in the toolchain file:
|
49
|
+
.
|
50
|
+
.IP "" 4
|
51
|
+
.
|
52
|
+
.nf
|
53
|
+
|
54
|
+
erbside:
|
55
|
+
path: lib/myapp/version\.rb
|
56
|
+
resource: \.index
|
57
|
+
.
|
58
|
+
.fi
|
59
|
+
.
|
60
|
+
.IP "" 0
|
61
|
+
.
|
62
|
+
.P
|
63
|
+
Of course, by default the path is \fBlib\fR and the resource is \fB\.index\fR if present\. So a simple:
|
64
|
+
.
|
65
|
+
.IP "" 4
|
66
|
+
.
|
67
|
+
.nf
|
68
|
+
|
69
|
+
erbside:
|
70
|
+
active: true
|
71
|
+
.
|
72
|
+
.fi
|
73
|
+
.
|
74
|
+
.IP "" 0
|
75
|
+
.
|
76
|
+
.P
|
77
|
+
Will likely do the trick\.
|
78
|
+
.
|
79
|
+
.SH "RESOURCES"
|
80
|
+
For more information:
|
81
|
+
.
|
82
|
+
.IP "\(bu" 4
|
83
|
+
API Reference \fIhttp://rubydoc\.info/gems/detroit\-erbside\fR
|
84
|
+
.
|
85
|
+
.IP "\(bu" 4
|
86
|
+
Development Site \fIhttp://github\.com/detroit/detroit\-erbside\fR
|
87
|
+
.
|
88
|
+
.IP "\(bu" 4
|
89
|
+
Detroit Project \fIhttp://detroit\.github\.com\fR
|
90
|
+
.
|
91
|
+
.IP "" 0
|
92
|
+
.
|
93
|
+
.SH "COPYRIGHT"
|
94
|
+
Copyright (c) 2011 Thomas Sawyer, Rubyworks
|
95
|
+
.
|
96
|
+
.P
|
97
|
+
Detroit Erbside is distributable in accordance with the GPLv3 license\.
|
98
|
+
.
|
99
|
+
.SH "SEE ALSO"
|
100
|
+
detroit(1), erbside(1)
|
@@ -0,0 +1,151 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<meta http-equiv='content-type' value='text/html;charset=utf8'>
|
5
|
+
<meta name='generator' value='Ronn/v0.7.3 (http://github.com/rtomayko/ronn/tree/0.7.3)'>
|
6
|
+
<title>detroit-erbside(5) - render inline source code templates</title>
|
7
|
+
<style type='text/css' media='all'>
|
8
|
+
/* style: man */
|
9
|
+
body#manpage {margin:0}
|
10
|
+
.mp {max-width:100ex;padding:0 9ex 1ex 4ex}
|
11
|
+
.mp p,.mp pre,.mp ul,.mp ol,.mp dl {margin:0 0 20px 0}
|
12
|
+
.mp h2 {margin:10px 0 0 0}
|
13
|
+
.mp > p,.mp > pre,.mp > ul,.mp > ol,.mp > dl {margin-left:8ex}
|
14
|
+
.mp h3 {margin:0 0 0 4ex}
|
15
|
+
.mp dt {margin:0;clear:left}
|
16
|
+
.mp dt.flush {float:left;width:8ex}
|
17
|
+
.mp dd {margin:0 0 0 9ex}
|
18
|
+
.mp h1,.mp h2,.mp h3,.mp h4 {clear:left}
|
19
|
+
.mp pre {margin-bottom:20px}
|
20
|
+
.mp pre+h2,.mp pre+h3 {margin-top:22px}
|
21
|
+
.mp h2+pre,.mp h3+pre {margin-top:5px}
|
22
|
+
.mp img {display:block;margin:auto}
|
23
|
+
.mp h1.man-title {display:none}
|
24
|
+
.mp,.mp code,.mp pre,.mp tt,.mp kbd,.mp samp,.mp h3,.mp h4 {font-family:monospace;font-size:14px;line-height:1.42857142857143}
|
25
|
+
.mp h2 {font-size:16px;line-height:1.25}
|
26
|
+
.mp h1 {font-size:20px;line-height:2}
|
27
|
+
.mp {text-align:justify;background:#fff}
|
28
|
+
.mp,.mp code,.mp pre,.mp pre code,.mp tt,.mp kbd,.mp samp {color:#131211}
|
29
|
+
.mp h1,.mp h2,.mp h3,.mp h4 {color:#030201}
|
30
|
+
.mp u {text-decoration:underline}
|
31
|
+
.mp code,.mp strong,.mp b {font-weight:bold;color:#131211}
|
32
|
+
.mp em,.mp var {font-style:italic;color:#232221;text-decoration:none}
|
33
|
+
.mp a,.mp a:link,.mp a:hover,.mp a code,.mp a pre,.mp a tt,.mp a kbd,.mp a samp {color:#0000ff}
|
34
|
+
.mp b.man-ref {font-weight:normal;color:#434241}
|
35
|
+
.mp pre {padding:0 4ex}
|
36
|
+
.mp pre code {font-weight:normal;color:#434241}
|
37
|
+
.mp h2+pre,h3+pre {padding-left:0}
|
38
|
+
ol.man-decor,ol.man-decor li {margin:3px 0 10px 0;padding:0;float:left;width:33%;list-style-type:none;text-transform:uppercase;color:#999;letter-spacing:1px}
|
39
|
+
ol.man-decor {width:100%}
|
40
|
+
ol.man-decor li.tl {text-align:left}
|
41
|
+
ol.man-decor li.tc {text-align:center;letter-spacing:4px}
|
42
|
+
ol.man-decor li.tr {text-align:right;float:right}
|
43
|
+
</style>
|
44
|
+
</head>
|
45
|
+
<!--
|
46
|
+
The following styles are deprecated and will be removed at some point:
|
47
|
+
div#man, div#man ol.man, div#man ol.head, div#man ol.man.
|
48
|
+
|
49
|
+
The .man-page, .man-decor, .man-head, .man-foot, .man-title, and
|
50
|
+
.man-navigation should be used instead.
|
51
|
+
-->
|
52
|
+
<body id='manpage'>
|
53
|
+
<div class='mp' id='man'>
|
54
|
+
|
55
|
+
<div class='man-navigation' style='display:none'>
|
56
|
+
<a href="#NAME">NAME</a>
|
57
|
+
<a href="#DESCRIPTION">DESCRIPTION</a>
|
58
|
+
<a href="#OPTIONS">OPTIONS</a>
|
59
|
+
<a href="#EXAMPLES">EXAMPLES</a>
|
60
|
+
<a href="#RESOURCES">RESOURCES</a>
|
61
|
+
<a href="#COPYRIGHT">COPYRIGHT</a>
|
62
|
+
<a href="#SEE-ALSO">SEE ALSO</a>
|
63
|
+
</div>
|
64
|
+
|
65
|
+
<ol class='man-decor man-head man head'>
|
66
|
+
<li class='tl'>detroit-erbside(5)</li>
|
67
|
+
<li class='tc'></li>
|
68
|
+
<li class='tr'>detroit-erbside(5)</li>
|
69
|
+
</ol>
|
70
|
+
|
71
|
+
<h2 id="NAME">NAME</h2>
|
72
|
+
<p class="man-name">
|
73
|
+
<code>detroit-erbside</code> - <span class="man-whatis">render inline source code templates</span>
|
74
|
+
</p>
|
75
|
+
|
76
|
+
<h2 id="DESCRIPTION">DESCRIPTION</h2>
|
77
|
+
|
78
|
+
<p>The DNote plug-in for Detroit utilize the Erbside command line tool
|
79
|
+
to render inline templates in source code files.</p>
|
80
|
+
|
81
|
+
<h2 id="OPTIONS">OPTIONS</h2>
|
82
|
+
|
83
|
+
<p>The following options can be used in the Detroit toolchain file
|
84
|
+
for defining an Erbside tool.</p>
|
85
|
+
|
86
|
+
<ul>
|
87
|
+
<li><p><code>path</code> - File paths to render. Default is <code>lib</code>.</p></li>
|
88
|
+
<li><p><code>exclude</code> - Exclude subpaths of <code>path</code>.</p></li>
|
89
|
+
<li><p><code>ignore</code> - Ignore subpaths of <code>path</code> based on basename of path.</p></li>
|
90
|
+
<li><p><code>resource</code> - Resource file(s) to gather metadata from.</p></li>
|
91
|
+
<li><p><code>prompt</code> - Prompt before writing each file.</p></li>
|
92
|
+
</ul>
|
93
|
+
|
94
|
+
|
95
|
+
<h2 id="EXAMPLES">EXAMPLES</h2>
|
96
|
+
|
97
|
+
<p>A common use by the author of this plugin is for insertion of version
|
98
|
+
number into source code. Say we have the file, <code>lib/myapp/version.rb</code>.</p>
|
99
|
+
|
100
|
+
<pre><code>module MyApp
|
101
|
+
VERSION = "1.0.0" #:erb: VERSION = "<%= version %>"
|
102
|
+
end
|
103
|
+
</code></pre>
|
104
|
+
|
105
|
+
<p>Then in the toolchain file:</p>
|
106
|
+
|
107
|
+
<pre><code>erbside:
|
108
|
+
path: lib/myapp/version.rb
|
109
|
+
resource: .index
|
110
|
+
</code></pre>
|
111
|
+
|
112
|
+
<p>Of course, by default the path is <code>lib</code> and the resource is <code>.index</code>
|
113
|
+
if present. So a simple:</p>
|
114
|
+
|
115
|
+
<pre><code>erbside:
|
116
|
+
active: true
|
117
|
+
</code></pre>
|
118
|
+
|
119
|
+
<p>Will likely do the trick.</p>
|
120
|
+
|
121
|
+
<h2 id="RESOURCES">RESOURCES</h2>
|
122
|
+
|
123
|
+
<p>For more information:</p>
|
124
|
+
|
125
|
+
<ul>
|
126
|
+
<li><p><a href="http://rubydoc.info/gems/detroit-erbside">API Reference</a></p></li>
|
127
|
+
<li><p><a href="http://github.com/detroit/detroit-erbside">Development Site</a></p></li>
|
128
|
+
<li><p><a href="http://detroit.github.com">Detroit Project</a></p></li>
|
129
|
+
</ul>
|
130
|
+
|
131
|
+
|
132
|
+
<h2 id="COPYRIGHT">COPYRIGHT</h2>
|
133
|
+
|
134
|
+
<p>Copyright (c) 2011 Thomas Sawyer, Rubyworks</p>
|
135
|
+
|
136
|
+
<p>Detroit Erbside is distributable in accordance with the GPLv3 license.</p>
|
137
|
+
|
138
|
+
<h2 id="SEE-ALSO">SEE ALSO</h2>
|
139
|
+
|
140
|
+
<p><span class="man-ref">detroit<span class="s">(1)</span></span>, <span class="man-ref">erbside<span class="s">(1)</span></span></p>
|
141
|
+
|
142
|
+
|
143
|
+
<ol class='man-decor man-foot man foot'>
|
144
|
+
<li class='tl'></li>
|
145
|
+
<li class='tc'>January 2014</li>
|
146
|
+
<li class='tr'>detroit-erbside(5)</li>
|
147
|
+
</ol>
|
148
|
+
|
149
|
+
</div>
|
150
|
+
</body>
|
151
|
+
</html>
|
data/man/detroit-erbside.5.ronn
CHANGED
@@ -9,8 +9,8 @@ to render inline templates in source code files.
|
|
9
9
|
|
10
10
|
## OPTIONS
|
11
11
|
|
12
|
-
The following options can be used in the Detroit
|
13
|
-
for defining an Erbside
|
12
|
+
The following options can be used in the Detroit toolchain file
|
13
|
+
for defining an Erbside tool.
|
14
14
|
|
15
15
|
* `path` - File paths to render. Default is `lib`.
|
16
16
|
|
@@ -25,20 +25,20 @@ for defining an Erbside service.
|
|
25
25
|
|
26
26
|
## EXAMPLES
|
27
27
|
|
28
|
-
|
29
|
-
into code. Say
|
28
|
+
A common use by the author of this plugin is for insertion of version
|
29
|
+
number into source code. Say we have the file, `lib/myapp/version.rb`.
|
30
30
|
|
31
31
|
module MyApp
|
32
32
|
VERSION = "1.0.0" #:erb: VERSION = "<%= version %>"
|
33
33
|
end
|
34
34
|
|
35
|
-
|
35
|
+
Then in the toolchain file:
|
36
36
|
|
37
37
|
erbside:
|
38
38
|
path: lib/myapp/version.rb
|
39
|
-
resource: .
|
39
|
+
resource: .index
|
40
40
|
|
41
|
-
Of course, by default the path is `lib` and the resource is `.
|
41
|
+
Of course, by default the path is `lib` and the resource is `.index`
|
42
42
|
if present. So a simple:
|
43
43
|
|
44
44
|
erbside:
|