Class: Jekyll::RpLogs::RpTasks
- Inherits:
-
Object
- Object
- Jekyll::RpLogs::RpTasks
- Includes:
- Rake::DSL
- Defined in:
- lib/jekyll/rp_logs/rp_tasks.rb
Instance Method Summary collapse
-
#ask(message, valid_options) ⇒ Object
Octopress.
- #copy_unless_exist(from, to, message = nil) ⇒ Object
-
#get_stdin(message) ⇒ Object
Octopress.
- #install_tasks ⇒ Object
Instance Method Details
#ask(message, valid_options) ⇒ Object
Octopress
22 23 24 25 26 27 28 29 |
# File 'lib/jekyll/rp_logs/rp_tasks.rb', line 22 def ask(, ) if answer = get_stdin("#{message} #{valid_options.to_s.gsub(/"/, '').gsub(/, /, '/')} ") until .include?(answer) else answer = get_stdin() end answer end |
#copy_unless_exist(from, to, message = nil) ⇒ Object
8 9 10 11 12 13 |
# File 'lib/jekyll/rp_logs/rp_tasks.rb', line 8 def copy_unless_exist(from, to, = nil) unless File.exist?(to) puts if cp from, to end end |
#get_stdin(message) ⇒ Object
Octopress
16 17 18 19 |
# File 'lib/jekyll/rp_logs/rp_tasks.rb', line 16 def get_stdin() print STDIN.gets.chomp end |
#install_tasks ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/jekyll/rp_logs/rp_tasks.rb', line 31 def install_tasks namespace :rp_logs do directory "_rps" desc "Create a new Jekyll site for RP logs, with the default theme" task :new do if File.directory?("_sass") abort("rake aborted!") if ask("A theme is already installed, proceeding will overwrite existing non-custom files. Are you sure?", ['y', 'n']) == 'n' end Rake::Task[:_rps].invoke # allow directory specification gem_root = Gem::Specification.find_by_name("jekyll-rp_logs").gem_dir cp_r Dir["#{gem_root}/.themes/default/source/*"], "./" copy_unless_exist("_config.yml.default", "_config.yml") touch "_sass/_custom-vars.scss" touch "_sass/_custom-rules.scss" end end end |