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(={}) @options = .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 = @options root = .root FileUtils.mkdir_p(root.join("docs","posts")) config = "use(#{.app})\n" if .app config = <<-EOF root = Pathname(Dir.pwd) config do # You can put any special brief configuration here # set(models_path: root.join('models')) if root.join('models').exist? # set(templates_path: root.join('templates')) if root.join('templates').exist? # set(docs_path: root.join('documents')) if root.join('documents').exist? end \n define "Post" do meta do title status :in => %w(draft published) tags Array end \n content do title "h1:first-of-type" subheading "h2:first-of-type" end end EOF example = <<-EOF --- type: post title: This is my first post status: published tags: - default - intro --- # This is my first post I should write something clever. EOF config.gsub!(/^\ {1,6}/m, '') example.gsub!(/^\ {1,6}/m, '') root.join("docs","posts","this-is-my-first-post.md").open("w+") {|fh| fh.write(example) } root.join("brief.rb").open("w+") do |fh| fh.write(config) end end |