Class: Jeweler::Generator::Options

Inherits:
Hash
  • Object
show all
Defined in:
lib/jeweler/generator/options.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args) ⇒ Options

Returns a new instance of Options.



6
7
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# File 'lib/jeweler/generator/options.rb', line 6

def initialize(args)
  super()

  @orig_args = args.clone
  self[:testing_framework] = :shoulda

  @opts = OptionParser.new do |o|
    o.banner = "Usage: #{File.basename($0)} [options] reponame\ne.g. #{File.basename($0)} the-perfect-gem"

    o.on('--bacon', 'generate bacon specifications') do
      self[:testing_framework] = :bacon
    end

    o.on('--shoulda', 'generate shoulda tests') do
      self[:testing_framework] = :shoulda
    end

    o.on('--testunit', 'generate test/unit tests') do
      self[:testing_framework] = :testunit
    end

    o.on('--minitest', 'generate minitest tests') do
      self[:testing_framework] = :minitest
    end

    o.on('--rspec', 'generate rspec code examples') do
      self[:testing_framework] = :rspec
    end

    o.on('--micronaut', 'generate micronaut examples') do
      self[:testing_framework] = :micronaut
    end

    o.on('--cucumber', 'generate cucumber stories in addition to the other tests') do
      self[:use_cucumber] = true
    end

    o.on('--create-repo', 'create the repository on GitHub') do
      self[:create_repo] = true
    end

    o.on('--rubyforge', 'setup project for rubyforge') do
      self[:rubyforge] = true
    end

    o.on('--summary [SUMMARY]', 'specify the summary of the project') do |summary|
      self[:summary] = summary
    end

    o.on('--directory [DIRECTORY]', 'specify the directory to generate into') do |directory|
      self[:directory] = directory
    end

    o.on_tail('-h', '--help', 'display this help and exit') do
      self[:show_help] = true
    end
  end

  begin
    @opts.parse!(args)
  rescue OptionParser::InvalidOption => e
    self[:invalid_argument] = e.message
  end
end

Instance Attribute Details

#optsObject (readonly)

Returns the value of attribute opts.



4
5
6
# File 'lib/jeweler/generator/options.rb', line 4

def opts
  @opts
end

#orig_argsObject (readonly)

Returns the value of attribute orig_args.



4
5
6
# File 'lib/jeweler/generator/options.rb', line 4

def orig_args
  @orig_args
end

Instance Method Details

#merge(other) ⇒ Object



71
72
73
# File 'lib/jeweler/generator/options.rb', line 71

def merge(other)
  self.class.new(@orig_args + other.orig_args)
end