class Minireq::Cli::Cli
Public Class Methods
source_root()
click to toggle source
# File lib/minireq/cli/cli.rb, line 16 def self.source_root Minireq.root end
Public Instance Methods
__print_version()
click to toggle source
# File lib/minireq/cli/cli.rb, line 23 def __print_version puts "Minireq #{Minireq::VERSION}" end
check()
click to toggle source
# File lib/minireq/cli/cli.rb, line 81 def check doc = Minireq::Core::Document.new file_repo = inreq { read_requirement_files } errors = doc.check_errors(file_repo) unless errors.empty? errmsg = "" if errors[:nonuniq_ids] errmsg << "Non-unique requirement ids:\n" errmsg << errors[:nonuniq_ids].join("\n") errmsg << "\n" end if errors[:wrong_links] errmsg << "Wrong requirements links:\n" errmsg << errors[:wrong_links].join("\n") errmsg << "\n" end puts errmsg return end puts "Everything is fine!" end
doc(id = nil)
click to toggle source
# File lib/minireq/cli/cli.rb, line 105 def doc(id = nil) if id if write_req(id) puts "'#{DOC}/#{id}.md' created." else # TODO show all possible requirement ids from repo puts "Requirement '#{id}' not found in repository!" return end else file_name = options[:output] file_name ||= 'requirements.md' write_doc(file_name) puts "'#{DOC}/#{file_name}' created." end end
init()
click to toggle source
# File lib/minireq/cli/cli.rb, line 51 def init create_project #TODO refactor it to init_project puts "Minireq project struture created successfully!" end
new(target)
click to toggle source
# File lib/minireq/cli/cli.rb, line 28 def new(target) Dir.mkdir(target) Dir.chdir(target) do create_project config = {} config.merge!({constant_name: target}) template("lib/minireq/templates/README.md.tt", "#{target}/README.md", config) copy_file("lib/minireq/templates/creq.thor", "#{target}/creq.thor") say "Initializing git repo in #{target}" `git init` `git add .` end end
promo()
click to toggle source
# File lib/minireq/cli/cli.rb, line 45 def promo promo_dir = File.join Minireq.root, 'lib/minireq/promo' directory promo_dir, Dir.pwd end
req(id, title = '')
click to toggle source
# File lib/minireq/cli/cli.rb, line 62 def req(id, title = '') errmsg = "File #{REQ}/#{id}.md already exists. Operation aborted." if File.exist?("#{REQ}/#{id}.md") puts errmsg return end params = {} params.merge!(title: title) unless title.empty? params.merge!(options[:attributes]) if options[:attributes] params.merge!({body: File.read(options[:template])}) if options[:template] # replace @@id params[:body].gsub!('@@id', id) if params[:body] params[:body].gsub!('@@title', title) if params[:body] && !title.empty? create_requirement_source(id, params) puts "#{REQ}/#{id}.md created." end