Sha256: f50d32eb45a68f599f12e14104a3860fbae13bbc17f2a23b057361d59b67cb98

Contents?: true

Size: 890 Bytes

Versions: 4

Compression:

Stored size: 890 Bytes

Contents

require 'baron'

@config = Baron::Config::Defaults

task :default => :new

desc "Create a new article."
task :new do
  title = ask('Title: ')
  slug = title.empty?? nil : title.strip.slugize

  article = {'title' => title, 'date' => Time.now.strftime("%d/%m/%Y")}.to_yaml
  article << "\n"
  article << "Once upon a time...\n\n"

  path = "#{Baron::Paths[:articles]}/#{Time.now.strftime("%Y-%m-%d")}#{'-' + slug if slug}.#{@config[:ext]}"

  unless File.exist? path
    File.open(path, "w") do |file|
      file.write article
    end
    baron "an article was created for you at #{path}."
  else
    baron "I can't create the article, #{path} already exists."
  end
end

desc "Publish my blog."
task :publish do
  baron "publishing your article(s)..."
  `git push heroku master`
end

def baron msg
  puts "\n  toto ~ #{msg}\n\n"
end

def ask message
  print message
  STDIN.gets.chomp
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
baron-1.0.3 spec/sample_data/Rakefile
baron-1.0.2 spec/sample_data/Rakefile
baron-1.0.1 spec/sample_data/Rakefile
baron-1.0.0 spec/sample_data/Rakefile