Class: ErpDevSvcs::Commands::BuildGems

Inherits:
Object
  • Object
show all
Defined in:
lib/erp_dev_svcs/commands/build_gems.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeBuildGems

Returns a new instance of BuildGems.



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
# File 'lib/erp_dev_svcs/commands/build_gems.rb', line 12

def initialize
  options = {:install => false,
    :gems => nil}

  opt_parser = OptionParser.new do |opt|
    opt.banner = "Usage: compass_ae-dev build_gems [OPTIONS]"

    opt.on("-g", "--gems [GEMLIST]", Array,
      "List of gems to build; defaults to all") {|gem| options[:gems] = gem}

    opt.on("-i", "--install",nil,
      "Install the gem locally after it's built") do |x|
      options[:install] = true
    end

    opt.on("-n", "--no-docs",nil,
      "Use --no-ri --no-rdoc") do |x|
      options[:no_docs] = true
    end
    
    opt.on_tail("-h", "--help", "Show this message") do
      puts opt
      exit
    end
  end

  opt_parser.parse!

  ErpDevSvcs::Commands::Helper.exec_in_engines(options[:gems]) do |engine_name|
    old_gem_files = Dir.glob("*.gem")
    old_gem_files.each {|x| File.delete(x); puts "\nDeleting old gem: #{x}"}

    puts "Starting build of #{engine_name}"
    build_result = %x[gem build #{engine_name}.gemspec]
    puts build_result

    if options[:install]
      gem_file = Dir.glob("*.gem")
      puts "Installing #{gem_file[0]}..."
      install_result = if options[:no_docs]
        %x[gem install #{gem_file[0]} --no-ri --no-rdoc]
      else
        %x[gem install #{gem_file[0]}]
      end
      puts install_result
    end
    puts "\n"
  end
end

Class Method Details

.executeObject



8
9
10
# File 'lib/erp_dev_svcs/commands/build_gems.rb', line 8

def self.execute
  new()
end