Class: Bio::Gem::Generator::Application

Inherits:
Object
  • Object
show all
Extended by:
Shellwords
Defined in:
lib/bio-gem/application.rb

Class Method Summary collapse

Class Method Details

.build_options(arguments) ⇒ Object

run!



56
57
58
59
60
61
62
# File 'lib/bio-gem/application.rb', line 56

def build_options(arguments)
  env_opts_string = ENV['JEWELER_OPTS'] || ""
  env_opts        = Jeweler::Generator::Options.new(shellwords(env_opts_string))
  argument_opts   = Jeweler::Generator::Options.new(arguments)

  env_opts.merge(argument_opts)
end

.run!(*arguments) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/bio-gem/application.rb', line 8

def run!(*arguments)

options = build_options(arguments)

if options[:invalid_argument]
  $stderr.puts options[:invalid_argument]
  options[:show_help] = true
end

if options[:show_version]
  $stderr.puts "Version: #{Jeweler::Version::STRING}"
  return 1
end

if options[:show_help]
  $stderr.puts options.opts
  return 1
end

if options[:project_name].nil? || options[:project_name].squeeze.strip == ""
  $stderr.puts options.opts
  return 1
end

begin
  if options[:directory]!='.'
    FileUtils.mkdir_p options[:directory]
  end
  FileUtils.cd options[:directory] do 
    generator = Jeweler::Generator.new(options)
    generator.run
    return 0
  end
rescue Jeweler::NoGitUserName
  $stderr.puts %Q{No user.name found in ~/.gitconfig. Please tell git about yourself (see http://help.github.com/git-email-settings/ for details). For example: git config --global user.name "mad voo"}
  return 1
rescue Jeweler::NoGitUserEmail
  $stderr.puts %Q{No user.email found in ~/.gitconfig. Please tell git about yourself (see http://help.github.com/git-email-settings/ for details). For example: git config --global user.email [email protected]}
  return 1
rescue Jeweler::NoGitHubUser
  $stderr.puts %Q{Please specify --github-username or set github.user in ~/.gitconfig (see http://github.com/blog/180-local-github-config for details). For example: git config --global github.user defunkt}
  return 1
rescue Jeweler::FileInTheWay
  $stderr.puts "The directory #{options[:project_name]} already exists. Maybe move it out of the way before continuing?"
  return 1
end
end