Class: BaseChip::TopMenu

Inherits:
Menu
  • Object
show all
Includes:
Cli
Defined in:
lib/base_chip/top_menu.rb

Instance Method Summary collapse

Methods included from Cli

included

Methods inherited from Menu

#list_line, #smart_print

Methods included from Reporting

included

Instance Method Details

#clean(*args) ⇒ Object



139
140
141
142
143
144
145
# File 'lib/base_chip/top_menu.rb', line 139

def clean(*args)
  args << 'all' if args.empty?
  ready_workload(*args)
  @project.workload.each do |w|
    w.clean
  end
end

#clobber(*args) ⇒ Object



149
150
151
152
153
154
155
# File 'lib/base_chip/top_menu.rb', line 149

def clobber(*args)
  args << 'all' if args.empty?
  ready_workload(*args)
  @project.workload.each do |w|
    w.clobber
  end
end

#exec(*args) ⇒ Object



81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
# File 'lib/base_chip/top_menu.rb', line 81

def exec(*args)
  begin
    fault "Repeat is a planned feature" if BaseChip.options.repeat

    args << 'all' if options.client_of && args.size == 0
    ready_workload(*args)

    @project.enable_tracking(options.opc,options.opi) if options.opc
    @project.tasker.clusters = @project.dereference_clusters
    @project.tasker.client_of = options.client_of
    @project.tasker.client_id = options.client_id || 0

    if options.client_of
      @project.tasker.run
    else
      if @targets.size > 0
        begin
          @project.run_all_readied
          # @project.track_complete 'pass'
        rescue Reporting::Fault => e
          # @project.track_complete 'fail', e.message
          exit 1
        rescue RuntimeError => e
          # @project.track_complete 'fail', e.message
          p e
          raise e
        end
      end
    end
  rescue Interrupt # quetly handle the interrupt of clients
    raise unless options.client_of 
  end
end

#init(project_name, shared_directory) ⇒ Object



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/base_chip/top_menu.rb', line 33

def init(project_name, shared_directory)
  $shared_directory = shared_directory
  BaseChip.project  = project_name
  BaseChip.root     = "./#{project_name}"
  FileUtils.mkdir_p BaseChip.root
  BaseChip.build_directory_structure(BaseChip.root, BaseChip.project_directories)
  BaseChip.erb_template "#{BaseChip::GEM_DIR}/collateral/project/settings.rb.erb", "#{BaseChip.root}/base_chip/settings.rb"
  BaseChip.erb_template "#{BaseChip::GEM_DIR}/collateral/project/project.rb.erb" , "#{BaseChip.root}/base_chip/project.rb"
  FileUtils.cp          "#{BaseChip::GEM_DIR}/collateral/project/gitignore"      , "#{BaseChip.root}/.gitignore"
  FileUtils.cd          BaseChip.root

  if options.git
    system "git init ."
    system "git add ./base_chip ./.gitignore"
    system "git commit -m 'Initial automated project build by BaseChip.' ."

    normal "Your project has been created.\n" +
           "Your next step is probably to generate a block.\n" +
           "You can learn more by entering your newly created directory, and typing:\n" +
           "  basechip help generate block"
  end
end

#ready_workload(*args) ⇒ Object



21
22
23
24
25
26
# File 'lib/base_chip/top_menu.rb', line 21

def ready_workload(*args)
  @targets = args
  BaseChip.load_environment
  @project = BaseChip.project
  @project.ready(@targets) if @targets.size > 0
end

#rerun(bundle_path) ⇒ Object



116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
# File 'lib/base_chip/top_menu.rb', line 116

def rerun(bundle_path)
  fault "#{bundle_path} does not exist" unless File.exist?(bundle_path)
  case bundle_path
  when /(.*)\.tgz$/ 
    puts "Unzipping #{bundle_path}"
    system "tar -zxvf #{bundle_path}"
    bundle_path = $1
  end
  fault "#{bundle_path}/rerun.yaml does not exist" unless File.exist?("#{bundle_path}/rerun.yaml")
  rerun_hash = YAML.load(File.read("#{bundle_path}/rerun.yaml"))
  BaseChip.options.seed            ||= rerun_hash['seed' ]
  BaseChip.options.modes           ||= rerun_hash['modes']
  BaseChip.options. append_arguments = (BaseChip.options. append_arguments || []) + (rerun_hash[' append_arguments'] || [])
  BaseChip.options.replace_arguments = (BaseChip.options.replace_arguments || []) + (rerun_hash['replace_arguments'] || [])
  BaseChip.options. append_arguments = nil if BaseChip.options. append_arguments.empty?
  BaseChip.options.replace_arguments = nil if BaseChip.options.replace_arguments.empty?
  ready_workload(rerun_hash['full_name'])
  @project.workload.first.directory "#{@project.workload.first.directory}.rerun"
  @project.run_all_readied
end