Sha256: 390e829d30283dbdaf5fba702eda17b2b87bc3f5b1eb428728af662d7b9a788d

Contents?: true

Size: 1.33 KB

Versions: 3

Compression:

Stored size: 1.33 KB

Contents

require "sequel"
require 'io/console'
require 'bcrypt'

require "bundler/gem_tasks"
require 'rspec/core/rake_task'

require_relative "lib/easycomments/ec_configuration.rb"

RSpec::Core::RakeTask.new
task :default => :spec

include Configuration

DB = Sequel.connect(CONNECTION) 

desc "Initializes EasyComments database"
task :init do
  DB.create_table :comments do
    primary_key :id
    String :name
    String :email
    String :post
    String :body
    TrueClass :approved, :default=>APPROVE_BY_DEFAULT
    TrueClass :action_taken, :default=>false
    DateTime :timestamp
  end
  puts "EasyComments database initialized."
end

desc "Updates EasyComments database."
task :update do
  DB.alter_table(:comments) do
    set_column_default :approved, APPROVE_BY_DEFAULT
  end
  puts "EasyComments database updated."
end

desc "Create a new user."
task :adduser do
  print "Username: "
  username = STDIN.gets.chomp
  print "Password for #{username}: "
  password = STDIN.noecho(&:gets).chomp
  bcrypt_password = BCrypt::Password.create(password)
  conf = CONFIG
  if conf[:users].nil?
    conf.merge!({:users => {username => bcrypt_password}})
  else
    conf[:users].merge!({username => bcrypt_password})
  end
  File.open("_config.yml", 'w') { |f| YAML.dump(conf, f) }
  File.open("_config.yml", 'a') { |f| f.write(comment_wall) }
  puts "\nNew user added."
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
easycomments-1.0.5 Rakefile
easycomments-1.0.4 Rakefile
easycomments-1.0.3 Rakefile