Module: Magellan::Cli::GemUpdate
- Defined in:
- lib/magellan/cli/gem_update.rb
Constant Summary collapse
- LAST_UPDATE_SEARCHED_AT =
"last_update_searched_at".freeze
- UPDATE_SEARCH_INTERVAL =
1 day
1 * 24 * 60 * 60
Class Method Summary collapse
Class Method Details
.search ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/magellan/cli/gem_update.rb', line 16 def search t = FileAccess.load_selections[LAST_UPDATE_SEARCHED_AT] return nil if t && (Time.now < Time.parse(t) + UPDATE_SEARCH_INTERVAL) name = "magellan-cli" version = `gem search -r #{name} -q --no-details --versions`.scan(/\((.*)\)/).flatten.first FileAccess.update_selections({LAST_UPDATE_SEARCHED_AT => Time.now.to_s}) if version curr = Gem::Version.new(Magellan::Cli::VERSION) last = Gem::Version.new(version) if last > curr yield(name, version) if block_given? return version else # puts "#{curr} is newer than equal #{last}" end else # puts "no gem version found for #{name}" end return nil end |