module Ecic::LibraryCreationHelper
Public Instance Methods
create_library_if_missing(library)
click to toggle source
# File lib/ecic/helpers/library_creation_helper.rb, line 3 def create_library_if_missing(library) unless library.already_exists? return ok_to_create_library? library end return true end
generate_library(library)
click to toggle source
# File lib/ecic/helpers/library_creation_helper.rb, line 19 def generate_library(library) if library.is_valid? generator = Ecic::LibraryGenerator.new generator.destination_root = library.project.root generator.library = library generator.invoke_all library.create else return false end end
ok_to_create_library?(library)
click to toggle source
# File lib/ecic/helpers/library_creation_helper.rb, line 10 def ok_to_create_library?(library) if must_create_new_library? library return generate_library library end # shell.error set_color("Operation aborted!",Thor::Shell::Color::RED) # exit(2) return false end
Protected Instance Methods
library_creation_help()
click to toggle source
# File lib/ecic/helpers/library_creation_helper.rb, line 60 def library_creation_help puts " Y - yes, create the library (default)" puts " n - no, continue without creating the library" puts " a - all, create this library (and any other)" puts " q - quit, abort" puts " h - help, show this help" end
must_create_new_library?(library)
click to toggle source
# File lib/ecic/helpers/library_creation_helper.rb, line 33 def must_create_new_library?(library) return true if @always_create_library options = "[Ynaqh]" loop do answer = ask( %[#{library.type.to_s.capitalize} library '#{library.name}' does not exist. Create it? (enter "h" for help) #{options}], :add_to_history => false ) case answer when nil say "" return true when is?(:yes), "" return true when is?(:no), is?(:skip) return false when is?(:all) return @always_create_library = true when is?(:quit) say "Aborting..." raise SystemExit else say library_creation_help end end end