Sha256: 434aa5a2022d28c24ab94cb99395385b0b7fb152f70259c31341fd517ecbd051

Contents?: true

Size: 1.41 KB

Versions: 11

Compression:

Stored size: 1.41 KB

Contents

def scrolls; @scrolls end
def scroll?(name); @scrolls.include?(name) end

def say_custom(tag, text); say "\033[1m\033[36m" + tag.to_s.rjust(10) + "\033[0m" + "  #{text}" end
def say_scroll(name); say "\033[1m\033[36m" + "scroll".rjust(10) + "\033[0m" + "  Running #{name} scroll..." end
def say_wizard(text); say_custom(@current_scroll || 'wizard', text) end

def ask_wizard(question)
  ask "\033[1m\033[30m\033[46m" + (@current_scroll || "prompt").rjust(10) + "\033[0m\033[36m" + "  #{question}\033[0m"
end

def yes_wizard?(question)
  answer = ask_wizard(question + " \033[33m(y/n)\033[0m")
  case answer.downcase
    when "yes", "y"
      true
    when "no", "n"
      false
    else
      yes_wizard?(question)
  end
end

def no_wizard?(question); !yes_wizard?(question) end

def multiple_choice(question, choices)
  say_custom('question', question)
  values = {}
  choices.each_with_index do |choice,i| 
    values[(i + 1).to_s] = choice[1]
    say_custom (i + 1).to_s + ')', choice[0]
  end
  answer = ask_wizard("Enter your selection:") while !values.keys.include?(answer)
  values[answer]
end

@current_scroll = nil
@configs = {}

@after_blocks = []
def after_bundler(&block); @after_blocks << [@current_scroll, block]; end
@after_everything_blocks = []
def after_everything(&block); @after_everything_blocks << [@current_scroll, block]; end
@before_configs = {}
def before_config(&block); @before_configs[@current_scroll] = block; end

Version data entries

11 entries across 11 versions & 3 rubygems

Version Path
appscrolls-0.8.4 templates/helpers.erb
appscrolls-0.8.3 templates/helpers.erb
appscrolls-0.8.2 templates/helpers.erb
appscrolls-0.8.1 templates/helpers.erb
appscrolls-0.8.0 templates/helpers.erb
appscrolls-0.7.1 templates/helpers.erb
appscrolls-0.7.0 templates/helpers.erb
eldarscrolls-0.7.0 templates/helpers.erb
ey_rails_wizard-0.6.0 templates/helpers.erb
ey_rails_wizard-0.5.0 templates/helpers.erb
ey_rails_wizard-0.4.0 templates/helpers.erb