Class: Vocco::Generator
- Inherits:
-
Object
- Object
- Vocco::Generator
- Defined in:
- lib/vocco/generator.rb
Defined Under Namespace
Classes: SourceFile
Constant Summary collapse
- CSS =
<<-'__YOU_ARE_SPECIAL__' body { font-family: "Palatino Linotype", "Book Antiqua", Palatino, FreeSerif, serif; font-size: 15px; } html, body { height: 100%; } body { padding: 1em; } .code { font-family: Menlo, Monaco, "DejaVu Sans Mono", Consolas, "Lucida Console", monospace; font-size: 16px; padding: 1em; width: 50%; } .nav { width: 40%; position: fixed; top: 0; left: 55%; height: 100%; font-size: 15px; line-height: 22px; color: #252519; } .nav .wrapper { color: black; height: 100%; } .nav .wrapper .area { background-color: #cccccc; padding: 1em 1em 1em 1em; border-bottom: 1px dashed #bbbbbb; border-top: 1px dashed #666666; } .nav .wrapper .area .autohide { opacity: 0; height: 0px; -webkit-transition: all 0.2s linear; overflow: auto; } .nav .wrapper .area:hover .autohide { height: 150px; opacity: 1; } .nav .wrapper .notes { max-height: 40%; overflow: auto; } table th { text-align: right; } __YOU_ARE_SPECIAL__
Instance Attribute Summary collapse
-
#globs ⇒ Object
readonly
Returns the value of attribute globs.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#notes ⇒ Object
readonly
Returns the value of attribute notes.
-
#out ⇒ Object
readonly
Returns the value of attribute out.
-
#site ⇒ Object
readonly
Returns the value of attribute site.
Instance Method Summary collapse
-
#files ⇒ Object
array of SourceFile's mapped from the glob matches.
-
#glob_regex ⇒ Object
regex to trim the glob dir scopes off a source file path.
-
#initialize(opts) ⇒ Generator
constructor
A new instance of Generator.
- #run ⇒ Object (also: #run!)
-
#scopes ⇒ Object
the paths underneath which the @globs are globbing; the static part of the glob, or "scope" of sorts.
Constructor Details
#initialize(opts) ⇒ Generator
Returns a new instance of Generator.
13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/vocco/generator.rb', line 13 def initialize(opts) @globs = Array(opts[:files] ).compact.map do |glob| glob.gsub(/(^\.\/)|(\/$)/, '') end @out = opts[:out] @notes = Array(opts[:notes]).compact @name = opts[:name].capitalize @site = opts[:site] @vim = Array(opts[:vim]).compact FileUtils.mkdir_p(@out) # ensure out dir exists end |
Instance Attribute Details
#globs ⇒ Object (readonly)
Returns the value of attribute globs.
11 12 13 |
# File 'lib/vocco/generator.rb', line 11 def globs @globs end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
11 12 13 |
# File 'lib/vocco/generator.rb', line 11 def name @name end |
#notes ⇒ Object (readonly)
Returns the value of attribute notes.
11 12 13 |
# File 'lib/vocco/generator.rb', line 11 def notes @notes end |
#out ⇒ Object (readonly)
Returns the value of attribute out.
11 12 13 |
# File 'lib/vocco/generator.rb', line 11 def out @out end |
#site ⇒ Object (readonly)
Returns the value of attribute site.
11 12 13 |
# File 'lib/vocco/generator.rb', line 11 def site @site end |
Instance Method Details
#files ⇒ Object
array of SourceFile's mapped from the glob matches
48 49 50 51 52 53 54 |
# File 'lib/vocco/generator.rb', line 48 def files @files ||= @globs.map do |glob| Dir[glob] end.flatten.uniq.map do |path| SourceFile.new(path, self) end end |
#glob_regex ⇒ Object
regex to trim the glob dir scopes off a source file path.
38 39 40 41 42 43 44 45 |
# File 'lib/vocco/generator.rb', line 38 def glob_regex @glob_regex ||= begin str = scopes.map do |scope| Regexp::escape(scope) end.join('|') /^(\.\/)?(#{str})(\/)?/ end end |
#run ⇒ Object Also known as: run!
56 57 58 |
# File 'lib/vocco/generator.rb', line 56 def run run_vim; postprocess end |
#scopes ⇒ Object
the paths underneath which the @globs are globbing; the static part of the glob, or "scope" of sorts
29 30 31 32 33 34 |
# File 'lib/vocco/generator.rb', line 29 def scopes @scopes ||= @globs.map do |glob| tokens = glob.split('*') tokens.size > 1 ? tokens.first : nil end.compact end |