Sha256: 48d32015e21736acd9e3fa318a5d03ea5c53aee25cc30deec7f95e7ba13775b2

Contents?: true

Size: 891 Bytes

Versions: 13

Compression:

Stored size: 891 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

13 entries across 13 versions & 1 rubygems

Version Path
baron-1.0.20 spec/sample_data/Rakefile
baron-1.0.18 spec/sample_data/Rakefile
baron-1.0.17 spec/sample_data/Rakefile
baron-1.0.14 spec/sample_data/Rakefile
baron-1.0.13 spec/sample_data/Rakefile
baron-1.0.12 spec/sample_data/Rakefile
baron-1.0.11 spec/sample_data/Rakefile
baron-1.0.9 spec/sample_data/Rakefile
baron-1.0.8 spec/sample_data/Rakefile
baron-1.0.7 spec/sample_data/Rakefile
baron-1.0.6 spec/sample_data/Rakefile
baron-1.0.5 spec/sample_data/Rakefile
baron-1.0.4 spec/sample_data/Rakefile