Class: SmallCage::Commands::Update
- Inherits:
-
Object
- Object
- SmallCage::Commands::Update
- Includes:
- SmallCage
- Defined in:
- lib/smallcage/commands/update.rb
Overview
‘smc update’ command
Constant Summary
Constants included from SmallCage
Class Method Summary collapse
Instance Method Summary collapse
- #execute ⇒ Object
-
#initialize(opts) ⇒ Update
constructor
A new instance of Update.
Constructor Details
#initialize(opts) ⇒ Update
Returns a new instance of Update.
12 13 14 |
# File 'lib/smallcage/commands/update.rb', line 12 def initialize(opts) @opts = opts end |
Class Method Details
.execute(opts) ⇒ Object
8 9 10 |
# File 'lib/smallcage/commands/update.rb', line 8 def self.execute(opts) new(opts).execute end |
Instance Method Details
#execute ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/smallcage/commands/update.rb', line 16 def execute start = Time.now target = Pathname.new(@opts[:path]) fail 'target directory or file does not exist.: ' + target.to_s unless target.exist? @loader = Loader.new(target) @renderer = Renderer.new(@loader) @list = UpdateList.create(@loader.root, target) STDERR.puts 'WARN: Can\'t load tmp/list.yml file.' if @list.load_error render_smc_files expire_old_files @list.expire @list.save count = @list.update_count elapsed = Time.now - start puts "-- #{count} files. #{sprintf('%.3f', elapsed)} sec." + " #{sprintf('%.3f', count == 0 ? 0 : elapsed / count)} sec/file." unless @opts[:quiet] end |