Class: Anticuado::Elixir::Hex
Class Method Summary collapse
-
.format(outdated) ⇒ Array
Array include outdated data.
-
.outdated(project = nil) ⇒ String
The result of command ‘mix hex.outdated`.
Class Method Details
.format(outdated) ⇒ Array
Returns Array include outdated data. If target project have no outdated data, then return blank array such as ‘[]`.
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 |
# File 'lib/anticuado/elixir/hex.rb', line 25 def self.format(outdated) array = outdated.split(/\R/).map(&:strip) index = array.find_index { |line| line.scan(/\ADependency\s+Current\s+/) != [] } return [] if index.nil? array[index + 1..array.size].reduce([]) do |acc, library| break acc if library.empty? array_lib = library.split(/\s+/) current_version = array_lib[1] last_version = array_lib[2] if current_version != last_version acc.push({ library_name: array_lib[0], current_version: current_version, available_version: last_version, latest_version: last_version }) end acc end end |
.outdated(project = nil) ⇒ String
Returns The result of command ‘mix hex.outdated`.
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/anticuado/elixir/hex.rb', line 6 def self.outdated(project = nil) return puts "have no mix command" if `which mix`.empty? `mix local.hex --force` if project current_dir = Anticuado.current_dir Dir.chdir Anticuado.project_dir(project) outdated_str = `mix hex.outdated` Dir.chdir current_dir else outdated_str = `mix hex.outdated` end outdated_str end |