Class: Autoproj::CLI::Update::AskUpdateFilter

Inherits:
Object
  • Object
show all
Defined in:
lib/autoproj/cli/update.rb

Instance Method Summary collapse

Constructor Details

#initialize(prompt, parallel: 1, only_local: false) ⇒ AskUpdateFilter

Returns a new instance of AskUpdateFilter.



201
202
203
204
205
206
207
208
209
# File 'lib/autoproj/cli/update.rb', line 201

def initialize(prompt, parallel: 1, only_local: false)
    @prompt = prompt
    @only_local = only_local
    @executor = Concurrent::FixedThreadPool.new(parallel, max_length: 0)

    @parallel = parallel
    @futures = {}
    @lookahead_queue = []
end

Instance Method Details

#call(pkg) ⇒ Object



211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
# File 'lib/autoproj/cli/update.rb', line 211

def call(pkg)
    unless (status = @futures.delete(pkg).value)
        raise v.reason
    end

    clean = !status.unexpected &&
            (status.sync || (status.local && !status.remote))
    if clean
        msg = Autobuild.color("already up-to-date", :green)
        pkg.autobuild.message "#{msg} %s"
        return false
    end

    Autobuild.progress_display_synchronize do
        status.msg.each { |m| puts m }
        @prompt.yes?("Update #{pkg.name} ?")
    end
end

#lookahead(pkg) ⇒ Object



230
231
232
233
234
235
236
# File 'lib/autoproj/cli/update.rb', line 230

def lookahead(pkg)
    @futures[pkg] = Concurrent::Promises.future_on(@executor) do
        Status.status_of_package(
            pkg, snapshot: false, only_local: @only_local
        )
    end
end