Sha256: 6dc972fcbce1285106fa29a6012e5773825a8dfa6eb8cc9aac19541cbc655341

Contents?: true

Size: 1.44 KB

Versions: 70

Compression:

Stored size: 1.44 KB

Contents

class Brief::Briefcase
  class Initializer
    def initialize(options={})
      @options = options.to_mash
    end

    def run
      options = @options
      root    = options.root

      FileUtils.mkdir_p(root.join("docs","posts"))

      config = "use(#{options.app})\n" if options.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
  end
end

Version data entries

70 entries across 70 versions & 1 rubygems

Version Path
brief-1.17.14 lib/brief/briefcase/initializer.rb
brief-1.17.13 lib/brief/briefcase/initializer.rb
brief-1.17.12 lib/brief/briefcase/initializer.rb
brief-1.17.11 lib/brief/briefcase/initializer.rb
brief-1.17.10 lib/brief/briefcase/initializer.rb
brief-1.17.9 lib/brief/briefcase/initializer.rb
brief-1.17.8 lib/brief/briefcase/initializer.rb
brief-1.17.7 lib/brief/briefcase/initializer.rb
brief-1.17.5 lib/brief/briefcase/initializer.rb
brief-1.17.4 lib/brief/briefcase/initializer.rb
brief-1.17.3 lib/brief/briefcase/initializer.rb
brief-1.17.2 lib/brief/briefcase/initializer.rb
brief-1.17.1 lib/brief/briefcase/initializer.rb
brief-1.17.0 lib/brief/briefcase/initializer.rb
brief-1.16.2 lib/brief/briefcase/initializer.rb
brief-1.16.1 lib/brief/briefcase/initializer.rb
brief-1.16.0 lib/brief/briefcase/initializer.rb
brief-1.15.5 lib/brief/briefcase/initializer.rb
brief-1.15.4 lib/brief/briefcase/initializer.rb
brief-1.15.3 lib/brief/briefcase/initializer.rb