Class: Atom::Scaffold
- Inherits:
-
Object
- Object
- Atom::Scaffold
- Defined in:
- lib/atom/scaffold.rb
Class Method Summary collapse
- .create(root_dir) ⇒ Object
- .mk_atom(root_dir) ⇒ Object
- .mk_concept(root_dir) ⇒ Object
- .mk_dotatom(root_dir) ⇒ Object
- .mk_dotgitignore(root_dir) ⇒ Object
- .mk_html_skeleton(root_dir) ⇒ Object
- .mk_map(root_dir) ⇒ Object
- .mk_procedure(root_dir) ⇒ Object
- .mkdirs(root_dir, dirs) ⇒ Object
Class Method Details
.create(root_dir) ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/atom/scaffold.rb', line 3 def self.create(root_dir) dirs = [ 'source', ['source', 'topics'], ['source', 'maps'], 'config', 'temp', 'output', ['output', 'html'], 'templates', 'plugins' ] if mkdirs(root_dir, dirs) mk_dotatom(root_dir) mk_dotgitignore(root_dir) mk_atom(root_dir) mk_concept(root_dir) mk_procedure(root_dir) mk_map(root_dir) mk_html_skeleton(root_dir) end end |
.mk_atom(root_dir) ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/atom/scaffold.rb', line 43 def self.mk_atom(root_dir) $stdout.puts "create [File]: #{root_dir}/config/atom.yml" File.open("#{root_dir}/config/atom.yml", "w") do |file| file.puts <<EOS markup: textile plugins: { pre: [], post: [] } EOS end end |
.mk_concept(root_dir) ⇒ Object
55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/atom/scaffold.rb', line 55 def self.mk_concept(root_dir) $stdout.puts "create [File]: #{root_dir}/templates/concept.textile" File.open("#{root_dir}/templates/concept.textile", "w") do |file| file.puts <<EOS --- author: {{author}} class: concept --- h1(topic-title). {{title}} EOS end end |
.mk_dotatom(root_dir) ⇒ Object
27 28 29 30 |
# File 'lib/atom/scaffold.rb', line 27 def self.mk_dotatom(root_dir) $stdout.puts "create [File]: #{root_dir}/.atom" FileUtils.touch "#{root_dir}/.atom" end |
.mk_dotgitignore(root_dir) ⇒ Object
32 33 34 35 36 37 38 39 40 41 |
# File 'lib/atom/scaffold.rb', line 32 def self.mk_dotgitignore(root_dir) $stdout.puts "create [File]: #{root_dir}/.gitignore" File.open("#{root_dir}/.gitignore", "w") do |file| file.puts <<EOS config/ output/ temp/ EOS end end |
.mk_html_skeleton(root_dir) ⇒ Object
112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 |
# File 'lib/atom/scaffold.rb', line 112 def self.mk_html_skeleton(root_dir) $stdout.puts "create [File]: #{root_dir}/templates/default.html" File.open("#{root_dir}/templates/default.html", "w") do |file| file.puts <<EOS <!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <title>{{title}}</title> </head> <body> {{{body}}} </body> </html> EOS end end |
.mk_map(root_dir) ⇒ Object
93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 |
# File 'lib/atom/scaffold.rb', line 93 def self.mk_map(root_dir) $stdout.puts "create [File]: #{root_dir}/templates/map.textile" File.open("#{root_dir}/templates/map.textile", "w") do |file| file.puts <<EOS --- author: {{author}} class: map --- h1(map-title). {{title}} To include topics in this document, begin a line with @=@ followed by a space and the title of the topic. Like so: bc. = Title of My Topic EOS end end |
.mk_procedure(root_dir) ⇒ Object
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 |
# File 'lib/atom/scaffold.rb', line 70 def self.mk_procedure(root_dir) $stdout.puts "create [File]: #{root_dir}/templates/procedure.textile" File.open("#{root_dir}/templates/procedure.textile", "w") do |file| file.puts <<EOS --- author: {{author}} class: procedure --- h1(topic-title). {{title}} p(preparation). Before you begin h2. Procedure # Step 1 p(result). Result of procedure EOS end end |
.mkdirs(root_dir, dirs) ⇒ Object
130 131 132 133 134 135 136 137 138 139 140 141 142 |
# File 'lib/atom/scaffold.rb', line 130 def self.mkdirs(root_dir, dirs) if File.exist? root_dir raise "'#{root_dir}' already exists" return false end FileUtils.mkdir root_dir dirs.each do |dir| $stdout.puts "create [Dir]: #{File.join(root_dir, dir)}" FileUtils.mkdir "#{File.join(root_dir, dir)}" end end |