Skip to content

Commit

Permalink
tab: allow to store versions
Browse files Browse the repository at this point in the history
  • Loading branch information
vladshablinsky authored and xu-cheng committed Aug 6, 2016
1 parent 63c563f commit 42bc623
Showing 1 changed file with 36 additions and 2 deletions.
38 changes: 36 additions & 2 deletions Library/Homebrew/tab.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,12 @@ def self.create(formula, compiler, stdlib)
"source" => {
"path" => formula.path.to_s,
"tap" => formula.tap ? formula.tap.name : nil,
"spec" => formula.active_spec_sym.to_s
"spec" => formula.active_spec_sym.to_s,
"versions" => {
"stable" => formula.stable ? formula.stable.version.to_s : nil,
"devel" => formula.devel ? formula.devel.version.to_s : nil,
"head" => formula.head ? formula.head.version.to_s : nil,
}
}
}

Expand Down Expand Up @@ -68,6 +73,14 @@ def self.from_file_content(content, path)
end
end

if attributes["source"]["versions"].nil?
attributes["source"]["versions"] = {
"stable" => nil,
"devel" => nil,
"head" => nil,
}
end

new(attributes)
end

Expand Down Expand Up @@ -145,7 +158,12 @@ def self.empty
"source" => {
"path" => nil,
"tap" => nil,
"spec" => "stable"
"spec" => "stable",
"versions" => {
"stable" => nil,
"devel" => nil,
"head" => nil,
}
}
}

Expand Down Expand Up @@ -232,6 +250,22 @@ def spec
source["spec"].to_sym
end

def versions
source["versions"]
end

def stable_version
Version.create(versions["stable"]) if versions["stable"]
end

def devel_version
Version.create(versions["devel"]) if versions["devel"]
end

def head_version
Version.create(versions["head"]) if versions["head"]
end

def source_modified_time
Time.at(super)
end
Expand Down

0 comments on commit 42bc623

Please sign in to comment.