class Octokitchen::Generator

Public Class Methods

banner() click to toggle source

Private Class Methods

source_root() click to toggle source
# File lib/octokitchen/generator.rb, line 50
def self.source_root
  File.dirname(__FILE__)
end

Public Instance Methods

new_gemfile() click to toggle source
# File lib/octokitchen/generator.rb, line 38
def new_gemfile
  if options[:gemfile]
    template('templates/new_gemfile.tt', "#{@directory}/Gemfile")
  end
end
new_readme() click to toggle source
# File lib/octokitchen/generator.rb, line 34
def new_readme
  template('templates/new_readme.tt', "#{@directory}/README.md")
end
new_script() click to toggle source
# File lib/octokitchen/generator.rb, line 30
def new_script
  template('templates/new_script.tt', "#{@directory}/#{@filename}")
end
setup() click to toggle source
# File lib/octokitchen/generator.rb, line 19
def setup
  unless name[/\w+/]
    Generator.help(shell)
    exit
  end
  @directory = directory
  @filename = [(options[:command] || underscore(name)), 'rb'].join('.')
  @dependencies = options[:dependencies].to_s.split(',').unshift('octokit')
  @git_info = git_info
end

Private Instance Methods

directory() click to toggle source
# File lib/octokitchen/generator.rb, line 46
def directory
  path[/\w+/] ? path : underscore(name)
end
git_info() click to toggle source
# File lib/octokitchen/generator.rb, line 58
def git_info
  if use_git?
    {
      git_path: git_path,
      git_origin_url: git_origin_url
    }
  end
end
git_origin_url() click to toggle source
# File lib/octokitchen/generator.rb, line 75
def git_origin_url
  `git config --get remote.origin.url`.strip
end
git_path() click to toggle source
# File lib/octokitchen/generator.rb, line 71
def git_path
  `git rev-parse --show-prefix`.strip
end
underscore(str) click to toggle source
# File lib/octokitchen/generator.rb, line 54
def underscore(str)
  str.gsub(/\W/, '_').downcase
end
use_git?() click to toggle source
# File lib/octokitchen/generator.rb, line 67
def use_git?
  system('which git && git rev-parse')
end