Class: Brief::Briefcase::Initializer
- Inherits:
-
Object
- Object
- Brief::Briefcase::Initializer
- Defined in:
- lib/brief/briefcase/initializer.rb
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Initializer
constructor
A new instance of Initializer.
- #run ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Initializer
Returns a new instance of Initializer.
3 4 5 |
# File 'lib/brief/briefcase/initializer.rb', line 3 def initialize(={}) = .to_mash end |
Instance Method Details
#run ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/brief/briefcase/initializer.rb', line 7 def run = root = .root FileUtils.mkdir_p(root.join("docs","posts")) config = "use(#{options.app})\n" if .app config = " root = Pathname(Dir.pwd)\n\n config do\n # You can put any special brief configuration here\n # set(models_path: root.join('models')) if root.join('models').exist?\n # set(templates_path: root.join('templates')) if root.join('templates').exist?\n # set(docs_path: root.join('documents')) if root.join('documents').exist?\n end\n \\n\n define \"Post\" do\n meta do\n title\n status :in => %w(draft published)\n tags Array\n end\n \\n\n content do\n title \"h1:first-of-type\"\n subheading \"h2:first-of-type\"\n end\n end\n EOF\n\n example = <<-EOF\n ---\n type: post\n title: This is my first post\n status: published\n tags:\n - default\n - intro\n ---\n\n # This is my first post\n\n I should write something clever.\n EOF\n\n config.gsub!(/^\\ {1,6}/m, '')\n example.gsub!(/^\\ {1,6}/m, '')\n\n root.join(\"docs\",\"posts\",\"this-is-my-first-post.md\").open(\"w+\") {|fh| fh.write(example) }\n\n root.join(\"brief.rb\").open(\"w+\") do |fh|\n fh.write(config)\n end\nend\n" |