diff --git a/Gemfile b/Gemfile index 6d0b329..0a7ae4b 100644 --- a/Gemfile +++ b/Gemfile @@ -14,3 +14,7 @@ gem 'redclothcoderay' gem 'coderay' gem 'RedCloth' gem 'redcarpet' + +group :install do + gem 'highline' +end diff --git a/Gemfile.lock b/Gemfile.lock index 295474c..9225904 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -58,6 +58,7 @@ GEM fastercsv (1.5.4) fssm (0.2.7) haml (3.1.2) + highline (1.6.2) json (1.4.6) rack (1.3.2) rack-flash (0.1.2) @@ -86,6 +87,7 @@ DEPENDENCIES data_mapper dm-postgres-adapter haml + highline rack-flash redcarpet redclothcoderay diff --git a/Rakefile b/Rakefile index 3cf92b7..2ced099 100644 --- a/Rakefile +++ b/Rakefile @@ -1,22 +1,28 @@ $LOAD_PATH << File.expand_path(File.dirname(__FILE__)) + '/' -require 'libs' -require 'rake/functions' -require 'dm-migrations' +def require_files + require 'libs' + require 'rake/functions' +end namespace :dm do desc 'migrate to the database model' task :migrate do + require_files + require 'dm-migrations' DataMapper.auto_migrate! end desc 'upgrade the database to the latest model' task :upgrade do + require_files + require 'dm-migrations' DataMapper.auto_upgrade! end desc 'fill the database with dummy data from seeds.rb' task :seed do + require_files require 'seeds' end end @@ -26,9 +32,30 @@ task :console do sh "irb -rubygems -I#{File.expand_path(File.dirname(__FILE__))} -r libs" end +namespace :account do + desc 'create a new account' + task :create do + require_files + require 'highline' + h = HighLine.new + acc = Account.new + acc.username = h.ask('username: ') + acc.password = h.ask('password: '){|q| q.echo = false } + acc.password_confirmation = h.ask('password again: '){|q| q.echo = false } + acc.email = h.ask('email: ') + acc.role = :admin + if acc.save + puts "account saved with id #{acc.id}" + else + puts "failure at saving the account: #{acc.errors.first}" + end + end +end + namespace :import do desc 'import all posts from this directory' task :jekyll do + require_files path = ask("Where are the jekyll posts?") template = ask("What is the default template? (textile, markdown, ...?)") if path.nil?