class Jive::Issue
Attributes
name[R]
repo[R]
type[R]
Public Class Methods
create!(name:, type:, repo: Repo.current)
click to toggle source
# File lib/jive/issue.rb, line 15 def create!(name:, type:, repo: Repo.current) new(repo: repo, name: name, type: type) end
dir_for(type, repo: Repo.current)
click to toggle source
# File lib/jive/issue.rb, line 26 def dir_for(type, repo: Repo.current) Jive.home .join(repo.uri.host) .join(repo.nwo) .join(type) end
for(type, repo: Repo.current)
click to toggle source
# File lib/jive/issue.rb, line 19 def for(type, repo: Repo.current) dir_for(type, repo: repo).glob("*.md").map do |x| name = x.basename.to_s.gsub(".md", "") new(repo: repo, name: name, type: type) end end
new(name:, type:, repo: Repo.current)
click to toggle source
# File lib/jive/issue.rb, line 34 def initialize(name:, type:, repo: Repo.current) @repo = repo @type = type @name = name end
what_type?()
click to toggle source
# File lib/jive/issue.rb, line 6 def what_type? Jive.prompt?( Jive.root .join("lib/jive/templates") .glob("*.md") .map { |x| x.basename.to_s.gsub(".md", "") } ) end
Public Instance Methods
edit(editor: ENV["EDITOR"])
click to toggle source
# File lib/jive/issue.rb, line 44 def edit(editor: ENV["EDITOR"]) Jive.shell.execute([editor, issue.to_s]) end
file_name()
click to toggle source
# File lib/jive/issue.rb, line 40 def file_name "#{name.gsub(/[^a-z0-9\-_]+/i, "-").downcase}.md" end
Private Instance Methods
issue()
click to toggle source
# File lib/jive/issue.rb, line 52 def issue @issue ||= begin dir = self.class.dir_for(type, repo: repo) Jive.shell.execute([:mkdir, "-p", dir]) dir.join(file_name).tap do |file| file.write(template_for(type).read) unless file.exist? end end end
template_for(type)
click to toggle source
# File lib/jive/issue.rb, line 63 def template_for(type) Jive.root.join("lib/jive/templates/#{type}.md") end