Sha256: a52cd806c313c7f5722740715365e2c86fdb54224e5feeba1d04d6e8f12df59a

Contents?: true

Size: 668 Bytes

Versions: 4

Compression:

Stored size: 668 Bytes

Contents

require "date"
require "writer/configuration"
require "writer/version"
require "writer/file_creator"

module Writer
  class << self
    def write!(name = nil, content = nil)
      name ||= default_filename
      FileCreator.create!(name, content)
    end

    def configure
      yield(config)
    end

    # attempt delegation to config
    def method_missing(name, *args)
      return config.send(name, *args)
      rescue
        super
    end

    private
    def default_filename
      date = Date.today
      date.strftime('%Y-%m%b-%d.md')
    end

    def config
      @config ||= Configuration.new
    end
  end
end

def wr(*args)
  `wr #{args.join(' ')}`
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
writer-0.3.0 lib/writer.rb
writer-0.2.0 lib/writer.rb
writer-0.1.1 lib/writer.rb
writer-0.1.0 lib/writer.rb